diff --git a/.github/workflows_inactive/artcraft-macos-publish.yml b/.github/workflows_inactive/artcraft-macos-publish.yml deleted file mode 100644 index edcc068f9c..0000000000 --- a/.github/workflows_inactive/artcraft-macos-publish.yml +++ /dev/null @@ -1,240 +0,0 @@ -name: "Artcraft MacOS Publish" - -on: - push: - branches: - - release - - artcraft-release - - artcraft-macos # Additional branch for MacOS testing - -# This workflow creates Universal macOS builds with signing certificate support. -# On each push to the release branches it will create or update a GitHub release, build your app, and upload the artifacts to the release. - -jobs: - publish-artcraft: - permissions: - contents: write - strategy: - fail-fast: false - matrix: - include: - # Universal macOS builds (arm64 and x86_64) - - platform: 'macos-latest-xlarge' - args: '--target universal-apple-darwin' - # Uncomment below for additional platforms - # - platform: 'ubuntu-22.04' - # args: '' - # - platform: 'windows-latest' - # args: '' - - runs-on: ${{ matrix.platform }} - steps: - - uses: actions/checkout@v4 - - - name: setup node - uses: actions/setup-node@v4 - with: - node-version: lts/* - - - name: install Rust stable - uses: dtolnay/rust-toolchain@stable - with: - targets: ${{ matrix.platform == 'macos-latest-xlarge' && 'aarch64-apple-darwin,x86_64-apple-darwin' || '' }} - - - name: install dependencies (ubuntu only) - if: matrix.platform == 'ubuntu-22.04' - run: | - sudo apt-get update - sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf - - - name: replace tauri config with mac-specific version - run: | - pushd ${{ github.workspace }}/crates/desktop/artcraft - # Use the mac-specific tauri conf for the build - # TODO(bt): Replace this with the platform-specific naming conventions - cp tauri-mac.conf.json tauri.conf.json - popd - - - name: install frontend dependencies - run: | - # Navigate to the frontend directory to install dependencies - cd ./frontend - - npm cache clean --force - - echo "Installing all workspace dependencies..." - npm ci - - echo "=== Version Information ===" - echo "Node version:" - node --version - echo "NPM version:" - npm --version - - # Remove mismatched @nx packages and reinstall with correct versions - npm install --save-dev @nx/remix@21.1.1 @nx/js@21.1.1 @nx/react@21.1.1 @nx/vite@21.1.1 @nx/eslint@21.1.1 - - echo "=== Nx versions after adjustment ===" - npm list --depth=0 | grep nx - - - name: import Apple Developer Certificate - if: matrix.platform == 'macos-latest-xlarge' - env: - APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }} - APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }} - KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }} - run: | - echo "Starting certificate import process..." - - # Create certificate file - echo $APPLE_CERTIFICATE | base64 --decode > certificate.p12 - - # Debug: Check if certificate file exists and has content - echo "Certificate file info:" - ls -la certificate.p12 - file certificate.p12 - - # Debug: Check certificate contents without password (just structure) - echo "Certificate structure (may show error if password protected):" - openssl pkcs12 -info -in certificate.p12 -passin pass:$APPLE_CERTIFICATE_PASSWORD -noout || echo "Could not read certificate structure" - - # Debug: Try to list what's in the p12 file - echo "Attempting to list certificate contents:" - security cms -D -i certificate.p12 || echo "Not a CMS file, trying PKCS12..." - openssl pkcs12 -in certificate.p12 -passin pass:$APPLE_CERTIFICATE_PASSWORD -info -nodes 2>&1 | head -20 || echo "Failed to read PKCS12 contents" - - # Debug: Extract certificate details to verify type and expiration - echo "Extracting certificate details..." - # Extract just the certificate portion and examine it - openssl pkcs12 -in certificate.p12 -passin pass:$APPLE_CERTIFICATE_PASSWORD -nokeys 2>/dev/null | openssl x509 -text -noout | grep -E "(Subject:|Issuer:|Not Before|Not After)" || echo "Failed to parse certificate details" - - # Also try to see what type of certificate this is - echo "Certificate type check:" - openssl pkcs12 -in certificate.p12 -passin pass:$APPLE_CERTIFICATE_PASSWORD -nokeys 2>/dev/null | openssl x509 -text -noout | grep -E "(CN=|OU=)" || echo "Could not determine certificate type" - - # Debug: Check if private key exists - echo "Checking for private key..." - openssl pkcs12 -in certificate.p12 -passin pass:$APPLE_CERTIFICATE_PASSWORD -nocerts -nodes 2>&1 | grep -E "(PRIVATE KEY|RSA KEY)" | head -5 || echo "No private key found" - - # Create temporary keychain - security create-keychain -p "$KEYCHAIN_PASSWORD" build.keychain - security default-keychain -s build.keychain - security unlock-keychain -p "$KEYCHAIN_PASSWORD" build.keychain - security set-keychain-settings -t 3600 -u build.keychain - - # Import certificate - ensure both certificate and private key are imported - echo "Importing certificate into keychain..." - # Import the p12 directly - this is the most reliable method - security import certificate.p12 -k build.keychain -P "$APPLE_CERTIFICATE_PASSWORD" -T /usr/bin/codesign -T /usr/bin/security -T /usr/bin/productbuild - - # Alternative: Try with additional flags if the first import didn't create an identity - echo "Verifying import..." - if ! security find-identity -v build.keychain | grep -q "1 valid identities found"; then - echo "First import didn't create identity, trying with -A flag..." - security import certificate.p12 -k build.keychain -P "$APPLE_CERTIFICATE_PASSWORD" -A - fi - - # Set trust settings for the certificate - echo "Setting trust settings..." - security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "$KEYCHAIN_PASSWORD" build.keychain - - # Unlock the keychain again to ensure it's accessible - security unlock-keychain -p "$KEYCHAIN_PASSWORD" build.keychain - - # Add the keychain to the search list - security list-keychains -d user -s build.keychain $(security list-keychains -d user | sed 's/^[[:space:]]*"//;s/"$//') - - # List all certificates to debug - echo "Listing all keychains:" - security list-keychains - - echo "Listing all certificates in build keychain:" - security find-certificate -a -p build.keychain || echo "No certificates found" - - echo "Detailed certificate info:" - security find-certificate -c "Learning Machines" build.keychain || echo "Certificate 'Learning Machines' not found" - - # Check certificate trust settings - echo "Checking certificate trust settings:" - security dump-trust-settings || echo "No custom trust settings" - - # Try to find codesigning identities - echo "Finding all identities in keychain:" - security find-identity -v build.keychain || echo "No identities found" - - echo "Finding codesigning identities:" - security find-identity -v -p codesigning build.keychain || echo "No codesigning identities found" - - # Additional debug: Check if this is a valid Developer ID cert - echo "Checking for Developer ID certificates:" - security find-certificate -a build.keychain | grep -A 5 -B 5 "Developer ID" || echo "No Developer ID certificates found" - - - name: verify certificate - if: matrix.platform == 'macos-latest-xlarge' - run: | - echo "=== Certificate Verification ===" - - echo "1. Checking codesigning identities:" - security find-identity -v -p codesigning build.keychain || echo "No codesigning identities found" - - echo -e "\n2. Checking all identities:" - security find-identity -v build.keychain || echo "No identities found" - - echo -e "\n3. Checking certificates in keychain:" - security find-certificate -c "Learning Machines" build.keychain -p | openssl x509 -text -noout | grep -E "(Subject:|CN=)" || echo "Could not parse certificate" - - # Set the correct signing identity - echo "APPLE_SIGNING_IDENTITY=Developer ID Application: Learning Machines LLC (DJ6XS33FX8)" >> $GITHUB_ENV - echo "Proceeding with identity: Developer ID Application: Learning Machines LLC (DJ6XS33FX8)" - - # Also set the team ID - echo "APPLE_DEVELOPMENT_TEAM=DJ6XS33FX8" >> $GITHUB_ENV - - - name: Pre-build frontend to avoid Tauri build issues - run: | - # Build the frontend app from the correct directory - cd ./frontend - - # Increase Node.js memory limit for the build - export NODE_OPTIONS="--max-old-space-size=8192" - - # Use npx to ensure we use the local nx version - echo "Building with npx nx..." - npx nx run artcraft:build - - echo "Checking build output..." - ls -la apps/artcraft/dist/ | head -10 - - # Update Tauri config to skip the build (since we already built) - cd ${{ github.workspace }}/crates/desktop/artcraft - cp tauri.conf.json tauri.conf.json.bak - # Set beforeBuildCommand to empty or a no-op command - if command -v jq &> /dev/null; then - jq '.build.beforeBuildCommand = ""' tauri.conf.json > tauri.conf.json.tmp - mv tauri.conf.json.tmp tauri.conf.json - else - node -e "const fs = require('fs'); const config = JSON.parse(fs.readFileSync('tauri.conf.json', 'utf8')); config.build.beforeBuildCommand = ''; fs.writeFileSync('tauri.conf.json', JSON.stringify(config, null, 2));" - fi - - - - name: build and publish - uses: tauri-apps/tauri-action@v0 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - APPLE_ID: ${{ secrets.APPLE_ID }} - APPLE_ID_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }} - APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }} - APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }} - APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }} - APPLE_SIGNING_IDENTITY: ${{ env.APPLE_SIGNING_IDENTITY }} - APPLE_DEVELOPMENT_TEAM: ${{ env.APPLE_DEVELOPMENT_TEAM }} - # Use the SQLx query cache for SQLite - SQLX_OFFLINE: true - with: - projectPath: ./crates/desktop/artcraft - tagName: artcraft-v__VERSION__ # the action automatically replaces __VERSION__ with the app version. - releaseName: "ArtCraft v__VERSION__" - releaseBody: "See the assets below to download this version and install." - releaseDraft: true - prerelease: false - args: ${{ matrix.args }} diff --git a/.github/workflows_inactive/artcraft-windows-publish.yml b/.github/workflows_inactive/artcraft-windows-publish.yml deleted file mode 100644 index ec4a1e5e13..0000000000 --- a/.github/workflows_inactive/artcraft-windows-publish.yml +++ /dev/null @@ -1,107 +0,0 @@ -name: "Artcraft Windows Publish" - -on: - push: - branches: - - release - - artcraft-release - - artcraft-windows # Additional branch for Windows testing - -# This workflow creates Windows builds. -# On each push to the release branches it will create or update a GitHub release, build your app, and upload the artifacts to the release. - -jobs: - publish-artcraft-windows: - permissions: - contents: write - strategy: - fail-fast: false - matrix: - include: - # Windows builds - - platform: 'windows-latest' - args: '' - - runs-on: ${{ matrix.platform }} - steps: - - uses: actions/checkout@v4 - - - name: install Rust stable - uses: dtolnay/rust-toolchain@stable - - - name: install wreq dependencies - run: | - choco install cmake -y - choco install strawberryperl -y - choco install pkgconfiglite -y - choco install llvm -y - choco install nasm -y - shell: cmd - - - name: setup node - uses: actions/setup-node@v4 - with: - node-version: lts/* - - - name: install frontend dependencies - run: | - # Navigate to the frontend directory to install dependencies - cd ./frontend - - npm cache clean --force - - echo "Installing all workspace dependencies..." - npm ci - - echo "=== Version Information ===" - echo "Node version:" - node --version - echo "NPM version:" - npm --version - - # Remove mismatched @nx packages and reinstall with correct versions - npm install --save-dev @nx/remix@21.1.1 @nx/js@21.1.1 @nx/react@21.1.1 @nx/vite@21.1.1 @nx/eslint@21.1.1 - - echo "=== Nx versions after adjustment ===" - npm list --depth=0 | findstr nx - - - name: Pre-build frontend to avoid Tauri build issues - run: | - # Build the frontend app from the correct directory - cd ./frontend - - # Increase Node.js memory limit for the build - $env:NODE_OPTIONS="--max-old-space-size=8192" - - # Use npx to ensure we use the local nx version - echo "Building with npx nx..." - npx nx run artcraft:build - - echo "Checking build output..." - dir apps/artcraft/dist/ | Select-Object -First 10 - - # Update Tauri config to skip the build (since we already built) - cd ${{ github.workspace }}/crates/desktop/artcraft - Copy-Item tauri.conf.json tauri.conf.json.bak - - # Set beforeBuildCommand to empty using PowerShell - $config = Get-Content tauri.conf.json | ConvertFrom-Json - $config.build.beforeBuildCommand = "" - $config | ConvertTo-Json -Depth 10 | Set-Content tauri.conf.json - - - name: build and publish - uses: tauri-apps/tauri-action@v0 - env: - # NB(bt): This is needed by wreq. Hopefully it doesn't kill Tauri - RUSTFLAGS: "-C target-feature=+crt-static" - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # Use the SQLx query cache for SQLite - SQLX_OFFLINE: true - with: - projectPath: ./crates/desktop/artcraft - tagName: artcraft-v__VERSION__ # the action automatically replaces __VERSION__ with the app version. - releaseName: "ArtCraft v__VERSION__" - releaseBody: "Production build of ArtCraft. See the assets below to download and install." - releaseDraft: true - prerelease: false - args: ${{ matrix.args }} diff --git a/.github/workflows_inactive/tauri-publish-2d.yml b/.github/workflows_inactive/tauri-publish-2d.yml deleted file mode 100644 index b0d61342cb..0000000000 --- a/.github/workflows_inactive/tauri-publish-2d.yml +++ /dev/null @@ -1,63 +0,0 @@ -name: 'publish' - -on: - push: - branches: - - tauri-prod-release - -# This workflow will trigger on each push to the `release` branch to create or update a GitHub release, build your app, and upload the artifacts to the release. - -jobs: - publish-tauri: - permissions: - contents: write - strategy: - fail-fast: false - matrix: - include: - - platform: 'macos-latest' # for Arm based macs (M1 and above). - args: '--target aarch64-apple-darwin' - # - platform: 'macos-latest' # for Intel based macs. - # args: '--target x86_64-apple-darwin' - # - platform: 'ubuntu-22.04' # for Tauri v1 you could replace this with ubuntu-20.04. - # args: '' - # - platform: 'windows-latest' - # args: '' - - runs-on: ${{ matrix.platform }} - steps: - - uses: actions/checkout@v4 - - - name: setup node - uses: actions/setup-node@v4 - with: - node-version: lts/* - - - name: install Rust stable - uses: dtolnay/rust-toolchain@stable - with: - # Those targets are only used on macos runners so it's in an `if` to slightly speed up windows and linux builds. - targets: ${{ matrix.platform == 'macos-latest' && 'aarch64-apple-darwin,x86_64-apple-darwin' || '' }} - - - name: install dependencies (ubuntu only) - if: matrix.platform == 'ubuntu-22.04' # This must match the platform value defined above. - run: | - sudo apt-get update - sudo apt-get install -y libwebkit2gtk-4.0-dev libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf - # webkitgtk 4.0 is for Tauri v1 - webkitgtk 4.1 is for Tauri v2. - # You can remove the one that doesn't apply to your app to speed up the workflow a bit. - - - name: install frontend dependencies - run: cd ./crates/desktop/artcraft && yarn install # change this to npm, pnpm or bun depending on which one you use. - - - uses: tauri-apps/tauri-action@v0 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - projectPath: ./crates/desktop/artcraft - tagName: app-v__VERSION__ # the action automatically replaces \_\_VERSION\_\_ with the app version. - releaseName: 'App v__VERSION__' - releaseBody: 'See the assets to download this version and install.' - releaseDraft: true - prerelease: false - args: ${{ matrix.args }} \ No newline at end of file diff --git a/.gitignore b/.gitignore index 986d68eaf9..77278b9fde 100644 --- a/.gitignore +++ b/.gitignore @@ -29,7 +29,6 @@ twitch_secrets.toml production_database_secret_connect.sh production_database_secret_query.sh production_database_voice_clone_report_download.sh -script/artcraft/mac_signing_build.sh script/production_database_secret_backup.sh script/production_database_secret_connect.sh script/socat_dev_database_connect.sh @@ -56,9 +55,6 @@ crates/lib/sqlite_queries/target/ # Javascript build directories node_modules/ -# Frontend build outputs -frontend/apps/artcraft/bundle-report.html - # Vim noise *.swo *.swp diff --git a/.sqlx/query-13d435d8f681b73e4080748dcef0579e246e41049af67e1bd79ffc06aa6ba974.json b/.sqlx/query-13d435d8f681b73e4080748dcef0579e246e41049af67e1bd79ffc06aa6ba974.json deleted file mode 100644 index 129a5f59bd..0000000000 --- a/.sqlx/query-13d435d8f681b73e4080748dcef0579e246e41049af67e1bd79ffc06aa6ba974.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "db_name": "SQLite", - "query": "\n UPDATE tasks\n SET is_dismissed_by_user = 1\n WHERE id = ?\n ", - "describe": { - "columns": [], - "parameters": { - "Right": 1 - }, - "nullable": [] - }, - "hash": "13d435d8f681b73e4080748dcef0579e246e41049af67e1bd79ffc06aa6ba974" -} diff --git a/.sqlx/query-1e3758851fc8451670f86a9432009b73bdb81de4a08dcaa96a86afb5f9be7a68.json b/.sqlx/query-1e3758851fc8451670f86a9432009b73bdb81de4a08dcaa96a86afb5f9be7a68.json deleted file mode 100644 index 5c1b1e3f1a..0000000000 --- a/.sqlx/query-1e3758851fc8451670f86a9432009b73bdb81de4a08dcaa96a86afb5f9be7a68.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "db_name": "SQLite", - "query": "\n UPDATE tasks\n SET\n task_status = ?,\n on_complete_batch_token = ?,\n on_complete_primary_media_file_token = ?,\n on_complete_primary_media_file_class = ?,\n on_complete_primary_media_file_cdn_url = ?,\n on_complete_primary_media_file_thumbnail_url_template = ?\n WHERE\n provider = ?\n AND provider_job_id = ?\n ", - "describe": { - "columns": [], - "parameters": { - "Right": 8 - }, - "nullable": [] - }, - "hash": "1e3758851fc8451670f86a9432009b73bdb81de4a08dcaa96a86afb5f9be7a68" -} diff --git a/.sqlx/query-2436eb7bf4b0e23a899311a67a77f71d89eb35461e2113e43cd9d221bfa91c9a.json b/.sqlx/query-2436eb7bf4b0e23a899311a67a77f71d89eb35461e2113e43cd9d221bfa91c9a.json deleted file mode 100644 index 923d83d541..0000000000 --- a/.sqlx/query-2436eb7bf4b0e23a899311a67a77f71d89eb35461e2113e43cd9d221bfa91c9a.json +++ /dev/null @@ -1,128 +0,0 @@ -{ - "db_name": "SQLite", - "query": "\n SELECT\n id,\n task_status,\n task_type,\n model_type,\n provider,\n provider_job_id,\n frontend_caller,\n frontend_subscriber_id,\n frontend_subscriber_payload,\n on_complete_primary_media_file_token,\n on_complete_primary_media_file_class,\n on_complete_batch_token,\n on_complete_primary_media_file_cdn_url,\n on_complete_primary_media_file_thumbnail_url_template,\n on_failure_type,\n on_failure_message,\n created_at as \"created_at: DateTime\",\n updated_at as \"updated_at: DateTime\",\n completed_at as \"completed_at: DateTime\"\n FROM tasks\n WHERE is_dismissed_by_user == 0\n ", - "describe": { - "columns": [ - { - "name": "id", - "ordinal": 0, - "type_info": "Text" - }, - { - "name": "task_status", - "ordinal": 1, - "type_info": "Text" - }, - { - "name": "task_type", - "ordinal": 2, - "type_info": "Text" - }, - { - "name": "model_type", - "ordinal": 3, - "type_info": "Text" - }, - { - "name": "provider", - "ordinal": 4, - "type_info": "Text" - }, - { - "name": "provider_job_id", - "ordinal": 5, - "type_info": "Text" - }, - { - "name": "frontend_caller", - "ordinal": 6, - "type_info": "Text" - }, - { - "name": "frontend_subscriber_id", - "ordinal": 7, - "type_info": "Text" - }, - { - "name": "frontend_subscriber_payload", - "ordinal": 8, - "type_info": "Text" - }, - { - "name": "on_complete_primary_media_file_token", - "ordinal": 9, - "type_info": "Text" - }, - { - "name": "on_complete_primary_media_file_class", - "ordinal": 10, - "type_info": "Text" - }, - { - "name": "on_complete_batch_token", - "ordinal": 11, - "type_info": "Text" - }, - { - "name": "on_complete_primary_media_file_cdn_url", - "ordinal": 12, - "type_info": "Text" - }, - { - "name": "on_complete_primary_media_file_thumbnail_url_template", - "ordinal": 13, - "type_info": "Text" - }, - { - "name": "on_failure_type", - "ordinal": 14, - "type_info": "Text" - }, - { - "name": "on_failure_message", - "ordinal": 15, - "type_info": "Text" - }, - { - "name": "created_at: DateTime", - "ordinal": 16, - "type_info": "Int64" - }, - { - "name": "updated_at: DateTime", - "ordinal": 17, - "type_info": "Int64" - }, - { - "name": "completed_at: DateTime", - "ordinal": 18, - "type_info": "Int64" - } - ], - "parameters": { - "Right": 0 - }, - "nullable": [ - false, - false, - false, - true, - true, - true, - true, - true, - true, - true, - true, - true, - true, - true, - true, - true, - false, - false, - true - ] - }, - "hash": "2436eb7bf4b0e23a899311a67a77f71d89eb35461e2113e43cd9d221bfa91c9a" -} diff --git a/.sqlx/query-30272128d83543d9fbfca930b7cdd4af30adfb4d90f2de044463a111c6340495.json b/.sqlx/query-30272128d83543d9fbfca930b7cdd4af30adfb4d90f2de044463a111c6340495.json deleted file mode 100644 index 4be4ed4894..0000000000 --- a/.sqlx/query-30272128d83543d9fbfca930b7cdd4af30adfb4d90f2de044463a111c6340495.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "db_name": "SQLite", - "query": "\n UPDATE tasks\n SET task_status = \"cancelled_by_user\"\n WHERE task_status NOT IN (\n \"complete_success\",\n \"complete_failure\",\n \"dead\",\n \"cancelled_by_user\",\n \"cancelled_by_provider\",\n \"cancelled_by_us\"\n )\n ", - "describe": { - "columns": [], - "parameters": { - "Right": 0 - }, - "nullable": [] - }, - "hash": "30272128d83543d9fbfca930b7cdd4af30adfb4d90f2de044463a111c6340495" -} diff --git a/.sqlx/query-35677894f7b02f32a1bf6396fa6d10caba69bb0f3f03ee7ffbfa1437689d42df.json b/.sqlx/query-35677894f7b02f32a1bf6396fa6d10caba69bb0f3f03ee7ffbfa1437689d42df.json deleted file mode 100644 index b63c200075..0000000000 --- a/.sqlx/query-35677894f7b02f32a1bf6396fa6d10caba69bb0f3f03ee7ffbfa1437689d42df.json +++ /dev/null @@ -1,86 +0,0 @@ -{ - "db_name": "SQLite", - "query": "\n SELECT\n id,\n task_status,\n task_type,\n model_type,\n provider,\n provider_job_id,\n frontend_caller,\n queue_status_url,\n queue_response_url,\n prompt_token,\n frontend_subscriber_id,\n frontend_subscriber_payload\n FROM tasks\n WHERE\n provider = ?\n AND provider_job_id = ?\n ", - "describe": { - "columns": [ - { - "name": "id", - "ordinal": 0, - "type_info": "Text" - }, - { - "name": "task_status", - "ordinal": 1, - "type_info": "Text" - }, - { - "name": "task_type", - "ordinal": 2, - "type_info": "Text" - }, - { - "name": "model_type", - "ordinal": 3, - "type_info": "Text" - }, - { - "name": "provider", - "ordinal": 4, - "type_info": "Text" - }, - { - "name": "provider_job_id", - "ordinal": 5, - "type_info": "Text" - }, - { - "name": "frontend_caller", - "ordinal": 6, - "type_info": "Text" - }, - { - "name": "queue_status_url", - "ordinal": 7, - "type_info": "Text" - }, - { - "name": "queue_response_url", - "ordinal": 8, - "type_info": "Text" - }, - { - "name": "prompt_token", - "ordinal": 9, - "type_info": "Text" - }, - { - "name": "frontend_subscriber_id", - "ordinal": 10, - "type_info": "Text" - }, - { - "name": "frontend_subscriber_payload", - "ordinal": 11, - "type_info": "Text" - } - ], - "parameters": { - "Right": 2 - }, - "nullable": [ - false, - false, - false, - true, - true, - true, - true, - true, - true, - true, - true, - true - ] - }, - "hash": "35677894f7b02f32a1bf6396fa6d10caba69bb0f3f03ee7ffbfa1437689d42df" -} diff --git a/.sqlx/query-4fc9674ae39abaadc36054c200290ec95d0e2c7765336f0fa97805a2265f5c4c.json b/.sqlx/query-4fc9674ae39abaadc36054c200290ec95d0e2c7765336f0fa97805a2265f5c4c.json deleted file mode 100644 index 4c505058f4..0000000000 --- a/.sqlx/query-4fc9674ae39abaadc36054c200290ec95d0e2c7765336f0fa97805a2265f5c4c.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "db_name": "SQLite", - "query": "\n INSERT INTO tasks (\n id,\n task_status,\n task_type,\n model_type,\n provider,\n provider_job_id,\n queue_status_url,\n queue_response_url,\n prompt_token,\n frontend_caller,\n frontend_subscriber_id,\n frontend_subscriber_payload\n )\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)\n ", - "describe": { - "columns": [], - "parameters": { - "Right": 12 - }, - "nullable": [] - }, - "hash": "4fc9674ae39abaadc36054c200290ec95d0e2c7765336f0fa97805a2265f5c4c" -} diff --git a/.sqlx/query-50a2449b87abed7df3302a74ecd0e8ab87940077a247636680cb09b2fe488321.json b/.sqlx/query-50a2449b87abed7df3302a74ecd0e8ab87940077a247636680cb09b2fe488321.json deleted file mode 100644 index 8d5c10f103..0000000000 --- a/.sqlx/query-50a2449b87abed7df3302a74ecd0e8ab87940077a247636680cb09b2fe488321.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "db_name": "SQLite", - "query": "\n UPDATE tasks\n SET\n task_status = ?,\n on_complete_batch_token = ?,\n on_complete_primary_media_file_token = ?,\n on_complete_primary_media_file_class = ?,\n on_complete_primary_media_file_cdn_url = ?,\n on_complete_primary_media_file_thumbnail_url_template = ?\n WHERE id = ?\n ", - "describe": { - "columns": [], - "parameters": { - "Right": 7 - }, - "nullable": [] - }, - "hash": "50a2449b87abed7df3302a74ecd0e8ab87940077a247636680cb09b2fe488321" -} diff --git a/.sqlx/query-9b99ccd0baf9a4b74d8903f63e3a3dcf4c09b75cad978f0532388cbd743b7516.json b/.sqlx/query-9b99ccd0baf9a4b74d8903f63e3a3dcf4c09b75cad978f0532388cbd743b7516.json deleted file mode 100644 index 3f2887d4fe..0000000000 --- a/.sqlx/query-9b99ccd0baf9a4b74d8903f63e3a3dcf4c09b75cad978f0532388cbd743b7516.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "db_name": "SQLite", - "query": "\n UPDATE tasks\n SET task_status = ?,\n on_failure_type = ?,\n on_failure_message = ?\n WHERE id = ?\n ", - "describe": { - "columns": [], - "parameters": { - "Right": 4 - }, - "nullable": [] - }, - "hash": "9b99ccd0baf9a4b74d8903f63e3a3dcf4c09b75cad978f0532388cbd743b7516" -} diff --git a/.sqlx/query-dc0367e9e43c3d7dda3623e77337ab4529eac2192475be7d08589886703ba1cb.json b/.sqlx/query-dc0367e9e43c3d7dda3623e77337ab4529eac2192475be7d08589886703ba1cb.json deleted file mode 100644 index b4ed499639..0000000000 --- a/.sqlx/query-dc0367e9e43c3d7dda3623e77337ab4529eac2192475be7d08589886703ba1cb.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "db_name": "SQLite", - "query": "\n UPDATE tasks\n SET task_status = ?\n WHERE id = ?\n ", - "describe": { - "columns": [], - "parameters": { - "Right": 2 - }, - "nullable": [] - }, - "hash": "dc0367e9e43c3d7dda3623e77337ab4529eac2192475be7d08589886703ba1cb" -} diff --git a/.sqlx/query-f83018ec5493982659a56576296914f937bb4e75db3a522eb4bda486d5caa402.json b/.sqlx/query-f83018ec5493982659a56576296914f937bb4e75db3a522eb4bda486d5caa402.json deleted file mode 100644 index 244607f5bd..0000000000 --- a/.sqlx/query-f83018ec5493982659a56576296914f937bb4e75db3a522eb4bda486d5caa402.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "db_name": "SQLite", - "query": "\n UPDATE tasks\n SET is_dismissed_by_user = 1\n WHERE is_dismissed_by_user != 1\n ", - "describe": { - "columns": [], - "parameters": { - "Right": 0 - }, - "nullable": [] - }, - "hash": "f83018ec5493982659a56576296914f937bb4e75db3a522eb4bda486d5caa402" -} diff --git a/AGENTS.md b/AGENTS.md index 36c8acae45..2fca37e2c6 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -4,54 +4,38 @@ This file provides guidance for coding agents when working with the Artcraft mon ## Project Overview -Artcraft is a web and desktop application for generating AI image and video. It is written in -Rust and TypeScript and contains desktop, server, and frontend components. +ArtCraft Services contains the Rust backend, HTTP API, workers, and TypeScript web +frontends for ArtCraft. The Tauri desktop application is maintained separately at +https://github.com/storytold/artcraft. ## Project Structure -``` -artcraft/ -├── _database/ # Schema definitions and migrations (MySQL, SQLite, Elasticsearch, etc.) -│ ├── elasticsearch/ # Elasticsearch schema and queries -│ └── sql/ # MySQL and SQLite schema definitions and migrations -│ ├── artcraft_migrations/ # ArtCraft desktop app SQLite migrations -│ ├── migrations/ # Server MySQL migrations -│ └── migrations_squashed/ # Fully materialized MySQL schema definitions for most tables -├── _tools/ # Various 3rd party tool integrations and configurations -│ └── postman/ # Postman configs for test HTTP requests against development and production -├── build/ # Dockerfile build instructions for server components -├── crates/ # Rust workspace -│ ├── api_clients/ # HTTP clients for calling internal and 3rd party services -│ ├── cli/ # Command line tools -│ ├── desktop/ # Desktop (Tauri) apps -│ │ └── artcraft/ # (Important) ArtCraft, the desktop app. This is one of our main pieces of software -│ ├── lib/ # Various utility libraries for servers, CLI tools, desktop, etc. -│ ├── schema/ # Data definition layer: MySQL, SQlite, Redis, S3/R2 buckets, etc. -│ │ ├── buckets/ # Declares R2 cloud bucket topology -│ │ ├── database/ # MySQL, SQLite, Elasticsearch, Redis, etc. -│ │ │ ├── elasticsearch_schema/ # Elasticsearch -│ │ │ ├── migration/ # (deprecated) Online schema adapters for MySQL -│ │ │ ├── mysql_queries/ # Sqlx MySQL queries for our backend monolith `storyteller-web`, jobs, etc. -│ │ │ ├── redis_common/ # Redis support -│ │ │ ├── redis_schema/ # Redis key and HKEY topology -│ │ │ ├── sqlite_queries/ # (deprecated) Sqlite queries -│ │ │ └── sqlite_tasks/ # Queries for the ArtCraft desktop app's "tasks" database. -│ │ ├── public/ # Token identifier and enum variant definitions -│ │ │ ├── composite_identifier/ # MySQL composite key system -│ │ │ ├── enums/ # MySQL "enums" stored in VARCHAR fields. -│ │ │ └── tokens/ # Primary database identifiers with Stripe-like ID prefixes, eg. "user_{entropy}" -│ │ └── service/ # Backend HTTP services and jobs -│ │ ├── job/ # Backend jobs. -│ │ │ └── video_thumbnail_job/ # Render video thumbnails -│ │ ├── plugins/ # Collections of reusable Actix-Web HTTP functions (user and billing systems) -│ │ └── web/ # HTTP web servers -│ │ └── storyteller_web/ # (Important) Our main HTTP API monolith and backend. -│ └── frontend/ # Nx typescript monorepo for our websites and Tauri desktop apps -│ ├── apps/ # Websites and Tauri desktop apps -│ │ ├── artcraft/ # ArtCraft the Tauri app's frontend. Used in conjunction with `artcraft` the Rust crate. -│ │ └── artcraft-website/ # The website for https://getartcraft.com -│ └── libs/ # Support libraries, reusable React components, etc. -└── Cargo.toml # Rust monorepo workspace +```text +artcraft-services/ +├── _database/ # SQL migrations and Elasticsearch schemas +│ └── sql/ +│ ├── migrations/ # Server MySQL migrations +│ └── migrations_squashed/ # Materialized MySQL table definitions +├── _tools/postman/ # HTTP request collections +├── build/ # Service Dockerfiles +├── crates/ +│ ├── api_clients/ # ArtCraft API types, clients, router, provider clients +│ ├── cli/ # Development and operations tools +│ ├── lib/ # Shared Rust utilities +│ ├── schema/ # Database queries, public tokens/enums, bucket paths +│ │ └── database/ +│ │ ├── mysql_queries/ # SQLx queries shared by services, jobs, and CLI tools +│ │ ├── redis_common/ # Redis support +│ │ └── redis_schema/ # Redis key and HKEY topology +│ └── service/ +│ ├── job/ # Provider workers, media processing, analytics +│ ├── plugins/ # Shared billing and service components +│ └── web/storyteller_web/ # Main Actix Web HTTP API +├── frontend/ +│ ├── apps/artcraft-webapp/ # Browser application at app.getartcraft.com +│ ├── apps/artcraft-website/ # Product website at getartcraft.com +│ └── libs/ # Shared React components and TypeScript libraries +└── Cargo.toml # Rust workspace ``` ## Code Style diff --git a/Cargo.lock b/Cargo.lock index c79c69c2d5..9dc9959307 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -251,7 +251,7 @@ dependencies = [ "actix-utils", "actix-web", "actix-web-lab-derive", - "ahash 0.8.12", + "ahash", "arc-swap", "bytes", "bytestring", @@ -383,17 +383,6 @@ dependencies = [ "workspace-build-acceleration", ] -[[package]] -name = "ahash" -version = "0.7.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "891477e0c6a8957309ee5c45a6368af3ae14bb510732d2684ffa19af310920f9" -dependencies = [ - "getrandom 0.2.14", - "once_cell", - "version_check", -] - [[package]] name = "ahash" version = "0.8.12" @@ -504,23 +493,6 @@ dependencies = [ "workspace-build-acceleration", ] -[[package]] -name = "android_log-sys" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84521a3cf562bc62942e294181d9eef17eb38ceb8c68677bc49f144e4c3d4f8d" - -[[package]] -name = "android_logger" -version = "0.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6f39be698127218cca460cb624878c9aa4e2b47dba3b277963d2bf00bad263b" -dependencies = [ - "android_log-sys", - "env_filter 0.1.0", - "log", -] - [[package]] name = "android_system_properties" version = "0.1.5" @@ -636,66 +608,6 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" -[[package]] -name = "artcraft" -version = "0.0.1" -dependencies = [ - "anyhow", - "artcraft_api_defs", - "artcraft_client", - "artcraft_router", - "base64 0.22.1", - "build_metadata", - "bytes", - "chrono", - "cookie_store 0.0.1", - "directories", - "dirs", - "discord-rich-presence", - "enums", - "errors", - "fal_client", - "filesys", - "futures 0.3.32", - "grok_consumer_client", - "image", - "images", - "indexmap 2.13.0", - "log", - "memory_store", - "midjourney_client", - "mimetypes", - "once_cell", - "openai_sora_client", - "os_info", - "primitives", - "rand 0.9.2", - "reqwest 0.12.23", - "serde", - "serde_derive", - "serde_json", - "serial_test", - "sqlite_tasks", - "tauri", - "tauri-build", - "tauri-plugin-dialog", - "tauri-plugin-http", - "tauri-plugin-log", - "tauri-plugin-opener", - "tauri-plugin-upload", - "tempdir", - "tempfile", - "tokens", - "tokio", - "tokio-util", - "url", - "url_utils", - "uuid_utils", - "web_base64", - "workspace-build-acceleration", - "worldlabs_consumer_client", -] - [[package]] name = "artcraft_api_defs" version = "0.0.1" @@ -741,7 +653,7 @@ dependencies = [ "tokio", "url", "url-builder", - "uuid 1.22.0", + "uuid", "uuid_utils", "workspace-build-acceleration", ] @@ -769,7 +681,7 @@ dependencies = [ "tokens", "tokio", "url_utils", - "uuid 1.22.0", + "uuid", "workspace-build-acceleration", "worldlabs_api_client", "wreq", @@ -784,18 +696,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "async-broadcast" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "435a87a52755b8f27fcf321ac4f04b2802e337c8c4872923137471ec39c37532" -dependencies = [ - "event-listener 5.4.1", - "event-listener-strategy", - "futures-core", - "pin-project-lite", -] - [[package]] name = "async-channel" version = "1.9.0" @@ -803,23 +703,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81953c529336010edd6d8e358f886d9581267795c61b19475b71314bffa46d35" dependencies = [ "concurrent-queue", - "event-listener 2.5.3", + "event-listener", "futures-core", ] -[[package]] -name = "async-channel" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f2776ead772134d55b62dd45e59a79e21612d85d0af729b8b7d3967d601a62a" -dependencies = [ - "concurrent-queue", - "event-listener 5.4.1", - "event-listener-strategy", - "futures-core", - "pin-project-lite", -] - [[package]] name = "async-compression" version = "0.4.27" @@ -836,97 +723,6 @@ dependencies = [ "zstd-safe 7.1.0", ] -[[package]] -name = "async-executor" -version = "1.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b10202063978b3351199d68f8b22c4e47e4b1b822f8d43fd862d5ea8c006b29a" -dependencies = [ - "async-task", - "concurrent-queue", - "fastrand 2.3.0", - "futures-lite 2.6.0", - "slab", -] - -[[package]] -name = "async-io" -version = "2.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43a2b323ccce0a1d90b449fd71f2a06ca7faa7c54c2751f06c9bd851fc061059" -dependencies = [ - "async-lock", - "cfg-if", - "concurrent-queue", - "futures-io", - "futures-lite 2.6.0", - "parking", - "polling", - "rustix 0.38.44", - "slab", - "tracing", - "windows-sys 0.59.0", -] - -[[package]] -name = "async-lock" -version = "3.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff6e472cdea888a4bd64f342f09b3f50e1886d32afe8df3d663c01140b811b18" -dependencies = [ - "event-listener 5.4.1", - "event-listener-strategy", - "pin-project-lite", -] - -[[package]] -name = "async-process" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63255f1dc2381611000436537bbedfe83183faa303a5a0edaf191edef06526bb" -dependencies = [ - "async-channel 2.3.0", - "async-io", - "async-lock", - "async-signal", - "async-task", - "blocking", - "cfg-if", - "event-listener 5.4.1", - "futures-lite 2.6.0", - "rustix 0.38.44", - "tracing", -] - -[[package]] -name = "async-recursion" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.117", -] - -[[package]] -name = "async-signal" -version = "0.2.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "637e00349800c0bdf8bfc21ebbc0b6524abea702b0da4168ac00d070d0c0b9f3" -dependencies = [ - "async-io", - "async-lock", - "atomic-waker", - "cfg-if", - "futures-core", - "futures-io", - "rustix 0.38.44", - "signal-hook-registry", - "slab", - "windows-sys 0.59.0", -] - [[package]] name = "async-stream" version = "0.3.5" @@ -1093,12 +889,6 @@ dependencies = [ "thiserror 1.0.63", ] -[[package]] -name = "async-task" -version = "4.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b75356056920673b02621b35afd0f7dda9306d03c79a30f5c56c44cf256e3de" - [[package]] name = "async-trait" version = "0.1.80" @@ -1110,29 +900,6 @@ dependencies = [ "syn 2.0.117", ] -[[package]] -name = "atk" -version = "0.18.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "241b621213072e993be4f6f3a9e4b45f65b7e6faad43001be957184b7bb1824b" -dependencies = [ - "atk-sys", - "glib", - "libc", -] - -[[package]] -name = "atk-sys" -version = "0.18.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5e48b684b0ca77d2bbadeef17424c2ea3c897d44d566a1617e7e8f30614d086" -dependencies = [ - "glib-sys", - "gobject-sys", - "libc", - "system-deps", -] - [[package]] name = "atoi" version = "2.0.0" @@ -1455,15 +1222,6 @@ dependencies = [ "workspace-build-acceleration", ] -[[package]] -name = "bincode" -version = "1.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" -dependencies = [ - "serde", -] - [[package]] name = "bindgen" version = "0.72.1" @@ -1488,21 +1246,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7e0d60973d9320722cb1206f412740e162a33b8547ea8d6be75d7cff237c7a85" -[[package]] -name = "bit-set" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08807e080ed7f9d5433fa9b275196cfc35414f66a0c79d864dc51a0d825231a3" -dependencies = [ - "bit-vec", -] - -[[package]] -name = "bit-vec" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e764a1d40d510daf35e07be9eb06e75770908c27d411ee6c92109c9840eaaf7" - [[package]] name = "bit_field" version = "0.10.2" @@ -1530,18 +1273,6 @@ version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6099cdc01846bc367c4e7dd630dc5966dccf36b652fae7a74e17b640411a91b2" -[[package]] -name = "bitvec" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" -dependencies = [ - "funty", - "radium", - "tap", - "wyz", -] - [[package]] name = "blake2b_simd" version = "1.0.2" @@ -1597,37 +1328,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8d696c370c750c948ada61c69a0ee2cbbb9c50b1019ddb86d9317157a99c2cae" -[[package]] -name = "block2" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c132eebf10f5cad5289222520a4a058514204aed6d791f1cf4fe8088b82d15f" -dependencies = [ - "objc2 0.5.2", -] - -[[package]] -name = "block2" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "340d2f0bdb2a43c1d3cd40513185b2bd7def0aa1052f956455114bc98f82dcf2" -dependencies = [ - "objc2 0.6.4", -] - -[[package]] -name = "blocking" -version = "1.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "703f41c54fc768e63e091340b424302bb1c29ef4aa0c7f10fe849dfb114d29ea" -dependencies = [ - "async-channel 2.3.0", - "async-task", - "futures-io", - "futures-lite 2.6.0", - "piper", -] - [[package]] name = "blowfish" version = "0.9.1" @@ -1671,7 +1371,7 @@ checksum = "183ccc3854411c035410dcdbffafca62084f3a6c33f013c77e83c025d2a08a28" dependencies = [ "bitflags 2.11.0", "boring-sys2", - "foreign-types 0.5.0", + "foreign-types", "libc", "openssl-macros", ] @@ -1682,23 +1382,9 @@ version = "1.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5430e3be710b68d984d1391c854eb431a9d548640711faa54eecb1df93db91cc" dependencies = [ - "borsh-derive", "cfg_aliases", ] -[[package]] -name = "borsh-derive" -version = "1.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8b668d39970baad5356d7c83a86fee3a539e6f93bf6764c97368243e17a0487" -dependencies = [ - "once_cell", - "proc-macro-crate 3.5.0", - "proc-macro2", - "quote", - "syn 2.0.117", -] - [[package]] name = "brotli" version = "8.0.2" @@ -1720,17 +1406,6 @@ dependencies = [ "alloc-stdlib", ] -[[package]] -name = "bstr" -version = "1.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63044e1ae8e69f3b5a92c736ca6269b8d12fa7efe39bf34ddb06d102cf0e2cab" -dependencies = [ - "memchr", - "regex-automata", - "serde", -] - [[package]] name = "bucket_client" version = "0.0.1" @@ -1747,79 +1422,6 @@ dependencies = [ "workspace-build-acceleration", ] -[[package]] -name = "build-info" -version = "0.0.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "288657edd15bfa5a7f30ca3b123c1af2c503eaf218e517fa10bc9063dbc2ad99" -dependencies = [ - "bincode", - "build-info-common", - "build-info-proc", -] - -[[package]] -name = "build-info-build" -version = "0.0.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3146483d5bc5081ec26f9c4e60232e770980d750b2802d6cc2563cded665cc73" -dependencies = [ - "anyhow", - "base64 0.22.1", - "bincode", - "build-info-common", - "cargo_metadata", - "chrono", - "git2", - "glob", - "pretty_assertions", - "rustc_version 0.4.0", - "serde_json", - "zstd 0.13.3", -] - -[[package]] -name = "build-info-common" -version = "0.0.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8524ad59f5958f37f95e66bf6c9a8fa8440c4f56c069247c44244434cfca3eb1" -dependencies = [ - "chrono", - "derive_more 2.0.1", - "semver 1.0.23", - "serde", -] - -[[package]] -name = "build-info-proc" -version = "0.0.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b58fb02636d968e8327d84a5a256df9704ac27a1eda98429c35dbe50a278f69" -dependencies = [ - "anyhow", - "base64 0.22.1", - "bincode", - "build-info-common", - "chrono", - "num-bigint", - "num-traits", - "proc-macro-error2", - "proc-macro2", - "quote", - "serde_json", - "syn 2.0.117", - "zstd 0.13.3", -] - -[[package]] -name = "build_metadata" -version = "0.0.1" -dependencies = [ - "build-info", - "build-info-build", - "workspace-build-acceleration", -] - [[package]] name = "built" version = "0.7.6" @@ -1832,39 +1434,6 @@ version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" -[[package]] -name = "byte-unit" -version = "5.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1cd29c3c585209b0cbc7309bfe3ed7efd8c84c21b7af29c8bfae908f8777174" -dependencies = [ - "rust_decimal", - "serde", - "utf8-width", -] - -[[package]] -name = "bytecheck" -version = "0.6.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23cdc57ce23ac53c931e88a43d06d070a6fd142f2617be5855eb75efc9beb1c2" -dependencies = [ - "bytecheck_derive", - "ptr_meta", - "simdutf8", -] - -[[package]] -name = "bytecheck_derive" -version = "0.6.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3db406d29fbcd95542e92559bed4d8ad92636d1ca8b3b72ede10b4bcc010e659" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "bytemuck" version = "1.16.0" @@ -1888,9 +1457,6 @@ name = "bytes" version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e748733b7cbc798e1434b6ac524f0c1ff2ab456fe201501e6497c8417a4fc33" -dependencies = [ - "serde", -] [[package]] name = "bytestring" @@ -1922,73 +1488,6 @@ dependencies = [ "pkg-config", ] -[[package]] -name = "cairo-rs" -version = "0.18.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ca26ef0159422fb77631dc9d17b102f253b876fe1586b03b803e63a309b4ee2" -dependencies = [ - "bitflags 2.11.0", - "cairo-sys-rs", - "glib", - "libc", - "once_cell", - "thiserror 1.0.63", -] - -[[package]] -name = "cairo-sys-rs" -version = "0.18.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "685c9fa8e590b8b3d678873528d83411db17242a73fccaed827770ea0fedda51" -dependencies = [ - "glib-sys", - "libc", - "system-deps", -] - -[[package]] -name = "camino" -version = "1.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b96ec4966b5813e2c0507c1f86115c8c5abaadc3980879c3424042a02fd1ad3" -dependencies = [ - "serde", -] - -[[package]] -name = "cargo-platform" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e35af189006b9c0f00a064685c727031e3ed2d8020f7ba284d78cc2671bd36ea" -dependencies = [ - "serde", -] - -[[package]] -name = "cargo_metadata" -version = "0.19.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8769706aad5d996120af43197bf46ef6ad0fda35216b4505f926a365a232d924" -dependencies = [ - "camino", - "cargo-platform", - "semver 1.0.23", - "serde", - "serde_json", - "thiserror 2.0.18", -] - -[[package]] -name = "cargo_toml" -version = "0.22.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02260d489095346e5cafd04dea8e8cb54d1d74fcd759022a9b72986ebe9a1257" -dependencies = [ - "serde", - "toml 0.8.23", -] - [[package]] name = "castaway" version = "0.2.3" @@ -2033,7 +1532,7 @@ checksum = "d38f2da7a0a2c4ccf0065be06397cc26a81f4e528be095826eee9d4adbb8c60f" dependencies = [ "byteorder", "fnv", - "uuid 1.22.0", + "uuid", ] [[package]] @@ -2133,7 +1632,7 @@ checksum = "0b023947811758c97c59bf9d1c188fd619ad4718dcaa767947df1cadb14f39f4" dependencies = [ "glob", "libc", - "libloading 0.8.6", + "libloading", ] [[package]] @@ -2228,15 +1727,6 @@ dependencies = [ "workspace-build-acceleration", ] -[[package]] -name = "cloudflare_mitigation" -version = "0.0.1" -dependencies = [ - "once_cell", - "workspace-build-acceleration", - "wreq", -] - [[package]] name = "cmake" version = "0.1.57" @@ -2481,17 +1971,6 @@ dependencies = [ "version_check", ] -[[package]] -name = "cookie_store" -version = "0.0.1" -dependencies = [ - "errors", - "serde", - "serde_derive", - "serde_json", - "workspace-build-acceleration", -] - [[package]] name = "cookie_store" version = "0.21.1" @@ -2536,43 +2015,6 @@ version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" -[[package]] -name = "core-graphics" -version = "0.24.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa95a34622365fa5bbf40b20b75dba8dfa8c94c734aea8ac9a5ca38af14316f1" -dependencies = [ - "bitflags 2.11.0", - "core-foundation 0.10.0", - "core-graphics-types", - "foreign-types 0.5.0", - "libc", -] - -[[package]] -name = "core-graphics" -version = "0.25.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "064badf302c3194842cf2c5d61f56cc88e54a759313879cdf03abdd27d0c3b97" -dependencies = [ - "bitflags 2.11.0", - "core-foundation 0.10.0", - "core-graphics-types", - "foreign-types 0.5.0", - "libc", -] - -[[package]] -name = "core-graphics-types" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d44a101f213f6c4cdc1853d4b78aef6db6bdfa3468798cc1d9912f4735013eb" -dependencies = [ - "bitflags 2.11.0", - "core-foundation 0.10.0", - "libc", -] - [[package]] name = "coreaudio-rs" version = "0.10.0" @@ -2716,15 +2158,6 @@ dependencies = [ "workspace-build-acceleration", ] -[[package]] -name = "crossbeam-channel" -version = "0.5.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33480d6946193aa8033910124896ca395333cae7e2d1113d1fef6c3272217df2" -dependencies = [ - "crossbeam-utils", -] - [[package]] name = "crossbeam-deque" version = "0.8.3" @@ -2812,59 +2245,6 @@ dependencies = [ "subtle", ] -[[package]] -name = "cssparser" -version = "0.29.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f93d03419cb5950ccfd3daf3ff1c7a36ace64609a1a8746d493df1ca0afde0fa" -dependencies = [ - "cssparser-macros", - "dtoa-short", - "itoa 1.0.11", - "matches", - "phf 0.10.1", - "proc-macro2", - "quote", - "smallvec", - "syn 1.0.109", -] - -[[package]] -name = "cssparser" -version = "0.35.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e901edd733a1472f944a45116df3f846f54d37e67e68640ac8bb69689aca2aa" -dependencies = [ - "cssparser-macros", - "dtoa-short", - "itoa 1.0.11", - "phf 0.11.2", - "smallvec", -] - -[[package]] -name = "cssparser" -version = "0.36.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dae61cf9c0abb83bd659dab65b7e4e38d8236824c85f0f804f173567bda257d2" -dependencies = [ - "cssparser-macros", - "dtoa-short", - "itoa 1.0.11", - "phf 0.13.1", - "smallvec", -] - -[[package]] -name = "cssparser-macros" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13b588ba4ac1a99f7f2964d24b3d896ddc6bf847ee3855dbd4366f058cfcd331" -dependencies = [ - "quote", - "syn 2.0.117", -] - [[package]] name = "csv" version = "1.3.0" @@ -2892,22 +2272,6 @@ version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "026ac6ceace6298d2c557ef5ed798894962296469ec7842288ea64674201a2d1" -[[package]] -name = "ctor" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "352d39c2f7bef1d6ad73db6f5160efcaed66d94ef8c6c573a8410c00bf909a98" -dependencies = [ - "ctor-proc-macro", - "dtor", -] - -[[package]] -name = "ctor-proc-macro" -version = "0.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52560adf09603e58c9a7ee1fe1dcb95a16927b17c127f0ac02d6e768a0e25bc1" - [[package]] name = "darling" version = "0.13.4" @@ -3004,12 +2368,6 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7e962a19be5cfc3f3bf6dd8f61eb50107f356ad6270fbb3ed41476571db78be5" -[[package]] -name = "data-url" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c297a1c74b71ae29df00c3e22dd9534821d60eb9af5a0192823fa2acea70c2a" - [[package]] name = "datadog_client" version = "0.0.1" @@ -3096,17 +2454,6 @@ dependencies = [ "workspace-build-acceleration", ] -[[package]] -name = "dbus" -version = "0.9.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b942602992bb7acfd1f51c49811c58a610ef9181b6e66f3e519d79b540a3bf73" -dependencies = [ - "libc", - "libdbus-sys", - "windows-sys 0.61.2", -] - [[package]] name = "debug-helper" version = "0.3.13" @@ -3196,12 +2543,6 @@ dependencies = [ "opaque-debug", ] -[[package]] -name = "destructure_traitobject" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c877555693c14d2f84191cfd3ad8582790fc52b5e2274b40b59cf5f5cea25c7" - [[package]] name = "dev-database-seed" version = "0.0.1" @@ -3285,12 +2626,6 @@ dependencies = [ "syn 2.0.117", ] -[[package]] -name = "diff" -version = "0.1.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56254986775e3233ffa9c4d7d3faaf6d36a2c09d30b20687e9f88bc8bafc16c8" - [[package]] name = "digest" version = "0.9.0" @@ -3323,63 +2658,6 @@ dependencies = [ "crypto-common 0.2.1", ] -[[package]] -name = "directories" -version = "6.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16f5094c54661b38d03bd7e50df373292118db60b585c08a411c6d840017fe7d" -dependencies = [ - "dirs-sys", -] - -[[package]] -name = "dirs" -version = "6.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3e8aa94d75141228480295a7d0e7feb620b1a5ad9f12bc40be62411e38cce4e" -dependencies = [ - "dirs-sys", -] - -[[package]] -name = "dirs-sys" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e01a3366d27ee9890022452ee61b2b63a67e6f13f58900b651ff5665f0bb1fab" -dependencies = [ - "libc", - "option-ext", - "redox_users", - "windows-sys 0.61.2", -] - -[[package]] -name = "discord-rich-presence" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90c55d69cab17c19677ce3a5f8face993a9e6eaf847fecac3547f3a3ff4a2494" -dependencies = [ - "log", - "serde", - "serde_derive", - "serde_json", - "serde_repr", - "thiserror 2.0.18", - "uuid 0.8.2", -] - -[[package]] -name = "dispatch2" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89a09f22a6c6069a18470eb92d2298acf25463f14256d24778e1230d789a2aec" -dependencies = [ - "bitflags 2.11.0", - "block2 0.6.1", - "libc", - "objc2 0.6.4", -] - [[package]] name = "displaydoc" version = "0.2.4" @@ -3391,29 +2669,6 @@ dependencies = [ "syn 2.0.117", ] -[[package]] -name = "dlopen2" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b54f373ccf864bf587a89e880fb7610f8d73f3045f13580948ccbcaff26febff" -dependencies = [ - "dlopen2_derive", - "libc", - "once_cell", - "winapi", -] - -[[package]] -name = "dlopen2_derive" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2b99bf03862d7f545ebc28ddd33a665b50865f4dfd84031a393823879bd4c54" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.117", -] - [[package]] name = "dlv-list" version = "0.5.2" @@ -3432,36 +2687,6 @@ dependencies = [ "litrs", ] -[[package]] -name = "dom_query" -version = "0.20.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2646c2bb4993c86006961293208b69d86a2b254356889ddad826e9df3f684f9" -dependencies = [ - "bit-set", - "cssparser 0.35.0", - "foldhash 0.1.5", - "html5ever 0.35.0", - "precomputed-hash", - "selectors 0.30.0", - "tendril 0.4.3", -] - -[[package]] -name = "dom_query" -version = "0.27.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "521e380c0c8afb8d9a1e83a1822ee03556fc3e3e7dbc1fd30be14e37f9cb3f89" -dependencies = [ - "bit-set", - "cssparser 0.36.0", - "foldhash 0.2.0", - "html5ever 0.38.0", - "precomputed-hash", - "selectors 0.36.1", - "tendril 0.5.0", -] - [[package]] name = "dotenv" version = "0.15.0" @@ -3523,15 +2748,6 @@ dependencies = [ "zip 0.6.6", ] -[[package]] -name = "dpi" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f25c0e292a7ca6d6498557ff1df68f32c99850012b6ea401cf8daf771f22ff53" -dependencies = [ - "serde", -] - [[package]] name = "dsl_auto_type" version = "0.1.1" @@ -3552,36 +2768,6 @@ version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "56899898ce76aaf4a0f24d914c97ea6ed976d42fec6ad33fcbb0a1103e07b2b0" -[[package]] -name = "dtoa" -version = "1.0.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcbb2bf8e87535c23f7a8a321e364ce21462d0ff10cb6407820e8e96dfff6653" - -[[package]] -name = "dtoa-short" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbaceec3c6e4211c79e7b1800fb9680527106beb2f9c51904a3210c03a448c74" -dependencies = [ - "dtoa 1.0.9", -] - -[[package]] -name = "dtor" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1057d6c64987086ff8ed0fd3fbf377a6b7d205cc7715868cd401705f715cbe4" -dependencies = [ - "dtor-proc-macro", -] - -[[package]] -name = "dtor-proc-macro" -version = "0.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f678cf4a922c215c63e0de95eb1ff08a958a81d47e485cf9da1e27bf6305cfa5" - [[package]] name = "dummy-service" version = "0.0.1" @@ -3659,12 +2845,6 @@ dependencies = [ "getrandom 0.2.14", ] -[[package]] -name = "ego-tree" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2972feb8dffe7bc8c5463b1dacda1b0dfbed3710e50f977d965429692d74cd8" - [[package]] name = "either" version = "1.12.0" @@ -3689,7 +2869,7 @@ dependencies = [ "rustc_version 0.2.3", "serde", "serde_json", - "serde_with 1.14.0", + "serde_with", "url", "void", ] @@ -3811,26 +2991,6 @@ dependencies = [ "workspace-build-acceleration", ] -[[package]] -name = "embed-resource" -version = "3.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fbc6e0d8e0c03a655b53ca813f0463d2c956bc4db8138dbc89f120b066551e3" -dependencies = [ - "cc", - "memchr", - "rustc_version 0.4.0", - "toml 0.8.23", - "vswhom", - "winreg 0.52.0", -] - -[[package]] -name = "embed_plist" -version = "1.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ef6b89e5b37196644d8796de5268852ff179b44e96276cf4290264843743bb7" - [[package]] name = "encoding_rs" version = "0.8.34" @@ -3840,33 +3000,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "endi" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3d8a32ae18130a3c84dd492d4215c3d913c3b07c6b63c2eb3eb7ff1101ab7bf" - -[[package]] -name = "enumflags2" -version = "0.7.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba2f4b465f5318854c6f8dd686ede6c0a9dc67d4b1ac241cf0eb51521a309147" -dependencies = [ - "enumflags2_derive", - "serde", -] - -[[package]] -name = "enumflags2_derive" -version = "0.7.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc4caf64a58d7a6d65ab00639b046ff54399a39f5f2554728895ace4b297cd79" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.117", -] - [[package]] name = "enums" version = "0.0.1" @@ -3894,16 +3027,6 @@ dependencies = [ "num_threads", ] -[[package]] -name = "env_filter" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a009aa4810eb158359dda09d0c87378e4bbb89b5a801f016885a4707ba24f7ea" -dependencies = [ - "log", - "regex", -] - [[package]] name = "env_filter" version = "1.0.0" @@ -3921,7 +3044,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36" dependencies = [ "atty", - "humantime 1.3.0", + "humantime", "log", "regex", "termcolor", @@ -3935,7 +3058,7 @@ checksum = "b2daee4ea451f429a58296525ddf28b45a3b64f1acf6587e2067437bb11e218d" dependencies = [ "anstream", "anstyle", - "env_filter 1.0.0", + "env_filter", "jiff", "log", ] @@ -4031,27 +3154,6 @@ version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" -[[package]] -name = "event-listener" -version = "5.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e13b66accf52311f30a0db42147dadea9850cb48cd070028831ae5f5d4b856ab" -dependencies = [ - "concurrent-queue", - "parking", - "pin-project-lite", -] - -[[package]] -name = "event-listener-strategy" -version = "0.5.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8be9f3dfaaffdae2972880079a491a1a8bb7cbed0b8dd7a347f668b4150a3b93" -dependencies = [ - "event-listener 5.4.1", - "pin-project-lite", -] - [[package]] name = "exr" version = "1.73.0" @@ -4118,15 +3220,6 @@ dependencies = [ "simd-adler32", ] -[[package]] -name = "fern" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4316185f709b23713e41e3195f90edef7fb00c3ed4adc79769cf09cc762a3b29" -dependencies = [ - "log", -] - [[package]] name = "ff" version = "0.13.0" @@ -4160,16 +3253,6 @@ dependencies = [ "serde_json", ] -[[package]] -name = "field-offset" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38e2275cc4e4fc009b0669731a1e5ab7ebf11f469eaede2bab9309a5b4d6057f" -dependencies = [ - "memoffset 0.9.0", - "rustc_version 0.4.0", -] - [[package]] name = "file_to_base64_url" version = "0.0.1" @@ -4245,15 +3328,6 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb" -[[package]] -name = "foreign-types" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" -dependencies = [ - "foreign-types-shared 0.1.1", -] - [[package]] name = "foreign-types" version = "0.5.0" @@ -4261,7 +3335,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d737d9aa519fb7b749cbc3b962edcf310a8dd1f4b67c91c4f83975dbdd17d965" dependencies = [ "foreign-types-macros", - "foreign-types-shared 0.3.1", + "foreign-types-shared", ] [[package]] @@ -4275,12 +3349,6 @@ dependencies = [ "syn 2.0.117", ] -[[package]] -name = "foreign-types-shared" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" - [[package]] name = "foreign-types-shared" version = "0.3.1" @@ -4324,22 +3392,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" -[[package]] -name = "funty" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" - -[[package]] -name = "futf" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df420e2e84819663797d1ec6544b13c5be84629e7bb00dc960d6917db2987843" -dependencies = [ - "mac", - "new_debug_unreachable", -] - [[package]] name = "futures" version = "0.1.31" @@ -4420,19 +3472,6 @@ dependencies = [ "waker-fn", ] -[[package]] -name = "futures-lite" -version = "2.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5edaec856126859abb19ed65f39e90fea3a9574b9707f13539acf4abf7eb532" -dependencies = [ - "fastrand 2.3.0", - "futures-core", - "futures-io", - "parking", - "pin-project-lite", -] - [[package]] name = "futures-macro" version = "0.3.32" @@ -4479,114 +3518,6 @@ dependencies = [ "slab", ] -[[package]] -name = "fxhash" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c" -dependencies = [ - "byteorder", -] - -[[package]] -name = "gdk" -version = "0.18.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9f245958c627ac99d8e529166f9823fb3b838d1d41fd2b297af3075093c2691" -dependencies = [ - "cairo-rs", - "gdk-pixbuf", - "gdk-sys", - "gio", - "glib", - "libc", - "pango", -] - -[[package]] -name = "gdk-pixbuf" -version = "0.18.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50e1f5f1b0bfb830d6ccc8066d18db35c487b1b2b1e8589b5dfe9f07e8defaec" -dependencies = [ - "gdk-pixbuf-sys", - "gio", - "glib", - "libc", - "once_cell", -] - -[[package]] -name = "gdk-pixbuf-sys" -version = "0.18.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9839ea644ed9c97a34d129ad56d38a25e6756f99f3a88e15cd39c20629caf7" -dependencies = [ - "gio-sys", - "glib-sys", - "gobject-sys", - "libc", - "system-deps", -] - -[[package]] -name = "gdk-sys" -version = "0.18.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c2d13f38594ac1e66619e188c6d5a1adb98d11b2fcf7894fc416ad76aa2f3f7" -dependencies = [ - "cairo-sys-rs", - "gdk-pixbuf-sys", - "gio-sys", - "glib-sys", - "gobject-sys", - "libc", - "pango-sys", - "pkg-config", - "system-deps", -] - -[[package]] -name = "gdkwayland-sys" -version = "0.18.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "140071d506d223f7572b9f09b5e155afbd77428cd5cc7af8f2694c41d98dfe69" -dependencies = [ - "gdk-sys", - "glib-sys", - "gobject-sys", - "libc", - "pkg-config", - "system-deps", -] - -[[package]] -name = "gdkx11" -version = "0.18.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3caa00e14351bebbc8183b3c36690327eb77c49abc2268dd4bd36b856db3fbfe" -dependencies = [ - "gdk", - "gdkx11-sys", - "gio", - "glib", - "libc", - "x11", -] - -[[package]] -name = "gdkx11-sys" -version = "0.18.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e2e7445fe01ac26f11601db260dd8608fe172514eb63b3b5e261ea6b0f4428d" -dependencies = [ - "gdk-sys", - "glib-sys", - "libc", - "system-deps", - "x11", -] - [[package]] name = "generic-array" version = "0.14.7" @@ -4671,98 +3602,6 @@ dependencies = [ "weezl", ] -[[package]] -name = "gio" -version = "0.18.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4fc8f532f87b79cbc51a79748f16a6828fb784be93145a322fa14d06d354c73" -dependencies = [ - "futures-channel", - "futures-core", - "futures-io", - "futures-util", - "gio-sys", - "glib", - "libc", - "once_cell", - "pin-project-lite", - "smallvec", - "thiserror 1.0.63", -] - -[[package]] -name = "gio-sys" -version = "0.18.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37566df850baf5e4cb0dfb78af2e4b9898d817ed9263d1090a2df958c64737d2" -dependencies = [ - "glib-sys", - "gobject-sys", - "libc", - "system-deps", - "winapi", -] - -[[package]] -name = "git2" -version = "0.20.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2deb07a133b1520dc1a5690e9bd08950108873d7ed5de38dcc74d3b5ebffa110" -dependencies = [ - "bitflags 2.11.0", - "libc", - "libgit2-sys", - "log", - "url", -] - -[[package]] -name = "glib" -version = "0.18.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "233daaf6e83ae6a12a52055f568f9d7cf4671dabb78ff9560ab6da230ce00ee5" -dependencies = [ - "bitflags 2.11.0", - "futures-channel", - "futures-core", - "futures-executor", - "futures-task", - "futures-util", - "gio-sys", - "glib-macros", - "glib-sys", - "gobject-sys", - "libc", - "memchr", - "once_cell", - "smallvec", - "thiserror 1.0.63", -] - -[[package]] -name = "glib-macros" -version = "0.18.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bb0228f477c0900c880fd78c8759b95c7636dbd7842707f49e132378aa2acdc" -dependencies = [ - "heck 0.4.1", - "proc-macro-crate 2.0.0", - "proc-macro-error", - "proc-macro2", - "quote", - "syn 2.0.117", -] - -[[package]] -name = "glib-sys" -version = "0.18.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "063ce2eb6a8d0ea93d2bf8ba1957e78dbab6be1c2220dd3daca57d5a9d869898" -dependencies = [ - "libc", - "system-deps", -] - [[package]] name = "glob" version = "0.3.1" @@ -4819,17 +3658,6 @@ dependencies = [ "workspace-build-acceleration", ] -[[package]] -name = "gobject-sys" -version = "0.18.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0850127b514d1c4a4654ead6dedadb18198999985908e6ffe4436f53c785ce44" -dependencies = [ - "glib-sys", - "libc", - "system-deps", -] - [[package]] name = "google_drive_downloader" version = "0.0.1" @@ -4932,41 +3760,6 @@ dependencies = [ "workspace-build-acceleration", ] -[[package]] -name = "grok_consumer_client" -version = "0.0.1" -dependencies = [ - "anyhow", - "base64 0.22.1", - "bstr", - "byteorder", - "chrono", - "cloudflare_errors", - "cloudflare_mitigation", - "cookie_store 0.0.1", - "env", - "env_logger 0.11.9", - "errors", - "filesys", - "futures 0.3.32", - "log", - "log4rs", - "once_cell", - "regex", - "scraper", - "serde", - "serde_json", - "sha2 0.11.0-rc.5", - "test_data", - "test_utils", - "tokio", - "url", - "uuid 1.22.0", - "workspace-build-acceleration", - "wreq", - "wreq-util", -] - [[package]] name = "group" version = "0.13.0" @@ -4978,58 +3771,6 @@ dependencies = [ "subtle", ] -[[package]] -name = "gtk" -version = "0.18.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd56fb197bfc42bd5d2751f4f017d44ff59fbb58140c6b49f9b3b2bdab08506a" -dependencies = [ - "atk", - "cairo-rs", - "field-offset", - "futures-channel", - "gdk", - "gdk-pixbuf", - "gio", - "glib", - "gtk-sys", - "gtk3-macros", - "libc", - "pango", - "pkg-config", -] - -[[package]] -name = "gtk-sys" -version = "0.18.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f29a1c21c59553eb7dd40e918be54dccd60c52b049b75119d5d96ce6b624414" -dependencies = [ - "atk-sys", - "cairo-sys-rs", - "gdk-pixbuf-sys", - "gdk-sys", - "gio-sys", - "glib-sys", - "gobject-sys", - "libc", - "pango-sys", - "system-deps", -] - -[[package]] -name = "gtk3-macros" -version = "0.18.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52ff3c5b21f14f0736fed6dcfc0bfb4225ebf5725f3c0209edeec181e4d73e9d" -dependencies = [ - "proc-macro-crate 1.3.1", - "proc-macro-error", - "proc-macro2", - "quote", - "syn 2.0.117", -] - [[package]] name = "h2" version = "0.3.27" @@ -5083,9 +3824,6 @@ name = "hashbrown" version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" -dependencies = [ - "ahash 0.7.8", -] [[package]] name = "hashbrown" @@ -5099,7 +3837,7 @@ version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" dependencies = [ - "ahash 0.8.12", + "ahash", "allocator-api2", ] @@ -5174,12 +3912,6 @@ version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" -[[package]] -name = "hermit-abi" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbf6a919d6cf397374f7dfeeea91d974c7c0a7221d0d0f4f20d859d329e53fcc" - [[package]] name = "hex" version = "0.4.3" @@ -5275,39 +4007,6 @@ dependencies = [ "windows 0.52.0", ] -[[package]] -name = "html5ever" -version = "0.29.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b7410cae13cbc75623c98ac4cbfd1f0bedddf3227afc24f370cf0f50a44a11c" -dependencies = [ - "log", - "mac", - "markup5ever 0.14.1", - "match_token 0.1.0", -] - -[[package]] -name = "html5ever" -version = "0.35.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55d958c2f74b664487a2035fe1dadb032c48718a03b63f3ab0b8537db8549ed4" -dependencies = [ - "log", - "markup5ever 0.35.0", - "match_token 0.35.0", -] - -[[package]] -name = "html5ever" -version = "0.38.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1054432bae2f14e0061e33d23402fbaa67a921d319d56adc6bcf887ddad1cbc2" -dependencies = [ - "log", - "markup5ever 0.38.0", -] - [[package]] name = "http" version = "0.2.11" @@ -5364,12 +4063,6 @@ dependencies = [ "pin-project-lite", ] -[[package]] -name = "http-range" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21dec9db110f5f872ed9699c3ecf50cf16f423502706ba5c72462e28d3157573" - [[package]] name = "http-types" version = "2.12.0" @@ -5377,9 +4070,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e9b187a72d63adbfba487f48095306ac823049cb504ee195541e91c7775f5ad" dependencies = [ "anyhow", - "async-channel 1.9.0", + "async-channel", "base64 0.13.1", - "futures-lite 1.13.0", + "futures-lite", "http 0.2.11", "infer 0.2.3", "pin-project-lite", @@ -5458,12 +4151,6 @@ dependencies = [ "quick-error 1.2.3", ] -[[package]] -name = "humantime" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" - [[package]] name = "hybrid-array" version = "0.4.8" @@ -5565,22 +4252,6 @@ dependencies = [ "tokio-io-timeout", ] -[[package]] -name = "hyper-tls" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" -dependencies = [ - "bytes", - "http-body-util", - "hyper 1.6.0", - "hyper-util", - "native-tls", - "tokio", - "tokio-native-tls", - "tower-service", -] - [[package]] name = "hyper-util" version = "0.1.16" @@ -5630,16 +4301,6 @@ dependencies = [ "cc", ] -[[package]] -name = "ico" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e795dff5605e0f04bff85ca41b51a96b83e80b281e96231bcaaf1ac35103371" -dependencies = [ - "byteorder", - "png 0.17.16", -] - [[package]] name = "icu_collections" version = "1.5.0" @@ -5814,7 +4475,7 @@ dependencies = [ "gif", "image-webp", "num-traits", - "png 0.17.16", + "png", "qoi", "ravif", "rayon", @@ -5882,7 +4543,6 @@ checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" dependencies = [ "autocfg", "hashbrown 0.12.3", - "serde", ] [[package]] @@ -6036,25 +4696,6 @@ dependencies = [ "serde", ] -[[package]] -name = "is-docker" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "928bae27f42bc99b60d9ac7334e3a21d10ad8f1835a4e12ec3ec0464765ed1b3" -dependencies = [ - "once_cell", -] - -[[package]] -name = "is-wsl" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "173609498df190136aa7dea1a91db051746d339e18476eed5ca40521f02d7aa5" -dependencies = [ - "is-docker", - "once_cell", -] - [[package]] name = "is_terminal_polyfill" version = "1.70.0" @@ -6109,29 +4750,6 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" -[[package]] -name = "javascriptcore-rs" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca5671e9ffce8ffba57afc24070e906da7fc4b1ba66f2cabebf61bf2ea257fcc" -dependencies = [ - "bitflags 1.3.2", - "glib", - "javascriptcore-rs-sys", -] - -[[package]] -name = "javascriptcore-rs-sys" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af1be78d14ffa4b75b66df31840478fef72b51f8c2465d4ca7c194da9f7a5124" -dependencies = [ - "glib-sys", - "gobject-sys", - "libc", - "system-deps", -] - [[package]] name = "jiff" version = "0.2.15" @@ -6231,18 +4849,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "json-patch" -version = "3.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "863726d7afb6bc2590eeff7135d923545e5e964f004c2ccf8716c25e70a86f08" -dependencies = [ - "jsonptr", - "serde", - "serde_json", - "thiserror 1.0.63", -] - [[package]] name = "jsonpath_lib" version = "0.3.0" @@ -6254,16 +4860,6 @@ dependencies = [ "serde_json", ] -[[package]] -name = "jsonptr" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dea2b27dd239b2556ed7a25ba842fe47fd602e7fc7433c2a8d6106d4d9edd70" -dependencies = [ - "serde", - "serde_json", -] - [[package]] name = "jwt" version = "0.13.0" @@ -6348,17 +4944,6 @@ dependencies = [ "cpufeatures 0.2.12", ] -[[package]] -name = "keyboard-types" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b750dcadc39a09dbadd74e118f6dd6598df77fa01df0cfcdc52c28dece74528a" -dependencies = [ - "bitflags 2.11.0", - "serde", - "unicode-segmentation", -] - [[package]] name = "kinovi_web_client" version = "0.0.1" @@ -6396,18 +4981,6 @@ dependencies = [ "workspace-build-acceleration", ] -[[package]] -name = "kuchikiki" -version = "0.8.8-speedreader" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02cb977175687f33fa4afa0c95c112b987ea1443e5a51c8f8ff27dc618270cc2" -dependencies = [ - "cssparser 0.29.6", - "html5ever 0.29.1", - "indexmap 2.13.0", - "selectors 0.24.0", -] - [[package]] name = "language-tags" version = "0.3.2" @@ -6480,45 +5053,12 @@ dependencies = [ "linked_hash_set", ] -[[package]] -name = "libappindicator" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03589b9607c868cc7ae54c0b2a22c8dc03dd41692d48f2d7df73615c6a95dc0a" -dependencies = [ - "glib", - "gtk", - "gtk-sys", - "libappindicator-sys", - "log", -] - -[[package]] -name = "libappindicator-sys" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e9ec52138abedcc58dc17a7c6c0c00a2bdb4f3427c7f63fa97fd0d859155caf" -dependencies = [ - "gtk-sys", - "libloading 0.7.4", - "once_cell", -] - [[package]] name = "libc" version = "0.2.183" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5b646652bf6661599e1da8901b3b9522896f01e736bad5f723fe7a3a27f899d" -[[package]] -name = "libdbus-sys" -version = "0.2.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "328c4789d42200f1eeec05bd86c9c13c7f091d2ba9a6ea35acdf51f31bc0f043" -dependencies = [ - "pkg-config", -] - [[package]] name = "libfuzzer-sys" version = "0.4.9" @@ -6529,28 +5069,6 @@ dependencies = [ "cc", ] -[[package]] -name = "libgit2-sys" -version = "0.18.1+1.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1dcb20f84ffcdd825c7a311ae347cce604a6f084a767dec4a4929829645290e" -dependencies = [ - "cc", - "libc", - "libz-sys", - "pkg-config", -] - -[[package]] -name = "libloading" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f" -dependencies = [ - "cfg-if", - "winapi", -] - [[package]] name = "libloading" version = "0.8.6" @@ -6615,16 +5133,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "libredox" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" -dependencies = [ - "bitflags 2.11.0", - "libc", -] - [[package]] name = "libsqlite3-sys" version = "0.27.0" @@ -6645,18 +5153,6 @@ dependencies = [ "zlib-rs", ] -[[package]] -name = "libz-sys" -version = "1.1.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b70e7a7df205e92a1a4cd9aaae7898dac0aa555503cc0a649494d0d60e7651d" -dependencies = [ - "cc", - "libc", - "pkg-config", - "vcpkg", -] - [[package]] name = "limitation" version = "0.1.1" @@ -6684,12 +5180,6 @@ dependencies = [ "linked-hash-map", ] -[[package]] -name = "linux-raw-sys" -version = "0.4.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" - [[package]] name = "linux-raw-sys" version = "0.12.1" @@ -6745,45 +5235,6 @@ name = "log" version = "0.4.29" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897" -dependencies = [ - "serde_core", - "value-bag", -] - -[[package]] -name = "log-mdc" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a94d21414c1f4a51209ad204c1776a3d0765002c76c6abcb602a6f09f1e881c7" - -[[package]] -name = "log4rs" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e947bb896e702c711fccc2bf02ab2abb6072910693818d1d6b07ee2b9dfd86c" -dependencies = [ - "anyhow", - "arc-swap", - "chrono", - "derive_more 2.0.1", - "fnv", - "humantime 2.1.0", - "libc", - "log", - "log-mdc", - "mock_instant", - "parking_lot 0.12.5", - "rand 0.9.2", - "serde", - "serde-value", - "serde_json", - "serde_yaml", - "thiserror 2.0.18", - "thread-id", - "typemap-ors", - "unicode-segmentation", - "winapi", -] [[package]] name = "logging" @@ -6837,12 +5288,6 @@ dependencies = [ "crc", ] -[[package]] -name = "mac" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c41e0c4fef86961ac6d6f8a82609f55f31b05e4fce149ac5710e439df7619ba4" - [[package]] name = "mach" version = "0.3.2" @@ -6889,76 +5334,12 @@ dependencies = [ "workspace-build-acceleration", ] -[[package]] -name = "markup5ever" -version = "0.14.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7a7213d12e1864c0f002f52c2923d4556935a43dec5e71355c2760e0f6e7a18" -dependencies = [ - "log", - "phf 0.11.2", - "phf_codegen 0.11.3", - "string_cache 0.8.9", - "string_cache_codegen 0.5.4", - "tendril 0.4.3", -] - -[[package]] -name = "markup5ever" -version = "0.35.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "311fe69c934650f8f19652b3946075f0fc41ad8757dbb68f1ca14e7900ecc1c3" -dependencies = [ - "log", - "tendril 0.4.3", - "web_atoms 0.1.3", -] - -[[package]] -name = "markup5ever" -version = "0.38.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8983d30f2915feeaaab2d6babdd6bc7e9ed1a00b66b5e6d74df19aa9c0e91862" -dependencies = [ - "log", - "tendril 0.5.0", - "web_atoms 0.2.4", -] - [[package]] name = "match_cfg" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ffbee8634e0d45d258acb448e7eaab3fce7a0a467395d4d9f228e3c1f01fb2e4" -[[package]] -name = "match_token" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88a9689d8d44bf9964484516275f5cd4c9b59457a6940c1d5d0ecbb94510a36b" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.117", -] - -[[package]] -name = "match_token" -version = "0.35.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac84fd3f360fcc43dc5f5d186f02a94192761a080e8bc58621ad4d12296a58cf" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.117", -] - -[[package]] -name = "matches" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2532096657941c2fea9c289d370a250971c689d4f143798ff67113ec042024a5" - [[package]] name = "matchit" version = "0.7.3" @@ -7058,15 +5439,6 @@ dependencies = [ "workspace-build-acceleration", ] -[[package]] -name = "memory_store" -version = "0.0.1" -dependencies = [ - "anyhow", - "errors", - "workspace-build-acceleration", -] - [[package]] name = "metrics" version = "0.0.1" @@ -7077,29 +5449,6 @@ dependencies = [ "workspace-build-acceleration", ] -[[package]] -name = "midjourney_client" -version = "0.0.1" -dependencies = [ - "anyhow", - "cloudflare_errors", - "cookie_store 0.0.1", - "dom_query 0.20.2", - "errors", - "filesys", - "futures 0.3.32", - "log", - "serde", - "serde_json", - "test_data", - "test_utils", - "tokio", - "url", - "workspace-build-acceleration", - "wreq", - "wreq-util", -] - [[package]] name = "migration" version = "0.0.1" @@ -7244,12 +5593,6 @@ dependencies = [ "const_format", ] -[[package]] -name = "mock_instant" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dce6dd36094cac388f119d2e9dc82dc730ef91c32a6222170d630e5414b956e6" - [[package]] name = "mockall" version = "0.12.1" @@ -7314,27 +5657,6 @@ dependencies = [ "wreq-util", ] -[[package]] -name = "muda" -version = "0.19.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47a2e3dff89cd322c66647942668faee0a2b1f88ea6cbb4d374b4a8d7e92528c" -dependencies = [ - "crossbeam-channel", - "dpi", - "gtk", - "keyboard-types", - "objc2 0.6.4", - "objc2-app-kit", - "objc2-core-foundation", - "objc2-foundation 0.3.1", - "once_cell", - "png 0.18.1", - "serde", - "thiserror 2.0.18", - "windows-sys 0.61.2", -] - [[package]] name = "mysql_queries" version = "0.0.1" @@ -7389,23 +5711,6 @@ dependencies = [ "vcpkg", ] -[[package]] -name = "native-tls" -version = "0.2.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "465500e14ea162429d264d44189adc38b199b62b1c21eea9f69e4b73cb03bbf2" -dependencies = [ - "libc", - "log", - "openssl", - "openssl-probe 0.2.1", - "openssl-sys", - "schannel", - "security-framework 3.7.0", - "security-framework-sys", - "tempfile", -] - [[package]] name = "ndk" version = "0.6.0" @@ -7433,21 +5738,6 @@ dependencies = [ "thiserror 1.0.63", ] -[[package]] -name = "ndk" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3f42e7bbe13d351b6bead8286a43aac9534b82bd3cc43e47037f012ebfd62d4" -dependencies = [ - "bitflags 2.11.0", - "jni-sys", - "log", - "ndk-sys 0.6.0+11769913", - "num_enum 0.7.2", - "raw-window-handle", - "thiserror 1.0.63", -] - [[package]] name = "ndk-context" version = "0.1.1" @@ -7500,15 +5790,6 @@ dependencies = [ "jni-sys", ] -[[package]] -name = "ndk-sys" -version = "0.6.0+11769913" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee6cda3051665f1fb8d9e08fc35c96d5a244fb1be711a03b71118828afc9a873" -dependencies = [ - "jni-sys", -] - [[package]] name = "new_debug_unreachable" version = "1.0.4" @@ -7528,12 +5809,6 @@ dependencies = [ "memoffset 0.6.5", ] -[[package]] -name = "nodrop" -version = "0.1.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" - [[package]] name = "nom" version = "7.1.3" @@ -7727,242 +6002,6 @@ dependencies = [ "libc", ] -[[package]] -name = "objc-sys" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdb91bdd390c7ce1a8607f35f3ca7151b65afc0ff5ff3b34fa350f7d7c7e4310" - -[[package]] -name = "objc2" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46a785d4eeff09c14c487497c162e92766fbb3e4059a71840cecc03d9a50b804" -dependencies = [ - "objc-sys", - "objc2-encode", -] - -[[package]] -name = "objc2" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a12a8ed07aefc768292f076dc3ac8c48f3781c8f2d5851dd3d98950e8c5a89f" -dependencies = [ - "objc2-encode", - "objc2-exception-helper", -] - -[[package]] -name = "objc2-app-kit" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6f29f568bec459b0ddff777cec4fe3fd8666d82d5a40ebd0ff7e66134f89bcc" -dependencies = [ - "bitflags 2.11.0", - "block2 0.6.1", - "objc2 0.6.4", - "objc2-core-foundation", - "objc2-foundation 0.3.1", -] - -[[package]] -name = "objc2-cloud-kit" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17614fdcd9b411e6ff1117dfb1d0150f908ba83a7df81b1f118005fe0a8ea15d" -dependencies = [ - "bitflags 2.11.0", - "objc2 0.6.4", - "objc2-foundation 0.3.1", -] - -[[package]] -name = "objc2-core-data" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291fbbf7d29287518e8686417cf7239c74700fd4b607623140a7d4a3c834329d" -dependencies = [ - "objc2 0.6.4", - "objc2-foundation 0.3.1", -] - -[[package]] -name = "objc2-core-foundation" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c10c2894a6fed806ade6027bcd50662746363a9589d3ec9d9bef30a4e4bc166" -dependencies = [ - "bitflags 2.11.0", - "dispatch2", - "objc2 0.6.4", -] - -[[package]] -name = "objc2-core-graphics" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "989c6c68c13021b5c2d6b71456ebb0f9dc78d752e86a98da7c716f4f9470f5a4" -dependencies = [ - "bitflags 2.11.0", - "dispatch2", - "objc2 0.6.4", - "objc2-core-foundation", - "objc2-io-surface", -] - -[[package]] -name = "objc2-core-image" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79b3dc0cc4386b6ccf21c157591b34a7f44c8e75b064f85502901ab2188c007e" -dependencies = [ - "objc2 0.6.4", - "objc2-foundation 0.3.1", -] - -[[package]] -name = "objc2-core-location" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac0f75792558aa9d618443bbb5db7426a7a0b6fddf96903f86ef9ad02e135740" -dependencies = [ - "objc2 0.6.4", - "objc2-foundation 0.3.1", -] - -[[package]] -name = "objc2-encode" -version = "4.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef25abbcd74fb2609453eb695bd2f860d389e457f67dc17cafc8b8cbc89d0c33" - -[[package]] -name = "objc2-exception-helper" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7a1c5fbb72d7735b076bb47b578523aedc40f3c439bea6dfd595c089d79d98a" -dependencies = [ - "cc", -] - -[[package]] -name = "objc2-foundation" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ee638a5da3799329310ad4cfa62fbf045d5f56e3ef5ba4149e7452dcf89d5a8" -dependencies = [ - "bitflags 2.11.0", - "block2 0.5.1", - "libc", - "objc2 0.5.2", -] - -[[package]] -name = "objc2-foundation" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "900831247d2fe1a09a683278e5384cfb8c80c79fe6b166f9d14bfdde0ea1b03c" -dependencies = [ - "bitflags 2.11.0", - "block2 0.6.1", - "libc", - "objc2 0.6.4", - "objc2-core-foundation", -] - -[[package]] -name = "objc2-io-surface" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7282e9ac92529fa3457ce90ebb15f4ecbc383e8338060960760fa2cf75420c3c" -dependencies = [ - "bitflags 2.11.0", - "objc2 0.6.4", - "objc2-core-foundation", -] - -[[package]] -name = "objc2-metal" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd0cba1276f6023976a406a14ffa85e1fdd19df6b0f737b063b95f6c8c7aadd6" -dependencies = [ - "bitflags 2.11.0", - "block2 0.5.1", - "objc2 0.5.2", - "objc2-foundation 0.2.2", -] - -[[package]] -name = "objc2-quartz-core" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e42bee7bff906b14b167da2bac5efe6b6a07e6f7c0a21a7308d40c960242dc7a" -dependencies = [ - "bitflags 2.11.0", - "block2 0.5.1", - "objc2 0.5.2", - "objc2-foundation 0.2.2", - "objc2-metal", -] - -[[package]] -name = "objc2-quartz-core" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90ffb6a0cd5f182dc964334388560b12a57f7b74b3e2dec5e2722aa2dfb2ccd5" -dependencies = [ - "bitflags 2.11.0", - "objc2 0.6.4", - "objc2-core-foundation", - "objc2-foundation 0.3.1", -] - -[[package]] -name = "objc2-ui-kit" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "777a571be14a42a3990d4ebedaeb8b54cd17377ec21b92e8200ac03797b3bee1" -dependencies = [ - "bitflags 2.11.0", - "block2 0.6.1", - "objc2 0.6.4", - "objc2-cloud-kit", - "objc2-core-data", - "objc2-core-foundation", - "objc2-core-graphics", - "objc2-core-image", - "objc2-core-location", - "objc2-foundation 0.3.1", - "objc2-quartz-core 0.3.1", - "objc2-user-notifications", -] - -[[package]] -name = "objc2-user-notifications" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a3f5ec77a81d9e0c5a0b32159b0cb143d7086165e79708351e02bf37dfc65cd" -dependencies = [ - "objc2 0.6.4", - "objc2-foundation 0.3.1", -] - -[[package]] -name = "objc2-web-kit" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91672909de8b1ce1c2252e95bbee8c1649c9ad9d14b9248b3d7b4c47903c47ad" -dependencies = [ - "bitflags 2.11.0", - "block2 0.6.1", - "objc2 0.6.4", - "objc2-app-kit", - "objc2-core-foundation", - "objc2-foundation 0.3.1", -] - [[package]] name = "oboe" version = "0.4.6" @@ -8038,46 +6077,6 @@ dependencies = [ "serde_json", ] -[[package]] -name = "open" -version = "5.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43bb73a7fa3799b198970490a51174027ba0d4ec504b03cd08caf513d40024bc" -dependencies = [ - "dunce", - "is-wsl", - "libc", - "pathdiff", -] - -[[package]] -name = "openai_sora_client" -version = "0.0.1" -dependencies = [ - "anyhow", - "base64 0.22.1", - "chrono", - "cloudflare_errors", - "cookie 0.18.1", - "errors", - "log", - "once_cell", - "rand 0.9.2", - "serde", - "serde_derive", - "serde_json", - "sha3", - "test_utils", - "thiserror 2.0.18", - "tokio", - "toml 1.0.7+spec-1.1.0", - "url", - "uuid_utils", - "workspace-build-acceleration", - "wreq", - "wreq-util", -] - [[package]] name = "openart_client" version = "0.0.1" @@ -8107,21 +6106,6 @@ dependencies = [ "workspace-build-acceleration", ] -[[package]] -name = "openssl" -version = "0.10.75" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08838db121398ad17ab8531ce9de97b244589089e290a384c900cb9ff7434328" -dependencies = [ - "bitflags 2.11.0", - "cfg-if", - "foreign-types 0.3.2", - "libc", - "once_cell", - "openssl-macros", - "openssl-sys", -] - [[package]] name = "openssl-macros" version = "0.1.1" @@ -8139,34 +6123,6 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" -[[package]] -name = "openssl-probe" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c87def4c32ab89d880effc9e097653c8da5d6ef28e6b539d313baaacfbafcbe" - -[[package]] -name = "openssl-src" -version = "300.4.2+3.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168ce4e058f975fe43e89d9ccf78ca668601887ae736090aacc23ae353c298e2" -dependencies = [ - "cc", -] - -[[package]] -name = "openssl-sys" -version = "0.9.111" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82cab2d520aa75e3c58898289429321eb788c3106963d0dc886ec7a5f4adc321" -dependencies = [ - "cc", - "libc", - "openssl-src", - "pkg-config", - "vcpkg", -] - [[package]] name = "opentelemetry" version = "0.23.0" @@ -8225,7 +6181,7 @@ dependencies = [ "lazy_static", "once_cell", "opentelemetry", - "ordered-float 4.2.0", + "ordered-float", "percent-encoding", "rand 0.8.5", "thiserror 1.0.63", @@ -8233,21 +6189,6 @@ dependencies = [ "tokio-stream", ] -[[package]] -name = "option-ext" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" - -[[package]] -name = "ordered-float" -version = "2.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68f19d67e5a2795c94e73e0bb1cc1a7edeb2e28efd39e2e1c9b7a40c1108b11c" -dependencies = [ - "num-traits", -] - [[package]] name = "ordered-float" version = "4.2.0" @@ -8267,27 +6208,6 @@ dependencies = [ "hashbrown 0.14.5", ] -[[package]] -name = "ordered-stream" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9aa2b01e1d916879f73a53d01d1d6cee68adbb31d6d9177a8cfce093cced1d50" -dependencies = [ - "futures-core", - "pin-project-lite", -] - -[[package]] -name = "os_info" -version = "3.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0e1ac5fde8d43c34139135df8ea9ee9465394b2d8d20f032d38998f64afffc3" -dependencies = [ - "log", - "plist", - "windows-sys 0.52.0", -] - [[package]] name = "os_str_bytes" version = "6.6.1" @@ -8332,31 +6252,6 @@ dependencies = [ "workspace-build-acceleration", ] -[[package]] -name = "pango" -version = "0.18.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ca27ec1eb0457ab26f3036ea52229edbdb74dee1edd29063f5b9b010e7ebee4" -dependencies = [ - "gio", - "glib", - "libc", - "once_cell", - "pango-sys", -] - -[[package]] -name = "pango-sys" -version = "0.18.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "436737e391a843e5933d6d9aa102cb126d501e815b83601365a948a518555dc5" -dependencies = [ - "glib-sys", - "gobject-sys", - "libc", - "system-deps", -] - [[package]] name = "parking" version = "2.2.0" @@ -8443,12 +6338,6 @@ version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" -[[package]] -name = "pathdiff" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df94ce210e5bc13cb6651479fa48d14f601d9858cfe0467f43ae157023b938d3" - [[package]] name = "pbkdf2" version = "0.11.0" @@ -8486,193 +6375,6 @@ version = "2.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" -[[package]] -name = "phf" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3dfb61232e34fcb633f43d12c58f83c1df82962dcdfa565a4e866ffc17dafe12" -dependencies = [ - "phf_shared 0.8.0", -] - -[[package]] -name = "phf" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fabbf1ead8a5bcbc20f5f8b939ee3f5b0f6f281b6ad3468b84656b658b455259" -dependencies = [ - "phf_macros 0.10.0", - "phf_shared 0.10.0", - "proc-macro-hack", -] - -[[package]] -name = "phf" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ade2d8b8f33c7333b51bcf0428d37e217e9f32192ae4772156f65063b8ce03dc" -dependencies = [ - "phf_macros 0.11.2", - "phf_shared 0.11.3", -] - -[[package]] -name = "phf" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1562dc717473dbaa4c1f85a36410e03c047b2e7df7f45ee938fbef64ae7fadf" -dependencies = [ - "phf_macros 0.13.1", - "phf_shared 0.13.1", - "serde", -] - -[[package]] -name = "phf_codegen" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbffee61585b0411840d3ece935cce9cb6321f01c45477d30066498cd5e1a815" -dependencies = [ - "phf_generator 0.8.0", - "phf_shared 0.8.0", -] - -[[package]] -name = "phf_codegen" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aef8048c789fa5e851558d709946d6d79a8ff88c0440c587967f8e94bfb1216a" -dependencies = [ - "phf_generator 0.11.2", - "phf_shared 0.11.3", -] - -[[package]] -name = "phf_codegen" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49aa7f9d80421bca176ca8dbfebe668cc7a2684708594ec9f3c0db0805d5d6e1" -dependencies = [ - "phf_generator 0.13.1", - "phf_shared 0.13.1", -] - -[[package]] -name = "phf_generator" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17367f0cc86f2d25802b2c26ee58a7b23faeccf78a396094c13dced0d0182526" -dependencies = [ - "phf_shared 0.8.0", - "rand 0.7.3", -] - -[[package]] -name = "phf_generator" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d5285893bb5eb82e6aaf5d59ee909a06a16737a8970984dd7746ba9283498d6" -dependencies = [ - "phf_shared 0.10.0", - "rand 0.8.5", -] - -[[package]] -name = "phf_generator" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48e4cc64c2ad9ebe670cb8fd69dd50ae301650392e81c05f9bfcb2d5bdbc24b0" -dependencies = [ - "phf_shared 0.11.3", - "rand 0.8.5", -] - -[[package]] -name = "phf_generator" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "135ace3a761e564ec88c03a77317a7c6b80bb7f7135ef2544dbe054243b89737" -dependencies = [ - "fastrand 2.3.0", - "phf_shared 0.13.1", -] - -[[package]] -name = "phf_macros" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58fdf3184dd560f160dd73922bea2d5cd6e8f064bf4b13110abd81b03697b4e0" -dependencies = [ - "phf_generator 0.10.0", - "phf_shared 0.10.0", - "proc-macro-hack", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "phf_macros" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3444646e286606587e49f3bcf1679b8cef1dc2c5ecc29ddacaffc305180d464b" -dependencies = [ - "phf_generator 0.11.2", - "phf_shared 0.11.3", - "proc-macro2", - "quote", - "syn 2.0.117", -] - -[[package]] -name = "phf_macros" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "812f032b54b1e759ccd5f8b6677695d5268c588701effba24601f6932f8269ef" -dependencies = [ - "phf_generator 0.13.1", - "phf_shared 0.13.1", - "proc-macro2", - "quote", - "syn 2.0.117", -] - -[[package]] -name = "phf_shared" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c00cf8b9eafe68dde5e9eaa2cef8ee84a9336a47d566ec55ca16589633b65af7" -dependencies = [ - "siphasher 0.3.11", -] - -[[package]] -name = "phf_shared" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6796ad771acdc0123d2a88dc428b5e38ef24456743ddb1744ed628f9815c096" -dependencies = [ - "siphasher 0.3.11", -] - -[[package]] -name = "phf_shared" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67eabc2ef2a60eb7faa00097bd1ffdb5bd28e62bf39990626a582201b7a754e5" -dependencies = [ - "siphasher 1.0.1", -] - -[[package]] -name = "phf_shared" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e57fef6bc5981e38c2ce2d63bfa546861309f875b8a75f092d1d54ae2d64f266" -dependencies = [ - "siphasher 1.0.1", -] - [[package]] name = "pin-project" version = "1.1.4" @@ -8699,17 +6401,6 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" -[[package]] -name = "piper" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96c8c490f422ef9a4efd2cb5b42b76c8613d7e7dfc1caf667b8a3350a5acc066" -dependencies = [ - "atomic-waker", - "fastrand 2.3.0", - "futures-io", -] - [[package]] name = "pkcs1" version = "0.7.5" @@ -8737,19 +6428,6 @@ version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" -[[package]] -name = "plist" -version = "1.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42cf17e9a1800f5f396bc67d193dc9411b59012a5876445ef450d449881e1016" -dependencies = [ - "base64 0.22.1", - "indexmap 2.13.0", - "quick-xml 0.32.0", - "serde", - "time", -] - [[package]] name = "png" version = "0.17.16" @@ -8763,34 +6441,6 @@ dependencies = [ "miniz_oxide", ] -[[package]] -name = "png" -version = "0.18.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60769b8b31b2a9f263dae2776c37b1b28ae246943cf719eb6946a1db05128a61" -dependencies = [ - "bitflags 2.11.0", - "crc32fast", - "fdeflate", - "flate2", - "miniz_oxide", -] - -[[package]] -name = "polling" -version = "3.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a604568c3202727d1507653cb121dbd627a58684eb09a820fd746bee38b4442f" -dependencies = [ - "cfg-if", - "concurrent-queue", - "hermit-abi 0.4.0", - "pin-project-lite", - "rustix 0.38.44", - "tracing", - "windows-sys 0.59.0", -] - [[package]] name = "portable-atomic" version = "1.11.1" @@ -8818,12 +6468,6 @@ version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" -[[package]] -name = "precomputed-hash" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" - [[package]] name = "predicates" version = "3.1.0" @@ -8850,16 +6494,6 @@ dependencies = [ "termtree", ] -[[package]] -name = "pretty_assertions" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ae130e2f271fbc2ac3a40fb1d07180839cdbbe443c7a27e1e3c13c5cac0116d" -dependencies = [ - "diff", - "yansi", -] - [[package]] name = "pretty_env_logger" version = "0.4.0" @@ -8917,67 +6551,6 @@ dependencies = [ "toml_edit 0.20.7", ] -[[package]] -name = "proc-macro-crate" -version = "3.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e67ba7e9b2b56446f1d419b1d807906278ffa1a658a8a5d8a39dcb1f5a78614f" -dependencies = [ - "toml_edit 0.25.5+spec-1.1.0", -] - -[[package]] -name = "proc-macro-error" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" -dependencies = [ - "proc-macro-error-attr", - "proc-macro2", - "quote", - "syn 1.0.109", - "version_check", -] - -[[package]] -name = "proc-macro-error-attr" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" -dependencies = [ - "proc-macro2", - "quote", - "version_check", -] - -[[package]] -name = "proc-macro-error-attr2" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96de42df36bb9bba5542fe9f1a054b8cc87e172759a1868aa05c1f3acc89dfc5" -dependencies = [ - "proc-macro2", - "quote", -] - -[[package]] -name = "proc-macro-error2" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11ec05c52be0a07b08061f7dd003e7d7092e0472bc731b4af7bb1ef876109802" -dependencies = [ - "proc-macro-error-attr2", - "proc-macro2", - "quote", - "syn 2.0.117", -] - -[[package]] -name = "proc-macro-hack" -version = "0.5.20+deprecated" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068" - [[package]] name = "proc-macro2" version = "1.0.106" @@ -9044,26 +6617,6 @@ dependencies = [ "cc", ] -[[package]] -name = "ptr_meta" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0738ccf7ea06b608c10564b31debd4f5bc5e197fc8bfe088f68ae5ce81e7a4f1" -dependencies = [ - "ptr_meta_derive", -] - -[[package]] -name = "ptr_meta_derive" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16b845dbfca988fa33db069c0e230574d15a3088f147a87b64c7589eb662c9ac" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "publicsuffix" version = "2.3.0" @@ -9257,12 +6810,6 @@ dependencies = [ "redis 0.20.2", ] -[[package]] -name = "radium" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" - [[package]] name = "rand" version = "0.4.6" @@ -9287,7 +6834,6 @@ dependencies = [ "rand_chacha 0.2.2", "rand_core 0.5.1", "rand_hc", - "rand_pcg", ] [[package]] @@ -9409,15 +6955,6 @@ dependencies = [ "rand_core 0.5.1", ] -[[package]] -name = "rand_pcg" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16abd0c1b639e9eb4d7c50c0b8100b0d0f849be2349829c740fe8e6eb4816429" -dependencies = [ - "rand_core 0.5.1", -] - [[package]] name = "rav1e" version = "0.7.1" @@ -9477,12 +7014,6 @@ dependencies = [ "bitflags 2.11.0", ] -[[package]] -name = "raw-window-handle" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20675572f6f24e9e76ef639bc5552774ed45f1c30e2951e1e99c59888861c539" - [[package]] name = "rayon" version = "1.10.0" @@ -9518,17 +7049,6 @@ dependencies = [ "rand_core 0.3.1", ] -[[package]] -name = "read-progress-stream" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6435842fc2fea44b528719eb8c32203bbc1bb2f5b619fbe0c0a3d8350fd8d2a8" -dependencies = [ - "bytes", - "futures 0.3.32", - "pin-project-lite", -] - [[package]] name = "redis" version = "0.20.2" @@ -9537,7 +7057,7 @@ checksum = "d4f0ceb2ec0dd769483ecd283f6615aa83dcd0be556d5294c6e659caefe7cc54" dependencies = [ "async-trait", "combine", - "dtoa 0.4.8", + "dtoa", "itoa 0.4.8", "percent-encoding", "sha1 0.6.1", @@ -9645,17 +7165,6 @@ dependencies = [ "bitflags 2.11.0", ] -[[package]] -name = "redox_users" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd6f9d3d47bdd2ad6945c5015a226ec6155d0bcdfd8f7cd29f86b71f8de99d2b" -dependencies = [ - "getrandom 0.2.14", - "libredox", - "thiserror 2.0.18", -] - [[package]] name = "regex" version = "1.12.3" @@ -9700,15 +7209,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "rend" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71fe3824f5629716b1589be05dacd749f6aa084c87e00e016714a8cdfccc997c" -dependencies = [ - "bytecheck", -] - [[package]] name = "reqwest" version = "0.11.27" @@ -9749,7 +7249,7 @@ dependencies = [ "wasm-bindgen-futures", "web-sys", "webpki-roots 0.25.3", - "winreg 0.50.0", + "winreg", ] [[package]] @@ -9762,7 +7262,7 @@ dependencies = [ "base64 0.22.1", "bytes", "cookie 0.18.1", - "cookie_store 0.21.1", + "cookie_store", "encoding_rs", "futures-channel", "futures-core", @@ -9773,25 +7273,21 @@ dependencies = [ "http-body-util", "hyper 1.6.0", "hyper-rustls 0.27.3", - "hyper-tls", "hyper-util", "js-sys", "log", "mime", "mime_guess", - "native-tls", "percent-encoding", "pin-project-lite", "quinn", "rustls 0.23.36", - "rustls-native-certs 0.8.0", "rustls-pki-types", "serde", "serde_json", "serde_urlencoded", "sync_wrapper 1.0.2", "tokio", - "tokio-native-tls", "tokio-rustls 0.26.0", "tokio-util", "tower 0.5.3", @@ -9800,7 +7296,7 @@ dependencies = [ "url", "wasm-bindgen", "wasm-bindgen-futures", - "wasm-streams 0.4.0", + "wasm-streams", "web-sys", "webpki-roots 1.0.2", ] @@ -9814,7 +7310,6 @@ dependencies = [ "base64 0.22.1", "bytes", "futures-core", - "futures-util", "h2 0.4.5", "http 1.3.1", "http-body 1.0.1", @@ -9836,14 +7331,12 @@ dependencies = [ "sync_wrapper 1.0.2", "tokio", "tokio-rustls 0.26.0", - "tokio-util", "tower 0.5.3", "tower-http", "tower-service", "url", "wasm-bindgen", "wasm-bindgen-futures", - "wasm-streams 0.5.0", "web-sys", ] @@ -9887,30 +7380,6 @@ dependencies = [ "subtle", ] -[[package]] -name = "rfd" -version = "0.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a15ad77d9e70a92437d8f74c35d99b4e4691128df018833e99f90bcd36152672" -dependencies = [ - "block2 0.6.1", - "dispatch2", - "glib-sys", - "gobject-sys", - "gtk-sys", - "js-sys", - "log", - "objc2 0.6.4", - "objc2-app-kit", - "objc2-core-foundation", - "objc2-foundation 0.3.1", - "raw-window-handle", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", - "windows-sys 0.60.2", -] - [[package]] name = "rgb" version = "0.8.50" @@ -9932,35 +7401,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "rkyv" -version = "0.7.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9008cd6385b9e161d8229e1f6549dd23c3d022f132a2ea37ac3a10ac4935779b" -dependencies = [ - "bitvec", - "bytecheck", - "bytes", - "hashbrown 0.12.3", - "ptr_meta", - "rend", - "rkyv_derive", - "seahash", - "tinyvec", - "uuid 1.22.0", -] - -[[package]] -name = "rkyv_derive" -version = "0.7.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "503d1d27590a2b0a3a4ca4c94755aa2875657196ecbf401a42eff41d7de532c0" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "rodio" version = "0.20.1" @@ -10121,22 +7561,6 @@ dependencies = [ "url", ] -[[package]] -name = "rust_decimal" -version = "1.36.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b082d80e3e3cc52b2ed634388d436fe1f4de6af5786cc2de9ba9737527bdf555" -dependencies = [ - "arrayvec", - "borsh", - "bytes", - "num-traits", - "rand 0.8.5", - "rkyv", - "serde", - "serde_json", -] - [[package]] name = "rustc-hash" version = "2.1.1" @@ -10161,19 +7585,6 @@ dependencies = [ "semver 1.0.23", ] -[[package]] -name = "rustix" -version = "0.38.44" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" -dependencies = [ - "bitflags 2.11.0", - "errno", - "libc", - "linux-raw-sys 0.4.14", - "windows-sys 0.59.0", -] - [[package]] name = "rustix" version = "1.1.4" @@ -10183,7 +7594,7 @@ dependencies = [ "bitflags 2.11.0", "errno", "libc", - "linux-raw-sys 0.12.1", + "linux-raw-sys", "windows-sys 0.61.2", ] @@ -10235,7 +7646,7 @@ version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a9aace74cb666635c918e9c12bc0d348266037aa8eb599b5cba565709a8dff00" dependencies = [ - "openssl-probe 0.1.5", + "openssl-probe", "rustls-pemfile 1.0.4", "schannel", "security-framework 2.10.0", @@ -10247,7 +7658,7 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fcaf18a4f2be7326cd874a5fa579fae794320a0f388d365dca7e480e55f83f8a" dependencies = [ - "openssl-probe 0.1.5", + "openssl-probe", "rustls-pemfile 2.1.2", "rustls-pki-types", "schannel", @@ -10410,40 +7821,13 @@ dependencies = [ "parking_lot 0.12.5", ] -[[package]] -name = "schemars" -version = "0.8.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09c024468a378b7e36765cd36702b7a90cc3cba11654f6685c8f233408e89e92" -dependencies = [ - "dyn-clone", - "indexmap 1.9.3", - "schemars_derive", - "serde", - "serde_json", - "url", - "uuid 1.22.0", -] - -[[package]] -name = "schemars_derive" -version = "0.8.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1eee588578aff73f856ab961cd2f79e36bc45d7ded33a7562adba4667aecc0e" -dependencies = [ - "proc-macro2", - "quote", - "serde_derive_internals", - "syn 2.0.117", -] - [[package]] name = "schnellru" version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "356285bbf17bea63d9e52e96bd18f039672ac92b55b8cb997d6162a2a37d1649" dependencies = [ - "ahash 0.8.12", + "ahash", "cfg-if", "hashbrown 0.13.2", ] @@ -10454,21 +7838,6 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" -[[package]] -name = "scraper" -version = "0.24.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5f3a24d916e78954af99281a455168d4a9515d65eca99a18da1b813689c4ad9" -dependencies = [ - "cssparser 0.35.0", - "ego-tree", - "getopts", - "html5ever 0.35.0", - "precomputed-hash", - "selectors 0.31.0", - "tendril 0.4.3", -] - [[package]] name = "sct" version = "0.7.1" @@ -10485,12 +7854,6 @@ version = "3.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "584e070911c7017da6cb2eb0788d09f43d789029b5877d3e5ecc8acf86ceee21" -[[package]] -name = "seahash" -version = "4.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b" - [[package]] name = "sec1" version = "0.7.3" @@ -10577,81 +7940,6 @@ dependencies = [ "workspace-build-acceleration", ] -[[package]] -name = "selectors" -version = "0.24.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c37578180969d00692904465fb7f6b3d50b9a2b952b87c23d0e2e5cb5013416" -dependencies = [ - "bitflags 1.3.2", - "cssparser 0.29.6", - "derive_more 0.99.17", - "fxhash", - "log", - "phf 0.8.0", - "phf_codegen 0.8.0", - "precomputed-hash", - "servo_arc 0.2.0", - "smallvec", -] - -[[package]] -name = "selectors" -version = "0.30.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3df44ba8a7ca7a4d28c589e04f526266ed76b6cc556e33fe69fa25de31939a65" -dependencies = [ - "bitflags 2.11.0", - "cssparser 0.35.0", - "derive_more 2.0.1", - "fxhash", - "log", - "new_debug_unreachable", - "phf 0.11.2", - "phf_codegen 0.11.3", - "precomputed-hash", - "servo_arc 0.4.3", - "smallvec", -] - -[[package]] -name = "selectors" -version = "0.31.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5685b6ae43bfcf7d2e7dfcfb5d8e8f61b46442c902531e41a32a9a8bf0ee0fb6" -dependencies = [ - "bitflags 2.11.0", - "cssparser 0.35.0", - "derive_more 2.0.1", - "fxhash", - "log", - "new_debug_unreachable", - "phf 0.11.2", - "phf_codegen 0.11.3", - "precomputed-hash", - "servo_arc 0.4.3", - "smallvec", -] - -[[package]] -name = "selectors" -version = "0.36.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5d9c0c92a92d33f08817311cf3f2c29a3538a8240e94a6a3c622ce652d7e00c" -dependencies = [ - "bitflags 2.11.0", - "cssparser 0.36.0", - "derive_more 2.0.1", - "log", - "new_debug_unreachable", - "phf 0.13.1", - "phf_codegen 0.13.1", - "precomputed-hash", - "rustc-hash", - "servo_arc 0.4.3", - "smallvec", -] - [[package]] name = "semver" version = "0.9.0" @@ -10666,9 +7954,6 @@ name = "semver" version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" -dependencies = [ - "serde", -] [[package]] name = "semver-parser" @@ -10686,27 +7971,6 @@ dependencies = [ "serde_derive", ] -[[package]] -name = "serde-untagged" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2676ba99bd82f75cae5cbd2c8eda6fa0b8760f18978ea840e980dd5567b5c5b6" -dependencies = [ - "erased-serde", - "serde", - "typeid", -] - -[[package]] -name = "serde-value" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3a1a3341211875ef120e117ea7fd5228530ae7e7036a779fdc9117be6b3282c" -dependencies = [ - "ordered-float 2.10.1", - "serde", -] - [[package]] name = "serde_core" version = "1.0.228" @@ -10727,17 +7991,6 @@ dependencies = [ "syn 2.0.117", ] -[[package]] -name = "serde_derive_internals" -version = "0.29.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.117", -] - [[package]] name = "serde_html_form" version = "0.4.0" @@ -10817,17 +8070,6 @@ dependencies = [ "thiserror 1.0.63", ] -[[package]] -name = "serde_repr" -version = "0.1.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.117", -] - [[package]] name = "serde_spanned" version = "0.6.9" @@ -10865,25 +8107,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "678b5a069e50bf00ecd22d0cd8ddf7c236f68581b03db652061ed5eb13a312ff" dependencies = [ "serde", - "serde_with_macros 1.5.2", -] - -[[package]] -name = "serde_with" -version = "3.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6b6f7f2fcb69f747921f79f3926bd1e203fce4fef62c268dd3abfb6d86029aa" -dependencies = [ - "base64 0.22.1", - "chrono", - "hex", - "indexmap 1.9.3", - "indexmap 2.13.0", - "serde", - "serde_derive", - "serde_json", - "serde_with_macros 3.12.0", - "time", + "serde_with_macros", ] [[package]] @@ -10898,18 +8122,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "serde_with_macros" -version = "3.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d00caa5193a3c8362ac2b73be6b9e768aa5a4b2f721d8f4b339600c3cb51f8e" -dependencies = [ - "darling 0.20.10", - "proc-macro2", - "quote", - "syn 2.0.117", -] - [[package]] name = "serde_yaml" version = "0.9.34+deprecated" @@ -10948,28 +8160,6 @@ dependencies = [ "syn 2.0.117", ] -[[package]] -name = "serialize-to-javascript" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04f3666a07a197cdb77cdf306c32be9b7f598d7060d50cfd4d5aa04bfd92f6c5" -dependencies = [ - "serde", - "serde_json", - "serialize-to-javascript-impl", -] - -[[package]] -name = "serialize-to-javascript-impl" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "772ee033c0916d670af7860b6e1ef7d658a4629a6d0b4c8c3e67f09b3765b75d" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.117", -] - [[package]] name = "server_environment" version = "0.0.1" @@ -10977,25 +8167,6 @@ dependencies = [ "workspace-build-acceleration", ] -[[package]] -name = "servo_arc" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d52aa42f8fdf0fed91e5ce7f23d8138441002fa31dca008acf47e6fd4721f741" -dependencies = [ - "nodrop", - "stable_deref_trait", -] - -[[package]] -name = "servo_arc" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "170fb83ab34de17dc69aa7c67482b22218ddb85da56546f9bd6b929e32a05930" -dependencies = [ - "stable_deref_trait", -] - [[package]] name = "sha1" version = "0.6.1" @@ -11139,24 +8310,6 @@ dependencies = [ "quote", ] -[[package]] -name = "simdutf8" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3a9fe34e3e7a50316060351f37187a3f546bce95496156754b601a5fa71b76e" - -[[package]] -name = "siphasher" -version = "0.3.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" - -[[package]] -name = "siphasher" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56199f7ddabf13fe5074ce809e7d3f42b42ae711800501b5b16ea82ad029c39d" - [[package]] name = "slab" version = "0.4.9" @@ -11222,54 +8375,6 @@ dependencies = [ "windows-sys 0.60.2", ] -[[package]] -name = "softbuffer" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18051cdd562e792cad055119e0cdb2cfc137e44e3987532e0f9659a77931bb08" -dependencies = [ - "bytemuck", - "cfg_aliases", - "core-graphics 0.24.0", - "foreign-types 0.5.0", - "js-sys", - "log", - "objc2 0.5.2", - "objc2-foundation 0.2.2", - "objc2-quartz-core 0.2.2", - "raw-window-handle", - "redox_syscall 0.5.2", - "wasm-bindgen", - "web-sys", - "windows-sys 0.59.0", -] - -[[package]] -name = "soup3" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "471f924a40f31251afc77450e781cb26d55c0b650842efafc9c6cbd2f7cc4f9f" -dependencies = [ - "futures-channel", - "gio", - "glib", - "libc", - "soup3-sys", -] - -[[package]] -name = "soup3-sys" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ebe8950a680a12f24f15ebe1bf70db7af98ad242d9db43596ad3108aab86c27" -dependencies = [ - "gio-sys", - "glib-sys", - "gobject-sys", - "libc", - "system-deps", -] - [[package]] name = "speculoos" version = "0.11.0" @@ -11324,26 +8429,6 @@ dependencies = [ "unicode_categories", ] -[[package]] -name = "sqlite_tasks" -version = "0.0.1" -dependencies = [ - "anyhow", - "chrono", - "enums", - "errors", - "log", - "once_cell", - "regex", - "serde", - "serde_derive", - "serde_json", - "sqlx", - "tempfile", - "tokens", - "workspace-build-acceleration", -] - [[package]] name = "sqlx" version = "0.7.4" @@ -11363,7 +8448,7 @@ version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24ba59a9342a3d9bab6c56c118be528b27c9b60e490080e9711a04dccac83ef6" dependencies = [ - "ahash 0.8.12", + "ahash", "atoi", "bigdecimal", "byteorder", @@ -11372,7 +8457,7 @@ dependencies = [ "crc", "crossbeam-queue", "either", - "event-listener 2.5.3", + "event-listener", "futures-channel", "futures-core", "futures-intrusive", @@ -11726,55 +8811,6 @@ dependencies = [ "workspace-build-acceleration", ] -[[package]] -name = "string_cache" -version = "0.8.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf776ba3fa74f83bf4b63c3dcbbf82173db2632ed8452cb2d891d33f459de70f" -dependencies = [ - "new_debug_unreachable", - "parking_lot 0.12.5", - "phf_shared 0.11.3", - "precomputed-hash", - "serde", -] - -[[package]] -name = "string_cache" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a18596f8c785a729f2819c0f6a7eae6ebeebdfffbfe4214ae6b087f690e31901" -dependencies = [ - "new_debug_unreachable", - "parking_lot 0.12.5", - "phf_shared 0.13.1", - "precomputed-hash", -] - -[[package]] -name = "string_cache_codegen" -version = "0.5.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c711928715f1fe0fe509c53b43e993a9a557babc2d0a3567d0a3006f1ac931a0" -dependencies = [ - "phf_generator 0.11.2", - "phf_shared 0.11.3", - "proc-macro2", - "quote", -] - -[[package]] -name = "string_cache_codegen" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "585635e46db231059f76c5849798146164652513eb9e8ab2685939dd90f29b69" -dependencies = [ - "phf_generator 0.13.1", - "phf_shared 0.13.1", - "proc-macro2", - "quote", -] - [[package]] name = "stringprep" version = "0.1.4" @@ -11889,18 +8925,7 @@ dependencies = [ "serde_json", "tokens", "tokio", - "uuid 1.22.0", -] - -[[package]] -name = "swift-rs" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4057c98e2e852d51fdcfca832aac7b571f6b351ad159f9eda5db1655f8d0c4d7" -dependencies = [ - "base64 0.21.7", - "serde", - "serde_json", + "uuid", ] [[package]] @@ -12327,428 +9352,12 @@ dependencies = [ "version-compare", ] -[[package]] -name = "tao" -version = "0.35.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1c93047acf68669466a34690ac58cca7010bd1b201e1ec86f1fd0a75d3dd4a9" -dependencies = [ - "bitflags 2.11.0", - "block2 0.6.1", - "core-foundation 0.10.0", - "core-graphics 0.25.0", - "crossbeam-channel", - "dbus", - "dispatch2", - "dlopen2", - "dpi", - "gdkwayland-sys", - "gdkx11-sys", - "gtk", - "jni 0.21.1", - "libc", - "log", - "ndk 0.9.0", - "ndk-sys 0.6.0+11769913", - "objc2 0.6.4", - "objc2-app-kit", - "objc2-foundation 0.3.1", - "objc2-ui-kit", - "once_cell", - "parking_lot 0.12.5", - "percent-encoding", - "raw-window-handle", - "tao-macros", - "unicode-segmentation", - "url", - "windows 0.61.3", - "windows-core 0.61.2", - "windows-version", - "x11-dl", -] - -[[package]] -name = "tao-macros" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4e16beb8b2ac17db28eab8bca40e62dbfbb34c0fcdc6d9826b11b7b5d047dfd" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.117", -] - -[[package]] -name = "tap" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" - [[package]] name = "target-lexicon" version = "0.12.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1fc403891a21bcfb7c37834ba66a547a8f402146eba7265b5a6d88059c9ff2f" -[[package]] -name = "tauri" -version = "2.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "437404997acf375d85f1177afa7e11bb971f274ed6a7b83a2a3e339015f4cc28" -dependencies = [ - "anyhow", - "bytes", - "cookie 0.18.1", - "dirs", - "dunce", - "embed_plist", - "getrandom 0.3.1", - "glob", - "gtk", - "heck 0.5.0", - "http 1.3.1", - "http-range", - "jni 0.21.1", - "libc", - "log", - "mime", - "muda", - "objc2 0.6.4", - "objc2-app-kit", - "objc2-foundation 0.3.1", - "objc2-ui-kit", - "objc2-web-kit", - "percent-encoding", - "plist", - "raw-window-handle", - "reqwest 0.13.2", - "serde", - "serde_json", - "serde_repr", - "serialize-to-javascript", - "swift-rs", - "tauri-build", - "tauri-macros", - "tauri-runtime", - "tauri-runtime-wry", - "tauri-utils", - "thiserror 2.0.18", - "tokio", - "tray-icon", - "url", - "webkit2gtk", - "webview2-com", - "window-vibrancy", - "windows 0.61.3", -] - -[[package]] -name = "tauri-build" -version = "2.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4aa1f9055fc23919a54e4e125052bed16ed04aef0487086e758fe01a67b451c7" -dependencies = [ - "anyhow", - "cargo_toml", - "dirs", - "glob", - "heck 0.5.0", - "json-patch", - "schemars", - "semver 1.0.23", - "serde", - "serde_json", - "tauri-utils", - "tauri-winres", - "walkdir", -] - -[[package]] -name = "tauri-codegen" -version = "2.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4a0319528a025a38c4078e7dae2c446f4e63620ddb0659a643ede1cb38f90e9" -dependencies = [ - "base64 0.22.1", - "brotli", - "ico", - "json-patch", - "plist", - "png 0.17.16", - "proc-macro2", - "quote", - "semver 1.0.23", - "serde", - "serde_json", - "sha2 0.10.8", - "syn 2.0.117", - "tauri-utils", - "thiserror 2.0.18", - "time", - "url", - "uuid 1.22.0", - "walkdir", -] - -[[package]] -name = "tauri-macros" -version = "2.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae6cb4e3896c21d2f6da5b31251d2faea0153bba56ed0e970f918115dbee4924" -dependencies = [ - "heck 0.5.0", - "proc-macro2", - "quote", - "syn 2.0.117", - "tauri-codegen", - "tauri-utils", -] - -[[package]] -name = "tauri-plugin" -version = "2.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e126abc9e84e35cdfd01596140a73a1850cdb0df0a23acf0185776c30b469a6e" -dependencies = [ - "anyhow", - "glob", - "plist", - "schemars", - "serde", - "serde_json", - "tauri-utils", - "walkdir", -] - -[[package]] -name = "tauri-plugin-dialog" -version = "2.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65981abb771e74e571a38196c3baa11c459379164791eba0e67abc1a5fac9884" -dependencies = [ - "log", - "raw-window-handle", - "rfd", - "serde", - "serde_json", - "tauri", - "tauri-plugin", - "tauri-plugin-fs", - "thiserror 2.0.18", - "url", -] - -[[package]] -name = "tauri-plugin-fs" -version = "2.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7ecc274121aca0c036a2b42d1cbe83d368d348f54e0bb8a735c2b1548e8f371" -dependencies = [ - "anyhow", - "dunce", - "glob", - "log", - "objc2-foundation 0.3.1", - "percent-encoding", - "schemars", - "serde", - "serde_json", - "serde_repr", - "tauri", - "tauri-plugin", - "tauri-utils", - "thiserror 2.0.18", - "toml 1.0.7+spec-1.1.0", - "url", -] - -[[package]] -name = "tauri-plugin-http" -version = "2.4.3" -dependencies = [ - "bytes", - "cookie_store 0.21.1", - "data-url", - "http 1.3.1", - "regex", - "reqwest 0.12.23", - "schemars", - "serde", - "serde_json", - "tauri", - "tauri-plugin", - "tauri-plugin-fs", - "thiserror 2.0.18", - "tokio", - "tracing", - "url", - "urlpattern", -] - -[[package]] -name = "tauri-plugin-log" -version = "2.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7545bd67f070a4500432c826e2e0682146a1d6712aee22a2786490156b574d93" -dependencies = [ - "android_logger", - "byte-unit", - "fern", - "log", - "objc2 0.6.4", - "objc2-foundation 0.3.1", - "serde", - "serde_json", - "serde_repr", - "swift-rs", - "tauri", - "tauri-plugin", - "thiserror 2.0.18", - "time", -] - -[[package]] -name = "tauri-plugin-opener" -version = "2.5.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17e1bea14edce6b793a04e2417e3fd924b9bc4faae83cdee7d714156cceeed29" -dependencies = [ - "dunce", - "glob", - "objc2-app-kit", - "objc2-foundation 0.3.1", - "open", - "schemars", - "serde", - "serde_json", - "tauri", - "tauri-plugin", - "thiserror 2.0.18", - "url", - "windows 0.61.3", - "zbus", -] - -[[package]] -name = "tauri-plugin-upload" -version = "2.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e2844560c33b360506cea7289626267f43be253a01018b53bd556e86163b9fd" -dependencies = [ - "futures-util", - "log", - "read-progress-stream", - "reqwest 0.12.23", - "serde", - "serde_json", - "tauri", - "tauri-plugin", - "thiserror 2.0.18", - "tokio", - "tokio-util", -] - -[[package]] -name = "tauri-runtime" -version = "2.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48222d7116c8807eaa6fe2f372e023fae125084e61e6eca6d70b7961cdf129ef" -dependencies = [ - "cookie 0.18.1", - "dpi", - "gtk", - "http 1.3.1", - "jni 0.21.1", - "objc2 0.6.4", - "objc2-ui-kit", - "objc2-web-kit", - "raw-window-handle", - "serde", - "serde_json", - "tauri-utils", - "thiserror 2.0.18", - "url", - "webkit2gtk", - "webview2-com", - "windows 0.61.3", -] - -[[package]] -name = "tauri-runtime-wry" -version = "2.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b83849ee63ecb27a8e8d0fe51915ca215076914aca43f96db1179f0f415f6cd9" -dependencies = [ - "gtk", - "http 1.3.1", - "jni 0.21.1", - "log", - "objc2 0.6.4", - "objc2-app-kit", - "once_cell", - "percent-encoding", - "raw-window-handle", - "softbuffer", - "tao", - "tauri-runtime", - "tauri-utils", - "url", - "webkit2gtk", - "webview2-com", - "windows 0.61.3", - "wry", -] - -[[package]] -name = "tauri-utils" -version = "2.9.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "092379df9a707631978e6c56b1bc2401d387f01e2d4a3c123360d167bbb9aa95" -dependencies = [ - "anyhow", - "brotli", - "cargo_metadata", - "ctor", - "dom_query 0.27.0", - "dunce", - "glob", - "html5ever 0.29.1", - "http 1.3.1", - "infer 0.19.0", - "json-patch", - "kuchikiki", - "log", - "memchr", - "phf 0.13.1", - "plist", - "proc-macro2", - "quote", - "regex", - "schemars", - "semver 1.0.23", - "serde", - "serde-untagged", - "serde_json", - "serde_with 3.12.0", - "swift-rs", - "thiserror 2.0.18", - "toml 1.0.7+spec-1.1.0", - "url", - "urlpattern", - "uuid 1.22.0", - "walkdir", -] - -[[package]] -name = "tauri-winres" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56eaa45f707bedf34d19312c26d350bc0f3c59a47e58e8adbeecdc850d2c13a0" -dependencies = [ - "embed-resource", - "toml 0.8.23", -] - [[package]] name = "tempdir" version = "0.3.7" @@ -12768,31 +9377,10 @@ dependencies = [ "fastrand 2.3.0", "getrandom 0.4.1", "once_cell", - "rustix 1.1.4", + "rustix", "windows-sys 0.61.2", ] -[[package]] -name = "tendril" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d24a120c5fc464a3458240ee02c299ebcb9d67b5249c8848b09d639dca8d7bb0" -dependencies = [ - "futf", - "mac", - "utf-8", -] - -[[package]] -name = "tendril" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4790fc369d5a530f4b544b094e31388b9b3a37c0f4652ade4505945f5660d24" -dependencies = [ - "new_debug_unreachable", - "utf-8", -] - [[package]] name = "termcolor" version = "1.4.1" @@ -12871,16 +9459,6 @@ dependencies = [ "syn 2.0.117", ] -[[package]] -name = "thread-id" -version = "5.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99043e46c5a15af379c06add30d9c93a6c0e8849de00d244c4a2c417da128d80" -dependencies = [ - "libc", - "windows-sys 0.59.0", -] - [[package]] name = "thumbnail_generator" version = "0.1.0" @@ -12922,9 +9500,7 @@ checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" dependencies = [ "deranged", "itoa 1.0.11", - "libc", "num-conv", - "num_threads", "powerfmt", "serde", "time-core", @@ -13046,16 +9622,6 @@ dependencies = [ "syn 2.0.117", ] -[[package]] -name = "tokio-native-tls" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" -dependencies = [ - "native-tls", - "tokio", -] - [[package]] name = "tokio-rustls" version = "0.24.1" @@ -13204,22 +9770,9 @@ dependencies = [ "serde", "serde_spanned 0.6.9", "toml_datetime 0.6.11", - "toml_write", "winnow 0.7.13", ] -[[package]] -name = "toml_edit" -version = "0.25.5+spec-1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ca1a40644a28bce036923f6a431df0b34236949d111cc07cb6dca830c9ef2e1" -dependencies = [ - "indexmap 2.13.0", - "toml_datetime 1.0.1+spec-1.1.0", - "toml_parser", - "winnow 1.0.0", -] - [[package]] name = "toml_parser" version = "1.0.10+spec-1.1.0" @@ -13229,12 +9782,6 @@ dependencies = [ "winnow 1.0.0", ] -[[package]] -name = "toml_write" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d99f8c9a7727884afe522e9bd5edbfc91a3312b36a77b5fb8926e4c31a41801" - [[package]] name = "toml_writer" version = "1.0.7+spec-1.1.0" @@ -13381,28 +9928,6 @@ dependencies = [ "once_cell", ] -[[package]] -name = "tray-icon" -version = "0.23.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15edbb0d80583e85ee8df283410038e17314df5cba30da2087a54a85216c0773" -dependencies = [ - "crossbeam-channel", - "dirs", - "libappindicator", - "muda", - "objc2 0.6.4", - "objc2-app-kit", - "objc2-core-foundation", - "objc2-core-graphics", - "objc2-foundation 0.3.1", - "once_cell", - "png 0.18.1", - "serde", - "thiserror 2.0.18", - "windows-sys 0.61.2", -] - [[package]] name = "trim-in-place" version = "0.1.7" @@ -13542,73 +10067,12 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0e13db2e0ccd5e14a544e8a246ba2312cd25223f616442d7f2cb0e3db614236e" -[[package]] -name = "typemap-ors" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a68c24b707f02dd18f1e4ccceb9d49f2058c2fb86384ef9972592904d7a28867" -dependencies = [ - "unsafe-any-ors", -] - [[package]] name = "typenum" version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" -[[package]] -name = "uds_windows" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89daebc3e6fd160ac4aa9fc8b3bf71e1f74fbf92367ae71fb83a037e8bf164b9" -dependencies = [ - "memoffset 0.9.0", - "tempfile", - "winapi", -] - -[[package]] -name = "unic-char-property" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8c57a407d9b6fa02b4795eb81c5b6652060a15a7903ea981f3d723e6c0be221" -dependencies = [ - "unic-char-range", -] - -[[package]] -name = "unic-char-range" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0398022d5f700414f6b899e10b8348231abf9173fa93144cbc1a43b9793c1fbc" - -[[package]] -name = "unic-common" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80d7ff825a6a654ee85a63e80f92f054f904f21e7d12da4e22f9834a4aaa35bc" - -[[package]] -name = "unic-ucd-ident" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e230a37c0381caa9219d67cf063aa3a375ffed5bf541a452db16e744bdab6987" -dependencies = [ - "unic-char-property", - "unic-char-range", - "unic-ucd-version", -] - -[[package]] -name = "unic-ucd-version" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96bd2f2237fe450fcd0a1d2f5f4e91711124f7857ba2e964247776ebeeb7b0c4" -dependencies = [ - "unic-common", -] - [[package]] name = "unicase" version = "2.8.1" @@ -13660,15 +10124,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39ec24b3121d976906ece63c9daad25b85969647682eee313cb5779fdd69e14e" -[[package]] -name = "unsafe-any-ors" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0a303d30665362d9680d7d91d78b23f5f899504d4f08b3c4cf08d055d87c0ad" -dependencies = [ - "destructure_traitobject", -] - [[package]] name = "unsafe-libyaml" version = "0.2.11" @@ -13725,18 +10180,6 @@ version = "2.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da" -[[package]] -name = "urlpattern" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70acd30e3aa1450bc2eece896ce2ad0d178e9c079493819301573dae3c37ba6d" -dependencies = [ - "regex", - "serde", - "unic-ucd-ident", - "url", -] - [[package]] name = "user-spend-analytics-job" version = "0.0.1" @@ -13810,12 +10253,6 @@ version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c8232dd3cdaed5356e0f716d285e4b40b932ac434100fe9b7e0e8e935b9e6246" -[[package]] -name = "utf8-width" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86bd8d4e895da8537e5315b8254664e6b769c4ff3db18321b297a1e7004392e3" - [[package]] name = "utf8_iter" version = "1.0.4" @@ -13871,15 +10308,6 @@ dependencies = [ "zip 3.0.0", ] -[[package]] -name = "uuid" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" -dependencies = [ - "getrandom 0.2.14", -] - [[package]] name = "uuid" version = "1.22.0" @@ -13888,7 +10316,6 @@ checksum = "a68d3c8f01c0cfa54a75291d83601161799e4a89a39e0929f4b0354d88757a37" dependencies = [ "getrandom 0.4.1", "js-sys", - "serde_core", "wasm-bindgen", ] @@ -13896,7 +10323,7 @@ dependencies = [ name = "uuid_utils" version = "0.0.1" dependencies = [ - "uuid 1.22.0", + "uuid", "workspace-build-acceleration", ] @@ -13911,12 +10338,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "value-bag" -version = "1.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ba6f5989077681266825251a52748b8c1d8a4ad098cc37e440103d0ea717fc0" - [[package]] name = "vcpkg" version = "0.2.15" @@ -14006,26 +10427,6 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" -[[package]] -name = "vswhom" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be979b7f07507105799e854203b470ff7c78a1639e330a58f183b5fea574608b" -dependencies = [ - "libc", - "vswhom-sys", -] - -[[package]] -name = "vswhom-sys" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3b17ae1f6c8a2b28506cd96d412eebf83b4a0ff2cbefeeb952f2f9dfa44ba18" -dependencies = [ - "cc", - "libc", -] - [[package]] name = "waker-fn" version = "1.1.1" @@ -14195,19 +10596,6 @@ dependencies = [ "web-sys", ] -[[package]] -name = "wasm-streams" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d1ec4f6517c9e11ae630e200b2b65d193279042e28edd4a2cda233e46670bbb" -dependencies = [ - "futures-util", - "js-sys", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", -] - [[package]] name = "wasmparser" version = "0.244.0" @@ -14240,82 +10628,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "web_atoms" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57ffde1dc01240bdf9992e3205668b235e59421fd085e8a317ed98da0178d414" -dependencies = [ - "phf 0.11.2", - "phf_codegen 0.11.3", - "string_cache 0.8.9", - "string_cache_codegen 0.5.4", -] - -[[package]] -name = "web_atoms" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7cff6eef815df1834fd250e3a2ff436044d82a9f1bc1980ca1dbdf07effc538" -dependencies = [ - "phf 0.13.1", - "phf_codegen 0.13.1", - "string_cache 0.9.0", - "string_cache_codegen 0.6.1", -] - -[[package]] -name = "web_base64" -version = "0.0.1" -dependencies = [ - "base64 0.22.1", - "workspace-build-acceleration", -] - -[[package]] -name = "webkit2gtk" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1027150013530fb2eaf806408df88461ae4815a45c541c8975e61d6f2fc4793" -dependencies = [ - "bitflags 1.3.2", - "cairo-rs", - "gdk", - "gdk-sys", - "gio", - "gio-sys", - "glib", - "glib-sys", - "gobject-sys", - "gtk", - "gtk-sys", - "javascriptcore-rs", - "libc", - "once_cell", - "soup3", - "webkit2gtk-sys", -] - -[[package]] -name = "webkit2gtk-sys" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "916a5f65c2ef0dfe12fff695960a2ec3d4565359fdbb2e9943c974e06c734ea5" -dependencies = [ - "bitflags 1.3.2", - "cairo-sys-rs", - "gdk-sys", - "gio-sys", - "glib-sys", - "gobject-sys", - "gtk-sys", - "javascriptcore-rs-sys", - "libc", - "pkg-config", - "soup3-sys", - "system-deps", -] - [[package]] name = "webpki-root-certs" version = "1.0.2" @@ -14349,42 +10661,6 @@ dependencies = [ "rustls-pki-types", ] -[[package]] -name = "webview2-com" -version = "0.38.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4ba622a989277ef3886dd5afb3e280e3dd6d974b766118950a08f8f678ad6a4" -dependencies = [ - "webview2-com-macros", - "webview2-com-sys", - "windows 0.61.3", - "windows-core 0.61.2", - "windows-implement", - "windows-interface", -] - -[[package]] -name = "webview2-com-macros" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d228f15bba3b9d56dde8bddbee66fa24545bd17b48d5128ccf4a8742b18e431" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.117", -] - -[[package]] -name = "webview2-com-sys" -version = "0.38.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36695906a1b53a3bf5c4289621efedac12b73eeb0b89e7e1a89b517302d5d75c" -dependencies = [ - "thiserror 2.0.18", - "windows 0.61.3", - "windows-core 0.61.2", -] - [[package]] name = "weezl" version = "0.1.8" @@ -14432,21 +10708,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -[[package]] -name = "window-vibrancy" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9bec5a31f3f9362f2258fd0e9c9dd61a9ca432e7306cc78c444258f0dce9a9c" -dependencies = [ - "objc2 0.6.4", - "objc2-app-kit", - "objc2-core-foundation", - "objc2-foundation 0.3.1", - "raw-window-handle", - "windows-sys 0.59.0", - "windows-version", -] - [[package]] name = "windows" version = "0.52.0" @@ -14467,28 +10728,6 @@ dependencies = [ "windows-targets 0.52.6", ] -[[package]] -name = "windows" -version = "0.61.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9babd3a767a4c1aef6900409f85f5d53ce2544ccdfaa86dad48c91782c6d6893" -dependencies = [ - "windows-collections", - "windows-core 0.61.2", - "windows-future", - "windows-link 0.1.3", - "windows-numerics", -] - -[[package]] -name = "windows-collections" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3beeceb5e5cfd9eb1d76b381630e82c4241ccd0d27f1a39ed41b2760b255c5e8" -dependencies = [ - "windows-core 0.61.2", -] - [[package]] name = "windows-core" version = "0.51.1" @@ -14517,52 +10756,6 @@ dependencies = [ "windows-targets 0.52.6", ] -[[package]] -name = "windows-core" -version = "0.61.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0fdd3ddb90610c7638aa2b3a3ab2904fb9e5cdbecc643ddb3647212781c4ae3" -dependencies = [ - "windows-implement", - "windows-interface", - "windows-link 0.1.3", - "windows-result 0.3.4", - "windows-strings", -] - -[[package]] -name = "windows-future" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc6a41e98427b19fe4b73c550f060b59fa592d7d686537eebf9385621bfbad8e" -dependencies = [ - "windows-core 0.61.2", - "windows-link 0.1.3", - "windows-threading", -] - -[[package]] -name = "windows-implement" -version = "0.60.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a47fddd13af08290e67f4acabf4b459f647552718f683a7b415d290ac744a836" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.117", -] - -[[package]] -name = "windows-interface" -version = "0.59.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd9211b69f8dcdfa817bfd14bf1c97c9188afa36f4750130fcdf3f400eca9fa8" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.117", -] - [[package]] name = "windows-link" version = "0.1.3" @@ -14575,16 +10768,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" -[[package]] -name = "windows-numerics" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9150af68066c4c5c07ddc0ce30421554771e528bde427614c61038bc2c92c2b1" -dependencies = [ - "windows-core 0.61.2", - "windows-link 0.1.3", -] - [[package]] name = "windows-registry" version = "0.5.2" @@ -14740,24 +10923,6 @@ dependencies = [ "windows_x86_64_msvc 0.53.0", ] -[[package]] -name = "windows-threading" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b66463ad2e0ea3bbf808b7f1d371311c80e115c0b71d60efc142cafbcfb057a6" -dependencies = [ - "windows-link 0.1.3", -] - -[[package]] -name = "windows-version" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c12476c23a74725c539b24eae8bfc0dac4029c39cdb561d9f23616accd4ae26d" -dependencies = [ - "windows-targets 0.53.3", -] - [[package]] name = "windows_aarch64_gnullvm" version = "0.42.2" @@ -14961,9 +11126,6 @@ name = "winnow" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a90e88e4667264a994d34e6d1ab2d26d398dcdca8b7f52bec8668957517fc7d8" -dependencies = [ - "memchr", -] [[package]] name = "winreg" @@ -14975,16 +11137,6 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "winreg" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a277a57398d4bfa075df44f501a17cfdf8542d224f0d36095a2adc7aee4ef0a5" -dependencies = [ - "cfg-if", - "windows-sys 0.48.0", -] - [[package]] name = "wit-bindgen" version = "0.51.0" @@ -15088,27 +11240,26 @@ version = "0.1.0" dependencies = [ "actix-router", "actix-rt", - "ahash 0.8.12", + "ahash", "anstream", "arrayvec", "async-compression", - "base64 0.21.7", + "async-stripe-shared", + "async-stripe-types", "base64 0.22.1", "base64ct", "bitflags 2.11.0", "block-buffer 0.9.0", "bytemuck", "byteorder", - "bytes", "cc", "chrono", "clap 4.5.60", + "combine", "cookie 0.18.1", - "core-foundation-sys", "crossbeam-utils", "crypto-common 0.1.6", "deranged", - "derive_more 0.99.17", "digest 0.10.7", "either", "flate2", @@ -15124,18 +11275,28 @@ dependencies = [ "generic-array", "getrandom 0.2.14", "getrandom 0.3.1", + "getrandom 0.4.1", "hashbrown 0.14.5", - "heck 0.4.1", + "hashbrown 0.16.1", "hmac 0.12.1", + "hyper 0.14.28", + "hyper 1.6.0", + "hyper-rustls 0.24.2", + "hyper-rustls 0.27.3", + "hyper-util", "idna 1.1.0", "indexmap 1.9.3", "indexmap 2.13.0", + "itertools 0.13.0", "lazy_static", "libc", "log", "md-5 0.10.6", "memchr", "mime_guess", + "miniz_oxide", + "mio", + "nom", "num-bigint", "num-integer", "num-iter", @@ -15145,52 +11306,57 @@ dependencies = [ "parking_lot 0.12.5", "percent-encoding", "proc-macro2", - "quick-xml 0.32.0", "quote", - "rand 0.7.3", "rand 0.8.5", "rand_chacha 0.3.1", "rand_core 0.6.4", "regex", "regex-automata", "regex-syntax", + "reqwest 0.12.23", "rsa", + "rustls 0.21.12", + "rustls 0.23.36", "rustls-pki-types", - "schemars", - "scopeguard", - "security-framework 2.10.0", - "semver 1.0.23", + "rustls-webpki 0.103.9", + "security-framework-sys", "serde", + "serde_core", "serde_json", "sha1 0.10.6", "sha2 0.10.8", + "simd-adler32", + "slab", "smallvec", "socket2 0.5.10", "spin 0.9.8", + "sqlx", + "sqlx-core", + "sqlx-macros", + "sqlx-macros-core", "sqlx-mysql", "sqlx-sqlite", - "stable_deref_trait", "subtle", "syn 1.0.109", "syn 2.0.117", - "tauri-build", - "tauri-utils", "time", "time-macros", "tokio", + "tokio-rustls 0.24.1", + "tokio-rustls 0.26.0", "tokio-stream", "tokio-util", - "toml_edit 0.19.15", + "tower-http", "tracing", + "typenum", "unicode-bidi", "unicode-normalization", "url", - "uuid 1.22.0", - "void", + "uuid", "winapi", "windows-sys 0.48.0", "windows-sys 0.52.0", - "windows-sys 0.59.0", + "windows-sys 0.61.2", "zeroize", "zstd 0.13.3", "zstd-safe 7.1.0", @@ -15244,56 +11410,18 @@ dependencies = [ "strum", "test_data", "tokio", - "uuid 1.22.0", + "uuid", "workspace-build-acceleration", "wreq", ] -[[package]] -name = "worldlabs_consumer_client" -version = "0.0.1" -dependencies = [ - "anyhow", - "base64 0.22.1", - "bstr", - "byteorder", - "chrono", - "cloudflare_errors", - "cloudflare_mitigation", - "cookie_store 0.0.1", - "env", - "env_logger 0.11.9", - "errors", - "filesys", - "futures 0.3.32", - "http_headers", - "indexmap 2.13.0", - "jwt_light", - "log", - "log4rs", - "once_cell", - "regex", - "scraper", - "serde", - "serde_json", - "sha2 0.11.0-rc.5", - "test_data", - "test_utils", - "tokio", - "url", - "uuid 1.22.0", - "workspace-build-acceleration", - "wreq", - "wreq-util", -] - [[package]] name = "wreq" version = "6.0.0-rc.28" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f79937f6c4df65b3f6f78715b9de2977afe9ee3b3436483c7949a24511e25935" dependencies = [ - "ahash 0.8.12", + "ahash", "boring2", "brotli", "bytes", @@ -15352,92 +11480,12 @@ version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51" -[[package]] -name = "wry" -version = "0.55.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "186f9871daa55fd9c016578b810d149de58367113db7fb72b462d2323ce19514" -dependencies = [ - "base64 0.22.1", - "block2 0.6.1", - "cookie 0.18.1", - "crossbeam-channel", - "dirs", - "dom_query 0.27.0", - "dpi", - "dunce", - "gdkx11", - "gtk", - "http 1.3.1", - "javascriptcore-rs", - "jni 0.21.1", - "libc", - "ndk 0.9.0", - "objc2 0.6.4", - "objc2-app-kit", - "objc2-core-foundation", - "objc2-foundation 0.3.1", - "objc2-ui-kit", - "objc2-web-kit", - "once_cell", - "percent-encoding", - "raw-window-handle", - "sha2 0.10.8", - "soup3", - "tao-macros", - "thiserror 2.0.18", - "url", - "webkit2gtk", - "webkit2gtk-sys", - "webview2-com", - "windows 0.61.3", - "windows-core 0.61.2", - "windows-version", - "x11-dl", -] - -[[package]] -name = "wyz" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" -dependencies = [ - "tap", -] - -[[package]] -name = "x11" -version = "2.21.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "502da5464ccd04011667b11c435cb992822c2c0dbde1770c988480d312a0db2e" -dependencies = [ - "libc", - "pkg-config", -] - -[[package]] -name = "x11-dl" -version = "2.21.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38735924fedd5314a6e548792904ed8c6de6636285cb9fec04d5b1db85c1516f" -dependencies = [ - "libc", - "once_cell", - "pkg-config", -] - [[package]] name = "xxhash-rust" version = "0.8.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fdd20c5420375476fbd4394763288da7eb0cc0b8c11deed431a91562af7335d3" -[[package]] -name = "yansi" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfe53a6657fd280eaa890a3bc59152892ffa3e30101319d168b781ed6529b049" - [[package]] name = "yoke" version = "0.7.5" @@ -15462,67 +11510,6 @@ dependencies = [ "synstructure", ] -[[package]] -name = "zbus" -version = "5.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eee682d202a77e4a9f3b2c2bdf48a7b28af5c08c34ddf66f98c93e5e39464285" -dependencies = [ - "async-broadcast", - "async-executor", - "async-io", - "async-lock", - "async-process", - "async-recursion", - "async-task", - "async-trait", - "blocking", - "enumflags2", - "event-listener 5.4.1", - "futures-core", - "futures-lite 2.6.0", - "hex", - "libc", - "ordered-stream", - "rustix 1.1.4", - "serde", - "serde_repr", - "tracing", - "uds_windows", - "uuid 1.22.0", - "windows-sys 0.61.2", - "winnow 1.0.0", - "zbus_macros", - "zbus_names", - "zvariant", -] - -[[package]] -name = "zbus_macros" -version = "5.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adf1bd45a81a103745b1757754762a26e8cd01e4532e4d6c8ec431624b80d1d6" -dependencies = [ - "proc-macro-crate 3.5.0", - "proc-macro2", - "quote", - "syn 2.0.117", - "zbus_names", - "zvariant", - "zvariant_utils", -] - -[[package]] -name = "zbus_names" -version = "4.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7074f3e50b894eac91750142016d30d0a89be8e67dbfd9704fb875825760e52d" -dependencies = [ - "serde", - "winnow 1.0.0", - "zvariant", -] - [[package]] name = "zerocopy" version = "0.8.27" @@ -15774,43 +11761,3 @@ checksum = "99a5bab8d7dedf81405c4bb1f2b83ea057643d9cb28778cea9eecddeedd2e028" dependencies = [ "zune-core", ] - -[[package]] -name = "zvariant" -version = "5.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a192a0bde63360d77a7523c833d4b4ce6070a927e2c53246e4c540b1a3e27be0" -dependencies = [ - "endi", - "enumflags2", - "serde", - "winnow 1.0.0", - "zvariant_derive", - "zvariant_utils", -] - -[[package]] -name = "zvariant_derive" -version = "5.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bc6cde9c01c511074be97f7ccb6c19d0da89e3f8662e812e999dcfd4638737" -dependencies = [ - "proc-macro-crate 3.5.0", - "proc-macro2", - "quote", - "syn 2.0.117", - "zvariant_utils", -] - -[[package]] -name = "zvariant_utils" -version = "3.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e8535915cfa75547e559d8c68e8139909a4aeee076831e4ef7fc59d8172c4d6" -dependencies = [ - "proc-macro2", - "quote", - "serde", - "syn 2.0.117", - "winnow 1.0.0", -] diff --git a/Cargo.toml b/Cargo.toml index b65f2548fa..d7d7241a03 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,19 +18,15 @@ members = [ "crates/api_clients/google_drive_downloader", "crates/api_clients/google_sign_in", "crates/api_clients/grok_api_client", - "crates/api_clients/grok_consumer_client", "crates/api_clients/gmicloud_client", - "crates/api_clients/midjourney_client", "crates/api_clients/muapi_client", "crates/api_clients/beeble_client", - "crates/api_clients/openai_sora_client", "crates/api_clients/openart_client", "crates/api_clients/rootly_client", "crates/api_clients/runwayml_client", "crates/api_clients/kinovi_web_client", "crates/api_clients/thumbnail_generator", "crates/api_clients/worldlabs_api_client", - "crates/api_clients/worldlabs_consumer_client", # CLI tools for operations, etc. "crates/cli/devenv/dev-database-seed", @@ -44,27 +40,19 @@ members = [ "crates/cli/production/migration-tool", "crates/cli/production/support-tool", - # Desktop apps - "crates/desktop/artcraft", - # Shared libraries "crates/lib/actix_artcraft", "crates/lib/actix_cors_configs", "crates/lib/actix_helpers", "crates/lib/bootstrap", - "crates/lib/build_metadata", "crates/lib/caching/memory_caching", - "crates/lib/caching/memory_store", "crates/lib/caching/redis_caching", "crates/lib/cloudflare_errors", - "crates/lib/cloudflare_mitigation", "crates/lib/concurrency", - "crates/lib/cookie_store", "crates/lib/data/collections", "crates/lib/data/crockford", "crates/lib/data/datetimes", "crates/lib/data/primitives", - "crates/lib/data/web_base64", "crates/lib/easyenv", # NB: Vendored version of https://github.com/echelon/easyenv.rs that we'll improve. "crates/lib/error_utils", "crates/lib/errors", @@ -123,7 +111,6 @@ members = [ "crates/schema/database/mysql_testing", "crates/schema/database/redis_common", "crates/schema/database/redis_schema", - "crates/schema/database/sqlite_tasks", #"crates/schema/database/sqlite_queries", # Schema (public): common strongly-typed tokens, ids, payloads, etc. @@ -167,7 +154,6 @@ members = [ # Vendored code "crates/vendor/limitation", - "crates/vendor/tauri-plugin-http", "crates/vendor/Symphonia/symphonia", "crates/vendor/Symphonia/symphonia-bundle-flac", "crates/vendor/Symphonia/symphonia-bundle-mp3", @@ -245,14 +231,11 @@ artcraft_router = { path = "crates/api_clients/artcraft/artcraft_router" } bootstrap = { path = "crates/lib/bootstrap" } bucket_client = { path = "crates/api_clients/bucket_client" } bucket_paths = { path = "crates/schema/buckets/bucket_paths" } -build_metadata = { path = "crates/lib/build_metadata" } cloud_storage = { path = "crates/api_clients/cloud_storage" } cloudflare_errors = { path = "crates/lib/cloudflare_errors" } -cloudflare_mitigation = { path = "crates/lib/cloudflare_mitigation" } collections = { path = "crates/lib/data/collections" } component_traits = { path = "crates/service/plugins/component_traits" } concurrency = { path = "crates/lib/concurrency" } -cookie_store = { path = "crates/lib/cookie_store" } crockford = { path = "crates/lib/data/crockford" } datadog_client = { path = "crates/api_clients/datadog_client" } easyenv = { path = "crates/lib/easyenv" } @@ -266,7 +249,6 @@ file_to_base64_url = { path = "crates/lib/files/file_to_base64_url" } filesys = { path = "crates/lib/files/filesys" } beeble_client = { path = "crates/api_clients/beeble_client" } grok_api_client = { path = "crates/api_clients/grok_api_client" } -grok_consumer_client = { path = "crates/api_clients/grok_consumer_client" } rootly_client = { path = "crates/api_clients/rootly_client" } rootly_config = { path = "crates/schema/config/rootly_config" } shared_env_var_config = { path = "crates/schema/config/shared_env_var_config" } @@ -277,21 +259,17 @@ jwt_light = { path = "crates/lib/jwt_light" } jwt_signer = { path = "crates/lib/jwt_signer" } opaque_cursors = { path = "crates/lib/opaque_cursors" } memory_caching = { path = "crates/lib/caching/memory_caching" } -memory_store = { path = "crates/lib/caching/memory_store" } -midjourney_client = { path = "crates/api_clients/midjourney_client" } mimetypes = { path = "crates/lib/files/mimetypes" } muapi_client = { path = "crates/api_clients/muapi_client" } metrics = { path = "crates/lib/metrics" } mysql_queries = { path = "crates/schema/database/mysql_queries" } mysql_testing = { path = "crates/schema/database/mysql_testing" } pager = { path = "crates/lib/pager" } -openai_sora_client = { path = "crates/api_clients/openai_sora_client" } primitives = { path = "crates/lib/data/primitives" } kinovi_web_client = { path = "crates/api_clients/kinovi_web_client" } server_environment = { path = "crates/lib/server_environment" } sha1_hash = { path = "crates/lib/sha1_hash" } shared_service_components = { path = "crates/lib/shared_service_components" } -sqlite_tasks = { path = "crates/schema/database/sqlite_tasks" } subprocess_common = { path = "crates/lib/deprecated/subprocess_common" } test_data = { path = "crates/testing/test_data" } test_utils = { path = "crates/testing/test_utils" } @@ -301,9 +279,7 @@ url_utils = { path = "crates/lib/url_utils" } users = { path = "crates/lib/users" } uuid_utils = { path = "crates/lib/uuid_utils" } video_info = { path = "crates/lib/video_info" } -web_base64 = { path = "crates/lib/data/web_base64" } worldlabs_api_client = { path = "crates/api_clients/worldlabs_api_client" } -worldlabs_consumer_client = { path = "crates/api_clients/worldlabs_consumer_client" } # External libs # Centrally pinned versions so that we can uniformly upgrade/downgrade versions across the workspace @@ -320,8 +296,6 @@ anyhow = "1.0.102" assertor = "0.0.3" base64 = "0.22.1" bcrypt = "0.15" -bstr = "1.12.1" -byteorder = "1.5.0" bytes = "1.11.1" chrono = { version = "0.4.44", features = ["serde"] } clap = { version = "=4.5.60", features = ["derive"] } @@ -333,7 +307,6 @@ env_logger = "0.11.9" futures = { version = "0.3.32" } hex-literal = "1.1.0" hostname = "0.4.0" -indexmap = "2.13.0" log = "0.4.29" md-5 = "0.10.6" # insecure but used for gravatar mockall = "0.12.1" @@ -355,11 +328,6 @@ sha2 = "0.11.0-rc.5" sha3 = "0.10.8" speculoos = "0.11.0" strum = { version = "0.28.0", features = ["derive"] } -tauri = { version = "2.11.2", features = ["unstable", "devtools", "protocol-asset"] } # NB: "devtools" prevents App Store distribution; "ubstable" is needed for window access -tauri-plugin-dialog = "2.7.1" -tauri-plugin-fs = "2.5.1" -tauri-plugin-log = "2.8.0" -tauri-plugin-upload = "2.4.0" tempdir = "0.3.7" tempfile = "3.27.0" thiserror = "2.0.18" diff --git a/README.md b/README.md index e0bcebad51..5943f2a8be 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,11 @@ This repository contains ArtCraft's backend, HTTP API, background workers, and web frontends. It is a Rust and TypeScript monorepo with shared API definitions, -provider clients, database queries, and development tooling. The checkout also -includes the Tauri desktop application and its shared frontend libraries. +provider clients, database queries, and development tooling. -For the product overview, feature demos, and desktop downloads, see -[storytold/artcraft](https://github.com/storytold/artcraft). +The Tauri desktop application is maintained in +[storytold/artcraft](https://github.com/storytold/artcraft), along with the product +overview, feature demos, and desktop downloads. ## Backend architecture @@ -53,7 +53,6 @@ Storage responsibilities are split across these components: | Redis | Caching, rate limiting, and job progress | | Elasticsearch | Search indexes and queries | | S3-compatible storage / R2 | Uploaded media, generated assets, and derived files | -| SQLite + SQLx | Local desktop task persistence | HTTP routes and handlers live in [`storyteller_web/src/http_server`](./crates/service/web/storyteller_web/src/http_server). @@ -99,24 +98,23 @@ Start with these sources when adding or tracing an endpoint: ## Frontend [`frontend`](./frontend) contains the Nx workspace for React and TypeScript apps -and shared libraries. The main web and desktop frontends use Vite, with Zustand +and shared libraries. The main web frontends use Vite, with Zustand and signals for state, Three.js for 3D scenes, and shared UI and generation tools. | Path | Purpose | |----------------------------------|-----------------------------------------------| | `frontend/apps/artcraft-webapp` | Browser application at `app.getartcraft.com` | | `frontend/apps/artcraft-website` | Product website at `getartcraft.com` | -| `frontend/apps/artcraft` | Frontend for the Tauri desktop application | | `frontend/libs/api` | HTTP clients, API host selection, and models | | `frontend/libs/omni-gen` | Shared generation logic | | `frontend/libs/components` | Reusable UI, editors, and generation controls | | `frontend/libs/tauri-api` | Frontend bindings for native desktop commands | -| `frontend/libs/tauri-events` | Desktop event integration | The web apps call the backend through the shared API library, which handles JSON -and multipart requests and session credentials. The desktop frontend also invokes -Rust commands and receives events through Tauri; the native application lives in -[`crates/desktop/artcraft`](./crates/desktop/artcraft). +and multipart requests and session credentials. Libraries such as `tauri-api` and +`tauri-utils` remain because shared web components still import their types, +helpers, and browser-compatible behavior. The native desktop app and libraries +used only by that app live in the separate desktop repository. ## Repository layout @@ -129,10 +127,9 @@ artcraft-services/ │ ├── api_clients/ # ArtCraft API types, clients, router, provider clients │ ├── schema/ # Database access, public tokens/enums, bucket paths │ ├── lib/ # Shared Rust utilities -│ ├── cli/ # Development and operations tools -│ └── desktop/artcraft/ # Tauri desktop application +│ └── cli/ # Development and operations tools ├── frontend/ -│ ├── apps/ # Web and desktop frontends +│ ├── apps/ # Web frontends │ └── libs/ # Shared TypeScript libraries ├── _database/ # SQL migrations, materialized schemas, search schemas ├── _docs/ # Setup guides and technical documentation @@ -201,8 +198,8 @@ npx nx dev artcraft-website ``` The website runs at `http://localhost:4200`. Repository-root launchers are in -[`script/website`](./script/website), and desktop launchers are in -[`script/artcraft`](./script/artcraft). +[`script/website`](./script/website). For desktop development, use the +[ArtCraft desktop repository](https://github.com/storytold/artcraft). ## Further reading diff --git a/_database/sql/artcraft_migrations/20250708000000_create_tasks_table.sql b/_database/sql/artcraft_migrations/20250708000000_create_tasks_table.sql deleted file mode 100644 index c6fe4a2541..0000000000 --- a/_database/sql/artcraft_migrations/20250708000000_create_tasks_table.sql +++ /dev/null @@ -1,127 +0,0 @@ --- noinspection SqlDialectInspectionForFile --- --- NB: This version needs to be bumped even if just adding or changing comments! --- Failure to do so will cause Windows to segfault at start. (This is horrible!) --- --- NB: `app_state_dir.rs` contains the file version number. --- --- Migration history: --- tasks_v1.sqlite - initial version --- tasks_v2.sqlite - added model_type (nullable) --- tasks_v3.sqlite - added frontend_caller, comments --- tasks_v4.sqlite - added is_dismissed_by_user --- tasks_v5.sqlite - added five fields: --- on_complete_batch_token, --- on_complete_primary_media_file_token, --- on_complete_primary_media_file_class, --- on_complete_primary_media_file_cdn_url, --- on_complete_primary_media_file_thumbnail_url_template, --- tasks_v6.sqlite - added two fields: --- on_failure_type --- on_failure_message --- tasks_v7.sqlite - added prompt token + two fields (for fal): --- prompt_token --- queue_status_url --- queue_response_url - -CREATE TABLE tasks ( - -- Task auto-incrementing primary key. - -- We don't use this. - id TEXT NOT NULL PRIMARY KEY, - - -- TaskStatus enum - -- This is how the job system manages job states. - -- e.g. pending, started, complete_success, dead, etc. - task_status TEXT NOT NULL, - - -- TaskType enum - -- e.g. image_generation, video_generation, etc. - task_type TEXT NOT NULL, - - -- TaskModelType enum - -- e.g. flux_1_dev, veo_2, etc. - model_type TEXT, - - -- GenerationProvider enum - -- Together with `provider_job_id`, this creates a foreign key lookup to the job. - -- e.g. 'artcraft', 'fal', 'sora', etc. - provider TEXT, - - -- The primary key for the job in the provider's system. - provider_job_id TEXT, - - -- OPTIONAL. - -- For third party jobs, we need to record the prompt details upfront. - -- We create a prompt record and store the token to associate once the task completes. - prompt_token TEXT, - - -- OPTIONAL. - -- Tell the job system which caller initiated the task. - -- e.g. 'canvas' - frontend_caller TEXT, - - -- OPTIONAL. - -- An arbitrary opaque identifier that frontend can set. - frontend_subscriber_id TEXT, - - -- OPTIONAL. - -- An opaque JSON payload set by the frontend subscriber that - -- will be re-emitted back to the frontend. - frontend_subscriber_payload TEXT, - - -- Whether the user has dismissed the task from view. - is_dismissed_by_user INTEGER NOT NULL DEFAULT 0, - - -- OPTIONAL. - -- For some third party systems (eg. FAL), the URL to check the status of the - -- job in the queue. - queue_status_url TEXT, - - -- OPTIONAL. - -- For some third party systems (eg. FAL), the URL to check the - -- results (when the job completes) - queue_response_url TEXT, - - -- OPTIONAL. - -- When the generation completes, the batch token (if any). - -- This will point to a collection of multiple files. - on_complete_batch_token TEXT, - - -- OPTIONAL. - -- When the generation completes, the media token of the "primary" media file. - -- We'll probably always generate homogenous types, but just in case this is the first or primary item in a batch. - on_complete_primary_media_file_token TEXT, - - -- OPTIONAL. - -- When the generation completes, the file type of the primary media file. - -- We'll probably always generate homogenous types, but just in case this is the first or primary item in a batch. - on_complete_primary_media_file_class TEXT, - - -- OPTIONAL. - -- The URL to the media file. - on_complete_primary_media_file_cdn_url TEXT, - - -- OPTIONAL. - -- The URL template for the thumbnail of the primary media file. - on_complete_primary_media_file_thumbnail_url_template TEXT, - - -- OPTIONAL. - -- An enum-like string describing the failure reason (even for non-terminal failures). - -- The enum is `TaskFailureType`, which is a close analogue of the backend API's `FrontendFailureCategory`. - on_failure_type TEXT, - - -- OPTIONAL. - -- A human-readable message describing the failure reason (even for non-terminal failures). - on_failure_message TEXT, - - created_at INTEGER NOT NULL DEFAULT (unixepoch('now')), - updated_at INTEGER NOT NULL DEFAULT (unixepoch('now')), - completed_at INTEGER DEFAULT NULL -); - --- Unique Indices -CREATE UNIQUE INDEX idx_tasks_on_provider_job_id ON tasks(provider_job_id); - --- Indices -CREATE INDEX idx_tasks_on_status ON tasks(task_status); -CREATE INDEX idx_tasks_on_provider ON tasks(provider); diff --git a/_docs/dev_setup.md b/_docs/dev_setup.md index d81564ee48..9e1de59128 100644 --- a/_docs/dev_setup.md +++ b/_docs/dev_setup.md @@ -1,45 +1,40 @@ -Dev Setup -========= +# Development setup -# ArtCraft +This repository contains the ArtCraft backend and web frontends. Desktop development +lives in [storytold/artcraft](https://github.com/storytold/artcraft). -ArtCraft is a Rust / Tauri app. +## Backend -To set up the ArtCraft development environment, install the following: +Install Rust and Cargo, then follow the [server setup guide](./dev_setup_server.md) +for MySQL and Redis. The server also needs Elasticsearch configuration, object +storage, and credentials for the integrations you use. Configuration files live in +[`storyteller_web/config`](../crates/service/web/storyteller_web/config); dependency +initialization lives in [`startup`](../crates/service/web/storyteller_web/src/startup). -1. [Install Rust](https://doc.rust-lang.org/cargo/getting-started/installation.html). -2. [Install npm](https://nodejs.org/en/download) or [nvm](https://github.com/nvm-sh/nvm). (Node version `v24.13.0` works at time of writing.) -3. [Install nx](https://nx.dev/docs/getting-started/installation). (Nx version `v22.4.5` works at time of writing.) -4. [Install Tauri CLI](https://v2.tauri.app/reference/cli/). (Version `tauri-cli 2.10.0` works at time of writing.) - -An easy way to get started with running the app in development is to run the two commands (in separate terminals): - -**Mac and Linux Development** +From the repository root, with those dependencies configured: ```bash -# Run the frontend dev server -./script/artcraft/unix_frontend_dev.sh - -# Run the Tauri Rust application -./script/artcraft/unix_rust_dev.sh +SQLX_OFFLINE=true cargo check -p storyteller-web +SQLX_OFFLINE=true cargo run -p storyteller-web ``` -**Windows Development** +The API listens on `http://localhost:12345` by default. `SQLX_OFFLINE=true` uses +checked-in query metadata at build time; the server still needs MySQL at runtime. +See the [root README](../README.md) for configuration loading and worker setup. -```powershell -# Run the frontend dev server -.\script\artcraft\windows_frontend_dev.ps1 +## Web frontends -# Run the Tauri Rust application -.\script\artcraft\windows_rust_dev.ps1 +Install Node.js and npm, then run from the repository root: + +```bash +cd frontend +npm install +VITE_USE_LOCAL_API=true npx nx dev artcraft-webapp ``` +The web app runs at `http://localhost:4201`, using the local backend. To develop +against the hosted API, omit `VITE_USE_LOCAL_API=true`. -# ArtCraft Server - -ArtCraft's server is a Rust / Actix app called `storyteller-web`. - -You don't need to run this to develop the ArtCraft application, but it can be useful to spin up -a development instance for adding new server functions or as your own private local copy. - -See [dev_setup_server.md](./dev_setup_server.md) for instructions. +For the product website, run `npx nx dev artcraft-website` from `frontend`; it uses +`http://localhost:4200`. Repository-root launchers live under [`script/website`](../script/website). +See the [frontend README](../frontend/README.md) for builds and troubleshooting. diff --git a/_docs/dev_setup_server.md b/_docs/dev_setup_server.md index 8664b3b7db..f05cd6a9b9 100644 --- a/_docs/dev_setup_server.md +++ b/_docs/dev_setup_server.md @@ -2,11 +2,9 @@ ArtCraft's server is a Rust / Actix app called `storyteller-web`. -You don't need to run this to develop the ArtCraft application, but it can be useful to spin up -a development instance for adding new server functions or as your own private local copy. - -`storyteller-web` can function entirely within the development environment, and ArtCraft can be -pointed to a local instance of the server. +Run it locally to develop backend functionality or connect the web app to your +own API instance. The desktop app is maintained in +[storytold/artcraft](https://github.com/storytold/artcraft). **TODO**: Concisely describe setting up server components. Note: we have previous docs in `old/` that may still be relevant, though they're perhaps @@ -53,7 +51,7 @@ Then verify access with `./script/dev_mysql_connect.sh` ```bash cargo install diesel_cli \ --no-default-features \ - --features mysql,sqlite + --features mysql ``` If this fails, @@ -90,7 +88,7 @@ Finally, you'll need the sqlx CLI tool to run codegen. You likely won't need this now, but if you change any queries, this will be necessary: ```bash -cargo install sqlx-cli --features rustls,mysql,sqlite +cargo install sqlx-cli --version 0.7.4 --no-default-features --features rustls,mysql --locked ``` ### Install Redis (Mac) diff --git a/crates/AGENTS.md b/crates/AGENTS.md index 302b7d238a..0be7b131b5 100644 --- a/crates/AGENTS.md +++ b/crates/AGENTS.md @@ -50,7 +50,6 @@ helpers go in the parent `mod tests` so sub-modules can `use super::*`. ## Key Crates - `storyteller_web` — main HTTP API monolith (actix-web) -- `artcraft` (desktop) — Tauri desktop app - `artcraft_router` — provider routing for image/video generation (Artcraft, Fal, KinoviWeb, Muapi) - `artcraft_api_defs` — shared HTTP API type definitions - `kinovi_web_client` — HTTP client for the Kinovi/KinoviWeb video generation service diff --git a/crates/api_clients/grok_consumer_client/Cargo.toml b/crates/api_clients/grok_consumer_client/Cargo.toml deleted file mode 100644 index 8a78c8f6bd..0000000000 --- a/crates/api_clients/grok_consumer_client/Cargo.toml +++ /dev/null @@ -1,52 +0,0 @@ -[package] -name = "grok_consumer_client" -edition = "2024" -version = "0.0.1" -publish = false - -[package.metadata.cargo-udeps.ignore] -normal = ["workspace-build-acceleration"] - -[lib] -name = "grok_consumer_client" -path = "src/lib.rs" - -[dependencies] -# Workspace hack (faster compile times) -workspace-build-acceleration.workspace = true - -# Internal -cloudflare_errors.workspace = true -cloudflare_mitigation.workspace = true -cookie_store.workspace = true -errors.workspace = true - -# External -anyhow.workspace = true -base64.workspace = true -bstr.workspace = true -byteorder.workspace = true -chrono.workspace = true -futures.workspace = true -log.workspace = true -once_cell.workspace = true -regex.workspace = true -scraper = "0.24.0" -serde.workspace = true -serde_json.workspace = true -sha2.workspace = true -tokio = { version = "1", features = ["full"] } -url.workspace = true -uuid.workspace = true -wreq-util.workspace = true -wreq.workspace = true - -[dev-dependencies] -filesys.workspace = true -test_data.workspace = true -test_utils.workspace = true -log4rs = "1.4.0" -env_logger.workspace = true -env.workspace = true -chrono.workspace = true - diff --git a/crates/api_clients/grok_consumer_client/src/client/browser_user_agents.rs b/crates/api_clients/grok_consumer_client/src/client/browser_user_agents.rs deleted file mode 100644 index 94f3923b48..0000000000 --- a/crates/api_clients/grok_consumer_client/src/client/browser_user_agents.rs +++ /dev/null @@ -1,10 +0,0 @@ - -/// Firefox 139 (2025) on macOS, which matches wreq's Emulation::Firefox139 -pub const FIREFOX_139_MAC_USER_AGENT : &str = - "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:139.0) Gecko/20100101 Firefox/139.0"; - -pub const FIREFOX_143_MAC_USER_AGENT : &str = - "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:143.0) Gecko/20100101 Firefox/143.0"; - -pub const FIREFOX_144_MAC_USER_AGENT_UNSUPPORTED_TLS_FINGERPRINTING : &str = - "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:144.0) Gecko/20100101 Firefox/144.0"; diff --git a/crates/api_clients/grok_consumer_client/src/client/mod.rs b/crates/api_clients/grok_consumer_client/src/client/mod.rs deleted file mode 100644 index 82c176fa31..0000000000 --- a/crates/api_clients/grok_consumer_client/src/client/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod browser_user_agents; \ No newline at end of file diff --git a/crates/api_clients/grok_consumer_client/src/credentials/_metadata/crypto_signature/xStatsigIDGenerator.py b/crates/api_clients/grok_consumer_client/src/credentials/_metadata/crypto_signature/xStatsigIDGenerator.py deleted file mode 100644 index 1346c58a53..0000000000 --- a/crates/api_clients/grok_consumer_client/src/credentials/_metadata/crypto_signature/xStatsigIDGenerator.py +++ /dev/null @@ -1,517 +0,0 @@ -#!/usr/bin/env python3 -# From https://github.com/kbtit25/grok2api/blob/73c917b15438e12699531ccf9411d3a7d1110cbf/xStatsigIDGenerator.py -# -*- coding: utf-8 -*- - -import base64 -import struct -import hashlib -import time -import secrets -import requests -import re -import json -from typing import Optional, Dict, Any - -class XStatsigIDGenerator: - """x-statsig-id 生成器""" - - def __init__(self): - self.base_timestamp = int(time.time()) # 使用当前系统时间 - self.grok_url = "https://grok.com" - - def get_grok_meta_content(self) -> bytes: - """ - 从 grok.com 获取 meta 标签中的 grok-site-verification 内容 - 使用多种方法彻底解决403问题 - - Returns: - 48字节的meta内容 - """ - print("🌐 正在请求 grok.com...") - - # 定义多种绕过策略 - strategies = [ - #self._try_curl_with_proxy, - self._try_curl_with_different_ua, - #self._try_requests_with_session, - #self._try_curl_cffi_advanced, - #self._try_alternative_endpoints, - #self._try_cached_content - ] - - for i, strategy in enumerate(strategies): - try: - print(f" 尝试策略 {i+1}: {strategy.__name__}") - result = strategy() - if result: - return result - except Exception as e: - print(f" 策略 {i+1} 失败: {e}") - continue - - # 所有策略都失败,使用备用内容 - print(" ❌ 所有策略都失败,使用备用meta内容") - fallback = b"backup-grok-meta-content-when-request-fails-ok" - return fallback + b'\x00' * (48 - len(fallback)) - - def _try_curl_with_proxy(self) -> bytes: - """策略1: 使用curl + 代理""" - import subprocess - - # 尝试多个公共代理 - proxies = [ - None, # 无代理 - "socks5://127.0.0.1:1080", # 本地代理 - "http://127.0.0.1:8080", # 本地HTTP代理 - ] - - for proxy in proxies: - try: - curl_command = [ - 'curl', '-s', '-L', '--max-time', '15', - '--user-agent', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36', - '--header', 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', - '--header', 'Accept-Language: en-US,en;q=0.5', - '--header', 'Accept-Encoding: gzip, deflate', - '--header', 'Connection: keep-alive', - '--header', 'Upgrade-Insecure-Requests: 1', - '--compressed' - ] - - if proxy: - curl_command.extend(['--proxy', proxy]) - - curl_command.append(self.grok_url) - - result = subprocess.run(curl_command, capture_output=True, text=True, timeout=15) - - if result.returncode == 0 and len(result.stdout) > 1000: - print(f" ✅ curl成功 (代理: {proxy or '无'})") - return self._extract_meta_from_html(result.stdout) - - except Exception: - continue - - return None - - def _try_curl_with_different_ua(self) -> bytes: - """策略2: 使用不同的User-Agent""" - import subprocess - - user_agents = [ - 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:143.0) Gecko/20100101 Firefox/143.0', - #'Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Mobile/15E148 Safari/604.1', - #'Mozilla/5.0 (Android 13; Mobile; rv:109.0) Gecko/109.0 Firefox/119.0', - #'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36', - #'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.1 Safari/605.1.15' - ] - - for ua in user_agents: - try: - curl_command = [ - 'curl-impersonate-ff', '-s', '-L', '--max-time', '10', - '--user-agent', ua, - '--header', 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', - '--header', 'Accept-Language: en-US,en;q=0.9', - '--header', 'Cache-Control: no-cache', - '--header', 'Pragma: no-cache', - '--compressed', - self.grok_url - ] - - result = subprocess.run(curl_command, capture_output=True, text=True, timeout=10) - - if result.returncode == 0 and len(result.stdout) > 1000: - print(f" ✅ 不同UA成功") - return self._extract_meta_from_html(result.stdout) - - except Exception: - continue - - return None - - def _try_requests_with_session(self) -> bytes: - """策略3: 使用requests session模拟真实浏览器行为""" - import requests - from requests.adapters import HTTPAdapter - from urllib3.util.retry import Retry - - session = requests.Session() - - # 配置重试策略 - retry_strategy = Retry( - total=3, - backoff_factor=1, - status_forcelist=[429, 500, 502, 503, 504], - ) - adapter = HTTPAdapter(max_retries=retry_strategy) - session.mount("http://", adapter) - session.mount("https://", adapter) - - # 模拟真实浏览器行为 - headers = { - 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36', - 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8', - 'Accept-Language': 'en-US,en;q=0.9', - 'Accept-Encoding': 'gzip, deflate, br', - 'DNT': '1', - 'Connection': 'keep-alive', - 'Upgrade-Insecure-Requests': '1', - 'Sec-Fetch-Dest': 'document', - 'Sec-Fetch-Mode': 'navigate', - 'Sec-Fetch-Site': 'none', - 'Sec-Fetch-User': '?1', - 'Cache-Control': 'max-age=0' - } - - try: - # 先访问主页建立session - session.get('https://x.com', headers=headers, timeout=5) - - # 再访问grok - response = session.get(self.grok_url, headers=headers, timeout=10) - - if response.status_code == 200 and len(response.text) > 1000: - print(f" ✅ session请求成功") - return self._extract_meta_from_html(response.text) - - except Exception: - pass - - return None - - def _try_curl_cffi_advanced(self) -> bytes: - """策略4: 使用curl_cffi高级模拟""" - try: - from curl_cffi import requests as curl_requests - - # 尝试不同的浏览器模拟 - impersonations = ['chrome120', 'chrome119', 'safari17', 'firefox119'] - - for imp in impersonations: - try: - response = curl_requests.get( - self.grok_url, - impersonate=imp, - timeout=10, - headers={ - 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', - 'Accept-Language': 'en-US,en;q=0.9', - 'Cache-Control': 'no-cache' - } - ) - - if response.status_code == 200 and len(response.text) > 1000: - print(f" ✅ curl_cffi成功 ({imp})") - return self._extract_meta_from_html(response.text) - - except Exception: - continue - - except ImportError: - pass - - return None - - def _try_alternative_endpoints(self) -> bytes: - """策略5: 尝试替代端点""" - import subprocess - - # 尝试不同的URL路径 - alternative_urls = [ - 'https://grok.com/', - 'https://grok.com/login', - 'https://grok.com/home', - 'https://x.com/i/grok' - ] - - for url in alternative_urls: - try: - curl_command = [ - 'curl', '-s', '-L', '--max-time', '8', - '--user-agent', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36', - '--header', 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', - '--compressed', - url - ] - - result = subprocess.run(curl_command, capture_output=True, text=True, timeout=8) - - if result.returncode == 0 and len(result.stdout) > 500: - print(f" ✅ 替代端点成功: {url}") - meta_result = self._extract_meta_from_html(result.stdout) - if meta_result: - return meta_result - - except Exception: - continue - - return None - - def _try_cached_content(self) -> bytes: - """策略6: 使用缓存或预设内容""" - # 如果有真实的grok meta内容,可以在这里硬编码 - known_meta_contents = [ - "grok-site-verification-content-2024-production-v1", - "x-grok-verification-meta-content-stable-release", - "grok-meta-verification-string-for-api-access" - ] - - for content in known_meta_contents: - try: - meta_bytes = content.encode('utf-8') - if len(meta_bytes) < 48: - meta_bytes = meta_bytes + b'\x00' * (48 - len(meta_bytes)) - elif len(meta_bytes) > 48: - meta_bytes = meta_bytes[:48] - - print(f" ✅ 使用预设内容: {content[:30]}...") - return meta_bytes - - except Exception: - continue - - return None - - def _extract_meta_from_html(self, html_content: str) -> bytes: - """从HTML中提取meta内容""" - patterns = [ - r' 48: - meta_bytes = meta_bytes[:48] - - return meta_bytes - - # 如果没找到特定的meta标签,尝试从HTML中提取其他有用信息 - if 'grok' in html_content.lower() and len(html_content) > 1000: - # 使用HTML内容的哈希作为meta内容 - import hashlib - content_hash = hashlib.sha256(html_content.encode()).hexdigest()[:48] - meta_bytes = content_hash.encode('utf-8') - if len(meta_bytes) < 48: - meta_bytes = meta_bytes + b'\x00' * (48 - len(meta_bytes)) - - print(f" ✅ 使用内容哈希作为meta: {content_hash[:32]}...") - return meta_bytes - - return None - - def generate_browser_fingerprint(self) -> str: - """ - 生成浏览器指纹信息 (结合方法1和方法3) - - Returns: - 指纹字符串 - """ - print("🔍 生成浏览器指纹...") - - # 模拟浏览器指纹信息 - fingerprint_data = { - "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:143.0) Gecko/20100101 Firefox/143.0", - "language": "en", - "languages": ["en", "en-US"], - "platform": "MacIntel", - "cookieEnabled": True, - "doNotTrack": None, - "screenWidth": 450, - "screenHeight": 654, - "screenColorDepth": 24, - "screenPixelDepth": 24, - "screenAvailWidth": 450, - "screenAvailHeight": 654, - "innerWidth": 450, - "innerHeight": 654, - "outerWidth": 1920, - "outerHeight": 1055, - "timezone": "America/New York", - "timezoneOffset": -400, - "hardwareConcurrency": 14, - "deviceMemory": 16, - "maxTouchPoints": 0 - } - - # 方法3: 生成指纹哈希 - fingerprint_string = json.dumps(fingerprint_data, sort_keys=True, separators=(',', ':')) - fingerprint_hash = hashlib.sha256(fingerprint_string.encode('utf-8')).hexdigest() - - print(f" 指纹数据长度: {len(fingerprint_string)} 字符") - print(f" 指纹哈希: {fingerprint_hash[:32]}...") - - return fingerprint_hash - - def generate_x_statsig_id(self, method: str = "GET", pathname: str = "/") -> str: - """ - 生成完整的 x-statsig-id - - Args: - method: 请求方式 (GET/POST) - pathname: 请求路径 - - Returns: - 生成的 x-statsig-id 字符串 - """ - print("=" * 60) - print("🚀 开始生成 x-statsig-id") - print("=" * 60) - - print(f"📋 生成参数:") - print(f" Method: {method}") - print(f" Pathname: {pathname}") - - # 1. 获取 grok.com 的 meta content - meta_content = self.get_grok_meta_content() - - # 2. 生成浏览器指纹 - fingerprint = self.generate_browser_fingerprint() - - # 3. 生成当前时间戳 - current_timestamp = int(time.time()) - relative_timestamp = current_timestamp - self.base_timestamp - - print(f"⏰ 时间信息:") - print(f" 当前时间戳: {current_timestamp}") - print(f" 基准时间戳: {self.base_timestamp}") - print(f" 相对时间戳: {relative_timestamp}") - - # 4. 生成时间戳字节 (小端序) - timestamp_bytes = struct.pack(' bool: - """ - 验证生成的ID结构是否正确 - - Args: - statsig_id: 要验证的ID - - Returns: - 验证是否通过 - """ - print("\n" + "=" * 60) - print("🔍 验证生成的ID结构") - print("=" * 60) - - try: - # Base64解码 - decoded_bytes = base64.b64decode(statsig_id) - print(f"✅ Base64解码成功,长度: {len(decoded_bytes)} 字节") - - # 提取异或key - xor_key = decoded_bytes[0] - print(f"✅ 异或key: 0x{xor_key:02x} ({xor_key})") - - # 异或解密 - decrypted = bytearray() - for i in range(1, len(decoded_bytes)): - decrypted.append(decoded_bytes[i] ^ xor_key) - - print(f"✅ 解密后长度: {len(decrypted)} 字节") - - # 验证数据结构 - expected_length = 48 + 4 + 16 + 1 # meta + timestamp + sha256 + fixed - if len(decrypted) == expected_length: - print(f"✅ 数据长度正确: {len(decrypted)}/{expected_length}") - else: - print(f"❌ 数据长度错误: {len(decrypted)}/{expected_length}") - return False - - # 检查固定值 - fixed_val = decrypted[-1] - if fixed_val == 3: - print(f"✅ 固定值正确: {fixed_val}") - else: - print(f"❌ 固定值错误: {fixed_val} (期望: 3)") - return False - - # 解析时间戳 - timestamp_bytes = decrypted[48:52] - timestamp = struct.unpack(' float: - def bezier(u: float): - omu = 1.0 - u - b1 = 3.0 * omu * omu * u - b2 = 3.0 * omu * u * u - b3 = u * u * u - x = b1 * x1 + b2 * x2 + b3 - y = b1 * y1 + b2 * y2 + b3 - return x, y - - lo, hi = 0.0, 1.0 - for _ in range(80): - mid = 0.5 * (lo + hi) - if bezier(mid)[0] < t: - lo = mid - else: - hi = mid - u = 0.5 * (lo + hi) - return bezier(u)[1] - - @staticmethod - def xa(svg: str) -> List[List[int]]: - s = (svg) - substr = s[9:] - parts = substr.split("C") - out = [] - for part in parts: - cleaned = sub(r"[^\d]+", " ", part).strip() - if cleaned == "": - nums = [0] - else: - nums = [int(tok) for tok in cleaned.split() if tok != ""] - out.append(nums) - return out - - @staticmethod - def tohex(num: float) -> str: - rounded = round(float(num), 2) - if rounded == 0.0: - return "0" - sign = "-" if copysign(1.0, rounded) < 0 else "" - absval = abs(rounded) - intpart = int(floor(absval)) - frac = absval - intpart - if frac == 0.0: - return sign + format(intpart, "x") - frac_digits = [] - f = frac - for _ in range(20): - f *= 16 - digit = int(floor(f + 1e-12)) - frac_digits.append(format(digit, "x")) - f -= digit - if abs(f) < 1e-12: - break - frac_str = "".join(frac_digits).rstrip("0") - if frac_str == "": - return sign + format(intpart, "x") - return sign + format(intpart, "x") + "." + frac_str - - @staticmethod - def simulateStyle(values: List[int], c: int) -> Dict[str,str]: - duration = 4096 - currentTime = round(c / 10.0) * 10 - t = currentTime / duration - - cp = [Signature._h(v, -1 if (i % 2) else 0, 1, False) for i, v in enumerate(values[7:])] - - easedY = Signature.cubicBezierEased(t, cp[0], cp[1], cp[2], cp[3]) - - start = [float(x) for x in values[0:3]] - end = [float(x) for x in values[3:6]] - r = round(start[0] + (end[0] - start[0]) * easedY) - g = round(start[1] + (end[1] - start[1]) * easedY) - b = round(start[2] + (end[2] - start[2]) * easedY) - color = f"rgb({r}, {g}, {b})" - - endAngle = Signature._h(values[6], 60, 360, True) - angle = endAngle * easedY - rad = angle * pi / 180.0 - - def is_effectively_zero(val: float) -> bool: - return abs(val) < 1e-7 - - def is_effectively_integer(val: float) -> bool: - return abs(val - round(val)) < 1e-7 - - cosv = cos(rad) - sinv = sin(rad) - - if is_effectively_zero(cosv): - a = 0 - d = 0 - else: - if is_effectively_integer(cosv): - a = int(round(cosv)) - d = int(round(cosv)) - else: - a = f"{cosv:.6f}" - d = f"{cosv:.6f}" - - if is_effectively_zero(sinv): - bval = 0 - cval = 0 - else: - if is_effectively_integer(sinv): - bval = int(round(sinv)) - cval = int(round(-sinv)) - else: - bval = f"{sinv:.7f}" - cval = f"{(-sinv):.7f}" - - transform = f"matrix({a}, {bval}, {cval}, {d}, 0, 0)" - return {"color": color, "transform": transform} - - @staticmethod - def xs(x_bytes: bytes, svg: str, x_values: list) -> str: - arr = list(x_bytes) - idx = arr[x_values[0]] % 16 - c = ((arr[x_values[1]] % 16) * (arr[x_values[2]] % 16)) * (arr[x_values[3]] % 16) - o = Signature.xa(svg) - vals = o[idx] - k = Signature.simulateStyle(vals, c) - - concat = str(k["color"]) + str(k["transform"]) - matches = findall(r"[\d\.\-]+", concat) - converted = [] - for m in matches: - num = float(m) - hexstr = Signature.tohex(num) - converted.append(hexstr) - joined = "".join(converted) - cleaned = joined.replace(".", "").replace("-", "") - return cleaned - - @staticmethod - def generate_sign(path: str, method: str, verification: str, svg: str, x_values: list, time_n: int = None, random_float: float = None) -> str: - - n = int(time() - 1682924400) if not time_n else time_n - t = pack(' 0: - first = arr[0] - for i in range(1, len(arr)): - arr[i] = arr[i] ^ first - - return b64encode(bytes(arr)).decode('ascii').replace('=', '') - - -def main(): - sig = Signature.generate_sign('/rest/app-chat/conversations/new', 'POST', self.verification_token, self.svg_data, self.numbers) - print('Signature', sig) - pass - -if __name__ == 'main': - main() diff --git a/crates/api_clients/grok_consumer_client/src/credentials/grok_client_secrets.rs b/crates/api_clients/grok_consumer_client/src/credentials/grok_client_secrets.rs deleted file mode 100644 index 704d8125fd..0000000000 --- a/crates/api_clients/grok_consumer_client/src/credentials/grok_client_secrets.rs +++ /dev/null @@ -1,36 +0,0 @@ -use crate::datatypes::api::baggage::Baggage; -use crate::datatypes::api::sentry_trace::SentryTrace; -use crate::datatypes::api::svg_path_data::SvgPathData; -use crate::datatypes::api::user_email::UserEmail; -use crate::datatypes::api::user_id::UserId; -use crate::datatypes::api::verification_token::VerificationToken; -use crate::datatypes::api::xsid_numbers::XsidNumbers; - -#[derive(Clone)] -pub struct GrokClientSecrets { - /// Baggage is tag data from the index.html - pub baggage: Baggage, - - /// Baggage is tag data from the index.html - pub sentry_trace: SentryTrace, - - /// Baggage is tag data from the index.html - pub verification_token: VerificationToken, - - /// The SVG path data to use (chosen via verification_token) - /// We selected one of four-ish possible SVG paths (of length >= 200) by - /// the `verification token -> animation index` algo. - pub svg_path_data: SvgPathData, - - /// This doesn't come from the index.html - /// These numbers are separately loaded from the xsid javascript - pub numbers: XsidNumbers, - - /// From index.html - /// Not strictly needed to sign requests, but typically needed to generate URLs. - pub user_id: UserId, - - /// From index.html - /// Not needed, but returned alongside other details. - pub user_email: Option, -} diff --git a/crates/api_clients/grok_consumer_client/src/credentials/grok_cookies.rs b/crates/api_clients/grok_consumer_client/src/credentials/grok_cookies.rs deleted file mode 100644 index d7ebcad944..0000000000 --- a/crates/api_clients/grok_consumer_client/src/credentials/grok_cookies.rs +++ /dev/null @@ -1,24 +0,0 @@ - -#[derive(Clone)] -pub struct GrokCookies { - /// The entire cookies header (for now) - cookies: String, -} - -impl GrokCookies { - pub fn new(cookies: String) -> Self { - Self { cookies } - } - - pub fn as_str(&self) -> &str { - &self.cookies - } - - pub fn as_bytes(&self) -> &[u8] { - self.cookies.as_bytes() - } - - pub fn to_string(&self) -> String { - self.cookies.clone() - } -} diff --git a/crates/api_clients/grok_consumer_client/src/credentials/grok_full_credentials.rs b/crates/api_clients/grok_consumer_client/src/credentials/grok_full_credentials.rs deleted file mode 100644 index 0b37a18a2d..0000000000 --- a/crates/api_clients/grok_consumer_client/src/credentials/grok_full_credentials.rs +++ /dev/null @@ -1,30 +0,0 @@ -use crate::credentials::grok_client_secrets::GrokClientSecrets; -use crate::credentials::grok_cookies::GrokCookies; -use crate::datatypes::api::user_id::UserId; - -/// Includes the cookies and all the magic other bits needed to call the API. -#[derive(Clone)] -pub struct GrokFullCredentials { - /// Entire cookie payload - pub cookies: GrokCookies, - - /// Secrets from `index.html` and the xsid javascript. - /// Required for video generation. - pub client_secrets: GrokClientSecrets, -} - -impl GrokFullCredentials { - pub fn from_cookies_and_client_secrets( - cookies: GrokCookies, - client_secrets: GrokClientSecrets - ) -> Self { - Self { - cookies, - client_secrets, - } - } - - pub fn get_user_id_ref(&self) -> &UserId { - &self.client_secrets.user_id - } -} diff --git a/crates/api_clients/grok_consumer_client/src/credentials/grok_user_data.rs b/crates/api_clients/grok_consumer_client/src/credentials/grok_user_data.rs deleted file mode 100644 index 8b9f28b563..0000000000 --- a/crates/api_clients/grok_consumer_client/src/credentials/grok_user_data.rs +++ /dev/null @@ -1,22 +0,0 @@ -use crate::datatypes::api::user_email::UserEmail; -use crate::datatypes::api::user_id::UserId; - -#[derive(Clone)] -pub struct GrokUserData { - /// From index.html - /// Not strictly needed to sign requests, but typically needed to generate URLs. - pub user_id: UserId, - - /// From index.html - /// Not needed, but returned alongside other details. - pub user_email: Option, -} - -impl GrokUserData { - pub fn from_id_and_email(id: String, email: Option) -> Self { - Self { - user_id: UserId(id), - user_email: email.map(|email| UserEmail(email)), - } - } -} diff --git a/crates/api_clients/grok_consumer_client/src/credentials/mod.rs b/crates/api_clients/grok_consumer_client/src/credentials/mod.rs deleted file mode 100644 index 4d7ea21059..0000000000 --- a/crates/api_clients/grok_consumer_client/src/credentials/mod.rs +++ /dev/null @@ -1,4 +0,0 @@ -pub mod grok_client_secrets; -pub mod grok_cookies; -pub mod grok_full_credentials; -pub mod grok_user_data; diff --git a/crates/api_clients/grok_consumer_client/src/datatypes/api/aspect_ratio.rs b/crates/api_clients/grok_consumer_client/src/datatypes/api/aspect_ratio.rs deleted file mode 100644 index 614e451591..0000000000 --- a/crates/api_clients/grok_consumer_client/src/datatypes/api/aspect_ratio.rs +++ /dev/null @@ -1,13 +0,0 @@ -use serde::Serialize; - -#[derive(Serialize, Clone, Copy, Debug)] -pub enum AspectRatio { - #[serde(rename = "2:3")] - TallTwoByThree, - - #[serde(rename = "3:2")] - WideThreeByTwo, - - #[serde(rename = "1:1")] - Square, -} diff --git a/crates/api_clients/grok_consumer_client/src/datatypes/api/baggage.rs b/crates/api_clients/grok_consumer_client/src/datatypes/api/baggage.rs deleted file mode 100644 index 0264b43a17..0000000000 --- a/crates/api_clients/grok_consumer_client/src/datatypes/api/baggage.rs +++ /dev/null @@ -1,4 +0,0 @@ - -/// "baggage" data from the tags -#[derive(Debug, Clone)] -pub struct Baggage(pub(crate) String); diff --git a/crates/api_clients/grok_consumer_client/src/datatypes/api/file_id.rs b/crates/api_clients/grok_consumer_client/src/datatypes/api/file_id.rs deleted file mode 100644 index b262a287ae..0000000000 --- a/crates/api_clients/grok_consumer_client/src/datatypes/api/file_id.rs +++ /dev/null @@ -1,5 +0,0 @@ - -/// Type for File IDs. -/// File IDs are UUIds. -#[derive(Clone, Debug)] -pub struct FileId(pub String); diff --git a/crates/api_clients/grok_consumer_client/src/datatypes/api/mod.rs b/crates/api_clients/grok_consumer_client/src/datatypes/api/mod.rs deleted file mode 100644 index 4fe3408938..0000000000 --- a/crates/api_clients/grok_consumer_client/src/datatypes/api/mod.rs +++ /dev/null @@ -1,12 +0,0 @@ -pub mod aspect_ratio; -pub mod baggage; -pub mod file_id; -pub mod video_generation_mode; -pub mod post_id; -pub mod request_id; -pub mod sentry_trace; -pub mod svg_path_data; -pub mod user_email; -pub mod user_id; -pub mod verification_token; -pub mod xsid_numbers; diff --git a/crates/api_clients/grok_consumer_client/src/datatypes/api/post_id.rs b/crates/api_clients/grok_consumer_client/src/datatypes/api/post_id.rs deleted file mode 100644 index 3315dc9bb3..0000000000 --- a/crates/api_clients/grok_consumer_client/src/datatypes/api/post_id.rs +++ /dev/null @@ -1,12 +0,0 @@ - -/// Type for Post IDs. -/// Post IDs are UUIds. -/// These are often shared with media/image uploads' `FileId`s, but seldom video generation `FileId`s -#[derive(Clone, Debug)] -pub struct PostId(pub String); - -impl PostId { - pub fn to_string(&self) -> String { - self.0.clone() - } -} diff --git a/crates/api_clients/grok_consumer_client/src/datatypes/api/request_id.rs b/crates/api_clients/grok_consumer_client/src/datatypes/api/request_id.rs deleted file mode 100644 index 1e06ece469..0000000000 --- a/crates/api_clients/grok_consumer_client/src/datatypes/api/request_id.rs +++ /dev/null @@ -1,13 +0,0 @@ - -/// Request IDs. -/// Type for image websocket "tasks" -/// These are for image generation websockets. -/// Request IDs are UUIds. -#[derive(Clone, Debug)] -pub struct RequestId(pub String); - -impl RequestId { - pub fn to_string(&self) -> String { - self.0.clone() - } -} diff --git a/crates/api_clients/grok_consumer_client/src/datatypes/api/sentry_trace.rs b/crates/api_clients/grok_consumer_client/src/datatypes/api/sentry_trace.rs deleted file mode 100644 index 8d81c7c89d..0000000000 --- a/crates/api_clients/grok_consumer_client/src/datatypes/api/sentry_trace.rs +++ /dev/null @@ -1,40 +0,0 @@ -use uuid::Uuid; - -/// "sentry trace" data from the tags -#[derive(Debug, Clone)] -pub struct SentryTrace(pub (crate) String); - -impl SentryTrace { - - /// Generate the format of trace sent in the HTTP request headers - pub fn to_http_request_header(&self) -> String { - // Python reference: - // f'{self.sentry_trace}-{str(uuid4()).replace("-", "")[:16]}-0', - // Inner bit: - // str(uuid4()).replace("-", "")[:16] - let sentry_start = &self.0; - let sentry_uuid = Uuid::new_v4().to_string(); - let sentry_inner = sentry_uuid.replace("-", "")[..16].to_string(); - - format!("{sentry_start}-{sentry_inner}-0") - } -} - -#[cfg(test)] -mod tests { - use crate::datatypes::api::sentry_trace::SentryTrace; - - #[test] - fn test_real_trace() { - let short = SentryTrace("d6d7c55e4a489c0dabaed06e5c7b257b".to_string()); - let header = short.to_http_request_header(); - assert_eq!(header.len(), 51); - } - - #[test] - fn test_invalid_trace() { - let short = SentryTrace("".to_string()); - let header = short.to_http_request_header(); - assert_eq!(header.len(), 19); // header is invalid, we're just making sure Rust doesn't panic - } -} diff --git a/crates/api_clients/grok_consumer_client/src/datatypes/api/svg_path_data.rs b/crates/api_clients/grok_consumer_client/src/datatypes/api/svg_path_data.rs deleted file mode 100644 index 800e5d6358..0000000000 --- a/crates/api_clients/grok_consumer_client/src/datatypes/api/svg_path_data.rs +++ /dev/null @@ -1,4 +0,0 @@ - -/// Data on an SVG path, eg. -#[derive(Debug, Clone)] -pub struct SvgPathData(pub(crate) String); diff --git a/crates/api_clients/grok_consumer_client/src/datatypes/api/user_email.rs b/crates/api_clients/grok_consumer_client/src/datatypes/api/user_email.rs deleted file mode 100644 index a6ba535a04..0000000000 --- a/crates/api_clients/grok_consumer_client/src/datatypes/api/user_email.rs +++ /dev/null @@ -1,9 +0,0 @@ -/// Type for User Emails -#[derive(Clone, Debug)] -pub struct UserEmail(pub String); - -impl UserEmail { - pub fn to_string(&self) -> String { - self.0.clone() - } -} diff --git a/crates/api_clients/grok_consumer_client/src/datatypes/api/user_id.rs b/crates/api_clients/grok_consumer_client/src/datatypes/api/user_id.rs deleted file mode 100644 index c7e522fddc..0000000000 --- a/crates/api_clients/grok_consumer_client/src/datatypes/api/user_id.rs +++ /dev/null @@ -1,12 +0,0 @@ - -/// Type for User IDs. -/// User IDs are UUIDs. -#[derive(Clone, Debug)] -pub struct UserId(pub String); - -impl UserId { - pub fn to_string(&self) -> String { - self.0.clone() - } -} - diff --git a/crates/api_clients/grok_consumer_client/src/datatypes/api/verification_token.rs b/crates/api_clients/grok_consumer_client/src/datatypes/api/verification_token.rs deleted file mode 100644 index f7dba1f88f..0000000000 --- a/crates/api_clients/grok_consumer_client/src/datatypes/api/verification_token.rs +++ /dev/null @@ -1,3 +0,0 @@ - -#[derive(Debug, Clone)] -pub struct VerificationToken(pub(crate) String); diff --git a/crates/api_clients/grok_consumer_client/src/datatypes/api/video_generation_mode.rs b/crates/api_clients/grok_consumer_client/src/datatypes/api/video_generation_mode.rs deleted file mode 100644 index 3036b34114..0000000000 --- a/crates/api_clients/grok_consumer_client/src/datatypes/api/video_generation_mode.rs +++ /dev/null @@ -1,27 +0,0 @@ - -/// The video generation mode selector. -#[derive(Copy, Clone, Debug)] -pub enum VideoGenerationMode { - /// Supposedly the "NSFW" mode. - Spicy, - - Fun, - - Normal, - - /// This might be the only mode that allows for a custom text prompt - Custom, -} - -impl VideoGenerationMode { - - /// This is the value for `--mode` in video generation chats. - pub fn as_api_mode_arg(&self) -> &'static str { - match self { - Self::Spicy => "extremely-spicy-or-crazy", - Self::Fun => "extremely-crazy", - Self::Normal => "normal", - Self::Custom => "custom", - } - } -} diff --git a/crates/api_clients/grok_consumer_client/src/datatypes/api/xsid_numbers.rs b/crates/api_clients/grok_consumer_client/src/datatypes/api/xsid_numbers.rs deleted file mode 100644 index 484b010066..0000000000 --- a/crates/api_clients/grok_consumer_client/src/datatypes/api/xsid_numbers.rs +++ /dev/null @@ -1,6 +0,0 @@ - -/// Magic numbers pulled from Javascript -#[derive(Clone, Debug)] -pub struct XsidNumbers { - pub numbers: Vec, -} diff --git a/crates/api_clients/grok_consumer_client/src/datatypes/file_upload_spec.rs b/crates/api_clients/grok_consumer_client/src/datatypes/file_upload_spec.rs deleted file mode 100644 index 2e2e435645..0000000000 --- a/crates/api_clients/grok_consumer_client/src/datatypes/file_upload_spec.rs +++ /dev/null @@ -1,18 +0,0 @@ -use std::path::Path; - -/// Descriptor of a file to be uploaded -/// Includes necessary metadata -pub enum FileUploadSpec> { - /// Path to the file - Path(P), - - /// Bytes of the file - Bytes { - /// Must be owned. - bytes: Vec, - /// Must be owned. - filename: String, - /// Mime type - mimetype: String, - } -} diff --git a/crates/api_clients/grok_consumer_client/src/datatypes/mod.rs b/crates/api_clients/grok_consumer_client/src/datatypes/mod.rs deleted file mode 100644 index fa09308d96..0000000000 --- a/crates/api_clients/grok_consumer_client/src/datatypes/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod api; -pub mod file_upload_spec; diff --git a/crates/api_clients/grok_consumer_client/src/error/categorize_grok_http_error.rs b/crates/api_clients/grok_consumer_client/src/error/categorize_grok_http_error.rs deleted file mode 100644 index 4d84b63918..0000000000 --- a/crates/api_clients/grok_consumer_client/src/error/categorize_grok_http_error.rs +++ /dev/null @@ -1,37 +0,0 @@ -use crate::error::grok_error::GrokError; -use crate::error::grok_generic_api_error::GrokGenericApiError; -use crate::error::grok_specific_api_error::GrokSpecificApiError; -use cloudflare_errors::filter_cloudflare_errors::filter_cloudflare_errors; -use wreq::StatusCode; - -/// We know the response is an error at this point. -/// We're just turning it into the right error. -pub fn categorize_grok_http_error(status_code: StatusCode, maybe_body: Option<&str>) -> GrokError { - - if let Some(body) = maybe_body { - if let Err(err) = filter_cloudflare_errors(status_code.as_u16(), body) { - return GrokGenericApiError::CloudflareError(err).into(); - } - - let body = body.to_lowercase(); - let anti_bot = body.contains("anti-bot") || body.contains("rejected"); - - if anti_bot { - return GrokSpecificApiError::AutomationBlocked.into(); - } - - match status_code { - StatusCode::TOO_MANY_REQUESTS => { - return GrokSpecificApiError::TooManyVideos.into(); - } - _ => {}, - } - - return GrokGenericApiError::UncategorizedBadResponseWithStatusAndBody { - status_code, - body: body.to_string(), - }.into(); - } - - GrokGenericApiError::UncategorizedBadResponseWithStatus(status_code).into() -} diff --git a/crates/api_clients/grok_consumer_client/src/error/grok_client_error.rs b/crates/api_clients/grok_consumer_client/src/error/grok_client_error.rs deleted file mode 100644 index b33f902558..0000000000 --- a/crates/api_clients/grok_consumer_client/src/error/grok_client_error.rs +++ /dev/null @@ -1,154 +0,0 @@ -use base64::DecodeError; -use std::error::Error; -use std::fmt::{Display, Formatter}; - -#[derive(Debug)] -pub enum GrokClientError { - - /// An error was encountered in building the Wreq client - WreqClientError(wreq::Error), - - /// Error serializing a message to send the websocket - WebsocketRequestSerializationError(serde_json::Error), - - /// Error locking the websocket for sending/receiving - WebsocketLockError, - - /// Error reading from a websocket. - WebsocketReadError(wreq::Error), - - /// Error sending to an open websocket. - WebsocketSendError(wreq::Error), - - /// Can't open a local file for uploading. - CannotOpenLocalFileForUpload(std::io::Error), - - /// Can't read a local file for uploading. - CannotReadLocalFileForUpload(std::io::Error), - - /// Couldn't write to the file - CannotOpenLocalFileForWriting(std::io::Error), - - /// Couldn't write to the file - CannotWriteLocalFile(std::io::Error), - - /// File for upload has an invalid path. - FileForUploadHasInvalidPath, - - /// Error parsing HTML - HtmlParsingError, - - /// Error decoding verification token - FailedToDecodeVerificationToken(DecodeError), - - /// Verification token bytes are invalid - InvalidVerificationTokenBytes, - - /// Our script logic is out of date - ScriptLogicOutOfDate, - - /// Our script logic is out of date (SVG) - ScriptSvgLogicOutOfDate, - - /// Our script logic is out of date (script 1) - Script1LogicOutOfDate, - - /// Our script logic is out of date (script 2) - Script2LogicOutOfDate, - - /// Our script logic is out of date (xsid script) - ScriptXsidLogicOutOfDate, - - /// Signature algorithm isn't working with inputs - BadSignatureInputs, - - /// Something is broken with timeout math - TimeoutMathBroken, - - /// Can't make request because cookies aren't present - NoCookiesPresent, - - /// Unknown error generating video - ErrorGeneratingVideo, - -// /// An error reading the file for upload. -// FileForUploadReadError(std::io::Error), -// -// /// The file path provided for upload is invalid. -// FileForUploadHasInvalidPath, -// -// /// Something is wrong with the JWT bearer token. -// /// This error originates on our end as we try to parse the JWT. -// LocalJwtClaimsParseError(String), -// -// /// There was an error constructing the form-multipart request. -// MultipartFormError(wreq::Error), -// -// /// We haven't received a bearer token yet -// /// This is our own internal application state error, not something Sora returns. -// /// We know our client can't make the request, so we preemptively fail it. -// NoBearerTokenForRequest, -// -// /// A sentinel token is not present in the client, which is required for some requests. -// NoSentinelTokenForRequest, -// -// /// Issue with using the SoraCredentialBuilder. -// SoraCredentialBuilderError(&'static str), -// -// /// Error parsing a request URL. -// UrlParseError(url::ParseError), -// -// /// Error serializing the sentinel store token to JSON (typically for persistent storage). -// CouldNotSerializeSentinelTokenStore(serde_json::Error), -// -// /// Error deserializing the sentinel token from JSON (typically for persistent storage). -// CouldNotDeserializeSentinelTokenStore { -// error: serde_json::Error, -// raw_json: String -// }, -} - -impl Error for GrokClientError {} - -impl Display for GrokClientError { - fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { - match self { - Self::WreqClientError(err) => write!(f, "Wreq client error (during client creation): {}", err), - Self::WebsocketRequestSerializationError(err) => write!(f, "Websocket request serialization error: {}", err), - Self::WebsocketLockError => write!(f, "Websocket lock error"), - Self::WebsocketReadError(err) => write!(f, "Websocket read error: {}", err), - Self::WebsocketSendError(err) => write!(f, "Websocket send error: {}", err), - Self::CannotOpenLocalFileForUpload(err) => write!(f, "Cannot open local file for upload: {}", err), - Self::CannotReadLocalFileForUpload(err) => write!(f, "Cannot read local file for upload: {}", err), - Self::CannotOpenLocalFileForWriting(err) => write!(f, "Cannot open local file for writing: {}", err), - Self::CannotWriteLocalFile(err) => write!(f, "Cannot write local file: {}", err), - Self::FileForUploadHasInvalidPath => write!(f, "File for upload has invalid path"), - Self::HtmlParsingError => write!(f, "Html parsing error"), - Self::FailedToDecodeVerificationToken(err) => write!(f, "Failed to decode verification token: {}", err), - Self::InvalidVerificationTokenBytes => write!(f, "Invalid verification token bytes"), - Self::ScriptLogicOutOfDate => write!(f, "Script logic out of date"), - Self::ScriptSvgLogicOutOfDate => write!(f, "Script logic out of date (SVG parsing)"), - Self::Script1LogicOutOfDate => write!(f, "Script logic out of date (script 1)"), - Self::Script2LogicOutOfDate => write!(f, "Script logic out of date (script 2)"), - Self::ScriptXsidLogicOutOfDate => write!(f, "Script logic out of date (xsid script)"), - Self::BadSignatureInputs => write!(f, "Bad signature inputs"), - Self::TimeoutMathBroken => write!(f, "Timeout math is broken"), - Self::NoCookiesPresent => write!(f, "No cookies present"), - Self::ErrorGeneratingVideo => write!(f, "Error generating video"), - - //Self::FileForUploadReadError(err) => write!(f, "Error reading file for upload: {}", err), - //Self::FileForUploadHasInvalidPath => write!(f, "The file path provided for upload is invalid."), - //Self::LocalJwtClaimsParseError(msg) => write!(f, "Local JWT claims parse error: {}", msg), - //Self::MultipartFormError(err) => write!(f, "Multipart form error: {}", err), - //Self::NoBearerTokenForRequest => write!(f, "No bearer token available. The client needs a bearer token to make the request."), - //Self::NoSentinelTokenForRequest => write!(f, "No sentinel token available. The client needs a sentinel token to make the request."), - //Self::SoraCredentialBuilderError(msg) => write!(f, "Sora Credential Builder error: {}", msg), - //Self::UrlParseError(err) => write!(f, "URL parse error: {}", err), - //Self::CouldNotSerializeSentinelToken(err) => write!(f, "Could not serialize sentinel token to JSON: {}", err), - //Self::CouldNotSerializeSentinelTokenStore(err) => write!(f, "Could not serialize sentinel token store to JSON: {}", err), - //Self::CouldNotDeserializeSentinelTokenStore { error, raw_json} => { - // write!(f, "Could not deserialize sentinel token store from JSON: {:?}, raw JSON: {}", error, raw_json) - //}, - } - } -} diff --git a/crates/api_clients/grok_consumer_client/src/error/grok_error.rs b/crates/api_clients/grok_consumer_client/src/error/grok_error.rs deleted file mode 100644 index 31a79ae950..0000000000 --- a/crates/api_clients/grok_consumer_client/src/error/grok_error.rs +++ /dev/null @@ -1,53 +0,0 @@ -use crate::error::grok_client_error::GrokClientError; -use crate::error::grok_generic_api_error::GrokGenericApiError; -use crate::error::grok_specific_api_error::GrokSpecificApiError; -use cloudflare_errors::cloudflare_error::CloudflareError; -use std::error::Error; - -#[derive(Debug)] -pub enum GrokError { - Client(GrokClientError), - ApiSpecific(GrokSpecificApiError), - ApiGeneric(GrokGenericApiError), -} - -impl GrokError { - pub fn is_grok_having_downtime_issues(&self) -> bool { - match self { - Self::ApiGeneric(GrokGenericApiError::CloudflareError(CloudflareError::BadGateway502)) => true, - Self::ApiGeneric(GrokGenericApiError::CloudflareError(CloudflareError::GatewayTimeout504)) => true, - Self::ApiGeneric(GrokGenericApiError::CloudflareError(CloudflareError::TimeoutOccurred524)) => true, - _ => false, - } - } -} - -impl Error for GrokError {} - -impl std::fmt::Display for GrokError { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - Self::Client(e) => write!(f, "GrokClientError: {:?}", e), - Self::ApiSpecific(e) => write!(f, "GrokSpecificApiError: {:?}", e), - Self::ApiGeneric(e) => write!(f, "GrokGenericApiError: {:?}", e), - } - } -} - -impl From for GrokError { - fn from(error: GrokClientError) -> Self { - Self::Client(error) - } -} - -impl From for GrokError { - fn from(error: GrokSpecificApiError) -> Self { - Self::ApiSpecific(error) - } -} - -impl From for GrokError { - fn from(error: GrokGenericApiError) -> Self { - Self::ApiGeneric(error) - } -} diff --git a/crates/api_clients/grok_consumer_client/src/error/grok_generic_api_error.rs b/crates/api_clients/grok_consumer_client/src/error/grok_generic_api_error.rs deleted file mode 100644 index a56d0f3ab2..0000000000 --- a/crates/api_clients/grok_consumer_client/src/error/grok_generic_api_error.rs +++ /dev/null @@ -1,82 +0,0 @@ -use cloudflare_errors::cloudflare_error::CloudflareError; -use std::error::Error; -use std::fmt::{Display, Formatter}; -use wreq::StatusCode; - -#[derive(Debug)] -pub enum GrokGenericApiError { - /// Specific Cloudflare errors. - CloudflareError(CloudflareError), - - /// The downloaded index.html did not include the expected data. - /// This is necessary for handshakes between client and server. - IndexHtmlDidNotIncludeExpectedData { - message: String, - }, - - /// The downloaded javascript did not include the expected data. - /// This is necessary for handshakes between client and server. - ScriptBodyDidNotIncludeExpectedData { - message: String, - }, - - /// Error creating the websocket due to 401 Unauthorized, likely an authentication error with Grok. - /// Unfortunately we can't read the response body text to diagnose more because wreq has some API design issues. - LikelyWebsocketAuthentication401, - - /// We received a 403 on websocket upgrade, likely from Cloudflare. - /// Unfortunately we can't read the response body text to diagnose more because wreq has some API design issues. - LikelyWebsocketCloudflare403, - - /// Unknown status code on websocket upgrade. - UnexpectedWebsocketUpgradeStatusCode(StatusCode), - - /// serde_json::Error, likely from JSON deserialization schema mismatch. - /// Includes the original body. - SerdeResponseParseErrorWithBody(serde_json::Error, String), - - /// serde_json::Error, likely from JSON deserialization schema mismatch. - /// Includes the original body. - /// Specifically, this is for non-200 (error) responses. - SerdeParseErrorWithBodyOnNon200(serde_json::Error, String), - - /// An uncategorized bad HTTP response from Grok. - UncategorizedBadResponseWithStatus(StatusCode), - - /// An uncategorized bad HTTP response from Grok. - UncategorizedBadResponseWithStatusAndBody { - status_code: StatusCode, - body: String, - }, - - /// Our previous upload failed - UploadFailed, - - /// An error upgrading the connection to a websocket. - WreqWebsocketUpgradeError(wreq::Error), - - /// An uncaught error from the API client. - WreqError(wreq::Error), -} - -impl Error for GrokGenericApiError {} - -impl Display for GrokGenericApiError { - fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { - match self { - Self::CloudflareError(err) => write!(f, "Cloudflare error: {}", err), - Self::IndexHtmlDidNotIncludeExpectedData { message } => write!(f, "IndexHtmlDidNotIncludeExpectedData ( message: {} )", message), - Self::ScriptBodyDidNotIncludeExpectedData { message } => write!(f, "ScriptBodyDidNotIncludeExpectedData ( message: {} )", message), - Self::LikelyWebsocketAuthentication401 => write!(f, "Likely websocket authentication 401 error (probably Grok authentication issue with cookies)"), - Self::LikelyWebsocketCloudflare403 => write!(f, "Likely Cloudflare 403 error on websocket upgrade"), - Self::UnexpectedWebsocketUpgradeStatusCode(status) => write!(f, "Unexpected websocket upgrade status code: {}", status), - Self::SerdeResponseParseErrorWithBody(err, body) => write!(f, "Failed to parse response body: {:?}. Body: {}", err, body), - Self::SerdeParseErrorWithBodyOnNon200(err, body) => write!(f, "Failed to parse non-200 response body: {:?}. Body: {}", err, body), - Self::UncategorizedBadResponseWithStatus(status) => write!(f, "Uncategorized with status code: {}", status), - Self::UncategorizedBadResponseWithStatusAndBody { status_code, body } => write!(f, "Uncategorized bad response: status code {}, body: {}", status_code, body), - Self::UploadFailed => write!(f, "Upload failed"), - Self::WreqWebsocketUpgradeError(err) => write!(f, "Websocket upgrade error: {}", err), - Self::WreqError(err) => write!(f, "Wreq client error: {}", err), - } - } -} diff --git a/crates/api_clients/grok_consumer_client/src/error/grok_specific_api_error.rs b/crates/api_clients/grok_consumer_client/src/error/grok_specific_api_error.rs deleted file mode 100644 index e0fd7e4078..0000000000 --- a/crates/api_clients/grok_consumer_client/src/error/grok_specific_api_error.rs +++ /dev/null @@ -1,78 +0,0 @@ -use std::error::Error; -use std::fmt::{Display, Formatter}; - -#[derive(Debug)] -pub enum GrokSpecificApiError { - /// Grok is detecting and blocking our bot, likely due to new secrets use. - AutomationBlocked, - - /// Too many videos are being generated. - TooManyVideos, - - -// /// Failed to generate a bearer token despite the `200 OK` response. -// /// This has been generated by sending old/expired session cookies or empty cookies. -// FailedToGenerateBearerToken, -// -// /// The endpoint told us we used an invalid JWT. -// InvalidJwt, -// -// /// Sora has responded with "sentinel block". -// /// This usually means we need to refresh our sentinel token. -// SentinelBlockError, -// -// /// Sora requires users to set up an account username before they can generate images. -// /// This requires the user to set up that username. -// SoraUsernameNotYetCreated, -// -// /// Sora has responded with "token expired". -// /// This (probably?) means we need to refresh our JWT bearer token. -// TokenExpiredError, -// -// /// We're sending too many tasks to Sora. -// /// Sora is telling us to cool it. -// TooManyConcurrentTasks, -// -// // TODO: Try to make concrete error types for these distinct cases. -// /// Unauthorized, cookie and/or bearer token expired. We'll need to ask for a refreshed login. -// /// -// /// Example message, e.g. from the upload endpoint: -// /// { -// /// "error": { -// /// "message": "Your authentication token has expired. Please try signing in again.", -// /// "type": "invalid_request_error", -// /// "param": null, -// /// "code": "token_expired" -// /// } -// /// } -// UnauthorizedCookieOrBearerExpired, -// -// /// The Sora sentinel token response is missing fields -// SentinelResponseIsMissingFields { -// missing_token: bool, -// missing_turnstile: bool, -// raw_response: String, -// }, -} - -impl Error for GrokSpecificApiError {} - -impl Display for GrokSpecificApiError { - fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { - match self { - Self::AutomationBlocked => write!(f, "Automation blocked"), - Self::TooManyVideos => write!(f, "Too many videos are being generated"), - - //Self::FailedToGenerateBearerToken => write!(f, "Failed to generate bearer token. Probably invalid or expired session cookies."), - //Self::InvalidJwt => write!(f, "Invalid JWT token. Please refresh the token."), - //Self::SentinelBlockError => write!(f, "Request blocked by Sentinel Token Block. Please refresh the sentinel token."), - //Self::SoraUsernameNotYetCreated => write!(f, "Sora username not yet created. Please create a username in the Sora app or website."), - //Self::TokenExpiredError => write!(f, "JWT token has expired. Please refresh the token."), - //Self::TooManyConcurrentTasks => write!(f, "Too many concurrent tasks. Please wait."), - //Self::UnauthorizedCookieOrBearerExpired => write!(f, "Unauthorized: cookie and/or bearer token expired"), - //Self::SentinelResponseIsMissingFields { missing_token: token_missing, missing_turnstile: turnstile_missing, raw_response } => { - // write!(f, "Sentinel response is missing fields. token_missing: {}, turnstile_missing: {}. Raw response: {}", token_missing, turnstile_missing, raw_response) - //}, - } - } -} diff --git a/crates/api_clients/grok_consumer_client/src/error/mod.rs b/crates/api_clients/grok_consumer_client/src/error/mod.rs deleted file mode 100644 index 97c7749fe7..0000000000 --- a/crates/api_clients/grok_consumer_client/src/error/mod.rs +++ /dev/null @@ -1,5 +0,0 @@ -pub mod grok_client_error; -pub mod grok_error; -pub mod grok_generic_api_error; -pub mod grok_specific_api_error; -pub (crate) mod categorize_grok_http_error; \ No newline at end of file diff --git a/crates/api_clients/grok_consumer_client/src/lib.rs b/crates/api_clients/grok_consumer_client/src/lib.rs deleted file mode 100644 index f0d3e6b848..0000000000 --- a/crates/api_clients/grok_consumer_client/src/lib.rs +++ /dev/null @@ -1,15 +0,0 @@ -//! A Grok API client. - -#[cfg(test)] -pub (crate) mod test_utils; - -// Library utils -pub (crate) mod client; - -// User lib -pub mod credentials; -pub mod datatypes; -pub mod error; -pub mod recipes; -pub mod requests; -pub mod utils; diff --git a/crates/api_clients/grok_consumer_client/src/recipes/_metadata/video_gen_request_flows.md b/crates/api_clients/grok_consumer_client/src/recipes/_metadata/video_gen_request_flows.md deleted file mode 100644 index e6e7290d82..0000000000 --- a/crates/api_clients/grok_consumer_client/src/recipes/_metadata/video_gen_request_flows.md +++ /dev/null @@ -1,93 +0,0 @@ -Upload Image -> Video Flow -========================== - -1. Upload Image - - Endpoint: https://grok.com/rest/app-chat/upload-file - - Response Fields: - { - **"fileMetadataId": "21a79085-e206-4b0b-88ac-5f2b7a453e45",** - **"fileUri": "users/85980643-ffab-4984-a3de-59a608c47d7f/21a79085-e206-4b0b-88ac-5f2b7a453e45/content",** - "fileMimeType": "image/jpeg", - "fileName": "0_0.jpeg", - "parsedFileUri": "", - "createTime": "2025-10-21T23:40:41.784448Z", - "fileSource": "SELF_UPLOAD_FILE_SOURCE" - } - - - File becomes a 480x640 copy: - - https://assets.grok.com/users/85980643-ffab-4984-a3de-59a608c47d7f/21a79085-e206-4b0b-88ac-5f2b7a453e45/content - -2. "Create Media Post" **(needed?)** - - Endpoint: https://grok.com/rest/media/post/create - - Request Fields: - { - "mediaType": "MEDIA_POST_TYPE_IMAGE", - "mediaUrl": "https://assets.grok.com/users/85980643-ffab-4984-a3de-59a608c47d7f/21a79085-e206-4b0b-88ac-5f2b7a453e45/content" - } - - Response: - { - "post": { - "id": "21a79085-e206-4b0b-88ac-5f2b7a453e45", - "userId": "85980643-ffab-4984-a3de-59a608c47d7f", - "createTime": "2025-10-21T23:40:41.993980477Z", - "prompt": "", - "mediaType": "MEDIA_POST_TYPE_IMAGE", - "mediaUrl": "https://assets.grok.com/users/85980643-ffab-4984-a3de-59a608c47d7f/21a79085-e206-4b0b-88ac-5f2b7a453e45/content", - "mimeType": "image/jpeg", - "audioUrls": [], - "childPosts": [] - } - } - -3. Chat Conversation for Video - - Endpoint: https://grok.com/rest/app-chat/conversations/new - - Request: - { - "temporary":true, - "modelName":"grok-3", - "message":"https://assets.grok.com/users/85980643-ffab-4984-a3de-59a608c47d7f/21a79085-e206-4b0b-88ac-5f2b7a453e45/content --mode=normal", - "fileAttachments":["21a79085-e206-4b0b-88ac-5f2b7a453e45"], - "toolOverrides": { - "videoGen":true - } - } - -Header 'x-xai-request-id: 7cb93340-5fb6-4fb3-b88d-ff9f5d99d456' is just a random UUID and it can be changed. - - -Generate Image -> Video Flow -============================ - -(TODO) - -2. Create Media Post - - Request - { - "mediaType": "MEDIA_POST_TYPE_IMAGE", - "mediaUrl":"https://imagine-public.x.ai/imagine-public/images/2d8260d7-3b7c-4bc1-84ca-6e82dd892c39.png" - } - - -3. Chat Conversation for Video - - Endpoint: https://grok.com/rest/app-chat/conversations/new - - Request: - { - "temporary": true, - "modelName": "grok-3", - "message": "https://imagine-public.x.ai/imagine-public/images/2d8260d7-3b7c-4bc1-84ca-6e82dd892c39.png alien walks down the hallway --mode=custom", - "toolOverrides": { - "videoGen":true - } - } diff --git a/crates/api_clients/grok_consumer_client/src/recipes/mod.rs b/crates/api_clients/grok_consumer_client/src/recipes/mod.rs deleted file mode 100644 index 68bb011571..0000000000 --- a/crates/api_clients/grok_consumer_client/src/recipes/mod.rs +++ /dev/null @@ -1,4 +0,0 @@ -pub mod prompt_websocket_image_with_retry; -pub mod request_client_secrets; -pub mod upload_image_and_generate_video; -pub mod upload_image_and_generate_video_with_retry; \ No newline at end of file diff --git a/crates/api_clients/grok_consumer_client/src/recipes/prompt_websocket_image_with_retry.rs b/crates/api_clients/grok_consumer_client/src/recipes/prompt_websocket_image_with_retry.rs deleted file mode 100644 index f6cea7cb1f..0000000000 --- a/crates/api_clients/grok_consumer_client/src/recipes/prompt_websocket_image_with_retry.rs +++ /dev/null @@ -1,201 +0,0 @@ -use crate::credentials::grok_cookies::GrokCookies; -use crate::error::grok_client_error::GrokClientError; -use crate::error::grok_error::GrokError; -use crate::requests::image_websocket::create_listen_websocket::{create_listen_websocket, CreateListenWebsocketArgs}; -use crate::requests::image_websocket::grok_websocket::GrokWebsocket; -use crate::requests::image_websocket::messages::websocket_client_message::{ClientMessageAspectRatio, WebsocketClientMessage}; -use log::{error, info}; - -pub struct PromptWebsocketImageWithRetryArgs<'a> { - pub websocket: &'a mut GrokWebsocket, - pub prompt: &'a str, - pub aspect_ratio: ClientMessageAspectRatio, - pub cookies: &'a GrokCookies, -} - -pub struct PromptWebsocketImageWithRetryResult { - pub maybe_new_websocket: Option, -} - - -pub async fn prompt_websocket_image_with_retry(args: PromptWebsocketImageWithRetryArgs<'_>) -> Result -{ - let mut maybe_new_websocket : Option = None; - - for i in 0..3 { - info!("Starting Grok Websocket image generation (attempt {}) ...", (i+1)); - - let message = WebsocketClientMessage::new_image_prompt(args.prompt, args.aspect_ratio); - - let result = - if let Some(websocket) = maybe_new_websocket.as_mut() { - websocket.send_serializable(&message).await - } else { - args.websocket.send_serializable(&message).await - }; - - match result { - Ok(()) => { - break; - } - Err(GrokError::Client(GrokClientError::WreqClientError(err))) => { - error!("Error sending message to websocket (WreqClientError): {}", err); - } - Err(GrokError::Client(err)) => { - error!("Error sending message to websocket (GrokClientError): {}", err); - } - Err(GrokError::ApiSpecific(err)) => { - error!("Error sending message to websocket (GrokSpecificApiError): {}", err); - } - Err(GrokError::ApiGeneric(err)) => { - error!("Error sending message to websocket (GrokGenericApiError): {}", err); - } - } - - let result = create_listen_websocket(CreateListenWebsocketArgs { - cookies: args.cookies.as_str(), - }).await?; - - maybe_new_websocket = Some(GrokWebsocket::new(result)); - } - - Ok(PromptWebsocketImageWithRetryResult { - maybe_new_websocket, - }) -} - -#[cfg(test)] -mod tests { - use crate::recipes::prompt_websocket_image_with_retry::{prompt_websocket_image_with_retry, PromptWebsocketImageWithRetryArgs}; - use crate::requests::image_websocket::create_listen_websocket::{create_listen_websocket, CreateListenWebsocketArgs}; - use crate::requests::image_websocket::grok_websocket::GrokWebsocket; - use crate::requests::image_websocket::grok_wrapped_websocket::GrokWrappedWebsocket; - use crate::requests::image_websocket::messages::websocket_client_message::ClientMessageAspectRatio; - use crate::requests::image_websocket::messages::websocket_server_message::WebsocketServerMessage; - use crate::requests::image_websocket::prompt_websocket_image::{prompt_websocket_image, PromptWebsocketImageArgs}; - use crate::test_utils::get_test_cookies::{get_test_cookies, get_typed_test_cookies}; - use errors::AnyhowResult; - use futures::SinkExt; - use log::warn; - use std::io::Write; - use std::time::Duration; - use wreq::ws::message::{CloseCode, Message, Utf8Bytes}; - - #[tokio::test] - #[ignore] // manually test - async fn prompt() -> AnyhowResult<()> { - //setup_test_logging(LevelFilter::Trace); - - let cookies = get_typed_test_cookies()?; - - let websocket = create_listen_websocket(CreateListenWebsocketArgs { - cookies: cookies.as_str(), - }).await?; - - let prompt = "A dinosaur on stilts walking on the beach"; - - //let websocket = GrokWrappedWebsocket::new(websocket); - let mut websocket = GrokWebsocket::new(websocket); - - //println!("Sending..."); - //std::io::stdout().flush()?; - - //println!("For our test, we'll close the websocket and retry..."); - //websocket.websocket - // .close(CloseCode::NORMAL, Utf8Bytes::try_from(Vec::new())?).await?; - - //let mut websocket = GrokWebsocket::new(websocket.websocket); - - let result = prompt_websocket_image_with_retry(PromptWebsocketImageWithRetryArgs { - websocket: &mut websocket, - prompt, - aspect_ratio: ClientMessageAspectRatio::WideThreeByTwo, - cookies: &cookies, - }).await?; - - println!("Reading..."); - std::io::stdout().flush()?; - - let mut count = 0; - - println!("Polling."); - - loop { - //let maybe_message = - // websocket.get_response_with_timeout(Duration::from_millis(1000)).await?; - - let maybe_message = - websocket.try_next_timeout(Duration::from_millis(1000)).await?; - - let mut maybe_raw_text : Option = None; - - let maybe_message = match maybe_message { - None => None, - Some(Message::Text(text)) => { - let maybe_message = WebsocketServerMessage::from_json_str(text.as_str())?; - let mut text = text.as_str().to_string(); - text.truncate(100); - //println!("Received message: {}", text); - maybe_raw_text = Some(text); - Some(maybe_message) - }, - Some(_) => { - warn!("Received non-text websocket message."); - None - }, - }; - - match maybe_message { - None => { - println!("No message received within timeout."); - count = count + 1; - } - Some(message) => { - match message { - WebsocketServerMessage::Image(image) => { - println!("IMAGE: {:?}", image.percentage_complete); - if let Some(percent) = image.percentage_complete { - if percent > 90.0 { - println!("Image: {:?}", image); - } - } - } - WebsocketServerMessage::Json(json) => { - println!("JSON : {:?}", json.percentage_complete); - if let Some(percent) = json.percentage_complete { - if percent > 90.0 { - println!("Image: {:?}", json); - } - } - } - WebsocketServerMessage::Unknown(unknown) => { - //let typ = unknown.get("type"); - let unknown_string = unknown.as_str(); - println!("[UNKNOWN] websocket message: {:?}", maybe_raw_text); - } - } - count = 0; - } - } - - // TODO: Make sure we capture all the events for images - // TODO: Explore the other APIs - // TODO understand the IDs - // TODO: Video websocket APIs - // TODO: Upload APIs - - if count > 5 { - println!("No messages after 5 seconds"); - break; - } - } - - println!("Done polling."); - - log::logger().flush(); - - assert_eq!(1,2); - - Ok(()) - } -} diff --git a/crates/api_clients/grok_consumer_client/src/recipes/request_client_secrets.rs b/crates/api_clients/grok_consumer_client/src/recipes/request_client_secrets.rs deleted file mode 100644 index f77afaff54..0000000000 --- a/crates/api_clients/grok_consumer_client/src/recipes/request_client_secrets.rs +++ /dev/null @@ -1,124 +0,0 @@ -use crate::credentials::grok_client_secrets::GrokClientSecrets; -use crate::credentials::grok_cookies::GrokCookies; -use crate::error::grok_error::GrokError; -use crate::error::grok_generic_api_error::GrokGenericApiError; -use crate::requests::index_page::get_index_page_and_scripts::{get_index_page_and_scripts, GetIndexPageAndScriptsArgs}; -use crate::requests::index_page::get_xsid_script::{get_xsid_script, GetXsidScriptArgs}; -use crate::requests::index_page::parsers::index::parse_index_baggage::parse_index_baggage; -use crate::requests::index_page::parsers::index::parse_index_sentry_trace::parse_index_sentry_trace; -use crate::requests::index_page::parsers::index::parse_index_svg_paths::parse_svg_paths_from_index_html; -use crate::requests::index_page::parsers::index::parse_index_user_email::parse_index_user_email; -use crate::requests::index_page::parsers::index::parse_index_user_id::parse_index_user_id; -use crate::requests::index_page::parsers::index::parse_index_verification_token::parse_index_verification_token; -use crate::requests::index_page::parsers::script::parse_script_actions_and_xsid_script_path::parse_script_actions_and_xsid_script_path; -use crate::requests::index_page::parsers::script::parse_xsid_script_numbers::parse_xsid_script_numbers; -use crate::requests::index_page::utils::convert_verification_token_to_loading_anim::convert_verification_token_to_loading_anim; -use crate::requests::index_page::utils::select_svg_path_by_loading_anim::select_svg_path_by_loading_anim; - -pub struct RequestClientSecretsArgs<'a> { - pub cookies: &'a GrokCookies, -} - -// Video generation needs: -// 1) baggage -- on index page -// 2) sentry_trace -- on index page -// 3) x_statsig - -/// Load all the things needed to make requests. -pub async fn request_client_secrets(args: RequestClientSecretsArgs<'_>) -> Result { - - let payloads = get_index_page_and_scripts(GetIndexPageAndScriptsArgs { - cookie: args.cookies.as_str(), - }).await?; - - let baggage = parse_index_baggage(&payloads.index_body_html) - .ok_or_else(|| GrokGenericApiError::IndexHtmlDidNotIncludeExpectedData { - message: "Index did not include baggage.".to_string() - })?; - - let sentry_trace = parse_index_sentry_trace(&payloads.index_body_html) - .ok_or_else(|| GrokGenericApiError::IndexHtmlDidNotIncludeExpectedData { - message: "Index did not include sentry trace.".to_string() - })?; - - let verification_token = parse_index_verification_token(&payloads.index_body_html) - .ok_or_else(|| GrokGenericApiError::IndexHtmlDidNotIncludeExpectedData { - message: "Index did not include verification token.".to_string() - })?; - - let user_id = parse_index_user_id(&payloads.index_body_html) - .ok_or_else(|| GrokGenericApiError::IndexHtmlDidNotIncludeExpectedData { - message: "Index did not include user id.".to_string() - })?; - - // NB: Optional. - let maybe_user_email = parse_index_user_email(&payloads.index_body_html); - - // NB: We'll only use one of the several SVG paths - let svg_paths = parse_svg_paths_from_index_html(&payloads.index_body_html); - - if svg_paths.is_empty() { - return Err(GrokGenericApiError::IndexHtmlDidNotIncludeExpectedData { - message: "Index did not include any SVG paths.".to_string(), - }.into()); - } - - let loading_anim = convert_verification_token_to_loading_anim(&verification_token)?; - - let svg_path_data = select_svg_path_by_loading_anim(&svg_paths, &loading_anim)?; - - let actions_and_xsid_script = parse_script_actions_and_xsid_script_path(&payloads.scripts)?; - - let xsid_script = get_xsid_script(GetXsidScriptArgs { - client: &payloads.client, - html: &payloads.index_body_html, - cookie: args.cookies.as_str(), - xsid_script_id: &actions_and_xsid_script.xsid_script_path, - }).await?; - - let numbers = parse_xsid_script_numbers(&xsid_script.xsid_script_body); - - if numbers.numbers.is_empty() { - return Err(GrokGenericApiError::IndexHtmlDidNotIncludeExpectedData { - message: "Index did not include any SVG paths.".to_string(), - }.into()); - } - - Ok(GrokClientSecrets { - baggage, - sentry_trace, - verification_token, - svg_path_data, - numbers, - user_id, - user_email: maybe_user_email, - }) -} - -#[cfg(test)] -mod tests { - use crate::recipes::request_client_secrets::{request_client_secrets, RequestClientSecretsArgs}; - use crate::test_utils::get_test_cookies::get_typed_test_cookies; - use errors::AnyhowResult; - - #[tokio::test] - #[ignore] // Manual test invocation - async fn test() -> AnyhowResult<()> { - let cookies = get_typed_test_cookies()?; - - let secrets = request_client_secrets(RequestClientSecretsArgs { - cookies: &cookies, - }).await?; - - println!("Baggage: {:?}", secrets.baggage); - println!("Sentry trace: {:?}", secrets.sentry_trace); - println!("Verification token: {:?}", secrets.verification_token); - println!("SVG path: {:?}", secrets.svg_path_data); - println!("Numbers: {:?}", secrets.numbers); - println!("User ID: {:?}", secrets.user_id); - println!("User Email: {:?}", secrets.user_email); - - assert_eq!(1, 2); - Ok(()) - } -} \ No newline at end of file diff --git a/crates/api_clients/grok_consumer_client/src/recipes/upload_image_and_generate_video.rs b/crates/api_clients/grok_consumer_client/src/recipes/upload_image_and_generate_video.rs deleted file mode 100644 index 01e8421010..0000000000 --- a/crates/api_clients/grok_consumer_client/src/recipes/upload_image_and_generate_video.rs +++ /dev/null @@ -1,242 +0,0 @@ -use crate::credentials::grok_full_credentials::GrokFullCredentials; -use crate::datatypes::api::aspect_ratio::AspectRatio; -use crate::datatypes::api::file_id::FileId; -use crate::datatypes::api::post_id::PostId; -use crate::datatypes::api::video_generation_mode::VideoGenerationMode; -use crate::datatypes::file_upload_spec::FileUploadSpec; -use crate::error::grok_error::GrokError; -use crate::error::grok_generic_api_error::GrokGenericApiError; -use crate::requests::media_posts::create_media_post::grok_create_media_post::{GrokCreateMediaPost, MediaPostType}; -use crate::requests::media_posts::like_media_post::grok_like_media::GrokLikeMediaPost; -use crate::requests::upload_file::grok_upload_file::GrokUploadFile; -use crate::requests::video_chat::grok_video_gen_chat_conversation::{GrokVideoGenChatConversationBuilder, VideoMediaPostType}; -use crate::utils::user_and_file_id_to_image_url::user_and_file_id_to_image_url; -use crate::utils::user_and_file_id_to_video_url::user_and_file_id_to_video_url; -use log::{error, info}; -use std::path::Path; -use std::time::Duration; - -pub struct UploadImageAndGenerateVideo<'a, P: AsRef> { - pub full_credentials: &'a GrokFullCredentials, - - // NB: Must be owned. - pub file: FileUploadSpec

, - - /// Video generation prompt - pub prompt: Option<&'a str>, - - /// Aspect ratio for the video. - pub aspect_ratio: Option, - - /// Mode to generate the video: normal, fun, spicy, etc. - pub mode: Option, - - /// Wait for the full video to be generated before returning - /// By default, the endpoint stays open for 30-ish seconds while - /// the video generates and streams back JSON progress updates. - /// If we set this to false, we'll wait for the video ID and exit - /// the request early, before the video is finished asynchronously - /// generating. - pub wait_for_generation: bool, - - pub individual_request_timeout: Option, -} - -#[derive(Debug, Clone)] -pub struct ImageUploadAndGenerateVideoResult { - /// The ID of the "post" - /// This often is equivalent to the upload id / `image_file_id`, - /// and this is in the user-facing URL for website navigation to the video. - pub post_id: PostId, - - /// The ID of the file we uploaded - pub image_file_id: FileId, - - /// The ID of the video we're generating, which may or may not exist yet. - pub video_file_id: Option, - - /// The URL for the video, which may or may not exist yet. - pub video_url: Option, - - /// Whether the video generation has already completed. - /// Based on request `wait_for_generation`. - pub generation_is_complete: bool, -} - -pub async fn upload_image_and_generate_video>(args: UploadImageAndGenerateVideo<'_, P>) - -> Result -{ - - info!("Uploading file to Grok..."); - - let request = GrokUploadFile { - file: args.file, - cookie: args.full_credentials.cookies.to_string(), - request_timeout: args.individual_request_timeout, - }; - - let upload_result = request.upload().await?; - - info!("File URI: {:?}", upload_result.file_uri); - info!("File Metadata ID: {:?}", upload_result.file_id); - - let upload_file_id = match upload_result.file_id { - Some(id) => id, - None => { - error!("Previous file upload failed. Cannot continue."); - return Err(GrokGenericApiError::UploadFailed.into()); - } - }; - - let url = user_and_file_id_to_image_url( - &args.full_credentials.client_secrets.user_id, - &upload_file_id - ); - - info!("Uploaded URI: {:?}", url); - - info!("Creating media post..."); - - let request = GrokCreateMediaPost { - user_id: &args.full_credentials.client_secrets.user_id, - file_id: &upload_file_id, - media_type: MediaPostType::UserUploadedImage, - cookie: args.full_credentials.cookies.as_str(), - request_timeout: args.individual_request_timeout, - }; - - let post_result = request.send().await?; - - info!("Posted Image."); - - info!("Video prompt: {:?}", args.prompt); - info!("Video aspect ratio: {:?}", args.aspect_ratio); - - info!("Generate video..."); - - let request = GrokVideoGenChatConversationBuilder { - user_id: &args.full_credentials.client_secrets.user_id, - file_id: &upload_file_id, - media_type: VideoMediaPostType::UserUploadedImage, - cookie: args.full_credentials.cookies.as_str(), - prompt: args.prompt, - mode: args.mode, - aspect_ratio: args.aspect_ratio, - request_timeout: args.individual_request_timeout, - baggage: &args.full_credentials.client_secrets.baggage, - sentry_trace: &args.full_credentials.client_secrets.sentry_trace, - verification_token: &args.full_credentials.client_secrets.verification_token, - svg_data: &args.full_credentials.client_secrets.svg_path_data, - numbers: &args.full_credentials.client_secrets.numbers, - }; - - let maybe_video_file_id; - let generation_is_complete; - - if args.wait_for_generation { - info!("Waiting for video generation..."); - let video_gen_result = request.wait_for_video().await?; - maybe_video_file_id = video_gen_result.video_file_id; - generation_is_complete = true; - } else { - info!("Streaming response partially..."); - let video_gen_result = request.stream_only_video_id().await?; - maybe_video_file_id = video_gen_result.video_file_id; - generation_is_complete = false; - } - - let maybe_video_url = maybe_video_file_id - .as_ref() - .map(|file_id| { - user_and_file_id_to_video_url(&args.full_credentials.client_secrets.user_id, file_id, false) - }); - - info!("Video Generation Enqueued"); - - info!("Liking media..."); - - let request = GrokLikeMediaPost { - file_id: &upload_file_id, - cookie: args.full_credentials.cookies.as_str(), - request_timeout: args.individual_request_timeout, - baggage: &args.full_credentials.client_secrets.baggage, - sentry_trace: &args.full_credentials.client_secrets.sentry_trace, - verification_token: &args.full_credentials.client_secrets.verification_token, - svg_data: &args.full_credentials.client_secrets.svg_path_data, - numbers: &args.full_credentials.client_secrets.numbers, - }; - - let _like_result = request.send().await?; - - info!("Media Liked"); - - Ok(ImageUploadAndGenerateVideoResult { - post_id: post_result.post_id, - image_file_id: upload_file_id, - video_file_id: maybe_video_file_id, - video_url: maybe_video_url, - generation_is_complete, - }) -} - - -#[cfg(test)] -mod tests { - use crate::credentials::grok_full_credentials::GrokFullCredentials; - use crate::datatypes::api::aspect_ratio::AspectRatio; - use crate::datatypes::file_upload_spec::FileUploadSpec; - use crate::recipes::request_client_secrets::{request_client_secrets, RequestClientSecretsArgs}; - use crate::recipes::upload_image_and_generate_video::{upload_image_and_generate_video, UploadImageAndGenerateVideo}; - use crate::test_utils::get_test_cookies::get_typed_test_cookies; - use crate::test_utils::setup_test_logging::setup_test_logging; - use errors::AnyhowResult; - use log::LevelFilter; - // Result: GrokUploadFileResponse { file_metadata_id: - // Some("acdee48f-9d6f-4bc6-9d06-fcc97dd4418a"), file_uri: - // Some("users/85980643-ffab-4984-a3de-59a608c47d7f/acdee48f-9d6f-4bc6-9d06-fcc97dd4418a/content") } - - #[tokio::test] - #[ignore] // Client side tests only - async fn test_upload_image_and_generate_video() -> AnyhowResult<()> { - setup_test_logging(LevelFilter::Info); - - //let image_path = "/Users/bt/Pictures/Zelda 64 Art/FCgYX6tWEAEhpsy.jpg"; - //let prompt = "our hero link plunges the sword into the pedestal, the temple is glowing with a blue aura"; - - let image_path = "/Users/bt/Pictures/Midjourney/hipster_girl.png"; - let maybe_prompt = Some("an anime girl runs away from a giant t-rex"); - - let cookies = get_typed_test_cookies()?; - - let secrets = request_client_secrets(RequestClientSecretsArgs { - cookies: &cookies, - }).await?; - - println!("[test] Verification Token: {:?}", secrets.verification_token); - println!("[test] Sentry Trace: {:?}", secrets.sentry_trace); - println!("[test] Numbers: {:?}", secrets.numbers); - println!("[test] Svg Path: {:?}", secrets.svg_path_data); - println!("[test] Baggage: {:?}", secrets.baggage); - - let credentials = GrokFullCredentials::from_cookies_and_client_secrets(cookies, secrets); - - let video_result = upload_image_and_generate_video(UploadImageAndGenerateVideo { - full_credentials: &credentials, - file: FileUploadSpec::Path(image_path), - prompt: maybe_prompt, - aspect_ratio: Some(AspectRatio::Square), - mode: None, - individual_request_timeout: None, - wait_for_generation: false, - }).await?; - - println!("[test] Post ID: {:?}", video_result.post_id); - println!("[test] Image File ID: {:?}", video_result.image_file_id); - println!("[test] Video File ID: {:?}", video_result.video_file_id); - println!("[test] Video URL: {:?}", video_result.video_url); - - assert_eq!(1, 2); - - Ok(()) - } -} diff --git a/crates/api_clients/grok_consumer_client/src/recipes/upload_image_and_generate_video_with_retry.rs b/crates/api_clients/grok_consumer_client/src/recipes/upload_image_and_generate_video_with_retry.rs deleted file mode 100644 index 856d97338a..0000000000 --- a/crates/api_clients/grok_consumer_client/src/recipes/upload_image_and_generate_video_with_retry.rs +++ /dev/null @@ -1,348 +0,0 @@ -use crate::credentials::grok_client_secrets::GrokClientSecrets; -use crate::credentials::grok_full_credentials::GrokFullCredentials; -use crate::datatypes::api::aspect_ratio::AspectRatio; -use crate::datatypes::api::video_generation_mode::VideoGenerationMode; -use crate::datatypes::file_upload_spec::FileUploadSpec; -use crate::error::grok_client_error::GrokClientError; -use crate::error::grok_error::GrokError; -use crate::error::grok_generic_api_error::GrokGenericApiError; -use crate::error::grok_specific_api_error::GrokSpecificApiError; -use crate::recipes::request_client_secrets::{request_client_secrets, RequestClientSecretsArgs}; -use crate::recipes::upload_image_and_generate_video::{ImageUploadAndGenerateVideoResult, UploadImageAndGenerateVideo}; -use crate::requests::media_posts::create_media_post::grok_create_media_post::{GrokCreateMediaPost, MediaPostType}; -use crate::requests::media_posts::like_media_post::grok_like_media::GrokLikeMediaPost; -use crate::requests::upload_file::grok_upload_file::GrokUploadFile; -use crate::requests::video_chat::grok_video_gen_chat_conversation::{GrokVideoGenChatConversationBuilder, VideoMediaPostType}; -use crate::utils::user_and_file_id_to_image_url::user_and_file_id_to_image_url; -use crate::utils::user_and_file_id_to_video_url::user_and_file_id_to_video_url; -use log::{error, info}; -use std::path::Path; -use std::time::Duration; - -pub struct UploadImageAndGenerateVideoWithRetry<'a, P: AsRef> { - pub credentials: &'a GrokFullCredentials, - - // NB: Must be owned. - pub file: FileUploadSpec

, - - /// Video generation prompt - pub prompt: Option<&'a str>, - - /// Aspect ratio for the video. - pub aspect_ratio: Option, - - /// Mode to generate the video: normal, fun, spicy, etc. - pub mode: Option, - - /// Wait for the full video to be generated before returning - /// By default, the endpoint stays open for 30-ish seconds while - /// the video generates and streams back JSON progress updates. - /// If we set this to false, we'll wait for the video ID and exit - /// the request early, before the video is finished asynchronously - /// generating. - pub wait_for_generation: bool, - - pub individual_request_timeout: Option, -} - -#[derive(Clone)] -pub struct ImageUploadAndGenerateVideoWithRetryResult { - /// If new secrets were generated, they're stored here. - pub maybe_new_client_secrets: Option, - - /// The video generation result. - pub upload_result: ImageUploadAndGenerateVideoResult, -} - -pub async fn upload_image_and_generate_video_with_retry>( - args: UploadImageAndGenerateVideoWithRetry<'_, P> -) -> Result { - - let mut current_full_credentials_ref = args.credentials; - let mut maybe_new_credentials = None; - - info!("Uploading file to Grok..."); - - let request = GrokUploadFile { - file: args.file, - cookie: current_full_credentials_ref.cookies.to_string(), - request_timeout: args.individual_request_timeout, - }; - - let upload_result = request.upload().await?; - - info!("File URI: {:?}", upload_result.file_uri); - info!("File Metadata ID: {:?}", upload_result.file_id); - - let upload_file_id = match upload_result.file_id { - Some(id) => id, - None => { - error!("Previous file upload failed. Cannot continue."); - return Err(GrokGenericApiError::UploadFailed.into()); - } - }; - - let url = user_and_file_id_to_image_url( - ¤t_full_credentials_ref.client_secrets.user_id, - &upload_file_id - ); - - info!("Uploaded URI: {:?}", url); - - info!("Creating media post..."); - - let request = GrokCreateMediaPost { - user_id: ¤t_full_credentials_ref.client_secrets.user_id, - file_id: &upload_file_id, - media_type: MediaPostType::UserUploadedImage, - cookie: current_full_credentials_ref.cookies.as_str(), - request_timeout: args.individual_request_timeout, - }; - - let post_result = request.send().await?; - - info!("Posted Image."); - - info!("Video prompt: {:?}", args.prompt); - info!("Video aspect ratio: {:?}", args.aspect_ratio); - - let mut video_enqueued_successfully = false; - let mut generation_is_complete= false; - let mut maybe_video_file_id = None; - let mut last_error = None; - - for i in 0..3 { - info!("Generate video... attempt {}", (i+1)); - - let request = GrokVideoGenChatConversationBuilder { - user_id: ¤t_full_credentials_ref.client_secrets.user_id, - file_id: &upload_file_id, - media_type: VideoMediaPostType::UserUploadedImage, - cookie: current_full_credentials_ref.cookies.as_str(), - prompt: args.prompt, - mode: args.mode, - aspect_ratio: args.aspect_ratio, - request_timeout: args.individual_request_timeout, - baggage: ¤t_full_credentials_ref.client_secrets.baggage, - sentry_trace: ¤t_full_credentials_ref.client_secrets.sentry_trace, - verification_token: ¤t_full_credentials_ref.client_secrets.verification_token, - svg_data: ¤t_full_credentials_ref.client_secrets.svg_path_data, - numbers: ¤t_full_credentials_ref.client_secrets.numbers, - }; - - let video_gen_result = - if args.wait_for_generation { - request.wait_for_video() - .await - .map(|res| res.video_file_id) - } else { - request.stream_only_video_id() - .await - .map(|res| res.video_file_id) - }; - - match video_gen_result { - Ok(res) => { - info!("Video Generation Enqueued!"); - video_enqueued_successfully = true; - generation_is_complete = args.wait_for_generation; // If we synchronously waited, it'll be complete. - maybe_video_file_id = res; - break; - } - Err(GrokError::ApiSpecific(GrokSpecificApiError::AutomationBlocked)) => { - info!("Grok automation blocked; renewing credentials."); - last_error = Some(GrokError::ApiSpecific(GrokSpecificApiError::AutomationBlocked)); - } - Err(err) => { - info!("Grok error; renewing credentials. Error = {:?}", err); - last_error = Some(err); - } - } - - info!("Refreshing Grok client secrets..."); - - let secrets = request_client_secrets(RequestClientSecretsArgs { - cookies: ¤t_full_credentials_ref.cookies, - }).await?; - - // NB: This is just to appease the borrow checker. It doesn't like that we're borrowing `maybe_new_credentials` - // in a loop and replacing it while borrowed, hence this hack. - current_full_credentials_ref = args.credentials; - - maybe_new_credentials = Some(GrokFullCredentials::from_cookies_and_client_secrets( - current_full_credentials_ref.cookies.clone(), - secrets, - )); - - if let Some(creds) = maybe_new_credentials.as_ref() { - current_full_credentials_ref = creds; - } - } - - if !video_enqueued_successfully { - if let Some(err) = last_error { - return Err(err); - } else { - // NB: This branch should be impossible as we should always set last_error. - return Err(GrokError::Client(GrokClientError::ErrorGeneratingVideo)) - } - } - - let mut video_liked_successfully = false; - let mut last_error = None; - - for i in 0..3 { - info!("Liking media ... attempt {}", (i+1)); - - let request = GrokLikeMediaPost { - file_id: &upload_file_id, - cookie: current_full_credentials_ref.cookies.as_str(), - request_timeout: args.individual_request_timeout, - baggage: ¤t_full_credentials_ref.client_secrets.baggage, - sentry_trace: ¤t_full_credentials_ref.client_secrets.sentry_trace, - verification_token: ¤t_full_credentials_ref.client_secrets.verification_token, - svg_data: ¤t_full_credentials_ref.client_secrets.svg_path_data, - numbers: ¤t_full_credentials_ref.client_secrets.numbers, - }; - - let like_result = request.send().await; - - match like_result { - Ok(_) => { - info!("Media Liked"); - video_liked_successfully = true; - break; - } - Err(GrokError::ApiSpecific(GrokSpecificApiError::AutomationBlocked)) => { - info!("Grok automation blocked liking media; renewing credentials."); - last_error = Some(GrokError::ApiSpecific(GrokSpecificApiError::AutomationBlocked)); - } - Err(err) => { - info!("Grok error liking media; renewing credentials. Error = {:?}", err); - last_error = Some(err); - } - } - - info!("Refreshing Grok client secrets..."); - - let secrets = request_client_secrets(RequestClientSecretsArgs { - cookies: ¤t_full_credentials_ref.cookies, - }).await?; - - // NB: This is just to appease the borrow checker. It doesn't like that we're borrowing `maybe_new_credentials` - // in a loop and replacing it while borrowed, hence this hack. - current_full_credentials_ref = args.credentials; - - maybe_new_credentials = Some(GrokFullCredentials::from_cookies_and_client_secrets( - current_full_credentials_ref.cookies.clone(), - secrets, - )); - - if let Some(creds) = maybe_new_credentials.as_ref() { - current_full_credentials_ref = creds; - } - } - - if !video_liked_successfully { - if let Some(err) = last_error { - return Err(err); - } else { - // NB: This branch should be impossible as we should always set last_error. - return Err(GrokError::Client(GrokClientError::ErrorGeneratingVideo)) - } - } - - let maybe_video_url = maybe_video_file_id - .as_ref() - .map(|file_id| { - user_and_file_id_to_video_url(¤t_full_credentials_ref.client_secrets.user_id, file_id, false) - }); - - Ok(ImageUploadAndGenerateVideoWithRetryResult { - maybe_new_client_secrets: maybe_new_credentials - .map(|secrets| secrets.client_secrets), - upload_result: ImageUploadAndGenerateVideoResult { - post_id: post_result.post_id, - image_file_id: upload_file_id, - video_file_id: maybe_video_file_id, - video_url: maybe_video_url, - generation_is_complete, - } - }) -} - - -#[cfg(test)] -mod tests { - use crate::credentials::grok_full_credentials::GrokFullCredentials; - use crate::datatypes::api::aspect_ratio::AspectRatio; - use crate::datatypes::api::video_generation_mode::VideoGenerationMode; - use crate::datatypes::file_upload_spec::FileUploadSpec; - use crate::recipes::request_client_secrets::{request_client_secrets, RequestClientSecretsArgs}; - use crate::recipes::upload_image_and_generate_video_with_retry::{upload_image_and_generate_video_with_retry, UploadImageAndGenerateVideoWithRetry}; - use crate::test_utils::get_test_cookies::get_typed_test_cookies; - use crate::test_utils::setup_test_logging::setup_test_logging; - use errors::AnyhowResult; - use log::LevelFilter; - - // Result: GrokUploadFileResponse { file_metadata_id: - // Some("acdee48f-9d6f-4bc6-9d06-fcc97dd4418a"), file_uri: - // Some("users/85980643-ffab-4984-a3de-59a608c47d7f/acdee48f-9d6f-4bc6-9d06-fcc97dd4418a/content") } - - #[tokio::test] - #[ignore] // Client side tests only - async fn test_upload_image_and_generate_video() -> AnyhowResult<()> { - setup_test_logging(LevelFilter::Info); - - //let image_path = "/Users/bt/Pictures/Zelda 64 Art/FCgYX6tWEAEhpsy.jpg"; - //let prompt = "our hero link plunges the sword into the pedestal, the temple is glowing with a blue aura"; - - let image_path = "/Users/bt/Pictures/Midjourney/hipster_girl.png"; - let maybe_prompt = Some("an anime girl turns and high fives a giant t-rex"); - - let cookies = get_typed_test_cookies()?; - - let mut bad_secrets = request_client_secrets(RequestClientSecretsArgs { - cookies: &cookies, - }).await?; - - // NB: We're purposely messing these up to trigger "retry". - bad_secrets.numbers.numbers = Vec::new(); - bad_secrets.sentry_trace.0 = "".to_string(); - - let credentials = GrokFullCredentials::from_cookies_and_client_secrets(cookies, bad_secrets); - - let result = upload_image_and_generate_video_with_retry(UploadImageAndGenerateVideoWithRetry { - credentials: &credentials, - file: FileUploadSpec::Path(image_path), - prompt: maybe_prompt, - mode: Some(VideoGenerationMode::Custom), - aspect_ratio: Some(AspectRatio::TallTwoByThree), - individual_request_timeout: None, - wait_for_generation: false, - }).await?; - - let new_secrets = result.maybe_new_client_secrets; - - println!("[test] New secrets ? : {:?}", new_secrets.is_some()); - - if let Some(secrets) = new_secrets { - println!("[test] Verification Token: {:?}", secrets.verification_token); - println!("[test] Sentry Trace: {:?}", secrets.sentry_trace); - println!("[test] Numbers: {:?}", secrets.numbers); - println!("[test] Svg Path: {:?}", secrets.svg_path_data); - println!("[test] Baggage: {:?}", secrets.baggage); - } - - let video_result = result.upload_result; - - println!("[test] Post ID: {:?}", video_result.post_id); - println!("[test] Image File ID: {:?}", video_result.image_file_id); - println!("[test] Video File ID: {:?}", video_result.video_file_id); - println!("[test] Video URL: {:?}", video_result.video_url); - - assert_eq!(1, 2); - - Ok(()) - } -} diff --git a/crates/api_clients/grok_consumer_client/src/requests/download_video_file/download_video_file.rs b/crates/api_clients/grok_consumer_client/src/requests/download_video_file/download_video_file.rs deleted file mode 100644 index 164c25aa77..0000000000 --- a/crates/api_clients/grok_consumer_client/src/requests/download_video_file/download_video_file.rs +++ /dev/null @@ -1,128 +0,0 @@ -use crate::client::browser_user_agents::FIREFOX_143_MAC_USER_AGENT; -use crate::datatypes::api::file_id::FileId; -use crate::datatypes::api::user_id::UserId; -use crate::error::grok_client_error::GrokClientError; -use crate::error::grok_error::GrokError; -use crate::error::grok_generic_api_error::GrokGenericApiError; -use crate::utils::user_and_file_id_to_video_url::user_and_file_id_to_video_url; -use log::{error, info, warn}; -use std::time::Duration; -use wreq::header::{ACCEPT, ACCEPT_ENCODING, ACCEPT_LANGUAGE, CACHE_CONTROL, CONNECTION, CONTENT_TYPE, COOKIE, ORIGIN, REFERER, TE, UPGRADE_INSECURE_REQUESTS, USER_AGENT}; -use wreq::Client; -use wreq_util::Emulation; - -pub struct DownloadVideoFileArgs<'a> { - pub cookies: &'a str, - pub user_id: &'a UserId, - pub file_id: &'a FileId, - pub request_timeout: Option, -} - -pub struct VideoFile { - pub bytes: Vec, -} - -pub async fn download_video_file(args: DownloadVideoFileArgs<'_>) -> Result { - - let client = Client::builder() - .emulation(Emulation::Firefox143) - .build() - .map_err(|err| GrokClientError::WreqClientError(err))?; - - let video_url = user_and_file_id_to_video_url(&args.user_id, &args.file_id, false); - - info!("Video file URL: {}", video_url); - - let mut request_builder = client.get(&video_url) - .header(USER_AGENT, FIREFOX_143_MAC_USER_AGENT) - .header(ACCEPT, "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8") - .header(ACCEPT_LANGUAGE, "en-US,en;q=0.5") - .header(ACCEPT_ENCODING, "gzip, deflate, br, zstd") - .header(REFERER, "https://grok.com/") - .header("Sec-GPC", "1") - .header(CONNECTION, "keep-alive") - .header(COOKIE, args.cookies) - .header(UPGRADE_INSECURE_REQUESTS, "1") - .header("sec-fetch-dest", "document") - .header("sec-fetch-mode", "navigate") - .header("sec-fetch-site", "same-site") - .header("sec-fetch-user", "?1") - .header("priority", "u=0, i"); - - - if let Some(timeout) = args.request_timeout { - request_builder = request_builder.timeout(timeout); - } - - let response = request_builder.send() - .await - .map_err(|err| GrokGenericApiError::WreqError(err))?; - - let status = response.status(); - - info!("Download video status: {:?}", status); - - let download_bytes = &response.bytes() - .await - .map_err(|err| { - error!("Error reading Grok create media response body: {:?}", err); - GrokGenericApiError::WreqError(err) - })?; - - // TODO: Classify errors - if !status.is_success() { - warn!("Not successful liking media (status: {:?})", status); - // error!("Upload file request returned an error (code {}) : {:?}", status.as_u16(), response_body); - // return Err(classify_general_http_status_code_and_body(status, response_body)); - } - - Ok(VideoFile { - bytes: download_bytes.to_vec(), - }) -} - -#[cfg(test)] -mod tests { - use std::fs::File; - use std::io::Write; - use crate::datatypes::api::file_id::FileId; - use crate::recipes::request_client_secrets::{request_client_secrets, RequestClientSecretsArgs}; - use crate::requests::download_video_file::download_video_file::{download_video_file, DownloadVideoFileArgs}; - use crate::test_utils::get_test_cookies::get_typed_test_cookies; - use errors::AnyhowResult; - - #[tokio::test] - #[ignore] // Client side tests only - async fn test_download() -> AnyhowResult<()> { - //setup_test_logging(LevelFilter::Trace); - - let cookies = get_typed_test_cookies()?; - - let file_id = FileId("d9b300c6-9562-4e24-a87a-3ede2a53f0bc".to_string()); // Ernest - - let secrets = request_client_secrets(RequestClientSecretsArgs { - cookies: &cookies, - }).await?; - - println!("Verification Token: {:?}", secrets.verification_token); - println!("Sentry Trace: {:?}", secrets.sentry_trace); - println!("Numbers: {:?}", secrets.numbers); - println!("Svg Path: {:?}", secrets.svg_path_data); - println!("Baggage: {:?}", secrets.baggage); - - let download = download_video_file(DownloadVideoFileArgs { - cookies: cookies.as_str(), - user_id: &secrets.user_id, - file_id: &file_id, - request_timeout: None, - }).await?; - - println!("Video byte length: {:?}", download.bytes.len()); - - let mut file = File::create("download_video_file.test.mp4")?; - file.write_all(&download.bytes)?; - - assert_eq!(1, 2); - Ok(()) - } -} \ No newline at end of file diff --git a/crates/api_clients/grok_consumer_client/src/requests/download_video_file/grok_download_video.rs b/crates/api_clients/grok_consumer_client/src/requests/download_video_file/grok_download_video.rs deleted file mode 100644 index ea415399e2..0000000000 --- a/crates/api_clients/grok_consumer_client/src/requests/download_video_file/grok_download_video.rs +++ /dev/null @@ -1,171 +0,0 @@ -use crate::client::browser_user_agents::FIREFOX_143_MAC_USER_AGENT; -use crate::datatypes::api::file_id::FileId; -use crate::datatypes::api::user_id::UserId; -use crate::error::grok_client_error::GrokClientError; -use crate::error::grok_error::GrokError; -use crate::error::grok_generic_api_error::GrokGenericApiError; -use crate::utils::user_and_file_id_to_video_url::user_and_file_id_to_video_url; -use futures::{StreamExt, TryStreamExt}; -use log::{error, info, warn}; -use std::io::Write; -use std::path::Path; -use std::time::Duration; -use tokio::fs::File; -use tokio::io::AsyncWriteExt; -use wreq::header::{ACCEPT, ACCEPT_ENCODING, ACCEPT_LANGUAGE, CACHE_CONTROL, CONNECTION, CONTENT_TYPE, COOKIE, ORIGIN, REFERER, TE, UPGRADE_INSECURE_REQUESTS, USER_AGENT}; -use wreq::{Client, Request, Response}; -use wreq_util::Emulation; - -pub struct GrokDownloadVideo<'a> { - pub cookies: &'a str, - pub user_id: &'a UserId, - pub file_id: &'a FileId, - pub request_timeout: Option, -} - -pub struct DownloadedVideoBytes { - pub bytes: Vec, -} - -impl <'a> GrokDownloadVideo<'a> { - - pub async fn download_to_path>(&self, path: P) -> Result<(), GrokError> { - let response = self.send_request().await?; - - let mut stream = response.bytes_stream(); - - let mut file = File::create(&path) - .await - .map_err(|err| GrokClientError::CannotOpenLocalFileForWriting(err))?; - - //let _r = stream.for_each_concurrent(None, |chunk_result| async { - // match chunk_result { - // Ok(chunk) => { - // file; - // //if let Err(e) = file.write_all(&chunk).await { - // // //error!("Error writing to file: {}", e); - // //} - // } - // Err(e) => { - // //error!("Error in stream: {}", e); - // } - // } - //}).await; - - while let Some(chunk) = stream.try_next() - .await - .map_err(|err| GrokGenericApiError::WreqError(err))? - { - file.write_all(&chunk) - .await - .map_err(|err| GrokClientError::CannotOpenLocalFileForWriting(err))? - } - - file.flush().await.unwrap(); - - Ok(()) - } - - pub async fn download_bytes(&self) -> Result { - let response = self.send_request().await?; - - let download_bytes = response.bytes() - .await - .map_err(|err| { - error!("Error reading Grok create media response body: {:?}", err); - GrokGenericApiError::WreqError(err) - })?; - - Ok(DownloadedVideoBytes { - bytes: download_bytes.to_vec(), - }) - } - - async fn send_request(&self) -> Result { - let client = Client::builder() - .emulation(Emulation::Firefox143) - .build() - .map_err(|err| GrokClientError::WreqClientError(err))?; - - let video_url = user_and_file_id_to_video_url(&self.user_id, &self.file_id, false); - - info!("Video file URL: {}", video_url); - - let mut request_builder = client.get(&video_url) - .header(USER_AGENT, FIREFOX_143_MAC_USER_AGENT) - .header(ACCEPT, "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8") - .header(ACCEPT_LANGUAGE, "en-US,en;q=0.5") - .header(ACCEPT_ENCODING, "gzip, deflate, br, zstd") - .header(REFERER, "https://grok.com/") - .header("Sec-GPC", "1") - .header(CONNECTION, "keep-alive") - .header(COOKIE, self.cookies.to_string()) - .header(UPGRADE_INSECURE_REQUESTS, "1") - .header("sec-fetch-dest", "document") - .header("sec-fetch-mode", "navigate") - .header("sec-fetch-site", "same-site") - .header("sec-fetch-user", "?1") - .header("priority", "u=0, i"); - - if let Some(timeout) = self.request_timeout { - request_builder = request_builder.timeout(timeout); - } - - let response = request_builder.send() - .await - .map_err(|err| GrokGenericApiError::WreqError(err))?; - - let status = response.status(); - - // TODO: Classify errors - if !status.is_success() { - warn!("Not successful liking media (status: {:?})", status); - // error!("Upload file request returned an error (code {}) : {:?}", status.as_u16(), response_body); - // return Err(classify_general_http_status_code_and_body(status, response_body)); - } - - Ok(response) - } -} - -#[cfg(test)] -mod tests { - use crate::datatypes::api::file_id::FileId; - use crate::recipes::request_client_secrets::{request_client_secrets, RequestClientSecretsArgs}; - use crate::requests::download_video_file::download_video_file::{download_video_file, DownloadVideoFileArgs}; - use crate::test_utils::get_test_cookies::get_typed_test_cookies; - use errors::AnyhowResult; - - #[tokio::test] - #[ignore] // Client side tests only - async fn test_download() -> AnyhowResult<()> { - //setup_test_logging(LevelFilter::Trace); - - let cookies = get_typed_test_cookies()?; - - let file_id = FileId("d9b300c6-9562-4e24-a87a-3ede2a53f0bc".to_string()); // Ernest - - let secrets = request_client_secrets(RequestClientSecretsArgs { - cookies: &cookies, - }).await?; - - println!("Verification Token: {:?}", secrets.verification_token); - println!("Sentry Trace: {:?}", secrets.sentry_trace); - println!("Numbers: {:?}", secrets.numbers); - println!("Svg Path: {:?}", secrets.svg_path_data); - println!("Baggage: {:?}", secrets.baggage); - - // TDOO: This implementation is untested. - //let download = download_video_file(DownloadVideoFileArgs { - // cookies: cookies.as_str(), - // user_id: &secrets.user_id, - // file_id: &file_id, - // request_timeout: None, - //}).await?; - - //println!("Video byte length: {:?}", download.bytes.len()); - - assert_eq!(1, 2); - Ok(()) - } -} \ No newline at end of file diff --git a/crates/api_clients/grok_consumer_client/src/requests/download_video_file/mod.rs b/crates/api_clients/grok_consumer_client/src/requests/download_video_file/mod.rs deleted file mode 100644 index bb83484e8a..0000000000 --- a/crates/api_clients/grok_consumer_client/src/requests/download_video_file/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod download_video_file; -pub mod grok_download_video; \ No newline at end of file diff --git a/crates/api_clients/grok_consumer_client/src/requests/image_websocket/_metadata/tls_fingerprint_checking.rs b/crates/api_clients/grok_consumer_client/src/requests/image_websocket/_metadata/tls_fingerprint_checking.rs deleted file mode 100644 index 868d379b34..0000000000 --- a/crates/api_clients/grok_consumer_client/src/requests/image_websocket/_metadata/tls_fingerprint_checking.rs +++ /dev/null @@ -1,81 +0,0 @@ -use crate::error::grok_client_error::GrokClientError; -use crate::error::grok_error::GrokError; -use std::time::Duration; -use wreq::header::{HeaderMap, USER_AGENT}; -use wreq::{Client, Proxy}; -use wreq_util::Emulation; - -const FINGERPRINT_URL : &str = "https://tools.scrapfly.io/api/tls"; - -fn build_chrome_140_client() -> Result { - Ok(Client::builder() - .emulation(Emulation::Chrome140) - .connection_verbose(true) - .connect_timeout(Duration::from_secs(10)) - .build() - .map_err(|err| GrokClientError::WreqClientError(err))?) -} - -fn build_firefox_139_client() -> Result { - Ok(Client::builder() - .emulation(Emulation::Firefox139) // NB: THIS IS IDENTICAL IN FINGERPRINT TO REAL FIREFOX !!! - .connection_verbose(true) - .connect_timeout(Duration::from_secs(10)) - .build() - .map_err(|err| GrokClientError::WreqClientError(err))?) -} - -fn build_firefox_143_client() -> Result { - Ok(Client::builder() - .emulation(Emulation::Firefox143) // NB: THIS IS IDENTICAL IN FINGERPRINT TO REAL FIREFOX !!! - .connection_verbose(true) - .connect_timeout(Duration::from_secs(10)) - .build() - .map_err(|err| GrokClientError::WreqClientError(err))?) -} - -fn build_raw_firefox_client_with_proxy() -> Result { - let proxy = Proxy::https("http://127.0.0.1:8080") - .map_err(|err| GrokClientError::WreqClientError(err))?; - Ok(Client::builder() - .emulation(Emulation::Firefox143) - .default_headers(HeaderMap::new()) - .proxy(proxy) - .cert_verification(false) - .connection_verbose(true) - .connect_timeout(Duration::from_secs(10)) - .build() - .map_err(|err| GrokClientError::WreqClientError(err))?) -} - -async fn get_with_client(client: &Client) -> Result { - let builder = client.get(FINGERPRINT_URL) - .header("Accept", "application/json"); - - let response = builder.send() - .await - .map_err(|err| GrokClientError::WreqClientError(err))?; - - - let body = response.text() - .await - .map_err(|err| GrokClientError::WreqClientError(err))?; - - Ok(body) -} - -#[cfg(test)] -mod tests { - use errors::AnyhowResult; - use super::*; - - #[tokio::test] - #[ignore] // manually test - async fn test() -> AnyhowResult<()> { - let client = build_firefox_143_client()?; - let body = get_with_client(&client).await?; - println!("{}", body); - assert_eq!(1, 2); - Ok(()) - } -} diff --git a/crates/api_clients/grok_consumer_client/src/requests/image_websocket/create_listen_websocket.rs b/crates/api_clients/grok_consumer_client/src/requests/image_websocket/create_listen_websocket.rs deleted file mode 100644 index 6e3f349d6b..0000000000 --- a/crates/api_clients/grok_consumer_client/src/requests/image_websocket/create_listen_websocket.rs +++ /dev/null @@ -1,106 +0,0 @@ -use crate::client::browser_user_agents::FIREFOX_143_MAC_USER_AGENT; -use crate::error::grok_client_error::GrokClientError; -use crate::error::grok_error::GrokError; -use crate::error::grok_generic_api_error::GrokGenericApiError; -use cloudflare_mitigation::headers::firefox_websocket_http_1_1_headers::get_firefox_websocket_http_1_1_headers; -use std::ops::{Deref, DerefMut}; -use std::time::Duration; -use tokio::io::AsyncReadExt; -use wreq::header::{ACCEPT, ACCEPT_LANGUAGE, CACHE_CONTROL, COOKIE, ORIGIN, PRAGMA, SEC_WEBSOCKET_EXTENSIONS, USER_AGENT}; -use wreq::ws::WebSocket; -use wreq::Client; -use wreq_util::Emulation; - -const WEBSOCKET_URL: &str = "wss://grok.com/ws/imagine/listen"; - -pub struct CreateListenWebsocketArgs<'a> { - pub cookies: &'a str, -} - -pub async fn create_listen_websocket(args: CreateListenWebsocketArgs<'_>) -> Result { - let mut client_builder = Client::builder() - .emulation(Emulation::Firefox143) - .connection_verbose(true) - .connect_timeout(Duration::from_secs(30)); - - let client = client_builder - .build() - .map_err(|err| GrokClientError::WreqClientError(err))?; - - // NB: We need to be careful with this because HTTP/1.1 WebSocket handshake is sensitive to header casing and order. - // Cloudflare doesn't like lower case header names, and we're sending headers in the right order just to be safe. - let builder = client.websocket(WEBSOCKET_URL) - .default_headers(false) - .orig_headers(get_firefox_websocket_http_1_1_headers()) - .header(COOKIE, args.cookies) - .header(ORIGIN,"https://grok.com") - .header(USER_AGENT, FIREFOX_143_MAC_USER_AGENT) - .header(SEC_WEBSOCKET_EXTENSIONS, "permessage-deflate") - .header(ACCEPT, "*/*") - .header(ACCEPT_LANGUAGE, "en-US,en;q=0.5") - .header("Sec-Fetch-Dest", "empty") - .header("Sec-Fetch-Mode", "websocket") - .header("Sec-Fetch-Site", "same-origin") - .header(PRAGMA, "no-cache") - .header(CACHE_CONTROL, "no-cache"); - - let mut response = builder.send() - .await - .map_err(|err| GrokClientError::WreqClientError(err))?; - - let status = response.status(); - - match status.as_u16() { - 101 => { - // Successful WebSocket upgrade ... fallthrough. - } - 401 => { - // 401 is a likely authentication error with Grok itself. - // Unfortunately we can't read the response body text because wreq wants to consume the Response to get it, but the - // WebsocketResponse type wraps and doesn't let us move it. It's wreq's fault. - return Err(GrokError::ApiGeneric(GrokGenericApiError::LikelyWebsocketAuthentication401)); - } - 403 => { - // 403 is likely a cloudflare error - // Unfortunately we can't read the response body text because wreq wants to consume the Response to get it, but the - // WebsocketResponse type wraps and doesn't let us move it. It's wreq's fault. - return Err(GrokError::ApiGeneric(GrokGenericApiError::LikelyWebsocketCloudflare403)); - } - _ => { - return Err(GrokError::ApiGeneric(GrokGenericApiError::UnexpectedWebsocketUpgradeStatusCode(status))); - }, - } - - let websocket = response.into_websocket() - .await - .map_err(|err| GrokGenericApiError::WreqWebsocketUpgradeError(err))?; - - Ok(websocket) -} - -#[cfg(test)] -mod tests { - use super::*; - use crate::test_utils::get_test_cookies::get_test_cookies; - use crate::test_utils::setup_test_logging::setup_test_logging; - use errors::AnyhowResult; - use log::LevelFilter; - - #[tokio::test] - #[ignore] // manually test - async fn create() -> AnyhowResult<()> { - setup_test_logging(LevelFilter::Trace); - //let cookies = SESSION_COOKIES_WITHOUT_CF_CLEARANCE; - let cookies = get_test_cookies()?; - let args = CreateListenWebsocketArgs { - cookies: &cookies, - }; - let result = create_listen_websocket(args).await; - if let Err(err) = result { - println!("Error: {:?}", err); - } - log::logger().flush(); - assert_eq!(1, 2); - Ok(()) - } -} diff --git a/crates/api_clients/grok_consumer_client/src/requests/image_websocket/grok_websocket.rs b/crates/api_clients/grok_consumer_client/src/requests/image_websocket/grok_websocket.rs deleted file mode 100644 index 9780099bb2..0000000000 --- a/crates/api_clients/grok_consumer_client/src/requests/image_websocket/grok_websocket.rs +++ /dev/null @@ -1,108 +0,0 @@ -use crate::error::grok_client_error::GrokClientError; -use crate::error::grok_error::GrokError; -use crate::requests::image_websocket::messages::websocket_server_message::WebsocketServerMessage; -use futures::stream::FusedStream; -use futures::{Stream, TryStreamExt}; -use log::{info, warn}; -use serde::Serialize; -use std::sync::{Arc, RwLock}; -use std::time::Duration; -use wreq::ws::message::Message; -use wreq::ws::WebSocket; - -pub struct GrokWebsocket { - pub(crate) websocket: WebSocket, -} - -impl GrokWebsocket { - pub fn new(websocket: WebSocket) -> Self { - Self { - websocket, - } - } - - pub async fn send(&mut self, message: String) -> Result<(), GrokError> { - let message = Message::text(message); - self.websocket.send(message) - .await - .map_err(|err| { - GrokClientError::WreqClientError(err) - })?; - Ok(()) - } - - pub async fn send_serializable(&mut self, message: T) -> Result<(), GrokError> { - let message_json = serde_json::to_string(&message) - .map_err(|err| { - warn!("Failed to serialize prompt websocket message: {}", err); - GrokClientError::WebsocketRequestSerializationError(err) - })?; - self.send(message_json).await - } - - pub async fn get_response_with_timeout(&mut self, duration: Duration) -> Result, GrokError> { - let result = tokio::time::timeout(duration, self.websocket.try_next()).await; - - match result { - Err(elapsed) => { - info!("Websocket try_next() elapsed without receiving a message: {:?}", elapsed); - Ok(None) // Timeout elapsed. - } - Ok(inner) => { - let maybe_message = inner.map_err(GrokClientError::WebsocketReadError)?; - - match maybe_message { - None => Ok(None), - Some(Message::Text(text)) => { - let maybe_message = WebsocketServerMessage::from_json_str(&text)?; - Ok(Some(maybe_message)) - }, - Some(_) => { - warn!("Received non-text websocket message."); - Ok(None) - }, - } - } - } - } - - pub async fn try_next_timeout(&mut self, duration: Duration) -> Result, GrokClientError> { - let result = tokio::time::timeout(duration, self.websocket.try_next()).await; - - match result { - Err(elapsed) => { - info!("Websocket try_next() elapsed without receiving a message: {:?}", elapsed); - Ok(None) // Timeout elapsed. - } - Ok(inner) => { - let maybe_message = inner.map_err(GrokClientError::WebsocketReadError)?; - Ok(maybe_message) - } - } - } - - // pub async fn is_terminated(&self) -> Result { - // match self.websocket.read() { - // Err(_) => Err(GrokClientError::WebsocketLockError.into()), - // Ok(websocket) => Ok(websocket.is_terminated()), - // } - // } - - // /// NB: This will block forever if there is no item. - // pub async fn try_next(&self) -> Result, GrokClientError> { - // match self.websocket.write() { - // Err(_) => Err(GrokClientError::WebsocketLockError), - // Ok(mut websocket) => websocket - // .try_next() - // .await - // .map_err(|err| GrokClientError::WebsocketReadError(err)), - // } - // } - - // pub fn size_hint(&self) -> Result<(usize, Option), GrokClientError> { - // match self.websocket.read() { - // Err(_) => Err(GrokClientError::WebsocketLockError), - // Ok(websocket) => Ok(websocket.size_hint()) - // } - // } -} diff --git a/crates/api_clients/grok_consumer_client/src/requests/image_websocket/grok_wrapped_websocket.rs b/crates/api_clients/grok_consumer_client/src/requests/image_websocket/grok_wrapped_websocket.rs deleted file mode 100644 index 712d1878f9..0000000000 --- a/crates/api_clients/grok_consumer_client/src/requests/image_websocket/grok_wrapped_websocket.rs +++ /dev/null @@ -1,124 +0,0 @@ -use crate::error::grok_client_error::GrokClientError; -use crate::error::grok_error::GrokError; -use crate::requests::image_websocket::messages::websocket_server_message::WebsocketServerMessage; -use futures::stream::FusedStream; -use futures::{Stream, TryStreamExt}; -use log::{info, warn}; -use serde::Serialize; -use std::sync::{Arc, RwLock}; -use std::time::Duration; -use wreq::ws::message::Message; -use wreq::ws::WebSocket; - -#[derive(Clone)] -pub struct GrokWrappedWebsocket { - pub(crate) websocket: Arc>, -} - -impl GrokWrappedWebsocket { - pub fn new(websocket: WebSocket) -> Self { - Self { - websocket: Arc::new(RwLock::new(websocket)), - } - } - - pub async fn send(&self, message: String) -> Result<(), GrokError> { - match self.websocket.write() { - Err(err) => Err(GrokClientError::WebsocketLockError.into()), - Ok(mut websocket) => { - let message = Message::text(message); - websocket.send(message) - .await - .map_err(|err| { - GrokClientError::WreqClientError(err) - })?; - Ok(()) - }, - } - } - - pub async fn send_serializable(&self, message: T) -> Result<(), GrokError> { - let message_json = serde_json::to_string(&message) - .map_err(|err| { - warn!("Failed to serialize prompt websocket message: {}", err); - GrokClientError::WebsocketRequestSerializationError(err) - })?; - self.send(message_json).await - } - - pub async fn get_response_with_timeout(&self, duration: Duration) -> Result, GrokError> { - match self.websocket.write() { - Err(_) => Err(GrokClientError::WebsocketLockError.into()), - Ok(mut websocket) => { - let result = tokio::time::timeout(duration, websocket.try_next()).await; - - match result { - Err(elapsed) => { - info!("Websocket try_next() elapsed without receiving a message: {:?}", elapsed); - Ok(None) // Timeout elapsed. - } - Ok(inner) => { - let maybe_message = inner.map_err(GrokClientError::WebsocketReadError)?; - - match maybe_message { - None => Ok(None), - Some(Message::Text(text)) => { - let maybe_message = WebsocketServerMessage::from_json_str(&text)?; - Ok(Some(maybe_message)) - }, - Some(_) => { - warn!("Received non-text websocket message."); - Ok(None) - }, - } - } - } - }, - } - } - - pub async fn try_next_timeout(&self, duration: Duration) -> Result, GrokClientError> { - match self.websocket.write() { - Err(_) => Err(GrokClientError::WebsocketLockError), - Ok(mut websocket) => { - let result = tokio::time::timeout(duration, websocket.try_next()).await; - - match result { - Err(elapsed) => { - info!("Websocket try_next() elapsed without receiving a message: {:?}", elapsed); - Ok(None) // Timeout elapsed. - } - Ok(inner) => { - let maybe_message = inner.map_err(GrokClientError::WebsocketReadError)?; - Ok(maybe_message) - } - } - }, - } - } - - // pub async fn is_terminated(&self) -> Result { - // match self.websocket.read() { - // Err(_) => Err(GrokClientError::WebsocketLockError.into()), - // Ok(websocket) => Ok(websocket.is_terminated()), - // } - // } - - // /// NB: This will block forever if there is no item. - // pub async fn try_next(&self) -> Result, GrokClientError> { - // match self.websocket.write() { - // Err(_) => Err(GrokClientError::WebsocketLockError), - // Ok(mut websocket) => websocket - // .try_next() - // .await - // .map_err(|err| GrokClientError::WebsocketReadError(err)), - // } - // } - - // pub fn size_hint(&self) -> Result<(usize, Option), GrokClientError> { - // match self.websocket.read() { - // Err(_) => Err(GrokClientError::WebsocketLockError), - // Ok(websocket) => Ok(websocket.size_hint()) - // } - // } -} diff --git a/crates/api_clients/grok_consumer_client/src/requests/image_websocket/listen_for_websocket_images.rs b/crates/api_clients/grok_consumer_client/src/requests/image_websocket/listen_for_websocket_images.rs deleted file mode 100644 index 4a192cb224..0000000000 --- a/crates/api_clients/grok_consumer_client/src/requests/image_websocket/listen_for_websocket_images.rs +++ /dev/null @@ -1,176 +0,0 @@ -use crate::datatypes::api::request_id::RequestId; -use crate::error::grok_client_error::GrokClientError; -use crate::error::grok_error::GrokError; -use crate::requests::image_websocket::grok_websocket::GrokWebsocket; -use crate::requests::image_websocket::grok_wrapped_websocket::GrokWrappedWebsocket; -use crate::requests::image_websocket::messages::message_image_data::MessageImageData; -use crate::utils::scrub_blobs_for_debug_logging::scrub_blobs_for_debug_logging; -use log::info; -use std::time::{Duration, Instant}; -use wreq::ws::message::Message; - -// Number of images we get per prompt by default -const DEFAULT_IMAGE_COUNT: usize = 6; - -pub struct ListenForWebsocketImagesArgs<'a> { - pub websocket: &'a mut GrokWebsocket, - pub timeout: Duration, -} - -#[derive(Clone, Debug)] -pub struct ImageResults { - pub images: Vec, -} - -#[derive(Clone, Debug)] -pub struct ImageData { - /// The "task" that generated the image - /// Multiple images have the same "task" - pub request_id: RequestId, - - /// Url where we can download the image. - pub url: String, - - /// The user-input prompt - pub user_prompt: String, - - /// An X.ai-enriched prompt - pub enriched_prompt: String, -} - -pub async fn listen_for_websocket_images(args: ListenForWebsocketImagesArgs<'_>) -> Result { - let start = Instant::now(); - let end_at = start.checked_add(args.timeout); - let end_at = match end_at { - Some(end_at) => end_at, - None => return Err(GrokClientError::TimeoutMathBroken.into()), - }; - - let mut images = Vec::new(); - - loop { - if end_at < Instant::now() { - break; - } - - let maybe_message = args.websocket.try_next_timeout(Duration::from_millis(500)).await?; - - let maybe_message = match maybe_message { - None => None, - Some(Message::Text(text)) => Some(text.to_string()), - Some(_) => { - // Got a ping, pong, binary payload, etc. - None - }, - }; - - let message = match maybe_message { - Some(message) => message, - None => continue, - }; - - let maybe_image_data = serde_json::from_str::(&message); - - let image_data = match maybe_image_data { - Ok(image_data) => image_data, - Err(_err) => { - - let message = scrub_blobs_for_debug_logging(&message); - println!("Unknown message: {}", message); - - // NB: Might not have been a parse error, since we're parsing irrelevant message payloads too. - // This is slightly dangerous to do this way as we might mask true parsing errors with image payloads. - continue; - } - }; - - match image_data.percentage_complete { - None => continue, - Some(percent) => { - if percent < 100.0 { - continue; - } - } - } - - images.push(ImageData { - request_id: RequestId(image_data.request_id), - url : image_data.url, - enriched_prompt: image_data.full_prompt, - user_prompt: image_data.prompt, - }); - - if images.len() >= DEFAULT_IMAGE_COUNT { - info!("{} images generated; we're done polling.", images.len()); - break; - } - } - - Ok(ImageResults { - images, - }) -} - - -#[cfg(test)] -mod tests { - use crate::requests::image_websocket::create_listen_websocket::{create_listen_websocket, CreateListenWebsocketArgs}; - use crate::requests::image_websocket::grok_websocket::GrokWebsocket; - use crate::requests::image_websocket::listen_for_websocket_images::{listen_for_websocket_images, ListenForWebsocketImagesArgs}; - use crate::requests::image_websocket::messages::websocket_client_message::ClientMessageAspectRatio; - use crate::requests::image_websocket::prompt_websocket_image::{prompt_websocket_image, PromptWebsocketImageArgs}; - use crate::test_utils::get_test_cookies::get_test_cookies; - use crate::test_utils::setup_test_logging::setup_test_logging; - use errors::AnyhowResult; - use log::LevelFilter; - use std::io::Write; - use std::time::Duration; - - #[tokio::test] - #[ignore] // manually test - async fn prompt() -> AnyhowResult<()> { - setup_test_logging(LevelFilter::Info); - - let prompt = "A tornado hitting the stadium"; - - let cookies = get_test_cookies()?; - - let websocket = create_listen_websocket(CreateListenWebsocketArgs { - cookies: &cookies, - }).await?; - - //let websocket = GrokWrappedWebsocket::new(websocket); - let mut websocket = GrokWebsocket::new(websocket); - - println!("Sending..."); - std::io::stdout().flush()?; - - let _result = prompt_websocket_image(PromptWebsocketImageArgs { - websocket: &mut websocket, - prompt, - aspect_ratio: ClientMessageAspectRatio::WideThreeByTwo, - }).await?; - - println!("Reading..."); - std::io::stdout().flush()?; - - println!("Polling."); - - let images = listen_for_websocket_images(ListenForWebsocketImagesArgs { - websocket: &mut websocket, - timeout: Duration::from_millis(10_000), - }).await?; - - println!("Done polling. Images: {}", images.images.len()); - - for image in images.images { - println!("Image: {:?}", image); - } - - log::logger().flush(); - - assert_eq!(1,2); - - Ok(()) - } -} diff --git a/crates/api_clients/grok_consumer_client/src/requests/image_websocket/listen_for_websocket_request_id.rs b/crates/api_clients/grok_consumer_client/src/requests/image_websocket/listen_for_websocket_request_id.rs deleted file mode 100644 index 3a35791dd3..0000000000 --- a/crates/api_clients/grok_consumer_client/src/requests/image_websocket/listen_for_websocket_request_id.rs +++ /dev/null @@ -1,127 +0,0 @@ -use crate::datatypes::api::request_id::RequestId; -use crate::error::grok_client_error::GrokClientError; -use crate::error::grok_error::GrokError; -use crate::requests::image_websocket::grok_websocket::GrokWebsocket; -use crate::requests::image_websocket::messages::message_request_id::MessageRequestId; -use std::time::{Duration, Instant}; -use wreq::ws::message::Message; - -pub struct ListenForWebsocketRequestIdArgs<'a> { - pub websocket: &'a mut GrokWebsocket, - pub timeout: Duration, -} - -#[derive(Clone, Debug)] -pub struct RequestIdResult { - pub request_id: Option, -} - -pub async fn listen_for_websocket_request_id(args: ListenForWebsocketRequestIdArgs<'_>) -> Result { - let start = Instant::now(); - let end_at = start.checked_add(args.timeout); - let end_at = match end_at { - Some(end_at) => end_at, - None => return Err(GrokClientError::TimeoutMathBroken.into()), - }; - - let mut request_id = None; - - loop { - if end_at < Instant::now() { - break; - } - - let maybe_message = args.websocket.try_next_timeout(Duration::from_millis(500)).await?; - - let maybe_message = match maybe_message { - None => None, - Some(Message::Text(text)) => Some(text.to_string()), - Some(_) => { - // Got a ping, pong, binary payload, etc. - None - }, - }; - - let message = match maybe_message { - Some(message) => message, - None => continue, - }; - - let maybe_parsed = serde_json::from_str::(&message); - - let parsed = match maybe_parsed { - Ok(parsed) => parsed, - Err(_err) => { - // NB: Might not have been a parse error, since we're parsing irrelevant message payloads too. - // This is slightly dangerous to do this way as we might mask true parsing errors with image payloads. - continue; - } - }; - - request_id = Some(RequestId(parsed.request_id)); - break; - } - - Ok(RequestIdResult { - request_id, - }) -} - - -#[cfg(test)] -mod tests { - use crate::requests::image_websocket::create_listen_websocket::{create_listen_websocket, CreateListenWebsocketArgs}; - use crate::requests::image_websocket::grok_websocket::GrokWebsocket; - use crate::requests::image_websocket::listen_for_websocket_request_id::{listen_for_websocket_request_id, ListenForWebsocketRequestIdArgs}; - use crate::requests::image_websocket::messages::websocket_client_message::ClientMessageAspectRatio; - use crate::requests::image_websocket::prompt_websocket_image::{prompt_websocket_image, PromptWebsocketImageArgs}; - use crate::test_utils::get_test_cookies::get_test_cookies; - use crate::test_utils::setup_test_logging::setup_test_logging; - use errors::AnyhowResult; - use log::LevelFilter; - use std::io::Write; - use std::time::Duration; - - #[tokio::test] - #[ignore] // manually test - async fn prompt() -> AnyhowResult<()> { - setup_test_logging(LevelFilter::Info); - - let prompt = "A tiny tornado on a desk"; - - let cookies = get_test_cookies()?; - - let mut websocket = create_listen_websocket(CreateListenWebsocketArgs { - cookies: &cookies, - }).await?; - - //let websocket = GrokWrappedWebsocket::new(websocket); - let mut websocket = GrokWebsocket::new(websocket); - - println!("Sending..."); - std::io::stdout().flush()?; - - let _result = prompt_websocket_image(PromptWebsocketImageArgs { - websocket: &mut websocket, - prompt, - aspect_ratio: ClientMessageAspectRatio::Square, - }).await?; - - println!("Reading..."); - std::io::stdout().flush()?; - - println!("Polling."); - - let request_data = listen_for_websocket_request_id(ListenForWebsocketRequestIdArgs { - websocket: &mut websocket, - timeout: Duration::from_millis(10_000), - }).await?; - - println!("Done polling. Request Data: {:?}", request_data); - log::logger().flush(); - - assert_eq!(1,2); - - Ok(()) - } -} diff --git a/crates/api_clients/grok_consumer_client/src/requests/image_websocket/messages/message_image_data.rs b/crates/api_clients/grok_consumer_client/src/requests/image_websocket/messages/message_image_data.rs deleted file mode 100644 index 1fd37da356..0000000000 --- a/crates/api_clients/grok_consumer_client/src/requests/image_websocket/messages/message_image_data.rs +++ /dev/null @@ -1,63 +0,0 @@ -use serde::Deserialize; - - -/// Images with a binary blob and URLs. -/// We may receive several of these for a single prompt. -#[derive(Deserialize, Clone, Debug)] -pub struct MessageImageData { - /// UUID. - /// Probably an identifier for the original request/prompt. - pub request_id: String, // Option, - - /// UUID. - /// This turns out to be the file ID in the image URL (and `job_id`). - pub id: Option, - - /// UUID. - /// This turns out to be the file ID in the image URL (and `id`). - pub job_id: Option, - - /// Eg. null, "0", "50", "100" - pub percentage_complete: Option, - - /// The user's prompt - pub prompt: String, //pub prompt: Option, - - /// The X.ai enriched prompt - pub full_prompt: String, //pub full_prompt: Option, - - /// URL to the image. - pub url: String, //pub url: Option, - - // We don't need to decode - let's just download again - // /// Base64 encoded image blob. - // pub blob: Option, - - // /// NSFW flag - // pub r_rated: Option, - - // /// Name of the model used to generate the image - // /// eg. "imagine_h_1", "imagine_x_1" - // pub model_name: Option, -} - -/* -Received websocket message: { - "type": "image", - "blob": "...", - "job_id": "260270db-2515-470b-a730-1fe87e11d21c", - "grid_index": 0, - "is_alteration": false, - "order": 0, - "section_id": 0, - "request_id": "57b94c87-ae13-4ade-8fc0-ebd39fb511ec", - "url": "https://imagine-public.x.ai/imagine-public/images/260270db-2515-470b-a730-1fe87e11d21c.png", - "id": "260270db-2515-470b-a730-1fe87e11d21c", - "prompt": "a dog riding a motorcycle", - "full_prompt": "A dog sits in a motorcycle sidecar on a paved road with a natural background.", - "percentage_complete": 100.0, - "model_name": "imagine_x_1", - "suggested_moderation_rule": "MODERATION_RULE_DEFAULT", - "r_rated":false -} -*/ diff --git a/crates/api_clients/grok_consumer_client/src/requests/image_websocket/messages/message_request_id.rs b/crates/api_clients/grok_consumer_client/src/requests/image_websocket/messages/message_request_id.rs deleted file mode 100644 index cb7fc20b38..0000000000 --- a/crates/api_clients/grok_consumer_client/src/requests/image_websocket/messages/message_request_id.rs +++ /dev/null @@ -1,11 +0,0 @@ -use serde::Deserialize; - -/// This could intercept any message with a "request_id" -/// We're going to try to use these to end the image prompting early. -/// If we're not careful, we might accidentally ingest completed image messages this way. -#[derive(Deserialize, Clone, Debug)] -pub struct MessageRequestId { - /// UUID. - /// Probably an identifier for the original request/prompt. - pub request_id: String, // Option, -} diff --git a/crates/api_clients/grok_consumer_client/src/requests/image_websocket/messages/mod.rs b/crates/api_clients/grok_consumer_client/src/requests/image_websocket/messages/mod.rs deleted file mode 100644 index 3e831ada65..0000000000 --- a/crates/api_clients/grok_consumer_client/src/requests/image_websocket/messages/mod.rs +++ /dev/null @@ -1,4 +0,0 @@ -pub mod message_image_data; -pub mod message_request_id; -pub mod websocket_client_message; -pub mod websocket_server_message; \ No newline at end of file diff --git a/crates/api_clients/grok_consumer_client/src/requests/image_websocket/messages/websocket_client_message.rs b/crates/api_clients/grok_consumer_client/src/requests/image_websocket/messages/websocket_client_message.rs deleted file mode 100644 index f6422fad2c..0000000000 --- a/crates/api_clients/grok_consumer_client/src/requests/image_websocket/messages/websocket_client_message.rs +++ /dev/null @@ -1,90 +0,0 @@ -use chrono::Utc; -use serde::Serialize; -use uuid::Uuid; - -#[derive(Serialize)] -pub struct WebsocketClientMessage { - /// Type of message - /// eg. "conversation.item.create" - pub r#type: String, - - /// Unix timestamp - pub timestamp: u64, - - pub item: ClientMessageItem, -} - -#[derive(Serialize)] -pub struct ClientMessageItem { - /// Type of item - /// eg. "message" - pub r#type: String, - - pub content: Vec, -} - -#[derive(Serialize)] -pub struct ClientMessageItemContent { - /// UUID - #[serde(rename="requestId")] - pub request_id: String, - - /// Type of item content - /// eg. "input_text" - pub r#type: String, - - /// The prompt for the request - pub text: String, - - pub properties: ClientMessageItemContentProperties, -} - -#[derive(Serialize)] -pub struct ClientMessageItemContentProperties { - pub section_count: usize, - pub is_kids_mode: bool, - pub enable_nsfw: bool, - pub skip_upsampler: bool, - pub is_initial: bool, - pub aspect_ratio: ClientMessageAspectRatio, -} - -#[derive(Serialize, Clone, Copy, Debug)] -pub enum ClientMessageAspectRatio { - #[serde(rename = "2:3")] - TallTwoByThree, - - #[serde(rename = "3:2")] - WideThreeByTwo, - - #[serde(rename = "1:1")] - Square, -} - -impl WebsocketClientMessage { - /// Create a new image prompt websocket client message - pub fn new_image_prompt(prompt: &str, aspect_ratio: ClientMessageAspectRatio) -> Self { - Self { - r#type: "conversation.item.create".to_string(), - timestamp: Utc::now().timestamp_millis() as u64, - item: ClientMessageItem { - r#type: "message".to_string(), - content: vec![ - ClientMessageItemContent { - request_id: Uuid::new_v4().to_string(), - r#type: "input_text".to_string(), - text: prompt.to_string(), - properties: ClientMessageItemContentProperties { - section_count: 0, - is_kids_mode: false, - enable_nsfw: true, - skip_upsampler: false, - is_initial: false, - aspect_ratio, - }, - } - ], - }, - } - } -} diff --git a/crates/api_clients/grok_consumer_client/src/requests/image_websocket/messages/websocket_server_message.rs b/crates/api_clients/grok_consumer_client/src/requests/image_websocket/messages/websocket_server_message.rs deleted file mode 100644 index 7238ec3f23..0000000000 --- a/crates/api_clients/grok_consumer_client/src/requests/image_websocket/messages/websocket_server_message.rs +++ /dev/null @@ -1,205 +0,0 @@ -use crate::error::grok_generic_api_error::GrokGenericApiError; -use serde::Deserialize; - -#[derive(Deserialize, Clone, Debug)] -#[serde(tag = "type")] -pub enum WebsocketServerMessage { - /// Json with root `type = "image"` - #[serde(rename = "image")] - Image(ImageDataMessage), - - /// Json with root `type = "json"` - #[serde(rename = "json")] - Json(JsonDataMessage), - - /// Captures any other JSON messages. - #[serde(untagged)] - Unknown(serde_json::Value), - //Unknown(String), -} - -/// Images with a binary blob and URLs. -/// We may receive several of these for a single prompt. -#[derive(Deserialize, Clone, Debug)] -pub struct ImageDataMessage { - /// UUID. - pub id: Option, - - /// UUID. - pub job_id: Option, - - /// UUID. - pub request_id: Option, - - /// Eg. "0", "50", "100" - pub percentage_complete: Option, - - pub prompt: Option, - - /// The enriched prompt - pub full_prompt: Option, - - /// Base64 encoded image blob. - pub blob: Option, - - /// URL to the image. - pub url: Option, - - /// NSFW flag - pub r_rated: Option, - - /// Name of the model used to generate the image - /// eg. "imagine_h_1" - pub model_name: Option, -} - -#[derive(Deserialize, Clone, Debug)] -pub struct JsonDataMessage { - /// UUID. - pub job_id: Option, - - /// UUID. - pub request_id: Option, - - /// Eg. "0", "50", "100" - pub percentage_complete: Option, - - pub prompt: Option, - pub full_prompt: Option, - - /// NSFW flag - pub r_rated: Option, - - /// UUID. - /// NB: This is observed to be nullable. - pub image_id: Option, -} - -impl WebsocketServerMessage { - pub fn from_json_str(json_str: &str) -> Result { - Ok(serde_json::from_str(json_str) - .map_err(|err| GrokGenericApiError::SerdeResponseParseErrorWithBody(err, json_str.to_string()))?) - } -} - -#[cfg(test)] -mod tests { - use crate::requests::image_websocket::messages::websocket_server_message::WebsocketServerMessage; - - fn json_path(file_name: &str) -> String { - // NB: Cargo runs tests with the crate root as the working directory. - format!("test_data/websocket_messages/{}", file_name) - } - - #[test] - fn test_image_complete() -> anyhow::Result<()> { - let path = json_path("create_image_complete_response.json"); - let data = std::fs::read_to_string(path)?; - //let message: WebsocketServerMessage = serde_json::from_str(&data)?; - let message = WebsocketServerMessage::from_json_str(&data)?; - - match message { - WebsocketServerMessage::Image(image_data) => { - assert_eq!(image_data.percentage_complete, Some(50.0)); - assert!(image_data.url.is_some()); - }, - _ => panic!("Expected ImageData message"), - } - - Ok(()) - } - - #[test] - fn test_image_status_complete() -> anyhow::Result<()> { - let path = json_path("create_image_complete_status_notification.json"); - let data = std::fs::read_to_string(path)?; - //let message: WebsocketServerMessage = serde_json::from_str(&data)?; - let message = WebsocketServerMessage::from_json_str(&data)?; - - match message { - WebsocketServerMessage::Json(image_data) => { - assert_eq!(image_data.percentage_complete, Some(100.0)); - }, - _ => panic!("Expected JsonData message"), - } - - Ok(()) - } - - #[test] - fn test_in_progress() -> anyhow::Result<()> { - let path = json_path("create_image_in_progress_response.json"); - let data = std::fs::read_to_string(path)?; - //let message: WebsocketServerMessage = serde_json::from_str(&data)?; - let message = WebsocketServerMessage::from_json_str(&data)?; - - match message { - WebsocketServerMessage::Json(image_data) => { - assert_eq!(image_data.percentage_complete, Some(0.0)); - }, - _ => panic!("Expected JsonData message"), - } - - Ok(()) - } - - #[test] - fn test_wire() -> anyhow::Result<()> { - let path = json_path("wire.json"); - let data = std::fs::read_to_string(path)?; - //let message: WebsocketServerMessage = serde_json::from_str(&data)?; - let message = WebsocketServerMessage::from_json_str(&data)?; - - match message { - WebsocketServerMessage::Json(_value)=> {}, - _ => panic!("Expected Json message"), - } - - Ok(()) - } - - #[test] - fn test_wire_formatted() -> anyhow::Result<()> { - let path = json_path("wire_formatted.json"); - let data = std::fs::read_to_string(path)?; - //let message: WebsocketServerMessage = serde_json::from_str(&data)?; - let message = WebsocketServerMessage::from_json_str(&data)?; - - match message { - WebsocketServerMessage::Json(_value)=> {}, - _ => panic!("Expected Json message"), - } - - Ok(()) - } - - #[test] - fn test_empty() -> anyhow::Result<()> { - let path = json_path("empty.json"); - let data = std::fs::read_to_string(path)?; - //let message: WebsocketServerMessage = serde_json::from_str(&data)?; - let message = WebsocketServerMessage::from_json_str(&data)?; - - match message { - WebsocketServerMessage::Unknown(_value)=> {}, - _ => panic!("Expected Unknown message"), - } - - Ok(()) - } - - #[test] - fn test_other_type() -> anyhow::Result<()> { - let path = json_path("other_type.json"); - let data = std::fs::read_to_string(path)?; - ///let message: WebsocketServerMessage = serde_json::from_str(&data)?; - let message = WebsocketServerMessage::from_json_str(&data)?; - - match message { - WebsocketServerMessage::Unknown(_value)=> {}, - _ => panic!("Expected Unknown message"), - } - - Ok(()) - } -} diff --git a/crates/api_clients/grok_consumer_client/src/requests/image_websocket/mod.rs b/crates/api_clients/grok_consumer_client/src/requests/image_websocket/mod.rs deleted file mode 100644 index f6c3676adb..0000000000 --- a/crates/api_clients/grok_consumer_client/src/requests/image_websocket/mod.rs +++ /dev/null @@ -1,7 +0,0 @@ -pub mod grok_wrapped_websocket; -pub mod create_listen_websocket; -pub mod listen_for_websocket_images; -pub mod listen_for_websocket_request_id; -pub mod messages; -pub mod prompt_websocket_image; -pub mod grok_websocket; \ No newline at end of file diff --git a/crates/api_clients/grok_consumer_client/src/requests/image_websocket/prompt_websocket_image.rs b/crates/api_clients/grok_consumer_client/src/requests/image_websocket/prompt_websocket_image.rs deleted file mode 100644 index 10b9c859d9..0000000000 --- a/crates/api_clients/grok_consumer_client/src/requests/image_websocket/prompt_websocket_image.rs +++ /dev/null @@ -1,171 +0,0 @@ -use crate::error::grok_error::GrokError; -use crate::requests::image_websocket::grok_websocket::GrokWebsocket; -use crate::requests::image_websocket::messages::websocket_client_message::{ClientMessageAspectRatio, WebsocketClientMessage}; - -pub struct PromptWebsocketImageArgs<'a> { - pub websocket: &'a mut GrokWebsocket, - pub prompt: &'a str, - pub aspect_ratio: ClientMessageAspectRatio, -} - - -pub async fn prompt_websocket_image(args: PromptWebsocketImageArgs<'_>) -> Result<(), GrokError> { - let message = WebsocketClientMessage::new_image_prompt(args.prompt, args.aspect_ratio); - - args.websocket.send_serializable(&message).await?; - - Ok(()) -} - -#[cfg(test)] -mod tests { - use crate::requests::image_websocket::create_listen_websocket::{create_listen_websocket, CreateListenWebsocketArgs}; - use crate::requests::image_websocket::grok_websocket::GrokWebsocket; - use crate::requests::image_websocket::grok_wrapped_websocket::GrokWrappedWebsocket; - use crate::requests::image_websocket::messages::websocket_client_message::ClientMessageAspectRatio; - use crate::requests::image_websocket::messages::websocket_server_message::WebsocketServerMessage; - use crate::requests::image_websocket::prompt_websocket_image::{prompt_websocket_image, PromptWebsocketImageArgs}; - use crate::test_utils::get_test_cookies::get_test_cookies; - use errors::AnyhowResult; - use log::warn; - use std::io::Write; - use std::time::Duration; - use wreq::ws::message::Message; - - #[tokio::test] - #[ignore] // manually test - async fn prompt() -> AnyhowResult<()> { - //setup_test_logging(LevelFilter::Trace); - - let cookies = get_test_cookies()?; - - let websocket = create_listen_websocket(CreateListenWebsocketArgs { - cookies: &cookies, - }).await?; - - //let websocket = GrokWrappedWebsocket::new(websocket); - let mut websocket = GrokWebsocket::new(websocket); - - println!("Sending..."); - std::io::stdout().flush()?; - - let result = prompt_websocket_image(PromptWebsocketImageArgs { - websocket: &mut websocket, - prompt: "a dog riding a motorcycle", - aspect_ratio: ClientMessageAspectRatio::WideThreeByTwo, - }).await?; - - println!("Reading..."); - std::io::stdout().flush()?; - - let mut count = 0; - - println!("Polling."); - - //while let Some(message) = websocket.try_next().await? { - // println!("[{count}] Received websocket message: {:?}", message); - // count = count + 1; - // tokio::time::sleep(Duration::from_millis(1000)).await; - // if count > 1000 { - // break; - // } - //} - - //loop { - // count = count + 1; - // let bounds = websocket.size_hint()?; - // println!("Websocket size hint: {:?}", bounds); - // tokio::time::sleep(Duration::from_millis(1000)).await; - // if count > 30 { - // break; - // } - //} - - //loop { - // let maybe_message = - // websocket.try_next_timeout(Duration::from_millis(1000)).await?; - // match maybe_message { - // None => { - // println!("No message received within timeout."); - // count = count + 1; - // } - // Some(message) => { - // println!("[{count}] Received websocket message!");//: {:?}", message); - // count = 0; - // } - // } - // if count > 5 { - // println!("No messages after 5 seconds"); - // break; - // } - //} - - loop { - //let maybe_message = - // websocket.get_response_with_timeout(Duration::from_millis(1000)).await?; - - let maybe_message = - websocket.try_next_timeout(Duration::from_millis(1000)).await?; - - let mut maybe_raw_text : Option = None; - - let maybe_message = match maybe_message { - None => None, - Some(Message::Text(text)) => { - let maybe_message = WebsocketServerMessage::from_json_str(text.as_str())?; - let mut text = text.as_str().to_string(); - text.truncate(100); - //println!("Received message: {}", text); - maybe_raw_text = Some(text); - Some(maybe_message) - }, - Some(_) => { - warn!("Received non-text websocket message."); - None - }, - }; - - match maybe_message { - None => { - println!("No message received within timeout."); - count = count + 1; - } - Some(message) => { - match message { - WebsocketServerMessage::Image(image) => { - println!("IMAGE: {:?}", image.percentage_complete); - } - WebsocketServerMessage::Json(json) => { - println!("JSON : {:?}", json.percentage_complete); - } - WebsocketServerMessage::Unknown(unknown) => { - //let typ = unknown.get("type"); - let unknown_string = unknown.as_str(); - println!("[UNKNOWN] websocket message: {:?}", maybe_raw_text); - } - } - count = 0; - } - } - - // TODO: Make sure we capture all the events for images - // TODO: Explore the other APIs - // TODO understand the IDs - // TODO: Video websocket APIs - // TODO: Upload APIs - - if count > 5 { - println!("No messages after 5 seconds"); - break; - } - } - - println!("Done polling."); - - log::logger().flush(); - - assert_eq!(1,2); - - Ok(()) - } -} \ No newline at end of file diff --git a/crates/api_clients/grok_consumer_client/src/requests/index_page/get_index_page.rs b/crates/api_clients/grok_consumer_client/src/requests/index_page/get_index_page.rs deleted file mode 100644 index 89851a68d0..0000000000 --- a/crates/api_clients/grok_consumer_client/src/requests/index_page/get_index_page.rs +++ /dev/null @@ -1,102 +0,0 @@ -use crate::client::browser_user_agents::FIREFOX_143_MAC_USER_AGENT; -use crate::error::grok_client_error::GrokClientError; -use crate::error::grok_error::GrokError; -use crate::error::grok_generic_api_error::GrokGenericApiError; -use log::info; -use std::ops::Deref; -use wreq::header::{ACCEPT, ACCEPT_ENCODING, ACCEPT_LANGUAGE, CACHE_CONTROL, CONNECTION, CONTENT_TYPE, COOKIE, ORIGIN, PRAGMA, REFERER, TE, UPGRADE, USER_AGENT}; -use wreq::ws::message::Message; -use wreq::Client; -use wreq_util::Emulation; - -const INDEX_URL: &str = "https://grok.com"; - -pub struct GetIndexPageArgs<'a> { - pub cookie: &'a str, -} - -pub struct IndexPage { - pub body: String, -} - -pub async fn get_index(args: GetIndexPageArgs<'_>) -> Result { - info!("Building client..."); - - let client = Client::builder() - .emulation(Emulation::Firefox143) - .build() - .map_err(|err| GrokClientError::WreqClientError(err))?; - - info!("Configuring client..."); - - let builder = client.get(INDEX_URL) - .header("User-Agent", FIREFOX_143_MAC_USER_AGENT) - .header("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8") - .header("Accept-Encoding", "gzip, deflate, br, zstd") - .header("Accept-Language", "en-US,en;q=0.5") - .header("Connection", "keep-alive") - .header("Sec-Fetch-Dest", "document") - .header("Sec-Fetch-Mode", "navigate") - .header("Sec-Fetch-Site", "none") - .header("Sec-Fetch-User", "?1") - .header("Sec-GPC", "1") - .header("priority", "u=0, i") - .header("Pragma", "no-cache") - .header("Cache-Control", "no-cache") - .header("Cookie", args.cookie.to_string()) - .header("TE", "trailers"); - - info!("Sending request for index page..."); - - let response = builder.send() - .await - .map_err(|err| GrokClientError::WreqClientError(err))?; - - let status = response.status(); - println!("Status: {}", status); - - //let body = response.text() - // .await - // .map_err(|err| GrokGenericApiError::WreqError(err))?; - - // stblid=08552693-0377-49d3-b17f-8e4c68b153ec - for cookie in response.cookies() { - println!("Cookie: {}={}", cookie.name(), cookie.value()); - } - - for (name, value) in response.headers() { - println!("Header: {}: {}", name.as_str(), value.to_str().unwrap()); - } - - let body = response.text() - .await - .map_err(|err| GrokClientError::WreqClientError(err))?; - - Ok(IndexPage { - body, - }) -} - -#[cfg(test)] -mod tests { - use super::*; - use crate::test_utils::get_test_cookies::get_test_cookies; - use crate::test_utils::setup_test_logging::setup_test_logging; - use errors::AnyhowResult; - use log::LevelFilter; - - #[tokio::test] - #[ignore] // manually test - async fn test() -> AnyhowResult<()> { - setup_test_logging(LevelFilter::Trace); - let cookie = get_test_cookies()?; - let args = GetIndexPageArgs { - cookie: &cookie, - }; - let result = get_index(args).await?; - println!("Body:\n\n"); - println!("{}", result.body); - assert_eq!(1, 2); - Ok(()) - } -} diff --git a/crates/api_clients/grok_consumer_client/src/requests/index_page/get_index_page_and_scripts.rs b/crates/api_clients/grok_consumer_client/src/requests/index_page/get_index_page_and_scripts.rs deleted file mode 100644 index ed75fbc59e..0000000000 --- a/crates/api_clients/grok_consumer_client/src/requests/index_page/get_index_page_and_scripts.rs +++ /dev/null @@ -1,88 +0,0 @@ -use crate::client::browser_user_agents::FIREFOX_143_MAC_USER_AGENT; -use crate::error::grok_client_error::GrokClientError; -use crate::error::grok_error::GrokError; -use crate::requests::index_page::parsers::index::parse_index_script_list::parse_index_svg_paths; -use crate::requests::index_page::requests::get_index_page_scripts_with_client::{get_index_page_scripts_with_client, GetIndexPageScriptsArgs}; -use crate::requests::index_page::requests::get_index_page_with_client::{get_index_page_with_client, GetIndexPageWithClientArgs}; -use crate::utils::create_firefox_client::create_firefox_client; -use log::info; -use std::collections::HashMap; -use wreq::Client; -use wreq_util::Emulation; - -const INDEX_URL: &str = "https://grok.com"; - -pub struct GetIndexPageAndScriptsArgs<'a> { - pub cookie: &'a str, -} - -pub struct IndexPageAndScripts { - /// Index.html - pub index_body_html: String, - - /// Script path -> Javascript payload. - pub scripts: HashMap, - - // The client that we used. - pub client: Client, -} - -pub async fn get_index_page_and_scripts(args: GetIndexPageAndScriptsArgs<'_>) -> Result { - info!("Building client..."); - let client = create_firefox_client()?; - - info!("Fetching index page..."); - - let index = get_index_page_with_client(GetIndexPageWithClientArgs { - client: &client, - cookie: args.cookie, - }).await?; - - let scripts = parse_index_svg_paths(&index.body); - - info!("Fetching {} scripts...", scripts.len()); - - let scripts = get_index_page_scripts_with_client(GetIndexPageScriptsArgs { - client: &client, - cookie: &args.cookie, - scripts: &scripts, - }).await?; - - Ok(IndexPageAndScripts { - index_body_html: index.body, - scripts, - client, - }) -} - -#[cfg(test)] -mod tests { - use crate::requests::index_page::get_index_page_and_scripts::{get_index_page_and_scripts, GetIndexPageAndScriptsArgs}; - use crate::test_utils::get_test_cookies::get_test_cookies; - use errors::AnyhowResult; - - #[tokio::test] - #[ignore] // manually test - async fn test() -> AnyhowResult<()> { - //setup_test_logging(LevelFilter::Trace); - let cookie = get_test_cookies()?; - let result = get_index_page_and_scripts(GetIndexPageAndScriptsArgs { - cookie: &cookie, - }).await?; - - let mut truncated_body = result.index_body_html.clone(); - truncated_body.truncate(500); - - println!("Body:\n\n"); - println!("{}", truncated_body); - - for (k, v) in result.scripts.iter() { - let mut body = v.to_string(); - body.truncate(100); - println!("{}: {}\n\n", k, body); - } - - assert_eq!(1, 2); - Ok(()) - } -} diff --git a/crates/api_clients/grok_consumer_client/src/requests/index_page/get_numbers.rs b/crates/api_clients/grok_consumer_client/src/requests/index_page/get_numbers.rs deleted file mode 100644 index df2553a302..0000000000 --- a/crates/api_clients/grok_consumer_client/src/requests/index_page/get_numbers.rs +++ /dev/null @@ -1,87 +0,0 @@ -use crate::datatypes::api::xsid_numbers::XsidNumbers; -use crate::error::grok_error::GrokError; -use crate::requests::index_page::parsers::index::parse_index_on_demand_script::parse_index_on_demand_script; -use crate::requests::index_page::parsers::script::parse_xsid_script_numbers::parse_xsid_script_numbers; -use crate::requests::index_page::requests::get_index_page_script_with_client::{get_index_page_script_with_client, GetIndexPageScriptArgs}; -use crate::requests::index_page::utils::convert_verification_token_to_loading_anim::LoadingAnim; -use wreq::Client; -// self.svg_data, self.numbers = Parser.parse_values(c_request.text, self.anim, self.xsid_script) - -pub struct GetNumbersArgs<'a> { - pub client: &'a Client, - pub html: &'a str, - pub cookie: &'a str, - pub loading_anim: &'a LoadingAnim, - pub xsid_script_id: &'a str, -} - -pub async fn get_numbers(args: GetNumbersArgs<'_>) -> Result { - - let script_link = match args.xsid_script_id { - "ondemand.s" => { - // TODO: Not sure this is relevant anymore. Not a full or correct implementation of this branch. - let on_demand = parse_index_on_demand_script(&args.html); - let on_demand = on_demand.unwrap_or_else(|| "".to_string()); - format!("https://abs.twimg.com/responsive-web/client-web/ondemand.s.{}a.js", on_demand) - }, - _ => format!("https://grok.com/_next/{}", args.xsid_script_id), - }; - - let xsid_script_body = get_index_page_script_with_client(GetIndexPageScriptArgs { - client: &args.client, - cookie: args.cookie, - script_url: &script_link, - }).await?; - - Ok(parse_xsid_script_numbers(&xsid_script_body)) -} - -#[cfg(test)] -mod tests { - use crate::requests::index_page::get_index_page_and_scripts::{get_index_page_and_scripts, GetIndexPageAndScriptsArgs}; - use crate::requests::index_page::get_numbers::{get_numbers, GetNumbersArgs}; - use crate::requests::index_page::parsers::index::parse_index_verification_token::parse_index_verification_token; - use crate::requests::index_page::parsers::script::parse_script_actions_and_xsid_script_path::parse_script_actions_and_xsid_script_path; - use crate::requests::index_page::utils::convert_verification_token_to_loading_anim::convert_verification_token_to_loading_anim; - use crate::test_utils::get_test_cookies::get_test_cookies; - use errors::AnyhowResult; - - #[tokio::test] - #[ignore] // Manual test invocation - async fn test() -> AnyhowResult<()> { - let cookie = get_test_cookies()?; - - let page_and_scripts = get_index_page_and_scripts(GetIndexPageAndScriptsArgs { - cookie: &cookie, - }).await?; - - let verification_token = parse_index_verification_token(&page_and_scripts.index_body_html) - .expect("expected verification token"); - - println!("Verification Token: {:?}", verification_token); - - let loading_anim = convert_verification_token_to_loading_anim(&verification_token)?; - - println!("Loading Animation: {:?}", loading_anim); - - let actions_and_xsid_script = parse_script_actions_and_xsid_script_path(&page_and_scripts.scripts)?; - - println!("Actions and XSID: {:?}", actions_and_xsid_script); - - let result = get_numbers(GetNumbersArgs { - client: &page_and_scripts.client, - html: &page_and_scripts.index_body_html, - cookie: &cookie, - loading_anim: &loading_anim, - xsid_script_id: &actions_and_xsid_script.xsid_script_path, - }).await?; - - println!("Final Numbers: {:?}", result); - - println!("\n\nBody:\n\n"); - println!("{}", page_and_scripts.index_body_html); - - assert_eq!(1, 2); - Ok(()) - } -} diff --git a/crates/api_clients/grok_consumer_client/src/requests/index_page/get_xsid_script.rs b/crates/api_clients/grok_consumer_client/src/requests/index_page/get_xsid_script.rs deleted file mode 100644 index 103a3a6e37..0000000000 --- a/crates/api_clients/grok_consumer_client/src/requests/index_page/get_xsid_script.rs +++ /dev/null @@ -1,92 +0,0 @@ -use crate::error::grok_error::GrokError; -use crate::requests::index_page::parsers::index::parse_index_on_demand_script::parse_index_on_demand_script; -use crate::requests::index_page::requests::get_index_page_script_with_client::{get_index_page_script_with_client, GetIndexPageScriptArgs}; -use wreq::Client; - -// self.svg_data, self.numbers = Parser.parse_values(c_request.text, self.anim, self.xsid_script) - -pub struct GetXsidScriptArgs<'a> { - pub client: &'a Client, - pub html: &'a str, - pub cookie: &'a str, - pub xsid_script_id: &'a str, -} - -/// We pull numbers out of the xsid script -#[derive(Clone, Debug)] -pub struct XsidScript { - pub xsid_script_body: String, -} - -pub async fn get_xsid_script(args: GetXsidScriptArgs<'_>) -> Result { - - let script_link = match args.xsid_script_id { - "ondemand.s" => { - // TODO: Not sure this is relevant anymore. Not a full or correct implementation of this branch. - let on_demand = parse_index_on_demand_script(&args.html); - let on_demand = on_demand.unwrap_or_else(|| "".to_string()); - format!("https://abs.twimg.com/responsive-web/client-web/ondemand.s.{}a.js", on_demand) - }, - _ => format!("https://grok.com/_next/{}", args.xsid_script_id), - }; - - let xsid_script_body = get_index_page_script_with_client(GetIndexPageScriptArgs { - client: &args.client, - cookie: args.cookie, - script_url: &script_link, - }).await?; - - Ok(XsidScript { - xsid_script_body, - }) -} - -#[cfg(test)] -mod tests { - use crate::requests::index_page::get_index_page_and_scripts::{get_index_page_and_scripts, GetIndexPageAndScriptsArgs}; - use crate::requests::index_page::get_numbers::{get_numbers, GetNumbersArgs}; - use crate::requests::index_page::parsers::index::parse_index_verification_token::parse_index_verification_token; - use crate::requests::index_page::parsers::script::parse_script_actions_and_xsid_script_path::parse_script_actions_and_xsid_script_path; - use crate::requests::index_page::utils::convert_verification_token_to_loading_anim::convert_verification_token_to_loading_anim; - use crate::test_utils::get_test_cookies::get_test_cookies; - use errors::AnyhowResult; - - #[tokio::test] - #[ignore] // Manual test invocation - async fn test() -> AnyhowResult<()> { - let cookie = get_test_cookies()?; - - let page_and_scripts = get_index_page_and_scripts(GetIndexPageAndScriptsArgs { - cookie: &cookie, - }).await?; - - let verification_token = parse_index_verification_token(&page_and_scripts.index_body_html) - .expect("expected verification token"); - - println!("Verification Token: {:?}", verification_token); - - let loading_anim = convert_verification_token_to_loading_anim(&verification_token)?; - - println!("Loading Animation: {:?}", loading_anim); - - let actions_and_xsid_script = parse_script_actions_and_xsid_script_path(&page_and_scripts.scripts)?; - - println!("Actions and XSID: {:?}", actions_and_xsid_script); - - let result = get_numbers(GetNumbersArgs { - client: &page_and_scripts.client, - html: &page_and_scripts.index_body_html, - cookie: &cookie, - loading_anim: &loading_anim, - xsid_script_id: &actions_and_xsid_script.xsid_script_path, - }).await?; - - println!("Final Numbers: {:?}", result); - - println!("\n\nBody:\n\n"); - println!("{}", page_and_scripts.index_body_html); - - assert_eq!(1, 2); - Ok(()) - } -} diff --git a/crates/api_clients/grok_consumer_client/src/requests/index_page/mod.rs b/crates/api_clients/grok_consumer_client/src/requests/index_page/mod.rs deleted file mode 100644 index db4bbb425b..0000000000 --- a/crates/api_clients/grok_consumer_client/src/requests/index_page/mod.rs +++ /dev/null @@ -1,8 +0,0 @@ -pub (super) mod requests; -pub mod get_index_page; -pub mod get_index_page_and_scripts; -pub mod get_numbers; -pub mod get_xsid_script; -pub mod parsers; -pub mod signature; -pub mod utils; diff --git a/crates/api_clients/grok_consumer_client/src/requests/index_page/parsers/index/mod.rs b/crates/api_clients/grok_consumer_client/src/requests/index_page/parsers/index/mod.rs deleted file mode 100644 index b2056eb17f..0000000000 --- a/crates/api_clients/grok_consumer_client/src/requests/index_page/parsers/index/mod.rs +++ /dev/null @@ -1,8 +0,0 @@ -pub mod parse_index_baggage; -pub mod parse_index_on_demand_script; -pub mod parse_index_script_list; -pub mod parse_index_sentry_trace; -pub mod parse_index_svg_paths; -pub mod parse_index_user_email; -pub mod parse_index_user_id; -pub mod parse_index_verification_token; \ No newline at end of file diff --git a/crates/api_clients/grok_consumer_client/src/requests/index_page/parsers/index/parse_index_baggage.rs b/crates/api_clients/grok_consumer_client/src/requests/index_page/parsers/index/parse_index_baggage.rs deleted file mode 100644 index dbbcf08fc7..0000000000 --- a/crates/api_clients/grok_consumer_client/src/requests/index_page/parsers/index/parse_index_baggage.rs +++ /dev/null @@ -1,44 +0,0 @@ -use once_cell::sync::Lazy; -use scraper::{Html, Selector}; -use crate::datatypes::api::baggage::Baggage; -// - -static BAGGAGE_SELECTOR : Lazy = Lazy::new(|| { - Selector::parse("meta[name=baggage]") - .expect("HTML selector should parse") -}); - - -pub fn parse_index_baggage(html: &str) -> Option { - let document = Html::parse_document(html); - let selected = document.select(&BAGGAGE_SELECTOR); - let mut values = selected - .filter_map(|node| node.attr("content")) - .map(|s| s.to_string()) - .collect::>(); - values.pop().map(|b| Baggage(b)) -} - -#[cfg(test)] -mod tests { - use crate::requests::index_page::get_index_page::{get_index, GetIndexPageArgs}; - use crate::requests::index_page::parsers::index::parse_index_baggage::parse_index_baggage; - use crate::test_utils::get_test_cookies::get_test_cookies; - use errors::AnyhowResult; - - #[tokio::test] - #[ignore] // Manual test invocation - async fn test() -> AnyhowResult<()> { - let cookie = get_test_cookies()?; - let index = get_index(GetIndexPageArgs { - cookie: &cookie, - }).await?; - - let baggage = parse_index_baggage(&index.body); - - println!("Baggage: {:?}", baggage); - - assert_eq!(1, 2); - Ok(()) - } -} diff --git a/crates/api_clients/grok_consumer_client/src/requests/index_page/parsers/index/parse_index_on_demand_script.rs b/crates/api_clients/grok_consumer_client/src/requests/index_page/parsers/index/parse_index_on_demand_script.rs deleted file mode 100644 index c3047f69e6..0000000000 --- a/crates/api_clients/grok_consumer_client/src/requests/index_page/parsers/index/parse_index_on_demand_script.rs +++ /dev/null @@ -1,47 +0,0 @@ -use once_cell::sync::Lazy; -use regex::Regex; - -static ON_DEMAND_REGEX : Lazy = Lazy::new(|| { - Regex::new(r#""ondemand.s":"([^"]*)""#) - .expect("Regex should parse") -}); - -pub fn parse_index_on_demand_script(html: &str) -> Option { - let on_demand = scrape_on_demand_via_regex(html); - - if let Some(on_demand) = on_demand { - return Some(on_demand); - } - - None -} - -fn scrape_on_demand_via_regex(html: &str) -> Option { - let captures = ON_DEMAND_REGEX.captures(html)?; - let capture = captures.get(1)?; - Some(capture.as_str().to_string()) -} - - -#[cfg(test)] -mod tests { - use crate::requests::index_page::get_index_page::{get_index, GetIndexPageArgs}; - use crate::requests::index_page::parsers::index::parse_index_on_demand_script::parse_index_on_demand_script; - use crate::test_utils::get_test_cookies::get_test_cookies; - use errors::AnyhowResult; - - #[tokio::test] - #[ignore] // Manual test invocation - async fn test() -> AnyhowResult<()> { - let cookie = get_test_cookies()?; - let index = get_index(GetIndexPageArgs { - cookie: &cookie, - }).await?; - - let result = parse_index_on_demand_script(&index.body); - println!("{:?}", result); - - assert_eq!(1, 2); - Ok(()) - } -} diff --git a/crates/api_clients/grok_consumer_client/src/requests/index_page/parsers/index/parse_index_script_list.rs b/crates/api_clients/grok_consumer_client/src/requests/index_page/parsers/index/parse_index_script_list.rs deleted file mode 100644 index 0d336f1fc8..0000000000 --- a/crates/api_clients/grok_consumer_client/src/requests/index_page/parsers/index/parse_index_script_list.rs +++ /dev/null @@ -1,48 +0,0 @@ -use once_cell::sync::Lazy; -use scraper::{Html, Selector}; - -// scripts: list = [s['src'] for s in BeautifulSoup(load_site.text, 'html.parser').find_all('script', src=True) if s['src'].startswith('/_next/static/chunks/')] - -static SCRIPT_SELECTOR: Lazy = Lazy::new(|| { - Selector::parse("script[src]") - .expect("HTML selector should parse") -}); - - -pub fn parse_index_svg_paths(html: &str) -> Vec { - let document = Html::parse_document(html); - let selected = document.select(&SCRIPT_SELECTOR); - selected - .filter_map(|node| node.attr("src")) - .filter(|src| src.starts_with("/_next/static/chunks/")) - .map(|s| s.to_string()) - .collect::>() -} - -#[cfg(test)] -mod tests { - use crate::requests::index_page::get_index_page::{get_index, GetIndexPageArgs}; - use crate::requests::index_page::parsers::index::parse_index_script_list::parse_index_svg_paths; - use crate::test_utils::get_test_cookies::get_test_cookies; - use errors::AnyhowResult; - - #[tokio::test] - #[ignore] // Manual test invocation - async fn test() -> AnyhowResult<()> { - let cookie = get_test_cookies()?; - let index = get_index(GetIndexPageArgs { - cookie: &cookie, - }).await?; - - let scripts = parse_index_svg_paths(&index.body); - - println!("Script count: {:?}", scripts.len()); - - for script in scripts { - println!("{}", script); - } - - assert_eq!(1, 2); - Ok(()) - } -} diff --git a/crates/api_clients/grok_consumer_client/src/requests/index_page/parsers/index/parse_index_sentry_trace.rs b/crates/api_clients/grok_consumer_client/src/requests/index_page/parsers/index/parse_index_sentry_trace.rs deleted file mode 100644 index a4867ce56d..0000000000 --- a/crates/api_clients/grok_consumer_client/src/requests/index_page/parsers/index/parse_index_sentry_trace.rs +++ /dev/null @@ -1,85 +0,0 @@ -use crate::datatypes::api::sentry_trace::SentryTrace; -use once_cell::sync::Lazy; -use scraper::{Html, Selector}; - -/// eg. -static SENTRY_TRACE_SELECTOR : Lazy = Lazy::new(|| { - Selector::parse("meta[name=sentry-trace]") - .expect("HTML selector should parse") -}); - - -/// Extract the sentry trace, then process it. -/// The Python library discards the latter half of the trace. -pub fn parse_index_sentry_trace(html: &str) -> Option { - get_meta_value(html) - .map(|trace| split_sentry_trace(&trace)) - .map(|trace| SentryTrace(trace)) -} - -fn get_meta_value(html: &str) -> Option { - let document = Html::parse_document(html); - let selected = document.select(&SENTRY_TRACE_SELECTOR); - let mut values = selected - .filter_map(|node| node.attr("content")) - .map(|s| s.to_string()) - .collect::>(); - values.pop() -} - -fn split_sentry_trace(trace: &str) -> String { - trace.split("-") - .next() - .map(|v| v.to_string()) - .unwrap_or_else(|| trace.to_string()) -} - -#[cfg(test)] -mod tests { - use crate::requests::index_page::get_index_page::{get_index, GetIndexPageArgs}; - use crate::requests::index_page::parsers::index::parse_index_sentry_trace::parse_index_sentry_trace; - use crate::test_utils::get_test_cookies::get_test_cookies; - use errors::AnyhowResult; - - mod test_request { - use super::*; - - #[tokio::test] - #[ignore] // Manual test invocation - async fn test() -> AnyhowResult<()> { - let cookie = get_test_cookies()?; - let index = get_index(GetIndexPageArgs { - cookie: &cookie, - }).await?; - - let sentry_trace = parse_index_sentry_trace(&index.body); - - println!("Sentry trace: {:?}", sentry_trace); - - assert_eq!(1, 2); - Ok(()) - } - } - - mod test_sentry_split { - use crate::requests::index_page::parsers::index::parse_index_sentry_trace::split_sentry_trace; - - #[test] - fn test_production_case() { - let result = split_sentry_trace("d6d7c55e4a489c0dabaed06e5c7b257b-d2391b601d54494f-0"); - assert_eq!(&result, "d6d7c55e4a489c0dabaed06e5c7b257b"); - } - - #[test] - fn fallback_case_1() { - let result = split_sentry_trace("asdf"); - assert_eq!(&result, "asdf"); - } - - #[test] - fn fallback_case_2() { - let result = split_sentry_trace(""); - assert_eq!(&result, ""); - } - } -} diff --git a/crates/api_clients/grok_consumer_client/src/requests/index_page/parsers/index/parse_index_svg_paths.rs b/crates/api_clients/grok_consumer_client/src/requests/index_page/parsers/index/parse_index_svg_paths.rs deleted file mode 100644 index 374ff9491c..0000000000 --- a/crates/api_clients/grok_consumer_client/src/requests/index_page/parsers/index/parse_index_svg_paths.rs +++ /dev/null @@ -1,52 +0,0 @@ -use crate::datatypes::api::svg_path_data::SvgPathData; -use once_cell::sync::Lazy; -use scraper::{Html, Selector}; - -static SVG_PATH_SELECTOR: Lazy = Lazy::new(|| { - Selector::parse("path[d]") - .expect("HTML selector should parse") -}); - - -pub fn parse_svg_paths_from_index_html(html: &str) -> Vec { - // From https://github.com/realasfngl/Grok-Api : - // all_d_values = findall(r'"d":"(M[^"]{200,})"', html) - // svg_data = all_d_values[int(loading.split("loading-x-anim-")[1])] - - let document = Html::parse_document(html); - let selected = document.select(&SVG_PATH_SELECTOR); - selected - .filter_map(|node| node.attr("d")) - .filter(|path_data| path_data.len() >= 200) // NB: Not sure why these SVG strokes are more important. - .map(|s| SvgPathData(s.to_string())) - .collect::>() -} - -// TODO: Get from JSON instead ? - That's how the python source does it. - -#[cfg(test)] -mod tests { - use crate::requests::index_page::get_index_page::{get_index, GetIndexPageArgs}; - use crate::requests::index_page::parsers::index::parse_index_svg_paths::parse_svg_paths_from_index_html; - use crate::test_utils::get_test_cookies::get_test_cookies; - use errors::AnyhowResult; - - #[tokio::test] - #[ignore] // Manual test invocation - async fn test() -> AnyhowResult<()> { - let cookie = get_test_cookies()?; - let index = get_index(GetIndexPageArgs { - cookie: &cookie, - }).await?; - - let paths = parse_svg_paths_from_index_html(&index.body); - println!("Paths count: {:?}", paths.len()); - - for path in paths { - println!("{}", path.0); - } - - assert_eq!(1, 2); - Ok(()) - } -} diff --git a/crates/api_clients/grok_consumer_client/src/requests/index_page/parsers/index/parse_index_user_email.rs b/crates/api_clients/grok_consumer_client/src/requests/index_page/parsers/index/parse_index_user_email.rs deleted file mode 100644 index fdba99ec0c..0000000000 --- a/crates/api_clients/grok_consumer_client/src/requests/index_page/parsers/index/parse_index_user_email.rs +++ /dev/null @@ -1,50 +0,0 @@ -use crate::datatypes::api::user_email::UserEmail; -use once_cell::sync::Lazy; -use regex::Regex; - -/// Find the user email in the index.html payload -/// eg. -static JSON_REGEX: Lazy = Lazy::new(|| { - Regex::new(r#"\\?"email\\?":\s*\\?"([^"\\]+)\\?",?"#) - .expect("Regex should parse") -}); - -/// Parse the user email from the index.html -pub fn parse_index_user_email(html: &str) -> Option { - let maybe_meta = scrape_user_email_via_regex(html); - - if let Some(meta) = maybe_meta { - return Some(UserEmail(meta)) - } - - None -} - -fn scrape_user_email_via_regex(html: &str) -> Option { - let captures = JSON_REGEX.captures(html)?; - let capture = captures.get(1)?; - Some(capture.as_str().to_string()) -} - -#[cfg(test)] -mod tests { - use crate::requests::index_page::get_index_page::{get_index, GetIndexPageArgs}; - use crate::requests::index_page::parsers::index::parse_index_user_email::parse_index_user_email; - use crate::test_utils::get_test_cookies::get_test_cookies; - use errors::AnyhowResult; - - #[tokio::test] - #[ignore] // Manual test invocation - async fn test() -> AnyhowResult<()> { - let cookie = get_test_cookies()?; - let index = get_index(GetIndexPageArgs { - cookie: &cookie, - }).await?; - - let user_email = parse_index_user_email(&index.body); - println!("User Email : {:?}", user_email); - - assert_eq!(1, 2); - Ok(()) - } -} diff --git a/crates/api_clients/grok_consumer_client/src/requests/index_page/parsers/index/parse_index_user_id.rs b/crates/api_clients/grok_consumer_client/src/requests/index_page/parsers/index/parse_index_user_id.rs deleted file mode 100644 index 551cda1728..0000000000 --- a/crates/api_clients/grok_consumer_client/src/requests/index_page/parsers/index/parse_index_user_id.rs +++ /dev/null @@ -1,50 +0,0 @@ -use crate::datatypes::api::user_id::UserId; -use once_cell::sync::Lazy; -use regex::Regex; - -/// Find the user id in the index.html payload -/// eg. \"userId\":\"85980643-ffab-4984-a3de-59a608c47d7f\", -static JSON_REGEX: Lazy = Lazy::new(|| { - Regex::new(r#"\\?"userI[dD]\\?":\s*\\?"([a-zA-Z0-9-]{25,})\\?",?"#) - .expect("Regex should parse") -}); - -/// Parse the user id from the index.html -pub fn parse_index_user_id(html: &str) -> Option { - let maybe_meta = scrape_user_id_via_regex(html); - - if let Some(meta) = maybe_meta { - return Some(UserId(meta)) - } - - None -} - -fn scrape_user_id_via_regex(html: &str) -> Option { - let captures = JSON_REGEX.captures(html)?; - let capture = captures.get(1)?; - Some(capture.as_str().to_string()) -} - -#[cfg(test)] -mod tests { - use crate::requests::index_page::get_index_page::{get_index, GetIndexPageArgs}; - use crate::requests::index_page::parsers::index::parse_index_user_id::parse_index_user_id; - use crate::test_utils::get_test_cookies::get_test_cookies; - use errors::AnyhowResult; - - #[tokio::test] - #[ignore] // Manual test invocation - async fn test() -> AnyhowResult<()> { - let cookie = get_test_cookies()?; - let index = get_index(GetIndexPageArgs { - cookie: &cookie, - }).await?; - - let user_id = parse_index_user_id(&index.body); - println!("User ID : {:?}", user_id); - - assert_eq!(1, 2); - Ok(()) - } -} diff --git a/crates/api_clients/grok_consumer_client/src/requests/index_page/parsers/index/parse_index_verification_token.rs b/crates/api_clients/grok_consumer_client/src/requests/index_page/parsers/index/parse_index_verification_token.rs deleted file mode 100644 index 7db1188f49..0000000000 --- a/crates/api_clients/grok_consumer_client/src/requests/index_page/parsers/index/parse_index_verification_token.rs +++ /dev/null @@ -1,80 +0,0 @@ -use crate::datatypes::api::verification_token::VerificationToken; -use once_cell::sync::Lazy; -use regex::Regex; -use scraper::{Html, Selector}; - -/// Find the verification token in the meta tags using HTML parsing. -static META_SELECTOR : Lazy = Lazy::new(|| { - Selector::parse("meta[name=grok-site-verification]") - .expect("HTML selector should parse") -}); - -/// Find the verification token in the meta tags using regex -// eg. -static META_TAG_REGEX : Lazy = Lazy::new(|| { - Regex::new(r#""grok-site-verification"\s*content="([A-Za-z0-9/=+-]{5,})""#) - .expect("Regex should parse") -}); - -/// Find the verification token in the script tags using regex -/// eg. {\"name\":\"grok-site-verification\",\"content\":\"iFlTOEJNfQZP1B6YMRf/zuj3eYFrKWi6eNUg5XvvpllTOw5TS82coZkeUBdiHxYr\"}] -static JSON_REGEX: Lazy = Lazy::new(|| { - Regex::new(r#""grok-site-verification\\?",\s*\\?"content\\?":\\?"([A-Za-z0-9/=+-]{5,})\\?""#) - .expect("Regex should parse") -}); - -/// Parse the verification token from the root HTML -pub fn parse_index_verification_token(html: &str) -> Option { - let maybe_meta = scrape_meta_tag_via_parsing(html); - - if let Some(meta) = maybe_meta { - return Some(VerificationToken(meta)) - } - - let maybe_script = scrape_script_via_regex(html); - - if let Some(script) = maybe_script { - return Some(VerificationToken(script)) - } - - None -} - -fn scrape_script_via_regex(html: &str) -> Option { - let captures = META_TAG_REGEX.captures(html)?; - let capture = captures.get(1)?; - Some(capture.as_str().to_string()) -} - -fn scrape_meta_tag_via_parsing(html: &str) -> Option { - let document = Html::parse_document(html); - let selected = document.select(&META_SELECTOR); - let mut values = selected - .filter_map(|node| node.attr("content")) - .map(|s| s.to_string()) - .collect::>(); - values.pop() -} - -#[cfg(test)] -mod tests { - use crate::requests::index_page::get_index_page::{get_index, GetIndexPageArgs}; - use crate::requests::index_page::parsers::index::parse_index_verification_token::parse_index_verification_token; - use crate::test_utils::get_test_cookies::get_test_cookies; - use errors::AnyhowResult; - - #[tokio::test] - #[ignore] // Manual test invocation - async fn test() -> AnyhowResult<()> { - let cookie = get_test_cookies()?; - let index = get_index(GetIndexPageArgs { - cookie: &cookie, - }).await?; - - let result = parse_index_verification_token(&index.body); - println!("{:?}", result); - - assert_eq!(1, 2); - Ok(()) - } -} diff --git a/crates/api_clients/grok_consumer_client/src/requests/index_page/parsers/mod.rs b/crates/api_clients/grok_consumer_client/src/requests/index_page/parsers/mod.rs deleted file mode 100644 index 31d99fbdd6..0000000000 --- a/crates/api_clients/grok_consumer_client/src/requests/index_page/parsers/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod index; -pub mod script; diff --git a/crates/api_clients/grok_consumer_client/src/requests/index_page/parsers/script/mod.rs b/crates/api_clients/grok_consumer_client/src/requests/index_page/parsers/script/mod.rs deleted file mode 100644 index fa61bc36e8..0000000000 --- a/crates/api_clients/grok_consumer_client/src/requests/index_page/parsers/script/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod parse_xsid_script_numbers; -pub mod parse_script_actions_and_xsid_script_path; \ No newline at end of file diff --git a/crates/api_clients/grok_consumer_client/src/requests/index_page/parsers/script/parse_script_actions_and_xsid_script_path.rs b/crates/api_clients/grok_consumer_client/src/requests/index_page/parsers/script/parse_script_actions_and_xsid_script_path.rs deleted file mode 100644 index bd383bc1fa..0000000000 --- a/crates/api_clients/grok_consumer_client/src/requests/index_page/parsers/script/parse_script_actions_and_xsid_script_path.rs +++ /dev/null @@ -1,124 +0,0 @@ -use crate::error::grok_client_error::GrokClientError; -use once_cell::sync::Lazy; -use regex::Regex; -use std::collections::HashMap; -use log::info; - -static ACTIONS_REGEX : Lazy = Lazy::new(|| { - Regex::new(r#"createServerReference\)\("([a-f0-9]+)""#) - .expect("Regex should parse") -}); - -/// 2025-10-01: "(static/chunks/[^"]+\.js)"[^}]*?a\(880932\)" -/// 2025-12-01: "(static/chunks/[^"]+\.js)"[^}]*?\(880932\)" -static XSID_SCRIPT_REGEX : Lazy = Lazy::new(|| { - Regex::new(r#""(static/chunks/[^"]+\.js)"[^}]*?\(880932\)"#) - .expect("Regex should parse") -}); - -#[derive(Debug, Clone)] -pub struct ActionsAndXsid { - /// A list of opaque IDs for "actions" - pub actions: Vec, - - /// The URL path of the xsid script, with no leading slash. - pub xsid_script_path: String, -} - -pub fn parse_script_actions_and_xsid_script_path(scripts: &HashMap) -> Result { - let mut action_script_path = None; - let mut script_content_1 = None; - let mut script_content_2 = None; - - for (script_path, script_body) in scripts.iter() { - if script_body.contains("anonPrivateKey") { - action_script_path = Some(script_path.to_string()); - script_content_1 = Some(script_body.to_string()); - } else if script_body.contains("880932") { - script_content_2 = Some(script_body.to_string()); - } - } - - // NB: Commented out because we don't use it. - // let action_script_path = match action_script_path { - // Some(action_script_path) => action_script_path, - // None => return Err(GrokClientError::ScriptLogicOutOfDate), - // }; - - let script_content_1 = match script_content_1 { - Some(script_content_1) => script_content_1, - None => return Err(GrokClientError::Script1LogicOutOfDate), - }; - - let script_content_2 = match script_content_2 { - Some(script_content_2) => script_content_2, - None => return Err(GrokClientError::Script2LogicOutOfDate), - }; - - //println!("Script content 1:"); - //println!("{}", script_content_1); - //println!("Script content 2:"); - //println!("{}", script_content_2); - - let actions = ACTIONS_REGEX.captures_iter(&script_content_1) - .flat_map(|captures| captures.get(1).map(|m| m.as_str().to_string())) - .collect::>(); - - let xsid_script_path = parse_xsid_script_path_from_turbopack_script(&script_content_2)?; - - Ok(ActionsAndXsid { - actions, - xsid_script_path, - }) -} - -fn parse_xsid_script_path_from_turbopack_script(script_source: &str) -> Result { - let xsid_script_path = XSID_SCRIPT_REGEX.captures(&script_source) - .map(|captures| captures.get(1) - .map(|m| m.as_str() - .to_string())) - .flatten(); - - match xsid_script_path { - Some(xsid_script) => Ok(xsid_script), - None => Err(GrokClientError::ScriptXsidLogicOutOfDate), - } -} - -#[cfg(test)] -mod tests { - use crate::requests::index_page::get_index_page_and_scripts::{get_index_page_and_scripts, GetIndexPageAndScriptsArgs}; - use crate::requests::index_page::parsers::script::parse_script_actions_and_xsid_script_path::{parse_script_actions_and_xsid_script_path, parse_xsid_script_path_from_turbopack_script}; - use crate::test_utils::get_test_cookies::get_test_cookies; - use errors::AnyhowResult; - - #[tokio::test] - #[ignore] // manually test - async fn test() -> AnyhowResult<()> { - //setup_test_logging(LevelFilter::Trace); - let cookie = get_test_cookies()?; - let page_and_scripts = get_index_page_and_scripts(GetIndexPageAndScriptsArgs { - cookie: &cookie, - }).await?; - - let result = parse_script_actions_and_xsid_script_path(&page_and_scripts.scripts)?; - - println!("{:?}", result); - - assert_eq!(1, 2); - Ok(()) - } - - #[test] - fn parse_turbopack_script_2_for_xsid() { - // NB: The XSID parsing script broke on December 1st. - // The valid script to parse out is "static/chunks/6450f465e55b5c24.js" (as it contains the magic numbers). This comes before the string (880932) - // They probably just changed the TurboPack configs. - let example_script_2 = r#" - (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,483347,a=>{a.v(s=>Promise.all(["static/chunks/6450f465e55b5c24.js"].map(s=>a.l(s))).then(()=>s(880932)))},330040,a=>{a.v(s=>Promise.all(["static/chunks/5cc0fc78839e38d4.js"].map(s=>a.l(s))).then(()=>s(921398)))},127660,a=>{a.v(s=>Promise.all(["static/chunks/fc24fa4ac57f0fa9.js"].map(s=>a.l(s))).then(()=>s(969999)))},307492,a=>{a.v(s=>Promise.all(["static/chunks/eb46b9f393cc69d9.js"].map(s=>a.l(s))).then(()=>s(529107)))},460973,a=>{a.v(s=>Promise.all(["static/chunks/7ff9ad06da182f94.js"].map(s=>a.l(s))).then(()=>s(296273)))},900864, - "#; - - let parsed = parse_xsid_script_path_from_turbopack_script(example_script_2).unwrap(); - assert_eq!(parsed, "static/chunks/6450f465e55b5c24.js".to_string()); - } -} diff --git a/crates/api_clients/grok_consumer_client/src/requests/index_page/parsers/script/parse_xsid_script_numbers.rs b/crates/api_clients/grok_consumer_client/src/requests/index_page/parsers/script/parse_xsid_script_numbers.rs deleted file mode 100644 index 91fe36020c..0000000000 --- a/crates/api_clients/grok_consumer_client/src/requests/index_page/parsers/script/parse_xsid_script_numbers.rs +++ /dev/null @@ -1,27 +0,0 @@ -use crate::datatypes::api::xsid_numbers::XsidNumbers; -use log::error; -use once_cell::sync::Lazy; -use regex::Regex; -use std::str::FromStr; - -static NUMBERS_REGEX : Lazy = Lazy::new(|| { - Regex::new(r#"x\[(\d+)\]\s*,\s*16"#) - .expect("Regex should parse") -}); - -pub fn parse_xsid_script_numbers(script_body: &str) -> XsidNumbers { - let numbers = NUMBERS_REGEX.captures_iter(&script_body) - .flat_map(|captures| captures.get(1).map(|m| m.as_str().to_string())) - .flat_map(|num| match u32::from_str(&num) { - Ok(num) => Some(num), - Err(err) => { - error!("Error parsing: {:?}", err); - None - } - }) - .collect::<_>(); - - XsidNumbers { - numbers, - } -} diff --git a/crates/api_clients/grok_consumer_client/src/requests/index_page/requests/get_index_page_script_with_client.rs b/crates/api_clients/grok_consumer_client/src/requests/index_page/requests/get_index_page_script_with_client.rs deleted file mode 100644 index b7c283384e..0000000000 --- a/crates/api_clients/grok_consumer_client/src/requests/index_page/requests/get_index_page_script_with_client.rs +++ /dev/null @@ -1,63 +0,0 @@ -use crate::client::browser_user_agents::FIREFOX_143_MAC_USER_AGENT; -use crate::error::grok_client_error::GrokClientError; -use crate::error::grok_error::GrokError; -use log::warn; -use wreq::Client; - -const INDEX_URL: &str = "https://grok.com"; - -pub struct GetIndexPageScriptArgs<'a> { - pub client: &'a Client, - pub cookie: &'a str, - pub script_url: &'a str, -} - - -/// Get javascript that we'll need for client crypto purposes. -pub async fn get_index_page_script_with_client(args: GetIndexPageScriptArgs<'_>) -> Result { - - let script_url; - - if args.script_url.starts_with("https://") { - script_url = args.script_url.to_string(); - } else { - script_url = get_script_url(args.script_url); - } - - let builder = args.client.get(script_url) - .header("User-Agent", FIREFOX_143_MAC_USER_AGENT) - .header("Accept", "*/*") - .header("Accept-Language", "en-US,en;q=0.5") - .header("Accept-Encoding", "gzip, deflate, br, zstd") - .header("Referer", "https://grok.com") - .header("Connection", "keep-alive") - .header("Sec-Fetch-Dest", "script") - .header("Sec-Fetch-Mode", "no-cors") - .header("Sec-Fetch-Site", "same-origin") - .header("TE", "trailers"); - - let response = builder.send() - .await - .map_err(|err| GrokClientError::WreqClientError(err))?; - - let status = response.status(); - - // TODO: Cloudflare handling. - let body = response.text() - .await - .map_err(|err| GrokClientError::WreqClientError(err))?; - - if !status.is_success() { - warn!("could not get index page script: {}, body: {}", status, body); - } - - Ok(body) -} - -fn get_script_url(script_path: &str) -> String { - if script_path.starts_with("/") { - format!("{}{}", INDEX_URL, script_path) - } else { - format!("{}/{}", INDEX_URL, script_path) - } -} diff --git a/crates/api_clients/grok_consumer_client/src/requests/index_page/requests/get_index_page_scripts_with_client.rs b/crates/api_clients/grok_consumer_client/src/requests/index_page/requests/get_index_page_scripts_with_client.rs deleted file mode 100644 index 5825890ea7..0000000000 --- a/crates/api_clients/grok_consumer_client/src/requests/index_page/requests/get_index_page_scripts_with_client.rs +++ /dev/null @@ -1,80 +0,0 @@ -use crate::client::browser_user_agents::FIREFOX_143_MAC_USER_AGENT; -use crate::error::grok_client_error::GrokClientError; -use crate::error::grok_error::GrokError; -use crate::requests::index_page::requests::get_index_page_script_with_client::{get_index_page_script_with_client, GetIndexPageScriptArgs}; -use log::error; -use std::collections::HashMap; -use wreq::Client; - -pub struct GetIndexPageScriptsArgs<'a> { - pub client: &'a Client, - pub cookie: &'a str, - pub scripts: &'a Vec, -} - -/// Get javascript that we'll need for client crypto purposes. -pub async fn get_index_page_scripts_with_client(args: GetIndexPageScriptsArgs<'_>) -> Result, GrokError> { - let mut map = HashMap::with_capacity(args.scripts.len()); - - for script_url in args.scripts { - let result = get_index_page_script_with_client(GetIndexPageScriptArgs { - client: args.client, - cookie: args.cookie, - script_url, - }).await; - - let script = match result { - Ok(script) => script, - Err(err) => { - error!("Error fetching script: {}: {:?}", script_url, err); - return Err(err); - } - }; - - map.insert(script_url.to_string(), script); - } - - Ok(map) -} - -#[cfg(test)] -mod tests { - use crate::requests::index_page::parsers::index::parse_index_script_list::parse_index_svg_paths; - use crate::requests::index_page::requests::get_index_page_scripts_with_client::{get_index_page_scripts_with_client, GetIndexPageScriptsArgs}; - use crate::requests::index_page::requests::get_index_page_with_client::{get_index_page_with_client, GetIndexPageWithClientArgs}; - use crate::test_utils::get_test_cookies::get_test_cookies; - use crate::utils::create_firefox_client::create_firefox_client; - use errors::AnyhowResult; - - #[tokio::test] - #[ignore] // manually test - async fn test() -> AnyhowResult<()> { - //setup_test_logging(LevelFilter::Trace); - - let client = create_firefox_client()?; - let cookie = get_test_cookies()?; - - let index = get_index_page_with_client(GetIndexPageWithClientArgs { - client: &client, - cookie: &cookie, - }).await?; - - let scripts = parse_index_svg_paths(&index.body); - - let scripts = get_index_page_scripts_with_client(GetIndexPageScriptsArgs { - client: &client, - cookie: &cookie, - scripts: &scripts, - }).await?; - - for (k, v) in scripts.iter() { - let mut body = v.to_string(); - body.truncate(100); - println!("{}: {}\n\n", k, body); - } - - assert_eq!(1, 2); - - Ok(()) - } -} diff --git a/crates/api_clients/grok_consumer_client/src/requests/index_page/requests/get_index_page_with_client.rs b/crates/api_clients/grok_consumer_client/src/requests/index_page/requests/get_index_page_with_client.rs deleted file mode 100644 index a770734dee..0000000000 --- a/crates/api_clients/grok_consumer_client/src/requests/index_page/requests/get_index_page_with_client.rs +++ /dev/null @@ -1,87 +0,0 @@ -use crate::client::browser_user_agents::FIREFOX_143_MAC_USER_AGENT; -use crate::error::grok_client_error::GrokClientError; -use crate::error::grok_error::GrokError; -use crate::error::grok_generic_api_error::GrokGenericApiError; -use log::{info, warn}; -use std::ops::Deref; -use wreq::header::{ACCEPT, ACCEPT_ENCODING, ACCEPT_LANGUAGE, CACHE_CONTROL, CONNECTION, CONTENT_TYPE, COOKIE, ORIGIN, PRAGMA, REFERER, TE, UPGRADE, USER_AGENT}; -use wreq::ws::message::Message; -use wreq::Client; -use wreq_util::Emulation; - -const INDEX_URL: &str = "https://grok.com"; - -pub struct GetIndexPageWithClientArgs<'a> { - pub client: &'a Client, - pub cookie: &'a str, -} - -pub struct IndexPage { - pub body: String, -} - -pub async fn get_index_page_with_client(args: GetIndexPageWithClientArgs<'_>) -> Result { - let builder = args.client.get(INDEX_URL) - .header("User-Agent", FIREFOX_143_MAC_USER_AGENT) - .header("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8") - .header("Accept-Encoding", "gzip, deflate, br, zstd") - .header("Accept-Language", "en-US,en;q=0.5") - .header("Connection", "keep-alive") - .header("Sec-Fetch-Dest", "document") - .header("Sec-Fetch-Mode", "navigate") - .header("Sec-Fetch-Site", "none") - .header("Sec-Fetch-User", "?1") - .header("Sec-GPC", "1") - .header("priority", "u=0, i") - .header("Pragma", "no-cache") - .header("Cache-Control", "no-cache") - .header("Cookie", args.cookie.to_string()) - .header("TE", "trailers"); - - info!("Sending request for index page..."); - - let response = builder.send() - .await - .map_err(|err| GrokClientError::WreqClientError(err))?; - - let status = response.status(); - - let body = response.text() - .await - .map_err(|err| GrokClientError::WreqClientError(err))?; - - // TODO: Cloudflare handling - if !status.is_success() { - warn!("could not get index page script: {}, body: {}", status, body); - } - - Ok(IndexPage { - body, - }) -} - -#[cfg(test)] -mod tests { - use super::*; - use crate::test_utils::get_test_cookies::get_test_cookies; - use crate::test_utils::setup_test_logging::setup_test_logging; - use crate::utils::create_firefox_client::create_firefox_client; - use errors::AnyhowResult; - use log::LevelFilter; - - #[tokio::test] - #[ignore] // manually test - async fn test() -> AnyhowResult<()> { - setup_test_logging(LevelFilter::Trace); - let cookie = get_test_cookies()?; - let client = create_firefox_client()?; - let result = get_index_page_with_client(GetIndexPageWithClientArgs { - client: &client, - cookie: &cookie, - }).await?; - println!("Body:\n\n"); - println!("{}", result.body); - assert_eq!(1, 2); - Ok(()) - } -} diff --git a/crates/api_clients/grok_consumer_client/src/requests/index_page/requests/mod.rs b/crates/api_clients/grok_consumer_client/src/requests/index_page/requests/mod.rs deleted file mode 100644 index 03bf5f2f22..0000000000 --- a/crates/api_clients/grok_consumer_client/src/requests/index_page/requests/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub (super) mod get_index_page_script_with_client; -pub (super) mod get_index_page_scripts_with_client; -pub (super) mod get_index_page_with_client; diff --git a/crates/api_clients/grok_consumer_client/src/requests/index_page/signature/generate_xsid.rs b/crates/api_clients/grok_consumer_client/src/requests/index_page/signature/generate_xsid.rs deleted file mode 100644 index 7f92f715a8..0000000000 --- a/crates/api_clients/grok_consumer_client/src/requests/index_page/signature/generate_xsid.rs +++ /dev/null @@ -1,186 +0,0 @@ -use crate::datatypes::api::svg_path_data::SvgPathData; -use crate::datatypes::api::verification_token::VerificationToken; -use crate::datatypes::api::xsid_numbers::XsidNumbers; -use crate::error::grok_client_error::GrokClientError; -use crate::requests::index_page::signature::signature_xs::signature_xs; -use base64::prelude::BASE64_STANDARD; -use base64::Engine; -use byteorder::{LittleEndian, WriteBytesExt}; -use chrono::{TimeDelta, Utc}; -use log::{debug, error}; -use sha2::{Digest, Sha256}; -use std::ops::Sub; - -pub struct GenerateXsidArgs<'a> { - /// Path of the request, - /// eg. `/rest/app-chat/conversations/new` - pub path: &'a str, - - /// HTTP Method - /// eg. `POST` - pub method: &'a str, - - pub verification_token: &'a VerificationToken, - - pub svg_data: &'a SvgPathData, - - // "x_values" - pub numbers: &'a XsidNumbers, -} - -pub fn generate_xsid(args: GenerateXsidArgs<'_>) -> Result { - let timestamp = Utc::now().timestamp(); - let timestamp = timestamp as u32; - generate_xsid_with_timestamp(timestamp, args) -} - -pub fn generate_xsid_with_timestamp(timestamp: u32, args: GenerateXsidArgs<'_>) -> Result { - /* - xsid: str = Signature.generate_sign('/rest/app-chat/conversations/new', 'POST', self.verification_token, self.svg_data, self.numbers) - - @staticmethod - def generate_sign(path: str, method: str, verification: str, svg: str, x_values: list, time_n: int = None, random_float: float = None) -> str: - - n = int(time() - 1682924400) if not time_n else time_n - t = pack(' 0: - first = arr[0] - for i in range(1, len(arr)): - arr[i] = arr[i] ^ first - - return b64encode(bytes(arr)).decode('ascii').replace('=', '') - */ - - let n = timestamp - 1682924400; - - debug!("[xsid] n = {}", n); - - let mut t = vec![]; - t.write_u32::(n).unwrap(); // TODO Unwrap - - debug!("[xsid] t = {:?}", t); - - let r = BASE64_STANDARD.decode(&args.verification_token.0) - .map_err(|err| { - error!("Decode verification_token failed. {}", err); - GrokClientError::FailedToDecodeVerificationToken(err) - })?; // TODO: Not sure this is right. - - debug!("[xsid] r = {:?}", r); - - // o = Signature.xs(r, svg, x_values) - let o = signature_xs(&r, &args.svg_data.0, &args.numbers.numbers)?; - - debug!("[xsid] o = {:?}", o); - - // msg = "!".join([method, path, str(n)]) + "obfiowerehiring" + o - let method = args.method; - let path = args.path; - let msg = format!("{method}!{path}!{n}obfiowerehiring{o}"); - - // POST!/rest/app-chat/conversations/new!78721673obfiowerehiring4320e30fd70a3d70a3d7028f5c28f5c28f6028f5c28f5c28f60fd70a3d70a3d700 - debug!("[xsid] msg = {}", msg); - - //digest = sha256(msg.encode('utf-8')).digest()[:16] - - let digest_all_bytes = Sha256::digest(msg.as_bytes()).to_vec(); - debug!("[xsid] digest_all_bytes = {:?}", digest_all_bytes); - - if digest_all_bytes.len() < 16 { - error!("Digest is too short: {}", digest_all_bytes.len()); - return Err(GrokClientError::BadSignatureInputs); - } - - let digest : &[u8] = &digest_all_bytes[.. 16]; - - debug!("[xsid] digest = {:?}", digest); - - // prefix_byte = int(floor(random() if not random_float else random_float * 256)) - let prefix_byte = 0; // NB: This is bad code? floor(random) = 0 always. - - // assembled = bytes([prefix_byte]) + r + t + digest + bytes([3]) - let mut assembled = vec![prefix_byte]; - assembled.extend(r); - assembled.extend(t); - assembled.extend(digest); - assembled.extend([3]); - - debug!("[xsid] assembled = {:?}", assembled); - - /* - arr = bytearray(assembled) - if len(arr) > 0: - first = arr[0] - for i in range(1, len(arr)): - arr[i] = arr[i] ^ first - */ - - let mut arr = assembled.clone(); - - // NB: Does not appear to be needed because the first byte is always "0" (for now) - //if arr.len() > 0 { - // let first = *arr.get(0).ok_or(GrokClientError::BadSignatureInputs)?; - // for i in 1..arr.len() { - // let mut a = arr.get_mut(i).ok_or(GrokClientError::BadSignatureInputs)?; - // let av = *a; - // let bv = av ^ first; - // *a = bv; - // } - //} - - debug!("[xsid] arr = {:?}", arr); - - // Uses + and / for base64 - // encoded = b64encode(bytes(arr)).decode('ascii').replace('=', '') - - let encoded_bytes = BASE64_STANDARD.encode(arr); - let encoded_bytes = encoded_bytes.replace("=", ""); - - debug!("[xsid] encoded_bytes = {:?}", encoded_bytes); - - Ok(encoded_bytes) -} - - -#[cfg(test)] -mod tests { - use crate::datatypes::api::svg_path_data::SvgPathData; - use crate::datatypes::api::verification_token::VerificationToken; - use crate::datatypes::api::xsid_numbers::XsidNumbers; - use crate::requests::index_page::signature::generate_xsid::{generate_xsid_with_timestamp, GenerateXsidArgs}; - use errors::AnyhowResult; - - // TODO: More test cases - #[test] - fn test() -> AnyhowResult<()> { - let ver = VerificationToken("yt16CWiUI42s7wGGeMxcdEIT2miPF5PVOGZF1Jcae7K7HMQrLeI4RTYufmdfBIZU".to_string()); - let svg_data = "M 10,30 C 147,16 51,222 136,87 h 31 s 177,77 40,114 C 68,166 18,188 114,44 h 220 s 148,210 202,25 C 220,36 246,218 12,120 h 244 s 34,154 56,161 C 211,204 208,60 174,14 h 155 s 157,116 220,95 C 116,164 53,210 174,232 h 139 s 148,151 135,221 C 167,196 118,27 149,247 h 233 s 129,238 113,21 C 73,44 215,158 218,29 h 68 s 13,98 243,134 C 44,98 149,35 20,178 h 163 s 219,104 41,152 C 237,107 118,120 127,117 h 57 s 41,167 43,136 C 116,168 44,246 182,209 h 143 s 238,93 237,119 C 142,36 64,67 97,111 h 71 s 230,247 119,27 C 206,56 158,51 71,115 h 135 s 120,186 74,57 C 197,165 180,214 102,16 h 88 s 252,48 189,166 C 163,237 57,253 154,60 h 96 s 84,56 15,66 C 177,101 10,202 185,227 h 29 s 204,55 115,219 C 103,82 127,143 194,99 h 102 s 179,63 84,110"; - let svg_data = SvgPathData(svg_data.to_string()); - let numbers = vec![40, 18, 3, 18]; - let numbers = XsidNumbers { numbers }; - let timestamp = 1761646073; - - let observed = generate_xsid_with_timestamp(timestamp, GenerateXsidArgs { - path: "/rest/app-chat/conversations/new", - method: "POST", - verification_token: &ver, - svg_data: &svg_data, - numbers: &numbers, - })?; - - let expected = "AMrdeglolCONrO8BhnjMXHRCE9pojxeT1ThmRdSXGnuyuxzEKy3iOEU2Ln5nXwSGVIkysQRoLOMjee3yLtjtJXbPVwjgAw"; - - assert_eq!(&observed, expected); - Ok(()) - } -} diff --git a/crates/api_clients/grok_consumer_client/src/requests/index_page/signature/mod.rs b/crates/api_clients/grok_consumer_client/src/requests/index_page/signature/mod.rs deleted file mode 100644 index d2f7c798d5..0000000000 --- a/crates/api_clients/grok_consumer_client/src/requests/index_page/signature/mod.rs +++ /dev/null @@ -1,8 +0,0 @@ -pub mod signature_xs; -pub mod generate_xsid; -mod signature_xa; -mod signature_simulate_style; -mod signature_h; -mod signature_cubic_bezier_eased; -mod signature_to_hex; -mod round_two_decimals; \ No newline at end of file diff --git a/crates/api_clients/grok_consumer_client/src/requests/index_page/signature/round_two_decimals.rs b/crates/api_clients/grok_consumer_client/src/requests/index_page/signature/round_two_decimals.rs deleted file mode 100644 index 79ef4be60a..0000000000 --- a/crates/api_clients/grok_consumer_client/src/requests/index_page/signature/round_two_decimals.rs +++ /dev/null @@ -1,19 +0,0 @@ - -pub fn round_two_decimals(f: f64) -> f64 { - // rounded = round(float(f), 2) - let rounded = (f * 100.0).round() / 100.0; // NB: Round to two places like Python - rounded -} - -#[cfg(test)] -mod tests { - use crate::requests::index_page::signature::round_two_decimals::round_two_decimals; - - #[test] - fn test() { - assert_eq!(round_two_decimals(0.1234), 0.12); - assert_eq!(round_two_decimals(1.00001), 1.0); - assert_eq!(round_two_decimals(-5.0003), -5.0); - assert_eq!(round_two_decimals(1234.0001), 1234.0); - } -} \ No newline at end of file diff --git a/crates/api_clients/grok_consumer_client/src/requests/index_page/signature/signature_cubic_bezier_eased.rs b/crates/api_clients/grok_consumer_client/src/requests/index_page/signature/signature_cubic_bezier_eased.rs deleted file mode 100644 index 56415f87bd..0000000000 --- a/crates/api_clients/grok_consumer_client/src/requests/index_page/signature/signature_cubic_bezier_eased.rs +++ /dev/null @@ -1,148 +0,0 @@ - - -pub fn signature_cubic_bezier_eased(t: f64, x1: f64, y1: f64, x2: f64, y2: f64) -> f64 { - /* - @staticmethod - def cubicBezierEased(t: float, x1: float, y1: float, x2: float, y2: float) -> float: - def bezier(u: float): - omu = 1.0 - u - b1 = 3.0 * omu * omu * u - b2 = 3.0 * omu * u * u - b3 = u * u * u - x = b1 * x1 + b2 * x2 + b3 - y = b1 * y1 + b2 * y2 + b3 - return x, y - - lo, hi = 0.0, 1.0 - for _ in range(80): - mid = 0.5 * (lo + hi) - if bezier(mid)[0] < t: - lo = mid - else: - hi = mid - u = 0.5 * (lo + hi) - return bezier(u)[1] - */ - - let mut lo = 0.0; - let mut hi = 1.0; - - for _ in 0..80 { - let mid = 0.5 * (lo + hi); - if bezier(mid, x1, y1, x2, y2).0 < t { - lo = mid; - } else { - hi = mid; - } - } - - let u = 0.5 * (lo + hi); - - bezier(u, x1, y1, x2, y2).1 -} - - -fn bezier(u: f64, x1: f64, y1: f64, x2: f64, y2: f64) -> (f64, f64) { - /* - def bezier(u: float): - omu = 1.0 - u - b1 = 3.0 * omu * omu * u - b2 = 3.0 * omu * u * u - b3 = u * u * u - x = b1 * x1 + b2 * x2 + b3 - y = b1 * y1 + b2 * y2 + b3 - return x, y - */ - - let omu = 1.0 - u; - let b1 = 3.0 * omu * omu * u; - let b2 = 3.0 * omu * u * u; - let b3 = u * u * u; - - let x = b1 * x1 + b2 * x2 + b3; - let y = b1 * y1 + b2 * y2 + b3; - - (x, y) -} - -#[cfg(test)] -mod tests { - - mod test_signature_cubic_bezier_eased { - use crate::requests::index_page::signature::signature_cubic_bezier_eased::signature_cubic_bezier_eased; - - #[test] - fn test() { - // Input: - // - // t 0.2197265625 - // cp [0.05, -0.23, 0.95, 0.05] - // cp[0] 0.05 - // cp[1] -0.23 - // cp[2] 0.95 - // cp[3] 0.05 - // - // Output: - // - // easedY -0.06687371608353283 - - let t = 0.2197265625; - let cp0 = 0.05; - let cp1 = -0.23; - let cp2 = 0.95; - let cp3 = 0.05; - - let output = signature_cubic_bezier_eased(t, cp0, cp1, cp2, cp3); - - let expected = -0.06687371608353283; - - assert_eq!(output, expected); - } - } - - mod test_bezier { - use crate::requests::index_page::signature::signature_cubic_bezier_eased::{bezier, signature_cubic_bezier_eased}; - - #[test] - fn test_0() { - // bezier.u 0.5 - // bezier.x1 0.05 - // bezier.y1 -0.23 - // bezier.x2 0.95 - // bezier.y2 0.05 - // bezier.x 0.49999999999999994 - // bezier.y 0.057499999999999996 - let u = 0.5; - let x1 = 0.05; - let y1 = -0.23; - let x2 = 0.95; - let y2 = 0.05; - - let expected_x = 0.49999999999999994; - let expected_y = 0.057499999999999996; - - let output = bezier(u, x1, y1, x2, y2); - - assert_eq!(output.0, expected_x); - assert_eq!(output.1, expected_y); - } - - #[test] - fn test_1() { - // NB: Test values that were run through Python - let u = 0.29268743212748927; // bezier.u 0.29268743212748927 - let x1 = 0.05; // bezier.x1 0.05 - let y1 = -0.23; // bezier.y1 -0.23 - let x2 = 0.95; // bezier.x2 0.95 - let y2 = 0.05; // bezier.y2 0.05 - - let expected_x = 0.2197265625; // bezier.x 0.2197265625 - let expected_y = -0.06687371608353283; // bezier.y -0.06687371608353283 - - let output = bezier(u, x1, y1, x2, y2); - - assert_eq!(output.0, expected_x); - assert_eq!(output.1, expected_y); - } - } -} diff --git a/crates/api_clients/grok_consumer_client/src/requests/index_page/signature/signature_h.rs b/crates/api_clients/grok_consumer_client/src/requests/index_page/signature/signature_h.rs deleted file mode 100644 index d59d0c561e..0000000000 --- a/crates/api_clients/grok_consumer_client/src/requests/index_page/signature/signature_h.rs +++ /dev/null @@ -1,156 +0,0 @@ -use log::debug; -use crate::error::grok_client_error::GrokClientError; -use crate::requests::index_page::signature::round_two_decimals::round_two_decimals; -/* - @staticmethod - def _h(x: float, _param: float, c: float, e: bool): - f = ((x * (c - _param)) / 255.0) + _param - if e: - return floor(f) - rounded = round(float(f), 2) - if rounded == 0.0: - return 0.0 - return rounded - */ - - -/// Based on "Grok-Api/core/xctid.py" -/// Some kind of stroke angle calculator or trig function -/// `x` - could be values in the svg path -/// `param` - misc values: flags (-1, 1) and constants (60) -/// `c` - misc values: (1, 360) -/// `e` - some kind of flag -pub fn signature_h(x: f64, param: f64, c: f64, e: bool) -> Result { - // f = ((x * (c - _param)) / 255.0) + _param - let f = ((x * (c - param)) / 255.0) + param; - - debug!("[signature_h] f = {}", f); - - if e { - let floor = f.floor(); - debug!("[signature_h] floor = {}", floor); - return Ok(floor) - } - - // rounded = round(float(f), 2) - let rounded = round_two_decimals(f); - - debug!("[signature_h] rounded = {}", rounded); - - if rounded == 0.0 { - debug!("[signature_h] rounded is zero"); - return Ok(0.0) // TODO: This might not work - } - - Ok(rounded) // TODO: Looks like it can return ints or floats -} - - -#[cfg(test)] -mod tests { - use crate::requests::index_page::signature::signature_h::signature_h; - - // TODO: This needs more tests for other parameter setups - #[test] - fn test_end_angle() { - // "h" gets used lots of times, but the "end angle" calculation case is the most straightforward to use as a test case - // values = [73, 44, 215, 158, 218, 29, 68, 13, 98, 243, 134] - // endAngle = Signature._h(values[6], 60, 360, True) - - // NB: Note that the function type annotations call for floats, but that the "end_angle" case passes integers. - let x = 68f64; // [73, 44, 215, 158, 218, 29, 68, 13, 98, 243, 134] @ index 6 - let param = 60f64; - let c = 360f64; - let e = true; - - let observed = signature_h(x, param, c, e).unwrap(); - - let expected = 140.0; // NB: Python returns in `int` for this (I checked the type), but it can also return floats. Ugh. - - assert_eq!(expected, observed); - } - - #[test] - fn svg_test_1() { - // Actual test case, called in loop: - // cp = [Signature._h(v, -1 if (i % 2) else 0, 1, False) for i, v in enumerate(values[7:])] - // Python Inputs: - // - // _h.x 13 - // _h._param 0 - // _h.c 1 - // _h.e False - // - // Python Outputs: - // - // _h.f 0.050980392156862744 - // _h.rounded 0.05 - - let x = 13.0; // NB: This was an int in python - let param = 0.0; // NB: This was an int in python - let c = 1.0; // NB: This was an int in python - let e = false; - - let observed = signature_h(x, param, c, e).unwrap(); - - let expected = 0.05; - - assert_eq!(expected, observed); - } - - #[test] - fn svg_test_2() { - // Actual test case, called in loop: - // cp = [Signature._h(v, -1 if (i % 2) else 0, 1, False) for i, v in enumerate(values[7:])] - // Python Inputs: - // - // _h.x 98 - // _h._param -1 - // _h.c 1 - // _h.e False - // - // Python Outputs: - // - // _h.f -0.2313725490196078 - // _h.rounded -0.23 - - let x = 98.0; // NB: This was an int in python - let param = -1.0; // NB: This was an int in python - let c = 1.0; // NB: This was an int in python - let e = false; - - let observed = signature_h(x, param, c, e).unwrap(); - - let expected = -0.23; - - assert_eq!(expected, observed); - } - - #[test] - fn svg_test_3() { - // Actual test case, called in loop: - // cp = [Signature._h(v, -1 if (i % 2) else 0, 1, False) for i, v in enumerate(values[7:])] - // Python Inputs: - // - // _h.x 243 - // _h._param 0 - // _h.c 1 - // _h.e False - // - // Python Outputs: - // - // _h.f 0.9529411764705882 - // _h.rounded 0.95 - - let x = 243.0; // NB: This was an int in python - let param = 0.0; // NB: This was an int in python - let c = 1.0; // NB: This was an int in python - let e = false; - - let observed = signature_h(x, param, c, e).unwrap(); - - let expected = 0.95; - - assert_eq!(expected, observed); - } -} diff --git a/crates/api_clients/grok_consumer_client/src/requests/index_page/signature/signature_simulate_style.rs b/crates/api_clients/grok_consumer_client/src/requests/index_page/signature/signature_simulate_style.rs deleted file mode 100644 index 4ac5d62d67..0000000000 --- a/crates/api_clients/grok_consumer_client/src/requests/index_page/signature/signature_simulate_style.rs +++ /dev/null @@ -1,321 +0,0 @@ -use crate::error::grok_client_error::GrokClientError; -use crate::requests::index_page::signature::signature_cubic_bezier_eased::signature_cubic_bezier_eased; -use crate::requests::index_page::signature::signature_h::signature_h; -use log::{debug, error}; -use once_cell::sync::Lazy; -use regex::Regex; -use std::fmt::format; - -static CLEAN_NON_DIGIT_REGEX : Lazy = Lazy::new(|| { - Regex::new(r#"[^\d]+"#) - .expect("Regex should parse") -}); - -/* - @staticmethod - def simulateStyle(values: List[int], c: int) -> Dict[str,str]: - duration = 4096 - currentTime = round(c / 10.0) * 10 - t = currentTime / duration - - cp = [Signature._h(v, -1 if (i % 2) else 0, 1, False) for i, v in enumerate(values[7:])] - - easedY = Signature.cubicBezierEased(t, cp[0], cp[1], cp[2], cp[3]) - - start = [float(x) for x in values[0:3]] - end = [float(x) for x in values[3:6]] - r = round(start[0] + (end[0] - start[0]) * easedY) - g = round(start[1] + (end[1] - start[1]) * easedY) - b = round(start[2] + (end[2] - start[2]) * easedY) - color = f"rgb({r}, {g}, {b})" - - endAngle = Signature._h(values[6], 60, 360, True) - angle = endAngle * easedY - rad = angle * pi / 180.0 - - def is_effectively_zero(val: float) -> bool: - return abs(val) < 1e-7 - - def is_effectively_integer(val: float) -> bool: - return abs(val - round(val)) < 1e-7 - - cosv = cos(rad) - sinv = sin(rad) - - if is_effectively_zero(cosv): - a = 0 - d = 0 - else: - if is_effectively_integer(cosv): - a = int(round(cosv)) - d = int(round(cosv)) - else: - a = f"{cosv:.6f}" - d = f"{cosv:.6f}" - - if is_effectively_zero(sinv): - bval = 0 - cval = 0 - else: - if is_effectively_integer(sinv): - bval = int(round(sinv)) - cval = int(round(-sinv)) - else: - bval = f"{sinv:.7f}" - cval = f"{(-sinv):.7f}" - - transform = f"matrix({a}, {bval}, {cval}, {d}, 0, 0)" - return {"color": color, "transform": transform} - */ - -pub struct SimulatedStyle { - pub color: String, - pub transform: String, -} - -/// Based on "Grok-Api/core/xctid.py" -/// `values` is one svg path stroke calculated by the `xa` algo -/// `c` is the multiplied value from `xs` -/// -pub fn signature_simulate_style(values: &[u32], c: u32) -> Result { - // duration = 4096 - let duration = 4096; - - // currentTime = round(c / 10.0) * 10 - let current_time = ((c as f32 / 10.0).round()) as u32 * 10; - - debug!("[simulate_style] current_time = {:?}", current_time); - - // t = currentTime / duration - let t = current_time as f64 / duration as f64; - - debug!("[simulate_style] t = {:?}", t); - - // cp = [Signature._h(v, -1 if (i % 2) else 0, 1, False) for i, v in enumerate(values[7:])] - let subvalues = &values[7..]; - let mut cp = Vec::with_capacity(subvalues.len()); - for (i, v) in subvalues.iter().enumerate() { - let param = if i % 2 != 0 { - 1.0 } else { 0.0 }; - let val = signature_h(*v as f64, param, 1.0, false)?; - cp.push(val); - } - - debug!("[simulate_style] cp = {:?}", cp); - - // easedY = Signature.cubicBezierEased(t, cp[0], cp[1], cp[2], cp[3]) - let cp_0 = cp.get(0).map(|x| *x).ok_or_else(|| GrokClientError::BadSignatureInputs)?; - let cp_1 = cp.get(1).map(|x| *x).ok_or_else(|| GrokClientError::BadSignatureInputs)?; - let cp_2 = cp.get(2).map(|x| *x).ok_or_else(|| GrokClientError::BadSignatureInputs)?; - let cp_3 = cp.get(3).map(|x| *x).ok_or_else(|| GrokClientError::BadSignatureInputs)?; - let eased_y = signature_cubic_bezier_eased(t, cp_0, cp_1, cp_2, cp_3); - - debug!("[simulate_style] eased_y = {:?}", eased_y); - - // NB: Safety - if values.len() < 6 { - error!("Values array is too short."); - return Err(GrokClientError::BadSignatureInputs); - } - - // start = [float(x) for x in values[0:3]] - let start = values[0..3].iter().map(|x| *x as f64).collect::>(); - - // end = [float(x) for x in values[3:6]] - let end = values[3..6].iter().map(|x| *x as f64).collect::>(); - - debug!("[simulate_style] start = {:?}", start); - debug!("[simulate_style] end = {:?}", end); - - // r = round(start[0] + (end[0] - start[0]) * easedY) - // g = round(start[1] + (end[1] - start[1]) * easedY) - // b = round(start[2] + (end[2] - start[2]) * easedY) - - let r = (start[0] + (end[0] - start[0]) * eased_y).round() as u32; - let g = (start[1] + (end[1] - start[1]) * eased_y).round() as u32; - let b = (start[2] + (end[2] - start[2]) * eased_y).round() as u32; - - // color = f"rgb({r}, {g}, {b})" - let color = format!("rgb({r}, {g}, {b})"); - - debug!("[simulate_style] color = {:?}", color); - - // endAngle = Signature._h(values[6], 60, 360, True) - let value_6 = values.get(6).map(|v| *v as f64).ok_or_else(|| GrokClientError::BadSignatureInputs)?; - let end_angle = signature_h(value_6, 60.0, 360.0, true)?; - - debug!("[simulate_style] end_angle = {:?}", end_angle); - - // angle = endAngle * easedY - let angle = end_angle * eased_y; - - debug!("[simulate_style] angle = {:?}", angle); - - // rad = angle * pi / 180.0 - let pi = std::f64::consts::PI; - let rad = angle * pi / 180.0; - - debug!("[simulate_style] rad = {:?}", rad); - - // cosv = cos(rad) - // sinv = sin(rad) - let cosv = rad.cos(); - let sinv = rad.sin(); - - debug!("[simulate_style] cosv = {:?}", cosv); - debug!("[simulate_style] sinv = {:?}", sinv); - - /* - if is_effectively_zero(cosv): - a = 0 - d = 0 - else: - if is_effectively_integer(cosv): - a = int(round(cosv)) - d = int(round(cosv)) - else: - a = f"{cosv:.6f}" - d = f"{cosv:.6f}" - - if is_effectively_zero(sinv): - bval = 0 - cval = 0 - else: - if is_effectively_integer(sinv): - bval = int(round(sinv)) - cval = int(round(-sinv)) - else: - bval = f"{sinv:.7f}" - cval = f"{(-sinv):.7f}" - - transform = f"matrix({a}, {bval}, {cval}, {d}, 0, 0)" - return {"color": color, "transform": transform} - */ - - let a; - let d; - - if is_effectively_zero(cosv) { - // a = 0 - // d = 0 - a = "0".to_string(); - d = "0".to_string(); - } else { - if is_effectively_integer(cosv) { - // a = int(round(cosv)) - // d = int(round(cosv)) - let rounded = cosv.round() as i32; - a = format!("{:.0}", rounded); - d = format!("{:.0}", rounded); - } else { - //a = f"{cosv:.6f}" - //d = f"{cosv:.6f}" - a = format!("{:.6}", cosv); - d = format!("{:.6}", cosv); - } - } - - let bval; - let cval; - - if is_effectively_zero(sinv) { - // bval = 0 - // cval = 0 - bval = "0".to_string(); - cval = "0".to_string(); - } else { - if is_effectively_integer(cosv) { - // bval = int(round(sinv)) - // cval = int(round(-sinv)) - let rounded_pos = sinv.round() as i32; - let rounded_neg= (-1.0 * sinv).round() as i32; - bval = format!("{:.0}", rounded_pos); - cval = format!("{:.0}", rounded_neg); - } else { - // bval = f"{sinv:.7f}" - // cval = f"{(-sinv):.7f}" - bval = format!("{:.7}", sinv); - cval = format!("{:.7}", (sinv * -1.0)); - } - } - - debug!("[simulate_style] a = {}", a); - debug!("[simulate_style] d = {}", d); - debug!("[simulate_style] bval = {}", bval); - debug!("[simulate_style] cval = {}", cval); - - // transform = f"matrix({a}, {bval}, {cval}, {d}, 0, 0)" - let transform = format!("matrix({a}, {bval}, {cval}, {d}, 0, 0)"); - - debug!("[simulate_style] transform = {:?}", transform); - - Ok(SimulatedStyle { - color, - transform, - }) -} - - -fn is_effectively_zero(val: f64) -> bool { - val.abs() <= 1e-7 -} - -fn is_effectively_integer(val: f64) -> bool { - (val - val.round()).abs() <= 1e-7 -} - -#[cfg(test)] -mod tests { - - mod test_signature_simulate_style { - use crate::requests::index_page::signature::signature_simulate_style::signature_simulate_style; - - #[test] - fn test_1() { - // from xs - 'vals' - let values = vec![73, 44, 215, 158, 218, 29, 68, 13, 98, 243, 134]; - // from xs - 'c' - let c = 900; - - let output = signature_simulate_style(&values, c).unwrap(); - - // NB: Values from python code - let expected_color = "rgb(67, 32, 227)"; - let expected_transform = "matrix(0.986679, -0.1626771, 0.1626771, 0.986679, 0, 0)"; - - assert_eq!(&output.color, expected_color); - assert_eq!(&output.transform, expected_transform); - } - } - - mod helper_functions { - use crate::requests::index_page::signature::signature_simulate_style::{is_effectively_integer, is_effectively_zero}; - - #[test] - fn test_is_effectively_zero() { - // Yes - assert!(is_effectively_zero(0.0)); - assert!(is_effectively_zero(0.00000001)); - assert!(is_effectively_zero(0.0000000001)); - // No - assert!(!is_effectively_zero(0.000001)); - assert!(!is_effectively_zero(1.0)); - assert!(!is_effectively_zero(-1.0)); - assert!(!is_effectively_zero(10.0)); - assert!(!is_effectively_zero(0.231)); - } - - #[test] - fn test_is_effectively_integer() { - // Yes - assert!(is_effectively_integer(0.0)); - assert!(is_effectively_integer(1.0)); - assert!(is_effectively_integer(1.00000001)); - assert!(is_effectively_integer(3.00000001)); - assert!(is_effectively_integer(-0.00000001)); - // No - assert!(!is_effectively_integer(3.5)); - assert!(!is_effectively_integer(0.2)); - assert!(!is_effectively_integer(-0.01234)); - } - } -} diff --git a/crates/api_clients/grok_consumer_client/src/requests/index_page/signature/signature_to_hex.rs b/crates/api_clients/grok_consumer_client/src/requests/index_page/signature/signature_to_hex.rs deleted file mode 100644 index b4f8fdeedc..0000000000 --- a/crates/api_clients/grok_consumer_client/src/requests/index_page/signature/signature_to_hex.rs +++ /dev/null @@ -1,144 +0,0 @@ -use log::debug; -use crate::error::grok_client_error::GrokClientError; -use crate::requests::index_page::signature::round_two_decimals::round_two_decimals; - -/* - @staticmethod - def tohex(num: float) -> str: - rounded = round(float(num), 2) - if rounded == 0.0: - return "0" - sign = "-" if copysign(1.0, rounded) < 0 else "" - absval = abs(rounded) - intpart = int(floor(absval)) - frac = absval - intpart - if frac == 0.0: - return sign + format(intpart, "x") - frac_digits = [] - f = frac - for _ in range(20): - f *= 16 - digit = int(floor(f + 1e-12)) - frac_digits.append(format(digit, "x")) - f -= digit - if abs(f) < 1e-12: - break - frac_str = "".join(frac_digits).rstrip("0") - if frac_str == "": - return sign + format(intpart, "x") - return sign + format(intpart, "x") + "." + frac_str -*/ - -/// Convert the floating point number to a hexadecimal representation -pub fn signature_to_hex(num: f64) -> Result { - // rounded = round(float(num), 2) - let rounded = round_two_decimals(num); - - debug!("[to_hex] rounded = {}", rounded); - - if rounded == 0.0 { - return Ok("0".to_string()); - } - - // sign = "-" if copysign(1.0, rounded) < 0 else "" - let test = 1.0f64.copysign(rounded); - let sign = if test < 0.0 { "-" } else { "" }; - - debug!("[to_hex] sign = {}", sign); - - let absval = rounded.abs(); - let intpart = absval.floor() as u32; - - debug!("[to_hex] absval = {}", absval); - debug!("[to_hex] intpart = {}", intpart); - - let frac = absval - (intpart as f64); - - debug!("[to_hex] frac = {}", frac); - - if frac == 0.0 { - // return sign + format(intpart, "x") -- this is hex formatting - let ret = format!("{sign}{intpart:x}"); - debug!("[to_hex] return = {}", ret); - return Ok(ret); - } - - /* - frac_digits = [] - f = frac - for _ in range(20): - f *= 16 - digit = int(floor(f + 1e-12)) - frac_digits.append(format(digit, "x")) - f -= digit - if abs(f) < 1e-12: - break - frac_str = "".join(frac_digits).rstrip("0") - if frac_str == "": - return sign + format(intpart, "x") - return sign + format(intpart, "x") + "." + frac_str - */ - - let mut frac_digits = Vec::new(); - - let mut f = frac; - - for _ in 0..20 { - // f *= 16 - f *= 16.0; - - // digit = int(floor(f + 1e-12)) - let digit = (f + 1e-12).floor() as i32; - - // frac_digits.append(format(digit, "x")) - frac_digits.push(format!("{digit:x}")); - - // f -= digit - f -= digit as f64; - if f.abs() < 1e-12 { - break; - } - } - - // frac_str = "".join(frac_digits).rstrip("0") - let frac_str = frac_digits.join(""); - let frac_str = frac_str.trim_end_matches('0'); - - debug!("[to_hex] frac_str = {}", frac_str); - - if frac_str.is_empty() { - // return sign + format(intpart, "x") - let ret = format!("{sign}{intpart:x}"); - debug!("[to_hex] return = {}", ret); - return Ok(ret); - } - - // return sign + format(intpart, "x") + "." + frac_str - let ret = format!("{sign}{intpart:x}.{frac_str}"); - debug!("[to_hex] return = {}", ret); - - Ok(ret) -} - -#[cfg(test)] -mod tests { - use errors::AnyhowResult; - use crate::requests::index_page::signature::signature_to_hex::signature_to_hex; - - #[test] - fn integers() -> AnyhowResult<()> { - assert_eq!(&signature_to_hex(67.0)?, "43"); // Test case from Python - assert_eq!(&signature_to_hex(32.0)?, "20"); // Test case from Python - assert_eq!(&signature_to_hex(227.0)?, "e3"); // Test case from Python - assert_eq!(&signature_to_hex(0.0)?, "0"); // Test case from Python - Ok(()) - } - - #[test] - fn fractions() -> AnyhowResult<()> { - assert_eq!(&signature_to_hex(0.986679)?, "0.fd70a3d70a3d7"); // Test case from Python - assert_eq!(&signature_to_hex(-0.1626771)?, "-0.28f5c28f5c28f6"); // Test case from Python - assert_eq!(&signature_to_hex(0.1626771)?, "0.28f5c28f5c28f6"); // Test case from Python - Ok(()) - } -} diff --git a/crates/api_clients/grok_consumer_client/src/requests/index_page/signature/signature_xa.rs b/crates/api_clients/grok_consumer_client/src/requests/index_page/signature/signature_xa.rs deleted file mode 100644 index f5cdf38c73..0000000000 --- a/crates/api_clients/grok_consumer_client/src/requests/index_page/signature/signature_xa.rs +++ /dev/null @@ -1,100 +0,0 @@ -use crate::error::grok_client_error::GrokClientError; -use log::debug; -use once_cell::sync::Lazy; -use regex::Regex; - -static CLEAN_NON_DIGIT_REGEX : Lazy = Lazy::new(|| { - Regex::new(r#"[^\d]+"#) - .expect("Regex should parse") -}); - -/* - @staticmethod - def xa(svg: str) -> List[List[int]]: - s = (svg) - substr = s[9:] - parts = substr.split("C") - out = [] - for part in parts: - cleaned = sub(r"[^\d]+", " ", part).strip() - if cleaned == "": - nums = [0] - else: - nums = [int(tok) for tok in cleaned.split() if tok != ""] - out.append(nums) - return out - */ - -/// Based on "Grok-Api/core/xctid.py" -/// `svg_data` is the svg path stroke data -pub fn signature_xa(svg_data: &str) -> Result>, GrokClientError> { - // s = (svg) -- not this is needed, looks like a NO-OP to me. - let s = svg_data; - debug!("[xa] s.len() ={}", s.len()); - - // substr = s[9:] - let substr = &s[9..]; - debug!("[xa] substr ={}", substr); - debug!("[xa] substr.len() ={}", substr.len()); - - // parts = substr.split("C") - let parts = substr.split("C").collect::>(); - debug!("[xa] parts.len() = {}", parts.len()); - debug!("[xa] parts = {:?}", parts); - - let mut out = Vec::new(); - - for part in parts { - // cleaned = sub(r"[^\d]+", " ", part).strip() - let cleaned = CLEAN_NON_DIGIT_REGEX.replace_all(part, " ").to_string().trim().to_string(); - debug!("[xa] cleaned len = {} value = {}", cleaned.len(), cleaned); - let mut nums; - if cleaned == "" { - // nums = [0] - nums = vec![0u32] - } else { - // nums = [int(tok) for tok in cleaned.split() if tok != ""] - nums = cleaned.split_whitespace() - .filter(|x| !x.is_empty()) - .filter_map(|s| s.parse::().ok()) // TODO: Don't choke on parse errors - .collect(); - } - out.push(nums); - } - - debug!("[xa] out = {:?}", out); - - Ok(out) -} - -#[cfg(test)] -mod tests { - use crate::requests::index_page::signature::signature_xa::signature_xa; - - #[test] - fn test() { - let svg_data = "M 10,30 C 147,16 51,222 136,87 h 31 s 177,77 40,114 C 68,166 18,188 114,44 h 220 s 148,210 202,25 C 220,36 246,218 12,120 h 244 s 34,154 56,161 C 211,204 208,60 174,14 h 155 s 157,116 220,95 C 116,164 53,210 174,232 h 139 s 148,151 135,221 C 167,196 118,27 149,247 h 233 s 129,238 113,21 C 73,44 215,158 218,29 h 68 s 13,98 243,134 C 44,98 149,35 20,178 h 163 s 219,104 41,152 C 237,107 118,120 127,117 h 57 s 41,167 43,136 C 116,168 44,246 182,209 h 143 s 238,93 237,119 C 142,36 64,67 97,111 h 71 s 230,247 119,27 C 206,56 158,51 71,115 h 135 s 120,186 74,57 C 197,165 180,214 102,16 h 88 s 252,48 189,166 C 163,237 57,253 154,60 h 96 s 84,56 15,66 C 177,101 10,202 185,227 h 29 s 204,55 115,219 C 103,82 127,143 194,99 h 102 s 179,63 84,110"; - let expected = vec![ - vec![147, 16, 51, 222, 136, 87, 31, 177, 77, 40, 114], - vec![68, 166, 18, 188, 114, 44, 220, 148, 210, 202, 25], - vec![220, 36, 246, 218, 12, 120, 244, 34, 154, 56, 161], - vec![211, 204, 208, 60, 174, 14, 155, 157, 116, 220, 95], - vec![116, 164, 53, 210, 174, 232, 139, 148, 151, 135, 221], - vec![167, 196, 118, 27, 149, 247, 233, 129, 238, 113, 21], - vec![73, 44, 215, 158, 218, 29, 68, 13, 98, 243, 134], - vec![44, 98, 149, 35, 20, 178, 163, 219, 104, 41, 152], - vec![237, 107, 118, 120, 127, 117, 57, 41, 167, 43, 136], - vec![116, 168, 44, 246, 182, 209, 143, 238, 93, 237, 119], - vec![142, 36, 64, 67, 97, 111, 71, 230, 247, 119, 27], - vec![206, 56, 158, 51, 71, 115, 135, 120, 186, 74, 57], - vec![197, 165, 180, 214, 102, 16, 88, 252, 48, 189, 166], - vec![163, 237, 57, 253, 154, 60, 96, 84, 56, 15, 66], - vec![177, 101, 10, 202, 185, 227, 29, 204, 55, 115, 219], - vec![103, 82, 127, 143, 194, 99, 102, 179, 63, 84, 110] - ]; - - let output = signature_xa(&svg_data).unwrap(); - - assert_eq!(output, expected); - } -} diff --git a/crates/api_clients/grok_consumer_client/src/requests/index_page/signature/signature_xs.rs b/crates/api_clients/grok_consumer_client/src/requests/index_page/signature/signature_xs.rs deleted file mode 100644 index e6b8e636c7..0000000000 --- a/crates/api_clients/grok_consumer_client/src/requests/index_page/signature/signature_xs.rs +++ /dev/null @@ -1,162 +0,0 @@ -use crate::error::grok_client_error::GrokClientError; -use crate::requests::index_page::signature::signature_simulate_style::signature_simulate_style; -use crate::requests::index_page::signature::signature_to_hex::signature_to_hex; -use crate::requests::index_page::signature::signature_xa::signature_xa; -use log::{debug, error}; -use once_cell::sync::Lazy; -use regex::Regex; - -static NUMBER_REGEX : Lazy = Lazy::new(|| { - Regex::new(r#"[\d\.\-]+"#) - .expect("Regex should parse") -}); - -/* - @staticmethod - def xs(x_bytes: bytes, svg: str, x_values: list) -> str: - arr = list(x_bytes) -- we already have this - idx = arr[x_values[0]] % 16 - c = ((arr[x_values[1]] % 16) * (arr[x_values[2]] % 16)) * (arr[x_values[3]] % 16) - o = Signature.xa(svg) - vals = o[idx] - k = Signature.simulateStyle(vals, c) - - concat = str(k["color"]) + str(k["transform"]) - matches = findall(r"[\d\.\-]+", concat) - converted = [] - for m in matches: - num = float(m) - hexstr = Signature.tohex(num) - converted.append(hexstr) - joined = "".join(converted) - cleaned = joined.replace(".", "").replace("-", "") - return cleaned - */ - -/// Based on "Grok-Api/core/xctid.py" -/// `bytes` is -/// `svg_data` is the svg path stroke data -/// `x_values` are the magic numbers from the script -pub fn signature_xs(x_bytes: &[u8], svg_data: &str, x_values: &[u32]) -> Result { - // arr = list(x_bytes) -- we already have this as the input - let arr = x_bytes; - - // idx = arr[x_values[0]] % 16 - let i = x_values.get(0).map(|x| *x as usize).ok_or_else(|| GrokClientError::BadSignatureInputs)?; - let a = arr.get(i).map(|x| *x).ok_or_else(|| GrokClientError::BadSignatureInputs)?; - let idx = a % 16; - - debug!("[xs] idx = {}", idx); - - // c = ((arr[x_values[1]] % 16) * (arr[x_values[2]] % 16)) * (arr[x_values[3]] % 16) - let xv1 = ith_usize(x_values, 1)?; - let av1 = ith_u32(arr, xv1)? % 16; - let xv2 = ith_usize(x_values, 2)?; - let av2 = ith_u32(arr, xv2)? % 16; - let xv3 = ith_usize(x_values, 3)?; - let av3 = ith_u32(arr, xv3)? % 16; - let c = av1 * av2 * av3; // Max value: 4096 (16x16x16) - - debug!("[xs] c = {}", c); - - // o = Signature.xa(svg) - let o = signature_xa(svg_data)?; - - // vals = o[idx] - let vals = o.get(idx as usize).ok_or_else(|| GrokClientError::BadSignatureInputs)?; - - debug!("[xs] vals.len = {:?}", vals.len()); - debug!("[xs] vals = {:?}", vals); - - // k = Signature.simulateStyle(vals, c) - let k = signature_simulate_style(vals, c)?; - - debug!("[xs] k.color = {}", &k.color); - debug!("[xs] k.transform = {}", &k.transform); - - /* - concat = str(k["color"]) + str(k["transform"]) - matches = findall(r"[\d\.\-]+", concat) - converted = [] - for m in matches: - num = float(m) - hexstr = Signature.tohex(num) - converted.append(hexstr) - joined = "".join(converted) - cleaned = joined.replace(".", "").replace("-", "") - return cleaned - */ - - // concat = str(k["color"]) + str(k["transform"]) - let concat = format!("{}{}", k.color, k.transform); - - debug!("[xs] concat = {}", concat); - - // matches = findall(r"[\d\.\-]+", concat) - let matches = NUMBER_REGEX.captures_iter(&concat) - .filter_map(|captures| captures.get(0)) - .map(|m| m.as_str().to_string()) - .collect::>(); - - debug!("[xs] matches = {:?}", matches); - - /* - converted = [] - for m in matches: - num = float(m) - hexstr = Signature.tohex(num) - converted.append(hexstr) - joined = "".join(converted) - cleaned = joined.replace(".", "").replace("-", "") - */ - - let mut converted = Vec::new(); - - for m in matches.iter() { - let num = m.as_str().parse::().map_err(|err| { - error!("Invalid floating point: {} - err: {:?}", m, err); - GrokClientError::BadSignatureInputs - })?; - - let hexstr = signature_to_hex(num)?; - converted.push(hexstr); - } - - let joined = converted.join(""); - let cleaned = joined.replace(".", "").replace("-", ""); - - debug!("[xs] joined = {}", joined); - debug!("[xs] cleaned = {}", cleaned); - - Ok(cleaned) -} - -fn ith_usize(numbers: &[u32], i: usize) -> Result { - numbers.get(i) - .map(|x| *x as usize) - .ok_or_else(|| GrokClientError::BadSignatureInputs) -} - -fn ith_u32(bytes: &[u8], i: usize) -> Result { - bytes.get(i) - .map(|x| *x as u32) - .ok_or_else(|| GrokClientError::BadSignatureInputs) -} - -#[cfg(test)] -mod tests { - use crate::requests::index_page::signature::signature_xs::signature_xs; - - #[test] - fn test() { - let x_bytes = [202, 221, 122, 9, 104, 148, 35, 141, 172, 239, 1, 134, 120, 204, 92, 116, 66, 19, 218, 104, 143, 23, 147, 213, 56, 102, 69, 212, 151, 26, 123, 178, 187, 28, 196, 43, 45, 226, 56, 69, 54, 46, 126, 103, 95, 4, 134, 84]; - let svg_data = "M 10,30 C 147,16 51,222 136,87 h 31 s 177,77 40,114 C 68,166 18,188 114,44 h 220 s 148,210 202,25 C 220,36 246,218 12,120 h 244 s 34,154 56,161 C 211,204 208,60 174,14 h 155 s 157,116 220,95 C 116,164 53,210 174,232 h 139 s 148,151 135,221 C 167,196 118,27 149,247 h 233 s 129,238 113,21 C 73,44 215,158 218,29 h 68 s 13,98 243,134 C 44,98 149,35 20,178 h 163 s 219,104 41,152 C 237,107 118,120 127,117 h 57 s 41,167 43,136 C 116,168 44,246 182,209 h 143 s 238,93 237,119 C 142,36 64,67 97,111 h 71 s 230,247 119,27 C 206,56 158,51 71,115 h 135 s 120,186 74,57 C 197,165 180,214 102,16 h 88 s 252,48 189,166 C 163,237 57,253 154,60 h 96 s 84,56 15,66 C 177,101 10,202 185,227 h 29 s 204,55 115,219 C 103,82 127,143 194,99 h 102 s 179,63 84,110"; - let x_values = [40, 18, 3, 18]; - - let observed = signature_xs(&x_bytes, &svg_data, &x_values).unwrap(); - - let expected = "4320e30fd70a3d70a3d7028f5c28f5c28f6028f5c28f5c28f60fd70a3d70a3d700"; // NB: From python - - assert_eq!(&observed, expected); - } -} diff --git a/crates/api_clients/grok_consumer_client/src/requests/index_page/utils/convert_verification_token_to_loading_anim.rs b/crates/api_clients/grok_consumer_client/src/requests/index_page/utils/convert_verification_token_to_loading_anim.rs deleted file mode 100644 index 04c132785e..0000000000 --- a/crates/api_clients/grok_consumer_client/src/requests/index_page/utils/convert_verification_token_to_loading_anim.rs +++ /dev/null @@ -1,60 +0,0 @@ -use crate::datatypes::api::verification_token::VerificationToken; -use crate::error::grok_client_error::GrokClientError; -use base64::prelude::BASE64_STANDARD; -use base64::Engine; -use log::{debug, error}; - -#[derive(Debug, Clone)] -pub struct LoadingAnim(pub(crate) usize); - -impl LoadingAnim { - pub fn to_id(&self) -> String { - format!("loading-x-anim-{}", self.0) - } -} - -/// This arbitrary algorithm is used by Grok. -/// See https://github.com/realasfngl/Grok-Api -/// The verification token comes from the index HTML. -pub fn convert_verification_token_to_loading_anim(verification_token: &VerificationToken) -> Result { - // array: list = list(b64decode(verification_token)) -- note: we don't need to convert to a list - let decoded_bytes = BASE64_STANDARD.decode(&verification_token.0) - .map_err(|err| { - error!("Failed to decode verification token: {} ; err = {:?}", verification_token.0, err); - GrokClientError::FailedToDecodeVerificationToken(err) - })?; - - // anim: str = "loading-x-anim-" + str(array[5] % 4) - let byte = decoded_bytes.get(5) - .map(|byte| *byte) - .ok_or(GrokClientError::InvalidVerificationTokenBytes)?; - - debug!("verification token byte: {}", byte); - - // note, we'll put the string construction in the `to_id()` method since we need the raw integer again - let anim = (byte % 4) as usize; - - Ok(LoadingAnim(anim)) -} - -#[cfg(test)] -mod tests { - use crate::datatypes::api::verification_token::VerificationToken; - use crate::error::grok_client_error::GrokClientError; - use crate::requests::index_page::utils::convert_verification_token_to_loading_anim::convert_verification_token_to_loading_anim; - use errors::AnyhowResult; - - #[test] - fn test() -> AnyhowResult<()> { - assert_eq!(&to_id("aezWdJW6+WJhvtMA1faxopO11Q1JRcM6j7JcW/R0gO09CQhO7GzIs760yo1A0MnF")?, "loading-x-anim-2"); - assert_eq!(&to_id("wROL4+VivbPuVc37N+4VNq0K3cEMW0bPKuToO6JWxJ9fzsP3Rsn2eC8DDDZFFlov")?, "loading-x-anim-2"); - assert_eq!(&to_id("ckWUvquxT8AdPRpdjXTeNkkXRfKiGGnQFH3Hq4aznsUrSsjtDSI4JcO59j7U/+VQ")?, "loading-x-anim-1"); - Ok(()) - } - - fn to_id(verification_token: &str) -> Result { - let verification_token = VerificationToken(verification_token.to_string()); - let anim = convert_verification_token_to_loading_anim(&verification_token)?; - Ok(anim.to_id()) - } -} diff --git a/crates/api_clients/grok_consumer_client/src/requests/index_page/utils/mod.rs b/crates/api_clients/grok_consumer_client/src/requests/index_page/utils/mod.rs deleted file mode 100644 index fe07f5ea5b..0000000000 --- a/crates/api_clients/grok_consumer_client/src/requests/index_page/utils/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod select_svg_path_by_loading_anim; -pub mod convert_verification_token_to_loading_anim; diff --git a/crates/api_clients/grok_consumer_client/src/requests/index_page/utils/select_svg_path_by_loading_anim.rs b/crates/api_clients/grok_consumer_client/src/requests/index_page/utils/select_svg_path_by_loading_anim.rs deleted file mode 100644 index 999700cf08..0000000000 --- a/crates/api_clients/grok_consumer_client/src/requests/index_page/utils/select_svg_path_by_loading_anim.rs +++ /dev/null @@ -1,23 +0,0 @@ -use crate::datatypes::api::svg_path_data::SvgPathData; -use crate::error::grok_client_error::GrokClientError; -use crate::requests::index_page::utils::convert_verification_token_to_loading_anim::LoadingAnim; -use log::error; - -pub fn select_svg_path_by_loading_anim( - svg_paths: &[SvgPathData], - loading_anim: &LoadingAnim -) -> Result { - svg_paths.get(loading_anim.0) - .map(|path| path.clone()) - .ok_or_else(|| { - error!("There was not an SVG path data at index {} (array len {})", loading_anim.0, svg_paths.len()); - GrokClientError::ScriptSvgLogicOutOfDate - }) -} - -// #[cfg(test)] -// mod tests { -// #[test] -// fn test() { -// } -// } diff --git a/crates/api_clients/grok_consumer_client/src/requests/media_posts/create_media_post/grok_create_media_post.rs b/crates/api_clients/grok_consumer_client/src/requests/media_posts/create_media_post/grok_create_media_post.rs deleted file mode 100644 index a0ce3d97de..0000000000 --- a/crates/api_clients/grok_consumer_client/src/requests/media_posts/create_media_post/grok_create_media_post.rs +++ /dev/null @@ -1,165 +0,0 @@ -use crate::client::browser_user_agents::FIREFOX_143_MAC_USER_AGENT; -use crate::datatypes::api::file_id::FileId; -use crate::datatypes::api::post_id::PostId; -use crate::datatypes::api::user_id::UserId; -use crate::error::grok_client_error::GrokClientError; -use crate::error::grok_error::GrokError; -use crate::error::grok_generic_api_error::GrokGenericApiError; -use crate::requests::media_posts::create_media_post::request::CreateMediaPostWireRequest; -use crate::requests::media_posts::create_media_post::response::CreateMediaPostRawResponse; -use crate::requests::upload_file::grok_upload_file::{GrokUploadFile, GrokUploadFileResponse}; -use crate::utils::user_and_file_id_to_image_url::user_and_file_id_to_image_url; -use log::{error, info}; -use std::time::Duration; -use wreq::header::{ACCEPT, ACCEPT_LANGUAGE, CACHE_CONTROL, CONTENT_TYPE, COOKIE, ORIGIN, PRAGMA, REFERER, USER_AGENT}; -use wreq::Client; -use wreq_util::Emulation; - -const CREATE_MEDIA_POST_URL : &str = "https://grok.com/rest/media/post/create"; - -/// Request builder -pub struct GrokCreateMediaPost<'a> { - pub user_id: &'a UserId, - pub file_id: &'a FileId, - pub media_type: MediaPostType, - pub cookie: &'a str, - pub request_timeout: Option, -} - -#[derive(Debug, Copy, Clone)] -pub enum MediaPostType { - UserUploadedImage, - GrokGeneratedImage, - Video, -} - -/// Response type -#[derive(Debug, Clone)] -pub struct GrokCreateMediaPostResponse { - pub post_id: PostId, -} - -impl <'a> GrokCreateMediaPost<'a> { - pub async fn send(&self) -> Result { - info!("Configuring client..."); - - let client = Client::builder() - .emulation(Emulation::Firefox143) - .build() - .map_err(|err| GrokClientError::WreqClientError(err))?; - - // TODO: Headers were from Chromium, not Firefox. Partial implementation. - let mut request_builder = client.post(CREATE_MEDIA_POST_URL) - // TODO: Missing header "baggage" - // TODO: Missing header "sentry-trace" - // TODO: Missing header "traceparent" - // TODO: Missing header "traceparent" - // TODO: Missing header "x-statsig-id" - // TODO: Missing header "x-xai-request-id" - //.header("sec-ch-ua", "") // NB: Not present in firefox - //.header("sec-ch-ua-mobile", "") // NB: Not present in firefox - //.header("sec-ch-ua-platform", "") // NB: Not present in firefox - .header(ACCEPT, "*/*") - .header(ACCEPT_LANGUAGE, "en-US,en;q=0.5") - .header(CACHE_CONTROL, "no-cache") - .header(CONTENT_TYPE, "application/json") - .header(COOKIE, self.cookie.to_string()) - .header(ORIGIN, "https://grok.com") - .header(PRAGMA, "no-cache") - .header("priority", "u=1, i") - .header(REFERER, "https://grok.com/imagine/favorites") - .header("sec-fetch-dest", "empty") - .header("sec-fetch-mode", "cors") - .header("sec-fetch-site", "same-origin") - .header(USER_AGENT, FIREFOX_143_MAC_USER_AGENT); - - //info!("Sending..."); - //let response = builder.send() - // .await - // .map_err(|err| GrokClientError::WreqClientError(err))?; - - if let Some(timeout) = self.request_timeout { - request_builder = request_builder.timeout(timeout); - } - - let media_url = match self.media_type { - MediaPostType::UserUploadedImage => user_and_file_id_to_image_url(self.user_id, self.file_id), - MediaPostType::GrokGeneratedImage => unimplemented!("implement for generated images"), - MediaPostType::Video => unimplemented!("implement for videos"), - }; - - let request_body = CreateMediaPostWireRequest { - media_type: "MEDIA_POST_TYPE_IMAGE".to_string(), - media_url, - }; - - let http_request = request_builder.json(&request_body) - .build() - .map_err(|err| { - error!("Error building create media request: {:?}", err); - GrokClientError::WreqClientError(err) - })?; - - let response = client.execute(http_request) - .await - .map_err(|err| { - error!("Error during create media: {:?}", err); - GrokGenericApiError::WreqError(err) - })?; - - let status = response.status(); - - let response_body = response.text() - .await - .map_err(|err| { - error!("Error reading Grok create media response body: {:?}", err); - GrokGenericApiError::WreqError(err) - })?; - - // TODO: Handle errors (Cloudflare, Grok, etc.) - if !status.is_success() { - error!("Upload file request returned an error (code {}) : {:?}", status.as_u16(), response_body); - //return Err(classify_general_http_status_code_and_body(status, response_body)); - } - - let response : CreateMediaPostRawResponse = serde_json::from_str(&response_body) - .map_err(|err| GrokGenericApiError::SerdeResponseParseErrorWithBody(err, response_body.to_string()))?; - - Ok(GrokCreateMediaPostResponse { - post_id: PostId(response.post.id), - }) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use crate::test_utils::get_test_cookies::get_test_cookies; - use errors::AnyhowResult; - - #[tokio::test] - #[ignore] // Client side tests only - async fn create_media_post() -> AnyhowResult<()> { - //setup_test_logging(LevelFilter::Trace); - let cookies = get_test_cookies()?; - - let user_id = UserId("85980643-ffab-4984-a3de-59a608c47d7f".to_string()); // User - let file_id = FileId("990ddf90-8f34-42b1-81a5-39c509d62ff7".to_string()); // Mochi - - let request = GrokCreateMediaPost { - user_id: &user_id, - file_id: &file_id, - media_type: MediaPostType::UserUploadedImage, - cookie: &cookies, - request_timeout: None, - }; - - let result = request.send().await?; - - println!("Result: {:?}", result); - println!("Post ID: {:?}", result.post_id); - - assert_eq!(1, 2); - Ok(()) - } -} diff --git a/crates/api_clients/grok_consumer_client/src/requests/media_posts/create_media_post/mod.rs b/crates/api_clients/grok_consumer_client/src/requests/media_posts/create_media_post/mod.rs deleted file mode 100644 index 9fc4c9c3f9..0000000000 --- a/crates/api_clients/grok_consumer_client/src/requests/media_posts/create_media_post/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub mod grok_create_media_post; -pub (super) mod request; -mod response; \ No newline at end of file diff --git a/crates/api_clients/grok_consumer_client/src/requests/media_posts/create_media_post/request.rs b/crates/api_clients/grok_consumer_client/src/requests/media_posts/create_media_post/request.rs deleted file mode 100644 index e812cb4345..0000000000 --- a/crates/api_clients/grok_consumer_client/src/requests/media_posts/create_media_post/request.rs +++ /dev/null @@ -1,10 +0,0 @@ -use serde::Serialize; - -#[derive(Serialize)] -pub (super) struct CreateMediaPostWireRequest { - #[serde(rename = "mediaType")] - pub (super) media_type: String, - - #[serde(rename = "mediaUrl")] - pub (super) media_url: String, -} diff --git a/crates/api_clients/grok_consumer_client/src/requests/media_posts/create_media_post/response.rs b/crates/api_clients/grok_consumer_client/src/requests/media_posts/create_media_post/response.rs deleted file mode 100644 index feb01ffc9a..0000000000 --- a/crates/api_clients/grok_consumer_client/src/requests/media_posts/create_media_post/response.rs +++ /dev/null @@ -1,28 +0,0 @@ -use serde::Deserialize; - -#[derive(Deserialize)] -pub struct CreateMediaPostRawResponse { - pub post: PostData, -} - -#[derive(Deserialize)] -pub struct PostData { - /// The identifier for the post - pub id: String, -} - -/* -{ - "post": { - "id": "3c896963-8e6b-4e71-83e1-4253b2bf2ac8", - "userId":"85980643-ffab-4984-a3de-59a608c47d7f", - "createTime":"2025-10-30T23:22:19.528702688Z", - "prompt":"", - "mediaType":"MEDIA_POST_TYPE_IMAGE", - "mediaUrl":"https://assets.grok.com/users/85980643-ffab-4984-a3de-59a608c47d7f/3c896963-8e6b-4e71-83e1-4253b2bf2ac8/content", - "mimeType":"image/jpeg", - "audioUrls":[], - "childPosts":[] - } -} -*/ diff --git a/crates/api_clients/grok_consumer_client/src/requests/media_posts/like_media_post/grok_like_media.rs b/crates/api_clients/grok_consumer_client/src/requests/media_posts/like_media_post/grok_like_media.rs deleted file mode 100644 index 20aeabf9af..0000000000 --- a/crates/api_clients/grok_consumer_client/src/requests/media_posts/like_media_post/grok_like_media.rs +++ /dev/null @@ -1,190 +0,0 @@ -use crate::client::browser_user_agents::FIREFOX_143_MAC_USER_AGENT; -use crate::datatypes::api::baggage::Baggage; -use crate::datatypes::api::file_id::FileId; -use crate::datatypes::api::sentry_trace::SentryTrace; -use crate::datatypes::api::svg_path_data::SvgPathData; -use crate::datatypes::api::verification_token::VerificationToken; -use crate::datatypes::api::xsid_numbers::XsidNumbers; -use crate::error::grok_client_error::GrokClientError; -use crate::error::grok_error::GrokError; -use crate::error::grok_generic_api_error::GrokGenericApiError; -use crate::requests::index_page::signature::generate_xsid::{generate_xsid, GenerateXsidArgs}; -use crate::requests::media_posts::like_media_post::request::LikeMediaWireRequest; -use crate::requests::upload_file::grok_upload_file::{GrokUploadFile, GrokUploadFileResponse}; -use crate::utils::user_and_file_id_to_image_url::user_and_file_id_to_image_url; -use log::{error, info, warn}; -use std::time::Duration; -use uuid::Uuid; -use wreq::header::{ACCEPT, ACCEPT_ENCODING, ACCEPT_LANGUAGE, CACHE_CONTROL, CONNECTION, CONTENT_TYPE, COOKIE, ORIGIN, PRAGMA, REFERER, TE, USER_AGENT}; -use wreq::Client; -use wreq_util::Emulation; - -const LIKE_MEDIA_POST_URL: &str = "https://grok.com/rest/media/post/like"; - -/// "Liking" media is currently necessary to preserve it in your account -/// Request builder -pub struct GrokLikeMediaPost<'a> { - pub file_id: &'a FileId, - - pub cookie: &'a str, - pub baggage: &'a Baggage, - pub sentry_trace: &'a SentryTrace, - pub verification_token: &'a VerificationToken, - pub svg_data: &'a SvgPathData, - pub numbers: &'a XsidNumbers, - - pub request_timeout: Option, -} - -/// Response type -#[derive(Debug)] -pub struct GrokLikeMediaPostResponse { -} - -impl <'a> GrokLikeMediaPost<'a> { - pub async fn send(&self) -> Result { - info!("Configuring client..."); - - let client = Client::builder() - .emulation(Emulation::Firefox143) - .build() - .map_err(|err| GrokClientError::WreqClientError(err))?; - - let xai_request_id = Uuid::new_v4().to_string(); - println!("xai_request_id (uuid) = {}", xai_request_id); - - let sentry_trace_header = self.sentry_trace.to_http_request_header(); - println!("sentry_trace = {}", sentry_trace_header); - - let x_statsig_id = generate_xsid(GenerateXsidArgs { - path: "/rest/app-chat/conversations/new", - method: "POST", - verification_token: &self.verification_token, - svg_data: &self.svg_data, - numbers: &self.numbers, - })?; - - println!("x_statsig_id = {}", x_statsig_id); - - // NB: Adapting to firefox - let mut request_builder = client.post(LIKE_MEDIA_POST_URL) - .header(USER_AGENT, FIREFOX_143_MAC_USER_AGENT) - .header(ACCEPT, "*/*") - .header(ACCEPT_LANGUAGE, "en-US,en;q=0.5") - .header(ACCEPT_ENCODING, "gzip, deflate, br, zstd") - .header(REFERER, "https://grok.com/imagine/favorites") - // TODO: Missing header "traceparent" - .header(CONTENT_TYPE, "application/json") - .header("x-xai-request-id", xai_request_id) - .header("x-statsig-id", x_statsig_id) - .header("sentry-trace", sentry_trace_header) - .header("baggage", &self.baggage.0) - .header(ORIGIN, "https://grok.com") - .header("Sec-GPC", "1") - .header(CONNECTION, "keep-alive") - .header(COOKIE, self.cookie.to_string()) - .header(CACHE_CONTROL, "no-cache") - .header("sec-fetch-dest", "empty") - .header("sec-fetch-mode", "cors") - .header("sec-fetch-site", "same-origin") - .header("priority", "u=4") - .header(TE, "trailers"); - - //info!("Sending..."); - //let response = builder.send() - // .await - // .map_err(|err| GrokClientError::WreqClientError(err))?; - - if let Some(timeout) = self.request_timeout { - request_builder = request_builder.timeout(timeout); - } - - let request_body = LikeMediaWireRequest { - id: self.file_id.0.to_string(), - }; - - let http_request = request_builder.json(&request_body) - .build() - .map_err(|err| { - error!("Error building create media request: {:?}", err); - GrokClientError::WreqClientError(err) - })?; - - let response = client.execute(http_request) - .await - .map_err(|err| { - error!("Error during create media: {:?}", err); - GrokGenericApiError::WreqError(err) - })?; - - let status = response.status(); - - info!("Like Media Status: {:?}", status); - - let response_body = &response.text() - .await - .map_err(|err| { - error!("Error reading Grok create media response body: {:?}", err); - GrokGenericApiError::WreqError(err) - })?; - - // TODO: Classify errors - if !status.is_success() { - warn!("Not successful liking media (status: {:?}) : {:?}", status, response_body); - // error!("Upload file request returned an error (code {}) : {:?}", status.as_u16(), response_body); - // return Err(classify_general_http_status_code_and_body(status, response_body)); - } - - //let response : GrokApiUploadFileResponse = serde_json::from_str(response_body) - // .map_err(|err| GrokGenericApiError::SerdeResponseParseErrorWithBody(err, response_body.to_string()))?; - - Ok(GrokLikeMediaPostResponse { - }) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use crate::recipes::request_client_secrets::{request_client_secrets, RequestClientSecretsArgs}; - use crate::test_utils::get_test_cookies::get_typed_test_cookies; - use errors::AnyhowResult; - - #[tokio::test] - #[ignore] // Client side tests only - async fn like_media_post() -> AnyhowResult<()> { - //setup_test_logging(LevelFilter::Trace); - let cookies = get_typed_test_cookies()?; - - let file_id = FileId("990ddf90-8f34-42b1-81a5-39c509d62ff7".to_string()); // Mochi - - let secrets = request_client_secrets(RequestClientSecretsArgs { - cookies: &cookies, - }).await?; - - println!("Verification Token: {:?}", secrets.verification_token); - println!("Sentry Trace: {:?}", secrets.sentry_trace); - println!("Numbers: {:?}", secrets.numbers); - println!("Svg Path: {:?}", secrets.svg_path_data); - println!("Baggage: {:?}", secrets.baggage); - - let request = GrokLikeMediaPost { - file_id: &file_id, - - cookie: cookies.as_str(), - baggage: &secrets.baggage, - sentry_trace: &secrets.sentry_trace, - verification_token: &secrets.verification_token, - svg_data: &secrets.svg_path_data, - numbers: &secrets.numbers, - - request_timeout: None, - }; - - let result = request.send().await?; - - println!("Result: {:?}", result); - assert_eq!(1, 2); - Ok(()) - } -} diff --git a/crates/api_clients/grok_consumer_client/src/requests/media_posts/like_media_post/mod.rs b/crates/api_clients/grok_consumer_client/src/requests/media_posts/like_media_post/mod.rs deleted file mode 100644 index 6d256bf653..0000000000 --- a/crates/api_clients/grok_consumer_client/src/requests/media_posts/like_media_post/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -mod request; -pub mod grok_like_media; \ No newline at end of file diff --git a/crates/api_clients/grok_consumer_client/src/requests/media_posts/like_media_post/request.rs b/crates/api_clients/grok_consumer_client/src/requests/media_posts/like_media_post/request.rs deleted file mode 100644 index 60f483eaf9..0000000000 --- a/crates/api_clients/grok_consumer_client/src/requests/media_posts/like_media_post/request.rs +++ /dev/null @@ -1,8 +0,0 @@ -use serde::Serialize; - -#[derive(Serialize)] -pub (super) struct LikeMediaWireRequest { - /// The file ID - /// Videos can be favorited before they are generated ! - pub (super) id: String, -} diff --git a/crates/api_clients/grok_consumer_client/src/requests/media_posts/list_media_posts/grok_list_media_posts.rs b/crates/api_clients/grok_consumer_client/src/requests/media_posts/list_media_posts/grok_list_media_posts.rs deleted file mode 100644 index 7c78ecbc28..0000000000 --- a/crates/api_clients/grok_consumer_client/src/requests/media_posts/list_media_posts/grok_list_media_posts.rs +++ /dev/null @@ -1,224 +0,0 @@ -use crate::client::browser_user_agents::FIREFOX_143_MAC_USER_AGENT; -use crate::datatypes::api::file_id::FileId; -use crate::datatypes::api::post_id::PostId; -use crate::datatypes::api::user_id::UserId; -use crate::error::grok_client_error::GrokClientError; -use crate::error::grok_error::GrokError; -use crate::error::grok_generic_api_error::GrokGenericApiError; -use crate::requests::media_posts::list_media_posts::request::{FilterData, MediaPostListRawRequest}; -use crate::requests::media_posts::list_media_posts::response::{PostItem, PostListRawResponse}; -use crate::requests::upload_file::grok_upload_file::{GrokUploadFile, GrokUploadFileResponse}; -use crate::utils::user_and_file_id_to_image_url::user_and_file_id_to_image_url; -use log::{error, info}; -use std::time::Duration; -use wreq::header::{ACCEPT, ACCEPT_ENCODING, ACCEPT_LANGUAGE, CACHE_CONTROL, CONNECTION, CONTENT_TYPE, COOKIE, ORIGIN, PRAGMA, REFERER, TE, USER_AGENT}; -use wreq::Client; -use wreq_util::Emulation; - -const MEDIA_LIST_URL: &str = "https://grok.com/rest/media/post/list"; - -/// Request builder -pub struct GrokMediaPostListRequest<'a> { - pub cookie: &'a str, - - /// Optional cursor - pub cursor: Option, - - pub request_timeout: Option, -} - -/// Response type -#[derive(Debug, Clone)] -pub struct GrokMediaPostList { - /// List of posts - pub posts: Vec, - - /// Cursor for the next items. - pub next_cursor: Option, -} - -#[derive(Debug, Clone)] -pub struct MediaPost { - pub post_id: PostId, - - /// Only populated if there's a video and all the video data is present. - pub video_data: Option -} - -#[derive(Debug, Clone)] -pub struct VideoData { - pub file_id: FileId, - pub video_url: String, - pub prompt: Option, -} - -impl <'a> GrokMediaPostListRequest<'a> { - - pub async fn send(&self) -> Result { - info!("Configuring client..."); - - let client = Client::builder() - .emulation(Emulation::Firefox143) - .build() - .map_err(|err| GrokClientError::WreqClientError(err))?; - - // TODO: Headers were from Chromium, not Firefox. Partial implementation. - let mut request_builder = client.post(MEDIA_LIST_URL) - // TODO: Missing header "baggage" - // TODO: Missing header "sentry-trace" - // TODO: Missing header "traceparent" - // TODO: Missing header "x-statsig-id" - // TODO: Missing header "x-xai-request-id" - //.header(CACHE_CONTROL, "no-cache") // NB: Not present in firefox - //.header(PRAGMA, "no-cache") // NB: Not present in firefox - //.header("sec-ch-ua", "") // NB: Not present in firefox - //.header("sec-ch-ua-mobile", "") // NB: Not present in firefox - //.header("sec-ch-ua-platform", "") // NB: Not present in firefox - .header(USER_AGENT, FIREFOX_143_MAC_USER_AGENT) - .header(ACCEPT, "*/*") - .header(ACCEPT_LANGUAGE, "en-US,en;q=0.5") - .header(ACCEPT_ENCODING, "gzip, deflate, br, zstd") - .header(REFERER, "https://grok.com/imagine/favorites") - .header(CONTENT_TYPE, "application/json") - .header(ORIGIN, "https://grok.com") - .header("Sec-GPC", "1") - .header(CONNECTION, "keep-alive") - .header(COOKIE, self.cookie.to_string()) - .header("sec-fetch-dest", "empty") - .header("sec-fetch-mode", "cors") - .header("sec-fetch-site", "same-origin") - .header("Priority", "u=4") - .header(TE, "trailers"); - - if let Some(timeout) = self.request_timeout { - request_builder = request_builder.timeout(timeout); - } - - let request_body = MediaPostListRawRequest { - limit: 40, - filter: FilterData { - source: "MEDIA_POST_SOURCE_LIKED".to_string(), - }, - }; - - let http_request = request_builder.json(&request_body) - .build() - .map_err(|err| { - error!("Error building create media request: {:?}", err); - GrokClientError::WreqClientError(err) - })?; - - let response = client.execute(http_request) - .await - .map_err(|err| { - error!("Error during create media: {:?}", err); - GrokGenericApiError::WreqError(err) - })?; - - let status = response.status(); - - let response_body = response.text() - .await - .map_err(|err| { - error!("Error reading Grok create media response body: {:?}", err); - GrokGenericApiError::WreqError(err) - })?; - - // TODO: Handle errors (Cloudflare, Grok, etc.) - if !status.is_success() { - error!("Upload file request returned an error (code {}) : {:?}", status.as_u16(), response_body); - //return Err(classify_general_http_status_code_and_body(status, response_body)); - } - - let response : PostListRawResponse = serde_json::from_str(&response_body) - .map_err(|err| GrokGenericApiError::SerdeResponseParseErrorWithBody(err, response_body.to_string()))?; - - let mut posts = Vec::new(); - - for post in response.posts.into_iter() { - let post_id = post.id; - - // If the child video doesn't have a prompt, this parent prompt could - // be a VLM-based auto-prompt we can copy to the video. - let maybe_parent_prompt = empty_to_none(post.prompt); - - let mut video_data = None; - - for child in post.child_posts.into_iter() { - // Maybe children can have more than one video? - if let Some(url) = child.media_url { - let mut has_video = false; - if url.to_lowercase().contains(".mp4") { - has_video = true; - } - if has_video { - let mut maybe_video_prompt = empty_to_none(child.original_prompt); - - if maybe_video_prompt.is_none() { - maybe_video_prompt = maybe_parent_prompt.clone(); - } - - video_data = Some(VideoData { - file_id: FileId(child.id), - video_url: url, - prompt: maybe_video_prompt, - }); - } - } - } - - posts.push(MediaPost { - post_id: PostId(post_id), - video_data, - }) - } - - Ok(GrokMediaPostList { - posts, - next_cursor: response.next_cursor, - }) - } -} - -pub fn empty_to_none(opt: Option) -> Option { - match opt.as_deref() { - None => None, - Some("") => None, - _ => opt, - } -} - - -#[cfg(test)] -mod tests { - use super::*; - use crate::test_utils::get_test_cookies::get_test_cookies; - use crate::test_utils::setup_test_logging::setup_test_logging; - use errors::AnyhowResult; - use log::LevelFilter; - - #[tokio::test] - #[ignore] // Client side tests only - async fn create_media_post() -> AnyhowResult<()> { - setup_test_logging(LevelFilter::Info); - - let cookies = get_test_cookies()?; - - let request = GrokMediaPostListRequest { - cookie: &cookies, - request_timeout: None, - cursor: None, - }; - - let result = request.send().await?; - - println!("[test] Next Cursor: {:?}", result.next_cursor); - - for post in result.posts { - println!("[test] Post : {:?}", post); - } - - assert_eq!(1, 2); - Ok(()) - } -} diff --git a/crates/api_clients/grok_consumer_client/src/requests/media_posts/list_media_posts/mod.rs b/crates/api_clients/grok_consumer_client/src/requests/media_posts/list_media_posts/mod.rs deleted file mode 100644 index 2f3476f8e8..0000000000 --- a/crates/api_clients/grok_consumer_client/src/requests/media_posts/list_media_posts/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -mod response; -mod request; -pub mod grok_list_media_posts; \ No newline at end of file diff --git a/crates/api_clients/grok_consumer_client/src/requests/media_posts/list_media_posts/request.rs b/crates/api_clients/grok_consumer_client/src/requests/media_posts/list_media_posts/request.rs deleted file mode 100644 index 89d9a47123..0000000000 --- a/crates/api_clients/grok_consumer_client/src/requests/media_posts/list_media_posts/request.rs +++ /dev/null @@ -1,24 +0,0 @@ -use serde::Serialize; - -#[derive(Serialize)] -pub struct MediaPostListRawRequest { - /// eg. 40 - pub limit: usize, - pub filter: FilterData, -} - -#[derive(Serialize)] -pub struct FilterData { - /// eg. "MEDIA_POST_SOURCE_LIKED" - pub source: String, -} - -/* -{ - "limit":40, - "filter":{ - "source":"MEDIA_POST_SOURCE_LIKED" - } -} -*/ - diff --git a/crates/api_clients/grok_consumer_client/src/requests/media_posts/list_media_posts/response.rs b/crates/api_clients/grok_consumer_client/src/requests/media_posts/list_media_posts/response.rs deleted file mode 100644 index 2d6eac94cc..0000000000 --- a/crates/api_clients/grok_consumer_client/src/requests/media_posts/list_media_posts/response.rs +++ /dev/null @@ -1,88 +0,0 @@ -use serde::Deserialize; - -#[derive(Deserialize, Debug)] -pub (crate) struct PostListRawResponse { - pub posts: Vec, - - #[serde(rename = "nextCursor")] - pub next_cursor: Option, -} - -#[derive(Deserialize, Debug)] -pub (crate) struct PostItem { - /// The "id" of the post. - /// This is how we assert video task completion - pub id: String, - - /// Sometimes this is a VLM-generated prompt - /// This might become the prompt of the video if the video has no prompt. - pub prompt: Option, - - /// eg. `MEDIA_POST_TYPE_IMAGE` - #[serde(rename = "mediaType")] - pub media_type: Option, - - /// eg. "https://imagine-public.x.ai/imagine-public/share-images/abd9331b-c5ac-49cc-8bec-c410c7efde98.jpg" - #[serde(rename = "mediaUrl")] - pub media_url: Option, - - #[serde(rename = "childPosts")] - pub child_posts: Vec, -} - -#[derive(Deserialize, Debug)] -pub (crate) struct ChildPostItem { - pub id: String, - - /// eg. `MEDIA_POST_TYPE_VIDEO` - #[serde(rename = "mediaType")] - pub media_type: Option, - - /// eg. "https://assets.grok.com/users/85980643-ffab-4984-a3de-59a608c47d7f/generated/ecec690e-15bd-4f5f-b4e9-9b8733c3fd69/generated_video.mp4" - #[serde(rename = "mediaUrl")] - pub media_url: Option, - - /// The unmodified user prompt - #[serde(rename = "originalPrompt")] - pub original_prompt: Option, -} - -/* -{ - "posts": [ - { - "id": "abd9331b-c5ac-49cc-8bec-c410c7efde98", - "userId": "85980643-ffab-4984-a3de-59a608c47d7f", - "createTime": "2025-10-30T23:49:37.583477Z", - "prompt": "", - "mediaType": "MEDIA_POST_TYPE_IMAGE", - "mediaUrl": "https://imagine-public.x.ai/imagine-public/share-images/abd9331b-c5ac-49cc-8bec-c410c7efde98.jpg", - "mimeType": "image/jpeg", - "audioUrls": [], - "childPosts": [ - { - "id": "ecec690e-15bd-4f5f-b4e9-9b8733c3fd69", - "userId": "85980643-ffab-4984-a3de-59a608c47d7f", - "createTime": "2025-10-30T23:50:04.862487Z", - "prompt": "", - "mediaType": "MEDIA_POST_TYPE_VIDEO", - "mediaUrl": "https://assets.grok.com/users/85980643-ffab-4984-a3de-59a608c47d7f/generated/ecec690e-15bd-4f5f-b4e9-9b8733c3fd69/generated_video.mp4", - "mimeType": "video/mp4", - "originalPostId": "abd9331b-c5ac-49cc-8bec-c410c7efde98", - "audioUrls": [], - "childPosts": [], - "originalPrompt": "an anime girl runs away from a giant t-rex", - "mode": "custom", - "modelName": "imagine_xdit_1" - } - ], - "originalPrompt": "", - "userInteractionStatus": { - "likeStatus": true - }, - "modelName": "imagine_h_1", - "thumbnailImageUrl": "https://imagine-public.x.ai/cdn-cgi/image/width=500,fit=scale-down,format=auto/imagine-public/share-images/abd9331b-c5ac-49cc-8bec-c410c7efde98.jpg" - }, - { - "id": "3c896963-8e6b-4e71-83e1-4253b2bf2ac8", - */ \ No newline at end of file diff --git a/crates/api_clients/grok_consumer_client/src/requests/media_posts/mod.rs b/crates/api_clients/grok_consumer_client/src/requests/media_posts/mod.rs deleted file mode 100644 index 4e09b02490..0000000000 --- a/crates/api_clients/grok_consumer_client/src/requests/media_posts/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub mod create_media_post; -pub mod like_media_post; -pub mod list_media_posts; diff --git a/crates/api_clients/grok_consumer_client/src/requests/mod.rs b/crates/api_clients/grok_consumer_client/src/requests/mod.rs deleted file mode 100644 index cc125f1174..0000000000 --- a/crates/api_clients/grok_consumer_client/src/requests/mod.rs +++ /dev/null @@ -1,6 +0,0 @@ -pub mod download_video_file; -pub mod image_websocket; -pub mod index_page; -pub mod media_posts; -pub mod upload_file; -pub mod video_chat; diff --git a/crates/api_clients/grok_consumer_client/src/requests/upload_file/grok_upload_file.rs b/crates/api_clients/grok_consumer_client/src/requests/upload_file/grok_upload_file.rs deleted file mode 100644 index e6e17d424c..0000000000 --- a/crates/api_clients/grok_consumer_client/src/requests/upload_file/grok_upload_file.rs +++ /dev/null @@ -1,220 +0,0 @@ -use crate::client::browser_user_agents::FIREFOX_143_MAC_USER_AGENT; -use crate::datatypes::api::file_id::FileId; -use crate::datatypes::file_upload_spec::FileUploadSpec; -use crate::error::grok_client_error::GrokClientError; -use crate::error::grok_error::GrokError; -use crate::error::grok_generic_api_error::GrokGenericApiError; -use crate::requests::upload_file::request::UploadFileRequest; -use crate::requests::upload_file::response::GrokApiUploadFileResponse; -use base64::prelude::BASE64_STANDARD; -use base64::Engine; -use log::{error, info}; -use serde::Deserialize; -use std::path::Path; -use std::time::Duration; -use tokio::fs::File; -use tokio::io::AsyncReadExt; -use wreq::header::{ACCEPT, ACCEPT_ENCODING, ACCEPT_LANGUAGE, CACHE_CONTROL, CONTENT_TYPE, COOKIE, ORIGIN, PRAGMA, REFERER, USER_AGENT}; -use wreq::Client; -use wreq_util::Emulation; - -const UPLOAD_FILE_URL : &str = "https://grok.com/rest/app-chat/upload-file"; - -/// Try to prevent buffer reallocations. -/// There's a better way to implement this. -const INITIAL_BUFFER_SIZE : usize = 1024*1024; - -/// Request builder -pub struct GrokUploadFile> { - pub file: FileUploadSpec

, - pub cookie: String, - pub request_timeout: Option, -} - - -/// Response type -#[derive(Clone, Debug)] -pub struct GrokUploadFileResponse { - pub file_id: Option, - pub file_uri: Option, -} - -impl

GrokUploadFile

where P: AsRef { - - pub async fn upload(&self) -> Result { - match &self.file { - FileUploadSpec::Path(path) => { - self.upload_from_file(path.as_ref()).await - } - FileUploadSpec::Bytes { bytes, filename, mimetype } => { - unimplemented!("todo: implement bytes upload") - } - } - } - - async fn upload_from_file(&self, file_path: &Path) -> Result { - let mut file = File::open(file_path) - .await - .map_err(|err| { - error!("Failed to open file for upload: {}", err); - GrokClientError::CannotOpenLocalFileForUpload(err) - })?; - - let mut buffer = Vec::with_capacity(INITIAL_BUFFER_SIZE); - - file.read_to_end(&mut buffer) - .await - .map_err(|err| { - error!("Failed to read file for upload: {}", err); - GrokClientError::CannotReadLocalFileForUpload(err) - })?; - - let filename = file_path - .file_name() - .ok_or_else(|| GrokClientError::FileForUploadHasInvalidPath)? - .to_string_lossy() - .to_string(); - - let maybe_ext = file_path - .extension() - .and_then(|e| e.to_str()); - - // TODO: Share library code. - // TODO: Read file magic bytes first, then fall back to this. - let mime_type = match maybe_ext { - Some("jpg") | Some("jpeg") => "image/jpeg", - Some("png") => "image/png", - // Some("webp") => "image/webp", - // Some("gif") => "image/gif", - // Some("mp4") => "video/mp4", - // Some("mov") => "video/quicktime", - // Some("webm") => "video/webm", - _ => "application/octet-stream", - }; - - // The encoded images have '/' and '+'. - // The files have base64 padding! - let base64_file = BASE64_STANDARD.encode(buffer); - - self.do_upload(base64_file, &filename, &mime_type ).await - } - - async fn do_upload(&self, base64_file: String, file_name: &str, mime_type: &str) -> Result { - - let client = Client::builder() - .emulation(Emulation::Firefox143) - .build() - .map_err(|err| GrokClientError::WreqClientError(err))?; - - info!("Configuring client..."); - - // TODO: Headers were from Chromium, not Firefox. Partial implementation. - let mut request_builder = client.post(UPLOAD_FILE_URL) - .header(ACCEPT, "*/*") - .header(ACCEPT_LANGUAGE, "en-US,en;q=0.5") - // TODO: Missing header "baggage" - .header(CACHE_CONTROL, "no-cache") - .header(CONTENT_TYPE, "application/json") - .header(COOKIE, self.cookie.to_string()) - .header(ORIGIN, "https://grok.com") - .header(PRAGMA, "no-cache") - .header("priority", "u=1, i") - .header(REFERER, "https://grok.com/imagine/favorites") - //.header("sec-ch-ua", "") // TODO - //.header("sec-ch-ua-mobile", "") // TODO - //.header("sec-ch-ua-platform", "") // TODO - .header("sec-fetch-dest", "empty") - .header("sec-fetch-mode", "cors") - .header("sec-fetch-site", "same-origin") - // TODO: Missing header "sentry-trace" - // TODO: Missing header "traceparent" - // TODO: Missing header "traceparent" - // TODO: Missing header "x-statsig-id" - // TODO: Missing header "x-xai-request-id" - .header(USER_AGENT, FIREFOX_143_MAC_USER_AGENT); - - //info!("Sending..."); - //let response = builder.send() - // .await - // .map_err(|err| GrokClientError::WreqClientError(err))?; - - if let Some(timeout) = self.request_timeout { - request_builder = request_builder.timeout(timeout); - } - - let request_body = UploadFileRequest { - fileName: file_name.to_string(), - fileMimeType: mime_type.to_string(), - content: base64_file, - fileSource: "IMAGINE_SELF_UPLOAD_FILE_SOURCE".to_string(), - }; - - let http_request = request_builder.json(&request_body) - .build() - .map_err(|err| { - error!("Error building image upload request: {:?}", err); - GrokClientError::WreqClientError(err) - })?; - - let response = client.execute(http_request) - .await - .map_err(|err| { - error!("Error during image upload: {:?}", err); - GrokGenericApiError::WreqError(err) - })?; - - let status = response.status(); - - let response_body = &response.text() - .await - .map_err(|err| { - error!("Error reading Grok image upload response body: {:?}", err); - GrokGenericApiError::WreqError(err) - })?; - - // TODO: Handle bad statuses - if !status.is_success() { - error!("Upload file request returned an error (code {}) : {:?}", status.as_u16(), response_body); - //return Err(classify_general_http_status_code_and_body(status, response_body)); - } - - let response : GrokApiUploadFileResponse = serde_json::from_str(response_body) - .map_err(|err| GrokGenericApiError::SerdeResponseParseErrorWithBody(err, response_body.to_string()))?; - - let file_id = response.file_metadata_id - .map(|id| FileId(id)); - - Ok(GrokUploadFileResponse { - file_id, - file_uri: response.file_uri, - }) - } -} - - -#[cfg(test)] -mod tests { - use super::*; - use crate::test_utils::get_test_cookies::get_test_cookies; - use errors::AnyhowResult; - - #[tokio::test] - #[ignore] - async fn upload_file() -> AnyhowResult<()> { - //setup_test_logging(LevelFilter::Trace); - - let cookies = get_test_cookies()?; - - let request = GrokUploadFile { - file: FileUploadSpec::Path("/Users/bt/dev/storyteller/storyteller-rust/test_data/image/mochi.jpg"), - cookie: cookies.to_string(), - request_timeout: None, - }; - - let result = request.upload().await?; - - println!("Result: {:?}", result); - assert_eq!(1, 2); - Ok(()) - } -} diff --git a/crates/api_clients/grok_consumer_client/src/requests/upload_file/mod.rs b/crates/api_clients/grok_consumer_client/src/requests/upload_file/mod.rs deleted file mode 100644 index a3fb932f84..0000000000 --- a/crates/api_clients/grok_consumer_client/src/requests/upload_file/mod.rs +++ /dev/null @@ -1,4 +0,0 @@ -pub mod grok_upload_file; - -pub (super) mod request; -pub (super) mod response; diff --git a/crates/api_clients/grok_consumer_client/src/requests/upload_file/request.rs b/crates/api_clients/grok_consumer_client/src/requests/upload_file/request.rs deleted file mode 100644 index b3b19015c7..0000000000 --- a/crates/api_clients/grok_consumer_client/src/requests/upload_file/request.rs +++ /dev/null @@ -1,18 +0,0 @@ -use serde::Serialize; - -#[derive(Serialize)] -pub (super) struct UploadFileRequest { - #[serde(rename="fileName")] - pub fileName: String, - - #[serde(rename="fileMimeType")] - pub fileMimeType: String, - - /// Base64-encoded content - pub content: String, - - /// eg. 'IMAGINE_SELF_UPLOAD_FILE_SOURCE' - #[serde(rename="fileSource")] - pub fileSource: String, -} - diff --git a/crates/api_clients/grok_consumer_client/src/requests/upload_file/response.rs b/crates/api_clients/grok_consumer_client/src/requests/upload_file/response.rs deleted file mode 100644 index 92f10b8ced..0000000000 --- a/crates/api_clients/grok_consumer_client/src/requests/upload_file/response.rs +++ /dev/null @@ -1,26 +0,0 @@ -use serde::Deserialize; - -#[derive(Deserialize)] -pub (super) struct GrokApiUploadFileResponse { - - /// The uploaded file_id, which is used to reference the file later. - #[serde(rename = "fileMetadataId")] - pub file_metadata_id: Option, - - /// Partial path to the media file, not a full URI. - /// eg. `users/{user_id}/{file_id}/content` - #[serde(rename = "fileUri")] - pub file_uri: Option, -} - -/* -{ - "fileMetadataId": "21a79085-e206-4b0b-88ac-5f2b7a453e45", - "fileMimeType": "image/jpeg", - "fileName": "0_0.jpeg", - "fileUri": "users/85980643-ffab-4984-a3de-59a608c47d7f/21a79085-e206-4b0b-88ac-5f2b7a453e45/content", - "parsedFileUri": "", - "createTime": "2025-10-21T23:40:41.784448Z", - "fileSource": "SELF_UPLOAD_FILE_SOURCE" -} -*/ diff --git a/crates/api_clients/grok_consumer_client/src/requests/video_chat/grok_video_gen_chat_conversation.rs b/crates/api_clients/grok_consumer_client/src/requests/video_chat/grok_video_gen_chat_conversation.rs deleted file mode 100644 index 10b7b50f47..0000000000 --- a/crates/api_clients/grok_consumer_client/src/requests/video_chat/grok_video_gen_chat_conversation.rs +++ /dev/null @@ -1,459 +0,0 @@ -use crate::client::browser_user_agents::FIREFOX_143_MAC_USER_AGENT; -use crate::datatypes::api::aspect_ratio::AspectRatio; -use crate::datatypes::api::baggage::Baggage; -use crate::datatypes::api::file_id::FileId; -use crate::datatypes::api::sentry_trace::SentryTrace; -use crate::datatypes::api::svg_path_data::SvgPathData; -use crate::datatypes::api::user_id::UserId; -use crate::datatypes::api::verification_token::VerificationToken; -use crate::datatypes::api::video_generation_mode::VideoGenerationMode; -use crate::datatypes::api::xsid_numbers::XsidNumbers; -use crate::error::categorize_grok_http_error::categorize_grok_http_error; -use crate::error::grok_client_error::GrokClientError; -use crate::error::grok_error::GrokError; -use crate::error::grok_generic_api_error::GrokGenericApiError; -use crate::requests::index_page::signature::generate_xsid::{generate_xsid, GenerateXsidArgs}; -use crate::requests::upload_file::grok_upload_file::{GrokUploadFile, GrokUploadFileResponse}; -use crate::requests::video_chat::parse_video_id::parse_video_id; -use crate::requests::video_chat::parse_video_id_from_partial_byte_stream_buffer::parse_video_id_from_partial_byte_stream_buffer; -use crate::requests::video_chat::request::{CreateChatConversationWireRequest, ModelConfigOverride, ModelMap, ResponseMetadata, ToolOverrides, VideoGenAspectRatio, VideoGenModelConfig}; -use crate::utils::user_and_file_id_to_image_url::user_and_file_id_to_image_url; -use futures::StreamExt; -use log::{debug, error, info, warn}; -use std::time::Duration; -use uuid::Uuid; -use wreq::header::{ACCEPT, ACCEPT_ENCODING, ACCEPT_LANGUAGE, CACHE_CONTROL, CONNECTION, CONTENT_TYPE, COOKIE, ORIGIN, PRAGMA, REFERER, TE, USER_AGENT}; -use wreq::{Client, Request, RequestBuilder, Response}; -use wreq_util::Emulation; - -const CHAT_CONVERSATION_URL: &str = "https://grok.com/rest/app-chat/conversations/new"; - -/// Request builder -/// NOTE: Without sending a "like" request after generation, the video will likely never render! -pub struct GrokVideoGenChatConversationBuilder<'a> { - pub file_id: &'a FileId, - pub media_type: VideoMediaPostType, - pub prompt: Option<&'a str>, - pub mode: Option, - pub aspect_ratio: Option, - - pub cookie: &'a str, - pub user_id: &'a UserId, - - pub baggage: &'a Baggage, - pub sentry_trace: &'a SentryTrace, - pub verification_token: &'a VerificationToken, - pub svg_data: &'a SvgPathData, - pub numbers: &'a XsidNumbers, - - pub request_timeout: Option, -} - -#[derive(Debug, Copy, Clone)] -pub enum VideoMediaPostType { - UserUploadedImage, - GrokGeneratedImage, - Video, -} - -/// Response type -#[derive(Debug)] -pub struct GrokVideoGenChatConversationResponse { - pub video_file_id: Option, -} - -/// Partial response type -/// This is from an incomplete stream -#[derive(Debug)] -pub struct GrokVideoGenChatConversationPartialResponse { - pub video_file_id: Option, -} - -impl <'a> GrokVideoGenChatConversationBuilder<'a> { - - /// Send the request and only wait long enough to get the video ID. - pub async fn stream_only_video_id(&self) -> Result { - info!("Configuring client and request..."); - let client = Self::build_client()?; - let http_request = self.build_request(&client)?; - - info!("Sending request..."); - let response = Self::send_request(&client, http_request).await?; - - info!("Reading status..."); - let status = response.status(); - - info!("Video Generation Enqueue Status: {:?}", status); - - let mut stream = response.bytes_stream(); - - let mut buffer = Vec::with_capacity(1024 * 1024); - - let mut file_id = None; - - while let Some(chunk) = stream.next().await { - if let Ok(bytes) = chunk { - buffer.extend(bytes); - } - - if let Some(id) = parse_video_id_from_partial_byte_stream_buffer(&buffer) { - file_id = Some(id); - info!("Got video id; ending stream early..."); - break; - } - } - - if file_id.is_none() { - warn!("Request ended without video id!"); - if let Some(id) = parse_video_id_from_partial_byte_stream_buffer(&buffer) { - file_id = Some(id); - } - } - - Ok(GrokVideoGenChatConversationPartialResponse { - video_file_id: file_id, - }) - } - - - pub async fn wait_for_video(&self) -> Result { - info!("Configuring client and request..."); - let client = Self::build_client()?; - let http_request = self.build_request(&client)?; - - info!("Sending request..."); - let response = Self::send_request(&client, http_request).await?; - - info!("Reading status..."); - let status = response.status(); - - info!("Video Generation Enqueue Status: {:?}", status); - - info!("Reading body..."); - - /* - Reading the body is what takes time. - 18:03:09.085612 [INFO] - Configuring client... - 18:03:09.089810 [INFO] - Sending request... - 18:03:09.089872 [INFO] - Pending response... - 18:03:09.274033 [INFO] - Reading status... - 18:03:09.274262 [INFO] - Video Generation Enqueue Status: 200 - 18:03:09.274304 [INFO] - Reading body... <-- This is what takes a while. - 18:03:35.186344 [INFO] - Read body. - */ - - /// TODO: Handle anti-bot detection - /// Body: {"error":{"code":7,"message":"Request rejected by anti-bot rules.","details":[]}} - let response_body = response.text() - .await - .map_err(|err| { - error!("Error reading Grok create media response body: {:?}", err); - GrokGenericApiError::WreqError(err) - })?; - - info!("Read body."); - - // TODO: Handle unsuccessful request, cloudflare, etc. - if !status.is_success() { - warn!("Not successful enqueuing video gen (code: {}) : {:?}", status.as_u16(), response_body); - // error!("Upload file request returned an error (code {}) : {:?}", status.as_u16(), response_body); - // return Err(classify_general_http_status_code_and_body(status, response_body)); - } - - // TODO: Just for now... - println!("Video Body: {:?}", response_body); - - let file_id = parse_video_id(&response_body); - - Ok(GrokVideoGenChatConversationResponse { - video_file_id: file_id, - }) - } - - - fn build_client() -> Result { - Ok(Client::builder() - .emulation(Emulation::Firefox143) - .build() - .map_err(|err| GrokClientError::WreqClientError(err))?) - } - - fn build_request(&self, client: &Client) -> Result { - let xai_request_id = Uuid::new_v4().to_string(); - let sentry_trace_header = self.sentry_trace.to_http_request_header(); - - debug!("xai_request_id (uuid) = {}", xai_request_id); - debug!("sentry_trace = {}", sentry_trace_header); - - let x_statsig_id = generate_xsid(GenerateXsidArgs { - path: "/rest/app-chat/conversations/new", - method: "POST", - verification_token: &self.verification_token, - svg_data: &self.svg_data, - numbers: &self.numbers, - })?; - - debug!("x_statsig_id = {}", x_statsig_id); - - // TODO: Headers were from Chromium, not Firefox. Partial implementation. - let mut request_builder = client.post(CHAT_CONVERSATION_URL) - //.header(PRAGMA, "no-cache") // Not on firefox - //.header(CACHE_CONTROL, "no-cache") // Not on firefox - //.header("priority", "u=1, i") // Different on firefox - //.header("sec-ch-ua", "") // NB: NOT IN FIREFOX - //.header("sec-ch-ua-mobile", "") // NB: NOT IN FIREFOX - //.header("sec-ch-ua-platform", "") // NB: NOT IN FIREFOX - //.header("traceparent", "") // TODO: Not sure where this originates - .header(USER_AGENT, FIREFOX_143_MAC_USER_AGENT) - .header(ACCEPT, "*/*") - .header(ACCEPT_LANGUAGE, "en-US,en;q=0.5") - .header(ACCEPT_ENCODING, "gzip, deflate, br, zstd") - .header(REFERER, "https://grok.com/imagine/favorites") - .header(CONTENT_TYPE, "application/json") - .header("x-xai-request-id", xai_request_id) - .header("x-statsig-id", x_statsig_id) - .header("sentry-trace", sentry_trace_header) - .header("baggage", &self.baggage.0) - .header(ORIGIN, "https://grok.com") - .header("priority", "u=4") - .header("sec-fetch-dest", "empty") - .header("sec-fetch-mode", "cors") - .header("sec-fetch-site", "same-origin") - .header("Sec-GPC", "1") - .header(CONNECTION, "keep-alive") - .header(COOKIE, self.cookie.to_string()) - .header(TE, "trailers"); - - if let Some(timeout) = self.request_timeout { - request_builder = request_builder.timeout(timeout); - } - - let media_url = match self.media_type { - VideoMediaPostType::UserUploadedImage => user_and_file_id_to_image_url(self.user_id, self.file_id), - VideoMediaPostType::GrokGeneratedImage => unimplemented!("implement for generated images"), - VideoMediaPostType::Video => unimplemented!("implement for videos"), - }; - - let mode_string = self.mode - .unwrap_or(VideoGenerationMode::Normal) - .as_api_mode_arg(); - - let mut prompt = format!("{media_url} --mode={mode_string}"); - - if let Some(user_prompt) = self.prompt { - // If a text prompt is set, mode seems to typically be "custom". - let mode_string = self.mode - .unwrap_or(VideoGenerationMode::Custom) - .as_api_mode_arg(); - - prompt = format!("{media_url} {user_prompt} --mode={mode_string}"); - } - - info!("Grok video prompt: {prompt}"); - - let aspect_ratio = match self.aspect_ratio { - Some(AspectRatio::Square) => VideoGenAspectRatio::Square, - Some(AspectRatio::WideThreeByTwo) => VideoGenAspectRatio::WideThreeByTwo, - Some(AspectRatio::TallTwoByThree) => VideoGenAspectRatio::TallTwoByThree, - None => VideoGenAspectRatio::WideThreeByTwo, - }; - - let request_body = CreateChatConversationWireRequest { - temporary: true, - model_name: "grok-3".to_string(), - message: prompt, - file_attachments: vec![ - self.file_id.0.to_string(), - ], - tool_overrides: ToolOverrides { - video_gen: true, - }, - response_metadata: ResponseMetadata { - model_config_override: ModelConfigOverride { - model_map: ModelMap { - video_gen_model_config: VideoGenModelConfig { - parent_post_id: self.file_id.0.to_string(), - video_length: 6, // NB: API defaults to "6" - aspect_ratio, - }, - }, - }, - }, - }; - - let http_request = request_builder.json(&request_body) - .build() - .map_err(|err| { - error!("Error building create media request: {:?}", err); - GrokClientError::WreqClientError(err) - })?; - - Ok(http_request) - } - - async fn send_request(client: &Client, request: Request) -> Result { - let response = client.execute(request) - .await - .map_err(|err| { - error!("Error during create media: {:?}", err); - GrokGenericApiError::WreqError(err) - })?; - - let status = response.status(); - - if !status.is_success() { - let maybe_body = response.text() - .await - .map_err(|err| { - error!("Error reading Grok video generation response body: {:?}", err); - err - }) - .ok(); - - return Err(categorize_grok_http_error(status, maybe_body.as_deref())) - } - - Ok(response) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use crate::datatypes::file_upload_spec::FileUploadSpec; - use crate::recipes::request_client_secrets::{request_client_secrets, RequestClientSecretsArgs}; - use crate::test_utils::get_test_cookies::get_typed_test_cookies; - use crate::test_utils::setup_test_logging::setup_test_logging; - use crate::utils::user_and_file_id_to_video_url::user_and_file_id_to_video_url; - use errors::AnyhowResult; - use log::LevelFilter; - - #[tokio::test] - #[ignore] - async fn create_video() -> AnyhowResult<()> { - setup_test_logging(LevelFilter::Info); - - //let file_id = FileId("990ddf90-8f34-42b1-81a5-39c509d62ff7".to_string()); // Mochi - - let image_path = "/Users/bt/Pictures/Zelda 64 Art/7j8baxv9m8u61.jpg"; - let maybe_prompt = Some("The hero shoots an arrow and it hits a skeleton monster"); - - let cookies = get_typed_test_cookies()?; - - let secrets = request_client_secrets(RequestClientSecretsArgs { - cookies: &cookies, - }).await?; - - let upload_request = GrokUploadFile { - file: FileUploadSpec::Path(image_path), - cookie: cookies.to_string(), - request_timeout: None, - }; - - let upload_result = upload_request.upload().await?; - - let file_id = upload_result.file_id.expect("upload should have file_id"); - - println!("Verification Token: {:?}", secrets.verification_token); - println!("Sentry Trace: {:?}", secrets.sentry_trace); - println!("Numbers: {:?}", secrets.numbers); - println!("Svg Path: {:?}", secrets.svg_path_data); - println!("Baggage: {:?}", secrets.baggage); - - let request = GrokVideoGenChatConversationBuilder { - file_id: &file_id, - media_type: VideoMediaPostType::UserUploadedImage, - prompt: maybe_prompt, - mode: Some(VideoGenerationMode::Custom), - aspect_ratio: Some(AspectRatio::TallTwoByThree), - - cookie: cookies.as_str(), - user_id: &secrets.user_id, - baggage: &secrets.baggage, - sentry_trace: &secrets.sentry_trace, - verification_token: &secrets.verification_token, - svg_data: &secrets.svg_path_data, - numbers: &secrets.numbers, - - request_timeout: None, - }; - - let result = request.wait_for_video().await?; - - println!("Result: {:?}", result); - - let video_id = result.video_file_id.expect("should have video id"); - - // NOTE: WITHOUT A "LIKE" REQUEST, THIS FILE WILL LIKELY CEASE TO EXIST. - let video_url = user_and_file_id_to_video_url(&secrets.user_id, &video_id, false); - - println!("Video URL: {:?}", video_url); - - assert_eq!(1, 2); - Ok(()) - } - - - #[tokio::test] - #[ignore] - async fn stream_video_id() -> AnyhowResult<()> { - setup_test_logging(LevelFilter::Info); - - let image_path = "/Users/bt/Pictures/Zelda 64 Art/7j8baxv9m8u61.jpg"; - let maybe_prompt = Some("The hero puts down his bow"); - - let cookies = get_typed_test_cookies()?; - - let secrets = request_client_secrets(RequestClientSecretsArgs { - cookies: &cookies, - }).await?; - - let upload_request = GrokUploadFile { - file: FileUploadSpec::Path(image_path), - cookie: cookies.to_string(), - request_timeout: None, - }; - - let upload_result = upload_request.upload().await?; - - let file_id = upload_result.file_id.expect("upload should have file_id"); - - println!("Verification Token: {:?}", secrets.verification_token); - println!("Sentry Trace: {:?}", secrets.sentry_trace); - println!("Numbers: {:?}", secrets.numbers); - println!("Svg Path: {:?}", secrets.svg_path_data); - println!("Baggage: {:?}", secrets.baggage); - - let request = GrokVideoGenChatConversationBuilder { - file_id: &file_id, - media_type: VideoMediaPostType::UserUploadedImage, - prompt: maybe_prompt, - mode: None, - aspect_ratio: Some(AspectRatio::Square), - - cookie: cookies.as_str(), - user_id: &secrets.user_id, - baggage: &secrets.baggage, - sentry_trace: &secrets.sentry_trace, - verification_token: &secrets.verification_token, - svg_data: &secrets.svg_path_data, - numbers: &secrets.numbers, - - request_timeout: None, - }; - - let result = request.stream_only_video_id().await?; - - println!("Result: {:?}", result); - - let video_id = result.video_file_id.expect("should have video id"); - - // NOTE: WITHOUT A "LIKE" REQUEST, THIS FILE WILL LIKELY CEASE TO EXIST. - let video_url = user_and_file_id_to_video_url(&secrets.user_id, &video_id, false); - - println!("Video URL: {:?}", video_url); - - assert_eq!(1, 2); - Ok(()) - } -} diff --git a/crates/api_clients/grok_consumer_client/src/requests/video_chat/mod.rs b/crates/api_clients/grok_consumer_client/src/requests/video_chat/mod.rs deleted file mode 100644 index 075805f744..0000000000 --- a/crates/api_clients/grok_consumer_client/src/requests/video_chat/mod.rs +++ /dev/null @@ -1,4 +0,0 @@ -pub mod grok_video_gen_chat_conversation; -pub (super) mod request; -mod parse_video_id; -mod parse_video_id_from_partial_byte_stream_buffer; \ No newline at end of file diff --git a/crates/api_clients/grok_consumer_client/src/requests/video_chat/parse_video_id.rs b/crates/api_clients/grok_consumer_client/src/requests/video_chat/parse_video_id.rs deleted file mode 100644 index e104d6816c..0000000000 --- a/crates/api_clients/grok_consumer_client/src/requests/video_chat/parse_video_id.rs +++ /dev/null @@ -1,44 +0,0 @@ -use crate::datatypes::api::file_id::FileId; -use once_cell::sync::Lazy; -use regex::Regex; - -/// Find the video id in the response (which is streamed, appended JSON) -/// eg. {\"videoId\":\"34fa0313-3cde-4693-b046-319093374dbe\" -static JSON_REGEX: Lazy = Lazy::new(|| { - // NB: Should be a 36 character UUID. - Regex::new(r#"\\?"videoI[dD]\\?":\s*\\?"([a-zA-Z0-9-]{25,})\\?",?"#) - .expect("Regex should parse") -}); - -/// Parse the video ID from the response -pub fn parse_video_id(html: &str) -> Option { - let maybe_meta = scrape_video_id_via_regex(html); - - if let Some(meta) = maybe_meta { - return Some(FileId(meta)) - } - - None -} - -fn scrape_video_id_via_regex(html: &str) -> Option { - let captures = JSON_REGEX.captures(html)?; - let capture = captures.get(1)?; - Some(capture.as_str().to_string()) -} - -#[cfg(test)] -mod tests { - use crate::requests::video_chat::parse_video_id::parse_video_id; - use errors::AnyhowResult; - - const PAYLOAD : &str = r#"{\"result\":{\"conversation\":{\"conversationId\":\"ba9499ba-4a59-46f5-8d41-a04c527c1693\",\"title\":\"New conversation\",\"starred\":false,\"createTime\":\"2025-10-30T19:04:27.650012Z\",\"modifyTime\":\"2025-10-30T19:04:27.652930Z\",\"systemPromptName\":\"\",\"temporary\":true,\"mediaTypes\":[],\"workspaces\":[],\"taskResult\":null}}}\n{\"result\":{\"response\":{\"userResponse\":{\"responseId\":\"62d85bb5-746f-45e1-9a9e-40f8a9ef2a3e\",\"message\":\"https://assets.grok.com/users/85980643-ffab-4984-a3de-59a608c47d7f/eabcc2a5-8a9b-4382-82d2-020b4b286e87/content our hero link on horseback galloping through the fantasy world, bright sun behind him. a dormant volcano has a circling ring of smoke. the camera pulls back and follows our hero --mode=custom\",\"sender\":\"human\",\"createTime\":\"2025-10-30T19:04:27.706802818Z\",\"manual\":false,\"partial\":false,\"shared\":false,\"query\":\"\",\"queryType\":\"\",\"webSearchResults\":[],\"xpostIds\":[],\"xposts\":[],\"generatedImageUrls\":[],\"imageAttachments\":[],\"fileAttachments\":[\"eabcc2a5-8a9b-4382-82d2-020b4b286e87\"],\"cardAttachmentsJson\":[],\"fileUris\":[],\"fileAttachmentsMetadata\":[],\"isControl\":false,\"steps\":[],\"imageEditUris\":[],\"mediaTypes\":[],\"webpageUrls\":[],\"metadata\":{\"modelConfigOverride\":{\"modelMap\":{\"videoGenModelConfig\":{\"parentPostId\":\"eabcc2a5-8a9b-4382-82d2-020b4b286e87\"}}}},\"citedWebSearchResults\":[],\"toolResponses\":[],\"model\":\"grok-3\",\"ragResults\":[],\"citedRagResults\":[],\"searchProductResults\":[]},\"isThinking\":false,\"isSoftStop\":false,\"responseId\":\"62d85bb5-746f-45e1-9a9e-40f8a9ef2a3e\"}}}\n{\"result\":{\"response\":{\"streamingVideoGenerationResponse\":{\"videoId\":\"34fa0313-3cde-4693-b046-319093374dbe\",\"progress\":1,\"audioUrls\":[],\"videoPrompt\":\"our hero link on horseback galloping through the fantasy world, bright sun behind him. a dormant volcano has a circling ring of smoke. the camera pulls back and follows our hero\",\"imageReference\":\"https://assets.grok.com/users/85980643-ffab-4984-a3de-59a608c47d7f/eabcc2a5-8a9b-4382-82d2-020b4b286e87/content\",\"audioTranscripts\":[],\"moderated\":false,\"mode\":\"custom\",\"modelName\":\"imagine_xdit_1\"},\"isThinking\":false,\"isSoftStop\":false,\"responseId\":\"791ddc68-d4c1-4e37-95d1-88ad9c7903dc\"}}}\n{\"result\":{\"response\":{\"streamingVideoGenerationResponse\":{\"videoId\":\"34fa0313-3cde-4693-b046-319093374dbe\",\"progress\":5,\"audioUrls\":[],\"videoPrompt\":\"our hero link on horseback galloping through the fantasy world, bright sun behind him. a dormant volcano has a circling ring of smoke. the camera pulls back and follows our hero\",\"imageReference\":\"https://assets.grok.com/users/85980643-ffab-4984-a3de-59a608c47d7f/eabcc2a5-8a9b-4382-82d2-020b4b286e87/content\",\"audioTranscripts\":[],\"moderated\":false,\"mode\":\"custom\",\"modelName\":\"imagine_xdit_1\"},\"isThinking\":false,\"isSoftStop\":false,\"responseId\":\"791ddc68-d4c1-4e37-95d1-88ad9c7903dc\"}}}\n{\"result\":{\"response\":{\"streamingVideoGenerationResponse\":{\"videoId\":\"34fa0313-3cde-4693-b046-319093374dbe\",\"progress\":14,\"audioUrls\":[],\"videoPrompt\":\"our hero link on horseback galloping through the fantasy world, bright sun behind him. a dormant volcano has a circling ring of smoke. the camera pulls back and follows our hero\",\"imageReference\":\"https://assets.grok.com/users/85980643-ffab-4984-a3de-59a608c47d7f/eabcc2a5-8a9b-4382-82d2-020b4b286e87/content\",\"audioTranscripts\":[],\"moderated\":false,\"mode\":\"custom\",\"modelName\":\"imagine_xdit_1\"},\"isThinking\":false,\"isSoftStop\":false,\"responseId\":\"791ddc68-d4c1-4e37-95d1-88ad9c7903dc\"}}}\n{\"result\":{\"response\":{\"streamingVideoGenerationResponse\":{\"videoId\":\"34fa0313-3cde-4693-b046-319093374dbe\",\"progress\":23,\"audioUrls\":[],\"videoPrompt\":\"our hero link on horseback galloping through the fantasy world, bright sun behind him. a dormant volcano has a circling ring of smoke. the camera pulls back and follows our hero\",\"imageReference\":\"https://assets.grok.com/users/85980643-ffab-4984-a3de-59a608c47d7f/eabcc2a5-8a9b-4382-82d2-020b4b286e87/content\",\"audioTranscripts\":[],\"moderated\":false,\"mode\":\"custom\",\"modelName\":\"imagine_xdit_1\"},\"isThinking\":false,\"isSoftStop\":false,\"responseId\":\"791ddc68-d4c1-4e37-95d1-88ad9c7903dc\"}}}\n{\"result\":{\"response\":{\"streamingVideoGenerationResponse\":{\"videoId\":\"34fa0313-3cde-4693-b046-319093374dbe\",\"progress\":32,\"audioUrls\":[],\"videoPrompt\":\"our hero link on horseback galloping through the fantasy world, bright sun behind him. a dormant volcano has a circling ring of smoke. the camera pulls back and follows our hero\",\"imageReference\":\"https://assets.grok.com/users/85980643-ffab-4984-a3de-59a608c47d7f/eabcc2a5-8a9b-4382-82d2-020b4b286e87/content\",\"audioTranscripts\":[],\"moderated\":false,\"mode\":\"custom\",\"modelName\":\"imagine_xdit_1\"},\"isThinking\":false,\"isSoftStop\":false,\"responseId\":\"791ddc68-d4c1-4e37-95d1-88ad9c7903dc\"}}}\n{\"result\":{\"response\":{\"streamingVideoGenerationResponse\":{\"videoId\":\"34fa0313-3cde-4693-b046-319093374dbe\",\"progress\":42,\"audioUrls\":[],\"videoPrompt\":\"our hero link on horseback galloping through the fantasy world, bright sun behind him. a dormant volcano has a circling ring of smoke. the camera pulls back and follows our hero\",\"imageReference\":\"https://assets.grok.com/users/85980643-ffab-4984-a3de-59a608c47d7f/eabcc2a5-8a9b-4382-82d2-020b4b286e87/content\",\"audioTranscripts\":[],\"moderated\":false,\"mode\":\"custom\",\"modelName\":\"imagine_xdit_1\"},\"isThinking\":false,\"isSoftStop\":false,\"responseId\":\"791ddc68-d4c1-4e37-95d1-88ad9c7903dc\"}}}\n{\"result\":{\"response\":{\"streamingVideoGenerationResponse\":{\"videoId\":\"34fa0313-3cde-4693-b046-319093374dbe\",\"progress\":52,\"audioUrls\":[],\"videoPrompt\":\"our hero link on horseback galloping through the fantasy world, bright sun behind him. a dormant volcano has a circling ring of smoke. the camera pulls back and follows our hero\",\"imageReference\":\"https://assets.grok.com/users/85980643-ffab-4984-a3de-59a608c47d7f/eabcc2a5-8a9b-4382-82d2-020b4b286e87/content\",\"audioTranscripts\":[],\"moderated\":false,\"mode\":\"custom\",\"modelName\":\"imagine_xdit_1\"},\"isThinking\":false,\"isSoftStop\":false,\"responseId\":\"791ddc68-d4c1-4e37-95d1-88ad9c7903dc\"}}}\n{\"result\":{\"response\":{\"streamingVideoGenerationResponse\":{\"videoId\":\"34fa0313-3cde-4693-b046-319093374dbe\",\"progress\":95,\"audioUrls\":[],\"videoPrompt\":\"our hero link on horseback galloping through the fantasy world, bright sun behind him. a dormant volcano has a circling ring of smoke. the camera pulls back and follows our hero\",\"imageReference\":\"https://assets.grok.com/users/85980643-ffab-4984-a3de-59a608c47d7f/eabcc2a5-8a9b-4382-82d2-020b4b286e87/content\",\"audioTranscripts\":[],\"moderated\":false,\"mode\":\"custom\",\"modelName\":\"imagine_xdit_1\"},\"isThinking\":false,\"isSoftStop\":false,\"responseId\":\"791ddc68-d4c1-4e37-95d1-88ad9c7903dc\"}}}\n{\"result\":{\"response\":{\"streamingVideoGenerationResponse\":{\"videoId\":\"34fa0313-3cde-4693-b046-319093374dbe\",\"progress\":100,\"assetId\":\"34fa0313-3cde-4693-b046-319093374dbe\",\"videoUrl\":\"users/85980643-ffab-4984-a3de-59a608c47d7f/generated/34fa0313-3cde-4693-b046-319093374dbe/generated_video.mp4\",\"audioUrls\":[],\"videoPrompt\":\"our hero link on horseback galloping through the fantasy world, bright sun behind him. a dormant volcano has a circling ring of smoke. the camera pulls back and follows our hero\",\"imageReference\":\"https://assets.grok.com/users/85980643-ffab-4984-a3de-59a608c47d7f/eabcc2a5-8a9b-4382-82d2-020b4b286e87/content\",\"audioTranscripts\":[],\"moderated\":false,\"mode\":\"custom\",\"modelName\":\"imagine_xdit_1\",\"thumbnailImageUrl\":\"users/85980643-ffab-4984-a3de-59a608c47d7f/generated/34fa0313-3cde-4693-b046-319093374dbe/preview_image.jpg\"},\"isThinking\":false,\"isSoftStop\":false,\"responseId\":\"791ddc68-d4c1-4e37-95d1-88ad9c7903dc\"}}}\n{\"result\":{\"response\":{\"token\":\"I generated a video with the prompt: 'our hero link on horseback galloping through the fantasy world, bright sun behind him. a dormant volcano has a circling ring of smoke. the camera pulls back and follows our hero'\",\"isThinking\":false,\"isSoftStop\":false,\"responseId\":\"791ddc68-d4c1-4e37-95d1-88ad9c7903dc\"}}}\n{\"result\":{\"response\":{\"token\":\"\",\"isThinking\":false,\"isSoftStop\":true,\"responseId\":\"791ddc68-d4c1-4e37-95d1-88ad9c7903dc\"}}}\n{\"result\":{\"response\":{\"modelResponse\":{\"responseId\":\"791ddc68-d4c1-4e37-95d1-88ad9c7903dc\",\"message\":\"I generated a video with the prompt: 'our hero link on horseback galloping through the fantasy world, bright sun behind him. a dormant volcano has a circling ring of smoke. the camera pulls back and follows our hero'\",\"sender\":\"ASSISTANT\",\"createTime\":\"2025-10-30T19:04:52.510270096Z\",\"parentResponseId\":\"62d85bb5-746f-45e1-9a9e-40f8a9ef2a3e\",\"manual\":false,\"partial\":false,\"shared\":false,\"query\":\"\",\"queryType\":\"\",\"webSearchResults\":[],\"xpostIds\":[],\"xposts\":[],\"generatedImageUrls\":[],\"imageAttachments\":[],\"fileAttachments\":[\"34fa0313-3cde-4693-b046-319093374dbe\"],\"cardAttachmentsJson\":[],\"fileUris\":[],\"fileAttachmentsMetadata\":[],\"isControl\":false,\"steps\":[],\"imageEditUris\":[],\"mediaTypes\":[],\"webpageUrls\":[],\"metadata\":{\"deepsearchPreset\":\"\",\"request_metadata\":{\"effort\":\"low\",\"mode\":\"fast\",\"model\":\"grok-3\"},\"request_trace_id\":\"5447a9522af26a244b86bdaef90e4a25\"},\"citedWebSearchResults\":[],\"toolResponses\":[],\"model\":\"grok-3\",\"requestMetadata\":{\"model\":\"grok-3\",\"mode\":\"MODEL_MODE_FAST\",\"effort\":\"LOW\"},\"ragResults\":[],\"citedRagResults\":[],\"searchProductResults\":[]},\"isThinking\":false,\"isSoftStop\":false,\"responseId\":\"791ddc68-d4c1-4e37-95d1-88ad9c7903dc\"}}}\n{\"result\":{\"title\":{\"newTitle\":\"Video Generation: Fantasy Hero Journey\"}}}\n"#; - - #[test] - fn test() -> AnyhowResult<()> { - let video_id = parse_video_id(PAYLOAD).unwrap(); - let expected = "34fa0313-3cde-4693-b046-319093374dbe"; - assert_eq!(&video_id.0, expected); - Ok(()) - } -} diff --git a/crates/api_clients/grok_consumer_client/src/requests/video_chat/parse_video_id_from_partial_byte_stream_buffer.rs b/crates/api_clients/grok_consumer_client/src/requests/video_chat/parse_video_id_from_partial_byte_stream_buffer.rs deleted file mode 100644 index 66c2da434b..0000000000 --- a/crates/api_clients/grok_consumer_client/src/requests/video_chat/parse_video_id_from_partial_byte_stream_buffer.rs +++ /dev/null @@ -1,69 +0,0 @@ -use crate::datatypes::api::file_id::FileId; -use bstr::ByteSlice; -use once_cell::sync::Lazy; -use regex::Regex; - -/// Find the video id in the response (which is streamed, appended JSON) -/// eg. {\"videoId\":\"34fa0313-3cde-4693-b046-319093374dbe\" -static JSON_REGEX: Lazy = Lazy::new(|| { - // NB: Should be a 36 character UUID. - Regex::new(r#"\\?"videoI[dD]\\?":\s*\\?"([a-zA-Z0-9-]{25,})\\?",?"#) - .expect("Regex should parse") -}); - -/// Look for this in the incomplete byte stream to try parsing it out. -const VIDEO_BYTES : &[u8] = b"videoI"; - -/// Parse the video ID from the streamed response -pub fn parse_video_id_from_partial_byte_stream_buffer(bytes: &[u8]) -> Option { - let found = bytes.find(VIDEO_BYTES).is_some(); - if !found { - return None; - } - - let partial_json = bytes.to_str_lossy(); - let maybe_meta = scrape_video_id_via_regex(&partial_json); - - if let Some(meta) = maybe_meta { - return Some(FileId(meta)) - } - - None -} - -fn scrape_video_id_via_regex(html: &str) -> Option { - let captures = JSON_REGEX.captures(html)?; - let capture = captures.get(1)?; - Some(capture.as_str().to_string()) -} - -#[cfg(test)] -mod tests { - use crate::requests::video_chat::parse_video_id_from_partial_byte_stream_buffer::parse_video_id_from_partial_byte_stream_buffer; - use errors::AnyhowResult; - - #[test] - fn present_in_partial_bytes() -> AnyhowResult<()> { - let partial_bytes = b"}}}\n{\"result\":{\"response\":{\"streamingVideoGenerationResponse\":{\"videoId\":\"34fa0313-3cde-4693-b046-319093374dbe\",\"pro"; - let video_id = parse_video_id_from_partial_byte_stream_buffer(partial_bytes).unwrap(); - let expected = "34fa0313-3cde-4693-b046-319093374dbe"; - assert_eq!(&video_id.0, expected); - Ok(()) - } - - #[test] - fn field_present_but_data_incomplete() -> AnyhowResult<()> { - let partial_bytes = b"Response\":{\"videoId\":\"34fa0313-3cde-4693-b046-"; - let result = parse_video_id_from_partial_byte_stream_buffer(partial_bytes); - assert!(result.is_none()); - Ok(()) - } - - #[test] - fn not_present() -> AnyhowResult<()> { - let partial_bytes = b"}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}]"; - let result = parse_video_id_from_partial_byte_stream_buffer(partial_bytes); - assert!(result.is_none()); - Ok(()) - } -} diff --git a/crates/api_clients/grok_consumer_client/src/requests/video_chat/request.rs b/crates/api_clients/grok_consumer_client/src/requests/video_chat/request.rs deleted file mode 100644 index 2fa53073f2..0000000000 --- a/crates/api_clients/grok_consumer_client/src/requests/video_chat/request.rs +++ /dev/null @@ -1,163 +0,0 @@ -use serde::Serialize; - -#[derive(Serialize)] -pub (super) struct CreateChatConversationWireRequest { - #[serde(rename = "temporary")] - pub (super) temporary: bool, - - #[serde(rename = "modelName")] - pub (super) model_name: String, - - /// The prompt - #[serde(rename = "message")] - pub (super) message: String, - - #[serde(rename = "fileAttachments")] - pub (super) file_attachments: Vec, - - #[serde(rename = "toolOverrides")] - pub (super) tool_overrides: ToolOverrides, - - #[serde(rename = "responseMetadata")] - pub (super) response_metadata: ResponseMetadata, -} - -#[derive(Serialize)] -pub (super) struct ToolOverrides { - #[serde(rename = "videoGen")] - pub (super) video_gen: bool, -} - -#[derive(Serialize)] -pub (super) struct ResponseMetadata { - #[serde(rename = "modelConfigOverride")] - pub (super) model_config_override: ModelConfigOverride, -} - -#[derive(Serialize)] -pub (super) struct ModelConfigOverride { - #[serde(rename = "modelMap")] - pub (super) model_map: ModelMap, -} - - -#[derive(Serialize)] -pub (super) struct ModelMap { - #[serde(rename = "videoGenModelConfig")] - pub (super) video_gen_model_config: VideoGenModelConfig, -} - -#[derive(Serialize)] -pub (super) struct VideoGenModelConfig { - #[serde(rename = "parentPostId")] - pub (super) parent_post_id: String, - - /// Newer field as of November - /// values: "1:1", "2:3" (tall), - #[serde(rename = "aspectRatio")] - pub (super) aspect_ratio: VideoGenAspectRatio, - - /// Newer field as of November - /// default seems to be "6" - #[serde(rename = "videoLength")] - pub (super) video_length: u32, -} - -#[derive(Serialize, Clone, Copy, Debug)] -pub (super) enum VideoGenAspectRatio { - #[serde(rename = "2:3")] - TallTwoByThree, - - #[serde(rename = "3:2")] - WideThreeByTwo, - - #[serde(rename = "1:1")] - Square, -} - -/* - -November 27 no image (text only) square aspect ratio - - ---data-raw - { - "temporary":true, - "modelName":"grok-3", - "message":"A waterspout wrecks an oil tanker, misty, huge waves --mode=custom", - "toolOverrides": { - "videoGen":true - }, - "responseMetadata": { - "modelConfigOverride": { - "modelMap": { - "videoGenModelConfig": { - "parentPostId":"b0b88b45-9724-49bd-a82c-c83ddcd2937f", - "aspectRatio":"2:3", - "videoLength":6 - } - } - } - } - } - -October 29 request struct - - ---data-raw - { - "temporary":true, - "modelName":"grok-3", - "message":"https://assets.grok.com/users/85980643-ffab-4984-a3de-59a608c47d7f/d6d73ffd-ce87-40a3-9cc2-3432d7192652/content --mode=normal", - "fileAttachments":["d6d73ffd-ce87-40a3-9cc2-3432d7192652"], - "toolOverrides":{ - "videoGen":true - }, - "responseMetadata":{ - "modelConfigOverride":{ - "modelMap":{ - "videoGenModelConfig":{ - "parentPostId":"d6d73ffd-ce87-40a3-9cc2-3432d7192652" - } - } - } - } - } - - -October 29 generate from already uploaded image with prompt struct - ---data-raw - { - "temporary":true, - "modelName":"grok-3", - "message":"https://assets.grok.com/users/85980643-ffab-4984-a3de-59a608c47d7f/d6d73ffd-ce87-40a3-9cc2-3432d7192652/content building gets hit by tornado --mode=custom", - "fileAttachments":["d6d73ffd-ce87-40a3-9cc2-3432d7192652"], - "toolOverrides":{ - "videoGen":true - }, - "responseMetadata":{ - "modelConfigOverride":{ - "modelMap":{ - "videoGenModelConfig":{ - "parentPostId":"d6d73ffd-ce87-40a3-9cc2-3432d7192652" - } - } - } - } - } - -October 22 request struct - - ---data-raw - { - "temporary":true, - "modelName":"grok-3", - "message":"https://assets.grok.com/users/85980643-ffab-4984-a3de-59a608c47d7f/21a79085-e206-4b0b-88ac-5f2b7a453e45/content --mode=normal", - "fileAttachments": [ - "21a79085-e206-4b0b-88ac-5f2b7a453e45" - ], - "toolOverrides": { - "videoGen":true - } - } - -*/ - diff --git a/crates/api_clients/grok_consumer_client/src/test_utils/get_test_cookies.rs b/crates/api_clients/grok_consumer_client/src/test_utils/get_test_cookies.rs deleted file mode 100644 index d406647978..0000000000 --- a/crates/api_clients/grok_consumer_client/src/test_utils/get_test_cookies.rs +++ /dev/null @@ -1,15 +0,0 @@ -use crate::credentials::grok_cookies::GrokCookies; -use errors::AnyhowResult; -use std::fs::read_to_string; - -#[cfg(test)] -pub fn get_test_cookies() -> AnyhowResult { - let cookies = read_to_string("/Users/bt/Artcraft/credentials/grok_cookies.txt")?; - let cookies = cookies.trim().to_string(); - Ok(cookies) -} - -pub fn get_typed_test_cookies() -> AnyhowResult { - let cookies = get_test_cookies()?; - Ok(GrokCookies::new(cookies)) -} diff --git a/crates/api_clients/grok_consumer_client/src/test_utils/mod.rs b/crates/api_clients/grok_consumer_client/src/test_utils/mod.rs deleted file mode 100644 index 54c16f3413..0000000000 --- a/crates/api_clients/grok_consumer_client/src/test_utils/mod.rs +++ /dev/null @@ -1,5 +0,0 @@ -#[cfg(test)] -pub (crate) mod get_test_cookies; - -#[cfg(test)] -pub (crate) mod setup_test_logging; diff --git a/crates/api_clients/grok_consumer_client/src/test_utils/setup_test_logging.rs b/crates/api_clients/grok_consumer_client/src/test_utils/setup_test_logging.rs deleted file mode 100644 index 9438da106c..0000000000 --- a/crates/api_clients/grok_consumer_client/src/test_utils/setup_test_logging.rs +++ /dev/null @@ -1,52 +0,0 @@ -use chrono::Local; -use env_logger::Builder; -use log::{debug, error, info, trace, warn, LevelFilter}; -use std::io::Write; - -const RUST_LOG : &str = "RUST_LOG"; - -pub fn setup_test_logging(level: LevelFilter) { - let level_str = get_level_str(level); - - println!("Previous log level: {:?}", env::var(RUST_LOG)); - - let is_unsafe = env::set_var(RUST_LOG, level_str); - - if is_unsafe.is_none() { - println!("Unsafely setting Rust Log Level..."); - unsafe { std::env::set_var(RUST_LOG, level_str) } - } - - println!("Log level: {:?}", env::var(RUST_LOG)); - - Builder::new() - .is_test(true) - .format(|buf, record| { - writeln!(buf, - "{} [{}] - {}", - Local::now().format("%H:%M:%S%.6f"), - record.level(), - record.args() - ) - }) - .filter(None, level) - .filter_level(level) - .init(); - - trace!("Test trace log"); - debug!("Test debug log"); - info!("Test info log"); - warn!("Test warn log"); - error!("Test error log"); -} - -fn get_level_str(level: LevelFilter) -> &'static str { - match level { - LevelFilter::Error => "error", - LevelFilter::Warn => "warn", - LevelFilter::Info => "info", - LevelFilter::Debug => "debug", - LevelFilter::Trace => "trace", - LevelFilter::Off => "off", - } -} diff --git a/crates/api_clients/grok_consumer_client/src/utils/create_firefox_client.rs b/crates/api_clients/grok_consumer_client/src/utils/create_firefox_client.rs deleted file mode 100644 index c3ade7e315..0000000000 --- a/crates/api_clients/grok_consumer_client/src/utils/create_firefox_client.rs +++ /dev/null @@ -1,10 +0,0 @@ -use crate::error::grok_client_error::GrokClientError; -use wreq::Client; -use wreq_util::Emulation; - -pub fn create_firefox_client() -> Result { - Client::builder() - .emulation(Emulation::Firefox143) - .build() - .map_err(|err| GrokClientError::WreqClientError(err)) -} diff --git a/crates/api_clients/grok_consumer_client/src/utils/mod.rs b/crates/api_clients/grok_consumer_client/src/utils/mod.rs deleted file mode 100644 index 22c38941b9..0000000000 --- a/crates/api_clients/grok_consumer_client/src/utils/mod.rs +++ /dev/null @@ -1,6 +0,0 @@ -pub mod user_and_file_id_to_image_url; -pub mod user_and_file_id_to_video_url; - -// Just for the crate -pub (crate) mod create_firefox_client; -pub (crate) mod scrub_blobs_for_debug_logging; diff --git a/crates/api_clients/grok_consumer_client/src/utils/scrub_blobs_for_debug_logging.rs b/crates/api_clients/grok_consumer_client/src/utils/scrub_blobs_for_debug_logging.rs deleted file mode 100644 index fa1d3404cc..0000000000 --- a/crates/api_clients/grok_consumer_client/src/utils/scrub_blobs_for_debug_logging.rs +++ /dev/null @@ -1,12 +0,0 @@ -use once_cell::sync::Lazy; -use regex::Regex; - -static LARGE_BLOB_REGEX: Lazy = Lazy::new(|| { - Regex::new(r#"[^"]{100,}"#) - .expect("Regex should parse") -}); - -/// Helpful for debugging large websocket payloads with in-stream base64-encoded image binaries. -pub fn scrub_blobs_for_debug_logging(blob: &str) -> String { - LARGE_BLOB_REGEX.replace(blob, "...").to_string() -} diff --git a/crates/api_clients/grok_consumer_client/src/utils/user_and_file_id_to_image_url.rs b/crates/api_clients/grok_consumer_client/src/utils/user_and_file_id_to_image_url.rs deleted file mode 100644 index f2a594c24d..0000000000 --- a/crates/api_clients/grok_consumer_client/src/utils/user_and_file_id_to_image_url.rs +++ /dev/null @@ -1,25 +0,0 @@ -use crate::datatypes::api::file_id::FileId; -use crate::datatypes::api::user_id::UserId; - -/// Return media URLs to images given the user and file IDs. -/// These are non-public and will return 403s unless you're logged in. -pub fn user_and_file_id_to_image_url(user: &UserId, file: &FileId) -> String { - let user_id = &user.0; - let file_id = &file.0; - format!("https://assets.grok.com/users/{user_id}/{file_id}/content") -} - -#[cfg(test)] -mod tests { - use crate::datatypes::api::file_id::FileId; - use crate::datatypes::api::user_id::UserId; - use crate::utils::user_and_file_id_to_image_url::user_and_file_id_to_image_url; - - #[test] - fn test_url() { - let user = UserId(String::from("USER_UUID")); - let file = FileId(String::from("FILE_UUID")); - let url = user_and_file_id_to_image_url(&user, &file); - assert_eq!(&url, "https://assets.grok.com/users/USER_UUID/FILE_UUID/content"); - } -} diff --git a/crates/api_clients/grok_consumer_client/src/utils/user_and_file_id_to_video_url.rs b/crates/api_clients/grok_consumer_client/src/utils/user_and_file_id_to_video_url.rs deleted file mode 100644 index 07fa438762..0000000000 --- a/crates/api_clients/grok_consumer_client/src/utils/user_and_file_id_to_video_url.rs +++ /dev/null @@ -1,32 +0,0 @@ -use crate::datatypes::api::file_id::FileId; -use crate::datatypes::api::user_id::UserId; - -/// Return media URLs to images given the user and file IDs. -/// These are non-public and will return 403s unless you're logged in. -pub fn user_and_file_id_to_video_url(user: &UserId, file: &FileId, cache_bust: bool) -> String { - let user_id = &user.0; - let file_id = &file.0; - if cache_bust { - format!("https://assets.grok.com/users/{user_id}/generated/{file_id}/generated_video.mp4?cache=1") - } else { - format!("https://assets.grok.com/users/{user_id}/generated/{file_id}/generated_video.mp4") - } -} - -#[cfg(test)] -mod tests { - use crate::datatypes::api::file_id::FileId; - use crate::datatypes::api::user_id::UserId; - use crate::utils::user_and_file_id_to_video_url::user_and_file_id_to_video_url; - - #[test] - fn test_url() { - let user = UserId(String::from("USER_UUID")); - let file = FileId(String::from("FILE_UUID")); - let url = user_and_file_id_to_video_url(&user, &file, false); - assert_eq!(&url, "https://assets.grok.com/users/USER_UUID/generated/FILE_UUID/generated_video.mp4"); - - let url = user_and_file_id_to_video_url(&user, &file, true); - assert_eq!(&url, "https://assets.grok.com/users/USER_UUID/generated/FILE_UUID/generated_video.mp4?cache=1"); - } -} diff --git a/crates/api_clients/grok_consumer_client/test_data/websocket_messages/create_image_complete_response.json b/crates/api_clients/grok_consumer_client/test_data/websocket_messages/create_image_complete_response.json deleted file mode 100644 index ee9ac6b9a9..0000000000 --- a/crates/api_clients/grok_consumer_client/test_data/websocket_messages/create_image_complete_response.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "type": "image", - "blob": "/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL/wAARCATgA0ADASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwDpBThTRThTJHinimCn0hjhS00U6kMKWkoqQFpRSUtAx1LTaWgB1LTaXNAxaSiigANNpTQaZIlJS0UxCUUuKSmAUtAooGFFFFIYYopaKAEpKWimJjTSU40lBI2ilxRikIQU8UgFKKBjhTxTBTxSGLS0lFMYtNNLSGgBppppxpKAGGkxTqKBCYoFLiigBRThSCnCmAtLSUtMYtFFFABRRRSASig0lJjCkNFJUgJSUppppAFJS0UCEpaKUUigpRRSigYopaQUopgLTqbS00SxRSikopiFzRmkozQAZpKM0maQAabS5pKBiGkNBpKYCUUUlMBaM0lGaBDqKSloAWlpKKAFptLSUxCUhpaQ0ANNJS0lACUlLijFIY2inYpMUgDFGKXFLipYxKdRilFJgUxTxTRTxWpI4U4U0U4UhjhS0gpaQwpaSjNIBaWkooAWlpKKYDqWm0tAC0tJRQAUUUYpkhikpcUUwEooooAKKKKQwpaSloGFLikFLQAlFLSUCEpMU6kpiG4oxTsUYpCsJSgUYpRQMUU4UgpaAFooooGFJS0lIBDTadSUANopaKAExS4oxS0AGKWilFMApaSloAKWiimAUlKaSkMSiikpAIaTNBpKACkoopAFFFFIApaKWgApaQUtIYtKKSlpgLS02lqhC0UlFMQtJmikoAWkopKQBSUUlAAaaaU0hoGJSZpaSmAUUUUALRSUtAC0uaSimAZooooEJSUtJQMSkpaKQCUUtLQA3FLilxS4pANxS4pcUYqRiYpaMUtICpilFLilxWhICnCkFLikMWloFLSGFFFFABRRRTELS02loAdS0gpaBBmlpKWmAtFFFMQUUYooASilooAbRS0UhiUtFFIYtFFFAgopaKYCYpKdikoASilooCwlLS0UAFLRS0gCilooASg0tJQA2ilopANxRilooGJS0UUAFLSUtMAFLQKBQAtFFFAAaaaWkNACGmmnGmmgBKSlNJSGFFFFAgpRSUtAgpaSlpDFFFJRQMWlpKKYDqKSlpiFzRmkopiCkoooAKSikoAKSlpKBiUhpaSkAlFLSUAFFFFMYUtFFABS0YooAKSlpKAENFKaSgAxRiiigApaKWgAxRS0UhhiilxRSASiiikBXxS4p2KMVZIgFGKdiikMSloooAKKKKQBRRRTAKWkpaBCinU0U4UAFKKBRTELS0lKKYgooooAMUlLRQMSkpaKQxKWiikAUtJS0AFFFFMAooooAKKKKACloooAWlpKUUgFopKKBBQaKDQAlJS0lAwNJRRSAKKSgUALS0lLTAWiiigBaSiigApKWkpAIaaadSUANoxS0UhiUUtGKYhKKXFFAhKKWkoAXNGaSigYtLTaWgBaWkpaYC5pKKKYBQaKQ0AFJSmkoASiiigBKSlopAJRRiigAooooAKWiimAUuKKKQxMUUtFADaKXFFMBMUUuKKACgUUtACiikpaBhRRRSGFFFJSAbikxTsUVRA2ilooASilpMUhhSUtFACUUtFACUtFLigApRSUtAhaWkpaBC0tNpaYC0UlLQAUUUtACUUtFAxKKXFGKQCUUtFACUUtFACUUUUwCikzRmgBc0uaZmjNIY/NGaZmlzQA/NGaZmlzQA7NFNzS5oEFFFFACUUUUAFFFFAwpaSloAWiiigQUUUUAFFFFIBKTFLRikA3FGKdijFACYoxS0UxCYpKdSGgBtJSmkNACUUUZoAWikzRTGOpabS0AOopKKYhaSiigYUlLSGgApKWikAlJS0UAJRS4pKACiiigBaKBRQAuKKKKQBRilpKAEopaTFMAooopgFFFFABRRRQMWikpaQxKKWigYlJRmimZgaSlpKBhRRRSAKKKKBhRRilxSASjFLRigAooooAKWkopiFpabRTAdS02loAdRSUtAC0UUUgCiiigAooozQAUlFJmgBc03NBNNJoAXNJmmlqaWoGPLUm6oy1N30ATbqN1Qb6N9IZY3Uu6q4enB6AJ91LmoQ1ODUxEuaWow1OBoAdRSZpaYBRRRQAUtFFAC0UUUAFAoopCA0UUUCCjFFLSASilooASkNLTSaBAaQmgmmk0wAmkJpCaaTQMXNGaZuo3UDH5ozTN1LmgB+admo80uaAJM0ZpmaXNMB+aKbmlzQAuaSiigAooooAKSlopAJRRSGkAUUUUCFFFJRQA6ikpaACiiigAooopgFJS0UAJRS0lMYUYopaAExS0UuKQwoopaBkWaM03NGaCB1FJRQMWikFLQAUtFFAC0UUtIBKKWigBKSlpKAEzRRmkzTAWikzRmmA6lzTc0uaAHUtNBpc0AOozSZozSAdmkzTc0ZpAOzSZpuaTNADs00mkJppagYpamlqaWqNmoAeWphao2eo2egCQvTS9QGSmGSgZZ8yk8yqvmUeZSGXBJThJVIS08SUAXQ9PD1SWSpVemIthqeGqqr1KrUxFgGlBqINTgaYEmaWmZpc0CHUuabmjNAx1GabmjNADs0ZpmaN1IQ/NGaZupc0CHZpc0zNGaQD80Zpm6k3UAOJppNNLU0tTEOLUwtTC9Rl6BkhamlqiL0wvQMm3Ubqg30b6Bk+6l3VBvpQ9ICwGpwaq4enB6AJwaXNQhqcGpgS5pc1GGpQaYiTNLTAaXNAD6KbmloELQaKQ0gCkpTSUhhRRSUCDNGaKKQC0tNpaYDs0ZptLmmIKKTNFAxc0tJRQAtFJS0AFFFFAwpaKKAFpcUlLSGVc0ZpuaXNAh1LTacKAFpaaKcKYhaWkFLQAUtFFABSUpppNAwJppNBNNJoAXNJmmk03dQA/NLmo91G6gCTNLmo91LupgS5pc1Fuo3UgJc0m6o91IWpAS7qTdUW+k30AS7qaWqIvTS9AyUvTS9Ql6YZKBkrPUbPUTSVE0lAErPULSVG0lQtJSAlaSozJUDS1E0tAy0Zab5tVDLTfNoGXhLTxLWeJaeJfegDSWWplkrMWWpklpiNNZKmV6zkkqdJKYi8r1IGqmslSq9MRaDU7dVcPS76AJ91G6od9JvoAm3Ubqg30m+kBY3Um6oPMo30AT76XfVffS76AJ99Luqvvpd9IRNupC1Ql6aXoCxKXpjPURkqNpKYWJWeomkqJpKiaSgCYyUwyVAZKYZKBlnzKPMqp5lL5lIZbD04PVMSU8SUDLgenB6piSniSgC2Hp4eqgenh6BFsPTg1Vg9PD0xFgNTwarhqeGpiJgacDUQanA0ASUU3NGaQhaKTNGaQC0lGaSgAopM0UALS03NLmgBaM0maM0xC5opKKYx1FJRQA6ikpaQxaKKKQC0UlFIYtLTaM0DKmacDTKcKCRwpwpopwpgOFLSCloEKKdSUtMAoopDQAE0wmlJphNACE0wtQzVEzUDHFqaWqMvTC9AE2+jfVffR5lAFnfS76q+ZS+ZQBZ30u+q3mUnmUgLJekL1WMlNMlAFkvTTJVYyU0y0hlkyUwyVWMtMMtAyyZKYZKrGX3pjS0DLDSVC0tQNLUTSUATNLULS1E0lQPLQMmaWomlqBpKiaSgCwZab5vvVUyUzzKALwlpwlqgJacJaANJZanSWstJanSWmI1UlqyktZSS1YSWmI01kqZZKzklqZZKYi+JKd5lUxJTvMpAW/MpPMqr5lHmUAWfMpPMqsZKb5lAFrzKPMqr5lJ5lAy35lL5lU/MpfMpAW/MpfMqn5tL5tAWLXmUhkqr5tIZaAsTmSo2kqAyVG0lMLEzSVC0lRNJUTSUCsTGSmGSq5kphkoGWvMo8yqnmUokpDLgkpwkqmJKeJKQy4JKeJKpCSniSgC8JKeJKpCSpFkpiLoepFeqQkqRZKYi8r1IGqkslSq9Ai2Gp4aqoenh6BFkNS5qAPTg9AEuaM1Huo3UhEmaM1Huo3UDJM0maZuozQIfmjNMzRmgCTNGaZupc0wH5ozTM0uaYx2aWm5pc0AOpabS0gHZopuaWkAtFJRmpGGaM0lGaBlYU4U0U4VRI4U4U0U8UAKKdSClpgLS0lFABSE0E00mgBCaiY05jULNQAjNULPQ7VA70AOZ6iMlRs9QtJSGWDJTfMqqZaaZaALvmUebVLzfejzvekBd82jzapebSeb70AXDLTTLVQy00y0AWzLTDLVQy0wy0DLZlphlqqZaYZaALRlphl96qmWmGSgZZaWomlqAyVG0lAyZpKhaSomkqFpKAJWkqJpKiaSomegCYyU3zKrl6bvoAteZThJVMPTw9AF5ZKnSSs5XqdHpiNJJKsJJWYklWEkpiNNJKmWSs5JKmWSmBoCSniSqIkp4kpCLfme9HmVU8yjzKALRkpvmVWMlIZKYFrzKTzKq+ZR5lIZa8yjzKqeZS+ZQMt+ZR5lVPMo8ykMt+ZTTJVXzKaZKYFkyVG0lQGSmGSgRK0lRNJUTPTC9AEpemF6hL00vQBY30u+q2+l30hlkPTg9VQ9OD0AWxJThJVQPTg9IC4JKkWSqQepBJQIvLJUiyVRWSpVkpiLyyVKslUFkqVZKAL6yVIJKoLJUglpiLokp4kqkJKcJKQFwSUu+qglpfNoEW99G+qvmUeZQBa30b6reZS+ZQOxY30u6q4kpQ9AWLIalBquHp4amBODS5qINTgaYEmaUUwGnA0CH0tNFLSAdRSUtIAooopDEpKWilYCuKcKQCnAVYhwpwpop4oGKKUUgpRQAtJQaQ0CEJpjGnE1ExoAazVA7U92qu7UAMd6rO9Okaqsj0hg8lV2kpsklVnkoAmaWmGX3qs0tRmWkMueb70nm+9UvNo82gC75vvR5tUfNo82mBdMvvTTLVMy0hloAtGWmmWqpkppkoAtGWmmSq3mU0yUAWTJTDJVcvTS9IZOZKjaSoi9Rs9AyVpKiZ6jZ6jLUAPZ6jL00tUZagQ8tSbqjLUm6gCXdTg1QZpwNAFlWqZXqopqVWpgXFerCPVFWqZHpiL6yVMslUVeplegRdElPElUw9PD0wLW+jfVbfS76BE5ekL1Bvo3UwJt9G+oN1G6gZPvo31Buo3UWGTb6N9QbqN1IZPvppeod1IWpDJS9ML1EWppagQ8vTC9MLUwtQA8tSbqjLU3dQBLuo31Duo3UAT76cHqvupQ1AFkPTg9Vg1ODUgLQenh6qB6kD0AW1epFkqmHp4egC6slSCSqQeniSgRdEtPEtURJThLQBfEvvThLVAS0ol96YjQEtKJfeqAm96XzvekBoebS+bWf51OEtAy/5tKJPeqIlpRL70AXxJThJVES1IsnvQMvB6er1SWSplegRcVqkVqqK1TK1MRYBpwNRKaeDQIlFKKaKcKAHClFIKUUAFFFLRYBKKWiiwFcU4UgpRTGOFOFNFOFAC0tJRQAtNNKaaTSAaxqFzUjGoHNAEbtVWRqmkaqkjUgIZXqnI9TStVKV6Bkcj1Wd6WR6qu9ADmkqIyVGz1EXoAnMlJ5lVy9JvoAs+ZR5lVt9G+gCz5lJ5lV99G+gCcvTd9Q7qTdQBNvoL1DupN1AEpeml6jLUhagY8vTC1NLUwtSAcWphakJphNMBSaYTSE00mkIUmjNNopgOBp4NRinCkBKpqVTUANSKaYFhTUqtVZTUqmgC0rVKrVUVqlDUwLQenh6rBqeGpiJ91LuqANTt1AiXdRuqLdS5pgSbqN1R5ozTAk3UbqjzRmgY/dRupmaM0ih26kJpuaTNIBSaYTQTTSaAAmmE0pNMJoAQmkJpCaaTQIdmk3Uwmk3UASbqXdUW6jdSAnDU4NUAalDUAWA1PDVXDU8NQBYDU8PVYNTw1ICwHpweq+6l3UAWPMpfMqtvo30wLXmUvm1T8yjzKYF0S0vm1S8yl8ykBdEtOEvvVHzaUS0AXhLTxLWeJakEtIZfEtSrJWeslSrJSGaKyVOj1nJJViN6BGij1OjVQR6so1MRcVqlU1WRqmU0yScGnio1NSCmA8UtNFOFAhaXFIKWnYAopaMUCK9LRilpFgKcKSloABS0lFAgNMJpTTTQMYxqBzUrVA5pAV5DVSQ1ZkNU5TQMqytVGVqtSmqMppDK8jVVdqlkNVXNIBjNUZahjUZNMBxak3UzNJmgCTdRuqPNGaYiTdRuqPNGaAH7qN1MzSZoAk3UbqjzRmkA/NNJpM0maBik00mkJpCaAAmmE0pppoEJSUtJQAlLRRQAopRSUopAPFPBpgpwoAlBp4NRA08GmBMpqQNUANPBpgThqeGqAGng0CJw1KGqEGng0wJc0uaYDThTELmlzSUtMBc0maKKADNGaSkpFC0lFJQMDTTSmmmkAhphpxphoENNMJpxphoAaTSE0Gmk0CFzRmm5pM0wJM04Gos04GkBMDTwagBp4NAEwanBqiBpQaAJt1G6o80maBkm6kL1HmkJoESbqTfURak3UwJt9G+oN1G+gCx5lL5lVt1LvpDLIkqRZKph6eHpDLqyVMklUFepkepGaKPVmN6zo3qzG1AGlG9Wo2rPjarcbUEsvI1WENU4zVlDVCLSmpBUKGpVNMRKKcKYKeKYhwpaQUtMQoooopgQUCloqCgooooAWiikpgIaYaeaaaQETVXkqw1QPQBUkqlL3q7IKpSikUUZqoy1flqjKKQylJVV6tSCqr0gK7VGakaozTAbSUppKACikpaYgzRmkooELmkzSUUALmjNNzRQMXNGaSikMKSg0UAIaaadSUCG0lOpKAEpaKWgAFKKKUUgFFOFNFOFMBwpwNMFOFADwaeDUYpQaAJQaeDUQNPBpgSg1IDUS1ItAiUU4U1akApiFFLilAp2KYDMUmKkxSEUARmkpxFNoGJSUpppoGFIaM0hNIBDTDTjTTQAw1GakNRmgBhpppxphoASkzRSZpiHZpQaZSg0ASg04GowacDQBKDTs1GDTgaAH5ozTc0maAHE00mkJpCaAAmmk0E00mmIXNJmm5pM0AP3UbqZmjNIZKGpwaoAaeDUjLCtUyNVVTUyGkxl1Gq1G1UENW4zSAvxNVyI1nxGrsRoAvxmrSGqURq3HTJLSGplqBKmWqETCnCmLTxTEPFLSCloELS0gopgRUUUVIwooooAKKKKAGmmmn00igZEwqBxVlhUDigCnIKpyir8gqpKKQzNlFUZRWlKKoyrSAzpBVVxV2UVVkFAyowqIip3FRMKBkRpKcRSUAJSUtFAhKSlpKoApKWkoEFFFFIAooxRQMKMUtFIY2kxTqSgQ2jFLijFADcUuKXFGKADFLijFLigAApaKXFAAKdSUtAC0tJS0AOFPFMFPWmBKtSrUa1MgoESKKmUUxBU6rQIAtO208LTttMRFtphFTlaYy0wISKjNTMKiYUDIzTTTjTDQMDTc0pppoGBNNNKaaTSAQ1GaeaYaAGGmGnmmGgBppKU000CFopKWmA4GnA0wU4UASA0uaYKdQA7NGaSigBc00mikNMQGmmg0hoAQmkzQaTNAgozSUZpDFzTgaZThSGSqamQ1AtTJUsZajNWo6qR1bipDLkVXYqpRVeiFAFyKrkdVIhVuOmhFlKmWoUFTrTJJFp4pgp4pgOpaQUtAhaWkoouBHRRRSAKKKKACiiloASkNOpDQBGwqFxU5FRsKYypIKqSrV5xVWRaQGbKtUZVrTlWqMq0AZsq1TkFaEq1TkWkMpOKhYVYcVCwoGQkU01IRTCKBjaSnUlAhKSnUlMBtFLSYpiExS0YoxQAUUtFIYmKKWikAlJTsUmKAEpMU6igQmKKXFGKADFLijFLimAUtFGKACloopDClopRQAoqRaYKkUUwJVFToKiQVZQUCJUWrCLUca1ZRaCQC07bT1Wn7aYEBWmMtWCtRsKYiqwqFhVlxUDigZA1RmpWqJqBjCaQ0pptAxCaQ0GkpAIaYacaaaQxpphpxppoAaaaaU0lACUopKBTEOFPFMFOFADxS00U6mAtFFJQIKQ0UhpgIaaaU000CA0maCaaTQAZozSUZpDHU4UwU4UgJVqdKgWp0FIZZjq5EKqRirsQpDLcQq9EKqRCrsQpAW4hVuMVWiFW4xTEToKmWolFTKKAHinimCnimIWlpKWgBc0UlFAhtFFLSASilpKYBRRRigApDS0UDGmo2FSmmMKAKziq0gq44qtIKYFCVaozLWlKKoyrQBmSiqcq1oyrVGQUAUZBVdhVyQVWcUhlcimmpGFMIpDGUlONJQA2ilxRTAbRilpMUAJijFLRQAYooooEGKMUUUAJijFLRQAmKXFLijFAhKKdijFMBKKWigAopaSkMMUtFFAwpRSCnCkA4VKgqNamQUwJkFWYxUCCrUYoETxirKLUUYqygoJHKtO205RTsUxERFQuKssKhcUwKriq7irTiqz0xldqhap3qFqBkRpppxpppDGmm04000gENNNKaaaQxppppxpppANNNpTSUAFAooFMBwpwpop4oAUU4U0U4UxBRS0lMBDTTTjTTQIaaaacaaaYDTSUppDSAM0lFFIBRTxTBUi0DJUqeMVCgqzGKQFiIVeiFVIhV6JaQFuIVeiFVIlq9EKQFmMVbQVXjFWkFAEqipRUa1KKYDhThTRS0ALS0lGaAFopM0ZoELiinUmKRIlFLRTGJRS0lAwopcUhoGIRTDUhphpgQuKryCrTCq8gpiKUoqlKK0JBVKUUAZ0q1RlFaUq1RlWgChIKrOKuyLVZxQMqsKjIqdhUZFICIim4qQimkUAMop2KbQAlJS0lACGig0UAFJRRmgApaSgUCFpcUCnAUwExS4pQKXFAhMUYp2KMUAMxRTsUmKBiUlOpKBgKKKKQwFOFJThSAetTIKiWpkFAFiMVbjFVY6tximIsxirSCq8Yq0gpiJFFLigCnUySNhUD1YaoHpiK0lVnqzJVd6CkV3qBqnaoWoKIjTDTzTDSAaaaacaaaQxpphp5ppqQGGmmnGmmgBppKU0lABQKKBQA4U4U0U4UwHCnU0UopiHUlLSUCEpppxpDTAYaaaeaYaAGmkpxptIBKKMUuKQwFSqKYBUqigCVBVmMVAgq3EtAFmJavQrVWJavwrSEWolq7EKrRLV2NaAJ4xVlBUKCrCigB61IKYKeKBjqWkooAWikozQAuaM03NJmgCxRiiikQJiilpKBhSUtJQUFBooNAxDTTTjTTTAjaoHFWGqFxTEU5BVSUVekFVJBTEZ8q1SlWtGVapSrQBnyLVZ1q9ItVXWkMqMKiIqw4qFhQBCRTSKkIppFAEZppp5phoAQ02lNNJoACabmgmm5oEOzSUmaKYDqUU0U4UCHCniminimAoFOxSAU4CgQmKMU7FGKBjMUmKkxSYpFDMUmKfijbSuMjxRin4oxSuMbinCjFKBRcB61MlRLUyUAWI6tx1Vjq3HQItR1aSq0dWUpkslFKaQUpqhDGqB6maoHpiK71WerMlVnoKRA1QtUzVE1IoiIphqQimkUhkZppqQimEUgGEUw1IaYaQhhphp5pppAMNJSmkoAKKKTNMBwpwpgpwNMB4pwpgNKDQIfRTc0uaYgpDRQaAGmmmn000ANNNp5pMUhjcUYp2KUCgYKKmQUxRU6LQBJGtW4lqKNauRJSETwrV+FarRLV6JaBFmJauRiq8S1bjFICZBUyio0FSimA8U4U0U6mAtFJRQMXNJmkzSZpALmkzSZozQMt0UmaXNIzCkNLSUFBSUtJQMKDSUUDA000ppDTEMaomqY1G1MCs4qrIKuOKrSCgRQkWqcq1oyLVOVaBmfItVHWr8i1VkWgCk4qFhVpxUDCmBXYVGRUzCo2FAERqM1K1RNQIYaYacaYaAEJpM0E03NAC5pabSigQ8U4UwVIKYDxTxTBUgoEOApwFIKeBTATFLilxS4pFIbijbT8Uu2pZSI9tJtqbbRtqGykiDbRtqfbTStK47EO2lAqQrSbaLhYRRUyVGBUqimInjq1HVVKsx1RJcjqyhqohqyhpkk4pSaYDSk0xDWNQOalY1C5pgQPVd6neoGouUiFhUTCpmFMIpXKSISKaRUpFNIqbjsREUwipiKYRSuBCRTDUpFMIoEREUw1IaYaYhhptONNNACUUUlAC0uabS0xDwaXNMzS5piH5pc0wGlzQA7NFJmloAKQ0tFIY2jFLijFACYpwFAFSKKQwVasItMRasxrQBLEtXYkqCJKvRJQImiSr0S1BElXYlpATRrVlBUca1YQUAPUVIKaop4FMQtFLRQAZpKKKYxKSlpKQxKSlpKQFvNGabmlzQZjqKbmloGFBopKBhRRSUxhSUtFMQw0xqkNMYUAQOKruKtMKgcUAU5BVOVavyCqkgoGZ8i1VkWr8gqpIKAKTiq7irbiqzimMrMKiap2FQtQIhaomqZqhagRGajNPaozQAhptKabSAWnCm04UxDhUi0wVItAD1qRRTFFSAUxDxThSCnCmAoFOApAKeBUspCAU4LSgU8CoZaGhaXbUgFOC1m2aJEOykK1PtpClTcdiuVpu2pytMK00xNEWKetLigCrRLJVqwhqstToapEMtoasKaqIanVqoRZDUpaoQ1LuoEKxqJzSlqjY0XGiNqiapGNRmlcpIjIppFSEUmKlstIiIppFTYppFK4WICKYwqdhUbCi4FdhUbVMwqJhVEsiNMNSNUbUyRhpppxpppgNpKcaSgQlFFJTAXNKDTaWgQ4GlBpmaXNAEgNLTAacDQA6ikzS0hhSgUClFACgVIopFFSoKQx6LVqNaijWrcS0ATRJV6JKgiWrsS0CJ4lq5GtQxLVuNaQEiLVhRTEFTKKYhQKdigCnYoATFJTsUlACUlOpKBjaSnYoxSGMop2KTFAEuaXNNBpRQZjqWkFKKBhRSijFACUUUUxiUUYpcUxDTTSKfTSKAIWFQOKssKhcUDKkgqrIKuuKqyCgZQkFVJBV6QVUkFAFKQVWcVckFVXFAyq4qB6suKrvTEQNULVM1QtQBE1RmntTDQIYaSlNFIAFPApAKeBTAcoqRRTVFSKKAHKKkApqipAKYhQKcKAKcBQIBTxTRTxSZSHAVIopgp61mzRDwKeBTRUgrNmiExQVp+KCKgohZajIqcioyKaJZCRSYp5FNrREMUVKpqIU9TVohllDUytVVTUoaqEWA1LuqENRuoESFqYxppamk1LKQE02gmipbLQYoxRS1DZaG4ppFSU00XAhYVEwqdqiamiWQNULVM1RNVolkTVEalaozVEjDTTTzTTTEMpMU+kpgNppp9NoEJRRSUALS5ptFADwacDUYNOBpDHg04UwGlBoAkFOFMFSLQA9RU6ColqdBQMnjFXIlqvGKuRCkBaiWrsS1WiFXYhQIsRLVtBUEYqygoESqKlApiipAKBDgKWgUtACUYpcUUDG4oxTsUmKBjcUmKfijFAxmKMU7FGKLCGilFIKUVJA4U6kFLTAWiiloGJRS0UwExSYp1JimAlNNPppoAjYVC4qdhUTigZVcVVkFXHFVpBQMoyCqkgq7IKqSCgZSkFVZKuSCqkgoAqvVZ6svVd6AK71C1TvULUCIWqM1K1MIoER4pcUuKUCmAAU9RSAVIooAcoqRRSKtSKKAFAp4FAFPApiAClxSgUuKAEpwpKUUmNDhUgqMU4GoZaJlNSCoQaeDWbRaZKDS0wGlzUWKuIajank0xjTSFcjamGnk0w1aJYU4GmZpQa0RDJlNSBqgBp4NMRNuo3VFupc0ASFqbupmaTNQxokzQDTM0oNQzREmaXNMzS5qSkOppoJppNADGqJqkY1ExqkSyJqiapWqJq0RDImphqQ0w1RJGaQ0402gQ2kxTqMUwG4pMU7FJigBhFJTyKaRQA2ig0lIBaUGm0uaBjwacDUYNOBoAlFSLUS1KtAyZKsx1XSrMdIC1EKuRCqkVXYhQBciFXYhVOKrsVAi3HVlKrR1ZSgRMtSCo1qQUCHClFIKWgBaKKKBhRRS0DExRiloxTATFGKXFGKqwiEU4UgpRWQhwpwpopwpgLS0lLQAUUtFMBKTFLRTASkNOppoAjaomFTNUTUDK7iq0gq09VpKBlKQVUkFXZBVOWkMpSVUkq5LVSSgZUeq71Zeq70wKzVC1WGFQsKBEJFNIqQikxQIjxShafinBaYDQtSKtKq1Iq0CBVqQLSqtPC0AAFOApwFKBQIbilxT8UmKAGYop2KTFAAKcKZSg1LKRIDTwahzTg1Q0UmTBqXdUQajdU2KuSFqYTTS1NLU7BcUmmE0E03NUiWLThTKcKpEjwacDTBThQA7NLmm0UALmkzSGkzSY0PzSg1HmlzUNFolBpc1HmjdU2KuSbqaTTd1NJp2C4rGomNOJqMmqSJY1qjanmmGqRDIzTDUhppqhEZFNxUhFNIoENxSYp2KMUANpMU/FJigBhFMNSEU0igCM02nkU00ANooopDHCnA00U4UwJFqZahWplpFE6VZjqslWY6ALcVXYqpR1dipBYuxVdiqlFVyOgLFuM1ZQ1VjqyhoJJ1qQVEpqQUxDxTqYKcKBDqKSloGApwpop1MYUYpaKaAMUUtFUhEAFKKXFLWIgFOFJSimAopaSlzTAKKM0UwCkpaSgApppaQmgBjVE1SMaiY0DIXqtJVhzVaQ0ikVZaqS1akNVJKBlSSqklW5KqSUDKslVnqy9V3FAiBhURFTMKYRTEQkUm2pdtG2gCMLTwtPC08JQAxVqVVpypUipQFhqrUgWlC08LQIaFp22nhaXbTAjxRipNtJigRERTSKmIphFAEZFNp5FNNIBM0ZpDSZpWGP3UbqjzSZpWHck3UmajzRmiwXH5ozTM0op2AeKcKYKkAoEKKeBSAU8CgBMUU7FIRQAw0008imGgYlGaSkzSsO4/NG6o80bqVirkm6mlqbupM0WC4pNITSZpKdiQNMNONJTEMNNIp+KQigRGRSYqQikxQBHijFPxRigBmKTFPxSYpARkU0ipSKYRQBERTSKlIphFMRGRSU8ikxQMSnCkxThQMetTJUK1MtIpE6VZjqslWY6Q7FuOrkVU46tx0XHYuxVcjNUojVyM0CLcZqyhqohqyhoJZYU1IDUKmpVNMkkFOFMFOFMQ6lptLQA6lFNFOoGOopKWqAWlpBS0wIsUtLiisyBKWiimMWikopgLRSUUALSZpM0maYCk00mgmmE0DEY1ExpzGoXakMjc1XkNSO1VpGqRohkNVJDU8jVUkagogkNVZDU8hqs5oAgeoGqZjURpgQkU0ipSKTbQIi204LUgWnBKVx2IwlSBKkCVIEouFiIJUgWpAlOC0XCwwLTgtPC07FAhgFLin4oxTJGYpCKkxQRTAhIphFTEUwimIhIqMipiKjYUwIjTDUjVGaQDSaTNBppoGLmjNNpRSAcDTxTBUiigByipVFNUVKooAUCnhaVVqQLQBHtpCKm200igCBhUbCp2FRMKAIjTTTjTDRYYhNNzQTTc0WGOzRmmZozRYB+aKbmlpALRRRQAmKTFPpMUCGYpMU/FGKQDMUmKfijFAxmKTFSYoxSAiIppFTFaQrRcRXK0wirBWmFaYWICKaRUxWmEUAMxSgU7FGKYxVqZajWpFpDROlWEqulWEqSi3HVuOqcdW46Qy5HVuM1TjNWozQJlyM1YQ1VjNWUNUSywtSrUK1KtMgkFPFMFOFMB1LSUUAOp1Mp1ADqWm0tFxjhS00UoouAlBoooMxKKKKBhRSUUwFpKKSmAE00mgmmk0DAmoyaUmo2agBrNULtTnaoHakUhkjVVkapHaq0jVJRHI1VJGqSRqrSNQMjdqrOakdqgY0ANY1GacTTaBCYpQtKBUirRcY0LUgSnKtTKlTcdiMJTwlSqlPCUrjsRBaXbUu2jbRcRFtpcU8ikqkSxuKKWkqkSFJS0lMQ00winmmGmIjaomqVqjamBC1RmpmFRkUDIjTTUhFMIoAbSilxSgUgFUVIopqipVFIB6ip1FMQVOi0AKoqQLQq1IFpiGbaaRU22mlaAKzCoWFWmFQOKBlZhUTVOwqFqAIzTCac1MNABmjNJRmgY7NOBpmaUGkMeKWmg0opAOooopAFGKWikAmKMU7FLigY3FG2pAKXbUgRbaQrU+2k20XCxWK0wrVopUbLTuFiqVphWrLLUbLTuKxARRinkU3FMBRT1pgp60DJkqxGarrU6GpKLcdWozVOM1ajNIZdjNW4zVKM1bjNAmW4zVlDVWM1ZQ1RLLKGpVqFDUq0ySUU8UwU8UCFFLSUtAC0tJS0DFpaQUooGKKdTRSigAopKKZmFJRRQAUUUUDEpDS000wENMJpxqMmmA1jUTGnMahY0hjHaq7tT3aq7tSKRHI1VZGqWRqqyNSKI5Gqq7VLI1VnagCN2qFjTmNRk0AGaUU2nCgQ9RUqrTVFTotSykOVKmVKEWp1WpbGhoSnbakC07bU3KIStNIqYio2FUiWREUw1I1RmrRLGmkpTTapEBmjNJmkqhAaaaU000wGmozUhphoAiIphFSEU0igCIim4qUik20hke2nBadtpwWkAirUqrQq1Kq0AORanRaYi1Oi0xDlWnhaVVqQCgRHtprCpiKYwpgVnFQOKtOKruKQFVxUDVZcVA4oGV2qM1KwqM0ANozQaSkMXNOBplLQMeDTgaYDThUgPpaaKUUgHUtNFOFAxRTgKQU4UgHAU4CkAqQCpYxNtG2pAtO20hlcrTGWrRWo2Wi4WKjLULLVtlqF1q0xFVhTCKmYVERTENp4plOFMCZTU6Gqymp0NIZajNWozVOM1ajNIZdjNW4zVKM1ajNAi7GasoaqRmrMZpklpDUy1XQ1OppiJlp4qNTTxQIeKWkFLQMWgUUUgFFOFNpaAHClpBS0AJSUZpM1ZItFJmkzSAdmkpM0maAFNNJoJppNMBCajY05jULGgBrmoHanu1QO1BSI3aq8jVI7VWkakUiJ2qs5qZzVZzSGQuaruamc1Xc0wImNRmntTKBAKkWmCpEpATIKsxioIxVqMVLKRMi1Oq1GgqdRWbKQoFGKeBQRSGRMKiapmqJqpCZC1RGpmqJhWiIZGabTyKaapEjaSnUlUIaaQ04imkUwGGmmpCKaRQBGRSYqTFG2kBFto21LtpQtICILTglShKcEpARqtSqtOCVKqUwEVanVaRVqZVpiBVqQLShadigQwimMKmIpjLQBWcVXcVcdarutAyk4qu4q461XdaQFRhUTCrLLULLRcZCabUhFNIpANpaKKBjhThTRSikA8UopopwpAOFKKQUopAPFPFRipFoGSLUiimLUq1LKQ8CnYoUU8CpGhhWo2WpyKjYUhlZ1qu4q24qu4q0Syo4qJqncVC1WiSM0Cg0CmIetToarrUyUAWkNWYzVNDVqM0DLsZq1GapRmrUZoAvRmrMZqlGasxmgRdQ1MhqqhqwhoJLCmpAahU1KDQBIKUU0U4UALS0lLQMWlpKUUAOFLSCnCgRFmjNNzSZqgHZpM00mmlqQD80maZupC1Ah5amFqaWphagBzNULNQzVEzUDEdqru1OdqgZqBjHaoHNPdqgc0DInNQOalc1A9BRC5qBqnaoGoERNTKkamYpiAVKlRgVKgpMCxHVqMVVSrUdZspFlKnWoEqZahlokFBoFIakYxqiYVMaiYVSEyFhUZFTEUwitESyEimkVMVpNtUmSQ4pNtTbaTZVXEQ4pMVMVppWi4EWKTbUu2k20XCxFto21NtpQlICILTglShKcEoAiCU8JUoSnhKQEQSpFSpAlSKlMQxUqRVpwSpAtMQ0LTttPC07bTERbaaVqcrTGWgCq61A61cZagdaQyi61XdavOtV3SpGUnWoWWrjrUDLRcdiqy0wirDLUZWlcdiHFGKkK0m2i4WGgU4ClxSgUgAClpQKXFACClFLilApAAqRaaBTxQBItSrUa1KtSykSrTxTFp4qWUhajYVJTGoGQOKruKsPVd6pEsrOKgarD1A1aIhkRpKU0lUIcKlWohUi0AWENWENVkqdDSGW4zVqNqpIasoaAL0bVZjaqUbVZjagReQ1OhqojVYQ0CLampVNV0NTKaBEwpwpgNPFADqWkFOpgKKUUgpwoELS0lLQBV3Uhaoi9NL0FEpamlqiL0wvQIlLUheoS9MMlMCYvTC9RGSozJQBKz1Ez1G0lRM9IBzvULNSM9RM1AwZqhZqVmqJjSGIxqJqeTUbUwImqJqmYVGwpgQEU3FSEU00CEFSLUY61ItJgTpVlDVVKsIazZaLSGp1NVkNTKahlomBpaYDS5qRgaYRT6SmgIiKbtqbFJtq0yWiLbSbKn20bKdxEGyk2VY2UmyquIrFKaUq0UppSi4FbZSbasFKTZTuBDspwSpQlOCUARBKeEqYJUgjoEQhKkEdTLHTxHTEQCOnhKnEdOCUxEISnBKmCUoWmIjC0bal20baAIttMK1ORTStICsy1C61bZaiZaTGUnSq7pV9kqB0qRlB0qBkq+6VA6UiiiyVGUq4yVEyUrjsVStG2pylJspXHYh20u2pdtLtouKxFtpdtS7KNtFwsRYpcVJto20XCw0CnAUuKcBRcLCqKlUUwCpBSGPFSCmCnVJSFpjU40xjQBC9V3qw9V3qkSyu9QNU71C1aIhkRpKcetNqhCipFpgp60ASpU6GoFqZaBlhDVlDVRDVhDSAuRtVlGqkhqyhoEXo2qyhqlGasxmgTLiGp1NVkNTqaBE61IKjWpBQIeKcKaKcKYhRThSUtAC0tAoFAGQXppeoDJTDJSNLE5eoy9QmSozJTAnMlMMlQGSmGSmInMlMMlQGSmGSgCZpKjL1EXphekBIXphaoy9NLUDHFqaTTc0ZoADTTS0hoERmo2FTEUwimBARTCKmIphFAiOnrTcUopMaJlNTIarqamQ1DLRaQ1MpqqpqZTWbLRYBp2aiBp4NSUPpaaKcKAFxS4pRTgKdxWGhadtpwFPC07isRbaTbU+2k207isQFKaUqwVpCtNMVitso2VPspQtVcCAJTwlShKkCUxESpUix1KqVKqUxEIjqQR1MqU8JTEQBKXZVjZRspkkGyjbU22kK0wIttJipSKbigCMimkVIRSYpAQlajZasEUxlqRoqstQulXGWoWWpZSKTpUDpV9kqBkpMpFFkqJkq6yVEyVNyioUpNlWSlJsqbjsVtlLsqfZRsouFiDZRtqxspNlFwsQbaNtTbaTbRcViLbSgU/bRtp3CwgFOApQKUUrhYUU6kpc0ihDTGNONRtTQiNzVd6mc1A9UiWQvUDVM9QtVoljDSUppKskUU8UwU8UCJFqZahWpVoGTrUyGoFqVTQMtIasoapoasoaQi7GatRmqUZq1GaBF2M1YQ1UjNWUNAiytSrUKVKtMRIKeKYKeKBDhS0gpRTAWloFLQByRkphlqsZaaZKk2LBkqNpKrmSozJTEWDJTDJVcyU0yUxFgyU0yVXMlJvoAnL00vUW6jdSAk3UmajzS5oAfmlpgNOFIB1FApaYhpFMIqTFIRTEQMKYRUzCo2FAERpKcRSUmNCg1KpqGng1DLRYU1MrVWU1KpqGWiypqQGoFNSqahlkwp4qJTUimkBIKkFRg1ItFwHgU8Cminii4rBilxSilouKwzbSbakxRirTER7aNlS7acFqkIjCVIqU8LUipVoljFSpVSnqlSKlUJjAlPCVIFpdtMkj20m2pcUhFAiEimkVKajNAEZFNIqQ0w0AMIpMU6kpANIppFPNIRSGiErUbLVgimEUmNFVlqFkq4y1Ey1DLRTZKjKVbZaiK1DLRVKUhSrJWmlallFfZSbKn20baVwINtIVqfbTStMCErTSKmK00igLEJFJipSKbimFhuKXFLRQAmKKKTNIBDUbGnk1ExpoTI3NQOalc1A5q0QyJzULVIxqJjVohjTSUUVRI4U8UwU9aYEi1ItRipFoGSqalU1CtSrQBYQ1YQ1VQ1YQ0gLkZq1GapRmrcZoEXYzVpDVKM1ajNAi0hqZagQ1MtMRMKeKjFPFAh4pwpopwpgOFLigUooA85MlMMlQGSmGSpNycyVGZKhL00vTETF6TfUG+jdTETb6N1Q7qUNSAm3UuaiBpwNICQGnA1GKeKBjxThTBTxQIeKcKaKcKYgxSEU6kIpiIyKjYVMRUbCgRARTcVKwphFJjQynCkxS1LKRIpqRTUIqRTWbNEWFNSqarqalU1DLROpqVTUCmpVNSMmU1KtQKalU0gJlNPFRA1IDSESCnCmCnCmhDqXFApwFWhABTwtAFSKK0RLBVqVVoVakArREMFWpAtAFPAqiWIBS4paQmmIaaYacTUZNIQhqNjSsajJoGITTSaCaaTSAXNJSZpM0ALRSZooGBppFOpDSGiIimMtTEUwioZSK5Wo2WrJWoytQzRFcrTStTlaaRWbKIStNIqUimkUhkZFMIqU0w0wIyKYRUhFMNMCM0008000ANpKU00mgBc00mgmmE0CBjUTGnE1ExqkSxjGoHNSMahY1SIZGxqImnsaiJrREMSgUUVQh4p61GKeKAJVqRajWpBQBItSLUQqQGgZMpqdDVZTU6GkBcjNWozVKM1ajNAi9GatRmqUZq1GaALiGp1NVUNWFNAidakFQqalFMRIKeKjFPFMQ8U4U0U4UAeSl6aXqItSbqk3JC1NLVGWpM0xEm6lzUeaUGgRIDTgajFPFICQGnioxUgpDHinimCnigdh4pwpgp4oAeKcKYKeKZI4UlApaYmNIphFSEU0imSQsKjIqdhTCKQyEijFPIpMVLKQgp4puKeKhloetSqaiWpVrNlolWpVqJalWpKJVNSrUS1ItICUVIKiFSLSAkFPFMFPFNCHingUwVKoq0Sx6ipFFNUVIorVEMeoqRRTVFSCtEQxRTqSkzVkik0xjQTUbNQIGao2akZqiZ6QCs1MLUxmphepGPLU3dUZak3UASbqM1Fuo3UDJc0uaiDU4GgCTNFNBpc0gFppFOpDUspEZFMIqUimkVmy0QkUwipSKYRUMtERFRmpWqM1JQw0w081GaYxhphp5qM0ANNMNONMNACE0wmnE1GTQICaYTQTTCaYhCaiY05mqFjVIhiOahY05jUTGrRDGsajJpSaaatEsKBSUoqiR4p4pgp4oGSLUgqNakFADxTxTBTxSAlWp0qutTpQMsxmrUZqpHVqOgRcjNWozVOOrUdAFtDVhDVZKnSmIsLUq1CtSrTESinioxTxTAkFOFMFOFAjxvNJmiiszcKKKXFAgFKKAKcBQAop4poFPAoActSCmAVIKRQ4U8U0CngUhjhThTRTqYhwpwpgpRVIlklLTAadTJYtIRS0uKZJGRTCKmIppFICErTdtTFabtqWUiPFKBT9tKFqGWgAqRRSAVIoqGWhVFSrTVWpVWpHccoqVRTVFSKKVh3HAVIBTQKeBRYVxwqQCmgU8CmkK49RUi0xRUiirSJbJFFSqKjUVKtaJENjxTxTRS5rREsXNITSE0xjVkgzVEzUM1QM9ACs9Qs9NZ6hZ6lgPZ6YXqNnqMvSGTF6bvqEvSb6AJ91LuqvvpQ9AFgNTw1Vg9PDUDLAang1AGp4akBNmlpgNOzUsaENNNPpprNlojNRNUrVG1Qy0RNUbVI1RGpLQw1Gae1MNAxhphpxphoAYaYaeaY1ADCajJp5qNqBDWNRMae1RsapEsYxqJjTmNRtVohjGNRsac1MNWiGMNNpxpKtEiU4UmKcBTEKKeKaBUiikMctSCmCpBQA4VIKYKkUUhj1qdKiUVOgoAmSrMdQIKsoKBFiOrUdVoxVmOgRZSp0qBBU6UxE61KtRLUq0wJFqQVGKeKYDxThTRSigDx3FAFSbaXbWRuMxS7aeFpdtAhgFKBT9tKFoAaBTwKULTgKQABUgFIBTwKBiinCkApwFIYtKKKKYBS0lFUiWPBpwNRg04GqIY8U6mA08UyRcUmKcKXFAiMrSbalxRtqWUiLbShal20oWpaLTIwtSKtOC1Iq1DRVxqrUqrSqtSKtKw7gq1Iq0qrUgWlYLiBaeBShacBTsK4gFPApQKcBTsTcVRUiikAqRRVJCuOUVIKaop4FWkTcUUtFIatCEJqJmpzGoXNUIY7VA7U52qs7UAI71Az0jvUDvUgPZ6YXqJnqMvSGTF6TfVcyUnmUAWt9KHqp5lOD0AXA9PV6pq9Sq9AFxWqVWqorVMrUhloGng1ApqQGpYyTNNNGaQ1LKQ1qiapDUTVDLTI2qJqkao2qbFpkZphp5phpFDDTDTyKaRSAjNMNSkUwigCI1E1TEVGwpkkLVE1TMKiYVSJZC1RmpmFRkVaJZCRTCKlIppWrRDIiKTFSbaNtWSMxSgU7FLigBAKeKQCngUDFFSKKaBT1FIB6ipVFMUVKopAPUVOi0xBU6LQBIi1ZQVGi1YRaBEiCrKCokWrCCgRKgqdaiQVMopiJVqVaiWpVpiJBTxTBThTGPFOpgpwoA8o2UuypglKErI6CEJTtlShKdsoEQbKXbU2yjZSAi20oWpNtLtoAYBTwKULTgKQxAKXFOApcUhjcUYp2KTFFxDaSnEUhqkxMKUGm0oqkyGSCng1GKepqkSyQU4U0U8VRI4Cl20oFOApDGhacFp4WnhalopMjC1IFpwWpFWpaHcaq1Iq04LUirSsO40LUgWnBaeFpWFcaFpwFOC04CnYVxgWnAU4CnAU7CuIBUgFIBTwKpIVxQKeKQCnVSEFNNOpjVQEbmoHNSuaryGmBBI1VZGqaQ1UkagCN2qu70sjVWdqQCs9Rl6Yz1EXpDJS9J5lQF6bvpAWd9OD1V304PQBcV6lV6pq9TI1AF5GqwjVRRqso1IC4pqUGqyGp1NJjJM0E0goNSxoa1RtTzUbVLLTI2qM1I1RkVLLTIzTTUhFNIqSkyM00ipCKQikMiIphFTEUwigCFhUTCrBWmFaCSswqNlqyy1Ey1aJZWK0wrVkrTCtWiWVitNK1YKU0rVollcrSbanKUm2mIh20uKk20mKYDMU4ClxRQMUU9aaKetICRanQVEtTpSAlQVZRahQVZjFAiVFqyi1FGKsotAh6LVhBUaip1FAh6ipVFMUVIBTEPWpBTBTxTAeKeKYKcKAHinUwUuaBnnOynbKseXS+XWZsV9lLsqx5dGygCvspNlWdlJsoAr7aNtT7KTZSAh207bUm2l21IyPbRipNtG2kMjxSEVJikIoAiIppqQimkU0JjKKXFJVIhjhThTBTxVolkq1ItRLUq1SJJVqQCo1qVaYDwKeFpFFSqKAALT1WlValValodxAtPC0oWpAtTYLiBacFpwFOApWFcaFpcU/FGKBXG4pQKXFKBTEAFPFIBThVIBwpaBS00AhqNqkNRtVAQOaqyGrMlVJDTArSmqUrValNUpTQMryNVV2qaQ1VdqQDGaoWah2qJmpDHF6TfURak3Uhkwanq1Vw1PU0CLStVhGqmhqwhoAuxmrUZqlGatx0AW0NTqarx1OtICUUUDpS1IxhpjVIRTCKllIiNMIqUimEVLLTIyKbipcUmKllJkRFJipdtJtqR3ISKaVqcrTStAEBWmFasFaYVpiKxWoytWStMK1SEVitMK1aK1GVq0SyuVphWrBWmlapCK5WmlanK0wiqEQkU0ipSKYRQBHRS0lAxRTxTBTlNICdKnSq6GrCUCLMdW4xVWOrcdAixGKtIKrx1ZSgRMoqZRUaVMtADgKkFNFPFMQ4U4U0U4UxDhThTBThQMfmlzTM0uaQHH+XS7KseXS7Kk0uV9lGyrGyjZQMrFKQpVnZTdlICtso2VYKUmykMr7aNtT7aaVpMaIdtJtqbbSFakZCRTSKmIphFICEimEVMRUZFNCIyKaRUhFNIqkSxtOFJSirRLJFqVaiWpVq0STLUy1CtTrVCJVFTKKiSp1FAh6ipAKRRUiikAoWpAKQCngVIXACnYoxS0hCYpaWikAlAopRTAUU4U0U4UwHClzTRS1SADUT1IaiamIgkqpLVqSqktMCnKaoymrstUpaQynIaqyGrUlVJKQyu5qJjUr1C1AxhNJmlNNxSGOBqRajFSKKBEyVZjqulWYxQBajq1HVWMVbjFAFqOp1qGMVOopASCloAp2KljGEU0ipCKaRUsaIyKaRUhFJipZRFijbUm2jbUspEe2k21LtpNtIoiK00ipitNK0BcgK0wrU5WmkU0K5XK0wrU5FRkVaJISKYRUxFMIqkIhIphFSmmGmIhIphFStUTUwI2qI1K1RtQBGaSlNMNAxaetRinrQBOlWEqstWI6Qi3HVuOqcdW46BFyOrKVVjNWUNAFlKmWoENTKaYiUU8VGDTxTEPFKKaKdTAcKWminUALRmkpaQzD2Umyp9tG2ixVyDZRsqbbSbaQEO2mlan20hWkMgK03bU5WmlaTGQlaaVqYrTSKljRCVppFTEUwikUQkUwipSKYRSAhIphFSsKYRTEREU0ipCKaRVIljMUAU7FKBVITACpVpoFSKKpEkqVOgqFBVhBVCJUFToKiQVOopkkiipFFMUVKKBDgKeBTRTxSEFLRRSAKKKSkAUUUZpDFpQabmlzTAeDRmm5ozTAUmo2pxNRsaoCF6qy1aeqslAFKWqcoq9LVOQUhlGQVVkFXZFqs60DKTiomFWmWoWWkMgIpMVKVpNtIBgFSKKULUirTEOQVZjFRItWY1oAnjFW4xVeMVajFAE6CrCioUFTqKQx4p1IKdUgJimkU+kxUjGYpMU/FGKkYzFGKfijFIoZikxUmKQilYdyMimEVKRTDTsFyIimEVIajaqSFcjao2qRqiY1SRNxjVGTTmNRsadhDTUZNKxphNMBrVG1OJqNjQAxqjNPamGgYw000402gYCnLSAU8CkBItTpUC1OlIC1HVqOqkdWozQIuRmrKGqkZqyhpiLSGplNV0NTKaaETg08GolNSA1QDxThTAacKBD6WminCgBaBRSikBn7aTbUmKTFVYdyPbSEVIRSEVIERFNIqUimkUhkeKaRUhFNNIojIphFSkUwipGREUwipSKYRSsO5CRTGFSkVGRRYLkRFMIqUimEU7CIiKbipCKTFMBmKUCnYpwWmIRRUiihVqVVqhCqKnQUxVqZRVEskUVMoqNRUyimSyRakFMWnigkeKUU0U6gBaWkzRSEFFFJSGFJRSUhi5pc02jNAx2aXNMzRmgBxNRsaUmmE0xEbmq8lTsagei4yrIKqyCrjiqzii4ylItV3WrrrUDrSApMtRMlW2SoylAyqUpNlWClJsoAhCVIqU8JUipQAiLVhFpqpVhFpiHxrVlBUaLVhBSGSIKnWo1FSrSAcKdSClpDCkpaKkBKKXFFIYmKMUtFIYlNNOpposA01G1PNRsadguMaomNPY1ExqkhXGMahY052qFmqrCuIxqJmoZqiZqYhWaoy1IWqMtQA4mmE0hNNzSADTTSk0lAxppMU7FLikUNAp4FAWnhaQCqKmQUxRUqikBMlWUqulWEoAspVlDVVDVhDVIRZQ1OpquhqZTVIROpqQGoVNSg0xEgNOFMFOBoAeKcKYDTgaBDhThTM07NICrikxT6StLE3GEU0ipKaRUsq5GRSEU8ikIqRkZFNIqQimkUh3IyKaRUhFNIpWHciIqMipitMK0WHcgIphFTFaYVosFyAimkVKRTSKLAREUmKkIpMUAM204LTgtPC0wEVakVaFFSBaYhVWplFNUVKBTJHKKkFNAp4pkseKeKYKUGmIkFLmmA0uaBD80U3NLSAWkoooASiikpDCkzQaSkMXNJmkzSZoACaaTQTTSaB2GtUTVIajalcdiF6gcVO1RMKLhYrOtQstWmFRMtIZUZKYUq0VphSmBVKUbKslKTZQIgCU5UqYJTwlMCNUqdFoVKmVaABFqdRTVWplFADlFSCmgU8UgFFLSUtIYUUUlIBaKSikMWkozSZpAFNJoJphNMBGNRsaVmqFmqkgEZqgdqczVA7UxCO1QM1KzVCzUxCM1RM1KzVEzUABamFqQmmk0gFJozTc0ZoGOooFKKQwxTgKAKeBU3GIBTwKAKeBSuMFFSqKaBTxQMkUVOtQrUy0CJ0qdDVdKnU1SEWUNTqarIanU1SJJ1NSKahU1KDVCJRTgajBpwNAEgNKDTM0uaYh+aXNR5pc0gG0UtFaszTG4pCKfikxUsq5HikIqQikxUjuREUhFS4ppFIdyIimkVMRTStKwXIStMK1OVppWgdyuRUZWrJWomWiwXK5WmEVYIqMikO5CRRinkUmKChAKcBQBTwKABRUqimgVIKBDlFSAUwU8UyWPFOFNFLmmIeKWmZpwNBI4GnA1HmnA0xD80tNBpaAHZpKKKACkpaSkMaaQ0ppDQMSmmnGmmkMQ000ppppDGmozTzTTSGRMKYwqU0wilcCEioytTkUwigZAVppSrBWm7aAINlGyp9tG2mIhCU4JUu2nBaYEYWpFWnBaeFoECrUgFAFOApAKBThSAU6gAooopDCkopKAFpM0U3NIYpNNJoJphNACk1GzUM1RM1MQM1Qs1DNULNVIBHaoHaldqhZqYhGaoWalZqjY0AIxqImnE0w0gGk03NOpKVxiU4UlKKVxiinimingUrjSHAU8CkFPFSUKBTgKQU4UhjgKcKaKdTAkWpFNQg1IppoTLCmp1NVVNTqapElpDUymqyGpkNUIsqalU1ApqVTTESg04GowadmmIkzRmmZozQA/NGaZmk3UAWMUuKXFLitmYjcUYp2KXFSxkeKQipMUYqRkW2k21LikxSHci20hWpcUmKAIStNK1ORTCKQFdlqJhVlhULCgZAwqNhUzVC1IpEZpppzGmE0ikOFOBqPNOBpFEoqQGoQaeDQImFPBqEGng07isS5pQajBpc0XJsPzTgaYDS0xDwacKYDThTEOFOpopRTJHUtNpaYC0lFFIY00hp1NNIYhppp9NNSykMNNNPNNNIYw00inkU0ipGRkU0ipCKQigCIimkVKRTcUAR7aTbUmKMUwI9tLtp+2lxQAwLShafilAoAaFp4FKBSgUCAClApaWmAUUUUgCiikoAKSikoAKaTQaaTQMQmmE0rGo2NADWaomalZqhdqYDXaoWaldqgZqYgZqhZqGaoyaYATTCaCabQAhppFPpMVLGMxSYqTFG2pHYjxTgKdtpcUrjsIBTxSAU4CpuMcKcKaKcKBjhTs0zNLmgY/NGaZmjdTESg08NUAanhqaEyyrVOjVTVqmVqokuI1WEaqSNVhGpiLamplNVUap1NMRODTs1EDTgaYEmaTNNzRmgBc0maTNNzTEaeKXFLilArYxExS4p2KMVLAbikxUmKTFIYzFJipMUmKQyPFIRUmKQikBERUbCpiKjagCFqgep2qBzSGQOahY1I5qB2pFIaxqMtSM1RlqRSJN1KGqDfSh6RZZDU8NVUPTw9IC2Gp4aqoepA1AFgNTgagDU8NQSTA08GogaeDVCZIKcKYKeKaJHCnCmilqiR1FJmlpiFpM0UZpDCkoopDEpDTqSpZSGGkIp1IakZGRSU8imkUhjCKaRTzSGgBhFJin4pMUAMxRinYoxQA3FLinYoxQAmKXFLRQAUtFFMApaSigQtFJRQAUlFJmgApDS000AIaYTTjTCaBjWNRMaexqFjQBG5qBzUrmq7mmBG5qFjT2NQsaYDWNRmnGmGgAoxRTgKAG4pdtPApQtSxjNtG2pNtLtqWMi20YqTbSYqShmKdS4opDEpc0lJmgB2aTNNJpC1MB+6k3VGWpN1MkmDU4NVfdTg1UhFtWqZWqkrVMjUxF5GqwjVRRqso1MRdRqnU1URqnQ0AWVNPBqFTUgNAD80UgopiCkpTSUwNjFLijFLWxgFLiilqQDFJTqSkMTFIRS0UAMpDTjTTSGMaoWqVqhc0AROarSGp3NVZDQMhkNVnapZGqrI1IpDWaoWekZqiZqRSJC9G+oN9JvqRotB6kD1TD08PSKLivUqvVJXqVXpAXFapVaqitUytQIsqakU1XVqmU0xE4NPFRKaeDVJkskFOpgNKDVXJY6jNJmjNMQuaXNNpc0ALRSUUhhRRRUsYlIaWkNJjGmmkU8000hjTTSKeabSGNxSYp1FADcUYp2KTFACUYpaKADFFFJQAuaSikpgLmikzRmgQuaTNJmjNAC0lGaSgApDRSGgBDTDTjTGoAY1QtUrVC1AyFzUD1O9V3pgQNUTVM1REUARmm4p5FJigYgFOAoAp4FAABTgKUCngUmMbtoxT8UYqRkZFJipCKaRUjGEU0080w0hjTTSaU0wmgBCaYWoJphNNCFLUm6mE00tVCJd1KGqDdTg1Mksq1To1U1apkamIvI1WY2qjG1WY2oAvI1WUNUo2qyhpgWlNSg1ApqZTQBIKWminUAFJinUYpiNiloorYwFpaSlpAFJS0lIYUlLSUANNNNONMNIZG1QualaoHNAyCQ1VkNWJDVSQ0DK8hqpI1WJDVSQ0hkLtULNT3NQMaQwLUm6mE03NIZOHp4eqwanq1IotK1TK1U1aplapGXEap0aqaNVhDSAtK1TqaqoamU0XCxZU1IDUCmpAadybEoNOzUQNOzVJktEmaM0zNGadxWH5pc0zNGaYh+aWmZpc0AOopM0uaACkpc0lIYhpDS0lIoaaSnUlIBtFLRQMSkxTqSkAlIadSUAIaSlNNoAKTNFJTAM0ZpM0maAHZozTc0ZoAXNFJS0CCkNLSGgBppjU8000ARNULVM1RNQBA1QOKsNULCgZXYVGRU7CoyKYyIikxUpFJtoAaBTwKAKeBSGIBTwKAKXFIYYpMU6kqWMaaYakNMNIZGaYakNRmkBG1RsakaomoEMJqNjT2qJjTENJppNBNMJqhDs04Go80oNMROpqZDVVTU6GgRbjarUbVSjNWozTAvRmrKGqUZq3GaALaGplquhqdaYEwp4qNakFMQtLiilxSEa1FFFbGItFFFABRRmkoGFJRRSAQ1G1PNMNAyNqrvU7VXekMrSVVkq09VJKRRUkqpJVuSqsgpDKr1A1WHqBhSGRGm5pzUw0AKDTlNMpwpDJlNTIagWpkqWUiwhqwhqslTpUNlWLKGp1NVlqZTSuFidTUgaoQacDRcViYNTt1Qg0u6qTFYm3Uu6od1LuqkyWiXNLmog1OzVJk2JQaUGogacDVCJM0uaYDS5oEPopuaXNAwoNFJSGJSUpopDEpMU6kpDEopaSgBKSlpKQDTSGlNNNMBDSGlNNNACUUUlAC0UlKKAFopBS0CFpDS0GgBpphp5ppoAiaomqZqiamBAwqJhU7VEwpDIWFMIqUimkUDIsUmKkxSYoGNApwFKBS0hhS0UUmxhSUtJUtjGmmmnmmGpGMNRtUpFRsKLgQtUTVMwqJhTEQtUTVM1RMKaJIjTDT2phFUISlFJSimIepqZDUK1KtAFlDVqM1USrMdAF2M1ajNU4zVqM0xFxDVhKqoasIaYiwtSColNSimA4U4U0U4UhGrRS0YrUwAUlLSUDCkoooGFITRSE0AIaY1ONMY0DI3NQPUrGoXpFFeSqslWnqrJUsoqSCqzirbiqzikMqOKgYVacVAwpDK7CmEVMy00rQBHinAUuKcFpMYqipkFNVamRalspD0FToKjQVOorNspIkUVItMUVIKm5VhwpwNNpc0XFYdml3UzNGaaYrEm6jdUeaN1WmS0TBqUNUIanBqtMlomDU4GoQ1ODVSIJgacDUQNOBqhEoNLmowacDQA/NGabmjNAxaKTNFIAooopDA0lFJSGFIaKSgBDTTSmkNADTTTTjTTQAlFFFMApaKKQC0UUUCFpKKKAENNNKaaaYDGqJqkNMNAETVG1SNUbUDIyKYRUhphpDG4pKWikMSlopaTKExS4opcVLYxMUlOxRipuMYRTSKkxSEVNxkRFRsKnIqMigRXYVEwqyy1Ey00IrMKiYVZZaiZatElYimkVMVphWqQiLFAFSbaMVQhAKlUU0CpFFAEqVYjqBBVhKALMdW46qR1ajoEWkNWENVkNWENMRYU1MpqBTUqmmIlFOFMBpwpAbFJinUYrUxG0lOpDQA2kpaQ0DENIaU000DEJqNjTiajY0DQxjULmpGNQOakoieqz1Yc1XekMrvVdxVl6gYVJRWcVCy1ZYVEy0gK5WmlanK00rQMh204LUgSnBaTZSGqtTKtCrUypUNlIFWplWhVqVVrNlABTwKULTsVIxuKSn4pMUANpKcRTSKpEsTNGaDSVaEx2aUGo80uapEMlDU4NUINOBq0SyYNTw1QBqcGqkSThqcGqENTgaYE2aXNRA04GmBJmjNMzS5pDHUUmaM0gCkzRSUgFzSGkpCaQAaaaUmkNMYhpppxpKAEooooAKKKKAFopKTNAC5pCaTNITQApNMJoJppNACE0wmlJqNmoAaxqM05jUZNACGmGlJppNIoKKTNFSNC0tApQKljFxRilAp2KkY3FGKfil21IyPFJipdtJtpDIStNK1OVppWgCsy1Ey1aZajZaaEVGWoWWrjLUTJVoRUK0wrVlkphWqRJX20bam20baoRGFp6inBacFpiFUVOgqNRUyigCZKspVZKsJQIsoasIaqoasIaYiypqVTUCmpVNMCYGng1EDTwaAN2kNLRWhgNNJTqQ0DGmmmnGmmmA000mnGmGkMYxqNjTmNRsaRSI2NQsakY1CxpMpEbmoGNSMahY1I0RtULVK1MNIZCwqMrUxFJtqRkJWm7an20baQ0QhKcEqUJTwlJspEapUypTlSpFSobKQirUqrShakC1LKGhaXbUgWl20gIttIVqbbSFaEibkBFNIqcrTStWkK5ARTcVMVphFUkTcipKeRTSKaEJmlBpDSVSESA04NUOaUNVCJw1ODVAGpwaqEWA1ODVXDU8NQBMGpwNQhqcGoAlzRmmA0uaAH5pKbmlzUgFJRSUAFJS0lMApKWkoAKKKKAEooppNIBSaaTQTTSaBgTTS1IWphagBxamFqaWphagBxaoy1NLUwtQA4tTC1NLUwtSGOJpM0zNGaQx9KKaKeKQxwFPApFFSqKkYgWnBaeFp4WpC5HtpdtShaNtILkW2k21PtpNtKw7kBWmlasFaaVpDKxWoytWitMK0wKjJUTJVtkqNkpoCmyUwpVopTClWmTYqlKTbVgpTdtO4iLbTgtP20uKYhoFSKKQCngUxEi1MlQrUy0xE61OhqutTKaYiwpqZTVdTUymgZMDTwaiBp4NMDoaKTNFamAUhpaQ0ANNIaU0hoGMNRtUhqNqQ0RNUTVK1RNSGQsahapWqFqllETVC1StURqSkRmmmnmm4pMYzFGKfil21IyPbS7KkC08LUtjREEqQJTwlSBKlspEYSpFSpAlPCUihgWnhakC04LSAYFpdtSbaXbRYTZFtpCtTbaNtUkS2VytNK1YK00rVJEtlYrTCtWStRstVYVysVphFWGWomFOwrkJFMNSsKjIpgNzSZoNMJoAk3U4NUOaA1MCwGp4aq4anBqYFkNTg1QBqeGoETg0uaiDUoagCXNGaYDS5pAPzSUmaM0ALRSUtMQUUUUwEpKWkpAITTSaUmmE0DEJphNDGmE0gAtUZakZqjZqBilqYWprNUZagBxamFqaWphagBxamlqYWpM0hkmaUGowacKQEoqVRUS1OgpDuSKKmVaai1Oi0guCrUgWnKtSBaVguRhaXbUoSl20rBch20m2p9tJtosO5BtppWrBWmlaVh3KxWmFaslaYy0rDKrLUTLVplqNloGVWWoytWmWoytMCsVppWrBWmFadxEG2jFSlaTFVckZinAUuKUCmIVakWmAVIopkkq1MtQrUq0wJlNTKagWplpgSrUgNRCng0DOiopKK3OcWkoooASmmnU00gGmo2qQ0xqTGiFqiap2FQsKllIgcVA1WWFQsKRSK7CoyKnYVGRUlEJFJipCKTFSxjMU4CnbacFqWMaFp4WnBaeFqWMQLTwtOVakC1JSGhakC0oWpAtIY0LTgtPC04LTFcj20u2pNtLtqkhNkW2kK1LigiqSIbIStNK1MRTStVYm5AVqMrVkrTCtMVyqy1Ey1aZahZaAKrComFWXFQOKBkDVGalYVC1AxCaTNIabmgCUNTg1Qg04GgCwGp4aq4apA1AE4anBqhDU4NTETA07NQg04GgCXNLmowadmmA8GlpgNLmmIdRSUZoAKQ0ZppNIBCaYTTiajY0ANY1ExpzGomNIY1jUbGlY1ExoGIzUwmgmmE0AITTCaCaaaQC5opKUUAOFSKKYoqVRQBIgqwgqJFqzGtILkqLVhFqNFqwi0guOVakC0KtShaLCuNC0u2nhaXFFguRbaTbU2KTFFh3IStNK1MVppWlYdyArTCtWCtRstTYpMrstRMtWWWo2WkUVmWoytWWWoitIZXK00rU5WmEUwIStNxUxFNK0yWRYpcU/FLtqkJjQKeBQFp4FUSKoqVRTVFSqKYDlFSrTFFSAUAPFOFNFPFAzoKKKK6DlCiiikAUlLSUDGmmGpDTSKQ0RMKiYVMRUbCpKIGFQstWWFRMtJjRWYUwrVgrTCtSy0VytG2pStJtqWNEe2nAU7bSgVDKEAqQCkAp4FSxjlFSAU1RUiipGOAqQLSKKeBTC4BacBTgKcBVJE3G7aMU/FGKpIlsjxSYqTFNIqiWyPFIRUhFNIpkkRFMIqYimEUxEDComFWGFRMKBlVxUDirbiq7igZUcVAwq04qu4pDIDTTUhFRkUhhmlBptKKAJAaeDUQpwNMCYGnA1EDTwaAJQacDUQNPBpiJAacDUYNPBpgSA0uaYDS5piHZozTc0ZoAXNITRTTSAQmo2NPNRmkBG1RtUjVGaBkTVE1SsKjIoGRGmGpCKYRQBGaTFSbaNtICPFOC08LTwtMBqrUyLQqVOiUCFRasotNRasItIQ9FqdFpqLUyigByipAKRRTwKADFLilooAbijFOpKLANIppFSUlFhkRFRkVORTCKloaZXZajYVYIqNhUtFJldhUbLU7CoyKktEBFMIqYimEUDISKTbUpFJtoQiLbS7ak20oWqJGBaeFpwWnhaoQ0LUirShakC0xCAU8CgCngUwEApwoxS4pjN+iiitjmCiiigAooxRQAlNIp9IRQMjIqNhUxFMIqWMgIqNlqwRUZFSykVytNK1OVphWpZSICtJtqYrTStQykRYpcU/FGKhlDQKcBRinAUhiipFpgqVaLAPUVKoqNalFNIVx4FOApAKeKpIlsTFJinYoqiRmKaaeaaaYhhppp5ptMkaaYRTzTTQBGwqJhUxqJqAK7ioHFWWFQuKBlRxUDirTioHFIaKrCmEVOy1GRQURYpMU8ijFIY0U4UuKUCmAop4poFOApiHCnimgU4UxDhThTRTxTEKKUUCloAKWjFFAhKQ0tIaAGmmGpCKYRSGRMKjIqYimEUhkDCmEVOVphWgZXK0hWpytJsoAg20oSptlKEoAiCU8JUoSnqlAhipUyJT1SplSgBESp0WhUqZVoECrUyikVakApAKBTqQCloAKKKSmAtFJRmmAUlLSUgENNIp1NNJgRsKjIqY1GwqWikQsKjYVMwqMioZaZCRTCKlIppFIojxSYqTFJigBm2nBadinAVQmNC08LTgKcBTRIgWngUoFOAqhCAU4ClApcUwExRinYpcUwNqlxSUtanOFFFFMAopcUUwEpCKdSUhjCKaRUhppFICMioyKmIphFSykREUwipiKaRUMpEJFNIqUimkVDKIyKTFPIpMVJQzFKBS4pQKVhigVItMAqRadhXHrUq1GtSrVJEtjxThTRThVWFcWkNLSGgQ00004mmE0CGmmmlNNJoADTTQTTSaYhDUTU8mo2NAEbVC9TNUTUDIGFQsKsNULCkUiuy1GVqwwqMigZCVpNtSlaTFAyPFKBT8UYpoBoFOApwFKBVEgBTgKUCnAUxCAU8CgCnAUCEpcUuKXFAhuKMU7FGKAG0Yp2KMUhjMU0ipMUYpAQlaaVqbFIVoGVytNK1YK03bQMrlaNlT7aNtAEGynBKm20oWgCMJUipUipUipSAYqVKqU9UqRVoEIqVIq05Vp4WgBAKcBSgU7FIBuKKWkNAAaSg00mgBc0maTNJmmA7NGabmjNAC0lGaSgBDTGp5phqWNEZqMipTUZqWWiMimkU800ipKuNxRilxS4oHcQCngUAU4CmSAFPAoApwFUhABTgKUClApkhilxS0uKoBuKXFOxRimK5rUCiitTEWlFJRQMWijNJmmAtJRSUCCkNGaQmkMQ0w04mmk1LGNNNNONNNQykNIppFPNNNQ0UhhFNxTzTTSsMSiloFFh3FAqQUwVIoppCuPWpFpi1IKqwhwp1NFLQIWmk0pNMJoEBNMJoJphNIYE00mgmmE0CFJppNITTSaYATTCaCaYTQAjGomp5NRsaBjGqM08mmGkURkUwipDTTQMjIpMU80lMYzFLilopoQYpwFJThVEigU4CkFOFMQ4ClxSCnUEhilxRS0AJijFLRQAmKMUtFIBMUYp2KMUAMxSYp+KTFKw7jCtN21LSYoAj20bafilxQMYFpwWnAU4CgBFWpFWlAp4FIQKtSBaAKkAoAAKcBSgUuKQwxRS0GkA2mmnmmGgY00wmnGmGgAJpM0hNJmgB2aM0zNGaYD80ZpuaTNACk00mlpppDENMNOJppqRoYaaaeabSsUJilAopRRYAFPApop4p2EOApwFIKeBTRLACnAUAU4CqEIBS4pcU7FMQ3FLinYoxTA0aXNJRWpmLRmkozQAuaM03NJmgQ7NJmmlqaWoAeTTS1MLU0tSAfupC1RlqaXpMaJCaaTTC1NLVLRQ8mkJqMtSbqmw7kmaTNR7qN1KwySlFRhqcDRYCQU8VGDUgNFgJBTxUYNPBpgPpc03NGaAFJphNBNMJpABNMJoY0wmkAE0wmgmmk0DAmmk0hNNLUABNMLUhamFqAAmmE0hNNLUhgTTCaC1NJoGKTTCaCaaTTGBNJmkJppagB2aM0zdRuqhEmacDUQalDUySYGnA1CGpwaqEyYGnA1EGpd1BJLmlzUe6jdQBJmjNM3UbqBD80uaj3UbqAJM0Zpm6jdQA/NGaZupN1IY+imbqN1ADqWmbqUNQMeKeKjBpwNAEoqRaiBqQGkBIKkFRA1IDSAeKdTAadmkMdSGkzRmkAhphpxNMJoGNNMNOJphNACGkzQTTc0ALRmm5ozQMdmjNMzRmmA7NNJpM0hNIYE0maQmkJoAKSkJpM0rAOpRTM04GiwXHinimCninYVx4p4pgqQUxDgKcBSAU8CmIAKXFLS0xCYpcUUtAFyikorYzFpM0hNNJpAKTTS1IWqNmpAOLUwvTGeoy9AiUvTS9Ql6YZKAJy9NL1AZKaZKBk5emmSq5kppkpWHcs76TfVbzKPMqbFFnfQHqt5lOD0rBcshqkDVVD1Ir0DuWVNSKarq1Sq1ICcGng1CGp4agZJmgmmbqTdSAcTTCaQtTC1IBWamE00tTC1AxxamFqaWppakMUmmk00tTC1IBSaYWpC1Rs1MYpamFqaWphakA4tSFqjLU0tTGPLU0tUZeml6AJC1NLVEXppemBLuo3VAXpN9MRZD0oeq2+lD1RJaD04PVUPTg9MRaD04PVUPThJTEWQ9Lvqtvo8ygRZ30b6r+ZR5lMRY30u+q3mUb6ALO+l31W8yjzKQFjfRvqt5lHmUDLG+jfVbzKPMoAtb6UPVXzKcJKALQepA1Uw9SB6QFxWqRWqor1Ir0AWw1PDVVV6kD0gLIanbqrh6cGpDJt1Gai3UbqQyQmmE0hamFqQxSaYTSFqaWoAUmmk0hamk0DHZpM03dSbqYD80maZupC1Ax5amlqYWpC1IB5amlqYWppamA/dRmot1G6gRNupQ1QhqcGoETg1KpqupqVTQBOtSrUKmpVpiJBTxTRTxTEKBS4oFLigQmKXFLRQBYzSZpM0hNbECk0wmgmmM1IBGao2ahmqFmpADPUTPTXaoWegRIXqMvUbPUZegCYyU0yVAXphegCcyU0yVAXppegZY8yk8yq2+jfSGWhJTxJVMPTlekMvK9Sq9UVeplekMvK9Sq1UleplekMuK1PDVUV6eHpDLG6gvUG+k30hkxaoy1Rl6YXpASFqYWqMvTC9ICQtTC1Rl6aXoGPLUwtUZemF6QyQvUTPTC9Rl6AJC9RlqjL0wvQMlL0wvUReml6YEhemF6iL0wvQBMXpheoi9ML0xExek31Bvo30xFjfSh6rb6cHpiLIelD1WD0oemItb6USVWD0u+mBZ8yl8yqu+l30xFrzKPMqrvo30CLXmUeZVbfR5lMCz5lHmVV8yjzKQFnzKTzKreZSeZQBa8yjzKq+ZR5lAy2JKcJKpiSnCSgC6JKkWSqIkqRZKQi8slSrJVBZKkWSgC+slSCSqKyVIJKQy8JKcHqkJKeJKQFzfRvqr5lL5lIZZ300vUHmUhegCYtTC1RF6aXoGTFqaWqIvSb6Bku6k3VDvpN9AE26kLVCXpC9AyUtTS1RF6YXoAlL0heoS9JvpiZLvo3VDvo30yScNTw1Vw1PVqALStUymqitU6NSAtqamU1VQ1YU0xE6mpBUKmpVoESClpopwoELiiilpgOzTSaTNNJrQkUmo2agtUTNSARmqB2pztUDtQA12qFmpXaoGagAZqjLUjNUZagBxamlqYWphagB5eml6YWppagB5ajfUW6k3UDJw9OD1XDU4NSGW1epVeqatUqvSGXVepleqKvUqyUhl4SU4SVTElO8ypGW/MpDJVbzKQyUDLBkppkquZKaZKQE5emF6gMlMMlICcvTC9Ql6YZKQyYvUZkqEyUwyUATNJUZeoTJUZkpgTF6YXqEvTS9ICUvTC9RF6aXoHckL0wvUZamlqYrkhemlqiLUm6mFyXdSbqi3UbqYrk26l3VDmlzTETbqXdUOaXdTAm30u+od1G6gRNvo31Duo3UwJ99G+oN1G6gCffRvqDdRuoETb6N9Q7qTdQBMXpN9Q7qTdQBPvo31Bupd1AycPTg9Vw1KGoAtB6eHqoGp4ekBcElSLJVEPUgkoAvLJUgkqgJKeJKQF8SU8S1QElPEtIZeEtL5lUhLSiWgC75lJ5lVPMo8ykBaMlIZKreZSeZQMsF6TzKr+ZSGSgCx5lJvqt5lJ5lAyyXppeoPMpu+gCwXppeoN9JvoAmL0m+ot1Jupkku6lDVDupQ1MROGqRWquDUimmBaVqnQ1UU1OhpAXENToaqIasIaALSmplNVkNTKaBEwp4qNakFMQ4UtIKdQIgJppamlqYWrQQ5mqJmoZqiZqQxrtUDtTnaoHagBrtULGnM1QsaAEY1GTSk0wmgBCaaTQaaaQCE00mlNNNABmkzRSUDHZpQajzS5pDJg1PVqgBpwagCyHqQPVUNTg9IZbElL5lVd9HmUgLXmUhkqt5lIZKBlkyU0yVWMlNMlICwZKaZKrmSmmSkMsGSmGSoDJTC9AE5kqMyVCXpheiwEpkphkqEvTC9AExkppeoS9JuoAlL0heot1JuoAkLU0tTc0madhXHE0mabmjNOwrjs0uaZS0wH5pc0yloAdmlzTaKAHZozTaTNMB+aTNNzRmgB+aTNNzSZoAfmjdTM0ZoAfupN1MzRmgB2aM0zNGaBD80uaZmjNMB+aUNTM0ZpAShqcGqHNLmgCYNTw9V80oakMsh6cHqtupd9IC0JKcJKqB6UPSGXBJSiWqfmUvmUAXPNpfMqn5lO8ygC15lHmVV8yjzKALPmUhkqvvppegCwZKTzKrl6TfQMs76TfVffRvoAsb6N1QBqcGoAm3UZqMGnA0xD804GmCnCmIkBqRTUQqRaAJ0NToarKanQ0AWkNWENVENWENIC0hqdTVZDU6mgRYU1IKhU1KKZJIKcKaKcKBGeWphamlqYWrQBWaomahmqJmpDEZqgZqczVCzUAIzVExpWNRk0AITTSaCaQ0hiGmmlNNNACGmmnGmmkMSkpaMUAJRRRQMWlzTaM0gH7qXdUeaTNAEu6jfUO6k3UxExeml6hLUhelYCUvSF6hL00vSsMmL00vUJeml6LDJi9NL1CXpC1ICQvTC9MLUwtQMeXppamE0hNADt1G6mZozQIfmjNNpaYhc0UlLQAUtJS0xBS0YpcU7AAoFFLQAUUUUAFFFFACUUUUAJRRRTAKSg0UgCkoooAKKKKYC0UUUCFooopDClzSUUALmjNJSZpDH7qN1MzSZoGSbqXdUWaN1IRLvpd9Q7qN1AE4el31X3Uu6gCxvo31Buo3UATb6TfUW6k3UAS76TfUW6jdQBNupQ1QA08GiwyYNTwahBqRaYEoNPFRrUi0CHinimCnimA4VItMFPFAEq1MhqBalU0gLKGp0NVkNToaALSGp1NVkNToaBFlDUy1XQ1OtAiVaeKjFSCkIxS1RlqaWphatRCs1RM1DNUbNQAjNUTGlY1GxpDEJphNKTTCaAA0lFJSGIaQ0tIaQDTSUppKBiUUtFIYlJS0UAJSUtJQAhppNKaaaYgJppNBppoACaYTQTTSaBAWppakJppNAxS1NLUhNNJpDHE0mabmigYuaaTRSUDAmkNFFAhKUUYpcUAApwpAKcBQIBS0Yp2KYhMUYpcUYpgFFLiigAoopaACiiikAUlLRTASjFLSUAJSU6koASkp1JQAlFLRQAlFLijFAhKWijFABRRRQAUUUUhiUlLSUDEpKWkoATNGaKSgAzRmkopAOzRmm5ooEPzRmmZozQA7NGabmkzQMdmjNNpRTAeDThTBT1oAkWpVqJalWgCValWolqVaAHiniminikAop4popwoAkFSKaiBp6mgCwpqZDVZTU6GkBaQ1YQ1UQ1YQ0CLSGp1NVkNTKaBFhTUgNQqakBpAc8WphNBNMJrYkRjUbGnE1GTQA0mmE0rGmE0hiE00mg000DDNFJRmkAUlFFACGg0UUhiUUUtACUlLRSGJTTTjTTQIaaaacaaaYDTTDTjTTTEMNNNONNNADDTDTzTDQA00lOpKQxtFLilxQMbRinYoxQMbijFOxRigBuKXFLilxQAgFOAoxS4oEAFLQKWmITFLRRQIKKKKACiiigYUUUUgFpKWigBKKKKYAaSlpKADFJS0UAJRilxS4pgNxRinYpKQhKKWkxQAUlLRQAlFFBoGJSUtFAxtJTqSgBtJSmikIbRS0YoAbilpaMUAJSUuKKAEooxRigApRRilAoAUVIKaBTxQA9akWoxUq0DJFqVahWpAaAJRTxUYNPBpAPBpwNRg04GgCQGng1EDTwaQE6mplNVlNTKaALSGrCGqaNVhGoEW0NTqaqI1Tq1AFpTTwagVqeGpCMAmmk0pNMJrYkQmmGnE0w0DGGmGnGmGkMaaQ0pNNJoASkzRmigAopKKQC0UlLSAKSlooGJRRSUAJSGlNNNAhDTTTjTDTAaaaacaaaBDTTDTzTTQAwimEVIRTSKBjKTFPxSYoGNxS4pcU7FAxmKXFOxRigY3FGKdijFADMUuKWikITFLRRQIWiiimIKKKKACikooAWkoopDFopKM0DFoozRmgQUUmaM0wFoozRQAYooooAKWiimAYpKWikAlJSmg0ANNFLSUAJRRRQMSiikoAKSlNJQAhpKWigQlFLRigBKKXFGKAExSYp2KMUANxRinYoxQAmKUClxTgKAEAp4FAFOAoAUU8U0U4UAPFSA1EDTwaQyUGng1CDTwaQEoNOBqMGnA0ASA04GowacDQBKDUqmoAakU0gLKNU6NVRWqZGoEXUaplaqaNUytSAtq1SBqqq1SBqQGQTTSaCaaTW5AGoyacTTCaBoaaYacTTDQMaaaacaaaBiUmaDSUALRSUUhC0tJRSAXNFFFABSUUhoAQ0hpTTTTEIaaaU000AIabTqSkA0000+mkUANIppFPxSYoGMxSYp+KMUANxRinYpcUDG4pcUuKMUDG4pKfikoAZSGnGkoASiiigQUUUUCFpKKKACkzRRSGFLmkooGLmjNJRQAuaM0lFAhc0maKKAFopKWgBaKSlpgLRSUtABRRRSAKSlpKBiUlOpKAG0UtJTASkpaSgBDRS0lABSUtFABS4opcUCEoxS0YoATFGKXFLigBuKXFLilxQAmKUClxS4oATFOoxS0AFLRRQA4U4GmClFIZIDTwaiBp4NAEgNPBqIGng0gJAacDUYNOBoAkBp4NRA04GgCwrVKrVVVqlVqALatU6tVNWqZWpAW1apA1VVapA1IDOLUmaZupC1bmYpNNJpC1NJpDAmmk0hNNJoKAmkJpCaQmgAJpKTNJmgB1GabmjNIQ7NLmmZp2aAHUU3NGaQC0hNGaTNMANNNBNIaBCGkopKBBSUuaSkMKSlooAbikxTqSkA3FGKdikpjExRS0UAJiilopjEppp1IaAGmm040lACUlLSUgCkpaSgAoopM0gFpKKKACiiigAooooAKKKKYBS0lLQAUUUUgFopKM0wFpaSigBaWkpaQBRQKWgYlJS0lACU2nUlMQ2kp1JQAlFGKXFAxKKWloEJS0YpaAExS4pcUUAJilxS4oxQAmKXFLilxQAmKXFLRQAYooxRQIKKKKBhS0lKKAHCnCmCnCkMkBpwNMBpwNADwaUGmZpc0CJAacDUQNKDSGTBqkVqrg1IrUAWVap1aqimpkNIZaVqlDVWU1KpoAziaaWppNITWxkOJppNNzSE0ihSaaTSE00mgBSaQmkJpM0ALmkzTc0maAHZozTM0ZpASZpc1HmlBoAkzRmmZpc0gHZpM0maTNMBSaaaKSgQUlFJmgQtFJRSGLRSZooAKKKKQCUUtFMY3FFLRQAlFFFMBDSUppDQAlIacaaaAG0lONJikAlJTqSgY3FFLRSASiiigBKWiigAoopcUxCUClxS4oASjFLijFAxMUuKXFJigBKKWigBBS0UUALS0lLQAUtFFABikpaTFACUlOpKYhtJTqMUANxRTsUmKAExS0YpcUhiUtLijFIAopcUuKAEpaMUuKYBilxRijFAgopaKAEpDS0UwEpKU0lIYUtJRQA4U4GmU4UhjwadmowaXNAD80uaZmlzQIfmlBpmaUGgCQGnqaiBp60DLCmpkNV0qZKQywpqVTUK1KtIZm001IRTSK3MhhpppxFNIpANJppNKaaaQwJppNBppoEGaM0lJQAuaM02igB2acDTKUUhjwaWmilFAC5oooxQAGkpcUmKBCUlOIpMUANozS4oxSAKKXFGKACijFGKBiUU7FJigBMUlOxRimA2kxT8UmKBDaSn4pMUDGYpMU/FGKQEeKMU/FG2gCPFJipMUmKQxmKTFSbaTbQAzFGKfto20AMxRin7aXbTER4pcU/bS7aYiPFLipNtG2gYzFGKk20baQEeKMU/bRtoGR4oxT9tG2mBHilxT9tG2gQ3FGKdilxQA3FGKdijFADcUU7FGKAGYpMVJto20wI8UmKl20baBEeKMVJto20gI8UYqTbRtpDGYoxT9tLtpAMxS4p2KNtADcUuKdtpcUwG4oxT8UYoAZijFPxSYoAZSU/FJimAykp+KTFAxtFLijFIBBThSYooAdS02loAWlpKWkIWnCkApwFAxRUi00CpVFAD0FToKiQVYRaCh6iplFMValVaQyiUppWrRSmFK1MSoVphWrbJUbJQMqlaYRVkpTClAFcimkVOUppWgCAikxUxWk20AQ4oxUu2jbSAjxTgKfspQlAxoFKBTwlOCUgI8Uu2pQlLsoAh20m2p9lJsoEQ7aTbU+yk2UAQbaNtTbKNtAEW2jbUuyl2UDIdtLtqXZS7KQEO2jbU2yjZQBDto21NspdlMCDbSban2UbKBEG2k21Pso2UAV9tG2p9lGykMr7aNtT7KNlAEG2k2VZ2UmykMr7aNlWPLo8ugRX2UbKseXRspgV9lGyrHl0vl0xFfZS7KseXS+XQBX2UbKs+XR5dAFfZRsqx5dHl0DK2yk2Va8uk8ugCtspNlWfLo8ugZW20baseXR5ftQIr7aNtWPLo8umBX20u2p/Lo8ukBBto21P5dLspgV9tLsqfy6Xy6BFfZRsqz5dHl0wK2yjZVny6PLpAVtlGyrPl0eXSArbKNtWPLo2UgK+2l21Pso8ugCDbS7am2UuygCDbRtqfZRsoAg20m2rGyk2UwK5Wk21YKUmygZWK0m2rBSkKUxlfbRiptlJsoAhxRipdlLspARYoxUuyjZQIjApwFPCU8JSAYFpwWpAlPVKAGqtSqtOVKlVKQxFSp0WlRKmVKBiKtSqtOVKkCUDK5jphjq4UphStDIpmOo2jq8Y6jMdAyiY6jMdXmjqMx0CKRSmFKumOmmOgCkUo8urZipPLoAqeXR5dW/LpfKoGVPLpwjq0IqURUgKwjpwjq0IqcIqAKojpfLq0IqXyqAKnl0nl1c8qjyqAKfl0nl1c8qk8qgCn5dHl1b8qjyqAKnl0vl1b8qjyqQyp5dL5dW/KpfKoAqeXR5dW/KpfKoEU/Lo8urnlUeVTAp+XR5dXPKo8qgCl5dHl1c8qk8qkBT8uk8urnlUeXSAp+XR5dXPLo8ugZT8ujy6ueXR5VAFTy6Ty6ueVR5VAin5dHlVd8qjyqYFPy6Xyqt+VS+VQBT8uneVVvyqXyqBFTy6PKq55VL5VAyl5VHl1d8qk8r2oApeXR5VXPKo8qgZS8qk8qrvlUeV7UAUvKo8qrvlUeVQBS8ujy6ueVR5VMCn5VJ5ftV3yqPK9qBFPy6PLq55XtR5VAFTy6XyqueVS+VQBT8ql8qrnlUvlUxFLyvak8qr3le1HlUgKPlUnlVe8qk8qgCl5dJ5dXfKo8qkBS8ujy6ueVR5XtQBT8ul8urflUvlUDKfl0eXVzyqPKoEU/LpPLq55VHlUxlIx03y6vGKmmKgCkY6aY6umOmmKmMpeXSeXV0xUnlUAUvLo8urnle1J5VICp5dHl1b8ql8qkIqiOnCOrQipRFQBXEdSrHUwiqVY6QECx1MsdTLHUqx0DIljqZUqRY6lWOgdyNUqQJUoSnhKQXINlNKVY20myrIKxSmGOreykKUAUjHTDFV4x00x0wKBippiq+YqaYqBFHyqTyqveVSeVQMpeVR5VXfKo8qkBTEVOEVWxFThFTAqCKnCKrYipRFSAq+VS+VVvyqXyqYFPyqTyqu+VR5VAFHyqPKq75VJ5VAFPyqPKq55dL5VAFLyqPKq75VHlUhlPyqPKq55dL5VAFPyqPKq55VL5VAin5VHle1XPKpfKoApeVR5VXfKo8qgCj5VJ5VXvKpPKpAUfKpPKq8YqTyqAKXlUeVVzyqPKoAp+V7UeVVzy6Xy6AKflUeVVzy6Xy6AKflUeVV3yqPKoAp+VR5VXfKo8qgCn5VL5VXPLo8ugCp5VHlVc8ujy6AKfl0eVVzy6Ty6BlPyqTyqu+XR5dAFLyvajyqueXR5dAFPyqPKq75VHlUAUvKo8qrvlUnl0wKXlUeV7Vd8uk8ugCn5XtS+VVvy6Xy6BFPyqXyqt+XS+XQBU8ql8qrfl0vl0wKnlUeVVzy6Ty6AKflUnlVd8uk8ukBS8qjyqu+XSeXQBS8r2o8qrnl0eXQBT8r2o8qrnl0vle1ICl5VHlVd8ujy6AKXlUeVVzy6Ty6YFIxU0xVeMdIY6YygYqQxVeMdNMVMCl5VJ5VXfKpPKpAUvK9qPK9qu+V7UeV7UgKXlUvlVd8qjyqAKYipwiq35VOEVIRUEVSLFVkRU8R0AV1jqRY6nEdPEdAyJUqRUqUJTwlAEYSnBakC04LQBX20bakxS7aBEWyk2VPto20AV9lIY6s7KNlAFUx0nl1a2UmymIq+XSeXVrZSbKAK3l0eXVnZRsoGVvLpwjqxspQlAEAjpRHU4SnBKAIBHS+XU+yl2UCK/l+1Hl1Z2UbKYFby6Ty6tbKNlAFXy6PLqzso2Uhlby6PLqzso2UAVvLpfLqxto2UAV/Lo2VY2UbKBEGyjZVjZRsoAg8ujy6sbKNtAFby6PLqzspClICqY6Ty6slKTZQMreXR5dWNlGygCvso8urGyl2UxFfy6Xy6sbKXZQBW8ul8urGyl2UgK/l+1Hl1Y20bKBlfy6NlWNtG2gCDZR5dT7aNtAEGyk2VY20baYFfZRsqfbRtoAg2UbKn20baQEGyjZU+2jbQBBspNlWNtG2gCv5dGyrG2k2UwK+yl2VPto20AQbKXZU22l20CIdlGypttLtpgQ7KNlTbaXbQBBspNlT7aNtAFfZRsqxtpNtAFfZRsqxto20gINlHl1Pto20AQeXR5dWNtJtpDK+yk2VZ20hWmBW2UmyrG2k20wKxjpPLqztpNlAFby6PLqzto2UDK3l0vl1Z2UBKQFby6Xy6s7KXZQIreXSiOrOyjZSAriOnCOp9lLtoAhCU4JUu2l20AMC04LTsUuKBDQtOxS4paBlcClxSgU4CgQgFLtpwFKBQMbto21JijFAEe2k21LikxQBFtpNtS4pMUAR7aNtSYoxQMj20u2n4pcUAM20oWn4pcUxDQtLtpwFOxQAzbRtp+KXFAiPbRtqXFG2gRFto21LtoxQMh20bal20mKAI9tG2pMUmKAGbaNtPxRigBm2l207FLigBm2jbT8UUgGbaTbUmKMUhkW2k21LikxQBHto21JijFAEe2jbUm2lxTER7aXbUmKXFMRHto21JikxSGM20m2pMUmKAGYpMU+koAbijFOooAbijFOopgNxRinYoxQA3FGKdijFIY3FGKdijFADcUYp1FADMUYp+KSgBuKMU6imA3FGKdiigQ3FLilpaAG4oxTqMUwG4oxTsUUANxSYp+KSgBuKXFLS0AMxS4p1FIBuKMU7FFIYzFJipKSmBHik21JikxQBHto21JikxQAzbRtp+KXFAxm2l20/FGKAGbaXbT8UuKBDNtLtp+KMUAM20Yp+KMUgGYoxTqSgBKWkopgLRTc0ZoAaBTgKQU4UhCgUooFLQMKWiloASkpaQ0DENJSmkzQOwlFGaM0BYKWkzS0AKKWkFOFMQopaSnCgQoFKBRSigQYoxTsUuKBDMUYp+KTFADMUmKfikxQMZikxT8UlADcUYpaSkMMUUlGaAFzRSZozSAWim5ozQMWikzS0AJS0UtABilxQKWmITFLilooEJSU4000AJTTSmmk0DCkoJpuaAHZopuaXNMBaWm0tAC0UUUCCiiigAoopKQxaSiimAUUUlABRRRmgAoozRSAWiiii4BS0UUAFFJRTAKKTNFMQtFJS5oAKWkzRmkMXNJRmikAUlKaSgYGkpaSmAUUUUAFFFFAC0tJS0AKKdTRTqYgxSYpaKQCUlLSUAIaaaUmmk0DCkzQTSZoAXNJmkzSZoAkpRSUtIQ6lpBSigBaKBSUDA0hpaaaBgTTc0E03NIYtFJmjNMYuacDTKUGmIfThTKcKCR9OFMFPFMQ8Uopop4oEKKdikFOoEJikNOpDQA002nmmmgY00004000hiUlBpDSGJSUE0maQxc0ZpM0maQDs0U3NLmgBaWm5paAHUtNFKKYDqWkFLQIWiiimAhpppTTTQIQmmk0pNMJoAQmkzSE0maYDs0optKKAHUtIKWmAtLSUtAgoopKACiiikMSiiigYUUlFABRSUUCFopKWpGLS0lKKBhRRRQAUlFJVIQUUlFMQtFJRQA6ikopDFopKM0gFzSZpM0uaACiiigApKWkpjClpKKAHUtNpaBDgaWmilpiFoopKADNITQaaTQMCaaTQTTSaQATTc0E0lMBc0maSigD//2Q==", - "job_id": "4123b4ec-ea71-49f4-b7e2-ad86d622b947", - "grid_index": 0, - "is_alteration": false, - "order": 2, - "section_id": 0, - "request_id": "fc39cefd-fcf9-4775-b490-7e17ce670060", - "url": "https://imagine-public.x.ai/imagine-public/images/7693b927-1c34-488c-8ccc-6750367c66b1.png", - "id": "7693b927-1c34-488c-8ccc-6750367c66b1", - "prompt": "a dog typing on a keyboard", - "full_prompt": "a dog typing on a keyboard", - "percentage_complete": 50, - "model_name": "imagine_h_1", - "suggested_moderation_rule": null, - "r_rated": false -} diff --git a/crates/api_clients/grok_consumer_client/test_data/websocket_messages/create_image_complete_status_notification.json b/crates/api_clients/grok_consumer_client/test_data/websocket_messages/create_image_complete_status_notification.json deleted file mode 100644 index fcbeb21691..0000000000 --- a/crates/api_clients/grok_consumer_client/test_data/websocket_messages/create_image_complete_status_notification.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "type": "json", - "current_status": "completed", - "percentage_complete": 100, - "job_id": "c1bed796-3f05-4716-8ef0-a4d4900dfc6e", - "elapsed": null, - "prompt": "a dog typing on a keyboard", - "confirmation": "Drew a dog typing", - "full_prompt": "a dog typing on a keyboard", - "flags": null, - "is_alteration": false, - "section_id": 0, - "input_type": "text", - "request_id": "fc39cefd-fcf9-4775-b490-7e17ce670060", - "asr_transcript": null, - "asr_accepted": null, - "seed": null, - "image_reference": null, - "is_image_edit": null, - "moderated": false, - "r_rated": false, - "order": 1, - "model_name": "imagine_h_1", - "image_id": "78b3e6ef-defc-41a6-a9ac-b7a370d26ce5" -} diff --git a/crates/api_clients/grok_consumer_client/test_data/websocket_messages/create_image_in_progress_response.json b/crates/api_clients/grok_consumer_client/test_data/websocket_messages/create_image_in_progress_response.json deleted file mode 100644 index e84278d197..0000000000 --- a/crates/api_clients/grok_consumer_client/test_data/websocket_messages/create_image_in_progress_response.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "type": "json", - "current_status": "start_stage", - "percentage_complete": 0, - "job_id": "57baeffe-d5cf-483b-a5bb-7794899f905c", - "elapsed": null, - "prompt": "a dog typing on a keyboard", - "confirmation": "Drew a dog typing", - "full_prompt": "a dog typing on a keyboard", - "flags": null, - "is_alteration": true, - "section_id": 0, - "input_type": "text", - "request_id": "fc39cefd-fcf9-4775-b490-7e17ce670060", - "asr_transcript": null, - "asr_accepted": null, - "seed": null, - "image_reference": null, - "is_image_edit": null, - "moderated": false, - "r_rated": null, - "order": 7, - "model_name": "imagine_h_1", - "image_id": null -} diff --git a/crates/api_clients/grok_consumer_client/test_data/websocket_messages/create_image_request.json b/crates/api_clients/grok_consumer_client/test_data/websocket_messages/create_image_request.json deleted file mode 100644 index 5ea498f971..0000000000 --- a/crates/api_clients/grok_consumer_client/test_data/websocket_messages/create_image_request.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "type": "conversation.item.create", - "timestamp": 1761010203630, - "item": { - "type": "message", - "content": [ - { - "requestId": "fc39cefd-fcf9-4775-b490-7e17ce670060", - "text": "a dog typing on a keyboard", - "type": "input_text", - "properties": { - "section_count": 0, - "is_kids_mode": false, - "enable_nsfw": true, - "skip_upsampler": false, - "is_initial": false - } - } - ] - } -} diff --git a/crates/api_clients/grok_consumer_client/test_data/websocket_messages/empty.json b/crates/api_clients/grok_consumer_client/test_data/websocket_messages/empty.json deleted file mode 100644 index 9e26dfeeb6..0000000000 --- a/crates/api_clients/grok_consumer_client/test_data/websocket_messages/empty.json +++ /dev/null @@ -1 +0,0 @@ -{} \ No newline at end of file diff --git a/crates/api_clients/grok_consumer_client/test_data/websocket_messages/other_type.json b/crates/api_clients/grok_consumer_client/test_data/websocket_messages/other_type.json deleted file mode 100644 index 9bb5b8947a..0000000000 --- a/crates/api_clients/grok_consumer_client/test_data/websocket_messages/other_type.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "type": "other_type", - "foo": "bar" -} diff --git a/crates/api_clients/grok_consumer_client/test_data/websocket_messages/wire.json b/crates/api_clients/grok_consumer_client/test_data/websocket_messages/wire.json deleted file mode 100644 index a7900b55f3..0000000000 --- a/crates/api_clients/grok_consumer_client/test_data/websocket_messages/wire.json +++ /dev/null @@ -1 +0,0 @@ -{"type":"json","current_status":"start_stage","percentage_complete":0.0,"job_id":"0080eaac-f7f7-4369-90a2-346491939c1b","elapsed":null,"prompt":"a dog riding a motorcycle","confirmation":"Drew a dog riding a motorcycle","full_prompt":"a dog riding a motorcycle","flags":null,"is_alteration":false,"section_id":0,"input_type":"text","request_id":"bbc15402-3257-4415-922e-b156c151f3c2","asr_transcript":null,"asr_accepted":null,"seed":null,"image_reference":null,"is_image_edit":null,"moderated":false,"r_rated":null,"order":0,"model_name":"imagine_h_1","image_id":null} \ No newline at end of file diff --git a/crates/api_clients/grok_consumer_client/test_data/websocket_messages/wire_formatted.json b/crates/api_clients/grok_consumer_client/test_data/websocket_messages/wire_formatted.json deleted file mode 100644 index 2f458d5128..0000000000 --- a/crates/api_clients/grok_consumer_client/test_data/websocket_messages/wire_formatted.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "type": "json", - "current_status": "start_stage", - "percentage_complete": 0, - "job_id": "0080eaac-f7f7-4369-90a2-346491939c1b", - "elapsed": null, - "prompt": "a dog riding a motorcycle", - "confirmation": "Drew a dog riding a motorcycle", - "full_prompt": "a dog riding a motorcycle", - "flags": null, - "is_alteration": false, - "section_id": 0, - "input_type": "text", - "request_id": "bbc15402-3257-4415-922e-b156c151f3c2", - "asr_transcript": null, - "asr_accepted": null, - "seed": null, - "image_reference": null, - "is_image_edit": null, - "moderated": false, - "r_rated": null, - "order": 0, - "model_name": "imagine_h_1", - "image_id": null -} diff --git a/crates/api_clients/midjourney_client/Cargo.toml b/crates/api_clients/midjourney_client/Cargo.toml deleted file mode 100644 index 1a417a703b..0000000000 --- a/crates/api_clients/midjourney_client/Cargo.toml +++ /dev/null @@ -1,40 +0,0 @@ -[package] -name = "midjourney_client" -edition = "2024" -version = "0.0.1" -publish = false - -[package.metadata.cargo-udeps.ignore] -normal = ["workspace-build-acceleration"] - -[lib] -name = "midjourney_client" -path = "src/lib.rs" - -[dependencies] -# Workspace hack (faster compile times) -workspace-build-acceleration.workspace = true - -# Internal -cloudflare_errors.workspace = true -cookie_store.workspace = true -errors.workspace = true - -# External -anyhow.workspace = true -futures.workspace = true -log.workspace = true -serde.workspace = true -serde_json.workspace = true -tokio = { version = "1", features = ["full"] } -url.workspace = true -wreq-util.workspace = true -wreq.workspace = true - -# NB: We need to parse HTML to get out the websocket token -dom_query = "0.20.2" - -[dev-dependencies] -filesys.workspace = true -test_data.workspace = true -test_utils.workspace = true diff --git a/crates/api_clients/midjourney_client/src/client/midjourney_hostname.rs b/crates/api_clients/midjourney_client/src/client/midjourney_hostname.rs deleted file mode 100644 index 3110ff0c40..0000000000 --- a/crates/api_clients/midjourney_client/src/client/midjourney_hostname.rs +++ /dev/null @@ -1,17 +0,0 @@ - -/// Multiple third party Midjourney clients make this configurable. -/// Not sure why, I'm just cargo culting it. -#[derive(Clone)] -pub enum MidjourneyHostname { - Standard, - Custom(String), -} - -impl MidjourneyHostname { - pub fn as_str(&self) -> &str { - match self { - Self::Standard => "www.midjourney.com", - Self::Custom(domain) => domain, - } - } -} diff --git a/crates/api_clients/midjourney_client/src/client/midjourney_websocket_client.rs b/crates/api_clients/midjourney_client/src/client/midjourney_websocket_client.rs deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/crates/api_clients/midjourney_client/src/client/mod.rs b/crates/api_clients/midjourney_client/src/client/mod.rs deleted file mode 100644 index 233febf33d..0000000000 --- a/crates/api_clients/midjourney_client/src/client/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod midjourney_hostname; -pub mod midjourney_websocket_client; diff --git a/crates/api_clients/midjourney_client/src/credentials/cookie_names.rs b/crates/api_clients/midjourney_client/src/credentials/cookie_names.rs deleted file mode 100644 index 6eba239b04..0000000000 --- a/crates/api_clients/midjourney_client/src/credentials/cookie_names.rs +++ /dev/null @@ -1,6 +0,0 @@ - -/// One of the apparent authentication cookies used by Midjourney. -pub (crate) const AUTH_COOKIE_NAME_R : &str = "__Host-Midjourney.AuthUserTokenV3_r"; - -/// One of the apparent authentication cookies used by Midjourney. -pub (crate) const AUTH_COOKIE_NAME_I : &str = "__Host-Midjourney.AuthUserTokenV3_i"; diff --git a/crates/api_clients/midjourney_client/src/credentials/cookie_store_has_auth_cookies.rs b/crates/api_clients/midjourney_client/src/credentials/cookie_store_has_auth_cookies.rs deleted file mode 100644 index 89827f00f9..0000000000 --- a/crates/api_clients/midjourney_client/src/credentials/cookie_store_has_auth_cookies.rs +++ /dev/null @@ -1,8 +0,0 @@ -use crate::credentials::cookie_names::{AUTH_COOKIE_NAME_I, AUTH_COOKIE_NAME_R}; -use cookie_store::cookie_store::CookieStore; - -/// Returns true if the given cookie store has the necessary authentication cookies. -pub fn cookie_store_has_auth_cookies(cookie_store: &CookieStore) -> bool { - cookie_store.has_cookie(AUTH_COOKIE_NAME_I) - && cookie_store.has_cookie(AUTH_COOKIE_NAME_R) -} diff --git a/crates/api_clients/midjourney_client/src/credentials/jwt_decode.rs b/crates/api_clients/midjourney_client/src/credentials/jwt_decode.rs deleted file mode 100644 index 2efdd4e47e..0000000000 --- a/crates/api_clients/midjourney_client/src/credentials/jwt_decode.rs +++ /dev/null @@ -1,31 +0,0 @@ - -/* -{ - "name": "u3869671173", - "picture": "https://lh3.googleusercontent.com/a/ACg8ocKw0aaXKYSqy-Xkkn69ydIJFGnJA37S13XvjNY4d9xCzUzKUw=s96-c", - "midjourney_id": "f8a57ac3-e416-4dd4-9be8-2c4223691b01", - "iss": "https://securetoken.google.com/authjourney", - "aud": "authjourney", - "auth_time": 1754970849, - "user_id": "bS9idl73DlSbE61KnCyKpDfazCX2", - "sub": "bS9idl73DlSbE61KnCyKpDfazCX2", - "iat": 1754970849, - "exp": 1754974449, - "email": "victorvoice89@gmail.com", - "email_verified": true, - "firebase": { - "identities": { - "google.com": [ - "116459300198619888836" - ], - "email": [ - "victorvoice89@gmail.com" - ] - }, - "sign_in_provider": "google.com" - } -} -*/ - -/* - */ \ No newline at end of file diff --git a/crates/api_clients/midjourney_client/src/credentials/midjourney_user_id.rs b/crates/api_clients/midjourney_client/src/credentials/midjourney_user_id.rs deleted file mode 100644 index 1df40c2dde..0000000000 --- a/crates/api_clients/midjourney_client/src/credentials/midjourney_user_id.rs +++ /dev/null @@ -1,22 +0,0 @@ - -/// The user ID used for several midjourney requests. -#[derive(Clone, Debug, Eq, PartialEq, Hash)] -pub struct MidjourneyUserId(pub String); - -impl MidjourneyUserId { - pub fn from_str(user_id: &str) -> Self { - Self(user_id.to_string()) - } - - pub fn from_string(user_id: String) -> Self { - Self(user_id) - } - - pub fn as_str(&self) -> &str { - &self.0 - } - - pub fn to_string(&self) -> String { - self.0.to_string() - } -} diff --git a/crates/api_clients/midjourney_client/src/credentials/mod.rs b/crates/api_clients/midjourney_client/src/credentials/mod.rs deleted file mode 100644 index 3f9cb6efcb..0000000000 --- a/crates/api_clients/midjourney_client/src/credentials/mod.rs +++ /dev/null @@ -1,4 +0,0 @@ -pub mod cookie_names; -pub mod cookie_store_has_auth_cookies; -pub mod jwt_decode; -pub mod midjourney_user_id; diff --git a/crates/api_clients/midjourney_client/src/endpoints/get_index_page_html.rs b/crates/api_clients/midjourney_client/src/endpoints/get_index_page_html.rs deleted file mode 100644 index 90949efa9d..0000000000 --- a/crates/api_clients/midjourney_client/src/endpoints/get_index_page_html.rs +++ /dev/null @@ -1,95 +0,0 @@ -use crate::client::midjourney_hostname::MidjourneyHostname; -use crate::error::midjourney_api_error::MidjourneyApiError; -use crate::error::midjourney_client_error::MidjourneyClientError; -use crate::error::midjourney_error::MidjourneyError; -use cloudflare_errors::filter_cloudflare_errors::filter_cloudflare_errors; -use log::error; -use serde::Deserialize; -use wreq::Client; -use wreq_util::Emulation; - -/// This grabs the pre-rendered HTML page, which contains the websocket token and other details. -pub struct GetIndexPageRequest { - pub hostname: MidjourneyHostname, - pub cookie_header: String, -} - -pub async fn get_index_page_html(req: GetIndexPageRequest) -> Result { - let url = format!("https://{}/", req.hostname.as_str()); - - let client = Client::builder() - .emulation(Emulation::Firefox139) - .build() - .map_err(|err| MidjourneyClientError::WreqError(err))?; - - let cookie_header = req.cookie_header.trim(); - - if cookie_header.len() < 20 { - error!("Cookie header is too short (len: {}): {}", cookie_header.len(), cookie_header); - return Err(MidjourneyClientError::CookieTooShort.into()); - } - - // NB: missing headers that were in the browser request: - // -H 'sec-ch-ua-platform: "macOS"' \ - // -H 'sec-ch-ua: "Not)A;Brand";v="8", "Chromium";v="138", "Google Chrome";v="138"' \ - - let mut http_request = client.get(url) - .header("cookie", cookie_header) - .header("Referrer-Policy", "origin-when-cross-origin") - .header("accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7") - .header("accept-language", "en-US,en;q=0.8") - .header("content-type", "application/json") - .header("priority", "u=0, i") - .header("sec-ch-ua-mobile", "?0") - .header("sec-fetch-dest", "document") - .header("sec-fetch-mode", "navigate") - .header("sec-fetch-site", "none") - .header("sec-fetch-user", "?1") - .header("upgrade-insecure-requests", "1"); - - let http_request = http_request - .build() - .map_err(|err| MidjourneyClientError::WreqError(err))?; - - let response = client.execute(http_request) - .await - .map_err(|e| MidjourneyApiError::NetworkError(e.to_string()))?; - - let status = response.status(); - - let response_body = response.text().await - .map_err(|e| MidjourneyApiError::NetworkError(e.to_string()))?; - - if !status.is_success() { - if let Err(err) = filter_cloudflare_errors(status.as_u16(), &response_body) { - return Err(MidjourneyApiError::CloudflareError(err).into()); - } - } - - Ok(response_body) -} - -#[cfg(test)] -mod tests { - use crate::client::midjourney_hostname::MidjourneyHostname; - use errors::AnyhowResult; - use filesys::read_to_trimmed_string::read_to_trimmed_string; - use crate::endpoints::get_index_page_html::{get_index_page_html, GetIndexPageRequest}; - - #[ignore] - #[tokio::test] - async fn test() -> AnyhowResult<()> { - let cookie_header = read_to_trimmed_string("/Users/bt/secrets/midjourney/cookie.txt")?; - - let result = get_index_page_html(GetIndexPageRequest { - cookie_header, - hostname: MidjourneyHostname::Standard, - }).await?; - - println!("Response: {:?}\n\n", result); - - assert_eq!(1, 2); - - Ok(()) - } -} diff --git a/crates/api_clients/midjourney_client/src/endpoints/imagine.rs b/crates/api_clients/midjourney_client/src/endpoints/imagine.rs deleted file mode 100644 index 35ea862e20..0000000000 --- a/crates/api_clients/midjourney_client/src/endpoints/imagine.rs +++ /dev/null @@ -1,251 +0,0 @@ -use crate::client::midjourney_hostname::MidjourneyHostname; -use crate::credentials::midjourney_user_id::MidjourneyUserId; -use crate::error::midjourney_api_error::MidjourneyApiError; -use crate::error::midjourney_client_error::MidjourneyClientError; -use crate::error::midjourney_error::MidjourneyError; -use cloudflare_errors::filter_cloudflare_errors::filter_cloudflare_errors; -use log::error; -use serde::Deserialize; -use wreq::Client; -use wreq_util::Emulation; - -const DEFAULT_PAGE_SIZE : u64 = 1000; - -/// This returns Midjourney's job/media list -pub struct ImagineRequest<'a> { - pub hostname: MidjourneyHostname, - pub cookie_header: String, - pub user_id: &'a MidjourneyUserId, - pub page_size: Option, -} - -#[derive(Debug, Clone)] -pub struct ImagineResponse { - pub items: Vec, - pub cursor: Option, -} - -#[derive(Debug, Clone)] -pub struct ImagineItem { - pub id: Option, - - /// This is the prompt, e.g. - /// `cute puppy wearing a polar bear suit --ar 4:3 --raw --v 7.0` - pub full_command: Option, - - pub job_type: Option, -} - -#[derive(Debug, Clone)] -pub enum MidjourneyJobType { - V6Diffusion, - V6p1Diffusion, - V6p1RawDiffusion, - V7Diffusion, - V7DraftDiffusion, - V7DraftRawDiffusion, - V7RawDiffusion, - Vid11I2vRenderAJointVideo, - Vid11I2vRenderBJointVideo, - Vid11I2vStartEndAVideo, - Vid11I2vStartEndBVideo, - Other(String), -} - -impl MidjourneyJobType { - pub fn from_str(s: &str) -> MidjourneyJobType { - match s { - "v6_diffusion" => MidjourneyJobType::V6Diffusion, - "v6-1_diffusion" => MidjourneyJobType::V6p1Diffusion, - "v6-1_raw_diffusion" => MidjourneyJobType::V6p1RawDiffusion, - "v7_diffusion" => MidjourneyJobType::V7Diffusion, - "v7_draft_diffusion" => MidjourneyJobType::V7DraftDiffusion, - "v7_draft_raw_diffusion" => MidjourneyJobType::V7DraftRawDiffusion, - "v7_raw_diffusion" => MidjourneyJobType::V7RawDiffusion, - "vid_1.1_i2v_render_a_joint_video" => MidjourneyJobType::Vid11I2vRenderAJointVideo, - "vid_1.1_i2v_render_b_joint_video" => MidjourneyJobType::Vid11I2vRenderBJointVideo, - "vid_1.1_i2v_start_end_a_video" => MidjourneyJobType::Vid11I2vStartEndAVideo, - "vid_1.1_i2v_start_end_b_video" => MidjourneyJobType::Vid11I2vStartEndBVideo, - other => MidjourneyJobType::Other(other.to_string()), - } - } -} - -pub async fn imagine(req: ImagineRequest<'_>) -> Result { - let cookie_header = req.cookie_header.trim(); - - if cookie_header.len() < 20 { - error!("Cookie header is too short (len: {}): {}", cookie_header.len(), cookie_header); - return Err(MidjourneyClientError::CookieTooShort.into()); - } - - let page_size = req.page_size.unwrap_or(DEFAULT_PAGE_SIZE); - - let referer = format!("https://{}/imagine", req.hostname.as_str()); - - let url = format!("https://{}/api/imagine?user_id={}&page_size={}", - req.hostname.as_str(), - req.user_id.as_str(), - page_size, - ); - - let client = Client::builder() - .emulation(Emulation::Firefox139) - .build() - .map_err(|err| MidjourneyClientError::WreqError(err))?; - - // NB: missing headers that were in the browser request: - // -H 'sec-ch-ua-platform: "macOS"' \ - // -H 'sec-ch-ua: "Not)A;Brand";v="8", "Chromium";v="138", "Google Chrome";v="138"' \ - - let mut http_request = client.get(url) - .header("cookie", cookie_header) - .header("Referer", &referer) - .header("Referrer-Policy", "origin-when-cross-origin") - .header("accept", "*/*") - .header("accept-encoding", "gzip, deflate, br, zstd") - .header("accept-language", "en-US,en;q=0.8") - .header("content-type", "application/json") - .header("priority", "u=1, i") - .header("sec-ch-ua-mobile", "?0") - .header("sec-fetch-dest", "empty") - .header("sec-fetch-mode", "cors") - .header("sec-fetch-site", "same-origin") - .header("x-csrf-protection", "1"); - - let http_request = http_request - .build() - .map_err(|err| MidjourneyClientError::WreqError(err))?; - - let response = client.execute(http_request) - .await - .map_err(|e| MidjourneyApiError::NetworkError(e.to_string()))?; - - let status = response.status(); - - let response_body = response.text().await - .map_err(|e| MidjourneyApiError::NetworkError(e.to_string()))?; - - if !status.is_success() { - if let Err(err) = filter_cloudflare_errors(status.as_u16(), &response_body) { - return Err(MidjourneyApiError::CloudflareError(err).into()); - } - } - - /* - { - "data": [ - { - "id": "a2339f14-ff71-43e4-a69f-8da15e7ba871", - "enqueue_time": "2025-08-14T17:21:28.403560+00:00", - "parent_id": null, - "video_segments": null, - "rating": null, - "job_type": "v7_diffusion", - "event_type": "diffusion", - "parent_grid": null, - "full_command": "a modern n64 console", - "batch_size": 4, - "width": 1024, - "height": 1024, - "published": true, - "shown": true, - "user_hidden": false, - "template": null, - "vid_framecount": null - }, - ], - "cursor": "encrypted cursor", - "checkpoint": "encrypted something ???" - } - */ - - - #[derive(Deserialize, Debug)] - #[allow(non_snake_case)] - struct RawImagineResponse { - data: Vec, - cursor: Option, - //pub checkpoint: Option, - } - - #[derive(Deserialize, Debug)] - #[allow(non_snake_case)] - struct RawImagineItem { - // The job id - id: Option, - - // The prompt plus `--` args. - full_command: Option, - - // Number of images, typically 4 - batch_size: Option, - - // Some possible values: - // "v6_diffusion" - // "v7_diffusion" - // "v7_draft_raw_diffusion" - // "v7_raw_diffusion" - // "vid_1.1_i2v_render_b_joint_video", - // "vid_1.1_i2v_start_end_a_video" - // "vid_1.1_i2v_start_end_b_video" - job_type: Option, - - // Some possible values: - // "diffusion" - // "draft" - // "variation" - // "video_diffusion" - // "video_start_end" - event_type: Option, - } - - let response : RawImagineResponse = serde_json::from_str(&response_body) - .map_err(|err| MidjourneyApiError::DeserializationError(err))?; - - Ok(ImagineResponse { - cursor: response.cursor.clone(), - items: response.data - .into_iter() - .map(|item| { - ImagineItem { - id: item.id, - full_command: item.full_command, - job_type: item.job_type.as_ref() - .map(|jt| MidjourneyJobType::from_str(jt)) - } - }).collect(), - }) -} - -#[cfg(test)] -mod tests { - use crate::client::midjourney_hostname::MidjourneyHostname; - use crate::credentials::midjourney_user_id::MidjourneyUserId; - use crate::endpoints::imagine::{imagine, ImagineRequest}; - use errors::AnyhowResult; - use filesys::read_to_trimmed_string::read_to_trimmed_string; - - #[ignore] - #[tokio::test] - async fn test() -> AnyhowResult<()> { - let cookie_header = read_to_trimmed_string("/Users/bt/secrets/midjourney/cookie.txt")?; - let user_id = read_to_trimmed_string("/Users/bt/secrets/midjourney/user_id.txt")?; - let user_id = MidjourneyUserId::from_string(user_id); - - let result = imagine(ImagineRequest { - cookie_header, - hostname: MidjourneyHostname::Standard, - user_id: &user_id, - page_size: None, - }).await?; - - println!("Response: {:?}\n\n", result); - - assert_eq!(1, 2); - - Ok(()) - } -} - - diff --git a/crates/api_clients/midjourney_client/src/endpoints/mod.rs b/crates/api_clients/midjourney_client/src/endpoints/mod.rs deleted file mode 100644 index 6abc6a8e51..0000000000 --- a/crates/api_clients/midjourney_client/src/endpoints/mod.rs +++ /dev/null @@ -1,5 +0,0 @@ -pub mod get_index_page_html; -pub mod imagine; -pub mod storage_list; -pub mod submit_job; -pub mod user_connections; \ No newline at end of file diff --git a/crates/api_clients/midjourney_client/src/endpoints/storage_list.rs b/crates/api_clients/midjourney_client/src/endpoints/storage_list.rs deleted file mode 100644 index 9fb0ad9f43..0000000000 --- a/crates/api_clients/midjourney_client/src/endpoints/storage_list.rs +++ /dev/null @@ -1,147 +0,0 @@ -use crate::client::midjourney_hostname::MidjourneyHostname; -use crate::error::midjourney_api_error::MidjourneyApiError; -use crate::error::midjourney_client_error::MidjourneyClientError; -use crate::error::midjourney_error::MidjourneyError; -use cloudflare_errors::filter_cloudflare_errors::filter_cloudflare_errors; -use log::error; -use serde::Deserialize; -use wreq::Client; -use wreq_util::Emulation; - -/// This endpoint returns the user id -pub struct GetStorageListRequest { - pub hostname: MidjourneyHostname, - pub cookie_header: String, -} - -#[derive(Debug)] -pub struct StorageItem { - // NB: The path contains the user ID. - pub bucket_pathname: Option, - - // NB: Other fields aren't necessary for us right now. -} - -pub async fn storage_list(req: GetStorageListRequest) -> Result, MidjourneyError> { - - let referer = format!("https://{}", req.hostname.as_str()); - - let url = format!("https://{}/api/storage-list", req.hostname.as_str()); - - let client = Client::builder() - .emulation(Emulation::Firefox139) - .build() - .map_err(|err| MidjourneyClientError::WreqError(err))?; - - let cookie_header = req.cookie_header.trim(); - - if cookie_header.len() < 20 { - error!("Cookie header is too short (len: {}): {}", cookie_header.len(), cookie_header); - return Err(MidjourneyClientError::CookieTooShort.into()); - } - - // NB: missing headers that were in the browser request: - // -H 'sec-ch-ua-platform: "macOS"' \ - // -H 'sec-ch-ua: "Not)A;Brand";v="8", "Chromium";v="138", "Google Chrome";v="138"' \ - - let mut http_request = client.get(url) - .header("cookie", cookie_header) - .header("Referer", &referer) - .header("Referrer-Policy", "origin-when-cross-origin") - .header("accept", "*/*") - .header("accept-language", "en-US,en;q=0.8") - .header("content-type", "application/json") - .header("priority", "u=1, i") - .header("sec-ch-ua-mobile", "?0") - .header("sec-fetch-dest", "empty") - .header("sec-fetch-mode", "cors") - .header("sec-fetch-site", "same-origin") - .header("x-csrf-protection", "1"); - - let http_request = http_request - .build() - .map_err(|err| MidjourneyClientError::WreqError(err))?; - - let response = client.execute(http_request) - .await - .map_err(|e| MidjourneyApiError::NetworkError(e.to_string()))?; - - let status = response.status(); - - // if status == 301 { - // for (name, value) in response.headers().iter() { - // println!("- {}: {}", name.as_str(), value.to_str().unwrap()); - // } - // } - - let response_body = &response.text().await - .map_err(|e| MidjourneyApiError::NetworkError(e.to_string()))?; - - if !status.is_success() { - if let Err(err) = filter_cloudflare_errors(status.as_u16(), &response_body) { - return Err(MidjourneyApiError::CloudflareError(err).into()); - } - } - - /* - [ - { - "bucketPathname": "UUID/OTHER_HEX_ENTROPY.png", - "shortUrl": null, - "type": "image-prompt", - "origin": "web", - "timeCreated": TIMESTAMP, - "hidden": false, - "contentType": "image/png", - "state": "loaded" - } - ] - */ - - #[derive(Deserialize, Debug)] - #[allow(non_snake_case)] - struct RawStorageItem { - bucketPathname: Option, - } - - let response : Vec = serde_json::from_str(response_body) - .map_err(|err| MidjourneyApiError::DeserializationError(err))?; - - let items = response - .into_iter() - .map(|r| StorageItem { - bucket_pathname: r.bucketPathname, - }) - .collect::>(); - - Ok(items) -} - -#[cfg(test)] -mod tests { - use crate::client::midjourney_hostname::MidjourneyHostname; - use errors::AnyhowResult; - use filesys::read_to_trimmed_string::read_to_trimmed_string; - use crate::endpoints::storage_list::{storage_list, GetStorageListRequest}; - - #[ignore] - #[tokio::test] - async fn test() -> AnyhowResult<()> { - let cookie_header = read_to_trimmed_string("/Users/bt/secrets/midjourney/cookie.txt")?; - - let result = storage_list(GetStorageListRequest { - cookie_header, - hostname: MidjourneyHostname::Standard, - }).await?; - - println!("Response: {:?}\n\n", result); - - for provider in result { - println!("Provider: {:?}", provider); - } - - assert_eq!(1, 2); - - Ok(()) - } -} diff --git a/crates/api_clients/midjourney_client/src/endpoints/submit_job.rs b/crates/api_clients/midjourney_client/src/endpoints/submit_job.rs deleted file mode 100644 index c1240ee20d..0000000000 --- a/crates/api_clients/midjourney_client/src/endpoints/submit_job.rs +++ /dev/null @@ -1,230 +0,0 @@ -use crate::error::midjourney_api_error::MidjourneyApiError; -use crate::error::midjourney_client_error::MidjourneyClientError; -use crate::error::midjourney_error::MidjourneyError; -use log::{error, warn}; -use serde::{Deserialize, Serialize}; - -use crate::client::midjourney_hostname::MidjourneyHostname; -use cloudflare_errors::filter_cloudflare_errors::filter_cloudflare_errors; -use wreq::Client; -use wreq_util::Emulation; - -pub struct SubmitJobRequest<'a> { - pub prompt: &'a str, - pub channel_id: &'a str, - pub hostname: MidjourneyHostname, - pub cookie_header: String, -} - -#[derive(Debug, Clone)] -pub struct SubmitJobResponse { - /// On success, the job ID is returned. - pub maybe_job_id: Option, - - /// On error, we have a list of error messages. - pub maybe_errors: Option>, -} - -#[derive(Debug, Clone)] -pub struct SubmitJobError { - pub error_type: Option, - pub message: Option, -} - -pub async fn submit_job(req: SubmitJobRequest<'_>) -> Result { - let client = Client::builder() - .emulation(Emulation::Firefox139) - .build() - .map_err(|err| MidjourneyClientError::WreqError(err))?; - - let referer = format!("https://{}", req.hostname.as_str()); - - // NB: Other recent clients use /api/app/submit-jobs, but this appears invalid. - let url = format!("https://{}/api/submit-jobs", req.hostname.as_str()); - - let cookie_header = req.cookie_header.trim(); - - if cookie_header.len() < 20 { - error!("Cookie header is too short (len: {}): {}", cookie_header.len(), cookie_header); - return Err(MidjourneyClientError::CookieTooShort.into()); - } - - let mut http_request = client.post(url) - .header("cookie", cookie_header) - .header("Referer", &referer) - .header("Referrer-Policy", "origin-when-cross-origin") - .header("accept", "*/*") - .header("accept-language", "en-US,en;q=0.8") - .header("content-type", "application/json") - .header("priority", "u=1, i") - .header("sec-ch-ua-mobile", "?0") - .header("sec-fetch-dest", "empty") - .header("sec-fetch-mode", "cors") - .header("sec-fetch-site", "same-origin") - .header("x-csrf-protection", "1"); - - #[derive(Serialize)] - struct F { - mode: String, - private: bool, - } - - #[derive(Serialize)] - #[allow(non_snake_case)] - struct Metadata { - imagePrompts: u8, - imageReferences: u8, - characterReferences: u8, - depthReferences: u8, - lightboxOpen: String, - } - - #[derive(Serialize)] - #[allow(non_snake_case)] - struct RawRequest { - f: F, - channelId: String, - metadata: Metadata, - t: String, - prompt: String, - } - - let body = RawRequest { - f: F { - mode: "fast".to_string(), - private: false, - }, - channelId: req.channel_id.to_string(), - metadata: Metadata { - imagePrompts: 0, - imageReferences: 0, - characterReferences: 0, - depthReferences: 0, - lightboxOpen: "".to_string(), - }, - t: "imagine".to_string(), - prompt: req.prompt.to_string(), - }; - - let http_request = http_request - .json(&body) - .build() - .map_err(|err| MidjourneyClientError::WreqError(err))?; - - let response = client.execute(http_request) - .await - .map_err(|e| MidjourneyApiError::NetworkError(e.to_string()))?; - - let status = response.status(); - - // if status == 301 { - // for (name, value) in response.headers().iter() { - // println!("- {}: {}", name.as_str(), value.to_str().unwrap()); - // } - // } - - let response_body = &response.text().await - .map_err(|e| MidjourneyApiError::NetworkError(e.to_string()))?; - - if !status.is_success() { - if let Err(err) = filter_cloudflare_errors(status.as_u16(), &response_body) { - return Err(MidjourneyApiError::CloudflareError(err).into()); - } - } - - /* - {"success":[ - { - "job_id":"UUID-like-string", - "prompt":"prompt", - "is_queued":false, - "event_type":"diffusion", - "flags":{ - "mode":"fast","visibility":"public" - }, - "meta":{ - "height":1024,"width":1024,"batch_size":4,"parent_id":null,"parent_grid":null - }, - "optimisticJobIndex":0, - "personalization_codes":null - }], - "failure":[]} - */ - - #[derive(Deserialize)] - struct SuccessPayload { - job_id: String, - } - - #[derive(Deserialize)] - struct FailurePayload { - r#type: String, - message: String, - } - - #[derive(Deserialize)] - #[allow(non_snake_case)] - struct RawResponse { - success: Vec, - failure: Option>, - } - - let response = serde_json::from_str::(response_body) - .map_err(|err| MidjourneyApiError::DeserializationError(err))?; - - let maybe_job_id = response.success - .get(0) - .map(|s| s.job_id.clone()); - - if maybe_job_id.is_none() { - warn!("No job id found in body: {:?}", response_body); - } - - let mut maybe_errors = None; - - if let Some(failures) = response.failure.as_ref() { - if !failures.is_empty() { - maybe_errors = Some(failures.iter() - .map(|f| SubmitJobError { - error_type: Some(f.r#type.clone()), - message: Some(f.message.clone()), - }).collect()); - } - } - - Ok(SubmitJobResponse { - maybe_job_id, - maybe_errors, - }) -} - -#[cfg(test)] -mod tests { - use crate::client::midjourney_hostname::MidjourneyHostname; - use crate::endpoints::submit_job::{submit_job, SubmitJobRequest}; - use errors::AnyhowResult; - use filesys::read_to_trimmed_string::read_to_trimmed_string; - - // Get channel id via: - // https://identitytoolkit.googleapis.com/v1/accounts:lookup?key=[TOKEN] - #[ignore] - #[tokio::test] - async fn test() -> AnyhowResult<()> { - let cookie_header = read_to_trimmed_string("/Users/bt/secrets/midjourney/cookie.txt")?; - let channel_id = read_to_trimmed_string("/Users/bt/secrets/midjourney/channel_id.txt")?; - - let result = submit_job(SubmitJobRequest { - prompt: "a modern n64 console", - channel_id: &channel_id, - cookie_header, - hostname: MidjourneyHostname::Standard, - }).await?; - - println!("Response: {:?}", result); - - assert_eq!(1, 2); - - - Ok(()) - } -} diff --git a/crates/api_clients/midjourney_client/src/endpoints/user_connections.rs b/crates/api_clients/midjourney_client/src/endpoints/user_connections.rs deleted file mode 100644 index 5ddaae7c1f..0000000000 --- a/crates/api_clients/midjourney_client/src/endpoints/user_connections.rs +++ /dev/null @@ -1,178 +0,0 @@ -use crate::client::midjourney_hostname::MidjourneyHostname; -use crate::error::midjourney_api_error::MidjourneyApiError; -use crate::error::midjourney_client_error::MidjourneyClientError; -use crate::error::midjourney_error::MidjourneyError; -use cloudflare_errors::filter_cloudflare_errors::filter_cloudflare_errors; -use log::error; -use serde::Deserialize; -use wreq::Client; -use wreq_util::Emulation; - -const USER_CONNECTIONS_URL :&str = "https://www.midjourney.com/api/user-connections"; - -pub struct GetUserConnectionsRequest { - pub hostname: MidjourneyHostname, - pub cookie_header: String, -} - -#[derive(Debug)] -pub struct UserData { - pub provider_id: String, - pub display_name: Option, - pub email: Option, - pub user_id: Option, -} - -#[derive(Debug)] -pub struct Provider { - pub provider_id: String, - pub user_data: Option, - pub is_linked: bool, -} - -pub async fn user_connections(req: GetUserConnectionsRequest) -> Result, MidjourneyError> { - - let referer = format!("https://{}", req.hostname.as_str()); - - let url = format!("https://{}/api/user-connections", req.hostname.as_str()); - - let client = Client::builder() - .emulation(Emulation::Firefox139) - .build() - .map_err(|err| MidjourneyClientError::WreqError(err))?; - - let cookie_header = req.cookie_header.trim(); - - if cookie_header.len() < 20 { - error!("Cookie header is too short (len: {}): {}", cookie_header.len(), cookie_header); - return Err(MidjourneyClientError::CookieTooShort.into()); - } - - // NB: missing headers that were in the browser request: - // -H 'sec-ch-ua-platform: "macOS"' \ - // -H 'sec-ch-ua: "Not)A;Brand";v="8", "Chromium";v="138", "Google Chrome";v="138"' \ - - let mut http_request = client.get(url) - .header("cookie", cookie_header) - .header("Referer", &referer) - .header("Referrer-Policy", "origin-when-cross-origin") - .header("accept", "*/*") - .header("accept-language", "en-US,en;q=0.8") - .header("content-type", "application/json") - .header("priority", "u=1, i") - .header("sec-ch-ua-mobile", "?0") - .header("sec-fetch-dest", "empty") - .header("sec-fetch-mode", "cors") - .header("sec-fetch-site", "same-origin") - .header("x-csrf-protection", "1"); - - let http_request = http_request - .build() - .map_err(|err| MidjourneyClientError::WreqError(err))?; - - let response = client.execute(http_request) - .await - .map_err(|e| MidjourneyApiError::NetworkError(e.to_string()))?; - - let status = response.status(); - - // if status == 301 { - // for (name, value) in response.headers().iter() { - // println!("- {}: {}", name.as_str(), value.to_str().unwrap()); - // } - // } - - let response_body = &response.text().await - .map_err(|e| MidjourneyApiError::NetworkError(e.to_string()))?; - - if !status.is_success() { - if let Err(err) = filter_cloudflare_errors(status.as_u16(), &response_body) { - return Err(MidjourneyApiError::CloudflareError(err).into()); - } - } - - /* - [ - { - "providerId": "google.com", - "userData": { - "providerId": "google.com", - "displayName": "John Doe", - "email": "john.doe@gmail.com", - "userId": "123456789000000001", - }, - "isLinked": true - }, - { - "providerId": "discord.com", - "isLinked": false - } - ] - */ - - #[derive(Deserialize, Debug)] - #[allow(non_snake_case)] - struct RawProviderUserData { - providerId: String, - displayName: Option, - email: Option, - userId: Option, - } - - #[derive(Deserialize, Debug)] - #[allow(non_snake_case)] - struct RawProvider { - providerId: String, - userData: Option, - isLinked: bool, - } - - let response : Vec = serde_json::from_str(response_body) - .map_err(|err| MidjourneyApiError::DeserializationError(err))?; - - let providers = response - .into_iter() - .map(|r| Provider { - provider_id: r.providerId, - user_data: r.userData.map(|u| UserData { - provider_id: u.providerId, - display_name: u.displayName, - email: u.email, - user_id: u.userId, - }), - is_linked: r.isLinked, - }) - .collect::>(); - - Ok(providers) -} - -#[cfg(test)] -mod tests { - use crate::client::midjourney_hostname::MidjourneyHostname; - use crate::endpoints::user_connections::{user_connections, GetUserConnectionsRequest}; - use errors::AnyhowResult; - use filesys::read_to_trimmed_string::read_to_trimmed_string; - - #[ignore] - #[tokio::test] - async fn test() -> AnyhowResult<()> { - let cookie_header = read_to_trimmed_string("/Users/bt/secrets/midjourney/cookie.txt")?; - - let result = user_connections(GetUserConnectionsRequest { - cookie_header, - hostname: MidjourneyHostname::Standard, - }).await?; - - println!("Response: {:?}\n\n", result); - - for provider in result { - println!("Provider: {:?}", provider); - } - - assert_eq!(1, 2); - - Ok(()) - } -} - diff --git a/crates/api_clients/midjourney_client/src/error/midjourney_api_error.rs b/crates/api_clients/midjourney_client/src/error/midjourney_api_error.rs deleted file mode 100644 index 59081f7d7e..0000000000 --- a/crates/api_clients/midjourney_client/src/error/midjourney_api_error.rs +++ /dev/null @@ -1,117 +0,0 @@ -use cloudflare_errors::cloudflare_error::CloudflareError; -use errors::AnyhowError; -use std::error::Error; -use std::fmt::{Display, Formatter}; -use std::io; - -#[derive(Debug)] -pub enum MidjourneyApiError { - /// There was no user ID in an otherwise valid-looking response. - NoUserId, - - /// No user props in index HTML payload. - /// We need this for the user ID and the websocket token. - NoUserProps, - - /// No initialAuthUser in the index HTML payload. - /// We need this for the user ID and the websocket token. - NoInitialAuthUser, - - /// 400. The request was invalid. - InvalidRequest(String), - - /// 401. The request was not authorized. - Unauthorized(String), - - /// 403. The request was forbidden. - Forbidden(String), - - /// 404. The requested resource was not found. - NotFound(String), - - /// 429. Too many requests. - TooManyRequests(String), - - /// 500. An internal server error occurred. - InternalServerError { - body: String, - backend_hostname: Option, - }, - - /// Eg. when downloading images - UnknownHttpFailure { - status_code: u16, - body: String, - }, - - /// Cloudflare errors. - CloudflareError(CloudflareError), - - /// A deserialization error with the response. - DeserializationError(serde_json::Error), - - /// The request timed out. - Timeout(String), - - /// A network error occurred. - NetworkError(String), - - /// An error doing file I/O (on our side) - IoError(io::Error), - - /// Another type of error. - Other(AnyhowError), -} - -impl Error for MidjourneyApiError {} - -impl Display for MidjourneyApiError { - fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { - match self { - // Response body errors - Self::NoUserId => write!(f, "No user ID found in the response body."), - Self::NoUserProps => write!(f, "No user properties found in the index HTML payload."), - Self::NoInitialAuthUser => write!(f, "No initialAuthUser in the index HTML payload."), - // Server response code errors - Self::InvalidRequest(msg) => write!(f, "Invalid request: {}", msg), - Self::Unauthorized(msg) => write!(f, "Unauthorized: {}", msg), - Self::Forbidden(msg) => write!(f, "Forbidden: {}", msg), - Self::NotFound(msg) => write!(f, "Not found: {}", msg), - Self::TooManyRequests(msg) => write!(f, "Too many requests: {}", msg), - Self::InternalServerError {body, backend_hostname} => - write!(f, "Internal Server Error; backend hostname: {:?} ; body: {}; ", backend_hostname, body), - Self::UnknownHttpFailure {status_code, body} => - write!(f, "Unknown HTTP failure; status code: {}; body: {}", status_code, body), - // Deserialization errors - // Server response handling errors - Self::DeserializationError(error) => write!(f, "Deserialization error: {}", error), - // Network errors - Self::Timeout(msg) => write!(f, "Timeout: {}", msg), - Self::NetworkError(msg) => write!(f, "Network error: {}", msg), - // Cloudflare errors - Self::CloudflareError(error) => write!(f, "Cloudflare Error: {}", error), - // I/O errors - Self::IoError(error) => write!(f, "IO error: {}", error), - // Other - Self::Other(error) => write!(f, "Other error: {}", error), - } - } -} - -impl From for MidjourneyApiError { - fn from(error: serde_json::Error) -> Self { - Self::DeserializationError(error) - } -} - -impl From for MidjourneyApiError { - fn from(error: io::Error) -> Self { - Self::IoError(error) - } -} - -impl From for MidjourneyApiError { - fn from(error: CloudflareError) -> Self { - Self::CloudflareError(error) - } -} diff --git a/crates/api_clients/midjourney_client/src/error/midjourney_client_error.rs b/crates/api_clients/midjourney_client/src/error/midjourney_client_error.rs deleted file mode 100644 index de74e8e1cd..0000000000 --- a/crates/api_clients/midjourney_client/src/error/midjourney_client_error.rs +++ /dev/null @@ -1,71 +0,0 @@ -use std::error::Error; -use std::fmt::{Display, Formatter}; -use std::io; -use std::path::PathBuf; - -/// An error arising from the client, either before or after the request is sent. -#[derive(Debug)] -pub enum MidjourneyClientError { - /// The cookie was too short to be valid. - CookieTooShort, - - /// Tried to look up an image out of range [0,4) - InvalidImageIndex, - - /// Could not determine the filetype for the file. - FileTypeNotKnown(PathBuf), - - /// Could not handle the file type. - FileTypeNotHandled(PathBuf), - - /// An error doing file I/O (on our side) - IoError(io::Error), - - // /// An error setting up the client - // ReqwestError(reqwest::Error), - WreqError(wreq::Error), - - /// A serialization error with the request. - SerializationError(serde_json::Error), -} - -impl Error for MidjourneyClientError {} - -impl Display for MidjourneyClientError { - fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { - match self { - Self::CookieTooShort => write!(f, "The cookie header is too short to be valid."), - Self::InvalidImageIndex => write!(f, "The image index is out of range. Valid range is [0, 4)."), - Self::FileTypeNotKnown(path) => write!(f, "Could not determine the filetype for the file: {:?}", path), - Self::FileTypeNotHandled(path) => write!(f, "Could not handle the file type for the file: {:?}", path), - Self::IoError(err) => write!(f, "IO error: {}", err), - //Self::ReqwestError(err) => write!(f, "Reqwest client error: {}", err), - Self::WreqError(err) => write!(f, "Wreq client error: {}", err), - Self::SerializationError(err) => write!(f, "Request serialization error: {}", err), - } - } -} - -impl From for MidjourneyClientError { - fn from(error: io::Error) -> Self { - Self::IoError(error) - } -} - -impl From for MidjourneyClientError { - fn from(error: serde_json::Error) -> Self { - Self::SerializationError(error) - } -} - -/*impl From for MidjourneyClientError { - fn from(error: reqwest::Error) -> Self { - Self::ReqwestError(error) - } -}*/ - -impl From for MidjourneyClientError { - fn from(error: wreq::Error) -> Self { - Self::WreqError(error) - } -} diff --git a/crates/api_clients/midjourney_client/src/error/midjourney_error.rs b/crates/api_clients/midjourney_client/src/error/midjourney_error.rs deleted file mode 100644 index 61b6490ff7..0000000000 --- a/crates/api_clients/midjourney_client/src/error/midjourney_error.rs +++ /dev/null @@ -1,32 +0,0 @@ -use crate::error::midjourney_api_error::MidjourneyApiError; -use crate::error::midjourney_client_error::MidjourneyClientError; -use std::error::Error; - -#[derive(Debug)] -pub enum MidjourneyError { - Api(MidjourneyApiError), - Client(MidjourneyClientError), -} - -impl Error for MidjourneyError {} - -impl std::fmt::Display for MidjourneyError { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - Self::Api(e) => write!(f, "Midjourney API error: {:?}", e), - Self::Client(e) => write!(f, "Midjourney Client error: {:?}", e), - } - } -} - -impl From for MidjourneyError { - fn from(error: MidjourneyApiError) -> Self { - Self::Api(error) - } -} - -impl From for MidjourneyError { - fn from(error: MidjourneyClientError) -> Self { - Self::Client(error) - } -} diff --git a/crates/api_clients/midjourney_client/src/error/mod.rs b/crates/api_clients/midjourney_client/src/error/mod.rs deleted file mode 100644 index ceefb7b1b1..0000000000 --- a/crates/api_clients/midjourney_client/src/error/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub mod midjourney_error; -pub mod midjourney_api_error; -pub mod midjourney_client_error; \ No newline at end of file diff --git a/crates/api_clients/midjourney_client/src/lib.rs b/crates/api_clients/midjourney_client/src/lib.rs deleted file mode 100644 index 1adf93044d..0000000000 --- a/crates/api_clients/midjourney_client/src/lib.rs +++ /dev/null @@ -1,8 +0,0 @@ -//! A midjourney API client. - -pub mod client; -pub mod credentials; -pub mod endpoints; -pub mod error; -pub mod recipes; -pub mod utils; diff --git a/crates/api_clients/midjourney_client/src/recipes/channel_id.rs b/crates/api_clients/midjourney_client/src/recipes/channel_id.rs deleted file mode 100644 index b9f876cf3c..0000000000 --- a/crates/api_clients/midjourney_client/src/recipes/channel_id.rs +++ /dev/null @@ -1,20 +0,0 @@ -use crate::credentials::midjourney_user_id::MidjourneyUserId; - -#[derive(Debug, Clone)] -pub enum ChannelId { - /// Channel based on the user ID. - /// This is what Midjourney uses by default. - UserId(MidjourneyUserId), - - // Bare string ID - Raw(String), -} - -impl ChannelId { - pub fn to_string(&self) -> String { - match self { - Self::UserId(user_id) => format!("singleplayer_{}", user_id.0), - Self::Raw(id) => id.clone(), - } - } -} diff --git a/crates/api_clients/midjourney_client/src/recipes/get_midjourney_user_id_from_storage.rs b/crates/api_clients/midjourney_client/src/recipes/get_midjourney_user_id_from_storage.rs deleted file mode 100644 index 1c0a112452..0000000000 --- a/crates/api_clients/midjourney_client/src/recipes/get_midjourney_user_id_from_storage.rs +++ /dev/null @@ -1,52 +0,0 @@ -use crate::client::midjourney_hostname::MidjourneyHostname; -use crate::credentials::midjourney_user_id::MidjourneyUserId; -use crate::endpoints::storage_list::{storage_list, GetStorageListRequest}; -use crate::error::midjourney_api_error::MidjourneyApiError; -use crate::error::midjourney_error::MidjourneyError; - -pub struct GetMidjourneyUserIdRequest { - pub hostname: MidjourneyHostname, - pub cookie_header: String, -} - -pub async fn get_midjourney_user_id_from_storage(req: GetMidjourneyUserIdRequest) -> Result { - let items = storage_list(GetStorageListRequest { - hostname: req.hostname, - cookie_header: req.cookie_header, - }).await?; - - let user_id = items - .into_iter() - .find_map(|item| item.bucket_pathname) - .and_then(|path| path.split('/').next().map(|id| id.to_owned())) - .map(|id| MidjourneyUserId(id.to_string())) - .ok_or(MidjourneyApiError::NoUserId)?; - - Ok(user_id) -} - -#[cfg(test)] -mod tests { - use crate::client::midjourney_hostname::MidjourneyHostname; - use crate::recipes::get_midjourney_user_id_from_storage::{get_midjourney_user_id_from_storage, GetMidjourneyUserIdRequest}; - use errors::AnyhowResult; - use filesys::read_to_trimmed_string::read_to_trimmed_string; - - #[ignore] - #[tokio::test] - async fn test() -> AnyhowResult<()> { - let cookie_header = read_to_trimmed_string("/Users/bt/secrets/midjourney/cookie.txt")?; - - let result = get_midjourney_user_id_from_storage(GetMidjourneyUserIdRequest { - cookie_header, - hostname: MidjourneyHostname::Standard, - }).await?; - - println!("Response: {:?}\n\n", result); - - assert_eq!(1, 2); - - Ok(()) - } -} - diff --git a/crates/api_clients/midjourney_client/src/recipes/get_user_info.rs b/crates/api_clients/midjourney_client/src/recipes/get_user_info.rs deleted file mode 100644 index f1fee8f084..0000000000 --- a/crates/api_clients/midjourney_client/src/recipes/get_user_info.rs +++ /dev/null @@ -1,153 +0,0 @@ -use crate::client::midjourney_hostname::MidjourneyHostname; -use crate::credentials::midjourney_user_id::MidjourneyUserId; -use crate::endpoints::get_index_page_html::{get_index_page_html, GetIndexPageRequest}; -use crate::error::midjourney_api_error::MidjourneyApiError; -use crate::error::midjourney_error::MidjourneyError; -use dom_query::Document; -use serde::Deserialize; - -pub struct GetUserInfoRequest { - pub hostname: MidjourneyHostname, - pub cookie_header: String, -} - -#[derive(Debug, Clone)] -pub struct GetUserInfoResponse { - pub user_id: Option, - pub email: Option, - pub websocket_token: Option, -} - -pub async fn get_user_info(req: GetUserInfoRequest) -> Result { - let index_html = get_index_page_html(GetIndexPageRequest { - hostname: req.hostname, - cookie_header: req.cookie_header, - }).await?; - - /* - - */ - - let document = Document::from(index_html); - let maybe_nodes = document.select("script[id=initialProps]"); - - let node = match maybe_nodes.get(0) { - Some(node) => node, - None => { - return Err(MidjourneyApiError::NoUserProps.into()); - } - }; - - let inner_json = node.inner_html().to_string(); - - #[derive(Deserialize, Debug)] - #[allow(non_snake_case)] - struct RawAuthUser { - // NB: The Midjourney user id. - id: Option, - email: Option, - websocketToken: Option, - } - - #[derive(Deserialize, Debug)] - #[allow(non_snake_case)] - struct RawBody { - initialAuthUser: Option, - } - - let response : RawBody = serde_json::from_str(&inner_json) - .map_err(|err| MidjourneyApiError::DeserializationError(err))?; - - let props = match response.initialAuthUser { - Some(props) => props, - None => { - return Err(MidjourneyApiError::NoInitialAuthUser.into()); - } - }; - - Ok(GetUserInfoResponse { - user_id: props.id - .map(|id| MidjourneyUserId::from_string(id)), - email: props.email - .map(|email| email.to_string()), - websocket_token: props.websocketToken - .map(|email| email.to_string()), - }) -} - -#[cfg(test)] -mod tests { - use crate::client::midjourney_hostname::MidjourneyHostname; - use crate::recipes::get_user_info::{get_user_info, GetUserInfoRequest}; - use errors::AnyhowResult; - use filesys::read_to_trimmed_string::read_to_trimmed_string; - - #[ignore] - #[tokio::test] - async fn test() -> AnyhowResult<()> { - let cookie_header = read_to_trimmed_string("/Users/bt/secrets/midjourney/cookie.txt")?; - - let result = get_user_info(GetUserInfoRequest { - cookie_header, - hostname: MidjourneyHostname::Standard, - }).await?; - - println!("Response: {:?}\n\n", result); - - assert_eq!(1, 2); - - Ok(()) - } -} - diff --git a/crates/api_clients/midjourney_client/src/recipes/mod.rs b/crates/api_clients/midjourney_client/src/recipes/mod.rs deleted file mode 100644 index 7ec937df23..0000000000 --- a/crates/api_clients/midjourney_client/src/recipes/mod.rs +++ /dev/null @@ -1,4 +0,0 @@ -mod get_midjourney_user_id_from_storage; -pub mod channel_id; -pub mod get_user_info; -pub mod text_to_image; \ No newline at end of file diff --git a/crates/api_clients/midjourney_client/src/recipes/text_to_image.rs b/crates/api_clients/midjourney_client/src/recipes/text_to_image.rs deleted file mode 100644 index 77d15bce6f..0000000000 --- a/crates/api_clients/midjourney_client/src/recipes/text_to_image.rs +++ /dev/null @@ -1,49 +0,0 @@ -use crate::client::midjourney_hostname::MidjourneyHostname; -use crate::endpoints::submit_job::{submit_job, SubmitJobRequest}; -use crate::error::midjourney_error::MidjourneyError; -use crate::recipes::channel_id::ChannelId; - -pub struct TextToImageRequest<'a> { - pub prompt: &'a str, - pub channel_id: &'a ChannelId, - pub hostname: MidjourneyHostname, - pub cookie_header: String, -} - -#[derive(Debug, Clone)] -pub struct TextToImageResponse { - /// On success, the job ID is returned. - pub maybe_job_id: Option, - - /// On error, we have a list of error messages. - pub maybe_errors: Option>, -} - -#[derive(Debug, Clone)] -pub struct TextToImageError { - pub error_type: Option, - pub message: Option, -} - -/// Slightly more ergonomic text-to-image API. -/// As we add more `submit_job()` cases, we'll keep this simple. -pub async fn text_to_image(req: TextToImageRequest<'_>) -> Result { - let channel_id = req.channel_id.to_string(); - - let response = submit_job(SubmitJobRequest { - prompt: req.prompt, - channel_id: &channel_id, - hostname: req.hostname, - cookie_header: req.cookie_header, - }).await?; - - Ok(TextToImageResponse { - maybe_job_id: response.maybe_job_id, - maybe_errors: response.maybe_errors.map(|errs| { - errs.into_iter().map(|e| TextToImageError { - error_type: e.error_type, - message: e.message, - }).collect() - }), - }) -} diff --git a/crates/api_clients/midjourney_client/src/utils/get_image_url.rs b/crates/api_clients/midjourney_client/src/utils/get_image_url.rs deleted file mode 100644 index 81116e8c74..0000000000 --- a/crates/api_clients/midjourney_client/src/utils/get_image_url.rs +++ /dev/null @@ -1,9 +0,0 @@ -use crate::error::midjourney_client_error::MidjourneyClientError; -use crate::error::midjourney_error::MidjourneyError; - -pub fn get_image_url(job_id: &str, image_index: u8) -> Result { - if image_index > 3 { - return Err(MidjourneyClientError::InvalidImageIndex.into()) - } - Ok(format!("https://cdn.midjourney.com/{}/0_{}.png", job_id, image_index)) -} diff --git a/crates/api_clients/midjourney_client/src/utils/image_downloader_client.rs b/crates/api_clients/midjourney_client/src/utils/image_downloader_client.rs deleted file mode 100644 index c5e3720353..0000000000 --- a/crates/api_clients/midjourney_client/src/utils/image_downloader_client.rs +++ /dev/null @@ -1,70 +0,0 @@ -use crate::error::midjourney_api_error::MidjourneyApiError; -use crate::error::midjourney_client_error::MidjourneyClientError; -use crate::error::midjourney_error::MidjourneyError; -use crate::utils::get_image_url::get_image_url; -use cloudflare_errors::filter_cloudflare_errors::filter_cloudflare_errors; -use wreq::Client; -use wreq_util::Emulation; - -#[derive(Clone)] -pub struct ImageDownloaderClient { - client: Client, -} - -impl ImageDownloaderClient { - pub fn create() -> Result { - Ok(Self { - client: Client::builder() - .emulation(Emulation::Firefox139) - .build() - .map_err(|err| MidjourneyClientError::WreqError(err))? - }) - } - - pub async fn download_image(&self, job_id: &str, image_index: u8) -> anyhow::Result, MidjourneyError> { - let url = get_image_url(job_id, image_index)?; - - // TODO: Cookies - // TODO: Cache control headers? - let mut http_request = self.client.get(url) - //.header("Referrer-Policy", "origin-when-cross-origin") - //.header("content-type", "application/json") - //.header("sec-fetch-user", "?1") - //.header("upgrade-insecure-requests", "1"); - .header("Referrer", "https://www.midjourney.com/") - .header("accept", "image/avif,image/webp,image/apng,image/svg+xml,image/*,*/*;q=0.8") - .header("accept-language", "en-US,en;q=0.8") - .header("priority", "i") - .header("sec-ch-ua-mobile", "?0") - .header("sec-fetch-dest", "image") - .header("sec-fetch-mode", "no-cors") - .header("sec-fetch-site", "same-site"); - - let http_request = http_request - .build() - .map_err(|err| MidjourneyClientError::WreqError(err))?; - - let response = self.client.execute(http_request) - .await - .map_err(|e| MidjourneyApiError::NetworkError(e.to_string()))?; - - let status = response.status(); - - let response_bytes = response.bytes().await - .map_err(|e| MidjourneyApiError::NetworkError(e.to_string()))?; - - if !status.is_success() { - let response_body = String::from_utf8_lossy(&response_bytes).to_string(); - if let Err(err) = filter_cloudflare_errors(status.as_u16(), &response_body) { - return Err(MidjourneyApiError::CloudflareError(err).into()); - } - - return Err(MidjourneyApiError::UnknownHttpFailure { - status_code: status.as_u16(), - body: response_body, - }.into()); - } - - Ok(response_bytes.to_vec()) - } -} diff --git a/crates/api_clients/midjourney_client/src/utils/mod.rs b/crates/api_clients/midjourney_client/src/utils/mod.rs deleted file mode 100644 index 9f61b7f98a..0000000000 --- a/crates/api_clients/midjourney_client/src/utils/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod get_image_url; -pub mod image_downloader_client; \ No newline at end of file diff --git a/crates/api_clients/openai_sora_client/Cargo.toml b/crates/api_clients/openai_sora_client/Cargo.toml deleted file mode 100644 index 4a04e9ed5f..0000000000 --- a/crates/api_clients/openai_sora_client/Cargo.toml +++ /dev/null @@ -1,46 +0,0 @@ -[package] -name = "openai_sora_client" -edition = "2024" -version = "0.0.1" -publish = false - -[package.metadata.cargo-udeps.ignore] -normal = ["workspace-build-acceleration"] - -[lib] -name = "openai_sora_client" -path = "src/lib.rs" - -[dependencies] -# Workspace hack (faster compile times) -workspace-build-acceleration.workspace = true - -# Internal -errors.workspace = true -uuid_utils.workspace = true - -# External -anyhow.workspace = true -base64.workspace = true -chrono.workspace = true -cloudflare_errors.workspace = true -cookie.workspace = true -log.workspace = true -once_cell.workspace = true -rand.workspace = true -#reqwest = { workspace = true, features = ["multipart", "gzip"] } -serde.workspace = true -serde_derive.workspace = true -serde_json.workspace = true -sha3.workspace = true -thiserror.workspace = true -#tokio.workspace = true -toml.workspace = true -url.workspace = true - -tokio = { version = "1", features = ["full"] } -wreq-util.workspace = true -wreq.workspace = true - -[dev-dependencies] -test_utils = { path = "../../testing/test_utils" } diff --git a/crates/api_clients/openai_sora_client/src/constants/mod.rs b/crates/api_clients/openai_sora_client/src/constants/mod.rs deleted file mode 100644 index e4782e128e..0000000000 --- a/crates/api_clients/openai_sora_client/src/constants/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub (crate) mod user_agent; \ No newline at end of file diff --git a/crates/api_clients/openai_sora_client/src/constants/user_agent.rs b/crates/api_clients/openai_sora_client/src/constants/user_agent.rs deleted file mode 100644 index 092f804529..0000000000 --- a/crates/api_clients/openai_sora_client/src/constants/user_agent.rs +++ /dev/null @@ -1,22 +0,0 @@ - -// TODO: enum UserAgent { Mac, Linux, Windows } which maps to these. - -/// This user agent is tied to the sentinel generation. -/// If we need to change it, we may need to change sentinel generation too. -pub (crate) const CLIENT_USER_AGENT: &str = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36"; - - -// NB: from sentinel token request - -// /// This user agent is tied to the sentinel generation. If we need to change it, we may need to change sentinel generation too. -// const USER_AGENT : &str = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36"; - -// NB: from image gen request - -// /// This user agent is tied to the sentinel generation. If we need to change it, we may need to change sentinel generation too. -// //const USER_AGENT : &str = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36"; - -// Previous job status user agent -// const USER_AGENT : &str = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36"; - -// NB: image gen status - -// /// This user agent is tied to the sentinel generation. If we need to change it, we may need to change sentinel generation too. -// pub (crate) const USER_AGENT: &str = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36"; diff --git a/crates/api_clients/openai_sora_client/src/creds/mod.rs b/crates/api_clients/openai_sora_client/src/creds/mod.rs deleted file mode 100644 index 1cea80d0bc..0000000000 --- a/crates/api_clients/openai_sora_client/src/creds/mod.rs +++ /dev/null @@ -1,6 +0,0 @@ -pub mod sora_cookies; -pub mod sora_credential_builder; -pub mod sora_credential_set; -pub mod sora_jwt_bearer_token; -pub mod sora_sentinel; -pub mod sora_sentinel_token; \ No newline at end of file diff --git a/crates/api_clients/openai_sora_client/src/creds/sora_cookies.rs b/crates/api_clients/openai_sora_client/src/creds/sora_cookies.rs deleted file mode 100644 index 5ff387b645..0000000000 --- a/crates/api_clients/openai_sora_client/src/creds/sora_cookies.rs +++ /dev/null @@ -1,25 +0,0 @@ -/// Cookies are the credential that are always required. -/// You can mint a JWT bearer token with just the cookies. - -#[derive(Clone)] -pub struct SoraCookies { - cookies: String, -} - -impl SoraCookies { - pub fn new(cookies: String) -> Self { - SoraCookies { cookies } - } - - pub fn as_str(&self) -> &str { - &self.cookies - } - - pub fn as_bytes(&self) -> &[u8] { - self.cookies.as_bytes() - } - - pub fn to_string(&self) -> String { - self.cookies.clone() - } -} diff --git a/crates/api_clients/openai_sora_client/src/creds/sora_credential_builder.rs b/crates/api_clients/openai_sora_client/src/creds/sora_credential_builder.rs deleted file mode 100644 index a23cbfc27b..0000000000 --- a/crates/api_clients/openai_sora_client/src/creds/sora_credential_builder.rs +++ /dev/null @@ -1,99 +0,0 @@ -use crate::creds::sora_cookies::SoraCookies; -use crate::creds::sora_credential_set::SoraCredentialSet; -use crate::creds::sora_jwt_bearer_token::SoraJwtBearerToken; -use crate::creds::sora_sentinel::SoraSentinel; -use crate::creds::sora_sentinel_token::SoraSentinelToken; -use crate::error::sora_client_error::SoraClientError; -use crate::error::sora_error::SoraError; - -pub struct SoraCredentialBuilder { - cookies: Option, - - jwt_bearer_token: Option, - - #[deprecated(note="use sora_sentinel_token instead")] - sora_sentinel: Option, - - /// This is the newer sentinel token. Gradually phase out the older one. - sora_sentinel_token: Option, -} - -impl SoraCredentialBuilder { - pub fn new() -> Self { - SoraCredentialBuilder { - cookies: None, - jwt_bearer_token: None, - sora_sentinel: None, - sora_sentinel_token: None, - } - } - - // Consuming methods - - pub fn with_cookies(mut self, cookies: &str) -> Self { - self.cookies = Some(cookies.to_string()); - self - } - - pub fn with_jwt_bearer_token(mut self, token: &str) -> Self { - self.jwt_bearer_token = Some(token.to_string()); - self - } - - pub fn with_sora_sentinel(mut self, sentinel: &str) -> Self { - self.sora_sentinel = Some(sentinel.to_string()); - self - } - - pub fn with_sora_sentinel_token(mut self, sentinel_token: &SoraSentinelToken) -> Self { - self.sora_sentinel_token = Some(sentinel_token.clone()); - self - } - - // Mutable methods - - pub fn set_cookies(&mut self, cookies: &str) { - self.cookies = Some(cookies.to_string()); - } - - pub fn set_jwt_bearer_token(&mut self, token: &str) { - self.jwt_bearer_token = Some(token.to_string()); - } - - pub fn set_sora_sentinel(&mut self, sentinel: &str) { - self.sora_sentinel = Some(sentinel.to_string()); - } - - pub fn set_sora_sentinel_token(&mut self, sentinel_token: &SoraSentinelToken) { - self.sora_sentinel_token = Some(sentinel_token.clone()); - } - - pub fn build(self) -> Result { - let cookies = match self.cookies { - Some(c) => SoraCookies::new(c), - None => return Err(SoraClientError::SoraCredentialBuilderError("no cookies provided").into()), - }; - - let jwt_bearer_token = match self.jwt_bearer_token { - Some(t) => Some(SoraJwtBearerToken::new(t)?), - None => None, - }; - - let sora_sentinel = match self.sora_sentinel { - Some(s) => Some(SoraSentinel::new(s)), - None => None, - }; - - let sora_sentinel_token = match self.sora_sentinel_token { - Some(s) => Some(s), - None => None, - }; - - Ok(SoraCredentialSet { - cookies, - jwt_bearer_token, - sora_sentinel, - sora_sentinel_token, - }) - } -} diff --git a/crates/api_clients/openai_sora_client/src/creds/sora_credential_set.rs b/crates/api_clients/openai_sora_client/src/creds/sora_credential_set.rs deleted file mode 100644 index 5f885e6444..0000000000 --- a/crates/api_clients/openai_sora_client/src/creds/sora_credential_set.rs +++ /dev/null @@ -1,63 +0,0 @@ -use crate::creds::sora_cookies::SoraCookies; -use crate::creds::sora_credential_builder::SoraCredentialBuilder; -use crate::creds::sora_jwt_bearer_token::SoraJwtBearerToken; -use crate::creds::sora_sentinel::SoraSentinel; -use crate::creds::sora_sentinel_token::SoraSentinelToken; - -#[derive(Clone)] -pub struct SoraCredentialSet { - pub cookies: SoraCookies, - pub jwt_bearer_token: Option, - - #[deprecated(note="use sora_sentinel_token instead")] - pub sora_sentinel: Option, - - // NB: This is the newer sentinel token. Gradually phase out the older one. - pub sora_sentinel_token: Option, -} - -impl SoraCredentialSet { - pub fn initialize( - cookies: SoraCookies, - bearer: Option, - sentinel: Option, - sentinel_token: Option, - ) -> Self { - Self { - cookies, - jwt_bearer_token: bearer, - sora_sentinel: sentinel, - sora_sentinel_token: sentinel_token, - } - } - - pub fn initialize_with_just_cookies(cookies: SoraCookies) -> Self { - SoraCredentialSet { - cookies, - jwt_bearer_token: None, - sora_sentinel: None, - sora_sentinel_token: None, - } - } - - pub fn initialize_with_just_cookies_str(cookies: &str) -> Self { - Self::initialize_with_just_cookies( - SoraCookies::new(cookies.to_string()), - ) - } - - pub fn to_builder(&self) -> SoraCredentialBuilder { - let mut builder = SoraCredentialBuilder::new() - .with_cookies(self.cookies.as_str()); - if let Some(bearer) = &self.jwt_bearer_token { - builder = builder.with_jwt_bearer_token(bearer.as_str()); - } - if let Some(sentinel) = &self.sora_sentinel { - builder = builder.with_sora_sentinel(sentinel.as_str()); - } - if let Some(sentinel_token) = &self.sora_sentinel_token { - builder = builder.with_sora_sentinel_token(sentinel_token); - } - builder - } -} diff --git a/crates/api_clients/openai_sora_client/src/creds/sora_jwt_bearer_token.rs b/crates/api_clients/openai_sora_client/src/creds/sora_jwt_bearer_token.rs deleted file mode 100644 index b062a41414..0000000000 --- a/crates/api_clients/openai_sora_client/src/creds/sora_jwt_bearer_token.rs +++ /dev/null @@ -1,42 +0,0 @@ -use crate::error::sora_error::SoraError; -use crate::utils_internal::lightweight_sora_jwt_parse::{lightweight_sora_jwt_parse, SoraJwtClaims}; - -/// Sora bearer tokens are JWT tokens that can be minted with a valid cookie/session. -#[derive(Clone)] -pub struct SoraJwtBearerToken { - token: String, - jwt_claims: SoraJwtClaims, -} - -impl SoraJwtBearerToken { - pub fn new(token: String) -> Result { - let jwt_claims = lightweight_sora_jwt_parse(&token)?; - Ok(SoraJwtBearerToken { - token, - jwt_claims, - }) - } - - pub fn token_str(&self) -> &str { - &self.token - } - - pub fn as_str(&self) -> &str { - &self.token - } - - pub fn as_bytes(&self) -> &[u8] { - self.token.as_bytes() - } - - pub fn jwt_claims(&self) -> &SoraJwtClaims { - &self.jwt_claims - } - - pub fn to_authorization_header_value(&self) -> String { - match self.token.get(0..6) { - Some("bearer") | Some("Bearer") => self.token.clone(), - _ => "Bearer ".to_owned() + &self.token, - } - } -} diff --git a/crates/api_clients/openai_sora_client/src/creds/sora_sentinel.rs b/crates/api_clients/openai_sora_client/src/creds/sora_sentinel.rs deleted file mode 100644 index 70aa657293..0000000000 --- a/crates/api_clients/openai_sora_client/src/creds/sora_sentinel.rs +++ /dev/null @@ -1,31 +0,0 @@ - -/// Sora Sentinel tokens can be generated without cookies or JWTs, and are needed for some API calls. -#[derive(Clone)] -#[deprecated(note="use SoraSentinelToken instead")] -pub struct SoraSentinel { - sentinel: String, - - // TODO(bt,2025-04-23): We may want to store the user agent alongside the sentinel - // as that appears to be important for the validity of the sentinel token. -} - -impl SoraSentinel { - pub fn new(sentinel: String) -> Self { - SoraSentinel { sentinel } - } - - #[deprecated(note="use SoraSentinelToken instead")] - pub fn get_sentinel(&self) -> &str { - &self.sentinel - } - - #[deprecated(note="use SoraSentinelToken instead")] - pub fn as_str(&self) -> &str { - &self.sentinel - } - - #[deprecated(note="use SoraSentinelToken instead")] - pub fn as_bytes(&self) -> &[u8] { - self.sentinel.as_bytes() - } -} diff --git a/crates/api_clients/openai_sora_client/src/creds/sora_sentinel_token.rs b/crates/api_clients/openai_sora_client/src/creds/sora_sentinel_token.rs deleted file mode 100644 index c59a285140..0000000000 --- a/crates/api_clients/openai_sora_client/src/creds/sora_sentinel_token.rs +++ /dev/null @@ -1,99 +0,0 @@ -use crate::error::sora_client_error::SoraClientError; -use chrono::{DateTime, TimeDelta, Utc}; -use log::{error, warn}; -use serde_derive::{Deserialize, Serialize}; - -#[derive(Clone, Debug, Serialize, Deserialize)] -pub struct SoraSentinelToken { - /// The token sent over the wire. - /// (The other fields in this struct are metadata.) - pub token: RawSoraSentinelToken, - - /// User agent used to get the token. - pub browser_user_agent: String, - - /// Clientside time when it was generated (client-side). - pub generated_at: DateTime, - - /// Seconds of validity (reported by the server, or our best guess). - /// If the server doesn't tell us, we'll fill it in with our best guess. - pub expires_in_seconds: u32, -} - -/// This is what is sent over the wire in requests. -#[derive(Clone, Debug, Serialize, Deserialize)] -pub struct RawSoraSentinelToken { - /// "Proof of Work" token (we generated this clientside) - #[serde(rename = "p")] - pub p: String, - - /// Random UUID (we generated this clientside) - #[serde(rename = "id")] - pub id: String, - - /// Frontend UI flow (this is the website flow used) - #[serde(rename = "flow")] - pub flow: String, - - /// Turnstile dx from the response. - /// response["turnstile"]["dx"] - #[serde(rename = "t")] - pub t: String, - - /// Token from the response. - /// response["token"] - #[serde(rename = "c")] - pub c: String, -} - -impl SoraSentinelToken { - /// Check to see if the sentinel token is expired and in need of a refresh. - pub fn is_expired(&self) -> bool { - let now = Utc::now(); - - let maybe_expires_at = self.generated_at - .checked_add_signed(TimeDelta::seconds(self.expires_in_seconds as i64)); - - let expires_at = match maybe_expires_at { - Some(expires_at) => expires_at, - None => { - error!("Could not compute expires_at for sentinel token!"); - return false; - } - }; - - if now >= expires_at { - return true; - } - - if expires_at.signed_duration_since(now).num_seconds() < 30 { - warn!("Less than 30 seconds remaining on sentinel token, treating as expired."); - return true; - } - - false - } - - /// Convert to JSON, which is the raw over-the-wire format Sora consumes. - pub fn to_request_header_json(&self) -> Result { - self.token.to_request_header_json() - } - - pub fn to_persistent_storage_json(&self) -> Result { - serde_json::to_string(self) - .map_err(|err| SoraClientError::CouldNotSerializeSentinelTokenStore(err)) - } - - pub fn from_persistent_storage_json(json: &str) -> Result { - serde_json::from_str(json) - .map_err(|err| SoraClientError::CouldNotDeserializeSentinelTokenStore { error: err, raw_json: json.to_owned() }) - } -} - -impl RawSoraSentinelToken { - /// Convert to JSON, which is the raw over-the-wire format Sora consumes. - pub fn to_request_header_json(&self) -> Result { - serde_json::to_string(self) - .map_err(|err| SoraClientError::CouldNotSerializeSentinelToken(err)) - } -} diff --git a/crates/api_clients/openai_sora_client/src/error/mod.rs b/crates/api_clients/openai_sora_client/src/error/mod.rs deleted file mode 100644 index 010e4fe745..0000000000 --- a/crates/api_clients/openai_sora_client/src/error/mod.rs +++ /dev/null @@ -1,4 +0,0 @@ -pub mod sora_client_error; -pub mod sora_error; -pub mod sora_generic_api_error; -pub mod sora_specific_api_error; \ No newline at end of file diff --git a/crates/api_clients/openai_sora_client/src/error/sora_client_error.rs b/crates/api_clients/openai_sora_client/src/error/sora_client_error.rs deleted file mode 100644 index 6c5d946967..0000000000 --- a/crates/api_clients/openai_sora_client/src/error/sora_client_error.rs +++ /dev/null @@ -1,70 +0,0 @@ -use std::error::Error; -use std::fmt::{Display, Formatter}; - -#[derive(Debug)] -pub enum SoraClientError { - /// An error reading the file for upload. - FileForUploadReadError(std::io::Error), - - /// The file path provided for upload is invalid. - FileForUploadHasInvalidPath, - - /// Something is wrong with the JWT bearer token. - /// This error originates on our end as we try to parse the JWT. - LocalJwtClaimsParseError(String), - - /// There was an error constructing the form-multipart request. - MultipartFormError(wreq::Error), - - /// We haven't received a bearer token yet - /// This is our own internal application state error, not something Sora returns. - /// We know our client can't make the request, so we preemptively fail it. - NoBearerTokenForRequest, - - /// A sentinel token is not present in the client, which is required for some requests. - NoSentinelTokenForRequest, - - /// Issue with using the SoraCredentialBuilder. - SoraCredentialBuilderError(&'static str), - - /// Error parsing a request URL. - UrlParseError(url::ParseError), - - /// An error was encountered in building the Wreq client - WreqClientError(wreq::Error), - - /// Error serializing the sentinel token to JSON - CouldNotSerializeSentinelToken(serde_json::Error), - - /// Error serializing the sentinel store token to JSON (typically for persistent storage). - CouldNotSerializeSentinelTokenStore(serde_json::Error), - - /// Error deserializing the sentinel token from JSON (typically for persistent storage). - CouldNotDeserializeSentinelTokenStore { - error: serde_json::Error, - raw_json: String - }, -} - -impl Error for SoraClientError {} - -impl Display for SoraClientError { - fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { - match self { - Self::FileForUploadReadError(err) => write!(f, "Error reading file for upload: {}", err), - Self::FileForUploadHasInvalidPath => write!(f, "The file path provided for upload is invalid."), - Self::LocalJwtClaimsParseError(msg) => write!(f, "Local JWT claims parse error: {}", msg), - Self::MultipartFormError(err) => write!(f, "Multipart form error: {}", err), - Self::NoBearerTokenForRequest => write!(f, "No bearer token available. The client needs a bearer token to make the request."), - Self::NoSentinelTokenForRequest => write!(f, "No sentinel token available. The client needs a sentinel token to make the request."), - Self::SoraCredentialBuilderError(msg) => write!(f, "Sora Credential Builder error: {}", msg), - Self::UrlParseError(err) => write!(f, "URL parse error: {}", err), - Self::WreqClientError(err) => write!(f, "Wreq client error (during client creation): {}", err), - Self::CouldNotSerializeSentinelToken(err) => write!(f, "Could not serialize sentinel token to JSON: {}", err), - Self::CouldNotSerializeSentinelTokenStore(err) => write!(f, "Could not serialize sentinel token store to JSON: {}", err), - Self::CouldNotDeserializeSentinelTokenStore { error, raw_json} => { - write!(f, "Could not deserialize sentinel token store from JSON: {:?}, raw JSON: {}", error, raw_json) - }, - } - } -} diff --git a/crates/api_clients/openai_sora_client/src/error/sora_error.rs b/crates/api_clients/openai_sora_client/src/error/sora_error.rs deleted file mode 100644 index 5fc7ae3978..0000000000 --- a/crates/api_clients/openai_sora_client/src/error/sora_error.rs +++ /dev/null @@ -1,54 +0,0 @@ -use crate::error::sora_client_error::SoraClientError; -use crate::error::sora_generic_api_error::SoraGenericApiError; -use crate::error::sora_specific_api_error::SoraSpecificApiError; -use cloudflare_errors::cloudflare_error::CloudflareError; -use std::error::Error; - -#[derive(Debug)] -pub enum SoraError { - Client(SoraClientError), - ApiSpecific(SoraSpecificApiError), - ApiGeneric(SoraGenericApiError), -} - -impl SoraError { - pub fn is_sora_having_downtime_issues(&self) -> bool { - match self { - Self::ApiGeneric(SoraGenericApiError::Http502ErrorBadGateway(_)) => true, - Self::ApiGeneric(SoraGenericApiError::CloudflareError(CloudflareError::BadGateway502)) => true, - Self::ApiGeneric(SoraGenericApiError::CloudflareError(CloudflareError::GatewayTimeout504)) => true, - Self::ApiGeneric(SoraGenericApiError::CloudflareError(CloudflareError::TimeoutOccurred524)) => true, - _ => false, - } - } -} - -impl Error for SoraError {} - -impl std::fmt::Display for SoraError { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - Self::Client(e) => write!(f, "SoraClientError: {:?}", e), - Self::ApiSpecific(e) => write!(f, "SoraSpecificApiError: {:?}", e), - Self::ApiGeneric(e) => write!(f, "SoraGenericApiError: {:?}", e), - } - } -} - -impl From for SoraError { - fn from(error: SoraClientError) -> Self { - Self::Client(error) - } -} - -impl From for SoraError { - fn from(error: SoraSpecificApiError) -> Self { - Self::ApiSpecific(error) - } -} - -impl From for SoraError { - fn from(error: SoraGenericApiError) -> Self { - Self::ApiGeneric(error) - } -} diff --git a/crates/api_clients/openai_sora_client/src/error/sora_generic_api_error.rs b/crates/api_clients/openai_sora_client/src/error/sora_generic_api_error.rs deleted file mode 100644 index a4004941b3..0000000000 --- a/crates/api_clients/openai_sora_client/src/error/sora_generic_api_error.rs +++ /dev/null @@ -1,54 +0,0 @@ -use cloudflare_errors::cloudflare_error::CloudflareError; -use std::error::Error; -use std::fmt::{Display, Formatter}; -use wreq::StatusCode; - -#[derive(Debug)] -pub enum SoraGenericApiError { - /// Specific Cloudflare errors. - CloudflareError(CloudflareError), - - /// HTTP 502 Bad Gateway - /// Sora is having issues. - /// Typically served from Cloudflare - /// We preserve the message for debugging. - Http502ErrorBadGateway(String), - - /// serde_json::Error, likely from JSON deserialization schema mismatch. - /// Includes the original body. - SerdeResponseParseErrorWithBody(serde_json::Error, String), - - /// serde_json::Error, likely from JSON deserialization schema mismatch. - /// Includes the original body. - /// Specifically, this is for non-200 (error) responses. - SerdeParseErrorWithBodyOnNon200(serde_json::Error, String), - - /// Another error occurred. - /// TODO: Try to get rid of this. - UncategorizedBadResponse(String), - - /// An uncategorized bad HTTP response from Sora. - UncategorizedBadResponseWithStatusAndBody { - status_code: StatusCode, - body: String, - }, - - /// An uncaught error from the API client. - WreqError(wreq::Error), -} - -impl Error for SoraGenericApiError {} - -impl Display for SoraGenericApiError { - fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { - match self { - Self::CloudflareError(err) => write!(f, "Cloudflare error: {}", err), - Self::Http502ErrorBadGateway(msg) => write!(f, "HTTP 502 Bad Gateway: {}", msg), - Self::SerdeResponseParseErrorWithBody(err, body) => write!(f, "Failed to parse response body: {:?}. Body: {}", err, body), - Self::SerdeParseErrorWithBodyOnNon200(err, body) => write!(f, "Failed to parse non-200 response body: {:?}. Body: {}", err, body), - Self::UncategorizedBadResponseWithStatusAndBody { status_code, body } => write!(f, "Uncategorized bad response: status code {}, body: {}", status_code, body), - Self::UncategorizedBadResponse(msg) => write!(f, "Uncategorized bad response status: {}", msg), - Self::WreqError(err) => write!(f, "Wreq client error: {}", err), - } - } -} diff --git a/crates/api_clients/openai_sora_client/src/error/sora_specific_api_error.rs b/crates/api_clients/openai_sora_client/src/error/sora_specific_api_error.rs deleted file mode 100644 index 3366fedb29..0000000000 --- a/crates/api_clients/openai_sora_client/src/error/sora_specific_api_error.rs +++ /dev/null @@ -1,68 +0,0 @@ -use std::error::Error; -use std::fmt::{Display, Formatter}; - -#[derive(Debug)] -pub enum SoraSpecificApiError { - /// Failed to generate a bearer token despite the `200 OK` response. - /// This has been generated by sending old/expired session cookies or empty cookies. - FailedToGenerateBearerToken, - - /// The endpoint told us we used an invalid JWT. - InvalidJwt, - - /// Sora has responded with "sentinel block". - /// This usually means we need to refresh our sentinel token. - SentinelBlockError, - - /// Sora requires users to set up an account username before they can generate images. - /// This requires the user to set up that username. - SoraUsernameNotYetCreated, - - /// Sora has responded with "token expired". - /// This (probably?) means we need to refresh our JWT bearer token. - TokenExpiredError, - - /// We're sending too many tasks to Sora. - /// Sora is telling us to cool it. - TooManyConcurrentTasks, - - // TODO: Try to make concrete error types for these distinct cases. - /// Unauthorized, cookie and/or bearer token expired. We'll need to ask for a refreshed login. - /// - /// Example message, e.g. from the upload endpoint: - /// { - /// "error": { - /// "message": "Your authentication token has expired. Please try signing in again.", - /// "type": "invalid_request_error", - /// "param": null, - /// "code": "token_expired" - /// } - /// } - UnauthorizedCookieOrBearerExpired, - - /// The Sora sentinel token response is missing fields - SentinelResponseIsMissingFields { - missing_token: bool, - missing_turnstile: bool, - raw_response: String, - }, -} - -impl Error for SoraSpecificApiError {} - -impl Display for SoraSpecificApiError { - fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { - match self { - Self::FailedToGenerateBearerToken => write!(f, "Failed to generate bearer token. Probably invalid or expired session cookies."), - Self::InvalidJwt => write!(f, "Invalid JWT token. Please refresh the token."), - Self::SentinelBlockError => write!(f, "Request blocked by Sentinel Token Block. Please refresh the sentinel token."), - Self::SoraUsernameNotYetCreated => write!(f, "Sora username not yet created. Please create a username in the Sora app or website."), - Self::TokenExpiredError => write!(f, "JWT token has expired. Please refresh the token."), - Self::TooManyConcurrentTasks => write!(f, "Too many concurrent tasks. Please wait."), - Self::UnauthorizedCookieOrBearerExpired => write!(f, "Unauthorized: cookie and/or bearer token expired"), - Self::SentinelResponseIsMissingFields { missing_token: token_missing, missing_turnstile: turnstile_missing, raw_response } => { - write!(f, "Sentinel response is missing fields. token_missing: {}, turnstile_missing: {}. Raw response: {}", token_missing, turnstile_missing, raw_response) - }, - } - } -} diff --git a/crates/api_clients/openai_sora_client/src/lib.rs b/crates/api_clients/openai_sora_client/src/lib.rs deleted file mode 100644 index 78cefe3cc4..0000000000 --- a/crates/api_clients/openai_sora_client/src/lib.rs +++ /dev/null @@ -1,13 +0,0 @@ -#[cfg(test)] -pub (crate) mod test_utils; - -// Internal lib -pub (crate) mod constants; -pub (crate) mod utils_internal; - -// User API -pub mod creds; -pub mod error; -pub mod recipes; -pub mod requests; -pub mod utils; diff --git a/crates/api_clients/openai_sora_client/src/recipes/generate_sora2_video/generate_sora2_video_with_session_auto_renew.rs b/crates/api_clients/openai_sora_client/src/recipes/generate_sora2_video/generate_sora2_video_with_session_auto_renew.rs deleted file mode 100644 index 32f53d6828..0000000000 --- a/crates/api_clients/openai_sora_client/src/recipes/generate_sora2_video/generate_sora2_video_with_session_auto_renew.rs +++ /dev/null @@ -1,63 +0,0 @@ -use crate::creds::sora_credential_set::SoraCredentialSet; -use crate::error::sora_error::SoraError; -use crate::recipes::utils::maybe_renew_sentinel_token::maybe_renew_sentinel_token; -use crate::recipes::utils::maybe_renew_session_jwt::maybe_renew_session_jwt; -use crate::requests::generate_sora2_video::generate_sora2_video::{generate_sora2_video, GenerateSora2VideoArgs, GenerateSora2VideoResponse}; -use std::io::Write; - -/// Generate Sora 2 video with session auto-renewal. -/// If a new sora credential is returned, replace the old one with the new one. -pub async fn generate_sora2_video_with_session_auto_renew( - args: GenerateSora2VideoArgs<'_>, -) -> Result<(GenerateSora2VideoResponse, Option), SoraError> { - - let mut maybe_new_creds = maybe_renew_session_jwt(&args.credentials).await?; - - let use_creds = maybe_new_creds.as_ref() - .unwrap_or_else(|| &args.credentials); - - let mut maybe_new_creds = maybe_renew_sentinel_token(use_creds).await?; - - let use_creds = maybe_new_creds.as_ref() - .unwrap_or_else(|| &args.credentials); - - let mut request = args.clone(); - request.credentials = use_creds; - - let result = generate_sora2_video(request).await; - - match result { - Ok(response) => Ok((response, maybe_new_creds)), - Err(err) => Err(err), // TODO: Should we retry? - } -} - -#[cfg(test)] -mod tests { - use crate::recipes::generate_sora2_video::generate_sora2_video_with_session_auto_renew::generate_sora2_video_with_session_auto_renew; - use crate::requests::generate_sora2_video::generate_sora2_video::{GenerateSora2VideoArgs, Orientation}; - use crate::test_utils::get_test_credentials::get_test_credentials; - use errors::AnyhowResult; - - #[ignore] // You can manually run "ignore" tests in the IDE, but they won't run in CI. - #[tokio::test] - pub async fn manual_test() -> AnyhowResult<()> { - let creds = get_test_credentials()?; - - let args = GenerateSora2VideoArgs { - prompt: "a Golden Retriever playing basketball at Venice Beach during sunset", - credentials: &creds, - request_timeout: None, - orientation: Orientation::Landscape, - image_reference_media_ids: None, - }; - - let (result , creds) = - generate_sora2_video_with_session_auto_renew(args).await?; - - println!("result: {:#?}", result); - assert_eq!(1, 2); - - Ok(()) - } -} diff --git a/crates/api_clients/openai_sora_client/src/recipes/generate_sora2_video/mod.rs b/crates/api_clients/openai_sora_client/src/recipes/generate_sora2_video/mod.rs deleted file mode 100644 index 300e294aaa..0000000000 --- a/crates/api_clients/openai_sora_client/src/recipes/generate_sora2_video/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod generate_sora2_video_with_session_auto_renew; \ No newline at end of file diff --git a/crates/api_clients/openai_sora_client/src/recipes/image_remix_with_session_auto_renew.rs b/crates/api_clients/openai_sora_client/src/recipes/image_remix_with_session_auto_renew.rs deleted file mode 100644 index 6c3ea911ca..0000000000 --- a/crates/api_clients/openai_sora_client/src/recipes/image_remix_with_session_auto_renew.rs +++ /dev/null @@ -1,142 +0,0 @@ -use crate::creds::sora_credential_set::SoraCredentialSet; -use crate::creds::sora_jwt_bearer_token::SoraJwtBearerToken; -use crate::creds::sora_sentinel::SoraSentinel; -use crate::error::sora_error::SoraError; -use crate::error::sora_generic_api_error::SoraGenericApiError; -use crate::error::sora_specific_api_error::SoraSpecificApiError; -use crate::requests::auth_bearer::generate_bearer_jwt_with_cookie::generate_bearer_jwt_with_cookie; -use crate::requests::auth_sentinel::generate_sentinel_token::generate_sentinel_token; -use crate::requests::image_gen::common::{ImageSize, NumImages, SoraImageGenResponse}; -use crate::requests::image_gen::sora_image_gen_remix::{sora_image_gen_remix, SoraImageGenRemixRequest}; -use anyhow::anyhow; -use errors::AnyhowResult; -use log::{error, info, warn}; -use std::time::Duration; - -pub struct ImageRemixAutoRenewRequest<'a> { - pub prompt: String, - pub num_images: NumImages, - pub image_size: ImageSize, - pub sora_media_tokens: Vec, - pub credentials: &'a SoraCredentialSet, - /// This function can try several different requests. This is the timeout for *individual* requests. - pub request_timeout: Option, -} - -/// Image request with retry and session auto-renewal. -/// If a new sora credential is returned, replace the old one with the new one. -pub async fn image_remix_with_session_auto_renew(request: ImageRemixAutoRenewRequest<'_>) -> Result<(SoraImageGenResponse, Option), SoraError> { - let result = sora_image_gen_remix(SoraImageGenRemixRequest { - prompt: request.prompt.clone(), // NB: Clone because used again - num_images: request.num_images, - image_size: request.image_size, - sora_media_tokens: request.sora_media_tokens.clone(), // NB: Clone because used again - credentials: request.credentials, - request_timeout: request.request_timeout, - }).await; - - let err = match result { - Ok(response) => return Ok((response, None)), - Err(err) => err, - }; - - warn!("Image generation failed: {:?}", err); - - let mut refresh_jwt = false; - let mut refresh_sentinel = false; - - match err { - // We'll specifically fail these non-retryable requests... - - SoraError::ApiSpecific(SoraSpecificApiError::TooManyConcurrentTasks) | - SoraError::ApiSpecific(SoraSpecificApiError::SoraUsernameNotYetCreated) => { - error!("Non-retryable image generation error: {:?}", err); - return Err(err); - } - - // We'll retry these requests... - - SoraError::ApiSpecific(SoraSpecificApiError::SentinelBlockError) => { - warn!("Image generation failed due to sentinel block error: {:?}", err); - refresh_sentinel = true; - } - SoraError::ApiSpecific(SoraSpecificApiError::TokenExpiredError) => { - warn!("Image generation failed due to token expired error: {:?}", err); - refresh_sentinel = true; // TODO: Not sure what this error is, actually. - refresh_jwt = true; - } - SoraError::ApiSpecific(SoraSpecificApiError::InvalidJwt) => { - warn!("Image generation failed due to invalid jwt error: {:?}", err); - refresh_jwt = true; - } - SoraError::ApiSpecific(SoraSpecificApiError::UnauthorizedCookieOrBearerExpired) => { - warn!("Image generation failed due to auth error (nb: this is a legacy error): {:?}", err); - refresh_jwt = true; - refresh_sentinel = true; - } - - // We'll fail everything else eagerly... - - _ => { - error!("Image generation error: {:?}", err); - return Err(err); - } - } - - let mut new_bearer = None; - - if refresh_jwt { - info!("Generating new JWT bearer token..."); - let cookies = request.credentials.cookies.as_str(); - let response = generate_bearer_jwt_with_cookie(cookies).await; - match response { - Err(err) => { - return Err(SoraGenericApiError::UncategorizedBadResponse(format!("failed to generate new JWT bearer token: {:?}", err)).into()) - } - Ok(bearer) => { - match SoraJwtBearerToken::new(bearer) { - Err(err) => { - return Err(SoraGenericApiError::UncategorizedBadResponse(format!("Failed to parse new JWT bearer token: {:?}", err)).into()); - } - Ok(bearer) => new_bearer = Some(bearer), - } - }, - } - } - - let mut new_sentinel = None; - - if refresh_sentinel { - info!("Generating new sentinel..."); - let response = generate_sentinel_token().await; - match response { - Err(err) => { - return Err(SoraGenericApiError::UncategorizedBadResponse(format!("failed to generate new sentinel: {:?}", err)).into()) - } - Ok(sentinel) => new_sentinel = Some(SoraSentinel::new(sentinel)), - } - } - - let mut new_creds = request.credentials.clone(); - - if let Some(bearer) = new_bearer { - new_creds.jwt_bearer_token = Some(bearer); - } - - if let Some(sentinel) = new_sentinel { - new_creds.sora_sentinel = Some(sentinel); - } - - // Now try again... - - let result = sora_image_gen_remix(SoraImageGenRemixRequest { - prompt: request.prompt, - num_images: request.num_images, - image_size: request.image_size, - sora_media_tokens: request.sora_media_tokens, - credentials: &new_creds, - request_timeout: request.request_timeout, - }).await?; - - Ok((result, Some(new_creds))) -} diff --git a/crates/api_clients/openai_sora_client/src/recipes/image_upload_from_bytes_with_session_auto_renew.rs b/crates/api_clients/openai_sora_client/src/recipes/image_upload_from_bytes_with_session_auto_renew.rs deleted file mode 100644 index 7183369809..0000000000 --- a/crates/api_clients/openai_sora_client/src/recipes/image_upload_from_bytes_with_session_auto_renew.rs +++ /dev/null @@ -1,62 +0,0 @@ -use crate::creds::sora_credential_set::SoraCredentialSet; -use crate::creds::sora_jwt_bearer_token::SoraJwtBearerToken; -use crate::creds::sora_sentinel::SoraSentinel; -use crate::error::sora_error::SoraError; -use crate::recipes::maybe_refresh_credentials_on_sora_error::maybe_refresh_credentials_on_sora_error; -use crate::requests::auth_bearer::generate_bearer_jwt_with_cookie::generate_bearer_jwt_with_cookie; -use crate::requests::image_gen::common::{ImageSize, NumImages, SoraImageGenResponse}; -use crate::requests::image_gen::image_gen_http_request; -use crate::requests::image_gen::sora_image_gen_remix::{sora_image_gen_remix, SoraImageGenRemixRequest}; -use crate::requests::upload::upload_media_from_bytes::sora_media_upload_from_bytes; -use crate::requests::upload::upload_media_http_request::upload_media_http_request; -use crate::requests::upload::upload_media_http_response::SoraMediaUploadResponse; -use anyhow::anyhow; -use errors::AnyhowResult; -use log::{error, info, warn}; -use std::time::Duration; - -pub struct ImageUploadFromBytesAutoRenewRequest<'a> { - pub file_bytes: Vec, - pub filename: String, - pub mime_type: &'a str, - pub credentials: &'a SoraCredentialSet, - - /// This function can try to upload several times. This is the timeout for *individual* requests. - pub request_timeout: Option, -} - -/// Image upload with retry and session auto-renewal. -/// If a new sora credential is returned, replace the old one with the new one. -pub async fn image_upload_from_bytes_with_session_auto_renew( - request: ImageUploadFromBytesAutoRenewRequest<'_> -) -> Result<(SoraMediaUploadResponse, Option), SoraError> { - - let result = sora_media_upload_from_bytes( - request.file_bytes.clone(), // FIXME(bt): This is horrible, but the client needs to take ownership. :( - request.filename.clone(), // FIXME: Same - request.credentials, - request.request_timeout, - ).await; - - let err = match result { - Ok(response) => return Ok((response, None)), - Err(err) => err, - }; - - warn!("Image upload failed: {:?}", err); - - let new_creds = maybe_refresh_credentials_on_sora_error(request.credentials, err).await?; - - // Now try again... - - info!("Retrying image upload with new credentials..."); - - let result = sora_media_upload_from_bytes( - request.file_bytes, - request.filename, - &new_creds, - request.request_timeout, - ).await?; - - Ok((result, Some(new_creds))) -} diff --git a/crates/api_clients/openai_sora_client/src/recipes/image_upload_from_file_with_session_auto_renew.rs b/crates/api_clients/openai_sora_client/src/recipes/image_upload_from_file_with_session_auto_renew.rs deleted file mode 100644 index 78a1299929..0000000000 --- a/crates/api_clients/openai_sora_client/src/recipes/image_upload_from_file_with_session_auto_renew.rs +++ /dev/null @@ -1,55 +0,0 @@ -use crate::creds::sora_credential_set::SoraCredentialSet; -use crate::error::sora_error::SoraError; -use crate::error::sora_specific_api_error::SoraSpecificApiError; -use crate::recipes::maybe_refresh_credentials_on_sora_error::maybe_refresh_credentials_on_sora_error; -use crate::requests::upload::upload_media_from_file::sora_media_upload_from_file; -use crate::requests::upload::upload_media_http_request::upload_media_http_request; -use crate::requests::upload::upload_media_http_response::SoraMediaUploadResponse; -use log::{info, warn}; -use std::path::Path; -use std::time::Duration; - -pub struct ImageUploadFromFileAutoRenewRequest<'a, P: AsRef> { - pub file_path: P, - pub credentials: &'a SoraCredentialSet, - - /// This function can try to upload several times. This is the timeout for *individual* requests. - pub request_timeout: Option, -} - -/// Image upload with retry and session auto-renewal. -/// If a new sora credential is returned, replace the old one with the new one. -pub async fn image_upload_from_file_with_session_auto_renew>( - request: ImageUploadFromFileAutoRenewRequest<'_, P> -) -> Result<(SoraMediaUploadResponse, Option), SoraError> { - - let result = sora_media_upload_from_file( - request.file_path.as_ref().clone(), // FIXME(bt): This is horrible, but the client needs to take ownership. :( - request.credentials, - /// This function can try to upload several times. This is the timeout for *individual* requests. - request.request_timeout, - ).await; - - let err = match result { - Ok(response) => return Ok((response, None)), - // We can't retry some errors. - Err(err @ SoraError::ApiSpecific(SoraSpecificApiError::SoraUsernameNotYetCreated)) => return Err(err), - // Retry all other errors. - Err(err) => err, - }; - - warn!("Image upload failed: {:?}", err); - - let new_creds = maybe_refresh_credentials_on_sora_error(request.credentials, err).await?; - - info!("Retrying image upload with new credentials..."); - - let result = sora_media_upload_from_file( - request.file_path, - &new_creds, - request.request_timeout, - ).await?; - - Ok((result, Some(new_creds))) -} - diff --git a/crates/api_clients/openai_sora_client/src/recipes/list_classic_sora_tasks_with_session_auto_renew.rs b/crates/api_clients/openai_sora_client/src/recipes/list_classic_sora_tasks_with_session_auto_renew.rs deleted file mode 100644 index 4d161886cc..0000000000 --- a/crates/api_clients/openai_sora_client/src/recipes/list_classic_sora_tasks_with_session_auto_renew.rs +++ /dev/null @@ -1,60 +0,0 @@ -use crate::creds::sora_credential_set::SoraCredentialSet; -use crate::error::sora_error::SoraError; -use crate::recipes::image_upload_from_file_with_session_auto_renew::ImageUploadFromFileAutoRenewRequest; -use crate::recipes::maybe_refresh_credentials_on_sora_error::maybe_refresh_credentials_on_sora_error; -use crate::recipes::maybe_upgrade_or_renew_session::maybe_upgrade_or_renew_session; -use crate::requests::common::task_id::TaskId; -use crate::requests::deprecated::job_status::sora_job_status::{get_image_gen_status, StatusRequest, TaskResponse, VideoGenStatusResponse}; -use crate::requests::list_classic_tasks::list_classic_tasks::{list_classic_tasks, ListTasksResponse}; -use crate::requests::upload::upload_media_from_file::sora_media_upload_from_file; -use anyhow::Error; -use log::{info, warn}; -use std::path::Path; - -/// Check Sora task statuses with session auto-renewal. -/// If a new sora credential is returned, replace the old one with the new one. -pub async fn list_classic_sora_tasks_with_session_auto_renew( - credentials: &SoraCredentialSet, -) -> Result<(ListTasksResponse, Option), SoraError> { - - let mut maybe_new_creds = maybe_renew_session(&credentials).await?; - - let upgraded_creds = maybe_new_creds.as_ref() - .unwrap_or_else(|| &credentials); - - let result = list_classic_tasks(&upgraded_creds).await; - - let err = match result { - Ok(response) => return Ok((response, maybe_new_creds)), - Err(err) => err, - }; - - warn!("Task status polling failed: {:?}", err); - - // TODO(bt,2025-05-28): This should only be done if the credentials were known to be bad - let new_creds = maybe_refresh_credentials_on_sora_error(&upgraded_creds, err).await?; - - // TODO(bt,2025-05-28): This should only be done if the credentials were actually refreshed. - info!("Retrying task polling with new credentials..."); - - let result = list_classic_tasks(&new_creds).await?; - - Ok((result, Some(new_creds))) -} - -async fn maybe_renew_session(creds: &SoraCredentialSet) -> Result, SoraError> { - if !creds.jwt_bearer_token.is_none() { - // TODO: Handle JWT expired case as well. - return Ok(None); - } - - info!("JWT not set. Upgrading credentials..."); - let mut updated_creds = creds.clone(); - - if let Err(err) = maybe_upgrade_or_renew_session(&mut updated_creds).await { - warn!("Failed to upgrade or renew session: {:?}", err); - return Err(err); - } - - Ok(Some(updated_creds)) -} diff --git a/crates/api_clients/openai_sora_client/src/recipes/list_sora2_drafts/list_sora2_drafts_with_session_auto_renew.rs b/crates/api_clients/openai_sora_client/src/recipes/list_sora2_drafts/list_sora2_drafts_with_session_auto_renew.rs deleted file mode 100644 index 021de7e6a3..0000000000 --- a/crates/api_clients/openai_sora_client/src/recipes/list_sora2_drafts/list_sora2_drafts_with_session_auto_renew.rs +++ /dev/null @@ -1,45 +0,0 @@ -use crate::creds::sora_credential_set::SoraCredentialSet; -use crate::error::sora_error::SoraError; -use crate::recipes::utils::maybe_renew_session_jwt::maybe_renew_session_jwt; -use crate::requests::list_sora2_drafts::list_sora2_drafts::{list_sora2_drafts, ListSora2DraftsResponse}; - -/// Check Sora 2 drafts with session auto-renewal. -/// If a new sora credential is returned, replace the old one with the new one. -pub async fn list_sora2_drafts_with_session_auto_renew( - credentials: &SoraCredentialSet, -) -> Result<(ListSora2DraftsResponse, Option), SoraError> { - - let mut maybe_new_creds = maybe_renew_session_jwt(&credentials).await?; - - let use_creds = maybe_new_creds.as_ref() - .unwrap_or_else(|| &credentials); - - let result = list_sora2_drafts(&use_creds).await; - - match result { - Ok(response) => Ok((response, maybe_new_creds)), - Err(err) => Err(err), // TODO: Should we retry? - } -} - - -#[cfg(test)] -mod tests { - use crate::recipes::list_sora2_drafts::list_sora2_drafts_with_session_auto_renew::list_sora2_drafts_with_session_auto_renew; - use crate::test_utils::get_test_credentials::get_test_credentials; - use errors::AnyhowResult; - - #[ignore] // You can manually run "ignore" tests in the IDE, but they won't run in CI. - #[tokio::test] - pub async fn manual_test() -> AnyhowResult<()> { - let creds = get_test_credentials()?; - - let (result , creds) = - list_sora2_drafts_with_session_auto_renew(&creds).await?; - - println!("result: {:#?}", result); - assert_eq!(1, 2); - - Ok(()) - } -} diff --git a/crates/api_clients/openai_sora_client/src/recipes/list_sora2_drafts/mod.rs b/crates/api_clients/openai_sora_client/src/recipes/list_sora2_drafts/mod.rs deleted file mode 100644 index 4909b4b23b..0000000000 --- a/crates/api_clients/openai_sora_client/src/recipes/list_sora2_drafts/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod list_sora2_drafts_with_session_auto_renew; \ No newline at end of file diff --git a/crates/api_clients/openai_sora_client/src/recipes/maybe_refresh_credentials_on_sora_error.rs b/crates/api_clients/openai_sora_client/src/recipes/maybe_refresh_credentials_on_sora_error.rs deleted file mode 100644 index 63146f6746..0000000000 --- a/crates/api_clients/openai_sora_client/src/recipes/maybe_refresh_credentials_on_sora_error.rs +++ /dev/null @@ -1,53 +0,0 @@ -use crate::creds::sora_credential_set::SoraCredentialSet; -use crate::creds::sora_jwt_bearer_token::SoraJwtBearerToken; -use crate::error::sora_client_error::SoraClientError; -use crate::error::sora_error::SoraError; -use crate::error::sora_specific_api_error::SoraSpecificApiError; -use crate::requests::auth_bearer::generate_bearer_jwt_with_cookie::generate_bearer_jwt_with_cookie; -use anyhow::anyhow; -use log::{error, info, warn}; - -// TODO: Make other APIs work with this. - -pub async fn maybe_refresh_credentials_on_sora_error(creds: &SoraCredentialSet, error: SoraError) -> Result { - - match error { - SoraError::Client(SoraClientError::NoBearerTokenForRequest) => { - error!("Previous request failed due to missing bearer token."); - } - SoraError::ApiSpecific(SoraSpecificApiError::UnauthorizedCookieOrBearerExpired) => { - error!("Previous request failed due to invalid bearer token."); - } - _ => { - error!("Previous request failed due to the following error: {:?}", error); - return Err(error) - } - } - - info!("Generating new JWT bearer token..."); - - let cookies = creds.cookies.as_str(); - let response = generate_bearer_jwt_with_cookie(cookies).await; - - let new_bearer = match response { - Err(err) => { - error!("Error generating new JWT bearer token: {}", err); - return Err(err); - } - Ok(bearer) => { - match SoraJwtBearerToken::new(bearer) { - Err(err) => { - error!("Error parsing new JWT bearer token: {}", err); - return Err(err); - } - Ok(bearer) => bearer, - } - } - }; - - let mut new_creds = creds.clone(); - - new_creds.jwt_bearer_token = Some(new_bearer); - - Ok(new_creds) -} diff --git a/crates/api_clients/openai_sora_client/src/recipes/maybe_upgrade_or_renew_session.rs b/crates/api_clients/openai_sora_client/src/recipes/maybe_upgrade_or_renew_session.rs deleted file mode 100644 index 652cb47edb..0000000000 --- a/crates/api_clients/openai_sora_client/src/recipes/maybe_upgrade_or_renew_session.rs +++ /dev/null @@ -1,70 +0,0 @@ -use crate::creds::sora_credential_set::SoraCredentialSet; -use crate::creds::sora_jwt_bearer_token::SoraJwtBearerToken; -use crate::creds::sora_sentinel::SoraSentinel; -use crate::error::sora_error::SoraError; -use crate::requests::auth_bearer::generate_bearer_jwt_with_cookie::generate_bearer_jwt_with_cookie; -use crate::requests::auth_sentinel::generate_sentinel_token::generate_sentinel_token; -use crate::requests::auth_sentinel_2::generate_sentinel_token_2::generate_sentinel_token_2; -use chrono::{DateTime, TimeDelta, Utc}; -use errors::AnyhowResult; -use log::info; -use std::ops::Sub; - -const JWT_EXPIRATION_DEADLINE: TimeDelta = TimeDelta::hours(12); - -/// Call this at session startup to generate the tokens for the first time. -/// Call this periodically to refresh the JWT as it nears its expiration date. -/// This will not refresh the sentinel token once it's been generated - we can use other flows to accomplish that. -#[deprecated(note="The sentinel appears to be going away. Use `maybe_renew_session_jwt` instead for newer '2.0' code.")] -pub async fn maybe_upgrade_or_renew_session(sora_credentials: &mut SoraCredentialSet) -> Result { - let mut refresh_jwt = !sora_credentials.jwt_bearer_token.is_some(); - - if let Some(jwt) = &sora_credentials.jwt_bearer_token { - let now = Utc::now(); - let refresh_deadline = now.sub(JWT_EXPIRATION_DEADLINE); - if jwt.jwt_claims().expiration.lt(&now) { - info!("JWT expiration time has elapsed."); - refresh_jwt = true; - } else if jwt.jwt_claims().expiration.lt(&refresh_deadline) { - info!("JWT expiration time is under the expiration deadline."); - refresh_jwt = true; - } - } - - let mut credential_updated = false; - - if refresh_jwt { - info!("Refreshing JWT..."); - let cookies = sora_credentials.cookies.as_str(); - let token = generate_bearer_jwt_with_cookie(cookies).await?; - - info!("Parsing JWT bearer token."); - let token = SoraJwtBearerToken::new(token)?; - sora_credentials.jwt_bearer_token = Some(token); - credential_updated = true; - } - - //let refresh_sentinel = !sora_credentials.sora_sentinel.is_some(); - //if refresh_sentinel { - // info!("Generating new sentinel..."); - // let token = generate_sentinel_token().await?; - // let token = SoraSentinel::new(token); - // sora_credentials.sora_sentinel = Some(token); - // credential_updated = true; - //} - - let refresh_sentinel_token = sora_credentials.sora_sentinel_token - .as_ref() - .map(|t| t.is_expired()) - .unwrap_or(true); - - if refresh_sentinel_token { - info!("Refreshing sentinel token..."); - let token = generate_sentinel_token_2().await?; - sora_credentials.sora_sentinel = Some(SoraSentinel::new(token.to_request_header_json()?)); // Legacy - sora_credentials.sora_sentinel_token = Some(token); // New - credential_updated = true; - } - - Ok(credential_updated) -} diff --git a/crates/api_clients/openai_sora_client/src/recipes/mod.rs b/crates/api_clients/openai_sora_client/src/recipes/mod.rs deleted file mode 100644 index 98675c8669..0000000000 --- a/crates/api_clients/openai_sora_client/src/recipes/mod.rs +++ /dev/null @@ -1,11 +0,0 @@ -pub mod generate_sora2_video; -pub mod image_remix_with_session_auto_renew; -pub mod image_upload_from_bytes_with_session_auto_renew; -pub mod image_upload_from_file_with_session_auto_renew; -pub mod list_classic_sora_tasks_with_session_auto_renew; -pub mod list_sora2_drafts; -pub mod maybe_refresh_credentials_on_sora_error; -pub mod maybe_upgrade_or_renew_session; -pub mod simple_image_gen_with_session_auto_renew; -pub mod utils; -pub mod wait_for_image_gen_status; \ No newline at end of file diff --git a/crates/api_clients/openai_sora_client/src/recipes/simple_image_gen_with_session_auto_renew.rs b/crates/api_clients/openai_sora_client/src/recipes/simple_image_gen_with_session_auto_renew.rs deleted file mode 100644 index f005902aee..0000000000 --- a/crates/api_clients/openai_sora_client/src/recipes/simple_image_gen_with_session_auto_renew.rs +++ /dev/null @@ -1,143 +0,0 @@ -use crate::creds::sora_credential_set::SoraCredentialSet; -use crate::creds::sora_jwt_bearer_token::SoraJwtBearerToken; -use crate::creds::sora_sentinel::SoraSentinel; -use crate::error::sora_error::SoraError; -use crate::error::sora_generic_api_error::SoraGenericApiError; -use crate::error::sora_specific_api_error::SoraSpecificApiError; -use crate::requests::auth_bearer::generate_bearer_jwt_with_cookie::generate_bearer_jwt_with_cookie; -use crate::requests::auth_sentinel::generate_sentinel_token::generate_sentinel_token; -use crate::requests::image_gen::common::{ImageSize, NumImages, SoraImageGenResponse}; -use crate::requests::image_gen::sora_image_gen_remix::{sora_image_gen_remix, SoraImageGenRemixRequest}; -use crate::requests::image_gen::sora_image_gen_simple::{sora_image_gen_simple, SoraImageGenSimpleRequest}; -use anyhow::anyhow; -use errors::AnyhowResult; -use log::{error, info, warn}; -use std::time::Duration; - -pub struct SimpleImageGenAutoRenewRequest<'a> { - pub prompt: String, - pub num_images: NumImages, - pub image_size: ImageSize, - pub credentials: &'a SoraCredentialSet, - /// This function can try several different requests. This is the timeout for *individual* requests. - pub request_timeout: Option, -} - -/// Image request with retry and session auto-renewal. -/// If a new sora credential is returned, replace the old one with the new one. -pub async fn simple_image_gen_with_session_auto_renew(request: SimpleImageGenAutoRenewRequest<'_>) -> Result<(SoraImageGenResponse, Option), SoraError> { - let result = sora_image_gen_simple(SoraImageGenSimpleRequest { - prompt: request.prompt.clone(), // NB: Clone because used again - num_images: request.num_images, - image_size: request.image_size, - credentials: request.credentials, - request_timeout: request.request_timeout, - }).await; - - let err = match result { - Ok(response) => return Ok((response, None)), - Err(err) => err, - }; - - warn!("Image generation failed: {:?}", err); - - let mut refresh_jwt = false; - let mut refresh_sentinel = false; - - match err { - // We'll specifically fail these non-retryable requests... - - SoraError::ApiSpecific(SoraSpecificApiError::TooManyConcurrentTasks) | - SoraError::ApiSpecific(SoraSpecificApiError::SoraUsernameNotYetCreated) => { - error!("Non-retryable image generation error: {:?}", err); - return Err(err); - } - - // We'll retry these requests... - - SoraError::ApiSpecific(SoraSpecificApiError::SentinelBlockError) => { - warn!("Image generation failed due to sentinel block error: {:?}", err); - refresh_sentinel = true; - } - SoraError::ApiSpecific(SoraSpecificApiError::TokenExpiredError) => { - warn!("Image generation failed due to token expired error: {:?}", err); - refresh_sentinel = true; // TODO: Not sure what this error is, actually. - refresh_jwt = true; - } - SoraError::ApiSpecific(SoraSpecificApiError::InvalidJwt) => { - warn!("Image generation failed due to invalid jwt error: {:?}", err); - refresh_jwt = true; - } - SoraError::ApiSpecific(SoraSpecificApiError::UnauthorizedCookieOrBearerExpired) => { - warn!("Image generation failed due to auth error (nb: this is a legacy error): {:?}", err); - refresh_jwt = true; - refresh_sentinel = true; - } - - // We'll fail everything else eagerly... - - _ => { - error!("Image generation error: {:?}", err); - return Err(err); - } - } - - let mut new_bearer = None; - - if refresh_jwt { - info!("Generating new JWT bearer token..."); - let cookies = request.credentials.cookies.as_str(); - let response = generate_bearer_jwt_with_cookie(cookies).await; - match response { - Err(err) => { - error!("Error asking to generate JWT: {:?}", err); - return Err(err); - } - Ok(bearer) => { - match SoraJwtBearerToken::new(bearer) { - Err(err) => { - error!("Failed to parse new JWT: {:?}", err); - return Err(err); - } - Ok(bearer) => new_bearer = Some(bearer), - } - }, - } - } - - let mut new_sentinel = None; - - if refresh_sentinel { - info!("Generating new sentinel..."); - let response = generate_sentinel_token().await; - match response { - Err(err) => { - error!("failed to generate new sentinel: {:?}", err); - return Err(err) - } - Ok(sentinel) => new_sentinel = Some(SoraSentinel::new(sentinel)), - } - } - - let mut new_creds = request.credentials.clone(); - - if let Some(bearer) = new_bearer { - new_creds.jwt_bearer_token = Some(bearer); - } - - if let Some(sentinel) = new_sentinel { - new_creds.sora_sentinel = Some(sentinel); - } - - // Now try again... - - let result = sora_image_gen_simple(SoraImageGenSimpleRequest { - prompt: request.prompt, - num_images: request.num_images, - image_size: request.image_size, - credentials: &new_creds, - request_timeout: request.request_timeout, - }).await?; - - Ok((result, Some(new_creds))) -} diff --git a/crates/api_clients/openai_sora_client/src/recipes/utils/maybe_renew_sentinel_token.rs b/crates/api_clients/openai_sora_client/src/recipes/utils/maybe_renew_sentinel_token.rs deleted file mode 100644 index 1c68aedb4e..0000000000 --- a/crates/api_clients/openai_sora_client/src/recipes/utils/maybe_renew_sentinel_token.rs +++ /dev/null @@ -1,35 +0,0 @@ -use crate::creds::sora_credential_set::SoraCredentialSet; -use crate::creds::sora_sentinel_token::SoraSentinelToken; -use crate::error::sora_error::SoraError; -use crate::requests::auth_sentinel_2::generate_sentinel_token_2::generate_sentinel_token_2; -use log::info; - -/// Returns a new sentinel token if one was generated, or None if no update was needed. -pub async fn maybe_renew_sentinel_token(creds: &SoraCredentialSet) -> Result, SoraError> { - let mut refresh_sentinel = false; - - match creds.sora_sentinel_token.as_ref() { - None => { - info!("Sentinel token not set. It needs to be generated..."); - refresh_sentinel = true; - } - Some(sentinel) => { - let expired = sentinel.is_expired(); - if expired { - info!("Sentinel token is expired. It needs to be renewed..."); - refresh_sentinel = true; - } - } - } - - if !refresh_sentinel { - return Ok(None); - } - - let sentinel = generate_sentinel_token_2().await?; - - let mut new_creds = creds.clone(); - new_creds.sora_sentinel_token = Some(sentinel); - - Ok(Some(new_creds)) -} diff --git a/crates/api_clients/openai_sora_client/src/recipes/utils/maybe_renew_session_jwt.rs b/crates/api_clients/openai_sora_client/src/recipes/utils/maybe_renew_session_jwt.rs deleted file mode 100644 index 630a2b568d..0000000000 --- a/crates/api_clients/openai_sora_client/src/recipes/utils/maybe_renew_session_jwt.rs +++ /dev/null @@ -1,48 +0,0 @@ -use crate::creds::sora_credential_set::SoraCredentialSet; -use crate::creds::sora_jwt_bearer_token::SoraJwtBearerToken; -use crate::error::sora_error::SoraError; -use crate::requests::auth_bearer::generate_bearer_jwt_with_cookie::generate_bearer_jwt_with_cookie; -use chrono::{TimeDelta, Utc}; -use log::{info, warn}; -use std::io::Write; -use std::ops::Sub; - -const EXPIRATION_DEADLINE : TimeDelta = TimeDelta::hours(12); - -/// Returns a new set of credentials if they were updated, or None if no update was needed. -pub async fn maybe_renew_session_jwt(creds: &SoraCredentialSet) -> Result, SoraError> { - let mut refresh_jwt = false; - - match creds.jwt_bearer_token.as_ref() { - None => { - info!("JWT not set. It needs to be generated..."); - refresh_jwt = true; - } - Some(jwt) => { - let now = Utc::now(); - let refresh_deadline = now.sub(EXPIRATION_DEADLINE); - if jwt.jwt_claims().expiration.lt(&now) { - info!("JWT expiration time has elapsed. It needs to be renewed..."); - refresh_jwt = true; - } else if jwt.jwt_claims().expiration.lt(&refresh_deadline) { - info!("JWT expiration time is under the expiration deadline. It needs to be renewed..."); - refresh_jwt = true; - } - } - } - - if !refresh_jwt { - return Ok(None); - } - - info!("Refreshing JWT..."); - let token = generate_bearer_jwt_with_cookie(creds.cookies.as_str()).await?; - - info!("Parsing JWT bearer token..."); - let token = SoraJwtBearerToken::new(token)?; - - let mut updated_creds = creds.clone(); - updated_creds.jwt_bearer_token = Some(token); - - Ok(Some(updated_creds)) -} diff --git a/crates/api_clients/openai_sora_client/src/recipes/utils/mod.rs b/crates/api_clients/openai_sora_client/src/recipes/utils/mod.rs deleted file mode 100644 index d84aadc1d9..0000000000 --- a/crates/api_clients/openai_sora_client/src/recipes/utils/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod maybe_renew_session_jwt; -pub mod maybe_renew_sentinel_token; \ No newline at end of file diff --git a/crates/api_clients/openai_sora_client/src/recipes/wait_for_image_gen_status.rs b/crates/api_clients/openai_sora_client/src/recipes/wait_for_image_gen_status.rs deleted file mode 100644 index de8cac04aa..0000000000 --- a/crates/api_clients/openai_sora_client/src/recipes/wait_for_image_gen_status.rs +++ /dev/null @@ -1,50 +0,0 @@ -use crate::creds::sora_credential_set::SoraCredentialSet; -use crate::requests::deprecated::job_status::sora_job_status::{get_image_gen_status, StatusRequest, TaskResponse, TaskStatus, VideoGenStatusResponse}; -use errors::AnyhowResult; - -pub async fn wait_for_image_gen_status(task_id: &String, creds: &SoraCredentialSet, retry_limit: Option) -> AnyhowResult { - let status_request = StatusRequest { - limit: None, - before: None, - // before: Some(task_id.clone()), - }; - let retry_limit = retry_limit.unwrap_or(10); - - for _ in 0..retry_limit { - tokio::time::sleep(std::time::Duration::from_secs(10)).await; - - let status_response = get_image_gen_status(&status_request, &creds).await?; - - match find_task_response_by_id(&status_response, task_id.clone()) { - Some(task_response) => match TaskStatus::from_str(&task_response.status) { - TaskStatus::Succeeded => { - return Ok(task_response.clone()); - }, - TaskStatus::Failed => { - return Err(anyhow::anyhow!("Task failed")); - }, - TaskStatus::Unknown(status) => { - println!("Unknown task status: {}", status); - continue; - }, - TaskStatus::Queued => { - println!("Task is queued"); - continue; - }, - TaskStatus::Running => { - println!("Task is running"); - continue; - }, - }, - None => { - return Err(anyhow::anyhow!("Task not found")); - }, - } - } - - Err(anyhow::anyhow!("Task not found")) -} - -fn find_task_response_by_id(status_response: &VideoGenStatusResponse, task_id: String) -> Option<&TaskResponse> { - status_response.task_responses.iter().find(|task| task.id.0 == task_id) -} diff --git a/crates/api_clients/openai_sora_client/src/requests/auth_bearer/generate_bearer_jwt_with_cookie.rs b/crates/api_clients/openai_sora_client/src/requests/auth_bearer/generate_bearer_jwt_with_cookie.rs deleted file mode 100644 index 59df7982c9..0000000000 --- a/crates/api_clients/openai_sora_client/src/requests/auth_bearer/generate_bearer_jwt_with_cookie.rs +++ /dev/null @@ -1,154 +0,0 @@ -use crate::error::sora_client_error::SoraClientError; -use crate::error::sora_error::SoraError; -use crate::error::sora_generic_api_error::SoraGenericApiError; -use crate::error::sora_specific_api_error::SoraSpecificApiError; -use crate::utils_internal::classify_general_http_error::classify_general_http_error; -use crate::utils_internal::classify_general_http_status_code_and_body::classify_general_http_status_code_and_body; -use errors::AnyhowResult; -use log::{debug, error, info}; -use serde_derive::Deserialize; -use wreq::Client; - -const SORA_BEARER_GENERATE_URL: &str = "https://sora.chatgpt.com/api/auth/session"; - -#[derive(Debug, Deserialize)] -pub struct SoraAuthResponse { - pub user: SoraUser, - pub expires: String, - #[serde(rename = "accessToken")] - pub access_token: String, - #[serde(rename = "internalApiBase")] - pub internal_api_base: Option, -} - -#[derive(Debug, Deserialize)] -pub struct SoraUser { - pub id: String, - pub name: Option, - pub email: Option, - pub image: Option, - pub picture: Option, - pub provider: Option, - #[serde(rename = "lastAuthorizationCheck")] - pub last_authorization_check: Option, -} - -pub async fn generate_bearer_jwt_with_cookie(cookie: &str) -> Result { - let client = Client::builder() - .gzip(true) - .build() - .map_err(|err| { - error!("Error building the client: {:?}", err); - SoraClientError::WreqClientError(err) - })?; - - info!("Generating new JWT bearer token from session cookies... (cookie payload length: {})", cookie.len()); - - let response = client.get(SORA_BEARER_GENERATE_URL) - .header("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:137.0) Gecko/20100101 Firefox/137.0") - .header("Accept", "*/*") - .header("Accept-Encoding", "gzip, deflate, br") - .header("Accept-Language", "en-US,en;q=0.5") - .header("Cookie", cookie) - .send() - .await - .map_err(|err| { - error!("Error sending request: {:?}", err); - SoraGenericApiError::WreqError(err) - })?; - - let status = response.status(); - - let response_body = &response.text().await - .map_err(|err| { - error!("Error reading body while attempting to generate bearer token: {:?}", err); - SoraGenericApiError::WreqError(err) - })?; - - if !status.is_success() { - error!("Failed to generate bearer token with session cookies: {} ; body = {}", status, response_body); - let error = classify_general_http_status_code_and_body(status, &response_body); - return Err(error); - } - - debug!("Bearer token generation response was 200."); - debug!("Auth Response: {}", response_body); - - if response_body == "null" { - error!("Failed to generate bearer token. Response was the string `null`."); - return Err(SoraSpecificApiError::FailedToGenerateBearerToken.into()) - } - - let auth_response: SoraAuthResponse = serde_json::from_str(&response_body) - .map_err(|err| { - error!("Error parsing body while attempting to generate bearer token: {:?}", err); - SoraGenericApiError::SerdeResponseParseErrorWithBody(err, response_body.to_string()) - })?; - - Ok(auth_response.access_token) -} - -#[cfg(test)] -mod tests { - use super::*; - use crate::test_utils::get_test_credentials::get_test_credentials; - - const LOGGED_OUT_COOKIE :&str = ""; - const OLD_COOKIE : &str = ""; - - mod success_case { - use super::*; - - #[tokio::test] - #[ignore] // Don't run in CI. Requires valid cookie - async fn test_generate_bearer_with_cookie() { - let creds = get_test_credentials().unwrap(); - - let cookie = creds.cookies.as_str(); - - let result = generate_bearer_jwt_with_cookie(cookie).await; - - assert!(result.is_ok()); - - let bearer = result.unwrap(); - println!("Bearer token: {}", bearer); - } - } - - mod failure_cases { - use super::*; - - #[tokio::test] - #[ignore] // Don't run in CI. Requires valid cookie - async fn logged_out_cookie_failure() { - let result = generate_bearer_jwt_with_cookie(LOGGED_OUT_COOKIE).await; - - println!("Results: {:?}", result); - - assert!(result.is_ok()); - println!("Bearer token: {}", result.unwrap()); - } - - #[tokio::test] - #[ignore] // Don't run in CI. Requires valid cookie - async fn old_cookie_failure() { - let result = generate_bearer_jwt_with_cookie(LOGGED_OUT_COOKIE).await; - - println!("Results: {:?}", result); - - assert!(result.is_ok()); - println!("Bearer token: {}", result.unwrap()); - } - - #[tokio::test] - #[ignore] // Don't run in CI. Requires valid cookie - async fn invalid_cookie_failure() { - let result = generate_bearer_jwt_with_cookie("").await; - - println!("Results: {:?}", result); - - assert!(result.is_ok()); - println!("Bearer token: {}", result.unwrap()); - } - } -} diff --git a/crates/api_clients/openai_sora_client/src/requests/auth_bearer/mod.rs b/crates/api_clients/openai_sora_client/src/requests/auth_bearer/mod.rs deleted file mode 100644 index 6a2a8a4382..0000000000 --- a/crates/api_clients/openai_sora_client/src/requests/auth_bearer/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod generate_bearer_jwt_with_cookie; \ No newline at end of file diff --git a/crates/api_clients/openai_sora_client/src/requests/auth_sentinel/config.rs b/crates/api_clients/openai_sora_client/src/requests/auth_sentinel/config.rs deleted file mode 100644 index 07aa12ad76..0000000000 --- a/crates/api_clients/openai_sora_client/src/requests/auth_sentinel/config.rs +++ /dev/null @@ -1,671 +0,0 @@ -use rand::Rng; - -// cores = [8, 16, 24, 32] -// cached_scripts = ["https://cdn.oaistatic.com/_next/static/cXh69klOLzS0Gy2joLDRS/_ssgManifest.js?dpl=453ebaec0d44c2decab71692e1bfe39be35a24b3"] - -// cached_dpl = ["prod-f501fe933b3edf57aea882da888e1a544df99840"] - -// navigator_key = [ -// "registerProtocolHandler−function registerProtocolHandler() { [native code] }", -// "storage−[object StorageManager]", -// "locks−[object LockManager]", -// "appCodeName−Mozilla", -// "permissions−[object Permissions]", -// "share−function share() { [native code] }", -// "webdriver−false", -// "managed−[object NavigatorManagedData]", -// "canShare−function canShare() { [native code] }", -// "vendor−Google Inc.", -// "vendor−Google Inc.", -// "mediaDevices−[object MediaDevices]", -// "vibrate−function vibrate() { [native code] }", -// "storageBuckets−[object StorageBucketManager]", -// "mediaCapabilities−[object MediaCapabilities]", -// "getGamepads−function getGamepads() { [native code] }", -// "bluetooth−[object Bluetooth]", -// "share−function share() { [native code] }", -// "cookieEnabled−true", -// "virtualKeyboard−[object VirtualKeyboard]", -// "product−Gecko", -// "mediaDevices−[object MediaDevices]", -// "canShare−function canShare() { [native code] }", -// "getGamepads−function getGamepads() { [native code] }", -// "product−Gecko", -// "xr−[object XRSystem]", -// "clipboard−[object Clipboard]", -// "storageBuckets−[object StorageBucketManager]", -// "unregisterProtocolHandler−function unregisterProtocolHandler() { [native code] }", -// "productSub−20030107", -// "login−[object NavigatorLogin]", -// "vendorSub−", -// "login−[object NavigatorLogin]", -// "getInstalledRelatedApps−function getInstalledRelatedApps() { [native code] }", -// "mediaDevices−[object MediaDevices]", -// "locks−[object LockManager]", -// "webkitGetUserMedia−function webkitGetUserMedia() { [native code] }", -// "vendor−Google Inc.", -// "xr−[object XRSystem]", -// "mediaDevices−[object MediaDevices]", -// "virtualKeyboard−[object VirtualKeyboard]", -// "virtualKeyboard−[object VirtualKeyboard]", -// "appName−Netscape", -// "storageBuckets−[object StorageBucketManager]", -// "presentation−[object Presentation]", -// "onLine−true", -// "mimeTypes−[object MimeTypeArray]", -// "credentials−[object CredentialsContainer]", -// "presentation−[object Presentation]", -// "getGamepads−function getGamepads() { [native code] }", -// "vendorSub−", -// "virtualKeyboard−[object VirtualKeyboard]", -// "serviceWorker−[object ServiceWorkerContainer]", -// "xr−[object XRSystem]", -// "product−Gecko", -// "keyboard−[object Keyboard]", -// "gpu−[object GPU]", -// "getInstalledRelatedApps−function getInstalledRelatedApps() { [native code] }", -// "webkitPersistentStorage−[object DeprecatedStorageQuota]", -// "doNotTrack", -// "clearAppBadge−function clearAppBadge() { [native code] }", -// "presentation−[object Presentation]", -// "serial−[object Serial]", -// "locks−[object LockManager]", -// "requestMIDIAccess−function requestMIDIAccess() { [native code] }", -// "locks−[object LockManager]", -// "requestMediaKeySystemAccess−function requestMediaKeySystemAccess() { [native code] }", -// "vendor−Google Inc.", -// "pdfViewerEnabled−true", -// "language−zh-CN", -// "setAppBadge−function setAppBadge() { [native code] }", -// "geolocation−[object Geolocation]", -// "userAgentData−[object NavigatorUAData]", -// "mediaCapabilities−[object MediaCapabilities]", -// "requestMIDIAccess−function requestMIDIAccess() { [native code] }", -// "getUserMedia−function getUserMedia() { [native code] }", -// "mediaDevices−[object MediaDevices]", -// "webkitPersistentStorage−[object DeprecatedStorageQuota]", -// "sendBeacon−function sendBeacon() { [native code] }", -// "hardwareConcurrency−32", -// "credentials−[object CredentialsContainer]", -// "storage−[object StorageManager]", -// "cookieEnabled−true", -// "pdfViewerEnabled−true", -// "windowControlsOverlay−[object WindowControlsOverlay]", -// "scheduling−[object Scheduling]", -// "pdfViewerEnabled−true", -// "hardwareConcurrency−32", -// "xr−[object XRSystem]", -// "webdriver−false", -// "getInstalledRelatedApps−function getInstalledRelatedApps() { [native code] }", -// "getInstalledRelatedApps−function getInstalledRelatedApps() { [native code] }", -// "bluetooth−[object Bluetooth]" -// ] - -// document_key = ['_reactListeningo743lnnpvdg', 'location'] - -// window_key = [ -// "0", -// "window", -// "self", -// "document", -// "name", -// "location", -// "customElements", -// "history", -// "navigation", -// "locationbar", -// "menubar", -// "personalbar", -// "scrollbars", -// "statusbar", -// "toolbar", -// "status", -// "closed", -// "frames", -// "length", -// "top", -// "opener", -// "parent", -// "frameElement", -// "navigator", -// "origin", -// "external", -// "screen", -// "innerWidth", -// "innerHeight", -// "scrollX", -// "pageXOffset", -// "scrollY", -// "pageYOffset", -// "visualViewport", -// "screenX", -// "screenY", -// "outerWidth", -// "outerHeight", -// "devicePixelRatio", -// "clientInformation", -// "screenLeft", -// "screenTop", -// "styleMedia", -// "onsearch", -// "isSecureContext", -// "trustedTypes", -// "performance", -// "onappinstalled", -// "onbeforeinstallprompt", -// "crypto", -// "indexedDB", -// "sessionStorage", -// "localStorage", -// "onbeforexrselect", -// "onabort", -// "onbeforeinput", -// "onbeforematch", -// "onbeforetoggle", -// "onblur", -// "oncancel", -// "oncanplay", -// "oncanplaythrough", -// "onchange", -// "onclick", -// "onclose", -// "oncontentvisibilityautostatechange", -// "oncontextlost", -// "oncontextmenu", -// "oncontextrestored", -// "oncuechange", -// "ondblclick", -// "ondrag", -// "ondragend", -// "ondragenter", -// "ondragleave", -// "ondragover", -// "ondragstart", -// "ondrop", -// "ondurationchange", -// "onemptied", -// "onended", -// "onerror", -// "onfocus", -// "onformdata", -// "oninput", -// "oninvalid", -// "onkeydown", -// "onkeypress", -// "onkeyup", -// "onload", -// "onloadeddata", -// "onloadedmetadata", -// "onloadstart", -// "onmousedown", -// "onmouseenter", -// "onmouseleave", -// "onmousemove", -// "onmouseout", -// "onmouseover", -// "onmouseup", -// "onmousewheel", -// "onpause", -// "onplay", -// "onplaying", -// "onprogress", -// "onratechange", -// "onreset", -// "onresize", -// "onscroll", -// "onsecuritypolicyviolation", -// "onseeked", -// "onseeking", -// "onselect", -// "onslotchange", -// "onstalled", -// "onsubmit", -// "onsuspend", -// "ontimeupdate", -// "ontoggle", -// "onvolumechange", -// "onwaiting", -// "onwebkitanimationend", -// "onwebkitanimationiteration", -// "onwebkitanimationstart", -// "onwebkittransitionend", -// "onwheel", -// "onauxclick", -// "ongotpointercapture", -// "onlostpointercapture", -// "onpointerdown", -// "onpointermove", -// "onpointerrawupdate", -// "onpointerup", -// "onpointercancel", -// "onpointerover", -// "onpointerout", -// "onpointerenter", -// "onpointerleave", -// "onselectstart", -// "onselectionchange", -// "onanimationend", -// "onanimationiteration", -// "onanimationstart", -// "ontransitionrun", -// "ontransitionstart", -// "ontransitionend", -// "ontransitioncancel", -// "onafterprint", -// "onbeforeprint", -// "onbeforeunload", -// "onhashchange", -// "onlanguagechange", -// "onmessage", -// "onmessageerror", -// "onoffline", -// "ononline", -// "onpagehide", -// "onpageshow", -// "onpopstate", -// "onrejectionhandled", -// "onstorage", -// "onunhandledrejection", -// "onunload", -// "crossOriginIsolated", -// "scheduler", -// "alert", -// "atob", -// "blur", -// "btoa", -// "cancelAnimationFrame", -// "cancelIdleCallback", -// "captureEvents", -// "clearInterval", -// "clearTimeout", -// "close", -// "confirm", -// "createImageBitmap", -// "fetch", -// "find", -// "focus", -// "getComputedStyle", -// "getSelection", -// "matchMedia", -// "moveBy", -// "moveTo", -// "open", -// "postMessage", -// "print", -// "prompt", -// "queueMicrotask", -// "releaseEvents", -// "reportError", -// "requestAnimationFrame", -// "requestIdleCallback", -// "resizeBy", -// "resizeTo", -// "scroll", -// "scrollBy", -// "scrollTo", -// "setInterval", -// "setTimeout", -// "stop", -// "structuredClone", -// "webkitCancelAnimationFrame", -// "webkitRequestAnimationFrame", -// "chrome", -// "caches", -// "cookieStore", -// "ondevicemotion", -// "ondeviceorientation", -// "ondeviceorientationabsolute", -// "launchQueue", -// "documentPictureInPicture", -// "getScreenDetails", -// "queryLocalFonts", -// "showDirectoryPicker", -// "showOpenFilePicker", -// "showSaveFilePicker", -// "originAgentCluster", -// "onpageswap", -// "onpagereveal", -// "credentialless", -// "speechSynthesis", -// "onscrollend", -// "webkitRequestFileSystem", -// "webkitResolveLocalFileSystemURL", -// "sendMsgToSolverCS", -// "webpackChunk_N_E", -// "__next_set_public_path__", -// "next", -// "__NEXT_DATA__", -// "__SSG_MANIFEST_CB", -// "__NEXT_P", -// "_N_E", -// "regeneratorRuntime", -// "__REACT_INTL_CONTEXT__", -// "DD_RUM", -// "_", -// "filterCSS", -// "filterXSS", -// "__SEGMENT_INSPECTOR__", -// "__NEXT_PRELOADREADY", -// "Intercom", -// "__MIDDLEWARE_MATCHERS", -// "__STATSIG_SDK__", -// "__STATSIG_JS_SDK__", -// "__STATSIG_RERENDER_OVERRIDE__", -// "_oaiHandleSessionExpired", -// "__BUILD_MANIFEST", -// "__SSG_MANIFEST", -// "__intercomAssignLocation", -// "__intercomReloadLocation" -// ] - - -const CORES: &[usize] = &[8, 16, 24, 32]; - -const CACHED_SCRIPTS: &[&str] = &["https://cdn.oaistatic.com/_next/static/cXh69klOLzS0Gy2joLDRS/_ssgManifest.js?dpl=453ebaec0d44c2decab71692e1bfe39be35a24b3"]; - -const CACHED_DPL: &[&str] = &["prod-f501fe933b3edf57aea882da888e1a544df99840"]; - -const NAVIGATOR_KEY: &[&str] = &[ - "registerProtocolHandler−function registerProtocolHandler() { [native code] }", - "storage−[object StorageManager]", - "locks−[object LockManager]", - "appCodeName−Mozilla", - "permissions−[object Permissions]", - "share−function share() { [native code] }", - "webdriver−false", - "managed−[object NavigatorManagedData]", - "canShare−function canShare() { [native code] }", - "vendor−Google Inc.", - "vendor−Google Inc.", - "mediaDevices−[object MediaDevices]", - "vibrate−function vibrate() { [native code] }", - "storageBuckets−[object StorageBucketManager]", - "mediaCapabilities−[object MediaCapabilities]", - "getGamepads−function getGamepads() { [native code] }", - "bluetooth−[object Bluetooth]", - "share−function share() { [native code] }", - "cookieEnabled−true", - "pdfViewerEnabled−true", - "windowControlsOverlay−[object WindowControlsOverlay]", - "scheduling−[object Scheduling]", - "pdfViewerEnabled−true", - "hardwareConcurrency−32", - "xr−[object XRSystem]", - "webdriver−false", - "getInstalledRelatedApps−function getInstalledRelatedApps() { [native code] }", - "getInstalledRelatedApps−function getInstalledRelatedApps() { [native code] }", - "bluetooth−[object Bluetooth]" -]; - -const DOCUMENT_KEY: &[&str] = &["_reactListeningo743lnnpvdg", "location"]; - -const WINDOW_KEY: &[&str] = &[ - "0", - "window", - "self", - "document", - "name", - "location", - "customElements", - "history", - "navigation", - "locationbar", - "menubar", - "personalbar", - "scrollbars", - "statusbar", - "toolbar", - "status", - "closed", - "frames", - "length", - "top", - "opener", - "parent", - "frameElement", - "navigator", - "origin", - "external", - "screen", - "innerWidth", - "innerHeight", - "scrollX", - "pageXOffset", - "scrollY", - "pageYOffset", - "visualViewport", - "screenX", - "screenY", - "outerWidth", - "outerHeight", - "devicePixelRatio", - "clientInformation", - "screenLeft", - "screenTop", - "styleMedia", - "onsearch", - "isSecureContext", - "trustedTypes", - "performance", - "onappinstalled", - "onbeforeinstallprompt", - "crypto", - "indexedDB", - "sessionStorage", - "localStorage", - "onbeforexrselect", - "onabort", - "onbeforeinput", - "onbeforematch", - "onbeforetoggle", - "onblur", - "oncancel", - "oncanplay", - "oncanplaythrough", - "onchange", - "onclick", - "onclose", - "oncontentvisibilityautostatechange", - "oncontextlost", - "oncontextmenu", - "oncontextrestored", - "oncuechange", - "ondblclick", - "ondrag", - "ondragend", - "ondragenter", - "ondragleave", - "ondragover", - "ondragstart", - "ondrop", - "ondurationchange", - "onemptied", - "onended", - "onerror", - "onfocus", - "onformdata", - "oninput", - "oninvalid", - "onkeydown", - "onkeypress", - "onkeyup", - "onload", - "onloadeddata", - "onloadedmetadata", - "onloadstart", - "onmousedown", - "onmouseenter", - "onmouseleave", - "onmousemove", - "onmouseout", - "onmouseover", - "onmouseup", - "onmousewheel", - "onpause", - "onplay", - "onplaying", - "onprogress", - "onratechange", - "onreset", - "onresize", - "onscroll", - "onsecuritypolicyviolation", - "onseeked", - "onseeking", - "onselect", - "onslotchange", - "onstalled", - "onsubmit", - "onsuspend", - "ontimeupdate", - "ontoggle", - "onvolumechange", - "onwaiting", - "onwebkitanimationend", - "onwebkitanimationiteration", - "onwebkitanimationstart", - "onwebkittransitionend", - "onwheel", - "onauxclick", - "ongotpointercapture", - "onlostpointercapture", - "onpointerdown", - "onpointermove", - "onpointerrawupdate", - "onpointerup", - "onpointercancel", - "onpointerover", - "onpointerout", - "onpointerenter", - "onpointerleave", - "onselectstart", - "onselectionchange", - "onanimationend", - "onanimationiteration", - "onanimationstart", - "ontransitionrun", - "ontransitionstart", - "ontransitionend", - "ontransitioncancel", - "onafterprint", - "onbeforeprint", - "onbeforeunload", - "onhashchange", - "onlanguagechange", - "onmessage", - "onmessageerror", - "onoffline", - "ononline", - "onpagehide", - "onpageshow", - "onpopstate", - "onrejectionhandled", - "onstorage", - "onunhandledrejection", - "onunload", - "crossOriginIsolated", - "scheduler", - "alert", - "atob", - "blur", - "btoa", - "cancelAnimationFrame", - "cancelIdleCallback", - "captureEvents", - "clearInterval", - "clearTimeout", - "close", - "confirm", - "createImageBitmap", - "fetch", - "find", - "focus", - "getComputedStyle", - "getSelection", - "matchMedia", - "moveBy", - "moveTo", - "open", - "postMessage", - "print", - "prompt", - "queueMicrotask", - "releaseEvents", - "reportError", - "requestAnimationFrame", - "requestIdleCallback", - "resizeBy", - "resizeTo", - "scroll", - "scrollBy", - "scrollTo", - "setInterval", - "setTimeout", - "stop", - "structuredClone", - "webkitCancelAnimationFrame", - "webkitRequestAnimationFrame", - "chrome", - "caches", - "cookieStore", - "ondevicemotion", - "ondeviceorientation", - "ondeviceorientationabsolute", - "launchQueue", - "documentPictureInPicture", - "getScreenDetails", - "queryLocalFonts", - "showDirectoryPicker", - "showOpenFilePicker", - "showSaveFilePicker", - "originAgentCluster", - "onpageswap", - "onpagereveal", - "credentialless", - "speechSynthesis", - "onscrollend", - "webkitRequestFileSystem", - "webkitResolveLocalFileSystemURL", - "sendMsgToSolverCS", - "webpackChunk_N_E", - "__next_set_public_path__", - "next", - "__NEXT_DATA__", - "__SSG_MANIFEST_CB", - "__NEXT_P", - "_N_E", - "regeneratorRuntime", - "__REACT_INTL_CONTEXT__", - "DD_RUM", - "_", - "filterCSS", - "filterXSS", - "__SEGMENT_INSPECTOR__", - "__NEXT_PRELOADREADY", - "Intercom", - "__MIDDLEWARE_MATCHERS", - "__STATSIG_SDK__", - "__STATSIG_JS_SDK__", - "__STATSIG_RERENDER_OVERRIDE__", - "_oaiHandleSessionExpired", - "__BUILD_MANIFEST", - "__SSG_MANIFEST", - "__intercomAssignLocation", - "__intercomReloadLocation" -]; - -pub fn get_random_core_count() -> usize { - CORES[rand::rng().random_range(0..CORES.len())] -} - -pub fn get_random_navigator_key() -> String { - NAVIGATOR_KEY[rand::rng().random_range(0..NAVIGATOR_KEY.len())].to_string() -} - -pub fn get_random_document_key() -> String { - DOCUMENT_KEY[rand::rng().random_range(0..DOCUMENT_KEY.len())].to_string() -} - -pub fn get_random_window_key() -> String { - WINDOW_KEY[rand::rng().random_range(0..WINDOW_KEY.len())].to_string() -} diff --git a/crates/api_clients/openai_sora_client/src/requests/auth_sentinel/generate_sentinel_token.rs b/crates/api_clients/openai_sora_client/src/requests/auth_sentinel/generate_sentinel_token.rs deleted file mode 100644 index 9491c3207b..0000000000 --- a/crates/api_clients/openai_sora_client/src/requests/auth_sentinel/generate_sentinel_token.rs +++ /dev/null @@ -1,97 +0,0 @@ -use super::request::GenerateSentinelRefreshRequest; -use crate::constants::user_agent::CLIENT_USER_AGENT; -use crate::error::sora_error::SoraError; -use crate::error::sora_generic_api_error::SoraGenericApiError; -use crate::utils_internal::classify_general_http_error::classify_general_http_error; -use errors::AnyhowResult; -use uuid_utils::uuid::generate_random_uuid; -use log::error; -use serde_derive::{Deserialize, Serialize}; -use thiserror::Error; -use wreq::Client; - -const SORA_IMAGE_GEN_URL: &str = "https://chatgpt.com/backend-api/sentinel/req"; - -const SENTINEL_FLOW: &str = "sora_create_task"; - - -#[derive(Debug, Serialize, Deserialize)] -pub struct SentinelRequest { - #[serde(rename = "p")] - problem: String, - - #[serde(rename = "id")] - id: String, - - #[serde(rename = "flow")] - flow: String, -} - - -impl SentinelRequest { - pub fn new(problem: String) -> Self { - let id = generate_random_uuid(); - Self { problem, id, flow: SENTINEL_FLOW.to_string() } - } -} - - -#[derive(Debug, Serialize, Deserialize)] -pub struct SentinelResponse { - persona: String, - token: String, -} - - -/// Note: This looks like an incomplete implementation of the original Python implementation. -/// Curiously, it worked with Sora 1.0 (and continues to work), but it fails for Sora 2.0 while the -/// unchanged Python implementation works. We'll be deprecating this. -#[deprecated(note="use new sentinel token flow")] -pub async fn generate_sentinel_token() -> Result { - let (_request, base64_request) = GenerateSentinelRefreshRequest::new().with_fourth_and_tenth(); - let request = SentinelRequest::new(base64_request); - let client = Client::new(); - let response = client.post(SORA_IMAGE_GEN_URL) - .header("User-Agent", CLIENT_USER_AGENT) - .header("Content-Type", "application/json") - .json(&request) - .send() - .await - .map_err(|err| { - error!("Client failed to generate sentinel token: {:?}", err); - SoraGenericApiError::WreqError(err) - })?; - - if !response.status().is_success() { - error!("Failed to generate sentinel: {}", response.status()); - let error = classify_general_http_error(response).await; - return Err(error); - } - - let text_body = &response.text().await - .map_err(|err| { - error!("sora error reading sentinel token text body: {}", err); - SoraGenericApiError::WreqError(err) - })?; - - let response = serde_json::from_str::(&text_body) - .map_err(|err| { - error!("Failed to parse media list response: {}", err); - SoraGenericApiError::SerdeResponseParseErrorWithBody(err, text_body.to_string()) - })?; - - Ok(response.token) -} - - -#[cfg(test)] -mod tests { - use super::*; - - #[tokio::test] - #[ignore] // Only manually trigger this - async fn test_generate_token() { - let token = generate_sentinel_token().await.unwrap(); - println!("{}", token); - } -} \ No newline at end of file diff --git a/crates/api_clients/openai_sora_client/src/requests/auth_sentinel/mod.rs b/crates/api_clients/openai_sora_client/src/requests/auth_sentinel/mod.rs deleted file mode 100644 index 0c1f2e887f..0000000000 --- a/crates/api_clients/openai_sora_client/src/requests/auth_sentinel/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub mod generate_sentinel_token; -pub mod request; -pub(crate) mod config; \ No newline at end of file diff --git a/crates/api_clients/openai_sora_client/src/requests/auth_sentinel/request.rs b/crates/api_clients/openai_sora_client/src/requests/auth_sentinel/request.rs deleted file mode 100644 index 057aab068c..0000000000 --- a/crates/api_clients/openai_sora_client/src/requests/auth_sentinel/request.rs +++ /dev/null @@ -1,225 +0,0 @@ -use crate::requests::auth_sentinel::config::{get_random_core_count, get_random_document_key, get_random_navigator_key, get_random_window_key}; -use base64::prelude::BASE64_STANDARD; -use base64::Engine; -use chrono::FixedOffset; -use chrono::Utc; -use uuid_utils::uuid::generate_random_uuid; -use rand::Rng; -use sha3::{Digest, Sha3_512}; - -// [ -// 4000, // first -// "Fri Apr 11 2025 13:28:14 GMT+0530 (India Standard Time)", // second -// None, // third -// 28, // fourth -// "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:137.0) Gecko/20100101 Firefox/137.0", // fifth -// "https://sora-cdn.oaistatic.com/_next/static/chunks/f90f2e60-61da6d33257661c4.js", // sixth -// None, // seventh -// "en-US", // eighth -// "en-US,en", // ninth -// 29, // tenth -// "productSub−20100101", // eleventh -// "location", // twelfth -// "ondrop", // thirteenth -// 10520, // fourteenth - generated from time.perf_counter() * 1000 -// "48094014-a024-4d2d-8ec4-ba9c7cfef9c4", // fifteenth -// "", // sixteenth -// 16, // seventeenth - Number of cores -#[derive(Debug, Clone)] -pub struct GenerateSentinelRefreshRequest { - first: usize, - second: String, // Date - third: Option, - fourth: Option, - fifth: String, // User agent - sixth: String, // URL - seventh: Option, // Language - eighth: String, // Accept-Language - ninth: String, // Product Sub - tenth: Option, - eleventh: String, // Product Sub - Navigator key - twelfth: String, // Location - Document key - thirteenth: String, // On Drop - Window key - fourteenth: usize, // generated from time.perf_counter() * 1000 - fifteenth: String, // UUID - sixteenth: String, // empty string - seventeenth: usize, // Number of cores -} - -fn generate_date() -> String { - let now_utc = Utc::now(); - let offset = FixedOffset::west_opt(5 * 60 * 60).unwrap(); - let now_with_offset = Utc::now().with_timezone(&offset); - - let formatted_date = now_with_offset.format("%a %b %d %Y %H:%M:%S GMT-0500 (Eastern Standard Time)"); - return formatted_date.to_string(); -} - -impl GenerateSentinelRefreshRequest { - pub fn new() -> Self { - let first_candidates = vec![1920 + 1080, 2560 + 1440, 1920 + 1200, 2560 + 1600]; - let first = first_candidates[rand::rng().random_range(0..first_candidates.len())]; - - let second = generate_date(); - - let third = None; - - let fourth = None; - - let fifth = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:137.0) Gecko/20100101 Firefox/137.0".to_string(); - - let sixth = "https://sora-cdn.oaistatic.com/_next/static/chunks/f90f2e60-61da6d33257661c4.js".to_string(); - - let seventh = None; - - let eighth = "en-US".to_string(); - - let ninth = "en-US,en".to_string(); - - let tenth = None; - - let eleventh = get_random_navigator_key(); - - let twelfth = get_random_document_key(); - - let thirteenth = get_random_window_key(); - - let fourteenth = 10520; - - let fifteenth = generate_random_uuid(); - - let sixteenth = "".to_string(); - - let seventeenth = get_random_core_count(); - Self { first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh: eleventh.to_string(), twelfth: twelfth.to_string(), thirteenth: thirteenth.to_string(), fourteenth, fifteenth, sixteenth, seventeenth } - } - - pub fn with_fourth(mut self, fourth: usize) -> Self { - self.fourth = Some(fourth); - self - } - - pub fn with_tenth(mut self, tenth: usize) -> Self { - self.tenth = Some(tenth); - self - } - - //TODO(kasisnu): This is a temporary function to build the request. - // It is extremely hacky and this whole struct should be rewritten to be more ergonomic. - pub fn build(self) -> String { - let mut request = String::new(); - request.push_str("["); - request.push_str(&self.first.to_string()); - request.push_str(","); - request.push_str(&string_with_quotes(self.second)); - request.push_str(","); - request.push_str(&self.third.unwrap_or("null".to_string())); - request.push_str(","); - request.push_str(&self.fourth.unwrap_or(0).to_string()); - request.push_str(","); - request.push_str(&string_with_quotes(self.fifth)); - request.push_str(","); - request.push_str(&string_with_quotes(self.sixth)); - request.push_str(","); - request.push_str(&self.seventh.unwrap_or("null".to_string())); - request.push_str(","); - request.push_str(&string_with_quotes(self.eighth)); - request.push_str(","); - request.push_str(&string_with_quotes(self.ninth)); - request.push_str(","); - request.push_str(&self.tenth.unwrap_or(0).to_string()); - request.push_str(","); - request.push_str(&string_with_quotes(self.eleventh)); - request.push_str(","); - request.push_str(&string_with_quotes(self.twelfth)); - request.push_str(","); - request.push_str(&string_with_quotes(self.thirteenth)); - request.push_str(","); - request.push_str(&self.fourteenth.to_string()); - request.push_str(","); - request.push_str(&string_with_quotes(self.fifteenth)); - request.push_str(","); - request.push_str(&string_with_quotes(self.sixteenth)); - request.push_str(","); - request.push_str(&self.seventeenth.to_string()); - request.push_str("]"); - request - } - - pub fn hash_request(seed: f64, request: String) -> Vec { - let mut hasher = Sha3_512::new(); - hasher.update(seed.to_string()); - let base64_request = BASE64_STANDARD.encode(request.as_bytes()); - hasher.update(base64_request); - hasher.finalize().to_vec() - } - - pub fn with_fourth_and_tenth(mut self) -> (Self, String) { - let mut fourth = 0; - let mut tenth = 0; - let max_iterations = 500000; - let diff_len = 6; - let target_bytes = vec![0x0f, 0xff, 0xff]; - let random_seed: f64 = rand::rng().random(); - - let mut base64_request = BASE64_STANDARD.encode(self.clone().build().as_bytes()); - for i in 0..max_iterations { - fourth = i; - tenth = i >> 1; - let request = self.clone().with_fourth(fourth).with_tenth(tenth).build(); - let hash_bytes = Self::hash_request(random_seed, request.clone()); - base64_request = BASE64_STANDARD.encode(request.as_bytes()); - - let mut is_less_or_equal = true; - for j in 0..std::cmp::min(diff_len, target_bytes.len()) { - if j < hash_bytes.len() { - if hash_bytes[j] > target_bytes[j] { - is_less_or_equal = false; - break; - } else if hash_bytes[j] < target_bytes[j] { - break; - } - } - } - - if is_less_or_equal { - break; - } - } - - (self.with_fourth(fourth).with_tenth(tenth), format!("gAAAAAC{}", base64_request)) - } -} - -fn string_with_quotes(value: String) -> String { - format!("\"{}\"", value) -} -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn test_generate_sentinel_refresh_request() { - let request = GenerateSentinelRefreshRequest::new(); - println!("{}", request.build()); - } - - #[test] - fn test_with_fourth_and_tenth() { - let request = GenerateSentinelRefreshRequest::new().with_fourth(100).with_tenth(200); - println!("{}", request.build()); - } - - #[test] - fn test_hash_request() { - let request = GenerateSentinelRefreshRequest::new().with_fourth(100).with_tenth(200); - let hash = GenerateSentinelRefreshRequest::hash_request(0.1, request.build()); - println!("{}", hash.iter().map(|b| format!("{:02x}", b)).collect::()); - } - - #[test] - fn test_with_fourth_and_tenth_2() { - let (request, base64_request) = GenerateSentinelRefreshRequest::new().with_fourth_and_tenth(); - println!("{}", base64_request); - } -} diff --git a/crates/api_clients/openai_sora_client/src/requests/auth_sentinel_2/extract_expiry.rs b/crates/api_clients/openai_sora_client/src/requests/auth_sentinel_2/extract_expiry.rs deleted file mode 100644 index fa62c931e6..0000000000 --- a/crates/api_clients/openai_sora_client/src/requests/auth_sentinel_2/extract_expiry.rs +++ /dev/null @@ -1,62 +0,0 @@ -use crate::requests::auth_sentinel_2::response::SentinelResponse; -use chrono::{DateTime, TimeDelta, Utc}; -use log::{info, warn}; -use std::f32::consts::E; - -// Sora's servers typically tell us to expire in nine minutes (540 seconds). -const DEFAULT_EXPIRE_SECONDS : u32 = 60 * 3; // 3 minutes. - -pub (super) struct ExtractedExpiry { - pub (super) generated_at: DateTime, - pub (super) expires_in_seconds: u32, -} - -pub (super) fn extract_expiry(generated_at: DateTime, response: &SentinelResponse) -> ExtractedExpiry { - info!("Sentinel expires at: {:?} (in {:?} seconds)", response.expire_at, response.expire_after); - - const LOWER_BOUNDS_SECONDS: u32 = 60; - const UPPER_BOUNDS_SECONDS: u32 = 60 * 60; - - // Trust the `expire_at` timestamp first. - let mut maybe_expires_at = response.expire_at - .map(|timestamp| DateTime::from_timestamp(timestamp as i64, 0)) - .flatten(); - - if let Some(expires_at) = maybe_expires_at { - let seconds = expires_at.signed_duration_since(generated_at).num_seconds(); - - const LOWER_BOUNDS_SECONDS_I64: i64 = LOWER_BOUNDS_SECONDS as i64; - const UPPER_BOUNDS_SECONDS_I64: i64 = UPPER_BOUNDS_SECONDS as i64; - - if seconds.is_positive() - && seconds > LOWER_BOUNDS_SECONDS_I64 - && seconds < UPPER_BOUNDS_SECONDS_I64 - { - info!("Using sentinel expire_at timestamp, expires in {} seconds (at {})", seconds, expires_at); - - return ExtractedExpiry { - generated_at, - expires_in_seconds: seconds as u32, - } - } - } - - let mut expires_in_seconds = response.expire_after - .unwrap_or_else(|| { - warn!("No default expire_after from sentinel response, defaulting to {} seconds", DEFAULT_EXPIRE_SECONDS); - DEFAULT_EXPIRE_SECONDS - }); - - if expires_in_seconds < LOWER_BOUNDS_SECONDS { - warn!("Warning: sentinel token expires very soon: {} seconds, defaulting to {} seconds", expires_in_seconds, DEFAULT_EXPIRE_SECONDS); - expires_in_seconds = DEFAULT_EXPIRE_SECONDS; - } else if expires_in_seconds > UPPER_BOUNDS_SECONDS { - warn!("Warning: sentinel token expires very late: {} seconds, defaulting to {} seconds", expires_in_seconds, DEFAULT_EXPIRE_SECONDS); - expires_in_seconds = DEFAULT_EXPIRE_SECONDS; - } - - ExtractedExpiry { - generated_at, - expires_in_seconds, - } -} diff --git a/crates/api_clients/openai_sora_client/src/requests/auth_sentinel_2/generate_sentinel_token_2.rs b/crates/api_clients/openai_sora_client/src/requests/auth_sentinel_2/generate_sentinel_token_2.rs deleted file mode 100644 index e1adb119d0..0000000000 --- a/crates/api_clients/openai_sora_client/src/requests/auth_sentinel_2/generate_sentinel_token_2.rs +++ /dev/null @@ -1,169 +0,0 @@ -use crate::constants::user_agent::CLIENT_USER_AGENT; -use crate::creds::sora_sentinel_token::{RawSoraSentinelToken, SoraSentinelToken}; -use crate::error::sora_error::SoraError; -use crate::error::sora_generic_api_error::SoraGenericApiError; -use crate::error::sora_specific_api_error::SoraSpecificApiError; -use crate::requests::auth_sentinel::request::GenerateSentinelRefreshRequest; -use crate::requests::auth_sentinel_2::extract_expiry::extract_expiry; -use crate::requests::auth_sentinel_2::request::SentinelRequest; -use crate::requests::auth_sentinel_2::response::SentinelResponse; -use crate::utils_internal::classify_general_http_error::classify_general_http_error; -use chrono::{DateTime, NaiveDateTime, TimeDelta, TimeZone, Utc}; -use errors::AnyhowResult; -use uuid_utils::uuid::generate_random_uuid; -use log::{debug, error, info}; -use serde_derive::{Deserialize, Serialize}; -use std::io::Write; -use thiserror::Error; -use wreq::header::{ACCEPT, ACCEPT_LANGUAGE, AUTHORIZATION, CONTENT_TYPE, COOKIE, ORIGIN, REFERER, USER_AGENT}; -use wreq::Client; - -const SORA_SENTINEL_ENDPOINT: &str = "https://chatgpt.com/backend-api/sentinel/req"; - - -/// This generates a Sentinel Token that works with Sora 1.0 and Sora 2.0 consumer products. -pub async fn generate_sentinel_token_2() -> Result { - let (_request, base64_request) = GenerateSentinelRefreshRequest::new().with_fourth_and_tenth(); - - let request = SentinelRequest::new(base64_request); - let client = Client::new(); - - let request_builder = client.post(SORA_SENTINEL_ENDPOINT) - .header(USER_AGENT, CLIENT_USER_AGENT) - .header(ACCEPT, "*/*") - .header(ACCEPT_LANGUAGE, "en-US,en;q=0.9") - // TODO: Accept-Encoding - // TODO: Cookie - .header(REFERER, "https://chatgpt.com/backend-api/sentinel/frame.html") - .header(CONTENT_TYPE, "application/json") - .header(ORIGIN, "https://chatgpt.com") - .header("sec-gpc", "1") - .header("sec-fetch-dest", "empty") - .header("sec-fetch-mode", "cors") - .header("sec-fetch-site", "same-origin") - .header("priority", "u=4") - .header("te", "trailers"); - - let response = request_builder - .json(&request) - .send() - .await - .map_err(|err| { - error!("Client failed to generate sentinel token: {:?}", err); - SoraGenericApiError::WreqError(err) - })?; - - if !response.status().is_success() { - error!("Failed to generate sentinel: {}", response.status()); - let error = classify_general_http_error(response).await; - return Err(error); - } - - let text_body = &response.text().await - .map_err(|err| { - error!("sora error reading sentinel token text body: {}", err); - SoraGenericApiError::WreqError(err) - })?; - - debug!("Sentinel endpoint response body: {}", text_body); - - let response = serde_json::from_str::(&text_body) - .map_err(|err| { - error!("Failed to parse sentinel token response: {}", err); - SoraGenericApiError::SerdeResponseParseErrorWithBody(err, text_body.to_string()) - })?; - - let sentinel_token = into_sora_sentinel_token(request, response, text_body)?; - - Ok(sentinel_token) -} - -fn into_sora_sentinel_token(request: SentinelRequest, response: SentinelResponse, raw_body: &str) -> Result { - let expiry = extract_expiry(Utc::now(), &response); - - let maybe_token = response.token; - - let maybe_turnstile = response.turnstile - .map(|turn| turn.dx) - .flatten(); - - let mut missing_token = false; - let mut missing_turnstile = false; - - let (token, turnstile) = { - let maybe_items = match (maybe_token, maybe_turnstile) { - (Some(token), Some(turnstile)) => { - Some((token, turnstile)) - } - (None, None) => { - missing_token = true; - missing_turnstile = true; - None - } - (None, Some(_turnstile)) => { - missing_token = true; - None - } - (Some(_token), None) => { - missing_turnstile = true; - None - } - }; - match maybe_items { - Some((token, turnstile)) => (token, turnstile), - _ => return Err(SoraSpecificApiError::SentinelResponseIsMissingFields { - missing_token, - missing_turnstile, - raw_response: raw_body.to_string(), - }), - } - }; - - let sentinel_raw = RawSoraSentinelToken { - p: request.p, - id: request.id, - flow: request.flow, - t: turnstile, - c: token, - }; - - - let sentinel = SoraSentinelToken { - token: sentinel_raw, - browser_user_agent: CLIENT_USER_AGENT.to_string(), - generated_at: expiry.generated_at, - expires_in_seconds: expiry.expires_in_seconds, - }; - - Ok(sentinel) -} - - -#[cfg(test)] -mod tests { - use super::*; - use std::fs::write; - - #[tokio::test] - #[ignore] // Only manually trigger this - async fn test_generate_token_2() -> AnyhowResult<()> { - let token = generate_sentinel_token_2().await?; - println!("{:?}", token); - assert_eq!(1, 2); - Ok(()) - } - - #[tokio::test] - #[ignore] // Only manually trigger this - async fn write_token_to_disk() -> AnyhowResult<()> { - let filename = "/Users/bt/Artcraft/credentials/sora_sentinel_token_store.json"; - let token = generate_sentinel_token_2().await?; - - let json = token.to_persistent_storage_json()?; - - write(filename, &json)?; - - assert_eq!(1, 2); - Ok(()) - } -} diff --git a/crates/api_clients/openai_sora_client/src/requests/auth_sentinel_2/metadata/python_impl/config.py b/crates/api_clients/openai_sora_client/src/requests/auth_sentinel_2/metadata/python_impl/config.py deleted file mode 100644 index 0b7f7c998c..0000000000 --- a/crates/api_clients/openai_sora_client/src/requests/auth_sentinel_2/metadata/python_impl/config.py +++ /dev/null @@ -1,357 +0,0 @@ -cores = [8, 16, 24, 32] -cached_scripts = ["https://cdn.oaistatic.com/_next/static/cXh69klOLzS0Gy2joLDRS/_ssgManifest.js?dpl=453ebaec0d44c2decab71692e1bfe39be35a24b3"] - -cached_dpl = ["prod-f501fe933b3edf57aea882da888e1a544df99840"] - -navigator_key = [ - "registerProtocolHandler−function registerProtocolHandler() { [native code] }", - "storage−[object StorageManager]", - "locks−[object LockManager]", - "appCodeName−Mozilla", - "permissions−[object Permissions]", - "share−function share() { [native code] }", - "webdriver−false", - "managed−[object NavigatorManagedData]", - "canShare−function canShare() { [native code] }", - "vendor−Google Inc.", - "vendor−Google Inc.", - "mediaDevices−[object MediaDevices]", - "vibrate−function vibrate() { [native code] }", - "storageBuckets−[object StorageBucketManager]", - "mediaCapabilities−[object MediaCapabilities]", - "getGamepads−function getGamepads() { [native code] }", - "bluetooth−[object Bluetooth]", - "share−function share() { [native code] }", - "cookieEnabled−true", - "virtualKeyboard−[object VirtualKeyboard]", - "product−Gecko", - "mediaDevices−[object MediaDevices]", - "canShare−function canShare() { [native code] }", - "getGamepads−function getGamepads() { [native code] }", - "product−Gecko", - "xr−[object XRSystem]", - "clipboard−[object Clipboard]", - "storageBuckets−[object StorageBucketManager]", - "unregisterProtocolHandler−function unregisterProtocolHandler() { [native code] }", - "productSub−20030107", - "login−[object NavigatorLogin]", - "vendorSub−", - "login−[object NavigatorLogin]", - "getInstalledRelatedApps−function getInstalledRelatedApps() { [native code] }", - "mediaDevices−[object MediaDevices]", - "locks−[object LockManager]", - "webkitGetUserMedia−function webkitGetUserMedia() { [native code] }", - "vendor−Google Inc.", - "xr−[object XRSystem]", - "mediaDevices−[object MediaDevices]", - "virtualKeyboard−[object VirtualKeyboard]", - "virtualKeyboard−[object VirtualKeyboard]", - "appName−Netscape", - "storageBuckets−[object StorageBucketManager]", - "presentation−[object Presentation]", - "onLine−true", - "mimeTypes−[object MimeTypeArray]", - "credentials−[object CredentialsContainer]", - "presentation−[object Presentation]", - "getGamepads−function getGamepads() { [native code] }", - "vendorSub−", - "virtualKeyboard−[object VirtualKeyboard]", - "serviceWorker−[object ServiceWorkerContainer]", - "xr−[object XRSystem]", - "product−Gecko", - "keyboard−[object Keyboard]", - "gpu−[object GPU]", - "getInstalledRelatedApps−function getInstalledRelatedApps() { [native code] }", - "webkitPersistentStorage−[object DeprecatedStorageQuota]", - "doNotTrack", - "clearAppBadge−function clearAppBadge() { [native code] }", - "presentation−[object Presentation]", - "serial−[object Serial]", - "locks−[object LockManager]", - "requestMIDIAccess−function requestMIDIAccess() { [native code] }", - "locks−[object LockManager]", - "requestMediaKeySystemAccess−function requestMediaKeySystemAccess() { [native code] }", - "vendor−Google Inc.", - "pdfViewerEnabled−true", - "language−zh-CN", - "setAppBadge−function setAppBadge() { [native code] }", - "geolocation−[object Geolocation]", - "userAgentData−[object NavigatorUAData]", - "mediaCapabilities−[object MediaCapabilities]", - "requestMIDIAccess−function requestMIDIAccess() { [native code] }", - "getUserMedia−function getUserMedia() { [native code] }", - "mediaDevices−[object MediaDevices]", - "webkitPersistentStorage−[object DeprecatedStorageQuota]", - "sendBeacon−function sendBeacon() { [native code] }", - "hardwareConcurrency−32", - "credentials−[object CredentialsContainer]", - "storage−[object StorageManager]", - "cookieEnabled−true", - "pdfViewerEnabled−true", - "windowControlsOverlay−[object WindowControlsOverlay]", - "scheduling−[object Scheduling]", - "pdfViewerEnabled−true", - "hardwareConcurrency−32", - "xr−[object XRSystem]", - "webdriver−false", - "getInstalledRelatedApps−function getInstalledRelatedApps() { [native code] }", - "getInstalledRelatedApps−function getInstalledRelatedApps() { [native code] }", - "bluetooth−[object Bluetooth]" -] - -document_key = ['_reactListeningo743lnnpvdg', 'location'] - -window_key = [ - "0", - "window", - "self", - "document", - "name", - "location", - "customElements", - "history", - "navigation", - "locationbar", - "menubar", - "personalbar", - "scrollbars", - "statusbar", - "toolbar", - "status", - "closed", - "frames", - "length", - "top", - "opener", - "parent", - "frameElement", - "navigator", - "origin", - "external", - "screen", - "innerWidth", - "innerHeight", - "scrollX", - "pageXOffset", - "scrollY", - "pageYOffset", - "visualViewport", - "screenX", - "screenY", - "outerWidth", - "outerHeight", - "devicePixelRatio", - "clientInformation", - "screenLeft", - "screenTop", - "styleMedia", - "onsearch", - "isSecureContext", - "trustedTypes", - "performance", - "onappinstalled", - "onbeforeinstallprompt", - "crypto", - "indexedDB", - "sessionStorage", - "localStorage", - "onbeforexrselect", - "onabort", - "onbeforeinput", - "onbeforematch", - "onbeforetoggle", - "onblur", - "oncancel", - "oncanplay", - "oncanplaythrough", - "onchange", - "onclick", - "onclose", - "oncontentvisibilityautostatechange", - "oncontextlost", - "oncontextmenu", - "oncontextrestored", - "oncuechange", - "ondblclick", - "ondrag", - "ondragend", - "ondragenter", - "ondragleave", - "ondragover", - "ondragstart", - "ondrop", - "ondurationchange", - "onemptied", - "onended", - "onerror", - "onfocus", - "onformdata", - "oninput", - "oninvalid", - "onkeydown", - "onkeypress", - "onkeyup", - "onload", - "onloadeddata", - "onloadedmetadata", - "onloadstart", - "onmousedown", - "onmouseenter", - "onmouseleave", - "onmousemove", - "onmouseout", - "onmouseover", - "onmouseup", - "onmousewheel", - "onpause", - "onplay", - "onplaying", - "onprogress", - "onratechange", - "onreset", - "onresize", - "onscroll", - "onsecuritypolicyviolation", - "onseeked", - "onseeking", - "onselect", - "onslotchange", - "onstalled", - "onsubmit", - "onsuspend", - "ontimeupdate", - "ontoggle", - "onvolumechange", - "onwaiting", - "onwebkitanimationend", - "onwebkitanimationiteration", - "onwebkitanimationstart", - "onwebkittransitionend", - "onwheel", - "onauxclick", - "ongotpointercapture", - "onlostpointercapture", - "onpointerdown", - "onpointermove", - "onpointerrawupdate", - "onpointerup", - "onpointercancel", - "onpointerover", - "onpointerout", - "onpointerenter", - "onpointerleave", - "onselectstart", - "onselectionchange", - "onanimationend", - "onanimationiteration", - "onanimationstart", - "ontransitionrun", - "ontransitionstart", - "ontransitionend", - "ontransitioncancel", - "onafterprint", - "onbeforeprint", - "onbeforeunload", - "onhashchange", - "onlanguagechange", - "onmessage", - "onmessageerror", - "onoffline", - "ononline", - "onpagehide", - "onpageshow", - "onpopstate", - "onrejectionhandled", - "onstorage", - "onunhandledrejection", - "onunload", - "crossOriginIsolated", - "scheduler", - "alert", - "atob", - "blur", - "btoa", - "cancelAnimationFrame", - "cancelIdleCallback", - "captureEvents", - "clearInterval", - "clearTimeout", - "close", - "confirm", - "createImageBitmap", - "fetch", - "find", - "focus", - "getComputedStyle", - "getSelection", - "matchMedia", - "moveBy", - "moveTo", - "open", - "postMessage", - "print", - "prompt", - "queueMicrotask", - "releaseEvents", - "reportError", - "requestAnimationFrame", - "requestIdleCallback", - "resizeBy", - "resizeTo", - "scroll", - "scrollBy", - "scrollTo", - "setInterval", - "setTimeout", - "stop", - "structuredClone", - "webkitCancelAnimationFrame", - "webkitRequestAnimationFrame", - "chrome", - "caches", - "cookieStore", - "ondevicemotion", - "ondeviceorientation", - "ondeviceorientationabsolute", - "launchQueue", - "documentPictureInPicture", - "getScreenDetails", - "queryLocalFonts", - "showDirectoryPicker", - "showOpenFilePicker", - "showSaveFilePicker", - "originAgentCluster", - "onpageswap", - "onpagereveal", - "credentialless", - "speechSynthesis", - "onscrollend", - "webkitRequestFileSystem", - "webkitResolveLocalFileSystemURL", - "sendMsgToSolverCS", - "webpackChunk_N_E", - "__next_set_public_path__", - "next", - "__NEXT_DATA__", - "__SSG_MANIFEST_CB", - "__NEXT_P", - "_N_E", - "regeneratorRuntime", - "__REACT_INTL_CONTEXT__", - "DD_RUM", - "_", - "filterCSS", - "filterXSS", - "__SEGMENT_INSPECTOR__", - "__NEXT_PRELOADREADY", - "Intercom", - "__MIDDLEWARE_MATCHERS", - "__STATSIG_SDK__", - "__STATSIG_JS_SDK__", - "__STATSIG_RERENDER_OVERRIDE__", - "_oaiHandleSessionExpired", - "__BUILD_MANIFEST", - "__SSG_MANIFEST", - "__intercomAssignLocation", - "__intercomReloadLocation" -] \ No newline at end of file diff --git a/crates/api_clients/openai_sora_client/src/requests/auth_sentinel_2/metadata/python_impl/proof_of_work.py b/crates/api_clients/openai_sora_client/src/requests/auth_sentinel_2/metadata/python_impl/proof_of_work.py deleted file mode 100644 index 25797d305a..0000000000 --- a/crates/api_clients/openai_sora_client/src/requests/auth_sentinel_2/metadata/python_impl/proof_of_work.py +++ /dev/null @@ -1,71 +0,0 @@ -import hashlib, json, random, time, uuid, pybase64 -from datetime import datetime, timedelta, timezone -from config import cores, cached_scripts, cached_dpl, navigator_key, document_key, window_key - - -MAX_ITERATION = 500000 - -def get_parse_time(): - now = datetime.now(timezone(timedelta(hours=-5))) - return now.strftime("%a %b %d %Y %H:%M:%") + " GMT-0500 (Eastern Standard Time)" - - - -def get_config(user_agent): - config = [ - random.choice([1920 + 1080, 2560 + 1440, 1920 + 1200, 2560 + 1600]), - get_parse_time(), - 4294705152, - 0, - user_agent, - random.choice(cached_scripts) if cached_scripts else "", - cached_dpl, - "en-US", - "en-US,es-US,en,es", - 0, - random.choice(navigator_key), - random.choice(document_key), - random.choice(window_key), - time.perf_counter() * 1000, - str(uuid.uuid4()), - "", - random.choice(cores), - time.time() * 1000 - (time.perf_counter() * 1000), - ] - return config - - - -def generate_answer(seed, diff, config): - diff_len = len(diff) - seed_encoded = seed.encode() - static_config_part1 = (json.dumps(config[:3], separators=(',', ':'), ensure_ascii=False)[:-1] + ',').encode() - static_config_part2 = (',' + json.dumps(config[4:9], separators=(',', ':'), ensure_ascii=False)[1:-1] + ',').encode() - static_config_part3 = (',' + json.dumps(config[10:], separators=(',', ':'), ensure_ascii=False)[1:]).encode() - - target_diff = bytes.fromhex(diff) - - for i in range(MAX_ITERATION): - dynamic_json_i = str(i).encode() - dynamic_json_j = str(i >> 1).encode() - final_json_bytes = static_config_part1 + dynamic_json_i + static_config_part2 + dynamic_json_j + static_config_part3 - base_encode = pybase64.b64encode(final_json_bytes) - hash_value = hashlib.sha3_512(seed_encoded + base_encode).digest() - if hash_value[:diff_len] <= target_diff: - return base_encode.decode(), True - - return "wQ8Lk5FbGpA2NcR9dShT6gYjU7VxZ4D" + pybase64.b64encode(f'"{seed}"'.encode()).decode(), False - - -def get_requirements_token(config): - seed = format(random.random()) - diff = "0fffff" - solution, found = generate_answer(seed, diff, config) - return 'gAAAAAC' + solution - -def get_pow_token(): - config = get_config("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36") - return get_requirements_token(config) - -if __name__ == "__main__": - print(get_pow_token()) \ No newline at end of file diff --git a/crates/api_clients/openai_sora_client/src/requests/auth_sentinel_2/metadata/python_impl/readme.MD b/crates/api_clients/openai_sora_client/src/requests/auth_sentinel_2/metadata/python_impl/readme.MD deleted file mode 100644 index 3cf95b72ce..0000000000 --- a/crates/api_clients/openai_sora_client/src/requests/auth_sentinel_2/metadata/python_impl/readme.MD +++ /dev/null @@ -1,100 +0,0 @@ -# OpenAI Sentinel Token Generator - -This repository provides a Python-based implementation to generate **Proof of Work (PoW) tokens** and **Sentinel tokens** for bypassing security mechanisms in OpenAI's ChatGPT and Sora private APIs. By reverse engineering the browser's token generation process, this project enables programmatic access to these APIs without requiring manual interaction or browser-based token generation. - -## Table of Contents - -- [Overview](#overview) -- [Features](#features) -- [How It Works](#how-it-works) -- [Installation](#installation) -- [Usage](#usage) -- [File Structure](#file-structure) -- [Disclaimer](#disclaimer) - ---- - -## Overview - -OpenAI's private APIs, such as ChatGPT and Sora, use advanced security mechanisms like Proof of Work (PoW) and Sentinel tokens to prevent unauthorized access. These tokens are typically generated in the browser using a combination of cryptographic hashing, unique identifiers, and environmental data. - -This project reverse-engineers the token generation process to allow developers to programmatically generate these tokens and interact with the APIs directly. This can be useful for automation, testing, or research purposes. - ---- -## Features - -- **Proof of Work Token Generation**: Implements a hashing-based PoW mechanism to generate valid tokens. -- **Sentinel Token Generation**: Creates Sentinel tokens required for API authentication. -- **Reverse-Engineered Browser Behavior**: Mimics browser-specific configurations and environmental data. -- **Customizable**: Easily modify configurations like user agents, navigator keys, and more. - ---- -## How It Works -### Proof of Work (PoW) Token Generation -The PoW token is generated by solving a computational challenge. The process involves: -1. Generating a random seed and difficulty level. -2. Iteratively hashing the seed with encoded configuration data until the hash meets the difficulty criteria. -3. Returning the solution as a base64-encoded string. - -The implementation is in [`proof_of_work.py`](proof_of_work.py), which uses cryptographic hashing (`sha3_512`) and base64 encoding to generate the token. - -### Sentinel Token Generation -The Sentinel token is generated by: -1. Fetching API requirements using the PoW token. -2. Parsing the API response to extract necessary fields like `turnstile` and `token`. -3. Constructing a payload with the extracted data and generating the final Sentinel token. - -The implementation is in [`sentinel_token.py`](sentinel_token.py), which handles API communication and token generation. - ---- -## Installation - -1. Clone the repository: - ```bash - git clone https://github.com/your-username/openai-sentinel.git - cd openai-sentinel - ``` -2. Install the required dependencies: - ```bash - pip install -r requirements.txt - ``` - Ensure you have Python 3.8 or higher installed. - -___ -## Usage -### Generating a Proof of Work (PoW) Token -To generate a PoW token, run the following command: -```bash -python proof_of_work.py -``` -This will output a valid PoW token that can be used for API authentication. -### Generating a Sentinel Token -To generate a Sentinel token, run the following command: -```bash -python sentinel_token.py -``` -This will output a valid Sentinel token that can be used for API authentication. - ---- -## File Structure - -```plaintext -openai-sentinel/ -├── proof_of_work.py -├── sentinel_token.py -├── config.py -├── requirements.txt -├── README.md -``` -### Key Files: -- `proof_of_work.py`: Contains the implementation for generating PoW tokens. -- `sentinel_token.py`: Contains the implementation for generating Sentinel tokens. -- `config.py`: Configuration file for user agents, navigator keys, and other settings. -- `requirements.txt`: Lists the required Python packages. -- `README.md`: This documentation file. ---- -## Disclaimer -This project is intended for educational and research purposes only. The use of this code to bypass security mechanisms or access APIs without authorization may violate the terms of service of OpenAI or other third-party services. Use at your own risk, and ensure compliance with all applicable laws and regulations. -``` -Please do not use this code for malicious purposes or to infringe on the rights of others. The author and contributors are not responsible for any misuse or damage caused by the use of this code. -``` \ No newline at end of file diff --git a/crates/api_clients/openai_sora_client/src/requests/auth_sentinel_2/metadata/python_impl/sentinel_token.py b/crates/api_clients/openai_sora_client/src/requests/auth_sentinel_2/metadata/python_impl/sentinel_token.py deleted file mode 100644 index 85ef940733..0000000000 --- a/crates/api_clients/openai_sora_client/src/requests/auth_sentinel_2/metadata/python_impl/sentinel_token.py +++ /dev/null @@ -1,55 +0,0 @@ -import requests, json -from uuid import uuid4 -from proof_of_work import get_pow_token - -current_parameters = None - - -def generate_id(): - return str(uuid4()) - -def generate_payload(data, flow): - data['id'] = generate_id() - data['flow'] = flow - return json.dumps(data) - -def fetch_requirements(flow, pow_token): - max_retries = 3 - for attempt in range(max_retries): - try: - response = requests.post( - url = "https://chatgpt.com/backend-api/sentinel/req", - data = generate_payload({'p': pow_token}, flow), - ) - - result = response.json() - return result, True - except requests.exceptions.RequestException as err: - if attempt >= 2: - return generate_payload({'e': str(err)}, flow), False - -def refresh_token(flow): - pow_token = get_pow_token() - response,_ = fetch_requirements(flow, pow_token) - if not _: - return response - - try: - - payload = generate_payload({ - 'p': pow_token, - 't': response.get("turnstile", {}).get('dx', ""), - 'c': response.get('token') - }, flow) - return payload - except Exception as err: - failure = generate_payload({'e': str(err), 'p': pow_token}, flow) - return failure - -def get_sentinel_token(): - flow = 'sora_create_task' - token = refresh_token(flow) #This can be used now in 'OpenAI-Sentinel-Token' header - return token - -if __name__ == "__main__": - print(get_sentinel_token()) \ No newline at end of file diff --git a/crates/api_clients/openai_sora_client/src/requests/auth_sentinel_2/mod.rs b/crates/api_clients/openai_sora_client/src/requests/auth_sentinel_2/mod.rs deleted file mode 100644 index 3647ad408d..0000000000 --- a/crates/api_clients/openai_sora_client/src/requests/auth_sentinel_2/mod.rs +++ /dev/null @@ -1,4 +0,0 @@ -pub (super) mod extract_expiry; -pub (super) mod request; -pub (super) mod response; -pub mod generate_sentinel_token_2; \ No newline at end of file diff --git a/crates/api_clients/openai_sora_client/src/requests/auth_sentinel_2/request.rs b/crates/api_clients/openai_sora_client/src/requests/auth_sentinel_2/request.rs deleted file mode 100644 index 9beb3ddab3..0000000000 --- a/crates/api_clients/openai_sora_client/src/requests/auth_sentinel_2/request.rs +++ /dev/null @@ -1,32 +0,0 @@ -use uuid_utils::uuid::generate_random_uuid; -use serde_derive::Serialize; - -// TODO: Support more of these. -const SENTINEL_FLOW: &str = "sora_init"; -const SENTINEL_FLOW_OLD: &str = "sora_create_task"; - -#[derive(Debug, Serialize)] -pub struct SentinelRequest { - /// "Proof of Work" token - #[serde(rename = "p")] - pub (crate) p: String, - - /// Random UUID - #[serde(rename = "id")] - pub (crate) id: String, - - /// Frontend UI flow - #[serde(rename = "flow")] - pub (crate) flow: String, -} - -impl SentinelRequest { - pub fn new(pow_token: String) -> Self { - let id = generate_random_uuid(); - Self { - p: pow_token, - id, - flow: SENTINEL_FLOW.to_string() - } - } -} diff --git a/crates/api_clients/openai_sora_client/src/requests/auth_sentinel_2/response.rs b/crates/api_clients/openai_sora_client/src/requests/auth_sentinel_2/response.rs deleted file mode 100644 index 0f8a32fff5..0000000000 --- a/crates/api_clients/openai_sora_client/src/requests/auth_sentinel_2/response.rs +++ /dev/null @@ -1,21 +0,0 @@ -use chrono::{DateTime, Utc}; -use serde_derive::Deserialize; - -#[derive(Debug, Deserialize)] -pub (crate) struct SentinelResponse { - pub (crate) token: Option, - pub (crate) turnstile: Option, - - // NB: appears to be integer seconds. - // Not required for the sentinel token flow, but helps with renew. - pub (crate) expire_after: Option, - - // NB: appears to be Unix timestamp in seconds. - // Not required for the sentinel token flow, but helps with renew. - pub (crate) expire_at: Option, -} - -#[derive(Debug, Deserialize)] -pub (crate) struct SentinelTurnstile { - pub (crate) dx: Option, -} diff --git a/crates/api_clients/openai_sora_client/src/requests/common/mod.rs b/crates/api_clients/openai_sora_client/src/requests/common/mod.rs deleted file mode 100644 index aaf466b628..0000000000 --- a/crates/api_clients/openai_sora_client/src/requests/common/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod task_id; \ No newline at end of file diff --git a/crates/api_clients/openai_sora_client/src/requests/common/task_id.rs b/crates/api_clients/openai_sora_client/src/requests/common/task_id.rs deleted file mode 100644 index 131d933fe9..0000000000 --- a/crates/api_clients/openai_sora_client/src/requests/common/task_id.rs +++ /dev/null @@ -1,34 +0,0 @@ -use std::fmt::Display; -use serde_derive::{Deserialize, Serialize}; - -/// A strongly typed task ID for Sora tasks. -#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Serialize, Deserialize)] -pub struct TaskId(pub String); - -impl TaskId { - pub fn from_string(id: String) -> Self { - Self(id) - } - - pub fn from_str(id: &str) -> Self { - Self(id.to_string()) - } - - pub fn new(id: String) -> Self { - Self(id) - } - - pub fn as_str(&self) -> &str { - &self.0 - } - - pub fn to_string(&self) -> String { - self.0.to_string() - } -} - -impl Display for TaskId { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - std::fmt::Display::fmt(&self.0, f) - } -} diff --git a/crates/api_clients/openai_sora_client/src/requests/deprecated/job_status/mod.rs b/crates/api_clients/openai_sora_client/src/requests/deprecated/job_status/mod.rs deleted file mode 100644 index e679dd1843..0000000000 --- a/crates/api_clients/openai_sora_client/src/requests/deprecated/job_status/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod sora_job_status; -pub mod unimplemented_sora_job_status; \ No newline at end of file diff --git a/crates/api_clients/openai_sora_client/src/requests/deprecated/job_status/sora_job_status.rs b/crates/api_clients/openai_sora_client/src/requests/deprecated/job_status/sora_job_status.rs deleted file mode 100644 index fce3287c0c..0000000000 --- a/crates/api_clients/openai_sora_client/src/requests/deprecated/job_status/sora_job_status.rs +++ /dev/null @@ -1,359 +0,0 @@ -use crate::constants::user_agent::CLIENT_USER_AGENT; -use crate::creds::sora_credential_set::SoraCredentialSet; -use crate::creds::sora_jwt_bearer_token::SoraJwtBearerToken; -use crate::error::sora_client_error::SoraClientError; -use crate::error::sora_error::SoraError; -use crate::error::sora_generic_api_error::SoraGenericApiError; -use crate::requests::common::task_id::TaskId; -use crate::utils_internal::classify_general_http_status_code_and_body::classify_general_http_status_code_and_body; -use anyhow::anyhow; -use errors::AnyhowResult; -use log::{debug, error, warn}; -use serde_derive::{Deserialize, Serialize}; -use std::fmt::{Debug, Display}; -use std::{fs::File, io::Write, path::Path}; -use url::Url; -use wreq::Client; - -// NB(2025-10-02): The new URL is: -// https://sora.chatgpt.com/backend/v2/list_tasks?limit=20 -const SORA_STATUS_URL: &str = "https://sora.com/backend/video_gen"; - - -#[derive(Debug, Clone, PartialEq, Eq, Deserialize)] -pub enum TaskStatus { - Queued, - Running, - Succeeded, - Failed, - Unknown(String), -} - -impl TaskStatus { - pub fn from_str(s: &str) -> Self { - match s { - "queued" => TaskStatus::Queued, - "running" => TaskStatus::Running, - "succeeded" => TaskStatus::Succeeded, - "failed" => TaskStatus::Failed, - _ => TaskStatus::Unknown(s.to_string()), - } - } -} - -#[derive(Deserialize, Clone)] -#[serde(rename_all = "snake_case")] -pub struct VideoGenStatusResponse { - pub task_responses: Vec, - pub last_id: String, - pub has_more: bool, -} - -#[derive(Deserialize, Clone, Debug)] -#[serde(rename_all = "snake_case")] -pub struct TaskResponse { - pub id: TaskId, - pub user: String, - pub created_at: String, - pub status: String, - pub progress_pct: Option, - pub progress_pos_in_queue: Option, - pub estimated_queue_wait_time: Option, - pub queue_status_message: Option, - pub priority: i32, - pub r#type: String, - pub prompt: Option, - pub n_variants: i32, - pub n_frames: i32, - pub height: i32, - pub width: i32, - pub model: Option, - pub operation: String, - pub inpaint_items: Option>, - pub preset_id: Option, - pub caption: Option, - //pub actions: Option, - //pub interpolation: Option, - //pub sdedit: Option, - //pub remix_config: Option, - pub quality: Option, - pub generations: Vec, - pub num_unsafe_generations: i32, - pub title: String, - //pub moderation_result: ModerationResult, - pub failure_reason: Option, - pub needs_user_review: bool, -} - -#[derive(Deserialize, Clone, Debug)] -#[serde(rename_all = "snake_case")] -pub struct Generation { - pub id: String, - pub task_id: TaskId, - pub created_at: String, - pub deleted_at: Option, - pub url: String, - pub seed: Option, - pub can_download: Option, - pub download_status: Option, - pub is_favorite: Option, - pub is_liked: Option, - pub is_public: Option, - pub is_archived: Option, - pub is_featured: Option, - pub has_feedback: Option, - pub like_count: Option, - //pub cloudflare_metadata: Option, - pub cf_thumbnail_url: Option, - pub encodings: Encodings, - pub width: i32, - pub height: i32, - pub n_frames: i32, - pub prompt: String, - pub title: String, - pub actions: Option, - pub inpaint_items: Option>, - //pub interpolation: Option, - //pub sdedit: Option, - pub operation: String, - pub model: Option, - pub preset_id: Option, - //pub user: User, - //pub moderation_result: ModerationResult, - //pub paragen_status: Option, - pub task_type: String, - pub remix_config: Option, - pub quality: Option, -} - -#[derive(Deserialize, Clone, Debug)] -#[serde(rename_all = "snake_case")] -pub struct Encodings { - pub source: Source, - pub md: Option, - pub ld: Option, - pub thumbnail: Thumbnail, - pub spritesheet: Option, -} - -#[derive(Deserialize, Clone, Debug)] -#[serde(rename_all = "snake_case")] -pub struct Source { - pub path: String, - pub size: Option, - pub width: Option, - pub height: Option, - pub duration_secs: Option, - pub ssim: Option, -} - -#[derive(Deserialize, Clone, Debug)] -#[serde(rename_all = "snake_case")] -pub struct Thumbnail { - pub path: String, - pub size: Option, -} - -//#[derive(Deserialize, Clone, Debug)] -//#[serde(rename_all = "snake_case")] -//pub struct User { -// pub id: String, -// pub username: String, -//} - -#[derive(Deserialize, Clone, Debug)] -#[serde(rename_all = "snake_case")] -pub struct InpaintItem { - pub crop_bounds: Option, - pub r#type: String, - pub preset_id: Option, - pub generation_id: Option, - pub upload_media_id: Option, - pub frame_index: i32, - pub source_start_frame: i32, -} - -//#[derive(Deserialize, Clone, Debug)] -//#[serde(rename_all = "snake_case")] -//pub struct ModerationResult { -// pub r#type: String, -// pub results_by_frame_index: serde_json::Value, -// pub code: Option, -// pub is_output_rejection: bool, -// pub task_id: TaskId, -//} - -pub struct StatusRequest { - pub limit: Option, - pub before: Option, -} - -impl StatusRequest { - pub fn new(limit: Option, before: Option) -> Self { - let limit = limit.unwrap_or(100); - Self { limit: Some(limit), before } - } -} - -/// Gets the status of image generation tasks from Sora API -pub async fn get_image_gen_status(status_request: &StatusRequest, credentials: &SoraCredentialSet) -> Result { - - let bearer_header = match credentials.jwt_bearer_token.as_ref() { - Some(bearer) => bearer.to_authorization_header_value(), - None => { - warn!("No JWT bearer token in client - cannot fetch image gen status!"); - return Err(SoraClientError::NoBearerTokenForRequest.into()); - }, - }; - - let client = Client::new(); - - let mut url = Url::parse(SORA_STATUS_URL) - .map_err(|err| { - SoraClientError::UrlParseError(err) - })?; - - // Add query parameters - if let Some(limit) = status_request.limit { - url.query_pairs_mut().append_pair("limit", &limit.to_string()); - } - - if let Some(before) = &status_request.before { - url.query_pairs_mut().append_pair("before", &before); - } - - let http_request = client.get(url.as_str()) - .header("User-Agent", CLIENT_USER_AGENT) - .header("Cookie", credentials.cookies.as_str()) - .header("Authorization", bearer_header) - .header("Content-Type", "application/json"); - - let http_request = http_request.build() - .map_err(|err| { - SoraClientError::WreqClientError(err) - })?; - - let response = client.execute(http_request) - .await - .map_err(|err| { - error!("Client failed to fetch sora image gen status: {:?}", err); - SoraGenericApiError::WreqError(err) - })?; - - let status = response.status(); - - let response_body = &response.text() - .await - .map_err(|err| { - error!("Client failed to read sora image gen status: {:?}", err); - SoraGenericApiError::WreqError(err) - })?; - - debug!("response_body: {}", response_body); - - if !status.is_success() { - error!("The sora status request failed; status = {:?} ; response body = {}", status, response_body); - let error = classify_general_http_status_code_and_body(status, &response_body); - return Err(error); - } - - let maybe_response = serde_json::from_str::(response_body); - - match maybe_response { - Ok(response) => Ok(response), - Err(err) => { - warn!("Failed to parse status response: {:?}", err); - Err(SoraGenericApiError::SerdeResponseParseErrorWithBody( - err, response_body.to_string()).into()) - } - } -} - -pub async fn save_generations_to_dir(generations: &[Generation], dir: &str) -> AnyhowResult<()> { - let dir = Path::new(dir); - if !dir.exists() { - std::fs::create_dir_all(dir)?; - } - for generation in generations { - let response = wreq::get(generation.url.clone()).send().await?; - let image_bytes = response.bytes().await?; - - let url = Url::parse(&generation.url)?; - let ext = url.path().split(".").last().unwrap_or("png"); - let path = Path::new(dir).join(format!("{}.{}", generation.id, ext)); - - let mut file = File::create(path)?; - file.write_all(&image_bytes)?; - - let thumbnail_url = generation.encodings.thumbnail.path.clone(); - let thumbnail_response = wreq::get(thumbnail_url).send().await?; - let thumbnail_bytes = thumbnail_response.bytes().await?; - let thumbnail_path = Path::new(dir).join(format!("{}_thumbnail.{}", generation.id, ext)); - let mut thumbnail_file = File::create(thumbnail_path)?; - thumbnail_file.write_all(&thumbnail_bytes)?; - } - - Ok(()) -} - -#[cfg(test)] -mod tests { - use crate::creds::sora_credential_builder::SoraCredentialBuilder; - use crate::recipes::wait_for_image_gen_status::wait_for_image_gen_status; - use crate::requests::deprecated::job_status::sora_job_status::{get_image_gen_status, save_generations_to_dir, StatusRequest, VideoGenStatusResponse}; - use errors::AnyhowResult; - use std::fs::read_to_string; - use test_utils::test_file_path::test_file_path; - - #[ignore] - #[tokio::test] - pub async fn test_deserialize_status_response() -> AnyhowResult<()> { - let response = read_to_string(test_file_path("test_data/image_gen/test_status_response_long.json")?)?; - let _response: VideoGenStatusResponse = serde_json::from_str(&response)?; - Ok(()) - } - - #[ignore] // You can manually run "ignore" tests in the IDE, but they won't run in CI. - #[tokio::test] - pub async fn manual_test() -> AnyhowResult<()> { - let sentinel = read_to_string(test_file_path("test_data/temp/sentinel.txt")?)?; - let sentinel = sentinel.trim().to_string(); - - let cookie = read_to_string(test_file_path("test_data/temp/cookie.txt")?)?; - let cookie = cookie.trim().to_string(); - - let bearer = read_to_string(test_file_path("test_data/temp/bearer.txt")?)?; - let bearer = bearer.trim().to_string(); - - let creds = SoraCredentialBuilder::new() - .with_cookies(&cookie) - .with_jwt_bearer_token(&bearer) - .with_sora_sentinel(&sentinel) - .build()?; - - // Get the task status for a specific task - // let response = get_image_gen_status(&StatusRequest::new(None, Some("task_01jr9yvpfyetx9r7qvvx38scna".to_string())), &creds).await?; - - let response = get_image_gen_status(&StatusRequest::new(Some(50), None), &creds).await?; - println!("task_id: {}", response.task_responses[0].id); - - let task_id = response.task_responses[0].id.clone(); - let task_response = wait_for_image_gen_status( - &task_id.0, - &creds, - Some(10) - ).await?; - - assert!(task_response.status == "succeeded"); - Ok(()) - } - - #[ignore] - #[tokio::test] - pub async fn test_save_generations_to_dir() -> AnyhowResult<()> { - let response = read_to_string(test_file_path("test_data/image_gen/test_status_response_long.json")?)?; - let response: VideoGenStatusResponse = serde_json::from_str(&response)?; - save_generations_to_dir(&response.task_responses[0].generations, test_file_path("test_data/image_gen/generations")?.to_str().unwrap()).await?; - Ok(()) - } -} diff --git a/crates/api_clients/openai_sora_client/src/requests/deprecated/job_status/unimplemented_sora_job_status.rs b/crates/api_clients/openai_sora_client/src/requests/deprecated/job_status/unimplemented_sora_job_status.rs deleted file mode 100644 index 51ed21ed79..0000000000 --- a/crates/api_clients/openai_sora_client/src/requests/deprecated/job_status/unimplemented_sora_job_status.rs +++ /dev/null @@ -1,79 +0,0 @@ -use crate::constants::user_agent::CLIENT_USER_AGENT; -use crate::creds::sora_credential_set::SoraCredentialSet; -use crate::error::sora_client_error::SoraClientError; -use crate::error::sora_error::SoraError; -use crate::error::sora_generic_api_error::SoraGenericApiError; -use log::error; -use wreq::Client; - -// https://sora.com/backend/notif?limit=100&before=task_01jqwwrkvgeqp8jsf5mqk1jceh - -pub async fn unimplemented_sora_job_status( - task_id: &str, - credentials: &SoraCredentialSet, -) -> Result<(), SoraError> { - let url = format!("https://sora.com/backend/notif?limit=100&before={}", task_id); - - let cookie = credentials.cookies.to_string(); - - let authorization_header = credentials.jwt_bearer_token.as_ref() - .ok_or(SoraClientError::NoBearerTokenForRequest)? - .to_authorization_header_value(); - - let client = Client::new(); - - let request = client - .get(url) - .header("Authorization", &authorization_header) - .header("User-Agent", CLIENT_USER_AGENT) - .header("Cookie", &cookie); - - let response = request.send() - .await - .map_err(|err| { - error!("sora fetch job status error: {}", err); - SoraGenericApiError::WreqError(err) - })?; - - let json_response = &response.text().await - .map_err(|err| { - error!("sora read job status error: {}", err); - SoraGenericApiError::WreqError(err) - })?; - - unimplemented!("job status is not parsed") -} - -#[cfg(test)] -mod tests { - use crate::creds::sora_credential_builder::SoraCredentialBuilder; - use crate::requests::deprecated::job_status::unimplemented_sora_job_status::unimplemented_sora_job_status; - use errors::AnyhowResult; - use std::fs::read_to_string; - use test_utils::test_file_path::test_file_path; - - #[ignore] - #[tokio::test] - pub async fn manual_test() -> AnyhowResult<()> { - let sentinel = read_to_string(test_file_path("test_data/temp/sentinel.txt")?)?; - let sentinel = sentinel.trim().to_string(); - - let cookie = read_to_string(test_file_path("test_data/temp/cookie.txt")?)?; - let cookie = cookie.trim().to_string(); - - let bearer = read_to_string(test_file_path("test_data/temp/bearer.txt")?)?; - let bearer = bearer.trim().to_string(); - - let creds = SoraCredentialBuilder::new() - .with_cookies(&cookie) - .with_jwt_bearer_token(&bearer) - .with_sora_sentinel(&sentinel) - .build()?; - - let task_id = "task_01jqwwrkvgeqp8jsf5mqk1jceh"; - - let result = unimplemented_sora_job_status(task_id, &creds).await?; - - Ok(()) - } -} diff --git a/crates/api_clients/openai_sora_client/src/requests/deprecated/list_media/list_media.rs b/crates/api_clients/openai_sora_client/src/requests/deprecated/list_media/list_media.rs deleted file mode 100644 index bb3fcd0421..0000000000 --- a/crates/api_clients/openai_sora_client/src/requests/deprecated/list_media/list_media.rs +++ /dev/null @@ -1,117 +0,0 @@ -use crate::creds::sora_credential_set::SoraCredentialSet; -use crate::error::sora_client_error::SoraClientError; -use crate::error::sora_error::SoraError; -use crate::error::sora_generic_api_error::SoraGenericApiError; -use crate::utils_internal::classify_general_http_error::classify_general_http_error; -use log::{error, info}; -use once_cell::sync::Lazy; -use serde_derive::Deserialize; -use wreq::Client; - -//const SORA_MEDIA_LIST_URL: &str = "https://sora.chatgpt.com/backend/video_gen?limit=50"; -const SORA_MEDIA_LIST_URL : &str = "https://sora.chatgpt.com/backend/v2/list_tasks?limit=20"; - -#[derive(Debug, Deserialize)] -pub struct ListMediaResponse { - pub task_responses: Vec, - pub last_id: Option, - pub has_more: Option, -} - -#[derive(Debug, Deserialize)] -pub struct TaskResponse { - /// Task id (eg. task_{foo}) - pub id: String, - pub title: String, - pub user: String, - pub created_at: String, - pub status: String, - /// Text prompt that generated the image - pub prompt: String, - pub r#type: String, - pub height: u32, - pub width: u32, - pub operation: String, - - // There are many more fields [...] -} - -/// Note: this request only requires a valid bearer token, and it doesn't require a cookie payload at all! -pub async fn list_media(credentials: &SoraCredentialSet) -> Result { - let auth_header = credentials.jwt_bearer_token - .as_ref() - .map(|bearer| bearer.to_authorization_header_value()) - .ok_or_else(|| SoraClientError::NoBearerTokenForRequest)?; - - let cookie = credentials.cookies.to_string(); - - let client = Client::builder() - .gzip(true) - .build() - .map_err(|err| { - error!("Failed to build HTTP client: {}", err); - SoraGenericApiError::WreqError(err) - })?; - - let response = client.get(SORA_MEDIA_LIST_URL) - .header("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:137.0) Gecko/20100101 Firefox/137.0") - .header("Accept", "*/*") - .header("Accept-Encoding", "gzip, deflate, br") - .header("Accept-Language", "en-US,en;q=0.5") - .header("Cookie", &cookie) - .header("Authorization", &auth_header) - .send() - .await - .map_err(|err| { - error!("Failed to fetch media list: {}", err); - SoraGenericApiError::WreqError(err) - })?; - - if !response.status().is_success() { - error!("Failed to fetch media list: {}", response.status()); - let error = classify_general_http_error(response).await; - return Err(error); - } - - info!("Successfully generated bearer token."); - - let text_body = &response.text().await - .map_err(|err| { - error!("sora error reading media list text body: {}", err); - SoraGenericApiError::WreqError(err) - })?; - - let response = serde_json::from_str::(text_body) - .map_err(|err| { - error!("Failed to parse media list response: {}", err); - SoraGenericApiError::SerdeResponseParseErrorWithBody(err, text_body.to_string()) - })?; - - Ok(response) -} - - -#[cfg(test)] -mod tests { - use super::*; - use crate::creds::sora_jwt_bearer_token::SoraJwtBearerToken; - use errors::AnyhowResult; - - #[tokio::test] - #[ignore] // Don't run in CI. Requires valid cookie - async fn test_list_media() -> AnyhowResult<()> { - let cookie = ""; - let bearer = ""; - - let mut creds = SoraCredentialSet::initialize_with_just_cookies_str(cookie); - creds.jwt_bearer_token = Some(SoraJwtBearerToken::new(bearer.to_string())?); - - let results = list_media(&creds).await.expect("should work"); - - println!("{:?}", results); - - assert!(results.task_responses.len() > 0); - - Ok(()) - } -} diff --git a/crates/api_clients/openai_sora_client/src/requests/deprecated/list_media/mod.rs b/crates/api_clients/openai_sora_client/src/requests/deprecated/list_media/mod.rs deleted file mode 100644 index b366dc8e8a..0000000000 --- a/crates/api_clients/openai_sora_client/src/requests/deprecated/list_media/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod list_media; \ No newline at end of file diff --git a/crates/api_clients/openai_sora_client/src/requests/deprecated/mod.rs b/crates/api_clients/openai_sora_client/src/requests/deprecated/mod.rs deleted file mode 100644 index 1473cf0aca..0000000000 --- a/crates/api_clients/openai_sora_client/src/requests/deprecated/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod job_status; -pub mod list_media; diff --git a/crates/api_clients/openai_sora_client/src/requests/generate_sora2_video/generate_sora2_video.rs b/crates/api_clients/openai_sora_client/src/requests/generate_sora2_video/generate_sora2_video.rs deleted file mode 100644 index e8c0f8f7bd..0000000000 --- a/crates/api_clients/openai_sora_client/src/requests/generate_sora2_video/generate_sora2_video.rs +++ /dev/null @@ -1,177 +0,0 @@ -use crate::constants::user_agent::CLIENT_USER_AGENT; -use crate::creds::sora_credential_set::SoraCredentialSet; -use crate::error::sora_client_error::SoraClientError; -use crate::error::sora_error::SoraError; -use crate::error::sora_generic_api_error::SoraGenericApiError; -use crate::requests::auth_sentinel_2::generate_sentinel_token_2::generate_sentinel_token_2; -use crate::requests::common::task_id::TaskId; -use crate::requests::generate_sora2_video::http_request::{HttpCreateRequest, InpaintItem}; -use crate::requests::generate_sora2_video::http_response::HttpCreateResponse; -use crate::requests::image_gen::image_gen_http_request::{RawSoraImageGenRequest, RawSoraResponse}; -use crate::utils_internal::classify_general_http_status_code_and_body::classify_general_http_status_code_and_body; -use log::error; -use std::io::Write; -use std::time::Duration; -use wreq::header::{ACCEPT, ACCEPT_LANGUAGE, AUTHORIZATION, CONTENT_TYPE, COOKIE, ORIGIN, REFERER, USER_AGENT}; -use wreq::Client; - -const GENERATE_SORA_2_VIDEO_URL: &str = "https://sora.chatgpt.com/backend/nf/create"; - -#[derive(Clone)] -pub struct GenerateSora2VideoArgs<'a> { - pub prompt: &'a str, - pub credentials: &'a SoraCredentialSet, - pub request_timeout: Option, - pub orientation: Orientation, - pub image_reference_media_ids: Option<&'a Vec>, -} - -#[derive(Clone, Copy)] -pub enum Orientation { - Portrait, - Landscape, -} - -#[derive(Debug)] -pub struct GenerateSora2VideoResponse { - pub task_id: TaskId, -} - -pub (crate) async fn generate_sora2_video( - args: GenerateSora2VideoArgs<'_>, -) -> Result { - - let client = Client::new(); - - let authorization_header = args.credentials.jwt_bearer_token.as_ref() - .ok_or(SoraClientError::NoBearerTokenForRequest)? - .to_authorization_header_value(); - - let sentinel_token = args.credentials.sora_sentinel_token - .as_ref() - .ok_or(SoraClientError::NoSentinelTokenForRequest)?; - - let sentinel_token = sentinel_token.to_request_header_json()?; - - let cookie = args.credentials.cookies.to_string(); - - // TODO: Make the sec-* headers match the user agent and platform - // TODO: device id - //-H 'oai-device-id: 7c216860-5b73-4e63-983f-142dbcae1809' \ - let mut request_builder = client.post(GENERATE_SORA_2_VIDEO_URL) - .header(ACCEPT, "*/*") - .header("priority", "u=1, i") - .header(REFERER, "https://sora.chatgpt.com/explore") - .header(ORIGIN, "https://sora.chatgpt.com") - .header(ACCEPT_LANGUAGE, "en-US,en;q=0.9") - .header(USER_AGENT, CLIENT_USER_AGENT) - .header(COOKIE, &cookie) - .header("OpenAI-Sentinel-Token", sentinel_token) - .header(AUTHORIZATION, &authorization_header) - .header(CONTENT_TYPE, "application/json") - .header("sec-ch-ua", "\"Chromium\";v=\"140\", \"Not=A?Brand\";v=\"24\", \"Google Chrome\";v=\"140\"") - .header("sec-ch-ua-mobile", "?0") - .header("sec-ch-ua-platform", "macOS") - .header("sec-fetch-dest", "empty") - .header("sec-fetch-mode", "cors") - .header("sec-fetch-site", "same-origin"); - - if let Some(timeout) = args.request_timeout { - request_builder = request_builder.timeout(timeout); - } - - let orientation = match args.orientation { - Orientation::Portrait => "portrait", - Orientation::Landscape => "landscape", - }; - - let inpaint_items; - - if let Some(media_ids) = args.image_reference_media_ids { - inpaint_items = media_ids.iter() - .map(|item_id| InpaintItem { - kind: "upload".to_string(), - upload_id: item_id.to_string(), - }) - .collect(); - } else { - inpaint_items = Vec::new(); - } - - let request_body = HttpCreateRequest { - kind: "video".to_string(), - prompt: args.prompt.to_string(), - title: None, - orientation: orientation.to_string(), - size: "small".to_string(), - n_frames: 300, - inpaint_items, - cameo_ids: None, - cameo_replacements: None, - model: "sy_8".to_string(), - style_id: None, - audio_caption: None, - audio_transcript: None, - video_caption: None, - storyboard_id: None, - }; - - let http_request = request_builder.json(&request_body) - .build() - .map_err(|err| { - error!("Error building Sora image generation HTTP request: {:?}", err); - SoraClientError::WreqClientError(err) - })?; - - let response = client.execute(http_request) - .await - .map_err(|err| { - error!("Error during Sora image generation request: {:?}", err); - SoraClientError::WreqClientError(err) - })?; - - let status = response.status(); - - let response_body = &response.text().await - .map_err(|err| { - error!("Error reading Sora image generation response body: {:?}", err); - SoraClientError::WreqClientError(err) - })?; - - if !status.is_success() { - error!("Sora image generation request returned an error (code {}) : {:?}", status.as_u16(), response_body); - return Err(classify_general_http_status_code_and_body(status, response_body)); - } - - let response : HttpCreateResponse = serde_json::from_str(response_body) - .map_err(|err| SoraGenericApiError::SerdeResponseParseErrorWithBody(err, response_body.to_string()))?; - - Ok(GenerateSora2VideoResponse { - task_id: response.id, - }) -} - -#[cfg(test)] -mod tests { - use crate::requests::generate_sora2_video::generate_sora2_video::{generate_sora2_video, GenerateSora2VideoArgs, Orientation}; - use crate::test_utils::get_test_credentials::get_test_credentials; - use errors::AnyhowResult; - - #[ignore] // You can manually run "ignore" tests in the IDE, but they won't run in CI. - #[tokio::test] - pub async fn manual_test() -> AnyhowResult<()> { - let creds = get_test_credentials()?; - let request = GenerateSora2VideoArgs { - //prompt: "A cute corgi wearing glasses, sitting on a picnic blanket and reading a book, digital art", - prompt: "A dog eating pancakes in an iHop", - credentials: &creds, - request_timeout: None, - orientation: Orientation::Landscape, - image_reference_media_ids: None, - }; - let result = generate_sora2_video(request).await?; - println!("result: {:#?}", result); - assert_eq!(1, 2); - Ok(()) - } -} diff --git a/crates/api_clients/openai_sora_client/src/requests/generate_sora2_video/http_request.rs b/crates/api_clients/openai_sora_client/src/requests/generate_sora2_video/http_request.rs deleted file mode 100644 index 5afb5d7e19..0000000000 --- a/crates/api_clients/openai_sora_client/src/requests/generate_sora2_video/http_request.rs +++ /dev/null @@ -1,60 +0,0 @@ -use serde_derive::Serialize; - -#[derive(Serialize)] -#[serde(rename_all = "snake_case")] -pub (super) struct HttpCreateRequest { - // eg. "video" - pub kind: String, - - // User prompt - pub prompt: String, - - // NB: sent as null - pub title: Option, - - // eg. "portrait" - pub orientation: String, - - // eg. "small" - pub size: String, - - // eg. 300 - pub n_frames: u16, - - // NB: sent as empty array - pub inpaint_items: Vec, - - // NB: Sent as null - pub cameo_ids: Option, - - // NB: Sent as null - pub cameo_replacements: Option, - - // eg. "sy_8" - pub model: String, - - // NB: Sent as null - pub style_id: Option, - - // NB: Sent as null - pub audio_caption: Option, - - // NB: Sent as null - pub audio_transcript: Option, - - // NB: Sent as null - pub video_caption: Option, - - // NB: Sent as null - pub storyboard_id: Option, -} - -#[derive(Serialize)] -#[serde(rename_all = "snake_case")] -pub (super) struct InpaintItem { - // eg. "upload" - pub kind: String, - - // eg. "media_01abc..." - pub upload_id: String, -} diff --git a/crates/api_clients/openai_sora_client/src/requests/generate_sora2_video/http_response.rs b/crates/api_clients/openai_sora_client/src/requests/generate_sora2_video/http_response.rs deleted file mode 100644 index 7e49bf97a5..0000000000 --- a/crates/api_clients/openai_sora_client/src/requests/generate_sora2_video/http_response.rs +++ /dev/null @@ -1,9 +0,0 @@ -use crate::requests::common::task_id::TaskId; -use serde_derive::Deserialize; - -#[derive(Deserialize)] -#[serde(rename_all = "snake_case")] -pub (super) struct HttpCreateResponse { - pub id: TaskId, - // NB: Ignoring other fields, like "priority". -} diff --git a/crates/api_clients/openai_sora_client/src/requests/generate_sora2_video/mod.rs b/crates/api_clients/openai_sora_client/src/requests/generate_sora2_video/mod.rs deleted file mode 100644 index 34de76d9a8..0000000000 --- a/crates/api_clients/openai_sora_client/src/requests/generate_sora2_video/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub mod generate_sora2_video; -mod http_request; -mod http_response; \ No newline at end of file diff --git a/crates/api_clients/openai_sora_client/src/requests/image_gen/common.rs b/crates/api_clients/openai_sora_client/src/requests/image_gen/common.rs deleted file mode 100644 index 8f1f8b8917..0000000000 --- a/crates/api_clients/openai_sora_client/src/requests/image_gen/common.rs +++ /dev/null @@ -1,49 +0,0 @@ -use crate::requests::common::task_id::TaskId; - -#[derive(Debug, Clone)] -pub struct SoraImageGenResponse { - pub task_id: TaskId, -} - -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum NumImages { - One, - Two, - Four -} - -impl NumImages { - pub fn as_count(&self) -> usize { - match self { - NumImages::One => 1, - NumImages::Two => 2, - NumImages::Four => 4, - } - } -} - -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum ImageSize { - Square, - Wide, - Tall, -} - -impl ImageSize { - // TODO: Verify these dimensions. 480x480 is correct. - pub fn as_dimensions(&self) -> (u16, u16) { - match self { - ImageSize::Square => (480, 480), - ImageSize::Wide => (854, 480), - ImageSize::Tall => (480, 854), - } - } - - pub fn as_width(&self) -> u16 { - self.as_dimensions().0 - } - - pub fn as_height(&self) -> u16 { - self.as_dimensions().1 - } -} diff --git a/crates/api_clients/openai_sora_client/src/requests/image_gen/image_gen_http_request.rs b/crates/api_clients/openai_sora_client/src/requests/image_gen/image_gen_http_request.rs deleted file mode 100644 index 4d4955dc2d..0000000000 --- a/crates/api_clients/openai_sora_client/src/requests/image_gen/image_gen_http_request.rs +++ /dev/null @@ -1,251 +0,0 @@ -use crate::constants::user_agent::CLIENT_USER_AGENT; -use crate::creds::sora_credential_set::SoraCredentialSet; -use crate::error::sora_client_error::SoraClientError; -use crate::error::sora_error::SoraError; -use crate::error::sora_generic_api_error::SoraGenericApiError; -use crate::error::sora_specific_api_error::SoraSpecificApiError; -use crate::requests::common::task_id::TaskId; -use log::{error, warn}; -use serde_derive::{Deserialize, Serialize}; -use std::io::Write; -use std::time::Duration; -use thiserror::Error; -use wreq::{Client, StatusCode}; - -const SORA_IMAGE_GEN_URL: &str = "https://sora.com/backend/video_gen"; - -#[derive(Serialize, Debug)] -#[serde(rename_all = "snake_case")] -pub (crate) enum VideoGenType { - ImageGen, -} - -#[derive(Serialize, Debug)] -#[serde(rename_all = "snake_case")] -pub (crate) enum OperationType { - /// Simple prompt without reference images - SimpleCompose, - /// Prompt with reference images - Remix, -} - -#[derive(Serialize, Debug)] -#[serde(rename_all = "snake_case")] -pub (crate) enum InpaintItemType { - Image, -} - -#[derive(Serialize, Debug)] -#[serde(rename_all = "snake_case")] -pub (crate) struct InpaintItem { - pub r#type: InpaintItemType, - /// Typically "0" - pub frame_index: u32, - /// Unknown field; defaults to null - pub preset_id: Option, - /// Unknown field; defaults to null - pub generation_id: Option, - /// Token identifier of the item, eg. "media_01jqt9vt20erx9zvryf3v1pecx" - pub upload_media_id: String, - /// Typically "0" - pub source_start_frame: u32, - /// Typically "0" - pub source_end_frame: u32, - /// Unknown field; defaults to null - pub crop_bounds: Option, -} - -#[derive(Serialize, Debug)] -#[serde(rename_all = "snake_case")] -pub (crate) struct RawSoraImageGenRequest { - /// eg. "image_gen" - pub r#type: VideoGenType, - /// eg. "simple_compose" - pub operation: OperationType, - /// The user's raw prompt - pub prompt: String, - /// The number of variants to generate, eg. 2 - pub n_variants: usize, - /// The width of the image, eg. 480 - pub width: u16, - /// The height of the image, eg. 480 - pub height: u16, - /// The number of frames to generate, eg. 1 - pub n_frames: u8, - /// The items to inpaint, eg. [] - pub inpaint_items: Vec, -} - -#[derive(Deserialize, Debug)] -#[serde(rename_all = "snake_case")] -pub (crate) struct RawSoraResponse { - /// eg. "task_01jqsz9dsae9tvjygf1abrv3xf" - pub id: TaskId, - /// not known - pub priority: Option, -} - -// https://sora.com/backend/notif?limit=100&before=task_01jqpg8qghenet0rw2a79p0vbn -// error -// message "Missing bearer authentication in header" -// type "invalid_request_error" -// param null -// code null -#[derive(Deserialize, Debug, Clone)] -#[serde(rename_all = "snake_case")] -pub struct RawSoraErrorResponse { - error: RawSoraErrorInner, -} - -#[derive(Deserialize, Debug, Clone)] -#[serde(rename_all = "snake_case")] -pub enum RawSoraError { - Error(RawSoraErrorInner), - Unknown(String), -} - - -#[derive(Deserialize, Debug, Clone)] -#[serde(rename_all = "snake_case")] -pub enum SoraErrorCode { - SentinelBlock, - InvalidJwt, - TokenExpired, - TooManyConcurrentTasks, - UsernameRequired, - Unknown(String), -} - - -#[derive(Deserialize, Debug, Clone, Error)] -#[serde(rename_all = "snake_case")] -pub struct RawSoraErrorInner { - message: String, - r#type: String, - param: Option, - code: Option, -} - -impl std::fmt::Display for RawSoraErrorInner { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(f, "Sora API error: {}", self.message) - } -} - -/// Don't expose the internal request implementation as there are only a few "correct" ways to call the API. -pub (crate) async fn image_gen_http_request( - sora_request: RawSoraImageGenRequest, - credentials: &SoraCredentialSet, - request_timeout: Option, -) -> Result { - let client = Client::new(); - - let cookie = credentials.cookies.to_string(); - - let authorization_header = credentials.jwt_bearer_token.as_ref() - .ok_or(SoraClientError::NoBearerTokenForRequest)? - .to_authorization_header_value(); - - let sentinel = credentials.sora_sentinel_token.as_ref() - .map(|sentinel| sentinel.to_request_header_json()) - .transpose()? - .ok_or(SoraClientError::NoSentinelTokenForRequest)?; - - //let sentinel = credentials.sora_sentinel.as_ref() - // .map(|sentinel| sentinel.get_sentinel().to_string()) - // .ok_or(SoraClientError::NoSentinelTokenForRequest)?; - - let mut http_request = client.post(SORA_IMAGE_GEN_URL) - .header("User-Agent", CLIENT_USER_AGENT) - .header("Cookie", &cookie) - .header("Authorization", &authorization_header) - .header("Content-Type", "application/json") - .header("OpenAI-Sentinel-Token", &sentinel); - - if let Some(timeout) = request_timeout { - http_request = http_request.timeout(timeout); - } - - let http_request = http_request.json(&sora_request).build() - .map_err(|err| { - error!("Error building Sora image generation HTTP request: {:?}", err); - SoraClientError::WreqClientError(err) - })?; - - let response = client.execute(http_request) - .await - .map_err(|err| { - error!("Error during Sora image generation request: {:?}", err); - SoraClientError::WreqClientError(err) - })?; - - let status = response.status(); - - let response_body = &response.text().await - .map_err(|err| { - error!("Error reading Sora image generation response body: {:?}", err); - SoraClientError::WreqClientError(err) - })?; - - if status != StatusCode::OK { - warn!("Sora image generation failure. Raw response: {:?}", response_body); - - let error_response: RawSoraErrorResponse = serde_json::from_str(response_body) - .map_err(|err| SoraGenericApiError::SerdeParseErrorWithBodyOnNon200(err, response_body.to_string()))?; - - // Check for specific error codes - if let Some(code) = &error_response.error.code { - match code { - SoraErrorCode::TokenExpired => { - error!("Sora token expired: {}", error_response.error); - return Err(SoraSpecificApiError::TokenExpiredError.into()); - } - SoraErrorCode::SentinelBlock => { - error!("Sora image generation error sentinel block: {}", error_response.error); - return Err(SoraSpecificApiError::SentinelBlockError.into()); - } - SoraErrorCode::TooManyConcurrentTasks => { - error!("Too many concurrent tasks. Please wait."); - return Err(SoraSpecificApiError::TooManyConcurrentTasks.into()); - } - SoraErrorCode::Unknown(message) => { - error!("Unknown error: {} - message: {}", error_response.error.message, message); - return Err(SoraGenericApiError::UncategorizedBadResponse(error_response.error.message).into()); - } - SoraErrorCode::InvalidJwt => { - error!("Invalid JWT token: {}", error_response.error.message); - return Err(SoraSpecificApiError::InvalidJwt.into()); - } - SoraErrorCode::UsernameRequired => { - error!("Username required: {}", error_response.error.message); - return Err(SoraSpecificApiError::SoraUsernameNotYetCreated.into()); - } - } - } - - error!("Sora image generation failure: {}", error_response.error); - return Err(SoraGenericApiError::UncategorizedBadResponse( - format!("Unknown error code: {:?}, message: {:?}", error_response.error.code, error_response.error.message)) - .into()); - } - - let response = serde_json::from_str(response_body) - .map_err(|err| SoraGenericApiError::SerdeResponseParseErrorWithBody(err, response_body.to_string()))?; - - Ok(response) -} - -#[cfg(test)] -mod tests { - use crate::requests::image_gen::image_gen_http_request::RawSoraResponse; - use errors::AnyhowResult; - - #[test] - #[ignore] // Run manually - fn deserialize_task_id() -> AnyhowResult<()> { - let json = "{\"id\": \"task_foobarbaz\"}"; - let response : RawSoraResponse = serde_json::from_str(json)?; - assert_eq!(response.id.0, "task_foobarbaz"); - Ok(()) - } -} diff --git a/crates/api_clients/openai_sora_client/src/requests/image_gen/mod.rs b/crates/api_clients/openai_sora_client/src/requests/image_gen/mod.rs deleted file mode 100644 index e25841c171..0000000000 --- a/crates/api_clients/openai_sora_client/src/requests/image_gen/mod.rs +++ /dev/null @@ -1,4 +0,0 @@ -pub (crate) mod image_gen_http_request; -pub mod common; -pub mod sora_image_gen_remix; -pub mod sora_image_gen_simple; diff --git a/crates/api_clients/openai_sora_client/src/requests/image_gen/sora_image_gen_remix.rs b/crates/api_clients/openai_sora_client/src/requests/image_gen/sora_image_gen_remix.rs deleted file mode 100644 index e17dafc4d6..0000000000 --- a/crates/api_clients/openai_sora_client/src/requests/image_gen/sora_image_gen_remix.rs +++ /dev/null @@ -1,93 +0,0 @@ -use crate::creds::sora_credential_set::SoraCredentialSet; -use crate::error::sora_error::SoraError; -use crate::requests::image_gen::common::{ImageSize, NumImages, SoraImageGenResponse}; -use crate::requests::image_gen::image_gen_http_request::{image_gen_http_request, InpaintItem, InpaintItemType, OperationType, RawSoraImageGenRequest, VideoGenType}; -use log::info; -use std::time::Duration; - -pub struct SoraImageGenRemixRequest<'a> { - pub prompt: String, - pub num_images: NumImages, - pub image_size: ImageSize, - pub sora_media_tokens: Vec, - pub credentials: &'a SoraCredentialSet, - pub request_timeout: Option, -} - -/// The "remix" commands let you supply additional images as context. -/// Sora "media tokens" of previously uploaded images must be supplied. -pub async fn sora_image_gen_remix(request: SoraImageGenRemixRequest<'_>) -> Result { - let args = RawSoraImageGenRequest { - r#type: VideoGenType::ImageGen, - operation: OperationType::Remix, - prompt: request.prompt, - n_variants: request.num_images.as_count(), - width: request.image_size.as_width(), - height: request.image_size.as_height(), - n_frames: 1, - inpaint_items: request.sora_media_tokens.into_iter().map(|token| { - InpaintItem { - r#type: InpaintItemType::Image, - frame_index: 0, - preset_id: None, - generation_id: None, - upload_media_id: token, - source_start_frame: 0, - source_end_frame: 0, - crop_bounds: None, - } - }).collect(), - }; - - // TODO: Replace this with debug level logging in the future. - info!("Sending remix request: {:?}", args); - - let result = image_gen_http_request(args, request.credentials, request.request_timeout).await?; - - Ok(SoraImageGenResponse { - task_id: result.id, - }) -} - -#[cfg(test)] -mod tests { - use crate::creds::sora_credential_builder::SoraCredentialBuilder; - use crate::requests::image_gen::common::{ImageSize, NumImages}; - use crate::requests::image_gen::sora_image_gen_remix::{sora_image_gen_remix, SoraImageGenRemixRequest}; - use errors::AnyhowResult; - use std::fs::read_to_string; - use test_utils::test_file_path::test_file_path; - - #[ignore] // You can manually run "ignore" tests in the IDE, but they won't run in CI. - #[tokio::test] - pub async fn manual_test() -> AnyhowResult<()> { - let sentinel = read_to_string(test_file_path("test_data/temp/sentinel.txt")?)?; - let sentinel = sentinel.trim().to_string(); - - let cookie = read_to_string(test_file_path("test_data/temp/cookie.txt")?)?; - let cookie = cookie.trim().to_string(); - - let bearer = read_to_string(test_file_path("test_data/temp/bearer.txt")?)?; - let bearer = bearer.trim().to_string(); - - let creds = SoraCredentialBuilder::new() - .with_cookies(&cookie) - .with_jwt_bearer_token(&bearer) - .with_sora_sentinel(&sentinel) - .build()?; - - let response = sora_image_gen_remix(SoraImageGenRemixRequest { - prompt: "Match the pose and scene layout from the uploaded image exactly. A smart dog getting kisses from another dog. Brick building. Anime style".to_string(), - num_images: NumImages::One, - image_size: ImageSize::Square, - sora_media_tokens: vec!["media_01jqyhrz4detyvtzwp2p4j63ad".to_string()], - credentials: &creds, - request_timeout: None, - }).await?; - - println!("task_id: {}", response.task_id); - - assert!(response.task_id.0.starts_with("task_")); - Ok(()) - } -} diff --git a/crates/api_clients/openai_sora_client/src/requests/image_gen/sora_image_gen_simple.rs b/crates/api_clients/openai_sora_client/src/requests/image_gen/sora_image_gen_simple.rs deleted file mode 100644 index 73f9674fe3..0000000000 --- a/crates/api_clients/openai_sora_client/src/requests/image_gen/sora_image_gen_simple.rs +++ /dev/null @@ -1,64 +0,0 @@ -use crate::creds::sora_credential_set::SoraCredentialSet; -use crate::error::sora_error::SoraError; -use crate::requests::image_gen::common::{ImageSize, NumImages, SoraImageGenResponse}; -use crate::requests::image_gen::image_gen_http_request::{image_gen_http_request, OperationType, RawSoraImageGenRequest, VideoGenType}; -use std::time::Duration; - -pub struct SoraImageGenSimpleRequest<'a> { - pub prompt: String, - pub num_images: NumImages, - pub image_size: ImageSize, - pub credentials: &'a SoraCredentialSet, - pub request_timeout: Option, -} - -pub async fn sora_image_gen_simple(args: SoraImageGenSimpleRequest<'_>) -> Result { - let sora_request = RawSoraImageGenRequest { - r#type: VideoGenType::ImageGen, - operation: OperationType::SimpleCompose, - prompt: args.prompt, - n_variants: args.num_images.as_count(), - width: args.image_size.as_width(), - height: args.image_size.as_height(), - n_frames: 1, - inpaint_items: vec![], - }; - - let result = image_gen_http_request( - sora_request, - args.credentials, - args.request_timeout - ).await?; - - Ok(SoraImageGenResponse { - task_id: result.id, - }) -} - -#[cfg(test)] -mod tests { - use crate::requests::image_gen::common::{ImageSize, NumImages}; - use crate::requests::image_gen::sora_image_gen_simple::{sora_image_gen_simple, SoraImageGenSimpleRequest}; - use crate::test_utils::get_test_credentials::get_test_credentials; - use errors::AnyhowResult; - - #[ignore] // You can manually run "ignore" tests in the IDE, but they won't run in CI. - #[tokio::test] - pub async fn manual_test() -> AnyhowResult<()> { - let creds = get_test_credentials()?; - - let response = sora_image_gen_simple(SoraImageGenSimpleRequest { - prompt: "A pirate ship catches on fire as an alien ufo attacks it, photorealistic".to_string(), - num_images: NumImages::One, - image_size: ImageSize::Square, - credentials: &creds, - request_timeout: None, - }).await?; - - println!("task_id: {}", response.task_id); - - assert!(response.task_id.0.starts_with("task_")); - assert_eq!(1, 2); - Ok(()) - } -} \ No newline at end of file diff --git a/crates/api_clients/openai_sora_client/src/requests/list_classic_tasks/list_classic_tasks.rs b/crates/api_clients/openai_sora_client/src/requests/list_classic_tasks/list_classic_tasks.rs deleted file mode 100644 index 84083ce42a..0000000000 --- a/crates/api_clients/openai_sora_client/src/requests/list_classic_tasks/list_classic_tasks.rs +++ /dev/null @@ -1,163 +0,0 @@ -use crate::constants::user_agent::CLIENT_USER_AGENT; -use crate::creds::sora_credential_set::SoraCredentialSet; -use crate::error::sora_client_error::SoraClientError; -use crate::error::sora_error::SoraError; -use crate::error::sora_generic_api_error::SoraGenericApiError; -use crate::requests::common::task_id::TaskId; -use crate::requests::deprecated::job_status::sora_job_status::{Generation, StatusRequest, VideoGenStatusResponse}; -use crate::utils_internal::classify_general_http_status_code_and_body::classify_general_http_status_code_and_body; -use log::{debug, error, warn}; -use serde_derive::Deserialize; -use url::Url; -use wreq::Client; - -const SORA_LIST_CLASSIC_TASKS_URL: &str = "https://sora.chatgpt.com/backend/v2/list_tasks?limit=20"; - - -/// NB: We omit fields we're not using to prevent breakage. -#[derive(Deserialize, Clone, Debug)] -#[serde(rename_all = "snake_case")] -pub struct ListTasksResponse { - pub task_responses: Vec, - pub last_id: Option, - pub has_more: bool, -} - -/// NB: We omit fields we're not using to prevent breakage. -#[derive(Deserialize, Clone, Debug)] -#[serde(rename_all = "snake_case")] -pub struct PartialTaskResponse { - pub id: TaskId, - pub status: TaskStatus, - - /// Text prompt used to generate the media. - pub prompt: Option, - - pub generations: Vec, - - //pub user: String, - //pub created_at: String, - //pub status: String, // eg. "succeeded" - //pub progress_pct: Option, - //pub progress_pos_in_queue: Option, - //pub encodings: Vec // NB: These are webp images. - // ... lots of other fields ... -} - - -#[derive(Deserialize, Clone, Debug, Eq, PartialEq)] -#[serde(rename_all = "snake_case")] -pub enum TaskStatus { - Queued, - Running, - Succeeded, - Failed, - #[serde(untagged)] - Unknown(String), -} - -/// NB: We omit fields we're not using to prevent breakage. -#[derive(Deserialize, Clone, Debug)] -#[serde(rename_all = "snake_case")] -pub struct PartialGeneration { - // A unique ID for the generation, eg. "gen_01abc..." - pub id: String, - pub url: String, - - //pub id: String, - //pub task_id: TaskId, - //pub created_at: String, - //pub deleted_at: Option, - //pub url: String, - //pub seed: Option, - //pub can_download: Option, - // ... lots of other fields ... -} - -pub async fn list_classic_tasks(credentials: &SoraCredentialSet) -> Result { - - let bearer_header = match credentials.jwt_bearer_token.as_ref() { - Some(bearer) => bearer.to_authorization_header_value(), - None => { - warn!("No JWT bearer token in client - cannot fetch image gen status!"); - return Err(SoraClientError::NoBearerTokenForRequest.into()); - }, - }; - - let client = Client::new(); - - let mut url = Url::parse(SORA_LIST_CLASSIC_TASKS_URL) - .map_err(|err| { - SoraClientError::UrlParseError(err) - })?; - - - // TODO: Future pagination. - // Add query parameters - //if let Some(limit) = status_request.limit { - // url.query_pairs_mut().append_pair("limit", &limit.to_string()); - //} - //if let Some(before) = &status_request.before { - // url.query_pairs_mut().append_pair("before", &before); - //} - - let http_request = client.get(url.as_str()) - .header("User-Agent", CLIENT_USER_AGENT) - .header("Cookie", credentials.cookies.as_str()) - .header("Authorization", bearer_header) - .header("Content-Type", "application/json"); - - let http_request = http_request.build() - .map_err(|err| { - SoraClientError::WreqClientError(err) - })?; - - let response = client.execute(http_request) - .await - .map_err(|err| { - error!("Client failed to fetch sora task list: {:?}", err); - SoraGenericApiError::WreqError(err) - })?; - - let status = response.status(); - - let response_body = &response.text() - .await - .map_err(|err| { - error!("Client failed to read sora task list: {:?}", err); - SoraGenericApiError::WreqError(err) - })?; - - debug!("response_body: {}", response_body); - - if !status.is_success() { - error!("The sora task list request failed; status = {:?} ; response body = {}", status, response_body); - let error = classify_general_http_status_code_and_body(status, &response_body); - return Err(error); - } - - let response = serde_json::from_str::(response_body) - .map_err(|err| { - error!("Failed to parse status response: {:?}", err); - SoraGenericApiError::SerdeResponseParseErrorWithBody(err, response_body.to_string()) - })?; - - Ok(response) -} - -#[cfg(test)] -mod tests { - use crate::requests::list_classic_tasks::list_classic_tasks::list_classic_tasks; - use crate::test_utils::get_test_credentials::get_test_credentials; - use errors::AnyhowResult; - - #[ignore] // You can manually run "ignore" tests in the IDE, but they won't run in CI. - #[tokio::test] - pub async fn manual_test() -> AnyhowResult<()> { - let creds = get_test_credentials()?; - let result = list_classic_tasks(&creds).await?; - println!("result: {:#?}", result); - assert_eq!(1, 2); - Ok(()) - } -} diff --git a/crates/api_clients/openai_sora_client/src/requests/list_classic_tasks/mod.rs b/crates/api_clients/openai_sora_client/src/requests/list_classic_tasks/mod.rs deleted file mode 100644 index 22f2d9226f..0000000000 --- a/crates/api_clients/openai_sora_client/src/requests/list_classic_tasks/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod list_classic_tasks; \ No newline at end of file diff --git a/crates/api_clients/openai_sora_client/src/requests/list_sora2_drafts/http_response.rs b/crates/api_clients/openai_sora_client/src/requests/list_sora2_drafts/http_response.rs deleted file mode 100644 index 5c319923ff..0000000000 --- a/crates/api_clients/openai_sora_client/src/requests/list_sora2_drafts/http_response.rs +++ /dev/null @@ -1,57 +0,0 @@ -use serde_derive::Deserialize; - -#[derive(Deserialize)] -pub (super) struct HttpDraftsResponse { - pub items: Vec, - - // NB: This is nullable. - // It's null in my tests, so I don't know if this is a string or integer yet. Probably an opaque string? - //pub cursor: Option, -} - -#[derive(Deserialize)] -pub (super) struct PartialItem { - /// The generation id, eg. "gen_01abc..." - pub id: String, - - /// The parent task id, eg "task_01abc..." - pub task_id: String, - - //pub generation_id: String, // it looks like this matches "id" for now - - /// The kind of draft - pub kind: DraftKind, - - // The text prompt - pub prompt: String, - - /// URL to the generation - /// This will not be present if the request failed, eg. for content reasons. - pub url: Option, - - /// "downloadable" URL to the generation - /// it looks like this matches "url" for now - /// This will not be present if the request failed, eg. for content reasons. - pub downloadable_url: Option, - - /// If there was a content violation, this will describe why. - pub reason_str: Option, - - // There are other things that might be interesting: "encodings", "width", "height", etc. -} - - -#[derive(Deserialize)] -#[serde(rename_all = "snake_case")] -pub enum DraftKind { - /// Generated video - SoraDraft, - - /// Video was blocked due to content - /// These failures will have different "reason_str" reasons. - SoraContentViolation, - - /// Unknown type. - #[serde(untagged)] - Unknown(String), -} diff --git a/crates/api_clients/openai_sora_client/src/requests/list_sora2_drafts/list_sora2_drafts.rs b/crates/api_clients/openai_sora_client/src/requests/list_sora2_drafts/list_sora2_drafts.rs deleted file mode 100644 index d295adf180..0000000000 --- a/crates/api_clients/openai_sora_client/src/requests/list_sora2_drafts/list_sora2_drafts.rs +++ /dev/null @@ -1,180 +0,0 @@ -use crate::constants::user_agent::CLIENT_USER_AGENT; -use crate::creds::sora_credential_set::SoraCredentialSet; -use crate::error::sora_client_error::SoraClientError; -use crate::error::sora_error::SoraError; -use crate::error::sora_generic_api_error::SoraGenericApiError; -use crate::requests::common::task_id::TaskId; -use crate::requests::deprecated::job_status::sora_job_status::{Generation, StatusRequest, VideoGenStatusResponse}; -use crate::requests::list_sora2_drafts::http_response::{DraftKind, HttpDraftsResponse}; -use crate::utils_internal::classify_general_http_status_code_and_body::classify_general_http_status_code_and_body; -use log::{debug, error, info, warn}; -use serde_derive::Deserialize; -use url::Url; -use wreq::header::{ACCEPT, ACCEPT_LANGUAGE, AUTHORIZATION, CONTENT_TYPE, COOKIE, ORIGIN, REFERER}; -use wreq::Client; - -const SORA_LIST_DRAFTS_URL: &str = "https://sora.chatgpt.com/backend/project_y/profile/drafts?limit=15"; - - -/// NB: We omit fields we're not using to prevent breakage. -#[derive(Clone, Debug)] -pub struct ListSora2DraftsResponse { - pub drafts: Vec, -} - -#[derive(Clone, Debug)] -pub enum Draft { - Success(DraftSuccess), - Failure(DraftFailure), -} - -#[derive(Clone, Debug)] -pub struct DraftSuccess { - pub id: String, - pub task_id: TaskId, - pub url: String, - pub prompt: String, -} - -#[derive(Clone, Debug)] -pub struct DraftFailure { - pub task_id: TaskId, - pub reason_message: String, -} - -pub async fn list_sora2_drafts(credentials: &SoraCredentialSet) -> Result { - - let client = Client::new(); - - let authorization_header = credentials.jwt_bearer_token.as_ref() - .ok_or(SoraClientError::NoBearerTokenForRequest)? - .to_authorization_header_value(); - - let cookie = credentials.cookies.to_string(); - - // TODO: Make the sec-* headers match the user agent and platform - // TODO: device id - //-H 'oai-device-id: 7c216860-5b73-4e63-983f-142dbcae1809' \ - let mut http_request = client.get(SORA_LIST_DRAFTS_URL) - //.header("OpenAI-Sentinel-Token", &sentinel); - .header(ACCEPT, "*/*") - .header(REFERER, "https://sora.chatgpt.com/drafts") - .header(ACCEPT_LANGUAGE, "en-US,en;q=0.9") - .header(wreq::header::USER_AGENT, CLIENT_USER_AGENT) - .header(COOKIE, &cookie) - .header(AUTHORIZATION, &authorization_header) - .header("priority", "u=1, i") - .header("sec-ch-ua", "\"Chromium\";v=\"140\", \"Not=A?Brand\";v=\"24\", \"Google Chrome\";v=\"140\"") - .header("sec-ch-ua-mobile", "?0") - .header("sec-ch-ua-platform", "macOS") - .header("sec-fetch-dest", "empty") - .header("sec-fetch-mode", "cors") - .header("sec-fetch-site", "same-origin"); - - //if let Some(timeout) = args.request_timeout { - // http_request = http_request.timeout(timeout); - //} - - let http_request = http_request.build() - .map_err(|err| { - error!("Error building Sora 2 list drafts HTTP request: {:?}", err); - SoraClientError::WreqClientError(err) - })?; - - let response = client.execute(http_request) - .await - .map_err(|err| { - error!("Error during Sora 2 list drafts request: {:?}", err); - SoraClientError::WreqClientError(err) - })?; - - let status = response.status(); - - let response_body = &response.text().await - .map_err(|err| { - error!("Error reading Sora 2 list drafts response body: {:?}", err); - SoraClientError::WreqClientError(err) - })?; - - if !status.is_success() { - error!("Sora list drafts request returned an error (code {}) : {:?}", status.as_u16(), response_body); - - // TODO: Categorize failures. - // error!("The sora task list request failed; status = {:?} ; response body = {}", status, response_body); - // let error = classify_general_http_status_code_and_body(status, &response_body).await; - // return Err(error); - - return Err(SoraGenericApiError::UncategorizedBadResponseWithStatusAndBody { - status_code: status, - body: response_body.to_string(), - }.into()); - } - - let response : HttpDraftsResponse = serde_json::from_str(response_body) - .map_err(|err| SoraGenericApiError::SerdeResponseParseErrorWithBody(err, response_body.to_string()))?; - - Ok(ListSora2DraftsResponse { - drafts: response.items - .into_iter() - .map(|draft| { - let task_id = TaskId::from_string(draft.task_id); - match draft.kind { - DraftKind::SoraDraft => { - match draft.url { - Some(url) => { - // Success case - Draft::Success(DraftSuccess { - id: draft.id, - task_id, - url, - prompt: draft.prompt, - }) - } - None => { - return Draft::Failure(DraftFailure { - task_id, - reason_message: "Generation failed. URL missing from the draft.".to_string(), - }); - } - } - } - DraftKind::SoraContentViolation => { - Draft::Failure(DraftFailure { - task_id, - reason_message: format!( - "Generation failed due to content violation: {}", - draft.reason_str - .unwrap_or_else(|| "no additional reason".to_string())), - }) - } - DraftKind::Unknown(value) => { - Draft::Failure(DraftFailure { - task_id, - reason_message: format!( - "Generation failed with unknown failure code: {}. Possible message: {}", - value, - draft.reason_str - .unwrap_or_else(|| "no additional message".to_string())), - }) - } - } - }).collect(), - }) -} - -#[cfg(test)] -mod tests { - use crate::requests::list_sora2_drafts::list_sora2_drafts::list_sora2_drafts; - use crate::test_utils::get_test_credentials::get_test_credentials; - use errors::AnyhowResult; - - #[ignore] // You can manually run "ignore" tests in the IDE, but they won't run in CI. - #[tokio::test] - pub async fn manual_test() -> AnyhowResult<()> { - let creds = get_test_credentials()?; - let result = list_sora2_drafts(&creds).await?; - println!("result: {:#?}", result); - assert_eq!(1, 2); - Ok(()) - } -} diff --git a/crates/api_clients/openai_sora_client/src/requests/list_sora2_drafts/mod.rs b/crates/api_clients/openai_sora_client/src/requests/list_sora2_drafts/mod.rs deleted file mode 100644 index 1b250f4e07..0000000000 --- a/crates/api_clients/openai_sora_client/src/requests/list_sora2_drafts/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod list_sora2_drafts; -pub (super) mod http_response; diff --git a/crates/api_clients/openai_sora_client/src/requests/mod.rs b/crates/api_clients/openai_sora_client/src/requests/mod.rs deleted file mode 100644 index a159398741..0000000000 --- a/crates/api_clients/openai_sora_client/src/requests/mod.rs +++ /dev/null @@ -1,11 +0,0 @@ -pub mod auth_bearer; -pub mod auth_sentinel; -pub mod auth_sentinel_2; -pub mod common; -pub mod deprecated; -pub mod generate_sora2_video; -pub mod image_gen; -pub mod list_classic_tasks; -pub mod list_sora2_drafts; -pub mod upload; -pub mod upload_sora2; \ No newline at end of file diff --git a/crates/api_clients/openai_sora_client/src/requests/upload/mod.rs b/crates/api_clients/openai_sora_client/src/requests/upload/mod.rs deleted file mode 100644 index d80cfa0605..0000000000 --- a/crates/api_clients/openai_sora_client/src/requests/upload/mod.rs +++ /dev/null @@ -1,5 +0,0 @@ -pub (crate) mod upload_media_http_request; -pub mod upload_media_http_response; - -pub mod upload_media_from_bytes; -pub mod upload_media_from_file; \ No newline at end of file diff --git a/crates/api_clients/openai_sora_client/src/requests/upload/upload_media_from_bytes.rs b/crates/api_clients/openai_sora_client/src/requests/upload/upload_media_from_bytes.rs deleted file mode 100644 index d3aaaeb19a..0000000000 --- a/crates/api_clients/openai_sora_client/src/requests/upload/upload_media_from_bytes.rs +++ /dev/null @@ -1,31 +0,0 @@ -use crate::creds::sora_credential_set::SoraCredentialSet; -use crate::error::sora_error::SoraError; -use crate::requests::upload::upload_media_http_request::upload_media_http_request; -use crate::requests::upload::upload_media_http_response::SoraMediaUploadResponse; -use std::path::PathBuf; -use std::time::Duration; - -/// Upload bytes. -/// The underlying reqwest lib needs to own the bytes, so we can't pass as a reference. -pub async fn sora_media_upload_from_bytes( - bytes: Vec, - file_name: String, - creds: &SoraCredentialSet, - maybe_timeout: Option, -) -> Result { - let file_path = PathBuf::from(&file_name); - - // TODO: Read file magic bytes first, then fall back to this. - let mime_type = match file_path.extension().and_then(|e| e.to_str()) { - Some("jpg") | Some("jpeg") => "image/jpeg", - Some("png") => "image/png", - // Some("webp") => "image/webp", - // Some("gif") => "image/gif", - // Some("mp4") => "video/mp4", - // Some("mov") => "video/quicktime", - // Some("webm") => "video/webm", - _ => "application/octet-stream", - }; - - Ok(upload_media_http_request(bytes, file_name, mime_type, creds, maybe_timeout).await?) -} diff --git a/crates/api_clients/openai_sora_client/src/requests/upload/upload_media_from_file.rs b/crates/api_clients/openai_sora_client/src/requests/upload/upload_media_from_file.rs deleted file mode 100644 index 6ea06bfa77..0000000000 --- a/crates/api_clients/openai_sora_client/src/requests/upload/upload_media_from_file.rs +++ /dev/null @@ -1,86 +0,0 @@ -use crate::creds::sora_credential_set::SoraCredentialSet; -use crate::error::sora_client_error::SoraClientError; -use crate::error::sora_error::SoraError; -use crate::requests::upload::upload_media_http_request::upload_media_http_request; -use crate::requests::upload::upload_media_http_response::SoraMediaUploadResponse; -use log::error; -use std::path::Path; -use std::time::Duration; -use tokio::fs::File; -use tokio::io::AsyncReadExt; - -/// Try to prevent buffer reallocations. -/// There's a better way to implement this. -const INITIAL_BUFFER_SIZE : usize = 1024*1024; - -pub async fn sora_media_upload_from_file>( - file_path: P, - creds: &SoraCredentialSet, - maybe_timeout: Option, -) -> Result { - let mut file = File::open(&file_path).await - .map_err(|err| { - error!("Failed to open file for upload: {}", err); - SoraClientError::FileForUploadReadError(err) - })?; - - let mut buffer = Vec::with_capacity(INITIAL_BUFFER_SIZE); - - file.read_to_end(&mut buffer).await - .map_err(|err| { - error!("Failed to read file for upload: {}", err); - SoraClientError::FileForUploadReadError(err) - })?; - - let filename = file_path.as_ref().file_name() - .ok_or_else(|| SoraClientError::FileForUploadHasInvalidPath)? - .to_string_lossy() - .to_string(); - - let maybe_ext = file_path.as_ref().extension().and_then(|e| e.to_str()); - - // TODO: Read file magic bytes first, then fall back to this. - let mime_type = match maybe_ext { - Some("jpg") | Some("jpeg") => "image/jpeg", - Some("png") => "image/png", - // Some("webp") => "image/webp", - // Some("gif") => "image/gif", - // Some("mp4") => "video/mp4", - // Some("mov") => "video/quicktime", - // Some("webm") => "video/webm", - _ => "application/octet-stream", - }; - - Ok(upload_media_http_request(buffer, filename, mime_type, creds, maybe_timeout).await?) -} - -#[cfg(test)] -mod tests { - use crate::requests::upload::upload_media_from_file::sora_media_upload_from_file; - use crate::test_utils::get_test_credentials::get_test_credentials; - use errors::AnyhowResult; - use test_utils::test_file_path::test_file_path; - - #[ignore] // You can manually run "ignore" tests in the IDE, but they won't run in CI. - #[tokio::test] - pub async fn manual_test() -> AnyhowResult<()> { - let creds = get_test_credentials()?; - - let image_path = test_file_path("test_data/image/juno.jpg")?; // media_01jqyqgqpwf40tkcapq5bmaz5d - - let response = sora_media_upload_from_file( - image_path, - &creds, - None, - ).await?; - - println!("media: {:?}", response); - - println!("media_id: {}", response.id); - println!("media_url: {}", response.url); - - assert!(response.id.starts_with("media_")); - - Ok(()) - } -} diff --git a/crates/api_clients/openai_sora_client/src/requests/upload/upload_media_http_request.rs b/crates/api_clients/openai_sora_client/src/requests/upload/upload_media_http_request.rs deleted file mode 100644 index bd4af01f62..0000000000 --- a/crates/api_clients/openai_sora_client/src/requests/upload/upload_media_http_request.rs +++ /dev/null @@ -1,94 +0,0 @@ -use crate::constants::user_agent::CLIENT_USER_AGENT; -use crate::creds::sora_credential_set::SoraCredentialSet; -use crate::error::sora_client_error::SoraClientError; -use crate::error::sora_error::SoraError; -use crate::error::sora_generic_api_error::SoraGenericApiError; -use crate::requests::upload::upload_media_http_response::SoraMediaUploadResponse; -use crate::utils_internal::classify_general_http_error::classify_general_http_error; -use log::{error, info}; -use serde::Deserialize; -use std::io::empty; -use std::time::Duration; -use wreq::header::{ACCEPT, ACCEPT_LANGUAGE, AUTHORIZATION, COOKIE, ORIGIN, REFERER}; -use wreq::multipart::{Form, Part}; -use wreq::Client; - -const SORA_UPLOAD_MEDIA_URL: &str = "https://sora.com/backend/uploads"; - -pub (crate) struct SoraMediaUploadRequest<'a> { - pub file_path: String, - pub credentials: &'a SoraCredentialSet, -} - -pub (crate) async fn upload_media_http_request( - file_bytes: Vec, - filename: String, - mime_type: &str, - credentials: &SoraCredentialSet, - maybe_timeout: Option, -) -> Result { - - // Create multipart form - let part = Part::bytes(file_bytes) // NB: Reqwest needs to own the bytes. - .file_name(filename) // NB: Reqwest needs to own the bytes - .mime_str(mime_type) - .map_err(|e| SoraClientError::MultipartFormError(e))?; - - let form = Form::new().part("file", part); - - let cookie = credentials.cookies.to_string(); - let auth_header = credentials.jwt_bearer_token - .as_ref() - .ok_or(SoraClientError::NoBearerTokenForRequest)? - .to_authorization_header_value(); - - // Make API request - let client = Client::new(); - let mut request_builder = client.post(SORA_UPLOAD_MEDIA_URL) - .multipart(form) - .header(ACCEPT, "*/*") - .header(ACCEPT_LANGUAGE, "en-US,en;q=0.9") - .header(AUTHORIZATION, &auth_header) - .header(COOKIE, &cookie) - .header(ORIGIN, "https://sora.chatgpt.com") - .header("user-agent", CLIENT_USER_AGENT) - .header(REFERER, "https://sora.chatgpt.com/explore") - .header("priority", "u=1, i") - .header("sec-ch-ua", "\"Chromium\";v=\"140\", \"Not=A?Brand\";v=\"24\", \"Google Chrome\";v=\"140\"") - .header("sec-ch-ua-mobile", "?0") - .header("sec-ch-ua-platform", "macOS") - .header("sec-fetch-dest", "empty") - .header("sec-fetch-mode", "cors") - .header("sec-fetch-site", "same-origin"); - - if let Some(timeout) = maybe_timeout { - request_builder = request_builder.timeout(timeout); - } - - let response = request_builder.send() - .await - .map_err(|err| { - SoraGenericApiError::WreqError(err) - })?; - - // Check response status - if !response.status().is_success() { - info!("Error uploading image: {:?}", response.status()); - let error = classify_general_http_error(response).await; - return Err(error); - } - - let response_body = &response.text().await - .map_err(|err| { - error!("Error reading response body while attempting file upload: {:?}", err); - SoraGenericApiError::WreqError(err) - })?; - - let upload_response : SoraMediaUploadResponse = serde_json::from_str(&response_body) - .map_err(|err| { - error!("Error parsing response body while attempting file upload: {:?}", err); - SoraGenericApiError::SerdeResponseParseErrorWithBody(err, response_body.to_string()) - })?; - - Ok(upload_response) -} diff --git a/crates/api_clients/openai_sora_client/src/requests/upload/upload_media_http_response.rs b/crates/api_clients/openai_sora_client/src/requests/upload/upload_media_http_response.rs deleted file mode 100644 index 0cb637c50c..0000000000 --- a/crates/api_clients/openai_sora_client/src/requests/upload/upload_media_http_response.rs +++ /dev/null @@ -1,51 +0,0 @@ -use serde_derive::Deserialize; - -#[derive(Debug, Deserialize)] -pub struct SoraMediaUploadResponse { - /// This is the media token id. - pub id: String, - pub r#type: String, - pub created_at: String, - pub filename: String, - pub extension: String, - pub mime_type: String, - pub url: String, - pub width: Option, - pub height: Option, - pub duration_sec: Option, - pub n_frames: Option, - pub size_bytes: u64, - pub thumbnail_url: Option, -} - -// Content-Disposition: form-data; name="file"; filename="imagename.webp" - -/* -Response: -{ - "id": "media_01jqt9vt20erx9zvryf3v1pecx", - "type": "image", - "created_at": "2025-04-02T03:49:04.185867Z", - "filename": "Rith_essa.webp", - "extension": "jpeg", - "mime_type": "image/jpeg", - "url": "https://videos.openai.com/vg-assets/assets%2Fclient_upload%2Fmedia%2Fuser-9wf6JFdgRSJLjvSJ53LNAbV8%2Fmedia_01jqt9vt20erx9zvryf3v1pecx.jpeg?st=2025-04-02T02%3A39%3A01Z&se=2025-04-08T03%3A39%3A01Z&sks=b&skt=2025-04-02T02%3A39%3A01Z&ske=2025-04-08T03%3A39%3A01Z&sktid=a48cca56-e6da-484e-a814-9c849652bcb3&skoid=3d249c53-07fa-4ba4-9b65-0bf8eb4ea46a&skv=2019-02-02&sv=2018-11-09&sr=b&sp=r&spr=https%2Chttp&sig=%2BdnTQyw9OFF2kaVoEReT2cVfTqmKjGt18m7P4wKCWCI%3D&az=oaivgprodscus", - "width": 1200, - "height": 675, - "duration_sec": null, - "n_frames": 1, - "size_bytes": 118501, - "thumbnail_url": "https://videos.openai.com/vg-assets/assets%2Fclient_upload%2Fmedia%2Fuser-9wf6JFdgRSJLjvSJ53LNAbV8%2Fmedia_01jqt9vt20erx9zvryf3v1pecx.jpg?st=2025-04-02T02%3A39%3A01Z&se=2025-04-08T03%3A39%3A01Z&sks=b&skt=2025-04-02T02%3A39%3A01Z&ske=2025-04-08T03%3A39%3A01Z&sktid=a48cca56-e6da-484e-a814-9c849652bcb3&skoid=3d249c53-07fa-4ba4-9b65-0bf8eb4ea46a&skv=2019-02-02&sv=2018-11-09&sr=b&sp=r&spr=https%2Chttp&sig=9aU9xKI0BkhRtrTb0RD05%2BT6prBnmXk1I7nV2nTsFbY%3D&az=oaivgprodscus" -} - -Error response: - -Failed to upload scene media to Sora: Upload failed with status 401 Unauthorized: { - "error": { - "message": "Your authentication token has expired. Please try signing in again.", - "type": "invalid_request_error", - "param": null, - "code": "token_expired" - } - } -*/ diff --git a/crates/api_clients/openai_sora_client/src/requests/upload_sora2/http_response.rs b/crates/api_clients/openai_sora_client/src/requests/upload_sora2/http_response.rs deleted file mode 100644 index db23ee8d0e..0000000000 --- a/crates/api_clients/openai_sora_client/src/requests/upload_sora2/http_response.rs +++ /dev/null @@ -1,21 +0,0 @@ -use serde_derive::Deserialize; - -#[derive(Debug, Deserialize)] -pub struct SoraMediaUploadResponse { - /// This is the media token id. - pub id: String, - - // NB: Don't need these, so commented out: - //pub r#type: String, - //pub created_at: String, - //pub filename: String, - //pub extension: String, - //pub mime_type: String, - //pub url: String, - //pub width: Option, - //pub height: Option, - //pub duration_sec: Option, - //pub n_frames: Option, - //pub size_bytes: u64, - //pub thumbnail_url: Option, -} diff --git a/crates/api_clients/openai_sora_client/src/requests/upload_sora2/mod.rs b/crates/api_clients/openai_sora_client/src/requests/upload_sora2/mod.rs deleted file mode 100644 index a80e5b7f36..0000000000 --- a/crates/api_clients/openai_sora_client/src/requests/upload_sora2/mod.rs +++ /dev/null @@ -1,5 +0,0 @@ -//pub mod upload_media_sora2_from_bytes; -//pub mod upload_media_sora2_from_file; -// -//pub mod upload_media_sora2_http_request; -//mod http_response; diff --git a/crates/api_clients/openai_sora_client/src/requests/upload_sora2/upload_media_sora2_from_bytes.rs b/crates/api_clients/openai_sora_client/src/requests/upload_sora2/upload_media_sora2_from_bytes.rs deleted file mode 100644 index 3703cda94f..0000000000 --- a/crates/api_clients/openai_sora_client/src/requests/upload_sora2/upload_media_sora2_from_bytes.rs +++ /dev/null @@ -1,30 +0,0 @@ -use crate::creds::sora_credential_set::SoraCredentialSet; -use crate::error::sora_error::SoraError; -use crate::requests::upload::upload_media_http_request::{upload_media_http_request, SoraMediaUploadResponse}; -use std::path::PathBuf; -use std::time::Duration; - -/// Upload bytes. -/// The underlying reqwest lib needs to own the bytes, so we can't pass as a reference. -pub async fn sora_media_upload_from_bytes( - bytes: Vec, - file_name: String, - creds: &SoraCredentialSet, - maybe_timeout: Option, -) -> Result { - let file_path = PathBuf::from(&file_name); - - // TODO: Read file magic bytes first, then fall back to this. - let mime_type = match file_path.extension().and_then(|e| e.to_str()) { - Some("jpg") | Some("jpeg") => "image/jpeg", - Some("png") => "image/png", - // Some("webp") => "image/webp", - // Some("gif") => "image/gif", - // Some("mp4") => "video/mp4", - // Some("mov") => "video/quicktime", - // Some("webm") => "video/webm", - _ => "application/octet-stream", - }; - - Ok(upload_media_http_request(bytes, file_name, mime_type, creds, maybe_timeout).await?) -} diff --git a/crates/api_clients/openai_sora_client/src/requests/upload_sora2/upload_media_sora2_from_file.rs b/crates/api_clients/openai_sora_client/src/requests/upload_sora2/upload_media_sora2_from_file.rs deleted file mode 100644 index 597e1c4b8f..0000000000 --- a/crates/api_clients/openai_sora_client/src/requests/upload_sora2/upload_media_sora2_from_file.rs +++ /dev/null @@ -1,95 +0,0 @@ -use crate::creds::sora_credential_set::SoraCredentialSet; -use crate::error::sora_client_error::SoraClientError; -use crate::error::sora_error::SoraError; -use crate::requests::upload::upload_media_http_request::{upload_media_http_request, SoraMediaUploadResponse}; -use log::error; -use std::path::Path; -use std::time::Duration; -use tokio::fs::File; -use tokio::io::AsyncReadExt; - -/// Try to prevent buffer reallocations. -/// There's a better way to implement this. -const INITIAL_BUFFER_SIZE : usize = 1024*1024; - -pub async fn sora_media_upload_from_file>( - file_path: P, - creds: &SoraCredentialSet, - maybe_timeout: Option, -) -> Result { - let mut file = File::open(&file_path).await - .map_err(|err| { - error!("Failed to open file for upload: {}", err); - SoraClientError::FileForUploadReadError(err) - })?; - - let mut buffer = Vec::with_capacity(INITIAL_BUFFER_SIZE); - - file.read_to_end(&mut buffer).await - .map_err(|err| { - error!("Failed to read file for upload: {}", err); - SoraClientError::FileForUploadReadError(err) - })?; - - let filename = file_path.as_ref().file_name() - .ok_or_else(|| SoraClientError::FileForUploadHasInvalidPath)? - .to_string_lossy() - .to_string(); - - let maybe_ext = file_path.as_ref().extension().and_then(|e| e.to_str()); - - // TODO: Read file magic bytes first, then fall back to this. - let mime_type = match maybe_ext { - Some("jpg") | Some("jpeg") => "image/jpeg", - Some("png") => "image/png", - // Some("webp") => "image/webp", - // Some("gif") => "image/gif", - // Some("mp4") => "video/mp4", - // Some("mov") => "video/quicktime", - // Some("webm") => "video/webm", - _ => "application/octet-stream", - }; - - Ok(upload_media_http_request(buffer, filename, mime_type, creds, maybe_timeout).await?) -} - -#[cfg(test)] -mod tests { - use crate::creds::sora_credential_builder::SoraCredentialBuilder; - use crate::requests::upload::upload_media_from_file::sora_media_upload_from_file; - use errors::AnyhowResult; - use std::fs::read_to_string; - use test_utils::test_file_path::test_file_path; - - #[ignore] // You can manually run "ignore" tests in the IDE, but they won't run in CI. - #[tokio::test] - pub async fn manual_test() -> AnyhowResult<()> { - let cookie = read_to_string(test_file_path("test_data/temp/cookie.txt")?)?; - let cookie = cookie.trim().to_string(); - - let bearer = read_to_string(test_file_path("test_data/temp/bearer.txt")?)?; - let bearer = bearer.trim().to_string(); - - let image_path = test_file_path("test_data/image/juno.jpg")?; // media_01jqyqgqpwf40tkcapq5bmaz5d - - let creds = SoraCredentialBuilder::new() - .with_cookies(&cookie) - .with_jwt_bearer_token(&bearer) - .build()?; - - let response = sora_media_upload_from_file( - image_path, - &creds, - None, - ).await?; - - println!("media: {:?}", response); - - println!("media_id: {}", response.id); - println!("media_url: {}", response.url); - - assert!(response.id.starts_with("media_")); - - Ok(()) - } -} diff --git a/crates/api_clients/openai_sora_client/src/requests/upload_sora2/upload_media_sora2_http_request.rs b/crates/api_clients/openai_sora_client/src/requests/upload_sora2/upload_media_sora2_http_request.rs deleted file mode 100644 index e87c73ac69..0000000000 --- a/crates/api_clients/openai_sora_client/src/requests/upload_sora2/upload_media_sora2_http_request.rs +++ /dev/null @@ -1,88 +0,0 @@ -use crate::constants::user_agent::USER_AGENT; -use crate::creds::sora_credential_set::SoraCredentialSet; -use crate::error::sora_client_error::SoraClientError; -use crate::error::sora_error::SoraError; -use crate::error::sora_generic_api_error::SoraGenericApiError; -use crate::utils_internal::classify_general_http_error::classify_general_http_error; -use log::{error, info}; -use serde::Deserialize; -use std::io::empty; -use std::time::Duration; -use wreq::multipart::{Form, Part}; -use wreq::Client; -use crate::requests::list_sora2_drafts::list_sora2_drafts::Draft; - -const SORA_UPLOAD_MEDIA_URL: &str = "https://sora.chatgpt.com/backend/uploads"; - - - -pub (crate) struct SoraMediaUploadArgs<'a> { - pub credentials: &'a SoraCredentialSet, - pub file_bytes: Vec, // NB: Reqwest needs to own the bytes, so we can't pass as a reference. - pub filename: String, // NB: Reqwest needs to own the bytes, so we can't pass as a reference. - pub mime_type: &'a str, - pub maybe_timeout: Option, -} - -#[derive(Clone, Debug)] -pub struct SoraMediaUploadResult { - pub drafts: Vec, -} - -pub (crate) async fn upload_media_sora2_http_request( - args: SoraMediaUploadArgs<'_> -) -> Result { - - // Create multipart form - let part = Part::bytes(args.file_bytes) // NB: Reqwest needs to own the bytes. - .file_name(args.filename) // NB: Reqwest needs to own the bytes - .mime_str(args.mime_type) - .map_err(|e| SoraClientError::MultipartFormError(e))?; - - let form = Form::new().part("file", part); - - let cookie = args.credentials.cookies.to_string(); - let auth_header = args.credentials.jwt_bearer_token - .as_ref() - .ok_or(SoraClientError::NoBearerTokenForRequest)? - .to_authorization_header_value(); - - // Make API request - let client = Client::new(); - let mut request_builder = client.post(SORA_UPLOAD_MEDIA_URL) - .multipart(form) - .header("User-Agent", USER_AGENT) - .header("Cookie", &cookie) - .header("Authorization", &auth_header); - - if let Some(timeout) = args.maybe_timeout { - request_builder = request_builder.timeout(timeout); - } - - let response = request_builder.send() - .await - .map_err(|err| { - SoraGenericApiError::WreqError(err) - })?; - - // Check response status - if !response.status().is_success() { - info!("Error uploading image: {:?}", response.status()); - let error = classify_general_http_error(response).await; - return Err(error); - } - - let response_body = &response.text().await - .map_err(|err| { - error!("Error reading response body while attempting file upload: {:?}", err); - SoraGenericApiError::WreqError(err) - })?; - - let upload_response : SoraMediaUploadResponse = serde_json::from_str(&response_body) - .map_err(|err| { - error!("Error parsing response body while attempting file upload: {:?}", err); - SoraGenericApiError::SerdeResponseParseErrorWithBody(err, response_body.to_string()) - })?; - - Ok(upload_response) -} diff --git a/crates/api_clients/openai_sora_client/src/test_utils/get_test_credentials.rs b/crates/api_clients/openai_sora_client/src/test_utils/get_test_credentials.rs deleted file mode 100644 index bedc1b2e0f..0000000000 --- a/crates/api_clients/openai_sora_client/src/test_utils/get_test_credentials.rs +++ /dev/null @@ -1,33 +0,0 @@ -use crate::creds::sora_credential_builder::SoraCredentialBuilder; -use crate::creds::sora_credential_set::SoraCredentialSet; -use crate::creds::sora_sentinel_token::SoraSentinelToken; -use errors::AnyhowResult; -use std::fs::read_to_string; - -#[cfg(test)] -pub fn get_test_credentials() -> AnyhowResult { - // TODO: This should work on other folks' machines when they exist - // This is so brittle... - let sentinel_token = { - let sentinel_json = read_to_string("/Users/bt/Artcraft/credentials/sora_sentinel_token_store.json")?; - let sentinel_json = sentinel_json.trim().to_string(); - SoraSentinelToken::from_persistent_storage_json(&sentinel_json)? - }; - - let sentinel = read_to_string("/Users/bt/Artcraft/credentials/sora_sentinel.txt")?; - - let cookie = read_to_string("/Users/bt/Artcraft/credentials/sora_cookies.txt")?; - let cookie = cookie.trim().to_string(); - - let bearer = read_to_string("/Users/bt/Artcraft/credentials/sora_bearer_token.txt")?; - let bearer = bearer.trim().to_string(); - - let creds = SoraCredentialBuilder::new() - .with_cookies(&cookie) - .with_jwt_bearer_token(&bearer) - .with_sora_sentinel(&sentinel) - .with_sora_sentinel_token(&sentinel_token) - .build()?; - - Ok(creds) -} diff --git a/crates/api_clients/openai_sora_client/src/test_utils/mod.rs b/crates/api_clients/openai_sora_client/src/test_utils/mod.rs deleted file mode 100644 index 9346cd1864..0000000000 --- a/crates/api_clients/openai_sora_client/src/test_utils/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -#[cfg(test)] -pub (crate) mod get_test_credentials; \ No newline at end of file diff --git a/crates/api_clients/openai_sora_client/src/utils/has_session_cookie.rs b/crates/api_clients/openai_sora_client/src/utils/has_session_cookie.rs deleted file mode 100644 index 63a17cf9ce..0000000000 --- a/crates/api_clients/openai_sora_client/src/utils/has_session_cookie.rs +++ /dev/null @@ -1,104 +0,0 @@ -use cookie::Cookie; -use errors::AnyhowResult; -use once_cell::sync::Lazy; -use std::collections::HashSet; - -pub const SESSION_COOKIE_NAME_OLD : &str = "__Secure-authjs.session-token"; -pub const SESSION_COOKIE_NAME_NEW : &str = "__Secure-next-auth.session-token"; - -/// Cookies Sora.com mints that are not the session cookie. We can ignore these. -/// This list is very likely to change over time. -const IRRELEVANT_COOKIE_NAMES: Lazy> = Lazy::new(|| { - HashSet::from([ - "cf_clearance", - "oai-did", - "_cfuvid", - "__cflb", - "__cf_bm", - "__Host-authjs.csrf-token", - "__Secure-authjs.callback-url", - "__Secure-authjs.pkce.code_verifier", - "__Secure-authjs.state", - ]) -}); - -/// Super naive heuristic for "logged out" total cookie length being ~1972 characters. -const SESSION_COOKIE_LENGTH_HEURISTIC : usize = 2000; - -//pub fn has_session_cookie(cookies: &str) -> bool { -// // NB: This is not a valid check for cookies, just a cheap heuristic. -// cookies.contains(SESSION_COOKIE_NAME) -//} - -#[derive(Copy,Clone,Eq,PartialEq,Debug)] -pub enum SessionCookiePresence { - Present, - MaybePresent, - Absent, -} - -/// OpenAI might change the name of the session cookie, and we don't want to break clients, -/// so we use some heuristics to determine if the cookie might be present. -pub fn has_session_cookie(cookies_header: &str) -> AnyhowResult { - let cookies_header = cookies_header.trim(); - if (cookies_header.is_empty()) { - return Ok(SessionCookiePresence::Absent); - } - - let cookies = Cookie::split_parse(cookies_header); - let mut unknown_cookie_count = 0; // NB: In the event they change their session cookie - - for cookie in cookies { - let cookie= cookie?; - let cookie_name = cookie.name(); - if cookie_name == SESSION_COOKIE_NAME_NEW { - return Ok(SessionCookiePresence::Present); - } else if cookie_name == SESSION_COOKIE_NAME_OLD { - return Ok(SessionCookiePresence::Present); - } else if !IRRELEVANT_COOKIE_NAMES.contains(cookie_name) { - unknown_cookie_count += 1; - } - } - - // This is a really stupid heuristic, but we want to be safe. - if cookies_header.len() > SESSION_COOKIE_LENGTH_HEURISTIC { - return Ok(SessionCookiePresence::MaybePresent); - } - - // Another stupid heuristic. - if unknown_cookie_count > 3 { - return Ok(SessionCookiePresence::MaybePresent); - } - - Ok(SessionCookiePresence::Absent) -} - -#[cfg(test)] -mod tests { - use crate::utils::has_session_cookie::{has_session_cookie, SessionCookiePresence}; - - #[test] - fn test() { - assert_eq!(has_session_cookie("").unwrap(), SessionCookiePresence::Absent); - assert_eq!(has_session_cookie("foo=bar").unwrap(), SessionCookiePresence::Absent); - - // Heuristic: unknown cookies. - assert_eq!(has_session_cookie("foo=bar;bin=baz;bat=ban;bash=barn").unwrap(), SessionCookiePresence::MaybePresent); - - // Heuristic: cookie length - let cookies = format!("cookie={}", "a".repeat(10000)); - assert_eq!(has_session_cookie(&cookies).unwrap(), SessionCookiePresence::MaybePresent); - - // Synthetic fixture (the original real session token was redacted); the session - // cookie name is what matters for detection. - let cookies = "__Host-authjs.csrf-token=abc123; \ - __Secure-authjs.callback-url=https%3A%2F%2Fsora.com%2F; \ - __Secure-authjs.session-token=fake-session-token-value"; - - assert_eq!(has_session_cookie(cookies).unwrap(), SessionCookiePresence::Present); - - let cookies = "__Secure-next-auth.session-token=fake-session-token-value"; - - assert_eq!(has_session_cookie(cookies).unwrap(), SessionCookiePresence::Present); - } -} diff --git a/crates/api_clients/openai_sora_client/src/utils/mod.rs b/crates/api_clients/openai_sora_client/src/utils/mod.rs deleted file mode 100644 index d86421b410..0000000000 --- a/crates/api_clients/openai_sora_client/src/utils/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod has_session_cookie; \ No newline at end of file diff --git a/crates/api_clients/openai_sora_client/src/utils_internal/classify_general_http_error.rs b/crates/api_clients/openai_sora_client/src/utils_internal/classify_general_http_error.rs deleted file mode 100644 index 69d161c23b..0000000000 --- a/crates/api_clients/openai_sora_client/src/utils_internal/classify_general_http_error.rs +++ /dev/null @@ -1,15 +0,0 @@ -use crate::error::sora_error::SoraError; -use crate::error::sora_generic_api_error::SoraGenericApiError; -use crate::utils_internal::classify_general_http_status_code_and_body::classify_general_http_status_code_and_body; - -/// This assumes the request failed and returned a non-200. -/// The caller should check. -pub async fn classify_general_http_error(response: wreq::Response) -> SoraError { - let status = response.status(); - let message = match response.text().await { - Ok(text) => text, - Err(err) => return SoraGenericApiError::WreqError(err).into(), - }; - - classify_general_http_status_code_and_body(status, &message) -} diff --git a/crates/api_clients/openai_sora_client/src/utils_internal/classify_general_http_status_code_and_body.rs b/crates/api_clients/openai_sora_client/src/utils_internal/classify_general_http_status_code_and_body.rs deleted file mode 100644 index 5f29aacad3..0000000000 --- a/crates/api_clients/openai_sora_client/src/utils_internal/classify_general_http_status_code_and_body.rs +++ /dev/null @@ -1,71 +0,0 @@ -use crate::error::sora_error::SoraError; -use crate::error::sora_generic_api_error::SoraGenericApiError; -use crate::error::sora_specific_api_error::SoraSpecificApiError; -use cloudflare_errors::filter_cloudflare_errors::filter_cloudflare_errors; -use wreq::StatusCode; -/* - -Old cookie - - -Message: { - "error": { - "message": "Your authentication token has expired. Please try signing in again.", - "type": "invalid_request_error", - "param": null, - "code": "token_expired" - } -} - -No cookie - - -Message: { - "error": { - "message": "Your authentication token has expired. Please try signing in again.", - "type": "invalid_request_error", - "param": null, - "code": "token_expired" - } -} - -*/ - -/// Classify the type of error that occurred. -/// This first assumes the request failed and returned a non-200. -pub fn classify_general_http_status_code_and_body(status: StatusCode, response_body: &str) -> SoraError { - let message = response_body.to_string(); - - // TODO: I *think* this is just the bearer token, not the cookie. - let cookie_expired = - message.contains("Your authentication token has expired. Please try signing in again.") - || message.contains("token_expired"); - - if cookie_expired { - return SoraSpecificApiError::UnauthorizedCookieOrBearerExpired.into(); - } - - let needs_onboarding = - message.contains("You must onboard before using this service") - || message.contains("onboarding_required"); - - if needs_onboarding { - return SoraSpecificApiError::SoraUsernameNotYetCreated.into(); - } - - let status_code = status.as_u16(); - - if let Err(err) = filter_cloudflare_errors(status_code, &response_body) { - return SoraGenericApiError::CloudflareError(err).into(); - } - - match status_code { - 502 => { - return SoraGenericApiError::Http502ErrorBadGateway(message.to_string()).into(); - } - _ => {}, // Fall-through - } - - SoraGenericApiError::UncategorizedBadResponseWithStatusAndBody { - status_code: status, - body: response_body.to_string(), - }.into() -} diff --git a/crates/api_clients/openai_sora_client/src/utils_internal/lightweight_sora_jwt_parse.rs b/crates/api_clients/openai_sora_client/src/utils_internal/lightweight_sora_jwt_parse.rs deleted file mode 100644 index fa324fe6d9..0000000000 --- a/crates/api_clients/openai_sora_client/src/utils_internal/lightweight_sora_jwt_parse.rs +++ /dev/null @@ -1,157 +0,0 @@ -//! Adapted from 'jwt' crate - -use crate::error::sora_client_error::SoraClientError; -use crate::error::sora_error::SoraError; -use base64::prelude::BASE64_URL_SAFE_NO_PAD; -use base64::Engine; -use chrono::{DateTime, Utc}; -use errors::AnyhowResult; -use log::warn; -use serde_json::Value; - -const SEPARATOR: &str = "."; - -#[derive(Clone, Debug)] -pub struct SoraJwtClaims { - pub created: DateTime, - pub expiration: DateTime, - pub user_id: String, - pub email: String, - pub email_verified: bool, -} - -pub fn lightweight_sora_jwt_parse(token: &str) -> Result { - let [_header_str, claims_str, _signature_str] = split_components(token)?; - - let claims = decode_base64(claims_str) - .map_err(|err| as_jwt_error(format!("failure to parse claims base64: {:?}", err)))?; - - let claims : serde_json::Map = serde_json::from_str(&claims) - .map_err(|err| as_jwt_error( - format!("failure to parse claims json: {:?}", err)))?; - - let iat = claims.get("iat") - .map(|val| val.as_number()) - .flatten() - .ok_or_else(|| jwt_error("no iat claim"))?; - - let iat = iat.as_i64() - .ok_or_else(|| jwt_error("iat is not a number"))?; - - let iat = DateTime::from_timestamp(iat, 0) - .ok_or_else(|| jwt_error("iat is not a valid timestamp"))?; - - let exp = claims.get("exp") - .map(|val| val.as_number()) - .flatten() - .ok_or_else(|| jwt_error("no exp claim"))?; - - let exp = exp.as_i64() - .ok_or_else(|| jwt_error("exp is not a number"))?; - - let exp = DateTime::from_timestamp(exp, 0) - .ok_or_else(|| jwt_error("iat is not a valid timestamp"))?; - - let user_id = claims.get("https://api.openai.com/auth") - .map(|val| val.get("user_id")) - .flatten() - .map(|val| val.as_str()) - .flatten() - .ok_or_else(|| jwt_error("no user_id claim"))?; - - let profile = claims.get("https://api.openai.com/profile") - .ok_or_else(|| jwt_error("no user_id claim"))?; - - let email = profile.get("email") - .map(|val| val.as_str()) - .flatten() - .ok_or_else(|| jwt_error("no email claim"))?; - - let email_verified = profile.get("email_verified") - .map(|val| val.as_bool()) - .flatten() - .unwrap_or_else(|| { - warn!("no email_verified claim"); - false - }); - - Ok(SoraJwtClaims { - created: iat, - expiration: exp, - user_id: user_id.to_string(), - email: email.to_string(), - email_verified, - }) -} - -fn split_components(token: &str) -> Result<[&str; 3], SoraError> { - let mut components = token.split(SEPARATOR); - let header = components.next() - .ok_or_else(|| jwt_error("no header component"))?; - - let claims = components.next() - .ok_or_else(|| jwt_error("no claims component"))?; - - let signature = components.next() - .ok_or_else(|| jwt_error("no signature component"))?; - - if components.next().is_some() { - return Err(jwt_error("too many components")); - } - - Ok([header, claims, signature]) -} - -fn decode_base64(raw: &str) -> AnyhowResult { - let json_bytes = BASE64_URL_SAFE_NO_PAD.decode(raw)?; - let json_str = String::from_utf8(json_bytes.clone())?; - Ok(json_str) -} - -fn jwt_error(reason: &str) -> SoraError { - SoraError::Client(SoraClientError::LocalJwtClaimsParseError(reason.to_string())) -} - -fn as_jwt_error(reason: String) -> SoraError { - SoraError::Client(SoraClientError::LocalJwtClaimsParseError(reason)) -} - -#[cfg(test)] -mod tests { - use crate::utils_internal::lightweight_sora_jwt_parse::lightweight_sora_jwt_parse; - - #[test] - fn test_sora_jwt_bearer_token() { - let token = - "eyJhbGciOiJSUzI1NiIsImtpZCI6IjE5MzQ0ZTY1LWJiYzktNDRkMS1hOWQwLWY5NTdiMDc5YmQwZSIsInR5cCI6Ik\ - pXVCJ9.eyJhdWQiOlsiaHR0cHM6Ly9hcGkub3BlbmFpLmNvbS92MSJdLCJjbGllbnRfaWQiOiJhcHBfTTFuUTN0UjV2\ - VzdYOWpMMnBFNmdIOGRLNCIsImV4cCI6MTc0NTgwMDQ3MiwiaHR0cHM6Ly9hcGkub3BlbmFpLmNvbS9hdXRoIjp7InV\ - zZXJfaWQiOiJ1c2VyLTZOeEpmbEFIb0VCREp6Wmw5aVhocWJERyJ9LCJodHRwczovL2FwaS5vcGVuYWkuY29tL3Byb2\ - ZpbGUiOnsiZW1haWwiOiJ2b2NvZGVzMjAyMEBnbWFpbC5jb20iLCJlbWFpbF92ZXJpZmllZCI6dHJ1ZX0sImlhdCI6M\ - Tc0NDkzNjQ3MSwiaXNzIjoiaHR0cHM6Ly9hdXRoLm9wZW5haS5jb20iLCJqdGkiOiI0NTZmZjY5Yi0xZTZhLTQzOWYt\ - YTYzMC1jNmFjYzI3NzU1YjAiLCJuYmYiOjE3NDQ5MzY0NzEsInB3ZF9hdXRoX3RpbWUiOjE3NDQwNTkzMTc3NTAsInN\ - jcCI6WyJvcGVuaWQiLCJlbWFpbCIsInByb2ZpbGUiLCJvZmZsaW5lX2FjY2VzcyJdLCJzZXNzaW9uX2lkIjoiYXV0aH\ - Nlc3NfcEE4UGl3V0trNmJsSE1qQnVCQnVSRmh2Iiwic3ViIjoiZ29vZ2xlLW9hdXRoMnwxMTMxMDE5Njc2MTIzOTY3O\ - TM3NzcifQ.JOxYfrQSIsHdf-VN1zcOqDOS3tF1HpUYnRVfPKgi65am3sNiniOM1kWTNrKE5-sh4DaZ33G_XniGkhg-9\ - QKF8tspXpZ6BnTNkf-QdGqR_v89AIO8pZgQ7oECLXhnmg-31G-LAHlGfwWedJ6qPVy4dL5zoR0wVyoQ8gYv5QzQC-zd\ - IF7uY-umKKloAAYP_tkKLlQHackjTynN-bpu2mKv55-h7a3hSEPfxvgX0SsvL69xtNsZkwb43bqyP1x_c2ErfYoPyzg\ - rqgMIRZjCw9TI33vISKM_BfQXBiZT_BHkX4s0Jng3ph4vrwvnBsa0HpNxBhQYKb1u9gZXs7XjLZhjZJZsDTQI1V4Wov\ - iAL7ihvZkLxJRtDCOmX7-5BTEsMInFgXUAhCDhQUMwSfLLJuinBS96NGSX5_TfIVMkbCl-HWzdQx7KZAsahNe_CmuYT\ - lZH32NuRn78ohY4eViRyfC8OXVLwoLxxpen2CWlV2dxV5wwXeij_kHt5wOXSGYpSfxz37cK0CaK8K2pwudasxQ0lv2V\ - _Xx_z4UaEOr5wqT_BK1A1HO4HRjvFX2soF-qm4GCSWAbmFZs7DVEClrotxRx2romifRVb8XRia2M6YTmDyIT0YphFgG\ - nnrDIZNKO23uDYT60LVMVYpCCY2RiwxCR9bn7AeGbmi7cpL9aYZ5uJRM"; - - // jwt payload : - // - "https://api.openai.com/auth".user_id = "user-6NxJflAHoEBDJzZl9iXhqbDG" - // - "https://api.openai.com/profile".email = "vocodes2020@gmail.com" - // - "https://api.openai.com/profile".email_verified = true - // - "iat": 1744936471, - issued at claim (5 days ago) - // - "nbf": 1744936471, - not before, don't use before date - // - "exp": 1745800472, - in 5 days, expiry - - let result = lightweight_sora_jwt_parse(token).expect("claim should parse"); - - assert_eq!(result.email, "vocodes2020@gmail.com"); - assert_eq!(result.email_verified, true); - } -} diff --git a/crates/api_clients/openai_sora_client/src/utils_internal/mod.rs b/crates/api_clients/openai_sora_client/src/utils_internal/mod.rs deleted file mode 100644 index 73261e81d8..0000000000 --- a/crates/api_clients/openai_sora_client/src/utils_internal/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub mod classify_general_http_error; -pub mod classify_general_http_status_code_and_body; -pub mod lightweight_sora_jwt_parse; diff --git a/crates/api_clients/worldlabs_consumer_client/Cargo.toml b/crates/api_clients/worldlabs_consumer_client/Cargo.toml deleted file mode 100644 index 398dd0b1a7..0000000000 --- a/crates/api_clients/worldlabs_consumer_client/Cargo.toml +++ /dev/null @@ -1,55 +0,0 @@ -[package] -name = "worldlabs_consumer_client" -edition = "2024" -version = "0.0.1" -publish = false - -[package.metadata.cargo-udeps.ignore] -normal = ["workspace-build-acceleration"] - -[lib] -name = "worldlabs_consumer_client" -path = "src/lib.rs" - -[dependencies] -# Workspace hack (faster compile times) -workspace-build-acceleration.workspace = true - -# Internal -cloudflare_errors.workspace = true -cloudflare_mitigation.workspace = true -cookie_store.workspace = true -errors.workspace = true -filesys.workspace = true -http_headers.workspace = true -jwt_light.workspace = true - -# External -anyhow.workspace = true -base64.workspace = true -bstr.workspace = true -byteorder.workspace = true -chrono.workspace = true -futures.workspace = true -indexmap.workspace = true -log.workspace = true -once_cell.workspace = true -regex.workspace = true -scraper = "0.24.0" -serde.workspace = true -serde_json.workspace = true -sha2.workspace = true -tokio = { version = "1", features = ["full"] } -url.workspace = true -uuid.workspace = true -wreq-util.workspace = true -wreq.workspace = true - -[dev-dependencies] -filesys.workspace = true -test_data.workspace = true -test_utils.workspace = true -log4rs = "1.4.0" -env_logger.workspace = true -env.workspace = true -chrono.workspace = true diff --git a/crates/api_clients/worldlabs_consumer_client/src/api/api_types/image_input_object_id.rs b/crates/api_clients/worldlabs_consumer_client/src/api/api_types/image_input_object_id.rs deleted file mode 100644 index 207d6a5ead..0000000000 --- a/crates/api_clients/worldlabs_consumer_client/src/api/api_types/image_input_object_id.rs +++ /dev/null @@ -1,26 +0,0 @@ -use uuid::Uuid; - -/// Type for Image Input Object Ids -/// These are used to refer to worlds -/// These appear to be bare UUIDs. -#[derive(Clone, Debug)] -pub struct ImageInputObjectId(pub String); - -impl ImageInputObjectId { - pub fn generate_new() -> Self { - let uuid = Uuid::new_v4().to_string(); - Self(uuid) - } - - pub fn from_str(s: &str) -> Self { - Self(s.to_string()) - } - - pub fn as_str(&self) -> &str { - &self.0 - } - - pub fn to_string(&self) -> String { - self.0.clone() - } -} diff --git a/crates/api_clients/worldlabs_consumer_client/src/api/api_types/meta_world_object_id.rs b/crates/api_clients/worldlabs_consumer_client/src/api/api_types/meta_world_object_id.rs deleted file mode 100644 index 54cd53a198..0000000000 --- a/crates/api_clients/worldlabs_consumer_client/src/api/api_types/meta_world_object_id.rs +++ /dev/null @@ -1,26 +0,0 @@ -use uuid::Uuid; - -/// Type for "meta" World IDs (not sure what to term this). -/// These are in the first run patch request -/// These appear to be bare UUIDs. -#[derive(Clone, Debug)] -pub struct MetaWorldObjectId(pub String); - -impl MetaWorldObjectId { - pub fn generate_new() -> Self { - let uuid = Uuid::new_v4().to_string(); - Self(uuid) - } - - pub fn from_str(s: &str) -> Self { - Self(s.to_string()) - } - - pub fn as_str(&self) -> &str { - &self.0 - } - - pub fn to_string(&self) -> String { - self.0.clone() - } -} diff --git a/crates/api_clients/worldlabs_consumer_client/src/api/api_types/mod.rs b/crates/api_clients/worldlabs_consumer_client/src/api/api_types/mod.rs deleted file mode 100644 index ed4b37eb86..0000000000 --- a/crates/api_clients/worldlabs_consumer_client/src/api/api_types/mod.rs +++ /dev/null @@ -1,8 +0,0 @@ -pub mod image_input_object_id; -pub mod meta_world_object_id; -pub mod pano_object_id; -pub mod run_object; -pub mod run_object_id; -pub mod upload_mime_type; -pub mod upload_object_id; -pub mod world_id; \ No newline at end of file diff --git a/crates/api_clients/worldlabs_consumer_client/src/api/api_types/pano_object_id.rs b/crates/api_clients/worldlabs_consumer_client/src/api/api_types/pano_object_id.rs deleted file mode 100644 index 96c359f4c6..0000000000 --- a/crates/api_clients/worldlabs_consumer_client/src/api/api_types/pano_object_id.rs +++ /dev/null @@ -1,26 +0,0 @@ -use uuid::Uuid; - -/// Type for Pano Object Ids -/// These are used to refer to worlds -/// These appear to be bare UUIDs. -#[derive(Clone, Debug)] -pub struct PanoObjectId(pub String); - -impl PanoObjectId { - pub fn generate_new() -> Self { - let uuid = Uuid::new_v4().to_string(); - Self(uuid) - } - - pub fn from_str(s: &str) -> Self { - Self(s.to_string()) - } - - pub fn as_str(&self) -> &str { - &self.0 - } - - pub fn to_string(&self) -> String { - self.0.clone() - } -} diff --git a/crates/api_clients/worldlabs_consumer_client/src/api/api_types/run_object.rs b/crates/api_clients/worldlabs_consumer_client/src/api/api_types/run_object.rs deleted file mode 100644 index e923607c90..0000000000 --- a/crates/api_clients/worldlabs_consumer_client/src/api/api_types/run_object.rs +++ /dev/null @@ -1,79 +0,0 @@ -use std::collections::HashMap; -use chrono::Utc; -use serde::{Deserialize, Serialize}; -use serde_json::Value; - -const RUN_MIME_TYPE: &str = "application/run+json"; - -const RUN_VERSION : &str = "0.0.1"; - -/// World Labs' API is very frontend driven -/// They send whole objects back to the frontend that the frontend is in charge of mutatingbjects or PATCH them back to the server (yuck): -/// - request #1 - create run -/// - request #6 - patch run after image upload -/// Gotta go fast? -#[derive(Serialize, Deserialize, Clone)] -pub struct RunObject { - /// The primary ID of the run. - /// This won't exist until we post it to the server. - #[serde(skip_serializing_if = "Option::is_none")] - pub id: Option, - - pub metadata: RunObjectMetadata, - pub mime_type: String, -} - -#[derive(Serialize, Deserialize, Clone)] -pub struct RunObjectMetadata { - pub version: String, - - #[serde(rename = "createdAt")] - pub created_at: u64, - - #[serde(rename = "updatedAt")] - pub updated_at: u64, - - #[serde(rename = "usesAdvancedEditing")] - pub uses_advanced_editing: bool, - - #[serde(rename = "draftMode")] - pub draft_mode: bool, - - /// Polymorphic set of ID-to-object mappings. - pub nodes: HashMap, -} - -impl Default for RunObject { - fn default() -> Self { - let now = Utc::now(); - let now = now.timestamp().unsigned_abs() * 1000; // Millisecond resolution - Self { - id: None, - metadata: RunObjectMetadata{ - version: RUN_VERSION.to_string(), - created_at: now, - updated_at: now, - uses_advanced_editing: false, - draft_mode: false, - nodes: HashMap::new(), - }, - mime_type: RUN_MIME_TYPE.to_string(), - } - } -} - -#[cfg(test)] -mod tests { - use crate::api::api_types::run_object::RunObject; - - #[test] - fn default_runobject() { - let object = RunObject::default(); - assert!(object.id.is_none()); - assert_eq!(&object.metadata.version, "0.0.1"); - assert!(object.metadata.created_at > 1705433415549); - assert!(object.metadata.updated_at > 1705433415549); - assert_eq!(&object.mime_type, "application/run+json"); - } -} - diff --git a/crates/api_clients/worldlabs_consumer_client/src/api/api_types/run_object_id.rs b/crates/api_clients/worldlabs_consumer_client/src/api/api_types/run_object_id.rs deleted file mode 100644 index 73a50ae277..0000000000 --- a/crates/api_clients/worldlabs_consumer_client/src/api/api_types/run_object_id.rs +++ /dev/null @@ -1,15 +0,0 @@ -/// Type for Object IDs. -/// These are used to create inference runs and refer to the result -/// These appear to be bare UUIDs. -#[derive(Clone, Debug)] -pub struct RunObjectId(pub String); - -impl RunObjectId { - pub fn from_str(s: &str) -> Self { - Self(s.to_string()) - } - - pub fn to_string(&self) -> String { - self.0.clone() - } -} \ No newline at end of file diff --git a/crates/api_clients/worldlabs_consumer_client/src/api/api_types/upload_mime_type.rs b/crates/api_clients/worldlabs_consumer_client/src/api/api_types/upload_mime_type.rs deleted file mode 100644 index 72c60853d8..0000000000 --- a/crates/api_clients/worldlabs_consumer_client/src/api/api_types/upload_mime_type.rs +++ /dev/null @@ -1,21 +0,0 @@ -use serde::Serialize; - -#[derive(Clone, Copy, Debug, Serialize)] -pub enum UploadMimeType { - #[serde(rename = "image/jpeg")] - ImageJpeg, -} - -impl UploadMimeType { - pub fn content_type(&self) -> &'static str { - match self { - Self::ImageJpeg => "image/jpeg", - } - } - - pub fn extension_without_period(&self) -> &'static str { - match self { - Self::ImageJpeg => "jpeg", - } - } -} diff --git a/crates/api_clients/worldlabs_consumer_client/src/api/api_types/upload_object_id.rs b/crates/api_clients/worldlabs_consumer_client/src/api/api_types/upload_object_id.rs deleted file mode 100644 index 26eeb401fd..0000000000 --- a/crates/api_clients/worldlabs_consumer_client/src/api/api_types/upload_object_id.rs +++ /dev/null @@ -1,15 +0,0 @@ -/// Type for Upload IDs. -/// These are used to upload images. -/// These appear to be bare UUIDs. -#[derive(Clone, Debug)] -pub struct UploadObjectId(pub String); - -impl UploadObjectId { - pub fn as_str(&self) -> &str { - &self.0 - } - - pub fn to_string(&self) -> String { - self.0.clone() - } -} diff --git a/crates/api_clients/worldlabs_consumer_client/src/api/api_types/world_id.rs b/crates/api_clients/worldlabs_consumer_client/src/api/api_types/world_id.rs deleted file mode 100644 index 5d6b32b16e..0000000000 --- a/crates/api_clients/worldlabs_consumer_client/src/api/api_types/world_id.rs +++ /dev/null @@ -1,26 +0,0 @@ -use uuid::Uuid; - -/// Type for World IDs. -/// These are used to refer to worlds -/// These appear to be bare UUIDs. -#[derive(Clone, Debug)] -pub struct WorldObjectId(pub String); - -impl WorldObjectId { - pub fn new() -> Self { - let uuid = Uuid::new_v4().to_string(); - Self(uuid) - } - - pub fn from_str(s: &str) -> Self { - Self(s.to_string()) - } - - pub fn as_str(&self) -> &str { - &self.0 - } - - pub fn to_string(&self) -> String { - self.0.clone() - } -} diff --git a/crates/api_clients/worldlabs_consumer_client/src/api/common/common_header_values.rs b/crates/api_clients/worldlabs_consumer_client/src/api/common/common_header_values.rs deleted file mode 100644 index 2df742bef2..0000000000 --- a/crates/api_clients/worldlabs_consumer_client/src/api/common/common_header_values.rs +++ /dev/null @@ -1,6 +0,0 @@ - -/// Referer header value -pub(crate) const REFERER_VALUE: &str = "https://marble.worldlabs.ai/"; - -/// Origin header value -pub(crate) const ORIGIN_VALUE: &str = "https://marble.worldlabs.ai/"; diff --git a/crates/api_clients/worldlabs_consumer_client/src/api/common/mod.rs b/crates/api_clients/worldlabs_consumer_client/src/api/common/mod.rs deleted file mode 100644 index 6356e9460a..0000000000 --- a/crates/api_clients/worldlabs_consumer_client/src/api/common/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub (crate) mod common_header_values; \ No newline at end of file diff --git a/crates/api_clients/worldlabs_consumer_client/src/api/mod.rs b/crates/api_clients/worldlabs_consumer_client/src/api/mod.rs deleted file mode 100644 index 9729e3e72d..0000000000 --- a/crates/api_clients/worldlabs_consumer_client/src/api/mod.rs +++ /dev/null @@ -1,5 +0,0 @@ -pub mod api_types; -pub mod requests; - -pub (crate) mod common; -pub mod utils; diff --git a/crates/api_clients/worldlabs_consumer_client/src/api/requests/google_refresh_token/google_refresh_token.rs b/crates/api_clients/worldlabs_consumer_client/src/api/requests/google_refresh_token/google_refresh_token.rs deleted file mode 100644 index 7db5e6b9b1..0000000000 --- a/crates/api_clients/worldlabs_consumer_client/src/api/requests/google_refresh_token/google_refresh_token.rs +++ /dev/null @@ -1,154 +0,0 @@ -use crate::api::api_types::upload_mime_type::UploadMimeType; -use crate::api::common::common_header_values::{ORIGIN_VALUE, REFERER_VALUE}; -use crate::credentials::world_labs_bearer_token::WorldLabsBearerToken; -use crate::credentials::world_labs_cookies::WorldLabsCookies; -use crate::credentials::worldlabs_refresh_token::WorldLabsRefreshToken; -use crate::error::world_labs_client_error::WorldLabsClientError; -use crate::error::world_labs_error::WorldLabsError; -use crate::error::world_labs_generic_api_error::WorldLabsGenericApiError; -use crate::error::world_labs_specific_api_error::WorldLabsSpecificApiError; -use http_headers::names::{PRIORITY, SEC_FETCH_DEST, SEC_FETCH_MODE, SEC_FETCH_SITE, SEC_GPC}; -use http_headers::values::accept::ACCEPT_ALL; -use http_headers::values::accept_encoding::ACCEPT_ENCODING_GZIP_ETC; -use http_headers::values::accept_language::ACCEPT_LANGUAGE_EN_US; -use http_headers::values::cache_control::CACHE_CONTROL_NO_CACHE; -use http_headers::values::connection::CONNECTION_KEEP_ALIVE; -use http_headers::values::pragma::PRAGMA_NO_CACHE; -use http_headers::values::priority::{PRIORITY_4, PRIORITY_6}; -use http_headers::values::sec::{SEC_FETCH_DEST_EMPTY, SEC_FETCH_MODE_CORS, SEC_FETCH_SITE_CROSS_SITE}; -use http_headers::values::te::TE_TRAILERS; -use log::{debug, error}; -use serde::{Deserialize, Serialize}; -use std::collections::HashMap; -use std::time::Duration; -use wreq::header::{ACCEPT, ACCEPT_ENCODING, ACCEPT_LANGUAGE, AUTHORIZATION, CACHE_CONTROL, CONNECTION, CONTENT_LENGTH, CONTENT_TYPE, ORIGIN, PRAGMA, REFERER, TE}; -use wreq::multipart::Form; -use wreq::Client; -use wreq_util::Emulation; - -/// NB: key is the public API key for WorldLabs -/// https://docs.cloud.google.com/identity-platform/docs/use-rest-api -const URL : &str = "https://securetoken.googleapis.com/v1/token?key=AIzaSyAA88yObUN-0pnXAxcgOrT2exZxFWLW1BI"; -pub struct GoogleRefreshTokenArgs<'a> { - pub refresh_token: &'a WorldLabsRefreshToken, - pub request_timeout: Option, -} - -pub struct GoogleRefreshTokenResponse { - pub bearer_token: WorldLabsBearerToken, - pub refresh_token: WorldLabsRefreshToken, -} - -/// Refresh Access Token for WorldLabs using Google. -pub async fn google_refresh_token(args: GoogleRefreshTokenArgs<'_>) -> Result { - let client = Client::builder() - .emulation(Emulation::Firefox143) - .build() - .map_err(|err| WorldLabsClientError::WreqClientError(err))?; - - - debug!("Requesting URL: {}", URL); - - let mut request_builder = client.post(URL) - .header(ACCEPT, ACCEPT_ALL) - .header(ACCEPT_LANGUAGE, ACCEPT_LANGUAGE_EN_US) - .header(ACCEPT_ENCODING, ACCEPT_ENCODING_GZIP_ETC) - .header(REFERER, REFERER_VALUE) - .header(CONNECTION, CONNECTION_KEEP_ALIVE) - .header(SEC_FETCH_DEST, SEC_FETCH_DEST_EMPTY) - .header(SEC_FETCH_MODE, SEC_FETCH_MODE_CORS) - .header(SEC_FETCH_SITE, SEC_FETCH_SITE_CROSS_SITE) - .header(PRIORITY, PRIORITY_4) - .header(TE, TE_TRAILERS); - - let mut form = HashMap::new(); - form.insert("grant_type", "refresh_token".to_string()); - form.insert("refresh_token", args.refresh_token.to_raw_string()); - - if let Some(timeout) = args.request_timeout { - request_builder = request_builder.timeout(timeout); - } - - let http_request = request_builder - .form(&form) - .build() - .map_err(|err| { - error!("Error building request: {:?}", err); - WorldLabsClientError::WreqClientError(err) - })?; - - let response = client.execute(http_request) - .await - .map_err(|err| { - error!("Error during request execution: {:?}", err); - WorldLabsGenericApiError::WreqError(err) - })?; - - let status = response.status(); - - let response_body = response.text() - .await - .map_err(|err| { - error!("Error reading response body: {:?}", err); - WorldLabsGenericApiError::WreqError(err) - })?; - - if !status.is_success() { - error!("Request returned an error (code {}) : {:?}", status.as_u16(), response_body); - - if response_body.contains("SignatureDoesNotMatch") || response_body.contains("does not match the signature") { - return Err(WorldLabsSpecificApiError::GoogleUploadSignatureDoesNotMatch.into()); - } else { - return Err(WorldLabsGenericApiError::GoogleUploadFailed { status_code: status, body: response_body }.into()); - } - } - - debug!("Response body (200): {}", response_body); - - let response : RawResponse = serde_json::from_str(&response_body) - .map_err(|err| WorldLabsGenericApiError::SerdeResponseParseErrorWithBody(err, response_body.to_string()))?; - - let bearer_token = WorldLabsBearerToken::new(response.access_token); - let refresh_token = WorldLabsRefreshToken::new(response.refresh_token); - - Ok(GoogleRefreshTokenResponse { - bearer_token, - refresh_token, - }) -} - -#[derive(Deserialize)] -struct RawResponse { - pub access_token: String, - pub refresh_token: String, - - // eg. "3600" - pub expires_in: Option, - pub id_token: Option, - pub user_id: Option, -} - -#[cfg(test)] -mod tests { - use crate::api::requests::google_refresh_token::google_refresh_token::{google_refresh_token, GoogleRefreshTokenArgs}; - use crate::credentials::worldlabs_refresh_token::WorldLabsRefreshToken; - use crate::test_utils::setup_test_logging::setup_test_logging; - use errors::AnyhowResult; - use log::LevelFilter; - - #[tokio::test] - #[ignore] // Client side tests only - async fn test_requests() -> AnyhowResult<()> { - setup_test_logging(LevelFilter::Debug); - - let refresh_token = "AMf-vByUgA0J9S93vULECe-sD50cbR85AFVYF60gKAmLFF1MBYwXlKRJCsv7z3oSpLtP0ApyOU5fAl52qHWM2U0yKgEu5gQ5UCUDt5SEG4UBRHWvHEmLLcu-Zl04Fq4ljocSEO3qJzuX1wyshmptZxlDPRkjdLYgyn-Kp03woI2yRPKLuQF5hQtABHabsNUh9Zhs129sgxuUlOuw4zsFI4L8UdE3bEuF3k6Mic7KlE3440YwyQ8Qtmk9zHtXIx2ob56N-1WTGSqwMUuQ1mX4OOvLve9bw2zDW3UzchomTWkh732886RPrP-DNRkPbO3FejUEMxuYQFWYX3EEeIEdfNGXFNGPL1dNniSXlSaKadpX699Ishjviv-x9o-pPQa3zoAj3NzWLyd8mn5rDBh9qAO_iDETaeo01Sjhb4mGYfAWZ-g4S6nW778"; - let refresh_token = WorldLabsRefreshToken::new(refresh_token.to_string()); - - let result = google_refresh_token(GoogleRefreshTokenArgs { - refresh_token: &refresh_token, - request_timeout: None, - }).await?; - - Ok(()) - } -} diff --git a/crates/api_clients/worldlabs_consumer_client/src/api/requests/google_refresh_token/mod.rs b/crates/api_clients/worldlabs_consumer_client/src/api/requests/google_refresh_token/mod.rs deleted file mode 100644 index cfade37fe6..0000000000 --- a/crates/api_clients/worldlabs_consumer_client/src/api/requests/google_refresh_token/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod google_refresh_token; \ No newline at end of file diff --git a/crates/api_clients/worldlabs_consumer_client/src/api/requests/google_upload/google_upload_image.rs b/crates/api_clients/worldlabs_consumer_client/src/api/requests/google_upload/google_upload_image.rs deleted file mode 100644 index 7d2e0dc9b4..0000000000 --- a/crates/api_clients/worldlabs_consumer_client/src/api/requests/google_upload/google_upload_image.rs +++ /dev/null @@ -1,91 +0,0 @@ -use crate::api::api_types::upload_mime_type::UploadMimeType; -use crate::api::common::common_header_values::{ORIGIN_VALUE, REFERER_VALUE}; -use crate::credentials::world_labs_bearer_token::WorldLabsBearerToken; -use crate::credentials::world_labs_cookies::WorldLabsCookies; -use crate::error::world_labs_client_error::WorldLabsClientError; -use crate::error::world_labs_error::WorldLabsError; -use crate::error::world_labs_generic_api_error::WorldLabsGenericApiError; -use crate::error::world_labs_specific_api_error::WorldLabsSpecificApiError; -use http_headers::names::{PRIORITY, SEC_FETCH_DEST, SEC_FETCH_MODE, SEC_FETCH_SITE, SEC_GPC}; -use http_headers::values::accept::ACCEPT_ALL; -use http_headers::values::cache_control::CACHE_CONTROL_NO_CACHE; -use http_headers::values::connection::CONNECTION_KEEP_ALIVE; -use http_headers::values::pragma::PRAGMA_NO_CACHE; -use http_headers::values::priority::PRIORITY_6; -use http_headers::values::sec::{SEC_FETCH_DEST_EMPTY, SEC_FETCH_MODE_CORS, SEC_FETCH_SITE_CROSS_SITE}; -use http_headers::values::te::TE_TRAILERS; -use log::{debug, error}; -use serde::Serialize; -use std::time::Duration; -use wreq::header::{ACCEPT, ACCEPT_ENCODING, ACCEPT_LANGUAGE, AUTHORIZATION, CACHE_CONTROL, CONNECTION, CONTENT_LENGTH, CONTENT_TYPE, ORIGIN, PRAGMA, REFERER, TE}; -use wreq::Client; -use wreq_util::Emulation; - -pub struct GoogleUploadImageArgs<'a> { - pub upload_url: &'a str, - pub upload_mime_type: UploadMimeType, - pub file_bytes: Vec, - pub request_timeout: Option, -} - -/// Marble Image-to-World -/// Upload the binary to GCP using the signed URL -/// Request #4 (of ~10) -pub async fn google_upload_image(args: GoogleUploadImageArgs<'_>) -> Result<(), WorldLabsError> { - let client = Client::builder() - .emulation(Emulation::Firefox143) - .build() - .map_err(|err| WorldLabsClientError::WreqClientError(err))?; - - let content_type = args.upload_mime_type.content_type(); - - debug!("Requesting URL: {}", args.upload_url); - - let mut request_builder = client.put(args.upload_url) - .header(CONTENT_TYPE, content_type) - .header("x-goog-content-length-range", "0,1048576000"); - - if let Some(timeout) = args.request_timeout { - request_builder = request_builder.timeout(timeout); - } - - let http_request = request_builder - .body(args.file_bytes) - .build() - .map_err(|err| { - error!("Error building request: {:?}", err); - WorldLabsClientError::WreqClientError(err) - })?; - - let response = client.execute(http_request) - .await - .map_err(|err| { - error!("Error during request execution: {:?}", err); - WorldLabsGenericApiError::WreqError(err) - })?; - - let status = response.status(); - - let response_body = response.text() - .await - .map_err(|err| { - error!("Error reading response body: {:?}", err); - WorldLabsGenericApiError::WreqError(err) - })?; - - if !status.is_success() { - error!("Request returned an error (code {}) : {:?}", status.as_u16(), response_body); - - if response_body.contains("SignatureDoesNotMatch") || response_body.contains("does not match the signature") { - return Err(WorldLabsSpecificApiError::GoogleUploadSignatureDoesNotMatch.into()); - } else { - return Err(WorldLabsGenericApiError::GoogleUploadFailed { status_code: status, body: response_body }.into()); - } - } - - Ok(()) -} - -#[cfg(test)] -mod tests { -} diff --git a/crates/api_clients/worldlabs_consumer_client/src/api/requests/google_upload/mod.rs b/crates/api_clients/worldlabs_consumer_client/src/api/requests/google_upload/mod.rs deleted file mode 100644 index 66f712bf42..0000000000 --- a/crates/api_clients/worldlabs_consumer_client/src/api/requests/google_upload/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod google_upload_image; \ No newline at end of file diff --git a/crates/api_clients/worldlabs_consumer_client/src/api/requests/mod.rs b/crates/api_clients/worldlabs_consumer_client/src/api/requests/mod.rs deleted file mode 100644 index 618aa293b1..0000000000 --- a/crates/api_clients/worldlabs_consumer_client/src/api/requests/mod.rs +++ /dev/null @@ -1,5 +0,0 @@ -pub mod google_upload; -pub mod objects; -pub mod recaption; -pub mod worlds; -pub mod google_refresh_token; \ No newline at end of file diff --git a/crates/api_clients/worldlabs_consumer_client/src/api/requests/objects/begin_object_image_upload.rs b/crates/api_clients/worldlabs_consumer_client/src/api/requests/objects/begin_object_image_upload.rs deleted file mode 100644 index 26d55d551d..0000000000 --- a/crates/api_clients/worldlabs_consumer_client/src/api/requests/objects/begin_object_image_upload.rs +++ /dev/null @@ -1,147 +0,0 @@ -use crate::api::api_types::run_object_id::RunObjectId; -use crate::api::api_types::upload_mime_type::UploadMimeType; -use crate::api::api_types::upload_object_id::UploadObjectId; -use crate::api::common::common_header_values::{ORIGIN_VALUE, REFERER_VALUE}; -use crate::credentials::world_labs_bearer_token::WorldLabsBearerToken; -use crate::credentials::world_labs_cookies::WorldLabsCookies; -use crate::error::world_labs_client_error::WorldLabsClientError; -use crate::error::world_labs_error::WorldLabsError; -use crate::error::world_labs_generic_api_error::WorldLabsGenericApiError; -use chrono::Utc; -use http_headers::names::{PRIORITY, SEC_FETCH_DEST, SEC_FETCH_MODE, SEC_FETCH_SITE, SEC_GPC}; -use http_headers::values::accept::ACCEPT_ALL; -use http_headers::values::cache_control::CACHE_CONTROL_NO_CACHE; -use http_headers::values::connection::CONNECTION_KEEP_ALIVE; -use http_headers::values::content_type::CONTENT_TYPE_APPLICATION_JSON; -use http_headers::values::pragma::PRAGMA_NO_CACHE; -use http_headers::values::priority::PRIORITY_4; -use http_headers::values::sec::{SEC_FETCH_DEST_EMPTY, SEC_FETCH_MODE_CORS, SEC_FETCH_SITE_CROSS_SITE}; -use http_headers::values::te::TE_TRAILERS; -use log::{debug, error, info}; -use serde::{Deserialize, Serialize}; -use std::time::Duration; -use uuid::Uuid; -use wreq::header::{ACCEPT, ACCEPT_ENCODING, ACCEPT_LANGUAGE, AUTHORIZATION, CACHE_CONTROL, CONNECTION, CONTENT_LENGTH, CONTENT_TYPE, ORIGIN, PRAGMA, REFERER, TE}; -use wreq::Client; -use wreq_util::Emulation; - -const BASE_URL : &str = "https://api.worldlabs.ai/api/v1/objects"; - -// Note: WorldLabs is phasing out the old URL scheme: -// const BASE_URL : &str = "https://marble2-kgw-prod-iac1.wlt-ai.art/api/v1/objects"; - -fn get_url(upload_id: &UploadObjectId) -> String { - format!("{}/{}:upload", BASE_URL, upload_id.0) -} - -pub struct BeginObjectImageUploadArgs<'a> { - pub cookies: &'a WorldLabsCookies, - pub bearer_token: &'a WorldLabsBearerToken, - pub upload_mime_type: UploadMimeType, - pub upload_id: &'a UploadObjectId, - pub request_timeout: Option, -} - -pub struct BeginObjectImageUploadResponse { - pub upload_url: String, -} - -/// Marble Image-to-World -/// This request follows object attachment and signals upload. It returns the upload URL. -/// Request #3 (of ~10) -pub async fn begin_object_image_upload(args: BeginObjectImageUploadArgs<'_>) -> Result { - let client = Client::builder() - .emulation(Emulation::Firefox143) - .build() - .map_err(|err| WorldLabsClientError::WreqClientError(err))?; - - let url = get_url(args.upload_id); - - debug!("Requesting URL: {}", url); - - let mut request_builder = client.post(url) - .header(ACCEPT, ACCEPT_ALL) - .header(ACCEPT_LANGUAGE, "en-US,en;q=0.5") - .header(ACCEPT_ENCODING, "gzip, deflate, br, zstd") - .header(REFERER, REFERER_VALUE) - .header(CONTENT_TYPE, CONTENT_TYPE_APPLICATION_JSON) - .header(AUTHORIZATION, args.bearer_token.to_bearer_token_header_string()) - .header(ORIGIN, ORIGIN_VALUE) - .header(SEC_GPC, "1") - .header(CONNECTION, CONNECTION_KEEP_ALIVE) - .header(SEC_FETCH_DEST, SEC_FETCH_DEST_EMPTY) - .header(SEC_FETCH_MODE, SEC_FETCH_MODE_CORS) - .header(SEC_FETCH_SITE, SEC_FETCH_SITE_CROSS_SITE) - .header(PRIORITY, PRIORITY_4) - .header(PRAGMA, PRAGMA_NO_CACHE) - .header(CACHE_CONTROL, CACHE_CONTROL_NO_CACHE) - .header(CONTENT_LENGTH, 0) - .header(TE, TE_TRAILERS); - - if let Some(timeout) = args.request_timeout { - request_builder = request_builder.timeout(timeout); - } - - let http_request = request_builder - .build() - .map_err(|err| { - error!("Error building request: {:?}", err); - WorldLabsClientError::WreqClientError(err) - })?; - - let response = client.execute(http_request) - .await - .map_err(|err| { - error!("Error during request execution: {:?}", err); - WorldLabsGenericApiError::WreqError(err) - })?; - - let status = response.status(); - - let response_body = response.text() - .await - .map_err(|err| { - error!("Error reading response body: {:?}", err); - WorldLabsGenericApiError::WreqError(err) - })?; - - // TODO: Handle errors (Cloudflare, Grok, etc.) - if !status.is_success() { - error!("Request returned an error (code {}) : {:?}", status.as_u16(), response_body); - //return Err(classify_general_http_status_code_and_body(status, response_body)); - return Err(WorldLabsGenericApiError::UncategorizedBadResponseWithStatusAndBody { status_code: status, body: response_body}.into()) - } - - debug!("Response body (200) (ready for Google upload): {}", response_body); - - let response : RawResponse = serde_json::from_str(&response_body) - .map_err(|err| WorldLabsGenericApiError::SerdeResponseParseErrorWithBody(err, response_body.to_string()))?; - - info!("Curl command: {}", response.curl_example); - - Ok(BeginObjectImageUploadResponse { - upload_url: response.upload_url, - }) -} - -#[derive(Deserialize)] -struct RawResponse { - /// eg. "https://storage.googleapis.com/wlt-training-gsc-marble-assets-prod/temp/objects/{...}", - pub upload_url: String, - - /// Just for debugging, the server reports a test cURL command - pub curl_example: String, -} - -#[cfg(test)] -mod tests { - use crate::api::api_types::upload_object_id::UploadObjectId; - use crate::api::requests::objects::begin_object_image_upload::{get_url, BASE_URL}; - - #[test] - fn test_get_url() { - let upload_id = UploadObjectId("foo-bar-baz-bin".to_string()); - let expected = format!("{}/foo-bar-baz-bin:upload", BASE_URL); - assert_eq!(get_url(&upload_id), expected); - } -} diff --git a/crates/api_clients/worldlabs_consumer_client/src/api/requests/objects/create_run_object.rs b/crates/api_clients/worldlabs_consumer_client/src/api/requests/objects/create_run_object.rs deleted file mode 100644 index 341cc32129..0000000000 --- a/crates/api_clients/worldlabs_consumer_client/src/api/requests/objects/create_run_object.rs +++ /dev/null @@ -1,124 +0,0 @@ -use crate::api::api_types::run_object::RunObject; -use crate::api::api_types::run_object_id::RunObjectId; -use crate::api::common::common_header_values::{ORIGIN_VALUE, REFERER_VALUE}; -use crate::credentials::world_labs_bearer_token::WorldLabsBearerToken; -use crate::credentials::world_labs_cookies::WorldLabsCookies; -use crate::error::world_labs_client_error::WorldLabsClientError; -use crate::error::world_labs_error::WorldLabsError; -use crate::error::world_labs_generic_api_error::WorldLabsGenericApiError; -use crate::error::world_labs_specific_api_error::WorldLabsSpecificApiError; -use chrono::Utc; -use http_headers::names::{PRIORITY, SEC_FETCH_DEST, SEC_FETCH_MODE, SEC_FETCH_SITE, SEC_GPC}; -use http_headers::values::accept::ACCEPT_ALL; -use http_headers::values::cache_control::CACHE_CONTROL_NO_CACHE; -use http_headers::values::connection::CONNECTION_KEEP_ALIVE; -use http_headers::values::content_type::CONTENT_TYPE_APPLICATION_JSON; -use http_headers::values::pragma::PRAGMA_NO_CACHE; -use http_headers::values::priority::PRIORITY_HIGHEST; -use http_headers::values::sec::{SEC_FETCH_DEST_EMPTY, SEC_FETCH_MODE_CORS, SEC_FETCH_SITE_CROSS_SITE}; -use http_headers::values::te::TE_TRAILERS; -use log::{debug, error}; -use serde::{Deserialize, Serialize}; -use std::time::Duration; -use wreq::header::{ACCEPT, ACCEPT_ENCODING, ACCEPT_LANGUAGE, AUTHORIZATION, CACHE_CONTROL, CONNECTION, CONTENT_TYPE, ORIGIN, PRAGMA, REFERER, TE}; -use wreq::Client; -use wreq_util::Emulation; - -const URL : &str = "https://api.worldlabs.ai/api/v1/objects"; - -// Note: WorldLabs is phasing out the old URL scheme: -// const URL : &str = "https://marble2-kgw-prod-iac1.wlt-ai.art/api/v1/objects"; - -pub struct CreateRunObjectArgs<'a> { - pub cookies: &'a WorldLabsCookies, - pub bearer_token: &'a WorldLabsBearerToken, - pub request_timeout: Option, -} - -pub struct CreateRunObjectResponse { - pub id: RunObjectId, - pub run_object: RunObject, -} - -/// Marble Image-to-World -/// This request starts the process: it initializes a new world object inference and returns the object id. -/// Request #1 (of ~10) -pub async fn create_run_object(args: CreateRunObjectArgs<'_>) -> Result { - let client = Client::builder() - .emulation(Emulation::Firefox143) - .build() - .map_err(|err| WorldLabsClientError::WreqClientError(err))?; - - debug!("Requesting URL: {}", URL); - - let mut request_builder = client.post(URL) - .header(ACCEPT, ACCEPT_ALL) - .header(ACCEPT_LANGUAGE, "en-US,en;q=0.5") - .header(ACCEPT_ENCODING, "gzip, deflate, br, zstd") - .header(REFERER, REFERER_VALUE) - .header(CONTENT_TYPE, CONTENT_TYPE_APPLICATION_JSON) - .header(AUTHORIZATION, args.bearer_token.to_bearer_token_header_string()) - .header(ORIGIN, ORIGIN_VALUE) - .header(SEC_GPC, "1") - .header(CONNECTION, CONNECTION_KEEP_ALIVE) - .header(SEC_FETCH_DEST, SEC_FETCH_DEST_EMPTY) - .header(SEC_FETCH_MODE, SEC_FETCH_MODE_CORS) - .header(SEC_FETCH_SITE, SEC_FETCH_SITE_CROSS_SITE) - .header(PRIORITY, PRIORITY_HIGHEST) - .header(PRAGMA, PRAGMA_NO_CACHE) - .header(CACHE_CONTROL, CACHE_CONTROL_NO_CACHE) - .header(TE, TE_TRAILERS); - - if let Some(timeout) = args.request_timeout { - request_builder = request_builder.timeout(timeout); - } - - let new_run_object = RunObject::default(); - - let http_request = request_builder.json(&new_run_object) - .build() - .map_err(|err| { - error!("Error building request: {:?}", err); - WorldLabsClientError::WreqClientError(err) - })?; - - let response = client.execute(http_request) - .await - .map_err(|err| { - error!("Error during request execution: {:?}", err); - WorldLabsGenericApiError::WreqError(err) - })?; - - let status = response.status(); - - let response_body = response.text() - .await - .map_err(|err| { - error!("Error reading response body: {:?}", err); - WorldLabsGenericApiError::WreqError(err) - })?; - - // TODO: Handle errors (Cloudflare, Grok, etc.) - if !status.is_success() { - error!("Request returned an error (code {}) : {:?}", status.as_u16(), response_body); - //return Err(classify_general_http_status_code_and_body(status, response_body)); - return Err(WorldLabsGenericApiError::UncategorizedBadResponseWithStatusAndBody { status_code: status, body: response_body}.into()) - } - - debug!("Response body (200): {}", response_body); - - let response : RunObject = serde_json::from_str(&response_body) - .map_err(|err| WorldLabsGenericApiError::SerdeResponseParseErrorWithBody(err, response_body.to_string()))?; - - let run_id = match &response.id { - Some(id) => RunObjectId(id.to_string()), - None => { - return Err(WorldLabsSpecificApiError::NoRunIdInResponse { response_body }.into()) - } - }; - - Ok(CreateRunObjectResponse { - id: run_id, - run_object: response, - }) -} diff --git a/crates/api_clients/worldlabs_consumer_client/src/api/requests/objects/create_upload_object.rs b/crates/api_clients/worldlabs_consumer_client/src/api/requests/objects/create_upload_object.rs deleted file mode 100644 index ce329a84ef..0000000000 --- a/crates/api_clients/worldlabs_consumer_client/src/api/requests/objects/create_upload_object.rs +++ /dev/null @@ -1,155 +0,0 @@ -use crate::api::api_types::run_object_id::RunObjectId; -use crate::api::api_types::upload_mime_type::UploadMimeType; -use crate::api::api_types::upload_object_id::UploadObjectId; -use crate::api::common::common_header_values::{ORIGIN_VALUE, REFERER_VALUE}; -use crate::credentials::world_labs_bearer_token::WorldLabsBearerToken; -use crate::credentials::world_labs_cookies::WorldLabsCookies; -use crate::error::world_labs_client_error::WorldLabsClientError; -use crate::error::world_labs_error::WorldLabsError; -use crate::error::world_labs_generic_api_error::WorldLabsGenericApiError; -use chrono::Utc; -use http_headers::names::{PRIORITY, SEC_FETCH_DEST, SEC_FETCH_MODE, SEC_FETCH_SITE, SEC_GPC}; -use http_headers::values::accept::ACCEPT_ALL; -use http_headers::values::cache_control::CACHE_CONTROL_NO_CACHE; -use http_headers::values::connection::CONNECTION_KEEP_ALIVE; -use http_headers::values::content_type::CONTENT_TYPE_APPLICATION_JSON; -use http_headers::values::pragma::PRAGMA_NO_CACHE; -use http_headers::values::priority::PRIORITY_4; -use http_headers::values::sec::{SEC_FETCH_DEST_EMPTY, SEC_FETCH_MODE_CORS, SEC_FETCH_SITE_CROSS_SITE}; -use http_headers::values::te::TE_TRAILERS; -use log::{debug, error, info}; -use serde::{Deserialize, Serialize}; -use std::time::Duration; -use uuid::Uuid; -use wreq::header::{ACCEPT, ACCEPT_ENCODING, ACCEPT_LANGUAGE, AUTHORIZATION, CACHE_CONTROL, CONNECTION, CONTENT_TYPE, ORIGIN, PRAGMA, REFERER, TE}; -use wreq::Client; -use wreq_util::Emulation; - -const URL : &str = "https://api.worldlabs.ai/api/v1/objects"; - -// Note: WorldLabs is phasing out the old URL scheme: -// const URL : &str = "https://marble2-kgw-prod-iac1.wlt-ai.art/api/v1/objects"; - -pub struct CreateUploadObjectArgs<'a> { - pub cookies: &'a WorldLabsCookies, - pub bearer_token: &'a WorldLabsBearerToken, - pub upload_mime_type: UploadMimeType, - pub request_timeout: Option, -} - -pub struct CreateUploadObjectResponse { - pub id: UploadObjectId, -} - -/// Marble Image-to-World -/// This request follows object initialization and prepares for image upload. -/// Request #2 (of ~10) -pub async fn create_upload_object(args: CreateUploadObjectArgs<'_>) -> Result { - let client = Client::builder() - .emulation(Emulation::Firefox143) - .build() - .map_err(|err| WorldLabsClientError::WreqClientError(err))?; - - debug!("Requesting URL: {}", URL); - - let mut request_builder = client.post(URL) - .header(ACCEPT, ACCEPT_ALL) - .header(ACCEPT_LANGUAGE, "en-US,en;q=0.5") - .header(ACCEPT_ENCODING, "gzip, deflate, br, zstd") - .header(REFERER, REFERER_VALUE) - .header(CONTENT_TYPE, CONTENT_TYPE_APPLICATION_JSON) - .header(AUTHORIZATION, args.bearer_token.to_bearer_token_header_string()) - .header(ORIGIN, ORIGIN_VALUE) - .header(SEC_GPC, "1") - .header(CONNECTION, CONNECTION_KEEP_ALIVE) - .header(SEC_FETCH_DEST, SEC_FETCH_DEST_EMPTY) - .header(SEC_FETCH_MODE, SEC_FETCH_MODE_CORS) - .header(SEC_FETCH_SITE, SEC_FETCH_SITE_CROSS_SITE) - .header(PRIORITY, PRIORITY_4) - .header(PRAGMA, PRAGMA_NO_CACHE) - .header(CACHE_CONTROL, CACHE_CONTROL_NO_CACHE) - .header(TE, TE_TRAILERS); - - if let Some(timeout) = args.request_timeout { - request_builder = request_builder.timeout(timeout); - } - - let request_payload = RawRequest::for_mime_type(args.upload_mime_type); - - let http_request = request_builder.json(&request_payload) - .build() - .map_err(|err| { - error!("Error building request: {:?}", err); - WorldLabsClientError::WreqClientError(err) - })?; - - let response = client.execute(http_request) - .await - .map_err(|err| { - error!("Error during request execution: {:?}", err); - WorldLabsGenericApiError::WreqError(err) - })?; - - let status = response.status(); - - let response_body = response.text() - .await - .map_err(|err| { - error!("Error reading response body: {:?}", err); - WorldLabsGenericApiError::WreqError(err) - })?; - - // TODO: Handle errors (Cloudflare, Grok, etc.) - if !status.is_success() { - error!("Request returned an error (code {}) : {:?}", status.as_u16(), response_body); - //return Err(classify_general_http_status_code_and_body(status, response_body)); - return Err(WorldLabsGenericApiError::UncategorizedBadResponseWithStatusAndBody { status_code: status, body: response_body}.into()) - } - - debug!("Response body (200): {}", response_body); - - let response : RawResponse = serde_json::from_str(&response_body) - .map_err(|err| WorldLabsGenericApiError::SerdeResponseParseErrorWithBody(err, response_body.to_string()))?; - - Ok(CreateUploadObjectResponse { - id: UploadObjectId(response.id), - }) -} - -#[derive(Serialize)] -struct RawRequest { - pub display_name: String, - pub mime_type: String, -} - -impl RawRequest { - pub fn for_mime_type(mime_type: UploadMimeType) -> Self { - let uuid = Uuid::new_v4().to_string(); - let extension = mime_type.extension_without_period(); - let display_name = format!("uploaded_image_{uuid}.{extension}"); - Self { - display_name, - mime_type: mime_type.content_type().to_string(), - } - } -} - -#[derive(Deserialize)] -struct RawResponse { - pub id: String, -} - -#[cfg(test)] -mod tests { - use crate::api::api_types::upload_mime_type::UploadMimeType; - use crate::api::requests::objects::create_upload_object::RawRequest; - - #[test] - fn test_request() { - let request = RawRequest::for_mime_type(UploadMimeType::ImageJpeg); - // The display name embeds a random uuid, eg. "uploaded_image_{uuid}.jpeg" - assert!(request.display_name.starts_with("uploaded_image_")); - assert!(request.display_name.ends_with(".jpeg")); - assert_eq!(request.mime_type, "image/jpeg"); - } -} diff --git a/crates/api_clients/worldlabs_consumer_client/src/api/requests/objects/finalize_object_image_upload.rs b/crates/api_clients/worldlabs_consumer_client/src/api/requests/objects/finalize_object_image_upload.rs deleted file mode 100644 index de10d2d511..0000000000 --- a/crates/api_clients/worldlabs_consumer_client/src/api/requests/objects/finalize_object_image_upload.rs +++ /dev/null @@ -1,172 +0,0 @@ -use crate::api::api_types::run_object_id::RunObjectId; -use crate::api::api_types::upload_mime_type::UploadMimeType; -use crate::api::api_types::upload_object_id::UploadObjectId; -use crate::api::common::common_header_values::{ORIGIN_VALUE, REFERER_VALUE}; -use crate::credentials::world_labs_bearer_token::WorldLabsBearerToken; -use crate::credentials::world_labs_cookies::WorldLabsCookies; -use crate::error::world_labs_client_error::WorldLabsClientError; -use crate::error::world_labs_error::WorldLabsError; -use crate::error::world_labs_generic_api_error::WorldLabsGenericApiError; -use chrono::Utc; -use http_headers::names::{PRIORITY, SEC_FETCH_DEST, SEC_FETCH_MODE, SEC_FETCH_SITE, SEC_GPC}; -use http_headers::values::accept::ACCEPT_ALL; -use http_headers::values::cache_control::CACHE_CONTROL_NO_CACHE; -use http_headers::values::connection::CONNECTION_KEEP_ALIVE; -use http_headers::values::content_type::CONTENT_TYPE_APPLICATION_JSON; -use http_headers::values::pragma::PRAGMA_NO_CACHE; -use http_headers::values::priority::PRIORITY_4; -use http_headers::values::sec::{SEC_FETCH_DEST_EMPTY, SEC_FETCH_MODE_CORS, SEC_FETCH_SITE_CROSS_SITE}; -use http_headers::values::te::TE_TRAILERS; -use log::{debug, error}; -use serde::{Deserialize, Serialize}; -use std::time::Duration; -use uuid::Uuid; -use wreq::header::{ACCEPT, ACCEPT_ENCODING, ACCEPT_LANGUAGE, AUTHORIZATION, CACHE_CONTROL, CONNECTION, CONTENT_LENGTH, CONTENT_TYPE, ORIGIN, PRAGMA, REFERER, TE}; -use wreq::Client; -use wreq_util::Emulation; - -const BASE_URL : &str = "https://api.worldlabs.ai/api/v1/objects"; - -// Note: WorldLabs is phasing out the old URL scheme: -// const BASE_URL : &str = "https://marble2-kgw-prod-iac1.wlt-ai.art/api/v1/objects"; - -fn get_url(upload_id: &UploadObjectId) -> String { - format!("{}/{}:complete", BASE_URL, upload_id.0) -} - -pub struct FinalizeObjectImageUploadArgs<'a> { - pub cookies: &'a WorldLabsCookies, - pub bearer_token: &'a WorldLabsBearerToken, - pub upload_id: &'a UploadObjectId, - pub request_timeout: Option, -} - -pub struct FinalizeObjectImageUploadResponse { - pub object_url: String, - pub updated_at: u64, -} - -/// Marble Image-to-World -/// Mark the upload as complete. -/// Request #5 (of ~10) -pub async fn finalize_object_image_upload(args: FinalizeObjectImageUploadArgs<'_>) -> Result { - let client = Client::builder() - .emulation(Emulation::Firefox143) - .build() - .map_err(|err| WorldLabsClientError::WreqClientError(err))?; - - let url = get_url(args.upload_id); - - debug!("Requesting URL: {}", url); - - let mut request_builder = client.post(url) - .header(ACCEPT, ACCEPT_ALL) - .header(ACCEPT_LANGUAGE, "en-US,en;q=0.5") - .header(ACCEPT_ENCODING, "gzip, deflate, br, zstd") - .header(REFERER, REFERER_VALUE) - .header(AUTHORIZATION, args.bearer_token.to_bearer_token_header_string()) - .header(ORIGIN, ORIGIN_VALUE) - .header(SEC_GPC, "1") - .header(CONNECTION, CONNECTION_KEEP_ALIVE) - .header(SEC_FETCH_DEST, SEC_FETCH_DEST_EMPTY) - .header(SEC_FETCH_MODE, SEC_FETCH_MODE_CORS) - .header(SEC_FETCH_SITE, SEC_FETCH_SITE_CROSS_SITE) - .header(PRIORITY, PRIORITY_4) - .header(PRAGMA, PRAGMA_NO_CACHE) - .header(CACHE_CONTROL, CACHE_CONTROL_NO_CACHE) - .header(CONTENT_LENGTH, 0) - .header(TE, TE_TRAILERS); - - if let Some(timeout) = args.request_timeout { - request_builder = request_builder.timeout(timeout); - } - - let http_request = request_builder - .build() - .map_err(|err| { - error!("Error building request: {:?}", err); - WorldLabsClientError::WreqClientError(err) - })?; - - let response = client.execute(http_request) - .await - .map_err(|err| { - error!("Error during request execution: {:?}", err); - WorldLabsGenericApiError::WreqError(err) - })?; - - let status = response.status(); - - let response_body = response.text() - .await - .map_err(|err| { - error!("Error reading response body: {:?}", err); - WorldLabsGenericApiError::WreqError(err) - })?; - - // TODO: Handle errors (Cloudflare, Grok, etc.) - if !status.is_success() { - error!("Request returned an error (code {}) : {:?}", status.as_u16(), response_body); - //return Err(classify_general_http_status_code_and_body(status, response_body)); - return Err(WorldLabsGenericApiError::UncategorizedBadResponseWithStatusAndBody { status_code: status, body: response_body}.into()) - } - - debug!("Response body (200): {}", response_body); - - let response : RawResponse = serde_json::from_str(&response_body) - .map_err(|err| WorldLabsGenericApiError::SerdeResponseParseErrorWithBody(err, response_body.to_string()))?; - - Ok(FinalizeObjectImageUploadResponse { - object_url: response.object_uri, - updated_at: response.updated_at, - }) -} - -#[derive(Deserialize)] -struct RawResponse { - /// eg. "https://cdn.marble.worldlabs.ai/object/foo-bar-baz-bin/asset.jpg" - pub object_uri: String, - - /// Seconds-resolution timestamp. - /// eg. `1765745771` - pub updated_at: u64, -} - -#[cfg(test)] -mod tests { - use crate::api::api_types::upload_object_id::UploadObjectId; - use crate::api::requests::objects::finalize_object_image_upload::{finalize_object_image_upload, get_url, FinalizeObjectImageUploadArgs, BASE_URL}; - use crate::test_utils::get_test_bearer_token::get_test_bearer_token; - use crate::test_utils::get_test_cookies::get_typed_test_cookies; - use crate::test_utils::setup_test_logging::setup_test_logging; - use log::LevelFilter; - - #[test] - fn test_get_url() { - let upload_id = UploadObjectId("foo-bar-baz-bin".to_string()); - let expected = format!("{}/foo-bar-baz-bin:complete", BASE_URL); - assert_eq!(get_url(&upload_id), expected); - } - - #[tokio::test] - #[ignore] // Client side tests only - async fn test_requests() { - setup_test_logging(LevelFilter::Debug); - - let cookies = get_typed_test_cookies().unwrap(); - let bearer_token = get_test_bearer_token().unwrap(); - - let upload_id = UploadObjectId("09d86ef8-edcd-42d9-9b95-8efd28be0bee".to_string()); - - let response = finalize_object_image_upload(FinalizeObjectImageUploadArgs { - cookies: &cookies, - bearer_token: &bearer_token, - upload_id: &upload_id, - request_timeout: None, - }).await.unwrap(); - - println!("Object URL: {}", response.object_url); - - assert_eq!(1, 2); - } -} diff --git a/crates/api_clients/worldlabs_consumer_client/src/api/requests/objects/mod.rs b/crates/api_clients/worldlabs_consumer_client/src/api/requests/objects/mod.rs deleted file mode 100644 index 3c27307f0d..0000000000 --- a/crates/api_clients/worldlabs_consumer_client/src/api/requests/objects/mod.rs +++ /dev/null @@ -1,6 +0,0 @@ -pub mod create_upload_object; -pub mod begin_object_image_upload; -pub mod create_run_object; -pub mod finalize_object_image_upload; -pub mod update_run_object_with_upload; -pub mod update_run_object_with_world; \ No newline at end of file diff --git a/crates/api_clients/worldlabs_consumer_client/src/api/requests/objects/update_run_object_with_upload.rs b/crates/api_clients/worldlabs_consumer_client/src/api/requests/objects/update_run_object_with_upload.rs deleted file mode 100644 index 4414b7c4ed..0000000000 --- a/crates/api_clients/worldlabs_consumer_client/src/api/requests/objects/update_run_object_with_upload.rs +++ /dev/null @@ -1,523 +0,0 @@ -use crate::api::api_types::image_input_object_id::ImageInputObjectId; -use crate::api::api_types::meta_world_object_id::MetaWorldObjectId; -use crate::api::api_types::pano_object_id::PanoObjectId; -use crate::api::api_types::run_object_id::RunObjectId; -use crate::api::api_types::upload_mime_type::UploadMimeType; -use crate::api::api_types::upload_object_id::UploadObjectId; -use crate::api::common::common_header_values::{ORIGIN_VALUE, REFERER_VALUE}; -use crate::api::utils::upload_id_to_image_url::upload_id_to_image_url; -use crate::credentials::world_labs_bearer_token::WorldLabsBearerToken; -use crate::credentials::world_labs_cookies::WorldLabsCookies; -use crate::error::world_labs_client_error::WorldLabsClientError; -use crate::error::world_labs_error::WorldLabsError; -use crate::error::world_labs_generic_api_error::WorldLabsGenericApiError; -use chrono::Utc; -use http_headers::names::{PRIORITY, SEC_FETCH_DEST, SEC_FETCH_MODE, SEC_FETCH_SITE, SEC_GPC}; -use http_headers::values::accept::ACCEPT_ALL; -use http_headers::values::cache_control::CACHE_CONTROL_NO_CACHE; -use http_headers::values::connection::CONNECTION_KEEP_ALIVE; -use http_headers::values::content_type::CONTENT_TYPE_APPLICATION_JSON; -use http_headers::values::pragma::PRAGMA_NO_CACHE; -use http_headers::values::priority::PRIORITY_4; -use http_headers::values::sec::{SEC_FETCH_DEST_EMPTY, SEC_FETCH_MODE_CORS, SEC_FETCH_SITE_CROSS_SITE}; -use http_headers::values::te::TE_TRAILERS; -use indexmap::IndexMap; -use log::{debug, error}; -use serde::{Deserialize, Serialize}; -use serde_json::Value; -use std::collections::HashMap; -use std::time::Duration; -use wreq::header::{ACCEPT, ACCEPT_ENCODING, ACCEPT_LANGUAGE, AUTHORIZATION, CACHE_CONTROL, CONNECTION, CONTENT_TYPE, ORIGIN, PRAGMA, REFERER, TE}; -use wreq::Client; -use wreq_util::Emulation; - -const BASE_URL : &str = "https://api.worldlabs.ai/api/v1/objects"; - -// Note: WorldLabs is phasing out the old URL scheme: -// const BASE_URL : &str = "https://marble2-kgw-prod-iac1.wlt-ai.art/api/v1/objects"; - -fn get_url(run_id: &RunObjectId) -> String { - format!("{}/{}", BASE_URL, run_id.0) -} - -pub struct UpdateRunObjectWithUploadArgs<'a> { - pub cookies: &'a WorldLabsCookies, - pub bearer_token: &'a WorldLabsBearerToken, - - pub payload_args: UpdateRunObjectWithUploadPayloadArgs<'a>, - - pub request_timeout: Option, -} - -pub struct UpdateRunObjectWithUploadPayloadArgs<'a> { - pub run_id: &'a RunObjectId, - pub run_created_at_timestamp: u64, - - // eg. https://cdn.marble.worldlabs.ai/object/13ca760c-8ef9-4bf5-acc3-5a507fad3abf/asset.jpg - pub image_upload_url: &'a str, - - pub image_input_id: &'a ImageInputObjectId, - pub pano_id: &'a PanoObjectId, - pub meta_world_id: &'a MetaWorldObjectId, -} - -pub struct UpdateRunObjectWithUploadResponse { - pub image_input_id: ImageInputObjectId, - pub pano_id: PanoObjectId, - pub meta_world_id: MetaWorldObjectId, - pub run_updated_timestamp: u64, -} - -/// Marble Image-to-World -/// This request patches an object. Seems to update it with the attached files. -/// Request #6 (of ~10) -pub async fn update_run_object_with_upload(args: UpdateRunObjectWithUploadArgs<'_>) -> Result { - let client = Client::builder() - .emulation(Emulation::Firefox143) - .build() - .map_err(|err| WorldLabsClientError::WreqClientError(err))?; - - let url = get_url(args.payload_args.run_id); - - debug!("Requesting URL: {}", url); - - let mut request_builder = client.patch(url) - .header(ACCEPT, ACCEPT_ALL) - .header(ACCEPT_LANGUAGE, "en-US,en;q=0.5") - .header(ACCEPT_ENCODING, "gzip, deflate, br, zstd") - .header(REFERER, REFERER_VALUE) - .header(CONTENT_TYPE, CONTENT_TYPE_APPLICATION_JSON) - .header(AUTHORIZATION, args.bearer_token.to_bearer_token_header_string()) - .header(ORIGIN, ORIGIN_VALUE) - .header(SEC_GPC, "1") - .header(CONNECTION, CONNECTION_KEEP_ALIVE) - .header(SEC_FETCH_DEST, SEC_FETCH_DEST_EMPTY) - .header(SEC_FETCH_MODE, SEC_FETCH_MODE_CORS) - .header(SEC_FETCH_SITE, SEC_FETCH_SITE_CROSS_SITE) - .header(PRIORITY, PRIORITY_4) - .header(PRAGMA, PRAGMA_NO_CACHE) - .header(CACHE_CONTROL, CACHE_CONTROL_NO_CACHE) - .header(TE, TE_TRAILERS); - - if let Some(timeout) = args.request_timeout { - request_builder = request_builder.timeout(timeout); - } - - let payload = RawRequest::from_args(&args.payload_args); - let updated_at = payload.object.metadata.updated_at; - - let http_request = request_builder.json(&payload) - .build() - .map_err(|err| { - error!("Error building request: {:?}", err); - WorldLabsClientError::WreqClientError(err) - })?; - - let response = client.execute(http_request) - .await - .map_err(|err| { - error!("Error during request execution: {:?}", err); - WorldLabsGenericApiError::WreqError(err) - })?; - - let status = response.status(); - - let response_body = response.text() - .await - .map_err(|err| { - error!("Error reading response body: {:?}", err); - WorldLabsGenericApiError::WreqError(err) - })?; - - // TODO: Handle errors (Cloudflare, Grok, etc.) - if !status.is_success() { - error!("Request returned an error (code {}) : {:?}", status.as_u16(), response_body); - //return Err(classify_general_http_status_code_and_body(status, response_body)); - return Err(WorldLabsGenericApiError::UncategorizedBadResponseWithStatusAndBody { status_code: status, body: response_body}.into()) - } - - debug!("Response body (200): {}", response_body); - - let _response : RawResponse = serde_json::from_str(&response_body) - .map_err(|err| WorldLabsGenericApiError::SerdeResponseParseErrorWithBody(err, response_body.to_string()))?; - - Ok(UpdateRunObjectWithUploadResponse { - image_input_id: args.payload_args.image_input_id.clone(), - pano_id: args.payload_args.pano_id.clone(), - meta_world_id: args.payload_args.meta_world_id.clone(), - run_updated_timestamp: updated_at, - }) -} - -#[derive(Serialize)] -struct RawRequest { - pub object: ObjectDef, - pub update_mask: Vec, -} - -impl Default for RawRequest { - fn default() -> Self { - let now = Utc::now(); - let now = now.timestamp_millis().unsigned_abs(); - Self { - object: ObjectDef { - metadata: ObjectMetadata { - version: "0.0.1".to_string(), - created_at: now, - updated_at: now, - uses_advanced_editing: false, - draft_mode: false, - nodes: IndexMap::new(), - } - }, - update_mask: vec!["metadata".to_string()] - } - } -} - -impl RawRequest { - pub fn from_args(args: &UpdateRunObjectWithUploadPayloadArgs) -> Self { - let mut request = RawRequest::default(); - request.add_image_input_node({ - let mut node = ImageInputNode::default(); - node.id = args.image_input_id.to_string(); - node.source.image_url = args.image_upload_url.to_string(); - node - }); - request.add_pano_node({ - let mut node = PanoNode::default(); - node.id = args.pano_id.to_string(); - node.parent_id= Some(args.image_input_id.to_string()); - node - }); - request.add_world_node({ - let mut node = WorldNode::default(); - node.id = args.meta_world_id.to_string(); - node.parent_id= Some(args.pano_id.to_string()); - node - }); - request.set_updated_now(); - request - } - - pub fn add_image_input_node(&mut self, mut node: ImageInputNode) { - node.created_at = self.object.metadata.updated_at; - self.object.metadata.nodes.insert(node.id.clone(), NodeValue::ImageInput(node)); - } - - pub fn add_pano_node(&mut self, mut node: PanoNode) { - node.created_at = self.object.metadata.updated_at; - self.object.metadata.nodes.insert(node.id.clone(), NodeValue::Pano(node)); - } - - pub fn add_world_node(&mut self, mut node: WorldNode) { - node.created_at = self.object.metadata.updated_at; - self.object.metadata.nodes.insert(node.id.clone(), NodeValue::World(node)); - } - - pub fn set_updated_now(&mut self) { - let now = Utc::now(); - let now = now.timestamp_millis().unsigned_abs(); - self.set_updated_at(now); - } - - pub fn set_updated_at(&mut self, updated_at: u64) { - self.object.metadata.updated_at = updated_at; - for (_key, node) in self.object.metadata.nodes.iter_mut() { - match node { - NodeValue::ImageInput(value) => value.created_at = updated_at, - NodeValue::Pano(value) => value.created_at = updated_at, - NodeValue::World(value) => value.created_at = updated_at, - } - } - } -} - -#[derive(Serialize)] -struct ObjectDef { - pub metadata: ObjectMetadata, -} - -#[derive(Serialize)] -struct ObjectMetadata { - pub version: String, - - #[serde(rename = "createdAt")] - pub created_at: u64, - - #[serde(rename = "updatedAt")] - pub updated_at: u64, - - #[serde(rename = "usesAdvancedEditing")] - pub uses_advanced_editing: bool, - - #[serde(rename = "draftMode")] - pub draft_mode: bool, - - /// Polymorphic set of ID-to-object mappings. - /// NB: IndexMap maintains insertion order. - pub nodes: IndexMap, -} - -#[derive(Serialize)] -#[serde(untagged)] -//#[serde(tag = "type", content = "value")] -enum NodeValue { - ImageInput(ImageInputNode), - Pano(PanoNode), - World(WorldNode), -} - -#[derive(Serialize, Default)] -struct ImageInputNode { - pub id: String, - pub r#type: TypeInput, - #[serde(rename = "parentId")] - pub parent_id: Option, - pub source: ImageInputNodeSource, - #[serde(rename = "createdAt")] - pub created_at: u64, -} - -#[derive(Serialize, Default)] -struct ImageInputNodeSource { - pub r#type: TypeImage, - pub image_url: String, -} - -#[derive(Serialize, Default)] -enum TypeInput { - #[serde(rename = "input")] - #[default] - Input -} - -#[derive(Serialize, Default)] -enum TypeImage { - #[serde(rename = "image")] - #[default] - Image -} - -#[derive(Serialize, Default)] -enum StatusPending { - #[serde(rename = "pending")] - #[default] - Pending -} - -impl ImageInputNode { - pub fn with_id(id: &str) -> Self{ - Self { - id: id.to_string(), - ..Default::default() - } - } -} - -#[derive(Serialize, Default)] -struct PanoNode { - pub id: String, - pub r#type: TypePano, - #[serde(rename = "parentId")] - pub parent_id: Option, - pub source: PanoNodeSource, - #[serde(rename = "createdAt")] - pub created_at: u64, -} - -#[derive(Serialize, Default)] -struct PanoNodeSource { - pub r#type: TypeGenerateWorld, - pub world_id: StatusPending, - pub status: StatusPending, -} - -#[derive(Serialize, Default)] -enum TypePano { - #[serde(rename = "pano")] - #[default] - Pano -} - -#[derive(Serialize, Default)] -enum TypeGenerateWorld { - #[serde(rename = "generate_world")] - #[default] - GenerateWorld -} - -impl PanoNode { - pub fn with_id(id: &str) -> Self{ - Self { - id: id.to_string(), - ..Default::default() - } - } -} - -#[derive(Serialize, Default)] -struct WorldNode { - pub id: String, - pub r#type: TypeWorld, - #[serde(rename = "parentId")] - pub parent_id: Option, - pub source: WorldNodeSource, - #[serde(rename = "createdAt")] - pub created_at: u64, -} - -#[derive(Serialize, Default)] -struct WorldNodeSource { - pub r#type: TypeGenerateWorld, - pub world_id: StatusPending, - pub posed_cubemaps_url: String, - pub minimap_url: String, - pub minimap_metadata: String, - pub status: StatusPending, -} - -#[derive(Serialize, Default)] -enum TypeWorld { - #[serde(rename = "world")] - #[default] - World -} - -impl WorldNode { - pub fn with_id(id: &str) -> Self{ - Self { - id: id.to_string(), - ..Default::default() - } - } -} - -#[derive(Deserialize)] -struct RawResponse { - pub id: String, -} - -#[cfg(test)] -mod tests { - use crate::api::api_types::image_input_object_id::ImageInputObjectId; - use crate::api::api_types::meta_world_object_id::MetaWorldObjectId; - use crate::api::api_types::pano_object_id::PanoObjectId; - use crate::api::api_types::run_object_id::RunObjectId; - use crate::api::requests::objects::update_run_object_with_upload::{RawRequest, UpdateRunObjectWithUploadPayloadArgs}; - use serde_json::{json, Value}; - - /// Any timestamp from `Utc::now()` should exceed this (2023-11-14 in epoch millis). - const MIN_PLAUSIBLE_EPOCH_MILLIS: u64 = 1_700_000_000_000; - - #[test] - fn request_default() { - let request = RawRequest::default(); - assert_eq!(request.object.metadata.version, "0.0.1"); - assert!(request.object.metadata.created_at > 10000); - assert!(request.object.metadata.updated_at > 10000); - } - - #[test] - fn json() { - let run_id = RunObjectId::from_str("79795b32-e44d-4333-bac1-05b2c9a3ea12"); - let image_input_id = ImageInputObjectId::from_str("bc17252b-811e-49d7-be3e-b7c538df9d30"); - let pano_id = PanoObjectId::from_str("82f6b488-8afe-4311-9022-80ad5789ad92"); - let world_id = MetaWorldObjectId::from_str("f08ec501-601c-47c6-a104-402d1820b8f0"); - - let args = UpdateRunObjectWithUploadPayloadArgs { - run_created_at_timestamp: 1234, - image_upload_url: "https://todo.com", - run_id: &run_id, - image_input_id: &image_input_id, - pano_id: &pano_id, - meta_world_id: &world_id, - }; - - let request = RawRequest::from_args(&args); - - // The `createdAt` / `updatedAt` timestamps come from `Utc::now()` at build time, - // so they're nondeterministic. Sanity-check them, then zero them out before - // comparing the rest of the document. - assert!(request.object.metadata.created_at > MIN_PLAUSIBLE_EPOCH_MILLIS); - assert!(request.object.metadata.updated_at >= request.object.metadata.created_at); - - let mut actual = serde_json::to_value(&request).unwrap(); - zero_out_timestamps(&mut actual); - - let expected = json!({ - "object": { - "metadata": { - "version": "0.0.1", - "createdAt": 0, - "updatedAt": 0, - "usesAdvancedEditing": false, - "draftMode": false, - "nodes": { - "bc17252b-811e-49d7-be3e-b7c538df9d30": { - "id": "bc17252b-811e-49d7-be3e-b7c538df9d30", - "type": "input", - "parentId": null, - "source": { - "type": "image", - "image_url": "https://todo.com" - }, - "createdAt": 0 - }, - "82f6b488-8afe-4311-9022-80ad5789ad92": { - "id": "82f6b488-8afe-4311-9022-80ad5789ad92", - "type": "pano", - "parentId": "bc17252b-811e-49d7-be3e-b7c538df9d30", - "source": { - "type": "generate_world", - "world_id": "pending", - "status": "pending" - }, - "createdAt": 0 - }, - "f08ec501-601c-47c6-a104-402d1820b8f0": { - "id": "f08ec501-601c-47c6-a104-402d1820b8f0", - "type": "world", - "parentId": "82f6b488-8afe-4311-9022-80ad5789ad92", - "source": { - "type": "generate_world", - "world_id": "pending", - "posed_cubemaps_url": "", - "minimap_url": "", - "minimap_metadata": "", - "status": "pending" - }, - "createdAt": 0 - } - } - } - }, - "update_mask": [ - "metadata" - ] - }); - - assert_eq!(actual, expected); - } - - /// Recursively replaces nondeterministic `createdAt` / `updatedAt` values with 0. - fn zero_out_timestamps(value: &mut Value) { - match value { - Value::Object(map) => { - for (key, child) in map.iter_mut() { - if key == "createdAt" || key == "updatedAt" { - *child = json!(0); - } else { - zero_out_timestamps(child); - } - } - }, - Value::Array(items) => { - for item in items.iter_mut() { - zero_out_timestamps(item); - } - }, - _ => {}, - } - } -} diff --git a/crates/api_clients/worldlabs_consumer_client/src/api/requests/objects/update_run_object_with_world.rs b/crates/api_clients/worldlabs_consumer_client/src/api/requests/objects/update_run_object_with_world.rs deleted file mode 100644 index f04f49ff4f..0000000000 --- a/crates/api_clients/worldlabs_consumer_client/src/api/requests/objects/update_run_object_with_world.rs +++ /dev/null @@ -1,540 +0,0 @@ -use crate::api::api_types::image_input_object_id::ImageInputObjectId; -use crate::api::api_types::pano_object_id::PanoObjectId; -use crate::api::api_types::run_object_id::RunObjectId; -use crate::api::api_types::upload_mime_type::UploadMimeType; -use crate::api::api_types::upload_object_id::UploadObjectId; -use crate::api::api_types::meta_world_object_id::MetaWorldObjectId; -use crate::api::common::common_header_values::{ORIGIN_VALUE, REFERER_VALUE}; -use crate::api::utils::upload_id_to_image_url::upload_id_to_image_url; -use crate::credentials::world_labs_bearer_token::WorldLabsBearerToken; -use crate::credentials::world_labs_cookies::WorldLabsCookies; -use crate::error::world_labs_client_error::WorldLabsClientError; -use crate::error::world_labs_error::WorldLabsError; -use crate::error::world_labs_generic_api_error::WorldLabsGenericApiError; -use chrono::Utc; -use http_headers::names::{PRIORITY, SEC_FETCH_DEST, SEC_FETCH_MODE, SEC_FETCH_SITE, SEC_GPC}; -use http_headers::values::accept::ACCEPT_ALL; -use http_headers::values::cache_control::CACHE_CONTROL_NO_CACHE; -use http_headers::values::connection::CONNECTION_KEEP_ALIVE; -use http_headers::values::content_type::CONTENT_TYPE_APPLICATION_JSON; -use http_headers::values::pragma::PRAGMA_NO_CACHE; -use http_headers::values::priority::PRIORITY_4; -use http_headers::values::sec::{SEC_FETCH_DEST_EMPTY, SEC_FETCH_MODE_CORS, SEC_FETCH_SITE_CROSS_SITE}; -use http_headers::values::te::TE_TRAILERS; -use indexmap::IndexMap; -use log::{debug, error}; -use serde::{Deserialize, Serialize}; -use serde_json::Value; -use std::collections::HashMap; -use std::time::Duration; -use wreq::header::{ACCEPT, ACCEPT_ENCODING, ACCEPT_LANGUAGE, AUTHORIZATION, CACHE_CONTROL, CONNECTION, CONTENT_TYPE, ORIGIN, PRAGMA, REFERER, TE}; -use wreq::Client; -use wreq_util::Emulation; -use crate::api::api_types::world_id::WorldObjectId; -const BASE_URL : &str = "https://api.worldlabs.ai/api/v1/objects"; - -// Note: WorldLabs is phasing out the old URL scheme: -// const BASE_URL : &str = "https://marble2-kgw-prod-iac1.wlt-ai.art/api/v1/objects"; - -fn get_url(run_id: &RunObjectId) -> String { - format!("{}/{}", BASE_URL, run_id.0) -} - -pub struct UpdateRunObjectWithWorldArgs<'a> { - pub cookies: &'a WorldLabsCookies, - pub bearer_token: &'a WorldLabsBearerToken, - - pub payload_args: UpdateRunObjectWithWorldPayloadArgs<'a>, - - pub request_timeout: Option, -} - -pub struct UpdateRunObjectWithWorldPayloadArgs<'a> { - pub run_id: &'a RunObjectId, - pub run_created_at_timestamp: u64, - pub first_patch_timestamp: u64, - - // eg. https://cdn.marble.worldlabs.ai/object/13ca760c-8ef9-4bf5-acc3-5a507fad3abf/asset.jpg - pub image_upload_url: &'a str, - - pub image_input_id: &'a ImageInputObjectId, - pub pano_id: &'a PanoObjectId, - pub meta_world_id: &'a MetaWorldObjectId, - pub world_id: &'a WorldObjectId, - - pub title: &'a str, - pub text_prompt: &'a str, -} - -pub struct UpdateRunObjectWithWorldResponse { - //pub image_input_id: ImageInputObjectId, - //pub pano_id: PanoObjectId, - //pub meta_world_id: MetaWorldObjectId, - //pub world_id: WorldObjectId, -} - -/// Marble Image-to-World -/// This request patches the run object a second time. It updates -/// more fields - prompt, world_id, etc. -/// Request #9 (of ~10) -pub async fn update_run_object_with_world(args: UpdateRunObjectWithWorldArgs<'_>) -> Result { - let client = Client::builder() - .emulation(Emulation::Firefox143) - .build() - .map_err(|err| WorldLabsClientError::WreqClientError(err))?; - - let url = get_url(args.payload_args.run_id); - - debug!("Requesting URL: {}", url); - - let mut request_builder = client.patch(url) - .header(ACCEPT, ACCEPT_ALL) - .header(ACCEPT_LANGUAGE, "en-US,en;q=0.5") - .header(ACCEPT_ENCODING, "gzip, deflate, br, zstd") - .header(REFERER, REFERER_VALUE) - .header(CONTENT_TYPE, CONTENT_TYPE_APPLICATION_JSON) - .header(AUTHORIZATION, args.bearer_token.to_bearer_token_header_string()) - .header(ORIGIN, ORIGIN_VALUE) - .header(SEC_GPC, "1") - .header(CONNECTION, CONNECTION_KEEP_ALIVE) - .header(SEC_FETCH_DEST, SEC_FETCH_DEST_EMPTY) - .header(SEC_FETCH_MODE, SEC_FETCH_MODE_CORS) - .header(SEC_FETCH_SITE, SEC_FETCH_SITE_CROSS_SITE) - .header(PRIORITY, PRIORITY_4) - .header(PRAGMA, PRAGMA_NO_CACHE) - .header(CACHE_CONTROL, CACHE_CONTROL_NO_CACHE) - .header(TE, TE_TRAILERS); - - if let Some(timeout) = args.request_timeout { - request_builder = request_builder.timeout(timeout); - } - - let payload = RawRequest::from_args(&args.payload_args); - - let http_request = request_builder.json(&payload) - .build() - .map_err(|err| { - error!("Error building request: {:?}", err); - WorldLabsClientError::WreqClientError(err) - })?; - - let response = client.execute(http_request) - .await - .map_err(|err| { - error!("Error during request execution: {:?}", err); - WorldLabsGenericApiError::WreqError(err) - })?; - - let status = response.status(); - - let response_body = response.text() - .await - .map_err(|err| { - error!("Error reading response body: {:?}", err); - WorldLabsGenericApiError::WreqError(err) - })?; - - // TODO: Handle errors (Cloudflare, Grok, etc.) - if !status.is_success() { - error!("Request returned an error (code {}) : {:?}", status.as_u16(), response_body); - //return Err(classify_general_http_status_code_and_body(status, response_body)); - return Err(WorldLabsGenericApiError::UncategorizedBadResponseWithStatusAndBody { status_code: status, body: response_body}.into()) - } - - debug!("Response body (200): {}", response_body); - - let _response : RawResponse = serde_json::from_str(&response_body) - .map_err(|err| WorldLabsGenericApiError::SerdeResponseParseErrorWithBody(err, response_body.to_string()))?; - - Ok(UpdateRunObjectWithWorldResponse { - //image_input_id: args.payload_args.image_input_id.clone(), - //pano_id: args.payload_args.pano_id.clone(), - //meta_world_id: args.payload_args.meta_world_id.clone(), - }) -} - -#[derive(Serialize)] -struct RawRequest { - pub object: ObjectDef, - pub update_mask: Vec, -} - -impl Default for RawRequest { - fn default() -> Self { - let now = Utc::now(); - let now = now.timestamp_millis().unsigned_abs(); - Self { - object: ObjectDef { - metadata: ObjectMetadata { - version: "0.0.1".to_string(), - name: None, - created_at: now, - updated_at: now, - uses_advanced_editing: false, - draft_mode: false, - nodes: IndexMap::new(), - } - }, - update_mask: vec!["metadata".to_string()] - } - } -} - -impl RawRequest { - pub fn from_args(args: &UpdateRunObjectWithWorldPayloadArgs) -> Self { - let mut request = RawRequest::default(); - request.add_image_input_node({ - let mut node = ImageInputNode::default(); - node.id = args.image_input_id.to_string(); - node.source.image_url = args.image_upload_url.to_string(); - node.title = args.title.to_string(); - node.caption = args.text_prompt.to_string(); - node.created_at = args.first_patch_timestamp; - node - }); - request.add_pano_node({ - let mut node = PanoNode::default(); - node.id = args.pano_id.to_string(); - node.parent_id = Some(args.image_input_id.to_string()); - node.source.world_id = Some(args.world_id.to_string()); - node.created_at = args.first_patch_timestamp; - node - }); - request.add_world_node({ - let mut node = WorldNode::default(); - node.id = args.meta_world_id.to_string(); - node.parent_id= Some(args.pano_id.to_string()); - node.source.world_id = Some(args.world_id.to_string()); - node.created_at = args.first_patch_timestamp; - node - }); - let now = Utc::now(); - let now = now.timestamp_millis().unsigned_abs(); - request.object.metadata.updated_at = now; - request.object.metadata.name = Some(args.title.to_string()); - request - } - - pub fn add_image_input_node(&mut self, mut node: ImageInputNode) { - node.created_at = self.object.metadata.updated_at; - self.object.metadata.nodes.insert(node.id.clone(), NodeValue::ImageInput(node)); - } - - pub fn add_pano_node(&mut self, mut node: PanoNode) { - node.created_at = self.object.metadata.updated_at; - self.object.metadata.nodes.insert(node.id.clone(), NodeValue::Pano(node)); - } - - pub fn add_world_node(&mut self, mut node: WorldNode) { - node.created_at = self.object.metadata.updated_at; - self.object.metadata.nodes.insert(node.id.clone(), NodeValue::World(node)); - } -} - -#[derive(Serialize)] -struct ObjectDef { - pub metadata: ObjectMetadata, -} - -#[derive(Serialize)] -struct ObjectMetadata { - pub version: String, - - // NB: Not null in request, just for builder - pub name: Option, - - #[serde(rename = "createdAt")] - pub created_at: u64, - - #[serde(rename = "updatedAt")] - pub updated_at: u64, - - #[serde(rename = "usesAdvancedEditing")] - pub uses_advanced_editing: bool, - - #[serde(rename = "draftMode")] - pub draft_mode: bool, - - /// Polymorphic set of ID-to-object mappings. - /// NB: IndexMap maintains insertion order. - pub nodes: IndexMap, -} - -#[derive(Serialize)] -#[serde(untagged)] -//#[serde(tag = "type", content = "value")] -enum NodeValue { - ImageInput(ImageInputNode), - Pano(PanoNode), - World(WorldNode), -} - -#[derive(Serialize, Default)] -struct ImageInputNode { - pub id: String, - pub r#type: TypeInput, - #[serde(rename = "parentId")] - pub parent_id: Option, - pub source: ImageInputNodeSource, - #[serde(rename = "createdAt")] - pub created_at: u64, - pub title: String, - pub caption: String, -} - -#[derive(Serialize, Default)] -struct ImageInputNodeSource { - pub r#type: TypeImage, - pub image_url: String, -} - -#[derive(Serialize, Default)] -enum TypeInput { - #[serde(rename = "input")] - #[default] - Input -} - -#[derive(Serialize, Default)] -enum TypeImage { - #[serde(rename = "image")] - #[default] - Image -} - -#[derive(Serialize, Default)] -enum StatusPending { - #[serde(rename = "pending")] - #[default] - Pending -} - -impl ImageInputNode { - pub fn with_id(id: &str) -> Self{ - Self { - id: id.to_string(), - ..Default::default() - } - } -} - -#[derive(Serialize, Default)] -struct PanoNode { - pub id: String, - pub r#type: TypePano, - #[serde(rename = "parentId")] - pub parent_id: Option, - pub source: PanoNodeSource, - #[serde(rename = "createdAt")] - pub created_at: u64, -} - -#[derive(Serialize, Default)] -struct PanoNodeSource { - pub r#type: TypeGenerateWorld, - // NB: Not null in request, just for builder - pub world_id: Option, - pub status: StatusPending, -} - -#[derive(Serialize, Default)] -enum TypePano { - #[serde(rename = "pano")] - #[default] - Pano -} - -#[derive(Serialize, Default)] -enum TypeGenerateWorld { - #[serde(rename = "generate_world")] - #[default] - GenerateWorld -} - -impl PanoNode { - pub fn with_id(id: &str) -> Self{ - Self { - id: id.to_string(), - ..Default::default() - } - } -} - -#[derive(Serialize, Default)] -struct WorldNode { - pub id: String, - pub r#type: TypeWorld, - #[serde(rename = "parentId")] - pub parent_id: Option, - pub source: WorldNodeSource, - #[serde(rename = "createdAt")] - pub created_at: u64, -} - -#[derive(Serialize, Default)] -struct WorldNodeSource { - pub r#type: TypeGenerateWorld, - // NB: Not null in request, just for - pub world_id: Option, - pub posed_cubemaps_url: String, - pub minimap_url: String, - pub minimap_metadata: String, - pub status: StatusPending, -} - -#[derive(Serialize, Default)] -enum TypeWorld { - #[serde(rename = "world")] - #[default] - World -} - -impl WorldNode { - pub fn with_id(id: &str) -> Self{ - Self { - id: id.to_string(), - ..Default::default() - } - } -} - -#[derive(Deserialize)] -struct RawResponse { - pub id: String, -} - -#[cfg(test)] -mod tests { - use crate::api::api_types::image_input_object_id::ImageInputObjectId; - use crate::api::api_types::pano_object_id::PanoObjectId; - use crate::api::api_types::run_object_id::RunObjectId; - use crate::api::api_types::meta_world_object_id::MetaWorldObjectId; - use crate::api::api_types::world_id::WorldObjectId; - use crate::api::requests::objects::update_run_object_with_world::{RawRequest, UpdateRunObjectWithWorldPayloadArgs}; - use serde_json::{json, Value}; - - /// Any timestamp from `Utc::now()` should exceed this (2023-11-14 in epoch millis). - const MIN_PLAUSIBLE_EPOCH_MILLIS: u64 = 1_700_000_000_000; - - #[test] - fn request_default() { - let request = RawRequest::default(); - assert_eq!(request.object.metadata.version, "0.0.1"); - assert!(request.object.metadata.created_at > 10000); - assert!(request.object.metadata.updated_at > 10000); - } - - #[test] - fn json() { - let run_id = RunObjectId::from_str("79795b32-e44d-4333-bac1-05b2c9a3ea12"); - let image_input_id = ImageInputObjectId::from_str("bc17252b-811e-49d7-be3e-b7c538df9d30"); - let pano_id = PanoObjectId::from_str("82f6b488-8afe-4311-9022-80ad5789ad92"); - let meta_world_id = MetaWorldObjectId::from_str("f08ec501-601c-47c6-a104-402d1820b8f0"); - let world_id = WorldObjectId::from_str("d60cfa21-5506-43de-9a9c-0707fc17a5ec"); - - let title = "Cows Grazing in Indoor Pasture"; - let caption = "The scene is a surreal indoor agricultural environment, depicted with a realistic and slightly eerie tone, as rows of bright lights illuminate a vast, artificial pasture. The overall mood is quiet and contemplative, emphasizing the unusual juxtaposition of natural elements within a manufactured setting. Large herds of cattle are distributed across the lush, green grassy floor, peacefully grazing on the abundant vegetation. The entire space is encased within a massive, warehouse-like structure, supported by countless concrete columns that extend from the floor to the ceiling in an orderly grid. Above the columns, a network of metal beams forms the infrastructure of the roof, from which an extensive array of industrial lights is suspended. These lights are arranged in long, parallel lines, creating a striking visual perspective that converges towards a distant vanishing point at the center of the structure. The dense, vibrant green grass covers every inch of the ground, appearing soft and uniform, without any discernible paths or bare patches. Each cow is distinct, varying in color from black to brown and white, and each is engaged in individual grazing or resting. The concrete columns maintain a consistent light gray color and texture, creating a rhythmic architectural presence throughout the vast indoor landscape. To the right, another cluster of columns continues the architectural pattern, while the grassy expanse remains uninterrupted, extending toward the edges of the structure. "; - - let args = UpdateRunObjectWithWorldPayloadArgs { - run_created_at_timestamp: 1765756772176, - first_patch_timestamp: 1765756773647, - image_upload_url: "https://cdn.marble.worldlabs.ai/object/13ca760c-8ef9-4bf5-acc3-5a507fad3abf/asset.jpg", - run_id: &run_id, - image_input_id: &image_input_id, - pano_id: &pano_id, - meta_world_id: &meta_world_id, - world_id: &world_id, - title, - text_prompt: caption, - }; - - let request = RawRequest::from_args(&args); - - // The `createdAt` / `updatedAt` timestamps come from `Utc::now()` at build time, - // so they're nondeterministic. Sanity-check them, then zero them out before - // comparing the rest of the document. - assert!(request.object.metadata.created_at > MIN_PLAUSIBLE_EPOCH_MILLIS); - assert!(request.object.metadata.updated_at >= request.object.metadata.created_at); - - let mut actual = serde_json::to_value(&request).unwrap(); - zero_out_timestamps(&mut actual); - - let expected = json!({ - "object": { - "metadata": { - "version": "0.0.1", - "name": title, - "createdAt": 0, - "updatedAt": 0, - "usesAdvancedEditing": false, - "draftMode": false, - "nodes": { - "bc17252b-811e-49d7-be3e-b7c538df9d30": { - "id": "bc17252b-811e-49d7-be3e-b7c538df9d30", - "type": "input", - "parentId": null, - "source": { - "type": "image", - "image_url": "https://cdn.marble.worldlabs.ai/object/13ca760c-8ef9-4bf5-acc3-5a507fad3abf/asset.jpg" - }, - "createdAt": 0, - "title": title, - "caption": caption - }, - "82f6b488-8afe-4311-9022-80ad5789ad92": { - "id": "82f6b488-8afe-4311-9022-80ad5789ad92", - "type": "pano", - "parentId": "bc17252b-811e-49d7-be3e-b7c538df9d30", - "source": { - "type": "generate_world", - "world_id": "d60cfa21-5506-43de-9a9c-0707fc17a5ec", - "status": "pending" - }, - "createdAt": 0 - }, - "f08ec501-601c-47c6-a104-402d1820b8f0": { - "id": "f08ec501-601c-47c6-a104-402d1820b8f0", - "type": "world", - "parentId": "82f6b488-8afe-4311-9022-80ad5789ad92", - "source": { - "type": "generate_world", - "world_id": "d60cfa21-5506-43de-9a9c-0707fc17a5ec", - "posed_cubemaps_url": "", - "minimap_url": "", - "minimap_metadata": "", - "status": "pending" - }, - "createdAt": 0 - } - } - } - }, - "update_mask": [ - "metadata" - ] - }); - - assert_eq!(actual, expected); - } - - /// Recursively replaces nondeterministic `createdAt` / `updatedAt` values with 0. - fn zero_out_timestamps(value: &mut Value) { - match value { - Value::Object(map) => { - for (key, child) in map.iter_mut() { - if key == "createdAt" || key == "updatedAt" { - *child = json!(0); - } else { - zero_out_timestamps(child); - } - } - }, - Value::Array(items) => { - for item in items.iter_mut() { - zero_out_timestamps(item); - } - }, - _ => {}, - } - } -} diff --git a/crates/api_clients/worldlabs_consumer_client/src/api/requests/recaption/mod.rs b/crates/api_clients/worldlabs_consumer_client/src/api/requests/recaption/mod.rs deleted file mode 100644 index 58671219b6..0000000000 --- a/crates/api_clients/worldlabs_consumer_client/src/api/requests/recaption/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod recaption_image; \ No newline at end of file diff --git a/crates/api_clients/worldlabs_consumer_client/src/api/requests/recaption/recaption_image.rs b/crates/api_clients/worldlabs_consumer_client/src/api/requests/recaption/recaption_image.rs deleted file mode 100644 index 29c9732776..0000000000 --- a/crates/api_clients/worldlabs_consumer_client/src/api/requests/recaption/recaption_image.rs +++ /dev/null @@ -1,174 +0,0 @@ -use crate::api::api_types::run_object_id::RunObjectId; -use crate::api::api_types::upload_mime_type::UploadMimeType; -use crate::api::api_types::upload_object_id::UploadObjectId; -use crate::api::common::common_header_values::{ORIGIN_VALUE, REFERER_VALUE}; -use crate::api::utils::upload_id_to_image_url::upload_id_to_image_url; -use crate::credentials::world_labs_bearer_token::WorldLabsBearerToken; -use crate::credentials::world_labs_cookies::WorldLabsCookies; -use crate::error::world_labs_client_error::WorldLabsClientError; -use crate::error::world_labs_error::WorldLabsError; -use crate::error::world_labs_generic_api_error::WorldLabsGenericApiError; -use http_headers::names::{PRIORITY, SEC_FETCH_DEST, SEC_FETCH_MODE, SEC_FETCH_SITE, SEC_GPC}; -use http_headers::values::accept::ACCEPT_ALL; -use http_headers::values::cache_control::CACHE_CONTROL_NO_CACHE; -use http_headers::values::connection::CONNECTION_KEEP_ALIVE; -use http_headers::values::content_type::CONTENT_TYPE_APPLICATION_JSON; -use http_headers::values::pragma::PRAGMA_NO_CACHE; -use http_headers::values::priority::PRIORITY_4; -use http_headers::values::sec::{SEC_FETCH_DEST_EMPTY, SEC_FETCH_MODE_CORS, SEC_FETCH_SITE_CROSS_SITE}; -use http_headers::values::te::TE_TRAILERS; -use log::{debug, error}; -use serde::{Deserialize, Serialize}; -use std::time::Duration; -use wreq::header::{ACCEPT, ACCEPT_ENCODING, ACCEPT_LANGUAGE, AUTHORIZATION, CACHE_CONTROL, CONNECTION, CONTENT_TYPE, ORIGIN, PRAGMA, REFERER, TE}; -use wreq::Client; -use wreq_util::Emulation; - -const URL : &str = "https://api.worldlabs.ai/api/v1/recaption2"; - -// Note: WorldLabs is phasing out the old URL scheme: -// const URL : &str = "https://marble2-kgw-prod-iac1.wlt-ai.art/api/v1/recaption2"; - -pub struct RecaptionImageArgs<'a> { - pub cookies: &'a WorldLabsCookies, - pub bearer_token: &'a WorldLabsBearerToken, - pub upload_id: &'a UploadObjectId, - pub upload_mime_type: UploadMimeType, - pub run_id: &'a RunObjectId, - pub request_timeout: Option, -} - -pub struct RecaptionImageResponse { - pub title: String, - pub caption: String, -} - -/// Marble Image-to-World -/// This request generates captions and titles for images. It's a VLM. -/// The prompts are then used downstream to create the scenes. -/// Request #6 (of ~10) -pub async fn recaption_image(args: RecaptionImageArgs<'_>) -> Result { - let client = Client::builder() - .emulation(Emulation::Firefox143) - .build() - .map_err(|err| WorldLabsClientError::WreqClientError(err))?; - - debug!("Requesting URL: {}", URL); - - let mut request_builder = client.post(URL) - .header(ACCEPT, ACCEPT_ALL) - .header(ACCEPT_LANGUAGE, "en-US,en;q=0.5") - .header(ACCEPT_ENCODING, "gzip, deflate, br, zstd") - .header(REFERER, REFERER_VALUE) - .header(CONTENT_TYPE, CONTENT_TYPE_APPLICATION_JSON) - .header(AUTHORIZATION, args.bearer_token.to_bearer_token_header_string()) - .header(ORIGIN, ORIGIN_VALUE) - .header(SEC_GPC, "1") - .header(CONNECTION, CONNECTION_KEEP_ALIVE) - .header(SEC_FETCH_DEST, SEC_FETCH_DEST_EMPTY) - .header(SEC_FETCH_MODE, SEC_FETCH_MODE_CORS) - .header(SEC_FETCH_SITE, SEC_FETCH_SITE_CROSS_SITE) - .header(PRIORITY, PRIORITY_4) - .header(PRAGMA, PRAGMA_NO_CACHE) - .header(CACHE_CONTROL, CACHE_CONTROL_NO_CACHE) - .header(TE, TE_TRAILERS); - - if let Some(timeout) = args.request_timeout { - request_builder = request_builder.timeout(timeout); - } - - let request_payload = RawRequest::for_image_and_run(args.upload_id, args.upload_mime_type, args.run_id); - - let http_request = request_builder.json(&request_payload) - .build() - .map_err(|err| { - error!("Error building request: {:?}", err); - WorldLabsClientError::WreqClientError(err) - })?; - - let response = client.execute(http_request) - .await - .map_err(|err| { - error!("Error during request execution: {:?}", err); - WorldLabsGenericApiError::WreqError(err) - })?; - - let status = response.status(); - - let response_body = response.text() - .await - .map_err(|err| { - error!("Error reading response body: {:?}", err); - WorldLabsGenericApiError::WreqError(err) - })?; - - // TODO: Handle errors (Cloudflare, Grok, etc.) - if !status.is_success() { - error!("Request returned an error (code {}) : {:?}", status.as_u16(), response_body); - //return Err(classify_general_http_status_code_and_body(status, response_body)); - return Err(WorldLabsGenericApiError::UncategorizedBadResponseWithStatusAndBody { status_code: status, body: response_body}.into()) - } - - debug!("Response body (200): {}", response_body); - - let response : RawResponse = serde_json::from_str(&response_body) - .map_err(|err| WorldLabsGenericApiError::SerdeResponseParseErrorWithBody(err, response_body.to_string()))?; - - Ok(RecaptionImageResponse { - title: response.title, - caption: response.caption, - }) -} - -#[derive(Serialize)] -struct RawRequest { - pub world_prompt: WorldPrompt, - pub user_caption: String, - pub context: Context, -} - -#[derive(Serialize)] -struct WorldPrompt { - pub r#type: String, - pub image_prompt: ImagePrompt, - pub text_prompt: String, -} - -#[derive(Serialize)] -struct ImagePrompt { - pub uri: String, -} - -#[derive(Serialize)] -struct Context { - pub run_id: String, -} - -impl RawRequest { - pub fn for_image_and_run(image_upload_id: &UploadObjectId, image_mime_type: UploadMimeType, run_id: &RunObjectId) -> Self { - let image_url = upload_id_to_image_url(image_upload_id, image_mime_type); - Self { - world_prompt: WorldPrompt { - r#type: "image".to_string(), - image_prompt: ImagePrompt { - uri: image_url, - }, - text_prompt: "".to_string(), // NB: empty - }, - user_caption: "".to_string(), // NB: empty - context: Context { - run_id: run_id.0.clone(), - } - } - } -} - -#[derive(Deserialize)] -struct RawResponse { - pub caption: String, - pub title: String, -} - -#[cfg(test)] -mod tests { -} diff --git a/crates/api_clients/worldlabs_consumer_client/src/api/requests/worlds/create_world.rs b/crates/api_clients/worldlabs_consumer_client/src/api/requests/worlds/create_world.rs deleted file mode 100644 index 5ebd570227..0000000000 --- a/crates/api_clients/worldlabs_consumer_client/src/api/requests/worlds/create_world.rs +++ /dev/null @@ -1,186 +0,0 @@ -use crate::api::api_types::meta_world_object_id::MetaWorldObjectId; -use crate::api::api_types::run_object_id::RunObjectId; -use crate::api::api_types::upload_mime_type::UploadMimeType; -use crate::api::api_types::upload_object_id::UploadObjectId; -use crate::api::api_types::world_id::WorldObjectId; -use crate::api::common::common_header_values::{ORIGIN_VALUE, REFERER_VALUE}; -use crate::api::utils::upload_id_to_image_url::upload_id_to_image_url; -use crate::credentials::world_labs_bearer_token::WorldLabsBearerToken; -use crate::credentials::world_labs_cookies::WorldLabsCookies; -use crate::error::filter_world_labs_http_error::filter_world_labs_http_error; -use crate::error::world_labs_client_error::WorldLabsClientError; -use crate::error::world_labs_error::WorldLabsError; -use crate::error::world_labs_generic_api_error::WorldLabsGenericApiError; -use http_headers::names::{PRIORITY, SEC_FETCH_DEST, SEC_FETCH_MODE, SEC_FETCH_SITE, SEC_GPC}; -use http_headers::values::accept::ACCEPT_ALL; -use http_headers::values::cache_control::CACHE_CONTROL_NO_CACHE; -use http_headers::values::connection::CONNECTION_KEEP_ALIVE; -use http_headers::values::content_type::CONTENT_TYPE_APPLICATION_JSON; -use http_headers::values::pragma::PRAGMA_NO_CACHE; -use http_headers::values::priority::PRIORITY_4; -use http_headers::values::sec::{SEC_FETCH_DEST_EMPTY, SEC_FETCH_MODE_CORS, SEC_FETCH_SITE_CROSS_SITE}; -use http_headers::values::te::TE_TRAILERS; -use log::{debug, error}; -use serde::{Deserialize, Serialize}; -use std::time::Duration; -use wreq::header::{ACCEPT, ACCEPT_ENCODING, ACCEPT_LANGUAGE, AUTHORIZATION, CACHE_CONTROL, CONNECTION, CONTENT_TYPE, ORIGIN, PRAGMA, REFERER, TE}; -use wreq::Client; -use wreq_util::Emulation; - -const URL : &str = "https://api.worldlabs.ai/api/v1/worlds"; - -// Note: WorldLabs is phasing out the old URL scheme: -//const URL : &str = "https://marble2-kgw-prod-iac1.wlt-ai.art/api/v1/worlds"; - -pub struct CreateWorldArgs<'a> { - pub cookies: &'a WorldLabsCookies, - pub bearer_token: &'a WorldLabsBearerToken, - - // eg. https://cdn.marble.worldlabs.ai/object/13ca760c-8ef9-4bf5-acc3-5a507fad3abf/asset.jpg - pub image_upload_url: &'a str, - pub text_prompt: &'a str, - - pub request_timeout: Option, -} - -pub struct CreateWorldResponse { - pub world_id: WorldObjectId, -} - -/// Marble Image-to-World -/// This request starts world generation -/// Request #7 (of ~10) -pub async fn create_world(args: CreateWorldArgs<'_>) -> Result { - let client = Client::builder() - .emulation(Emulation::Firefox143) - .build() - .map_err(|err| WorldLabsClientError::WreqClientError(err))?; - - debug!("Requesting URL: {}", URL); - - let mut request_builder = client.post(URL) - .header(ACCEPT, ACCEPT_ALL) - .header(ACCEPT_LANGUAGE, "en-US,en;q=0.5") - .header(ACCEPT_ENCODING, "gzip, deflate, br, zstd") - .header(REFERER, REFERER_VALUE) - .header(CONTENT_TYPE, CONTENT_TYPE_APPLICATION_JSON) - .header(AUTHORIZATION, args.bearer_token.to_bearer_token_header_string()) - .header(ORIGIN, ORIGIN_VALUE) - .header(SEC_GPC, "1") - .header(CONNECTION, CONNECTION_KEEP_ALIVE) - .header(SEC_FETCH_DEST, SEC_FETCH_DEST_EMPTY) - .header(SEC_FETCH_MODE, SEC_FETCH_MODE_CORS) - .header(SEC_FETCH_SITE, SEC_FETCH_SITE_CROSS_SITE) - .header(PRIORITY, PRIORITY_4) - .header(PRAGMA, PRAGMA_NO_CACHE) - .header(CACHE_CONTROL, CACHE_CONTROL_NO_CACHE) - .header(TE, TE_TRAILERS); - - if let Some(timeout) = args.request_timeout { - request_builder = request_builder.timeout(timeout); - } - - let mut payload = RawRequest::default(); - payload.generation_input.prompt.image_prompt.uri = Some(args.image_upload_url.to_string()); - payload.generation_input.prompt.text_prompt = Some(args.text_prompt.to_string()); - - let http_request = request_builder.json(&payload) - .build() - .map_err(|err| { - error!("Error building request: {:?}", err); - WorldLabsClientError::WreqClientError(err) - })?; - - let response = client.execute(http_request) - .await - .map_err(|err| { - error!("Error during request execution: {:?}", err); - WorldLabsGenericApiError::WreqError(err) - })?; - - let status = response.status(); - - let response_body = response.text() - .await - .map_err(|err| { - error!("Error reading response body: {:?}", err); - WorldLabsGenericApiError::WreqError(err) - })?; - - if !status.is_success() { - error!("Request returned an error (code {}) : {:?}", status.as_u16(), response_body); - } - - filter_world_labs_http_error(status, Some(&response_body))?; - - debug!("Response body (200): {}", response_body); - - let response : RawResponse = serde_json::from_str(&response_body) - .map_err(|err| WorldLabsGenericApiError::SerdeResponseParseErrorWithBody(err, response_body.to_string()))?; - - Ok(CreateWorldResponse { - world_id: WorldObjectId(response.id), - }) -} - -#[derive(Serialize)] -struct RawRequest { - pub permission: Permission, - pub generation_input: GenerationInput, -} - -#[derive(Serialize)] -struct Permission { - pub public: bool, -} - -#[derive(Serialize)] -struct GenerationInput { - pub model: String, - pub prompt: Prompt, -} - -#[derive(Serialize)] -struct Prompt { - pub r#type: String, - pub image_prompt: ImagePrompt, - - // NB: Not null in request, just for building - pub text_prompt: Option, -} - -#[derive(Serialize)] -struct ImagePrompt { - // NB: Not null in request, just for building - pub uri: Option, -} - -impl Default for RawRequest { - fn default() -> Self { - Self { - permission: Permission { - public: true, - }, - generation_input: GenerationInput { - model: "Marble 0.1-plus".to_string(), - prompt: Prompt { - r#type: "image".to_string(), - image_prompt: ImagePrompt { - uri: None, - }, - text_prompt: None, - }, - }, - } - } -} - - -#[derive(Deserialize)] -struct RawResponse { - pub id: String, -} - -#[cfg(test)] -mod tests { -} diff --git a/crates/api_clients/worldlabs_consumer_client/src/api/requests/worlds/mod.rs b/crates/api_clients/worldlabs_consumer_client/src/api/requests/worlds/mod.rs deleted file mode 100644 index 58522dea54..0000000000 --- a/crates/api_clients/worldlabs_consumer_client/src/api/requests/worlds/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod create_world; -pub mod poll_world_status; \ No newline at end of file diff --git a/crates/api_clients/worldlabs_consumer_client/src/api/requests/worlds/poll_world_status.rs b/crates/api_clients/worldlabs_consumer_client/src/api/requests/worlds/poll_world_status.rs deleted file mode 100644 index 55b7c09c9d..0000000000 --- a/crates/api_clients/worldlabs_consumer_client/src/api/requests/worlds/poll_world_status.rs +++ /dev/null @@ -1,212 +0,0 @@ -use crate::api::api_types::run_object_id::RunObjectId; -use crate::api::api_types::upload_mime_type::UploadMimeType; -use crate::api::api_types::upload_object_id::UploadObjectId; -use crate::api::api_types::world_id::WorldObjectId; -use crate::api::common::common_header_values::{ORIGIN_VALUE, REFERER_VALUE}; -use crate::credentials::world_labs_bearer_token::WorldLabsBearerToken; -use crate::credentials::world_labs_cookies::WorldLabsCookies; -use crate::error::world_labs_client_error::WorldLabsClientError; -use crate::error::world_labs_error::WorldLabsError; -use crate::error::world_labs_generic_api_error::WorldLabsGenericApiError; -use chrono::Utc; -use http_headers::names::{PRIORITY, SEC_FETCH_DEST, SEC_FETCH_MODE, SEC_FETCH_SITE, SEC_GPC}; -use http_headers::values::accept::ACCEPT_ALL; -use http_headers::values::cache_control::CACHE_CONTROL_NO_CACHE; -use http_headers::values::connection::CONNECTION_KEEP_ALIVE; -use http_headers::values::content_type::CONTENT_TYPE_APPLICATION_JSON; -use http_headers::values::pragma::PRAGMA_NO_CACHE; -use http_headers::values::priority::PRIORITY_4; -use http_headers::values::sec::{SEC_FETCH_DEST_EMPTY, SEC_FETCH_MODE_CORS, SEC_FETCH_SITE_CROSS_SITE}; -use http_headers::values::te::TE_TRAILERS; -use log::{debug, error, info}; -use serde::{Deserialize, Serialize}; -use std::time::Duration; -use uuid::Uuid; -use wreq::header::{ACCEPT, ACCEPT_ENCODING, ACCEPT_LANGUAGE, AUTHORIZATION, CACHE_CONTROL, CONNECTION, CONTENT_LENGTH, CONTENT_TYPE, ORIGIN, PRAGMA, REFERER, TE}; -use wreq::Client; -use wreq_util::Emulation; - -const BASE_URL : &str = "https://api.worldlabs.ai/api/v1/worlds"; - -// Note: WorldLabs is phasing out the old URL scheme: -// const BASE_URL : &str = "https://marble2-kgw-prod-iac1.wlt-ai.art/api/v1/worlds"; - -fn get_url(world_id: &WorldObjectId) -> String { - format!("{}/{}", BASE_URL, world_id.0) -} - -pub struct PollWorldStatusArgs<'a> { - pub cookies: &'a WorldLabsCookies, - pub bearer_token: &'a WorldLabsBearerToken, - pub world_id: &'a WorldObjectId, - pub request_timeout: Option, -} - -pub struct PollWorldStatusResponse { - pub is_complete: bool, - pub spz_splat_url: Option, -} - -/// Marble Image-to-World -/// Poll the world generation status -/// Request #10 (of ~10) -pub async fn poll_world_status(args: PollWorldStatusArgs<'_>) -> Result { - let client = Client::builder() - .emulation(Emulation::Firefox143) - .build() - .map_err(|err| WorldLabsClientError::WreqClientError(err))?; - - let url = get_url(args.world_id); - - info!("Polling World: {}", url); - - let mut request_builder = client.get(url) - .header(ACCEPT, ACCEPT_ALL) - .header(ACCEPT_LANGUAGE, "en-US,en;q=0.5") - .header(ACCEPT_ENCODING, "gzip, deflate, br, zstd") - .header(REFERER, REFERER_VALUE) - .header(AUTHORIZATION, args.bearer_token.to_bearer_token_header_string()) - .header(ORIGIN, ORIGIN_VALUE) - .header(SEC_GPC, "1") - .header(CONNECTION, CONNECTION_KEEP_ALIVE) - .header(SEC_FETCH_DEST, SEC_FETCH_DEST_EMPTY) - .header(SEC_FETCH_MODE, SEC_FETCH_MODE_CORS) - .header(SEC_FETCH_SITE, SEC_FETCH_SITE_CROSS_SITE) - .header(PRIORITY, PRIORITY_4) - .header(PRAGMA, PRAGMA_NO_CACHE) - .header(CACHE_CONTROL, CACHE_CONTROL_NO_CACHE) - .header(CONTENT_LENGTH, 0) - .header(TE, TE_TRAILERS); - - if let Some(timeout) = args.request_timeout { - request_builder = request_builder.timeout(timeout); - } - - let http_request = request_builder - .build() - .map_err(|err| { - error!("Error building request: {:?}", err); - WorldLabsClientError::WreqClientError(err) - })?; - - let response = client.execute(http_request) - .await - .map_err(|err| { - error!("Error during request execution: {:?}", err); - WorldLabsGenericApiError::WreqError(err) - })?; - - let status = response.status(); - - let response_body = response.text() - .await - .map_err(|err| { - error!("Error reading response body: {:?}", err); - WorldLabsGenericApiError::WreqError(err) - })?; - - // TODO: Handle errors (Cloudflare, Grok, etc.) - if !status.is_success() { - error!("Request returned an error (code {}) : {:?}", status.as_u16(), response_body); - //return Err(classify_general_http_status_code_and_body(status, response_body)); - return Err(WorldLabsGenericApiError::UncategorizedBadResponseWithStatusAndBody { status_code: status, body: response_body}.into()) - } - - debug!("Response body (200): {}", response_body); - - let response : RawResponse = serde_json::from_str(&response_body) - .map_err(|err| WorldLabsGenericApiError::SerdeResponseParseErrorWithBody(err, response_body.to_string()))?; - - debug!("World status: {}", response.status); - - let maybe_spz_url = response.generation_output - .map(|out| out.spz_urls.full_res); - - Ok(PollWorldStatusResponse { - is_complete: maybe_spz_url.is_some(), - spz_splat_url: maybe_spz_url, - }) -} - -#[derive(Deserialize)] -struct RawResponse { - /// eg. "INITIALIZING", "SUCCEEDED", etc. - pub status: String, - - pub generation_output: Option, -} - -#[derive(Deserialize)] -struct GenerationOutput { - pub spz_urls: SpzUrls, - -} - -#[derive(Deserialize)] -struct SpzUrls { - // eg. https://cdn.marble.worldlabs.ai/d60cfa21-5506-43de-9a9c-0707fc17a5ec/1002dd35-fcad-4eeb-ba15-0d113c1778d8_ceramic.spz - pub full_res: String, -} - -#[cfg(test)] -mod tests { - use crate::api::api_types::world_id::WorldObjectId; - use crate::api::requests::worlds::poll_world_status::{get_url, poll_world_status, PollWorldStatusArgs, BASE_URL}; - use crate::test_utils::get_test_bearer_token::get_test_bearer_token; - use crate::test_utils::get_test_cookies::get_typed_test_cookies; - use crate::test_utils::setup_test_logging::setup_test_logging; - use log::LevelFilter; - - #[test] - fn test_get_url() { - let world_id = WorldObjectId("d60cfa21-5506-43de-9a9c-0707fc17a5ec".to_string()); - let expected = format!("{}/d60cfa21-5506-43de-9a9c-0707fc17a5ec", BASE_URL); - assert_eq!(get_url(&world_id), expected); - } - - #[tokio::test] - #[ignore] // Client side tests only - async fn test_requests() { - setup_test_logging(LevelFilter::Debug); - - let cookies = get_typed_test_cookies().unwrap(); - let bearer_token = get_test_bearer_token().unwrap(); - - let world_id = WorldObjectId("403c379b-b7d2-4449-8f1e-ebdb56142604".to_string()); - - let response = poll_world_status(PollWorldStatusArgs { - cookies: &cookies, - bearer_token: &bearer_token, - world_id: &world_id, - request_timeout: None, - }).await.unwrap(); - - println!("Is complete: {}", response.is_complete); - println!("Spz Url: {}", response.spz_splat_url.unwrap_or_else(|| "incomplete".to_string())); - - assert_eq!(1, 2); - } - - #[tokio::test] - #[ignore] // Client side tests only - async fn test_request_2() { - setup_test_logging(LevelFilter::Debug); - - let cookies = get_typed_test_cookies().unwrap(); - let bearer_token = get_test_bearer_token().unwrap(); - - let world_id = WorldObjectId("e739b11e-6039-49c7-b73d-b79e1b28e295".to_string()); - - let response = poll_world_status(PollWorldStatusArgs { - cookies: &cookies, - bearer_token: &bearer_token, - world_id: &world_id, - request_timeout: None, - }).await.unwrap(); - - println!("Is complete: {}", response.is_complete); - println!("Spz Url: {}", response.spz_splat_url.unwrap_or_else(|| "incomplete".to_string())); - - assert_eq!(1, 2); - } -} diff --git a/crates/api_clients/worldlabs_consumer_client/src/api/utils/mod.rs b/crates/api_clients/worldlabs_consumer_client/src/api/utils/mod.rs deleted file mode 100644 index ff1db7c174..0000000000 --- a/crates/api_clients/worldlabs_consumer_client/src/api/utils/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod upload_id_to_image_url; \ No newline at end of file diff --git a/crates/api_clients/worldlabs_consumer_client/src/api/utils/upload_id_to_image_url.rs b/crates/api_clients/worldlabs_consumer_client/src/api/utils/upload_id_to_image_url.rs deleted file mode 100644 index 3dc266bb5f..0000000000 --- a/crates/api_clients/worldlabs_consumer_client/src/api/utils/upload_id_to_image_url.rs +++ /dev/null @@ -1,38 +0,0 @@ -use crate::api::api_types::upload_object_id::UploadObjectId; -use crate::api::api_types::upload_mime_type::UploadMimeType; - -pub fn upload_id_to_image_url(upload_id: &UploadObjectId, upload_mime_type: UploadMimeType) -> String { - let extension_without_period = match upload_mime_type { - UploadMimeType::ImageJpeg => "jpg", - }; - let upload_id_str = upload_id.as_str(); - format!("https://cdn.marble.worldlabs.ai/object/{upload_id_str}/asset.{extension_without_period}") -} - -#[cfg(test)] -mod tests { - use super::upload_id_to_image_url; - use crate::api::api_types::upload_object_id::UploadObjectId; - use crate::api::api_types::upload_mime_type::UploadMimeType; - - // llm tests... sigh - #[test] - fn builds_jpeg_url_with_jpg_extension() { - let id = UploadObjectId("abc123".to_string()); - let url = upload_id_to_image_url(&id, UploadMimeType::ImageJpeg); - assert_eq!( - url, - "https://cdn.marble.worldlabs.ai/object/abc123/asset.jpg" - ); - } - - // llm tests... sigh - #[test] - fn preserves_exact_upload_id_in_url() { - let raw_id = "550e8400-e29b-41d4-a716-446655440000"; - let id = UploadObjectId(raw_id.to_string()); - let url = upload_id_to_image_url(&id, UploadMimeType::ImageJpeg); - assert!(url.contains(raw_id)); - assert!(url.ends_with("/asset.jpg")); - } -} diff --git a/crates/api_clients/worldlabs_consumer_client/src/client/browser_user_agents.rs b/crates/api_clients/worldlabs_consumer_client/src/client/browser_user_agents.rs deleted file mode 100644 index 94f3923b48..0000000000 --- a/crates/api_clients/worldlabs_consumer_client/src/client/browser_user_agents.rs +++ /dev/null @@ -1,10 +0,0 @@ - -/// Firefox 139 (2025) on macOS, which matches wreq's Emulation::Firefox139 -pub const FIREFOX_139_MAC_USER_AGENT : &str = - "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:139.0) Gecko/20100101 Firefox/139.0"; - -pub const FIREFOX_143_MAC_USER_AGENT : &str = - "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:143.0) Gecko/20100101 Firefox/143.0"; - -pub const FIREFOX_144_MAC_USER_AGENT_UNSUPPORTED_TLS_FINGERPRINTING : &str = - "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:144.0) Gecko/20100101 Firefox/144.0"; diff --git a/crates/api_clients/worldlabs_consumer_client/src/client/mod.rs b/crates/api_clients/worldlabs_consumer_client/src/client/mod.rs deleted file mode 100644 index 82c176fa31..0000000000 --- a/crates/api_clients/worldlabs_consumer_client/src/client/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod browser_user_agents; \ No newline at end of file diff --git a/crates/api_clients/worldlabs_consumer_client/src/credentials/jwt_claims.rs b/crates/api_clients/worldlabs_consumer_client/src/credentials/jwt_claims.rs deleted file mode 100644 index aa15ba35c2..0000000000 --- a/crates/api_clients/worldlabs_consumer_client/src/credentials/jwt_claims.rs +++ /dev/null @@ -1,101 +0,0 @@ -use base64::Engine; -use chrono::{DateTime, Utc}; -use jwt_light::common_claims::CommonClaims; -use jwt_light::error::JwtError; -use jwt_light::parse_jwt_claims_trait::ParseJwtClaims; -use serde_json::{Map, Value}; - - -#[derive(Clone, Debug)] -pub struct JwtClaims { - /// From the "iat" field - pub created: DateTime, - - /// From the "exp" field - pub expiration: DateTime, - - /// From the "user_id" field - pub user_id: Option, - - /// From the "email" field - pub email: Option, -} - -impl ParseJwtClaims for JwtClaims { - fn extract_claims(common_claims: CommonClaims, extra_claims: Map) -> Result { - let user_id = extra_claims.get("user_id") - .map(|val| val.as_str()) - .flatten() - .map(|val| val.to_string()); - - let mut email = extra_claims.get("email") - .map(|val| val.as_str()) - .flatten() - .map(|val| val.to_string()); - - if email.is_none() { - // Parse out email from this field: - // "firebase": { - // "identities": { - // "email": [ - // "sabalid234@crsay.com" - // ] - // }, - // }, - email = extra_claims.get("firebase") - .and_then(|val| val.as_object()) - .and_then(|fb| fb.get("identities")) - .and_then(|val| val.as_object()) - .and_then(|id| id.get("email")) - .and_then(|emails| emails.as_array()) - .and_then(|emails| emails.get(0)) - .and_then(|email| email.as_str()) - .map(|email| email.to_string()); - } - - Ok(Self { - created: common_claims.created, - expiration: common_claims.expiration, - user_id, - email, - }) - } -} - -#[cfg(test)] -mod tests { - use crate::credentials::jwt_claims::JwtClaims; - use jwt_light::parse_jwt_claims_trait::ParseJwtClaims; - - #[test] - fn test_token() { - /* - { - "iss": "https://securetoken.google.com/wlt-training-gsc", - "aud": "wlt-training-gsc", - "auth_time": 1766002923, - "user_id": "CArJJ2PQFFd8l2Rf8uptZhl86d33", - "sub": "CArJJ2PQFFd8l2Rf8uptZhl86d33", - "iat": 1766099113, - "exp": 1766102713, - "email": "sabalid234@crsay.com", - "email_verified": true, - "firebase": { - "identities": { - "email": [ - "sabalid234@crsay.com" - ] - }, - "sign_in_provider": "password" - } - } - */ - let jwt = "eyJhbGciOiJSUzI1NiIsImtpZCI6IjM4MTFiMDdmMjhiODQxZjRiNDllNDgyNTg1ZmQ2NmQ1NWUzOGRiNWQiLCJ0eXAiOiJKV1QifQ.eyJpc3MiOiJodHRwczovL3NlY3VyZXRva2VuLmdvb2dsZS5jb20vd2x0LXRyYWluaW5nLWdzYyIsImF1ZCI6IndsdC10cmFpbmluZy1nc2MiLCJhdXRoX3RpbWUiOjE3NjYwMDI5MjMsInVzZXJfaWQiOiJDQXJKSjJQUUZGZDhsMlJmOHVwdFpobDg2ZDMzIiwic3ViIjoiQ0FySkoyUFFGRmQ4bDJSZjh1cHRaaGw4NmQzMyIsImlhdCI6MTc2NjA5OTExMywiZXhwIjoxNzY2MTAyNzEzLCJlbWFpbCI6InNhYmFsaWQyMzRAY3JzYXkuY29tIiwiZW1haWxfdmVyaWZpZWQiOnRydWUsImZpcmViYXNlIjp7ImlkZW50aXRpZXMiOnsiZW1haWwiOlsic2FiYWxpZDIzNEBjcnNheS5jb20iXX0sInNpZ25faW5fcHJvdmlkZXIiOiJwYXNzd29yZCJ9fQ.byDW2QiRfajxDgQMD89YNdlRxO5rsHves3nwK_Ry5ZLFThARbdU9-wTgbCz1mzz9P3amUkM_XM9E4rEAnj2u-kCv5iW_FIfRDeJ0Z8FlwqxCt6ekvJgwYE80BUIedEvTiNpP_AilThz1ILqAu3gVQ2GXUcolquvS9i12iGTl-thJH6gnZgv3UdP2Vrr5ZP9VhKgMi5gQER5umFQ4Ud64kD9P9SLttRI2RJdolavJengQBAfec8hOEk6uikw20rEBeT_xzl8TpLNG6i4SIGYqJQHfRALGNniYoU9RlIoFR9VGeyk_6BFFGRd8I_EgL-fxnfmpV8w-riXHlOUg6uNRgw"; - let claims = JwtClaims::parse_claims(jwt).unwrap(); - - assert_eq!(claims.user_id, Some("CArJJ2PQFFd8l2Rf8uptZhl86d33".to_string())); - assert_eq!(claims.email, Some("sabalid234@crsay.com".to_string())); - assert_eq!(claims.created.timestamp(), 1766099113); - assert_eq!(claims.expiration.timestamp(), 1766102713); - } -} diff --git a/crates/api_clients/worldlabs_consumer_client/src/credentials/mod.rs b/crates/api_clients/worldlabs_consumer_client/src/credentials/mod.rs deleted file mode 100644 index f752f37ea7..0000000000 --- a/crates/api_clients/worldlabs_consumer_client/src/credentials/mod.rs +++ /dev/null @@ -1,4 +0,0 @@ -pub mod world_labs_bearer_token; -pub mod world_labs_cookies; -pub mod worldlabs_refresh_token; -pub mod jwt_claims; diff --git a/crates/api_clients/worldlabs_consumer_client/src/credentials/world_labs_bearer_token.rs b/crates/api_clients/worldlabs_consumer_client/src/credentials/world_labs_bearer_token.rs deleted file mode 100644 index 779b3968f0..0000000000 --- a/crates/api_clients/worldlabs_consumer_client/src/credentials/world_labs_bearer_token.rs +++ /dev/null @@ -1,69 +0,0 @@ -use crate::credentials::jwt_claims::JwtClaims; -use crate::error::world_labs_client_error::WorldLabsClientError; -use crate::error::world_labs_error::WorldLabsError; -use jwt_light::parse_jwt_claims_trait::ParseJwtClaims; -use log::error; - -/* - -This is issued by Google, even for email+password login: - - https://identitytoolkit.googleapis.com/v1/accounts:signInWithPassword?key={ENTROPY} - -Value: - -{ - "kind": "identitytoolkit#VerifyPasswordResponse", - "localId": "{{WorldLabsUserId}}", - "email": "{{email@whatever.com}}", - "displayName": "", - "idToken": "{{BEARER_TOKEN}}", - "registered": true, - "refreshToken": "{{REFRESH_TOKEN}}", - "expiresIn": "3600" -} - -*/ - -#[derive(Clone)] -pub struct WorldLabsBearerToken { - /// The bearer token - /// Without "Authorization:" header name and without "Bearer(space)" prefix. - bearer_token: String, -} - -impl WorldLabsBearerToken { - pub fn new(mut bearer_token: String) -> Self { - if bearer_token.starts_with("Bearer") { - bearer_token = bearer_token - .trim_start_matches("Bearer") - .trim() - .to_string(); - } - Self { bearer_token } - } - - pub fn as_raw_str(&self) -> &str { - &self.bearer_token - } - - pub fn as_raw_bytes(&self) -> &[u8] { - self.bearer_token.as_bytes() - } - - pub fn to_raw_string(&self) -> String { - self.bearer_token.clone() - } - - pub fn to_bearer_token_header_string(&self) -> String { - format!("Bearer {}", self.bearer_token) - } - - pub fn parse_jwt_claims(&self) -> Result { - JwtClaims::parse_claims(&self.bearer_token) - .map_err(|err| { - error!("Failed to parse bearer token into JWT claims: {}", err); - WorldLabsError::Client(WorldLabsClientError::FailedToParseJwtClaims(err)) - }) - } -} diff --git a/crates/api_clients/worldlabs_consumer_client/src/credentials/world_labs_cookies.rs b/crates/api_clients/worldlabs_consumer_client/src/credentials/world_labs_cookies.rs deleted file mode 100644 index f953c47dde..0000000000 --- a/crates/api_clients/worldlabs_consumer_client/src/credentials/world_labs_cookies.rs +++ /dev/null @@ -1,24 +0,0 @@ - -#[derive(Clone)] -pub struct WorldLabsCookies { - /// The entire cookies header (for now) - cookies: String, -} - -impl WorldLabsCookies { - pub fn new(cookies: String) -> Self { - Self { cookies } - } - - pub fn as_str(&self) -> &str { - &self.cookies - } - - pub fn as_bytes(&self) -> &[u8] { - self.cookies.as_bytes() - } - - pub fn to_string(&self) -> String { - self.cookies.clone() - } -} diff --git a/crates/api_clients/worldlabs_consumer_client/src/credentials/worldlabs_refresh_token.rs b/crates/api_clients/worldlabs_consumer_client/src/credentials/worldlabs_refresh_token.rs deleted file mode 100644 index 5e305ec425..0000000000 --- a/crates/api_clients/worldlabs_consumer_client/src/credentials/worldlabs_refresh_token.rs +++ /dev/null @@ -1,25 +0,0 @@ - -#[derive(Clone)] -pub struct WorldLabsRefreshToken { - /// The refresh token - /// Used to get a new bearer token - refresh_token: String, -} - -impl WorldLabsRefreshToken { - pub fn new(refresh_token: String) -> Self { - Self { refresh_token } - } - - pub fn as_raw_str(&self) -> &str { - &self.refresh_token - } - - pub fn as_raw_bytes(&self) -> &[u8] { - self.refresh_token.as_bytes() - } - - pub fn to_raw_string(&self) -> String { - self.refresh_token.clone() - } -} diff --git a/crates/api_clients/worldlabs_consumer_client/src/error/filter_world_labs_http_error.rs b/crates/api_clients/worldlabs_consumer_client/src/error/filter_world_labs_http_error.rs deleted file mode 100644 index 46cc9547cc..0000000000 --- a/crates/api_clients/worldlabs_consumer_client/src/error/filter_world_labs_http_error.rs +++ /dev/null @@ -1,32 +0,0 @@ -use crate::error::world_labs_error::WorldLabsError; -use crate::error::world_labs_generic_api_error::WorldLabsGenericApiError; -use crate::error::world_labs_specific_api_error::WorldLabsSpecificApiError; -use cloudflare_errors::filter_cloudflare_errors::filter_cloudflare_errors; -use wreq::StatusCode; - -/// Detect error HTTP responses and coerce the response as a Rust Error. -pub fn filter_world_labs_http_error(status_code: StatusCode, maybe_body: Option<&str>) -> Result<(), WorldLabsError> { - if status_code.is_success() { - return Ok(()); - } - - /// Early and easy to detect errors. - match status_code { - StatusCode::PAYMENT_REQUIRED => { - // {"detail":"Insufficient credits for product 'Marble 0.1-plus'. Please add credits to your account."} - return Err(WorldLabsSpecificApiError::InsufficientCredits.into()); - }, - _ => {}, // Fall Through. - } - - if let Some(body) = maybe_body { - filter_cloudflare_errors(status_code.as_u16(), body)?; - - return Err(WorldLabsGenericApiError::UncategorizedBadResponseWithStatusAndBody { - status_code, - body: body.to_string(), - }.into()); - } - - Err(WorldLabsGenericApiError::UncategorizedBadResponseWithStatus(status_code).into()) -} diff --git a/crates/api_clients/worldlabs_consumer_client/src/error/mod.rs b/crates/api_clients/worldlabs_consumer_client/src/error/mod.rs deleted file mode 100644 index 015cdc8108..0000000000 --- a/crates/api_clients/worldlabs_consumer_client/src/error/mod.rs +++ /dev/null @@ -1,5 +0,0 @@ -pub mod world_labs_client_error; -pub mod world_labs_error; -pub mod world_labs_generic_api_error; -pub mod world_labs_specific_api_error; -pub (crate) mod filter_world_labs_http_error; \ No newline at end of file diff --git a/crates/api_clients/worldlabs_consumer_client/src/error/world_labs_client_error.rs b/crates/api_clients/worldlabs_consumer_client/src/error/world_labs_client_error.rs deleted file mode 100644 index abcfb7f7af..0000000000 --- a/crates/api_clients/worldlabs_consumer_client/src/error/world_labs_client_error.rs +++ /dev/null @@ -1,158 +0,0 @@ -use base64::DecodeError; -use std::error::Error; -use std::fmt::{Display, Formatter}; - -#[derive(Debug)] -pub enum WorldLabsClientError { - - /// An error was encountered in building the Wreq client - WreqClientError(wreq::Error), - - /// Failed to parse JWT claims. - FailedToParseJwtClaims(jwt_light::error::JwtError), - - /// Error serializing a message to send the websocket - WebsocketRequestSerializationError(serde_json::Error), - - /// Error locking the websocket for sending/receiving - WebsocketLockError, - - /// Error reading from a websocket. - WebsocketReadError(wreq::Error), - - /// Error sending to an open websocket. - WebsocketSendError(wreq::Error), - - /// Can't open a local file for uploading. - CannotOpenLocalFileForUpload(std::io::Error), - - /// Can't read a local file for uploading. - CannotReadLocalFileForUpload(std::io::Error), - - /// Couldn't write to the file - CannotOpenLocalFileForWriting(std::io::Error), - - /// Couldn't write to the file - CannotWriteLocalFile(std::io::Error), - - /// File for upload has an invalid path. - FileForUploadHasInvalidPath, - - /// Error parsing HTML - HtmlParsingError, - - /// Error decoding verification token - FailedToDecodeVerificationToken(DecodeError), - - /// Verification token bytes are invalid - InvalidVerificationTokenBytes, - - /// Our script logic is out of date - ScriptLogicOutOfDate, - - /// Our script logic is out of date (SVG) - ScriptSvgLogicOutOfDate, - - /// Our script logic is out of date (script 1) - Script1LogicOutOfDate, - - /// Our script logic is out of date (script 2) - Script2LogicOutOfDate, - - /// Our script logic is out of date (xsid script) - ScriptXsidLogicOutOfDate, - - /// Signature algorithm isn't working with inputs - BadSignatureInputs, - - /// Something is broken with timeout math - TimeoutMathBroken, - - /// Can't make request because cookies aren't present - NoCookiesPresent, - - /// Unknown error generating video - ErrorGeneratingVideo, - -// /// An error reading the file for upload. -// FileForUploadReadError(std::io::Error), -// -// /// The file path provided for upload is invalid. -// FileForUploadHasInvalidPath, -// -// /// Something is wrong with the JWT bearer token. -// /// This error originates on our end as we try to parse the JWT. -// LocalJwtClaimsParseError(String), -// -// /// There was an error constructing the form-multipart request. -// MultipartFormError(wreq::Error), -// -// /// We haven't received a bearer token yet -// /// This is our own internal application state error, not something Sora returns. -// /// We know our client can't make the request, so we preemptively fail it. -// NoBearerTokenForRequest, -// -// /// A sentinel token is not present in the client, which is required for some requests. -// NoSentinelTokenForRequest, -// -// /// Issue with using the SoraCredentialBuilder. -// SoraCredentialBuilderError(&'static str), -// -// /// Error parsing a request URL. -// UrlParseError(url::ParseError), -// -// /// Error serializing the sentinel store token to JSON (typically for persistent storage). -// CouldNotSerializeSentinelTokenStore(serde_json::Error), -// -// /// Error deserializing the sentinel token from JSON (typically for persistent storage). -// CouldNotDeserializeSentinelTokenStore { -// error: serde_json::Error, -// raw_json: String -// }, -} - -impl Error for WorldLabsClientError {} - -impl Display for WorldLabsClientError { - fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { - match self { - Self::WreqClientError(err) => write!(f, "Wreq client error (during client creation): {}", err), - Self::FailedToParseJwtClaims(err) => write!(f, "Failed to parse JWT claims: {}", err), - Self::WebsocketRequestSerializationError(err) => write!(f, "Websocket request serialization error: {}", err), - Self::WebsocketLockError => write!(f, "Websocket lock error"), - Self::WebsocketReadError(err) => write!(f, "Websocket read error: {}", err), - Self::WebsocketSendError(err) => write!(f, "Websocket send error: {}", err), - Self::CannotOpenLocalFileForUpload(err) => write!(f, "Cannot open local file for upload: {}", err), - Self::CannotReadLocalFileForUpload(err) => write!(f, "Cannot read local file for upload: {}", err), - Self::CannotOpenLocalFileForWriting(err) => write!(f, "Cannot open local file for writing: {}", err), - Self::CannotWriteLocalFile(err) => write!(f, "Cannot write local file: {}", err), - Self::FileForUploadHasInvalidPath => write!(f, "File for upload has invalid path"), - Self::HtmlParsingError => write!(f, "Html parsing error"), - Self::FailedToDecodeVerificationToken(err) => write!(f, "Failed to decode verification token: {}", err), - Self::InvalidVerificationTokenBytes => write!(f, "Invalid verification token bytes"), - Self::ScriptLogicOutOfDate => write!(f, "Script logic out of date"), - Self::ScriptSvgLogicOutOfDate => write!(f, "Script logic out of date (SVG parsing)"), - Self::Script1LogicOutOfDate => write!(f, "Script logic out of date (script 1)"), - Self::Script2LogicOutOfDate => write!(f, "Script logic out of date (script 2)"), - Self::ScriptXsidLogicOutOfDate => write!(f, "Script logic out of date (xsid script)"), - Self::BadSignatureInputs => write!(f, "Bad signature inputs"), - Self::TimeoutMathBroken => write!(f, "Timeout math is broken"), - Self::NoCookiesPresent => write!(f, "No cookies present"), - Self::ErrorGeneratingVideo => write!(f, "Error generating video"), - - //Self::FileForUploadReadError(err) => write!(f, "Error reading file for upload: {}", err), - //Self::FileForUploadHasInvalidPath => write!(f, "The file path provided for upload is invalid."), - //Self::LocalJwtClaimsParseError(msg) => write!(f, "Local JWT claims parse error: {}", msg), - //Self::MultipartFormError(err) => write!(f, "Multipart form error: {}", err), - //Self::NoBearerTokenForRequest => write!(f, "No bearer token available. The client needs a bearer token to make the request."), - //Self::NoSentinelTokenForRequest => write!(f, "No sentinel token available. The client needs a sentinel token to make the request."), - //Self::SoraCredentialBuilderError(msg) => write!(f, "Sora Credential Builder error: {}", msg), - //Self::UrlParseError(err) => write!(f, "URL parse error: {}", err), - //Self::CouldNotSerializeSentinelToken(err) => write!(f, "Could not serialize sentinel token to JSON: {}", err), - //Self::CouldNotSerializeSentinelTokenStore(err) => write!(f, "Could not serialize sentinel token store to JSON: {}", err), - //Self::CouldNotDeserializeSentinelTokenStore { error, raw_json} => { - // write!(f, "Could not deserialize sentinel token store from JSON: {:?}, raw JSON: {}", error, raw_json) - //}, - } - } -} diff --git a/crates/api_clients/worldlabs_consumer_client/src/error/world_labs_error.rs b/crates/api_clients/worldlabs_consumer_client/src/error/world_labs_error.rs deleted file mode 100644 index 813240b08f..0000000000 --- a/crates/api_clients/worldlabs_consumer_client/src/error/world_labs_error.rs +++ /dev/null @@ -1,59 +0,0 @@ -use crate::error::world_labs_client_error::WorldLabsClientError; -use crate::error::world_labs_generic_api_error::WorldLabsGenericApiError; -use crate::error::world_labs_specific_api_error::WorldLabsSpecificApiError; -use cloudflare_errors::cloudflare_error::CloudflareError; -use std::error::Error; - -#[derive(Debug)] -pub enum WorldLabsError { - Client(WorldLabsClientError), - ApiSpecific(WorldLabsSpecificApiError), - ApiGeneric(WorldLabsGenericApiError), -} - -impl WorldLabsError { - pub fn is_world_labs_having_downtime_issues(&self) -> bool { - match self { - Self::ApiGeneric(WorldLabsGenericApiError::CloudflareError(CloudflareError::BadGateway502)) => true, - Self::ApiGeneric(WorldLabsGenericApiError::CloudflareError(CloudflareError::GatewayTimeout504)) => true, - Self::ApiGeneric(WorldLabsGenericApiError::CloudflareError(CloudflareError::TimeoutOccurred524)) => true, - _ => false, - } - } -} - -impl Error for WorldLabsError {} - -impl std::fmt::Display for WorldLabsError { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - Self::Client(e) => write!(f, "WorldLabsClientError: {:?}", e), - Self::ApiSpecific(e) => write!(f, "WorldLabsSpecificApiError: {:?}", e), - Self::ApiGeneric(e) => write!(f, "WorldLabsGenericApiError: {:?}", e), - } - } -} - -impl From for WorldLabsError { - fn from(error: WorldLabsClientError) -> Self { - Self::Client(error) - } -} - -impl From for WorldLabsError { - fn from(error: WorldLabsSpecificApiError) -> Self { - Self::ApiSpecific(error) - } -} - -impl From for WorldLabsError { - fn from(error: WorldLabsGenericApiError) -> Self { - Self::ApiGeneric(error) - } -} - -impl From for WorldLabsError { - fn from(error: CloudflareError) -> Self { - Self::ApiGeneric(WorldLabsGenericApiError::CloudflareError(error)) - } -} diff --git a/crates/api_clients/worldlabs_consumer_client/src/error/world_labs_generic_api_error.rs b/crates/api_clients/worldlabs_consumer_client/src/error/world_labs_generic_api_error.rs deleted file mode 100644 index b3c6f2f8ed..0000000000 --- a/crates/api_clients/worldlabs_consumer_client/src/error/world_labs_generic_api_error.rs +++ /dev/null @@ -1,89 +0,0 @@ -use cloudflare_errors::cloudflare_error::CloudflareError; -use std::error::Error; -use std::fmt::{Display, Formatter}; -use wreq::StatusCode; - -#[derive(Debug)] -pub enum WorldLabsGenericApiError { - /// Unknown error occurred when uploading to Google GCP - GoogleUploadFailed { - status_code: StatusCode, - body: String, - }, - - /// Specific Cloudflare errors. - CloudflareError(CloudflareError), - - /// The downloaded index.html did not include the expected data. - /// This is necessary for handshakes between client and server. - IndexHtmlDidNotIncludeExpectedData { - message: String, - }, - - /// The downloaded javascript did not include the expected data. - /// This is necessary for handshakes between client and server. - ScriptBodyDidNotIncludeExpectedData { - message: String, - }, - - /// Error creating the websocket due to 401 Unauthorized, likely an authentication error with Grok. - /// Unfortunately we can't read the response body text to diagnose more because wreq has some API design issues. - LikelyWebsocketAuthentication401, - - /// We received a 403 on websocket upgrade, likely from Cloudflare. - /// Unfortunately we can't read the response body text to diagnose more because wreq has some API design issues. - LikelyWebsocketCloudflare403, - - /// Unknown status code on websocket upgrade. - UnexpectedWebsocketUpgradeStatusCode(StatusCode), - - /// serde_json::Error, likely from JSON deserialization schema mismatch. - /// Includes the original body. - SerdeResponseParseErrorWithBody(serde_json::Error, String), - - /// serde_json::Error, likely from JSON deserialization schema mismatch. - /// Includes the original body. - /// Specifically, this is for non-200 (error) responses. - SerdeParseErrorWithBodyOnNon200(serde_json::Error, String), - - /// An uncategorized bad HTTP response from Grok. - UncategorizedBadResponseWithStatus(StatusCode), - - /// An uncategorized bad HTTP response from Grok. - UncategorizedBadResponseWithStatusAndBody { - status_code: StatusCode, - body: String, - }, - - /// Our previous upload failed - UploadFailed, - - /// An error upgrading the connection to a websocket. - WreqWebsocketUpgradeError(wreq::Error), - - /// An uncaught error from the API client. - WreqError(wreq::Error), -} - -impl Error for WorldLabsGenericApiError {} - -impl Display for WorldLabsGenericApiError { - fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { - match self { - Self::GoogleUploadFailed { status_code, body } => write!(f, "Google world upload failed with HTTP {}: {:?}", status_code, body), - Self::CloudflareError(err) => write!(f, "Cloudflare error: {}", err), - Self::IndexHtmlDidNotIncludeExpectedData { message } => write!(f, "IndexHtmlDidNotIncludeExpectedData ( message: {} )", message), - Self::ScriptBodyDidNotIncludeExpectedData { message } => write!(f, "ScriptBodyDidNotIncludeExpectedData ( message: {} )", message), - Self::LikelyWebsocketAuthentication401 => write!(f, "Likely websocket authentication 401 error (probably Grok authentication issue with cookies)"), - Self::LikelyWebsocketCloudflare403 => write!(f, "Likely Cloudflare 403 error on websocket upgrade"), - Self::UnexpectedWebsocketUpgradeStatusCode(status) => write!(f, "Unexpected websocket upgrade status code: {}", status), - Self::SerdeResponseParseErrorWithBody(err, body) => write!(f, "Failed to parse response body: {:?}. Body: {}", err, body), - Self::SerdeParseErrorWithBodyOnNon200(err, body) => write!(f, "Failed to parse non-200 response body: {:?}. Body: {}", err, body), - Self::UncategorizedBadResponseWithStatus(status) => write!(f, "Uncategorized with status code: {}", status), - Self::UncategorizedBadResponseWithStatusAndBody { status_code, body } => write!(f, "Uncategorized bad response: status code {}, body: {}", status_code, body), - Self::UploadFailed => write!(f, "Upload failed"), - Self::WreqWebsocketUpgradeError(err) => write!(f, "Websocket upgrade error: {}", err), - Self::WreqError(err) => write!(f, "Wreq client error: {}", err), - } - } -} diff --git a/crates/api_clients/worldlabs_consumer_client/src/error/world_labs_specific_api_error.rs b/crates/api_clients/worldlabs_consumer_client/src/error/world_labs_specific_api_error.rs deleted file mode 100644 index aba508705e..0000000000 --- a/crates/api_clients/worldlabs_consumer_client/src/error/world_labs_specific_api_error.rs +++ /dev/null @@ -1,89 +0,0 @@ -use std::error::Error; -use std::fmt::{Display, Formatter}; - -#[derive(Debug)] -pub enum WorldLabsSpecificApiError { - /// If the API drops run ids (unlikely) - NoRunIdInResponse { response_body: String }, - - /// The Google GCP upload failed because the signature does not match - GoogleUploadSignatureDoesNotMatch, - - /// Grok is detecting and blocking our bot, likely due to new secrets use. - AutomationBlocked, - - /// Too many videos are being generated. - TooManyVideos, - - /// There aren't sufficient funds for generation. - InsufficientCredits, - -// /// Failed to generate a bearer token despite the `200 OK` response. -// /// This has been generated by sending old/expired session cookies or empty cookies. -// FailedToGenerateBearerToken, -// -// /// The endpoint told us we used an invalid JWT. -// InvalidJwt, -// -// /// Sora has responded with "sentinel block". -// /// This usually means we need to refresh our sentinel token. -// SentinelBlockError, -// -// /// Sora requires users to set up an account username before they can generate images. -// /// This requires the user to set up that username. -// SoraUsernameNotYetCreated, -// -// /// Sora has responded with "token expired". -// /// This (probably?) means we need to refresh our JWT bearer token. -// TokenExpiredError, -// -// /// We're sending too many tasks to Sora. -// /// Sora is telling us to cool it. -// TooManyConcurrentTasks, -// -// // TODO: Try to make concrete error types for these distinct cases. -// /// Unauthorized, cookie and/or bearer token expired. We'll need to ask for a refreshed login. -// /// -// /// Example message, e.g. from the upload endpoint: -// /// { -// /// "error": { -// /// "message": "Your authentication token has expired. Please try signing in again.", -// /// "type": "invalid_request_error", -// /// "param": null, -// /// "code": "token_expired" -// /// } -// /// } -// UnauthorizedCookieOrBearerExpired, -// -// /// The Sora sentinel token response is missing fields -// SentinelResponseIsMissingFields { -// missing_token: bool, -// missing_turnstile: bool, -// raw_response: String, -// }, -} - -impl Error for WorldLabsSpecificApiError {} - -impl Display for WorldLabsSpecificApiError { - fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { - match self { - Self::NoRunIdInResponse { response_body } => write!(f, "no run.id found in response: {}", response_body), - Self::GoogleUploadSignatureDoesNotMatch => write!(f, "Google upload signature does not match"), - Self::AutomationBlocked => write!(f, "Automation blocked"), - Self::TooManyVideos => write!(f, "Too many videos are being generated"), - Self::InsufficientCredits => write!(f, "Insufficient credits"), - - //Self::FailedToGenerateBearerToken => write!(f, "Failed to generate bearer token. Probably invalid or expired session cookies."), - //Self::InvalidJwt => write!(f, "Invalid JWT token. Please refresh the token."), - //Self::SentinelBlockError => write!(f, "Request blocked by Sentinel Token Block. Please refresh the sentinel token."), - //Self::SoraUsernameNotYetCreated => write!(f, "Sora username not yet created. Please create a username in the Sora app or website."), - //Self::TokenExpiredError => write!(f, "JWT token has expired. Please refresh the token."), - //Self::TooManyConcurrentTasks => write!(f, "Too many concurrent tasks. Please wait."), - //Self::UnauthorizedCookieOrBearerExpired => write!(f, "Unauthorized: cookie and/or bearer token expired"), - //Self::SentinelResponseIsMissingFields { missing_token: token_missing, missing_turnstile: turnstile_missing, raw_response } => { - // write!(f, "Sentinel response is missing fields. token_missing: {}, turnstile_missing: {}. Raw response: {}", token_missing, turnstile_missing, raw_response) - //}, - } - } -} diff --git a/crates/api_clients/worldlabs_consumer_client/src/lib.rs b/crates/api_clients/worldlabs_consumer_client/src/lib.rs deleted file mode 100644 index dda4bd6712..0000000000 --- a/crates/api_clients/worldlabs_consumer_client/src/lib.rs +++ /dev/null @@ -1,9 +0,0 @@ - -#[cfg(test)] -pub (crate) mod test_utils; - -pub mod api; -pub mod client; -pub mod credentials; -pub mod error; -pub mod recipes; diff --git a/crates/api_clients/worldlabs_consumer_client/src/recipes/mod.rs b/crates/api_clients/worldlabs_consumer_client/src/recipes/mod.rs deleted file mode 100644 index d17ac4bb12..0000000000 --- a/crates/api_clients/worldlabs_consumer_client/src/recipes/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod upload_image_and_create_world_with_retry; \ No newline at end of file diff --git a/crates/api_clients/worldlabs_consumer_client/src/recipes/upload_image_and_create_world_with_retry.rs b/crates/api_clients/worldlabs_consumer_client/src/recipes/upload_image_and_create_world_with_retry.rs deleted file mode 100644 index b841da4f95..0000000000 --- a/crates/api_clients/worldlabs_consumer_client/src/recipes/upload_image_and_create_world_with_retry.rs +++ /dev/null @@ -1,346 +0,0 @@ -use crate::api::api_types::image_input_object_id::ImageInputObjectId; -use crate::api::api_types::meta_world_object_id::MetaWorldObjectId; -use crate::api::api_types::pano_object_id::PanoObjectId; -use crate::api::api_types::run_object_id::RunObjectId; -use crate::api::api_types::upload_mime_type::UploadMimeType; -use crate::api::api_types::world_id::WorldObjectId; -use crate::api::requests::google_refresh_token::google_refresh_token::{google_refresh_token, GoogleRefreshTokenArgs}; -use crate::api::requests::google_upload::google_upload_image::{google_upload_image, GoogleUploadImageArgs}; -use crate::api::requests::objects::begin_object_image_upload::{begin_object_image_upload, BeginObjectImageUploadArgs}; -use crate::api::requests::objects::create_run_object::{create_run_object, CreateRunObjectArgs}; -use crate::api::requests::objects::create_upload_object::{create_upload_object, CreateUploadObjectArgs}; -use crate::api::requests::objects::finalize_object_image_upload::{finalize_object_image_upload, FinalizeObjectImageUploadArgs}; -use crate::api::requests::objects::update_run_object_with_upload::{update_run_object_with_upload, UpdateRunObjectWithUploadArgs, UpdateRunObjectWithUploadPayloadArgs}; -use crate::api::requests::objects::update_run_object_with_world::{update_run_object_with_world, UpdateRunObjectWithWorldArgs, UpdateRunObjectWithWorldPayloadArgs}; -use crate::api::requests::recaption::recaption_image::{recaption_image, RecaptionImageArgs}; -use crate::api::requests::worlds::create_world::{create_world, CreateWorldArgs}; -use crate::credentials::world_labs_bearer_token::WorldLabsBearerToken; -use crate::credentials::world_labs_cookies::WorldLabsCookies; -use crate::credentials::worldlabs_refresh_token::WorldLabsRefreshToken; -use crate::error::world_labs_client_error::WorldLabsClientError; -use crate::error::world_labs_error::WorldLabsError; -use crate::error::world_labs_generic_api_error::WorldLabsGenericApiError; -use anyhow::bail; -use chrono::{TimeDelta, Utc}; -use filesys::file_read_bytes::file_read_bytes; -use log::{error, info, warn}; -use serde::Deserialize; -use std::path::PathBuf; -use std::time::Duration; -use uuid::Uuid; - -pub struct UploadImageAndCreateWorldWithRetryArgs<'a> { - pub file: FileBytesOrPath, - pub cookies: &'a WorldLabsCookies, - pub bearer_token: &'a WorldLabsBearerToken, - pub refresh_token: &'a WorldLabsRefreshToken, - pub individual_request_timeout: Option, -} - -pub enum FileBytesOrPath { - Bytes(Vec), - Path(PathBuf), -} - -pub struct UploadImageAndCreateWorldWithRetryResponse { - pub run_id: RunObjectId, - pub world_id: WorldObjectId, - pub image_upload_url: String, - - /// If the tokens were renewed, this is them. - pub maybe_new_access_tokens: Option, -} - -pub struct NewAccessTokens { - pub bearer_token: WorldLabsBearerToken, - pub refresh_token: WorldLabsRefreshToken, -} - -/// Marble Image-to-World -/// Mark the upload as complete. -/// Request #5 (of ~10) -pub async fn upload_image_and_create_world_with_retry(args: UploadImageAndCreateWorldWithRetryArgs<'_>) -> Result { - - info!("Checking to see if bearer token needs refresh (fails open) ..."); - - let mut maybe_refresh_bearer = false; - - match args.bearer_token.parse_jwt_claims() { - Err(err) => { - warn!("Failed to parse bearer_token jwt claims (failing open) : {}", err); - } - Ok(jwt) => { - let now = Utc::now(); - if now > jwt.expiration { - info!("Bearer is expired."); - maybe_refresh_bearer = true; - } - - let sooner_expiry = jwt.expiration - .checked_sub_signed(TimeDelta::minutes(30)) - .unwrap_or(jwt.expiration); - - if now > sooner_expiry { - info!("Bearer will expire soon, so we're renewing it in advance."); - maybe_refresh_bearer = true; - } - } - }; - - let mut maybe_new_access_tokens = None; - - if maybe_refresh_bearer { - info!("Refreshing bearer token..."); - - let updated = google_refresh_token(GoogleRefreshTokenArgs { - refresh_token: &args.refresh_token, - request_timeout: args.individual_request_timeout, - }).await?; - - info!("Bearer token refreshed!"); - - maybe_new_access_tokens = Some(NewAccessTokens { - bearer_token: updated.bearer_token, - refresh_token: updated.refresh_token, - }); - } - - let use_bearer_token = maybe_new_access_tokens - .as_ref() - .map(|tokens| &tokens.bearer_token) - .unwrap_or_else(|| args.bearer_token); - - info!("Checking file input..."); - - let file_bytes = match args.file { - FileBytesOrPath::Bytes(bytes) => { - info!("File bytes provided"); - bytes - } - FileBytesOrPath::Path(path) => { - info!("File path provided"); - match file_read_bytes(&path) { - Ok(bytes) => bytes, - Err(err) => { - error!("Error reading file bytes from path: {:?} - error: {:?}", path, err); - return Err(WorldLabsClientError::CannotReadLocalFileForUpload(err).into()); - } - } - } - }; - - info!("Request #1 of 10: create run object ..."); - - let response = create_run_object(CreateRunObjectArgs { - cookies: args.cookies, - bearer_token: use_bearer_token, - request_timeout: args.individual_request_timeout, - }).await?; - - let run_object_id = response.id; - let run_object = response.run_object; - - info!("Object id: {}", run_object_id.0); - - // TODO - multiple types. - let upload_mime_type= UploadMimeType::ImageJpeg; - - info!("Request #2 of 10: begin image attachment ..."); - - let response = create_upload_object(CreateUploadObjectArgs { - cookies: &args.cookies, - bearer_token: &use_bearer_token, - upload_mime_type, - request_timeout: args.individual_request_timeout, - }).await?; - - let upload_id = response.id; - - info!("Upload id: {}", upload_id.0); - - info!("Request #3 of 10: begin image upload ..."); - - let response = begin_object_image_upload(BeginObjectImageUploadArgs { - cookies: &args.cookies, - bearer_token: &use_bearer_token, - upload_mime_type, - request_timeout: args.individual_request_timeout, - upload_id: &upload_id, - }).await?; - - let google_upload_url = response.upload_url; - - info!("Request #4 of 10: upload to Google GCP ..."); - - info!("Google upload URL: {:?}", &google_upload_url); - - let _response = google_upload_image(GoogleUploadImageArgs { - upload_url: &google_upload_url, - upload_mime_type, - file_bytes, - request_timeout: args.individual_request_timeout, - }).await?; - - info!("Request #5 of 10: finalize object upload ..."); - - let response = finalize_object_image_upload(FinalizeObjectImageUploadArgs { - cookies: &args.cookies, - bearer_token: &use_bearer_token, - upload_id: &upload_id, - request_timeout: args.individual_request_timeout, - }).await?; - - let image_url = response.object_url; - - info!("Object/image URL: {image_url}"); - - info!("Request #6 of 10: Patch run with new info (first time) ..."); - - let image_input_id = ImageInputObjectId::generate_new(); - let pano_id = PanoObjectId::generate_new(); - let meta_world_id = MetaWorldObjectId::generate_new(); - - let response = update_run_object_with_upload(UpdateRunObjectWithUploadArgs { - cookies: &args.cookies, - bearer_token: &use_bearer_token, - payload_args: UpdateRunObjectWithUploadPayloadArgs { - run_id: &run_object_id, - run_created_at_timestamp: run_object.metadata.created_at, - image_upload_url: &image_url, - image_input_id: &image_input_id, - pano_id: &pano_id, - meta_world_id: &meta_world_id, - }, - request_timeout: args.individual_request_timeout, - }).await?; - - let run_first_updated_at = response.run_updated_timestamp; - - info!("Request #7 of 10: captioning with VLM ..."); - - let response = recaption_image(RecaptionImageArgs { - cookies: &args.cookies, - bearer_token: &use_bearer_token, - upload_id: &upload_id, - upload_mime_type, - run_id: &run_object_id, - request_timeout: args.individual_request_timeout, - }).await?; - - info!("Title: {}", response.title); - info!("Caption: {}", response.caption); - - let title = response.title; - let text_prompt = response.caption; - - info!("Request #8 of 10: create world ..."); - - let response = create_world(CreateWorldArgs { - cookies: &args.cookies, - bearer_token: &use_bearer_token, - text_prompt: &text_prompt, - image_upload_url: &image_url, - request_timeout: args.individual_request_timeout, - }).await?; - - let world_id = response.world_id; - - info!("World ID: {}", &world_id.0); - - info!("Request #9 of 10: patch run with new info (second time) ..."); - - let response = update_run_object_with_world(UpdateRunObjectWithWorldArgs { - cookies: &args.cookies, - bearer_token: &use_bearer_token, - payload_args: UpdateRunObjectWithWorldPayloadArgs { - run_id: &run_object_id, - run_created_at_timestamp: run_object.metadata.created_at, - first_patch_timestamp: run_first_updated_at, - image_upload_url: &image_url, - image_input_id: &image_input_id, - pano_id: &pano_id, - meta_world_id: &meta_world_id, - world_id: &world_id, - title: &title, - text_prompt: &text_prompt, - }, - request_timeout: args.individual_request_timeout, - }).await?; - - Ok(UploadImageAndCreateWorldWithRetryResponse { - run_id: run_object_id, - image_upload_url: image_url, - world_id, - maybe_new_access_tokens, - }) -} - -#[cfg(test)] -mod tests { - use crate::recipes::upload_image_and_create_world_with_retry::{upload_image_and_create_world_with_retry, FileBytesOrPath, UploadImageAndCreateWorldWithRetryArgs}; - use crate::test_utils::get_test_bearer_token::get_test_bearer_token; - use crate::test_utils::get_test_cookies::get_typed_test_cookies; - use crate::test_utils::get_test_refresh_token::get_typed_test_refresh_token; - use crate::test_utils::setup_test_logging::setup_test_logging; - use filesys::file_read_bytes::file_read_bytes; - use log::LevelFilter; - - #[tokio::test] - #[ignore] // Client side tests only - async fn test_requests() { - setup_test_logging(LevelFilter::Debug); - - let cookies = get_typed_test_cookies().unwrap(); - let bearer_token = get_test_bearer_token().unwrap(); - let refresh_token = get_typed_test_refresh_token().unwrap(); - - //let file_path = "/home/bt/Pictures/locations/island.jpg"; - let file_path = "/Users/bt/Pictures/Midjourney/jeep.jpeg"; - let file_bytes = file_read_bytes(file_path).unwrap(); - - println!("File bytes len: {}", file_bytes.len()); - - let results = upload_image_and_create_world_with_retry(UploadImageAndCreateWorldWithRetryArgs { - cookies: &cookies, - bearer_token: &bearer_token, - refresh_token: &refresh_token, - individual_request_timeout: None, - file: FileBytesOrPath::Bytes(file_bytes), - }).await.unwrap(); - - println!("Object ID: {}", results.run_id.0); - println!("World ID: {}", results.world_id.0); - println!("Upload URL: {}", results.image_upload_url); - println!("Has new access tokens: {}", results.maybe_new_access_tokens.is_some()); - - assert_eq!(1, 2); - } - - - #[tokio::test] - #[ignore] // Client side tests only - async fn test_requests_2() { - setup_test_logging(LevelFilter::Debug); - - let cookies = get_typed_test_cookies().unwrap(); - let bearer_token = get_test_bearer_token().unwrap(); - let refresh_token = get_typed_test_refresh_token().unwrap(); - - //let file_path = "/home/bt/Pictures/locations/island.jpg"; - let file_path = "/Users/bt/Pictures/Midjourney/train_ghibli.jpeg"; - let file_bytes = file_read_bytes(file_path).unwrap(); - - println!("File bytes len: {}", file_bytes.len()); - - let results = upload_image_and_create_world_with_retry(UploadImageAndCreateWorldWithRetryArgs { - cookies: &cookies, - bearer_token: &bearer_token, - refresh_token: &refresh_token, - individual_request_timeout: None, - file: FileBytesOrPath::Bytes(file_bytes), - }).await.unwrap(); - - println!("Upload URL: {}", results.image_upload_url); - println!("Object ID: {}", results.run_id.0); - } -} diff --git a/crates/api_clients/worldlabs_consumer_client/src/test_utils/get_test_bearer_token.rs b/crates/api_clients/worldlabs_consumer_client/src/test_utils/get_test_bearer_token.rs deleted file mode 100644 index 93aabc641e..0000000000 --- a/crates/api_clients/worldlabs_consumer_client/src/test_utils/get_test_bearer_token.rs +++ /dev/null @@ -1,17 +0,0 @@ -use crate::credentials::world_labs_bearer_token::WorldLabsBearerToken; -use errors::AnyhowResult; -use std::fs::read_to_string; - -#[cfg(test)] -pub (crate) fn get_test_bearer_token_raw() -> AnyhowResult { - let cookies = read_to_string("/Users/bt/Artcraft/credentials/worldlabs_bearer.txt")?; - //let cookies = read_to_string("/home/bt/Artcraft/credentials/world_labs_bearer.txt")?; - let cookies = cookies.trim().to_string(); - Ok(cookies) -} - -#[cfg(test)] -pub (crate) fn get_test_bearer_token() -> AnyhowResult { - let cookies = get_test_bearer_token_raw()?; - Ok(WorldLabsBearerToken::new(cookies)) -} diff --git a/crates/api_clients/worldlabs_consumer_client/src/test_utils/get_test_cookies.rs b/crates/api_clients/worldlabs_consumer_client/src/test_utils/get_test_cookies.rs deleted file mode 100644 index 3fd53c1a9c..0000000000 --- a/crates/api_clients/worldlabs_consumer_client/src/test_utils/get_test_cookies.rs +++ /dev/null @@ -1,17 +0,0 @@ -use crate::credentials::world_labs_cookies::WorldLabsCookies; -use errors::AnyhowResult; -use std::fs::read_to_string; - -#[cfg(test)] -pub (crate) fn get_test_cookies() -> AnyhowResult { - //let cookies = read_to_string("/home/bt/Artcraft/credentials/worldlabs_cookies.txt")?; - let cookies = read_to_string("/Users/bt/Artcraft/credentials/worldlabs_cookies.txt")?; - let cookies = cookies.trim().to_string(); - Ok(cookies) -} - -#[cfg(test)] -pub (crate) fn get_typed_test_cookies() -> AnyhowResult { - let cookies = get_test_cookies()?; - Ok(WorldLabsCookies::new(cookies)) -} diff --git a/crates/api_clients/worldlabs_consumer_client/src/test_utils/get_test_refresh_token.rs b/crates/api_clients/worldlabs_consumer_client/src/test_utils/get_test_refresh_token.rs deleted file mode 100644 index 385a868a17..0000000000 --- a/crates/api_clients/worldlabs_consumer_client/src/test_utils/get_test_refresh_token.rs +++ /dev/null @@ -1,17 +0,0 @@ -use crate::credentials::worldlabs_refresh_token::WorldLabsRefreshToken; -use errors::AnyhowResult; -use std::fs::read_to_string; - -#[cfg(test)] -pub (crate) fn get_test_refresh_token() -> AnyhowResult { - //let cookies = read_to_string("/home/bt/Artcraft/credentials/worldlabs_cookies.txt")?; - let token = read_to_string("/Users/bt/Artcraft/credentials/worldlabs_refresh.txt")?; - let token = token.trim().to_string(); - Ok(token) -} - -#[cfg(test)] -pub (crate) fn get_typed_test_refresh_token() -> AnyhowResult { - let token = get_test_refresh_token()?; - Ok(WorldLabsRefreshToken::new(token)) -} diff --git a/crates/api_clients/worldlabs_consumer_client/src/test_utils/mod.rs b/crates/api_clients/worldlabs_consumer_client/src/test_utils/mod.rs deleted file mode 100644 index ef9d0b8e3c..0000000000 --- a/crates/api_clients/worldlabs_consumer_client/src/test_utils/mod.rs +++ /dev/null @@ -1,4 +0,0 @@ -pub mod get_test_cookies; -pub mod get_test_bearer_token; -pub mod setup_test_logging; -pub mod get_test_refresh_token; \ No newline at end of file diff --git a/crates/api_clients/worldlabs_consumer_client/src/test_utils/setup_test_logging.rs b/crates/api_clients/worldlabs_consumer_client/src/test_utils/setup_test_logging.rs deleted file mode 100644 index 9438da106c..0000000000 --- a/crates/api_clients/worldlabs_consumer_client/src/test_utils/setup_test_logging.rs +++ /dev/null @@ -1,52 +0,0 @@ -use chrono::Local; -use env_logger::Builder; -use log::{debug, error, info, trace, warn, LevelFilter}; -use std::io::Write; - -const RUST_LOG : &str = "RUST_LOG"; - -pub fn setup_test_logging(level: LevelFilter) { - let level_str = get_level_str(level); - - println!("Previous log level: {:?}", env::var(RUST_LOG)); - - let is_unsafe = env::set_var(RUST_LOG, level_str); - - if is_unsafe.is_none() { - println!("Unsafely setting Rust Log Level..."); - unsafe { std::env::set_var(RUST_LOG, level_str) } - } - - println!("Log level: {:?}", env::var(RUST_LOG)); - - Builder::new() - .is_test(true) - .format(|buf, record| { - writeln!(buf, - "{} [{}] - {}", - Local::now().format("%H:%M:%S%.6f"), - record.level(), - record.args() - ) - }) - .filter(None, level) - .filter_level(level) - .init(); - - trace!("Test trace log"); - debug!("Test debug log"); - info!("Test info log"); - warn!("Test warn log"); - error!("Test error log"); -} - -fn get_level_str(level: LevelFilter) -> &'static str { - match level { - LevelFilter::Error => "error", - LevelFilter::Warn => "warn", - LevelFilter::Info => "info", - LevelFilter::Debug => "debug", - LevelFilter::Trace => "trace", - LevelFilter::Off => "off", - } -} diff --git a/crates/desktop/artcraft/.gitignore b/crates/desktop/artcraft/.gitignore deleted file mode 100644 index 502406b4ed..0000000000 --- a/crates/desktop/artcraft/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -# Generated by Cargo -# will have compiled files and executables -/target/ -/gen/schemas diff --git a/crates/desktop/artcraft/.taurignore b/crates/desktop/artcraft/.taurignore deleted file mode 100644 index ad17b2ca1c..0000000000 --- a/crates/desktop/artcraft/.taurignore +++ /dev/null @@ -1,4 +0,0 @@ -# Don't restart the dev server on Rust changes -crates/ -Cargo.toml -Cargo.lock \ No newline at end of file diff --git a/crates/desktop/artcraft/Cargo.toml b/crates/desktop/artcraft/Cargo.toml deleted file mode 100644 index 8206b71dff..0000000000 --- a/crates/desktop/artcraft/Cargo.toml +++ /dev/null @@ -1,102 +0,0 @@ -[package] -name = "artcraft" -version = "0.0.1" -description = "Artcraft" -authors = ["you"] -license = "" -repository = "" -edition = "2021" -rust-version = "1.77.2" -publish = false - -# [lints.rust] -# unused_imports = "forbid" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[lib] -name = "artcraft_app_lib" -crate-type = ["staticlib", "cdylib", "rlib"] - -[build-dependencies] -tauri-build = { version = "2.6.2", features = [] } - -[dependencies] -# Workspace hack (faster compile times) -workspace-build-acceleration.workspace = true - -# Internal -artcraft_api_defs.workspace = true -artcraft_client.workspace = true -artcraft_router.workspace = true -build_metadata.workspace = true -cookie_store.workspace = true -enums.workspace = true -errors.workspace = true -fal_client.workspace = true -filesys.workspace = true -grok_consumer_client.workspace = true -uuid_utils.workspace = true -images.workspace = true -memory_store.workspace = true -midjourney_client.workspace = true -mimetypes.workspace = true -openai_sora_client.workspace = true -primitives.workspace = true -sqlite_tasks.workspace = true -tokens.workspace = true -url_utils.workspace = true -web_base64.workspace = true -worldlabs_consumer_client.workspace = true - -# External -anyhow.workspace = true -base64.workspace = true -bytes = "1.10.1" -chrono.workspace = true -directories = "6.0.0" -dirs = "6.0.0" -discord-rich-presence = "1.1.0" -futures = "0.3" -image = "0.25.5" -indexmap.workspace = true -log.workspace = true -once_cell.workspace = true -os_info = { version = "3.12.0", default-features = false } -rand.workspace = true -reqwest = { workspace = true, features = ["multipart", "stream"], default-features = false } # NB(bt,2025-03-10): default-features = false on Windows while I debug openssl / rustls -serde.workspace = true -serde_derive.workspace = true -serde_json.workspace = true -tauri-plugin-dialog.workspace = true -tauri-plugin-log.workspace = true -tauri-plugin-upload.workspace = true -tauri.workspace = true -tempdir.workspace = true -tempfile.workspace = true -tokio = { version = "1.42", features = ["rt", "rt-multi-thread", "fs"] } -tokio-util.workspace = true -url.workspace = true - -# NB: We need to vendor this in so that we can access the cookies inside via the private API -tauri-plugin-http = { path = "../../vendor/tauri-plugin-http" } -tauri-plugin-opener = "2" - -# # Transparent title bar on MacOS -# # NB: See the notes here: -# # https://v2.tauri.app/learn/window-customization/ -# [target."cfg(target_os = \"macos\")".dependencies] -# cocoa = "0.26" - -[dev-dependencies] -serial_test = "3.2.0" - -[profile.dev] -incremental = true # Compile your binary in smaller steps. - -[profile.release] -codegen-units = 1 # Allows LLVM to perform better optimization. -lto = true # Enables link-time-optimizations. -opt-level = 3 # `s` prioritizes small binary size. Use `3` if you prefer speed. -panic = "abort" # Higher performance by disabling panic handlers. -strip = true # Ensures debug symbols are removed. diff --git a/crates/desktop/artcraft/build.rs b/crates/desktop/artcraft/build.rs deleted file mode 100644 index 795b9b7c83..0000000000 --- a/crates/desktop/artcraft/build.rs +++ /dev/null @@ -1,3 +0,0 @@ -fn main() { - tauri_build::build() -} diff --git a/crates/desktop/artcraft/capabilities/default.json b/crates/desktop/artcraft/capabilities/default.json deleted file mode 100644 index 9e286eff53..0000000000 --- a/crates/desktop/artcraft/capabilities/default.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "$schema": "../gen/schemas/desktop-schema.json", - "identifier": "default", - "description": "enables the default permissions", - "windows": [ - "main" - ], - "permissions": [ - "core:default", - "core:window:allow-close", - "core:window:allow-minimize", - "core:window:allow-start-dragging", - "core:window:allow-set-focus", - "core:window:allow-toggle-maximize", - "core:window:default", - "dialog:default", - "http:allow-fetch", - "log:default", - "upload:allow-download", - "upload:default", - { - "identifier": "http:default", - "allow": [ - { - "url": "https://*" - }, - { - "url": "http://localhost:12345" - } - ] - }, - "opener:default" - ] -} \ No newline at end of file diff --git a/crates/desktop/artcraft/icons/128x128.png b/crates/desktop/artcraft/icons/128x128.png deleted file mode 100644 index baeb9c0671..0000000000 Binary files a/crates/desktop/artcraft/icons/128x128.png and /dev/null differ diff --git a/crates/desktop/artcraft/icons/128x128@2x.png b/crates/desktop/artcraft/icons/128x128@2x.png deleted file mode 100644 index 97cfd0b250..0000000000 Binary files a/crates/desktop/artcraft/icons/128x128@2x.png and /dev/null differ diff --git a/crates/desktop/artcraft/icons/32x32.png b/crates/desktop/artcraft/icons/32x32.png deleted file mode 100644 index e7db6b6d84..0000000000 Binary files a/crates/desktop/artcraft/icons/32x32.png and /dev/null differ diff --git a/crates/desktop/artcraft/icons/64x64.png b/crates/desktop/artcraft/icons/64x64.png deleted file mode 100644 index 2bfadfe089..0000000000 Binary files a/crates/desktop/artcraft/icons/64x64.png and /dev/null differ diff --git a/crates/desktop/artcraft/icons/Square107x107Logo.png b/crates/desktop/artcraft/icons/Square107x107Logo.png deleted file mode 100644 index 35a253d410..0000000000 Binary files a/crates/desktop/artcraft/icons/Square107x107Logo.png and /dev/null differ diff --git a/crates/desktop/artcraft/icons/Square142x142Logo.png b/crates/desktop/artcraft/icons/Square142x142Logo.png deleted file mode 100644 index caaadd7bc9..0000000000 Binary files a/crates/desktop/artcraft/icons/Square142x142Logo.png and /dev/null differ diff --git a/crates/desktop/artcraft/icons/Square150x150Logo.png b/crates/desktop/artcraft/icons/Square150x150Logo.png deleted file mode 100644 index be7aa118d1..0000000000 Binary files a/crates/desktop/artcraft/icons/Square150x150Logo.png and /dev/null differ diff --git a/crates/desktop/artcraft/icons/Square284x284Logo.png b/crates/desktop/artcraft/icons/Square284x284Logo.png deleted file mode 100644 index b6ba3c2565..0000000000 Binary files a/crates/desktop/artcraft/icons/Square284x284Logo.png and /dev/null differ diff --git a/crates/desktop/artcraft/icons/Square30x30Logo.png b/crates/desktop/artcraft/icons/Square30x30Logo.png deleted file mode 100644 index bf7894738c..0000000000 Binary files a/crates/desktop/artcraft/icons/Square30x30Logo.png and /dev/null differ diff --git a/crates/desktop/artcraft/icons/Square310x310Logo.png b/crates/desktop/artcraft/icons/Square310x310Logo.png deleted file mode 100644 index c9378aeb4e..0000000000 Binary files a/crates/desktop/artcraft/icons/Square310x310Logo.png and /dev/null differ diff --git a/crates/desktop/artcraft/icons/Square44x44Logo.png b/crates/desktop/artcraft/icons/Square44x44Logo.png deleted file mode 100644 index b43d72fc7a..0000000000 Binary files a/crates/desktop/artcraft/icons/Square44x44Logo.png and /dev/null differ diff --git a/crates/desktop/artcraft/icons/Square71x71Logo.png b/crates/desktop/artcraft/icons/Square71x71Logo.png deleted file mode 100644 index 694d402abf..0000000000 Binary files a/crates/desktop/artcraft/icons/Square71x71Logo.png and /dev/null differ diff --git a/crates/desktop/artcraft/icons/Square89x89Logo.png b/crates/desktop/artcraft/icons/Square89x89Logo.png deleted file mode 100644 index cb81901862..0000000000 Binary files a/crates/desktop/artcraft/icons/Square89x89Logo.png and /dev/null differ diff --git a/crates/desktop/artcraft/icons/StoreLogo.png b/crates/desktop/artcraft/icons/StoreLogo.png deleted file mode 100644 index 971214c0b8..0000000000 Binary files a/crates/desktop/artcraft/icons/StoreLogo.png and /dev/null differ diff --git a/crates/desktop/artcraft/icons/android/mipmap-hdpi/ic_launcher.png b/crates/desktop/artcraft/icons/android/mipmap-hdpi/ic_launcher.png deleted file mode 100644 index a8f4606494..0000000000 Binary files a/crates/desktop/artcraft/icons/android/mipmap-hdpi/ic_launcher.png and /dev/null differ diff --git a/crates/desktop/artcraft/icons/android/mipmap-hdpi/ic_launcher_foreground.png b/crates/desktop/artcraft/icons/android/mipmap-hdpi/ic_launcher_foreground.png deleted file mode 100644 index 856fc5bdc6..0000000000 Binary files a/crates/desktop/artcraft/icons/android/mipmap-hdpi/ic_launcher_foreground.png and /dev/null differ diff --git a/crates/desktop/artcraft/icons/android/mipmap-hdpi/ic_launcher_round.png b/crates/desktop/artcraft/icons/android/mipmap-hdpi/ic_launcher_round.png deleted file mode 100644 index a8f4606494..0000000000 Binary files a/crates/desktop/artcraft/icons/android/mipmap-hdpi/ic_launcher_round.png and /dev/null differ diff --git a/crates/desktop/artcraft/icons/android/mipmap-mdpi/ic_launcher.png b/crates/desktop/artcraft/icons/android/mipmap-mdpi/ic_launcher.png deleted file mode 100644 index 2194742ee6..0000000000 Binary files a/crates/desktop/artcraft/icons/android/mipmap-mdpi/ic_launcher.png and /dev/null differ diff --git a/crates/desktop/artcraft/icons/android/mipmap-mdpi/ic_launcher_foreground.png b/crates/desktop/artcraft/icons/android/mipmap-mdpi/ic_launcher_foreground.png deleted file mode 100644 index 701f818ed8..0000000000 Binary files a/crates/desktop/artcraft/icons/android/mipmap-mdpi/ic_launcher_foreground.png and /dev/null differ diff --git a/crates/desktop/artcraft/icons/android/mipmap-mdpi/ic_launcher_round.png b/crates/desktop/artcraft/icons/android/mipmap-mdpi/ic_launcher_round.png deleted file mode 100644 index 2194742ee6..0000000000 Binary files a/crates/desktop/artcraft/icons/android/mipmap-mdpi/ic_launcher_round.png and /dev/null differ diff --git a/crates/desktop/artcraft/icons/android/mipmap-xhdpi/ic_launcher.png b/crates/desktop/artcraft/icons/android/mipmap-xhdpi/ic_launcher.png deleted file mode 100644 index b180db6303..0000000000 Binary files a/crates/desktop/artcraft/icons/android/mipmap-xhdpi/ic_launcher.png and /dev/null differ diff --git a/crates/desktop/artcraft/icons/android/mipmap-xhdpi/ic_launcher_foreground.png b/crates/desktop/artcraft/icons/android/mipmap-xhdpi/ic_launcher_foreground.png deleted file mode 100644 index 3cd93c4331..0000000000 Binary files a/crates/desktop/artcraft/icons/android/mipmap-xhdpi/ic_launcher_foreground.png and /dev/null differ diff --git a/crates/desktop/artcraft/icons/android/mipmap-xhdpi/ic_launcher_round.png b/crates/desktop/artcraft/icons/android/mipmap-xhdpi/ic_launcher_round.png deleted file mode 100644 index b180db6303..0000000000 Binary files a/crates/desktop/artcraft/icons/android/mipmap-xhdpi/ic_launcher_round.png and /dev/null differ diff --git a/crates/desktop/artcraft/icons/android/mipmap-xxhdpi/ic_launcher.png b/crates/desktop/artcraft/icons/android/mipmap-xxhdpi/ic_launcher.png deleted file mode 100644 index f09690f5c4..0000000000 Binary files a/crates/desktop/artcraft/icons/android/mipmap-xxhdpi/ic_launcher.png and /dev/null differ diff --git a/crates/desktop/artcraft/icons/android/mipmap-xxhdpi/ic_launcher_foreground.png b/crates/desktop/artcraft/icons/android/mipmap-xxhdpi/ic_launcher_foreground.png deleted file mode 100644 index 25d51ed4eb..0000000000 Binary files a/crates/desktop/artcraft/icons/android/mipmap-xxhdpi/ic_launcher_foreground.png and /dev/null differ diff --git a/crates/desktop/artcraft/icons/android/mipmap-xxhdpi/ic_launcher_round.png b/crates/desktop/artcraft/icons/android/mipmap-xxhdpi/ic_launcher_round.png deleted file mode 100644 index f09690f5c4..0000000000 Binary files a/crates/desktop/artcraft/icons/android/mipmap-xxhdpi/ic_launcher_round.png and /dev/null differ diff --git a/crates/desktop/artcraft/icons/android/mipmap-xxxhdpi/ic_launcher.png b/crates/desktop/artcraft/icons/android/mipmap-xxxhdpi/ic_launcher.png deleted file mode 100644 index eb4454e694..0000000000 Binary files a/crates/desktop/artcraft/icons/android/mipmap-xxxhdpi/ic_launcher.png and /dev/null differ diff --git a/crates/desktop/artcraft/icons/android/mipmap-xxxhdpi/ic_launcher_foreground.png b/crates/desktop/artcraft/icons/android/mipmap-xxxhdpi/ic_launcher_foreground.png deleted file mode 100644 index 963b1e48ee..0000000000 Binary files a/crates/desktop/artcraft/icons/android/mipmap-xxxhdpi/ic_launcher_foreground.png and /dev/null differ diff --git a/crates/desktop/artcraft/icons/android/mipmap-xxxhdpi/ic_launcher_round.png b/crates/desktop/artcraft/icons/android/mipmap-xxxhdpi/ic_launcher_round.png deleted file mode 100644 index eb4454e694..0000000000 Binary files a/crates/desktop/artcraft/icons/android/mipmap-xxxhdpi/ic_launcher_round.png and /dev/null differ diff --git a/crates/desktop/artcraft/icons/icon.icns b/crates/desktop/artcraft/icons/icon.icns deleted file mode 100644 index 1e11c08e89..0000000000 Binary files a/crates/desktop/artcraft/icons/icon.icns and /dev/null differ diff --git a/crates/desktop/artcraft/icons/icon.ico b/crates/desktop/artcraft/icons/icon.ico deleted file mode 100644 index b2e7a265e0..0000000000 Binary files a/crates/desktop/artcraft/icons/icon.ico and /dev/null differ diff --git a/crates/desktop/artcraft/icons/icon.png b/crates/desktop/artcraft/icons/icon.png deleted file mode 100644 index ae13d4ce65..0000000000 Binary files a/crates/desktop/artcraft/icons/icon.png and /dev/null differ diff --git a/crates/desktop/artcraft/icons/ios/AppIcon-20x20@1x.png b/crates/desktop/artcraft/icons/ios/AppIcon-20x20@1x.png deleted file mode 100644 index 08d04d792a..0000000000 Binary files a/crates/desktop/artcraft/icons/ios/AppIcon-20x20@1x.png and /dev/null differ diff --git a/crates/desktop/artcraft/icons/ios/AppIcon-20x20@2x-1.png b/crates/desktop/artcraft/icons/ios/AppIcon-20x20@2x-1.png deleted file mode 100644 index 6d4b74f08f..0000000000 Binary files a/crates/desktop/artcraft/icons/ios/AppIcon-20x20@2x-1.png and /dev/null differ diff --git a/crates/desktop/artcraft/icons/ios/AppIcon-20x20@2x.png b/crates/desktop/artcraft/icons/ios/AppIcon-20x20@2x.png deleted file mode 100644 index 6d4b74f08f..0000000000 Binary files a/crates/desktop/artcraft/icons/ios/AppIcon-20x20@2x.png and /dev/null differ diff --git a/crates/desktop/artcraft/icons/ios/AppIcon-20x20@3x.png b/crates/desktop/artcraft/icons/ios/AppIcon-20x20@3x.png deleted file mode 100644 index ef88a39233..0000000000 Binary files a/crates/desktop/artcraft/icons/ios/AppIcon-20x20@3x.png and /dev/null differ diff --git a/crates/desktop/artcraft/icons/ios/AppIcon-29x29@1x.png b/crates/desktop/artcraft/icons/ios/AppIcon-29x29@1x.png deleted file mode 100644 index 880b1300ee..0000000000 Binary files a/crates/desktop/artcraft/icons/ios/AppIcon-29x29@1x.png and /dev/null differ diff --git a/crates/desktop/artcraft/icons/ios/AppIcon-29x29@2x-1.png b/crates/desktop/artcraft/icons/ios/AppIcon-29x29@2x-1.png deleted file mode 100644 index 54d51c2eeb..0000000000 Binary files a/crates/desktop/artcraft/icons/ios/AppIcon-29x29@2x-1.png and /dev/null differ diff --git a/crates/desktop/artcraft/icons/ios/AppIcon-29x29@2x.png b/crates/desktop/artcraft/icons/ios/AppIcon-29x29@2x.png deleted file mode 100644 index 54d51c2eeb..0000000000 Binary files a/crates/desktop/artcraft/icons/ios/AppIcon-29x29@2x.png and /dev/null differ diff --git a/crates/desktop/artcraft/icons/ios/AppIcon-29x29@3x.png b/crates/desktop/artcraft/icons/ios/AppIcon-29x29@3x.png deleted file mode 100644 index 20c73d70f1..0000000000 Binary files a/crates/desktop/artcraft/icons/ios/AppIcon-29x29@3x.png and /dev/null differ diff --git a/crates/desktop/artcraft/icons/ios/AppIcon-40x40@1x.png b/crates/desktop/artcraft/icons/ios/AppIcon-40x40@1x.png deleted file mode 100644 index 6d4b74f08f..0000000000 Binary files a/crates/desktop/artcraft/icons/ios/AppIcon-40x40@1x.png and /dev/null differ diff --git a/crates/desktop/artcraft/icons/ios/AppIcon-40x40@2x-1.png b/crates/desktop/artcraft/icons/ios/AppIcon-40x40@2x-1.png deleted file mode 100644 index 5bd6a225fa..0000000000 Binary files a/crates/desktop/artcraft/icons/ios/AppIcon-40x40@2x-1.png and /dev/null differ diff --git a/crates/desktop/artcraft/icons/ios/AppIcon-40x40@2x.png b/crates/desktop/artcraft/icons/ios/AppIcon-40x40@2x.png deleted file mode 100644 index 5bd6a225fa..0000000000 Binary files a/crates/desktop/artcraft/icons/ios/AppIcon-40x40@2x.png and /dev/null differ diff --git a/crates/desktop/artcraft/icons/ios/AppIcon-40x40@3x.png b/crates/desktop/artcraft/icons/ios/AppIcon-40x40@3x.png deleted file mode 100644 index b90a6e91e0..0000000000 Binary files a/crates/desktop/artcraft/icons/ios/AppIcon-40x40@3x.png and /dev/null differ diff --git a/crates/desktop/artcraft/icons/ios/AppIcon-512@2x.png b/crates/desktop/artcraft/icons/ios/AppIcon-512@2x.png deleted file mode 100644 index 12aed85b0c..0000000000 Binary files a/crates/desktop/artcraft/icons/ios/AppIcon-512@2x.png and /dev/null differ diff --git a/crates/desktop/artcraft/icons/ios/AppIcon-60x60@2x.png b/crates/desktop/artcraft/icons/ios/AppIcon-60x60@2x.png deleted file mode 100644 index b90a6e91e0..0000000000 Binary files a/crates/desktop/artcraft/icons/ios/AppIcon-60x60@2x.png and /dev/null differ diff --git a/crates/desktop/artcraft/icons/ios/AppIcon-60x60@3x.png b/crates/desktop/artcraft/icons/ios/AppIcon-60x60@3x.png deleted file mode 100644 index 3a34b5042d..0000000000 Binary files a/crates/desktop/artcraft/icons/ios/AppIcon-60x60@3x.png and /dev/null differ diff --git a/crates/desktop/artcraft/icons/ios/AppIcon-76x76@1x.png b/crates/desktop/artcraft/icons/ios/AppIcon-76x76@1x.png deleted file mode 100644 index 8bf184ca53..0000000000 Binary files a/crates/desktop/artcraft/icons/ios/AppIcon-76x76@1x.png and /dev/null differ diff --git a/crates/desktop/artcraft/icons/ios/AppIcon-76x76@2x.png b/crates/desktop/artcraft/icons/ios/AppIcon-76x76@2x.png deleted file mode 100644 index 6fd0a546b2..0000000000 Binary files a/crates/desktop/artcraft/icons/ios/AppIcon-76x76@2x.png and /dev/null differ diff --git a/crates/desktop/artcraft/icons/ios/AppIcon-83.5x83.5@2x.png b/crates/desktop/artcraft/icons/ios/AppIcon-83.5x83.5@2x.png deleted file mode 100644 index e4d293c6bc..0000000000 Binary files a/crates/desktop/artcraft/icons/ios/AppIcon-83.5x83.5@2x.png and /dev/null differ diff --git a/crates/desktop/artcraft/src/core/api_adapters/aspect_ratio/common_aspect_ratio.rs b/crates/desktop/artcraft/src/core/api_adapters/aspect_ratio/common_aspect_ratio.rs deleted file mode 100644 index c16d63e159..0000000000 --- a/crates/desktop/artcraft/src/core/api_adapters/aspect_ratio/common_aspect_ratio.rs +++ /dev/null @@ -1,42 +0,0 @@ -use serde_derive::{Deserialize, Serialize}; - -/// This is a comprehensive list of common aspect ratios you can specify when enqueuing a generation. -/// Not every model will support every aspect ratio. -/// In the case a model doesn't support the aspect ratio, gracefully pick the nearest option. -#[derive(Copy, Clone, Debug, Serialize, Deserialize)] -#[serde(rename_all = "snake_case")] -pub enum CommonAspectRatio { - // Auto (eg. for image editing to use the source; used by Nano Banana Pro edit image, but not text-to-image) - Auto, - - // Square - Square, - - // Wide - WideThreeByTwo, - WideFourByThree, - WideFiveByFour, - WideSixteenByNine, - WideTwentyOneByNine, - - // Tall - TallTwoByThree, - TallThreeByFour, - TallFourByFive, - TallNineBySixteen, - TallNineByTwentyOne, - - // Imprecise semantic values that we probably remap to other meanings - // on a model-by-model basis. - Wide, - Tall, - - // Auto values that bake in resolution - // These are from the Seedream models - Auto2k, - Auto4k, - - // Defined aspect ratios that bake in resolution - // These are from the Seedream models - SquareHd, -} diff --git a/crates/desktop/artcraft/src/core/api_adapters/aspect_ratio/convert/aspect_ratio_to_artcraft_flux_1_dev.rs b/crates/desktop/artcraft/src/core/api_adapters/aspect_ratio/convert/aspect_ratio_to_artcraft_flux_1_dev.rs deleted file mode 100644 index 72f785e250..0000000000 --- a/crates/desktop/artcraft/src/core/api_adapters/aspect_ratio/convert/aspect_ratio_to_artcraft_flux_1_dev.rs +++ /dev/null @@ -1,31 +0,0 @@ -use crate::core::api_adapters::aspect_ratio::common_aspect_ratio::CommonAspectRatio; -use artcraft_api_defs::generate::image::text::generate_flux_1_dev_text_to_image::GenerateFlux1DevTextToImageAspectRatio; - -pub fn aspect_ratio_to_artcraft_flux_1_dev(aspect_ratio: CommonAspectRatio) -> GenerateFlux1DevTextToImageAspectRatio { - match aspect_ratio { - // Exact - CommonAspectRatio::Square => GenerateFlux1DevTextToImageAspectRatio::Square, - CommonAspectRatio::SquareHd => GenerateFlux1DevTextToImageAspectRatio::SquareHd, - CommonAspectRatio::WideFourByThree => GenerateFlux1DevTextToImageAspectRatio::LandscapeFourByThree, - CommonAspectRatio::WideSixteenByNine => GenerateFlux1DevTextToImageAspectRatio::LandscapeSixteenByNine, - CommonAspectRatio::TallThreeByFour => GenerateFlux1DevTextToImageAspectRatio::PortraitThreeByFour, - CommonAspectRatio::TallNineBySixteen => GenerateFlux1DevTextToImageAspectRatio::PortraitNineBySixteen, - - // Non-matching aspect ratios, use closest neighbor - CommonAspectRatio::TallFourByFive => GenerateFlux1DevTextToImageAspectRatio::LandscapeFourByThree, - CommonAspectRatio::TallNineByTwentyOne => GenerateFlux1DevTextToImageAspectRatio::PortraitNineBySixteen, - CommonAspectRatio::TallTwoByThree => GenerateFlux1DevTextToImageAspectRatio::PortraitThreeByFour, - CommonAspectRatio::WideFiveByFour => GenerateFlux1DevTextToImageAspectRatio::PortraitThreeByFour, - CommonAspectRatio::WideThreeByTwo => GenerateFlux1DevTextToImageAspectRatio::LandscapeFourByThree, - CommonAspectRatio::WideTwentyOneByNine => GenerateFlux1DevTextToImageAspectRatio::LandscapeSixteenByNine, - - // Special - CommonAspectRatio::Auto - | CommonAspectRatio::Auto2k - | CommonAspectRatio::Auto4k => GenerateFlux1DevTextToImageAspectRatio::Square, - - // Semantic values - CommonAspectRatio::Wide => GenerateFlux1DevTextToImageAspectRatio::LandscapeSixteenByNine, - CommonAspectRatio::Tall => GenerateFlux1DevTextToImageAspectRatio::PortraitNineBySixteen, - } -} diff --git a/crates/desktop/artcraft/src/core/api_adapters/aspect_ratio/convert/aspect_ratio_to_artcraft_flux_1_schnell.rs b/crates/desktop/artcraft/src/core/api_adapters/aspect_ratio/convert/aspect_ratio_to_artcraft_flux_1_schnell.rs deleted file mode 100644 index 1cbe70d0b0..0000000000 --- a/crates/desktop/artcraft/src/core/api_adapters/aspect_ratio/convert/aspect_ratio_to_artcraft_flux_1_schnell.rs +++ /dev/null @@ -1,31 +0,0 @@ -use crate::core::api_adapters::aspect_ratio::common_aspect_ratio::CommonAspectRatio; -use artcraft_api_defs::generate::image::text::generate_flux_1_schnell_text_to_image::GenerateFlux1SchnellTextToImageAspectRatio; - -pub fn aspect_ratio_to_artcraft_flux_1_schnell(aspect_ratio: CommonAspectRatio) -> GenerateFlux1SchnellTextToImageAspectRatio { - match aspect_ratio { - // Exact - CommonAspectRatio::Square => GenerateFlux1SchnellTextToImageAspectRatio::Square, - CommonAspectRatio::SquareHd => GenerateFlux1SchnellTextToImageAspectRatio::SquareHd, - CommonAspectRatio::WideFourByThree => GenerateFlux1SchnellTextToImageAspectRatio::LandscapeFourByThree, - CommonAspectRatio::WideSixteenByNine => GenerateFlux1SchnellTextToImageAspectRatio::LandscapeSixteenByNine, - CommonAspectRatio::TallThreeByFour => GenerateFlux1SchnellTextToImageAspectRatio::PortraitThreeByFour, - CommonAspectRatio::TallNineBySixteen => GenerateFlux1SchnellTextToImageAspectRatio::PortraitNineBySixteen, - - // Non-matching aspect ratios, use closest neighbor - CommonAspectRatio::TallFourByFive => GenerateFlux1SchnellTextToImageAspectRatio::LandscapeFourByThree, - CommonAspectRatio::TallNineByTwentyOne => GenerateFlux1SchnellTextToImageAspectRatio::PortraitNineBySixteen, - CommonAspectRatio::TallTwoByThree => GenerateFlux1SchnellTextToImageAspectRatio::PortraitThreeByFour, - CommonAspectRatio::WideFiveByFour => GenerateFlux1SchnellTextToImageAspectRatio::PortraitThreeByFour, - CommonAspectRatio::WideThreeByTwo => GenerateFlux1SchnellTextToImageAspectRatio::LandscapeFourByThree, - CommonAspectRatio::WideTwentyOneByNine => GenerateFlux1SchnellTextToImageAspectRatio::LandscapeSixteenByNine, - - // Special - CommonAspectRatio::Auto - | CommonAspectRatio::Auto2k - | CommonAspectRatio::Auto4k => GenerateFlux1SchnellTextToImageAspectRatio::Square, - - // Semantic values - CommonAspectRatio::Wide => GenerateFlux1SchnellTextToImageAspectRatio::LandscapeSixteenByNine, - CommonAspectRatio::Tall => GenerateFlux1SchnellTextToImageAspectRatio::PortraitNineBySixteen, - } -} diff --git a/crates/desktop/artcraft/src/core/api_adapters/aspect_ratio/convert/aspect_ratio_to_artcraft_flux_pro_1p1.rs b/crates/desktop/artcraft/src/core/api_adapters/aspect_ratio/convert/aspect_ratio_to_artcraft_flux_pro_1p1.rs deleted file mode 100644 index f0e6babd92..0000000000 --- a/crates/desktop/artcraft/src/core/api_adapters/aspect_ratio/convert/aspect_ratio_to_artcraft_flux_pro_1p1.rs +++ /dev/null @@ -1,33 +0,0 @@ -use crate::core::api_adapters::aspect_ratio::common_aspect_ratio::CommonAspectRatio; -use artcraft_api_defs::generate::image::text::generate_flux_pro_11_text_to_image::GenerateFluxPro11TextToImageAspectRatio; - -pub fn aspect_ratio_to_artcraft_flux_pro_1p1(aspect_ratio: CommonAspectRatio) -> GenerateFluxPro11TextToImageAspectRatio { - match aspect_ratio { - // Exact - CommonAspectRatio::Square => GenerateFluxPro11TextToImageAspectRatio::Square, - CommonAspectRatio::WideFourByThree => GenerateFluxPro11TextToImageAspectRatio::LandscapeFourByThree, - CommonAspectRatio::WideSixteenByNine => GenerateFluxPro11TextToImageAspectRatio::LandscapeSixteenByNine, - CommonAspectRatio::TallThreeByFour => GenerateFluxPro11TextToImageAspectRatio::PortraitThreeByFour, - CommonAspectRatio::TallNineBySixteen => GenerateFluxPro11TextToImageAspectRatio::PortraitNineBySixteen, - - // Non-matching aspect ratios, use closest neighbor - CommonAspectRatio::TallFourByFive => GenerateFluxPro11TextToImageAspectRatio::LandscapeFourByThree, - CommonAspectRatio::TallNineByTwentyOne => GenerateFluxPro11TextToImageAspectRatio::PortraitNineBySixteen, - CommonAspectRatio::TallTwoByThree => GenerateFluxPro11TextToImageAspectRatio::PortraitThreeByFour, - CommonAspectRatio::WideFiveByFour => GenerateFluxPro11TextToImageAspectRatio::PortraitThreeByFour, - CommonAspectRatio::WideThreeByTwo => GenerateFluxPro11TextToImageAspectRatio::LandscapeFourByThree, - CommonAspectRatio::WideTwentyOneByNine => GenerateFluxPro11TextToImageAspectRatio::LandscapeSixteenByNine, - - // Best match - CommonAspectRatio::SquareHd => GenerateFluxPro11TextToImageAspectRatio::Square, - - // Special - CommonAspectRatio::Auto - | CommonAspectRatio::Auto2k - | CommonAspectRatio::Auto4k => GenerateFluxPro11TextToImageAspectRatio::Square, - - // Semantic values - CommonAspectRatio::Wide => GenerateFluxPro11TextToImageAspectRatio::LandscapeSixteenByNine, - CommonAspectRatio::Tall => GenerateFluxPro11TextToImageAspectRatio::PortraitNineBySixteen, - } -} diff --git a/crates/desktop/artcraft/src/core/api_adapters/aspect_ratio/convert/aspect_ratio_to_artcraft_flux_pro_1p1_ultra.rs b/crates/desktop/artcraft/src/core/api_adapters/aspect_ratio/convert/aspect_ratio_to_artcraft_flux_pro_1p1_ultra.rs deleted file mode 100644 index f49a6208e7..0000000000 --- a/crates/desktop/artcraft/src/core/api_adapters/aspect_ratio/convert/aspect_ratio_to_artcraft_flux_pro_1p1_ultra.rs +++ /dev/null @@ -1,33 +0,0 @@ -use crate::core::api_adapters::aspect_ratio::common_aspect_ratio::CommonAspectRatio; -use artcraft_api_defs::generate::image::text::generate_flux_pro_11_ultra_text_to_image::GenerateFluxPro11UltraTextToImageAspectRatio; - -pub fn aspect_ratio_to_artcraft_flux_pro_1p1_ultra(aspect_ratio: CommonAspectRatio) -> GenerateFluxPro11UltraTextToImageAspectRatio { - match aspect_ratio { - // Exact - CommonAspectRatio::Square => GenerateFluxPro11UltraTextToImageAspectRatio::Square, - CommonAspectRatio::WideFourByThree => GenerateFluxPro11UltraTextToImageAspectRatio::LandscapeFourByThree, - CommonAspectRatio::WideThreeByTwo => GenerateFluxPro11UltraTextToImageAspectRatio::LandscapeThreeByTwo, - CommonAspectRatio::WideSixteenByNine => GenerateFluxPro11UltraTextToImageAspectRatio::LandscapeSixteenByNine, - CommonAspectRatio::WideTwentyOneByNine => GenerateFluxPro11UltraTextToImageAspectRatio::LandscapeTwentyOneByNine, - CommonAspectRatio::TallThreeByFour => GenerateFluxPro11UltraTextToImageAspectRatio::PortraitThreeByFour, - CommonAspectRatio::TallTwoByThree => GenerateFluxPro11UltraTextToImageAspectRatio::PortraitTwoByThree, - CommonAspectRatio::TallNineBySixteen => GenerateFluxPro11UltraTextToImageAspectRatio::PortraitNineBySixteen, - CommonAspectRatio::TallNineByTwentyOne => GenerateFluxPro11UltraTextToImageAspectRatio::PortraitNineByTwentyOne, - - // Non-matching aspect ratios, use closest neighbor - CommonAspectRatio::WideFiveByFour => GenerateFluxPro11UltraTextToImageAspectRatio::PortraitThreeByFour, - CommonAspectRatio::TallFourByFive => GenerateFluxPro11UltraTextToImageAspectRatio::LandscapeFourByThree, - - // Best match - CommonAspectRatio::SquareHd => GenerateFluxPro11UltraTextToImageAspectRatio::Square, - - // Special - CommonAspectRatio::Auto - | CommonAspectRatio::Auto2k - | CommonAspectRatio::Auto4k => GenerateFluxPro11UltraTextToImageAspectRatio::Square, - - // Semantic values - CommonAspectRatio::Wide => GenerateFluxPro11UltraTextToImageAspectRatio::LandscapeSixteenByNine, - CommonAspectRatio::Tall => GenerateFluxPro11UltraTextToImageAspectRatio::PortraitNineBySixteen, - } -} diff --git a/crates/desktop/artcraft/src/core/api_adapters/aspect_ratio/convert/aspect_ratio_to_artcraft_gpt_image_1.rs b/crates/desktop/artcraft/src/core/api_adapters/aspect_ratio/convert/aspect_ratio_to_artcraft_gpt_image_1.rs deleted file mode 100644 index 1c1d4954bc..0000000000 --- a/crates/desktop/artcraft/src/core/api_adapters/aspect_ratio/convert/aspect_ratio_to_artcraft_gpt_image_1.rs +++ /dev/null @@ -1,7 +0,0 @@ -use crate::core::api_adapters::aspect_ratio::common_aspect_ratio::CommonAspectRatio; - -pub fn aspect_ratio_to_artcraft_gpt_image_1(aspect_ratio: CommonAspectRatio) -> Option { - // TODO: We still make calls to two distinct endpoints for image-to-image and text-to-image. - // These need to be consolidated to benefit from this approach. - None -} diff --git a/crates/desktop/artcraft/src/core/api_adapters/aspect_ratio/convert/aspect_ratio_to_artcraft_gpt_image_1p5.rs b/crates/desktop/artcraft/src/core/api_adapters/aspect_ratio/convert/aspect_ratio_to_artcraft_gpt_image_1p5.rs deleted file mode 100644 index e6db82431c..0000000000 --- a/crates/desktop/artcraft/src/core/api_adapters/aspect_ratio/convert/aspect_ratio_to_artcraft_gpt_image_1p5.rs +++ /dev/null @@ -1,33 +0,0 @@ -use crate::core::api_adapters::aspect_ratio::common_aspect_ratio::CommonAspectRatio; -use artcraft_api_defs::generate::image::multi_function::gpt_image_1p5_multi_function_image_gen::GptImage1p5MultiFunctionImageGenSize; - -pub fn aspect_ratio_to_artcraft_gpt_image_1p5(aspect_ratio: CommonAspectRatio) -> GptImage1p5MultiFunctionImageGenSize { - match aspect_ratio { - // Exact - CommonAspectRatio::Square => GptImage1p5MultiFunctionImageGenSize::Square, - CommonAspectRatio::Wide => GptImage1p5MultiFunctionImageGenSize::Wide, - CommonAspectRatio::Tall => GptImage1p5MultiFunctionImageGenSize::Tall, - - // Non-matching - CommonAspectRatio::Auto - | CommonAspectRatio::Auto2k - | CommonAspectRatio::Auto4k => GptImage1p5MultiFunctionImageGenSize::Square, - - // Mismatch - square - CommonAspectRatio::SquareHd => GptImage1p5MultiFunctionImageGenSize::Square, - - // Mismatch - wide - CommonAspectRatio::WideThreeByTwo - | CommonAspectRatio::WideFiveByFour - | CommonAspectRatio::WideFourByThree - | CommonAspectRatio::WideSixteenByNine - | CommonAspectRatio::WideTwentyOneByNine => GptImage1p5MultiFunctionImageGenSize::Wide, - - // Mismatch - tall - CommonAspectRatio::TallTwoByThree - | CommonAspectRatio::TallFourByFive - | CommonAspectRatio::TallThreeByFour - | CommonAspectRatio::TallNineBySixteen - | CommonAspectRatio::TallNineByTwentyOne => GptImage1p5MultiFunctionImageGenSize::Tall, - } -} diff --git a/crates/desktop/artcraft/src/core/api_adapters/aspect_ratio/convert/aspect_ratio_to_artcraft_nano_banana.rs b/crates/desktop/artcraft/src/core/api_adapters/aspect_ratio/convert/aspect_ratio_to_artcraft_nano_banana.rs deleted file mode 100644 index d98e910281..0000000000 --- a/crates/desktop/artcraft/src/core/api_adapters/aspect_ratio/convert/aspect_ratio_to_artcraft_nano_banana.rs +++ /dev/null @@ -1,29 +0,0 @@ -use crate::core::api_adapters::aspect_ratio::common_aspect_ratio::CommonAspectRatio; -use artcraft_api_defs::generate::image::multi_function::nano_banana_multi_function_image_gen::NanoBananaMultiFunctionImageGenAspectRatio; - -pub fn aspect_ratio_to_artcraft_nano_banana(aspect_ratio: CommonAspectRatio) -> NanoBananaMultiFunctionImageGenAspectRatio { - match aspect_ratio { - // Exact - CommonAspectRatio::Square => NanoBananaMultiFunctionImageGenAspectRatio::OneByOne, - CommonAspectRatio::WideFiveByFour => NanoBananaMultiFunctionImageGenAspectRatio::FiveByFour, - CommonAspectRatio::WideFourByThree => NanoBananaMultiFunctionImageGenAspectRatio::FourByThree, - CommonAspectRatio::WideThreeByTwo => NanoBananaMultiFunctionImageGenAspectRatio::ThreeByTwo, - CommonAspectRatio::WideSixteenByNine => NanoBananaMultiFunctionImageGenAspectRatio::SixteenByNine, - CommonAspectRatio::WideTwentyOneByNine => NanoBananaMultiFunctionImageGenAspectRatio::TwentyOneByNine, - CommonAspectRatio::TallFourByFive => NanoBananaMultiFunctionImageGenAspectRatio::FourByFive, - CommonAspectRatio::TallThreeByFour => NanoBananaMultiFunctionImageGenAspectRatio::ThreeByFour, - CommonAspectRatio::TallTwoByThree => NanoBananaMultiFunctionImageGenAspectRatio::TwoByThree, - CommonAspectRatio::TallNineBySixteen => NanoBananaMultiFunctionImageGenAspectRatio::NineBySixteen, - // Special - // NB: this is only for image-to-image editing, not text-to-image. - CommonAspectRatio::Auto - | CommonAspectRatio::Auto2k - | CommonAspectRatio::Auto4k => NanoBananaMultiFunctionImageGenAspectRatio::Auto, - // NB: "9:21" value does not exist. Interpolated. - CommonAspectRatio::TallNineByTwentyOne => NanoBananaMultiFunctionImageGenAspectRatio::NineBySixteen, - // Semantic values - CommonAspectRatio::Wide => NanoBananaMultiFunctionImageGenAspectRatio::SixteenByNine, - CommonAspectRatio::Tall => NanoBananaMultiFunctionImageGenAspectRatio::NineBySixteen, - CommonAspectRatio::SquareHd => NanoBananaMultiFunctionImageGenAspectRatio::OneByOne, - } -} diff --git a/crates/desktop/artcraft/src/core/api_adapters/aspect_ratio/convert/aspect_ratio_to_artcraft_nano_banana_pro.rs b/crates/desktop/artcraft/src/core/api_adapters/aspect_ratio/convert/aspect_ratio_to_artcraft_nano_banana_pro.rs deleted file mode 100644 index 3171a8c5c1..0000000000 --- a/crates/desktop/artcraft/src/core/api_adapters/aspect_ratio/convert/aspect_ratio_to_artcraft_nano_banana_pro.rs +++ /dev/null @@ -1,29 +0,0 @@ -use crate::core::api_adapters::aspect_ratio::common_aspect_ratio::CommonAspectRatio; -use artcraft_api_defs::generate::image::multi_function::nano_banana_pro_multi_function_image_gen::NanoBananaProMultiFunctionImageGenAspectRatio; - -pub fn aspect_ratio_to_artcraft_nano_banana_pro(aspect_ratio: CommonAspectRatio) -> NanoBananaProMultiFunctionImageGenAspectRatio { - match aspect_ratio { - // Exact - CommonAspectRatio::Square => NanoBananaProMultiFunctionImageGenAspectRatio::OneByOne, - CommonAspectRatio::WideFiveByFour => NanoBananaProMultiFunctionImageGenAspectRatio::FiveByFour, - CommonAspectRatio::WideFourByThree => NanoBananaProMultiFunctionImageGenAspectRatio::FourByThree, - CommonAspectRatio::WideThreeByTwo => NanoBananaProMultiFunctionImageGenAspectRatio::ThreeByTwo, - CommonAspectRatio::WideSixteenByNine => NanoBananaProMultiFunctionImageGenAspectRatio::SixteenByNine, - CommonAspectRatio::WideTwentyOneByNine => NanoBananaProMultiFunctionImageGenAspectRatio::TwentyOneByNine, - CommonAspectRatio::TallFourByFive => NanoBananaProMultiFunctionImageGenAspectRatio::FourByFive, - CommonAspectRatio::TallThreeByFour => NanoBananaProMultiFunctionImageGenAspectRatio::ThreeByFour, - CommonAspectRatio::TallTwoByThree => NanoBananaProMultiFunctionImageGenAspectRatio::TwoByThree, - CommonAspectRatio::TallNineBySixteen => NanoBananaProMultiFunctionImageGenAspectRatio::NineBySixteen, - // Special - // NB: this is only for image-to-image editing, not text-to-image. - CommonAspectRatio::Auto - | CommonAspectRatio::Auto2k - | CommonAspectRatio::Auto4k => NanoBananaProMultiFunctionImageGenAspectRatio::Auto, - // NB: "9:21" value does not exist. Interpolated. - CommonAspectRatio::TallNineByTwentyOne => NanoBananaProMultiFunctionImageGenAspectRatio::NineBySixteen, - // Semantic values - CommonAspectRatio::Wide => NanoBananaProMultiFunctionImageGenAspectRatio::SixteenByNine, - CommonAspectRatio::Tall => NanoBananaProMultiFunctionImageGenAspectRatio::NineBySixteen, - CommonAspectRatio::SquareHd => NanoBananaProMultiFunctionImageGenAspectRatio::OneByOne, - } -} diff --git a/crates/desktop/artcraft/src/core/api_adapters/aspect_ratio/convert/aspect_ratio_to_artcraft_seedream_4.rs b/crates/desktop/artcraft/src/core/api_adapters/aspect_ratio/convert/aspect_ratio_to_artcraft_seedream_4.rs deleted file mode 100644 index d09fa7f4fb..0000000000 --- a/crates/desktop/artcraft/src/core/api_adapters/aspect_ratio/convert/aspect_ratio_to_artcraft_seedream_4.rs +++ /dev/null @@ -1,29 +0,0 @@ -use crate::core::api_adapters::aspect_ratio::common_aspect_ratio::CommonAspectRatio; -use artcraft_api_defs::generate::image::multi_function::bytedance_seedream_v4_multi_function_image_gen::BytedanceSeedreamV4MultiFunctionImageGenImageSize; - -pub fn aspect_ratio_to_artcraft_seedream_4(aspect_ratio: CommonAspectRatio) -> BytedanceSeedreamV4MultiFunctionImageGenImageSize { - match aspect_ratio { - // Exact - CommonAspectRatio::Auto => BytedanceSeedreamV4MultiFunctionImageGenImageSize::Auto, - CommonAspectRatio::Auto2k => BytedanceSeedreamV4MultiFunctionImageGenImageSize::Auto2k, - CommonAspectRatio::Auto4k => BytedanceSeedreamV4MultiFunctionImageGenImageSize::Auto4k, - CommonAspectRatio::Square => BytedanceSeedreamV4MultiFunctionImageGenImageSize::Square, - CommonAspectRatio::SquareHd => BytedanceSeedreamV4MultiFunctionImageGenImageSize::SquareHd, - CommonAspectRatio::WideFourByThree => BytedanceSeedreamV4MultiFunctionImageGenImageSize::LandscapeFourThree, - CommonAspectRatio::WideSixteenByNine => BytedanceSeedreamV4MultiFunctionImageGenImageSize::LandscapeSixteenNine, - CommonAspectRatio::TallThreeByFour => BytedanceSeedreamV4MultiFunctionImageGenImageSize::PortraitFourThree, - CommonAspectRatio::TallNineBySixteen => BytedanceSeedreamV4MultiFunctionImageGenImageSize::PortraitSixteenNine, - - // Non-matching aspect ratios, use closest neighbor - CommonAspectRatio::WideFiveByFour => BytedanceSeedreamV4MultiFunctionImageGenImageSize::LandscapeFourThree, - CommonAspectRatio::WideThreeByTwo => BytedanceSeedreamV4MultiFunctionImageGenImageSize::LandscapeFourThree, - CommonAspectRatio::WideTwentyOneByNine => BytedanceSeedreamV4MultiFunctionImageGenImageSize::LandscapeSixteenNine, - CommonAspectRatio::TallFourByFive => BytedanceSeedreamV4MultiFunctionImageGenImageSize::PortraitFourThree, - CommonAspectRatio::TallTwoByThree => BytedanceSeedreamV4MultiFunctionImageGenImageSize::PortraitFourThree, - CommonAspectRatio::TallNineByTwentyOne => BytedanceSeedreamV4MultiFunctionImageGenImageSize::PortraitSixteenNine, - - // Semantic values - CommonAspectRatio::Wide => BytedanceSeedreamV4MultiFunctionImageGenImageSize::LandscapeSixteenNine, - CommonAspectRatio::Tall => BytedanceSeedreamV4MultiFunctionImageGenImageSize::PortraitSixteenNine, - } -} diff --git a/crates/desktop/artcraft/src/core/api_adapters/aspect_ratio/convert/aspect_ratio_to_artcraft_seedream_4p5.rs b/crates/desktop/artcraft/src/core/api_adapters/aspect_ratio/convert/aspect_ratio_to_artcraft_seedream_4p5.rs deleted file mode 100644 index 71fae240f7..0000000000 --- a/crates/desktop/artcraft/src/core/api_adapters/aspect_ratio/convert/aspect_ratio_to_artcraft_seedream_4p5.rs +++ /dev/null @@ -1,29 +0,0 @@ -use crate::core::api_adapters::aspect_ratio::common_aspect_ratio::CommonAspectRatio; -use artcraft_api_defs::generate::image::multi_function::bytedance_seedream_v4p5_multi_function_image_gen::BytedanceSeedreamV4p5MultiFunctionImageGenImageSize; - -pub fn aspect_ratio_to_artcraft_seedream_4p5(aspect_ratio: CommonAspectRatio) -> BytedanceSeedreamV4p5MultiFunctionImageGenImageSize { - match aspect_ratio { - // Exact - CommonAspectRatio::Auto2k => BytedanceSeedreamV4p5MultiFunctionImageGenImageSize::Auto2k, - CommonAspectRatio::Auto4k => BytedanceSeedreamV4p5MultiFunctionImageGenImageSize::Auto4k, - CommonAspectRatio::Square => BytedanceSeedreamV4p5MultiFunctionImageGenImageSize::Square, - CommonAspectRatio::SquareHd => BytedanceSeedreamV4p5MultiFunctionImageGenImageSize::SquareHd, - CommonAspectRatio::WideFourByThree => BytedanceSeedreamV4p5MultiFunctionImageGenImageSize::LandscapeFourThree, - CommonAspectRatio::WideSixteenByNine => BytedanceSeedreamV4p5MultiFunctionImageGenImageSize::LandscapeSixteenNine, - CommonAspectRatio::TallThreeByFour => BytedanceSeedreamV4p5MultiFunctionImageGenImageSize::PortraitFourThree, - CommonAspectRatio::TallNineBySixteen => BytedanceSeedreamV4p5MultiFunctionImageGenImageSize::PortraitSixteenNine, - - // Non-matching aspect ratios, use closest neighbor - CommonAspectRatio::Auto => BytedanceSeedreamV4p5MultiFunctionImageGenImageSize::Auto4k, - CommonAspectRatio::WideFiveByFour => BytedanceSeedreamV4p5MultiFunctionImageGenImageSize::LandscapeFourThree, - CommonAspectRatio::WideThreeByTwo => BytedanceSeedreamV4p5MultiFunctionImageGenImageSize::LandscapeFourThree, - CommonAspectRatio::WideTwentyOneByNine => BytedanceSeedreamV4p5MultiFunctionImageGenImageSize::LandscapeSixteenNine, - CommonAspectRatio::TallFourByFive => BytedanceSeedreamV4p5MultiFunctionImageGenImageSize::PortraitFourThree, - CommonAspectRatio::TallTwoByThree => BytedanceSeedreamV4p5MultiFunctionImageGenImageSize::PortraitFourThree, - CommonAspectRatio::TallNineByTwentyOne => BytedanceSeedreamV4p5MultiFunctionImageGenImageSize::PortraitSixteenNine, - - // Semantic values - CommonAspectRatio::Wide => BytedanceSeedreamV4p5MultiFunctionImageGenImageSize::LandscapeSixteenNine, - CommonAspectRatio::Tall => BytedanceSeedreamV4p5MultiFunctionImageGenImageSize::PortraitSixteenNine, - } -} diff --git a/crates/desktop/artcraft/src/core/api_adapters/aspect_ratio/convert/aspect_ratio_to_grok_image.rs b/crates/desktop/artcraft/src/core/api_adapters/aspect_ratio/convert/aspect_ratio_to_grok_image.rs deleted file mode 100644 index 29d361f5a1..0000000000 --- a/crates/desktop/artcraft/src/core/api_adapters/aspect_ratio/convert/aspect_ratio_to_grok_image.rs +++ /dev/null @@ -1,33 +0,0 @@ -use crate::core::api_adapters::aspect_ratio::common_aspect_ratio::CommonAspectRatio; -use grok_consumer_client::requests::image_websocket::messages::websocket_client_message::ClientMessageAspectRatio; - -pub fn aspect_ratio_to_grok_image(aspect_ratio: CommonAspectRatio) -> ClientMessageAspectRatio { - match aspect_ratio { - // Exact - CommonAspectRatio::Square => ClientMessageAspectRatio::Square, - CommonAspectRatio::WideThreeByTwo => ClientMessageAspectRatio::WideThreeByTwo, - CommonAspectRatio::TallTwoByThree => ClientMessageAspectRatio::TallTwoByThree, - - // Close enough - CommonAspectRatio::SquareHd => ClientMessageAspectRatio::Square, - - // Non-matching - CommonAspectRatio::Auto - | CommonAspectRatio::Auto2k - | CommonAspectRatio::Auto4k => ClientMessageAspectRatio::Square, - - // Mismatch - wide - CommonAspectRatio::Wide - | CommonAspectRatio::WideFiveByFour - | CommonAspectRatio::WideFourByThree - | CommonAspectRatio::WideSixteenByNine - | CommonAspectRatio::WideTwentyOneByNine => ClientMessageAspectRatio::WideThreeByTwo, - - // Mismatch - tall - CommonAspectRatio::Tall - | CommonAspectRatio::TallFourByFive - | CommonAspectRatio::TallThreeByFour - | CommonAspectRatio::TallNineBySixteen - | CommonAspectRatio::TallNineByTwentyOne => ClientMessageAspectRatio::TallTwoByThree, - } -} diff --git a/crates/desktop/artcraft/src/core/api_adapters/aspect_ratio/convert/aspect_ratio_to_sora_native_gpt_image_1.rs b/crates/desktop/artcraft/src/core/api_adapters/aspect_ratio/convert/aspect_ratio_to_sora_native_gpt_image_1.rs deleted file mode 100644 index e929776e0d..0000000000 --- a/crates/desktop/artcraft/src/core/api_adapters/aspect_ratio/convert/aspect_ratio_to_sora_native_gpt_image_1.rs +++ /dev/null @@ -1,33 +0,0 @@ -use crate::core::api_adapters::aspect_ratio::common_aspect_ratio::CommonAspectRatio; -use openai_sora_client::requests::image_gen::common::ImageSize; - -pub fn aspect_ratio_to_sora_native_gpt_image_1(aspect_ratio: CommonAspectRatio) -> ImageSize { - match aspect_ratio { - // Exact - CommonAspectRatio::Square => ImageSize::Square, - CommonAspectRatio::Wide => ImageSize::Wide, - CommonAspectRatio::Tall => ImageSize::Tall, - - // Non-matching - CommonAspectRatio::Auto - | CommonAspectRatio::Auto2k - | CommonAspectRatio::Auto4k => ImageSize::Square, - - // Mismatch - square - CommonAspectRatio::SquareHd => ImageSize::Square, - - // Mismatch - wide - CommonAspectRatio::WideThreeByTwo - | CommonAspectRatio::WideFiveByFour - | CommonAspectRatio::WideFourByThree - | CommonAspectRatio::WideSixteenByNine - | CommonAspectRatio::WideTwentyOneByNine => ImageSize::Wide, - - // Mismatch - tall - CommonAspectRatio::TallTwoByThree - | CommonAspectRatio::TallFourByFive - | CommonAspectRatio::TallThreeByFour - | CommonAspectRatio::TallNineBySixteen - | CommonAspectRatio::TallNineByTwentyOne => ImageSize::Tall, - } -} diff --git a/crates/desktop/artcraft/src/core/api_adapters/aspect_ratio/convert/mod.rs b/crates/desktop/artcraft/src/core/api_adapters/aspect_ratio/convert/mod.rs deleted file mode 100644 index 848382b852..0000000000 --- a/crates/desktop/artcraft/src/core/api_adapters/aspect_ratio/convert/mod.rs +++ /dev/null @@ -1,13 +0,0 @@ -pub mod aspect_ratio_to_artcraft_flux_1_dev; -pub mod router_aspect_ratio_to_enums_aspect_ratio; -pub mod aspect_ratio_to_artcraft_flux_1_schnell; -pub mod aspect_ratio_to_artcraft_flux_pro_1p1; -pub mod aspect_ratio_to_artcraft_flux_pro_1p1_ultra; -pub mod aspect_ratio_to_artcraft_gpt_image_1; -pub mod aspect_ratio_to_artcraft_gpt_image_1p5; -pub mod aspect_ratio_to_artcraft_nano_banana; -pub mod aspect_ratio_to_artcraft_nano_banana_pro; -pub mod aspect_ratio_to_artcraft_seedream_4; -pub mod aspect_ratio_to_artcraft_seedream_4p5; -pub mod aspect_ratio_to_grok_image; -pub mod aspect_ratio_to_sora_native_gpt_image_1; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/core/api_adapters/aspect_ratio/convert/router_aspect_ratio_to_enums_aspect_ratio.rs b/crates/desktop/artcraft/src/core/api_adapters/aspect_ratio/convert/router_aspect_ratio_to_enums_aspect_ratio.rs deleted file mode 100644 index 5f72b24b85..0000000000 --- a/crates/desktop/artcraft/src/core/api_adapters/aspect_ratio/convert/router_aspect_ratio_to_enums_aspect_ratio.rs +++ /dev/null @@ -1,26 +0,0 @@ -use artcraft_router::api::router_aspect_ratio::RouterAspectRatio; -use enums::common::generation::common_aspect_ratio::CommonAspectRatio as EnumsCommonAspectRatio; - -/// Map from the router's CommonAspectRatio to the enums crate's CommonAspectRatio. -pub fn router_aspect_ratio_to_enums_aspect_ratio(ratio: RouterAspectRatio) -> EnumsCommonAspectRatio { - match ratio { - RouterAspectRatio::Auto => EnumsCommonAspectRatio::Auto, - RouterAspectRatio::Square => EnumsCommonAspectRatio::Square, - RouterAspectRatio::WideThreeByTwo => EnumsCommonAspectRatio::WideThreeByTwo, - RouterAspectRatio::WideFourByThree => EnumsCommonAspectRatio::WideFourByThree, - RouterAspectRatio::WideFiveByFour => EnumsCommonAspectRatio::WideFiveByFour, - RouterAspectRatio::WideSixteenByNine => EnumsCommonAspectRatio::WideSixteenByNine, - RouterAspectRatio::WideTwentyOneByNine => EnumsCommonAspectRatio::WideTwentyOneByNine, - RouterAspectRatio::TallTwoByThree => EnumsCommonAspectRatio::TallTwoByThree, - RouterAspectRatio::TallThreeByFour => EnumsCommonAspectRatio::TallThreeByFour, - RouterAspectRatio::TallFourByFive => EnumsCommonAspectRatio::TallFourByFive, - RouterAspectRatio::TallNineBySixteen => EnumsCommonAspectRatio::TallNineBySixteen, - RouterAspectRatio::TallNineByTwentyOne => EnumsCommonAspectRatio::TallNineByTwentyOne, - RouterAspectRatio::Wide => EnumsCommonAspectRatio::Wide, - RouterAspectRatio::Tall => EnumsCommonAspectRatio::Tall, - RouterAspectRatio::Auto2k => EnumsCommonAspectRatio::Auto2k, - RouterAspectRatio::Auto3k => EnumsCommonAspectRatio::Auto3k, - RouterAspectRatio::Auto4k => EnumsCommonAspectRatio::Auto4k, - RouterAspectRatio::SquareHd => EnumsCommonAspectRatio::SquareHd, - } -} diff --git a/crates/desktop/artcraft/src/core/api_adapters/aspect_ratio/mod.rs b/crates/desktop/artcraft/src/core/api_adapters/aspect_ratio/mod.rs deleted file mode 100644 index 9dbd41f347..0000000000 --- a/crates/desktop/artcraft/src/core/api_adapters/aspect_ratio/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod common_aspect_ratio; -pub mod convert; diff --git a/crates/desktop/artcraft/src/core/api_adapters/mod.rs b/crates/desktop/artcraft/src/core/api_adapters/mod.rs deleted file mode 100644 index f25f1f213e..0000000000 --- a/crates/desktop/artcraft/src/core/api_adapters/mod.rs +++ /dev/null @@ -1,4 +0,0 @@ -pub mod aspect_ratio; -pub mod models; -pub mod quality; -pub mod resolution; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/core/api_adapters/models/image/mod.rs b/crates/desktop/artcraft/src/core/api_adapters/models/image/mod.rs deleted file mode 100644 index 3d782c1e3c..0000000000 --- a/crates/desktop/artcraft/src/core/api_adapters/models/image/mod.rs +++ /dev/null @@ -1,4 +0,0 @@ -pub mod tauri_image_model_to_common_model_type; -pub mod tauri_image_model_to_enums_model; -pub mod tauri_image_model_to_generation_model; -pub mod tauri_image_model_to_router_model; diff --git a/crates/desktop/artcraft/src/core/api_adapters/models/image/tauri_image_model_to_common_model_type.rs b/crates/desktop/artcraft/src/core/api_adapters/models/image/tauri_image_model_to_common_model_type.rs deleted file mode 100644 index 62578bb348..0000000000 --- a/crates/desktop/artcraft/src/core/api_adapters/models/image/tauri_image_model_to_common_model_type.rs +++ /dev/null @@ -1,36 +0,0 @@ -use enums::common::generation::common_model_type::CommonModelType; - -use crate::core::commands::generate::generate_image::tauri_image_model::TauriImageModel; - -/// Map TauriImageModel to the legacy CommonModelType (enums crate). -pub fn tauri_image_model_to_common_model_type(model: TauriImageModel) -> CommonModelType { - match model { - TauriImageModel::Flux1Dev => CommonModelType::Flux1Dev, - TauriImageModel::Flux1Schnell => CommonModelType::Flux1Schnell, - TauriImageModel::FluxPro11 => CommonModelType::FluxPro11, - TauriImageModel::FluxPro11Ultra => CommonModelType::FluxPro11Ultra, - TauriImageModel::GrokImage => CommonModelType::GrokImage, - TauriImageModel::Recraft3 => CommonModelType::Recraft3, - TauriImageModel::GptImage1 => CommonModelType::GptImage1, - TauriImageModel::GptImage1p5 => CommonModelType::GptImage1p5, - TauriImageModel::GptImage2 => CommonModelType::GptImage2, - TauriImageModel::GptImage2p5Flare => CommonModelType::GptImage2p5Flare, - TauriImageModel::GptImage2p5Sunburst => CommonModelType::GptImage2p5Sunburst, - TauriImageModel::Gemini25Flash => CommonModelType::NanoBanana, - TauriImageModel::NanoBanana => CommonModelType::NanoBanana, - TauriImageModel::NanoBanana2 => CommonModelType::NanoBanana2, - TauriImageModel::NanoBananaPro => CommonModelType::NanoBananaPro, - TauriImageModel::Seedream4 => CommonModelType::Seedream4, - TauriImageModel::Seedream4p5 => CommonModelType::Seedream4p5, - TauriImageModel::Seedream5Lite => CommonModelType::Seedream5Lite, - TauriImageModel::Midjourney => CommonModelType::Midjourney, - TauriImageModel::Midjourney7 => CommonModelType::Midjourney7, - TauriImageModel::Midjourney7Niji => CommonModelType::Midjourney7Niji, - TauriImageModel::Midjourney8 => CommonModelType::Midjourney8, - TauriImageModel::FluxProKontextMax => CommonModelType::FluxProKontextMax, - TauriImageModel::QwenEdit2511Angles => CommonModelType::QwenEdit2511Angles, - TauriImageModel::Flux2LoraAngles => CommonModelType::Flux2LoraAngles, - TauriImageModel::FluxDevJuggernaut => CommonModelType::FluxDevJuggernaut, - TauriImageModel::FluxPro1 => CommonModelType::FluxPro1, - } -} diff --git a/crates/desktop/artcraft/src/core/api_adapters/models/image/tauri_image_model_to_enums_model.rs b/crates/desktop/artcraft/src/core/api_adapters/models/image/tauri_image_model_to_enums_model.rs deleted file mode 100644 index 8e3a3498cd..0000000000 --- a/crates/desktop/artcraft/src/core/api_adapters/models/image/tauri_image_model_to_enums_model.rs +++ /dev/null @@ -1,38 +0,0 @@ -use enums::common::generation::common_image_model::CommonImageModel; - -use crate::core::commands::generate::generate_image::tauri_image_model::TauriImageModel; - -/// Map TauriImageModel to the omni endpoint's CommonImageModel (enums crate). -/// Returns None for models not yet supported by the omni endpoint. -pub fn tauri_image_model_to_enums_model(model: TauriImageModel) -> Option { - match model { - TauriImageModel::Flux1Dev => Some(CommonImageModel::Flux1Dev), - TauriImageModel::Flux1Schnell => Some(CommonImageModel::Flux1Schnell), - TauriImageModel::FluxPro1 => Some(CommonImageModel::FluxPro11), // TODO: Might be a slight mismatch - TauriImageModel::FluxPro11 => Some(CommonImageModel::FluxPro11), - TauriImageModel::FluxPro11Ultra => Some(CommonImageModel::FluxPro11Ultra), - TauriImageModel::GptImage1 => Some(CommonImageModel::GptImage1), - TauriImageModel::GptImage1p5 => Some(CommonImageModel::GptImage1p5), - TauriImageModel::GptImage2 => Some(CommonImageModel::GptImage2), - TauriImageModel::GptImage2p5Flare => Some(CommonImageModel::GptImage2p5Flare), - TauriImageModel::GptImage2p5Sunburst => Some(CommonImageModel::GptImage2p5Sunburst), - TauriImageModel::NanoBanana => Some(CommonImageModel::NanoBanana), - TauriImageModel::NanoBanana2 => Some(CommonImageModel::NanoBanana2), - TauriImageModel::NanoBananaPro => Some(CommonImageModel::NanoBananaPro), - TauriImageModel::Gemini25Flash => Some(CommonImageModel::NanoBanana), - TauriImageModel::Seedream4 => Some(CommonImageModel::Seedream4), - TauriImageModel::Seedream4p5 => Some(CommonImageModel::Seedream4p5), - TauriImageModel::Seedream5Lite => Some(CommonImageModel::Seedream5Lite), - TauriImageModel::QwenEdit2511Angles => Some(CommonImageModel::QwenEdit2511Angles), - TauriImageModel::Flux2LoraAngles => Some(CommonImageModel::Flux2LoraAngles), - TauriImageModel::Midjourney7 => Some(CommonImageModel::Midjourney7), - TauriImageModel::Midjourney7Niji => Some(CommonImageModel::Midjourney7Niji), - TauriImageModel::Midjourney8 => Some(CommonImageModel::Midjourney8), - // Not accounted for yet - TauriImageModel::GrokImage => None, - TauriImageModel::Recraft3 => None, - TauriImageModel::Midjourney => None, // NB: Generic Midjourney is served by the native Midjourney provider. - TauriImageModel::FluxProKontextMax => None, - TauriImageModel::FluxDevJuggernaut => None, - } -} diff --git a/crates/desktop/artcraft/src/core/api_adapters/models/image/tauri_image_model_to_generation_model.rs b/crates/desktop/artcraft/src/core/api_adapters/models/image/tauri_image_model_to_generation_model.rs deleted file mode 100644 index 182e5e8453..0000000000 --- a/crates/desktop/artcraft/src/core/api_adapters/models/image/tauri_image_model_to_generation_model.rs +++ /dev/null @@ -1,35 +0,0 @@ -use crate::core::commands::generate::generate_image::tauri_image_model::TauriImageModel; -use crate::core::events::generation_events::common::GenerationModel; - -/// Map TauriImageModel to GenerationModel for frontend events. -pub fn tauri_image_model_to_generation_model(model: TauriImageModel) -> GenerationModel { - match model { - TauriImageModel::Flux1Dev => GenerationModel::Flux1Dev, - TauriImageModel::Flux1Schnell => GenerationModel::Flux1Schnell, - TauriImageModel::FluxPro11 => GenerationModel::FluxPro11, - TauriImageModel::FluxPro11Ultra => GenerationModel::FluxPro11Ultra, - TauriImageModel::GrokImage => GenerationModel::GrokImage, - TauriImageModel::Recraft3 => GenerationModel::Flux1Dev, // Fallback - TauriImageModel::GptImage1 => GenerationModel::GptImage1, - TauriImageModel::GptImage1p5 => GenerationModel::GptImage1p5, - TauriImageModel::GptImage2 => GenerationModel::GptImage2, - TauriImageModel::GptImage2p5Flare => GenerationModel::GptImage2p5Flare, - TauriImageModel::GptImage2p5Sunburst => GenerationModel::GptImage2p5Sunburst, - TauriImageModel::Gemini25Flash => GenerationModel::NanoBanana, - TauriImageModel::NanoBanana => GenerationModel::NanoBanana, - TauriImageModel::NanoBanana2 => GenerationModel::NanoBanana2, - TauriImageModel::NanoBananaPro => GenerationModel::NanoBananaPro, - TauriImageModel::Seedream4 => GenerationModel::Seedream4, - TauriImageModel::Seedream4p5 => GenerationModel::Seedream4p5, - TauriImageModel::Seedream5Lite => GenerationModel::Seedream5Lite, - TauriImageModel::Midjourney => GenerationModel::Midjourney, - TauriImageModel::Midjourney7 => GenerationModel::Midjourney7, - TauriImageModel::Midjourney7Niji => GenerationModel::Midjourney7Niji, - TauriImageModel::Midjourney8 => GenerationModel::Midjourney8, - TauriImageModel::FluxProKontextMax => GenerationModel::FluxProKontextMax, - TauriImageModel::QwenEdit2511Angles => GenerationModel::QwenEdit2511Angles, - TauriImageModel::Flux2LoraAngles => GenerationModel::Flux2LoraAngles, - TauriImageModel::FluxDevJuggernaut => GenerationModel::FluxDevJuggernaut, - TauriImageModel::FluxPro1 => GenerationModel::FluxPro1, - } -} diff --git a/crates/desktop/artcraft/src/core/api_adapters/models/image/tauri_image_model_to_router_model.rs b/crates/desktop/artcraft/src/core/api_adapters/models/image/tauri_image_model_to_router_model.rs deleted file mode 100644 index a7a5d5184c..0000000000 --- a/crates/desktop/artcraft/src/core/api_adapters/models/image/tauri_image_model_to_router_model.rs +++ /dev/null @@ -1,38 +0,0 @@ -use artcraft_router::api::router_image_model::RouterImageModel; - -use crate::core::commands::generate::generate_image::tauri_image_model::TauriImageModel; - -/// Map TauriImageModel to the artcraft_router's RouterImageModel. -/// Returns None for models not supported by the router (Grok, Midjourney, etc.). -pub fn tauri_image_model_to_router_model(model: TauriImageModel) -> Option { - match model { - TauriImageModel::Flux1Dev => Some(RouterImageModel::Flux1Dev), // Text-to-Image - TauriImageModel::Flux1Schnell => Some(RouterImageModel::Flux1Schnell), // Text-to-Image - TauriImageModel::FluxPro1 => Some(RouterImageModel::FluxPro11), // TODO: Might be a slight mismatch - TauriImageModel::FluxPro11 => Some(RouterImageModel::FluxPro11), // Text-to-Image - TauriImageModel::FluxPro11Ultra => Some(RouterImageModel::FluxPro11Ultra), // Text-to-Image - TauriImageModel::GptImage1 => Some(RouterImageModel::GptImage1), // Text-to-Image - TauriImageModel::GptImage1p5 => Some(RouterImageModel::GptImage1p5), // Text-to-Image - TauriImageModel::GptImage2 => Some(RouterImageModel::GptImage2), // Text-to-Image - TauriImageModel::GptImage2p5Flare => Some(RouterImageModel::GptImage2p5Flare), // Text-to-Image - TauriImageModel::GptImage2p5Sunburst => Some(RouterImageModel::GptImage2p5Sunburst), // Text-to-Image - TauriImageModel::NanoBanana => Some(RouterImageModel::NanoBanana), // Text-to-Image - TauriImageModel::NanoBanana2 => Some(RouterImageModel::NanoBanana2), // Text-to-Image - TauriImageModel::NanoBananaPro => Some(RouterImageModel::NanoBananaPro), // Text-to-Image - TauriImageModel::Gemini25Flash => Some(RouterImageModel::NanoBanana), // Text-to-Image - TauriImageModel::Seedream4 => Some(RouterImageModel::Seedream4), // Text-to-Image - TauriImageModel::Seedream4p5 => Some(RouterImageModel::Seedream4p5), // Text-to-Image - TauriImageModel::Seedream5Lite => Some(RouterImageModel::Seedream5Lite), // Text-to-Image - TauriImageModel::QwenEdit2511Angles => Some(RouterImageModel::QwenEdit2511Angles), - TauriImageModel::Flux2LoraAngles => Some(RouterImageModel::Flux2LoraAngles), - TauriImageModel::Midjourney7 => Some(RouterImageModel::Midjourney7), - TauriImageModel::Midjourney7Niji => Some(RouterImageModel::Midjourney7Niji), - TauriImageModel::Midjourney8 => Some(RouterImageModel::Midjourney8), - // Not accounted for yet - TauriImageModel::GrokImage => None, - TauriImageModel::Recraft3 => None, - TauriImageModel::Midjourney => None, // NB: Generic Midjourney is served by the native Midjourney provider. - TauriImageModel::FluxProKontextMax => None, - TauriImageModel::FluxDevJuggernaut => None, - } -} diff --git a/crates/desktop/artcraft/src/core/api_adapters/models/mod.rs b/crates/desktop/artcraft/src/core/api_adapters/models/mod.rs deleted file mode 100644 index c10a6ca15e..0000000000 --- a/crates/desktop/artcraft/src/core/api_adapters/models/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod image; -pub mod video; diff --git a/crates/desktop/artcraft/src/core/api_adapters/models/video/mod.rs b/crates/desktop/artcraft/src/core/api_adapters/models/video/mod.rs deleted file mode 100644 index b2235723ed..0000000000 --- a/crates/desktop/artcraft/src/core/api_adapters/models/video/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod tauri_video_model_to_generation_model; -pub mod tauri_video_model_to_router_model; diff --git a/crates/desktop/artcraft/src/core/api_adapters/models/video/tauri_video_model_to_generation_model.rs b/crates/desktop/artcraft/src/core/api_adapters/models/video/tauri_video_model_to_generation_model.rs deleted file mode 100644 index dad373a5de..0000000000 --- a/crates/desktop/artcraft/src/core/api_adapters/models/video/tauri_video_model_to_generation_model.rs +++ /dev/null @@ -1,31 +0,0 @@ -use crate::core::commands::generate::generate_video::request::TauriVideoModel; -use crate::core::events::generation_events::common::GenerationModel; - -/// Map TauriVideoModel to the GenerationModel used in events and the task database. -/// NB: GenerationModel serializations are stored in the tasks database — they keep -/// their legacy spellings for compatibility. -pub fn tauri_video_model_to_generation_model(model: TauriVideoModel) -> GenerationModel { - match model { - TauriVideoModel::GrokVideo => GenerationModel::GrokVideo, - TauriVideoModel::GrokImagineVideo1p5 => GenerationModel::GrokImagineVideo1p5, - TauriVideoModel::HappyHorse1p0 => GenerationModel::HappyHorse1p0, - TauriVideoModel::Kling16Pro => GenerationModel::Kling1_6, - TauriVideoModel::Kling21Master => GenerationModel::Kling21Master, - TauriVideoModel::Kling21Pro => GenerationModel::Kling21Pro, - TauriVideoModel::Kling2p5TurboPro => GenerationModel::Kling2p5TurboPro, - TauriVideoModel::Kling2p6Pro => GenerationModel::Kling2p6Pro, - TauriVideoModel::Kling3p0Pro => GenerationModel::Kling3p0Pro, - TauriVideoModel::Kling3p0Standard => GenerationModel::Kling3p0Standard, - TauriVideoModel::Seedance10Lite => GenerationModel::Seedance10Lite, - TauriVideoModel::Seedance1p5Pro => GenerationModel::Seedance1p5Pro, - TauriVideoModel::Seedance2p0 => GenerationModel::Seedance2p0, - TauriVideoModel::Seedance2p0Fast => GenerationModel::Seedance2p0Fast, - TauriVideoModel::Sora2 => GenerationModel::Sora2, - TauriVideoModel::Sora2Pro => GenerationModel::Sora2Pro, - TauriVideoModel::Veo2 => GenerationModel::Veo2, - TauriVideoModel::Veo3 => GenerationModel::Veo3, - TauriVideoModel::Veo3Fast => GenerationModel::Veo3Fast, - TauriVideoModel::Veo3p1 => GenerationModel::Veo3p1, - TauriVideoModel::Veo3p1Fast => GenerationModel::Veo3p1Fast, - } -} diff --git a/crates/desktop/artcraft/src/core/api_adapters/models/video/tauri_video_model_to_router_model.rs b/crates/desktop/artcraft/src/core/api_adapters/models/video/tauri_video_model_to_router_model.rs deleted file mode 100644 index 008c41690a..0000000000 --- a/crates/desktop/artcraft/src/core/api_adapters/models/video/tauri_video_model_to_router_model.rs +++ /dev/null @@ -1,30 +0,0 @@ -use artcraft_router::api::router_video_model::RouterVideoModel; - -use crate::core::commands::generate::generate_video::request::TauriVideoModel; - -/// Map TauriVideoModel to the artcraft_router's RouterVideoModel. -pub fn tauri_video_model_to_router_model(model: TauriVideoModel) -> RouterVideoModel { - match model { - TauriVideoModel::GrokVideo => RouterVideoModel::GrokImagineVideo, - TauriVideoModel::GrokImagineVideo1p5 => RouterVideoModel::GrokImagineVideo1p5, - TauriVideoModel::HappyHorse1p0 => RouterVideoModel::HappyHorse1p0, - TauriVideoModel::Kling16Pro => RouterVideoModel::Kling16Pro, - TauriVideoModel::Kling21Master => RouterVideoModel::Kling21Master, - TauriVideoModel::Kling21Pro => RouterVideoModel::Kling21Pro, - TauriVideoModel::Kling2p5TurboPro => RouterVideoModel::Kling2p5TurboPro, - TauriVideoModel::Kling2p6Pro => RouterVideoModel::Kling2p6Pro, - TauriVideoModel::Kling3p0Pro => RouterVideoModel::Kling3p0Pro, - TauriVideoModel::Kling3p0Standard => RouterVideoModel::Kling3p0Standard, - TauriVideoModel::Seedance10Lite => RouterVideoModel::Seedance10Lite, - TauriVideoModel::Seedance1p5Pro => RouterVideoModel::Seedance1p5Pro, - TauriVideoModel::Seedance2p0 => RouterVideoModel::Seedance2p0, - TauriVideoModel::Seedance2p0Fast => RouterVideoModel::Seedance2p0Fast, - TauriVideoModel::Sora2 => RouterVideoModel::Sora2, - TauriVideoModel::Sora2Pro => RouterVideoModel::Sora2Pro, - TauriVideoModel::Veo2 => RouterVideoModel::Veo2, - TauriVideoModel::Veo3 => RouterVideoModel::Veo3, - TauriVideoModel::Veo3Fast => RouterVideoModel::Veo3Fast, - TauriVideoModel::Veo3p1 => RouterVideoModel::Veo3p1, - TauriVideoModel::Veo3p1Fast => RouterVideoModel::Veo3p1Fast, - } -} diff --git a/crates/desktop/artcraft/src/core/api_adapters/quality/common_quality.rs b/crates/desktop/artcraft/src/core/api_adapters/quality/common_quality.rs deleted file mode 100644 index a28d9522d6..0000000000 --- a/crates/desktop/artcraft/src/core/api_adapters/quality/common_quality.rs +++ /dev/null @@ -1,21 +0,0 @@ -use serde_derive::{Deserialize, Serialize}; -use artcraft_router::api::router_quality::RouterQuality; - -/// Just cargo culting this. might not be necessary for standalone types anymore -#[derive(Copy, Clone, Debug, Serialize, Deserialize)] -#[serde(rename_all = "snake_case")] -pub enum CommonQuality { - High, - Medium, - Low, -} - -impl CommonQuality { - pub fn to_artcraft_router_type(&self) -> RouterQuality { - match self { - CommonQuality::High => RouterQuality::High, - CommonQuality::Medium => RouterQuality::Medium, - CommonQuality::Low => RouterQuality::Low, - } - } -} diff --git a/crates/desktop/artcraft/src/core/api_adapters/quality/mod.rs b/crates/desktop/artcraft/src/core/api_adapters/quality/mod.rs deleted file mode 100644 index 1f4f0aaad0..0000000000 --- a/crates/desktop/artcraft/src/core/api_adapters/quality/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod common_quality; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/core/api_adapters/resolution/common_resolution.rs b/crates/desktop/artcraft/src/core/api_adapters/resolution/common_resolution.rs deleted file mode 100644 index 3b401c02e4..0000000000 --- a/crates/desktop/artcraft/src/core/api_adapters/resolution/common_resolution.rs +++ /dev/null @@ -1,29 +0,0 @@ -use serde_derive::{Deserialize, Serialize}; - -/// This is a comprehensive list of common resolutions you can specify when enqueuing a generation. -/// Not every model will support every resolution -/// In the case a model doesn't support the resolution, gracefully pick the nearest option. -#[derive(Copy, Clone, Debug, Serialize, Deserialize)] -#[serde(rename_all = "snake_case")] -pub enum CommonResolution { - /// Models: Nano Banana Pro - OneK, - /// Models: Nano Banana Pro - TwoK, - /// Models: (None) - ThreeK, - /// Models: Nano Banana Pro - FourK, - - /// Used by Nano Banana 2 (and others) - HalfK, - - /// Used by the Seedance family (and others) - FourEightyP, - - /// Used by the Seedance family (and others) - SevenTwentyP, - - /// Used by the Seedance family (and others) - TenEightyP, -} diff --git a/crates/desktop/artcraft/src/core/api_adapters/resolution/convert/mod.rs b/crates/desktop/artcraft/src/core/api_adapters/resolution/convert/mod.rs deleted file mode 100644 index 332209b3cb..0000000000 --- a/crates/desktop/artcraft/src/core/api_adapters/resolution/convert/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod resolution_to_artcraft_nano_banana_pro; -pub mod router_resolution_to_enums_resolution; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/core/api_adapters/resolution/convert/resolution_to_artcraft_nano_banana_pro.rs b/crates/desktop/artcraft/src/core/api_adapters/resolution/convert/resolution_to_artcraft_nano_banana_pro.rs deleted file mode 100644 index a880943bcc..0000000000 --- a/crates/desktop/artcraft/src/core/api_adapters/resolution/convert/resolution_to_artcraft_nano_banana_pro.rs +++ /dev/null @@ -1,17 +0,0 @@ -use crate::core::api_adapters::resolution::common_resolution::CommonResolution; -use artcraft_api_defs::generate::image::multi_function::nano_banana_pro_multi_function_image_gen::NanoBananaProMultiFunctionImageGenImageResolution; - -pub fn resolution_to_artcraft_nano_banana_pro(resolution: CommonResolution) -> NanoBananaProMultiFunctionImageGenImageResolution { - match resolution { - CommonResolution::OneK => NanoBananaProMultiFunctionImageGenImageResolution::OneK, - CommonResolution::TwoK => NanoBananaProMultiFunctionImageGenImageResolution::TwoK, - // NB: ThreeK doesn't exist in Nano Banana Pro, use FourK as nearest higher resolution - CommonResolution::ThreeK => NanoBananaProMultiFunctionImageGenImageResolution::FourK, - CommonResolution::FourK => NanoBananaProMultiFunctionImageGenImageResolution::FourK, - // Fall back to nearest supported resolution - CommonResolution::HalfK => NanoBananaProMultiFunctionImageGenImageResolution::OneK, - CommonResolution::FourEightyP => NanoBananaProMultiFunctionImageGenImageResolution::OneK, - CommonResolution::SevenTwentyP => NanoBananaProMultiFunctionImageGenImageResolution::OneK, - CommonResolution::TenEightyP => NanoBananaProMultiFunctionImageGenImageResolution::OneK, - } -} diff --git a/crates/desktop/artcraft/src/core/api_adapters/resolution/convert/router_resolution_to_enums_resolution.rs b/crates/desktop/artcraft/src/core/api_adapters/resolution/convert/router_resolution_to_enums_resolution.rs deleted file mode 100644 index 3dbbce6766..0000000000 --- a/crates/desktop/artcraft/src/core/api_adapters/resolution/convert/router_resolution_to_enums_resolution.rs +++ /dev/null @@ -1,16 +0,0 @@ -use artcraft_router::api::router_resolution::RouterResolution; -use enums::common::generation::common_resolution::CommonResolution as EnumsCommonResolution; - -/// Map from the router's CommonResolution to the enums crate's CommonResolution. -pub fn router_resolution_to_enums_resolution(res: RouterResolution) -> EnumsCommonResolution { - match res { - RouterResolution::OneK => EnumsCommonResolution::OneK, - RouterResolution::TwoK => EnumsCommonResolution::TwoK, - RouterResolution::ThreeK => EnumsCommonResolution::ThreeK, - RouterResolution::FourK => EnumsCommonResolution::FourK, - RouterResolution::HalfK => EnumsCommonResolution::HalfK, - RouterResolution::FourEightyP => EnumsCommonResolution::FourEightyP, - RouterResolution::SevenTwentyP => EnumsCommonResolution::SevenTwentyP, - RouterResolution::TenEightyP => EnumsCommonResolution::TenEightyP, - } -} diff --git a/crates/desktop/artcraft/src/core/api_adapters/resolution/mod.rs b/crates/desktop/artcraft/src/core/api_adapters/resolution/mod.rs deleted file mode 100644 index f1197a3d7b..0000000000 --- a/crates/desktop/artcraft/src/core/api_adapters/resolution/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod common_resolution; -pub mod convert; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/core/artcraft_error.rs b/crates/desktop/artcraft/src/core/artcraft_error.rs deleted file mode 100644 index e42ebff92f..0000000000 --- a/crates/desktop/artcraft/src/core/artcraft_error.rs +++ /dev/null @@ -1,80 +0,0 @@ -use grok_consumer_client::error::grok_error::GrokError; -use std::error::Error; -use std::fmt::{Display, Formatter}; -use std::path::PathBuf; -use artcraft_client::error::storyteller_error::StorytellerError; - -#[derive(Debug)] -pub enum ArtcraftError { - AnyhowError(anyhow::Error), - DecodeError(base64::DecodeError), - IoError(std::io::Error), - ReqwestError(reqwest::Error), - // Service errors - GrokError(GrokError), - StorytellerError(StorytellerError), - // Lock errors - RwLockReadError, - RwLockWriteError, - MutexLockError, - // Download errors - BadDownloadFilename { path: PathBuf }, - CannotDownloadFilePathAlreadyExists { path: PathBuf }, -} - -impl Error for ArtcraftError {} - -impl Display for ArtcraftError { - fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { - match self { - Self::AnyhowError(e) => write!(f, "AnyhowError: {:?}", e), - Self::DecodeError(e) => write!(f, "DecodeError: {:?}", e), - Self::IoError(e) => write!(f, "IoError: {:?}", e), - Self::ReqwestError(e) => write!(f, "ReqwestError: {:?}", e), - Self::GrokError(e) => write!(f, "GrokError: {:?}", e), - Self::StorytellerError(e) => write!(f, "StorytellerError: {:?}", e), - Self::RwLockReadError => write!(f, "RwLockReadError"), - Self::RwLockWriteError => write!(f, "RwLockWriteError"), - Self::MutexLockError => write!(f, "MutexLockError"), - Self::BadDownloadFilename { path } => write!(f, "BadDownloadFilename: {:?}", path), - Self::CannotDownloadFilePathAlreadyExists { path } => write!(f, "CannotDownloadFilePathAlreadyExists {:?}", path), - } - } -} - -impl From for ArtcraftError { - fn from(value: anyhow::Error) -> Self { - Self::AnyhowError(value) - } -} - -impl From for ArtcraftError { - fn from(value: base64::DecodeError) -> Self { - Self::DecodeError(value) - } -} - -impl From for ArtcraftError { - fn from(value: std::io::Error) -> Self { - Self::IoError(value) - } -} - -impl From for ArtcraftError { - fn from(value: reqwest::Error) -> Self { - Self::ReqwestError(value) - } -} - -impl From for ArtcraftError { - fn from(value: GrokError) -> Self { - Self::GrokError(value) - } -} - -impl From for ArtcraftError { - fn from(value: StorytellerError) -> Self { - Self::StorytellerError(value) - } -} - diff --git a/crates/desktop/artcraft/src/core/commands/app_preferences/get_app_preferences_command.rs b/crates/desktop/artcraft/src/core/commands/app_preferences/get_app_preferences_command.rs deleted file mode 100644 index a42668a668..0000000000 --- a/crates/desktop/artcraft/src/core/commands/app_preferences/get_app_preferences_command.rs +++ /dev/null @@ -1,74 +0,0 @@ -use crate::core::state::app_preferences::app_preferences_manager::AppPreferencesManager; -use crate::core::state::app_preferences::preferred_download_directory::PreferredDownloadDirectory; -use errors::AnyhowResult; -use log::{error, info}; -use serde_derive::Serialize; -use tauri::State; - -#[derive(Serialize)] -pub struct GetAppPreferencesResponse { - pub preferences: AppPreferencesPayload, -} - -#[derive(Serialize)] -pub struct AppPreferencesPayload { - /// The downloads directory to use when a user downloads a file. - pub preferred_download_directory: PreferredDownloadDirectory, - - /// Play sounds on events. - pub play_sounds: bool, - - /// Key pointing to file; defined in the frontend code. - pub delete_file_sound: Option, - - /// Key pointing to file; defined in the frontend code. - /// Defined for enqueue since image enqueue can be async - pub enqueue_success_sound: Option, - - /// Key pointing to file; defined in the frontend code. - /// Defined for enqueue since image enqueue can be async - pub enqueue_failure_sound: Option, - - /// Key pointing to file; defined in the frontend code. - pub generation_success_sound: Option, - - /// Key pointing to file; defined in the frontend code. - pub generation_failure_sound: Option, - - /// Key pointing to file; defined in the frontend code. - #[deprecated] - pub generation_enqueue_sound: Option, -} - - -#[tauri::command] -pub async fn get_app_preferences_command( - app_prefs: State<'_, AppPreferencesManager>, -) -> Result { - info!("get_app_preferences_command called"); - - let result = get_prefs(&app_prefs) - .await - .map_err(|err| { - error!("Error getting app preferences: {:?}", err); - format!("Error getting app preferences: {:?}", err) - })?; - - Ok(GetAppPreferencesResponse { - preferences: result, - }) -} - -async fn get_prefs(app_prefs: &AppPreferencesManager) -> AnyhowResult { - let prefs = app_prefs.get_clone()?; - Ok(AppPreferencesPayload { - preferred_download_directory: prefs.preferred_download_directory, - play_sounds: prefs.play_sounds, - delete_file_sound: prefs.delete_file_sound, - enqueue_success_sound: prefs.enqueue_success_sound, - enqueue_failure_sound: prefs.enqueue_failure_sound, - generation_success_sound: prefs.generation_success_sound, - generation_failure_sound: prefs.generation_failure_sound, - generation_enqueue_sound: prefs.generation_enqueue_sound, - }) -} diff --git a/crates/desktop/artcraft/src/core/commands/app_preferences/mod.rs b/crates/desktop/artcraft/src/core/commands/app_preferences/mod.rs deleted file mode 100644 index d032ba902b..0000000000 --- a/crates/desktop/artcraft/src/core/commands/app_preferences/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod get_app_preferences_command; -pub mod update_app_preference_command; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/core/commands/app_preferences/update_app_preference_command.rs b/crates/desktop/artcraft/src/core/commands/app_preferences/update_app_preference_command.rs deleted file mode 100644 index 0e8a8ee2c9..0000000000 --- a/crates/desktop/artcraft/src/core/commands/app_preferences/update_app_preference_command.rs +++ /dev/null @@ -1,127 +0,0 @@ -use crate::core::state::app_preferences::app_preferences_manager::AppPreferencesManager; -use crate::core::state::app_preferences::preferred_download_directory::PreferredDownloadDirectory; -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use anyhow::anyhow; -use errors::AnyhowResult; -use log::{error, info}; -use serde_derive::{Deserialize, Serialize}; -use tauri::State; - -/// For now, we'll only update a single preference at a time. -#[derive(Deserialize)] -pub struct UpdateAppPreferencesRequest { - pub preference: PreferenceName, - /// We'll decode this with respect to the preference value. - pub value: Option, -} - -#[derive(Deserialize, Debug)] -#[serde(untagged)] -pub enum ValueType { - Bool(bool), - String(String), - DownloadDirectory(PreferredDownloadDirectory), -} - -#[derive(Deserialize)] -#[serde(rename_all = "snake_case")] -pub enum PreferenceName { - PreferredDownloadDirectory, - PlaySounds, - DeleteFileSound, - EnqueueSuccessSound, - EnqueueFailureSound, - GenerationSuccessSound, - GenerationFailureSound, -} - -#[derive(Serialize)] -pub struct UpdateAppPreferencesResponse { - pub success: bool, -} - -#[tauri::command] -pub async fn update_app_preferences_command( - request: UpdateAppPreferencesRequest, - app_prefs: State<'_, AppPreferencesManager>, - app_data_root: State<'_, AppDataRoot>, -) -> Result { - info!("update_app_preferences_command called"); - - update_prefs(request, &app_prefs, &app_data_root) - .await - .map_err(|err| { - error!("Error getting app preferences: {:?}", err); - format!("Error getting app preferences: {:?}", err) - })?; - - Ok(UpdateAppPreferencesResponse { - success: true, - }) -} - -async fn update_prefs( - request: UpdateAppPreferencesRequest, - app_prefs: &AppPreferencesManager, - app_data_root: &AppDataRoot, -) -> AnyhowResult<()> { - let mut prefs = app_prefs.get_clone()?; - - info!("Value is: {:?}", request.value); - - match request.preference { - PreferenceName::PreferredDownloadDirectory => { - match request.value { - Some(ValueType::DownloadDirectory(dir)) => - prefs.preferred_download_directory = dir, - _ => - return Err(anyhow!("Invalid value: {:?}", request.value)), - } - } - PreferenceName::PlaySounds => { - match request.value { - Some(ValueType::Bool(val)) => - prefs.play_sounds = val, - _ => - return Err(anyhow!("Invalid value: {:?}", request.value)), - } - } - PreferenceName::DeleteFileSound => { - prefs.delete_file_sound = request.value - .map(|val| string_value(&val)) - .transpose()?; - } - PreferenceName::EnqueueSuccessSound => { - prefs.enqueue_success_sound = request.value - .map(|val| string_value(&val)) - .transpose()?; - } - PreferenceName::EnqueueFailureSound => { - prefs.enqueue_failure_sound = request.value - .map(|val| string_value(&val)) - .transpose()?; - } - PreferenceName::GenerationSuccessSound => { - prefs.generation_success_sound = request.value - .map(|val| string_value(&val)) - .transpose()?; - } - PreferenceName::GenerationFailureSound => { - prefs.generation_failure_sound = request.value - .map(|val| string_value(&val)) - .transpose()?; - } - } - - app_prefs.set_clone(&prefs)?; - app_data_root.settings_dir().write_app_preferences(&prefs)?; - - Ok(()) -} - -fn string_value(value: &ValueType) -> AnyhowResult { - match value { - ValueType::String(val) => Ok(val.to_string()), - _ => Err(anyhow!("Invalid value type: {:?}", value)), - } -} diff --git a/crates/desktop/artcraft/src/core/commands/app_state/mod.rs b/crates/desktop/artcraft/src/core/commands/app_state/mod.rs deleted file mode 100644 index 33df1ad78c..0000000000 --- a/crates/desktop/artcraft/src/core/commands/app_state/mod.rs +++ /dev/null @@ -1 +0,0 @@ -mod reset_artcraft_command; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/core/commands/app_state/reset_artcraft_command.rs b/crates/desktop/artcraft/src/core/commands/app_state/reset_artcraft_command.rs deleted file mode 100644 index b60bd65666..0000000000 --- a/crates/desktop/artcraft/src/core/commands/app_state/reset_artcraft_command.rs +++ /dev/null @@ -1,34 +0,0 @@ -use crate::core::commands::deprecated::image_edit::enqueue_edit_image_command::EnqueueEditImageSuccessResponse; -use crate::core::commands::response::shorthand::ResponseOrErrorMessage; -use crate::core::commands::response::success_response_wrapper::SerializeMarker; -use crate::core::state::app_preferences::app_preferences_manager::AppPreferencesManager; -use crate::core::state::app_preferences::preferred_download_directory::PreferredDownloadDirectory; -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::services::storyteller::state::storyteller_credential_manager::StorytellerCredentialManager; -use crate::services::storyteller::windows::clear_main_webview_window_storyteller_cookies::clear_main_webview_window_storyteller_cookies; -use anyhow::anyhow; -use errors::AnyhowResult; -use log::{error, info}; -use serde_derive::{Deserialize, Serialize}; -use tauri::{AppHandle, State}; - -#[derive(Serialize)] -pub struct ResetArtcraftCommandResponse { - pub success: bool, -} - -impl SerializeMarker for ResetArtcraftCommandResponse {} - -#[tauri::command] -pub async fn reset_artcraft_command( - app: AppHandle, -) -> ResponseOrErrorMessage { - info!("reset_artcraft_command called"); - - // TODO: Reset local vs. production - - Ok(ResetArtcraftCommandResponse { - success: true, - }.into()) -} - diff --git a/crates/desktop/artcraft/src/core/commands/cost_estimate/estimate_audio_cost_command.rs b/crates/desktop/artcraft/src/core/commands/cost_estimate/estimate_audio_cost_command.rs deleted file mode 100644 index 8ac6d6671d..0000000000 --- a/crates/desktop/artcraft/src/core/commands/cost_estimate/estimate_audio_cost_command.rs +++ /dev/null @@ -1,11 +0,0 @@ -use crate::core::commands::generate::omni::{self, Modality, OmniRequest, OmniResult}; -use crate::core::commands::generate::omni::dispatch::local_error; -use tauri::AppHandle; - -#[tauri::command] -pub async fn estimate_audio_cost_command(request: OmniRequest, app: AppHandle) -> OmniResult { - if !request.uses_artcraft() { - return Err(local_error("No direct provider adapter is configured for this modality.")); - } - omni::estimate(request, Modality::Audio, &app).await -} diff --git a/crates/desktop/artcraft/src/core/commands/cost_estimate/estimate_image_cost_command.rs b/crates/desktop/artcraft/src/core/commands/cost_estimate/estimate_image_cost_command.rs deleted file mode 100644 index 68a6deca14..0000000000 --- a/crates/desktop/artcraft/src/core/commands/cost_estimate/estimate_image_cost_command.rs +++ /dev/null @@ -1,52 +0,0 @@ -use crate::core::commands::generate::omni::{self, Modality, OmniRequest, OmniResult}; -use crate::core::commands::generate::omni::dispatch::{adapt_legacy_response, decode_native}; -use tauri::{AppHandle, Manager}; -use crate::core::commands::response::failure_response_wrapper::{CommandErrorResponseWrapper, CommandErrorStatus}; -use crate::core::commands::response::shorthand::ResponseOrError; -use crate::core::commands::response::success_response_wrapper::SerializeMarker; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; -use artcraft_api_defs::generate::cost_estimate::estimate_image_cost::{ - EstimateImageCostError, EstimateImageCostErrorType, EstimateImageCostRequest, - EstimateImageCostResponse, -}; -use artcraft_client::endpoints::generate::cost_estimate::image::estimate_image_cost::estimate_image_cost; -use log::{debug, info}; -use tauri::State; - -impl SerializeMarker for EstimateImageCostResponse {} - -#[tauri::command] -pub async fn estimate_image_cost_command(request: OmniRequest, app: AppHandle) -> OmniResult { - if request.uses_artcraft() && !request.uses_legacy_image_endpoint() { - return omni::estimate(request, Modality::Image, &app).await; - } - adapt_legacy_response(estimate_image_cost_native(decode_native(request)?, app.state()).await) -} - -async fn estimate_image_cost_native( - request: EstimateImageCostRequest, - app_env_configs: State<'_, AppEnvConfigs>, -) -> ResponseOrError { - debug!("estimate_image_cost_command called: {:?}", request); - - let result = estimate_image_cost( - &app_env_configs.storyteller_host, - None, // Credentials are not required for this endpoint. - request, - ) - .await; - - match result { - Ok(response) => Ok(response.into()), - Err(err) => Err(CommandErrorResponseWrapper { - status: CommandErrorStatus::BadRequest, - error_message: None, - error_type: None, - error_details: Some(EstimateImageCostError { - success: false, - error_type: EstimateImageCostErrorType::InvalidInput, - error_message: err.to_string(), - }), - }), - } -} diff --git a/crates/desktop/artcraft/src/core/commands/cost_estimate/estimate_mesh_cost_command.rs b/crates/desktop/artcraft/src/core/commands/cost_estimate/estimate_mesh_cost_command.rs deleted file mode 100644 index 1af43fa031..0000000000 --- a/crates/desktop/artcraft/src/core/commands/cost_estimate/estimate_mesh_cost_command.rs +++ /dev/null @@ -1,11 +0,0 @@ -use crate::core::commands::generate::omni::{self, Modality, OmniRequest, OmniResult}; -use crate::core::commands::generate::omni::dispatch::local_error; -use tauri::AppHandle; - -#[tauri::command] -pub async fn estimate_mesh_cost_command(request: OmniRequest, app: AppHandle) -> OmniResult { - if !request.uses_artcraft() { - return Err(local_error("No direct provider adapter is configured for this modality.")); - } - omni::estimate(request, Modality::Mesh, &app).await -} diff --git a/crates/desktop/artcraft/src/core/commands/cost_estimate/estimate_splat_cost_command.rs b/crates/desktop/artcraft/src/core/commands/cost_estimate/estimate_splat_cost_command.rs deleted file mode 100644 index fef3df75b5..0000000000 --- a/crates/desktop/artcraft/src/core/commands/cost_estimate/estimate_splat_cost_command.rs +++ /dev/null @@ -1,52 +0,0 @@ -use crate::core::commands::generate::omni::{self, Modality, OmniRequest, OmniResult}; -use crate::core::commands::generate::omni::dispatch::{adapt_legacy_response, decode_native}; -use tauri::{AppHandle, Manager}; -use crate::core::commands::response::failure_response_wrapper::{CommandErrorResponseWrapper, CommandErrorStatus}; -use crate::core::commands::response::shorthand::ResponseOrError; -use crate::core::commands::response::success_response_wrapper::SerializeMarker; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; -use artcraft_api_defs::generate::cost_estimate::estimate_splat_cost::{ - EstimateSplatCostError, EstimateSplatCostErrorType, EstimateSplatCostRequest, - EstimateSplatCostResponse, -}; -use artcraft_client::endpoints::generate::cost_estimate::splat::estimate_splat_cost::estimate_splat_cost; -use log::debug; -use tauri::State; - -impl SerializeMarker for EstimateSplatCostResponse {} - -#[tauri::command] -pub async fn estimate_splat_cost_command(request: OmniRequest, app: AppHandle) -> OmniResult { - if request.uses_artcraft() { - return omni::estimate(request, Modality::Splat, &app).await; - } - adapt_legacy_response(estimate_splat_cost_native(decode_native(request)?, app.state()).await) -} - -async fn estimate_splat_cost_native( - request: EstimateSplatCostRequest, - app_env_configs: State<'_, AppEnvConfigs>, -) -> ResponseOrError { - debug!("estimate_splat_cost_command called"); - - let result = estimate_splat_cost( - &app_env_configs.storyteller_host, - None, // Credentials are not required for this endpoint. - request, - ) - .await; - - match result { - Ok(response) => Ok(response.into()), - Err(err) => Err(CommandErrorResponseWrapper { - status: CommandErrorStatus::BadRequest, - error_message: None, - error_type: None, - error_details: Some(EstimateSplatCostError { - success: false, - error_type: EstimateSplatCostErrorType::InvalidInput, - error_message: err.to_string(), - }), - }), - } -} diff --git a/crates/desktop/artcraft/src/core/commands/cost_estimate/estimate_video_cost_command.rs b/crates/desktop/artcraft/src/core/commands/cost_estimate/estimate_video_cost_command.rs deleted file mode 100644 index 7bf4d83fa5..0000000000 --- a/crates/desktop/artcraft/src/core/commands/cost_estimate/estimate_video_cost_command.rs +++ /dev/null @@ -1,53 +0,0 @@ -use crate::core::commands::generate::omni::{self, Modality, OmniRequest, OmniResult}; -use crate::core::commands::generate::omni::dispatch::{adapt_legacy_response, decode_native}; -use tauri::{AppHandle, Manager}; -use crate::core::commands::response::failure_response_wrapper::{CommandErrorResponseWrapper, CommandErrorStatus}; -use crate::core::commands::response::shorthand::ResponseOrError; -use crate::core::commands::response::success_response_wrapper::SerializeMarker; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; -use crate::services::storyteller::state::storyteller_credential_manager::StorytellerCredentialManager; -use artcraft_api_defs::generate::cost_estimate::estimate_video_cost::{ - EstimateVideoCostError, EstimateVideoCostErrorType, EstimateVideoCostRequest, - EstimateVideoCostResponse, -}; -use artcraft_client::endpoints::generate::cost_estimate::video::estimate_video_cost::estimate_video_cost; -use log::{debug, info}; -use tauri::State; - -impl SerializeMarker for EstimateVideoCostResponse {} - -#[tauri::command] -pub async fn estimate_video_cost_command(request: OmniRequest, app: AppHandle) -> OmniResult { - if request.uses_artcraft() { - return omni::estimate(request, Modality::Video, &app).await; - } - adapt_legacy_response(estimate_video_cost_native(decode_native(request)?, app.state()).await) -} - -async fn estimate_video_cost_native( - request: EstimateVideoCostRequest, - app_env_configs: State<'_, AppEnvConfigs>, -) -> ResponseOrError { - debug!("estimate_video_cost_command called: {:?}", request); - - let result = estimate_video_cost( - &app_env_configs.storyteller_host, - None, // Credentials are not required for this endpoint. - request, - ) - .await; - - match result { - Ok(response) => Ok(response.into()), - Err(err) => Err(CommandErrorResponseWrapper { - status: CommandErrorStatus::BadRequest, - error_message: None, - error_type: None, - error_details: Some(EstimateVideoCostError { - success: false, - error_type: EstimateVideoCostErrorType::InvalidInput, - error_message: err.to_string(), - }), - }), - } -} diff --git a/crates/desktop/artcraft/src/core/commands/cost_estimate/mod.rs b/crates/desktop/artcraft/src/core/commands/cost_estimate/mod.rs deleted file mode 100644 index 4edb9bdbb3..0000000000 --- a/crates/desktop/artcraft/src/core/commands/cost_estimate/mod.rs +++ /dev/null @@ -1,6 +0,0 @@ -pub mod estimate_image_cost_command; -pub mod estimate_splat_cost_command; -pub mod estimate_video_cost_command; - -pub mod estimate_mesh_cost_command; -pub mod estimate_audio_cost_command; diff --git a/crates/desktop/artcraft/src/core/commands/deprecated/image_edit/artcraft/handle_artcraft_flux_kontext_edit.rs b/crates/desktop/artcraft/src/core/commands/deprecated/image_edit/artcraft/handle_artcraft_flux_kontext_edit.rs deleted file mode 100644 index 5293adb024..0000000000 --- a/crates/desktop/artcraft/src/core/commands/deprecated/image_edit/artcraft/handle_artcraft_flux_kontext_edit.rs +++ /dev/null @@ -1,131 +0,0 @@ -use crate::core::commands::enqueue::generate_error::{BadInputReason, GenerateError}; -use crate::core::commands::deprecated::image_edit::enqueue_edit_image_command::{EditImageQuality, EditImageSize, EnqueueEditImageCommand}; -use crate::core::commands::enqueue::task_enqueue_success::TaskEnqueueSuccess; -use crate::core::events::basic_sendable_event_trait::BasicSendableEvent; -use crate::core::events::generation_events::common::{GenerationAction, GenerationModel, GenerationServiceProvider}; -use crate::core::events::generation_events::generation_enqueue_failure_event::GenerationEnqueueFailureEvent; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::core::state::provider_priority::ProviderPriorityStore; -use crate::services::sora::state::sora_credential_manager::SoraCredentialManager; -use crate::services::sora::state::sora_task_queue::SoraTaskQueue; -use crate::services::storyteller::state::storyteller_credential_manager::StorytellerCredentialManager; -use anyhow::anyhow; -use artcraft_api_defs::generate::image::edit::flux_pro_kontext_max_edit_image::{FluxProKontextMaxEditImageNumImages, FluxProKontextMaxEditImageRequest}; -use artcraft_api_defs::generate::image::edit::gpt_image_1_edit_image::{GptImage1EditImageImageQuality, GptImage1EditImageImageSize, GptImage1EditImageNumImages, GptImage1EditImageRequest}; -use enums::common::generation_provider::GenerationProvider; -use enums::tauri::tasks::task_type::TaskType; -use uuid_utils::uuid::generate_random_uuid; -use log::{error, info}; -use artcraft_client::endpoints::generate::image::edit::flux_pro_kontext_max_edit_image::flux_pro_kontext_max_edit_image; -use artcraft_client::endpoints::generate::image::edit::gpt_image_1_edit_image::gpt_image_1_edit_image; -use tauri::AppHandle; - -pub async fn handle_artcraft_flux_kontext_edit( - request: &EnqueueEditImageCommand, - app: &AppHandle, - app_data_root: &AppDataRoot, - app_env_configs: &AppEnvConfigs, - storyteller_creds_manager: &StorytellerCredentialManager, -) -> Result { - - let creds = match storyteller_creds_manager.get_credentials()? { - Some(creds) => creds, - None => { - return Err(GenerateError::needs_storyteller_credentials()); - }, - }; - - info!("Calling Artcraft flux kontext max edit (edit) ..."); - - let uuid_idempotency_token = generate_random_uuid(); - - let num_images = match request.image_count { - None => None, - Some(1) => Some(FluxProKontextMaxEditImageNumImages::One), - Some(2) => Some(FluxProKontextMaxEditImageNumImages::Two), - Some(3) => Some(FluxProKontextMaxEditImageNumImages::Three), - Some(4) => Some(FluxProKontextMaxEditImageNumImages::Four), - Some(other) => { - return Err(GenerateError::BadInput(BadInputReason::InvalidNumberOfRequestedImages { - min: 1, - max: 4, - requested: other, - })); - }, - }; - - let mut maybe_media_token = None; - - let list_count = request.image_media_tokens - .as_ref() - .map(|tokens| tokens.len()) - .unwrap_or(0); - - if request.scene_image_media_token.is_some() && list_count > 0 { - return Err(GenerateError::BadInput(BadInputReason::WrongImageArguments( - "Cannot specify both scene_image_media_token and image_media_tokens for Flux Kontext Max".to_string()))); - } - - if list_count > 1 { - return Err(GenerateError::BadInput(BadInputReason::WrongImageArguments( - "Cannot specify more than one image in image_media_tokens for Flux Kontext Max".to_string()))); - } - - if let Some(media_token) = &request.scene_image_media_token { - maybe_media_token = Some(media_token.clone()); - } - - let maybe_list_media_token = request.image_media_tokens - .as_ref() - .map(|tokens| tokens.first()) - .flatten(); - - if let Some(media_token) = maybe_list_media_token { - maybe_media_token = Some(media_token.clone()); - } - - let media_token = match maybe_media_token { - Some(token) => token, - None => { - return Err(GenerateError::BadInput(BadInputReason::WrongImageArguments( - "No input image specified for Flux Kontext Max edit".to_string()))); - }, - }; - - let request = FluxProKontextMaxEditImageRequest { - uuid_idempotency_token, - prompt: Some(request.prompt.clone()), - image_media_token: media_token, - num_images, - }; - - let result = flux_pro_kontext_max_edit_image( - &app_env_configs.storyteller_host, - Some(&creds), - request, - ).await; - - let job_id = match result { - Ok(enqueued) => { - // TODO(bt,2025-07-05): Enqueue job token? - info!("Successfully enqueued Artcraft gpt-image-1. Job token: {}", - enqueued.inference_job_token); - enqueued.inference_job_token - } - Err(err) => { - error!("Failed to use Artcraft gpt-image-1: {:?}", err); - return Err(GenerateError::from(err)); - } - }; - - Ok(TaskEnqueueSuccess { - provider: GenerationProvider::Artcraft, - model: Some(GenerationModel::FluxProKontextMax), - provider_job_id: Some(job_id.to_string()), - task_type: TaskType::ImageGeneration, - maybe_queue_status_url: None, - maybe_prompt_token: None, - maybe_queue_response_url: None, - }) -} diff --git a/crates/desktop/artcraft/src/core/commands/deprecated/image_edit/artcraft/handle_artcraft_gpt_image_1_edit.rs b/crates/desktop/artcraft/src/core/commands/deprecated/image_edit/artcraft/handle_artcraft_gpt_image_1_edit.rs deleted file mode 100644 index a7b7cda139..0000000000 --- a/crates/desktop/artcraft/src/core/commands/deprecated/image_edit/artcraft/handle_artcraft_gpt_image_1_edit.rs +++ /dev/null @@ -1,129 +0,0 @@ -use crate::core::commands::enqueue::generate_error::{BadInputReason, GenerateError}; -use crate::core::commands::deprecated::image_edit::enqueue_edit_image_command::{EditImageQuality, EditImageSize, EnqueueEditImageCommand}; -use crate::core::commands::enqueue::task_enqueue_success::TaskEnqueueSuccess; -use crate::core::events::basic_sendable_event_trait::BasicSendableEvent; -use crate::core::events::generation_events::common::{GenerationAction, GenerationModel, GenerationServiceProvider}; -use crate::core::events::generation_events::generation_enqueue_failure_event::GenerationEnqueueFailureEvent; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::core::state::provider_priority::ProviderPriorityStore; -use crate::services::sora::state::sora_credential_manager::SoraCredentialManager; -use crate::services::sora::state::sora_task_queue::SoraTaskQueue; -use crate::services::storyteller::state::storyteller_credential_manager::StorytellerCredentialManager; -use anyhow::anyhow; -use artcraft_api_defs::generate::image::edit::gpt_image_1_edit_image::{GptImage1EditImageImageQuality, GptImage1EditImageImageSize, GptImage1EditImageNumImages, GptImage1EditImageRequest}; -use enums::common::generation_provider::GenerationProvider; -use enums::tauri::tasks::task_type::TaskType; -use uuid_utils::uuid::generate_random_uuid; -use log::{error, info}; -use artcraft_client::endpoints::generate::image::edit::gpt_image_1_edit_image::gpt_image_1_edit_image; -use tauri::AppHandle; - -const MAX_IMAGES: usize = 4; - -pub async fn handle_artcraft_gpt_image_1_edit( - request: &EnqueueEditImageCommand, - app: &AppHandle, - app_data_root: &AppDataRoot, - app_env_configs: &AppEnvConfigs, - storyteller_creds_manager: &StorytellerCredentialManager, -) -> Result { - - let creds = match storyteller_creds_manager.get_credentials()? { - Some(creds) => creds, - None => { - return Err(GenerateError::needs_storyteller_credentials()); - }, - }; - - info!("Calling Artcraft gpt-image-1 (edit) ..."); - - let uuid_idempotency_token = generate_random_uuid(); - - let image_quality = request.image_quality - .map(|quality| match quality { - EditImageQuality::Auto => GptImage1EditImageImageQuality::Auto, - EditImageQuality::High => GptImage1EditImageImageQuality::High, - EditImageQuality::Medium => GptImage1EditImageImageQuality::Medium, - EditImageQuality::Low => GptImage1EditImageImageQuality::Low, - }); - - let image_size = request.aspect_ratio - .map(|size| match size { - EditImageSize::Auto => GptImage1EditImageImageSize::Square, - EditImageSize::Square => GptImage1EditImageImageSize::Square, - EditImageSize::Tall => GptImage1EditImageImageSize::Vertical, - EditImageSize::Wide => GptImage1EditImageImageSize::Horizontal, - }); - - let num_images = match request.image_count { - None => None, - Some(1) => Some(GptImage1EditImageNumImages::One), - Some(2) => Some(GptImage1EditImageNumImages::Two), - Some(3) => Some(GptImage1EditImageNumImages::Three), - Some(4) => Some(GptImage1EditImageNumImages::Four), - Some(other) => { - return Err(GenerateError::BadInput(BadInputReason::InvalidNumberOfRequestedImages { - min: 1, - max: 4, - requested: other, - })); - }, - }; - - let mut media_tokens = Vec::with_capacity(10); - - if let Some(scene_image_media_token) = request.scene_image_media_token.clone() { - media_tokens.push(scene_image_media_token); - } - - if let Some(image_media_tokens) = request.image_media_tokens.as_ref() { - media_tokens.extend_from_slice(image_media_tokens); - } - - if media_tokens.len() > MAX_IMAGES { - return Err(GenerateError::BadInput(BadInputReason::InvalidNumberOfInputImages { - min: 1, - max: MAX_IMAGES as u32, - provided: media_tokens.len() as u32, - })); - } - - let request = GptImage1EditImageRequest { - uuid_idempotency_token, - prompt: Some(request.prompt.clone()), - image_media_tokens: Some(media_tokens), - image_size, - num_images, - image_quality, - }; - - let result = gpt_image_1_edit_image( - &app_env_configs.storyteller_host, - Some(&creds), - request, - ).await; - - let job_id = match result { - Ok(enqueued) => { - // TODO(bt,2025-07-05): Enqueue job token? - info!("Successfully enqueued Artcraft gpt-image-1. Job token: {}", - enqueued.inference_job_token); - enqueued.inference_job_token - } - Err(err) => { - error!("Failed to use Artcraft gpt-image-1: {:?}", err); - return Err(GenerateError::from(err)); - } - }; - - Ok(TaskEnqueueSuccess { - provider: GenerationProvider::Artcraft, - model: Some(GenerationModel::GptImage1), - provider_job_id: Some(job_id.to_string()), - task_type: TaskType::ImageGeneration, - maybe_queue_status_url: None, - maybe_prompt_token: None, - maybe_queue_response_url: None, - }) -} diff --git a/crates/desktop/artcraft/src/core/commands/deprecated/image_edit/artcraft/handle_image_edit_artcraft.rs b/crates/desktop/artcraft/src/core/commands/deprecated/image_edit/artcraft/handle_image_edit_artcraft.rs deleted file mode 100644 index 0cf70d6d05..0000000000 --- a/crates/desktop/artcraft/src/core/commands/deprecated/image_edit/artcraft/handle_image_edit_artcraft.rs +++ /dev/null @@ -1,38 +0,0 @@ -use crate::core::commands::enqueue::generate_error::GenerateError; -use crate::core::commands::deprecated::image_edit::artcraft::handle_artcraft_flux_kontext_edit::handle_artcraft_flux_kontext_edit; -use crate::core::commands::deprecated::image_edit::artcraft::handle_artcraft_gpt_image_1_edit::handle_artcraft_gpt_image_1_edit; -use crate::core::commands::deprecated::image_edit::artcraft::handle_image_edit_artcraft_via_router::handle_image_edit_artcraft_via_router; -use crate::core::commands::deprecated::image_edit::enqueue_edit_image_command::{EnqueueEditImageCommand, ImageEditModel}; -use crate::core::commands::enqueue::task_enqueue_success::TaskEnqueueSuccess; -use crate::core::events::generation_events::common::GenerationModel; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::services::storyteller::state::storyteller_credential_manager::StorytellerCredentialManager; -use artcraft_router::api::router_image_model::RouterImageModel; -use tauri::AppHandle; - -pub async fn handle_image_edit_artcraft( - model: ImageEditModel, - request: &EnqueueEditImageCommand, - app: &AppHandle, - app_data_root: &AppDataRoot, - app_env_configs: &AppEnvConfigs, - storyteller_creds_manager: &StorytellerCredentialManager, -) -> Result { - - match model { - ImageEditModel::FluxProKontextMax => handle_artcraft_flux_kontext_edit(request, app, app_data_root, app_env_configs, storyteller_creds_manager).await, - ImageEditModel::Gemini25Flash | ImageEditModel::NanoBanana => { - handle_image_edit_artcraft_via_router(request, app_env_configs, storyteller_creds_manager, RouterImageModel::NanoBanana, GenerationModel::NanoBanana).await - }, - ImageEditModel::NanoBanana2 => handle_image_edit_artcraft_via_router(request, app_env_configs, storyteller_creds_manager, RouterImageModel::NanoBanana2, GenerationModel::NanoBanana2).await, - ImageEditModel::NanoBananaPro => handle_image_edit_artcraft_via_router(request, app_env_configs, storyteller_creds_manager, RouterImageModel::NanoBananaPro, GenerationModel::NanoBananaPro).await, - ImageEditModel::GptImage1 => handle_artcraft_gpt_image_1_edit(request, app, app_data_root, app_env_configs, storyteller_creds_manager).await, - ImageEditModel::GptImage1p5 => handle_image_edit_artcraft_via_router(request, app_env_configs, storyteller_creds_manager, RouterImageModel::GptImage1p5, GenerationModel::GptImage1p5).await, - ImageEditModel::Seedream4 => handle_image_edit_artcraft_via_router(request, app_env_configs, storyteller_creds_manager, RouterImageModel::Seedream4, GenerationModel::Seedream4).await, - ImageEditModel::Seedream4p5 => handle_image_edit_artcraft_via_router(request, app_env_configs, storyteller_creds_manager, RouterImageModel::Seedream4p5, GenerationModel::Seedream4p5).await, - ImageEditModel::Seedream5Lite => handle_image_edit_artcraft_via_router(request, app_env_configs, storyteller_creds_manager, RouterImageModel::Seedream5Lite, GenerationModel::Seedream5Lite).await, - ImageEditModel::QwenEdit2511Angles => handle_image_edit_artcraft_via_router(request, app_env_configs, storyteller_creds_manager, RouterImageModel::QwenEdit2511Angles, GenerationModel::QwenEdit2511Angles).await, - ImageEditModel::Flux2LoraAngles => handle_image_edit_artcraft_via_router(request, app_env_configs, storyteller_creds_manager, RouterImageModel::Flux2LoraAngles, GenerationModel::Flux2LoraAngles).await, - } -} diff --git a/crates/desktop/artcraft/src/core/commands/deprecated/image_edit/artcraft/handle_image_edit_artcraft_via_router.rs b/crates/desktop/artcraft/src/core/commands/deprecated/image_edit/artcraft/handle_image_edit_artcraft_via_router.rs deleted file mode 100644 index 3b9895339d..0000000000 --- a/crates/desktop/artcraft/src/core/commands/deprecated/image_edit/artcraft/handle_image_edit_artcraft_via_router.rs +++ /dev/null @@ -1,172 +0,0 @@ -use crate::core::api_adapters::aspect_ratio::common_aspect_ratio::CommonAspectRatio as DesktopCommonAspectRatio; -use crate::core::commands::enqueue::generate_error::{BadInputReason, GenerateError, MissingCredentialsReason}; -use crate::core::commands::deprecated::image_edit::enqueue_edit_image_command::{ - EditImageResolution, EditImageSize, EnqueueEditImageCommand, -}; -use crate::core::commands::enqueue::task_enqueue_success::TaskEnqueueSuccess; -use crate::core::events::generation_events::common::GenerationModel; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; -use crate::services::storyteller::state::storyteller_credential_manager::StorytellerCredentialManager; -use artcraft_router::api::router_aspect_ratio::RouterAspectRatio; -use artcraft_router::api::router_image_model::RouterImageModel; -use artcraft_router::api::router_resolution::RouterResolution; -use artcraft_router::api::image_list_ref::ImageListRef; -use artcraft_router::api::router_provider::RouterProvider; -use artcraft_router::client::request_mismatch_mitigation_strategy::RequestMismatchMitigationStrategy; -use artcraft_router::client::router_artcraft_client::RouterArtcraftClient; -use artcraft_router::client::router_client::RouterClient; -use artcraft_router::generate::generate_image::generate_image_request_builder::GenerateImageRequestBuilder; -use artcraft_router::generate::generate_image::image_generation_draft_or_request::ImageGenerationDraftOrRequest; -use enums::common::generation_provider::GenerationProvider; -use enums::tauri::tasks::task_type::TaskType; -use log::{error, info}; - -pub(super) const MAX_EDIT_IMAGES: usize = 10; - -pub(super) async fn handle_image_edit_artcraft_via_router( - request: &EnqueueEditImageCommand, - app_env_configs: &AppEnvConfigs, - storyteller_creds_manager: &StorytellerCredentialManager, - model: RouterImageModel, - generation_model: GenerationModel, -) -> Result { - let creds = match storyteller_creds_manager.get_credentials()? { - Some(creds) => creds, - None => return Err(GenerateError::MissingCredentials(MissingCredentialsReason::NeedsStorytellerCredentials)), - }; - - let client = RouterClient::Artcraft(RouterArtcraftClient::new( - app_env_configs.storyteller_host.clone(), - creds, - )); - - let mut media_tokens = Vec::with_capacity(MAX_EDIT_IMAGES); - - if let Some(scene_token) = request.scene_image_media_token.clone() { - media_tokens.push(scene_token); - } - if let Some(tokens) = request.image_media_tokens.as_ref() { - media_tokens.extend_from_slice(tokens); - } - - if media_tokens.len() > MAX_EDIT_IMAGES { - return Err(GenerateError::BadInput(BadInputReason::InvalidNumberOfInputImages { - min: 1, - max: MAX_EDIT_IMAGES as u32, - provided: media_tokens.len() as u32, - })); - } - - let image_inputs = if media_tokens.is_empty() { - None - } else { - Some(ImageListRef::MediaFileTokens(media_tokens)) - }; - - let aspect_ratio = get_aspect_ratio_edit(request); - let resolution = get_resolution_edit(request); - - let router_request = GenerateImageRequestBuilder { - model, - provider: RouterProvider::Artcraft, - prompt: Some(request.prompt.clone()), - image_inputs, - resolution, - aspect_ratio, - quality: None, // TODO(bt): Add quality - image_batch_count: request.image_count.map(|n| n as u16), - request_mismatch_mitigation_strategy: RequestMismatchMitigationStrategy::PayMoreUpgrade, - generation_mode_mismatch_strategy: None, - idempotency_token: None, - horizontal_angle: request.horizontal_angle, - vertical_angle: request.vertical_angle, - zoom: request.zoom, - }; - - let dor = router_request.build2()?; - - info!("Image Generation Request: {:?}", dor); - - let request = match dor { - ImageGenerationDraftOrRequest::Request(req) => req, - // Artcraft never returns a Draft — image-token resolution happens server-side. - // The only draft-producing models today are Kinovi-Midjourney variants, - // which are routed to a separate provider. - ImageGenerationDraftOrRequest::Draft(_) => unreachable!( - "Artcraft router should never produce a draft for image edits" - ), - }; - - let response = match request.send_request(&client).await { - Ok(resp) => { - info!("Successfully enqueued."); - resp - } - Err(err) => { - error!("Failed to enqueue: {:?}", err); - return Err(GenerateError::from(err)); - } - }; - - let job_id = response - .get_artcraft_payload() - .map(|p| p.inference_job_token.to_string()) - .ok_or(GenerateError::ResponseHadNoJobTokens)?; - - info!("Job token: {}", job_id); - - Ok(TaskEnqueueSuccess { - task_type: TaskType::ImageGeneration, - model: Some(generation_model), - provider: GenerationProvider::Artcraft, - provider_job_id: Some(job_id), - maybe_queue_status_url: None, - maybe_prompt_token: None, - maybe_queue_response_url: None, - }) -} - -fn get_aspect_ratio_edit(request: &EnqueueEditImageCommand) -> Option { - if let Some(ar) = request.common_aspect_ratio { - return Some(convert_desktop_aspect_ratio(ar)); - } - if let Some(ar) = request.aspect_ratio { - return Some(match ar { - EditImageSize::Auto => RouterAspectRatio::Auto, - EditImageSize::Square => RouterAspectRatio::Square, - EditImageSize::Wide => RouterAspectRatio::Wide, - EditImageSize::Tall => RouterAspectRatio::Tall, - }); - } - None -} - -fn get_resolution_edit(request: &EnqueueEditImageCommand) -> Option { - request.image_resolution.map(|res| match res { - EditImageResolution::OneK => RouterResolution::OneK, - EditImageResolution::TwoK => RouterResolution::TwoK, - EditImageResolution::FourK => RouterResolution::FourK, - }) -} - -fn convert_desktop_aspect_ratio(ar: DesktopCommonAspectRatio) -> RouterAspectRatio { - match ar { - DesktopCommonAspectRatio::Auto => RouterAspectRatio::Auto, - DesktopCommonAspectRatio::Square => RouterAspectRatio::Square, - DesktopCommonAspectRatio::WideThreeByTwo => RouterAspectRatio::WideThreeByTwo, - DesktopCommonAspectRatio::WideFourByThree => RouterAspectRatio::WideFourByThree, - DesktopCommonAspectRatio::WideFiveByFour => RouterAspectRatio::WideFiveByFour, - DesktopCommonAspectRatio::WideSixteenByNine => RouterAspectRatio::WideSixteenByNine, - DesktopCommonAspectRatio::WideTwentyOneByNine => RouterAspectRatio::WideTwentyOneByNine, - DesktopCommonAspectRatio::TallTwoByThree => RouterAspectRatio::TallTwoByThree, - DesktopCommonAspectRatio::TallThreeByFour => RouterAspectRatio::TallThreeByFour, - DesktopCommonAspectRatio::TallFourByFive => RouterAspectRatio::TallFourByFive, - DesktopCommonAspectRatio::TallNineBySixteen => RouterAspectRatio::TallNineBySixteen, - DesktopCommonAspectRatio::TallNineByTwentyOne => RouterAspectRatio::TallNineByTwentyOne, - DesktopCommonAspectRatio::Wide => RouterAspectRatio::Wide, - DesktopCommonAspectRatio::Tall => RouterAspectRatio::Tall, - DesktopCommonAspectRatio::Auto2k => RouterAspectRatio::Auto2k, - DesktopCommonAspectRatio::Auto4k => RouterAspectRatio::Auto4k, - DesktopCommonAspectRatio::SquareHd => RouterAspectRatio::SquareHd, - } -} diff --git a/crates/desktop/artcraft/src/core/commands/deprecated/image_edit/artcraft/mod.rs b/crates/desktop/artcraft/src/core/commands/deprecated/image_edit/artcraft/mod.rs deleted file mode 100644 index 49b2aaf980..0000000000 --- a/crates/desktop/artcraft/src/core/commands/deprecated/image_edit/artcraft/mod.rs +++ /dev/null @@ -1,5 +0,0 @@ -mod handle_image_edit_artcraft_via_router; -mod handle_artcraft_flux_kontext_edit; -mod handle_artcraft_gpt_image_1_edit; - -pub (super) mod handle_image_edit_artcraft; diff --git a/crates/desktop/artcraft/src/core/commands/deprecated/image_edit/enqueue_edit_image_command.rs b/crates/desktop/artcraft/src/core/commands/deprecated/image_edit/enqueue_edit_image_command.rs deleted file mode 100644 index c23b0db205..0000000000 --- a/crates/desktop/artcraft/src/core/commands/deprecated/image_edit/enqueue_edit_image_command.rs +++ /dev/null @@ -1,424 +0,0 @@ -use crate::core::api_adapters::aspect_ratio::common_aspect_ratio::CommonAspectRatio; -use crate::core::api_adapters::quality::common_quality::CommonQuality; -use crate::core::commands::enqueue::common::notify_frontend_of_errors::notify_frontend_of_errors; -use crate::core::commands::enqueue::generate_error::{BadInputReason, GenerateError}; -use crate::core::commands::deprecated::image_edit::artcraft::handle_image_edit_artcraft::handle_image_edit_artcraft; -use crate::core::commands::deprecated::image_edit::image_edit_models::image_edit_model_to_model_type; -use crate::core::commands::deprecated::image_edit::sora::handle_image_edit_sora::handle_image_edit_sora; -use crate::core::commands::enqueue::task_enqueue_success::TaskEnqueueSuccess; -use crate::core::commands::response::failure_response_wrapper::{CommandErrorResponseWrapper, CommandErrorStatus}; -use crate::core::commands::response::shorthand::{Response, ResponseOrErrorType}; -use crate::core::commands::response::success_response_wrapper::SerializeMarker; -use crate::core::events::basic_sendable_event_trait::BasicSendableEvent; -use crate::core::events::functional_events::credits_balance_changed_event::CreditsBalanceChangedEvent; -use crate::core::events::generation_events::common::{GenerationAction, GenerationServiceProvider}; -use crate::core::events::generation_events::generation_enqueue_failure_event::GenerationEnqueueFailureEvent; -use crate::core::events::generation_events::generation_enqueue_success_event::GenerationEnqueueSuccessEvent; -use crate::core::events::sendable_event_trait::SendableEvent; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; -use crate::core::state::artcraft_usage_tracker::artcraft_usage_tracker::ArtcraftUsageTracker; -use crate::core::state::artcraft_usage_tracker::artcraft_usage_type::{ArtcraftUsagePage, ArtcraftUsageType}; -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::core::state::data_dir::trait_data_subdir::DataSubdir; -use crate::core::state::provider_priority::ProviderPriorityStore; -use crate::core::state::task_database::TaskDatabase; -use crate::core::utils::get_url_file_extension::get_url_file_extension; -use crate::core::utils::simple_http_download::simple_http_download; -use crate::services::sora::state::sora_credential_manager::SoraCredentialManager; -use crate::services::sora::state::sora_task_queue::SoraTaskQueue; -use crate::services::storyteller::state::storyteller_credential_manager::StorytellerCredentialManager; -use artcraft_client::endpoints::media_files::get_media_file::get_media_file; -use artcraft_client::error::storyteller_error::StorytellerError; -use artcraft_client::utils::api_host::ApiHost; -use enums::common::generation_provider::GenerationProvider; -use enums::tauri::tasks::task_type::TaskType; -use enums::tauri::ux::tauri_command_caller::TauriCommandCaller; -use errors::AnyhowError; -use log::{error, info, warn}; -use openai_sora_client::recipes::image_remix_with_session_auto_renew::{image_remix_with_session_auto_renew, ImageRemixAutoRenewRequest}; -use openai_sora_client::recipes::image_upload_from_file_with_session_auto_renew::{image_upload_from_file_with_session_auto_renew, ImageUploadFromFileAutoRenewRequest}; -use openai_sora_client::recipes::maybe_upgrade_or_renew_session::maybe_upgrade_or_renew_session; -use openai_sora_client::requests::image_gen::common::{ImageSize, NumImages}; -use serde_derive::{Deserialize, Serialize}; -use sqlite_tasks::queries::create_task::{create_task, CreateTaskArgs}; -use std::time::Duration; -use tauri::{AppHandle, Manager, State}; -use tokens::tokens::media_files::MediaFileToken; - -/// This is used in the Tauri command bridge. -/// Don't change the serializations without coordinating with the frontend. -#[derive(Deserialize, Debug, Copy, Clone)] -#[serde(rename_all = "snake_case")] -pub enum ImageEditModel { - #[serde(rename = "flux_pro_kontext_max")] - FluxProKontextMax, - - #[serde(rename = "gemini_25_flash")] - Gemini25Flash, - - #[serde(rename = "nano_banana")] - NanoBanana, - - #[serde(rename = "nano_banana_2")] - NanoBanana2, - - #[serde(rename = "nano_banana_pro")] - NanoBananaPro, - - #[serde(rename = "gpt_image_1")] - GptImage1, - - #[serde(rename = "gpt_image_1p5")] - GptImage1p5, - - #[serde(rename = "seedream_4")] - Seedream4, - - #[serde(rename = "seedream_4p5")] - Seedream4p5, - - #[serde(rename = "seedream_5_lite")] - Seedream5Lite, - - #[serde(rename = "qwen_edit_2511_angles")] - QwenEdit2511Angles, - - #[serde(rename = "flux_2_lora_angles")] - Flux2LoraAngles, - -// #[serde(rename = "qwen")] -// Qwen, -// -// #[serde(rename = "seededit_3")] -// SeedEdit3, -} - -#[derive(Deserialize, Debug)] -pub struct EnqueueEditImageCommand { - /// The provider to use (defaults to Artcraft/Storyteller). - /// Not all (provider, model) combinations are valid. - pub provider: Option, - - /// The model to use. - pub model: Option, - - /// Images to use for the image edit. - /// The first image is typically a 2D canvas or 3D stage, but doesn't have to be. - /// There must be at least one image. - pub image_media_tokens: Option>, - - /// If set, this becomes the first image in the image media tokens (pushing back - /// each of the `image_media_tokens` by one). - /// This is useful if we want to do prompt engineering. - pub scene_image_media_token: Option, - - /// The user's image generation prompt. - pub prompt: String, - - /// Turn off the system prompt. - pub disable_system_prompt: Option, - - /// Number of images to generate. - pub image_count: Option, - - /// Aspect ratio. - #[deprecated(note="use common_aspect_ratio")] - pub aspect_ratio: Option, - - /// New field for aspect ratio. - /// Not all models support each of these aspect ratios, but we can choose or interpolate sensibly. - pub common_aspect_ratio: Option, - - /// Image quality. - pub image_quality: Option, - - /// Image resolution - pub image_resolution: Option, - - /// Quality. - /// Tends to be used by OpenAI models. - pub quality: Option, - - /// OPTIONAL. - /// Only for image angle edit models. - pub horizontal_angle: Option, - - /// OPTIONAL. - /// Only for image angle edit models. - pub vertical_angle: Option, - - /// OPTIONAL. - /// Only for image angle edit models. - pub zoom: Option, - - /// OPTIONAL. - /// Name of the frontend caller. - /// We'll use this to selectively trigger events. - pub frontend_caller: Option, - - /// OPTIONAL. - /// A frontend-defined identifier that we'll send back to the frontend - /// as a Tauri event on task completion. - pub frontend_subscriber_id: Option, - - /// OPTIONAL. - /// A frontend-defined payload that we'll send back to the frontend - /// as a Tauri event on task completion. - pub frontend_subscriber_payload: Option, -} - -#[derive(Deserialize, Debug, Copy, Clone)] -#[serde(rename_all = "snake_case")] -pub enum EditImageSize { - Auto, - Square, - Wide, - Tall, -} - -#[derive(Deserialize, Debug, Copy, Clone)] -#[serde(rename_all = "snake_case")] -pub enum EditImageQuality { - Auto, - High, - Medium, - Low, -} - -#[derive(Deserialize, Debug, Copy, Clone)] -#[serde(rename_all = "snake_case")] -pub enum EditImageResolution { - /// 1K - nano banana pro - OneK, - /// 2K - nano banana pro - TwoK, - /// 4K - nano banana pro - FourK, -} - -#[derive(Serialize, Debug)] -#[serde(rename_all = "snake_case")] -pub enum EnqueueEditImageErrorType { - /// Caller didn't specify a model - ModelNotSpecified, - - /// No model available for image generation - NoProviderAvailable, - - /// Generic bad request error - BadRequest, - - /// Generic server error - ServerError, - - /// The user is sending too many requests - TooManyConcurrentTasks, - /// User is not logged into Sora! - SoraLoginRequired, - /// The user needs to create a Sora account - SoraUsernameNotYetCreated, - /// The Sora service is having problems. Try again soon. - SoraIsHavingProblems, -} - -#[derive(Serialize)] -pub struct EnqueueEditImageSuccessResponse { -} - -impl SerializeMarker for EnqueueEditImageSuccessResponse {} - -#[tauri::command] -pub async fn enqueue_edit_image_command( - app: AppHandle, - request: EnqueueEditImageCommand, - app_data_root: State<'_, AppDataRoot>, - app_env_configs: State<'_, AppEnvConfigs>, - artcraft_usage_tracker: State<'_, ArtcraftUsageTracker>, - provider_priority_store: State<'_, ProviderPriorityStore>, - task_database: State<'_, TaskDatabase>, - storyteller_creds_manager: State<'_, StorytellerCredentialManager>, - sora_creds_manager: State<'_, SoraCredentialManager>, - sora_task_queue: State<'_, SoraTaskQueue>, -) -> ResponseOrErrorType { - - info!("enqueue_edit_image_command called; image media tokens : {:?}, full request: {:?}", - &request.image_media_tokens, &request); - - let result = handle_request( - &request, - &app, - &app_data_root, - &app_env_configs, - &artcraft_usage_tracker, - &provider_priority_store, - &task_database, - &storyteller_creds_manager, - &sora_creds_manager, - &sora_task_queue, - ).await; - - match result { - Err(err) => { - error!("Error enqueuing contextual edit image: {:?}", err); - - notify_frontend_of_errors(&app, &err).await; - - // TODO: Derive from err. Make service provider optional. - let event = GenerationEnqueueFailureEvent { - action: GenerationAction::GenerateImage, - service: GenerationServiceProvider::Artcraft, // FIXME: This is wrong. - model: None, - reason: None, - }; - - if let Err(err) = event.send(&app) { - error!("Failed to emit event: {:?}", err); // Fail open. - } - - Err(error_to_tauri_response(err)) - } - Ok(event) => { - let event = GenerationEnqueueSuccessEvent { - action: event.to_frontend_event_action(), - service: event.to_frontend_event_service(), - model: event.model, - }; - - if let Err(err) = event.send(&app) { - error!("Failed to emit event: {:?}", err); // Fail open. - } - - CreditsBalanceChangedEvent{}.send_infallible(&app); - - Ok(EnqueueEditImageSuccessResponse {}.into()) - } - } -} - -pub async fn handle_request( - request: &EnqueueEditImageCommand, - app: &AppHandle, - app_data_root: &AppDataRoot, - app_env_configs: &AppEnvConfigs, - artcraft_usage_tracker: &ArtcraftUsageTracker, - provider_priority_store: &ProviderPriorityStore, - task_database: &TaskDatabase, - storyteller_creds_manager: &StorytellerCredentialManager, - sora_creds_manager: &SoraCredentialManager, - sora_task_queue: &SoraTaskQueue, -) -> Result { - - let model = match request.model { - Some(model) => model, - None => { - return Err(GenerateError::no_model_specified()) - } - }; - - let provider = request.provider - .unwrap_or(GenerationProvider::Artcraft); - - info!("edit image with {:?} via provider {:?}", &model, &provider); - - let mut success_event = match provider { - GenerationProvider::Artcraft => { - handle_image_edit_artcraft( - model, - request, - app, - app_data_root, - app_env_configs, - storyteller_creds_manager, - ).await? - } - GenerationProvider::Sora => { - handle_image_edit_sora( - model, - request, - app, - app_data_root, - app_env_configs, - sora_creds_manager, - sora_task_queue, - ).await? - } - _ => { - return Err(GenerateError::BadProviderForModel { - provider, - model: image_edit_model_to_model_type(model), - }) - } - }; - - match request.frontend_caller { - Some(TauriCommandCaller::ImageEditor) => { - // NB: Certain image generations enqueued in the inpainting editor are classed - // as "image_generation" and won't update the inpainting UI. This is a hack to - // temporarily fix the UI event binding. - // TODO: The frontend shouldn't require us to change the type to inpainting. - success_event.task_type = TaskType::ImageInpaintEdit; - } - _ => {} // fall-through - } - - let result = success_event - .insert_into_task_database_with_frontend_payload( - task_database, - request.frontend_caller.clone(), - request.frontend_subscriber_id.as_deref(), - request.frontend_subscriber_payload.as_deref(), - ) - .await; - - if let Err(err) = result { - error!("Failed to create task in database: {:?}", err); - // NB: Fail open, but find a way to flag this. - } - - // TODO: We don't know that this is strictly the edit page. It could be the stage. It might also be nice to distinguish inpainting. - let num_images = request.image_count.map(|count| count as u16).unwrap_or(1); - if let Err(err) = artcraft_usage_tracker.record_image_generation(num_images, ArtcraftUsageType::ImageToResult, ArtcraftUsagePage::EditPage) { - // NB: Fail open. - warn!("Failed to report usage: {:?}", err); - } - - Ok(success_event) -} - -fn error_to_tauri_response(error: GenerateError) -> CommandErrorResponseWrapper { - let mut status = CommandErrorStatus::ServerError; - let mut error_type = EnqueueEditImageErrorType::ServerError; - let mut error_message = "A server error occurred. Please try again. If it continues, please tell our staff about the problem.".to_string(); - - match error { - GenerateError::BadInput(BadInputReason::NoModelSpecified) => { - status = CommandErrorStatus::BadRequest; - error_type = EnqueueEditImageErrorType::ModelNotSpecified; - error_message = "No model specified for image generation".to_string(); - } - GenerateError::NoProviderAvailable => { - status = CommandErrorStatus::ServerError; - error_type = EnqueueEditImageErrorType::NoProviderAvailable; - error_message = "No configured provider available for image generation".to_string(); - } - GenerateError::BadInput(BadInputReason::InvalidNumberOfRequestedImages { min, max, requested }) => { - status = CommandErrorStatus::BadRequest; - error_type = EnqueueEditImageErrorType::BadRequest; - error_message = format!("Invalid number of images requested ({}). Must be between {} and {}", requested, min, max); - - } - GenerateError::BadInput(BadInputReason::InvalidNumberOfInputImages{ min, max, provided }) => { - status = CommandErrorStatus::BadRequest; - error_type = EnqueueEditImageErrorType::BadRequest; - error_message = format!("Invalid number of input images ({}). Must be between {} and {}", provided, min, max); - } - _ => {} // Fall-through for now - } - - CommandErrorResponseWrapper { - status, - error_message: Some(error_message.to_string()), - error_type: Some(error_type), - error_details: None, - } -} diff --git a/crates/desktop/artcraft/src/core/commands/deprecated/image_edit/image_edit_models.rs b/crates/desktop/artcraft/src/core/commands/deprecated/image_edit/image_edit_models.rs deleted file mode 100644 index 6a0753e5b7..0000000000 --- a/crates/desktop/artcraft/src/core/commands/deprecated/image_edit/image_edit_models.rs +++ /dev/null @@ -1,19 +0,0 @@ -use enums::common::generation::common_model_type::CommonModelType; -use crate::core::commands::deprecated::image_edit::enqueue_edit_image_command::ImageEditModel; - -pub fn image_edit_model_to_model_type(model: ImageEditModel) -> CommonModelType { - match model { - ImageEditModel::FluxProKontextMax => CommonModelType::FluxProKontextMax, - ImageEditModel::Gemini25Flash => CommonModelType::NanoBanana, - ImageEditModel::NanoBanana => CommonModelType::NanoBanana, - ImageEditModel::NanoBanana2 => CommonModelType::NanoBanana2, - ImageEditModel::NanoBananaPro => CommonModelType::NanoBananaPro, - ImageEditModel::GptImage1 => CommonModelType::GptImage1, - ImageEditModel::GptImage1p5 => CommonModelType::GptImage1p5, - ImageEditModel::Seedream4 => CommonModelType::Seedream4, - ImageEditModel::Seedream4p5 => CommonModelType::Seedream4p5, - ImageEditModel::Seedream5Lite => CommonModelType::Seedream5Lite, - ImageEditModel::QwenEdit2511Angles => CommonModelType::QwenEdit2511Angles, - ImageEditModel::Flux2LoraAngles => CommonModelType::Flux2LoraAngles, - } -} diff --git a/crates/desktop/artcraft/src/core/commands/deprecated/image_edit/mod.rs b/crates/desktop/artcraft/src/core/commands/deprecated/image_edit/mod.rs deleted file mode 100644 index 146d166383..0000000000 --- a/crates/desktop/artcraft/src/core/commands/deprecated/image_edit/mod.rs +++ /dev/null @@ -1,5 +0,0 @@ -pub (super) mod artcraft; -pub (super) mod sora; -pub mod enqueue_edit_image_command; -pub mod image_edit_models; - diff --git a/crates/desktop/artcraft/src/core/commands/deprecated/image_edit/sora/handle_image_edit_sora.rs b/crates/desktop/artcraft/src/core/commands/deprecated/image_edit/sora/handle_image_edit_sora.rs deleted file mode 100644 index 91799a77f9..0000000000 --- a/crates/desktop/artcraft/src/core/commands/deprecated/image_edit/sora/handle_image_edit_sora.rs +++ /dev/null @@ -1,40 +0,0 @@ -use crate::core::commands::enqueue::generate_error::GenerateError; -use crate::core::commands::deprecated::image_edit::enqueue_edit_image_command::{EnqueueEditImageCommand, ImageEditModel}; -use crate::core::commands::deprecated::image_edit::image_edit_models::image_edit_model_to_model_type; -use crate::core::commands::deprecated::image_edit::sora::handle_sora_gpt_image_1_edit::handle_sora_gpt_image_1_edit; -use crate::core::commands::enqueue::task_enqueue_success::TaskEnqueueSuccess; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::services::sora::state::sora_credential_manager::SoraCredentialManager; -use crate::services::sora::state::sora_task_queue::SoraTaskQueue; -use enums::common::generation_provider::GenerationProvider; -use tauri::AppHandle; - -pub async fn handle_image_edit_sora( - model: ImageEditModel, - request: &EnqueueEditImageCommand, - app: &AppHandle, - app_data_root: &AppDataRoot, - app_env_configs: &AppEnvConfigs, - sora_creds_manager: &SoraCredentialManager, - sora_task_queue: &SoraTaskQueue, -) -> Result { - match model { - ImageEditModel::GptImage1 => { - handle_sora_gpt_image_1_edit( - request, - app, - app_data_root, - app_env_configs, - sora_creds_manager, - sora_task_queue, - ).await - }, - _ => { - Err(GenerateError::BadProviderForModel { - provider: GenerationProvider::Sora, - model: image_edit_model_to_model_type(model), - }) - } - } -} diff --git a/crates/desktop/artcraft/src/core/commands/deprecated/image_edit/sora/handle_sora_gpt_image_1_edit.rs b/crates/desktop/artcraft/src/core/commands/deprecated/image_edit/sora/handle_sora_gpt_image_1_edit.rs deleted file mode 100644 index f5d8927feb..0000000000 --- a/crates/desktop/artcraft/src/core/commands/deprecated/image_edit/sora/handle_sora_gpt_image_1_edit.rs +++ /dev/null @@ -1,183 +0,0 @@ -use crate::core::commands::enqueue::generate_error::{BadInputReason, GenerateError}; -use crate::core::commands::deprecated::image_edit::enqueue_edit_image_command::{EditImageSize, EnqueueEditImageCommand, EnqueueEditImageErrorType}; -use crate::core::commands::enqueue::task_enqueue_success::TaskEnqueueSuccess; -use crate::core::commands::response::failure_response_wrapper::{CommandErrorResponseWrapper, CommandErrorStatus}; -use crate::core::events::basic_sendable_event_trait::BasicSendableEvent; -use crate::core::events::functional_events::show_provider_login_modal_event::ShowProviderLoginModalEvent; -use crate::core::events::generation_events::common::{GenerationAction, GenerationModel, GenerationServiceProvider}; -use crate::core::events::generation_events::generation_enqueue_failure_event::GenerationEnqueueFailureEvent; -use crate::core::events::generation_events::generation_enqueue_success_event::GenerationEnqueueSuccessEvent; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::core::state::data_dir::trait_data_subdir::DataSubdir; -use crate::core::state::provider_priority::ProviderPriorityStore; -use crate::core::utils::get_url_file_extension::get_url_file_extension; -use crate::core::utils::simple_http_download::simple_http_download; -use crate::services::sora::state::sora_credential_manager::SoraCredentialManager; -use crate::services::sora::state::sora_task_queue::SoraTaskQueue; -use crate::services::storyteller::state::storyteller_credential_manager::StorytellerCredentialManager; -use anyhow::anyhow; -use enums::common::generation_provider::GenerationProvider; -use enums::tauri::tasks::task_type::TaskType; -use errors::AnyhowResult; -use uuid_utils::uuid::generate_random_uuid; -use log::{error, info, warn}; -use openai_sora_client::recipes::image_remix_with_session_auto_renew::{image_remix_with_session_auto_renew, ImageRemixAutoRenewRequest}; -use openai_sora_client::recipes::image_upload_from_file_with_session_auto_renew::{image_upload_from_file_with_session_auto_renew, ImageUploadFromFileAutoRenewRequest}; -use openai_sora_client::recipes::maybe_upgrade_or_renew_session::maybe_upgrade_or_renew_session; -use openai_sora_client::requests::image_gen::common::{ImageSize, NumImages}; -use std::time::Duration; -use artcraft_client::endpoints::media_files::get_media_file::get_media_file; -use tauri::AppHandle; - -const MAX_IMAGES: usize = 4; -const SORA_IMAGE_UPLOAD_TIMEOUT: Duration = Duration::from_millis(1000 * 30); // 30 seconds - -const SORA_IMAGE_REMIX_TIMEOUT: Duration = Duration::from_millis(1000 * 30); // 30 seconds - -const DEFAULT_ASPECT_RATIO : EditImageSize = EditImageSize::Square; - -pub async fn handle_sora_gpt_image_1_edit( - request: &EnqueueEditImageCommand, - app: &AppHandle, - app_data_root: &AppDataRoot, - app_env_configs: &AppEnvConfigs, - sora_creds_manager: &SoraCredentialManager, - sora_task_queue: &SoraTaskQueue, -) -> Result { - - let mut creds = match sora_creds_manager.get_credentials() { - Ok(Some(creds)) => creds, - Ok(None) => { - warn!("No Sora credentials found."); - ShowProviderLoginModalEvent::send_for_provider(GenerationProvider::Sora, &app); - return Err(GenerateError::needs_sora_credentials()); - } - Err(err) => { - error!("Failed to get Sora credentials: {:?}", err); - ShowProviderLoginModalEvent::send_for_provider(GenerationProvider::Sora, &app); - return Err(GenerateError::needs_sora_credentials()); - } - }; - - let mut media_tokens = Vec::with_capacity(10); - - if let Some(scene_image_media_token) = request.scene_image_media_token.clone() { - media_tokens.push(scene_image_media_token); - } - - if let Some(image_media_tokens) = request.image_media_tokens.as_ref() { - media_tokens.extend_from_slice(image_media_tokens); - } - - if media_tokens.len() > MAX_IMAGES { - return Err(GenerateError::BadInput(BadInputReason::InvalidNumberOfInputImages { - min: 1, - max: MAX_IMAGES as u32, - provided: media_tokens.len() as u32, - })); - } - - info!("Calling get media file API: {:?}", app_env_configs.storyteller_host); - - let mut files_to_upload_to_sora = Vec::with_capacity(10); - - // TODO(bt,2025-07-07): This is inefficient. Cache and parallelize this. - for media_token in media_tokens.iter() { - info!("Using media token: {:?}", media_token); - - let response = get_media_file( - &app_env_configs.storyteller_host, - media_token - ).await?; - - let media_file_url = &response.media_file.media_links.cdn_url; - let extension_with_dot = get_url_file_extension(media_file_url) - .map(|ext| format!(".{}", ext)) - .unwrap_or_else(|| ".png".to_string()); - - let filename = format!("{}{}", response.media_file.token.as_str(), extension_with_dot); - let filename = app_data_root.downloads_dir().path().join(&filename); - - simple_http_download(&media_file_url, &filename).await?; - - files_to_upload_to_sora.push(filename); - } - - let credential_updated = maybe_upgrade_or_renew_session(&mut creds) - .await - .map_err(|err| { - error!("Failed to upgrade or renew session: {:?}", err); - err - })?; - - if credential_updated { - info!("Storing updated credentials"); - sora_creds_manager.set_credentials(&creds)?; - } - - let mut sora_media_tokens = Vec::with_capacity(files_to_upload_to_sora.len()); - - for (i, file_path) in files_to_upload_to_sora.iter().enumerate() { - info!("Uploading image {} of {}...", (i+1), files_to_upload_to_sora.len()); - - let (response, maybe_new_credentials) = - image_upload_from_file_with_session_auto_renew(ImageUploadFromFileAutoRenewRequest { - file_path, - credentials: &creds, - request_timeout: Some(SORA_IMAGE_UPLOAD_TIMEOUT), // TODO: Centralize and make configurable. - }).await?; - - if let Some(new_creds) = maybe_new_credentials { - info!("Storing updated credentials."); - sora_creds_manager.set_credentials(&new_creds)?; - creds = new_creds; - } - - sora_media_tokens.push(response.id); - } - - let aspect_ratio = request.aspect_ratio.unwrap_or(DEFAULT_ASPECT_RATIO); - - let aspect_ratio = match aspect_ratio { - EditImageSize::Auto => ImageSize::Square, - EditImageSize::Square => ImageSize::Square, - EditImageSize::Wide => ImageSize::Wide, - EditImageSize::Tall => ImageSize::Tall, - }; - - info!("Calling Sora image generation..."); - - // TODO(bt,2025-04-21): Download media tokens. - // Note: This is incredibly inefficient. We should keep a local cache. - // Also, if they've already been uploaded to OpenAI, we shouldn't continue to re-upload. - - let (response, maybe_new_creds) = - image_remix_with_session_auto_renew(ImageRemixAutoRenewRequest { - prompt: request.prompt.to_string(), - num_images: NumImages::One, - image_size: aspect_ratio, - sora_media_tokens: sora_media_tokens.clone(), - credentials: &creds, - request_timeout: Some(SORA_IMAGE_REMIX_TIMEOUT), - }).await?; - - if let Some(new_creds) = maybe_new_creds { - info!("Storing updated credentials."); - sora_creds_manager.set_credentials(&new_creds)?; - } - - info!("New Sora Task ID: {:?} ", response.task_id); - - sora_task_queue.insert(&response.task_id)?; - - Ok(TaskEnqueueSuccess { - task_type: TaskType::ImageGeneration, - model: Some(GenerationModel::GptImage1), - provider: GenerationProvider::Sora, - provider_job_id: Some(response.task_id.to_string()), - maybe_queue_status_url: None, - maybe_prompt_token: None, - maybe_queue_response_url: None, - }) -} diff --git a/crates/desktop/artcraft/src/core/commands/deprecated/image_edit/sora/mod.rs b/crates/desktop/artcraft/src/core/commands/deprecated/image_edit/sora/mod.rs deleted file mode 100644 index f7b715be9d..0000000000 --- a/crates/desktop/artcraft/src/core/commands/deprecated/image_edit/sora/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -mod handle_sora_gpt_image_1_edit; -pub (super) mod handle_image_edit_sora; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/core/commands/deprecated/image_inpaint/artcraft/handle_artcraft_flux_dev_juggernaut_inpaint.rs b/crates/desktop/artcraft/src/core/commands/deprecated/image_inpaint/artcraft/handle_artcraft_flux_dev_juggernaut_inpaint.rs deleted file mode 100644 index 7908f1bf9c..0000000000 --- a/crates/desktop/artcraft/src/core/commands/deprecated/image_inpaint/artcraft/handle_artcraft_flux_dev_juggernaut_inpaint.rs +++ /dev/null @@ -1,161 +0,0 @@ -use crate::core::commands::enqueue::generate_error::{BadInputReason, GenerateError}; -use crate::core::commands::enqueue::image_bg_removal::enqueue_image_bg_removal_command::EnqueueImageBgRemovalCommand; -use crate::core::commands::deprecated::image_edit::enqueue_edit_image_command::{EditImageQuality, EditImageSize, EnqueueEditImageCommand}; -use crate::core::commands::deprecated::image_inpaint::enqueue_image_inpaint_command::EnqueueInpaintImageCommand; -use crate::core::commands::enqueue::task_enqueue_success::TaskEnqueueSuccess; -use crate::core::events::basic_sendable_event_trait::BasicSendableEvent; -use crate::core::events::generation_events::common::{GenerationAction, GenerationModel, GenerationServiceProvider}; -use crate::core::events::generation_events::generation_enqueue_failure_event::GenerationEnqueueFailureEvent; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::core::state::provider_priority::ProviderPriorityStore; -use crate::core::utils::save_base64_image_to_temp_dir::save_base64_image_to_temp_dir; -use crate::services::sora::state::sora_credential_manager::SoraCredentialManager; -use crate::services::sora::state::sora_task_queue::SoraTaskQueue; -use crate::services::storyteller::state::storyteller_credential_manager::StorytellerCredentialManager; -use anyhow::anyhow; -use artcraft_api_defs::generate::image::edit::gpt_image_1_edit_image::{GptImage1EditImageImageQuality, GptImage1EditImageImageSize, GptImage1EditImageNumImages, GptImage1EditImageRequest}; -use artcraft_api_defs::generate::image::inpaint::flux_dev_juggernaut_inpaint_image::{FluxDevJuggernautInpaintImageNumImages, FluxDevJuggernautInpaintImageRequest}; -use enums::common::generation_provider::GenerationProvider; -use enums::tauri::tasks::task_type::TaskType; -use uuid_utils::uuid::generate_random_uuid; -use images::encoding::image_bytes_to_png_bytes::image_bytes_to_png_bytes; -use images::encoding::image_bytes_to_png_bytes_with_dimensions::image_bytes_to_png_bytes_with_dimensions; -use images::mask_images::normalize_image_bytes_to_flux_mask::normalize_image_bytes_to_flux_mask; -use log::{error, info}; -use mimetypes::mimetype_info::mimetype_info::MimetypeInfo; -use artcraft_client::credentials::storyteller_credential_set::StorytellerCredentialSet; -use artcraft_client::endpoints::generate::image::edit::gpt_image_1_edit_image::gpt_image_1_edit_image; -use artcraft_client::endpoints::generate::image::inpaint::flux_dev_juggernaut_inpaint_image::flux_dev_juggernaut_inpaint_image; -use artcraft_client::endpoints::generate::image::inpaint::flux_pro_1_inpaint_image::flux_pro_1_inpaint_image; -use artcraft_client::endpoints::media_files::get_media_file::get_media_file; -use artcraft_client::endpoints::media_files::upload_image_media_file_from_bytes::{upload_image_media_file_from_bytes, ImageType, UploadImageBytesArgs}; -use artcraft_client::endpoints::media_files::upload_image_media_file_from_file::upload_image_media_file_from_file; -use tauri::AppHandle; -use tokens::tokens::media_files::MediaFileToken; - -pub async fn handle_artcraft_flux_dev_juggernaut_inpaint( - request: &EnqueueInpaintImageCommand, - app: &AppHandle, - app_data_root: &AppDataRoot, - app_env_configs: &AppEnvConfigs, - storyteller_creds_manager: &StorytellerCredentialManager, -) -> Result { - - let creds = match storyteller_creds_manager.get_credentials()? { - Some(creds) => creds, - None => { - return Err(GenerateError::needs_storyteller_credentials()); - }, - }; - - let image_media_token = match &request.image_media_token { - Some(token) => token.clone(), - None => { - return Err(GenerateError::required_source_image_not_provided()); - }, - }; - - let mask_media_token = get_mask( - request, - app_env_configs, - &creds, - ).await?; - - info!("Calling Artcraft flux dev juggernaut inpaint ..."); - - let uuid_idempotency_token = generate_random_uuid(); - - let num_images = match request.image_count { - None => None, - Some(1) => Some(FluxDevJuggernautInpaintImageNumImages::One), - Some(2) => Some(FluxDevJuggernautInpaintImageNumImages::Two), - Some(3) => Some(FluxDevJuggernautInpaintImageNumImages::Three), - Some(4) => Some(FluxDevJuggernautInpaintImageNumImages::Four), - Some(other) => { - return Err(GenerateError::BadInput(BadInputReason::InvalidNumberOfRequestedImages { - min: 1, - max: 4, - requested: other, - })); - }, - }; - - let request = FluxDevJuggernautInpaintImageRequest { - uuid_idempotency_token, - prompt: Some(request.prompt.clone()), - image_media_token, - mask_media_token, - num_images, - }; - - let result = flux_dev_juggernaut_inpaint_image( - &app_env_configs.storyteller_host, - Some(&creds), - request, - ).await; - - let job_id = match result { - Ok(enqueued) => { - // TODO(bt,2025-07-05): Enqueue job token? - info!("Successfully enqueued Artcraft flux dev juggernaut inpaint. Job token: {}", - enqueued.inference_job_token); - enqueued.inference_job_token - } - Err(err) => { - error!("Failed to use Artcraft flux dev juggernaut inpaint: {:?}", err); - return Err(GenerateError::from(err)); - } - }; - - Ok(TaskEnqueueSuccess { - provider: GenerationProvider::Artcraft, - model: Some(GenerationModel::FluxDevJuggernaut), - provider_job_id: Some(job_id.to_string()), - task_type: TaskType::ImageInpaintEdit, - maybe_queue_status_url: None, - maybe_prompt_token: None, - maybe_queue_response_url: None, - }) -} - -async fn get_mask( - request: &EnqueueInpaintImageCommand, - app_env_configs: &AppEnvConfigs, - storyteller_creds: &StorytellerCredentialSet, -) -> Result { - - if request.mask_image_media_token.is_some() && request.mask_image_raw_bytes.is_some() { - return Err(GenerateError::both_image_mask_media_token_and_bytes_supplied()); - } - - if let Some(token) = request.mask_image_media_token.as_ref() { - return Ok(token.clone()); - }; - - let image_bytes = request.mask_image_raw_bytes.as_ref() - .ok_or(GenerateError::required_source_image_mask_not_provided())?; - - let image_bytes = normalize_image_bytes_to_flux_mask(image_bytes) - .map_err(|err| { - error!("Failed to convert image bytes to png: {:?}", err); - GenerateError::AnyhowError(anyhow!("Failed to convert image bytes to png mask")) - })?; - - info!("Uploading image media file from bytes..."); - - let result = upload_image_media_file_from_bytes(UploadImageBytesArgs { - api_host: &app_env_configs.storyteller_host, - maybe_creds: Some(&storyteller_creds), - image_bytes: image_bytes.0, - image_type: ImageType::Png, - is_intermediate_system_file: true, - maybe_generation_provider: None, - }).await - .map_err(|err| { - error!("Failed to upload image media file: {:?}", err); - GenerateError::from(err) - })?; - - Ok(result.media_file_token) -} diff --git a/crates/desktop/artcraft/src/core/commands/deprecated/image_inpaint/artcraft/handle_artcraft_flux_pro_1_inpaint.rs b/crates/desktop/artcraft/src/core/commands/deprecated/image_inpaint/artcraft/handle_artcraft_flux_pro_1_inpaint.rs deleted file mode 100644 index d7653b87a9..0000000000 --- a/crates/desktop/artcraft/src/core/commands/deprecated/image_inpaint/artcraft/handle_artcraft_flux_pro_1_inpaint.rs +++ /dev/null @@ -1,160 +0,0 @@ -use crate::core::commands::enqueue::generate_error::{BadInputReason, GenerateError}; -use crate::core::commands::enqueue::image_bg_removal::enqueue_image_bg_removal_command::EnqueueImageBgRemovalCommand; -use crate::core::commands::deprecated::image_edit::enqueue_edit_image_command::{EditImageQuality, EditImageSize, EnqueueEditImageCommand}; -use crate::core::commands::deprecated::image_inpaint::enqueue_image_inpaint_command::EnqueueInpaintImageCommand; -use crate::core::commands::enqueue::task_enqueue_success::TaskEnqueueSuccess; -use crate::core::events::basic_sendable_event_trait::BasicSendableEvent; -use crate::core::events::generation_events::common::{GenerationAction, GenerationModel, GenerationServiceProvider}; -use crate::core::events::generation_events::generation_enqueue_failure_event::GenerationEnqueueFailureEvent; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::core::state::provider_priority::ProviderPriorityStore; -use crate::core::utils::save_base64_image_to_temp_dir::save_base64_image_to_temp_dir; -use crate::services::sora::state::sora_credential_manager::SoraCredentialManager; -use crate::services::sora::state::sora_task_queue::SoraTaskQueue; -use crate::services::storyteller::state::storyteller_credential_manager::StorytellerCredentialManager; -use anyhow::anyhow; -use artcraft_api_defs::generate::image::edit::gpt_image_1_edit_image::{GptImage1EditImageImageQuality, GptImage1EditImageImageSize, GptImage1EditImageNumImages, GptImage1EditImageRequest}; -use artcraft_api_defs::generate::image::inpaint::flux_pro_1_inpaint_image::{FluxPro1InpaintImageNumImages, FluxPro1InpaintImageRequest}; -use enums::common::generation_provider::GenerationProvider; -use enums::tauri::tasks::task_type::TaskType; -use uuid_utils::uuid::generate_random_uuid; -use images::encoding::image_bytes_to_png_bytes::image_bytes_to_png_bytes; -use images::encoding::image_bytes_to_png_bytes_with_dimensions::image_bytes_to_png_bytes_with_dimensions; -use images::mask_images::normalize_image_bytes_to_flux_mask::normalize_image_bytes_to_flux_mask; -use log::{error, info}; -use mimetypes::mimetype_info::mimetype_info::MimetypeInfo; -use artcraft_client::credentials::storyteller_credential_set::StorytellerCredentialSet; -use artcraft_client::endpoints::generate::image::edit::gpt_image_1_edit_image::gpt_image_1_edit_image; -use artcraft_client::endpoints::generate::image::inpaint::flux_pro_1_inpaint_image::flux_pro_1_inpaint_image; -use artcraft_client::endpoints::media_files::get_media_file::get_media_file; -use artcraft_client::endpoints::media_files::upload_image_media_file_from_bytes::{upload_image_media_file_from_bytes, ImageType, UploadImageBytesArgs}; -use artcraft_client::endpoints::media_files::upload_image_media_file_from_file::upload_image_media_file_from_file; -use tauri::AppHandle; -use tokens::tokens::media_files::MediaFileToken; - -pub async fn handle_artcraft_flux_pro_1_inpaint( - request: &EnqueueInpaintImageCommand, - app: &AppHandle, - app_data_root: &AppDataRoot, - app_env_configs: &AppEnvConfigs, - storyteller_creds_manager: &StorytellerCredentialManager, -) -> Result { - - let creds = match storyteller_creds_manager.get_credentials()? { - Some(creds) => creds, - None => { - return Err(GenerateError::needs_storyteller_credentials()); - }, - }; - - let image_media_token = match &request.image_media_token { - Some(token) => token.clone(), - None => { - return Err(GenerateError::required_source_image_not_provided()); - }, - }; - - let mask_media_token = get_mask( - request, - app_env_configs, - &creds, - ).await?; - - info!("Calling Artcraft flux pro 1 inpaint ..."); - - let uuid_idempotency_token = generate_random_uuid(); - - let num_images = match request.image_count { - None => None, - Some(1) => Some(FluxPro1InpaintImageNumImages::One), - Some(2) => Some(FluxPro1InpaintImageNumImages::Two), - Some(3) => Some(FluxPro1InpaintImageNumImages::Three), - Some(4) => Some(FluxPro1InpaintImageNumImages::Four), - Some(other) => { - return Err(GenerateError::BadInput(BadInputReason::InvalidNumberOfRequestedImages { - min: 1, - max: 4, - requested: other, - })); - }, - }; - - let request = FluxPro1InpaintImageRequest { - uuid_idempotency_token, - prompt: Some(request.prompt.clone()), - image_media_token, - mask_media_token, - num_images, - }; - - let result = flux_pro_1_inpaint_image( - &app_env_configs.storyteller_host, - Some(&creds), - request, - ).await; - - let job_id = match result { - Ok(enqueued) => { - // TODO(bt,2025-07-05): Enqueue job token? - info!("Successfully enqueued Artcraft flux pro 1 inpaint. Job token: {}", - enqueued.inference_job_token); - enqueued.inference_job_token - } - Err(err) => { - error!("Failed to use Artcraft flux pro 1 inpaint: {:?}", err); - return Err(GenerateError::from(err)); - } - }; - - Ok(TaskEnqueueSuccess { - provider: GenerationProvider::Artcraft, - model: Some(GenerationModel::FluxPro1), - provider_job_id: Some(job_id.to_string()), - task_type: TaskType::ImageInpaintEdit, - maybe_queue_status_url: None, - maybe_prompt_token: None, - maybe_queue_response_url: None, - }) -} - -async fn get_mask( - request: &EnqueueInpaintImageCommand, - app_env_configs: &AppEnvConfigs, - storyteller_creds: &StorytellerCredentialSet, -) -> Result { - - if request.mask_image_media_token.is_some() && request.mask_image_raw_bytes.is_some() { - return Err(GenerateError::both_image_mask_media_token_and_bytes_supplied()); - } - - if let Some(token) = request.mask_image_media_token.as_ref() { - return Ok(token.clone()); - }; - - let image_bytes = request.mask_image_raw_bytes.as_ref() - .ok_or(GenerateError::required_source_image_mask_not_provided())?; - - let image_bytes = normalize_image_bytes_to_flux_mask(image_bytes) - .map_err(|err| { - error!("Failed to convert image bytes to png: {:?}", err); - GenerateError::AnyhowError(anyhow!("could not encode image mask to png")) - })?; - - info!("Uploading image media file from bytes..."); - - let result = upload_image_media_file_from_bytes(UploadImageBytesArgs { - api_host: &app_env_configs.storyteller_host, - maybe_creds: Some(&storyteller_creds), - image_bytes: image_bytes.0, - image_type: ImageType::Png, - is_intermediate_system_file: true, - maybe_generation_provider: None, - }).await - .map_err(|err| { - error!("Failed to upload image media file: {:?}", err); - GenerateError::from(err) - })?; - - Ok(result.media_file_token) -} diff --git a/crates/desktop/artcraft/src/core/commands/deprecated/image_inpaint/artcraft/handle_artcraft_flux_pro_kontext_inpaint.rs b/crates/desktop/artcraft/src/core/commands/deprecated/image_inpaint/artcraft/handle_artcraft_flux_pro_kontext_inpaint.rs deleted file mode 100644 index c999e9ad5f..0000000000 --- a/crates/desktop/artcraft/src/core/commands/deprecated/image_inpaint/artcraft/handle_artcraft_flux_pro_kontext_inpaint.rs +++ /dev/null @@ -1,132 +0,0 @@ -use crate::core::commands::enqueue::generate_error::{BadInputReason, GenerateError}; -use crate::core::commands::enqueue::image_bg_removal::enqueue_image_bg_removal_command::EnqueueImageBgRemovalCommand; -use crate::core::commands::deprecated::image_edit::enqueue_edit_image_command::{EditImageQuality, EditImageSize, EnqueueEditImageCommand}; -use crate::core::commands::deprecated::image_inpaint::enqueue_image_inpaint_command::EnqueueInpaintImageCommand; -use crate::core::commands::enqueue::task_enqueue_success::TaskEnqueueSuccess; -use crate::core::events::basic_sendable_event_trait::BasicSendableEvent; -use crate::core::events::generation_events::common::{GenerationAction, GenerationModel, GenerationServiceProvider}; -use crate::core::events::generation_events::generation_enqueue_failure_event::GenerationEnqueueFailureEvent; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::core::state::provider_priority::ProviderPriorityStore; -use crate::core::utils::save_base64_image_to_temp_dir::save_base64_image_to_temp_dir; -use crate::services::sora::state::sora_credential_manager::SoraCredentialManager; -use crate::services::sora::state::sora_task_queue::SoraTaskQueue; -use crate::services::storyteller::state::storyteller_credential_manager::StorytellerCredentialManager; -use anyhow::anyhow; -use artcraft_api_defs::generate::image::edit::flux_pro_kontext_max_edit_image::{FluxProKontextMaxEditImageNumImages, FluxProKontextMaxEditImageRequest}; -use artcraft_api_defs::generate::image::edit::gpt_image_1_edit_image::{GptImage1EditImageImageQuality, GptImage1EditImageImageSize, GptImage1EditImageNumImages, GptImage1EditImageRequest}; -use artcraft_api_defs::generate::image::inpaint::flux_pro_1_inpaint_image::{FluxPro1InpaintImageNumImages, FluxPro1InpaintImageRequest}; -use enums::common::generation_provider::GenerationProvider; -use enums::tauri::tasks::task_type::TaskType; -use uuid_utils::uuid::generate_random_uuid; -use images::encoding::image_bytes_to_png_bytes::image_bytes_to_png_bytes; -use images::encoding::image_bytes_to_png_bytes_with_dimensions::image_bytes_to_png_bytes_with_dimensions; -use images::mask_images::normalize_image_bytes_to_flux_mask::normalize_image_bytes_to_flux_mask; -use log::{error, info}; -use mimetypes::mimetype_info::mimetype_info::MimetypeInfo; -use artcraft_client::credentials::storyteller_credential_set::StorytellerCredentialSet; -use artcraft_client::endpoints::generate::image::edit::flux_pro_kontext_max_edit_image::flux_pro_kontext_max_edit_image; -use artcraft_client::endpoints::generate::image::edit::gpt_image_1_edit_image::gpt_image_1_edit_image; -use artcraft_client::endpoints::generate::image::inpaint::flux_pro_1_inpaint_image::flux_pro_1_inpaint_image; -use artcraft_client::endpoints::media_files::get_media_file::get_media_file; -use artcraft_client::endpoints::media_files::upload_image_media_file_from_bytes::{upload_image_media_file_from_bytes, ImageType, UploadImageBytesArgs}; -use artcraft_client::endpoints::media_files::upload_image_media_file_from_file::upload_image_media_file_from_file; -use tauri::AppHandle; -use tokens::tokens::media_files::MediaFileToken; - -pub async fn handle_artcraft_flux_pro_kontext_inpaint( - request: &EnqueueInpaintImageCommand, - app: &AppHandle, - app_data_root: &AppDataRoot, - app_env_configs: &AppEnvConfigs, - storyteller_creds_manager: &StorytellerCredentialManager, -) -> Result { - - let creds = match storyteller_creds_manager.get_credentials()? { - Some(creds) => creds, - None => { - return Err(GenerateError::needs_storyteller_credentials()); - }, - }; - - let image_media_token = match &request.image_media_token { - Some(token) => token.clone(), - None => { - return Err(GenerateError::required_source_image_not_provided()); - }, - }; - - //let image_media_file = get_media_file( - // &app_env_configs.storyteller_host, - // &image_media_token, - //).await.map_err(|err| { - // error!("Failed to get media file for image: {:?}", err); - // InternalImageInpaintError::StorytellerError(err) - //})?; - - // TODO: Experiment in seeing if we can use the mask in any useful way. - - // let mask_media_token = get_mask( - // request, - // app_env_configs, - // &creds, - // ).await?; - - info!("Calling Artcraft flux pro kontext inpaint ..."); - - let uuid_idempotency_token = generate_random_uuid(); - - let num_images = match request.image_count { - None => None, - Some(1) => Some(FluxProKontextMaxEditImageNumImages::One), - Some(2) => Some(FluxProKontextMaxEditImageNumImages::Two), - Some(3) => Some(FluxProKontextMaxEditImageNumImages::Three), - Some(4) => Some(FluxProKontextMaxEditImageNumImages::Four), - Some(other) => { - return Err(GenerateError::BadInput(BadInputReason::InvalidNumberOfRequestedImages { - min: 1, - max: 4, - requested: other, - })); - }, - }; - - - let request = FluxProKontextMaxEditImageRequest { - uuid_idempotency_token, - prompt: Some(request.prompt.clone()), - image_media_token, - num_images, - }; - - let result = flux_pro_kontext_max_edit_image( - &app_env_configs.storyteller_host, - Some(&creds), - request, - ).await; - - - let job_id = match result { - Ok(enqueued) => { - // TODO(bt,2025-07-05): Enqueue job token? - info!("Successfully enqueued Artcraft flux pro kontext inpaint. Job token: {}", - enqueued.inference_job_token); - enqueued.inference_job_token - } - Err(err) => { - error!("Failed to use Artcraft flux pro kontext inpaint: {:?}", err); - return Err(GenerateError::from(err)); - } - }; - - Ok(TaskEnqueueSuccess { - provider: GenerationProvider::Artcraft, - model: Some(GenerationModel::FluxProKontextMax), - provider_job_id: Some(job_id.to_string()), - task_type: TaskType::ImageInpaintEdit, - maybe_queue_status_url: None, - maybe_prompt_token: None, - maybe_queue_response_url: None, - }) -} diff --git a/crates/desktop/artcraft/src/core/commands/deprecated/image_inpaint/artcraft/handle_artcraft_nano_banana_inpaint.rs b/crates/desktop/artcraft/src/core/commands/deprecated/image_inpaint/artcraft/handle_artcraft_nano_banana_inpaint.rs deleted file mode 100644 index 213c04d12a..0000000000 --- a/crates/desktop/artcraft/src/core/commands/deprecated/image_inpaint/artcraft/handle_artcraft_nano_banana_inpaint.rs +++ /dev/null @@ -1,117 +0,0 @@ -use crate::core::commands::enqueue::generate_error::{BadInputReason, GenerateError}; -use crate::core::commands::enqueue::image_bg_removal::enqueue_image_bg_removal_command::EnqueueImageBgRemovalCommand; -use crate::core::commands::deprecated::image_edit::enqueue_edit_image_command::{EditImageQuality, EditImageSize, EnqueueEditImageCommand}; -use crate::core::commands::deprecated::image_inpaint::enqueue_image_inpaint_command::EnqueueInpaintImageCommand; -use crate::core::commands::enqueue::task_enqueue_success::TaskEnqueueSuccess; -use crate::core::events::basic_sendable_event_trait::BasicSendableEvent; -use crate::core::events::generation_events::common::{GenerationAction, GenerationModel, GenerationServiceProvider}; -use crate::core::events::generation_events::generation_enqueue_failure_event::GenerationEnqueueFailureEvent; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::core::state::provider_priority::ProviderPriorityStore; -use crate::core::utils::save_base64_image_to_temp_dir::save_base64_image_to_temp_dir; -use crate::services::sora::state::sora_credential_manager::SoraCredentialManager; -use crate::services::sora::state::sora_task_queue::SoraTaskQueue; -use crate::services::storyteller::state::storyteller_credential_manager::StorytellerCredentialManager; -use anyhow::anyhow; -use artcraft_api_defs::generate::image::edit::flux_pro_kontext_max_edit_image::{FluxProKontextMaxEditImageNumImages, FluxProKontextMaxEditImageRequest}; -use artcraft_api_defs::generate::image::edit::gemini_25_flash_edit_image::{Gemini25FlashEditImageNumImages, Gemini25FlashEditImageRequest}; -use artcraft_api_defs::generate::image::edit::gpt_image_1_edit_image::{GptImage1EditImageImageQuality, GptImage1EditImageImageSize, GptImage1EditImageNumImages, GptImage1EditImageRequest}; -use artcraft_api_defs::generate::image::inpaint::flux_pro_1_inpaint_image::{FluxPro1InpaintImageNumImages, FluxPro1InpaintImageRequest}; -use enums::common::generation_provider::GenerationProvider; -use enums::tauri::tasks::task_type::TaskType; -use uuid_utils::uuid::generate_random_uuid; -use images::encoding::image_bytes_to_png_bytes::image_bytes_to_png_bytes; -use images::encoding::image_bytes_to_png_bytes_with_dimensions::image_bytes_to_png_bytes_with_dimensions; -use images::mask_images::normalize_image_bytes_to_flux_mask::normalize_image_bytes_to_flux_mask; -use log::{error, info}; -use mimetypes::mimetype_info::mimetype_info::MimetypeInfo; -use artcraft_client::credentials::storyteller_credential_set::StorytellerCredentialSet; -use artcraft_client::endpoints::generate::image::edit::flux_pro_kontext_max_edit_image::flux_pro_kontext_max_edit_image; -use artcraft_client::endpoints::generate::image::edit::gemini_25_flash_edit_image::gemini_25_flash_edit_image; -use artcraft_client::endpoints::generate::image::edit::gpt_image_1_edit_image::gpt_image_1_edit_image; -use artcraft_client::endpoints::generate::image::inpaint::flux_pro_1_inpaint_image::flux_pro_1_inpaint_image; -use artcraft_client::endpoints::media_files::get_media_file::get_media_file; -use artcraft_client::endpoints::media_files::upload_image_media_file_from_bytes::{upload_image_media_file_from_bytes, ImageType, UploadImageBytesArgs}; -use artcraft_client::endpoints::media_files::upload_image_media_file_from_file::upload_image_media_file_from_file; -use tauri::AppHandle; -use tokens::tokens::media_files::MediaFileToken; - -pub async fn handle_artcraft_nano_banana_inpaint( - request: &EnqueueInpaintImageCommand, - app: &AppHandle, - app_data_root: &AppDataRoot, - app_env_configs: &AppEnvConfigs, - storyteller_creds_manager: &StorytellerCredentialManager, -) -> Result { - - let creds = match storyteller_creds_manager.get_credentials()? { - Some(creds) => creds, - None => { - return Err(GenerateError::needs_storyteller_credentials()); - }, - }; - - let image_media_token = match &request.image_media_token { - Some(token) => token.clone(), - None => { - return Err(GenerateError::required_source_image_not_provided()); - }, - }; - - info!("Calling Artcraft gemini 2.5 flash inpaint ..."); - - let uuid_idempotency_token = generate_random_uuid(); - - let num_images = match request.image_count { - None => None, - Some(1) => Some(Gemini25FlashEditImageNumImages::One), - Some(2) => Some(Gemini25FlashEditImageNumImages::Two), - Some(3) => Some(Gemini25FlashEditImageNumImages::Three), - Some(4) => Some(Gemini25FlashEditImageNumImages::Four), - Some(other) => { - return Err(GenerateError::BadInput(BadInputReason::InvalidNumberOfRequestedImages { - min: 1, - max: 4, - requested: other, - })); - }, - }; - - let request = Gemini25FlashEditImageRequest { - uuid_idempotency_token, - prompt: Some(request.prompt.clone()), - image_media_tokens: Some(vec![image_media_token]), - num_images, - image_quality: None, - }; - - let result = gemini_25_flash_edit_image( - &app_env_configs.storyteller_host, - Some(&creds), - request, - ).await; - - let job_id = match result { - Ok(enqueued) => { - // TODO(bt,2025-07-05): Enqueue job token? - info!("Successfully enqueued Artcraft gemini 2.5 flash inpaint. Job token: {}", - enqueued.inference_job_token); - enqueued.inference_job_token - } - Err(err) => { - error!("Failed to use Artcraft gemini 2.5 flash inpaint: {:?}", err); - return Err(GenerateError::from(err)); - } - }; - - Ok(TaskEnqueueSuccess { - provider: GenerationProvider::Artcraft, - model: Some(GenerationModel::Gemini25Flash), - provider_job_id: Some(job_id.to_string()), - task_type: TaskType::ImageInpaintEdit, - maybe_queue_status_url: None, - maybe_prompt_token: None, - maybe_queue_response_url: None, - }) -} diff --git a/crates/desktop/artcraft/src/core/commands/deprecated/image_inpaint/artcraft/handle_inpaint_artcraft.rs b/crates/desktop/artcraft/src/core/commands/deprecated/image_inpaint/artcraft/handle_inpaint_artcraft.rs deleted file mode 100644 index 66deb9afa5..0000000000 --- a/crates/desktop/artcraft/src/core/commands/deprecated/image_inpaint/artcraft/handle_inpaint_artcraft.rs +++ /dev/null @@ -1,60 +0,0 @@ -use crate::core::commands::enqueue::generate_error::GenerateError; -use crate::core::commands::deprecated::image_inpaint::artcraft::handle_artcraft_flux_dev_juggernaut_inpaint::handle_artcraft_flux_dev_juggernaut_inpaint; -use crate::core::commands::deprecated::image_inpaint::artcraft::handle_artcraft_flux_pro_1_inpaint::handle_artcraft_flux_pro_1_inpaint; -use crate::core::commands::deprecated::image_inpaint::artcraft::handle_artcraft_flux_pro_kontext_inpaint::handle_artcraft_flux_pro_kontext_inpaint; -use crate::core::commands::deprecated::image_inpaint::artcraft::handle_artcraft_nano_banana_inpaint::handle_artcraft_nano_banana_inpaint; -use crate::core::commands::deprecated::image_inpaint::enqueue_image_inpaint_command::{EnqueueInpaintImageCommand, ImageInpaintModel}; -use crate::core::commands::enqueue::task_enqueue_success::TaskEnqueueSuccess; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::services::storyteller::state::storyteller_credential_manager::StorytellerCredentialManager; -use tauri::AppHandle; - -pub async fn handle_inpaint_artcraft( - model: ImageInpaintModel, - request: &EnqueueInpaintImageCommand, - app: &AppHandle, - app_data_root: &AppDataRoot, - app_env_configs: &AppEnvConfigs, - storyteller_creds_manager: &StorytellerCredentialManager, -) -> Result { - - match model { - ImageInpaintModel::FluxDevJuggernaut => { - handle_artcraft_flux_dev_juggernaut_inpaint( - request, - app, - app_data_root, - app_env_configs, - storyteller_creds_manager, - ).await - } - ImageInpaintModel::FluxPro1 => { - handle_artcraft_flux_pro_1_inpaint( - request, - app, - app_data_root, - app_env_configs, - storyteller_creds_manager, - ).await - } - ImageInpaintModel::FluxProKontextMax => { - handle_artcraft_flux_pro_kontext_inpaint( - request, - app, - app_data_root, - app_env_configs, - storyteller_creds_manager, - ).await - } - ImageInpaintModel::Gemini25Flash => { - handle_artcraft_nano_banana_inpaint( - request, - app, - app_data_root, - app_env_configs, - storyteller_creds_manager, - ).await - } - } -} diff --git a/crates/desktop/artcraft/src/core/commands/deprecated/image_inpaint/artcraft/mod.rs b/crates/desktop/artcraft/src/core/commands/deprecated/image_inpaint/artcraft/mod.rs deleted file mode 100644 index b0b915f5da..0000000000 --- a/crates/desktop/artcraft/src/core/commands/deprecated/image_inpaint/artcraft/mod.rs +++ /dev/null @@ -1,6 +0,0 @@ -pub (super) mod handle_inpaint_artcraft; - -mod handle_artcraft_flux_pro_1_inpaint; -mod handle_artcraft_flux_dev_juggernaut_inpaint; -mod handle_artcraft_flux_pro_kontext_inpaint; -mod handle_artcraft_nano_banana_inpaint; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/core/commands/deprecated/image_inpaint/enqueue_image_inpaint_command.rs b/crates/desktop/artcraft/src/core/commands/deprecated/image_inpaint/enqueue_image_inpaint_command.rs deleted file mode 100644 index 6ab4469dcc..0000000000 --- a/crates/desktop/artcraft/src/core/commands/deprecated/image_inpaint/enqueue_image_inpaint_command.rs +++ /dev/null @@ -1,348 +0,0 @@ -use crate::core::api_adapters::quality::common_quality::CommonQuality; -use crate::core::commands::enqueue::common::notify_frontend_of_errors::notify_frontend_of_errors; -use crate::core::commands::enqueue::generate_error::{BadInputReason, GenerateError}; -use crate::core::commands::deprecated::image_edit::image_edit_models::image_edit_model_to_model_type; -use crate::core::commands::deprecated::image_inpaint::artcraft::handle_inpaint_artcraft::handle_inpaint_artcraft; -use crate::core::commands::deprecated::image_inpaint::inpaint_models::image_inpaint_model_to_model_type; -use crate::core::commands::enqueue::task_enqueue_success::TaskEnqueueSuccess; -use crate::core::commands::response::failure_response_wrapper::{CommandErrorResponseWrapper, CommandErrorStatus}; -use crate::core::commands::response::shorthand::{Response, ResponseOrErrorType}; -use crate::core::commands::response::success_response_wrapper::SerializeMarker; -use crate::core::events::basic_sendable_event_trait::BasicSendableEvent; -use crate::core::events::functional_events::credits_balance_changed_event::CreditsBalanceChangedEvent; -use crate::core::events::generation_events::common::{GenerationAction, GenerationServiceProvider}; -use crate::core::events::generation_events::generation_enqueue_failure_event::GenerationEnqueueFailureEvent; -use crate::core::events::generation_events::generation_enqueue_success_event::GenerationEnqueueSuccessEvent; -use crate::core::events::sendable_event_trait::SendableEvent; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; -use crate::core::state::artcraft_usage_tracker::artcraft_usage_tracker::ArtcraftUsageTracker; -use crate::core::state::artcraft_usage_tracker::artcraft_usage_type::{ArtcraftUsagePage, ArtcraftUsageType}; -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::core::state::data_dir::trait_data_subdir::DataSubdir; -use crate::core::state::provider_priority::ProviderPriorityStore; -use crate::core::state::task_database::TaskDatabase; -use crate::core::utils::get_url_file_extension::get_url_file_extension; -use crate::core::utils::simple_http_download::simple_http_download; -use crate::services::sora::state::sora_credential_manager::SoraCredentialManager; -use crate::services::sora::state::sora_task_queue::SoraTaskQueue; -use crate::services::storyteller::state::storyteller_credential_manager::StorytellerCredentialManager; -use artcraft_client::endpoints::media_files::get_media_file::get_media_file; -use artcraft_client::error::storyteller_error::StorytellerError; -use artcraft_client::utils::api_host::ApiHost; -use enums::common::generation_provider::GenerationProvider; -use enums::tauri::ux::tauri_command_caller::TauriCommandCaller; -use errors::AnyhowError; -use log::{error, info, warn}; -use openai_sora_client::recipes::image_remix_with_session_auto_renew::{image_remix_with_session_auto_renew, ImageRemixAutoRenewRequest}; -use openai_sora_client::recipes::image_upload_from_file_with_session_auto_renew::{image_upload_from_file_with_session_auto_renew, ImageUploadFromFileAutoRenewRequest}; -use openai_sora_client::recipes::maybe_upgrade_or_renew_session::maybe_upgrade_or_renew_session; -use openai_sora_client::requests::image_gen::common::{ImageSize, NumImages}; -use serde_derive::{Deserialize, Serialize}; -use sqlite_tasks::queries::create_task::{create_task, CreateTaskArgs}; -use std::time::Duration; -use tauri::{AppHandle, Manager, State}; -use tokens::tokens::media_files::MediaFileToken; - -#[derive(Deserialize, Debug, Copy, Clone)] -#[serde(rename_all = "snake_case")] -pub enum ImageInpaintModel { - /* - * Mask-based inpainting models - */ - - #[serde(rename = "flux_dev_juggernaut")] - FluxDevJuggernaut, - - #[serde(rename = "flux_pro_1")] - FluxPro1, - - /* - * Non-inpainting, instructive editing models - * NB: We're supporting these to keep the app simple and not over-complicate the javascript - */ - - #[serde(rename = "flux_pro_kontext_max")] - FluxProKontextMax, - - #[serde(rename = "gemini_25_flash")] - Gemini25Flash, -} - -#[derive(Deserialize, Debug)] -pub struct EnqueueInpaintImageCommand { - /// The provider to use (defaults to Artcraft/Storyteller). - /// Not all (provider, model) combinations are valid. - pub provider: Option, - - /// REQUIRED (Option is just for error messages). - /// The model to use. - pub model: Option, - - /// REQUIRED (Option is just for error messages). - /// The source image to edit. - pub image_media_token: Option, - - /// REQUIRED: Supply this *XOR* `mask_image_raw_bytes`. - /// The mask to focus the edit (already uploaded). - pub mask_image_media_token: Option, - - /// REQUIRED: Supply this *XOR* `mask_image_media_token`. - /// The mask to focus the edit (raw bytes). - pub mask_image_raw_bytes: Option>, - - /// REQUIRED. - /// The user's image generation prompt. - pub prompt: String, - - /// Number of images to generate. - pub image_count: Option, - - /// Quality. - /// Tends to be used by OpenAI models. - pub quality: Option, - - /// If true, force the dimensions of the source image and mask image to match. - pub require_matching_dimensions: Option, - - /// OPTIONAL. - /// Name of the frontend caller. - /// We'll use this to selectively trigger events. - pub frontend_caller: Option, - - /// OPTIONAL. - /// A frontend-defined identifier that we'll send back to the frontend - /// as a Tauri event on task completion. - pub frontend_subscriber_id: Option, - - /// OPTIONAL. - /// A frontend-defined payload that we'll send back to the frontend - /// as a Tauri event on task completion. - pub frontend_subscriber_payload: Option, -} - -#[derive(Serialize, Debug)] -#[serde(rename_all = "snake_case")] -pub enum EnqueueInpaintImageErrorType { - /// Caller didn't specify a model - ModelNotSpecified, - - /// No model available for image generation - NoProviderAvailable, - - /// No source image was supplied. - NoSourceImageSpecified, - - /// No mask image was supplied. - NoMaskImageSpecified, - - /// Too many mask images were supplied. - MultipleMaskImagesSpecified, - - /// Bad mask image was supplied. - BadMaskImage, - - /// Generic bad request error - BadRequest, - - /// Generic server error - ServerError, -} - -#[derive(Serialize)] -pub struct EnqueueImageInpaintSuccessResponse { -} - -impl SerializeMarker for EnqueueImageInpaintSuccessResponse {} - -#[tauri::command] -pub async fn enqueue_image_inpaint_command( - app: AppHandle, - request: EnqueueInpaintImageCommand, - app_data_root: State<'_, AppDataRoot>, - app_env_configs: State<'_, AppEnvConfigs>, - artcraft_usage_tracker: State<'_, ArtcraftUsageTracker>, - provider_priority_store: State<'_, ProviderPriorityStore>, - task_database: State<'_, TaskDatabase>, - storyteller_creds_manager: State<'_, StorytellerCredentialManager>, - sora_creds_manager: State<'_, SoraCredentialManager>, - sora_task_queue: State<'_, SoraTaskQueue>, -) -> ResponseOrErrorType { - - info!("enqueue_image_inpaint_command called; model: {:?}, image_media_token: {:?}, prompt: {:?}, image_count: {:?}", - &request.model, &request.image_media_token, &request.prompt, &request.image_count); - - let result = handle_request( - &request, - &app, - &app_data_root, - &app_env_configs, - &artcraft_usage_tracker, - &provider_priority_store, - &task_database, - &storyteller_creds_manager, - &sora_creds_manager, - &sora_task_queue, - ).await; - - match result { - Err(err) => { - error!("Error enqueuing inpaint image: {:?}", err); - - notify_frontend_of_errors(&app, &err).await; - - // TODO: Derive from err. Make service provider optional. - let event = GenerationEnqueueFailureEvent { - action: GenerationAction::GenerateImage, - service: GenerationServiceProvider::Artcraft, // FIXME: This is wrong. - model: None, - reason: None, - }; - - if let Err(err) = event.send(&app) { - error!("Failed to emit event: {:?}", err); // Fail open. - } - - Err(error_to_tauri_response(err)) - } - Ok(event) => { - let event = GenerationEnqueueSuccessEvent { - action: event.to_frontend_event_action(), - service: event.to_frontend_event_service(), - model: event.model, - }; - - if let Err(err) = event.send(&app) { - error!("Failed to emit event: {:?}", err); // Fail open. - } - - CreditsBalanceChangedEvent{}.send_infallible(&app); - - Ok(EnqueueImageInpaintSuccessResponse {}.into()) - } - } -} - -pub async fn handle_request( - request: &EnqueueInpaintImageCommand, - app: &AppHandle, - app_data_root: &AppDataRoot, - app_env_configs: &AppEnvConfigs, - artcraft_usage_tracker: &ArtcraftUsageTracker, - provider_priority_store: &ProviderPriorityStore, - task_database: &TaskDatabase, - storyteller_creds_manager: &StorytellerCredentialManager, - sora_creds_manager: &SoraCredentialManager, - sora_task_queue: &SoraTaskQueue, -) -> Result { - - let model = match request.model { - Some(model) => model, - None => { - return Err(GenerateError::no_model_specified()) - } - }; - - let provider = request.provider - .unwrap_or(GenerationProvider::Artcraft); - - info!("image inpaint with {:?} via provider {:?}", &model, &provider); - - let success_event = match provider { - GenerationProvider::Artcraft => { - handle_inpaint_artcraft( - model, - request, - app, - app_data_root, - app_env_configs, - storyteller_creds_manager, - ).await? - } - _ => { - return Err(GenerateError::BadProviderForModel { - provider, - model: image_inpaint_model_to_model_type(model), - }) - } - }; - - let result = success_event - .insert_into_task_database_with_frontend_payload( - task_database, - request.frontend_caller, - request.frontend_subscriber_id.as_deref(), - request.frontend_subscriber_payload.as_deref() - ) - .await; - - if let Err(err) = result { - error!("Failed to create task in database: {:?}", err); - // NB: Fail open, but find a way to flag this. - } - - // TODO: We don't know that this is strictly the edit page. It could be the stage. It might also be nice to distinguish inpainting. - let num_images = request.image_count.map(|count| count as u16).unwrap_or(1); - if let Err(err) = artcraft_usage_tracker.record_image_generation(num_images, ArtcraftUsageType::ImageToResult, ArtcraftUsagePage::EditPage) { - // NB: Fail open. - warn!("Failed to report usage: {:?}", err); - } - - Ok(success_event) -} - -pub fn error_to_tauri_response(error: GenerateError) -> CommandErrorResponseWrapper { - let mut status = CommandErrorStatus::ServerError; - let mut error_type = EnqueueInpaintImageErrorType::ServerError; - let mut error_message = "A server error occurred. Please try again. If it continues, please tell our staff about the problem.".to_string(); - - match error { - GenerateError::BadInput(BadInputReason::NoModelSpecified) => { - status = CommandErrorStatus::BadRequest; - error_type = EnqueueInpaintImageErrorType::ModelNotSpecified; - error_message = "No model specified for image generation".to_string(); - } - GenerateError::NoProviderAvailable => { - status = CommandErrorStatus::ServerError; - error_type = EnqueueInpaintImageErrorType::NoProviderAvailable; - error_message = "No configured provider available for image generation".to_string(); - } - GenerateError::BadInput(BadInputReason::RequiredSourceImageNotProvided) => { - status = CommandErrorStatus::BadRequest; - error_type = EnqueueInpaintImageErrorType::NoSourceImageSpecified; - error_message = "No source image was provided".to_string(); - } - GenerateError::BadInput(BadInputReason::RequiredSourceImageMaskNotProvided) => { - status = CommandErrorStatus::BadRequest; - error_type = EnqueueInpaintImageErrorType::NoMaskImageSpecified; - error_message = "No mask image was provided".to_string(); - } - GenerateError::BadInput(BadInputReason::BothImageMaskMediaTokenAndBytesSupplied) => { - status = CommandErrorStatus::BadRequest; - error_type = EnqueueInpaintImageErrorType::MultipleMaskImagesSpecified; - error_message = "multiple mask images provided".to_string(); - } - GenerateError::BadInput(BadInputReason::CannotDetermineImageMimeType) => { - status = CommandErrorStatus::BadRequest; - error_type = EnqueueInpaintImageErrorType::BadMaskImage; - error_message = "bad mask image (mime)".to_string(); - } - GenerateError::BadInput(BadInputReason::InvalidNumberOfRequestedImages { min, max, requested }) => { - status = CommandErrorStatus::BadRequest; - error_type = EnqueueInpaintImageErrorType::BadRequest; - error_message = format!("Invalid number of images requested ({}). Must be between {} and {}", requested, min, max); - } - GenerateError::BadInput(BadInputReason::InvalidNumberOfInputImages{ min, max, provided }) => { - status = CommandErrorStatus::BadRequest; - error_type = EnqueueInpaintImageErrorType::BadRequest; - error_message = format!("Invalid number of input images ({}). Must be between {} and {}", provided, min, max); - } - _ => {}, // Other cases fall through. - } - - CommandErrorResponseWrapper { - status, - error_message: Some(error_message.to_string()), - error_type: Some(error_type), - error_details: None, - } -} diff --git a/crates/desktop/artcraft/src/core/commands/deprecated/image_inpaint/inpaint_models.rs b/crates/desktop/artcraft/src/core/commands/deprecated/image_inpaint/inpaint_models.rs deleted file mode 100644 index 30fa56b0c2..0000000000 --- a/crates/desktop/artcraft/src/core/commands/deprecated/image_inpaint/inpaint_models.rs +++ /dev/null @@ -1,11 +0,0 @@ -use crate::core::commands::deprecated::image_inpaint::enqueue_image_inpaint_command::ImageInpaintModel; -use enums::common::generation::common_model_type::CommonModelType; - -pub fn image_inpaint_model_to_model_type(model: ImageInpaintModel) -> CommonModelType { - match model { - ImageInpaintModel::FluxDevJuggernaut => CommonModelType::FluxDevJuggernaut, - ImageInpaintModel::FluxPro1 => CommonModelType::FluxPro1, - ImageInpaintModel::FluxProKontextMax => CommonModelType::FluxProKontextMax, - ImageInpaintModel::Gemini25Flash => CommonModelType::NanoBanana, - } -} diff --git a/crates/desktop/artcraft/src/core/commands/deprecated/image_inpaint/mod.rs b/crates/desktop/artcraft/src/core/commands/deprecated/image_inpaint/mod.rs deleted file mode 100644 index f57a278228..0000000000 --- a/crates/desktop/artcraft/src/core/commands/deprecated/image_inpaint/mod.rs +++ /dev/null @@ -1,4 +0,0 @@ -pub (super) mod inpaint_models; -pub mod enqueue_image_inpaint_command; - -mod artcraft; diff --git a/crates/desktop/artcraft/src/core/commands/deprecated/mod.rs b/crates/desktop/artcraft/src/core/commands/deprecated/mod.rs deleted file mode 100644 index 7302986596..0000000000 --- a/crates/desktop/artcraft/src/core/commands/deprecated/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub mod image_edit; -pub mod image_inpaint; -pub mod text_to_image; diff --git a/crates/desktop/artcraft/src/core/commands/deprecated/text_to_image/artcraft/handle_artcraft_gpt_image_1_text_to_image.rs b/crates/desktop/artcraft/src/core/commands/deprecated/text_to_image/artcraft/handle_artcraft_gpt_image_1_text_to_image.rs deleted file mode 100644 index 5dc9601fb3..0000000000 --- a/crates/desktop/artcraft/src/core/commands/deprecated/text_to_image/artcraft/handle_artcraft_gpt_image_1_text_to_image.rs +++ /dev/null @@ -1,115 +0,0 @@ -use crate::core::commands::enqueue::generate_error::GenerateError; -use crate::core::commands::deprecated::image_edit::enqueue_edit_image_command::{EditImageQuality, EditImageSize}; -use crate::core::commands::enqueue::task_enqueue_success::TaskEnqueueSuccess; -use crate::core::commands::deprecated::text_to_image::enqueue_text_to_image_command::{EnqueueTextToImageRequest, TextToImageSize}; -use crate::core::events::basic_sendable_event_trait::BasicSendableEvent; -use crate::core::events::generation_events::common::{GenerationAction, GenerationModel, GenerationServiceProvider}; -use crate::core::events::generation_events::generation_enqueue_failure_event::GenerationEnqueueFailureEvent; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::core::state::provider_priority::ProviderPriorityStore; -use crate::services::sora::state::sora_credential_manager::SoraCredentialManager; -use crate::services::sora::state::sora_task_queue::SoraTaskQueue; -use crate::services::storyteller::state::storyteller_credential_manager::StorytellerCredentialManager; -use artcraft_api_defs::generate::image::text::generate_gpt_image_1_text_to_image::{GenerateGptImage1TextToImageImageQuality, GenerateGptImage1TextToImageImageSize, GenerateGptImage1TextToImageNumImages, GenerateGptImage1TextToImageRequest}; -use enums::common::generation_provider::GenerationProvider; -use enums::tauri::tasks::task_type::TaskType; -use uuid_utils::uuid::generate_random_uuid; -use log::{error, info}; -use openai_sora_client::recipes::maybe_upgrade_or_renew_session::maybe_upgrade_or_renew_session; -use openai_sora_client::recipes::simple_image_gen_with_session_auto_renew::{simple_image_gen_with_session_auto_renew, SimpleImageGenAutoRenewRequest}; -use openai_sora_client::requests::image_gen::common::{ImageSize, NumImages}; -use std::time::Duration; -use artcraft_client::endpoints::generate::image::edit::gpt_image_1_edit_image::gpt_image_1_edit_image; -use artcraft_client::endpoints::generate::image::text::generate_gpt_image_1_text_to_image::generate_gpt_image_1_text_to_image; -use tauri::AppHandle; - -pub async fn handle_artcraft_gpt_image_1_text_to_image( - request: &EnqueueTextToImageRequest, - app_env_configs: &AppEnvConfigs, - storyteller_creds_manager: &StorytellerCredentialManager, -) -> Result { - - let creds = match storyteller_creds_manager.get_credentials()? { - Some(creds) => creds, - None => { - return Err(GenerateError::needs_storyteller_credentials()); - }, - }; - - info!("Calling Artcraft gpt-image-1 ..."); - - let uuid_idempotency_token = generate_random_uuid(); - - let image_quality = Some(GenerateGptImage1TextToImageImageQuality::High); - - //let image_quality = request.image_quality - // .map(|quality| match quality { - // EditImageQuality::Auto => GenerateGptImage1TextToImageImageQuality::Auto, - // EditImageQuality::High => GenerateGptImage1TextToImageImageQuality::High, - // EditImageQuality::Medium => GenerateGptImage1TextToImageImageQuality::Medium, - // EditImageQuality::Low => GenerateGptImage1TextToImageImageQuality::Low, - // }); - - let image_size = request.aspect_ratio - .map(|size| match size { - TextToImageSize::Auto => GenerateGptImage1TextToImageImageSize::Square, - TextToImageSize::Square => GenerateGptImage1TextToImageImageSize::Square, - TextToImageSize::Tall => GenerateGptImage1TextToImageImageSize::Vertical, - TextToImageSize::Wide => GenerateGptImage1TextToImageImageSize::Horizontal, - }); - - let num_images = match request.number_images { - None => None, - Some(1) => Some(GenerateGptImage1TextToImageNumImages::One), - Some(2) => Some(GenerateGptImage1TextToImageNumImages::Two), - Some(3) => Some(GenerateGptImage1TextToImageNumImages::Three), - Some(4) => Some(GenerateGptImage1TextToImageNumImages::Four), - // TODO: Error - //Some(other) => { - // return Err(InternalImageError::InvalidNumberOfRequestedImages { - // min: 1, - // max: 4, - // requested: other, - // }); - //}, - _ => Some(GenerateGptImage1TextToImageNumImages::One), // Default to one image if invalid number - }; - - let request = GenerateGptImage1TextToImageRequest { - uuid_idempotency_token, - prompt: request.prompt.clone(), - image_size, - num_images, - image_quality, - }; - - let result = generate_gpt_image_1_text_to_image( - &app_env_configs.storyteller_host, - Some(&creds), - request, - ).await; - - let job_id = match result { - Ok(enqueued) => { - // TODO(bt,2025-07-05): Enqueue job token? - info!("Successfully enqueued Artcraft gpt-image-1. Job token: {}", - enqueued.inference_job_token); - enqueued.inference_job_token - } - Err(err) => { - error!("Failed to use Artcraft gpt-image-1: {:?}", err); - return Err(GenerateError::from(err)); - } - }; - - Ok(TaskEnqueueSuccess { - provider: GenerationProvider::Artcraft, - model: Some(GenerationModel::GptImage1), - provider_job_id: Some(job_id.to_string()), - task_type: TaskType::ImageGeneration, - maybe_queue_status_url: None, - maybe_prompt_token: None, - maybe_queue_response_url: None, - }) -} diff --git a/crates/desktop/artcraft/src/core/commands/deprecated/text_to_image/artcraft/handle_text_to_image_artcraft.rs b/crates/desktop/artcraft/src/core/commands/deprecated/text_to_image/artcraft/handle_text_to_image_artcraft.rs deleted file mode 100644 index 09feb45a79..0000000000 --- a/crates/desktop/artcraft/src/core/commands/deprecated/text_to_image/artcraft/handle_text_to_image_artcraft.rs +++ /dev/null @@ -1,50 +0,0 @@ -use crate::core::commands::enqueue::generate_error::GenerateError; -use crate::core::commands::enqueue::task_enqueue_success::TaskEnqueueSuccess; -use crate::core::commands::deprecated::text_to_image::artcraft::handle_artcraft_gpt_image_1_text_to_image::handle_artcraft_gpt_image_1_text_to_image; -use crate::core::commands::deprecated::text_to_image::artcraft::handle_text_to_image_artcraft_via_router::handle_text_to_image_artcraft_via_router; -use crate::core::commands::deprecated::text_to_image::enqueue_text_to_image_command::{EnqueueTextToImageRequest, TextToImageModel}; -use crate::core::commands::deprecated::text_to_image::text_to_image_models::text_to_image_model_to_model_type; -use crate::core::events::generation_events::common::GenerationModel; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::services::storyteller::state::storyteller_credential_manager::StorytellerCredentialManager; -use artcraft_router::api::router_image_model::RouterImageModel; -use enums::common::generation_provider::GenerationProvider; -use tauri::AppHandle; - -pub async fn handle_text_to_image_artcraft( - model: TextToImageModel, - request: &EnqueueTextToImageRequest, - app: &AppHandle, - app_data_root: &AppDataRoot, - app_env_configs: &AppEnvConfigs, - storyteller_creds_manager: &StorytellerCredentialManager, -) -> Result { - - match model { - TextToImageModel::Midjourney | TextToImageModel::GrokImage => { - Err(GenerateError::BadProviderForModel { - provider: GenerationProvider::Artcraft, - model: text_to_image_model_to_model_type(model), - }) - } - TextToImageModel::Recraft3 => { - Err(GenerateError::NotYetImplemented(format!("not yet implemented in Artcraft"))) - } - TextToImageModel::Flux1Dev => handle_text_to_image_artcraft_via_router(request, app_env_configs, storyteller_creds_manager, RouterImageModel::Flux1Dev, GenerationModel::Flux1Dev).await, - TextToImageModel::Flux1Schnell => handle_text_to_image_artcraft_via_router(request, app_env_configs, storyteller_creds_manager, RouterImageModel::Flux1Schnell, GenerationModel::Flux1Schnell).await, - TextToImageModel::FluxPro11 => handle_text_to_image_artcraft_via_router(request, app_env_configs, storyteller_creds_manager, RouterImageModel::FluxPro11, GenerationModel::FluxPro11).await, - TextToImageModel::FluxPro11Ultra => handle_text_to_image_artcraft_via_router(request, app_env_configs, storyteller_creds_manager, RouterImageModel::FluxPro11Ultra, GenerationModel::FluxPro11Ultra).await, - TextToImageModel::GptImage1 => handle_artcraft_gpt_image_1_text_to_image(request, app_env_configs, storyteller_creds_manager).await, - TextToImageModel::GptImage1p5 => handle_text_to_image_artcraft_via_router(request, app_env_configs, storyteller_creds_manager, RouterImageModel::GptImage1p5, GenerationModel::GptImage1p5).await, - TextToImageModel::GptImage2 => handle_text_to_image_artcraft_via_router(request, app_env_configs, storyteller_creds_manager, RouterImageModel::GptImage2, GenerationModel::GptImage2).await, - TextToImageModel::Gemini25Flash | TextToImageModel::NanoBanana => { - handle_text_to_image_artcraft_via_router(request, app_env_configs, storyteller_creds_manager, RouterImageModel::NanoBanana, GenerationModel::NanoBanana).await - }, - TextToImageModel::NanoBanana2 => handle_text_to_image_artcraft_via_router(request, app_env_configs, storyteller_creds_manager, RouterImageModel::NanoBanana2, GenerationModel::NanoBanana2).await, - TextToImageModel::NanoBananaPro => handle_text_to_image_artcraft_via_router(request, app_env_configs, storyteller_creds_manager, RouterImageModel::NanoBananaPro, GenerationModel::NanoBananaPro).await, - TextToImageModel::Seedream4 => handle_text_to_image_artcraft_via_router(request, app_env_configs, storyteller_creds_manager, RouterImageModel::Seedream4, GenerationModel::Seedream4).await, - TextToImageModel::Seedream4p5 => handle_text_to_image_artcraft_via_router(request, app_env_configs, storyteller_creds_manager, RouterImageModel::Seedream4p5, GenerationModel::Seedream4p5).await, - TextToImageModel::Seedream5Lite => handle_text_to_image_artcraft_via_router(request, app_env_configs, storyteller_creds_manager, RouterImageModel::Seedream5Lite, GenerationModel::Seedream5Lite).await, - } -} diff --git a/crates/desktop/artcraft/src/core/commands/deprecated/text_to_image/artcraft/handle_text_to_image_artcraft_via_router.rs b/crates/desktop/artcraft/src/core/commands/deprecated/text_to_image/artcraft/handle_text_to_image_artcraft_via_router.rs deleted file mode 100644 index 66f98e5c3a..0000000000 --- a/crates/desktop/artcraft/src/core/commands/deprecated/text_to_image/artcraft/handle_text_to_image_artcraft_via_router.rs +++ /dev/null @@ -1,173 +0,0 @@ -use crate::core::api_adapters::aspect_ratio::common_aspect_ratio::CommonAspectRatio as CommonAspectRatio2; -use crate::core::api_adapters::resolution::common_resolution::CommonResolution as CommonResolution2; -use crate::core::commands::enqueue::generate_error::{GenerateError, MissingCredentialsReason}; -use crate::core::commands::enqueue::task_enqueue_success::TaskEnqueueSuccess; -use crate::core::commands::deprecated::text_to_image::enqueue_text_to_image_command::{ - EnqueueTextToImageRequest, TextToImageResolution, TextToImageSize, -}; -use crate::core::events::generation_events::common::GenerationModel; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; -use crate::services::storyteller::state::storyteller_credential_manager::StorytellerCredentialManager; -use artcraft_router::api::router_aspect_ratio::RouterAspectRatio; -use artcraft_router::api::router_image_model::RouterImageModel; -use artcraft_router::api::router_resolution::RouterResolution; -use artcraft_router::api::router_quality::RouterQuality; -use artcraft_router::api::image_list_ref::ImageListRef; -use artcraft_router::api::router_provider::RouterProvider; -use artcraft_router::client::request_mismatch_mitigation_strategy::RequestMismatchMitigationStrategy; -use artcraft_router::client::router_artcraft_client::RouterArtcraftClient; -use artcraft_router::client::router_client::RouterClient; -use artcraft_router::generate::generate_image::generate_image_request_builder::GenerateImageRequestBuilder; -use artcraft_router::generate::generate_image::image_generation_draft_or_request::ImageGenerationDraftOrRequest; -use enums::common::generation_provider::GenerationProvider; -use enums::tauri::tasks::task_type::TaskType; -use log::{error, info}; - -pub(super) async fn handle_text_to_image_artcraft_via_router( - request: &EnqueueTextToImageRequest, - app_env_configs: &AppEnvConfigs, - storyteller_creds_manager: &StorytellerCredentialManager, - model: RouterImageModel, - generation_model: GenerationModel, -) -> Result { - let creds = match storyteller_creds_manager.get_credentials()? { - Some(creds) => creds, - None => return Err(GenerateError::MissingCredentials(MissingCredentialsReason::NeedsStorytellerCredentials)), - }; - - let client = RouterClient::Artcraft(RouterArtcraftClient::new( - app_env_configs.storyteller_host.clone(), - creds, - )); - - let image_inputs = request.image_media_tokens.clone().map(ImageListRef::MediaFileTokens); - - let aspect_ratio = get_aspect_ratio_t2i(request); - let resolution = get_resolution_t2i(request); - let quality = get_quality_t2i(request); - - let router_request = GenerateImageRequestBuilder { - model, - provider: RouterProvider::Artcraft, - prompt: request.prompt.clone(), - image_inputs, - resolution, - aspect_ratio, - quality, - image_batch_count: request.number_images.map(|n| n as u16), - request_mismatch_mitigation_strategy: RequestMismatchMitigationStrategy::PayMoreUpgrade, - generation_mode_mismatch_strategy: None, - idempotency_token: None, - horizontal_angle: None, - vertical_angle: None, - zoom: None, - }; - - let dor = router_request.build2()?; - - info!("Image Generation Request: {:?}", dor); - - let request = match dor { - ImageGenerationDraftOrRequest::Request(req) => req, - // Artcraft never returns a Draft — image-token resolution happens server-side. - // The only draft-producing models today are Kinovi-Midjourney variants, - // which are routed to a separate provider. - ImageGenerationDraftOrRequest::Draft(_) => unreachable!( - "Artcraft router should never produce a draft for text-to-image" - ), - }; - - let response = match request.send_request(&client).await { - Ok(resp) => { - info!("Successfully enqueued."); - resp - } - Err(err) => { - error!("Failed to enqueue: {:?}", err); - return Err(GenerateError::from(err)); - } - }; - - let job_id = response - .get_artcraft_payload() - .map(|p| p.inference_job_token.to_string()) - .ok_or(GenerateError::ResponseHadNoJobTokens)?; - - Ok(TaskEnqueueSuccess { - task_type: TaskType::ImageGeneration, - model: Some(generation_model), - provider: GenerationProvider::Artcraft, - provider_job_id: Some(job_id), - maybe_queue_status_url: None, - maybe_prompt_token: None, - maybe_queue_response_url: None, - }) -} - -fn get_aspect_ratio_t2i(request: &EnqueueTextToImageRequest) -> Option { - if let Some(ar) = request.common_aspect_ratio { - return Some(convert_desktop_aspect_ratio(ar)); - } - if let Some(ar) = request.aspect_ratio { - return Some(match ar { - TextToImageSize::Auto => RouterAspectRatio::Auto, - TextToImageSize::Square => RouterAspectRatio::Square, - TextToImageSize::Wide => RouterAspectRatio::Wide, - TextToImageSize::Tall => RouterAspectRatio::Tall, - }); - } - None -} - -fn get_resolution_t2i(request: &EnqueueTextToImageRequest) -> Option { - if let Some(res) = request.common_resolution { - return Some(convert_desktop_resolution(res)); - } - if let Some(res) = request.image_resolution { - return Some(match res { - TextToImageResolution::OneK => RouterResolution::OneK, - TextToImageResolution::TwoK => RouterResolution::TwoK, - TextToImageResolution::FourK => RouterResolution::FourK, - }); - } - None -} - -fn get_quality_t2i(request: &EnqueueTextToImageRequest) -> Option { - request.quality.map(|quality| quality.to_artcraft_router_type()) -} - -fn convert_desktop_aspect_ratio(ar: CommonAspectRatio2) -> RouterAspectRatio { - match ar { - CommonAspectRatio2::Auto => RouterAspectRatio::Auto, - CommonAspectRatio2::Square => RouterAspectRatio::Square, - CommonAspectRatio2::WideThreeByTwo => RouterAspectRatio::WideThreeByTwo, - CommonAspectRatio2::WideFourByThree => RouterAspectRatio::WideFourByThree, - CommonAspectRatio2::WideFiveByFour => RouterAspectRatio::WideFiveByFour, - CommonAspectRatio2::WideSixteenByNine => RouterAspectRatio::WideSixteenByNine, - CommonAspectRatio2::WideTwentyOneByNine => RouterAspectRatio::WideTwentyOneByNine, - CommonAspectRatio2::TallTwoByThree => RouterAspectRatio::TallTwoByThree, - CommonAspectRatio2::TallThreeByFour => RouterAspectRatio::TallThreeByFour, - CommonAspectRatio2::TallFourByFive => RouterAspectRatio::TallFourByFive, - CommonAspectRatio2::TallNineBySixteen => RouterAspectRatio::TallNineBySixteen, - CommonAspectRatio2::TallNineByTwentyOne => RouterAspectRatio::TallNineByTwentyOne, - CommonAspectRatio2::Wide => RouterAspectRatio::Wide, - CommonAspectRatio2::Tall => RouterAspectRatio::Tall, - CommonAspectRatio2::Auto2k => RouterAspectRatio::Auto2k, - CommonAspectRatio2::Auto4k => RouterAspectRatio::Auto4k, - CommonAspectRatio2::SquareHd => RouterAspectRatio::SquareHd, - } -} - -fn convert_desktop_resolution(res: CommonResolution2) -> RouterResolution { - match res { - CommonResolution2::OneK => RouterResolution::OneK, - CommonResolution2::TwoK => RouterResolution::TwoK, - CommonResolution2::ThreeK => RouterResolution::ThreeK, - CommonResolution2::FourK => RouterResolution::FourK, - CommonResolution2::HalfK => RouterResolution::HalfK, - CommonResolution2::FourEightyP => RouterResolution::FourEightyP, - CommonResolution2::SevenTwentyP => RouterResolution::SevenTwentyP, - CommonResolution2::TenEightyP => RouterResolution::TenEightyP, - } -} diff --git a/crates/desktop/artcraft/src/core/commands/deprecated/text_to_image/artcraft/mod.rs b/crates/desktop/artcraft/src/core/commands/deprecated/text_to_image/artcraft/mod.rs deleted file mode 100644 index 572b124965..0000000000 --- a/crates/desktop/artcraft/src/core/commands/deprecated/text_to_image/artcraft/mod.rs +++ /dev/null @@ -1,4 +0,0 @@ -pub (super) mod handle_text_to_image_artcraft; - -mod handle_text_to_image_artcraft_via_router; -mod handle_artcraft_gpt_image_1_text_to_image; diff --git a/crates/desktop/artcraft/src/core/commands/deprecated/text_to_image/enqueue_text_to_image_command.rs b/crates/desktop/artcraft/src/core/commands/deprecated/text_to_image/enqueue_text_to_image_command.rs deleted file mode 100644 index 9b7310b819..0000000000 --- a/crates/desktop/artcraft/src/core/commands/deprecated/text_to_image/enqueue_text_to_image_command.rs +++ /dev/null @@ -1,425 +0,0 @@ -use crate::core::api_adapters::aspect_ratio::common_aspect_ratio::CommonAspectRatio; -use crate::core::api_adapters::quality::common_quality::CommonQuality; -use crate::core::api_adapters::resolution::common_resolution::CommonResolution; -use crate::core::commands::enqueue::common::notify_frontend_of_errors::notify_frontend_of_errors; -use crate::core::commands::enqueue::generate_error::{BadInputReason, GenerateError, MissingCredentialsReason}; -use crate::core::commands::deprecated::image_edit::image_edit_models::image_edit_model_to_model_type; -use crate::core::commands::enqueue::task_enqueue_success::TaskEnqueueSuccess; -use crate::core::commands::deprecated::text_to_image::artcraft::handle_text_to_image_artcraft::handle_text_to_image_artcraft; -use crate::core::commands::deprecated::text_to_image::grok::handle_grok::handle_grok; -use crate::core::commands::deprecated::text_to_image::midjourney::handle_midjourney::handle_midjourney; -use crate::core::commands::deprecated::text_to_image::sora::handle_text_to_image_sora::handle_text_to_image_sora; -use crate::core::commands::deprecated::text_to_image::text_to_image_models::text_to_image_model_to_model_type; -use crate::core::commands::response::failure_response_wrapper::{CommandErrorResponseWrapper, CommandErrorStatus}; -use crate::core::commands::response::shorthand::Response; -use crate::core::commands::response::success_response_wrapper::SerializeMarker; -use crate::core::events::basic_sendable_event_trait::BasicSendableEvent; -use crate::core::events::functional_events::credits_balance_changed_event::CreditsBalanceChangedEvent; -use crate::core::events::generation_events::common::{GenerationAction, GenerationServiceProvider}; -use crate::core::events::generation_events::generation_enqueue_success_event::GenerationEnqueueSuccessEvent; -use crate::core::events::sendable_event_trait::SendableEvent; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; -use crate::core::state::artcraft_usage_tracker::artcraft_usage_tracker::ArtcraftUsageTracker; -use crate::core::state::artcraft_usage_tracker::artcraft_usage_type::{ArtcraftUsagePage, ArtcraftUsageType}; -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::core::state::provider_priority::{Provider, ProviderPriorityStore}; -use crate::core::state::task_database::TaskDatabase; -use crate::services::grok::state::grok_credential_manager::GrokCredentialManager; -use crate::services::grok::state::grok_image_prompt_queue::GrokImagePromptQueue; -use crate::services::midjourney::state::midjourney_credential_manager::MidjourneyCredentialManager; -use crate::services::sora::state::sora_credential_manager::SoraCredentialManager; -use crate::services::sora::state::sora_task_queue::SoraTaskQueue; -use crate::services::storyteller::state::storyteller_credential_manager::StorytellerCredentialManager; -use enums::common::generation_provider::GenerationProvider; -use enums::tauri::ux::tauri_command_caller::TauriCommandCaller; -use log::{error, info, warn}; -use serde::{Deserialize, Serialize}; -use sqlite_tasks::queries::create_task::{create_task, CreateTaskArgs}; -use tauri::{AppHandle, State}; -use tokens::tokens::media_files::MediaFileToken; - -/// This is used in the Tauri command bridge. -/// Don't change the serializations without coordinating with the frontend. -#[derive(Deserialize, Debug, Copy, Clone)] -#[serde(rename_all = "snake_case")] -pub enum TextToImageModel { - #[serde(rename = "flux_1_dev")] - Flux1Dev, - #[serde(rename = "flux_1_schnell")] - Flux1Schnell, - #[serde(rename = "flux_pro_11")] - FluxPro11, - #[serde(rename = "flux_pro_11_ultra")] - FluxPro11Ultra, - #[serde(rename = "grok_image")] - GrokImage, - #[serde(rename = "recraft_3")] - Recraft3, - - #[serde(rename = "gpt_image_1")] - GptImage1, - #[serde(rename = "gpt_image_1p5")] - GptImage1p5, - #[serde(rename = "gpt_image_2")] - GptImage2, - #[serde(rename = "gemini_25_flash")] - Gemini25Flash, - #[serde(rename = "nano_banana")] - NanoBanana, - #[serde(rename = "nano_banana_2")] - NanoBanana2, - #[serde(rename = "nano_banana_pro")] - NanoBananaPro, - #[serde(rename = "seedream_4")] - Seedream4, - #[serde(rename = "seedream_4p5")] - Seedream4p5, - #[serde(rename = "seedream_5_lite")] - Seedream5Lite, - - // Generic Midjourney model, version unknown. - #[serde(rename = "midjourney")] - Midjourney, -} - -#[derive(Deserialize, Debug)] -pub struct EnqueueTextToImageRequest { - /// The provider to use (defaults to Artcraft/Storyteller). - /// Not all (provider, model) combinations are valid. - pub provider: Option, - - /// The model to use. - pub model: Option, - - /// Text prompt for the image generation. Required. - pub prompt: Option, - - /// New field for aspect ratio. - /// Not all models support each of these aspect ratios, but we can choose or interpolate sensibly. - pub common_aspect_ratio: Option, - - /// New field for resolution. - /// Not all models support each of these resolutions, but we can choose or interpolate sensibly. - pub common_resolution: Option, - - /// Quality. - /// Tends to be used by OpenAI models. - pub quality: Option, - - /// Aspect ratio. - #[deprecated(note="use common_aspect_ratio")] - pub aspect_ratio: Option, - - /// Aspect ratio. - #[deprecated(note="use common_resolution")] - pub image_resolution: Option, - - /// The number of images to generate. - pub number_images: Option, - - /// OPTIONAL. - /// Reference images (without semantics) - /// The purpose varies on a model-by-model basis, but they - /// are not semantically treated as "style reference", - /// "character/object reference", etc. - pub image_media_tokens: Option>, - - /// OPTIONAL. - /// Name of the frontend caller. - /// We'll use this to selectively trigger events. - pub frontend_caller: Option, - - /// OPTIONAL. - /// A frontend-defined identifier that we'll send back to the frontend - /// as a Tauri event on task completion. - pub frontend_subscriber_id: Option, - - /// OPTIONAL. - /// A frontend-defined payload that we'll send back to the frontend - /// as a Tauri event on task completion. - pub frontend_subscriber_payload: Option, -} - -// TODO(bt,2025-07-14): Support other aspect ratios / resolutions - -// Flux Dev has: 4:3, 16:9, 3:4, 9:16, and custom. -// Flux Schnell has: 4:3, 16:9, 3:4, 9:16, and custom. -// Flux Pro has: 4:3, 16:9, 3:4, 9:16, and custom. -// Flux Pro Ulra has: 4:3, 16:9, 3:4, 9:16, and custom. - -#[derive(Deserialize, Debug, Copy, Clone)] -#[serde(rename_all = "snake_case")] -pub enum TextToImageSize { - Auto, - Square, - Wide, - Tall, -} - -#[derive(Deserialize, Debug, Copy, Clone)] -#[serde(rename_all = "snake_case")] -pub enum TextToImageResolution { - /// 1K - nano banana pro - OneK, - /// 2K - nano banana pro - TwoK, - /// 4K - nano banana pro - FourK, -} - -#[derive(Serialize)] -pub struct EnqueueTextToImageSuccessResponse { -} - -impl SerializeMarker for EnqueueTextToImageSuccessResponse {} - -#[derive(Serialize, Debug)] -#[serde(rename_all = "snake_case")] -pub enum EnqueueTextToImageErrorType { - /// Caller didn't specify a model - ModelNotSpecified, - /// No model available for image generation - NoProviderAvailable, - /// Generic server error - ServerError, - /// No Fal API key available - NeedsFalApiKey, - /// Fal had an API error - FalError, - /// Needs to be logged into Artcraft - NeedsStorytellerCredentials, -} - -#[tauri::command] -pub async fn enqueue_text_to_image_command( - request: EnqueueTextToImageRequest, - app: AppHandle, - app_data_root: State<'_, AppDataRoot>, - app_env_configs: State<'_, AppEnvConfigs>, - artcraft_usage_tracker: State<'_, ArtcraftUsageTracker>, - provider_priority_store: State<'_, ProviderPriorityStore>, - task_database: State<'_, TaskDatabase>, - mj_creds_manager: State<'_, MidjourneyCredentialManager>, - grok_creds_manager: State<'_, GrokCredentialManager>, - grok_image_prompt_queue: State<'_, GrokImagePromptQueue>, - storyteller_creds_manager: State<'_, StorytellerCredentialManager>, - sora_creds_manager: State<'_, SoraCredentialManager>, - sora_task_queue: State<'_, SoraTaskQueue>, -) -> Response { - - info!("enqueue_text_to_image called"); - - info!("request: {:?}", request); - - let result = handle_request( - request, - &app, - &app_data_root, - &artcraft_usage_tracker, - &provider_priority_store, - &task_database, - &mj_creds_manager, - &grok_creds_manager, - &grok_image_prompt_queue, - &storyteller_creds_manager, - &app_env_configs, - &sora_creds_manager, - &sora_task_queue, - ).await; - - match result { - Err(err) => { - error!("error: {:?}", err); - - notify_frontend_of_errors(&app, &err).await; - - let mut status = CommandErrorStatus::ServerError; - let mut error_type = EnqueueTextToImageErrorType::ServerError; - let mut error_message = "A server error occurred. Please try again. If it continues, please tell our staff about the problem."; - - match err { - GenerateError::BadInput(BadInputReason::NoModelSpecified) => { - status = CommandErrorStatus::BadRequest; - error_type = EnqueueTextToImageErrorType::ModelNotSpecified; - error_message = "No model specified for image generation"; - } - GenerateError::NoProviderAvailable => { - status = CommandErrorStatus::ServerError; - error_type = EnqueueTextToImageErrorType::NoProviderAvailable; - error_message = "No configured provider available for image generation"; - } - GenerateError::MissingCredentials(MissingCredentialsReason::NeedsFalApiKey) => { - status = CommandErrorStatus::Unauthorized; - error_type = EnqueueTextToImageErrorType::NeedsFalApiKey; - error_message = "You need to set a FAL api key"; - }, - _ => {}, // Fall-through - } - - Err(CommandErrorResponseWrapper { - status, - error_message: Some(error_message.to_string()), - error_type: Some(error_type), - error_details: None, - }) - } - Ok(event) => { - let event = GenerationEnqueueSuccessEvent { - action: event.to_frontend_event_action(), - service: event.to_frontend_event_service(), - model: event.model, - }; - - if let Err(err) = event.send(&app) { - error!("Failed to emit event: {:?}", err); // Fail open. - } - - CreditsBalanceChangedEvent{}.send_infallible(&app); - - Ok(EnqueueTextToImageSuccessResponse {}.into()) - } - } -} - -pub async fn handle_request( - request: EnqueueTextToImageRequest, - app: &AppHandle, - app_data_root: &AppDataRoot, - artcraft_usage_tracker: &ArtcraftUsageTracker, - provider_priority_store: &ProviderPriorityStore, - task_database: &TaskDatabase, - mj_creds_manager: &MidjourneyCredentialManager, - grok_creds_manager: &GrokCredentialManager, - grok_image_prompt_queue: &GrokImagePromptQueue, - storyteller_creds_manager: &StorytellerCredentialManager, - app_env_configs: &AppEnvConfigs, - sora_creds_manager: &SoraCredentialManager, - sora_task_queue: &SoraTaskQueue, -) -> Result { - - let result = dispatch_request( - &request, - &app, - &app_data_root, - &provider_priority_store, - &storyteller_creds_manager, - &app_env_configs, - &mj_creds_manager, - &grok_creds_manager, - &grok_image_prompt_queue, - &sora_creds_manager, - &sora_task_queue, - ).await; - - let success_event = match result { - Err(err) => return Err(err), - Ok(event) => event, - }; - - let result = success_event - .insert_into_task_database_with_frontend_payload( - task_database, - request.frontend_caller, - request.frontend_subscriber_id.as_deref(), - request.frontend_subscriber_payload.as_deref(), - ) - .await; - - if let Err(err) = result { - error!("Failed to create task in database: {:?}", err); - // NB: Fail open, but find a way to flag this. - } - - let num_images = request.number_images.map(|n| n as u16).unwrap_or(1); - - let is_image_to_image = request.image_media_tokens - .as_ref() - .map(|tokens| !tokens.is_empty()) - .unwrap_or(false); - - let usage_type = if is_image_to_image { - ArtcraftUsageType::ImageToResult - } else { - ArtcraftUsageType::TextToResult - }; - - if let Err(err) = artcraft_usage_tracker.record_image_generation(num_images, usage_type, ArtcraftUsagePage::ImagePage) { - // NB: Fail open. - warn!("Failed to report usage: {:?}", err); - } - - Ok(success_event) -} - -pub async fn dispatch_request( - request: &EnqueueTextToImageRequest, - app: &AppHandle, - app_data_root: &AppDataRoot, - provider_priority_store: &ProviderPriorityStore, - storyteller_creds_manager: &StorytellerCredentialManager, - app_env_configs: &AppEnvConfigs, - mj_creds_manager: &MidjourneyCredentialManager, - grok_creds_manager: &GrokCredentialManager, - grok_image_prompt_queue: &GrokImagePromptQueue, - sora_creds_manager: &SoraCredentialManager, - sora_task_queue: &SoraTaskQueue, -) -> Result { - - let model = match request.model { - Some(model) => model, - None => { - return Err(GenerateError::no_model_specified()) - } - }; - - let provider = match (model, request.provider) { - (TextToImageModel::GrokImage, _) => GenerationProvider::Grok, - (TextToImageModel::Midjourney, _) => GenerationProvider::Midjourney, - _ => request.provider.unwrap_or(GenerationProvider::Artcraft), - }; - - info!("generate image with {:?} via provider {:?}", &model, &provider); - - match provider { - GenerationProvider::Artcraft => { - handle_text_to_image_artcraft( - model, - request, - app, - app_data_root, - app_env_configs, - storyteller_creds_manager, - ).await - } - GenerationProvider::Grok => { - handle_grok( - app, - request, - app_env_configs, - grok_creds_manager, - grok_image_prompt_queue, - ).await - } - GenerationProvider::Midjourney => { - handle_midjourney( - app, - request, - app_env_configs, - mj_creds_manager, - ).await - } - GenerationProvider::Sora => { - handle_text_to_image_sora( - request, - app, - sora_creds_manager, - sora_task_queue, - ).await - } - _ => { - Err(GenerateError::BadProviderForModel { - provider, - model: text_to_image_model_to_model_type(model), - }) - } - } -} diff --git a/crates/desktop/artcraft/src/core/commands/deprecated/text_to_image/grok/handle_grok.rs b/crates/desktop/artcraft/src/core/commands/deprecated/text_to_image/grok/handle_grok.rs deleted file mode 100644 index b2b1b17223..0000000000 --- a/crates/desktop/artcraft/src/core/commands/deprecated/text_to_image/grok/handle_grok.rs +++ /dev/null @@ -1,95 +0,0 @@ -use crate::core::api_adapters::aspect_ratio::convert::aspect_ratio_to_grok_image::aspect_ratio_to_grok_image; -use crate::core::commands::enqueue::generate_error::GenerateError; -use crate::core::commands::enqueue::task_enqueue_success::TaskEnqueueSuccess; -use crate::core::commands::deprecated::text_to_image::enqueue_text_to_image_command::{EnqueueTextToImageRequest, TextToImageSize}; -use crate::core::events::generation_events::common::GenerationModel; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; -use crate::services::grok::state::grok_credential_manager::GrokCredentialManager; -use crate::services::grok::state::grok_image_prompt_queue::{GrokImagePromptQueue, PromptItem}; -use enums::common::generation_provider::GenerationProvider; -use enums::tauri::tasks::task_type::TaskType; -use grok_consumer_client::requests::image_websocket::messages::websocket_client_message::ClientMessageAspectRatio; -use uuid_utils::uuid::generate_random_uuid; -use tauri::AppHandle; - -pub async fn handle_grok( - app: &AppHandle, - request: &EnqueueTextToImageRequest, - app_env_configs: &AppEnvConfigs, - creds_manager: &GrokCredentialManager, - grok_image_prompt_queue: &GrokImagePromptQueue, -) -> Result { - - - //// TODO: We can request population of the user info if absent or expired. - //let websocket = get_websocket( - // app, - // creds_manager, - // websocket_manager, - //).await?; - // - //let _result = prompt_websocket_image(PromptWebsocketImageArgs { - // websocket_wrapped: &websocket, - // prompt: request.prompt.as_deref().unwrap_or_else(||""), - //}).await?; - // - //let request_id = listen_for_websocket_request_id(ListenForWebsocketRequestIdArgs { - // websocket: &websocket, - // timeout: Duration::from_millis(10_000), - //}).await?; - // - //let request_id = match request_id.request_id { - // Some(request_id) => request_id.to_string(), - // None => { - // warn!("No request id from Grok image generation (websocket)"); - // return Err(GenerateError::ProviderFailure(ProviderFailureReason::GrokJobEnqueueFailed)); - // } - //}; - // - //info!("Successfully enqueued MidJourney. Job token: {}", request_id); - - let job_id = generate_random_uuid(); - - let prompt = request.prompt - .as_deref() - .map(|prompt| prompt.trim().to_string()) - .unwrap_or_else(|| "".to_string()); - - let aspect_ratio = get_aspect_ratio(request); - - grok_image_prompt_queue.enqueue(PromptItem { - task_id: job_id.clone(), - prompt, - aspect_ratio: aspect_ratio.unwrap_or(ClientMessageAspectRatio::Square), - })?; - - Ok(TaskEnqueueSuccess { - provider: GenerationProvider::Grok, - model: Some(GenerationModel::GrokImage), - provider_job_id: Some(job_id), - task_type: TaskType::ImageGeneration, - maybe_queue_status_url: None, - maybe_prompt_token: None, - maybe_queue_response_url: None, - }) -} - -fn get_aspect_ratio(request: &EnqueueTextToImageRequest) -> Option { - if let Some(common_aspect_ratio) = request.common_aspect_ratio { - // Handle modern aspect ratio - let aspect = aspect_ratio_to_grok_image(common_aspect_ratio); - return Some(aspect); - } - - if let Some(aspect_ratio) = request.aspect_ratio { - // Handle deprecated aspect ratio - return match aspect_ratio { - TextToImageSize::Auto => Some(ClientMessageAspectRatio::Square), - TextToImageSize::Square => Some(ClientMessageAspectRatio::Square), - TextToImageSize::Wide => Some(ClientMessageAspectRatio::WideThreeByTwo), - TextToImageSize::Tall => Some(ClientMessageAspectRatio::TallTwoByThree), - } - } - - None -} diff --git a/crates/desktop/artcraft/src/core/commands/deprecated/text_to_image/grok/mod.rs b/crates/desktop/artcraft/src/core/commands/deprecated/text_to_image/grok/mod.rs deleted file mode 100644 index 181e756f1a..0000000000 --- a/crates/desktop/artcraft/src/core/commands/deprecated/text_to_image/grok/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub (super) mod handle_grok; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/core/commands/deprecated/text_to_image/midjourney/handle_midjourney.rs b/crates/desktop/artcraft/src/core/commands/deprecated/text_to_image/midjourney/handle_midjourney.rs deleted file mode 100644 index aefc881ed5..0000000000 --- a/crates/desktop/artcraft/src/core/commands/deprecated/text_to_image/midjourney/handle_midjourney.rs +++ /dev/null @@ -1,143 +0,0 @@ -use crate::core::commands::enqueue::generate_error::{GenerateError, MissingCredentialsReason, ProviderFailureReason}; -use crate::core::commands::deprecated::image_edit::enqueue_edit_image_command::{EditImageQuality, EditImageSize}; -use crate::core::commands::enqueue::task_enqueue_success::TaskEnqueueSuccess; -use crate::core::commands::deprecated::text_to_image::enqueue_text_to_image_command::{EnqueueTextToImageRequest, TextToImageSize}; -use crate::core::events::basic_sendable_event_trait::BasicSendableEvent; -use crate::core::events::functional_events::canvas_background_removal_complete_event::CanvasBackgroundRemovalCompleteEvent; -use crate::core::events::functional_events::show_provider_login_modal_event::ShowProviderLoginModalEvent; -use crate::core::events::generation_events::common::{GenerationAction, GenerationModel, GenerationServiceProvider}; -use crate::core::events::generation_events::generation_enqueue_failure_event::GenerationEnqueueFailureEvent; -use crate::core::events::warning_events::flash_user_input_error_event::FlashUserInputErrorEvent; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::core::state::provider_priority::ProviderPriorityStore; -use crate::services::midjourney::state::midjourney_credential_manager::MidjourneyCredentialManager; -use crate::services::sora::state::sora_credential_manager::SoraCredentialManager; -use crate::services::sora::state::sora_task_queue::SoraTaskQueue; -use crate::services::storyteller::state::storyteller_credential_manager::StorytellerCredentialManager; -use enums::common::generation_provider::GenerationProvider; -use enums::tauri::tasks::task_type::TaskType; -use uuid_utils::uuid::generate_random_uuid; -use log::{error, info}; -use midjourney_client::client::midjourney_hostname::MidjourneyHostname; -use midjourney_client::endpoints::submit_job::{submit_job, SubmitJobRequest}; -use midjourney_client::error::midjourney_api_error::MidjourneyApiError; -use midjourney_client::recipes::channel_id::ChannelId; -use midjourney_client::recipes::text_to_image::{text_to_image, TextToImageError, TextToImageRequest}; -use openai_sora_client::recipes::maybe_upgrade_or_renew_session::maybe_upgrade_or_renew_session; -use openai_sora_client::recipes::simple_image_gen_with_session_auto_renew::{simple_image_gen_with_session_auto_renew, SimpleImageGenAutoRenewRequest}; -use openai_sora_client::requests::image_gen::common::{ImageSize, NumImages}; -use std::time::Duration; -use tauri::AppHandle; -use tokens::tokens::media_files::MediaFileToken; - -pub async fn handle_midjourney( - app: &AppHandle, - request: &EnqueueTextToImageRequest, - app_env_configs: &AppEnvConfigs, - mj_creds_manager: &MidjourneyCredentialManager, -) -> Result { - - let creds = match mj_creds_manager.maybe_copy_cookie_store() { - Ok(Some(creds)) => creds, - Ok(None) => { - error!("Midjourney credentials not found."); - ShowProviderLoginModalEvent::send_for_provider(GenerationProvider::Midjourney, &app); - return Err(GenerateError::needs_midjourney_credentials()); - } - Err(err) => { - error!("Error reading Midjourney credentials: {:?}", err); - ShowProviderLoginModalEvent::send_for_provider(GenerationProvider::Midjourney, &app); - return Err(GenerateError::needs_midjourney_credentials()); - }, - }; - - // TODO: We can request population of the user info if absent or expired. - - let user_info = match mj_creds_manager.maybe_copy_user_info() { - Ok(Some(user_info)) => user_info, - Ok(None) => { - return Err(GenerateError::MissingCredentials(MissingCredentialsReason::NeedsMidjourneyUserInfo)); - } - Err(err) => { - error!("Error reading Midjourney user info: {:?}", err); - return Err(GenerateError::MissingCredentials(MissingCredentialsReason::NeedsMidjourneyUserInfo)); - }, - }; - - let channel_id = match user_info.user_id { - Some(user_id) => ChannelId::UserId(user_id), - None => { - error!("Midjourney user info does not contain a user ID."); - return Err(GenerateError::MissingCredentials(MissingCredentialsReason::NeedsMidjourneyUserId)); - } - }; - - info!("Calling midjourney ..."); - - let cookie_header = creds.to_cookie_string(); - - let prompt = request.prompt - .as_deref() - .unwrap_or(""); - - let result = text_to_image(TextToImageRequest { - prompt, - channel_id: &channel_id, - hostname: MidjourneyHostname::Standard, - cookie_header, - }).await; - - let result = match result { - Ok(result) => result, - Err(err) => { - error!("Failed to use MidJourney: {:?}", err); - return Err(GenerateError::from(err)); - } - }; - - let job_id = match result.maybe_job_id { - Some(job_id) => job_id, - None => { - error!("Failed to enqueue MidJourney: No job ID returned."); - return handle_midjourney_errors(app, result.maybe_errors); - } - }; - - info!("Successfully enqueued MidJourney. Job token: {}", job_id); - - Ok(TaskEnqueueSuccess { - provider: GenerationProvider::Midjourney, - model: Some(GenerationModel::Midjourney), - provider_job_id: Some(job_id), - task_type: TaskType::ImageGeneration, - maybe_queue_status_url: None, - maybe_prompt_token: None, - maybe_queue_response_url: None, - }) -} - -fn handle_midjourney_errors( - app: &AppHandle, - maybe_errors: Option> -) -> Result { - if let Some(errors) = maybe_errors { - if !errors.is_empty() { - let messages: Vec = errors.iter() - .map(|e| format!("{:?}", e)) - .collect(); - - let combined_message = messages.join("; "); - - let event = FlashUserInputErrorEvent { - message: format!("Midjourney Error: {}", combined_message), - }; - - if let Err(err) = event.send(&app) { - error!("Failed to send FlashUserInputErrorEvent: {:?}", err); // Fail open - } - } - } - - Err(GenerateError::ProviderFailure(ProviderFailureReason::MidjourneyJobEnqueueFailed)) -} diff --git a/crates/desktop/artcraft/src/core/commands/deprecated/text_to_image/midjourney/mod.rs b/crates/desktop/artcraft/src/core/commands/deprecated/text_to_image/midjourney/mod.rs deleted file mode 100644 index 18048875b6..0000000000 --- a/crates/desktop/artcraft/src/core/commands/deprecated/text_to_image/midjourney/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub (super) mod handle_midjourney; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/core/commands/deprecated/text_to_image/mod.rs b/crates/desktop/artcraft/src/core/commands/deprecated/text_to_image/mod.rs deleted file mode 100644 index e3a7d42879..0000000000 --- a/crates/desktop/artcraft/src/core/commands/deprecated/text_to_image/mod.rs +++ /dev/null @@ -1,7 +0,0 @@ -pub (super) mod text_to_image_models; -pub mod enqueue_text_to_image_command; - -mod artcraft; -mod grok; -mod midjourney; -mod sora; diff --git a/crates/desktop/artcraft/src/core/commands/deprecated/text_to_image/sora/handle_gpt_image_1_sora_text_to_image.rs b/crates/desktop/artcraft/src/core/commands/deprecated/text_to_image/sora/handle_gpt_image_1_sora_text_to_image.rs deleted file mode 100644 index d6a0e2c92d..0000000000 --- a/crates/desktop/artcraft/src/core/commands/deprecated/text_to_image/sora/handle_gpt_image_1_sora_text_to_image.rs +++ /dev/null @@ -1,138 +0,0 @@ -use crate::core::api_adapters::aspect_ratio::convert::aspect_ratio_to_grok_image::aspect_ratio_to_grok_image; -use crate::core::api_adapters::aspect_ratio::convert::aspect_ratio_to_sora_native_gpt_image_1::aspect_ratio_to_sora_native_gpt_image_1; -use crate::core::commands::enqueue::generate_error::GenerateError; -use crate::core::commands::enqueue::task_enqueue_success::TaskEnqueueSuccess; -use crate::core::commands::deprecated::text_to_image::enqueue_text_to_image_command::{EnqueueTextToImageRequest, TextToImageSize}; -use crate::core::events::basic_sendable_event_trait::BasicSendableEvent; -use crate::core::events::functional_events::show_provider_login_modal_event::ShowProviderLoginModalEvent; -use crate::core::events::generation_events::common::{GenerationAction, GenerationModel, GenerationServiceProvider}; -use crate::core::events::generation_events::generation_enqueue_failure_event::GenerationEnqueueFailureEvent; -use crate::services::sora::state::sora_credential_manager::SoraCredentialManager; -use crate::services::sora::state::sora_task_queue::SoraTaskQueue; -use enums::common::generation_provider::GenerationProvider; -use enums::tauri::tasks::task_type::TaskType; -use errors::AnyhowResult; -use grok_consumer_client::requests::image_websocket::messages::websocket_client_message::ClientMessageAspectRatio; -use log::{error, info}; -use openai_sora_client::recipes::maybe_upgrade_or_renew_session::maybe_upgrade_or_renew_session; -use openai_sora_client::recipes::simple_image_gen_with_session_auto_renew::{simple_image_gen_with_session_auto_renew, SimpleImageGenAutoRenewRequest}; -use openai_sora_client::requests::image_gen::common::{ImageSize, NumImages}; -use std::time::Duration; -use tauri::AppHandle; - -const SORA_SIMPLE_IMAGE_GEN_TIMEOUT : Duration = Duration::from_millis(1000 * 30); // 30 seconds - -pub async fn handle_gpt_image_1_sora_text_to_image( - request: &EnqueueTextToImageRequest, - app: &AppHandle, - sora_creds_manager: &SoraCredentialManager, - sora_task_queue: &SoraTaskQueue, -) -> Result { - - let mut creds = match sora_creds_manager.get_credentials() { - Ok(Some(creds)) => creds, - Ok(None) => { - error!("Sora credentials not found."); - ShowProviderLoginModalEvent::send_for_provider(GenerationProvider::Sora, &app); - return Err(GenerateError::needs_sora_credentials()); - } - Err(err) => { - error!("Error reading Sora credentials: {:?}", err); - ShowProviderLoginModalEvent::send_for_provider(GenerationProvider::Sora, &app); - return Err(GenerateError::needs_sora_credentials()); - } - }; - - let credential_updated = maybe_upgrade_or_renew_session(&mut creds) - .await - .map_err(|err| { - error!("Failed to upgrade or renew session: {:?}", err); - err - })?; - - if credential_updated { - info!("Storing updated credentials"); - sora_creds_manager.set_credentials(&creds)?; - } - - let prompt = request.prompt.as_deref().unwrap_or(""); - - let aspect_ratio = get_aspect_ratio(request) - .unwrap_or(ImageSize::Square); - - let num_images = match request.number_images { - None => NumImages::One, - Some(1) => NumImages::One, - Some(2) => NumImages::Two, - Some(3) => NumImages::Two, // NB: There is no option for three images! - Some(4) => NumImages::Four, - _ => NumImages::One, - }; - - let result = - simple_image_gen_with_session_auto_renew(SimpleImageGenAutoRenewRequest { - prompt: prompt.to_string(), - num_images, - image_size: aspect_ratio, - credentials: &creds, - request_timeout: Some(SORA_SIMPLE_IMAGE_GEN_TIMEOUT), - }).await; - - let (response, maybe_new_creds) = - match result { - Ok((response, maybe_new_creds)) => (response, maybe_new_creds), - Err(err) => { - let event = GenerationEnqueueFailureEvent { - action: GenerationAction::GenerateImage, - service: GenerationServiceProvider::Sora, - model: None, - reason: None, - }; - - if let Err(err) = event.send(app) { - error!("Failed to emit event: {:?}", err); // Fail open. - } - - return Err(GenerateError::from(err)); - } - }; - - if let Some(new_creds) = maybe_new_creds { - info!("Storing updated credentials."); - sora_creds_manager.set_credentials(&new_creds)?; - } - - info!("New Sora Task ID: {:?} ", response.task_id); - - sora_task_queue.insert(&response.task_id)?; - - Ok(TaskEnqueueSuccess { - provider: GenerationProvider::Sora, - task_type: TaskType::ImageGeneration, - model: Some(GenerationModel::GptImage1), - provider_job_id: Some(response.task_id.to_string()), - maybe_queue_status_url: None, - maybe_prompt_token: None, - maybe_queue_response_url: None, - }) -} - -fn get_aspect_ratio(request: &EnqueueTextToImageRequest) -> Option { - if let Some(common_aspect_ratio) = request.common_aspect_ratio { - // Handle modern aspect ratio - let aspect = aspect_ratio_to_sora_native_gpt_image_1(common_aspect_ratio); - return Some(aspect); - } - - if let Some(aspect_ratio) = request.aspect_ratio { - // Handle deprecated aspect ratio - return match aspect_ratio { - TextToImageSize::Auto => Some(ImageSize::Square), - TextToImageSize::Square => Some(ImageSize::Square), - TextToImageSize::Wide => Some(ImageSize::Wide), - TextToImageSize::Tall => Some(ImageSize::Tall), - } - } - - None -} diff --git a/crates/desktop/artcraft/src/core/commands/deprecated/text_to_image/sora/handle_text_to_image_sora.rs b/crates/desktop/artcraft/src/core/commands/deprecated/text_to_image/sora/handle_text_to_image_sora.rs deleted file mode 100644 index b776d84f97..0000000000 --- a/crates/desktop/artcraft/src/core/commands/deprecated/text_to_image/sora/handle_text_to_image_sora.rs +++ /dev/null @@ -1,21 +0,0 @@ -use crate::core::commands::enqueue::generate_error::GenerateError; -use crate::core::commands::enqueue::task_enqueue_success::TaskEnqueueSuccess; -use crate::core::commands::deprecated::text_to_image::enqueue_text_to_image_command::EnqueueTextToImageRequest; -use crate::core::commands::deprecated::text_to_image::sora::handle_gpt_image_1_sora_text_to_image::handle_gpt_image_1_sora_text_to_image; -use crate::services::sora::state::sora_credential_manager::SoraCredentialManager; -use crate::services::sora::state::sora_task_queue::SoraTaskQueue; -use tauri::AppHandle; - -pub async fn handle_text_to_image_sora( - request: &EnqueueTextToImageRequest, - app: &AppHandle, - sora_creds_manager: &SoraCredentialManager, - sora_task_queue: &SoraTaskQueue, -) -> Result { - handle_gpt_image_1_sora_text_to_image( - request, - app, - sora_creds_manager, - sora_task_queue, - ).await -} diff --git a/crates/desktop/artcraft/src/core/commands/deprecated/text_to_image/sora/mod.rs b/crates/desktop/artcraft/src/core/commands/deprecated/text_to_image/sora/mod.rs deleted file mode 100644 index 9a9529d300..0000000000 --- a/crates/desktop/artcraft/src/core/commands/deprecated/text_to_image/sora/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub (super) mod handle_text_to_image_sora; -mod handle_gpt_image_1_sora_text_to_image; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/core/commands/deprecated/text_to_image/text_to_image_models.rs b/crates/desktop/artcraft/src/core/commands/deprecated/text_to_image/text_to_image_models.rs deleted file mode 100644 index 48c16d5676..0000000000 --- a/crates/desktop/artcraft/src/core/commands/deprecated/text_to_image/text_to_image_models.rs +++ /dev/null @@ -1,24 +0,0 @@ -use crate::core::commands::deprecated::text_to_image::enqueue_text_to_image_command::TextToImageModel; -use enums::common::generation::common_model_type::CommonModelType; - -pub fn text_to_image_model_to_model_type(model: TextToImageModel) -> CommonModelType { - match model { - TextToImageModel::Flux1Dev => CommonModelType::Flux1Dev, - TextToImageModel::Flux1Schnell => CommonModelType::Flux1Schnell, - TextToImageModel::FluxPro11 => CommonModelType::FluxPro11, - TextToImageModel::FluxPro11Ultra => CommonModelType::FluxPro11Ultra, - TextToImageModel::GrokImage => CommonModelType::GrokImage, - TextToImageModel::Recraft3 => CommonModelType::Recraft3, - TextToImageModel::GptImage1 => CommonModelType::GptImage1, - TextToImageModel::GptImage1p5 => CommonModelType::GptImage1p5, - TextToImageModel::GptImage2 => CommonModelType::GptImage2, - TextToImageModel::Gemini25Flash => CommonModelType::NanoBanana, - TextToImageModel::NanoBanana => CommonModelType::NanoBanana, - TextToImageModel::NanoBanana2 => CommonModelType::NanoBanana2, - TextToImageModel::NanoBananaPro => CommonModelType::NanoBananaPro, - TextToImageModel::Seedream4 => CommonModelType::Seedream4, - TextToImageModel::Seedream4p5 => CommonModelType::Seedream4p5, - TextToImageModel::Seedream5Lite => CommonModelType::Seedream5Lite, - TextToImageModel::Midjourney => CommonModelType::Midjourney, - } -} diff --git a/crates/desktop/artcraft/src/core/commands/download/download_directory_reveal_command.rs b/crates/desktop/artcraft/src/core/commands/download/download_directory_reveal_command.rs deleted file mode 100644 index 793527b5ac..0000000000 --- a/crates/desktop/artcraft/src/core/commands/download/download_directory_reveal_command.rs +++ /dev/null @@ -1,70 +0,0 @@ -use crate::core::api_adapters::aspect_ratio::common_aspect_ratio::CommonAspectRatio; -use crate::core::artcraft_error::ArtcraftError; -use crate::core::commands::response::failure_response_wrapper::{CommandErrorResponseWrapper, CommandErrorStatus}; -use crate::core::commands::response::shorthand::{Response, ResponseOrErrorMessage, ResponseOrErrorType}; -use crate::core::commands::response::success_response_wrapper::SerializeMarker; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; -use crate::core::state::app_preferences::app_preferences::AppPreferences; -use crate::core::state::app_preferences::app_preferences_manager::AppPreferencesManager; -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::core::utils::download_url_to_temp_dir::download_url_to_temp_dir; -use crate::core::utils::download_url_to_user_download_dir::download_url_to_user_download_dir; -use anyhow::anyhow; -use log::{error, info}; -use serde_derive::{Deserialize, Serialize}; -use std::path::PathBuf; -use std::str::FromStr; -use artcraft_client::endpoints::media_files::get_media_file::get_media_file; -use tauri::{AppHandle, State}; -use tauri_plugin_opener::OpenerExt; -use tokens::tokens::media_files::MediaFileToken; - -#[derive(Serialize)] -pub struct DownloadDirectoryRevealSuccessResponse { -} - -impl SerializeMarker for DownloadDirectoryRevealSuccessResponse {} - -#[tauri::command] -pub async fn download_directory_reveal_command( - app: AppHandle, - app_prefs: State<'_, AppPreferencesManager>, - app_data_root: State<'_, AppDataRoot>, -) -> ResponseOrErrorMessage { - - info!("download_directory_reveal_command called"); - - let result = handle_request( - &app, - &app_prefs, - &app_data_root, - ).await; - - if let Err(err) = result { - format!("Error revealing download dir: {:?}", err); - return Err("error revealing download dir".into()) - } - - Ok(DownloadDirectoryRevealSuccessResponse {}.into()) -} - - -pub async fn handle_request( - app: &AppHandle, - app_prefs: &AppPreferencesManager, - app_data_root: &AppDataRoot, -) -> Result<(), ArtcraftError> { - - let app_prefs = app_prefs.get_clone()?; - - let download_directory = app_prefs - .preferred_download_directory - .download_directory(app_data_root); - - info!("Revealing item in directory: {:?}", download_directory); - - app.opener().reveal_item_in_dir(download_directory) - .map_err(|err| anyhow!("Failed to open directory: {:?}", err))?; - - Ok(()) -} diff --git a/crates/desktop/artcraft/src/core/commands/download/download_media_file_command.rs b/crates/desktop/artcraft/src/core/commands/download/download_media_file_command.rs deleted file mode 100644 index fb9e685814..0000000000 --- a/crates/desktop/artcraft/src/core/commands/download/download_media_file_command.rs +++ /dev/null @@ -1,104 +0,0 @@ -use crate::core::api_adapters::aspect_ratio::common_aspect_ratio::CommonAspectRatio; -use crate::core::artcraft_error::ArtcraftError; -use crate::core::commands::response::failure_response_wrapper::{CommandErrorResponseWrapper, CommandErrorStatus}; -use crate::core::commands::response::shorthand::{Response, ResponseOrErrorType}; -use crate::core::commands::response::success_response_wrapper::SerializeMarker; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; -use crate::core::state::app_preferences::app_preferences::AppPreferences; -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::core::utils::download_url_to_temp_dir::download_url_to_temp_dir; -use crate::core::utils::download_url_to_user_download_dir::download_url_to_user_download_dir; -use anyhow::anyhow; -use log::{error, info}; -use serde_derive::{Deserialize, Serialize}; -use std::path::PathBuf; -use std::str::FromStr; -use artcraft_client::endpoints::media_files::get_media_file::get_media_file; -use tauri::{AppHandle, State}; -use tokens::tokens::media_files::MediaFileToken; -use crate::core::state::app_preferences::app_preferences_manager::AppPreferencesManager; - -#[derive(Deserialize, Debug)] -pub struct DownloadMediaFileRequest { - pub media_token: MediaFileToken, -} - -#[derive(Serialize)] -pub struct DownloadMediaFileSuccessResponse { -} - -impl SerializeMarker for DownloadMediaFileSuccessResponse {} - -#[derive(Serialize, Debug)] -#[serde(rename_all = "snake_case")] -pub enum DownloadMediaFileErrorType { - FilesystemError, - NetworkError, - UnknownError, -} - - -#[tauri::command] -pub async fn download_media_file_command( - request: DownloadMediaFileRequest, - app: AppHandle, - app_prefs: State<'_, AppPreferencesManager>, - app_data_root: State<'_, AppDataRoot>, - app_env_configs: State<'_, AppEnvConfigs>, -) -> ResponseOrErrorType { - - info!("download_media_file_command called"); - - info!("request: {:?}", request); - - let result = handle_request( - request, - &app, - &app_prefs, - &app_data_root, - &app_env_configs, - ).await; - - if let Err(err) = result { - error!("Error downloading media: {:?}", err); - // TODO: This error is semantically incorrect - just trying to get the code done - return Err(CommandErrorResponseWrapper { - status: CommandErrorStatus::ServerError, - error_message: Some("error downloading file".to_string()), - error_type: Some(DownloadMediaFileErrorType::UnknownError), - error_details: None, - }); - } - - Ok(DownloadMediaFileSuccessResponse {}.into()) -} - - -pub async fn handle_request( - request: DownloadMediaFileRequest, - app: &AppHandle, - app_prefs: &AppPreferencesManager, - app_data_root: &AppDataRoot, - app_env_configs: &AppEnvConfigs -) -> Result<(), ArtcraftError> { - - let app_prefs = app_prefs.get_clone()?; - - // TODO: Api should return the extension and suggested filename so we can better construct something. - let media_file = get_media_file( - &app_env_configs.storyteller_host, - &request.media_token, - ).await?; - - let asset_url = media_file.media_file.media_links.cdn_url; - - let download_path = download_url_to_user_download_dir( - &asset_url, - app_data_root, - &app_prefs - ).await?; - - info!("downloaded to: {:?}", download_path); - - Ok(()) -} diff --git a/crates/desktop/artcraft/src/core/commands/download/download_url_command.rs b/crates/desktop/artcraft/src/core/commands/download/download_url_command.rs deleted file mode 100644 index cfcb4c071c..0000000000 --- a/crates/desktop/artcraft/src/core/commands/download/download_url_command.rs +++ /dev/null @@ -1,125 +0,0 @@ -use crate::core::api_adapters::aspect_ratio::common_aspect_ratio::CommonAspectRatio; -use crate::core::artcraft_error::ArtcraftError; -use crate::core::commands::response::failure_response_wrapper::{CommandErrorResponseWrapper, CommandErrorStatus}; -use crate::core::commands::response::shorthand::{Response, ResponseOrErrorType}; -use crate::core::commands::response::success_response_wrapper::SerializeMarker; -use crate::core::events::basic_sendable_event_trait::BasicSendableEvent; -use crate::core::events::warning_events::flash_file_download_error_event::{FlashFileDownloadErrorType, FlashFileDownloadErrorEvent}; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; -use crate::core::state::app_preferences::app_preferences::AppPreferences; -use crate::core::state::app_preferences::app_preferences_manager::AppPreferencesManager; -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::core::utils::download_url_to_temp_dir::download_url_to_temp_dir; -use crate::core::utils::download_url_to_user_download_dir::download_url_to_user_download_dir; -use anyhow::anyhow; -use log::{error, info}; -use serde_derive::{Deserialize, Serialize}; -use std::path::PathBuf; -use std::str::FromStr; -use artcraft_client::endpoints::media_files::get_media_file::get_media_file; -use tauri::{AppHandle, State}; -use url::Url; - -#[derive(Deserialize, Debug)] -pub struct DownloadUrlRequest { - pub url: Url, -} - -#[derive(Serialize)] -pub struct DownloadUrlSuccessResponse { -} - -impl SerializeMarker for DownloadUrlSuccessResponse {} - -#[derive(Serialize, Debug)] -#[serde(rename_all = "snake_case")] -pub enum DownloadUrlErrorType { - FilesystemError, - NetworkError, - UnknownError, -} - - -#[tauri::command] -pub async fn download_url_command( - request: DownloadUrlRequest, - app: AppHandle, - app_prefs: State<'_, AppPreferencesManager>, - app_data_root: State<'_, AppDataRoot>, - app_env_configs: State<'_, AppEnvConfigs>, -) -> ResponseOrErrorType { - - info!("download_url_command called"); - - info!("request: {:?}", request); - - let result = handle_request( - request, - &app, - &app_prefs, - &app_data_root, - &app_env_configs, - ).await; - - if let Err(err) = result { - error!("Error downloading media: {:?}", err); - - let mut endpoint_message = "unknown error when downloading file"; - let mut error_type = DownloadUrlErrorType::UnknownError; - - let mut flash_error_type = FlashFileDownloadErrorType::UnknownError; - let mut flash_filename = None; - let mut flash_message = Some("Failed to download file".to_string()); - - match err { - ArtcraftError::CannotDownloadFilePathAlreadyExists { path } => { - endpoint_message = "file already downloaded"; - error_type = DownloadUrlErrorType::FilesystemError; - - flash_error_type = FlashFileDownloadErrorType::FileAlreadyDownloaded; - flash_message = Some(format!("File already downloaded: {:?}", path)); - flash_filename = Some(path); - } - _ => {}, // NB: Fall-through - } - - let event = FlashFileDownloadErrorEvent { - filename: flash_filename, - message: flash_message, - error_type: flash_error_type, - }; - - event.send_infallible(&app); - - return Err(CommandErrorResponseWrapper { - status: CommandErrorStatus::ServerError, - error_message: Some(endpoint_message.to_string()), - error_type: Some(error_type), - error_details: None, - }); - } - - Ok(DownloadUrlSuccessResponse {}.into()) -} - - -pub async fn handle_request( - request: DownloadUrlRequest, - app: &AppHandle, - app_prefs: &AppPreferencesManager, - app_data_root: &AppDataRoot, - app_env_configs: &AppEnvConfigs -) -> Result<(), ArtcraftError> { - - let app_prefs = app_prefs.get_clone()?; - - let download_path = download_url_to_user_download_dir( - &request.url, - app_data_root, - &app_prefs - ).await?; - - info!("downloaded to: {:?}", download_path); - - Ok(()) -} diff --git a/crates/desktop/artcraft/src/core/commands/download/mod.rs b/crates/desktop/artcraft/src/core/commands/download/mod.rs deleted file mode 100644 index ad9c6330d3..0000000000 --- a/crates/desktop/artcraft/src/core/commands/download/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub mod download_directory_reveal_command; -pub mod download_media_file_command; -pub mod download_url_command; diff --git a/crates/desktop/artcraft/src/core/commands/enqueue/common/maybe_notify_frontend_of_billing_errors.rs b/crates/desktop/artcraft/src/core/commands/enqueue/common/maybe_notify_frontend_of_billing_errors.rs deleted file mode 100644 index 5259fefdcf..0000000000 --- a/crates/desktop/artcraft/src/core/commands/enqueue/common/maybe_notify_frontend_of_billing_errors.rs +++ /dev/null @@ -1,58 +0,0 @@ -use crate::core::commands::enqueue::generate_error::{BillingIssueReason, BillingProvider, GenerateError, ProviderFailureReason}; -use crate::core::events::functional_events::show_provider_billing_modal_event::ShowProviderBillingModalEvent; -use enums::common::generation_provider::GenerationProvider; -use log::warn; -use artcraft_client::error::api_error::ApiError; -use artcraft_client::error::storyteller_error::StorytellerError; -use tauri::AppHandle; - -pub async fn maybe_notify_frontend_of_billing_errors( - app: &AppHandle, - error: &GenerateError, -) { - match error { - GenerateError::BillingIssue(reason) => { - billing_error(app, reason); - } - GenerateError::ProviderFailure(reason) => { - provider_billing_error(app, reason); - } - _ => { - // Do nothing for other types of errors - } - } -} - -fn billing_error( - app: &AppHandle, - reason: &BillingIssueReason, -) { - let provider = match reason.provider { - BillingProvider::Artcraft => GenerationProvider::Artcraft, - BillingProvider::Fal => GenerationProvider::Fal, - BillingProvider::Kinovi => GenerationProvider::Artcraft, // NB: We don't support Kinovi yet. - BillingProvider::Midjourney => GenerationProvider::Midjourney, - BillingProvider::Sora => GenerationProvider::Sora, - }; - warn!("Billing issue with: {:?}", provider); - ShowProviderBillingModalEvent::send_for_provider(provider, app); -} - -fn provider_billing_error( - app: &AppHandle, - error: &ProviderFailureReason, -) { - let provider; - - match error { - ProviderFailureReason::StorytellerError(StorytellerError::Api(ApiError::PaymentRequired(reason))) => { - warn!("Billing issue with Artcraft/Storyteller: {}", reason); - provider = GenerationProvider::Artcraft; - } - _ => { - return; - } - } - - ShowProviderBillingModalEvent::send_for_provider(provider, app); -} diff --git a/crates/desktop/artcraft/src/core/commands/enqueue/common/maybe_notify_frontend_of_grok_errors.rs b/crates/desktop/artcraft/src/core/commands/enqueue/common/maybe_notify_frontend_of_grok_errors.rs deleted file mode 100644 index 1ff72f807d..0000000000 --- a/crates/desktop/artcraft/src/core/commands/enqueue/common/maybe_notify_frontend_of_grok_errors.rs +++ /dev/null @@ -1,41 +0,0 @@ -use crate::core::commands::enqueue::generate_error::{GenerateError, ProviderFailureReason}; -use crate::core::events::basic_sendable_event_trait::BasicSendableEvent; -use crate::core::events::generation_events::common::{GenerationAction, GenerationServiceProvider}; -use crate::core::events::generation_events::generation_enqueue_failure_event::GenerationEnqueueFailureEvent; -use grok_consumer_client::error::grok_error::GrokError; -use grok_consumer_client::error::grok_specific_api_error::GrokSpecificApiError; -use tauri::AppHandle; - -pub async fn maybe_notify_frontend_of_grok_errors( - app: &AppHandle, - error: &GenerateError, -) { - match error { - GenerateError::ProviderFailure(ProviderFailureReason::GrokError(error)) => { - grok_error(app, error); - } - _ => { - // Do nothing for other types of errors - } - } -} - -fn grok_error( - app: &AppHandle, - error: &GrokError, -) { - match error { - GrokError::ApiSpecific(GrokSpecificApiError::TooManyVideos) => { - let event = GenerationEnqueueFailureEvent { - action: GenerationAction::GenerateVideo, - service: GenerationServiceProvider::Grok, - model: None, - reason: Some("You've generated too many Grok videos. Please wait for more quota from Grok.".to_string()), - }; - event.send_infallible(&app); - } - GrokError::ApiSpecific(_) => {} - GrokError::Client(_) => {} - GrokError::ApiGeneric(_) => {} - } -} diff --git a/crates/desktop/artcraft/src/core/commands/enqueue/common/mod.rs b/crates/desktop/artcraft/src/core/commands/enqueue/common/mod.rs deleted file mode 100644 index feab773fad..0000000000 --- a/crates/desktop/artcraft/src/core/commands/enqueue/common/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub mod maybe_notify_frontend_of_billing_errors; -pub mod maybe_notify_frontend_of_grok_errors; -pub mod notify_frontend_of_errors; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/core/commands/enqueue/common/notify_frontend_of_errors.rs b/crates/desktop/artcraft/src/core/commands/enqueue/common/notify_frontend_of_errors.rs deleted file mode 100644 index 1f05e104c3..0000000000 --- a/crates/desktop/artcraft/src/core/commands/enqueue/common/notify_frontend_of_errors.rs +++ /dev/null @@ -1,12 +0,0 @@ -use crate::core::commands::enqueue::common::maybe_notify_frontend_of_billing_errors::maybe_notify_frontend_of_billing_errors; -use crate::core::commands::enqueue::common::maybe_notify_frontend_of_grok_errors::maybe_notify_frontend_of_grok_errors; -use crate::core::commands::enqueue::generate_error::GenerateError; -use tauri::AppHandle; - -pub async fn notify_frontend_of_errors( - app: &AppHandle, - error: &GenerateError, -) { - maybe_notify_frontend_of_billing_errors(app, error).await; - maybe_notify_frontend_of_grok_errors(app, error).await; -} diff --git a/crates/desktop/artcraft/src/core/commands/enqueue/generate_error.rs b/crates/desktop/artcraft/src/core/commands/enqueue/generate_error.rs deleted file mode 100644 index 17123ee6b5..0000000000 --- a/crates/desktop/artcraft/src/core/commands/enqueue/generate_error.rs +++ /dev/null @@ -1,257 +0,0 @@ -use crate::core::artcraft_error::ArtcraftError; -use anyhow::anyhow; -use artcraft_router::errors::artcraft_router_error::ArtcraftRouterError; -use artcraft_router::errors::provider_error::ProviderError; -use base64::DecodeError; -use enums::common::generation_provider::GenerationProvider; -use enums::common::generation::common_model_type::CommonModelType; -use errors::AnyhowError; -use grok_consumer_client::error::grok_error::GrokError; -use midjourney_client::error::midjourney_error::MidjourneyError; -use openai_sora_client::error::sora_error::SoraError; -use artcraft_client::error::storyteller_error::StorytellerError; -use artcraft_router::errors::download_error::DownloadError; -use worldlabs_consumer_client::error::world_labs_error::WorldLabsError; -//use fal_client::error::fal_error_plus::FalErrorPlus; - -#[derive(Debug)] -pub enum GenerateError { - BadInput(BadInputReason), - MissingCredentials(MissingCredentialsReason), - ProviderFailure(ProviderFailureReason), - - /// We couldn't find a provider to dispatch the request to. - NoProviderAvailable, - - /// We pulled out Fal (for now) - it's impacting build speeds. We'll add it in the future. - FalNoLongerSupported, - - /// Wrong provider for the model - BadProviderForModel { - provider: GenerationProvider, - model: CommonModelType, - }, - - /// If the response didn't contain job tokens to track. - ResponseHadNoJobTokens, - - /// Issue with Artcraft router downloads - ArtcraftRouterDownloadError(DownloadError), - - /// A provider we don't support yet in ArtCraft "the Tauri app" part. - ArtcraftRouterNotYetSupportedProvider(&'static str), - - /// There was a billing, credits, or payments issue. - BillingIssue(BillingIssueReason), - - /// The feature is not yet implemented. - NotYetImplemented(String), - - // Misc error buckets - AnyhowError(AnyhowError), - DecodeError(DecodeError), - IoError(std::io::Error), -} - -#[derive(Debug)] -pub enum BadInputReason { - Base64DecodeError, - BothImageMaskMediaTokenAndBytesSupplied, - CannotDetermineImageMimeType, - InvalidNumberOfInputImages { - provided: u32, - min: u32, - max: u32, - }, - InvalidNumberOfRequestedImages { - requested: u32, - min: u32, - max: u32, - }, - NoModelSpecified, - RequiredSourceImageMaskNotProvided, - RequiredSourceImageNotProvided, - WrongImageArguments(String), -} - -#[derive(Debug)] -pub enum MissingCredentialsReason { - NeedsGrokCredentials, - NeedsFalApiKey, - NeedsMidjourneyCredentials, - NeedsMidjourneyUserId, - NeedsMidjourneyUserInfo, - NeedsSoraCredentials, - NeedsStorytellerCredentials, - NeedsWorldLabsCredentials, -} - -#[derive(Debug)] -pub struct BillingIssueReason { - pub provider: BillingProvider, -} - -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum BillingProvider { - Artcraft, - Fal, - Kinovi, - Midjourney, - Sora, -} - -#[derive(Debug)] -pub enum ProviderFailureReason { - GrokError(GrokError), - /// NB: The Grok client doesn't say why certain errors (eg. missing fields) happen, so we synthesize this. - GrokJobEnqueueFailed, - //Fal(FalErrorPlus), - MidjourneyError(MidjourneyError), - /// NB: The midjourney client doesn't categorize all errors, so we have to do so on our end. - MidjourneyJobEnqueueFailed, - SoraError(SoraError), - StorytellerError(StorytellerError), - WorldLabsError(WorldLabsError), -} - -impl GenerateError { - - // - // Bad input - // - - pub fn both_image_mask_media_token_and_bytes_supplied() -> Self { - Self::BadInput(BadInputReason::BothImageMaskMediaTokenAndBytesSupplied) - } - - pub fn no_model_specified() -> Self { - Self::BadInput(BadInputReason::NoModelSpecified) - } - - pub fn required_source_image_mask_not_provided() -> Self { - Self::BadInput(BadInputReason::RequiredSourceImageMaskNotProvided) - } - - pub fn required_source_image_not_provided() -> Self { - Self::BadInput(BadInputReason::RequiredSourceImageNotProvided) - } - - // - // Missing credentials - // - - pub fn needs_fal_api_key() -> Self { - Self::MissingCredentials(MissingCredentialsReason::NeedsFalApiKey) - } - - pub fn needs_grok_credentials() -> Self { - Self::MissingCredentials(MissingCredentialsReason::NeedsGrokCredentials) - } - - pub fn needs_midjourney_credentials() -> Self { - Self::MissingCredentials(MissingCredentialsReason::NeedsMidjourneyCredentials) - } - - pub fn needs_sora_credentials() -> Self { - Self::MissingCredentials(MissingCredentialsReason::NeedsSoraCredentials) - } - - pub fn needs_storyteller_credentials() -> Self { - Self::MissingCredentials(MissingCredentialsReason::NeedsStorytellerCredentials) - } - - pub fn needs_worldlabs_credentials() -> Self { - Self::MissingCredentials(MissingCredentialsReason::NeedsWorldLabsCredentials) - } -} - -impl From for GenerateError { - fn from(value: AnyhowError) -> Self { - Self::AnyhowError(value) - } -} - -impl From for GenerateError { - fn from(value: ArtcraftError) -> Self { - match value { - ArtcraftError::AnyhowError(e) => Self::AnyhowError(e), - ArtcraftError::DecodeError(e) => Self::DecodeError(e), - ArtcraftError::IoError(e) => Self::IoError(e), - ArtcraftError::GrokError(e) => Self::ProviderFailure(ProviderFailureReason::GrokError(e)), - ArtcraftError::StorytellerError(e) => Self::ProviderFailure(ProviderFailureReason::StorytellerError(e)), - ArtcraftError::RwLockReadError => Self::AnyhowError(anyhow!("Lock read error")), - ArtcraftError::RwLockWriteError => Self::AnyhowError(anyhow!("Lock write error")), - ArtcraftError::MutexLockError => Self::AnyhowError(anyhow!("Mutex lock error")), - ArtcraftError::ReqwestError(err) => Self::AnyhowError(anyhow!("Reqwest error: {:?}", err)), - ArtcraftError::BadDownloadFilename { path } => Self::AnyhowError(anyhow!("Bad download file name: {:?}", path)), - ArtcraftError::CannotDownloadFilePathAlreadyExists { path } => Self::AnyhowError(anyhow!("Cannot download already existing file: {:?}", path)), - } - } -} - -//impl From for GenerateError { -// fn from(value: FalErrorPlus) -> Self { -// Self::ProviderFailure(ProviderFailureReason::Fal(value)) -// } -//} - -impl From for GenerateError { - fn from(value: GrokError) -> Self { - Self::ProviderFailure(ProviderFailureReason::GrokError(value)) - } -} - -impl From for GenerateError { - fn from(value: MidjourneyError) -> Self { - Self::ProviderFailure(ProviderFailureReason::MidjourneyError(value)) - } -} - -impl From for GenerateError { - fn from(value: SoraError) -> Self { - Self::ProviderFailure(ProviderFailureReason::SoraError(value)) - } -} - -impl From for GenerateError { - fn from(value: StorytellerError) -> Self { - Self::ProviderFailure(ProviderFailureReason::StorytellerError(value)) - } -} - -impl From for GenerateError { - fn from(value: WorldLabsError) -> Self { - Self::ProviderFailure(ProviderFailureReason::WorldLabsError(value)) - } -} - -impl From for GenerateError { - fn from(value: ArtcraftRouterError) -> Self { - match value { - ArtcraftRouterError::Client(e) => Self::BadInput(BadInputReason::WrongImageArguments(e.to_string())), - ArtcraftRouterError::Download(e) => Self::ArtcraftRouterDownloadError(e), - ArtcraftRouterError::InvalidInput(msg) => Self::BadInput(BadInputReason::WrongImageArguments(msg)), - ArtcraftRouterError::ProviderBillingError(err) => { - let provider = match err { - ProviderError::Fal(_) => BillingProvider::Fal, - ProviderError::KinoviWeb(_) => BillingProvider::Kinovi, - ProviderError::Storyteller(_) => BillingProvider::Artcraft, - ProviderError::GmiCloud(_) => BillingProvider::Artcraft, - ProviderError::Grok(_) => BillingProvider::Artcraft, - ProviderError::WorldLabs(_) => BillingProvider::Artcraft, - }; - Self::BillingIssue(BillingIssueReason { provider }) - }, - ArtcraftRouterError::Provider(ProviderError::Storyteller(e)) => Self::ProviderFailure(ProviderFailureReason::StorytellerError(e)), - ArtcraftRouterError::Provider(ProviderError::Fal(_)) => Self::FalNoLongerSupported, - ArtcraftRouterError::Provider(ProviderError::GmiCloud(_)) => Self::ArtcraftRouterNotYetSupportedProvider("gmicloud"), - ArtcraftRouterError::Provider(ProviderError::Grok(_)) => Self::ArtcraftRouterNotYetSupportedProvider("grok_api"), - ArtcraftRouterError::Provider(ProviderError::KinoviWeb(_)) => Self::ArtcraftRouterNotYetSupportedProvider("kinovi_web"), - // NB: the desktop app reaches World Labs through the Artcraft backend; the router's - // direct World Labs provider isn't used here. - ArtcraftRouterError::Provider(ProviderError::WorldLabs(_)) => Self::ArtcraftRouterNotYetSupportedProvider("world_labs"), - ArtcraftRouterError::UnsupportedModel(model) => Self::NotYetImplemented(format!("Unsupported model: {}", model)), - ArtcraftRouterError::UnsupportedProviderAndModelForNewApi(message) => Self::ArtcraftRouterNotYetSupportedProvider("unsupported model for new router API"), - } - } -} diff --git a/crates/desktop/artcraft/src/core/commands/enqueue/image_bg_removal/artcraft/handle_generic_bg_removal_artcraft.rs b/crates/desktop/artcraft/src/core/commands/enqueue/image_bg_removal/artcraft/handle_generic_bg_removal_artcraft.rs deleted file mode 100644 index b6ed87edbe..0000000000 --- a/crates/desktop/artcraft/src/core/commands/enqueue/image_bg_removal/artcraft/handle_generic_bg_removal_artcraft.rs +++ /dev/null @@ -1,126 +0,0 @@ -use crate::core::commands::enqueue::generate_error::{BadInputReason, GenerateError, MissingCredentialsReason, ProviderFailureReason}; -use crate::core::commands::enqueue::image_bg_removal::enqueue_image_bg_removal_command::EnqueueImageBgRemovalCommand; -use crate::core::commands::deprecated::image_edit::enqueue_edit_image_command::{EditImageQuality, EditImageSize, EnqueueEditImageCommand}; -use crate::core::commands::enqueue::task_enqueue_success::TaskEnqueueSuccess; -use crate::core::events::basic_sendable_event_trait::BasicSendableEvent; -use crate::core::events::generation_events::common::{GenerationAction, GenerationServiceProvider}; -use crate::core::events::generation_events::generation_enqueue_failure_event::GenerationEnqueueFailureEvent; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::core::state::provider_priority::ProviderPriorityStore; -use crate::core::utils::save_base64_image_to_temp_dir::save_base64_image_to_temp_dir; -use crate::services::sora::state::sora_credential_manager::SoraCredentialManager; -use crate::services::sora::state::sora_task_queue::SoraTaskQueue; -use crate::services::storyteller::state::storyteller_credential_manager::StorytellerCredentialManager; -use anyhow::anyhow; -use artcraft_api_defs::generate::image::bg_removal::remove_image_background::RemoveImageBackgroundRequest; -use enums::common::generation_provider::GenerationProvider; -use enums::tauri::tasks::task_type::TaskType; -use uuid_utils::uuid::generate_random_uuid; -use log::{error, info}; -use artcraft_client::credentials::storyteller_credential_set::StorytellerCredentialSet; -use artcraft_client::endpoints::generate::image::bg_removal::remove_image_background::remove_image_background; -use artcraft_client::endpoints::media_files::upload_image_media_file_from_file::{upload_image_media_file_from_file, UploadImageFromFileArgs}; -use tauri::AppHandle; -use tokens::tokens::media_files::MediaFileToken; - -pub async fn handle_generic_bg_removal_artcraft( - request: &EnqueueImageBgRemovalCommand, - app: &AppHandle, - app_data_root: &AppDataRoot, - app_env_configs: &AppEnvConfigs, - storyteller_creds_manager: &StorytellerCredentialManager, -) -> Result { - - let creds = match storyteller_creds_manager.get_credentials()? { - Some(creds) => creds, - None => { - return Err(GenerateError::MissingCredentials(MissingCredentialsReason::NeedsStorytellerCredentials)); - }, - }; - - info!("Calling Artcraft bg removal ..."); - - let uuid_idempotency_token = generate_random_uuid(); - - let image_media_token = match &request.image_media_token { - Some(image_media_token) => image_media_token.clone(), - None => { - upload_image_from_base64_bytes(&request, &app_data_root, &app_env_configs, &creds).await? - } - }; - - let request = RemoveImageBackgroundRequest { - uuid_idempotency_token, - media_file_token: Some(image_media_token), - }; - - let result = remove_image_background( - &app_env_configs.storyteller_host, - Some(&creds), - request, - ).await; - - let success_result = match result { - Ok(enqueued) => { - // TODO(bt,2025-07-05): Enqueue job token? - info!("Successfully enqueued Artcraft background removal. Job token: {}", - enqueued.inference_job_token); - enqueued - } - Err(err) => { - error!("Failed to use Artcraft background removal: {:?}", err); - return Err(GenerateError::ProviderFailure(ProviderFailureReason::StorytellerError(err))); - } - }; - - Ok(TaskEnqueueSuccess { - provider: GenerationProvider::Artcraft, - task_type: TaskType::BackgroundRemoval, - provider_job_id: Some(success_result.inference_job_token.to_string()), - model: None, - maybe_queue_status_url: None, - maybe_prompt_token: None, - maybe_queue_response_url: None, - }) -} - -async fn upload_image_from_base64_bytes( - request: &EnqueueImageBgRemovalCommand, - app_data_root: &AppDataRoot, - app_env_configs: &AppEnvConfigs, - creds: &StorytellerCredentialSet -) -> Result { - let temp_file; - - if let Some(base64_bytes) = &request.base64_image { - info!("Saving base64 image to temp dir ..."); - temp_file = save_base64_image_to_temp_dir(&app_data_root, base64_bytes) - .await - .map_err(|err| { - error!("Failed to save base64 image to temp dir: {:?}", err); - GenerateError::BadInput(BadInputReason::Base64DecodeError) - })?; - } else { - return Err(GenerateError::BadInput(BadInputReason::RequiredSourceImageNotProvided)); - }; - - info!("Uploading image media file from temp file: {:?}", temp_file.path()); - - let result = - upload_image_media_file_from_file(UploadImageFromFileArgs { - api_host: &app_env_configs.storyteller_host, - maybe_creds: Some(&creds), - path: temp_file, - is_intermediate_system_file: true, // NB: Probably not essential to keep this. - maybe_prompt_token: None, // NB: Not used for bg removal. - maybe_batch_token: None, // NB: Not used for bg removal. - maybe_generation_provider: None, - }).await - .map_err(|err| { - error!("Failed to upload image media file: {:?}", err); - GenerateError::ProviderFailure(ProviderFailureReason::StorytellerError(err)) - })?; - - Ok(result.media_file_token) -} diff --git a/crates/desktop/artcraft/src/core/commands/enqueue/image_bg_removal/artcraft/mod.rs b/crates/desktop/artcraft/src/core/commands/enqueue/image_bg_removal/artcraft/mod.rs deleted file mode 100644 index a02c2e249a..0000000000 --- a/crates/desktop/artcraft/src/core/commands/enqueue/image_bg_removal/artcraft/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod handle_generic_bg_removal_artcraft; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/core/commands/enqueue/image_bg_removal/enqueue_image_bg_removal_command.rs b/crates/desktop/artcraft/src/core/commands/enqueue/image_bg_removal/enqueue_image_bg_removal_command.rs deleted file mode 100644 index d18b85217b..0000000000 --- a/crates/desktop/artcraft/src/core/commands/enqueue/image_bg_removal/enqueue_image_bg_removal_command.rs +++ /dev/null @@ -1,230 +0,0 @@ -use crate::core::commands::enqueue::common::notify_frontend_of_errors::notify_frontend_of_errors; -use crate::core::commands::enqueue::generate_error::{BadInputReason, GenerateError}; -use crate::core::commands::enqueue::image_bg_removal::artcraft::handle_generic_bg_removal_artcraft::handle_generic_bg_removal_artcraft; -use crate::core::commands::enqueue::task_enqueue_success::TaskEnqueueSuccess; -use crate::core::commands::response::failure_response_wrapper::{CommandErrorResponseWrapper, CommandErrorStatus}; -use crate::core::commands::response::shorthand::{Response, ResponseOrErrorType}; -use crate::core::commands::response::success_response_wrapper::SerializeMarker; -use crate::core::events::basic_sendable_event_trait::BasicSendableEvent; -use crate::core::events::functional_events::credits_balance_changed_event::CreditsBalanceChangedEvent; -use crate::core::events::generation_events::common::{GenerationAction, GenerationServiceProvider}; -use crate::core::events::generation_events::generation_enqueue_failure_event::GenerationEnqueueFailureEvent; -use crate::core::events::generation_events::generation_enqueue_success_event::GenerationEnqueueSuccessEvent; -use crate::core::events::sendable_event_trait::SendableEvent; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; -use crate::core::state::artcraft_usage_tracker::artcraft_usage_tracker::ArtcraftUsageTracker; -use crate::core::state::artcraft_usage_tracker::artcraft_usage_type::{ArtcraftUsagePage, ArtcraftUsageType}; -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::core::state::data_dir::trait_data_subdir::DataSubdir; -use crate::core::state::provider_priority::{Provider, ProviderPriorityStore}; -use crate::core::state::task_database::TaskDatabase; -use crate::core::utils::get_url_file_extension::get_url_file_extension; -use crate::core::utils::simple_http_download::simple_http_download; -use crate::services::sora::state::sora_credential_manager::SoraCredentialManager; -use crate::services::sora::state::sora_task_queue::SoraTaskQueue; -use crate::services::storyteller::state::storyteller_credential_manager::StorytellerCredentialManager; -use enums::tauri::ux::tauri_command_caller::TauriCommandCaller; -use errors::AnyhowError; -use log::{error, info, warn}; -use openai_sora_client::recipes::image_remix_with_session_auto_renew::{image_remix_with_session_auto_renew, ImageRemixAutoRenewRequest}; -use openai_sora_client::recipes::image_upload_from_file_with_session_auto_renew::{image_upload_from_file_with_session_auto_renew, ImageUploadFromFileAutoRenewRequest}; -use openai_sora_client::recipes::maybe_upgrade_or_renew_session::maybe_upgrade_or_renew_session; -use openai_sora_client::requests::image_gen::common::{ImageSize, NumImages}; -use serde_derive::{Deserialize, Serialize}; -use sqlite_tasks::queries::create_task::{create_task, CreateTaskArgs}; -use std::time::Duration; -use artcraft_client::endpoints::media_files::get_media_file::get_media_file; -use artcraft_client::error::storyteller_error::StorytellerError; -use artcraft_client::utils::api_host::ApiHost; -use tauri::{AppHandle, Manager, State}; -use tokens::tokens::media_files::MediaFileToken; - -#[derive(Deserialize, Debug)] -pub struct EnqueueImageBgRemovalCommand { - // /// The bg removal model to use (optional). - // pub model: Option, - - /// Image media file; the image to remove the background from. - pub image_media_token: Option, - - /// Base64-encoded image - pub base64_image: Option, - - /// OPTIONAL. - /// Name of the frontend caller. - /// We'll use this to selectively trigger events. - pub frontend_caller: Option, - - /// OPTIONAL. - /// A frontend-defined identifier that we'll send back to the frontend - /// as a Tauri event on task completion. - pub frontend_subscriber_id: Option, - - /// OPTIONAL. - /// A frontend-defined payload that we'll send back to the frontend - /// as a Tauri event on task completion. - pub frontend_subscriber_payload: Option, -} - -#[derive(Serialize, Debug)] -#[serde(rename_all = "snake_case")] -pub enum EnqueueImageBgRemovalErrorType { - /// No model available for image generation - NoProviderAvailable, - - /// No image was provided for background removal - MissingImage, - - /// Bad base64 image data - Base64DecodeError, - - /// Generic bad request error - BadRequest, - - /// Generic server error - ServerError, -} - -#[derive(Serialize)] -pub struct EnqueueImageBgRemovalSuccessResponse { -} - -impl SerializeMarker for EnqueueImageBgRemovalSuccessResponse {} - -#[tauri::command] -pub async fn enqueue_image_bg_removal_command( - app: AppHandle, - request: EnqueueImageBgRemovalCommand, - app_data_root: State<'_, AppDataRoot>, - app_env_configs: State<'_, AppEnvConfigs>, - artcraft_usage_tracker: State<'_, ArtcraftUsageTracker>, - provider_priority_store: State<'_, ProviderPriorityStore>, - task_database: State<'_, TaskDatabase>, - storyteller_creds_manager: State<'_, StorytellerCredentialManager>, -) -> ResponseOrErrorType { - - info!("enqueue_image_bg_removal_command called"); - - let result = handle_request( - &request, - &app, - &app_data_root, - &app_env_configs, - &artcraft_usage_tracker, - &provider_priority_store, - &task_database, - &storyteller_creds_manager, - ).await; - - match result { - Err(err) => { - error!("Error removing background: {:?}", err); - - notify_frontend_of_errors(&app, &err).await; - - // TODO: Derive from err. Make service provider optional. - let event = GenerationEnqueueFailureEvent { - action: GenerationAction::RemoveBackground, - service: GenerationServiceProvider::Artcraft, // FIXME: This is wrong. - model: None, - reason: None, - }; - - if let Err(err) = event.send(&app) { - error!("Failed to emit event: {:?}", err); // Fail open. - } - - Err(error_to_tauri_response(err)) - } - Ok(event) => { - let event = GenerationEnqueueSuccessEvent { - action: event.to_frontend_event_action(), - service: event.to_frontend_event_service(), - model: None, // FIXME: This isn't right, though we probably don't care for simple bg removal. - }; - - if let Err(err) = event.send(&app) { - error!("Failed to emit event: {:?}", err); // Fail open. - } - - CreditsBalanceChangedEvent{}.send_infallible(&app); - - Ok(EnqueueImageBgRemovalSuccessResponse {}.into()) - } - } -} - -pub async fn handle_request( - request: &EnqueueImageBgRemovalCommand, - app: &AppHandle, - app_data_root: &AppDataRoot, - app_env_configs: &AppEnvConfigs, - artcraft_usage_tracker: &ArtcraftUsageTracker, - provider_priority_store: &ProviderPriorityStore, - task_database: &TaskDatabase, - storyteller_creds_manager: &StorytellerCredentialManager, -) -> Result { - - // TODO(bt,2025-07-07): Other model/provider routing... - - let success_event = handle_generic_bg_removal_artcraft( - request, - app, - app_data_root, - app_env_configs, - storyteller_creds_manager, - ).await?; - - let result = success_event - .insert_into_task_database_with_frontend_payload( - task_database, - request.frontend_caller, - request.frontend_subscriber_id.as_deref(), - request.frontend_subscriber_payload.as_deref() - ) - .await; - - if let Err(err) = result { - error!("Failed to create task in database: {:?}", err); - // NB: Fail open, but find a way to flag this. - } - - if let Err(err) = artcraft_usage_tracker.record_image_generation(1, ArtcraftUsageType::ImageToResult, ArtcraftUsagePage::EditPage) { - // NB: Fail open. - warn!("Failed to report usage: {:?}", err); - } - - Ok(success_event) -} - -fn error_to_tauri_response(error: GenerateError) -> CommandErrorResponseWrapper { - let mut status = CommandErrorStatus::ServerError; - let mut error_type = EnqueueImageBgRemovalErrorType::ServerError; - let mut error_message = "A server error occurred. Please try again. If it continues, please tell our staff about the problem.".to_string(); - - match error { - GenerateError::NoProviderAvailable => { - status = CommandErrorStatus::ServerError; - error_type = EnqueueImageBgRemovalErrorType::NoProviderAvailable; - error_message = "No configured provider available for background removal".to_string(); - } - GenerateError::BadInput(BadInputReason::RequiredSourceImageNotProvided) => { - status = CommandErrorStatus::BadRequest; - error_type = EnqueueImageBgRemovalErrorType::MissingImage; - error_message = "No image provided for background removal".to_string(); - } - GenerateError::BadInput(BadInputReason::Base64DecodeError) => { - status = CommandErrorStatus::BadRequest; - error_type = EnqueueImageBgRemovalErrorType::Base64DecodeError; - error_message = "Failed to decode base64 image data".to_string(); - } - _ => {}, // Other cases fall through. - } - - CommandErrorResponseWrapper { - status, - error_message: Some(error_message.to_string()), - error_type: Some(error_type), - error_details: None, - } -} diff --git a/crates/desktop/artcraft/src/core/commands/enqueue/image_bg_removal/mod.rs b/crates/desktop/artcraft/src/core/commands/enqueue/image_bg_removal/mod.rs deleted file mode 100644 index 31900208a8..0000000000 --- a/crates/desktop/artcraft/src/core/commands/enqueue/image_bg_removal/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod enqueue_image_bg_removal_command; -pub (super) mod artcraft; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/core/commands/enqueue/image_to_gaussian/artcraft/get_storyteller_creds_or_error.rs b/crates/desktop/artcraft/src/core/commands/enqueue/image_to_gaussian/artcraft/get_storyteller_creds_or_error.rs deleted file mode 100644 index f4bee82220..0000000000 --- a/crates/desktop/artcraft/src/core/commands/enqueue/image_to_gaussian/artcraft/get_storyteller_creds_or_error.rs +++ /dev/null @@ -1,26 +0,0 @@ -use crate::core::commands::enqueue::generate_error::GenerateError; -use crate::core::events::basic_sendable_event_trait::BasicSendableEvent; -use crate::core::events::generation_events::common::GenerationAction; -use crate::core::events::generation_events::generation_enqueue_failure_event::GenerationEnqueueFailureEvent; -use crate::services::storyteller::state::storyteller_credential_manager::StorytellerCredentialManager; -use artcraft_client::credentials::storyteller_credential_set::StorytellerCredentialSet; -use log::error; -use tauri::AppHandle; - -pub(super) fn get_storyteller_creds_or_error( - app: &AppHandle, - storyteller_creds_manager: &StorytellerCredentialManager, -) -> Result { - match storyteller_creds_manager.get_credentials()? { - Some(creds) => Ok(creds), - None => { - error!("No Artcraft credentials are set. Can't perform action."); - let event = - GenerationEnqueueFailureEvent::no_artcraft_credentials(GenerationAction::GenerateGaussian); - - event.send_infallible(app); - - Err(GenerateError::needs_storyteller_credentials()) - } - } -} diff --git a/crates/desktop/artcraft/src/core/commands/enqueue/image_to_gaussian/artcraft/handle_artcraft_gaussian.rs b/crates/desktop/artcraft/src/core/commands/enqueue/image_to_gaussian/artcraft/handle_artcraft_gaussian.rs deleted file mode 100644 index 0854e8af70..0000000000 --- a/crates/desktop/artcraft/src/core/commands/enqueue/image_to_gaussian/artcraft/handle_artcraft_gaussian.rs +++ /dev/null @@ -1,32 +0,0 @@ -use crate::core::commands::enqueue::generate_error::GenerateError; -use crate::core::commands::enqueue::image_to_gaussian::artcraft::get_storyteller_creds_or_error::get_storyteller_creds_or_error; -use crate::core::commands::enqueue::image_to_gaussian::artcraft::handle_artcraft_splat_via_router::handle_artcraft_splat_via_router; -use crate::core::commands::enqueue::image_to_gaussian::enqueue_image_to_gaussian_command::{EnqueueImageToGaussianRequest, GaussianModel}; -use crate::core::commands::enqueue::task_enqueue_success::TaskEnqueueSuccess; -use crate::core::events::generation_events::common::GenerationModel; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; -use crate::services::storyteller::state::storyteller_credential_manager::StorytellerCredentialManager; -use artcraft_router::api::router_splat_model::RouterSplatModel; -use tauri::AppHandle; - -pub async fn handle_gaussian_artcraft( - request: &EnqueueImageToGaussianRequest, - app: &AppHandle, - app_env_configs: &AppEnvConfigs, - storyteller_creds_manager: &StorytellerCredentialManager, -) -> Result { - let creds = get_storyteller_creds_or_error(app, storyteller_creds_manager)?; - - match request.model { - None => Err(GenerateError::no_model_specified()), - Some(GaussianModel::Marble0p1Mini) => { - handle_artcraft_splat_via_router(request, app_env_configs, &creds, RouterSplatModel::Marble0p1Mini, GenerationModel::WorldlabsMarble0p1Mini).await - } - Some( - GaussianModel::Marble0p1Plus | - GaussianModel::WorldLabsMarble // Legacy variant — route to Plus - ) => { - handle_artcraft_splat_via_router(request, app_env_configs, &creds, RouterSplatModel::Marble0p1Plus, GenerationModel::WorldlabsMarble0p1Plus).await - } - } -} diff --git a/crates/desktop/artcraft/src/core/commands/enqueue/image_to_gaussian/artcraft/handle_artcraft_splat_via_router.rs b/crates/desktop/artcraft/src/core/commands/enqueue/image_to_gaussian/artcraft/handle_artcraft_splat_via_router.rs deleted file mode 100644 index 0ddb799eb5..0000000000 --- a/crates/desktop/artcraft/src/core/commands/enqueue/image_to_gaussian/artcraft/handle_artcraft_splat_via_router.rs +++ /dev/null @@ -1,65 +0,0 @@ -use crate::core::commands::enqueue::generate_error::GenerateError; -use crate::core::commands::enqueue::image_to_gaussian::enqueue_image_to_gaussian_command::EnqueueImageToGaussianRequest; -use crate::core::commands::enqueue::task_enqueue_success::TaskEnqueueSuccess; -use crate::core::events::generation_events::common::GenerationModel; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; -use artcraft_client::credentials::storyteller_credential_set::StorytellerCredentialSet; -use artcraft_router::api::router_splat_model::RouterSplatModel; -use artcraft_router::api::image_list_ref::ImageListRef; -use artcraft_router::api::router_provider::RouterProvider; -use artcraft_router::client::router_artcraft_client::RouterArtcraftClient; -use artcraft_router::client::router_client::RouterClient; -use artcraft_router::generate::generate_splat::generate_splat_request::GenerateSplatRequest; -use enums::common::generation_provider::GenerationProvider; -use enums::tauri::tasks::task_type::TaskType; -use log::{error, info}; - -pub(super) async fn handle_artcraft_splat_via_router( - request: &EnqueueImageToGaussianRequest, - app_env_configs: &AppEnvConfigs, - creds: &StorytellerCredentialSet, - model: RouterSplatModel, - generation_model: GenerationModel, -) -> Result { - let client = RouterClient::Artcraft(RouterArtcraftClient::new( - app_env_configs.storyteller_host.clone(), - creds.clone(), - )); - - let router_request = GenerateSplatRequest { - model, - provider: RouterProvider::Artcraft, - prompt: request.prompt.clone(), - reference_images: request.image_media_tokens.clone().map(ImageListRef::MediaFileTokens), - idempotency_token: None, - }; - - let plan = router_request.build()?; - - info!("Splat Generation Plan: {:?}", plan); - - let response = match plan.generate_splat(&client).await { - Ok(resp) => { - info!("Successfully enqueued splat generation."); - resp - } - Err(err) => { - error!("Failed to enqueue splat generation: {:?}", err); - return Err(GenerateError::from(err)); - } - }; - - let job_id = response.get_artcraft_payload() - .map(|p| p.inference_job_token.to_string()) - .ok_or(GenerateError::ResponseHadNoJobTokens)?; - - Ok(TaskEnqueueSuccess { - task_type: TaskType::ImageGeneration, - model: Some(generation_model), - provider: GenerationProvider::Artcraft, - provider_job_id: Some(job_id), - maybe_queue_status_url: None, - maybe_prompt_token: None, - maybe_queue_response_url: None, - }) -} diff --git a/crates/desktop/artcraft/src/core/commands/enqueue/image_to_gaussian/artcraft/mod.rs b/crates/desktop/artcraft/src/core/commands/enqueue/image_to_gaussian/artcraft/mod.rs deleted file mode 100644 index b4eb5153e3..0000000000 --- a/crates/desktop/artcraft/src/core/commands/enqueue/image_to_gaussian/artcraft/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -mod get_storyteller_creds_or_error; -mod handle_artcraft_splat_via_router; -pub(super) mod handle_artcraft_gaussian; diff --git a/crates/desktop/artcraft/src/core/commands/enqueue/image_to_gaussian/enqueue_image_to_gaussian_command.rs b/crates/desktop/artcraft/src/core/commands/enqueue/image_to_gaussian/enqueue_image_to_gaussian_command.rs deleted file mode 100644 index 3e0c1f9404..0000000000 --- a/crates/desktop/artcraft/src/core/commands/enqueue/image_to_gaussian/enqueue_image_to_gaussian_command.rs +++ /dev/null @@ -1,262 +0,0 @@ -use crate::core::commands::enqueue::common::notify_frontend_of_errors::notify_frontend_of_errors; -use crate::core::commands::enqueue::generate_error::{BadInputReason, GenerateError, MissingCredentialsReason}; -use crate::core::commands::enqueue::image_to_gaussian::artcraft::handle_artcraft_gaussian::handle_gaussian_artcraft; -use crate::core::commands::enqueue::image_to_gaussian::worldlabs::handle_worldlabs_marble::handle_worldlabs_marble; -use crate::core::commands::enqueue::task_enqueue_success::TaskEnqueueSuccess; -use crate::core::commands::response::failure_response_wrapper::{CommandErrorResponseWrapper, CommandErrorStatus}; -use crate::core::commands::response::shorthand::Response; -use crate::core::commands::response::success_response_wrapper::SerializeMarker; -use crate::core::events::basic_sendable_event_trait::BasicSendableEvent; -use crate::core::events::functional_events::credits_balance_changed_event::CreditsBalanceChangedEvent; -use crate::core::events::generation_events::common::{GenerationAction, GenerationServiceProvider}; -use crate::core::events::generation_events::generation_enqueue_success_event::GenerationEnqueueSuccessEvent; -use crate::core::events::sendable_event_trait::SendableEvent; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::core::state::provider_priority::{Provider, ProviderPriorityStore}; -use crate::core::state::task_database::TaskDatabase; -use crate::services::grok::state::grok_credential_manager::GrokCredentialManager; -use crate::services::grok::state::grok_image_prompt_queue::GrokImagePromptQueue; -use crate::services::midjourney::state::midjourney_credential_manager::MidjourneyCredentialManager; -use crate::services::sora::state::sora_credential_manager::SoraCredentialManager; -use crate::services::sora::state::sora_task_queue::SoraTaskQueue; -use crate::services::storyteller::state::storyteller_credential_manager::StorytellerCredentialManager; -use crate::services::worldlabs::state::worldlabs_credential_manager::WorldlabsCredentialManager; -use enums::common::generation_provider::GenerationProvider; -use enums::tauri::ux::tauri_command_caller::TauriCommandCaller; -use log::{error, info, warn}; -use serde::{Deserialize, Serialize}; -use sqlite_tasks::queries::create_task::{create_task, CreateTaskArgs}; -use tauri::{AppHandle, State}; -use tokens::tokens::media_files::MediaFileToken; -use crate::core::state::artcraft_usage_tracker::artcraft_usage_tracker::ArtcraftUsageTracker; -use crate::core::state::artcraft_usage_tracker::artcraft_usage_type::{ArtcraftUsagePage, ArtcraftUsageType}; - -/// This is used in the Tauri command bridge. -/// Don't change the serializations without coordinating with the frontend. -#[derive(Deserialize, Debug, Copy, Clone)] -#[serde(rename_all = "snake_case")] -pub enum GaussianModel { - #[serde(rename = "world_labs_marble")] - WorldLabsMarble, - - #[serde(rename = "marble_0p1_mini")] - Marble0p1Mini, - - #[serde(rename = "marble_0p1_plus")] - Marble0p1Plus, -} - -#[derive(Deserialize)] -pub struct EnqueueImageToGaussianRequest { - /// REQUIRED. - /// The model to use. - pub model: Option, - - /// OPTIONAL. - /// The provider to use (defaults to Artcraft/Storyteller). - /// Not all (provider, model) combinations are valid. - pub provider: Option, - - /// OPTIONAL. - /// Text prompt for the gaussian generation. Required. - pub prompt: Option, - - /// OPTIONAL. - /// Images for the gaussian generation - pub image_media_tokens: Option>, - - /// OPTIONAL. - /// Name of the frontend caller. - /// We'll use this to selectively trigger events. - pub frontend_caller: Option, - - /// OPTIONAL. - /// A frontend-defined identifier that we'll send back to the frontend - /// as a Tauri event on task completion. - pub frontend_subscriber_id: Option, - - /// OPTIONAL. - /// A frontend-defined payload that we'll send back to the frontend - /// as a Tauri event on task completion. - pub frontend_subscriber_payload: Option, -} - -#[derive(Serialize)] -pub struct EnqueueImageToGaussianSuccessResponse { -} - -impl SerializeMarker for EnqueueImageToGaussianSuccessResponse {} - -#[derive(Serialize, Debug)] -#[serde(rename_all = "snake_case")] -pub enum EnqueueImageToGaussianErrorType { - /// Caller didn't specify a model - ModelNotSpecified, - /// No model available for image generation - NoProviderAvailable, - /// Generic server error - ServerError, - /// Needs to be logged into Artcraft - NeedsStorytellerCredentials, -} - -#[tauri::command] -pub async fn enqueue_image_to_gaussian_command( - request: EnqueueImageToGaussianRequest, - app: AppHandle, - app_data_root: State<'_, AppDataRoot>, - app_env_configs: State<'_, AppEnvConfigs>, - artcraft_usage_tracker: State<'_, ArtcraftUsageTracker>, - task_database: State<'_, TaskDatabase>, - storyteller_creds_manager: State<'_, StorytellerCredentialManager>, - worldlabs_creds_manager: State<'_, WorldlabsCredentialManager>, -) -> Response { - - info!("enqueue_image_to_gaussian called"); - - let result = handle_request( - request, - &app, - &app_data_root, - &artcraft_usage_tracker, - &task_database, - &storyteller_creds_manager, - &worldlabs_creds_manager, - &app_env_configs, - ).await; - - match result { - Err(err) => { - error!("error: {:?}", err); - - notify_frontend_of_errors(&app, &err).await; - - let mut status = CommandErrorStatus::ServerError; - let mut error_type = EnqueueImageToGaussianErrorType::ServerError; - let mut error_message = "A server error occurred. Please try again. If it continues, please tell our staff about the problem."; - - match err { - GenerateError::BadInput(BadInputReason::NoModelSpecified) => { - status = CommandErrorStatus::BadRequest; - error_type = EnqueueImageToGaussianErrorType::ModelNotSpecified; - error_message = "No model specified for image generation"; - } - GenerateError::NoProviderAvailable => { - status = CommandErrorStatus::ServerError; - error_type = EnqueueImageToGaussianErrorType::NoProviderAvailable; - error_message = "No configured provider available for image generation"; - } - _ => {}, // Fall-through - } - - Err(CommandErrorResponseWrapper { - status, - error_message: Some(error_message.to_string()), - error_type: Some(error_type), - error_details: None, - }) - } - Ok(event) => { - let event = GenerationEnqueueSuccessEvent { - action: event.to_frontend_event_action(), - service: event.to_frontend_event_service(), - model: event.model, - }; - - if let Err(err) = event.send(&app) { - error!("Failed to emit event: {:?}", err); // Fail open. - } - - CreditsBalanceChangedEvent{}.send_infallible(&app); - - Ok(EnqueueImageToGaussianSuccessResponse {}.into()) - } - } -} - -pub async fn handle_request( - request: EnqueueImageToGaussianRequest, - app: &AppHandle, - app_data_root: &AppDataRoot, - artcraft_usage_tracker: &ArtcraftUsageTracker, - task_database: &TaskDatabase, - storyteller_creds_manager: &StorytellerCredentialManager, - worldlabs_creds_manager: &WorldlabsCredentialManager, - app_env_configs: &AppEnvConfigs, -) -> Result { - - let result = dispatch_request( - &request, - &app, - &app_data_root, - &storyteller_creds_manager, - &worldlabs_creds_manager, - &app_env_configs, - ).await; - - let success_event = match result { - Err(err) => return Err(err), - Ok(event) => event, - }; - - let result = success_event - .insert_into_task_database_with_frontend_payload( - task_database, - request.frontend_caller, - request.frontend_subscriber_id.as_deref(), - request.frontend_subscriber_payload.as_deref(), - ) - .await; - - if let Err(err) = result { - error!("Failed to create task in database: {:?}", err); - // NB: Fail open, but find a way to flag this. - } - - if let Err(err) = artcraft_usage_tracker.record_object_generation(1, ArtcraftUsageType::ImageToResult, ArtcraftUsagePage::OtherPage) { - // NB: Fail open. - warn!("Failed to report usage: {:?}", err); - } - - Ok(success_event) -} - -pub async fn dispatch_request( - request: &EnqueueImageToGaussianRequest, - app: &AppHandle, - app_data_root: &AppDataRoot, - storyteller_creds_manager: &StorytellerCredentialManager, - worldlabs_creds_manager: &WorldlabsCredentialManager, - app_env_configs: &AppEnvConfigs, -) -> Result { - - if request.model.is_none() { - return Err(GenerateError::BadInput(BadInputReason::NoModelSpecified)); - } - - let provider = request.provider.unwrap_or(GenerationProvider::Artcraft); - - match provider { - GenerationProvider::WorldLabs => { - handle_worldlabs_marble( - app, - app_data_root, - app_env_configs, - request, - worldlabs_creds_manager, - ).await - } - GenerationProvider::Artcraft => { - handle_gaussian_artcraft( - request, - app, - app_env_configs, - storyteller_creds_manager, - ).await - } - _ => { - Err(GenerateError::NoProviderAvailable) - } - } -} diff --git a/crates/desktop/artcraft/src/core/commands/enqueue/image_to_gaussian/mod.rs b/crates/desktop/artcraft/src/core/commands/enqueue/image_to_gaussian/mod.rs deleted file mode 100644 index 59dc5bdcb9..0000000000 --- a/crates/desktop/artcraft/src/core/commands/enqueue/image_to_gaussian/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -mod artcraft; -pub mod enqueue_image_to_gaussian_command; -mod worldlabs; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/core/commands/enqueue/image_to_gaussian/worldlabs/handle_worldlabs_marble.rs b/crates/desktop/artcraft/src/core/commands/enqueue/image_to_gaussian/worldlabs/handle_worldlabs_marble.rs deleted file mode 100644 index 1b588af4ec..0000000000 --- a/crates/desktop/artcraft/src/core/commands/enqueue/image_to_gaussian/worldlabs/handle_worldlabs_marble.rs +++ /dev/null @@ -1,240 +0,0 @@ -use crate::core::commands::enqueue::generate_error::{BadInputReason, GenerateError, MissingCredentialsReason}; -use crate::core::commands::enqueue::image_to_gaussian::enqueue_image_to_gaussian_command::EnqueueImageToGaussianRequest; -use crate::core::commands::enqueue::task_enqueue_success::TaskEnqueueSuccess; -use crate::core::commands::deprecated::text_to_image::enqueue_text_to_image_command::{EnqueueTextToImageRequest, TextToImageSize}; -use crate::core::events::functional_events::show_provider_login_modal_event::ShowProviderLoginModalEvent; -use crate::core::events::generation_events::common::GenerationModel; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::core::state::data_dir::trait_data_subdir::DataSubdir; -use crate::core::utils::get_url_file_extension::get_url_file_extension; -use crate::core::utils::simple_http_download::simple_http_download; -use crate::services::storyteller::state::storyteller_credential_manager::StorytellerCredentialManager; -use crate::services::worldlabs::state::worldlabs_credential_manager::WorldlabsCredentialManager; -use enums::common::generation_provider::GenerationProvider; -use enums::tauri::tasks::task_type::TaskType; -use uuid_utils::uuid::generate_random_uuid; -use log::{error, info}; -use std::path::PathBuf; -use artcraft_client::endpoints::media_files::get_media_file::get_media_file; -use tauri::AppHandle; -use tokens::tokens::media_files::MediaFileToken; -use worldlabs_consumer_client::credentials::world_labs_cookies::WorldLabsCookies; -use worldlabs_consumer_client::recipes::upload_image_and_create_world_with_retry::{upload_image_and_create_world_with_retry, FileBytesOrPath, UploadImageAndCreateWorldWithRetryArgs}; - -pub(super) const MAX_IMAGES: usize = 10; - -#[deprecated(note = "Legacy direct-provider handler; desktop generation now uses ArtCraft.")] -pub async fn handle_worldlabs_marble( - app: &AppHandle, - app_data_root: &AppDataRoot, - app_env_configs: &AppEnvConfigs, - request: &EnqueueImageToGaussianRequest, - worldlabs_creds_manager: &WorldlabsCredentialManager, -) -> Result { - - let world_labs_cookies = match worldlabs_creds_manager.maybe_copy_typed_cookies()? { - Some(cookies) => cookies, - None => { - error!("No WorldLabs cookies!"); - ShowProviderLoginModalEvent::send_for_provider(GenerationProvider::WorldLabs, &app); - return Err(GenerateError::needs_worldlabs_credentials()); - } - }; - - let world_labs_bearer = match worldlabs_creds_manager.maybe_copy_bearer_token()? { - Some(bearer) => bearer, - None => { - error!("No WorldLabs bearer token!"); - ShowProviderLoginModalEvent::send_for_provider(GenerationProvider::WorldLabs, &app); - return Err(GenerateError::needs_worldlabs_credentials()); - } - }; - - let world_labs_refresh = match worldlabs_creds_manager.maybe_copy_refresh_token()? { - Some(bearer) => bearer, - None => { - error!("No WorldLabs refresh token!"); - ShowProviderLoginModalEvent::send_for_provider(GenerationProvider::WorldLabs, &app); - return Err(GenerateError::needs_worldlabs_credentials()); - } - }; - - let maybe_prompt = request.prompt - .as_deref() - .map(|prompt| prompt.trim().to_string()); - - info!("Downloading image file..."); - - let file_path = download_file( - app_data_root, - app_env_configs, - request, - ).await?; - - info!("Enqueueing WorldLabs request..."); - - let response = upload_image_and_create_world_with_retry(UploadImageAndCreateWorldWithRetryArgs { - cookies: &world_labs_cookies, - bearer_token: &world_labs_bearer, - refresh_token: &world_labs_refresh, - individual_request_timeout: None, - file: FileBytesOrPath::Path(file_path), - }).await?; - - let run_id = response.run_id; - let world_id = response.world_id; - - info!("Run ID: {:?}", run_id); - info!("World ID: {:?}", world_id); - - if let Some(new_access) = response.maybe_new_access_tokens { - info!("New access tokens were generated; saving."); - worldlabs_creds_manager.replace_bearer_and_refresh_token( - new_access.bearer_token, - new_access.refresh_token - )?; - - worldlabs_creds_manager.persist_to_disk()?; - } - - Ok(TaskEnqueueSuccess { - provider: GenerationProvider::WorldLabs, - model: Some(GenerationModel::WorldlabsMarble), - provider_job_id: Some(world_id.0), - task_type: TaskType::ImageGeneration, - maybe_queue_status_url: None, - maybe_prompt_token: None, - maybe_queue_response_url: None, - }) -} - -async fn download_file( - app_data_root: &AppDataRoot, - app_env_configs: &AppEnvConfigs, - request: &EnqueueImageToGaussianRequest, -) -> Result { - - let maybe_media_token = request.image_media_tokens - .as_ref() - .and_then(|tokens| tokens.get(0)); - - let media_token = match maybe_media_token { - Some(token) => token, - None => { - return Err(GenerateError::BadInput(BadInputReason::InvalidNumberOfInputImages { - min: 1, - max: MAX_IMAGES as u32, - provided: 0, - })); - } - }; - - info!("Calling get media file API: {:?}", app_env_configs.storyteller_host); - - // TODO(bt,2025-12-18): Add a cache. - info!("Using media token: {:?}", media_token); - - let response = get_media_file( - &app_env_configs.storyteller_host, - media_token - ).await?; - - let media_file_url = &response.media_file.media_links.cdn_url; - let extension_with_dot = get_url_file_extension(media_file_url) - .map(|ext| format!(".{}", ext)) - .unwrap_or_else(|| ".png".to_string()); - - let filename = format!("{}{}", response.media_file.token.as_str(), extension_with_dot); - let filename = app_data_root.downloads_dir().path().join(&filename); - - simple_http_download(&media_file_url, &filename).await?; - - Ok(filename) -} - -//async fn download_files( -// app_data_root: &AppDataRoot, -// app_env_configs: &AppEnvConfigs, -// request: &EnqueueImageToGaussianRequest, -//) -> Result, GenerateError> { -// -// let maybe_media_token = request.image_media_tokens -// .as_ref() -// .and_then(|tokens| tokens.get(0)); -// -// -// let media_tokens = match request.image_media_tokens.as_ref() { -// Some(media_tokens) => media_tokens.to_vec(), -// None => { -// return Err(GenerateError::BadInput(BadInputReason::InvalidNumberOfInputImages { -// min: 1, -// max: MAX_IMAGES as u32, -// provided: 0, -// })); -// } -// }; -// -// if media_tokens.len() > MAX_IMAGES { -// return Err(GenerateError::BadInput(BadInputReason::InvalidNumberOfInputImages { -// min: 1, -// max: MAX_IMAGES as u32, -// provided: media_tokens.len() as u32, -// })); -// } -// -// info!("Calling get media file API: {:?}", app_env_configs.storyteller_host); -// -// let mut local_files_to_upload = Vec::with_capacity(10); -// -// // TODO(bt,2025-07-07): This is inefficient. Cache and parallelize this. -// // TODO(bt,2025-12-18): Add a cache. -// for media_token in media_tokens.iter() { -// info!("Using media token: {:?}", media_token); -// -// let response = get_media_file( -// &app_env_configs.storyteller_host, -// media_token -// ).await?; -// -// let media_file_url = &response.media_file.media_links.cdn_url; -// let extension_with_dot = get_url_file_extension(media_file_url) -// .map(|ext| format!(".{}", ext)) -// .unwrap_or_else(|| ".png".to_string()); -// -// let filename = format!("{}{}", response.media_file.token.as_str(), extension_with_dot); -// let filename = app_data_root.downloads_dir().path().join(&filename); -// -// simple_http_download(&media_file_url, &filename).await?; -// -// local_files_to_upload.push(filename); -// } -// -// Ok(local_files_to_upload) -//} - -// TODO: -// fn handle_midjourney_errors( -// app: &AppHandle, -// maybe_errors: Option> -// ) -> Result { -// if let Some(errors) = maybe_errors { -// if !errors.is_empty() { -// let messages: Vec = errors.iter() -// .map(|e| format!("{:?}", e)) -// .collect(); -// -// let combined_message = messages.join("; "); -// -// let event = FlashUserInputErrorEvent { -// message: format!("Midjourney Error: {}", combined_message), -// }; -// -// if let Err(err) = event.send(&app) { -// error!("Failed to send FlashUserInputErrorEvent: {:?}", err); // Fail open -// } -// } -// } -// -// Err(GenerateError::ProviderFailure(ProviderFailureReason::MidjourneyJobEnqueueFailed)) -// } diff --git a/crates/desktop/artcraft/src/core/commands/enqueue/image_to_gaussian/worldlabs/mod.rs b/crates/desktop/artcraft/src/core/commands/enqueue/image_to_gaussian/worldlabs/mod.rs deleted file mode 100644 index 73ec59edec..0000000000 --- a/crates/desktop/artcraft/src/core/commands/enqueue/image_to_gaussian/worldlabs/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub (super) mod handle_worldlabs_marble; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/core/commands/enqueue/image_to_object/artcraft/handle_artcraft_object.rs b/crates/desktop/artcraft/src/core/commands/enqueue/image_to_object/artcraft/handle_artcraft_object.rs deleted file mode 100644 index d8775aee20..0000000000 --- a/crates/desktop/artcraft/src/core/commands/enqueue/image_to_object/artcraft/handle_artcraft_object.rs +++ /dev/null @@ -1,159 +0,0 @@ -use crate::core::commands::enqueue::generate_error::GenerateError; -use crate::core::commands::enqueue::image_to_object::enqueue_image_to_3d_object_command::{EnqueueImageTo3dObjectModel, EnqueueImageTo3dObjectRequest}; -use crate::core::commands::enqueue::task_enqueue_success::TaskEnqueueSuccess; -use crate::core::events::basic_sendable_event_trait::BasicSendableEvent; -use crate::core::events::generation_events::common::{GenerationAction, GenerationModel, GenerationServiceProvider}; -use crate::core::events::generation_events::generation_enqueue_failure_event::GenerationEnqueueFailureEvent; -use crate::core::events::generation_events::generation_enqueue_success_event::GenerationEnqueueSuccessEvent; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::services::storyteller::state::storyteller_credential_manager::StorytellerCredentialManager; -use artcraft_api_defs::generate::object::generate_hunyuan_2_0_image_to_3d::GenerateHunyuan20ImageTo3dRequest; -use artcraft_api_defs::generate::object::generate_hunyuan_2_1_image_to_3d::GenerateHunyuan21ImageTo3dRequest; -use enums::common::generation_provider::GenerationProvider; -use enums::tauri::tasks::task_type::TaskType; -use uuid_utils::uuid::generate_random_uuid; -use log::{error, info}; -use artcraft_client::endpoints::generate::object::generate_hunyuan_3d_2_0_image_to_3d::generate_hunyuan3d_2_0_image_to_3d; -use artcraft_client::endpoints::generate::object::generate_hunyuan_3d_2_1_image_to_3d::generate_hunyuan3d_2_1_image_to_3d; -use tauri::AppHandle; -use artcraft_api_defs::generate::object::multi_function::hunyuan3d_v3_multi_function_object_gen::Hunyuan3dV3MultiFunctionObjectGenRequest; -use artcraft_client::endpoints::generate::object::multi_function::hunyuan3d_v3_multi_function_object_gen::hunyuan3d_v3_multi_function_object_gen; - -pub async fn handle_artcraft_object( - request: &EnqueueImageTo3dObjectRequest, - app: &AppHandle, - app_env_configs: &AppEnvConfigs, - app_data_root: &AppDataRoot, - storyteller_creds_manager: &StorytellerCredentialManager, -) -> Result { - - let creds = match storyteller_creds_manager.get_credentials()? { - Some(creds) => creds, - None => { - error!("No Artcraft credentials are set. Can't perform action."); - let event = - GenerationEnqueueFailureEvent::no_artcraft_credentials(GenerationAction::ImageTo3d); - - if let Err(err) = event.send(&app) { - error!("Failed to emit event: {:?}", err); // Fail open. - } - - return Err(GenerateError::needs_storyteller_credentials()); - }, - }; - - info!("Calling Artcraft image to 3d ..."); - - let uuid_idempotency_token = generate_random_uuid(); - - let mut used_model = None; - - let job_token = match request.model { - None => { - return Err(GenerateError::no_model_specified()); - } - Some( - EnqueueImageTo3dObjectModel::Hunyuan3d2 | - EnqueueImageTo3dObjectModel::Hunyuan3d2_0 - ) => { - info!("enqueue Artcraft Hunyuan 3D 2.0"); - used_model = Some(GenerationModel::Hunyuan3d2_0); - let request = GenerateHunyuan20ImageTo3dRequest { - uuid_idempotency_token, - media_file_token: request.image_media_token.clone(), - }; - let result = generate_hunyuan3d_2_0_image_to_3d( - &app_env_configs.storyteller_host, - Some(&creds), - request, - ).await; - match result { - Ok(enqueued) => { - info!("Successfully enqueued Artcraft Hunyuan 3D 2.0"); - enqueued.inference_job_token - } - Err(err) => { - error!("Failed to use Artcraft Hunyuan 3D 2.0: {:?}", err); - return Err(GenerateError::from(err)); - } - } - } - Some(EnqueueImageTo3dObjectModel::Hunyuan3d2_1) => { - info!("enqueue Artcraft Hunyuan 3D 2.1"); - used_model = Some(GenerationModel::Hunyuan3d2_1); - let request = GenerateHunyuan21ImageTo3dRequest { - uuid_idempotency_token, - media_file_token: request.image_media_token.clone(), - }; - let result = generate_hunyuan3d_2_1_image_to_3d( - &app_env_configs.storyteller_host, - Some(&creds), - request, - ).await; - match result { - Ok(enqueued) => { - info!("Successfully enqueued Artcraft Hunyuan 3D 2.1"); - enqueued.inference_job_token - } - Err(err) => { - error!("Failed to use Artcraft Hunyuan 3D 2.1: {:?}", err); - return Err(GenerateError::from(err)); - } - } - } - Some(EnqueueImageTo3dObjectModel::Hunyuan3d3) => { - info!("enqueue Artcraft Hunyuan 3D 3"); - used_model = Some(GenerationModel::Hunyuan3d3); - let request = Hunyuan3dV3MultiFunctionObjectGenRequest { - uuid_idempotency_token, - image_media_token: request.image_media_token.clone(), - prompt: None, - back_image_media_token: None, - left_image_media_token: None, - right_image_media_token: None, - face_count: None, - generate_type: None, - polygon_type: None, - enable_pbr: None, - }; - let result = hunyuan3d_v3_multi_function_object_gen( - &app_env_configs.storyteller_host, - Some(&creds), - request, - ).await; - match result { - Ok(enqueued) => { - info!("Successfully enqueued Artcraft Hunyuan 3D 3"); - enqueued.inference_job_token - } - Err(err) => { - error!("Failed to use Artcraft Hunyuan 3D 3: {:?}", err); - return Err(GenerateError::from(err)); - } - } - } - }; - - info!("Successfully enqueued 3D generation"); - - //let event = GenerationEnqueueSuccessEvent { - // action: GenerationAction::ImageTo3d, - // service: GenerationServiceProvider::Artcraft, - // model: None, - //}; - // - //if let Err(err) = event.send(app) { - // error!("Failed to emit event: {:?}", err); // Fail open. - //} - - Ok(TaskEnqueueSuccess { - task_type: TaskType::ObjectGeneration, - model: used_model, - provider: GenerationProvider::Artcraft, - provider_job_id: Some(job_token.to_string()), - maybe_queue_status_url: None, - maybe_prompt_token: None, - maybe_queue_response_url: None, - }) -} diff --git a/crates/desktop/artcraft/src/core/commands/enqueue/image_to_object/artcraft/mod.rs b/crates/desktop/artcraft/src/core/commands/enqueue/image_to_object/artcraft/mod.rs deleted file mode 100644 index f623ebcbe4..0000000000 --- a/crates/desktop/artcraft/src/core/commands/enqueue/image_to_object/artcraft/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub (super) mod handle_artcraft_object; diff --git a/crates/desktop/artcraft/src/core/commands/enqueue/image_to_object/enqueue_image_to_3d_object_command.rs b/crates/desktop/artcraft/src/core/commands/enqueue/image_to_object/enqueue_image_to_3d_object_command.rs deleted file mode 100644 index 39bcf076d3..0000000000 --- a/crates/desktop/artcraft/src/core/commands/enqueue/image_to_object/enqueue_image_to_3d_object_command.rs +++ /dev/null @@ -1,217 +0,0 @@ -use crate::core::commands::enqueue::common::notify_frontend_of_errors::notify_frontend_of_errors; -use crate::core::commands::enqueue::generate_error::{BadInputReason, GenerateError, MissingCredentialsReason}; -use crate::core::commands::enqueue::image_to_object::artcraft::handle_artcraft_object::handle_artcraft_object; -use crate::core::commands::enqueue::task_enqueue_success::TaskEnqueueSuccess; -use crate::core::commands::response::failure_response_wrapper::{CommandErrorResponseWrapper, CommandErrorStatus}; -use crate::core::commands::response::shorthand::Response; -use crate::core::commands::response::success_response_wrapper::SerializeMarker; -use crate::core::events::basic_sendable_event_trait::BasicSendableEvent; -use crate::core::events::functional_events::credits_balance_changed_event::CreditsBalanceChangedEvent; -use crate::core::events::generation_events::generation_enqueue_success_event::GenerationEnqueueSuccessEvent; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::core::state::provider_priority::{Provider, ProviderPriorityStore}; -use crate::core::state::task_database::TaskDatabase; -use crate::services::sora::state::sora_task_queue::SoraTaskQueue; -use crate::services::storyteller::state::storyteller_credential_manager::StorytellerCredentialManager; -use enums::tauri::ux::tauri_command_caller::TauriCommandCaller; -use log::{error, info, warn}; -use serde_derive::{Deserialize, Serialize}; -use tauri::{AppHandle, State}; -use tokens::tokens::media_files::MediaFileToken; -use crate::core::state::artcraft_usage_tracker::artcraft_usage_tracker::ArtcraftUsageTracker; -use crate::core::state::artcraft_usage_tracker::artcraft_usage_type::{ArtcraftUsagePage, ArtcraftUsageType}; - -#[derive(Deserialize)] -pub struct EnqueueImageTo3dObjectRequest { - /// Image media file; the image to remove the background from. - /// TODO: In the future we may support base64 images, URLs, or file paths here. - pub image_media_token: Option, - - /// The model to use. - pub model: Option, - - /// OPTIONAL. - /// Name of the frontend caller. - /// We'll use this to selectively trigger events. - pub frontend_caller: Option, - - /// OPTIONAL. - /// A frontend-defined identifier that we'll send back to the frontend - /// as a Tauri event on task completion. - pub frontend_subscriber_id: Option, - - /// OPTIONAL. - /// A frontend-defined payload that we'll send back to the frontend - /// as a Tauri event on task completion. - pub frontend_subscriber_payload: Option, -} - -#[derive(Deserialize, Debug, Copy, Clone)] -#[serde(rename_all = "snake_case")] -pub enum EnqueueImageTo3dObjectModel { - #[deprecated(note="Use `hunyuan_3d_2_0` instead")] - #[serde(rename = "hunyuan_3d_2")] - Hunyuan3d2, - #[serde(rename = "hunyuan_3d_2_0")] - Hunyuan3d2_0, - #[serde(rename = "hunyuan_3d_2_1")] - Hunyuan3d2_1, - #[serde(rename = "hunyuan_3d_3")] - Hunyuan3d3, -} - -#[derive(Serialize)] -pub struct EnqueueImageTo3dObjectSuccessResponse { -} - -impl SerializeMarker for EnqueueImageTo3dObjectSuccessResponse {} - -#[derive(Serialize, Debug)] -#[serde(rename_all = "snake_case")] -pub enum EnqueueImageTo3dObjectErrorType { - /// Caller didn't specify a model - ModelNotSpecified, - /// No model available for object generation - NoProviderAvailable, - /// Generic server error - ServerError, - /// No Fal API key available - NeedsFalApiKey, - /// Fal had an API error - FalError, - /// Needs to be logged into Artcraft - NeedsStorytellerCredentials, -} - -#[tauri::command] -pub async fn enqueue_image_to_3d_object_command( - app: AppHandle, - request: EnqueueImageTo3dObjectRequest, - app_env_configs: State<'_, AppEnvConfigs>, - app_data_root: State<'_, AppDataRoot>, - artcraft_usage_tracker: State<'_, ArtcraftUsageTracker>, - provider_priority_store: State<'_, ProviderPriorityStore>, - task_database: State<'_, TaskDatabase>, - storyteller_creds_manager: State<'_, StorytellerCredentialManager>, - sora_task_queue: State<'_, SoraTaskQueue>, -) -> Response { - - info!("enqueue_image_to_3d_object_command called"); - - let result = handle_request( - request, - &app, - &app_env_configs, - &app_data_root, - &artcraft_usage_tracker, - &provider_priority_store, - &task_database, - &storyteller_creds_manager, - ).await; - - match result { - Err(err) => { - error!("error: {:?}", err); - - notify_frontend_of_errors(&app, &err).await; - - let mut status = CommandErrorStatus::ServerError; - let mut error_type = EnqueueImageTo3dObjectErrorType::ServerError; - let mut error_message = "A server error occurred. Please try again. If it continues, please tell our staff about the problem."; - - match err { - GenerateError::BadInput(BadInputReason::NoModelSpecified) => { - status = CommandErrorStatus::BadRequest; - error_type = EnqueueImageTo3dObjectErrorType::ModelNotSpecified; - error_message = "No model specified for object generation"; - } - GenerateError::NoProviderAvailable => { - status = CommandErrorStatus::ServerError; - error_type = EnqueueImageTo3dObjectErrorType::NoProviderAvailable; - error_message = "No configured provider available for object generation"; - } - GenerateError::MissingCredentials(MissingCredentialsReason::NeedsFalApiKey) => { - status = CommandErrorStatus::Unauthorized; - error_type = EnqueueImageTo3dObjectErrorType::NeedsFalApiKey; - error_message = "You need to set a FAL api key"; - }, - GenerateError::MissingCredentials(MissingCredentialsReason::NeedsStorytellerCredentials) => { - status = CommandErrorStatus::Unauthorized; - error_type = EnqueueImageTo3dObjectErrorType::NeedsStorytellerCredentials; - error_message = "You need to be logged into Artcraft."; - } - _ => {}, // Fall-through - } - - Err(CommandErrorResponseWrapper { - status, - error_message: Some(error_message.to_string()), - error_type: Some(error_type), - error_details: None, - }) - } - Ok(event) => { - let event = GenerationEnqueueSuccessEvent { - action: event.to_frontend_event_action(), - service: event.to_frontend_event_service(), - model: event.model, - }; - - if let Err(err) = event.send(&app) { - error!("Failed to emit event: {:?}", err); // Fail open. - } - - CreditsBalanceChangedEvent{}.send_infallible(&app); - - Ok(EnqueueImageTo3dObjectSuccessResponse {}.into()) - } - } -} - - -pub async fn handle_request( - request: EnqueueImageTo3dObjectRequest, - app: &AppHandle, - app_env_configs: &AppEnvConfigs, - app_data_root: &AppDataRoot, - artcraft_usage_tracker: &ArtcraftUsageTracker, - provider_priority_store: &ProviderPriorityStore, - task_database: &TaskDatabase, - storyteller_creds_manager: &StorytellerCredentialManager, -) -> Result { - - let result = handle_artcraft_object( - &request, - &app, - &app_env_configs, - &app_data_root, - &storyteller_creds_manager, - ).await; - - let success_event = match result { - Err(err) => return Err(err), - Ok(event) => event, - }; - - let result = success_event - .insert_into_task_database_with_frontend_payload( - task_database, - request.frontend_caller.clone(), - request.frontend_subscriber_id.as_deref(), - request.frontend_subscriber_payload.as_deref(), - ) - .await; - - if let Err(err) = result { - error!("Failed to create task in database: {:?}", err); - // NB: Fail open, but find a way to flag this. - } - - if let Err(err) = artcraft_usage_tracker.record_object_generation(1, ArtcraftUsageType::ImageToResult, ArtcraftUsagePage::ObjectPage) { - // NB: Fail open. - warn!("Failed to report usage: {:?}", err); - } - - Ok(success_event) -} diff --git a/crates/desktop/artcraft/src/core/commands/enqueue/image_to_object/mod.rs b/crates/desktop/artcraft/src/core/commands/enqueue/image_to_object/mod.rs deleted file mode 100644 index de940c5c8b..0000000000 --- a/crates/desktop/artcraft/src/core/commands/enqueue/image_to_object/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod enqueue_image_to_3d_object_command; -mod artcraft; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/core/commands/enqueue/mod.rs b/crates/desktop/artcraft/src/core/commands/enqueue/mod.rs deleted file mode 100644 index 73ce2476cc..0000000000 --- a/crates/desktop/artcraft/src/core/commands/enqueue/mod.rs +++ /dev/null @@ -1,6 +0,0 @@ -pub mod common; -pub mod generate_error; -pub mod image_bg_removal; -pub mod image_to_gaussian; -pub mod image_to_object; -pub mod task_enqueue_success; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/core/commands/enqueue/task_enqueue_success.rs b/crates/desktop/artcraft/src/core/commands/enqueue/task_enqueue_success.rs deleted file mode 100644 index 7d964c2abe..0000000000 --- a/crates/desktop/artcraft/src/core/commands/enqueue/task_enqueue_success.rs +++ /dev/null @@ -1,151 +0,0 @@ -use crate::core::events::generation_events::common::{GenerationAction, GenerationModel, GenerationServiceProvider}; -use crate::core::state::task_database::TaskDatabase; -use enums::common::generation_provider::GenerationProvider; -use enums::tauri::tasks::task_model_type::TaskModelType; -use enums::tauri::tasks::task_status::TaskStatus; -use enums::tauri::tasks::task_type::TaskType; -use enums::tauri::ux::tauri_command_caller::TauriCommandCaller; -use sqlite_tasks::error::SqliteTasksError; -use sqlite_tasks::queries::create_task::{create_task, CreateTaskArgs}; -use tokens::tokens::prompts::PromptToken; -use tokens::tokens::sqlite::tasks::TaskId; - -pub struct TaskEnqueueSuccess { - pub task_type: TaskType, - pub model: Option, - pub provider: GenerationProvider, - pub provider_job_id: Option, - pub maybe_queue_status_url: Option, - pub maybe_queue_response_url: Option, - pub maybe_prompt_token: Option, -} - -impl TaskEnqueueSuccess{ - pub fn to_frontend_event_action(&self) -> GenerationAction { - match self.task_type { - TaskType::ImageGeneration => GenerationAction::GenerateImage, - TaskType::GaussianGeneration => GenerationAction::GenerateGaussian, - TaskType::VideoGeneration => GenerationAction::GenerateVideo, - TaskType::AudioGeneration => GenerationAction::GenerateAudio, - TaskType::BackgroundRemoval => GenerationAction::RemoveBackground, - TaskType::ObjectGeneration => GenerationAction::ImageTo3d, - TaskType::ImageInpaintEdit => GenerationAction::ImageInpaintEdit, - } - } - - pub fn to_frontend_event_service(&self) -> GenerationServiceProvider { - match self.provider { - GenerationProvider::Artcraft => GenerationServiceProvider::Artcraft, - GenerationProvider::Fal => GenerationServiceProvider::Fal, - GenerationProvider::Grok => GenerationServiceProvider::Grok, - GenerationProvider::Midjourney => GenerationServiceProvider::Midjourney, - GenerationProvider::Sora => GenerationServiceProvider::Sora, - GenerationProvider::WorldLabs => GenerationServiceProvider::WorldLabs, - GenerationProvider::Higgsfield => GenerationServiceProvider::Higgsfield, - GenerationProvider::Krea => GenerationServiceProvider::Krea, - GenerationProvider::Leonardo => GenerationServiceProvider::Leonardo, - GenerationProvider::Magnific => GenerationServiceProvider::Magnific, - GenerationProvider::Openart => GenerationServiceProvider::Openart, - GenerationProvider::Picsart => GenerationServiceProvider::Picsart, - GenerationProvider::Pixverse => GenerationServiceProvider::Pixverse, - GenerationProvider::Runway => GenerationServiceProvider::Runway, - } - } - - pub async fn insert_into_task_database(&self, task_database: &TaskDatabase) -> Result { - self.insert_into_task_database_with_frontend_payload( - task_database, - None, - None, - None, - ).await - } - - // TODO: This belongs somewhere else, not as a method of an event struct. - pub async fn insert_into_task_database_with_frontend_payload( - &self, - task_database: &TaskDatabase, - frontend_caller: Option, - frontend_subscriber_id: Option<&str>, - frontend_subscriber_payload: Option<&str>, - ) -> Result { - // TODO: Move this mapping elsewhere, or remove the other models. - let model_type = match &self.model { - None => None, - Some(GenerationModel::Unknown(model)) => Some(TaskModelType::Unknown(model.clone())), - Some(GenerationModel::Flux1Dev) => Some(TaskModelType::Flux1Dev), - Some(GenerationModel::FluxDevJuggernaut) => Some(TaskModelType::FluxDevJuggernaut), - Some(GenerationModel::Flux1Schnell) => Some(TaskModelType::Flux1Schnell), - Some(GenerationModel::FluxPro1) => Some(TaskModelType::FluxPro1), // NB: This is for inpainting. - Some(GenerationModel::FluxPro11) => Some(TaskModelType::FluxPro11), - Some(GenerationModel::FluxPro11Ultra) => Some(TaskModelType::FluxPro11Ultra), - Some(GenerationModel::FluxProKontextMax) => Some(TaskModelType::FluxProKontextMax), - Some(GenerationModel::Gemini25Flash) => Some(TaskModelType::Gemini25Flash), - Some(GenerationModel::NanoBanana) => Some(TaskModelType::NanoBanana), - Some(GenerationModel::NanoBanana2) => Some(TaskModelType::NanoBanana2), - Some(GenerationModel::NanoBananaPro) => Some(TaskModelType::NanoBananaPro), - Some(GenerationModel::GptImage1) => Some(TaskModelType::GptImage1), - Some(GenerationModel::GptImage1p5) => Some(TaskModelType::GptImage1p5), - Some(GenerationModel::GptImage2) => Some(TaskModelType::GptImage2), - Some(GenerationModel::GptImage2p5Flare) => Some(TaskModelType::GptImage2p5Flare), - Some(GenerationModel::GptImage2p5Sunburst) => Some(TaskModelType::GptImage2p5Sunburst), - Some(GenerationModel::Seedream4) => Some(TaskModelType::Seedream4), - Some(GenerationModel::Seedream4p5) => Some(TaskModelType::Seedream4p5), - Some(GenerationModel::Seedream5Lite) => Some(TaskModelType::Seedream5Lite), - Some(GenerationModel::QwenEdit2511Angles) => Some(TaskModelType::QwenEdit2511Angles), - Some(GenerationModel::Flux2LoraAngles) => Some(TaskModelType::Flux2LoraAngles), - Some(GenerationModel::GrokImage) => Some(TaskModelType::GrokImage), - Some(GenerationModel::Recraft3) => Some(TaskModelType::Recraft3), - Some(GenerationModel::GrokVideo) => Some(TaskModelType::GrokVideo), - Some(GenerationModel::GrokImagineVideo1p5) => Some(TaskModelType::GrokImagineVideo1p5), - Some(GenerationModel::Kling21Pro) => Some(TaskModelType::Kling21Pro), - Some(GenerationModel::Kling21Master) => Some(TaskModelType::Kling21Master), - Some(GenerationModel::Kling2p5TurboPro) => Some(TaskModelType::Kling2p5TurboPro), - Some(GenerationModel::Kling2p6Pro) => Some(TaskModelType::Kling2p6Pro), - Some(GenerationModel::Kling3p0Standard) => Some(TaskModelType::Kling3p0Standard), - Some(GenerationModel::Kling3p0Pro) => Some(TaskModelType::Kling3p0Pro), - Some(GenerationModel::HappyHorse1p0) => Some(TaskModelType::HappyHorse1p0), - Some(GenerationModel::Seedance10Lite) => Some(TaskModelType::Seedance10Lite), - Some(GenerationModel::Seedance1p5Pro) => Some(TaskModelType::Seedance1p5Pro), - Some(GenerationModel::Seedance2p0) => Some(TaskModelType::Seedance2p0), - Some(GenerationModel::Seedance2p0Fast) => Some(TaskModelType::Seedance2p0Fast), - Some(GenerationModel::Sora2) => Some(TaskModelType::Sora2), - Some(GenerationModel::Sora2Pro) => Some(TaskModelType::Sora2Pro), - Some(GenerationModel::Veo2) => Some(TaskModelType::Veo2), - Some(GenerationModel::Veo3) => Some(TaskModelType::Veo3), - Some(GenerationModel::Veo3p1) => Some(TaskModelType::Veo3p1), - Some(GenerationModel::Veo3p1Fast) => Some(TaskModelType::Veo3p1Fast), - Some(GenerationModel::Veo3Fast) => Some(TaskModelType::Veo3Fast), - Some(GenerationModel::Hunyuan3d2_0) => Some(TaskModelType::Hunyuan3d2_0), - Some(GenerationModel::Hunyuan3d2_1) => Some(TaskModelType::Hunyuan3d2_1), - Some(GenerationModel::Hunyuan3d3) => Some(TaskModelType::Hunyuan3d3), - Some(GenerationModel::WorldlabsMarble) => Some(TaskModelType::WorldlabsMarble), - Some(GenerationModel::WorldlabsMarble0p1Mini) => Some(TaskModelType::WorldlabsMarble0p1Mini), - Some(GenerationModel::WorldlabsMarble0p1Plus) => Some(TaskModelType::WorldlabsMarble0p1Plus), - Some(GenerationModel::Midjourney) => Some(TaskModelType::Midjourney), // NB: This is a generic Midjourney model, version unknown. - Some(GenerationModel::Midjourney7) => Some(TaskModelType::Midjourney7), - Some(GenerationModel::Midjourney7Niji) => Some(TaskModelType::Midjourney7Niji), - Some(GenerationModel::Midjourney8) => Some(TaskModelType::Midjourney8), - - // TODO: These seem wrong - - Some(GenerationModel::Kling1_6) => Some(TaskModelType::Kling16Pro), // NB: `VideoModel::Kling16Pro`. - Some(GenerationModel::Kling2_0) => None, // TODO: unused elsewhere? - Some(GenerationModel::Sora) => None, // TODO: unused elsewhere? - }; - - create_task(CreateTaskArgs { - db: task_database.get_connection(), - status: TaskStatus::Pending, - task_type: self.task_type, - model_type, - provider: self.provider, - provider_job_id: self.provider_job_id.as_deref(), - queue_status_url: self.maybe_queue_status_url.as_deref(), - queue_response_url: self.maybe_queue_response_url.as_deref(), - prompt_token: self.maybe_prompt_token.as_ref(), - frontend_caller, - frontend_subscriber_id, - frontend_subscriber_payload, - }).await - } -} diff --git a/crates/desktop/artcraft/src/core/commands/flip_image.rs b/crates/desktop/artcraft/src/core/commands/flip_image.rs deleted file mode 100644 index cc6b2a7fea..0000000000 --- a/crates/desktop/artcraft/src/core/commands/flip_image.rs +++ /dev/null @@ -1,36 +0,0 @@ -use base64::prelude::BASE64_STANDARD; -use base64::Engine; -use image::codecs::png::{CompressionType, FilterType, PngEncoder}; -use image::ImageReader; -use std::io::Cursor; - -#[tauri::command] -pub fn flip_image(image: &str) -> Result { - println!("infer_image called; processing image..."); - - let bytes = BASE64_STANDARD.decode(image) - .map_err(|err| format!("Base64 decode error: {}", err))?; - - let image = ImageReader::new(Cursor::new(bytes)) - .with_guessed_format() - .map_err(|err| format!("Image format error: {}", err))? - .decode() - .map_err(|err| format!("Image decode error: {}", err))?; - - let rotated_image = image.rotate180(); - - let mut buffer = Vec::new(); // TODO: Preallocate, better data structure - let mut writer = Cursor::new(&mut buffer); - - let encoder = PngEncoder::new_with_quality - (&mut writer, CompressionType::Fast, FilterType::Adaptive); - - rotated_image.write_with_encoder(encoder) - .map_err(|err| format!("Image encoding error: {}", err))?; - - let encoded = BASE64_STANDARD.encode(&buffer); - - println!("Encoded: {:?}", encoded.split_at(10).0); - - Ok(encoded) -} diff --git a/crates/desktop/artcraft/src/core/commands/generate/common/mod.rs b/crates/desktop/artcraft/src/core/commands/generate/common/mod.rs deleted file mode 100644 index 7f7bebef4d..0000000000 --- a/crates/desktop/artcraft/src/core/commands/generate/common/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod router_image_request_to_artcraft_prompt; -pub mod router_video_request_to_artcraft_prompt; diff --git a/crates/desktop/artcraft/src/core/commands/generate/common/router_image_request_to_artcraft_prompt.rs b/crates/desktop/artcraft/src/core/commands/generate/common/router_image_request_to_artcraft_prompt.rs deleted file mode 100644 index ef7bb5742a..0000000000 --- a/crates/desktop/artcraft/src/core/commands/generate/common/router_image_request_to_artcraft_prompt.rs +++ /dev/null @@ -1,222 +0,0 @@ -use artcraft_api_defs::prompts::create_prompt::CreatePromptRequest; -use artcraft_router::api::router_aspect_ratio::RouterAspectRatio; -use artcraft_router::api::router_image_model::RouterImageModel; -use artcraft_router::api::router_resolution::RouterResolution; -use artcraft_router::api::router_provider::RouterProvider; -use artcraft_router::generate::generate_image::generate_image_request_builder::GenerateImageRequestBuilder; -use enums::common::generation::common_aspect_ratio::CommonAspectRatio as EnumsAspectRatio; -use enums::common::generation::common_generation_mode::CommonGenerationMode; -use enums::common::generation::common_model_type::CommonModelType; -use enums::common::generation::common_resolution::CommonResolution as EnumsResolution; -use enums::common::generation_provider::GenerationProvider; -use uuid_utils::uuid::generate_random_uuid; - -pub fn router_image_request_to_artcraft_prompt( - request: &GenerateImageRequestBuilder, -) -> CreatePromptRequest { - CreatePromptRequest { - uuid_idempotency_token: generate_random_uuid(), - positive_prompt: request.prompt.clone(), - negative_prompt: None, - model_type: image_model_to_common_model_type(request.model), - generation_provider: Some(provider_to_generation_provider(request.provider)), - maybe_generation_mode: Some(determine_image_generation_mode(request)), - maybe_aspect_ratio: request.aspect_ratio.map(router_aspect_ratio_to_enums), - maybe_resolution: request.resolution.map(router_resolution_to_enums), - maybe_batch_count: request.image_batch_count.map(|n| n.min(255) as u8), - maybe_generate_audio: None, - maybe_duration_seconds: None, - } -} - -// ── Converters ── - -fn determine_image_generation_mode(request: &GenerateImageRequestBuilder) -> CommonGenerationMode { - if request.image_inputs.is_some() { - CommonGenerationMode::Edit - } else { - CommonGenerationMode::Text - } -} - -fn image_model_to_common_model_type(model: RouterImageModel) -> Option { - match model { - RouterImageModel::Flux1Dev => Some(CommonModelType::Flux1Dev), - RouterImageModel::Flux1Schnell => Some(CommonModelType::Flux1Schnell), - RouterImageModel::FluxPro11 => Some(CommonModelType::FluxPro11), - RouterImageModel::FluxPro11Ultra => Some(CommonModelType::FluxPro11Ultra), - RouterImageModel::GptImage1 => Some(CommonModelType::GptImage1), - RouterImageModel::GptImage1p5 => Some(CommonModelType::GptImage1p5), - RouterImageModel::GptImage2 => Some(CommonModelType::GptImage2), - RouterImageModel::GptImage2p5Flare => Some(CommonModelType::GptImage2p5Flare), - RouterImageModel::GptImage2p5Sunburst => Some(CommonModelType::GptImage2p5Sunburst), - RouterImageModel::NanoBanana => Some(CommonModelType::NanoBanana), - RouterImageModel::NanoBanana2 => Some(CommonModelType::NanoBanana2), - RouterImageModel::NanoBananaPro => Some(CommonModelType::NanoBananaPro), - RouterImageModel::Seedream4 => Some(CommonModelType::Seedream4), - RouterImageModel::Seedream4p5 => Some(CommonModelType::Seedream4p5), - RouterImageModel::Seedream5Lite => Some(CommonModelType::Seedream5Lite), - RouterImageModel::Seedream5p0Pro => Some(CommonModelType::Seedream5p0Pro), - RouterImageModel::Seedream5p0ProUltra => Some(CommonModelType::Seedream5p0ProUltra), - RouterImageModel::QwenEdit2511Angles => Some(CommonModelType::QwenEdit2511Angles), - RouterImageModel::Flux2LoraAngles => Some(CommonModelType::Flux2LoraAngles), - RouterImageModel::GrokImagineImage => Some(CommonModelType::GrokImagineImage), - RouterImageModel::GrokImagineImageQuality => Some(CommonModelType::GrokImagineImageQuality), - RouterImageModel::Midjourney7 => Some(CommonModelType::Midjourney7), - RouterImageModel::Midjourney7Niji => Some(CommonModelType::Midjourney7Niji), - RouterImageModel::Midjourney8 => Some(CommonModelType::Midjourney8), - } -} - -fn provider_to_generation_provider(provider: RouterProvider) -> GenerationProvider { - match provider { - RouterProvider::Artcraft => GenerationProvider::Artcraft, - RouterProvider::Fal => GenerationProvider::Fal, - // Unused providers -> ArtCraft - RouterProvider::KinoviWeb => GenerationProvider::Artcraft , - RouterProvider::GmiCloud => GenerationProvider::Artcraft, - RouterProvider::GrokApi => GenerationProvider::Artcraft, - RouterProvider::WorldLabs => GenerationProvider::Artcraft, - } -} - -fn router_aspect_ratio_to_enums(ar: RouterAspectRatio) -> EnumsAspectRatio { - match ar { - RouterAspectRatio::Auto => EnumsAspectRatio::Auto, - RouterAspectRatio::Square => EnumsAspectRatio::Square, - RouterAspectRatio::WideThreeByTwo => EnumsAspectRatio::WideThreeByTwo, - RouterAspectRatio::WideFourByThree => EnumsAspectRatio::WideFourByThree, - RouterAspectRatio::WideFiveByFour => EnumsAspectRatio::WideFiveByFour, - RouterAspectRatio::WideSixteenByNine => EnumsAspectRatio::WideSixteenByNine, - RouterAspectRatio::WideTwentyOneByNine => EnumsAspectRatio::WideTwentyOneByNine, - RouterAspectRatio::TallTwoByThree => EnumsAspectRatio::TallTwoByThree, - RouterAspectRatio::TallThreeByFour => EnumsAspectRatio::TallThreeByFour, - RouterAspectRatio::TallFourByFive => EnumsAspectRatio::TallFourByFive, - RouterAspectRatio::TallNineBySixteen => EnumsAspectRatio::TallNineBySixteen, - RouterAspectRatio::TallNineByTwentyOne => EnumsAspectRatio::TallNineByTwentyOne, - RouterAspectRatio::Wide => EnumsAspectRatio::Wide, - RouterAspectRatio::Tall => EnumsAspectRatio::Tall, - RouterAspectRatio::Auto2k => EnumsAspectRatio::Auto2k, - RouterAspectRatio::Auto3k => EnumsAspectRatio::Auto3k, - RouterAspectRatio::Auto4k => EnumsAspectRatio::Auto4k, - RouterAspectRatio::SquareHd => EnumsAspectRatio::SquareHd, - } -} - -fn router_resolution_to_enums(res: RouterResolution) -> EnumsResolution { - match res { - RouterResolution::OneK => EnumsResolution::OneK, - RouterResolution::TwoK => EnumsResolution::TwoK, - RouterResolution::ThreeK => EnumsResolution::ThreeK, - RouterResolution::FourK => EnumsResolution::FourK, - RouterResolution::HalfK => EnumsResolution::HalfK, - RouterResolution::FourEightyP => EnumsResolution::FourEightyP, - RouterResolution::SevenTwentyP => EnumsResolution::SevenTwentyP, - RouterResolution::TenEightyP => EnumsResolution::TenEightyP, - } -} - -#[cfg(test)] -mod tests { - use super::*; - use artcraft_router::client::request_mismatch_mitigation_strategy::RequestMismatchMitigationStrategy; - - fn base_builder() -> GenerateImageRequestBuilder { - GenerateImageRequestBuilder { - model: RouterImageModel::NanoBananaPro, - provider: RouterProvider::Fal, - prompt: Some("a cat in space".to_string()), - image_inputs: None, - resolution: None, - aspect_ratio: None, - quality: None, - image_batch_count: None, - horizontal_angle: None, - vertical_angle: None, - zoom: None, - request_mismatch_mitigation_strategy: RequestMismatchMitigationStrategy::ErrorOut, - generation_mode_mismatch_strategy: None, - idempotency_token: None, - } - } - - #[test] - fn basic_conversion() { - let builder = base_builder(); - let prompt = router_image_request_to_artcraft_prompt(&builder); - assert_eq!(prompt.positive_prompt.as_deref(), Some("a cat in space")); - assert_eq!(prompt.model_type, Some(CommonModelType::NanoBananaPro)); - assert_eq!(prompt.generation_provider, Some(GenerationProvider::Fal)); - assert_eq!(prompt.maybe_generation_mode, Some(CommonGenerationMode::Text)); - assert!(prompt.negative_prompt.is_none()); - assert!(prompt.maybe_aspect_ratio.is_none()); - assert!(prompt.maybe_resolution.is_none()); - assert!(prompt.maybe_batch_count.is_none()); - assert!(!prompt.uuid_idempotency_token.is_empty()); - } - - #[test] - fn text_mode_when_no_images() { - let builder = base_builder(); - let prompt = router_image_request_to_artcraft_prompt(&builder); - assert_eq!(prompt.maybe_generation_mode, Some(CommonGenerationMode::Text)); - } - - #[test] - fn edit_mode_when_images_present() { - use artcraft_router::api::image_list_ref::ImageListRef; - let builder = GenerateImageRequestBuilder { - image_inputs: Some(ImageListRef::Urls(vec!["https://example.com/img.jpg".to_string()])), - ..base_builder() - }; - let prompt = router_image_request_to_artcraft_prompt(&builder); - assert_eq!(prompt.maybe_generation_mode, Some(CommonGenerationMode::Edit)); - } - - #[test] - fn with_aspect_ratio_and_resolution() { - let builder = GenerateImageRequestBuilder { - aspect_ratio: Some(RouterAspectRatio::WideSixteenByNine), - resolution: Some(RouterResolution::TwoK), - image_batch_count: Some(3), - ..base_builder() - }; - let prompt = router_image_request_to_artcraft_prompt(&builder); - assert_eq!(prompt.maybe_aspect_ratio, Some(EnumsAspectRatio::WideSixteenByNine)); - assert_eq!(prompt.maybe_resolution, Some(EnumsResolution::TwoK)); - assert_eq!(prompt.maybe_batch_count, Some(3)); - } - - #[test] - fn no_prompt() { - let builder = GenerateImageRequestBuilder { - prompt: None, - ..base_builder() - }; - let prompt = router_image_request_to_artcraft_prompt(&builder); - assert!(prompt.positive_prompt.is_none()); - } - - #[test] - fn all_image_models_map() { - let models = [ - (RouterImageModel::Flux1Dev, CommonModelType::Flux1Dev), - (RouterImageModel::Flux1Schnell, CommonModelType::Flux1Schnell), - (RouterImageModel::NanoBananaPro, CommonModelType::NanoBananaPro), - (RouterImageModel::GptImage1, CommonModelType::GptImage1), - (RouterImageModel::Seedream4, CommonModelType::Seedream4), - ]; - for (router_model, expected) in models { - let builder = GenerateImageRequestBuilder { model: router_model, ..base_builder() }; - let prompt = router_image_request_to_artcraft_prompt(&builder); - assert_eq!(prompt.model_type, Some(expected)); - } - } - - #[test] - fn provider_mapping() { - let builder = GenerateImageRequestBuilder { provider: RouterProvider::Artcraft, ..base_builder() }; - let prompt = router_image_request_to_artcraft_prompt(&builder); - assert_eq!(prompt.generation_provider, Some(GenerationProvider::Artcraft)); - } -} diff --git a/crates/desktop/artcraft/src/core/commands/generate/common/router_video_request_to_artcraft_prompt.rs b/crates/desktop/artcraft/src/core/commands/generate/common/router_video_request_to_artcraft_prompt.rs deleted file mode 100644 index 9420763e78..0000000000 --- a/crates/desktop/artcraft/src/core/commands/generate/common/router_video_request_to_artcraft_prompt.rs +++ /dev/null @@ -1,276 +0,0 @@ -use artcraft_api_defs::prompts::create_prompt::CreatePromptRequest; -use artcraft_router::api::router_aspect_ratio::RouterAspectRatio; -use artcraft_router::api::router_resolution::RouterResolution; -use artcraft_router::api::router_video_model::RouterVideoModel; -use artcraft_router::api::router_provider::RouterProvider; -use artcraft_router::generate::generate_video::generate_video_request_builder::GenerateVideoRequestBuilder; -use enums::common::generation::common_aspect_ratio::CommonAspectRatio as EnumsAspectRatio; -use enums::common::generation::common_generation_mode::CommonGenerationMode; -use enums::common::generation::common_model_type::CommonModelType; -use enums::common::generation::common_resolution::CommonResolution as EnumsResolution; -use enums::common::generation_provider::GenerationProvider; -use uuid_utils::uuid::generate_random_uuid; - -pub fn router_video_request_to_artcraft_prompt( - request: &GenerateVideoRequestBuilder, -) -> CreatePromptRequest { - CreatePromptRequest { - uuid_idempotency_token: generate_random_uuid(), - positive_prompt: request.prompt.clone(), - negative_prompt: request.negative_prompt.clone(), - model_type: video_model_to_common_model_type(request.model), - generation_provider: Some(provider_to_generation_provider(request.provider)), - maybe_generation_mode: Some(determine_video_generation_mode(request)), - maybe_aspect_ratio: request.aspect_ratio.map(router_aspect_ratio_to_enums), - maybe_resolution: request.resolution.map(router_resolution_to_enums), - maybe_batch_count: request.video_batch_count.map(|n| n.min(255) as u8), - maybe_generate_audio: request.generate_audio, - maybe_duration_seconds: request.duration_seconds.map(|d| d as u32), - } -} - -// ── Converters ── - -fn determine_video_generation_mode(request: &GenerateVideoRequestBuilder) -> CommonGenerationMode { - let has_keyframes = request.start_frame.is_some() || request.end_frame.is_some(); - let has_references = request.reference_images.is_some() - || request.reference_videos.is_some() - || request.reference_audio.is_some(); - - if has_keyframes { - CommonGenerationMode::Keyframe - } else if has_references { - CommonGenerationMode::Reference - } else { - CommonGenerationMode::Text - } -} - -fn video_model_to_common_model_type(model: RouterVideoModel) -> Option { - match model { - RouterVideoModel::GrokVideo => Some(CommonModelType::GrokVideo), - RouterVideoModel::Kling16Pro => Some(CommonModelType::Kling16Pro), - RouterVideoModel::Kling21Pro => Some(CommonModelType::Kling21Pro), - RouterVideoModel::Kling21Master => Some(CommonModelType::Kling21Master), - RouterVideoModel::Kling2p5TurboPro => Some(CommonModelType::Kling2p5TurboPro), - RouterVideoModel::Kling2p6Pro => Some(CommonModelType::Kling2p6Pro), - RouterVideoModel::Kling3p0Standard => Some(CommonModelType::Kling3p0Standard), - RouterVideoModel::Kling3p0Pro => Some(CommonModelType::Kling3p0Pro), - RouterVideoModel::Seedance10Lite => Some(CommonModelType::Seedance10Lite), - RouterVideoModel::Seedance1p5Pro => Some(CommonModelType::Seedance1p5Pro), - RouterVideoModel::Seedance2p0 => Some(CommonModelType::Seedance2p0), - RouterVideoModel::Seedance2p0Fast => Some(CommonModelType::Seedance2p0Fast), - RouterVideoModel::HappyHorse1p0 => Some(CommonModelType::HappyHorse1p0), - RouterVideoModel::MinimaxH3 => Some(CommonModelType::MinimaxH3), - RouterVideoModel::MinimaxH3Turbo => Some(CommonModelType::MinimaxH3Turbo), - RouterVideoModel::MinimaxH3Ultra => Some(CommonModelType::MinimaxH3Ultra), - RouterVideoModel::Flux3 => Some(CommonModelType::Flux3), - RouterVideoModel::Flux3Draft => Some(CommonModelType::Flux3Draft), - RouterVideoModel::Sora2 => Some(CommonModelType::Sora2), - RouterVideoModel::Sora2Pro => Some(CommonModelType::Sora2Pro), - RouterVideoModel::Veo2 => Some(CommonModelType::Veo2), - RouterVideoModel::Veo3 => Some(CommonModelType::Veo3), - RouterVideoModel::Veo3Fast => Some(CommonModelType::Veo3Fast), - RouterVideoModel::Veo3p1 => Some(CommonModelType::Veo3p1), - RouterVideoModel::Veo3p1Fast => Some(CommonModelType::Veo3p1Fast), - RouterVideoModel::Veo3p1Lite => Some(CommonModelType::Veo3p1Lite), - RouterVideoModel::ViduQ3 => Some(CommonModelType::ViduQ3), - RouterVideoModel::ViduQ3Turbo => Some(CommonModelType::ViduQ3Turbo), - RouterVideoModel::Seedance2p0BytePlus => Some(CommonModelType::Seedance2p0BytePlus), - RouterVideoModel::Seedance2p0BytePlusFast => Some(CommonModelType::Seedance2p0BytePlusFast), - RouterVideoModel::Seedance2p0BytePlusUltra => Some(CommonModelType::Seedance2p0BytePlusUltra), - RouterVideoModel::Seedance2p0BytePlusUltraFast => Some(CommonModelType::Seedance2p0BytePlusUltraFast), - RouterVideoModel::Seedance2p0Mini => Some(CommonModelType::Seedance2p0Mini), - RouterVideoModel::Seedance2p0BytePlusMini => Some(CommonModelType::Seedance2p0BytePlusMini), - RouterVideoModel::Seedance2p0BytePlusUltraMini => Some(CommonModelType::Seedance2p0BytePlusUltraMini), - RouterVideoModel::PreviewModel => Some(CommonModelType::PreviewModel), - RouterVideoModel::PreviewModelFast => Some(CommonModelType::PreviewModelFast), - RouterVideoModel::GrokImagineVideo => Some(CommonModelType::GrokImagineVideo), - RouterVideoModel::GrokImagineVideo1p5 => Some(CommonModelType::GrokImagineVideo1p5), - RouterVideoModel::Seedance2p5Preview => Some(CommonModelType::Seedance2p5Preview), - RouterVideoModel::Seedance2p5 => Some(CommonModelType::Seedance2p5), - RouterVideoModel::Seedance2p5Ultra => Some(CommonModelType::Seedance2p5Ultra), - } -} - -fn provider_to_generation_provider(provider: RouterProvider) -> GenerationProvider { - match provider { - RouterProvider::Artcraft => GenerationProvider::Artcraft, - RouterProvider::Fal => GenerationProvider::Fal, - // Unused providers -> ArtCraft - RouterProvider::KinoviWeb => GenerationProvider::Artcraft , - RouterProvider::GmiCloud => GenerationProvider::Artcraft, - RouterProvider::GrokApi => GenerationProvider::Artcraft, - RouterProvider::WorldLabs => GenerationProvider::Artcraft, - } -} - -fn router_aspect_ratio_to_enums(ar: RouterAspectRatio) -> EnumsAspectRatio { - match ar { - RouterAspectRatio::Auto => EnumsAspectRatio::Auto, - RouterAspectRatio::Square => EnumsAspectRatio::Square, - RouterAspectRatio::WideThreeByTwo => EnumsAspectRatio::WideThreeByTwo, - RouterAspectRatio::WideFourByThree => EnumsAspectRatio::WideFourByThree, - RouterAspectRatio::WideFiveByFour => EnumsAspectRatio::WideFiveByFour, - RouterAspectRatio::WideSixteenByNine => EnumsAspectRatio::WideSixteenByNine, - RouterAspectRatio::WideTwentyOneByNine => EnumsAspectRatio::WideTwentyOneByNine, - RouterAspectRatio::TallTwoByThree => EnumsAspectRatio::TallTwoByThree, - RouterAspectRatio::TallThreeByFour => EnumsAspectRatio::TallThreeByFour, - RouterAspectRatio::TallFourByFive => EnumsAspectRatio::TallFourByFive, - RouterAspectRatio::TallNineBySixteen => EnumsAspectRatio::TallNineBySixteen, - RouterAspectRatio::TallNineByTwentyOne => EnumsAspectRatio::TallNineByTwentyOne, - RouterAspectRatio::Wide => EnumsAspectRatio::Wide, - RouterAspectRatio::Tall => EnumsAspectRatio::Tall, - RouterAspectRatio::Auto2k => EnumsAspectRatio::Auto2k, - RouterAspectRatio::Auto3k => EnumsAspectRatio::Auto3k, - RouterAspectRatio::Auto4k => EnumsAspectRatio::Auto4k, - RouterAspectRatio::SquareHd => EnumsAspectRatio::SquareHd, - } -} - -fn router_resolution_to_enums(res: RouterResolution) -> EnumsResolution { - match res { - RouterResolution::OneK => EnumsResolution::OneK, - RouterResolution::TwoK => EnumsResolution::TwoK, - RouterResolution::ThreeK => EnumsResolution::ThreeK, - RouterResolution::FourK => EnumsResolution::FourK, - RouterResolution::HalfK => EnumsResolution::HalfK, - RouterResolution::FourEightyP => EnumsResolution::FourEightyP, - RouterResolution::SevenTwentyP => EnumsResolution::SevenTwentyP, - RouterResolution::TenEightyP => EnumsResolution::TenEightyP, - } -} - -#[cfg(test)] -mod tests { - use super::*; - - fn base_builder() -> GenerateVideoRequestBuilder { - GenerateVideoRequestBuilder { - model: RouterVideoModel::Kling3p0Standard, - provider: RouterProvider::Fal, - prompt: Some("a dog running on the beach".to_string()), - negative_prompt: None, - start_frame: None, - end_frame: None, - reference_images: None, - reference_videos: None, - reference_audio: None, - reference_character_tokens: None, - resolution: None, - aspect_ratio: None, - bitrate: None, - duration_seconds: None, - video_batch_count: None, - generate_audio: None, - total_reference_video_input_seconds: None, - request_mismatch_mitigation_strategy: - artcraft_router::client::request_mismatch_mitigation_strategy::RequestMismatchMitigationStrategy::ErrorOut, - idempotency_token: None, - } - } - - #[test] - fn basic_conversion() { - let builder = base_builder(); - let prompt = router_video_request_to_artcraft_prompt(&builder); - assert_eq!(prompt.positive_prompt.as_deref(), Some("a dog running on the beach")); - assert_eq!(prompt.model_type, Some(CommonModelType::Kling3p0Standard)); - assert_eq!(prompt.generation_provider, Some(GenerationProvider::Fal)); - assert_eq!(prompt.maybe_generation_mode, Some(CommonGenerationMode::Text)); - assert!(prompt.negative_prompt.is_none()); - assert!(prompt.maybe_aspect_ratio.is_none()); - assert!(prompt.maybe_resolution.is_none()); - assert!(prompt.maybe_batch_count.is_none()); - assert!(prompt.maybe_generate_audio.is_none()); - assert!(prompt.maybe_duration_seconds.is_none()); - } - - #[test] - fn with_video_fields() { - let builder = GenerateVideoRequestBuilder { - negative_prompt: Some("blurry".to_string()), - aspect_ratio: Some(RouterAspectRatio::WideSixteenByNine), - resolution: Some(RouterResolution::TenEightyP), - duration_seconds: Some(10), - video_batch_count: Some(2), - generate_audio: Some(true), - ..base_builder() - }; - let prompt = router_video_request_to_artcraft_prompt(&builder); - assert_eq!(prompt.negative_prompt.as_deref(), Some("blurry")); - assert_eq!(prompt.maybe_aspect_ratio, Some(EnumsAspectRatio::WideSixteenByNine)); - assert_eq!(prompt.maybe_resolution, Some(EnumsResolution::TenEightyP)); - assert_eq!(prompt.maybe_duration_seconds, Some(10)); - assert_eq!(prompt.maybe_batch_count, Some(2)); - assert_eq!(prompt.maybe_generate_audio, Some(true)); - } - - #[test] - fn text_mode_when_no_references() { - let builder = base_builder(); - let prompt = router_video_request_to_artcraft_prompt(&builder); - assert_eq!(prompt.maybe_generation_mode, Some(CommonGenerationMode::Text)); - } - - #[test] - fn keyframe_mode_with_start_frame() { - use artcraft_router::api::image_ref::ImageRef; - let builder = GenerateVideoRequestBuilder { - start_frame: Some(ImageRef::Url("https://example.com/frame.jpg".to_string())), - ..base_builder() - }; - let prompt = router_video_request_to_artcraft_prompt(&builder); - assert_eq!(prompt.maybe_generation_mode, Some(CommonGenerationMode::Keyframe)); - } - - #[test] - fn keyframe_mode_with_end_frame() { - use artcraft_router::api::image_ref::ImageRef; - let builder = GenerateVideoRequestBuilder { - end_frame: Some(ImageRef::Url("https://example.com/frame.jpg".to_string())), - ..base_builder() - }; - let prompt = router_video_request_to_artcraft_prompt(&builder); - assert_eq!(prompt.maybe_generation_mode, Some(CommonGenerationMode::Keyframe)); - } - - #[test] - fn reference_mode_with_reference_images() { - use artcraft_router::api::image_list_ref::ImageListRef; - let builder = GenerateVideoRequestBuilder { - reference_images: Some(ImageListRef::Urls(vec!["https://example.com/ref.jpg".to_string()])), - ..base_builder() - }; - let prompt = router_video_request_to_artcraft_prompt(&builder); - assert_eq!(prompt.maybe_generation_mode, Some(CommonGenerationMode::Reference)); - } - - #[test] - fn keyframe_takes_priority_over_reference() { - use artcraft_router::api::image_ref::ImageRef; - use artcraft_router::api::image_list_ref::ImageListRef; - let builder = GenerateVideoRequestBuilder { - start_frame: Some(ImageRef::Url("https://example.com/frame.jpg".to_string())), - reference_images: Some(ImageListRef::Urls(vec!["https://example.com/ref.jpg".to_string()])), - ..base_builder() - }; - let prompt = router_video_request_to_artcraft_prompt(&builder); - assert_eq!(prompt.maybe_generation_mode, Some(CommonGenerationMode::Keyframe)); - } - - #[test] - fn video_model_mapping() { - let models = [ - (RouterVideoModel::Kling3p0Standard, CommonModelType::Kling3p0Standard), - (RouterVideoModel::Veo3, CommonModelType::Veo3), - (RouterVideoModel::Seedance2p0, CommonModelType::Seedance2p0), - (RouterVideoModel::Sora2, CommonModelType::Sora2), - ]; - for (router_model, expected) in models { - let builder = GenerateVideoRequestBuilder { model: router_model, ..base_builder() }; - let prompt = router_video_request_to_artcraft_prompt(&builder); - assert_eq!(prompt.model_type, Some(expected)); - } - } -} diff --git a/crates/desktop/artcraft/src/core/commands/generate/generate_audio_command.rs b/crates/desktop/artcraft/src/core/commands/generate/generate_audio_command.rs deleted file mode 100644 index 23edcf18c7..0000000000 --- a/crates/desktop/artcraft/src/core/commands/generate/generate_audio_command.rs +++ /dev/null @@ -1,11 +0,0 @@ -use crate::core::commands::generate::omni::{self, Modality, OmniRequest, OmniResult}; -use crate::core::commands::generate::omni::dispatch::local_error; -use tauri::AppHandle; - -#[tauri::command] -pub async fn generate_audio_command(request: OmniRequest, app: AppHandle) -> OmniResult { - if !request.uses_artcraft() { - return Err(local_error("No direct provider adapter is configured for this modality.")); - } - omni::generate(request, Modality::Audio, &app).await -} diff --git a/crates/desktop/artcraft/src/core/commands/generate/generate_image/generate_image_command.rs b/crates/desktop/artcraft/src/core/commands/generate/generate_image/generate_image_command.rs deleted file mode 100644 index 4dff8b6c68..0000000000 --- a/crates/desktop/artcraft/src/core/commands/generate/generate_image/generate_image_command.rs +++ /dev/null @@ -1,190 +0,0 @@ -use crate::core::commands::generate::omni::{self, Modality, OmniRequest, OmniResult}; -use crate::core::commands::generate::omni::dispatch::{adapt_legacy_response, decode_native}; -use tauri::Manager; -use crate::core::commands::enqueue::common::notify_frontend_of_errors::notify_frontend_of_errors; -use crate::core::commands::enqueue::generate_error::{GenerateError, MissingCredentialsReason}; -use crate::core::commands::enqueue::task_enqueue_success::TaskEnqueueSuccess; -use crate::core::commands::generate::generate_image::providers::artcraft::handle_artcraft; -use crate::core::commands::generate::generate_image::providers::artcraft_router::handle_router::handle_router; -use crate::core::commands::generate::generate_image::tauri_generate_image_request::{ - TauriGenerateImageErrorType, TauriGenerateImageRequest, TauriGenerateImageResponse, -}; -use crate::core::commands::response::failure_response_wrapper::{CommandErrorResponseWrapper, CommandErrorStatus}; -use crate::core::commands::response::shorthand::Response; -use crate::core::events::basic_sendable_event_trait::BasicSendableEvent; -use crate::core::events::functional_events::credits_balance_changed_event::CreditsBalanceChangedEvent; -use crate::core::events::generation_events::generation_enqueue_success_event::GenerationEnqueueSuccessEvent; -use crate::core::providers::credentials::provider_credential_loading_cache::ProviderCredentialLoadingCache; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; -use crate::core::state::task_database::TaskDatabase; -use crate::services::storyteller::state::storyteller_credential_manager::StorytellerCredentialManager; -use enums::common::generation_provider::GenerationProvider; -use log::{error, info}; -use tauri::{AppHandle, State}; - -#[tauri::command] -pub async fn generate_image_command(request: OmniRequest, app: AppHandle) -> OmniResult { - if request.uses_artcraft() && !request.uses_legacy_image_endpoint() { - return omni::generate(request, Modality::Image, &app).await; - } - adapt_legacy_response(generate_image_native( - decode_native(request)?, app.clone(), - app.state(), app.state(), app.state(), app.state(), - ).await) -} - -async fn generate_image_native( - request: TauriGenerateImageRequest, - app: AppHandle, - app_env_configs: State<'_, AppEnvConfigs>, - task_database: State<'_, TaskDatabase>, - storyteller_creds_manager: State<'_, StorytellerCredentialManager>, - credential_cache: State<'_, ProviderCredentialLoadingCache>, -) -> Response { - - info!("generate_image_command called, request: {:?}", request); - - let provider = request.provider.unwrap_or(GenerationProvider::Artcraft); - - let result = match provider { - GenerationProvider::Artcraft => { - handle_artcraft( - &request, - &app_env_configs, - &storyteller_creds_manager, - ).await - } - // Midjourney uses its own legacy command path, not this one. - GenerationProvider::Midjourney => { - Err(GenerateError::NotYetImplemented( - "Midjourney should use its dedicated command".to_string(), - )) - } - // All other providers go through the router. - other => { - handle_router( - &request, - other, - &app_env_configs, - &credential_cache, - &storyteller_creds_manager, - ).await - } - }; - - match result { - Ok(success) => handle_success_behavior(&app, &task_database, &request, success).await, - Err(err) => handle_error_behavior(&app, err).await, - } -} - -// ── Result mapping ── - -async fn handle_success_behavior( - app: &AppHandle, - task_database: &TaskDatabase, - request: &TauriGenerateImageRequest, - success: TaskEnqueueSuccess, -) -> Response { - - - // Insert into task database - let db_result = success - .insert_into_task_database_with_frontend_payload( - &task_database, - request.frontend_caller, - request.frontend_subscriber_id.as_deref(), - request.frontend_subscriber_payload.as_deref(), - ) - .await; - - if let Err(err) = db_result { - error!("Failed to create task in database: {:?}", err); - } - - /* - let usage_type = if is_image_to_image { - ArtcraftUsageType::ImageToResult - } else { - ArtcraftUsageType::TextToResult - }; - - if let Err(err) = artcraft_usage_tracker.record_image_generation(num_images, usage_type, ArtcraftUsagePage::ImagePage) { - // NB: Fail open. - warn!("Failed to report usage: {:?}", err); - } - */ - - let event = GenerationEnqueueSuccessEvent { - action: success.to_frontend_event_action(), - service: success.to_frontend_event_service(), - model: success.model, - }; - - if let Err(err) = event.send(&app) { - error!("Failed to emit event: {:?}", err); - } - - CreditsBalanceChangedEvent{}.send_infallible(&app); - - Ok(TauriGenerateImageResponse {}.into()) -} - -async fn handle_error_behavior( - app: &AppHandle, - err: GenerateError, -) -> Response { - error!("generate_image_command error: {:?}", err); - - notify_frontend_of_errors(&app, &err).await; - - let error_type = match &err { - GenerateError::BadInput(_) => TauriGenerateImageErrorType::BadInput, - GenerateError::MissingCredentials(MissingCredentialsReason::NeedsFalApiKey) => TauriGenerateImageErrorType::NeedsFalApiKey, - GenerateError::MissingCredentials(MissingCredentialsReason::NeedsGrokCredentials) => TauriGenerateImageErrorType::NeedsGrokCredentials, - GenerateError::MissingCredentials(_) => TauriGenerateImageErrorType::NeedsStorytellerCredentials, - GenerateError::NoProviderAvailable => TauriGenerateImageErrorType::NoProviderAvailable, - GenerateError::BillingIssue(_) => TauriGenerateImageErrorType::BillingIssue, - _ => TauriGenerateImageErrorType::ServerError, - }; - - // TODO: - /* - let mut status = CommandErrorStatus::ServerError; - let mut error_type = EnqueueTextToImageErrorType::ServerError; - let mut error_message = "A server error occurred. Please try again. If it continues, please tell our staff about the problem."; - - match err { - GenerateError::BadInput(BadInputReason::NoModelSpecified) => { - status = CommandErrorStatus::BadRequest; - error_type = EnqueueTextToImageErrorType::ModelNotSpecified; - error_message = "No model specified for image generation"; - } - GenerateError::NoProviderAvailable => { - status = CommandErrorStatus::ServerError; - error_type = EnqueueTextToImageErrorType::NoProviderAvailable; - error_message = "No configured provider available for image generation"; - } - GenerateError::MissingCredentials(MissingCredentialsReason::NeedsFalApiKey) => { - status = CommandErrorStatus::Unauthorized; - error_type = EnqueueTextToImageErrorType::NeedsFalApiKey; - error_message = "You need to set a FAL api key"; - }, - _ => {}, // Fall-through - } - - Err(CommandErrorResponseWrapper { - status, - error_message: Some(error_message.to_string()), - error_type: Some(error_type), - error_details: None, - }) - */ - - Err(CommandErrorResponseWrapper { - status: CommandErrorStatus::ServerError, - error_message: Some(format!("{:?}", err)), - error_type: Some(error_type), - error_details: None, - }) -} diff --git a/crates/desktop/artcraft/src/core/commands/generate/generate_image/mod.rs b/crates/desktop/artcraft/src/core/commands/generate/generate_image/mod.rs deleted file mode 100644 index 568b848fe2..0000000000 --- a/crates/desktop/artcraft/src/core/commands/generate/generate_image/mod.rs +++ /dev/null @@ -1,5 +0,0 @@ -pub mod generate_image_command; -pub mod providers; -pub mod tauri_generate_image_request; -pub mod tauri_image_model; -pub mod utils; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/core/commands/generate/generate_image/providers/artcraft/handle_artcraft.rs b/crates/desktop/artcraft/src/core/commands/generate/generate_image/providers/artcraft/handle_artcraft.rs deleted file mode 100644 index 3dbd41876d..0000000000 --- a/crates/desktop/artcraft/src/core/commands/generate/generate_image/providers/artcraft/handle_artcraft.rs +++ /dev/null @@ -1,63 +0,0 @@ -use log::info; - -use crate::core::commands::enqueue::generate_error::{GenerateError, MissingCredentialsReason}; -use crate::core::commands::enqueue::task_enqueue_success::TaskEnqueueSuccess; -use crate::core::commands::generate::generate_image::providers::artcraft::handle_artcraft_via_legacy::handle_artcraft_via_legacy; -use crate::core::commands::generate::generate_image::providers::artcraft::handle_artcraft_via_omni_endpoint::handle_artcraft_via_omni_endpoint; -use crate::core::commands::generate::generate_image::tauri_generate_image_request::TauriGenerateImageRequest; -use crate::core::commands::generate::generate_image::tauri_image_model::TauriImageModel; -use crate::core::commands::generate::generate_image::utils::parse_semantic_media_files::parse_semantic_media_files; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; -use crate::services::storyteller::state::storyteller_credential_manager::StorytellerCredentialManager; - - -/// Dispatch an image generation request to Artcraft. -pub async fn handle_artcraft( - request: &TauriGenerateImageRequest, - app_env_configs: &AppEnvConfigs, - storyteller_creds_manager: &StorytellerCredentialManager, -) -> Result { - // Resolve credentials. - let creds = match storyteller_creds_manager.get_credentials()? { - Some(creds) => creds, - None => return Err(GenerateError::MissingCredentials(MissingCredentialsReason::NeedsStorytellerCredentials)), - }; - - // Resolve semantic media files (upload raw bytes if provided). - let semantic_media_files = parse_semantic_media_files( - request, - &creds, - &app_env_configs.storyteller_host, - ).await?; - - let use_legacy = request.model - .is_some_and(|m| is_legacy_only_model(m)); - - if use_legacy { - info!("Model {:?} is legacy-only, routing to artcraft_router path.", request.model); - handle_artcraft_via_legacy( - request, - &semantic_media_files, - &creds, - app_env_configs, - ).await - } else { - handle_artcraft_via_omni_endpoint( - request, - &semantic_media_files, - &creds, - app_env_configs, - ).await - } -} - -fn is_legacy_only_model(model: TauriImageModel) -> bool { - matches!( - model, - TauriImageModel::GrokImage - | TauriImageModel::Recraft3 - | TauriImageModel::Midjourney - | TauriImageModel::FluxProKontextMax - | TauriImageModel::FluxDevJuggernaut - ) -} diff --git a/crates/desktop/artcraft/src/core/commands/generate/generate_image/providers/artcraft/handle_artcraft_via_legacy.rs b/crates/desktop/artcraft/src/core/commands/generate/generate_image/providers/artcraft/handle_artcraft_via_legacy.rs deleted file mode 100644 index e4ea97ba75..0000000000 --- a/crates/desktop/artcraft/src/core/commands/generate/generate_image/providers/artcraft/handle_artcraft_via_legacy.rs +++ /dev/null @@ -1,49 +0,0 @@ -use artcraft_client::credentials::storyteller_credential_set::StorytellerCredentialSet; - -use crate::core::commands::enqueue::generate_error::GenerateError; -use crate::core::commands::enqueue::task_enqueue_success::TaskEnqueueSuccess; -use crate::core::commands::generate::generate_image::providers::artcraft::legacy::artcraft_flux_2_lora_angles::handle_flux_2_lora_angles; -use crate::core::commands::generate::generate_image::providers::artcraft::legacy::artcraft_flux_dev_juggernaut_inpaint::handle_flux_dev_juggernaut_inpaint; -use crate::core::commands::generate::generate_image::providers::artcraft::legacy::artcraft_flux_pro_kontext_edit::handle_flux_pro_kontext_edit; -use crate::core::commands::generate::generate_image::providers::artcraft::legacy::artcraft_qwen_edit_2511_angles::handle_qwen_edit_2511_angles; -use crate::core::commands::generate::generate_image::tauri_generate_image_request::TauriGenerateImageRequest; -use crate::core::commands::generate::generate_image::tauri_image_model::TauriImageModel; -use crate::core::commands::generate::generate_image::utils::parse_semantic_media_files::SemanticMediaFiles; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; - -/// Handle image generation via legacy model-specific paths. -/// -/// Dispatches to dedicated handlers for each supported legacy model. -pub async fn handle_artcraft_via_legacy( - request: &TauriGenerateImageRequest, - semantic_media_files: &SemanticMediaFiles, - creds: &StorytellerCredentialSet, - app_env_configs: &AppEnvConfigs, -) -> Result { - let model = request.model.ok_or(GenerateError::no_model_specified())?; - - match model { - TauriImageModel::FluxDevJuggernaut => { - handle_flux_dev_juggernaut_inpaint(request, semantic_media_files, creds, app_env_configs).await - } - TauriImageModel::FluxProKontextMax => { - handle_flux_pro_kontext_edit(request, semantic_media_files, creds, app_env_configs).await - } - TauriImageModel::QwenEdit2511Angles => { - handle_qwen_edit_2511_angles(request, semantic_media_files, creds, app_env_configs).await - } - TauriImageModel::Flux2LoraAngles => { - handle_flux_2_lora_angles(request, semantic_media_files, creds, app_env_configs).await - } - TauriImageModel::Midjourney | TauriImageModel::Recraft3 => { - Err(GenerateError::NotYetImplemented( - format!("Model {:?} is not supported by provider Artcraft", model), - )) - } - other => { - Err(GenerateError::NotYetImplemented( - format!("Model {:?} was incorrectly handled", other), - )) - } - } -} diff --git a/crates/desktop/artcraft/src/core/commands/generate/generate_image/providers/artcraft/handle_artcraft_via_omni_endpoint.rs b/crates/desktop/artcraft/src/core/commands/generate/generate_image/providers/artcraft/handle_artcraft_via_omni_endpoint.rs deleted file mode 100644 index f18fbb399f..0000000000 --- a/crates/desktop/artcraft/src/core/commands/generate/generate_image/providers/artcraft/handle_artcraft_via_omni_endpoint.rs +++ /dev/null @@ -1,101 +0,0 @@ -use artcraft_api_defs::omni_gen::cost_and_generate_requests::omni_gen_image_cost_and_generate_request::OmniGenImageCostAndGenerateRequest; -use artcraft_client::endpoints::omni_gen::generate::image::omni_gen_image::omni_gen_image_generate; -use enums::common::generation_provider::GenerationProvider; -use enums::tauri::tasks::task_type::TaskType; -use log::{error, info}; -use tokens::tokens::media_files::MediaFileToken; -use uuid_utils::uuid::generate_random_uuid; -use artcraft_client::credentials::storyteller_credential_set::StorytellerCredentialSet; -use crate::core::commands::enqueue::generate_error::GenerateError; -use crate::core::commands::enqueue::task_enqueue_success::TaskEnqueueSuccess; -use crate::core::api_adapters::models::image::tauri_image_model_to_enums_model::tauri_image_model_to_enums_model; -use crate::core::api_adapters::models::image::tauri_image_model_to_generation_model::tauri_image_model_to_generation_model; -use crate::core::commands::generate::generate_image::tauri_generate_image_request::TauriGenerateImageRequest; -use crate::core::commands::generate::generate_image::utils::parse_semantic_media_files::SemanticMediaFiles; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; - -pub async fn handle_artcraft_via_omni_endpoint( - request: &TauriGenerateImageRequest, - semantic_media_files: &SemanticMediaFiles, - creds: &StorytellerCredentialSet, - app_env_configs: &AppEnvConfigs, -) -> Result { - let tauri_model = request.model.ok_or(GenerateError::no_model_specified())?; - - let omni_api_model = tauri_image_model_to_enums_model(tauri_model) - .ok_or(GenerateError::NotYetImplemented( - format!("Model {:?} is not supported via the omni endpoint", tauri_model), - ))?; - - let uuid_idempotency_token = generate_random_uuid(); - - let image_media_tokens = get_image_media_tokens(request, semantic_media_files); - - let omni_request = OmniGenImageCostAndGenerateRequest { - idempotency_token: Some(uuid_idempotency_token), - model: Some(omni_api_model), - prompt: request.prompt.clone(), - image_media_tokens, - resolution: request.resolution, - aspect_ratio: request.aspect_ratio, - quality: request.quality, - image_batch_count: request.batch_size.map(|n| n as u16), - adjust_horizontal_angle: request.adjust_horizontal_angle, - adjust_vertical_angle: request.adjust_vertical_angle, - adjust_zoom: request.adjust_zoom, - }; - - info!("Sending image generation via omni endpoint: model={:?}", omni_api_model); - - let response = omni_gen_image_generate( - &app_env_configs.storyteller_host, - Some(creds), - omni_request, - ).await.map_err(|err| { - error!("Omni image generation failed: {:?}", err); - GenerateError::from(err) - })?; - - info!("Omni image generation succeeded: job_token={}", response.inference_job_token.as_str()); - - let generation_model = tauri_image_model_to_generation_model(tauri_model); - - Ok(TaskEnqueueSuccess { - task_type: TaskType::ImageGeneration, - model: Some(generation_model), - provider: GenerationProvider::Artcraft, - provider_job_id: Some(response.inference_job_token.to_string()), - maybe_queue_status_url: None, - maybe_prompt_token: None, - maybe_queue_response_url: None, - }) -} - -fn get_image_media_tokens( - request: &TauriGenerateImageRequest, - semantic_media_files: &SemanticMediaFiles, -) -> Option> { - let num_images = request.image_media_tokens.as_deref() - .map(|t| t.len()) - .unwrap_or(0); - - let mut image_media_tokens = Vec::with_capacity(num_images + 2); - - if let Some(canvas_token) = &semantic_media_files.canvas_image_media_token { - image_media_tokens.push(canvas_token.clone()); - } - - if let Some(scene_token) = &semantic_media_files.scene_image_media_token { - image_media_tokens.push(scene_token.clone()); - } - - if let Some(media_tokens) = &request.image_media_tokens { - image_media_tokens.extend(media_tokens.clone()); - } - - if image_media_tokens.is_empty() { - None - } else { - Some(image_media_tokens) - } -} diff --git a/crates/desktop/artcraft/src/core/commands/generate/generate_image/providers/artcraft/legacy/artcraft_flux_2_lora_angles.rs b/crates/desktop/artcraft/src/core/commands/generate/generate_image/providers/artcraft/legacy/artcraft_flux_2_lora_angles.rs deleted file mode 100644 index 929df4474f..0000000000 --- a/crates/desktop/artcraft/src/core/commands/generate/generate_image/providers/artcraft/legacy/artcraft_flux_2_lora_angles.rs +++ /dev/null @@ -1,107 +0,0 @@ -use log::{error, info}; - -use artcraft_client::credentials::storyteller_credential_set::StorytellerCredentialSet; -use artcraft_router::api::router_image_model::RouterImageModel; -use artcraft_router::api::image_list_ref::ImageListRef; -use artcraft_router::api::router_provider::RouterProvider; -use artcraft_router::client::request_mismatch_mitigation_strategy::RequestMismatchMitigationStrategy; -use artcraft_router::client::router_artcraft_client::RouterArtcraftClient; -use artcraft_router::client::router_client::RouterClient; -use artcraft_router::generate::generate_image::generate_image_request_builder::GenerateImageRequestBuilder; -use artcraft_router::generate::generate_image::image_generation_draft_or_request::ImageGenerationDraftOrRequest; -use enums::common::generation_provider::GenerationProvider; -use enums::tauri::tasks::task_type::TaskType; - -use crate::core::commands::enqueue::generate_error::GenerateError; -use crate::core::commands::enqueue::task_enqueue_success::TaskEnqueueSuccess; -use crate::core::commands::generate::generate_image::tauri_generate_image_request::TauriGenerateImageRequest; -use crate::core::commands::generate::generate_image::utils::parse_semantic_media_files::SemanticMediaFiles; -use crate::core::events::generation_events::common::GenerationModel; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; - -/// Handle Flux2LoraAngles image editing via the artcraft_router. -pub async fn handle_flux_2_lora_angles( - request: &TauriGenerateImageRequest, - semantic_media_files: &SemanticMediaFiles, - creds: &StorytellerCredentialSet, - app_env_configs: &AppEnvConfigs, -) -> Result { - let client = RouterClient::Artcraft(RouterArtcraftClient::new( - app_env_configs.storyteller_host.clone(), - creds.clone(), - )); - - let image_inputs = build_image_inputs(request, semantic_media_files); - - let router_request = GenerateImageRequestBuilder { - model: RouterImageModel::Flux2LoraAngles, - provider: RouterProvider::Artcraft, - prompt: request.prompt.clone(), - image_inputs, - resolution: None, - aspect_ratio: None, - quality: None, - image_batch_count: request.batch_size.map(|n| n as u16), - request_mismatch_mitigation_strategy: RequestMismatchMitigationStrategy::PayMoreUpgrade, - generation_mode_mismatch_strategy: None, - idempotency_token: None, - horizontal_angle: request.adjust_horizontal_angle, - vertical_angle: request.adjust_vertical_angle, - zoom: request.adjust_zoom, - }; - - let dor = router_request.build2()?; - - info!("Flux2LoraAngles request: {:?}", dor); - - let request = match dor { - ImageGenerationDraftOrRequest::Request(req) => req, - // Artcraft-side angle models always return a Request — never a Draft. - // The only draft-producing models today are Kinovi-Midjourney variants, - // which are routed to a separate provider. - ImageGenerationDraftOrRequest::Draft(_) => unreachable!( - "Artcraft Flux2LoraAngles should never produce a draft" - ), - }; - - let response = request.send_request(&client).await.map_err(|err| { - error!("Flux2LoraAngles generation failed: {:?}", err); - GenerateError::from(err) - })?; - - let job_id = response - .get_artcraft_payload() - .map(|p| p.inference_job_token.to_string()) - .ok_or(GenerateError::ResponseHadNoJobTokens)?; - - info!("Flux2LoraAngles succeeded: job_id={}", job_id); - - Ok(TaskEnqueueSuccess { - task_type: TaskType::ImageGeneration, - model: Some(GenerationModel::Flux2LoraAngles), - provider: GenerationProvider::Artcraft, - provider_job_id: Some(job_id), - maybe_queue_status_url: None, - maybe_prompt_token: None, - maybe_queue_response_url: None, - }) -} - -fn build_image_inputs( - request: &TauriGenerateImageRequest, - semantic_media_files: &SemanticMediaFiles, -) -> Option { - let mut tokens = Vec::new(); - - if let Some(scene_token) = &semantic_media_files.scene_image_media_token { - tokens.push(scene_token.clone()); - } - if let Some(canvas_token) = &semantic_media_files.canvas_image_media_token { - tokens.push(canvas_token.clone()); - } - if let Some(media_tokens) = &request.image_media_tokens { - tokens.extend(media_tokens.clone()); - } - - if tokens.is_empty() { None } else { Some(ImageListRef::MediaFileTokens(tokens)) } -} diff --git a/crates/desktop/artcraft/src/core/commands/generate/generate_image/providers/artcraft/legacy/artcraft_flux_dev_juggernaut_inpaint.rs b/crates/desktop/artcraft/src/core/commands/generate/generate_image/providers/artcraft/legacy/artcraft_flux_dev_juggernaut_inpaint.rs deleted file mode 100644 index a6b6dff483..0000000000 --- a/crates/desktop/artcraft/src/core/commands/generate/generate_image/providers/artcraft/legacy/artcraft_flux_dev_juggernaut_inpaint.rs +++ /dev/null @@ -1,101 +0,0 @@ -use log::{error, info}; - -use artcraft_api_defs::generate::image::inpaint::flux_dev_juggernaut_inpaint_image::{ - FluxDevJuggernautInpaintImageNumImages, FluxDevJuggernautInpaintImageRequest, -}; -use artcraft_client::credentials::storyteller_credential_set::StorytellerCredentialSet; -use artcraft_client::endpoints::generate::image::inpaint::flux_dev_juggernaut_inpaint_image::flux_dev_juggernaut_inpaint_image; -use enums::common::generation_provider::GenerationProvider; -use enums::tauri::tasks::task_type::TaskType; -use uuid_utils::uuid::generate_random_uuid; - -use tokens::tokens::media_files::MediaFileToken; - -use crate::core::commands::enqueue::generate_error::{BadInputReason, GenerateError}; -use crate::core::commands::enqueue::task_enqueue_success::TaskEnqueueSuccess; -use crate::core::commands::generate::generate_image::tauri_generate_image_request::TauriGenerateImageRequest; -use crate::core::commands::generate::generate_image::utils::parse_semantic_media_files::SemanticMediaFiles; -use crate::core::events::generation_events::common::GenerationModel; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; - -/// Handle FluxDevJuggernaut inpainting via the legacy dedicated endpoint. -/// -/// Requires a source image (from scene, canvas, or image_media_tokens) and an inpainting mask. -pub async fn handle_flux_dev_juggernaut_inpaint( - request: &TauriGenerateImageRequest, - semantic_media_files: &SemanticMediaFiles, - creds: &StorytellerCredentialSet, - app_env_configs: &AppEnvConfigs, -) -> Result { - let image_media_token = get_first_image_token(request, semantic_media_files) - .ok_or(GenerateError::required_source_image_not_provided())?; - - let mask_media_token = semantic_media_files.inpainting_mask_image_media_token.clone() - .ok_or(GenerateError::required_source_image_mask_not_provided())?; - - let num_images = match request.batch_size { - None => None, - Some(1) => Some(FluxDevJuggernautInpaintImageNumImages::One), - Some(2) => Some(FluxDevJuggernautInpaintImageNumImages::Two), - Some(3) => Some(FluxDevJuggernautInpaintImageNumImages::Three), - Some(4) => Some(FluxDevJuggernautInpaintImageNumImages::Four), - Some(other) => { - return Err(GenerateError::BadInput(BadInputReason::InvalidNumberOfRequestedImages { - min: 1, - max: 4, - requested: other, - })); - } - }; - - let uuid_idempotency_token = generate_random_uuid(); - - let inpaint_request = FluxDevJuggernautInpaintImageRequest { - uuid_idempotency_token, - prompt: request.prompt.clone(), - image_media_token, - mask_media_token, - num_images, - }; - - info!("Calling FluxDevJuggernaut inpaint..."); - - let response = flux_dev_juggernaut_inpaint_image( - &app_env_configs.storyteller_host, - Some(creds), - inpaint_request, - ).await.map_err(|err| { - error!("FluxDevJuggernaut inpaint failed: {:?}", err); - GenerateError::from(err) - })?; - - info!("FluxDevJuggernaut inpaint succeeded: job_token={}", response.inference_job_token); - - Ok(TaskEnqueueSuccess { - task_type: TaskType::ImageInpaintEdit, - model: Some(GenerationModel::FluxDevJuggernaut), - provider: GenerationProvider::Artcraft, - provider_job_id: Some(response.inference_job_token.to_string()), - maybe_queue_status_url: None, - maybe_prompt_token: None, - maybe_queue_response_url: None, - }) -} - -fn get_first_image_token( - request: &TauriGenerateImageRequest, - semantic_media_files: &SemanticMediaFiles, -) -> Option { - if let Some(scene_token) = &semantic_media_files.scene_image_media_token { - return Some(scene_token.clone()); - } - if let Some(canvas_token) = &semantic_media_files.canvas_image_media_token { - return Some(canvas_token.clone()); - } - if let Some(media_tokens) = &request.image_media_tokens { - if let Some(token) = media_tokens.first() { - return Some(token.clone()); - } - } - None -} diff --git a/crates/desktop/artcraft/src/core/commands/generate/generate_image/providers/artcraft/legacy/artcraft_flux_pro_kontext_edit.rs b/crates/desktop/artcraft/src/core/commands/generate/generate_image/providers/artcraft/legacy/artcraft_flux_pro_kontext_edit.rs deleted file mode 100644 index 131d4a588f..0000000000 --- a/crates/desktop/artcraft/src/core/commands/generate/generate_image/providers/artcraft/legacy/artcraft_flux_pro_kontext_edit.rs +++ /dev/null @@ -1,99 +0,0 @@ -use log::{error, info}; - -use artcraft_api_defs::generate::image::edit::flux_pro_kontext_max_edit_image::{ - FluxProKontextMaxEditImageNumImages, FluxProKontextMaxEditImageRequest, -}; -use artcraft_client::credentials::storyteller_credential_set::StorytellerCredentialSet; -use artcraft_client::endpoints::generate::image::edit::flux_pro_kontext_max_edit_image::flux_pro_kontext_max_edit_image; -use enums::common::generation_provider::GenerationProvider; -use enums::tauri::tasks::task_type::TaskType; -use tokens::tokens::media_files::MediaFileToken; -use uuid_utils::uuid::generate_random_uuid; - -use crate::core::commands::enqueue::generate_error::{BadInputReason, GenerateError}; -use crate::core::commands::enqueue::task_enqueue_success::TaskEnqueueSuccess; -use crate::core::commands::generate::generate_image::tauri_generate_image_request::TauriGenerateImageRequest; -use crate::core::commands::generate::generate_image::utils::parse_semantic_media_files::SemanticMediaFiles; -use crate::core::events::generation_events::common::GenerationModel; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; - -/// Handle FluxProKontextMax image editing via the legacy dedicated endpoint. -/// -/// Consolidates both the "edit" and "inpaint" legacy paths — both call the same -/// Kontext Max edit endpoint with a single source image. -pub async fn handle_flux_pro_kontext_edit( - request: &TauriGenerateImageRequest, - semantic_media_files: &SemanticMediaFiles, - creds: &StorytellerCredentialSet, - app_env_configs: &AppEnvConfigs, -) -> Result { - let image_media_token = get_first_image_token(request, semantic_media_files) - .ok_or(GenerateError::BadInput(BadInputReason::WrongImageArguments( - "No input image specified for Flux Kontext Max edit".to_string(), - )))?; - - let num_images = match request.batch_size { - None => None, - Some(1) => Some(FluxProKontextMaxEditImageNumImages::One), - Some(2) => Some(FluxProKontextMaxEditImageNumImages::Two), - Some(3) => Some(FluxProKontextMaxEditImageNumImages::Three), - Some(4) => Some(FluxProKontextMaxEditImageNumImages::Four), - Some(other) => { - return Err(GenerateError::BadInput(BadInputReason::InvalidNumberOfRequestedImages { - min: 1, - max: 4, - requested: other, - })); - } - }; - - let uuid_idempotency_token = generate_random_uuid(); - - let kontext_request = FluxProKontextMaxEditImageRequest { - uuid_idempotency_token, - prompt: request.prompt.clone(), - image_media_token, - num_images, - }; - - info!("Calling FluxProKontextMax edit..."); - - let response = flux_pro_kontext_max_edit_image( - &app_env_configs.storyteller_host, - Some(creds), - kontext_request, - ).await.map_err(|err| { - error!("FluxProKontextMax edit failed: {:?}", err); - GenerateError::from(err) - })?; - - info!("FluxProKontextMax edit succeeded: job_token={}", response.inference_job_token); - - Ok(TaskEnqueueSuccess { - task_type: TaskType::ImageGeneration, - model: Some(GenerationModel::FluxProKontextMax), - provider: GenerationProvider::Artcraft, - provider_job_id: Some(response.inference_job_token.to_string()), - maybe_queue_status_url: None, - maybe_prompt_token: None, - maybe_queue_response_url: None, - }) -} - -fn get_first_image_token( - request: &TauriGenerateImageRequest, - semantic_media_files: &SemanticMediaFiles, -) -> Option { - if let Some(scene_token) = &semantic_media_files.scene_image_media_token { - return Some(scene_token.clone()); - } - if let Some(canvas_token) = &semantic_media_files.canvas_image_media_token { - return Some(canvas_token.clone()); - } - if let Some(media_tokens) = &request.image_media_tokens { - if let Some(token) = media_tokens.first() { - return Some(token.clone()); - } - } - None -} diff --git a/crates/desktop/artcraft/src/core/commands/generate/generate_image/providers/artcraft/legacy/artcraft_qwen_edit_2511_angles.rs b/crates/desktop/artcraft/src/core/commands/generate/generate_image/providers/artcraft/legacy/artcraft_qwen_edit_2511_angles.rs deleted file mode 100644 index 30a9b0880e..0000000000 --- a/crates/desktop/artcraft/src/core/commands/generate/generate_image/providers/artcraft/legacy/artcraft_qwen_edit_2511_angles.rs +++ /dev/null @@ -1,107 +0,0 @@ -use log::{error, info}; - -use artcraft_client::credentials::storyteller_credential_set::StorytellerCredentialSet; -use artcraft_router::api::router_image_model::RouterImageModel; -use artcraft_router::api::image_list_ref::ImageListRef; -use artcraft_router::api::router_provider::RouterProvider; -use artcraft_router::client::request_mismatch_mitigation_strategy::RequestMismatchMitigationStrategy; -use artcraft_router::client::router_artcraft_client::RouterArtcraftClient; -use artcraft_router::client::router_client::RouterClient; -use artcraft_router::generate::generate_image::generate_image_request_builder::GenerateImageRequestBuilder; -use artcraft_router::generate::generate_image::image_generation_draft_or_request::ImageGenerationDraftOrRequest; -use enums::common::generation_provider::GenerationProvider; -use enums::tauri::tasks::task_type::TaskType; - -use crate::core::commands::enqueue::generate_error::GenerateError; -use crate::core::commands::enqueue::task_enqueue_success::TaskEnqueueSuccess; -use crate::core::commands::generate::generate_image::tauri_generate_image_request::TauriGenerateImageRequest; -use crate::core::commands::generate::generate_image::utils::parse_semantic_media_files::SemanticMediaFiles; -use crate::core::events::generation_events::common::GenerationModel; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; - -/// Handle QwenEdit2511Angles image editing via the artcraft_router. -pub async fn handle_qwen_edit_2511_angles( - request: &TauriGenerateImageRequest, - semantic_media_files: &SemanticMediaFiles, - creds: &StorytellerCredentialSet, - app_env_configs: &AppEnvConfigs, -) -> Result { - let client = RouterClient::Artcraft(RouterArtcraftClient::new( - app_env_configs.storyteller_host.clone(), - creds.clone(), - )); - - let image_inputs = build_image_inputs(request, semantic_media_files); - - let router_request = GenerateImageRequestBuilder { - model: RouterImageModel::QwenEdit2511Angles, - provider: RouterProvider::Artcraft, - prompt: request.prompt.clone(), - image_inputs, - resolution: None, - aspect_ratio: None, - quality: None, - image_batch_count: request.batch_size.map(|n| n as u16), - request_mismatch_mitigation_strategy: RequestMismatchMitigationStrategy::PayMoreUpgrade, - generation_mode_mismatch_strategy: None, - idempotency_token: None, - horizontal_angle: request.adjust_horizontal_angle, - vertical_angle: request.adjust_vertical_angle, - zoom: request.adjust_zoom, - }; - - let dor = router_request.build2()?; - - info!("QwenEdit2511Angles request: {:?}", dor); - - let request = match dor { - ImageGenerationDraftOrRequest::Request(req) => req, - // Artcraft-side angle models always return a Request — never a Draft. - // The only draft-producing models today are Kinovi-Midjourney variants, - // which are routed to a separate provider. - ImageGenerationDraftOrRequest::Draft(_) => unreachable!( - "Artcraft QwenEdit2511Angles should never produce a draft" - ), - }; - - let response = request.send_request(&client).await.map_err(|err| { - error!("QwenEdit2511Angles generation failed: {:?}", err); - GenerateError::from(err) - })?; - - let job_id = response - .get_artcraft_payload() - .map(|p| p.inference_job_token.to_string()) - .ok_or(GenerateError::ResponseHadNoJobTokens)?; - - info!("QwenEdit2511Angles succeeded: job_id={}", job_id); - - Ok(TaskEnqueueSuccess { - task_type: TaskType::ImageGeneration, - model: Some(GenerationModel::QwenEdit2511Angles), - provider: GenerationProvider::Artcraft, - provider_job_id: Some(job_id), - maybe_queue_status_url: None, - maybe_prompt_token: None, - maybe_queue_response_url: None, - }) -} - -fn build_image_inputs( - request: &TauriGenerateImageRequest, - semantic_media_files: &SemanticMediaFiles, -) -> Option { - let mut tokens = Vec::new(); - - if let Some(scene_token) = &semantic_media_files.scene_image_media_token { - tokens.push(scene_token.clone()); - } - if let Some(canvas_token) = &semantic_media_files.canvas_image_media_token { - tokens.push(canvas_token.clone()); - } - if let Some(media_tokens) = &request.image_media_tokens { - tokens.extend(media_tokens.clone()); - } - - if tokens.is_empty() { None } else { Some(ImageListRef::MediaFileTokens(tokens)) } -} diff --git a/crates/desktop/artcraft/src/core/commands/generate/generate_image/providers/artcraft/legacy/mod.rs b/crates/desktop/artcraft/src/core/commands/generate/generate_image/providers/artcraft/legacy/mod.rs deleted file mode 100644 index 83dc104d10..0000000000 --- a/crates/desktop/artcraft/src/core/commands/generate/generate_image/providers/artcraft/legacy/mod.rs +++ /dev/null @@ -1,4 +0,0 @@ -pub mod artcraft_flux_2_lora_angles; -pub mod artcraft_flux_dev_juggernaut_inpaint; -pub mod artcraft_flux_pro_kontext_edit; -pub mod artcraft_qwen_edit_2511_angles; diff --git a/crates/desktop/artcraft/src/core/commands/generate/generate_image/providers/artcraft/mod.rs b/crates/desktop/artcraft/src/core/commands/generate/generate_image/providers/artcraft/mod.rs deleted file mode 100644 index af34f55def..0000000000 --- a/crates/desktop/artcraft/src/core/commands/generate/generate_image/providers/artcraft/mod.rs +++ /dev/null @@ -1,6 +0,0 @@ -mod handle_artcraft; -mod handle_artcraft_via_legacy; -mod handle_artcraft_via_omni_endpoint; -mod legacy; - -pub use handle_artcraft::handle_artcraft; diff --git a/crates/desktop/artcraft/src/core/commands/generate/generate_image/providers/artcraft_router/handle_api_providers.rs b/crates/desktop/artcraft/src/core/commands/generate/generate_image/providers/artcraft_router/handle_api_providers.rs deleted file mode 100644 index ce7c59854e..0000000000 --- a/crates/desktop/artcraft/src/core/commands/generate/generate_image/providers/artcraft_router/handle_api_providers.rs +++ /dev/null @@ -1,203 +0,0 @@ -use artcraft_client::endpoints::prompts::create_prompt::create_prompt; -use artcraft_client::utils::api_host::ApiHost; -use artcraft_router::api::image_list_ref::ImageListRef; -use artcraft_router::api::router_provider::RouterProvider; -use artcraft_router::client::generation_mode_mismatch_strategy::GenerationModeMismatchStrategy; -use artcraft_router::client::request_mismatch_mitigation_strategy::RequestMismatchMitigationStrategy; -use artcraft_router::client::router_client::RouterClient; -use artcraft_router::client::router_fal_client::RouterFalClient; -use artcraft_router::generate::generate_image::generate_image_request_builder::GenerateImageRequestBuilder; -use artcraft_router::generate::generate_image::generate_image_response::GenerateImageResponse; -use artcraft_router::generate::generate_image::image_generation_draft_or_request::ImageGenerationDraftOrRequest; -use enums::common::generation_provider::GenerationProvider; -use enums::tauri::tasks::task_type::TaskType; -use log::{error, info, warn}; -use tokens::tokens::media_files::MediaFileToken; -use tokens::tokens::prompts::PromptToken; - -use crate::core::api_adapters::models::image::tauri_image_model_to_generation_model::tauri_image_model_to_generation_model; -use crate::core::api_adapters::models::image::tauri_image_model_to_router_model::tauri_image_model_to_router_model; -use crate::core::commands::enqueue::generate_error::GenerateError; -use crate::core::commands::enqueue::task_enqueue_success::TaskEnqueueSuccess; -use crate::core::commands::generate::common::router_image_request_to_artcraft_prompt::router_image_request_to_artcraft_prompt; -use crate::core::commands::generate::generate_image::providers::artcraft_router::utils::convert_enums_to_router::{convert_aspect_ratio, convert_quality, convert_resolution}; -use crate::core::commands::generate::generate_image::providers::artcraft_router::utils::map_media_files_to_urls::map_media_file_tokens_to_cdn_urls; -use crate::core::commands::generate::generate_image::tauri_generate_image_request::TauriGenerateImageRequest; -use crate::core::commands::generate::generate_image::tauri_image_model::TauriImageModel; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; -use crate::services::storyteller::state::storyteller_credential_manager::StorytellerCredentialManager; - -/// Handle image generation for providers that authenticate via API key. -pub async fn handle_api_key_provider( - request: &TauriGenerateImageRequest, - provider: GenerationProvider, - api_key: &str, - app_env_configs: &AppEnvConfigs, - storyteller_creds_manager: &StorytellerCredentialManager, -) -> Result { - match provider { - GenerationProvider::Fal => { - handle_fal(request, api_key, app_env_configs, storyteller_creds_manager).await - } - _ => { - Err(GenerateError::NotYetImplemented( - format!("API key provider {:?} is not yet supported via the router path", provider), - )) - } - } -} - -// ── FAL ── - -async fn handle_fal( - request: &TauriGenerateImageRequest, - api_key: &str, - app_env_configs: &AppEnvConfigs, - storyteller_creds_manager: &StorytellerCredentialManager, -) -> Result { - let tauri_model = request.model.ok_or(GenerateError::no_model_specified())?; - let api_host = &app_env_configs.storyteller_host; - - let router_model = tauri_image_model_to_router_model(tauri_model) - .ok_or(GenerateError::NotYetImplemented( - format!("Model {:?} is not supported via the FAL router path", tauri_model), - ))?; - - // Collect all media file tokens that need resolving. - let image_inputs = resolve_image_inputs(request, api_host).await?; - - let router_request = GenerateImageRequestBuilder { - model: router_model, - provider: RouterProvider::Fal, - prompt: request.prompt.clone(), - image_inputs, - resolution: request.resolution.map(convert_resolution), - aspect_ratio: request.aspect_ratio.map(convert_aspect_ratio), - quality: request.quality.map(convert_quality), - image_batch_count: request.batch_size.map(|n| n as u16), - horizontal_angle: request.adjust_horizontal_angle, - vertical_angle: request.adjust_vertical_angle, - zoom: request.adjust_zoom, - request_mismatch_mitigation_strategy: RequestMismatchMitigationStrategy::PayMoreUpgrade, - generation_mode_mismatch_strategy: Some(GenerationModeMismatchStrategy::GenerateAnyway), - idempotency_token: None, - }; - - // Create a prompt record before sending the generation request. - let maybe_prompt_token = create_prompt_record( - &router_request, - api_host, - storyteller_creds_manager, - ).await; - - let fal_client = RouterFalClient::new_polling_only_from_raw_key(api_key); - let client = RouterClient::Fal(fal_client); - - info!("Building FAL image generation plan: model={:?}", router_model); - - let request = match router_request.build2() { - Ok(ImageGenerationDraftOrRequest::Request(request)) => request, - Ok(ImageGenerationDraftOrRequest::Draft(draft)) => { - warn!("Fal is trying to send draft request: {:?}", draft); - return Err(GenerateError::NotYetImplemented("Fal should not be sending draft requests".to_string())); - }, - Err(err) => { - warn!("Could not use FAL: {:?}", err); - return Err(GenerateError::NotYetImplemented("Error Message: TODO".to_string())); - } - }; - - info!("Executing FAL image generation. Request: {:?}", request); - - match request.send_request(&client).await { - Ok(response) => { - build_task_enqueue_success(tauri_model, response, maybe_prompt_token) - }, - Err(err) => { - warn!("Fal image generation failed: {:?}", err); - Err(err.into()) - } - } -} - -// ── Helpers ── - -async fn resolve_image_inputs( - request: &TauriGenerateImageRequest, - api_host: &ApiHost, -) -> Result, GenerateError> { - let mut tokens: Vec = Vec::new(); - - if let Some(canvas_token) = &request.canvas_image_media_token { - tokens.push(canvas_token.clone()); - } - - if let Some(scene_token) = &request.scene_image_media_token { - tokens.push(scene_token.clone()); - } - - if let Some(media_tokens) = &request.image_media_tokens { - tokens.extend(media_tokens.clone()); - } - - if tokens.is_empty() { - return Ok(None); - } - - let urls = map_media_file_tokens_to_cdn_urls(&tokens, api_host).await?; - Ok(Some(ImageListRef::Urls(urls))) -} - -/// Create a prompt record in the Artcraft backend before sending the generation request. -/// Fails open: if prompt creation fails, we log and return None rather than blocking generation. -async fn create_prompt_record( - router_request: &GenerateImageRequestBuilder, - api_host: &ApiHost, - storyteller_creds_manager: &StorytellerCredentialManager, -) -> Option { - let creds = match storyteller_creds_manager.get_credentials() { - Ok(Some(creds)) => creds, - _ => { - warn!("[FalRouter] No Storyteller credentials available, skipping prompt creation"); - return None; - } - }; - - let prompt_request = router_image_request_to_artcraft_prompt(router_request); - - match create_prompt(api_host, Some(&creds), prompt_request).await { - Ok(response) => { - info!("[FalRouter] Created prompt: {:?}", response.prompt_token); - Some(response.prompt_token) - } - Err(err) => { - error!("[FalRouter] Failed to create prompt (continuing anyway): {:?}", err); - None - } - } -} - -fn build_task_enqueue_success( - tauri_model: TauriImageModel, - response: GenerateImageResponse, - maybe_prompt_token: Option, -) -> Result { - let fal_payload = response.get_fal_payload() - .ok_or(GenerateError::ResponseHadNoJobTokens)?; - - let provider_job_id = fal_payload.request_id - .or(fal_payload.gateway_request_id) - .ok_or(GenerateError::ResponseHadNoJobTokens)?; - - let generation_model = tauri_image_model_to_generation_model(tauri_model); - - Ok(TaskEnqueueSuccess { - task_type: TaskType::ImageGeneration, - model: Some(generation_model), - provider: GenerationProvider::Fal, - provider_job_id: Some(provider_job_id), - maybe_queue_status_url: fal_payload.maybe_status_url, - maybe_queue_response_url: fal_payload.maybe_response_url, - maybe_prompt_token, - }) -} diff --git a/crates/desktop/artcraft/src/core/commands/generate/generate_image/providers/artcraft_router/handle_router.rs b/crates/desktop/artcraft/src/core/commands/generate/generate_image/providers/artcraft_router/handle_router.rs deleted file mode 100644 index 56a19dd5a2..0000000000 --- a/crates/desktop/artcraft/src/core/commands/generate/generate_image/providers/artcraft_router/handle_router.rs +++ /dev/null @@ -1,68 +0,0 @@ -use enums::common::generation_provider::GenerationProvider; -use log::info; - -use crate::core::commands::enqueue::generate_error::{GenerateError, MissingCredentialsReason}; -use crate::core::commands::enqueue::task_enqueue_success::TaskEnqueueSuccess; -use crate::core::commands::generate::generate_image::providers::artcraft_router::handle_api_providers::handle_api_key_provider; -use crate::core::commands::generate::generate_image::providers::artcraft_router::handle_web_login_providers::handle_web_login_provider; -use crate::core::commands::generate::generate_image::tauri_generate_image_request::TauriGenerateImageRequest; -use crate::core::providers::credentials::payload::provider_credential_payload::ProviderCredentialPayload; -use crate::core::providers::credentials::provider_credential_key::ProviderCredentialKey; -use crate::core::providers::credentials::provider_credential_loading_cache::ProviderCredentialLoadingCache; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; -use crate::services::storyteller::state::storyteller_credential_manager::StorytellerCredentialManager; - -/// Dispatch an image generation request to a third-party provider via the router. -/// -/// This handles providers that authenticate with the user's own credentials -/// (API key or web login) rather than going through the Artcraft backend. -pub async fn handle_router( - request: &TauriGenerateImageRequest, - provider: GenerationProvider, - app_env_configs: &AppEnvConfigs, - credential_cache: &ProviderCredentialLoadingCache, - storyteller_creds_manager: &StorytellerCredentialManager, -) -> Result { - let credential_key = map_provider_to_credential_key(provider)?; - - info!("handle_router: provider={:?}, credential_key={:?}", provider, credential_key); - - let payload = credential_cache.get_credentials(credential_key) - .map_err(|err| { - GenerateError::AnyhowError(anyhow::anyhow!("Failed to load credentials: {:?}", err)) - })? - .ok_or_else(|| map_provider_to_missing_credentials_error(provider))?; - - match payload { - ProviderCredentialPayload::ApiKey(api_key_data) => { - handle_api_key_provider(request, provider, api_key_data.as_str(), app_env_configs, storyteller_creds_manager).await - } - ProviderCredentialPayload::WebLogin(web_login_data) => { - handle_web_login_provider(request, provider, &web_login_data).await - } - } -} - -// ── Helpers ── - -fn map_provider_to_credential_key( - provider: GenerationProvider, -) -> Result { - match provider { - GenerationProvider::Fal => Ok(ProviderCredentialKey::FalApiKey), - _ => Err(GenerateError::NotYetImplemented( - format!("Provider {:?} does not have a mapped credential key yet", provider), - )), - } -} - -fn map_provider_to_missing_credentials_error(provider: GenerationProvider) -> GenerateError { - match provider { - GenerationProvider::Fal => GenerateError::MissingCredentials(MissingCredentialsReason::NeedsFalApiKey), - GenerationProvider::Grok => GenerateError::MissingCredentials(MissingCredentialsReason::NeedsGrokCredentials), - GenerationProvider::Midjourney => GenerateError::MissingCredentials(MissingCredentialsReason::NeedsMidjourneyCredentials), - GenerationProvider::Sora => GenerateError::MissingCredentials(MissingCredentialsReason::NeedsSoraCredentials), - GenerationProvider::WorldLabs => GenerateError::MissingCredentials(MissingCredentialsReason::NeedsWorldLabsCredentials), - _ => GenerateError::NoProviderAvailable, - } -} diff --git a/crates/desktop/artcraft/src/core/commands/generate/generate_image/providers/artcraft_router/handle_web_login_providers.rs b/crates/desktop/artcraft/src/core/commands/generate/generate_image/providers/artcraft_router/handle_web_login_providers.rs deleted file mode 100644 index d9359f325f..0000000000 --- a/crates/desktop/artcraft/src/core/commands/generate/generate_image/providers/artcraft_router/handle_web_login_providers.rs +++ /dev/null @@ -1,17 +0,0 @@ -use enums::common::generation_provider::GenerationProvider; - -use crate::core::commands::enqueue::generate_error::GenerateError; -use crate::core::commands::enqueue::task_enqueue_success::TaskEnqueueSuccess; -use crate::core::commands::generate::generate_image::tauri_generate_image_request::TauriGenerateImageRequest; -use crate::core::providers::credentials::payload::web_login::WebLoginData; - -/// Handle image generation for providers that authenticate via web login. -/// -/// Not yet implemented — placeholder for Grok, Runway, Higgsfield, etc. -pub async fn handle_web_login_provider( - _request: &TauriGenerateImageRequest, - _provider: GenerationProvider, - _web_login: &WebLoginData, -) -> Result { - unimplemented!("Web login provider image generation is not yet supported via the router path") -} diff --git a/crates/desktop/artcraft/src/core/commands/generate/generate_image/providers/artcraft_router/mod.rs b/crates/desktop/artcraft/src/core/commands/generate/generate_image/providers/artcraft_router/mod.rs deleted file mode 100644 index ea74c39d9a..0000000000 --- a/crates/desktop/artcraft/src/core/commands/generate/generate_image/providers/artcraft_router/mod.rs +++ /dev/null @@ -1,4 +0,0 @@ -pub mod handle_router; -mod handle_api_providers; -mod handle_web_login_providers; -mod utils; diff --git a/crates/desktop/artcraft/src/core/commands/generate/generate_image/providers/artcraft_router/utils/convert_enums_to_router.rs b/crates/desktop/artcraft/src/core/commands/generate/generate_image/providers/artcraft_router/utils/convert_enums_to_router.rs deleted file mode 100644 index 33c23040fa..0000000000 --- a/crates/desktop/artcraft/src/core/commands/generate/generate_image/providers/artcraft_router/utils/convert_enums_to_router.rs +++ /dev/null @@ -1,50 +0,0 @@ -use artcraft_router::api::router_aspect_ratio::RouterAspectRatio; -use artcraft_router::api::router_quality::RouterQuality; -use artcraft_router::api::router_resolution::RouterResolution; -use enums::common::generation::common_aspect_ratio::CommonAspectRatio as EnumsAspectRatio; -use enums::common::generation::common_quality::CommonQuality as EnumsQuality; -use enums::common::generation::common_resolution::CommonResolution as EnumsResolution; - -pub fn convert_aspect_ratio(value: EnumsAspectRatio) -> RouterAspectRatio { - match value { - EnumsAspectRatio::Auto => RouterAspectRatio::Auto, - EnumsAspectRatio::Square => RouterAspectRatio::Square, - EnumsAspectRatio::WideThreeByTwo => RouterAspectRatio::WideThreeByTwo, - EnumsAspectRatio::WideFourByThree => RouterAspectRatio::WideFourByThree, - EnumsAspectRatio::WideFiveByFour => RouterAspectRatio::WideFiveByFour, - EnumsAspectRatio::WideSixteenByNine => RouterAspectRatio::WideSixteenByNine, - EnumsAspectRatio::WideTwentyOneByNine => RouterAspectRatio::WideTwentyOneByNine, - EnumsAspectRatio::TallTwoByThree => RouterAspectRatio::TallTwoByThree, - EnumsAspectRatio::TallThreeByFour => RouterAspectRatio::TallThreeByFour, - EnumsAspectRatio::TallFourByFive => RouterAspectRatio::TallFourByFive, - EnumsAspectRatio::TallNineBySixteen => RouterAspectRatio::TallNineBySixteen, - EnumsAspectRatio::TallNineByTwentyOne => RouterAspectRatio::TallNineByTwentyOne, - EnumsAspectRatio::Wide => RouterAspectRatio::Wide, - EnumsAspectRatio::Tall => RouterAspectRatio::Tall, - EnumsAspectRatio::Auto2k => RouterAspectRatio::Auto2k, - EnumsAspectRatio::Auto3k => RouterAspectRatio::Auto3k, - EnumsAspectRatio::Auto4k => RouterAspectRatio::Auto4k, - EnumsAspectRatio::SquareHd => RouterAspectRatio::SquareHd, - } -} - -pub fn convert_quality(value: EnumsQuality) -> RouterQuality { - match value { - EnumsQuality::High => RouterQuality::High, - EnumsQuality::Medium => RouterQuality::Medium, - EnumsQuality::Low => RouterQuality::Low, - } -} - -pub fn convert_resolution(value: EnumsResolution) -> RouterResolution { - match value { - EnumsResolution::OneK => RouterResolution::OneK, - EnumsResolution::TwoK => RouterResolution::TwoK, - EnumsResolution::ThreeK => RouterResolution::ThreeK, - EnumsResolution::FourK => RouterResolution::FourK, - EnumsResolution::HalfK => RouterResolution::HalfK, - EnumsResolution::FourEightyP => RouterResolution::FourEightyP, - EnumsResolution::SevenTwentyP => RouterResolution::SevenTwentyP, - EnumsResolution::TenEightyP => RouterResolution::TenEightyP, - } -} diff --git a/crates/desktop/artcraft/src/core/commands/generate/generate_image/providers/artcraft_router/utils/map_media_files_to_urls.rs b/crates/desktop/artcraft/src/core/commands/generate/generate_image/providers/artcraft_router/utils/map_media_files_to_urls.rs deleted file mode 100644 index 81f47670e7..0000000000 --- a/crates/desktop/artcraft/src/core/commands/generate/generate_image/providers/artcraft_router/utils/map_media_files_to_urls.rs +++ /dev/null @@ -1,27 +0,0 @@ -use artcraft_client::endpoints::media_files::get_media_file::get_media_file; -use artcraft_client::utils::api_host::ApiHost; -use log::info; -use tokens::tokens::media_files::MediaFileToken; - -use crate::core::commands::enqueue::generate_error::GenerateError; - -/// Resolve a list of media file tokens to their CDN URLs. -/// -/// FAL (and other third-party providers) can fetch images by URL directly, -/// so we just need the CDN link — no need to download the bytes locally. -pub async fn map_media_file_tokens_to_cdn_urls( - tokens: &[MediaFileToken], - api_host: &ApiHost, -) -> Result, GenerateError> { - let mut urls = Vec::with_capacity(tokens.len()); - - for token in tokens { - info!("Resolving media file token {} to CDN URL...", token.as_str()); - let response = get_media_file(api_host, token).await?; - let cdn_url = response.media_file.media_links.cdn_url.to_string(); - info!("Resolved {} -> {}", token.as_str(), &cdn_url); - urls.push(cdn_url); - } - - Ok(urls) -} diff --git a/crates/desktop/artcraft/src/core/commands/generate/generate_image/providers/artcraft_router/utils/mod.rs b/crates/desktop/artcraft/src/core/commands/generate/generate_image/providers/artcraft_router/utils/mod.rs deleted file mode 100644 index d9e43ac9c4..0000000000 --- a/crates/desktop/artcraft/src/core/commands/generate/generate_image/providers/artcraft_router/utils/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod convert_enums_to_router; -pub mod map_media_files_to_urls; diff --git a/crates/desktop/artcraft/src/core/commands/generate/generate_image/providers/grok/handle_grok.rs b/crates/desktop/artcraft/src/core/commands/generate/generate_image/providers/grok/handle_grok.rs deleted file mode 100644 index dc8f00476f..0000000000 --- a/crates/desktop/artcraft/src/core/commands/generate/generate_image/providers/grok/handle_grok.rs +++ /dev/null @@ -1,92 +0,0 @@ -use crate::core::api_adapters::aspect_ratio::convert::aspect_ratio_to_grok_image::aspect_ratio_to_grok_image; -use crate::core::commands::enqueue::generate_error::GenerateError; -use crate::core::commands::enqueue::task_enqueue_success::TaskEnqueueSuccess; -use crate::core::commands::deprecated::text_to_image::enqueue_text_to_image_command::{EnqueueTextToImageRequest, TextToImageSize}; -use crate::core::events::generation_events::common::GenerationModel; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; -use crate::services::grok::state::grok_credential_manager::GrokCredentialManager; -use crate::services::grok::state::grok_image_prompt_queue::{GrokImagePromptQueue, PromptItem}; -use enums::common::generation_provider::GenerationProvider; -use enums::tauri::tasks::task_type::TaskType; -use grok_consumer_client::requests::image_websocket::messages::websocket_client_message::ClientMessageAspectRatio; -use uuid_utils::uuid::generate_random_uuid; -use tauri::AppHandle; - -pub async fn handle_grok( - app: &AppHandle, - request: &EnqueueTextToImageRequest, - app_env_configs: &AppEnvConfigs, - creds_manager: &GrokCredentialManager, - grok_image_prompt_queue: &GrokImagePromptQueue, -) -> Result { - - - //// TODO: We can request population of the user info if absent or expired. - //let websocket = get_websocket( - // app, - // creds_manager, - // websocket_manager, - //).await?; - // - //let _result = prompt_websocket_image(PromptWebsocketImageArgs { - // websocket_wrapped: &websocket, - // prompt: request.prompt.as_deref().unwrap_or_else(||""), - //}).await?; - // - //let request_id = listen_for_websocket_request_id(ListenForWebsocketRequestIdArgs { - // websocket: &websocket, - // timeout: Duration::from_millis(10_000), - //}).await?; - // - //let request_id = match request_id.request_id { - // Some(request_id) => request_id.to_string(), - // None => { - // warn!("No request id from Grok image generation (websocket)"); - // return Err(GenerateError::ProviderFailure(ProviderFailureReason::GrokJobEnqueueFailed)); - // } - //}; - // - //info!("Successfully enqueued MidJourney. Job token: {}", request_id); - - let job_id = generate_random_uuid(); - - let prompt = request.prompt - .as_deref() - .map(|prompt| prompt.trim().to_string()) - .unwrap_or_else(|| "".to_string()); - - let aspect_ratio = get_aspect_ratio(request); - - grok_image_prompt_queue.enqueue(PromptItem { - task_id: job_id.clone(), - prompt, - aspect_ratio: aspect_ratio.unwrap_or(ClientMessageAspectRatio::Square), - })?; - - Ok(TaskEnqueueSuccess { - provider: GenerationProvider::Grok, - model: Some(GenerationModel::GrokImage), - provider_job_id: Some(job_id), - task_type: TaskType::ImageGeneration, - }) -} - -fn get_aspect_ratio(request: &EnqueueTextToImageRequest) -> Option { - if let Some(common_aspect_ratio) = request.common_aspect_ratio { - // Handle modern aspect ratio - let aspect = aspect_ratio_to_grok_image(common_aspect_ratio); - return Some(aspect); - } - - if let Some(aspect_ratio) = request.aspect_ratio { - // Handle deprecated aspect ratio - return match aspect_ratio { - TextToImageSize::Auto => Some(ClientMessageAspectRatio::Square), - TextToImageSize::Square => Some(ClientMessageAspectRatio::Square), - TextToImageSize::Wide => Some(ClientMessageAspectRatio::WideThreeByTwo), - TextToImageSize::Tall => Some(ClientMessageAspectRatio::TallTwoByThree), - } - } - - None -} diff --git a/crates/desktop/artcraft/src/core/commands/generate/generate_image/providers/grok/mod.rs b/crates/desktop/artcraft/src/core/commands/generate/generate_image/providers/grok/mod.rs deleted file mode 100644 index 181e756f1a..0000000000 --- a/crates/desktop/artcraft/src/core/commands/generate/generate_image/providers/grok/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub (super) mod handle_grok; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/core/commands/generate/generate_image/providers/midjourney/handle_midjourney.rs b/crates/desktop/artcraft/src/core/commands/generate/generate_image/providers/midjourney/handle_midjourney.rs deleted file mode 100644 index 4eceda6d30..0000000000 --- a/crates/desktop/artcraft/src/core/commands/generate/generate_image/providers/midjourney/handle_midjourney.rs +++ /dev/null @@ -1,140 +0,0 @@ -use crate::core::commands::enqueue::generate_error::{GenerateError, MissingCredentialsReason, ProviderFailureReason}; -use crate::core::commands::deprecated::image_edit::enqueue_edit_image_command::{EditImageQuality, EditImageSize}; -use crate::core::commands::enqueue::task_enqueue_success::TaskEnqueueSuccess; -use crate::core::commands::deprecated::text_to_image::enqueue_text_to_image_command::{EnqueueTextToImageRequest, TextToImageSize}; -use crate::core::events::basic_sendable_event_trait::BasicSendableEvent; -use crate::core::events::functional_events::canvas_background_removal_complete_event::CanvasBackgroundRemovalCompleteEvent; -use crate::core::events::functional_events::show_provider_login_modal_event::ShowProviderLoginModalEvent; -use crate::core::events::generation_events::common::{GenerationAction, GenerationModel, GenerationServiceProvider}; -use crate::core::events::generation_events::generation_enqueue_failure_event::GenerationEnqueueFailureEvent; -use crate::core::events::warning_events::flash_user_input_error_event::FlashUserInputErrorEvent; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::core::state::provider_priority::ProviderPriorityStore; -use crate::services::midjourney::state::midjourney_credential_manager::MidjourneyCredentialManager; -use crate::services::sora::state::sora_credential_manager::SoraCredentialManager; -use crate::services::sora::state::sora_task_queue::SoraTaskQueue; -use crate::services::storyteller::state::storyteller_credential_manager::StorytellerCredentialManager; -use enums::common::generation_provider::GenerationProvider; -use enums::tauri::tasks::task_type::TaskType; -use uuid_utils::uuid::generate_random_uuid; -use log::{error, info}; -use midjourney_client::client::midjourney_hostname::MidjourneyHostname; -use midjourney_client::endpoints::submit_job::{submit_job, SubmitJobRequest}; -use midjourney_client::error::midjourney_api_error::MidjourneyApiError; -use midjourney_client::recipes::channel_id::ChannelId; -use midjourney_client::recipes::text_to_image::{text_to_image, TextToImageError, TextToImageRequest}; -use openai_sora_client::recipes::maybe_upgrade_or_renew_session::maybe_upgrade_or_renew_session; -use openai_sora_client::recipes::simple_image_gen_with_session_auto_renew::{simple_image_gen_with_session_auto_renew, SimpleImageGenAutoRenewRequest}; -use openai_sora_client::requests::image_gen::common::{ImageSize, NumImages}; -use std::time::Duration; -use tauri::AppHandle; -use tokens::tokens::media_files::MediaFileToken; - -pub async fn handle_midjourney( - app: &AppHandle, - request: &EnqueueTextToImageRequest, - app_env_configs: &AppEnvConfigs, - mj_creds_manager: &MidjourneyCredentialManager, -) -> Result { - - let creds = match mj_creds_manager.maybe_copy_cookie_store() { - Ok(Some(creds)) => creds, - Ok(None) => { - error!("Midjourney credentials not found."); - ShowProviderLoginModalEvent::send_for_provider(GenerationProvider::Midjourney, &app); - return Err(GenerateError::needs_midjourney_credentials()); - } - Err(err) => { - error!("Error reading Midjourney credentials: {:?}", err); - ShowProviderLoginModalEvent::send_for_provider(GenerationProvider::Midjourney, &app); - return Err(GenerateError::needs_midjourney_credentials()); - }, - }; - - // TODO: We can request population of the user info if absent or expired. - - let user_info = match mj_creds_manager.maybe_copy_user_info() { - Ok(Some(user_info)) => user_info, - Ok(None) => { - return Err(GenerateError::MissingCredentials(MissingCredentialsReason::NeedsMidjourneyUserInfo)); - } - Err(err) => { - error!("Error reading Midjourney user info: {:?}", err); - return Err(GenerateError::MissingCredentials(MissingCredentialsReason::NeedsMidjourneyUserInfo)); - }, - }; - - let channel_id = match user_info.user_id { - Some(user_id) => ChannelId::UserId(user_id), - None => { - error!("Midjourney user info does not contain a user ID."); - return Err(GenerateError::MissingCredentials(MissingCredentialsReason::NeedsMidjourneyUserId)); - } - }; - - info!("Calling midjourney ..."); - - let cookie_header = creds.to_cookie_string(); - - let prompt = request.prompt - .as_deref() - .unwrap_or(""); - - let result = text_to_image(TextToImageRequest { - prompt, - channel_id: &channel_id, - hostname: MidjourneyHostname::Standard, - cookie_header, - }).await; - - let result = match result { - Ok(result) => result, - Err(err) => { - error!("Failed to use MidJourney: {:?}", err); - return Err(GenerateError::from(err)); - } - }; - - let job_id = match result.maybe_job_id { - Some(job_id) => job_id, - None => { - error!("Failed to enqueue MidJourney: No job ID returned."); - return handle_midjourney_errors(app, result.maybe_errors); - } - }; - - info!("Successfully enqueued MidJourney. Job token: {}", job_id); - - Ok(TaskEnqueueSuccess { - provider: GenerationProvider::Midjourney, - model: Some(GenerationModel::Midjourney), - provider_job_id: Some(job_id), - task_type: TaskType::ImageGeneration, - }) -} - -fn handle_midjourney_errors( - app: &AppHandle, - maybe_errors: Option> -) -> Result { - if let Some(errors) = maybe_errors { - if !errors.is_empty() { - let messages: Vec = errors.iter() - .map(|e| format!("{:?}", e)) - .collect(); - - let combined_message = messages.join("; "); - - let event = FlashUserInputErrorEvent { - message: format!("Midjourney Error: {}", combined_message), - }; - - if let Err(err) = event.send(&app) { - error!("Failed to send FlashUserInputErrorEvent: {:?}", err); // Fail open - } - } - } - - Err(GenerateError::ProviderFailure(ProviderFailureReason::MidjourneyJobEnqueueFailed)) -} diff --git a/crates/desktop/artcraft/src/core/commands/generate/generate_image/providers/midjourney/mod.rs b/crates/desktop/artcraft/src/core/commands/generate/generate_image/providers/midjourney/mod.rs deleted file mode 100644 index 18048875b6..0000000000 --- a/crates/desktop/artcraft/src/core/commands/generate/generate_image/providers/midjourney/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub (super) mod handle_midjourney; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/core/commands/generate/generate_image/providers/mod.rs b/crates/desktop/artcraft/src/core/commands/generate/generate_image/providers/mod.rs deleted file mode 100644 index c260241ca6..0000000000 --- a/crates/desktop/artcraft/src/core/commands/generate/generate_image/providers/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod artcraft; -pub mod artcraft_router; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/core/commands/generate/generate_image/providers/sora/handle_gpt_image_1_sora_text_to_image.rs b/crates/desktop/artcraft/src/core/commands/generate/generate_image/providers/sora/handle_gpt_image_1_sora_text_to_image.rs deleted file mode 100644 index d7e1a25875..0000000000 --- a/crates/desktop/artcraft/src/core/commands/generate/generate_image/providers/sora/handle_gpt_image_1_sora_text_to_image.rs +++ /dev/null @@ -1,136 +0,0 @@ -use crate::core::api_adapters::aspect_ratio::convert::aspect_ratio_to_grok_image::aspect_ratio_to_grok_image; -use crate::core::api_adapters::aspect_ratio::convert::aspect_ratio_to_sora_native_gpt_image_1::aspect_ratio_to_sora_native_gpt_image_1; -use crate::core::commands::enqueue::generate_error::GenerateError; -use crate::core::commands::enqueue::task_enqueue_success::TaskEnqueueSuccess; -use crate::core::commands::deprecated::text_to_image::enqueue_text_to_image_command::{EnqueueTextToImageRequest, TextToImageSize}; -use crate::core::events::basic_sendable_event_trait::BasicSendableEvent; -use crate::core::events::functional_events::show_provider_login_modal_event::ShowProviderLoginModalEvent; -use crate::core::events::generation_events::common::{GenerationAction, GenerationModel, GenerationServiceProvider}; -use crate::core::events::generation_events::generation_enqueue_failure_event::GenerationEnqueueFailureEvent; -use crate::services::sora::state::sora_credential_manager::SoraCredentialManager; -use crate::services::sora::state::sora_task_queue::SoraTaskQueue; -use enums::common::generation_provider::GenerationProvider; -use enums::tauri::tasks::task_type::TaskType; -use errors::AnyhowResult; -use grok_consumer_client::requests::image_websocket::messages::websocket_client_message::ClientMessageAspectRatio; -use log::{error, info}; -use openai_sora_client::recipes::maybe_upgrade_or_renew_session::maybe_upgrade_or_renew_session; -use openai_sora_client::recipes::simple_image_gen_with_session_auto_renew::{simple_image_gen_with_session_auto_renew, SimpleImageGenAutoRenewRequest}; -use openai_sora_client::requests::image_gen::common::{ImageSize, NumImages}; -use std::time::Duration; -use tauri::AppHandle; - -const SORA_SIMPLE_IMAGE_GEN_TIMEOUT : Duration = Duration::from_millis(1000 * 30); // 30 seconds - -#[deprecated(note = "Legacy direct-provider handler; desktop generation now uses ArtCraft.")] -pub async fn handle_gpt_image_1_sora_text_to_image( - request: &EnqueueTextToImageRequest, - app: &AppHandle, - sora_creds_manager: &SoraCredentialManager, - sora_task_queue: &SoraTaskQueue, -) -> Result { - - let mut creds = match sora_creds_manager.get_credentials() { - Ok(Some(creds)) => creds, - Ok(None) => { - error!("Sora credentials not found."); - ShowProviderLoginModalEvent::send_for_provider(GenerationProvider::Sora, &app); - return Err(GenerateError::needs_sora_credentials()); - } - Err(err) => { - error!("Error reading Sora credentials: {:?}", err); - ShowProviderLoginModalEvent::send_for_provider(GenerationProvider::Sora, &app); - return Err(GenerateError::needs_sora_credentials()); - } - }; - - let credential_updated = maybe_upgrade_or_renew_session(&mut creds) - .await - .map_err(|err| { - error!("Failed to upgrade or renew session: {:?}", err); - err - })?; - - if credential_updated { - info!("Storing updated credentials"); - sora_creds_manager.set_credentials(&creds)?; - } - - let prompt = request.prompt.as_deref().unwrap_or(""); - - let aspect_ratio = get_aspect_ratio(request) - .unwrap_or(ImageSize::Square); - - let num_images = match request.number_images { - None => NumImages::One, - Some(1) => NumImages::One, - Some(2) => NumImages::Two, - Some(3) => NumImages::Two, // NB: There is no option for three images! - Some(4) => NumImages::Four, - _ => NumImages::One, - }; - - let result = - simple_image_gen_with_session_auto_renew(SimpleImageGenAutoRenewRequest { - prompt: prompt.to_string(), - num_images, - image_size: aspect_ratio, - credentials: &creds, - request_timeout: Some(SORA_SIMPLE_IMAGE_GEN_TIMEOUT), - }).await; - - let (response, maybe_new_creds) = - match result { - Ok((response, maybe_new_creds)) => (response, maybe_new_creds), - Err(err) => { - let event = GenerationEnqueueFailureEvent { - action: GenerationAction::GenerateImage, - service: GenerationServiceProvider::Sora, - model: None, - reason: None, - }; - - if let Err(err) = event.send(app) { - error!("Failed to emit event: {:?}", err); // Fail open. - } - - return Err(GenerateError::from(err)); - } - }; - - if let Some(new_creds) = maybe_new_creds { - info!("Storing updated credentials."); - sora_creds_manager.set_credentials(&new_creds)?; - } - - info!("New Sora Task ID: {:?} ", response.task_id); - - sora_task_queue.insert(&response.task_id)?; - - Ok(TaskEnqueueSuccess { - provider: GenerationProvider::Sora, - task_type: TaskType::ImageGeneration, - model: Some(GenerationModel::GptImage1), - provider_job_id: Some(response.task_id.to_string()), - }) -} - -fn get_aspect_ratio(request: &EnqueueTextToImageRequest) -> Option { - if let Some(common_aspect_ratio) = request.common_aspect_ratio { - // Handle modern aspect ratio - let aspect = aspect_ratio_to_sora_native_gpt_image_1(common_aspect_ratio); - return Some(aspect); - } - - if let Some(aspect_ratio) = request.aspect_ratio { - // Handle deprecated aspect ratio - return match aspect_ratio { - TextToImageSize::Auto => Some(ImageSize::Square), - TextToImageSize::Square => Some(ImageSize::Square), - TextToImageSize::Wide => Some(ImageSize::Wide), - TextToImageSize::Tall => Some(ImageSize::Tall), - } - } - - None -} diff --git a/crates/desktop/artcraft/src/core/commands/generate/generate_image/providers/sora/handle_text_to_image_sora.rs b/crates/desktop/artcraft/src/core/commands/generate/generate_image/providers/sora/handle_text_to_image_sora.rs deleted file mode 100644 index f7bad13a58..0000000000 --- a/crates/desktop/artcraft/src/core/commands/generate/generate_image/providers/sora/handle_text_to_image_sora.rs +++ /dev/null @@ -1,22 +0,0 @@ -use crate::core::commands::enqueue::generate_error::GenerateError; -use crate::core::commands::enqueue::task_enqueue_success::TaskEnqueueSuccess; -use crate::core::commands::deprecated::text_to_image::enqueue_text_to_image_command::EnqueueTextToImageRequest; -use crate::core::commands::generate::generate_image::sora::handle_gpt_image_1_sora_text_to_image::handle_gpt_image_1_sora_text_to_image; -use crate::services::sora::state::sora_credential_manager::SoraCredentialManager; -use crate::services::sora::state::sora_task_queue::SoraTaskQueue; -use tauri::AppHandle; - -#[deprecated(note = "Legacy direct-provider handler; desktop generation now uses ArtCraft.")] -pub async fn handle_text_to_image_sora( - request: &EnqueueTextToImageRequest, - app: &AppHandle, - sora_creds_manager: &SoraCredentialManager, - sora_task_queue: &SoraTaskQueue, -) -> Result { - handle_gpt_image_1_sora_text_to_image( - request, - app, - sora_creds_manager, - sora_task_queue, - ).await -} diff --git a/crates/desktop/artcraft/src/core/commands/generate/generate_image/providers/sora/mod.rs b/crates/desktop/artcraft/src/core/commands/generate/generate_image/providers/sora/mod.rs deleted file mode 100644 index 9a9529d300..0000000000 --- a/crates/desktop/artcraft/src/core/commands/generate/generate_image/providers/sora/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub (super) mod handle_text_to_image_sora; -mod handle_gpt_image_1_sora_text_to_image; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/core/commands/generate/generate_image/tauri_generate_image_request.rs b/crates/desktop/artcraft/src/core/commands/generate/generate_image/tauri_generate_image_request.rs deleted file mode 100644 index 1e37568ff6..0000000000 --- a/crates/desktop/artcraft/src/core/commands/generate/generate_image/tauri_generate_image_request.rs +++ /dev/null @@ -1,125 +0,0 @@ -use enums::common::generation::common_aspect_ratio::CommonAspectRatio; -use enums::common::generation::common_resolution::CommonResolution; -use enums::common::generation::common_quality::CommonQuality; -use enums::common::generation_provider::GenerationProvider; -use enums::tauri::ux::tauri_command_caller::TauriCommandCaller; -use serde_derive::{Deserialize, Serialize}; -use tokens::tokens::media_files::MediaFileToken; - -use crate::core::commands::generate::generate_image::tauri_image_model::TauriImageModel; -use crate::core::commands::response::success_response_wrapper::SerializeMarker; - -// ── Request ── - -#[derive(Deserialize, Debug)] -pub struct TauriGenerateImageRequest { - /// The provider to use (defaults to Artcraft/Storyteller). - /// Not all (provider, model) combinations are valid. - pub provider: Option, - - /// The model to use. - pub model: Option, - - /// Text prompt for the image generation. - pub prompt: Option, - - /// Aspect ratio. - pub aspect_ratio: Option, - - /// Resolution. - pub resolution: Option, - - /// Quality (used by OpenAI models). - pub quality: Option, - - /// The number of images to generate. - pub batch_size: Option, - - /// Reference images (without semantics). - /// The purpose varies on a model-by-model basis. - pub image_media_tokens: Option>, - - // ── Canvas / scene images ── - - /// Supply this *XOR* `canvas_image_raw_bytes`. - /// Becomes the first image reference (pushing back `image_media_tokens` by one). - pub canvas_image_media_token: Option, - - /// Supply this *XOR* `canvas_image_media_token`. - /// Raw bytes of a canvas image. - pub canvas_image_raw_bytes: Option>, - - /// Supply this *XOR* `scene_image_raw_bytes`. - /// Becomes a scene reference image. - pub scene_image_media_token: Option, - - /// Supply this *XOR* `scene_image_media_token`. - /// Raw bytes of a scene image. - pub scene_image_raw_bytes: Option>, - - // ── Inpainting ── - - /// Supply this *XOR* `inpainting_mask_image_raw_bytes`. - /// The mask to focus the edit (already uploaded). - pub inpainting_mask_image_media_token: Option, - - /// Supply this *XOR* `inpainting_mask_image_media_token`. - /// The mask to focus the edit (raw bytes). - pub inpainting_mask_image_raw_bytes: Option>, - - // ── Angle adjustment (for edit models like QwenEdit, Flux2LoraAngles) ── - - /// Horizontal angle adjustment. - pub adjust_horizontal_angle: Option, - - /// Vertical angle adjustment. - pub adjust_vertical_angle: Option, - - /// Zoom adjustment. - pub adjust_zoom: Option, - - /// Turn on the system prompt. - pub enable_system_prompt: Option, - - // ── Frontend metadata ── - - /// Name of the frontend caller. - pub frontend_caller: Option, - - /// A frontend-defined identifier sent back as a Tauri event on task completion. - pub frontend_subscriber_id: Option, - - /// A frontend-defined payload sent back as a Tauri event on task completion. - pub frontend_subscriber_payload: Option, -} - -// ── Response ── - -#[derive(Serialize)] -pub struct TauriGenerateImageResponse { -} - -impl SerializeMarker for TauriGenerateImageResponse {} - -// ── Error ── - -#[derive(Serialize, Debug)] -#[serde(rename_all = "snake_case")] -pub enum TauriGenerateImageErrorType { - /// Caller didn't specify a model - ModelNotSpecified, - /// Bad input - BadInput, - /// No provider available - NoProviderAvailable, - /// Generic server error - ServerError, - /// Needs to be logged into Artcraft - NeedsStorytellerCredentials, - /// Needs a FAL API key - NeedsFalApiKey, - /// Needs Grok credentials - NeedsGrokCredentials, - /// Billing issue - BillingIssue, -} diff --git a/crates/desktop/artcraft/src/core/commands/generate/generate_image/tauri_image_model.rs b/crates/desktop/artcraft/src/core/commands/generate/generate_image/tauri_image_model.rs deleted file mode 100644 index 88c53c1078..0000000000 --- a/crates/desktop/artcraft/src/core/commands/generate/generate_image/tauri_image_model.rs +++ /dev/null @@ -1,81 +0,0 @@ -use serde_derive::Deserialize; - -/// Unified image model enum covering text-to-image, image edit, and inpainting. -/// -/// This is used in the Tauri command bridge. -/// Don't change the serializations without coordinating with the frontend. -/// -/// MIGRATION (2026-07): we're moving the frontend to send storyteller-web omni -/// identifiers (`CommonImageModel` serde strings). Variants whose legacy Tauri -/// id differs carry the omni id as a `#[serde(alias)]` so BOTH deserialize. -/// Once the frontend is 100% omni ids, the legacy renames can be dropped. -#[derive(Deserialize, Debug, Copy, Clone)] -#[serde(rename_all = "snake_case")] -pub enum TauriImageModel { - // Text-to-image models - - #[serde(rename = "flux_1_dev")] - Flux1Dev, - #[serde(rename = "flux_1_schnell")] - Flux1Schnell, - #[serde(rename = "flux_pro_11", alias = "flux_pro_1p1")] - FluxPro11, - #[serde(rename = "flux_pro_11_ultra", alias = "flux_pro_1p1_ultra")] - FluxPro11Ultra, - #[serde(rename = "grok_image", alias = "grok_imagine_image")] - GrokImage, - #[serde(rename = "recraft_3")] - Recraft3, - #[serde(rename = "gpt_image_1")] - GptImage1, - #[serde(rename = "gpt_image_1p5")] - GptImage1p5, - #[serde(rename = "gpt_image_2")] - GptImage2, - #[serde(rename = "gpt_image_2p5_flare")] - GptImage2p5Flare, - #[serde(rename = "gpt_image_2p5_sunburst")] - GptImage2p5Sunburst, - #[serde(rename = "gemini_25_flash")] - Gemini25Flash, - #[serde(rename = "nano_banana")] - NanoBanana, - #[serde(rename = "nano_banana_2")] - NanoBanana2, - #[serde(rename = "nano_banana_pro")] - NanoBananaPro, - #[serde(rename = "seedream_4")] - Seedream4, - #[serde(rename = "seedream_4p5")] - Seedream4p5, - #[serde(rename = "seedream_5_lite")] - Seedream5Lite, - // Generic Midjourney experience, served via the native Midjourney provider. - #[serde(rename = "midjourney")] - Midjourney, - - // Versioned Midjourney models, served by storyteller-web via the - // Artcraft provider (dispatched through artcraft_router). - #[serde(rename = "midjourney_7")] - Midjourney7, - #[serde(rename = "midjourney_7_niji")] - Midjourney7Niji, - #[serde(rename = "midjourney_8")] - Midjourney8, - - // Image edit models - - #[serde(rename = "flux_pro_kontext_max")] - FluxProKontextMax, - #[serde(rename = "qwen_edit_2511_angles")] - QwenEdit2511Angles, - #[serde(rename = "flux_2_lora_angles")] - Flux2LoraAngles, - - // Inpainting models - - #[serde(rename = "flux_dev_juggernaut")] - FluxDevJuggernaut, - #[serde(rename = "flux_pro_1")] - FluxPro1, -} diff --git a/crates/desktop/artcraft/src/core/commands/generate/generate_image/utils/mod.rs b/crates/desktop/artcraft/src/core/commands/generate/generate_image/utils/mod.rs deleted file mode 100644 index 1734914faa..0000000000 --- a/crates/desktop/artcraft/src/core/commands/generate/generate_image/utils/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod parse_semantic_media_files; diff --git a/crates/desktop/artcraft/src/core/commands/generate/generate_image/utils/parse_semantic_media_files.rs b/crates/desktop/artcraft/src/core/commands/generate/generate_image/utils/parse_semantic_media_files.rs deleted file mode 100644 index 2b0402a82a..0000000000 --- a/crates/desktop/artcraft/src/core/commands/generate/generate_image/utils/parse_semantic_media_files.rs +++ /dev/null @@ -1,123 +0,0 @@ -use log::info; - -use artcraft_client::credentials::storyteller_credential_set::StorytellerCredentialSet; -use artcraft_client::utils::api_host::ApiHost; -use tokens::tokens::media_files::MediaFileToken; - -use crate::core::commands::enqueue::generate_error::{BadInputReason, GenerateError}; -use crate::core::commands::generate::generate_image::tauri_generate_image_request::TauriGenerateImageRequest; -use crate::core::utils::upload_bytes_to_media_file::upload_image_bytes_as_media_file::upload_image_bytes_as_media_file; -use crate::core::utils::upload_bytes_to_media_file::upload_mask_image_bytes_as_media_file::upload_mask_image_bytes_as_media_file; - -/// Resolved semantic media file tokens for canvas, scene, and inpainting mask. -/// -/// Each field is populated either from an already-uploaded token on the request -/// or by uploading raw bytes on the fly. -pub struct SemanticMediaFiles { - pub canvas_image_media_token: Option, - pub scene_image_media_token: Option, - pub inpainting_mask_image_media_token: Option, -} - -/// Resolve semantic media files from the request. -/// -/// For each of (canvas, scene, mask): the request may supply a pre-uploaded -/// token XOR raw bytes. If both are supplied, returns an error. If raw bytes -/// are supplied, uploads them and returns the resulting token. -pub async fn parse_semantic_media_files( - request: &TauriGenerateImageRequest, - creds: &StorytellerCredentialSet, - api_host: &ApiHost, -) -> Result { - // Canvas image - let canvas_image_media_token = resolve_image_field( - "canvas_image", - request.canvas_image_media_token.as_ref(), - request.canvas_image_raw_bytes.as_deref(), - creds, - api_host, - ).await?; - - // Scene image - let scene_image_media_token = resolve_image_field( - "scene_image", - request.scene_image_media_token.as_ref(), - request.scene_image_raw_bytes.as_deref(), - creds, - api_host, - ).await?; - - // Inpainting mask - let inpainting_mask_image_media_token = resolve_mask_field( - request.inpainting_mask_image_media_token.as_ref(), - request.inpainting_mask_image_raw_bytes.as_deref(), - creds, - api_host, - ).await?; - - Ok(SemanticMediaFiles { - canvas_image_media_token, - scene_image_media_token, - inpainting_mask_image_media_token, - }) -} - -// ── Helpers ── - -pub(crate) async fn resolve_image_field( - field_name: &str, - maybe_token: Option<&MediaFileToken>, - maybe_raw_bytes: Option<&[u8]>, - creds: &StorytellerCredentialSet, - api_host: &ApiHost, -) -> Result, GenerateError> { - if maybe_token.is_some() && maybe_raw_bytes.is_some() { - return Err(GenerateError::BadInput(BadInputReason::WrongImageArguments(format!( - "Cannot supply both {}_media_token and {}_raw_bytes", - field_name, field_name - )))); - } - - if let Some(token) = maybe_token { - return Ok(Some(token.clone())); - } - - if let Some(raw_bytes) = maybe_raw_bytes { - info!("Uploading {} raw bytes ({} bytes)...", field_name, raw_bytes.len()); - let token = upload_image_bytes_as_media_file( - creds, - api_host, - raw_bytes.to_vec(), - ).await?; - return Ok(Some(token)); - } - - Ok(None) -} - -pub(crate) async fn resolve_mask_field( - maybe_token: Option<&MediaFileToken>, - maybe_raw_bytes: Option<&[u8]>, - creds: &StorytellerCredentialSet, - api_host: &ApiHost, -) -> Result, GenerateError> { - if maybe_token.is_some() && maybe_raw_bytes.is_some() { - return Err(GenerateError::BadInput(BadInputReason::BothImageMaskMediaTokenAndBytesSupplied)); - } - - if let Some(token) = maybe_token { - return Ok(Some(token.clone())); - } - - if let Some(raw_bytes) = maybe_raw_bytes { - info!("Uploading inpainting mask raw bytes ({} bytes)...", raw_bytes.len()); - let token = upload_mask_image_bytes_as_media_file( - creds, - api_host, - raw_bytes, - ).await?; - return Ok(Some(token)); - } - - Ok(None) -} diff --git a/crates/desktop/artcraft/src/core/commands/generate/generate_mesh_command.rs b/crates/desktop/artcraft/src/core/commands/generate/generate_mesh_command.rs deleted file mode 100644 index b3a626a442..0000000000 --- a/crates/desktop/artcraft/src/core/commands/generate/generate_mesh_command.rs +++ /dev/null @@ -1,11 +0,0 @@ -use crate::core::commands::generate::omni::{self, Modality, OmniRequest, OmniResult}; -use crate::core::commands::generate::omni::dispatch::local_error; -use tauri::AppHandle; - -#[tauri::command] -pub async fn generate_mesh_command(request: OmniRequest, app: AppHandle) -> OmniResult { - if !request.uses_artcraft() { - return Err(local_error("No direct provider adapter is configured for this modality.")); - } - omni::generate(request, Modality::Mesh, &app).await -} diff --git a/crates/desktop/artcraft/src/core/commands/generate/generate_splat_command.rs b/crates/desktop/artcraft/src/core/commands/generate/generate_splat_command.rs deleted file mode 100644 index 85b86ef839..0000000000 --- a/crates/desktop/artcraft/src/core/commands/generate/generate_splat_command.rs +++ /dev/null @@ -1,15 +0,0 @@ -use crate::core::commands::enqueue::image_to_gaussian::enqueue_image_to_gaussian_command::enqueue_image_to_gaussian_command; -use crate::core::commands::generate::omni::{self, Modality, OmniRequest, OmniResult}; -use crate::core::commands::generate::omni::dispatch::{adapt_legacy_response, decode_native}; -use tauri::{AppHandle, Manager}; - -#[tauri::command] -pub async fn generate_splat_command(mut request: OmniRequest, app: AppHandle) -> OmniResult { - if request.uses_artcraft() { - return omni::generate(request, Modality::Splat, &app).await; - } - if let Some(images) = request.fields.remove("reference_image_media_tokens") { - request.fields.insert("image_media_tokens".into(), images); - } - adapt_legacy_response(enqueue_image_to_gaussian_command(decode_native(request)?, app.clone(), app.state(), app.state(), app.state(), app.state(), app.state(), app.state()).await) -} diff --git a/crates/desktop/artcraft/src/core/commands/generate/generate_video/artcraft/get_storyteller_creds_or_error.rs b/crates/desktop/artcraft/src/core/commands/generate/generate_video/artcraft/get_storyteller_creds_or_error.rs deleted file mode 100644 index 3fdd114d5e..0000000000 --- a/crates/desktop/artcraft/src/core/commands/generate/generate_video/artcraft/get_storyteller_creds_or_error.rs +++ /dev/null @@ -1,27 +0,0 @@ -use crate::core::commands::enqueue::generate_error::GenerateError; -use crate::core::events::basic_sendable_event_trait::BasicSendableEvent; -use crate::core::events::generation_events::common::GenerationAction; -use crate::core::events::generation_events::generation_enqueue_failure_event::GenerationEnqueueFailureEvent; -use crate::services::storyteller::state::storyteller_credential_manager::StorytellerCredentialManager; -use log::error; -use artcraft_client::credentials::storyteller_credential_set::StorytellerCredentialSet; -use tauri::AppHandle; - -pub (super) fn get_storyteller_creds_or_error( - app: &AppHandle, - storyteller_creds_manager: &StorytellerCredentialManager, -) -> Result { - - match storyteller_creds_manager.get_credentials()? { - Some(creds) => Ok(creds), - None => { - error!("No Artcraft credentials are set. Can't perform action."); - let event = - GenerationEnqueueFailureEvent::no_artcraft_credentials(GenerationAction::GenerateVideo); - - event.send_infallible(app); - - Err(GenerateError::needs_storyteller_credentials()) - }, - } -} diff --git a/crates/desktop/artcraft/src/core/commands/generate/generate_video/artcraft/handle_artcraft_video.rs b/crates/desktop/artcraft/src/core/commands/generate/generate_video/artcraft/handle_artcraft_video.rs deleted file mode 100644 index cb526557bc..0000000000 --- a/crates/desktop/artcraft/src/core/commands/generate/generate_video/artcraft/handle_artcraft_video.rs +++ /dev/null @@ -1,30 +0,0 @@ -use crate::core::api_adapters::models::video::tauri_video_model_to_generation_model::tauri_video_model_to_generation_model; -use crate::core::api_adapters::models::video::tauri_video_model_to_router_model::tauri_video_model_to_router_model; -use crate::core::commands::enqueue::generate_error::GenerateError; -use crate::core::commands::enqueue::task_enqueue_success::TaskEnqueueSuccess; -use crate::core::commands::generate::generate_video::artcraft::get_storyteller_creds_or_error::get_storyteller_creds_or_error; -use crate::core::commands::generate::generate_video::artcraft::handle_artcraft_video_via_router::handle_artcraft_video_via_router; -use crate::core::commands::generate::generate_video::request::TauriGenerateVideoRequest; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; -use crate::services::storyteller::state::storyteller_credential_manager::StorytellerCredentialManager; -use tauri::AppHandle; - -pub async fn handle_video_artcraft( - request: &TauriGenerateVideoRequest, - app: &AppHandle, - app_env_configs: &AppEnvConfigs, - storyteller_creds_manager: &StorytellerCredentialManager, -) -> Result { - - let creds = get_storyteller_creds_or_error(app, storyteller_creds_manager)?; - - let model = match request.model { - None => return Err(GenerateError::no_model_specified()), - Some(model) => model, - }; - - let router_model = tauri_video_model_to_router_model(model); - let generation_model = tauri_video_model_to_generation_model(model); - - handle_artcraft_video_via_router(request, app_env_configs, &creds, router_model, generation_model).await -} diff --git a/crates/desktop/artcraft/src/core/commands/generate/generate_video/artcraft/handle_artcraft_video_via_router.rs b/crates/desktop/artcraft/src/core/commands/generate/generate_video/artcraft/handle_artcraft_video_via_router.rs deleted file mode 100644 index 78bb76d9d8..0000000000 --- a/crates/desktop/artcraft/src/core/commands/generate/generate_video/artcraft/handle_artcraft_video_via_router.rs +++ /dev/null @@ -1,107 +0,0 @@ -use crate::core::commands::enqueue::generate_error::GenerateError; -use crate::core::commands::generate::generate_video::request::TauriGenerateVideoRequest; -use crate::core::commands::enqueue::task_enqueue_success::TaskEnqueueSuccess; -use crate::core::events::generation_events::common::GenerationModel; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; -use artcraft_client::credentials::storyteller_credential_set::StorytellerCredentialSet; -use artcraft_router::api::audio_list_ref::AudioListRef; -use artcraft_router::api::character_list_ref::CharacterListRef; -use artcraft_router::api::router_video_model::RouterVideoModel; -use artcraft_router::api::image_list_ref::ImageListRef; -use artcraft_router::api::image_ref::ImageRef; -use artcraft_router::api::router_provider::RouterProvider; -use artcraft_router::api::video_list_ref::VideoListRef; -use artcraft_router::client::request_mismatch_mitigation_strategy::RequestMismatchMitigationStrategy; -use artcraft_router::client::router_artcraft_client::RouterArtcraftClient; -use artcraft_router::client::router_client::RouterClient; -use artcraft_router::generate::generate_video::generate_video_request_builder::GenerateVideoRequestBuilder; -use artcraft_router::generate::generate_video::generate_video_response::GenerateVideoResponse; -use artcraft_router::generate::generate_video::video_generation_draft_or_request::VideoGenerationDraftOrRequest; -use enums::common::generation_provider::GenerationProvider; -use enums::tauri::tasks::task_type::TaskType; -use log::{error, info}; - -pub(super) async fn handle_artcraft_video_via_router( - request: &TauriGenerateVideoRequest, - app_env_configs: &AppEnvConfigs, - creds: &StorytellerCredentialSet, - model: RouterVideoModel, - generation_model: GenerationModel, -) -> Result { - let client = RouterClient::Artcraft(RouterArtcraftClient::new( - app_env_configs.storyteller_host.clone(), - creds.clone(), - )); - - let start_frame = request.image_media_token.clone().map(ImageRef::MediaFileToken); - let end_frame = request.end_frame_image_media_token.clone().map(ImageRef::MediaFileToken); - - let reference_images = request.reference_image_media_tokens.clone().map(ImageListRef::MediaFileTokens); - let reference_videos = request.reference_video_media_tokens.clone().map(VideoListRef::MediaFileTokens); - let reference_audio = request.reference_audio_media_tokens.clone().map(AudioListRef::MediaFileTokens); - - let reference_character_tokens = request.reference_character_tokens.clone().map(CharacterListRef::CharacterTokens); - - let router_request = GenerateVideoRequestBuilder { - model, - provider: RouterProvider::Artcraft, - prompt: request.prompt.clone(), - start_frame, - end_frame, - reference_images, - reference_videos, - reference_audio, - reference_character_tokens, - resolution: request.resolution, - aspect_ratio: request.aspect_ratio, - bitrate: None, - duration_seconds: request.duration_seconds, - video_batch_count: request.video_batch_count, - generate_audio: request.generate_audio, - total_reference_video_input_seconds: None, - request_mismatch_mitigation_strategy: RequestMismatchMitigationStrategy::PayMoreUpgrade, - idempotency_token: None, - negative_prompt: None, - }; - - info!("Building request for artcraft_router (v2 pipeline)..."); - let response = generate_via_v2(router_request, &client).await?; - - let job_id = response.get_artcraft_payload() - .map(|p| p.inference_job_token.to_string()) - .ok_or(GenerateError::ResponseHadNoJobTokens)?; - - Ok(TaskEnqueueSuccess { - task_type: TaskType::VideoGeneration, - model: Some(generation_model), - provider: GenerationProvider::Artcraft, - provider_job_id: Some(job_id), - maybe_queue_status_url: None, - maybe_prompt_token: None, - maybe_queue_response_url: None, - }) -} - -/// V2 pipeline: build2 → send_request (Artcraft skips draft phase). -async fn generate_via_v2( - router_request: GenerateVideoRequestBuilder, - client: &RouterClient, -) -> Result { - let draft_or_request = router_request.build2()?; - - let request = match draft_or_request { - VideoGenerationDraftOrRequest::Request(r) => r, - VideoGenerationDraftOrRequest::Draft(_) => { - error!("Unexpected Draft variant for Artcraft provider"); - return Err(GenerateError::NotYetImplemented("Artcraft provider should not produce a draft request".to_string())); - } - }; - - let response = request.send_request(client).await.map_err(|err| { - error!("V2 failed to enqueue: {:?}", err); - GenerateError::from(err) - })?; - - info!("V2 successfully enqueued."); - Ok(response) -} diff --git a/crates/desktop/artcraft/src/core/commands/generate/generate_video/artcraft/mod.rs b/crates/desktop/artcraft/src/core/commands/generate/generate_video/artcraft/mod.rs deleted file mode 100644 index 5dd8e99770..0000000000 --- a/crates/desktop/artcraft/src/core/commands/generate/generate_video/artcraft/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -mod get_storyteller_creds_or_error; -mod handle_artcraft_video_via_router; -pub (super) mod handle_artcraft_video; diff --git a/crates/desktop/artcraft/src/core/commands/generate/generate_video/generate_video_command.rs b/crates/desktop/artcraft/src/core/commands/generate/generate_video/generate_video_command.rs deleted file mode 100644 index ebee2daad7..0000000000 --- a/crates/desktop/artcraft/src/core/commands/generate/generate_video/generate_video_command.rs +++ /dev/null @@ -1,227 +0,0 @@ -use crate::core::commands::generate::omni::{self, Modality, OmniRequest, OmniResult}; -use crate::core::commands::generate::omni::dispatch::{adapt_legacy_response, decode_native}; -use tauri::Manager; -use crate::core::commands::enqueue::common::notify_frontend_of_errors::notify_frontend_of_errors; -use crate::core::commands::enqueue::generate_error::{BadInputReason, GenerateError, MissingCredentialsReason}; -use crate::core::commands::enqueue::task_enqueue_success::TaskEnqueueSuccess; -use crate::core::commands::generate::generate_video::artcraft::handle_artcraft_video::handle_video_artcraft; -use crate::core::commands::generate::generate_video::grok::handle_grok_video::handle_grok_video; -use crate::core::commands::generate::generate_video::request::{ - TauriGenerateVideoErrorType, TauriGenerateVideoRequest, TauriGenerateVideoResponse, - TauriVideoModel, -}; -use crate::core::commands::generate::generate_video::sora2::handle_sora_sora2::handle_sora_sora2; -use crate::core::commands::response::failure_response_wrapper::{CommandErrorResponseWrapper, CommandErrorStatus}; -use crate::core::commands::response::shorthand::Response; -use crate::core::events::basic_sendable_event_trait::BasicSendableEvent; -use crate::core::events::functional_events::credits_balance_changed_event::CreditsBalanceChangedEvent; -use crate::core::events::generation_events::generation_enqueue_success_event::GenerationEnqueueSuccessEvent; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; -use crate::core::state::artcraft_usage_tracker::artcraft_usage_tracker::ArtcraftUsageTracker; -use crate::core::state::artcraft_usage_tracker::artcraft_usage_type::{ArtcraftUsagePage, ArtcraftUsageType}; -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::core::state::provider_priority::{Provider, ProviderPriorityStore}; -use crate::core::state::task_database::TaskDatabase; -use crate::services::grok::state::grok_credential_manager::GrokCredentialManager; -use crate::services::sora::state::sora_credential_manager::SoraCredentialManager; -use crate::services::sora::state::sora_task_queue::SoraTaskQueue; -use crate::services::storyteller::state::storyteller_credential_manager::StorytellerCredentialManager; -use enums::common::generation_provider::GenerationProvider; -use log::{error, info, warn}; -use tauri::{AppHandle, State}; - -#[tauri::command] -pub async fn generate_video_command(request: OmniRequest, app: AppHandle) -> OmniResult { - if request.uses_artcraft() { - return omni::generate(request, Modality::Video, &app).await; - } - adapt_legacy_response(generate_video_native( - decode_native(request)?, app.clone(), - app.state(), app.state(), app.state(), app.state(), app.state(), app.state(), app.state(), app.state(), app.state(), - ).await) -} - -async fn generate_video_native( - mut request: TauriGenerateVideoRequest, - app: AppHandle, - app_env_configs: State<'_, AppEnvConfigs>, - app_data_root: State<'_, AppDataRoot>, - artcraft_usage_tracker: State<'_, ArtcraftUsageTracker>, - provider_priority_store: State<'_, ProviderPriorityStore>, - task_database: State<'_, TaskDatabase>, - grok_creds_manager: State<'_, GrokCredentialManager>, - storyteller_creds_manager: State<'_, StorytellerCredentialManager>, - sora_task_queue: State<'_, SoraTaskQueue>, - sora_creds_manager: State<'_, SoraCredentialManager>, -) -> Response { - - info!("generate_video_command called, request: {:?}", request); - - if request.image_media_token.is_none() - && request.start_frame_image_media_token.is_some() { - // NB: This is to fix the legacy handlers - request.image_media_token = request.start_frame_image_media_token.clone(); - } - - if request.image_media_token.is_some() - && request.start_frame_image_media_token.is_none() { - // NB: This is to fix the modern handlers - request.start_frame_image_media_token = request.image_media_token.clone(); - } - - let result = handle_request( - request, - &app, - &app_env_configs, - &app_data_root, - &artcraft_usage_tracker, - &provider_priority_store, - &task_database, - &grok_creds_manager, - &sora_creds_manager, - &storyteller_creds_manager, - ).await; - - match result { - Err(err) => { - error!("error: {:?}", err); - - notify_frontend_of_errors(&app, &err).await; - - let mut status = CommandErrorStatus::ServerError; - let mut error_type = TauriGenerateVideoErrorType::ServerError; - let mut error_message = "A server error occurred. Please try again. If it continues, please tell our staff about the problem."; - - match err { - GenerateError::BadInput(BadInputReason::NoModelSpecified) => { - status = CommandErrorStatus::BadRequest; - error_type = TauriGenerateVideoErrorType::ModelNotSpecified; - error_message = "No model specified for video generation"; - } - GenerateError::NoProviderAvailable => { - status = CommandErrorStatus::ServerError; - error_type = TauriGenerateVideoErrorType::NoProviderAvailable; - error_message = "No configured provider available for video generation"; - } - GenerateError::MissingCredentials(MissingCredentialsReason::NeedsFalApiKey) => { - status = CommandErrorStatus::Unauthorized; - error_type = TauriGenerateVideoErrorType::NeedsFalApiKey; - error_message = "You need to set a FAL api key"; - }, - GenerateError::MissingCredentials(MissingCredentialsReason::NeedsStorytellerCredentials) => { - status = CommandErrorStatus::Unauthorized; - error_type = TauriGenerateVideoErrorType::NeedsStorytellerCredentials; - error_message = "You need to be logged into Artcraft."; - } - _ => {}, // Fall-through - } - - Err(CommandErrorResponseWrapper { - status, - error_message: Some(error_message.to_string()), - error_type: Some(error_type), - error_details: None, - }) - } - Ok(event) => { - let event = GenerationEnqueueSuccessEvent { - action: event.to_frontend_event_action(), - service: event.to_frontend_event_service(), - model: event.model, - }; - - if let Err(err) = event.send(&app) { - error!("Failed to emit event: {:?}", err); - } - - CreditsBalanceChangedEvent{}.send_infallible(&app); - - Ok(TauriGenerateVideoResponse {}.into()) - } - } -} - -async fn handle_request( - request: TauriGenerateVideoRequest, - app: &AppHandle, - app_env_configs: &AppEnvConfigs, - app_data_root: &AppDataRoot, - artcraft_usage_tracker: &ArtcraftUsageTracker, - provider_priority_store: &ProviderPriorityStore, - task_database: &TaskDatabase, - grok_creds_manager: &GrokCredentialManager, - sora_creds_manager: &SoraCredentialManager, - storyteller_creds_manager: &StorytellerCredentialManager, -) -> Result { - - let model = match request.model { - Some(model) => model, - None => { - return Err(GenerateError::no_model_specified()) - } - }; - - let provider = match (model, request.provider) { - (TauriVideoModel::GrokVideo, _) => GenerationProvider::Grok, - // NB: Grok Imagine 1.5 is served via Artcraft (storyteller-web / artcraft_router) - // for now — force it regardless of the requested provider. In the future we - // may serve it natively via the Grok provider. - (TauriVideoModel::GrokImagineVideo1p5, _) => GenerationProvider::Artcraft, - _ => request.provider.unwrap_or(GenerationProvider::Artcraft), - }; - - info!("generate video with {:?} via provider {:?}", &model, &provider); - - let result = match provider { - GenerationProvider::Grok => { - handle_grok_video( - &request, - app, - app_data_root, - app_env_configs, - grok_creds_manager, - ).await - } - GenerationProvider::Sora => { - handle_sora_sora2( - &request, - app, - app_data_root, - app_env_configs, - sora_creds_manager, - ).await - } - _ => { - handle_video_artcraft( - &request, - app, - app_env_configs, - storyteller_creds_manager, - ).await - } - }; - - let success_event = match result { - Err(err) => return Err(err), - Ok(event) => event, - }; - - let result = success_event - .insert_into_task_database_with_frontend_payload( - task_database, - request.frontend_caller, - request.frontend_subscriber_id.as_deref(), - request.frontend_subscriber_payload.as_deref() - ) - .await; - - if let Err(err) = result { - error!("Failed to create task in database: {:?}", err); - } - - if let Err(err) = artcraft_usage_tracker.record_video_generation(1, ArtcraftUsageType::ImageToResult, ArtcraftUsagePage::VideoPage) { - warn!("Failed to report usage: {:?}", err); - } - - Ok(success_event) -} diff --git a/crates/desktop/artcraft/src/core/commands/generate/generate_video/grok/handle_grok_video.rs b/crates/desktop/artcraft/src/core/commands/generate/generate_video/grok/handle_grok_video.rs deleted file mode 100644 index 871c487903..0000000000 --- a/crates/desktop/artcraft/src/core/commands/generate/generate_video/grok/handle_grok_video.rs +++ /dev/null @@ -1,152 +0,0 @@ -use crate::core::commands::enqueue::generate_error::{BadInputReason, GenerateError}; -use crate::core::commands::deprecated::image_edit::enqueue_edit_image_command::EnqueueEditImageCommand; -use crate::core::commands::deprecated::image_inpaint::enqueue_image_inpaint_command::EnqueueInpaintImageCommand; -use crate::core::commands::generate::generate_video::request::{TauriGenerateVideoRequest, TauriVideoModel, GrokAspectRatio, SoraOrientation}; -use crate::core::commands::enqueue::task_enqueue_success::TaskEnqueueSuccess; -use crate::core::events::functional_events::show_provider_login_modal_event::ShowProviderLoginModalEvent; -use crate::core::events::generation_events::common::GenerationModel; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::core::state::provider_priority::{Provider, ProviderPriorityStore}; -use crate::core::utils::download_media_file_to_temp_dir::download_media_file_to_temp_dir; -use crate::services::grok::state::grok_credential_manager::GrokCredentialManager; -use crate::services::grok::util::upload_image_media_file_to_grok::{upload_image_media_file_to_grok, UploadImageMediaFileToGrok}; -use crate::services::sora::state::sora_credential_manager::SoraCredentialManager; -use crate::services::sora::state::sora_task_queue::SoraTaskQueue; -use crate::services::sora::utils::upload_images_to_sora::{upload_images_to_sora, UploadImagesToSoraArgs}; -use crate::services::storyteller::state::storyteller_credential_manager::StorytellerCredentialManager; -use enums::common::generation_provider::GenerationProvider; -use enums::tauri::tasks::task_type::TaskType; -use grok_consumer_client::credentials::grok_cookies::GrokCookies; -use grok_consumer_client::credentials::grok_full_credentials::GrokFullCredentials; -use grok_consumer_client::datatypes::api::aspect_ratio::AspectRatio; -use grok_consumer_client::datatypes::file_upload_spec::FileUploadSpec; -use grok_consumer_client::recipes::request_client_secrets::{request_client_secrets, RequestClientSecretsArgs}; -use grok_consumer_client::recipes::upload_image_and_generate_video::{upload_image_and_generate_video, UploadImageAndGenerateVideo}; -use grok_consumer_client::recipes::upload_image_and_generate_video_with_retry::{upload_image_and_generate_video_with_retry, UploadImageAndGenerateVideoWithRetry}; -use log::{error, info, warn}; -use openai_sora_client::recipes::generate_sora2_video::generate_sora2_video_with_session_auto_renew::generate_sora2_video_with_session_auto_renew; -use openai_sora_client::requests::generate_sora2_video::generate_sora2_video::{GenerateSora2VideoArgs, Orientation}; -use std::time::Duration; -use tauri::AppHandle; - -const GROK_IMAGE_UPLOAD_TIMEOUT: Duration = Duration::from_millis(1000 * 30); // 30 seconds - -pub async fn handle_grok_video( - request: &TauriGenerateVideoRequest, - app: &AppHandle, - app_data_root: &AppDataRoot, - app_env_configs: &AppEnvConfigs, - grok_credential_manager: &GrokCredentialManager, -) -> Result { - - let creds = get_grok_creds(app, grok_credential_manager).await?; - - let image_token = match request.image_media_token.as_ref() { - Some(token) => token, - None => { - return Err(GenerateError::BadInput(BadInputReason::InvalidNumberOfInputImages { min: 1, max: 1, provided: 0 })) - } - }; - - info!("Downloading image media file..."); - - let local_image_file = download_media_file_to_temp_dir( - &app_env_configs, - &app_data_root, - image_token, - ).await?; - - let aspect_ratio = match request.grok_aspect_ratio { - None => AspectRatio::WideThreeByTwo, - Some(GrokAspectRatio::Landscape) => AspectRatio::WideThreeByTwo, - Some(GrokAspectRatio::Portrait) => AspectRatio::TallTwoByThree, - Some(GrokAspectRatio::Square) => AspectRatio::Square, - }; - - info!("Calling Grok Video generate..."); - - let upload_result = upload_image_and_generate_video_with_retry(UploadImageAndGenerateVideoWithRetry { - credentials: &creds, - file: FileUploadSpec::Path(local_image_file.path()), - prompt: request.prompt.as_deref(), - aspect_ratio: Some(aspect_ratio), - wait_for_generation: false, - individual_request_timeout: Some(GROK_IMAGE_UPLOAD_TIMEOUT), - mode: None, - }).await; - - let post_id = match upload_result { - Err(err) => { - error!("Failed to use Grok video: {:?}", err); - return Err(GenerateError::from(err)); - } - Ok(result) => { - if let Some(secrets) = result.maybe_new_client_secrets { - info!("New Grok secrets generated! Storing them in the credential manager..."); - grok_credential_manager.replace_client_secrets_only(secrets)?; - } - info!("Successfully enqueued Grok Video: post_id = {:?}", result.upload_result.post_id); - result.upload_result.post_id - } - }; - - // NB: Grok's consumer API doesn't take a version selector; this only affects - // which model is recorded for the task queue / events. - let generation_model = match request.model { - Some(TauriVideoModel::GrokImagineVideo1p5) => GenerationModel::GrokImagineVideo1p5, - _ => GenerationModel::GrokVideo, - }; - - Ok(TaskEnqueueSuccess { - provider: GenerationProvider::Grok, - model: Some(generation_model), - provider_job_id: Some(post_id.to_string()), - task_type: TaskType::VideoGeneration, - maybe_queue_status_url: None, - maybe_prompt_token: None, - maybe_queue_response_url: None, - }) -} - -async fn get_grok_creds(app: &AppHandle, grok_credential_manager: &GrokCredentialManager) -> Result { - if let Some(creds) = grok_credential_manager.maybe_copy_full_credentials()? { - return Ok(creds); - } - - let cookies = match grok_credential_manager.maybe_copy_cookie_store()? { - Some(cookies) => cookies.to_cookie_string(), - None => { - warn!("No Grok Cookie stored. Must login."); - ShowProviderLoginModalEvent::send_for_provider(GenerationProvider::Grok, &app); - return Err(GenerateError::needs_grok_credentials()) - } - }; - - let cookies = GrokCookies::new(cookies); - - info!("Requesting Grok client secrets..."); - - let upgraded = request_client_secrets(RequestClientSecretsArgs { - cookies: &cookies, - }).await; - - match upgraded { - Err(err) => { - error!("Failed to fetch Grok client secrets: {}", err); // NB: Fall-through - } - Ok(secrets) => { - info!("Grok client secrets successfully upgraded..."); - let full_creds = GrokFullCredentials::from_cookies_and_client_secrets(cookies, secrets); - grok_credential_manager.replace_full_credentials(full_creds.clone())?; - info!("Persisting grok credentials to disk..."); - grok_credential_manager.persist_to_disk()?; - return Ok(full_creds) - } - } - - warn!("Grok upgrade failed. Try logging in again..."); - - ShowProviderLoginModalEvent::send_for_provider(GenerationProvider::Grok, &app); - Err(GenerateError::needs_grok_credentials()) -} diff --git a/crates/desktop/artcraft/src/core/commands/generate/generate_video/grok/mod.rs b/crates/desktop/artcraft/src/core/commands/generate/generate_video/grok/mod.rs deleted file mode 100644 index 045dcc9439..0000000000 --- a/crates/desktop/artcraft/src/core/commands/generate/generate_video/grok/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub (super) mod handle_grok_video; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/core/commands/generate/generate_video/mod.rs b/crates/desktop/artcraft/src/core/commands/generate/generate_video/mod.rs deleted file mode 100644 index f7a6a5a7f9..0000000000 --- a/crates/desktop/artcraft/src/core/commands/generate/generate_video/mod.rs +++ /dev/null @@ -1,5 +0,0 @@ -pub mod generate_video_command; -pub mod request; -mod artcraft; -mod grok; -pub mod sora2; diff --git a/crates/desktop/artcraft/src/core/commands/generate/generate_video/request.rs b/crates/desktop/artcraft/src/core/commands/generate/generate_video/request.rs deleted file mode 100644 index 4640bf4530..0000000000 --- a/crates/desktop/artcraft/src/core/commands/generate/generate_video/request.rs +++ /dev/null @@ -1,152 +0,0 @@ -use artcraft_router::api::router_aspect_ratio::RouterAspectRatio; -use artcraft_router::api::router_resolution::RouterResolution; -use enums::common::generation_provider::GenerationProvider; -use enums::tauri::ux::tauri_command_caller::TauriCommandCaller; -use serde_derive::{Deserialize, Serialize}; -use tokens::tokens::characters::CharacterToken; -use tokens::tokens::media_files::MediaFileToken; - -use crate::core::commands::response::success_response_wrapper::SerializeMarker; - -/// This is used in the Tauri command bridge. -/// Don't change the serializations without coordinating with the frontend. -/// -/// MIGRATION (2026-07): we're moving the frontend to send storyteller-web omni -/// identifiers (`CommonVideoModel` serde strings). Variants whose legacy Tauri -/// id differs carry the omni id as a `#[serde(alias)]` so BOTH deserialize. -/// Once the frontend is 100% omni ids, the legacy renames can be dropped. -#[derive(Deserialize, Debug, Copy, Clone)] -#[serde(rename_all = "snake_case")] -pub enum TauriVideoModel { - #[serde(rename = "grok_video", alias = "grok_imagine_video")] - GrokVideo, - - #[serde(rename = "grok_imagine_video_1p5")] - GrokImagineVideo1p5, - - #[serde(rename = "kling_1.6_pro", alias = "kling_1p6_pro")] - Kling16Pro, - - #[serde(rename = "kling_2.1_pro", alias = "kling_2p1_pro")] - Kling21Pro, - - #[serde(rename = "kling_2.1_master", alias = "kling_2p1_master")] - Kling21Master, - - #[serde(rename = "kling_2p5_turbo_pro")] - Kling2p5TurboPro, - - #[serde(rename = "kling_2p6_pro")] - Kling2p6Pro, - - #[serde(rename = "kling_3p0_standard")] - Kling3p0Standard, - - #[serde(rename = "kling_3p0_pro")] - Kling3p0Pro, - - #[serde(rename = "happy_horse_1p0")] - HappyHorse1p0, - - #[serde(rename = "seedance_1.0_lite", alias = "seedance_1p0_lite")] - Seedance10Lite, - - #[serde(rename = "seedance_1p5_pro")] - Seedance1p5Pro, - - #[serde(rename = "seedance_2p0")] - Seedance2p0, - - #[serde(rename = "seedance_2p0_fast")] - Seedance2p0Fast, - - #[serde(rename = "sora_2")] - Sora2, - - #[serde(rename = "sora_2_pro")] - Sora2Pro, - - #[serde(rename = "veo_2")] - Veo2, - - #[serde(rename = "veo_3")] - Veo3, - - #[serde(rename = "veo_3_fast")] - Veo3Fast, - - #[serde(rename = "veo_3p1")] - Veo3p1, - - #[serde(rename = "veo_3p1_fast")] - Veo3p1Fast, -} - -#[derive(Deserialize, Debug, Clone)] -pub struct TauriGenerateVideoRequest { - pub provider: Option, - pub model: Option, - - pub prompt: Option, - pub negative_prompt: Option, - - #[deprecated(note = "Use start_frame_image_media_token instead")] - pub image_media_token: Option, - - pub start_frame_image_media_token: Option, - pub end_frame_image_media_token: Option, - - pub reference_image_media_tokens: Option>, - pub reference_video_media_tokens: Option>, - pub reference_audio_media_tokens: Option>, - pub reference_character_tokens: Option>, - - pub aspect_ratio: Option, - pub resolution: Option, - - pub duration_seconds: Option, - pub generate_audio: Option, - pub video_batch_count: Option, - - #[deprecated(note = "Use start_frame_image_media_token instead")] - pub sora_orientation: Option, - - #[deprecated(note = "Use start_frame_image_media_token instead")] - pub grok_aspect_ratio: Option, - - pub frontend_caller: Option, - pub frontend_subscriber_id: Option, - pub frontend_subscriber_payload: Option, -} - -#[derive(Deserialize, Debug, Clone, Copy)] -#[serde(rename_all = "snake_case")] -pub enum SoraOrientation { - Portrait, - Landscape, -} - -#[derive(Deserialize, Debug, Clone, Copy)] -#[serde(rename_all = "snake_case")] -pub enum GrokAspectRatio { - Portrait, - Landscape, - Square, -} - -#[derive(Serialize)] -pub struct TauriGenerateVideoResponse { -} - -impl SerializeMarker for TauriGenerateVideoResponse {} - -#[derive(Serialize, Debug)] -#[serde(rename_all = "snake_case")] -pub enum TauriGenerateVideoErrorType { - ModelNotSpecified, - NoProviderAvailable, - ServerError, - NeedsFalApiKey, - FalError, - NeedsStorytellerCredentials, -} diff --git a/crates/desktop/artcraft/src/core/commands/generate/generate_video/sora2/handle_sora_sora2.rs b/crates/desktop/artcraft/src/core/commands/generate/generate_video/sora2/handle_sora_sora2.rs deleted file mode 100644 index 48321dd2fa..0000000000 --- a/crates/desktop/artcraft/src/core/commands/generate/generate_video/sora2/handle_sora_sora2.rs +++ /dev/null @@ -1,106 +0,0 @@ -use crate::core::commands::enqueue::generate_error::GenerateError; -use crate::core::commands::generate::generate_video::request::{TauriGenerateVideoRequest, SoraOrientation}; -use crate::core::commands::enqueue::task_enqueue_success::TaskEnqueueSuccess; -use crate::core::events::functional_events::show_provider_login_modal_event::ShowProviderLoginModalEvent; -use crate::core::events::generation_events::common::GenerationModel; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::services::sora::state::sora_credential_manager::SoraCredentialManager; -use crate::services::sora::state::sora_task_queue::SoraTaskQueue; -use crate::services::sora::utils::upload_images_to_sora::{upload_images_to_sora, UploadImagesToSoraArgs, UploadImagesToSoraResult}; -use crate::services::storyteller::state::storyteller_credential_manager::StorytellerCredentialManager; -use enums::common::generation_provider::GenerationProvider; -use enums::tauri::tasks::task_type::TaskType; -use log::{error, info}; -use openai_sora_client::recipes::generate_sora2_video::generate_sora2_video_with_session_auto_renew::generate_sora2_video_with_session_auto_renew; -use openai_sora_client::recipes::list_sora2_drafts::list_sora2_drafts_with_session_auto_renew::list_sora2_drafts_with_session_auto_renew; -use openai_sora_client::requests::generate_sora2_video::generate_sora2_video::{GenerateSora2VideoArgs, Orientation}; -use tauri::AppHandle; -use tokens::tokens::media_files::MediaFileToken; - -#[deprecated(note = "Legacy direct-provider handler; desktop generation now uses ArtCraft.")] -pub async fn handle_sora_sora2( - request: &TauriGenerateVideoRequest, - app: &AppHandle, - app_data_root: &AppDataRoot, - app_env_configs: &AppEnvConfigs, - sora_creds_manager: &SoraCredentialManager, -) -> Result { - - let mut sora_creds = match sora_creds_manager.get_credentials()? { - Some(creds) => creds, - None => { - ShowProviderLoginModalEvent::send_for_provider(GenerationProvider::Sora, &app); - return Err(GenerateError::needs_sora_credentials()); - }, - }; - - // TODO: Handle multiple input images. - let image_media_tokens = match &request.image_media_token { - Some(token) => vec![token.clone()], - None => vec![], - }; - - let mut image_reference_media_ids = None; - - if !image_media_tokens.is_empty() { - let result = upload_images_to_sora(UploadImagesToSoraArgs { - storyteller_host: &app_env_configs.storyteller_host, - image_media_tokens: &image_media_tokens, - app_data_root, - sora_creds_manager, - }).await?; - - if let Some(creds) = result.maybe_new_sora_credentials { - sora_creds = creds; - } - - image_reference_media_ids = Some(result.sora_media_tokens); - } - - let orientation = match request.sora_orientation { - Some(SoraOrientation::Landscape) => Orientation::Landscape, - Some(SoraOrientation::Portrait) => Orientation::Portrait, - None => Orientation::Landscape, - }; - - info!("Calling Sora 2 generate..."); - - let result = generate_sora2_video_with_session_auto_renew( - GenerateSora2VideoArgs { - prompt: request.prompt.as_deref().unwrap_or(""), - credentials: &sora_creds, - request_timeout: None, - orientation, - image_reference_media_ids: image_reference_media_ids.as_ref(), - } - ).await; - - let job_id = match result { - Ok((response, maybe_new_session)) => { - info!("Successfully enqueued Sora2 Video: {}", response.task_id); - - if let Some(new_creds) = maybe_new_session { - if let Err(err) = sora_creds_manager.set_credentials(&new_creds) { - error!("Failed to save renewed Sora credentials: {:?}", err); - } - } - - response.task_id - } - Err(err) => { - error!("Failed to use Sora2 video: {:?}", err); - return Err(GenerateError::from(err)); - } - }; - - Ok(TaskEnqueueSuccess { - provider: GenerationProvider::Sora, - model: Some(GenerationModel::Sora2), - provider_job_id: Some(job_id.to_string()), - task_type: TaskType::VideoGeneration, - maybe_queue_status_url: None, - maybe_prompt_token: None, - maybe_queue_response_url: None, - }) -} diff --git a/crates/desktop/artcraft/src/core/commands/generate/generate_video/sora2/mod.rs b/crates/desktop/artcraft/src/core/commands/generate/generate_video/sora2/mod.rs deleted file mode 100644 index 8a58d2038c..0000000000 --- a/crates/desktop/artcraft/src/core/commands/generate/generate_video/sora2/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub (super) mod handle_sora_sora2; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/core/commands/generate/mod.rs b/crates/desktop/artcraft/src/core/commands/generate/mod.rs deleted file mode 100644 index b7caf159b3..0000000000 --- a/crates/desktop/artcraft/src/core/commands/generate/mod.rs +++ /dev/null @@ -1,9 +0,0 @@ -pub mod generate_image; -pub mod generate_video; -pub mod common; -pub mod models; -pub mod omni; - -pub mod generate_mesh_command; -pub mod generate_splat_command; -pub mod generate_audio_command; diff --git a/crates/desktop/artcraft/src/core/commands/generate/models/image/list_image_models_command.rs b/crates/desktop/artcraft/src/core/commands/generate/models/image/list_image_models_command.rs deleted file mode 100644 index 214c8ffcb1..0000000000 --- a/crates/desktop/artcraft/src/core/commands/generate/models/image/list_image_models_command.rs +++ /dev/null @@ -1,98 +0,0 @@ -//! Tauri command: list available image models. -//! -//! Maps the API-client response into command-specific types (see `response_types`), -//! retries the request up to `MAX_ATTEMPTS` times, and caches successful responses -//! in-memory for `CACHE_TTL`. - -use std::sync::RwLock; -use std::time::{Duration, Instant}; - -use log::{debug, warn}; -use once_cell::sync::Lazy; -use tauri::State; - -use artcraft_client::endpoints::omni_gen::models::image::omni_gen_list_image_models::{omni_gen_list_image_models, OmniGenListImageModelsArgs, OmniGenImageModelsResponse}; -use artcraft_client::utils::api_host::ApiHost; - -use crate::core::commands::generate::models::image::response_types::ListImageModelsResponse; -use crate::core::commands::response::shorthand::ResponseOrErrorMessage; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; - -const MAX_ATTEMPTS: u32 = 3; -const RETRY_BACKOFF: Duration = Duration::from_millis(250); -const CACHE_TTL: Duration = Duration::from_secs(60); - -struct CacheEntry { - response: ListImageModelsResponse, - loaded_at: Instant, -} - -static CACHE: Lazy>> = Lazy::new(|| RwLock::new(None)); - - -#[tauri::command] -pub async fn list_image_models_command( - app_env_configs: State<'_, AppEnvConfigs>, -) -> ResponseOrErrorMessage { - if let Some(cached) = cached_response() { - debug!("list_image_models_command: serving cached response"); - return Ok(cached.into()); - } - - match fetch_with_retry(&app_env_configs.storyteller_host).await { - Ok(api_response) => { - let response: ListImageModelsResponse = api_response.into(); - store_response(response.clone()); - Ok(response.into()) - } - Err(error_message) => { - warn!("list_image_models_command failed after {} attempts: {}", MAX_ATTEMPTS, error_message); - if let Some(stale) = any_cached_response() { - warn!("list_image_models_command: refresh failed; serving stale cached response"); - return Ok(stale.into()); - } - Err(error_message.into()) - } - } -} - -fn cached_response() -> Option { - let guard = CACHE.read().ok()?; - let entry = guard.as_ref()?; - if entry.loaded_at.elapsed() < CACHE_TTL { - Some(entry.response.clone()) - } else { - None - } -} - -/// The cached response regardless of age. Used as a fallback so that a failed -/// refresh still returns the last-known-good data instead of an error. -fn any_cached_response() -> Option { - let guard = CACHE.read().ok()?; - guard.as_ref().map(|entry| entry.response.clone()) -} - -fn store_response(response: ListImageModelsResponse) { - if let Ok(mut guard) = CACHE.write() { - *guard = Some(CacheEntry { response, loaded_at: Instant::now() }); - } -} - -/// Fetch the models list, retrying up to `MAX_ATTEMPTS` times on failure. -async fn fetch_with_retry(api_host: &ApiHost) -> Result { - let mut last_error = "unknown error".to_string(); - for attempt in 1..=MAX_ATTEMPTS { - match omni_gen_list_image_models(OmniGenListImageModelsArgs { api_host, maybe_creds: None, provider: None }).await { - Ok(response) => return Ok(response), - Err(err) => { - last_error = err.to_string(); - warn!("list_image_models attempt {}/{} failed: {}", attempt, MAX_ATTEMPTS, last_error); - if attempt < MAX_ATTEMPTS { - tokio::time::sleep(RETRY_BACKOFF).await; - } - } - } - } - Err(last_error) -} diff --git a/crates/desktop/artcraft/src/core/commands/generate/models/image/mod.rs b/crates/desktop/artcraft/src/core/commands/generate/models/image/mod.rs deleted file mode 100644 index fe780e0bea..0000000000 --- a/crates/desktop/artcraft/src/core/commands/generate/models/image/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod list_image_models_command; -pub mod response_types; diff --git a/crates/desktop/artcraft/src/core/commands/generate/models/image/response_types.rs b/crates/desktop/artcraft/src/core/commands/generate/models/image/response_types.rs deleted file mode 100644 index dfd7ac7321..0000000000 --- a/crates/desktop/artcraft/src/core/commands/generate/models/image/response_types.rs +++ /dev/null @@ -1,554 +0,0 @@ -//! Command-specific response types for `list_image_models_command`. -//! -//! These are duplicated (never `artcraft_client` types), and every enum has an -//! `Unknown(String)` catch-all so newer server variants are preserved instead of -//! breaking an older desktop build. `From` impls map the API-client response over. - -use serde_derive::Serialize; - -use artcraft_client::datatypes::common_enums::generation::api_client_generation_provider::ApiClientGenerationProvider; -use artcraft_client::datatypes::common_enums::generation::api_client_model_creator::ApiClientModelCreator; -use artcraft_client::datatypes::common_enums::generation::api_client_image_model::ApiClientImageModel; -use artcraft_client::datatypes::common_enums::generation::api_client_aspect_ratio::ApiClientAspectRatio; -use artcraft_client::datatypes::common_enums::generation::api_client_resolution::ApiClientResolution; -use artcraft_client::datatypes::common_enums::generation::api_client_quality::ApiClientQuality; -use artcraft_client::endpoints::omni_gen::models::image::omni_gen_list_image_models::{ - OmniGenImageModelDetails, OmniGenImageModelProviderDetails, OmniGenImageProviderModelDetails, OmniGenImageModelsResponse, -}; - -use crate::core::commands::response::success_response_wrapper::SerializeMarker; - -impl SerializeMarker for ListImageModelsResponse {} - -// ============================ Enums ============================ - -/// Command-specific copy of `ApiClientGenerationProvider` with an `Unknown` catch-all so newer -/// server variants are preserved rather than dropped. -#[derive(Clone, Debug, PartialEq, Eq, Serialize)] -#[serde(into = "String")] -pub enum ListImageModelsProvider { - Artcraft, - Fal, - Grok, - Midjourney, - Sora, - WorldLabs, - Higgsfield, - Krea, - Leonardo, - Magnific, - Openart, - Picsart, - Pixverse, - Runway, - Unknown(String), -} - -impl From for ListImageModelsProvider { - fn from(value: ApiClientGenerationProvider) -> Self { - match value { - ApiClientGenerationProvider::Artcraft => Self::Artcraft, - ApiClientGenerationProvider::Fal => Self::Fal, - ApiClientGenerationProvider::Grok => Self::Grok, - ApiClientGenerationProvider::Midjourney => Self::Midjourney, - ApiClientGenerationProvider::Sora => Self::Sora, - ApiClientGenerationProvider::WorldLabs => Self::WorldLabs, - ApiClientGenerationProvider::Higgsfield => Self::Higgsfield, - ApiClientGenerationProvider::Krea => Self::Krea, - ApiClientGenerationProvider::Leonardo => Self::Leonardo, - ApiClientGenerationProvider::Magnific => Self::Magnific, - ApiClientGenerationProvider::Openart => Self::Openart, - ApiClientGenerationProvider::Picsart => Self::Picsart, - ApiClientGenerationProvider::Pixverse => Self::Pixverse, - ApiClientGenerationProvider::Runway => Self::Runway, - ApiClientGenerationProvider::Unknown(other) => Self::Unknown(other), - } - } -} - -impl From for String { - fn from(value: ListImageModelsProvider) -> Self { - match value { - ListImageModelsProvider::Artcraft => "artcraft".to_string(), - ListImageModelsProvider::Fal => "fal".to_string(), - ListImageModelsProvider::Grok => "grok".to_string(), - ListImageModelsProvider::Midjourney => "midjourney".to_string(), - ListImageModelsProvider::Sora => "sora".to_string(), - ListImageModelsProvider::WorldLabs => "world_labs".to_string(), - ListImageModelsProvider::Higgsfield => "higgsfield".to_string(), - ListImageModelsProvider::Krea => "krea".to_string(), - ListImageModelsProvider::Leonardo => "leonardo".to_string(), - ListImageModelsProvider::Magnific => "magnific".to_string(), - ListImageModelsProvider::Openart => "openart".to_string(), - ListImageModelsProvider::Picsart => "picsart".to_string(), - ListImageModelsProvider::Pixverse => "pixverse".to_string(), - ListImageModelsProvider::Runway => "runway".to_string(), - ListImageModelsProvider::Unknown(other) => other, - } - } -} - -/// Command-specific copy of `ApiClientModelCreator` with an `Unknown` catch-all so newer -/// server variants are preserved rather than dropped. -#[derive(Clone, Debug, PartialEq, Eq, Serialize)] -#[serde(into = "String")] -pub enum ListImageModelsModelCreator { - Alibaba, - ArtCraft, - BlackForestLabs, - Bytedance, - Fal, - Google, - Grok, - Hailuo, - Higgsfield, - Kling, - Krea, - Midjourney, - OpenAi, - OpenArt, - Recraft, - Replicate, - Runway, - Stability, - Tencent, - TensorArt, - Vidu, - WorldLabs, - Unknown(String), -} - -impl From for ListImageModelsModelCreator { - fn from(value: ApiClientModelCreator) -> Self { - match value { - ApiClientModelCreator::Alibaba => Self::Alibaba, - ApiClientModelCreator::ArtCraft => Self::ArtCraft, - ApiClientModelCreator::BlackForestLabs => Self::BlackForestLabs, - ApiClientModelCreator::Bytedance => Self::Bytedance, - ApiClientModelCreator::Fal => Self::Fal, - ApiClientModelCreator::Google => Self::Google, - ApiClientModelCreator::Grok => Self::Grok, - ApiClientModelCreator::Hailuo => Self::Hailuo, - ApiClientModelCreator::Higgsfield => Self::Higgsfield, - ApiClientModelCreator::Kling => Self::Kling, - ApiClientModelCreator::Krea => Self::Krea, - ApiClientModelCreator::Midjourney => Self::Midjourney, - ApiClientModelCreator::OpenAi => Self::OpenAi, - ApiClientModelCreator::OpenArt => Self::OpenArt, - ApiClientModelCreator::Recraft => Self::Recraft, - ApiClientModelCreator::Replicate => Self::Replicate, - ApiClientModelCreator::Runway => Self::Runway, - ApiClientModelCreator::Stability => Self::Stability, - ApiClientModelCreator::Tencent => Self::Tencent, - ApiClientModelCreator::TensorArt => Self::TensorArt, - ApiClientModelCreator::Vidu => Self::Vidu, - ApiClientModelCreator::WorldLabs => Self::WorldLabs, - ApiClientModelCreator::Unknown(other) => Self::Unknown(other), - } - } -} - -impl From for String { - fn from(value: ListImageModelsModelCreator) -> Self { - match value { - ListImageModelsModelCreator::Alibaba => "alibaba".to_string(), - ListImageModelsModelCreator::ArtCraft => "artcraft".to_string(), - ListImageModelsModelCreator::BlackForestLabs => "black_forest_labs".to_string(), - ListImageModelsModelCreator::Bytedance => "bytedance".to_string(), - ListImageModelsModelCreator::Fal => "fal".to_string(), - ListImageModelsModelCreator::Google => "google".to_string(), - ListImageModelsModelCreator::Grok => "grok".to_string(), - ListImageModelsModelCreator::Hailuo => "hailuo".to_string(), - ListImageModelsModelCreator::Higgsfield => "higgsfield".to_string(), - ListImageModelsModelCreator::Kling => "kling".to_string(), - ListImageModelsModelCreator::Krea => "krea".to_string(), - ListImageModelsModelCreator::Midjourney => "midjourney".to_string(), - ListImageModelsModelCreator::OpenAi => "open_ai".to_string(), - ListImageModelsModelCreator::OpenArt => "open_art".to_string(), - ListImageModelsModelCreator::Recraft => "recraft".to_string(), - ListImageModelsModelCreator::Replicate => "replicate".to_string(), - ListImageModelsModelCreator::Runway => "runway".to_string(), - ListImageModelsModelCreator::Stability => "stability".to_string(), - ListImageModelsModelCreator::Tencent => "tencent".to_string(), - ListImageModelsModelCreator::TensorArt => "tensor_art".to_string(), - ListImageModelsModelCreator::Vidu => "vidu".to_string(), - ListImageModelsModelCreator::WorldLabs => "world_labs".to_string(), - ListImageModelsModelCreator::Unknown(other) => other, - } - } -} - -/// Command-specific copy of `ApiClientImageModel` with an `Unknown` catch-all so newer -/// server variants are preserved rather than dropped. -#[derive(Clone, Debug, PartialEq, Eq, Serialize)] -#[serde(into = "String")] -pub enum ListImageModelsImageModel { - Flux1Dev, - Flux1Schnell, - FluxPro11, - FluxPro11Ultra, - GptImage1, - GptImage1p5, - GptImage2, - GrokImagineImage, - GptImage2p5Flare, - GptImage2p5Sunburst, - GrokImagineImageQuality, - Midjourney7, - Midjourney7Niji, - Midjourney8, - NanoBanana, - NanoBanana2, - NanoBananaPro, - Seedream4, - Seedream4p5, - Seedream5Lite, - QwenEdit2511Angles, - Flux2LoraAngles, - Unknown(String), -} - -impl From for ListImageModelsImageModel { - fn from(value: ApiClientImageModel) -> Self { - match value { - ApiClientImageModel::Flux1Dev => Self::Flux1Dev, - ApiClientImageModel::Flux1Schnell => Self::Flux1Schnell, - ApiClientImageModel::FluxPro11 => Self::FluxPro11, - ApiClientImageModel::FluxPro11Ultra => Self::FluxPro11Ultra, - ApiClientImageModel::GptImage1 => Self::GptImage1, - ApiClientImageModel::GptImage1p5 => Self::GptImage1p5, - ApiClientImageModel::GptImage2 => Self::GptImage2, - ApiClientImageModel::GptImage2p5Flare => Self::GptImage2p5Flare, - ApiClientImageModel::GptImage2p5Sunburst => Self::GptImage2p5Sunburst, - ApiClientImageModel::GrokImagineImage => Self::GrokImagineImage, - ApiClientImageModel::GrokImagineImageQuality => Self::GrokImagineImageQuality, - ApiClientImageModel::Midjourney7 => Self::Midjourney7, - ApiClientImageModel::Midjourney7Niji => Self::Midjourney7Niji, - ApiClientImageModel::Midjourney8 => Self::Midjourney8, - ApiClientImageModel::NanoBanana => Self::NanoBanana, - ApiClientImageModel::NanoBanana2 => Self::NanoBanana2, - ApiClientImageModel::NanoBananaPro => Self::NanoBananaPro, - ApiClientImageModel::Seedream4 => Self::Seedream4, - ApiClientImageModel::Seedream4p5 => Self::Seedream4p5, - ApiClientImageModel::Seedream5Lite => Self::Seedream5Lite, - ApiClientImageModel::QwenEdit2511Angles => Self::QwenEdit2511Angles, - ApiClientImageModel::Flux2LoraAngles => Self::Flux2LoraAngles, - ApiClientImageModel::Unknown(other) => Self::Unknown(other), - } - } -} - -impl From for String { - fn from(value: ListImageModelsImageModel) -> Self { - match value { - ListImageModelsImageModel::Flux1Dev => "flux_1_dev".to_string(), - ListImageModelsImageModel::Flux1Schnell => "flux_1_schnell".to_string(), - ListImageModelsImageModel::FluxPro11 => "flux_pro_1p1".to_string(), - ListImageModelsImageModel::FluxPro11Ultra => "flux_pro_1p1_ultra".to_string(), - ListImageModelsImageModel::GptImage1 => "gpt_image_1".to_string(), - ListImageModelsImageModel::GptImage1p5 => "gpt_image_1p5".to_string(), - ListImageModelsImageModel::GptImage2 => "gpt_image_2".to_string(), - ListImageModelsImageModel::GptImage2p5Flare => "gpt_image_2p5_flare".to_string(), - ListImageModelsImageModel::GptImage2p5Sunburst => "gpt_image_2p5_sunburst".to_string(), - ListImageModelsImageModel::GrokImagineImage => "grok_imagine_image".to_string(), - ListImageModelsImageModel::GrokImagineImageQuality => "grok_imagine_image_q".to_string(), - ListImageModelsImageModel::Midjourney7 => "midjourney_7".to_string(), - ListImageModelsImageModel::Midjourney7Niji => "midjourney_7_niji".to_string(), - ListImageModelsImageModel::Midjourney8 => "midjourney_8".to_string(), - ListImageModelsImageModel::NanoBanana => "nano_banana".to_string(), - ListImageModelsImageModel::NanoBanana2 => "nano_banana_2".to_string(), - ListImageModelsImageModel::NanoBananaPro => "nano_banana_pro".to_string(), - ListImageModelsImageModel::Seedream4 => "seedream_4".to_string(), - ListImageModelsImageModel::Seedream4p5 => "seedream_4p5".to_string(), - ListImageModelsImageModel::Seedream5Lite => "seedream_5_lite".to_string(), - ListImageModelsImageModel::QwenEdit2511Angles => "qwen_edit_2511_angles".to_string(), - ListImageModelsImageModel::Flux2LoraAngles => "flux_2_lora_angles".to_string(), - ListImageModelsImageModel::Unknown(other) => other, - } - } -} - -/// Command-specific copy of `ApiClientAspectRatio` with an `Unknown` catch-all so newer -/// server variants are preserved rather than dropped. -#[derive(Clone, Debug, PartialEq, Eq, Serialize)] -#[serde(into = "String")] -pub enum ListImageModelsAspectRatio { - Auto, - Square, - WideThreeByTwo, - WideFourByThree, - WideFiveByFour, - WideSixteenByNine, - WideTwentyOneByNine, - TallTwoByThree, - TallThreeByFour, - TallFourByFive, - TallNineBySixteen, - TallNineByTwentyOne, - Wide, - Tall, - Auto2k, - Auto3k, - Auto4k, - SquareHd, - Unknown(String), -} - -impl From for ListImageModelsAspectRatio { - fn from(value: ApiClientAspectRatio) -> Self { - match value { - ApiClientAspectRatio::Auto => Self::Auto, - ApiClientAspectRatio::Square => Self::Square, - ApiClientAspectRatio::WideThreeByTwo => Self::WideThreeByTwo, - ApiClientAspectRatio::WideFourByThree => Self::WideFourByThree, - ApiClientAspectRatio::WideFiveByFour => Self::WideFiveByFour, - ApiClientAspectRatio::WideSixteenByNine => Self::WideSixteenByNine, - ApiClientAspectRatio::WideTwentyOneByNine => Self::WideTwentyOneByNine, - ApiClientAspectRatio::TallTwoByThree => Self::TallTwoByThree, - ApiClientAspectRatio::TallThreeByFour => Self::TallThreeByFour, - ApiClientAspectRatio::TallFourByFive => Self::TallFourByFive, - ApiClientAspectRatio::TallNineBySixteen => Self::TallNineBySixteen, - ApiClientAspectRatio::TallNineByTwentyOne => Self::TallNineByTwentyOne, - ApiClientAspectRatio::Wide => Self::Wide, - ApiClientAspectRatio::Tall => Self::Tall, - ApiClientAspectRatio::Auto2k => Self::Auto2k, - ApiClientAspectRatio::Auto3k => Self::Auto3k, - ApiClientAspectRatio::Auto4k => Self::Auto4k, - ApiClientAspectRatio::SquareHd => Self::SquareHd, - ApiClientAspectRatio::Unknown(other) => Self::Unknown(other), - } - } -} - -impl From for String { - fn from(value: ListImageModelsAspectRatio) -> Self { - match value { - ListImageModelsAspectRatio::Auto => "auto".to_string(), - ListImageModelsAspectRatio::Square => "square".to_string(), - ListImageModelsAspectRatio::WideThreeByTwo => "wide_three_by_two".to_string(), - ListImageModelsAspectRatio::WideFourByThree => "wide_four_by_three".to_string(), - ListImageModelsAspectRatio::WideFiveByFour => "wide_five_by_four".to_string(), - ListImageModelsAspectRatio::WideSixteenByNine => "wide_sixteen_by_nine".to_string(), - ListImageModelsAspectRatio::WideTwentyOneByNine => "wide_twenty_one_by_nine".to_string(), - ListImageModelsAspectRatio::TallTwoByThree => "tall_two_by_three".to_string(), - ListImageModelsAspectRatio::TallThreeByFour => "tall_three_by_four".to_string(), - ListImageModelsAspectRatio::TallFourByFive => "tall_four_by_five".to_string(), - ListImageModelsAspectRatio::TallNineBySixteen => "tall_nine_by_sixteen".to_string(), - ListImageModelsAspectRatio::TallNineByTwentyOne => "tall_nine_by_twenty_one".to_string(), - ListImageModelsAspectRatio::Wide => "wide".to_string(), - ListImageModelsAspectRatio::Tall => "tall".to_string(), - ListImageModelsAspectRatio::Auto2k => "auto_2k".to_string(), - ListImageModelsAspectRatio::Auto3k => "auto_3k".to_string(), - ListImageModelsAspectRatio::Auto4k => "auto_4k".to_string(), - ListImageModelsAspectRatio::SquareHd => "square_hd".to_string(), - ListImageModelsAspectRatio::Unknown(other) => other, - } - } -} - -/// Command-specific copy of `ApiClientResolution` with an `Unknown` catch-all so newer -/// server variants are preserved rather than dropped. -#[derive(Clone, Debug, PartialEq, Eq, Serialize)] -#[serde(into = "String")] -pub enum ListImageModelsResolution { - OneK, - TwoK, - ThreeK, - FourK, - HalfK, - FourEightyP, - SevenTwentyP, - TenEightyP, - Unknown(String), -} - -impl From for ListImageModelsResolution { - fn from(value: ApiClientResolution) -> Self { - match value { - ApiClientResolution::OneK => Self::OneK, - ApiClientResolution::TwoK => Self::TwoK, - ApiClientResolution::ThreeK => Self::ThreeK, - ApiClientResolution::FourK => Self::FourK, - ApiClientResolution::HalfK => Self::HalfK, - ApiClientResolution::FourEightyP => Self::FourEightyP, - ApiClientResolution::SevenTwentyP => Self::SevenTwentyP, - ApiClientResolution::TenEightyP => Self::TenEightyP, - ApiClientResolution::Unknown(other) => Self::Unknown(other), - } - } -} - -impl From for String { - fn from(value: ListImageModelsResolution) -> Self { - match value { - ListImageModelsResolution::OneK => "one_k".to_string(), - ListImageModelsResolution::TwoK => "two_k".to_string(), - ListImageModelsResolution::ThreeK => "three_k".to_string(), - ListImageModelsResolution::FourK => "four_k".to_string(), - ListImageModelsResolution::HalfK => "half_k".to_string(), - ListImageModelsResolution::FourEightyP => "four_eighty_p".to_string(), - ListImageModelsResolution::SevenTwentyP => "seven_twenty_p".to_string(), - ListImageModelsResolution::TenEightyP => "ten_eighty_p".to_string(), - ListImageModelsResolution::Unknown(other) => other, - } - } -} - -/// Command-specific copy of `ApiClientQuality` with an `Unknown` catch-all so newer -/// server variants are preserved rather than dropped. -#[derive(Clone, Debug, PartialEq, Eq, Serialize)] -#[serde(into = "String")] -pub enum ListImageModelsQuality { - High, - Medium, - Low, - Unknown(String), -} - -impl From for ListImageModelsQuality { - fn from(value: ApiClientQuality) -> Self { - match value { - ApiClientQuality::High => Self::High, - ApiClientQuality::Medium => Self::Medium, - ApiClientQuality::Low => Self::Low, - ApiClientQuality::Unknown(other) => Self::Unknown(other), - } - } -} - -impl From for String { - fn from(value: ListImageModelsQuality) -> Self { - match value { - ListImageModelsQuality::High => "high".to_string(), - ListImageModelsQuality::Medium => "medium".to_string(), - ListImageModelsQuality::Low => "low".to_string(), - ListImageModelsQuality::Unknown(other) => other, - } - } -} - -// ============================ Structs ============================ - -#[derive(Clone, Debug, Serialize)] -pub struct ListImageModelsResponse { - pub success: bool, - pub models: Vec, - pub providers: Vec, -} - -impl From for ListImageModelsResponse { - fn from(v: OmniGenImageModelsResponse) -> Self { - Self { - success: v.success, - models: v.models.into_iter().map(Into::into).collect(), - providers: v.providers.into_iter().map(Into::into).collect(), - } - } -} - -#[derive(Clone, Debug, Serialize)] -pub struct ListImageModelsProviderDetails { - pub provider: ListImageModelsProvider, - pub models: Vec, -} - -impl From for ListImageModelsProviderDetails { - fn from(v: OmniGenImageModelProviderDetails) -> Self { - Self { - provider: v.provider.into(), - models: v.models.into_iter().map(Into::into).collect(), - } - } -} - -#[derive(Clone, Debug, Serialize)] -pub struct ListImageModelsProviderModelDetails { - pub model: ListImageModelsImageModel, - #[serde(skip_serializing_if = "Option::is_none")] - pub overrides: Option, -} - -impl From for ListImageModelsProviderModelDetails { - fn from(v: OmniGenImageProviderModelDetails) -> Self { - Self { - model: v.model.into(), - overrides: v.overrides.map(Into::into), - } - } -} - -#[derive(Clone, Debug, Serialize)] -pub struct ListImageModelsModelDetails { - pub model: ListImageModelsImageModel, - #[serde(skip_serializing_if = "Option::is_none")] - pub model_creator: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub full_name: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub text_prompt_supported: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub text_prompt_max_length: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub negative_text_prompt_supported: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub negative_text_prompt_max_length: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub image_refs_supported: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub image_refs_max: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub has_fixed_editing_aspect_ratio: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub aspect_ratio_options: Option>, - #[serde(skip_serializing_if = "Option::is_none")] - pub aspect_ratio_default: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub aspect_ratio_default_when_editing: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub resolution_options: Option>, - #[serde(skip_serializing_if = "Option::is_none")] - pub resolution_default: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub quality_options: Option>, - #[serde(skip_serializing_if = "Option::is_none")] - pub default_quality: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub batch_size_min: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub batch_size_max: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub batch_size_options: Option>, - #[serde(skip_serializing_if = "Option::is_none")] - pub batch_size_default: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub is_disabled: Option, -} - -impl From for ListImageModelsModelDetails { - fn from(v: OmniGenImageModelDetails) -> Self { - Self { - model: v.model.into(), - model_creator: v.model_creator.map(Into::into), - full_name: v.full_name, - text_prompt_supported: v.text_prompt_supported, - text_prompt_max_length: v.text_prompt_max_length, - negative_text_prompt_supported: v.negative_text_prompt_supported, - negative_text_prompt_max_length: v.negative_text_prompt_max_length, - image_refs_supported: v.image_refs_supported, - image_refs_max: v.image_refs_max, - has_fixed_editing_aspect_ratio: v.has_fixed_editing_aspect_ratio, - aspect_ratio_options: v.aspect_ratio_options.map(|items| items.into_iter().map(Into::into).collect()), - aspect_ratio_default: v.aspect_ratio_default.map(Into::into), - aspect_ratio_default_when_editing: v.aspect_ratio_default_when_editing.map(Into::into), - resolution_options: v.resolution_options.map(|items| items.into_iter().map(Into::into).collect()), - resolution_default: v.resolution_default.map(Into::into), - quality_options: v.quality_options.map(|items| items.into_iter().map(Into::into).collect()), - default_quality: v.default_quality.map(Into::into), - batch_size_min: v.batch_size_min, - batch_size_max: v.batch_size_max, - batch_size_options: v.batch_size_options, - batch_size_default: v.batch_size_default, - is_disabled: v.is_disabled, - } - } -} diff --git a/crates/desktop/artcraft/src/core/commands/generate/models/mod.rs b/crates/desktop/artcraft/src/core/commands/generate/models/mod.rs deleted file mode 100644 index c10a6ca15e..0000000000 --- a/crates/desktop/artcraft/src/core/commands/generate/models/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod image; -pub mod video; diff --git a/crates/desktop/artcraft/src/core/commands/generate/models/video/list_video_models_command.rs b/crates/desktop/artcraft/src/core/commands/generate/models/video/list_video_models_command.rs deleted file mode 100644 index 79dfde8cda..0000000000 --- a/crates/desktop/artcraft/src/core/commands/generate/models/video/list_video_models_command.rs +++ /dev/null @@ -1,98 +0,0 @@ -//! Tauri command: list available video models. -//! -//! Maps the API-client response into command-specific types (see `response_types`), -//! retries the request up to `MAX_ATTEMPTS` times, and caches successful responses -//! in-memory for `CACHE_TTL`. - -use std::sync::RwLock; -use std::time::{Duration, Instant}; - -use log::{debug, warn}; -use once_cell::sync::Lazy; -use tauri::State; - -use artcraft_client::endpoints::omni_gen::models::video::omni_gen_list_video_models::{omni_gen_list_video_models, OmniGenListVideoModelsArgs, OmniGenVideoModelsResponse}; -use artcraft_client::utils::api_host::ApiHost; - -use crate::core::commands::generate::models::video::response_types::ListVideoModelsResponse; -use crate::core::commands::response::shorthand::ResponseOrErrorMessage; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; - -const MAX_ATTEMPTS: u32 = 3; -const RETRY_BACKOFF: Duration = Duration::from_millis(250); -const CACHE_TTL: Duration = Duration::from_secs(60); - -struct CacheEntry { - response: ListVideoModelsResponse, - loaded_at: Instant, -} - -static CACHE: Lazy>> = Lazy::new(|| RwLock::new(None)); - - -#[tauri::command] -pub async fn list_video_models_command( - app_env_configs: State<'_, AppEnvConfigs>, -) -> ResponseOrErrorMessage { - if let Some(cached) = cached_response() { - debug!("list_video_models_command: serving cached response"); - return Ok(cached.into()); - } - - match fetch_with_retry(&app_env_configs.storyteller_host).await { - Ok(api_response) => { - let response: ListVideoModelsResponse = api_response.into(); - store_response(response.clone()); - Ok(response.into()) - } - Err(error_message) => { - warn!("list_video_models_command failed after {} attempts: {}", MAX_ATTEMPTS, error_message); - if let Some(stale) = any_cached_response() { - warn!("list_video_models_command: refresh failed; serving stale cached response"); - return Ok(stale.into()); - } - Err(error_message.into()) - } - } -} - -fn cached_response() -> Option { - let guard = CACHE.read().ok()?; - let entry = guard.as_ref()?; - if entry.loaded_at.elapsed() < CACHE_TTL { - Some(entry.response.clone()) - } else { - None - } -} - -/// The cached response regardless of age. Used as a fallback so that a failed -/// refresh still returns the last-known-good data instead of an error. -fn any_cached_response() -> Option { - let guard = CACHE.read().ok()?; - guard.as_ref().map(|entry| entry.response.clone()) -} - -fn store_response(response: ListVideoModelsResponse) { - if let Ok(mut guard) = CACHE.write() { - *guard = Some(CacheEntry { response, loaded_at: Instant::now() }); - } -} - -/// Fetch the models list, retrying up to `MAX_ATTEMPTS` times on failure. -async fn fetch_with_retry(api_host: &ApiHost) -> Result { - let mut last_error = "unknown error".to_string(); - for attempt in 1..=MAX_ATTEMPTS { - match omni_gen_list_video_models(OmniGenListVideoModelsArgs { api_host, maybe_creds: None, provider: None }).await { - Ok(response) => return Ok(response), - Err(err) => { - last_error = err.to_string(); - warn!("list_video_models attempt {}/{} failed: {}", attempt, MAX_ATTEMPTS, last_error); - if attempt < MAX_ATTEMPTS { - tokio::time::sleep(RETRY_BACKOFF).await; - } - } - } - } - Err(last_error) -} diff --git a/crates/desktop/artcraft/src/core/commands/generate/models/video/mod.rs b/crates/desktop/artcraft/src/core/commands/generate/models/video/mod.rs deleted file mode 100644 index e7de36c168..0000000000 --- a/crates/desktop/artcraft/src/core/commands/generate/models/video/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod list_video_models_command; -pub mod response_types; diff --git a/crates/desktop/artcraft/src/core/commands/generate/models/video/response_types.rs b/crates/desktop/artcraft/src/core/commands/generate/models/video/response_types.rs deleted file mode 100644 index 755c5e60eb..0000000000 --- a/crates/desktop/artcraft/src/core/commands/generate/models/video/response_types.rs +++ /dev/null @@ -1,672 +0,0 @@ -//! Command-specific response types for `list_video_models_command`. -//! -//! These are duplicated (never `artcraft_client` types), and every enum has an -//! `Unknown(String)` catch-all so newer server variants are preserved instead of -//! breaking an older desktop build. `From` impls map the API-client response over. - -use serde_derive::Serialize; - -use artcraft_client::datatypes::common_enums::generation::api_client_generation_provider::ApiClientGenerationProvider; -use artcraft_client::datatypes::common_enums::generation::api_client_model_creator::ApiClientModelCreator; -use artcraft_client::datatypes::common_enums::generation::api_client_video_model::ApiClientVideoModel; -use artcraft_client::datatypes::common_enums::generation::api_client_aspect_ratio::ApiClientAspectRatio; -use artcraft_client::datatypes::common_enums::generation::api_client_resolution::ApiClientResolution; -use artcraft_client::datatypes::common_enums::generation::api_client_bitrate::ApiClientBitrate; -use artcraft_client::datatypes::common_enums::generation::api_client_quality::ApiClientQuality; -use artcraft_client::endpoints::omni_gen::models::video::omni_gen_list_video_models::{ - OmniGenVideoModelDetails, OmniGenVideoModelProviderDetails, OmniGenVideoProviderModelDetails, OmniGenVideoModelsResponse, -}; - -use crate::core::commands::response::success_response_wrapper::SerializeMarker; - -impl SerializeMarker for ListVideoModelsResponse {} - -// ============================ Enums ============================ - -/// Command-specific copy of `ApiClientGenerationProvider` with an `Unknown` catch-all so newer -/// server variants are preserved rather than dropped. -#[derive(Clone, Debug, PartialEq, Eq, Serialize)] -#[serde(into = "String")] -pub enum ListVideoModelsProvider { - Artcraft, - Fal, - Grok, - Midjourney, - Sora, - WorldLabs, - Higgsfield, - Krea, - Leonardo, - Magnific, - Openart, - Picsart, - Pixverse, - Runway, - Unknown(String), -} - -impl From for ListVideoModelsProvider { - fn from(value: ApiClientGenerationProvider) -> Self { - match value { - ApiClientGenerationProvider::Artcraft => Self::Artcraft, - ApiClientGenerationProvider::Fal => Self::Fal, - ApiClientGenerationProvider::Grok => Self::Grok, - ApiClientGenerationProvider::Midjourney => Self::Midjourney, - ApiClientGenerationProvider::Sora => Self::Sora, - ApiClientGenerationProvider::WorldLabs => Self::WorldLabs, - ApiClientGenerationProvider::Higgsfield => Self::Higgsfield, - ApiClientGenerationProvider::Krea => Self::Krea, - ApiClientGenerationProvider::Leonardo => Self::Leonardo, - ApiClientGenerationProvider::Magnific => Self::Magnific, - ApiClientGenerationProvider::Openart => Self::Openart, - ApiClientGenerationProvider::Picsart => Self::Picsart, - ApiClientGenerationProvider::Pixverse => Self::Pixverse, - ApiClientGenerationProvider::Runway => Self::Runway, - ApiClientGenerationProvider::Unknown(other) => Self::Unknown(other), - } - } -} - -impl From for String { - fn from(value: ListVideoModelsProvider) -> Self { - match value { - ListVideoModelsProvider::Artcraft => "artcraft".to_string(), - ListVideoModelsProvider::Fal => "fal".to_string(), - ListVideoModelsProvider::Grok => "grok".to_string(), - ListVideoModelsProvider::Midjourney => "midjourney".to_string(), - ListVideoModelsProvider::Sora => "sora".to_string(), - ListVideoModelsProvider::WorldLabs => "world_labs".to_string(), - ListVideoModelsProvider::Higgsfield => "higgsfield".to_string(), - ListVideoModelsProvider::Krea => "krea".to_string(), - ListVideoModelsProvider::Leonardo => "leonardo".to_string(), - ListVideoModelsProvider::Magnific => "magnific".to_string(), - ListVideoModelsProvider::Openart => "openart".to_string(), - ListVideoModelsProvider::Picsart => "picsart".to_string(), - ListVideoModelsProvider::Pixverse => "pixverse".to_string(), - ListVideoModelsProvider::Runway => "runway".to_string(), - ListVideoModelsProvider::Unknown(other) => other, - } - } -} - -/// Command-specific copy of `ApiClientModelCreator` with an `Unknown` catch-all so newer -/// server variants are preserved rather than dropped. -#[derive(Clone, Debug, PartialEq, Eq, Serialize)] -#[serde(into = "String")] -pub enum ListVideoModelsModelCreator { - Alibaba, - ArtCraft, - BlackForestLabs, - Bytedance, - Fal, - Google, - Grok, - Hailuo, - Higgsfield, - Kling, - Krea, - Midjourney, - OpenAi, - OpenArt, - Recraft, - Replicate, - Runway, - Stability, - Tencent, - TensorArt, - Vidu, - WorldLabs, - Unknown(String), -} - -impl From for ListVideoModelsModelCreator { - fn from(value: ApiClientModelCreator) -> Self { - match value { - ApiClientModelCreator::Alibaba => Self::Alibaba, - ApiClientModelCreator::ArtCraft => Self::ArtCraft, - ApiClientModelCreator::BlackForestLabs => Self::BlackForestLabs, - ApiClientModelCreator::Bytedance => Self::Bytedance, - ApiClientModelCreator::Fal => Self::Fal, - ApiClientModelCreator::Google => Self::Google, - ApiClientModelCreator::Grok => Self::Grok, - ApiClientModelCreator::Hailuo => Self::Hailuo, - ApiClientModelCreator::Higgsfield => Self::Higgsfield, - ApiClientModelCreator::Kling => Self::Kling, - ApiClientModelCreator::Krea => Self::Krea, - ApiClientModelCreator::Midjourney => Self::Midjourney, - ApiClientModelCreator::OpenAi => Self::OpenAi, - ApiClientModelCreator::OpenArt => Self::OpenArt, - ApiClientModelCreator::Recraft => Self::Recraft, - ApiClientModelCreator::Replicate => Self::Replicate, - ApiClientModelCreator::Runway => Self::Runway, - ApiClientModelCreator::Stability => Self::Stability, - ApiClientModelCreator::Tencent => Self::Tencent, - ApiClientModelCreator::TensorArt => Self::TensorArt, - ApiClientModelCreator::Vidu => Self::Vidu, - ApiClientModelCreator::WorldLabs => Self::WorldLabs, - ApiClientModelCreator::Unknown(other) => Self::Unknown(other), - } - } -} - -impl From for String { - fn from(value: ListVideoModelsModelCreator) -> Self { - match value { - ListVideoModelsModelCreator::Alibaba => "alibaba".to_string(), - ListVideoModelsModelCreator::ArtCraft => "artcraft".to_string(), - ListVideoModelsModelCreator::BlackForestLabs => "black_forest_labs".to_string(), - ListVideoModelsModelCreator::Bytedance => "bytedance".to_string(), - ListVideoModelsModelCreator::Fal => "fal".to_string(), - ListVideoModelsModelCreator::Google => "google".to_string(), - ListVideoModelsModelCreator::Grok => "grok".to_string(), - ListVideoModelsModelCreator::Hailuo => "hailuo".to_string(), - ListVideoModelsModelCreator::Higgsfield => "higgsfield".to_string(), - ListVideoModelsModelCreator::Kling => "kling".to_string(), - ListVideoModelsModelCreator::Krea => "krea".to_string(), - ListVideoModelsModelCreator::Midjourney => "midjourney".to_string(), - ListVideoModelsModelCreator::OpenAi => "open_ai".to_string(), - ListVideoModelsModelCreator::OpenArt => "open_art".to_string(), - ListVideoModelsModelCreator::Recraft => "recraft".to_string(), - ListVideoModelsModelCreator::Replicate => "replicate".to_string(), - ListVideoModelsModelCreator::Runway => "runway".to_string(), - ListVideoModelsModelCreator::Stability => "stability".to_string(), - ListVideoModelsModelCreator::Tencent => "tencent".to_string(), - ListVideoModelsModelCreator::TensorArt => "tensor_art".to_string(), - ListVideoModelsModelCreator::Vidu => "vidu".to_string(), - ListVideoModelsModelCreator::WorldLabs => "world_labs".to_string(), - ListVideoModelsModelCreator::Unknown(other) => other, - } - } -} - -/// Command-specific copy of `ApiClientVideoModel` with an `Unknown` catch-all so newer -/// server variants are preserved rather than dropped. -#[derive(Clone, Debug, PartialEq, Eq, Serialize)] -#[serde(into = "String")] -pub enum ListVideoModelsVideoModel { - GrokVideo, - GrokImagineVideo, - GrokImagineVideo1p5, - Kling16Pro, - Kling21Pro, - Kling21Master, - Kling2p5TurboPro, - Kling2p6Pro, - Kling3p0Standard, - Kling3p0Pro, - HappyHorse1p0, - Seedance10Lite, - Seedance1p5Pro, - Seedance2p0, - Seedance2p0Fast, - Seedance2p0BytePlus, - Seedance2p0BytePlusFast, - Seedance2p0BytePlusUltra, - Seedance2p0BytePlusUltraFast, - Seedance2p0Mini, - Seedance2p0BytePlusMini, - Seedance2p0BytePlusUltraMini, - Sora2, - Sora2Pro, - Veo2, - Veo3, - Veo3Fast, - Veo3p1, - Veo3p1Fast, - PreviewModel, - PreviewModelFast, - Unknown(String), -} - -impl From for ListVideoModelsVideoModel { - fn from(value: ApiClientVideoModel) -> Self { - match value { - ApiClientVideoModel::GrokVideo => Self::GrokVideo, - ApiClientVideoModel::GrokImagineVideo => Self::GrokImagineVideo, - ApiClientVideoModel::GrokImagineVideo1p5 => Self::GrokImagineVideo1p5, - ApiClientVideoModel::Kling16Pro => Self::Kling16Pro, - ApiClientVideoModel::Kling21Pro => Self::Kling21Pro, - ApiClientVideoModel::Kling21Master => Self::Kling21Master, - ApiClientVideoModel::Kling2p5TurboPro => Self::Kling2p5TurboPro, - ApiClientVideoModel::Kling2p6Pro => Self::Kling2p6Pro, - ApiClientVideoModel::Kling3p0Standard => Self::Kling3p0Standard, - ApiClientVideoModel::Kling3p0Pro => Self::Kling3p0Pro, - ApiClientVideoModel::HappyHorse1p0 => Self::HappyHorse1p0, - ApiClientVideoModel::Seedance10Lite => Self::Seedance10Lite, - ApiClientVideoModel::Seedance1p5Pro => Self::Seedance1p5Pro, - ApiClientVideoModel::Seedance2p0 => Self::Seedance2p0, - ApiClientVideoModel::Seedance2p0Fast => Self::Seedance2p0Fast, - ApiClientVideoModel::Seedance2p0BytePlus => Self::Seedance2p0BytePlus, - ApiClientVideoModel::Seedance2p0BytePlusFast => Self::Seedance2p0BytePlusFast, - ApiClientVideoModel::Seedance2p0BytePlusUltra => Self::Seedance2p0BytePlusUltra, - ApiClientVideoModel::Seedance2p0BytePlusUltraFast => Self::Seedance2p0BytePlusUltraFast, - ApiClientVideoModel::Seedance2p0Mini => Self::Seedance2p0Mini, - ApiClientVideoModel::Seedance2p0BytePlusMini => Self::Seedance2p0BytePlusMini, - ApiClientVideoModel::Seedance2p0BytePlusUltraMini => Self::Seedance2p0BytePlusUltraMini, - ApiClientVideoModel::Sora2 => Self::Sora2, - ApiClientVideoModel::Sora2Pro => Self::Sora2Pro, - ApiClientVideoModel::Veo2 => Self::Veo2, - ApiClientVideoModel::Veo3 => Self::Veo3, - ApiClientVideoModel::Veo3Fast => Self::Veo3Fast, - ApiClientVideoModel::Veo3p1 => Self::Veo3p1, - ApiClientVideoModel::Veo3p1Fast => Self::Veo3p1Fast, - ApiClientVideoModel::PreviewModel => Self::PreviewModel, - ApiClientVideoModel::PreviewModelFast => Self::PreviewModelFast, - ApiClientVideoModel::Unknown(other) => Self::Unknown(other), - } - } -} - -impl From for String { - fn from(value: ListVideoModelsVideoModel) -> Self { - match value { - ListVideoModelsVideoModel::GrokVideo => "grok_video".to_string(), - ListVideoModelsVideoModel::GrokImagineVideo => "grok_imagine_video".to_string(), - ListVideoModelsVideoModel::GrokImagineVideo1p5 => "grok_imagine_video_1p5".to_string(), - ListVideoModelsVideoModel::Kling16Pro => "kling_1p6_pro".to_string(), - ListVideoModelsVideoModel::Kling21Pro => "kling_2p1_pro".to_string(), - ListVideoModelsVideoModel::Kling21Master => "kling_2p1_master".to_string(), - ListVideoModelsVideoModel::Kling2p5TurboPro => "kling_2p5_turbo_pro".to_string(), - ListVideoModelsVideoModel::Kling2p6Pro => "kling_2p6_pro".to_string(), - ListVideoModelsVideoModel::Kling3p0Standard => "kling_3p0_standard".to_string(), - ListVideoModelsVideoModel::Kling3p0Pro => "kling_3p0_pro".to_string(), - ListVideoModelsVideoModel::HappyHorse1p0 => "happy_horse_1p0".to_string(), - ListVideoModelsVideoModel::Seedance10Lite => "seedance_1p0_lite".to_string(), - ListVideoModelsVideoModel::Seedance1p5Pro => "seedance_1p5_pro".to_string(), - ListVideoModelsVideoModel::Seedance2p0 => "seedance_2p0".to_string(), - ListVideoModelsVideoModel::Seedance2p0Fast => "seedance_2p0_fast".to_string(), - ListVideoModelsVideoModel::Seedance2p0BytePlus => "seedance_2p0_bp".to_string(), - ListVideoModelsVideoModel::Seedance2p0BytePlusFast => "seedance_2p0_bp_fast".to_string(), - ListVideoModelsVideoModel::Seedance2p0BytePlusUltra => "seedance_2p0_bpu".to_string(), - ListVideoModelsVideoModel::Seedance2p0BytePlusUltraFast => "seedance_2p0_bpu_fast".to_string(), - ListVideoModelsVideoModel::Seedance2p0Mini => "seedance_2p0_mini".to_string(), - ListVideoModelsVideoModel::Seedance2p0BytePlusMini => "seedance_2p0_bp_mini".to_string(), - ListVideoModelsVideoModel::Seedance2p0BytePlusUltraMini => "seedance_2p0_bpu_mini".to_string(), - ListVideoModelsVideoModel::Sora2 => "sora_2".to_string(), - ListVideoModelsVideoModel::Sora2Pro => "sora_2_pro".to_string(), - ListVideoModelsVideoModel::Veo2 => "veo_2".to_string(), - ListVideoModelsVideoModel::Veo3 => "veo_3".to_string(), - ListVideoModelsVideoModel::Veo3Fast => "veo_3_fast".to_string(), - ListVideoModelsVideoModel::Veo3p1 => "veo_3p1".to_string(), - ListVideoModelsVideoModel::Veo3p1Fast => "veo_3p1_fast".to_string(), - ListVideoModelsVideoModel::PreviewModel => "preview_model".to_string(), - ListVideoModelsVideoModel::PreviewModelFast => "preview_model_fast".to_string(), - ListVideoModelsVideoModel::Unknown(other) => other, - } - } -} - -/// Command-specific copy of `ApiClientAspectRatio` with an `Unknown` catch-all so newer -/// server variants are preserved rather than dropped. -#[derive(Clone, Debug, PartialEq, Eq, Serialize)] -#[serde(into = "String")] -pub enum ListVideoModelsAspectRatio { - Auto, - Square, - WideThreeByTwo, - WideFourByThree, - WideFiveByFour, - WideSixteenByNine, - WideTwentyOneByNine, - TallTwoByThree, - TallThreeByFour, - TallFourByFive, - TallNineBySixteen, - TallNineByTwentyOne, - Wide, - Tall, - Auto2k, - Auto3k, - Auto4k, - SquareHd, - Unknown(String), -} - -impl From for ListVideoModelsAspectRatio { - fn from(value: ApiClientAspectRatio) -> Self { - match value { - ApiClientAspectRatio::Auto => Self::Auto, - ApiClientAspectRatio::Square => Self::Square, - ApiClientAspectRatio::WideThreeByTwo => Self::WideThreeByTwo, - ApiClientAspectRatio::WideFourByThree => Self::WideFourByThree, - ApiClientAspectRatio::WideFiveByFour => Self::WideFiveByFour, - ApiClientAspectRatio::WideSixteenByNine => Self::WideSixteenByNine, - ApiClientAspectRatio::WideTwentyOneByNine => Self::WideTwentyOneByNine, - ApiClientAspectRatio::TallTwoByThree => Self::TallTwoByThree, - ApiClientAspectRatio::TallThreeByFour => Self::TallThreeByFour, - ApiClientAspectRatio::TallFourByFive => Self::TallFourByFive, - ApiClientAspectRatio::TallNineBySixteen => Self::TallNineBySixteen, - ApiClientAspectRatio::TallNineByTwentyOne => Self::TallNineByTwentyOne, - ApiClientAspectRatio::Wide => Self::Wide, - ApiClientAspectRatio::Tall => Self::Tall, - ApiClientAspectRatio::Auto2k => Self::Auto2k, - ApiClientAspectRatio::Auto3k => Self::Auto3k, - ApiClientAspectRatio::Auto4k => Self::Auto4k, - ApiClientAspectRatio::SquareHd => Self::SquareHd, - ApiClientAspectRatio::Unknown(other) => Self::Unknown(other), - } - } -} - -impl From for String { - fn from(value: ListVideoModelsAspectRatio) -> Self { - match value { - ListVideoModelsAspectRatio::Auto => "auto".to_string(), - ListVideoModelsAspectRatio::Square => "square".to_string(), - ListVideoModelsAspectRatio::WideThreeByTwo => "wide_three_by_two".to_string(), - ListVideoModelsAspectRatio::WideFourByThree => "wide_four_by_three".to_string(), - ListVideoModelsAspectRatio::WideFiveByFour => "wide_five_by_four".to_string(), - ListVideoModelsAspectRatio::WideSixteenByNine => "wide_sixteen_by_nine".to_string(), - ListVideoModelsAspectRatio::WideTwentyOneByNine => "wide_twenty_one_by_nine".to_string(), - ListVideoModelsAspectRatio::TallTwoByThree => "tall_two_by_three".to_string(), - ListVideoModelsAspectRatio::TallThreeByFour => "tall_three_by_four".to_string(), - ListVideoModelsAspectRatio::TallFourByFive => "tall_four_by_five".to_string(), - ListVideoModelsAspectRatio::TallNineBySixteen => "tall_nine_by_sixteen".to_string(), - ListVideoModelsAspectRatio::TallNineByTwentyOne => "tall_nine_by_twenty_one".to_string(), - ListVideoModelsAspectRatio::Wide => "wide".to_string(), - ListVideoModelsAspectRatio::Tall => "tall".to_string(), - ListVideoModelsAspectRatio::Auto2k => "auto_2k".to_string(), - ListVideoModelsAspectRatio::Auto3k => "auto_3k".to_string(), - ListVideoModelsAspectRatio::Auto4k => "auto_4k".to_string(), - ListVideoModelsAspectRatio::SquareHd => "square_hd".to_string(), - ListVideoModelsAspectRatio::Unknown(other) => other, - } - } -} - -/// Command-specific copy of `ApiClientResolution` with an `Unknown` catch-all so newer -/// server variants are preserved rather than dropped. -#[derive(Clone, Debug, PartialEq, Eq, Serialize)] -#[serde(into = "String")] -pub enum ListVideoModelsResolution { - OneK, - TwoK, - ThreeK, - FourK, - HalfK, - FourEightyP, - SevenTwentyP, - TenEightyP, - Unknown(String), -} - -impl From for ListVideoModelsResolution { - fn from(value: ApiClientResolution) -> Self { - match value { - ApiClientResolution::OneK => Self::OneK, - ApiClientResolution::TwoK => Self::TwoK, - ApiClientResolution::ThreeK => Self::ThreeK, - ApiClientResolution::FourK => Self::FourK, - ApiClientResolution::HalfK => Self::HalfK, - ApiClientResolution::FourEightyP => Self::FourEightyP, - ApiClientResolution::SevenTwentyP => Self::SevenTwentyP, - ApiClientResolution::TenEightyP => Self::TenEightyP, - ApiClientResolution::Unknown(other) => Self::Unknown(other), - } - } -} - -impl From for String { - fn from(value: ListVideoModelsResolution) -> Self { - match value { - ListVideoModelsResolution::OneK => "one_k".to_string(), - ListVideoModelsResolution::TwoK => "two_k".to_string(), - ListVideoModelsResolution::ThreeK => "three_k".to_string(), - ListVideoModelsResolution::FourK => "four_k".to_string(), - ListVideoModelsResolution::HalfK => "half_k".to_string(), - ListVideoModelsResolution::FourEightyP => "four_eighty_p".to_string(), - ListVideoModelsResolution::SevenTwentyP => "seven_twenty_p".to_string(), - ListVideoModelsResolution::TenEightyP => "ten_eighty_p".to_string(), - ListVideoModelsResolution::Unknown(other) => other, - } - } -} - -/// Command-specific copy of `ApiClientBitrate` with an `Unknown` catch-all so newer -/// server variants are preserved rather than dropped. -#[derive(Clone, Debug, PartialEq, Eq, Serialize)] -#[serde(into = "String")] -pub enum ListVideoModelsBitrate { - Normal, - High, - Unknown(String), -} - -impl From for ListVideoModelsBitrate { - fn from(value: ApiClientBitrate) -> Self { - match value { - ApiClientBitrate::Normal => Self::Normal, - ApiClientBitrate::High => Self::High, - ApiClientBitrate::Unknown(other) => Self::Unknown(other), - } - } -} - -impl From for String { - fn from(value: ListVideoModelsBitrate) -> Self { - match value { - ListVideoModelsBitrate::Normal => "normal".to_string(), - ListVideoModelsBitrate::High => "high".to_string(), - ListVideoModelsBitrate::Unknown(other) => other, - } - } -} - -/// Command-specific copy of `ApiClientQuality` with an `Unknown` catch-all so newer -/// server variants are preserved rather than dropped. -#[derive(Clone, Debug, PartialEq, Eq, Serialize)] -#[serde(into = "String")] -pub enum ListVideoModelsQuality { - High, - Medium, - Low, - Unknown(String), -} - -impl From for ListVideoModelsQuality { - fn from(value: ApiClientQuality) -> Self { - match value { - ApiClientQuality::High => Self::High, - ApiClientQuality::Medium => Self::Medium, - ApiClientQuality::Low => Self::Low, - ApiClientQuality::Unknown(other) => Self::Unknown(other), - } - } -} - -impl From for String { - fn from(value: ListVideoModelsQuality) -> Self { - match value { - ListVideoModelsQuality::High => "high".to_string(), - ListVideoModelsQuality::Medium => "medium".to_string(), - ListVideoModelsQuality::Low => "low".to_string(), - ListVideoModelsQuality::Unknown(other) => other, - } - } -} - -// ============================ Structs ============================ - -#[derive(Clone, Debug, Serialize)] -pub struct ListVideoModelsResponse { - pub success: bool, - pub models: Vec, - pub providers: Vec, -} - -impl From for ListVideoModelsResponse { - fn from(v: OmniGenVideoModelsResponse) -> Self { - Self { - success: v.success, - models: v.models.into_iter().map(Into::into).collect(), - providers: v.providers.into_iter().map(Into::into).collect(), - } - } -} - -#[derive(Clone, Debug, Serialize)] -pub struct ListVideoModelsProviderDetails { - pub provider: ListVideoModelsProvider, - pub models: Vec, -} - -impl From for ListVideoModelsProviderDetails { - fn from(v: OmniGenVideoModelProviderDetails) -> Self { - Self { - provider: v.provider.into(), - models: v.models.into_iter().map(Into::into).collect(), - } - } -} - -#[derive(Clone, Debug, Serialize)] -pub struct ListVideoModelsProviderModelDetails { - pub model: ListVideoModelsVideoModel, - #[serde(skip_serializing_if = "Option::is_none")] - pub overrides: Option, -} - -impl From for ListVideoModelsProviderModelDetails { - fn from(v: OmniGenVideoProviderModelDetails) -> Self { - Self { - model: v.model.into(), - overrides: v.overrides.map(Into::into), - } - } -} - -#[derive(Clone, Debug, Serialize)] -pub struct ListVideoModelsModelDetails { - pub model: ListVideoModelsVideoModel, - #[serde(skip_serializing_if = "Option::is_none")] - pub model_creator: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub full_name: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub extra_info: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub extra_info_short: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub text_to_video_supported: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub text_prompt_supported: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub text_prompt_max_length: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub negative_text_prompt_supported: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub negative_text_prompt_max_length: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub starting_keyframe_supported: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub starting_keyframe_required: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub ending_keyframe_supported: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub image_references_supported: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub image_references_max: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub video_references_supported: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub video_references_max: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub video_references_max_total_duration_seconds: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub audio_references_supported: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub audio_references_max: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub audio_references_max_total_duration_seconds: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub character_references_supported: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub character_references_max: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub show_generate_with_sound_toggle: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub aspect_ratio_options: Option>, - #[serde(skip_serializing_if = "Option::is_none")] - pub aspect_ratio_default: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub resolution_options: Option>, - #[serde(skip_serializing_if = "Option::is_none")] - pub resolution_default: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub bitrate_options: Option>, - #[serde(skip_serializing_if = "Option::is_none")] - pub bitrate_default: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub quality_options: Option>, - #[serde(skip_serializing_if = "Option::is_none")] - pub default_quality: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub duration_seconds_min: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub duration_seconds_max: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub duration_seconds_max_with_image_references: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub duration_seconds_options: Option>, - #[serde(skip_serializing_if = "Option::is_none")] - pub duration_seconds_default: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub batch_size_min: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub batch_size_max: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub batch_size_options: Option>, - #[serde(skip_serializing_if = "Option::is_none")] - pub batch_size_default: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub is_disabled: Option, -} - -impl From for ListVideoModelsModelDetails { - fn from(v: OmniGenVideoModelDetails) -> Self { - Self { - model: v.model.into(), - model_creator: v.model_creator.map(Into::into), - full_name: v.full_name, - extra_info: v.extra_info, - extra_info_short: v.extra_info_short, - text_to_video_supported: v.text_to_video_supported, - text_prompt_supported: v.text_prompt_supported, - text_prompt_max_length: v.text_prompt_max_length, - negative_text_prompt_supported: v.negative_text_prompt_supported, - negative_text_prompt_max_length: v.negative_text_prompt_max_length, - starting_keyframe_supported: v.starting_keyframe_supported, - starting_keyframe_required: v.starting_keyframe_required, - ending_keyframe_supported: v.ending_keyframe_supported, - image_references_supported: v.image_references_supported, - image_references_max: v.image_references_max, - video_references_supported: v.video_references_supported, - video_references_max: v.video_references_max, - video_references_max_total_duration_seconds: v.video_references_max_total_duration_seconds, - audio_references_supported: v.audio_references_supported, - audio_references_max: v.audio_references_max, - audio_references_max_total_duration_seconds: v.audio_references_max_total_duration_seconds, - character_references_supported: v.character_references_supported, - character_references_max: v.character_references_max, - show_generate_with_sound_toggle: v.show_generate_with_sound_toggle, - aspect_ratio_options: v.aspect_ratio_options.map(|items| items.into_iter().map(Into::into).collect()), - aspect_ratio_default: v.aspect_ratio_default.map(Into::into), - resolution_options: v.resolution_options.map(|items| items.into_iter().map(Into::into).collect()), - resolution_default: v.resolution_default.map(Into::into), - bitrate_options: v.bitrate_options.map(|items| items.into_iter().map(Into::into).collect()), - bitrate_default: v.bitrate_default.map(Into::into), - quality_options: v.quality_options.map(|items| items.into_iter().map(Into::into).collect()), - default_quality: v.default_quality.map(Into::into), - duration_seconds_min: v.duration_seconds_min, - duration_seconds_max: v.duration_seconds_max, - duration_seconds_max_with_image_references: v.duration_seconds_max_with_image_references, - duration_seconds_options: v.duration_seconds_options, - duration_seconds_default: v.duration_seconds_default, - batch_size_min: v.batch_size_min, - batch_size_max: v.batch_size_max, - batch_size_options: v.batch_size_options, - batch_size_default: v.batch_size_default, - is_disabled: v.is_disabled, - } - } -} diff --git a/crates/desktop/artcraft/src/core/commands/generate/omni/dispatch.rs b/crates/desktop/artcraft/src/core/commands/generate/omni/dispatch.rs deleted file mode 100644 index 01ea57b6fa..0000000000 --- a/crates/desktop/artcraft/src/core/commands/generate/omni/dispatch.rs +++ /dev/null @@ -1,211 +0,0 @@ -use super::request::{Modality, OmniRequest}; -use crate::core::commands::enqueue::common::notify_frontend_of_errors::notify_frontend_of_errors; -use crate::core::commands::enqueue::generate_error::{GenerateError, MissingCredentialsReason}; -use crate::core::commands::enqueue::task_enqueue_success::TaskEnqueueSuccess; -use crate::core::commands::generate::generate_image::utils::parse_semantic_media_files::{resolve_image_field, resolve_mask_field}; -use crate::core::commands::response::failure_response_wrapper::{CommandErrorResponseWrapper, CommandErrorStatus}; -use crate::core::commands::response::shorthand::Response; -use crate::core::commands::response::success_response_wrapper::SerializeMarker; -use crate::core::events::basic_sendable_event_trait::BasicSendableEvent; -use crate::core::events::functional_events::credits_balance_changed_event::CreditsBalanceChangedEvent; -use crate::core::events::generation_events::common::GenerationModel; -use crate::core::events::generation_events::generation_enqueue_success_event::GenerationEnqueueSuccessEvent; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; -use crate::core::state::artcraft_usage_tracker::artcraft_usage_tracker::ArtcraftUsageTracker; -use crate::core::state::artcraft_usage_tracker::artcraft_usage_type::{ArtcraftUsagePage, ArtcraftUsageType}; -use crate::core::state::task_database::TaskDatabase; -use crate::services::storyteller::state::storyteller_credential_manager::StorytellerCredentialManager; -use artcraft_client::credentials::storyteller_credential_set::StorytellerCredentialSet; -use artcraft_client::error::api_error::ApiError; -use artcraft_client::error::storyteller_error::StorytellerError; -use artcraft_client::utils::api_host::ApiHost; -use artcraft_client::utils::basic_json_post_request::basic_json_post_request; -use enums::common::generation_provider::GenerationProvider; -use log::error; -use serde::{Deserialize, Serialize}; -use serde_json::{Map, Value}; -use tauri::{AppHandle, Manager}; -use tokens::tokens::media_files::MediaFileToken; -use uuid_utils::uuid::generate_random_uuid; - -#[derive(Deserialize, Serialize)] -#[serde(transparent)] -pub struct OmniResponse(pub Value); - -impl SerializeMarker for OmniResponse {} - -pub type OmniResult = Response; - -pub async fn generate(request: OmniRequest, modality: Modality, app: &AppHandle) -> OmniResult { - let configs = app.state::(); - let manager = app.state::(); - let maybe_creds = manager.get_credentials().map_err(local_error)?; - let creds = match maybe_creds { - Some(creds) => creds, - None => { - notify_frontend_of_errors(app, &GenerateError::MissingCredentials(MissingCredentialsReason::NeedsStorytellerCredentials)).await; - return Err(command_error(CommandErrorStatus::Unauthorized, "needs_storyteller_credentials", "You need to be logged into ArtCraft.".into())); - }, - }; - let mut fields = request.api_fields(modality); - if modality == Modality::Image { - resolve_image_inputs(&mut fields, Some(&creds), &configs.storyteller_host).await?; - } - fields.remove("estimate_only"); - if fields.get("idempotency_token").is_none_or(Value::is_null) { - fields.insert("idempotency_token".into(), Value::String(generate_random_uuid())); - } - let model = fields.get("model").and_then(Value::as_str).map(str::to_owned); - let route = format!("/v1/omni_gen/generate/{}", modality.as_str()); - let response: OmniResponse = match basic_json_post_request(&configs.storyteller_host, &route, Some(&creds), fields).await { - Ok(response) => response, - Err(err) => { - let error = api_error(&err); - notify_frontend_of_errors(app, &GenerateError::from(err)).await; - return Err(error); - }, - }; - - // A batch may create several jobs. Track every job so history and completion - // events survive restart, including when a model was unknown at build time. - let job_tokens = job_tokens(&response.0); - if job_tokens.is_empty() { - return Err(local_error("The API accepted generation but returned no job tokens.")); - } - record_usage(app, &request, modality, job_tokens.len()); - let database = app.state::(); - for job_token in job_tokens { - let success = TaskEnqueueSuccess { task_type: modality.task_type(), model: model.clone().map(GenerationModel::Unknown), provider: GenerationProvider::Artcraft, provider_job_id: Some(job_token), maybe_queue_status_url: None, maybe_queue_response_url: None, maybe_prompt_token: None }; - if let Err(err) = success.insert_into_task_database_with_frontend_payload(&database, request.frontend_caller, request.frontend_subscriber_id.as_deref(), request.frontend_subscriber_payload.as_deref()).await { - // Generation has already been accepted. Do not encourage duplicate retries. - error!("Could not persist accepted Omni generation: {:?}", err); - } - GenerationEnqueueSuccessEvent { action: success.to_frontend_event_action(), service: success.to_frontend_event_service(), model: success.model }.send_infallible(app); - } - CreditsBalanceChangedEvent {}.send_infallible(app); - Ok(response.into()) -} - -pub async fn estimate(request: OmniRequest, modality: Modality, app: &AppHandle) -> OmniResult { - let configs = app.state::(); - let manager = app.state::(); - let creds = manager.get_credentials().map_err(local_error)?; - let mut fields = request.api_fields(modality); - if modality == Modality::Image { - // Pricing only needs reference presence, never upload a canvas on each keystroke. - resolve_image_inputs(&mut fields, None, &configs.storyteller_host).await?; - } - let route = format!("/v1/omni_gen/cost/{}", modality.as_str()); - let response: OmniResponse = basic_json_post_request(&configs.storyteller_host, &route, creds.as_ref(), fields).await.map_err(|err| api_error(&err))?; - Ok(response.into()) -} - -pub fn adapt_legacy_response(response: Response) -> OmniResult { - match response { - Ok(response) => Ok(OmniResponse(serde_json::to_value(response.payload).map_err(local_error)?).into()), - Err(err) => Err(CommandErrorResponseWrapper { status: err.status, error_message: err.error_message.or_else(|| serde_json::to_value(err.error_details).ok().and_then(|value| value.get("error_message").and_then(Value::as_str).map(str::to_owned))), error_type: err.error_type.and_then(|value| serde_json::to_value(value).ok()).and_then(|value| value.as_str().map(str::to_owned)), error_details: None }), - } -} - -pub fn decode_native(request: OmniRequest) -> Result> { - serde_json::from_value(serde_json::to_value(request).map_err(local_error)?).map_err(|err| command_error(CommandErrorStatus::BadRequest, "bad_input", err.to_string())) -} - -pub fn local_error(err: impl std::fmt::Display) -> CommandErrorResponseWrapper { - command_error(CommandErrorStatus::ServerError, "server_error", err.to_string()) -} - -fn api_error(err: &StorytellerError) -> CommandErrorResponseWrapper { - match err { - StorytellerError::Api(ApiError::InvalidRequest(body)) => command_error(CommandErrorStatus::BadRequest, "bad_input", api_message(body)), - StorytellerError::Api(ApiError::Unauthorized(body) | ApiError::Forbidden(body)) => command_error(CommandErrorStatus::Unauthorized, "unauthorized", api_message(body)), - StorytellerError::Api(ApiError::TooManyRequests(body)) => command_error(CommandErrorStatus::TooManyRequests, "too_many_requests", api_message(body)), - StorytellerError::Api(ApiError::PaymentRequired(body)) => command_error(CommandErrorStatus::BadRequest, "billing_issue", api_message(body)), - _ => local_error(err), - } -} - -fn api_message(body: &str) -> String { - serde_json::from_str::(body).ok().and_then(|value| value.get("error_message").or_else(|| value.get("message")).and_then(Value::as_str).map(str::to_owned)).unwrap_or_else(|| body.to_owned()) -} - -fn command_error(status: CommandErrorStatus, kind: &str, message: String) -> CommandErrorResponseWrapper { - CommandErrorResponseWrapper { status, error_type: Some(kind.into()), error_message: Some(message), error_details: None } -} - -async fn resolve_image_inputs(fields: &mut Map, maybe_creds: Option<&StorytellerCredentialSet>, host: &ApiHost) -> Result<(), CommandErrorResponseWrapper> { - let mut refs = Vec::new(); - for name in ["canvas_image", "scene_image", "inpainting_mask_image"] { - let token_key = format!("{}_media_token", name); - let bytes_key = format!("{}_raw_bytes", name); - let token: Option = serde_json::from_value(fields.remove(&token_key).unwrap_or(Value::Null)).map_err(local_error)?; - let bytes: Option> = serde_json::from_value(fields.remove(&bytes_key).unwrap_or(Value::Null)).map_err(local_error)?; - let resolved = if let Some(creds) = maybe_creds { if name == "inpainting_mask_image" { resolve_mask_field(token.as_ref(), bytes.as_deref(), creds, host).await } else { resolve_image_field(name, token.as_ref(), bytes.as_deref(), creds, host).await }.map_err(|err| local_error(format!("{:?}", err)))?.map(|token| token.to_string()) } else { token.map(|token| token.to_string()).or_else(|| bytes.map(|_| "mf_estimate_reference".into())) }; - if let Some(token) = resolved { - if name == "inpainting_mask_image" { - fields.insert(token_key, Value::String(token)); - } else { - refs.push(Value::String(token)); - } - } - } - if !refs.is_empty() { - if let Some(Value::Array(existing)) = fields.remove("image_media_tokens") { - refs.extend(existing); - } - fields.insert("image_media_tokens".into(), Value::Array(refs)); - } - Ok(()) -} - -fn job_tokens(response: &Value) -> Vec { - let mut result = Vec::new(); - if let Some(primary) = response.get("inference_job_token").and_then(Value::as_str) { - result.push(primary.to_owned()); - } - if let Some(tokens) = response.get("all_job_tokens").and_then(Value::as_array) { - for token in tokens.iter().filter_map(Value::as_str) { - if !result.iter().any(|existing| existing == token) { - result.push(token.to_owned()); - } - } - } - result -} - -fn record_usage(app: &AppHandle, request: &OmniRequest, modality: Modality, count: usize) { - let tracker = app.state::(); - let count = u16::try_from(count).unwrap_or(u16::MAX); - let has_media = request.fields.iter().any(|(key, value)| { - key.ends_with("media_token") && value.is_string() - || key.ends_with("media_tokens") && value.as_array().is_some_and(|values| !values.is_empty()) - }); - let usage = if has_media { ArtcraftUsageType::ImageToResult } else { ArtcraftUsageType::TextToResult }; - let result = match modality { - Modality::Video => tracker.record_video_generation(count, usage, ArtcraftUsagePage::VideoPage), - Modality::Mesh => tracker.record_object_generation(count, usage, ArtcraftUsagePage::ObjectPage), - Modality::Splat => tracker.record_object_generation(count, usage, ArtcraftUsagePage::OtherPage), - _ => Ok(()), - }; - if let Err(err) = result { - error!("Could not record generation usage: {:?}", err); - } -} - -#[cfg(test)] -mod tests { - use super::*; - use serde_json::json; - - #[test] - fn invalid_options_return_the_api_message() { - let err = api_error(&StorytellerError::Api(ApiError::InvalidRequest(r#"{"success":false,"error_message":"Duration must be between 4 and 30 seconds."}"#.into()))); - assert!(matches!(err.status, CommandErrorStatus::BadRequest)); - assert_eq!(err.error_message.as_deref(), Some("Duration must be between 4 and 30 seconds.")); - } - - #[test] - fn batch_tracks_each_job_once() { - assert_eq!(job_tokens(&json!({"inference_job_token":"job_1", "all_job_tokens":["job_1", "job_2"]})), vec!["job_1", "job_2"]); - } -} diff --git a/crates/desktop/artcraft/src/core/commands/generate/omni/mod.rs b/crates/desktop/artcraft/src/core/commands/generate/omni/mod.rs deleted file mode 100644 index 9fb0a48100..0000000000 --- a/crates/desktop/artcraft/src/core/commands/generate/omni/mod.rs +++ /dev/null @@ -1,5 +0,0 @@ -pub mod request; -pub mod dispatch; - -pub use dispatch::{generate, estimate, OmniResponse, OmniResult}; -pub use request::{OmniRequest, Modality}; diff --git a/crates/desktop/artcraft/src/core/commands/generate/omni/request.rs b/crates/desktop/artcraft/src/core/commands/generate/omni/request.rs deleted file mode 100644 index 6e7f98f2b2..0000000000 --- a/crates/desktop/artcraft/src/core/commands/generate/omni/request.rs +++ /dev/null @@ -1,187 +0,0 @@ -use enums::common::generation_provider::GenerationProvider; -use enums::tauri::tasks::task_type::TaskType; -use enums::tauri::ux::tauri_command_caller::TauriCommandCaller; -use serde::{Deserialize, Serialize}; -use serde_json::{Map, Value}; - -/// Desktop metadata is local. Everything else is an API-owned field, including -/// model IDs and option strings introduced after this version of the app. -#[derive(Clone, Deserialize, Serialize)] -pub struct OmniRequest { - pub provider: Option, - pub frontend_caller: Option, - pub frontend_subscriber_id: Option, - pub frontend_subscriber_payload: Option, - #[serde(flatten)] - pub fields: Map, -} - -#[derive(Clone, Copy, PartialEq, Eq)] -pub enum Modality { - Image, - Video, - Mesh, - Splat, - Audio, -} - -impl OmniRequest { - pub fn uses_artcraft(&self) -> bool { - // Native Grok is deliberately disabled, including calls from old UI state. - self.model().is_some_and(|model| model.starts_with("grok_")) || matches!(self.provider, None | Some(GenerationProvider::Artcraft | GenerationProvider::Grok)) - } - - pub fn model(&self) -> Option<&str> { - self.fields.get("model").and_then(Value::as_str) - } - - pub fn uses_legacy_image_endpoint(&self) -> bool { - // These desktop editor integrations still have dedicated request shapes. - // Catalog models, including any future ID, use Omni by default. - matches!(self.model(), Some("recraft_3" | "flux_pro_kontext_max" | "flux_dev_juggernaut" | "flux_pro_1" | "midjourney")) - } - - pub fn api_fields(&self, modality: Modality) -> Map { - let mut fields = self.fields.clone(); - if let Some(model) = self.model() { - fields.insert("model".into(), Value::String(canonical_model_id(model).into())); - } - match modality { - Modality::Image => rename_field(&mut fields, "batch_size", "image_batch_count"), - Modality::Video => { - rename_field(&mut fields, "image_media_token", "start_frame_image_media_token"); - fields.remove("sora_orientation"); - fields.remove("grok_aspect_ratio"); - }, - Modality::Splat => rename_field(&mut fields, "image_media_tokens", "reference_image_media_tokens"), - Modality::Mesh => { - if let Some(token) = fields.remove("image_media_token").filter(|v| !v.is_null()) { - fields.entry("reference_image_media_tokens").or_insert(Value::Array(vec![token])); - } - }, - Modality::Audio => {}, - } - // These belong to the old pricing endpoint, not Omni generation or pricing. - fields.remove("generation_mode"); - fields - } -} - -impl Modality { - pub fn as_str(self) -> &'static str { - match self { - Self::Image => "image", - Self::Video => "video", - Self::Mesh => "mesh", - Self::Splat => "splat", - Self::Audio => "audio", - } - } - - pub fn task_type(self) -> TaskType { - match self { - Self::Image => TaskType::ImageGeneration, - Self::Video => TaskType::VideoGeneration, - Self::Mesh => TaskType::ObjectGeneration, - Self::Splat => TaskType::GaussianGeneration, - Self::Audio => TaskType::AudioGeneration, - } - } -} - -fn rename_field(fields: &mut Map, old: &str, new: &str) { - if let Some(value) = fields.remove(old).filter(|v| !v.is_null()) { - if fields.get(new).is_none_or(Value::is_null) { - fields.insert(new.into(), value); - } - } -} - -// Compatibility for persisted desktop settings and existing editor callers. -// Unknown IDs pass through unchanged; this is not a model allowlist. -fn canonical_model_id(model: &str) -> &str { - match model { - "flux_pro_11" => "flux_pro_1p1", - "flux_pro_11_ultra" => "flux_pro_1p1_ultra", - "gemini_25_flash" => "nano_banana", - "grok_image" => "grok_imagine_image", - "grok_video" => "grok_imagine_video", - "kling_1.6_pro" => "kling_1p6_pro", - "kling_2.1_pro" => "kling_2p1_pro", - "kling_2.1_master" => "kling_2p1_master", - "seedance_1.0_lite" => "seedance_1p0_lite", - "hunyuan_3d_2" | "hunyuan_3d_2_0" => "hunyuan_3d_2p0", - "hunyuan_3d_2_1" => "hunyuan_3d_2p1", - "world_labs_marble" | "worldlabs_marble" => "marble_0p1_plus", - _ => model, - } -} - -#[cfg(test)] -mod tests { - use super::*; - use serde_json::json; - - #[test] - fn future_model_and_options_survive_without_desktop_metadata() { - let request: OmniRequest = serde_json::from_value(json!({ - "model": "future_video_v9", "resolution": "eight_k", "bitrate": "ultra", - "duration_seconds": 30, "generate_audio": false, "new_option": {"value": 1}, - "estimate_only": {"total_input_video_duration_millis": 7250}, - "frontend_subscriber_id": "local-only" - })) - .unwrap(); - let fields = request.api_fields(Modality::Video); - assert_eq!(fields["model"], "future_video_v9"); - assert_eq!(fields["resolution"], "eight_k"); - assert_eq!(fields["bitrate"], "ultra"); - assert_eq!(fields["duration_seconds"], 30); - assert_eq!(fields["generate_audio"], false); - assert_eq!(fields["new_option"]["value"], 1); - assert_eq!(fields["estimate_only"]["total_input_video_duration_millis"], 7250); - assert!(!fields.contains_key("frontend_subscriber_id")); - assert!(!fields.contains_key("provider")); - } - - #[test] - fn grok_uses_artcraft_even_with_a_saved_native_provider() { - let request: OmniRequest = serde_json::from_value(json!({ - "model": "grok_video", "provider": "grok" - })) - .unwrap(); - assert!(request.uses_artcraft()); - assert_eq!(request.api_fields(Modality::Video)["model"], "grok_imagine_video"); - } - - #[test] - fn legacy_mesh_and_splat_inputs_use_omni_field_names() { - let mesh: OmniRequest = serde_json::from_value(json!({ - "model": "hunyuan_3d_2_0", "image_media_token": "mf_mesh_input" - })) - .unwrap(); - let fields = mesh.api_fields(Modality::Mesh); - assert_eq!(fields["model"], "hunyuan_3d_2p0"); - assert_eq!(fields["reference_image_media_tokens"], json!(["mf_mesh_input"])); - assert!(!fields.contains_key("image_media_token")); - - let splat: OmniRequest = serde_json::from_value(json!({ - "model": "world_labs_marble", "image_media_tokens": ["mf_splat_input"] - })) - .unwrap(); - let fields = splat.api_fields(Modality::Splat); - assert_eq!(fields["model"], "marble_0p1_plus"); - assert_eq!(fields["reference_image_media_tokens"], json!(["mf_splat_input"])); - } - - #[test] - fn future_model_ids_survive_storage_and_event_serialization() { - use crate::core::events::generation_events::common::GenerationModel; - use enums::tauri::tasks::task_model_type::TaskModelType; - - let stored = TaskModelType::from_str("future_model_v99").unwrap(); - let event = GenerationModel::Unknown(stored.to_str().to_owned()); - assert_eq!(serde_json::to_value(event).unwrap(), json!("future_model_v99")); - // Keep existing event strings compatible with old history. - assert_eq!(serde_json::to_value(GenerationModel::FluxPro11).unwrap(), json!("flux_pro_1.1")); - } -} diff --git a/crates/desktop/artcraft/src/core/commands/get_app_info_command.rs b/crates/desktop/artcraft/src/core/commands/get_app_info_command.rs deleted file mode 100644 index 49e386a677..0000000000 --- a/crates/desktop/artcraft/src/core/commands/get_app_info_command.rs +++ /dev/null @@ -1,90 +0,0 @@ -use crate::core::commands::response::shorthand::InfallibleResponse; -use crate::core::commands::response::success_response_wrapper::SerializeMarker; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; -use crate::core::state::app_preferences::app_preferences_manager::AppPreferencesManager; -use crate::core::state::artcraft_platform_info::{ArtcraftOs, ArtcraftPlatformInfo}; -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::core::state::data_dir::trait_data_subdir::DataSubdir; -use crate::core::state::os_platform::OsPlatform; -use chrono::{DateTime, Utc}; -use log::{info, warn}; -use serde_derive::Serialize; -use std::path::PathBuf; -use tauri::State; - -#[derive(Debug, Serialize)] -pub struct AppInfoResponse { - pub artcraft_version: String, - - pub build_timestamp: DateTime, - - pub git_commit_id: Option, - pub git_commit_short_id: Option, - pub git_commit_timestamp: Option>, - - pub os_platform: DetectedOs, - pub os_version: String, - - pub storyteller_host: String, - - pub artcraft_root_directory: PathBuf, - pub download_directory: PathBuf, -} - -impl SerializeMarker for AppInfoResponse {} - -#[derive(Copy, Clone, Debug, Serialize)] -#[serde(rename_all = "snake_case")] -pub enum DetectedOs { - Windows, - #[serde(rename = "macos")] - MacOS, - Linux, - Unknown, -} - -#[tauri::command] -pub fn get_app_info_command( - app_data_root: State<'_, AppDataRoot>, - app_env_configs: State<'_, AppEnvConfigs>, - artcraft_platform_info: State<'_, ArtcraftPlatformInfo>, - app_prefs: State<'_, AppPreferencesManager>, -) -> InfallibleResponse { - info!("get_app_info_command called..."); - - let storyteller_host = app_env_configs.storyteller_host.to_api_hostname_and_scheme(); - - let os_platform = match artcraft_platform_info.os_platform { - ArtcraftOs::Linux => DetectedOs::Linux, - ArtcraftOs::MacOS => DetectedOs::MacOS, - ArtcraftOs::Windows => DetectedOs::Windows, - ArtcraftOs::Unknown => DetectedOs::Unknown, - }; - - let root_directory = app_data_root.path().to_path_buf(); - - let download_directory = match app_prefs.get_clone() { - Ok(app_prefs) => { - app_prefs.preferred_download_directory - .download_directory(&app_data_root) - } - Err(err) => { - warn!("Can't get user download directory: {:?}", err); - app_data_root.downloads_dir().path().to_path_buf() - } - }; - - AppInfoResponse { - artcraft_version: artcraft_platform_info.artcraft_version.clone(), - build_timestamp: artcraft_platform_info.build_timestamp, - git_commit_id: artcraft_platform_info.git_commit_id.clone(), - git_commit_short_id: artcraft_platform_info.git_commit_short_id.clone(), - git_commit_timestamp: artcraft_platform_info.git_commit_timestamp, - os_platform, - os_version: artcraft_platform_info.os_version.clone(), - storyteller_host, - artcraft_root_directory: root_directory, - download_directory, - }.into() -} - diff --git a/crates/desktop/artcraft/src/core/commands/load_without_cors_command.rs b/crates/desktop/artcraft/src/core/commands/load_without_cors_command.rs deleted file mode 100644 index 482dce15c3..0000000000 --- a/crates/desktop/artcraft/src/core/commands/load_without_cors_command.rs +++ /dev/null @@ -1,43 +0,0 @@ -use futures::TryFutureExt; -use log::{error, info}; -use reqwest::Client; -use tauri::ipc::Response; - -/// Request a URL and load it without worrying about CORS. -#[tauri::command] -pub async fn load_without_cors_command(url: String) -> Result { - - info!("load_without_cors_command for URL: {}", url); - - // TODO(bt,2025-07-22): Make sure the URL is valid and safe to fetch. Check an allowlist. - - // TODO(bt,2025-07-22): Should we cache clients so we don't need to SSL handshake every time? - let client = Client::builder() - .gzip(true) - .build() - .map_err(|e| { - error!("Failed to create HTTP client: {:?}", e); - format!("Failed to create HTTP client: {:?}", e) - })?; - - let response = client.get(url.clone()) - .send() - .await - .map_err(|e| { - error!("Failed to send HTTP request: {:?}", e); - format!("Failed to send HTTP request: {:?}", e) - })?; - - if response.status() != 200 { - return Err(format!("Failed to fetch URL: {}. Status: {}", url, response.status())); - } - - let bytes = response.bytes() - .await - .map_err(|e| { - error!("Failed to read response bytes: {:?}", e); - format!("Failed to read response bytes: {:?}", e) - })?; - - Ok(Response::new(bytes.to_vec())) -} diff --git a/crates/desktop/artcraft/src/core/commands/media_files/media_file_delete_command.rs b/crates/desktop/artcraft/src/core/commands/media_files/media_file_delete_command.rs deleted file mode 100644 index ff977acab7..0000000000 --- a/crates/desktop/artcraft/src/core/commands/media_files/media_file_delete_command.rs +++ /dev/null @@ -1,80 +0,0 @@ -use crate::core::commands::response::shorthand::ResponseOrErrorMessage; -use crate::core::commands::response::success_response_wrapper::SerializeMarker; -use crate::core::events::basic_sendable_event_trait::BasicSendableEvent; -use crate::core::events::functional_events::media_file_deleted_event::MediaFileDeletedEvent; -use crate::core::events::generation_events::generation_enqueue_success_event::GenerationEnqueueSuccessEvent; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::core::state::provider_priority::{Provider, ProviderPriorityStore}; -use crate::core::state::task_database::TaskDatabase; -use crate::services::sora::state::sora_task_queue::SoraTaskQueue; -use crate::services::storyteller::state::storyteller_credential_manager::StorytellerCredentialManager; -use errors::AnyhowResult; -use log::{error, info, warn}; -use serde_derive::{Deserialize, Serialize}; -use artcraft_client::endpoints::media_files::delete_media_file::delete_media_file; -use tauri::{AppHandle, State}; -use tokens::tokens::media_files::MediaFileToken; - -#[derive(Deserialize)] -pub struct MediaFileDeleteRequest { - /// REQUIRED. - /// Media file to delete. The user must own the file. - pub media_file_token: MediaFileToken, -} - -#[derive(Serialize)] -pub struct MediaFileDeleteSuccessResponse { - pub success: bool, -} - -impl SerializeMarker for MediaFileDeleteSuccessResponse {} - -#[tauri::command] -pub async fn media_file_delete_command( - app: AppHandle, - request: MediaFileDeleteRequest, - app_env_configs: State<'_, AppEnvConfigs>, - storyteller_creds_manager: State<'_, StorytellerCredentialManager>, -) -> ResponseOrErrorMessage { - - info!("media_file_delete_command called"); - - let result = handle_request( - request, - &app, - &app_env_configs, - &storyteller_creds_manager, - ).await; - - if let Err(err) = result { - error!("media_file_delete_command failed: {:?}", err); - return Err("delete failed".into()) - } - - Ok(MediaFileDeleteSuccessResponse { - success: true, - }.into()) -} - -pub async fn handle_request( - request: MediaFileDeleteRequest, - app: &AppHandle, - app_env_configs: &AppEnvConfigs, - storyteller_creds_manager: &StorytellerCredentialManager, -) -> AnyhowResult<()> { - - let creds = storyteller_creds_manager.get_credentials()?; - - let _result = delete_media_file( - &app_env_configs.storyteller_host, - creds.as_ref(), - &request.media_file_token - ).await?; - - MediaFileDeletedEvent { - media_file_token: request.media_file_token, - }.send_infallible(app); - - Ok(()) -} diff --git a/crates/desktop/artcraft/src/core/commands/media_files/mod.rs b/crates/desktop/artcraft/src/core/commands/media_files/mod.rs deleted file mode 100644 index c3bf63aa99..0000000000 --- a/crates/desktop/artcraft/src/core/commands/media_files/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod media_file_delete_command; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/core/commands/mod.rs b/crates/desktop/artcraft/src/core/commands/mod.rs deleted file mode 100644 index 4baa4c0584..0000000000 --- a/crates/desktop/artcraft/src/core/commands/mod.rs +++ /dev/null @@ -1,15 +0,0 @@ -pub mod app_preferences; -pub mod app_state; -pub mod cost_estimate; -pub mod download; -pub mod enqueue; -pub mod flip_image; -pub mod generate; -pub mod get_app_info_command; -pub mod load_without_cors_command; -pub mod media_files; -pub mod platform_info_command; -pub mod providers; -pub mod response; -pub mod task_queue; -pub mod deprecated; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/core/commands/platform_info_command.rs b/crates/desktop/artcraft/src/core/commands/platform_info_command.rs deleted file mode 100644 index aa367be47a..0000000000 --- a/crates/desktop/artcraft/src/core/commands/platform_info_command.rs +++ /dev/null @@ -1,61 +0,0 @@ -use crate::core::commands::response::shorthand::InfallibleResponse; -use crate::core::commands::response::success_response_wrapper::SerializeMarker; -use crate::core::state::os_platform::OsPlatform; -use log::info; -use serde_derive::Serialize; - -#[derive(Debug, Serialize)] -pub struct PlatformInfoResponse { - pub os_platform: DetectedOs, - pub webview_runtime: WebviewRuntime, -} - -impl SerializeMarker for PlatformInfoResponse {} - -#[derive(Copy, Clone, Debug, Serialize)] -#[serde(rename_all = "snake_case")] -pub enum DetectedOs { - Windows, - #[serde(rename = "macos")] - MacOS, - Linux, - Unknown, -} - -#[derive(Copy, Clone, Debug, Serialize)] -#[serde(rename_all = "snake_case")] -pub enum WebviewRuntime { - #[serde(rename = "webkit_safari")] - WebkitSafari, - #[serde(rename = "webkit_gtk")] - WebkitGtk, - #[serde(rename = "edge_webview_2")] - EdgeWebview2, - Unknown, -} - -#[tauri::command] -pub fn platform_info_command() -> InfallibleResponse { - info!("platform_info_command called..."); - - let os_platform = match OsPlatform::maybe_get() { - Some(OsPlatform::Linux) => DetectedOs::Linux, - Some(OsPlatform::MacOs) => DetectedOs::MacOS, - Some(OsPlatform::Windows) => DetectedOs::Windows, - None => DetectedOs::Unknown, - }; - - // These are the webviews that Tauri uses on each OS: - // https://tauri.app/reference/webview-versions/ - let webview_runtime = match os_platform { - DetectedOs::Windows => WebviewRuntime::EdgeWebview2, - DetectedOs::MacOS => WebviewRuntime::WebkitSafari, - DetectedOs::Linux => WebviewRuntime::WebkitGtk, - DetectedOs::Unknown => WebviewRuntime::Unknown, - }; - - PlatformInfoResponse { - os_platform, - webview_runtime, - }.into() -} diff --git a/crates/desktop/artcraft/src/core/commands/providers/deprecated/get_provider_order_command.rs b/crates/desktop/artcraft/src/core/commands/providers/deprecated/get_provider_order_command.rs deleted file mode 100644 index 0b7d69c170..0000000000 --- a/crates/desktop/artcraft/src/core/commands/providers/deprecated/get_provider_order_command.rs +++ /dev/null @@ -1,30 +0,0 @@ -use crate::core::commands::response::shorthand::ResponseOrErrorMessage; -use crate::core::commands::response::success_response_wrapper::SerializeMarker; -use crate::core::state::provider_priority::{Provider, ProviderPriorityStore}; -use log::{error, info}; -use serde_derive::Serialize; -use tauri::State; - -#[derive(Serialize)] -pub struct GetProviderOrderResponse { - pub providers: Vec, -} - -impl SerializeMarker for GetProviderOrderResponse{} - -#[tauri::command] -pub async fn get_provider_order_command( - provider_priority_store: State<'_, ProviderPriorityStore>, -) -> ResponseOrErrorMessage { - info!("get_provider_order_command called"); - - let providers = provider_priority_store.get_priority() - .map_err(|err| { - error!("Failed to get provider order: {:?}", err); - "Failed to retrieve provider order" - })?; - - Ok(GetProviderOrderResponse { - providers, - }.into()) -} diff --git a/crates/desktop/artcraft/src/core/commands/providers/deprecated/mod.rs b/crates/desktop/artcraft/src/core/commands/providers/deprecated/mod.rs deleted file mode 100644 index 83c74a6411..0000000000 --- a/crates/desktop/artcraft/src/core/commands/providers/deprecated/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod get_provider_order_command; -pub mod set_provider_order_command; diff --git a/crates/desktop/artcraft/src/core/commands/providers/deprecated/set_provider_order_command.rs b/crates/desktop/artcraft/src/core/commands/providers/deprecated/set_provider_order_command.rs deleted file mode 100644 index de5892d926..0000000000 --- a/crates/desktop/artcraft/src/core/commands/providers/deprecated/set_provider_order_command.rs +++ /dev/null @@ -1,34 +0,0 @@ -use crate::core::commands::response::shorthand::SuccessOrErrorMessage; -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::core::state::provider_priority::{Provider, ProviderPriorityStore}; -use log::{error, info}; -use serde_derive::Deserialize; -use tauri::State; - -#[derive(Deserialize)] -pub struct SetProviderOrderRequest { - pub providers: Vec, -} - -#[tauri::command] -pub async fn set_provider_order_command( - request: SetProviderOrderRequest, - provider_priority_store: State<'_, ProviderPriorityStore>, - app_data_root: State<'_, AppDataRoot>, -) -> SuccessOrErrorMessage { - info!("set_provider_order_command called"); - - provider_priority_store.set_priority(&request.providers) - .map_err(|err| { - error!("Failed to set provider order: {:?}", err); - "Failed to set provider order" - })?; - - provider_priority_store.persist_to_filesystem(&app_data_root) - .map_err(|err| { - error!("Failed to persist provider order to filesystem: {:?}", err); - "Failed to persist provider order" - })?; - - Ok(().into()) -} diff --git a/crates/desktop/artcraft/src/core/commands/providers/mod.rs b/crates/desktop/artcraft/src/core/commands/providers/mod.rs deleted file mode 100644 index 74b32e1655..0000000000 --- a/crates/desktop/artcraft/src/core/commands/providers/mod.rs +++ /dev/null @@ -1,4 +0,0 @@ -pub mod deprecated; -pub mod provider_list_command; -pub mod provider_set_api_key_command; -pub mod provider_clear_command; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/core/commands/providers/provider_clear_command.rs b/crates/desktop/artcraft/src/core/commands/providers/provider_clear_command.rs deleted file mode 100644 index 150a7a2dda..0000000000 --- a/crates/desktop/artcraft/src/core/commands/providers/provider_clear_command.rs +++ /dev/null @@ -1,33 +0,0 @@ -use crate::core::commands::response::shorthand::ResponseOrErrorMessage; -use crate::core::commands::response::success_response_wrapper::SerializeMarker; -use crate::core::providers::credentials::provider_credential_key::ProviderCredentialKey; -use crate::core::providers::credentials::provider_credential_loading_cache::ProviderCredentialLoadingCache; -use log::{error, info}; -use serde_derive::{Deserialize, Serialize}; -use tauri::State; - -#[derive(Deserialize)] -pub struct ProviderClearRequest { - pub provider_credential: ProviderCredentialKey, -} - -#[derive(Serialize)] -pub struct ProviderClearResponse {} - -impl SerializeMarker for ProviderClearResponse {} - -#[tauri::command] -pub async fn provider_clear_command( - request: ProviderClearRequest, - credential_cache: State<'_, ProviderCredentialLoadingCache>, -) -> ResponseOrErrorMessage { - info!("provider_clear_command called for key: {:?}", request.provider_credential); - - credential_cache.delete_credentials(request.provider_credential) - .map_err(|err| { - error!("Failed to clear provider credential: {:?}", err); - "Failed to clear provider credential" - })?; - - Ok(ProviderClearResponse {}.into()) -} diff --git a/crates/desktop/artcraft/src/core/commands/providers/provider_list_command.rs b/crates/desktop/artcraft/src/core/commands/providers/provider_list_command.rs deleted file mode 100644 index 55eee65b61..0000000000 --- a/crates/desktop/artcraft/src/core/commands/providers/provider_list_command.rs +++ /dev/null @@ -1,106 +0,0 @@ -use crate::core::commands::response::shorthand::ResponseOrErrorMessage; -use crate::core::commands::response::success_response_wrapper::SerializeMarker; -use crate::core::providers::credentials::payload::provider_credential_payload::ProviderCredentialPayload; -use crate::core::providers::credentials::provider_credential_key::ProviderCredentialKey; -use crate::core::providers::credentials::provider_credential_loading_cache::ProviderCredentialLoadingCache; -use crate::core::providers::credentials::provider_credential_type::ProviderCredentialType; -use log::{info, warn}; -use serde_derive::Serialize; -use tauri::State; - -/// All known credential keys. Add new ones here as providers are added. -const ALL_KEYS: &[ProviderCredentialKey] = &[ - ProviderCredentialKey::FalApiKey, - ProviderCredentialKey::ReplicateApiKey, - ProviderCredentialKey::GrokWebLogin, - ProviderCredentialKey::HiggsfieldWebLogin, - ProviderCredentialKey::MidjourneyLogin, - ProviderCredentialKey::RunwayWebLogin, -]; - -const REDACTED_KEY_VISIBLE_CHARS: usize = 6; - -#[derive(Serialize)] -pub struct ProviderListResponse { - pub providers: Vec, -} - -impl SerializeMarker for ProviderListResponse {} - -#[derive(Serialize)] -pub struct ProviderListEntry { - pub provider_credential: ProviderCredentialKey, - pub credential_type: ProviderCredentialType, - pub has_credentials: bool, - pub maybe_details: Option, -} - -#[derive(Serialize)] -pub struct ProviderCredentialDetails { - /// For API keys: the first few characters followed by asterisks. - pub maybe_key_start: Option, - /// For API keys: the full key value. - pub maybe_full_key: Option, - /// For web logins: the email address if available. - pub maybe_email_address: Option, - /// For web logins: the username if available. - pub maybe_username: Option, -} - -#[tauri::command] -pub async fn provider_list_command( - credential_cache: State<'_, ProviderCredentialLoadingCache>, -) -> ResponseOrErrorMessage { - info!("provider_list_command called"); - - let mut providers = Vec::with_capacity(ALL_KEYS.len()); - - for &key in ALL_KEYS { - let maybe_payload = match credential_cache.get_credentials(key) { - Ok(payload) => payload, - Err(err) => { - warn!("Error checking credential for {:?}: {:?}", key, err); - None - } - }; - - let has_credentials = maybe_payload.is_some(); - - let maybe_details = maybe_payload.map(|payload| match payload { - ProviderCredentialPayload::ApiKey(data) => { - ProviderCredentialDetails { - maybe_key_start: Some(redact_key(data.as_str())), - maybe_full_key: Some(data.as_str().to_string()), - maybe_email_address: None, - maybe_username: None, - } - } - ProviderCredentialPayload::WebLogin(data) => { - ProviderCredentialDetails { - maybe_key_start: None, - maybe_full_key: None, - maybe_email_address: data.email_address, - maybe_username: data.username, - } - } - }); - - providers.push(ProviderListEntry { - provider_credential: key, - credential_type: key.get_type(), - has_credentials, - maybe_details, - }); - } - - Ok(ProviderListResponse { providers }.into()) -} - -fn redact_key(key: &str) -> String { - if key.len() <= REDACTED_KEY_VISIBLE_CHARS { - "********".to_string() - } else { - let visible = &key[..REDACTED_KEY_VISIBLE_CHARS]; - format!("{}********", visible) - } -} diff --git a/crates/desktop/artcraft/src/core/commands/providers/provider_set_api_key_command.rs b/crates/desktop/artcraft/src/core/commands/providers/provider_set_api_key_command.rs deleted file mode 100644 index fc08ce0f2d..0000000000 --- a/crates/desktop/artcraft/src/core/commands/providers/provider_set_api_key_command.rs +++ /dev/null @@ -1,39 +0,0 @@ -use crate::core::commands::response::shorthand::ResponseOrErrorMessage; -use crate::core::commands::response::success_response_wrapper::SerializeMarker; -use crate::core::providers::credentials::payload::api_key::ApiKeyData; -use crate::core::providers::credentials::payload::provider_credential_payload::ProviderCredentialPayload; -use crate::core::providers::credentials::provider_credential_key::ProviderCredentialKey; -use crate::core::providers::credentials::provider_credential_loading_cache::ProviderCredentialLoadingCache; -use log::{error, info}; -use serde_derive::{Deserialize, Serialize}; -use tauri::State; - -#[derive(Deserialize)] -pub struct ProviderSetApiKeyRequest { - pub provider_credential: ProviderCredentialKey, - pub api_key: String, -} - -#[derive(Serialize)] -pub struct ProviderSetApiKeyResponse {} - -impl SerializeMarker for ProviderSetApiKeyResponse {} - -#[tauri::command] -pub async fn provider_set_api_key_command( - request: ProviderSetApiKeyRequest, - credential_cache: State<'_, ProviderCredentialLoadingCache>, -) -> ResponseOrErrorMessage { - info!("provider_set_api_key_command called for provider: {:?}", request.provider_credential); - - let api_key_data = ApiKeyData::from_str(&request.api_key); - let payload = ProviderCredentialPayload::ApiKey(api_key_data); - - credential_cache.save_credentials(request.provider_credential, payload) - .map_err(|err| { - error!("Failed to save API key: {:?}", err); - "Failed to save API key" - })?; - - Ok(ProviderSetApiKeyResponse {}.into()) -} diff --git a/crates/desktop/artcraft/src/core/commands/response/failure_response_wrapper.rs b/crates/desktop/artcraft/src/core/commands/response/failure_response_wrapper.rs deleted file mode 100644 index b193791d49..0000000000 --- a/crates/desktop/artcraft/src/core/commands/response/failure_response_wrapper.rs +++ /dev/null @@ -1,53 +0,0 @@ -use serde::Serialize; - -/// Statuses for errorful commands. -#[derive(Serialize, Clone, Debug)] -#[serde(rename_all = "snake_case")] -pub enum CommandErrorStatus { - BadRequest, // 400 - Unauthorized, // 401 - TooManyRequests, // 429 - ServerError, // 500 -} - -#[derive(Serialize, Debug)] -pub struct CommandErrorResponseWrapper { - /// Both "success" and "error" types have a `status` field for the frontend. - /// We constrain the value types for successes and failures. - pub status: CommandErrorStatus, - - #[serde(skip_serializing_if = "Option::is_none")] - pub error_message: Option, - - /// Represents a "type" of error, preferably an enum without payloads. - /// Preferably this serializes to a string. - #[serde(skip_serializing_if = "Option::is_none")] - pub error_type: Option, - - /// Represents a full error details object or payload. - /// This could be a structure, message, or whatever. - #[serde(skip_serializing_if = "Option::is_none")] - pub error_details: Option, -} - -impl From<&str> for CommandErrorResponseWrapper<(), ()> { - fn from(value: &str) -> Self { - CommandErrorResponseWrapper { - status: CommandErrorStatus::BadRequest, // NB: Default to 500 error. - error_message: Some(value.to_string()), - error_type: None, - error_details: None, - } - } -} - -impl From for CommandErrorResponseWrapper<(), ()> { - fn from(value: String) -> Self { - CommandErrorResponseWrapper { - status: CommandErrorStatus::BadRequest, // NB: Default to 500 error. - error_message: Some(value), - error_type: None, - error_details: None, - } - } -} diff --git a/crates/desktop/artcraft/src/core/commands/response/mod.rs b/crates/desktop/artcraft/src/core/commands/response/mod.rs deleted file mode 100644 index d9d4f3720d..0000000000 --- a/crates/desktop/artcraft/src/core/commands/response/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub mod failure_response_wrapper; -pub mod shorthand; -pub mod success_response_wrapper; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/core/commands/response/shorthand.rs b/crates/desktop/artcraft/src/core/commands/response/shorthand.rs deleted file mode 100644 index be12a6cfea..0000000000 --- a/crates/desktop/artcraft/src/core/commands/response/shorthand.rs +++ /dev/null @@ -1,57 +0,0 @@ -use crate::core::commands::response::failure_response_wrapper::CommandErrorResponseWrapper; -use crate::core::commands::response::success_response_wrapper::CommandSuccessResponseWrapper; - -// TODO(needs command response refactor): -// - get_app_preferences_command -// - update_app_preferences_command -// - flip_image -// - check_sora_session_command -// - open_sora_login_command -// - sora_image_generation_command - -// TODO(already updated, need to update frontend): -// - platform_info_command - -// TODO(simplify error types): -// - enqueue_text_to_image_command -// - fal_background_removal_command -// - fal_hunyuan_image_to_3d_command -// - fal_kling_image_to_video_command -// - get_fal_api_key_command -// - set_fal_api_key_command -// - sora_image_remix_command - -/// Easy to use infallible response. -/// This always contains a success payload and never results in an error. -pub type InfallibleResponse = CommandSuccessResponseWrapper; - -/// Easy to use Result type. -/// -/// There are easier ways to use Response : -/// - `SimpleResponse` just returns strings on success or error (but provides clues to the frontend) -/// - `SuccessOrErrorMessage` returns an empty success payload or an error message -/// - `ResponseOrErrorMessage` returns a success payload or an error message -/// - `ResponseOrErrorType` returns a success payload or an error type -/// - `ResponseOrError` returns a success payload or an error payload -/// -pub type Response = - Result, CommandErrorResponseWrapper>; - -/// No inner payloads for this type. Just strings as messages. -pub type SimpleResponse = Response<(), (), ()>; - -/// Either an empty success payload or error message. -pub type SuccessOrErrorMessage = - Result, CommandErrorResponseWrapper<(), ()>>; - -/// Either a success or error message. -pub type ResponseOrErrorMessage = - Result, CommandErrorResponseWrapper<(), ()>>; - -/// Either a success or error type. -pub type ResponseOrErrorType = - Result, CommandErrorResponseWrapper>; - -/// Either a success or error payload. -pub type ResponseOrError = - Result, CommandErrorResponseWrapper<(), ErrPayload>>; diff --git a/crates/desktop/artcraft/src/core/commands/response/success_response_wrapper.rs b/crates/desktop/artcraft/src/core/commands/response/success_response_wrapper.rs deleted file mode 100644 index 2666ce5f36..0000000000 --- a/crates/desktop/artcraft/src/core/commands/response/success_response_wrapper.rs +++ /dev/null @@ -1,86 +0,0 @@ -use serde::Serialize; - -/// Statuses for successful commands. -#[derive(Serialize, Clone, Debug)] -#[serde(rename_all = "snake_case")] -pub enum CommandSuccessStatus { - Success, // 200 -} - -#[derive(Serialize, Debug)] -pub struct CommandSuccessResponseWrapper { - /// Both "success" and "error" types have a `status` field for the frontend. - /// We constrain the value types for successes and failures. - pub status: CommandSuccessStatus, - - #[serde(skip_serializing_if = "Option::is_none")] - pub success_message: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - pub payload: Option, -} - -/// NB: This is a hack because of `()` (a.k.a. the "unit" type) and `Serialize` trait coherence and overlap. -/// We cannot currently implement a trait for `()` and generic `Serialize` because `()` itself implements -/// `Serialize`. Rust's `"specialization"`, which would let us account for this, is an unstable, nightly-only -/// feature. So instead we manually mark all types other than `()` with `SerializeMarker` as a hack to -/// distinguish the two. -pub trait SerializeMarker : Serialize {} - -impl CommandSuccessResponseWrapper<()> { - pub fn empty_success() -> Self { - Self::empty() - } - pub fn empty() -> Self { - CommandSuccessResponseWrapper { - status: CommandSuccessStatus::Success, - success_message: None, - payload: None, - } - } -} - -// NB: () is Serialize! So we can't broadly implement just `T: Serialize`. -impl From<()> for CommandSuccessResponseWrapper<()> { - fn from(_: ()) -> Self { - CommandSuccessResponseWrapper { - status: CommandSuccessStatus::Success, - success_message: None, - payload: None, - } - } -} - -/// NB: Note the `"+ SerializeMarker"` bound here. This is a hack to distinguish between `()` and other types -/// for which we will manually mark as `SerializeMarker`. -impl From for CommandSuccessResponseWrapper where T: Serialize + SerializeMarker { - fn from(val: T) -> Self { - CommandSuccessResponseWrapper { - status: CommandSuccessStatus::Success, - success_message: None, - payload: Some(val), - } - } -} - -impl From<&str> for CommandSuccessResponseWrapper { - fn from(msg: &str) -> Self { - CommandSuccessResponseWrapper { - status: CommandSuccessStatus::Success, - success_message: Some(msg.to_string()), - payload: None, - } - } -} - -#[cfg(test)] -mod tests { - - #[test] - fn test_empty_tuple_serialize() { - let response = super::CommandSuccessResponseWrapper::<()>::from(()); - let serialized = serde_json::to_string(&response).unwrap(); - // NB: This tests that the blanket "Serialize" impl doesn't produce a "null payload" field. - assert_eq!(serialized, r#"{"status":"success"}"#); - } -} diff --git a/crates/desktop/artcraft/src/core/commands/task_queue/get_task_queue_command.rs b/crates/desktop/artcraft/src/core/commands/task_queue/get_task_queue_command.rs deleted file mode 100644 index 89cc80c7da..0000000000 --- a/crates/desktop/artcraft/src/core/commands/task_queue/get_task_queue_command.rs +++ /dev/null @@ -1,173 +0,0 @@ -use crate::core::commands::response::shorthand::ResponseOrErrorMessage; -use crate::core::commands::response::success_response_wrapper::SerializeMarker; -use crate::core::events::generation_events::generation_enqueue_success_event::GenerationEnqueueSuccessEvent; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::core::state::provider_priority::{Provider, ProviderPriorityStore}; -use crate::core::state::task_database::TaskDatabase; -use crate::services::sora::state::sora_task_queue::SoraTaskQueue; -use crate::services::storyteller::state::storyteller_credential_manager::StorytellerCredentialManager; -use chrono::{DateTime, Utc}; -use enums::common::generation_provider::GenerationProvider; -use enums::tauri::tasks::task_model_type::TaskModelType; -use enums::tauri::tasks::task_status::TaskStatus; -use enums::tauri::tasks::task_type::TaskType; -use errors::AnyhowResult; -use log::{debug, error, info, warn}; -use serde_derive::{Deserialize, Serialize}; -use sqlite_tasks::queries::list_tasks_for_frontend::list_tasks_for_frontend; -use artcraft_client::endpoints::media_files::delete_media_file::delete_media_file; -use tauri::{AppHandle, State}; -use enums::tauri::tasks::task_failure_type::TaskFailureType; -use enums::tauri::tasks::task_media_file_class::TaskMediaFileClass; -use tokens::tokens::batch_generations::BatchGenerationToken; -use tokens::tokens::media_files::MediaFileToken; -use tokens::tokens::sqlite::tasks::TaskId; - -#[derive(Serialize)] -pub struct GetTaskQueueCommandResponse { - tasks: Vec, -} - -#[derive(Serialize)] -pub struct TaskQueueItem { - pub id: TaskId, - - pub task_status: TaskStatus, - pub task_type: TaskType, - pub model_type: Option, - - pub provider: Option, - pub provider_job_id: Option, - - /// If the item is done, these will be filled out. - pub completed_item: Option, - - /// If the item failed, this will be filled out. - pub failure_reason: Option, - - pub created_at: DateTime, - pub updated_at: DateTime, - pub completed_at: Option>, -} - -#[derive(Serialize)] -pub struct CompletedItemData { - pub primary_media_file: MediaFileData, - - /// The type of file(s) generated. - pub media_file_class: Option, - - /// If generated in a batch, we probably have a batch token we can query. - pub maybe_batch_token: Option, -} - -#[derive(Serialize)] -pub struct MediaFileData { - pub token: MediaFileToken, - pub cdn_url: String, - pub maybe_thumbnail_url_template: Option, - - // NB: The frontend wants this. - pub created_at: DateTime, -} - -#[derive(Serialize)] -pub struct FailedItemData { - pub failure_type: TaskFailureType, - pub failure_message: Option, -} - -impl SerializeMarker for GetTaskQueueCommandResponse {} - -#[tauri::command] -pub async fn get_task_queue_command( - app: AppHandle, - app_env_configs: State<'_, AppEnvConfigs>, - task_database: State<'_, TaskDatabase>, -) -> ResponseOrErrorMessage { - - // NB: This is debug because it spams the logs. - debug!("get_task_queue_command called"); - - let result = handle_request( - &task_database, - ).await; - - let tasks = match result { - Ok(items) => items, - Err(err) => { - error!("get_task_queue_command failed: {:?}", err); - return Err("get_task_queue_command failed".into()) - } - }; - - Ok(GetTaskQueueCommandResponse{ - tasks, - }.into()) -} - -pub async fn handle_request( - task_database: &TaskDatabase, -) -> AnyhowResult> { - - let tasks = list_tasks_for_frontend(task_database.get_connection()) - .await?; - - let mut transformed_tasks = Vec::with_capacity(tasks.tasks.len()); - - for task in tasks.tasks.into_iter() { - let mut completed_item = None; - let mut failure_reason = None; - - if task.status == TaskStatus::CompleteSuccess { - let token_and_url = task.on_complete_primary_media_file_token - .zip(task.on_complete_primary_media_file_cdn_url); - - if let Some((primary_media_file_token, media_file_url)) = token_and_url { - completed_item = Some(CompletedItemData { - primary_media_file: MediaFileData { - token: primary_media_file_token, - cdn_url: media_file_url.clone(), - maybe_thumbnail_url_template: task.on_complete_primary_media_file_thumbnail_url_template.clone(), - // NB: This isn't the exact completion date. Also, fallback to now if missing. - created_at: task.completed_at.unwrap_or_else(Utc::now), - }, - media_file_class: task.on_complete_primary_media_file_class, - maybe_batch_token: task.on_complete_batch_token, - }); - } else { - warn!("Task {} is marked complete but has no primary media file token or URL.", task.id); - } - } else { - // If either failure field is present, fill out the failure report. - if let Some(failure_message) = task.on_failure_message.as_deref() { - failure_reason = Some(FailedItemData { - failure_type: task.on_failure_type.unwrap_or(TaskFailureType::Unknown), - failure_message: Some(failure_message.to_string()), - }); - } else if let Some(failure_type) = task.on_failure_type { - failure_reason = Some(FailedItemData { - failure_type, - failure_message: None, - }); - } - } - - transformed_tasks.push(TaskQueueItem { - id: task.id, - task_status: task.status, - task_type: task.task_type, - model_type: task.model_type, - provider: task.provider, - provider_job_id: task.provider_job_id, - created_at: task.created_at, - updated_at: task.updated_at, - completed_at: task.completed_at, - completed_item, - failure_reason, - }) - } - - Ok(transformed_tasks) -} diff --git a/crates/desktop/artcraft/src/core/commands/task_queue/mark_task_as_dismissed_command.rs b/crates/desktop/artcraft/src/core/commands/task_queue/mark_task_as_dismissed_command.rs deleted file mode 100644 index cbdeff9633..0000000000 --- a/crates/desktop/artcraft/src/core/commands/task_queue/mark_task_as_dismissed_command.rs +++ /dev/null @@ -1,64 +0,0 @@ -use crate::core::commands::response::shorthand::ResponseOrErrorMessage; -use crate::core::commands::response::success_response_wrapper::SerializeMarker; -use crate::core::events::generation_events::generation_enqueue_success_event::GenerationEnqueueSuccessEvent; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::core::state::provider_priority::{Provider, ProviderPriorityStore}; -use crate::core::state::task_database::TaskDatabase; -use crate::services::sora::state::sora_task_queue::SoraTaskQueue; -use crate::services::storyteller::state::storyteller_credential_manager::StorytellerCredentialManager; -use chrono::{DateTime, Utc}; -use errors::AnyhowResult; -use log::{error, info, warn}; -use serde_derive::{Deserialize, Serialize}; -use sqlite_tasks::queries::list_tasks_for_frontend::list_tasks_for_frontend; -use sqlite_tasks::queries::mark_task_as_dismissed::mark_task_as_dismissed; -use artcraft_client::endpoints::media_files::delete_media_file::delete_media_file; -use tauri::{AppHandle, State}; -use tokens::tokens::media_files::MediaFileToken; -use tokens::tokens::sqlite::tasks::TaskId; - -#[derive(Deserialize)] -pub struct MarkTaskAsDismissedRequest { - task: TaskId, -} - -#[derive(Serialize)] -pub struct MarkTaskAsDismissedResponse { - success: bool, -} - -impl SerializeMarker for MarkTaskAsDismissedResponse {} - -#[tauri::command] -pub async fn mark_task_as_dismissed_command( - request: MarkTaskAsDismissedRequest, - app: AppHandle, - app_env_configs: State<'_, AppEnvConfigs>, - task_database: State<'_, TaskDatabase>, -) -> ResponseOrErrorMessage { - - info!("mark_task_as_dismissed_command called"); - - let result = handle_request( - &request.task, - &task_database, - ).await; - - if let Err(err) = &result { - error!("mark_task_as_dismissed_command failed: {:?}", err); - return Err("mark_task_as_dismissed_command failed".into()) - } - - Ok(MarkTaskAsDismissedResponse{ - success: true, - }.into()) -} - -pub async fn handle_request( - task_id: &TaskId, - task_database: &TaskDatabase, -) -> AnyhowResult<()> { - let _result = mark_task_as_dismissed(task_database.get_connection(), task_id).await?; - Ok(()) -} diff --git a/crates/desktop/artcraft/src/core/commands/task_queue/mod.rs b/crates/desktop/artcraft/src/core/commands/task_queue/mod.rs deleted file mode 100644 index 2bcdeb6515..0000000000 --- a/crates/desktop/artcraft/src/core/commands/task_queue/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub mod get_task_queue_command; -pub mod mark_task_as_dismissed_command; -pub mod tasks_nuke_all_command; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/core/commands/task_queue/tasks_nuke_all_command.rs b/crates/desktop/artcraft/src/core/commands/task_queue/tasks_nuke_all_command.rs deleted file mode 100644 index dac2300aab..0000000000 --- a/crates/desktop/artcraft/src/core/commands/task_queue/tasks_nuke_all_command.rs +++ /dev/null @@ -1,57 +0,0 @@ -use crate::core::commands::response::shorthand::ResponseOrErrorMessage; -use crate::core::commands::response::success_response_wrapper::SerializeMarker; -use crate::core::events::generation_events::generation_enqueue_success_event::GenerationEnqueueSuccessEvent; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::core::state::provider_priority::{Provider, ProviderPriorityStore}; -use crate::core::state::task_database::TaskDatabase; -use crate::services::sora::state::sora_task_queue::SoraTaskQueue; -use crate::services::storyteller::state::storyteller_credential_manager::StorytellerCredentialManager; -use chrono::{DateTime, Utc}; -use errors::AnyhowResult; -use log::{error, info, warn}; -use serde_derive::{Deserialize, Serialize}; -use sqlite_tasks::queries::dismiss_all_tasks::dismiss_all_tasks; -use sqlite_tasks::queries::list_tasks_for_frontend::list_tasks_for_frontend; -use sqlite_tasks::queries::mark_task_as_dismissed::mark_task_as_dismissed; -use sqlite_tasks::queries::nuke_all_tasks::nuke_all_tasks; -use artcraft_client::endpoints::media_files::delete_media_file::delete_media_file; -use tauri::{AppHandle, State}; -use tokens::tokens::media_files::MediaFileToken; -use tokens::tokens::sqlite::tasks::TaskId; - -#[derive(Serialize)] -pub struct TasksNukeAllResponse { - success: bool, -} - -impl SerializeMarker for TasksNukeAllResponse {} - -#[tauri::command] -pub async fn tasks_nuke_all_command( - task_database: State<'_, TaskDatabase>, -) -> ResponseOrErrorMessage { - - info!("tasks_nuke_all_command called"); - - let result = handle_request( - &task_database, - ).await; - - if let Err(err) = &result { - error!("tasks_nuke_all_command failed: {:?}", err); - return Err("tasks_nuke_all_command failed".into()) - } - - Ok(TasksNukeAllResponse{ - success: true, - }.into()) -} - -pub async fn handle_request( - task_database: &TaskDatabase, -) -> AnyhowResult<()> { - let _result = nuke_all_tasks(task_database.get_connection()).await?; - let _result = dismiss_all_tasks(task_database.get_connection()).await?; - Ok(()) -} diff --git a/crates/desktop/artcraft/src/core/events/basic_sendable_event_trait.rs b/crates/desktop/artcraft/src/core/events/basic_sendable_event_trait.rs deleted file mode 100644 index 8eae34f14b..0000000000 --- a/crates/desktop/artcraft/src/core/events/basic_sendable_event_trait.rs +++ /dev/null @@ -1,59 +0,0 @@ -use crate::core::events::sendable_event_error::SendableEventError; -use enums::tauri::ux::tauri_event_name::TauriEventName; -use log::{error, info}; -use serde::Serialize; -use std::fmt::Debug; -use tauri::{AppHandle, Emitter}; - -// Tagged enums here are waaay too "Rustic" -// #[derive(Clone, Serialize)] -// #[serde(rename_all = "camelCase", rename_all_fields = "camelCase", tag = "event", content = "data")] -// pub enum BasicEvent { -// Success(T), -// Failure(T), -// } - -#[derive(Copy, Clone, Debug, Serialize)] -#[serde(rename_all = "snake_case")] -pub enum BasicEventStatus { - Success, - Failure, -} - -/// Wrap the event with "status" and "data" fields. -#[derive(Clone, Debug, Serialize)] -#[serde(rename_all = "snake_case")] -struct BasicEventWrapper { - status: BasicEventStatus, - data: T, -} - -pub trait BasicSendableEvent : Clone + Debug + Serialize { - /// This is the name of the event that the frontend subscribes to. - const FRONTEND_EVENT_NAME: TauriEventName; - - /// This is the status of the event: Success, Failure, etc. - const EVENT_STATUS: BasicEventStatus; - - /// Default implementation of send(). - /// This serializes and sends the event to the frontend. - fn send(&self, app: &AppHandle) -> Result<(), SendableEventError> { - let wrapped = BasicEventWrapper { - status: Self::EVENT_STATUS, - data: self.clone(), - }; - info!("Sending event to frontend: {} ; payload = {:?}", Self::FRONTEND_EVENT_NAME.to_str(), wrapped); - let result = app.emit(Self::FRONTEND_EVENT_NAME.to_str(), wrapped); - if let Err(err) = result { - return Err(SendableEventError::from(err)); - } - Ok(()) - } - - fn send_infallible(&self, app: &AppHandle) { - if let Err(err) = self.send(app) { - // Fail open - error!("Failed to send event `{}`: {:?}", Self::FRONTEND_EVENT_NAME.to_str(), err); - } - } -} diff --git a/crates/desktop/artcraft/src/core/events/functional_events/canvas_background_removal_complete_event.rs b/crates/desktop/artcraft/src/core/events/functional_events/canvas_background_removal_complete_event.rs deleted file mode 100644 index 54fd74decb..0000000000 --- a/crates/desktop/artcraft/src/core/events/functional_events/canvas_background_removal_complete_event.rs +++ /dev/null @@ -1,19 +0,0 @@ -use crate::core::events::basic_sendable_event_trait::{BasicEventStatus, BasicSendableEvent}; -use enums::tauri::ux::tauri_event_name::TauriEventName; -use serde_derive::Serialize; -use tokens::tokens::media_files::MediaFileToken; -use url::Url; - -#[derive(Clone, Debug, Serialize)] -#[serde(rename_all = "snake_case")] -pub struct CanvasBackgroundRemovalCompleteEvent { - pub media_token: MediaFileToken, - pub image_cdn_url: Url, - pub maybe_frontend_subscriber_id: Option, - pub maybe_frontend_subscriber_payload: Option, -} - -impl BasicSendableEvent for CanvasBackgroundRemovalCompleteEvent { - const FRONTEND_EVENT_NAME: TauriEventName = TauriEventName::CanvasBgRemovedEvent; - const EVENT_STATUS: BasicEventStatus = BasicEventStatus::Success; -} diff --git a/crates/desktop/artcraft/src/core/events/functional_events/credits_balance_changed_event.rs b/crates/desktop/artcraft/src/core/events/functional_events/credits_balance_changed_event.rs deleted file mode 100644 index c295351c19..0000000000 --- a/crates/desktop/artcraft/src/core/events/functional_events/credits_balance_changed_event.rs +++ /dev/null @@ -1,17 +0,0 @@ -use crate::core::events::basic_sendable_event_trait::{BasicEventStatus, BasicSendableEvent}; -use enums::tauri::ux::tauri_event_name::TauriEventName; -use serde_derive::Serialize; -use tokens::tokens::media_files::MediaFileToken; -use url::Url; - -#[derive(Clone, Debug, Serialize)] -#[serde(rename_all = "snake_case")] -pub struct CreditsBalanceChangedEvent { - // NB: We don't know how much was added or removed, just that it changed. - // The frontend should re-query the balance -} - -impl BasicSendableEvent for CreditsBalanceChangedEvent { - const FRONTEND_EVENT_NAME: TauriEventName = TauriEventName::CreditsBalanceChangedEvent; - const EVENT_STATUS: BasicEventStatus = BasicEventStatus::Success; -} diff --git a/crates/desktop/artcraft/src/core/events/functional_events/gaussian_generation_complete_event.rs b/crates/desktop/artcraft/src/core/events/functional_events/gaussian_generation_complete_event.rs deleted file mode 100644 index 51ffda4794..0000000000 --- a/crates/desktop/artcraft/src/core/events/functional_events/gaussian_generation_complete_event.rs +++ /dev/null @@ -1,26 +0,0 @@ -use crate::core::events::basic_sendable_event_trait::{BasicEventStatus, BasicSendableEvent}; -use enums::tauri::ux::tauri_event_name::TauriEventName; -use serde_derive::Serialize; -use tokens::tokens::media_files::MediaFileToken; -use url::Url; - -#[derive(Clone, Debug, Serialize)] -#[serde(rename_all = "snake_case")] -pub struct GaussianGenerationCompleteEvent { - pub generated_gaussian: Option, - pub maybe_frontend_subscriber_id: Option, - pub maybe_frontend_subscriber_payload: Option, -} - -#[derive(Clone, Debug, Serialize)] -#[serde(rename_all = "snake_case")] -pub struct GeneratedGaussian { - pub media_token: MediaFileToken, - pub cdn_url: Url, - pub maybe_thumbnail_template: Option, -} - -impl BasicSendableEvent for GaussianGenerationCompleteEvent { - const FRONTEND_EVENT_NAME: TauriEventName = TauriEventName::GaussianGenerationCompleteEvent; - const EVENT_STATUS: BasicEventStatus = BasicEventStatus::Success; -} diff --git a/crates/desktop/artcraft/src/core/events/functional_events/image_edit_complete_event.rs b/crates/desktop/artcraft/src/core/events/functional_events/image_edit_complete_event.rs deleted file mode 100644 index ca89dcbb22..0000000000 --- a/crates/desktop/artcraft/src/core/events/functional_events/image_edit_complete_event.rs +++ /dev/null @@ -1,27 +0,0 @@ -use crate::core::events::basic_sendable_event_trait::{BasicEventStatus, BasicSendableEvent}; -use enums::tauri::ux::tauri_event_name::TauriEventName; -use serde_derive::Serialize; -use tokens::tokens::media_files::MediaFileToken; -use url::Url; - -#[derive(Clone, Debug, Serialize)] -#[serde(rename_all = "snake_case")] -pub struct ImageEditCompleteEvent { - // pub source_media_token: MediaFileToken, - pub edited_images: Vec, - pub maybe_frontend_subscriber_id: Option, - pub maybe_frontend_subscriber_payload: Option, -} - -#[derive(Clone, Debug, Serialize)] -#[serde(rename_all = "snake_case")] -pub struct EditedImage { - pub media_token: MediaFileToken, - pub cdn_url: Url, - pub maybe_thumbnail_template: Option, -} - -impl BasicSendableEvent for ImageEditCompleteEvent { - const FRONTEND_EVENT_NAME: TauriEventName = TauriEventName::ImageEditCompleteEvent; - const EVENT_STATUS: BasicEventStatus = BasicEventStatus::Success; -} diff --git a/crates/desktop/artcraft/src/core/events/functional_events/media_file_deleted_event.rs b/crates/desktop/artcraft/src/core/events/functional_events/media_file_deleted_event.rs deleted file mode 100644 index a77d15a0d5..0000000000 --- a/crates/desktop/artcraft/src/core/events/functional_events/media_file_deleted_event.rs +++ /dev/null @@ -1,16 +0,0 @@ -use crate::core::events::basic_sendable_event_trait::{BasicEventStatus, BasicSendableEvent}; -use enums::tauri::ux::tauri_event_name::TauriEventName; -use serde_derive::Serialize; -use tokens::tokens::media_files::MediaFileToken; -use url::Url; - -#[derive(Clone, Debug, Serialize)] -#[serde(rename_all = "snake_case")] -pub struct MediaFileDeletedEvent { - pub media_file_token: MediaFileToken, -} - -impl BasicSendableEvent for MediaFileDeletedEvent { - const FRONTEND_EVENT_NAME: TauriEventName = TauriEventName::MediaFileDeletedEvent; - const EVENT_STATUS: BasicEventStatus = BasicEventStatus::Success; -} diff --git a/crates/desktop/artcraft/src/core/events/functional_events/mod.rs b/crates/desktop/artcraft/src/core/events/functional_events/mod.rs deleted file mode 100644 index 2ef485383a..0000000000 --- a/crates/desktop/artcraft/src/core/events/functional_events/mod.rs +++ /dev/null @@ -1,12 +0,0 @@ -pub mod canvas_background_removal_complete_event; -pub mod credits_balance_changed_event; -pub mod gaussian_generation_complete_event; -pub mod image_edit_complete_event; -pub mod media_file_deleted_event; -pub mod object_generation_complete_event; -pub mod refresh_account_state_event; -pub mod show_provider_billing_modal_event; -pub mod show_provider_login_modal_event; -pub mod subscription_plan_changed_event; -pub mod text_to_image_generation_complete_event; -pub mod video_generation_complete_event; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/core/events/functional_events/object_generation_complete_event.rs b/crates/desktop/artcraft/src/core/events/functional_events/object_generation_complete_event.rs deleted file mode 100644 index 43b2311886..0000000000 --- a/crates/desktop/artcraft/src/core/events/functional_events/object_generation_complete_event.rs +++ /dev/null @@ -1,26 +0,0 @@ -use crate::core::events::basic_sendable_event_trait::{BasicEventStatus, BasicSendableEvent}; -use enums::tauri::ux::tauri_event_name::TauriEventName; -use serde_derive::Serialize; -use tokens::tokens::media_files::MediaFileToken; -use url::Url; - -#[derive(Clone, Debug, Serialize)] -#[serde(rename_all = "snake_case")] -pub struct ObjectGenerationCompleteEvent { - pub generated_object: Option, - pub maybe_frontend_subscriber_id: Option, - pub maybe_frontend_subscriber_payload: Option, -} - -#[derive(Clone, Debug, Serialize)] -#[serde(rename_all = "snake_case")] -pub struct GeneratedObject { - pub media_token: MediaFileToken, - pub cdn_url: Url, - pub maybe_thumbnail_template: Option, -} - -impl BasicSendableEvent for ObjectGenerationCompleteEvent { - const FRONTEND_EVENT_NAME: TauriEventName = TauriEventName::ObjectGenerationCompleteEvent; - const EVENT_STATUS: BasicEventStatus = BasicEventStatus::Success; -} diff --git a/crates/desktop/artcraft/src/core/events/functional_events/refresh_account_state_event.rs b/crates/desktop/artcraft/src/core/events/functional_events/refresh_account_state_event.rs deleted file mode 100644 index 56d55ad94f..0000000000 --- a/crates/desktop/artcraft/src/core/events/functional_events/refresh_account_state_event.rs +++ /dev/null @@ -1,19 +0,0 @@ -use crate::core::events::basic_sendable_event_trait::{BasicEventStatus, BasicSendableEvent}; -use enums::common::generation_provider::GenerationProvider; -use enums::tauri::ux::tauri_event_name::TauriEventName; -use serde_derive::Serialize; - -/// Send a signal to the frontend that an account state has changed: login, -/// logout, invalidated, etc. -#[derive(Clone, Debug, Serialize)] -#[serde(rename_all = "snake_case")] -pub struct RefreshAccountStateEvent { - /// The frontend can optionally decide whether it wants to refresh based - /// on the impacted provider account. - pub provider: Option, -} - -impl BasicSendableEvent for RefreshAccountStateEvent { - const FRONTEND_EVENT_NAME: TauriEventName = TauriEventName::RefreshAccountStateEvent; - const EVENT_STATUS: BasicEventStatus = BasicEventStatus::Success; -} diff --git a/crates/desktop/artcraft/src/core/events/functional_events/show_provider_billing_modal_event.rs b/crates/desktop/artcraft/src/core/events/functional_events/show_provider_billing_modal_event.rs deleted file mode 100644 index 1aaa4b5102..0000000000 --- a/crates/desktop/artcraft/src/core/events/functional_events/show_provider_billing_modal_event.rs +++ /dev/null @@ -1,25 +0,0 @@ -use crate::core::events::basic_sendable_event_trait::{BasicEventStatus, BasicSendableEvent}; -use enums::common::generation_provider::GenerationProvider; -use enums::tauri::ux::tauri_event_name::TauriEventName; -use serde_derive::Serialize; -use tauri::AppHandle; - -/// Send a signal to the frontend to show a modal that suggests fixing or setting up -/// service billing requirements. -#[derive(Clone, Debug, Serialize)] -#[serde(rename_all = "snake_case")] -pub struct ShowProviderBillingModalEvent { - pub provider: GenerationProvider, -} - -impl ShowProviderBillingModalEvent { - pub fn send_for_provider(provider: GenerationProvider, app: &AppHandle) { - let event = Self { provider }; - event.send_infallible(&app); - } -} - -impl BasicSendableEvent for ShowProviderBillingModalEvent { - const FRONTEND_EVENT_NAME: TauriEventName = TauriEventName::ShowProviderBillingModalEvent; - const EVENT_STATUS: BasicEventStatus = BasicEventStatus::Failure; -} diff --git a/crates/desktop/artcraft/src/core/events/functional_events/show_provider_login_modal_event.rs b/crates/desktop/artcraft/src/core/events/functional_events/show_provider_login_modal_event.rs deleted file mode 100644 index 9e4726c367..0000000000 --- a/crates/desktop/artcraft/src/core/events/functional_events/show_provider_login_modal_event.rs +++ /dev/null @@ -1,24 +0,0 @@ -use crate::core::events::basic_sendable_event_trait::{BasicEventStatus, BasicSendableEvent}; -use enums::common::generation_provider::GenerationProvider; -use enums::tauri::ux::tauri_event_name::TauriEventName; -use serde_derive::Serialize; -use tauri::AppHandle; - -/// Send a signal to the frontend to show a modal that suggests service setup. -#[derive(Clone, Debug, Serialize)] -#[serde(rename_all = "snake_case")] -pub struct ShowProviderLoginModalEvent { - pub provider: GenerationProvider, -} - -impl ShowProviderLoginModalEvent { - pub fn send_for_provider(provider: GenerationProvider, app: &AppHandle) { - let event = Self { provider }; - event.send_infallible(&app); - } -} - -impl BasicSendableEvent for ShowProviderLoginModalEvent { - const FRONTEND_EVENT_NAME: TauriEventName = TauriEventName::ShowProviderLoginModalEvent; - const EVENT_STATUS: BasicEventStatus = BasicEventStatus::Failure; -} diff --git a/crates/desktop/artcraft/src/core/events/functional_events/subscription_plan_changed_event.rs b/crates/desktop/artcraft/src/core/events/functional_events/subscription_plan_changed_event.rs deleted file mode 100644 index 78174ce4b8..0000000000 --- a/crates/desktop/artcraft/src/core/events/functional_events/subscription_plan_changed_event.rs +++ /dev/null @@ -1,18 +0,0 @@ -use crate::core::events::basic_sendable_event_trait::{BasicEventStatus, BasicSendableEvent}; -use enums::tauri::ux::tauri_event_name::TauriEventName; -use serde_derive::Serialize; -use tokens::tokens::media_files::MediaFileToken; -use url::Url; - -#[derive(Clone, Debug, Serialize)] -#[serde(rename_all = "snake_case")] -pub struct SubscriptionPlanChangedEvent { - // NB: We don't know what plan was changed (subscribed, upgraded, canceled, etc.), - // just that it changed. The actual fulfillment is async anyway. - // The frontend should re-query the subscription plan after a short delay. -} - -impl BasicSendableEvent for SubscriptionPlanChangedEvent { - const FRONTEND_EVENT_NAME: TauriEventName = TauriEventName::SubscriptionPlanChangedEvent; - const EVENT_STATUS: BasicEventStatus = BasicEventStatus::Success; -} diff --git a/crates/desktop/artcraft/src/core/events/functional_events/text_to_image_generation_complete_event.rs b/crates/desktop/artcraft/src/core/events/functional_events/text_to_image_generation_complete_event.rs deleted file mode 100644 index 31736a94bd..0000000000 --- a/crates/desktop/artcraft/src/core/events/functional_events/text_to_image_generation_complete_event.rs +++ /dev/null @@ -1,26 +0,0 @@ -use crate::core::events::basic_sendable_event_trait::{BasicEventStatus, BasicSendableEvent}; -use enums::tauri::ux::tauri_event_name::TauriEventName; -use serde_derive::Serialize; -use tokens::tokens::media_files::MediaFileToken; -use url::Url; - -#[derive(Clone, Debug, Serialize)] -#[serde(rename_all = "snake_case")] -pub struct TextToImageGenerationCompleteEvent { - pub generated_images: Vec, - pub maybe_frontend_subscriber_id: Option, - pub maybe_frontend_subscriber_payload: Option, -} - -#[derive(Clone, Debug, Serialize)] -#[serde(rename_all = "snake_case")] -pub struct GeneratedImage { - pub media_token: MediaFileToken, - pub cdn_url: Url, - pub maybe_thumbnail_template: Option, -} - -impl BasicSendableEvent for TextToImageGenerationCompleteEvent { - const FRONTEND_EVENT_NAME: TauriEventName = TauriEventName::TextToImageGenerationCompleteEvent; - const EVENT_STATUS: BasicEventStatus = BasicEventStatus::Success; -} diff --git a/crates/desktop/artcraft/src/core/events/functional_events/video_generation_complete_event.rs b/crates/desktop/artcraft/src/core/events/functional_events/video_generation_complete_event.rs deleted file mode 100644 index 5e20bcf548..0000000000 --- a/crates/desktop/artcraft/src/core/events/functional_events/video_generation_complete_event.rs +++ /dev/null @@ -1,26 +0,0 @@ -use crate::core::events::basic_sendable_event_trait::{BasicEventStatus, BasicSendableEvent}; -use enums::tauri::ux::tauri_event_name::TauriEventName; -use serde_derive::Serialize; -use tokens::tokens::media_files::MediaFileToken; -use url::Url; - -#[derive(Clone, Debug, Serialize)] -#[serde(rename_all = "snake_case")] -pub struct VideoGenerationCompleteEvent { - pub generated_video: Option, - pub maybe_frontend_subscriber_id: Option, - pub maybe_frontend_subscriber_payload: Option, -} - -#[derive(Clone, Debug, Serialize)] -#[serde(rename_all = "snake_case")] -pub struct GeneratedVideo { - pub media_token: MediaFileToken, - pub cdn_url: Url, - pub maybe_thumbnail_template: Option, -} - -impl BasicSendableEvent for VideoGenerationCompleteEvent { - const FRONTEND_EVENT_NAME: TauriEventName = TauriEventName::VideoGenerationCompleteEvent; - const EVENT_STATUS: BasicEventStatus = BasicEventStatus::Success; -} diff --git a/crates/desktop/artcraft/src/core/events/generation_events/common.rs b/crates/desktop/artcraft/src/core/events/generation_events/common.rs deleted file mode 100644 index 12484e62fc..0000000000 --- a/crates/desktop/artcraft/src/core/events/generation_events/common.rs +++ /dev/null @@ -1,164 +0,0 @@ -use serde::Serialize; - -#[derive(Debug, Copy, Clone, Serialize)] -#[serde(rename_all = "snake_case")] -pub enum GenerationServiceProvider { - Artcraft, - Fal, - Grok, - Midjourney, - Sora, - WorldLabs, - Higgsfield, - Krea, - Leonardo, - Magnific, - Openart, - Picsart, - Pixverse, - Runway, -} - -#[derive(Debug, Clone, Serialize)] -#[serde(rename_all = "snake_case")] -pub enum GenerationModel { - #[serde(rename = "flux_1_dev")] - Flux1Dev, - #[serde(rename = "flux_1_schnell")] - Flux1Schnell, - #[serde(rename = "flux_dev_juggernaut")] - FluxDevJuggernaut, - #[serde(rename = "flux_pro_1")] - FluxPro1, - #[serde(rename = "flux_pro_1.1")] - FluxPro11, - #[serde(rename = "flux_pro_1.1_ultra")] - FluxPro11Ultra, - - #[serde(rename = "flux_pro_kontext_max")] - FluxProKontextMax, - #[serde(rename = "gpt_image_1")] - GptImage1, - #[serde(rename = "gpt_image_1p5")] - GptImage1p5, - #[serde(rename = "gpt_image_2")] - GptImage2, - #[serde(rename = "gpt_image_2p5_flare")] - GptImage2p5Flare, - #[serde(rename = "gpt_image_2p5_sunburst")] - GptImage2p5Sunburst, - #[serde(rename = "grok_image")] - GrokImage, - #[serde(rename = "gemini_25_flash")] - Gemini25Flash, - #[serde(rename = "nano_banana")] - NanoBanana, - #[serde(rename = "nano_banana_2")] - NanoBanana2, - #[serde(rename = "nano_banana_pro")] - NanoBananaPro, - #[serde(rename = "seedream_4")] - Seedream4, - #[serde(rename = "seedream_4p5")] - Seedream4p5, - #[serde(rename = "seedream_5_lite")] - Seedream5Lite, - - #[serde(rename = "qwen_edit_2511_angles")] - QwenEdit2511Angles, - #[serde(rename = "flux_2_lora_angles")] - Flux2LoraAngles, - - #[serde(rename = "hunyuan_3d_2_0")] - Hunyuan3d2_0, - #[serde(rename = "hunyuan_3d_2_1")] - Hunyuan3d2_1, - #[serde(rename = "hunyuan_3d_3")] - Hunyuan3d3, - - #[serde(rename = "worldlabs_marble")] - WorldlabsMarble, - #[serde(rename = "worldlabs_marble_0p1_mini")] - WorldlabsMarble0p1Mini, - #[serde(rename = "worldlabs_marble_0p1_plus")] - WorldlabsMarble0p1Plus, - - // Generic Midjourney model, version unknown. - #[serde(rename = "midjourney")] - Midjourney, - #[serde(rename = "midjourney_7")] - Midjourney7, - #[serde(rename = "midjourney_7_niji")] - Midjourney7Niji, - #[serde(rename = "midjourney_8")] - Midjourney8, - - // Generic Grok video model, version unknown. - #[serde(rename = "grok_video")] - GrokVideo, - #[serde(rename = "grok_imagine_video_1p5")] - GrokImagineVideo1p5, - // TODO: Should be Kling16Pro - #[serde(rename = "kling_1.6")] - Kling1_6, - #[serde(rename = "kling_2.0")] - Kling2_0, - #[serde(rename = "kling_2.1_master")] - Kling21Master, - #[serde(rename = "kling_2.1_pro")] - Kling21Pro, - #[serde(rename = "kling_2p5_turbo_pro")] - Kling2p5TurboPro, - #[serde(rename = "kling_2p6_pro")] - Kling2p6Pro, - #[serde(rename = "kling_3p0_standard")] - Kling3p0Standard, - #[serde(rename = "kling_3p0_pro")] - Kling3p0Pro, - #[serde(rename = "happy_horse_1p0")] - HappyHorse1p0, - #[serde(rename = "recraft_3")] - Recraft3, - #[serde(rename = "sora")] - Sora, - #[serde(rename = "sora_2")] - Sora2, - #[serde(rename = "sora_2_pro")] - Sora2Pro, - #[serde(rename = "seedance_1.0_lite")] - Seedance10Lite, - #[serde(rename = "seedance_1p5_pro")] - Seedance1p5Pro, - #[serde(rename = "seedance_2p0")] - Seedance2p0, - #[serde(rename = "seedance_2p0_fast")] - Seedance2p0Fast, - #[serde(rename = "veo_2")] - Veo2, - #[serde(rename = "veo_3")] - Veo3, - #[serde(rename = "veo_3_fast")] - Veo3Fast, - #[serde(rename = "veo_3p1")] - Veo3p1, - #[serde(rename = "veo_3p1_fast")] - Veo3p1Fast, - - /// An API model ID that does not need a compiled desktop variant. - #[serde(untagged)] - Unknown(String), -} - -#[derive(Debug, Copy, Clone, Serialize)] -#[serde(rename_all = "snake_case")] -pub enum GenerationAction { - GenerateImage, - GenerateVideo, - GenerateAudio, - RemoveBackground, - #[serde(rename = "image_to_3d")] - ImageTo3d, - GenerateGaussian, - #[serde(rename = "image_inpaint_edit")] - ImageInpaintEdit, -} diff --git a/crates/desktop/artcraft/src/core/events/generation_events/generation_complete_event.rs b/crates/desktop/artcraft/src/core/events/generation_events/generation_complete_event.rs deleted file mode 100644 index e1c225dc41..0000000000 --- a/crates/desktop/artcraft/src/core/events/generation_events/generation_complete_event.rs +++ /dev/null @@ -1,17 +0,0 @@ -use crate::core::events::basic_sendable_event_trait::{BasicEventStatus, BasicSendableEvent}; -use crate::core::events::generation_events::common::{GenerationAction, GenerationModel, GenerationServiceProvider}; -use enums::tauri::ux::tauri_event_name::TauriEventName; -use serde_derive::Serialize; - -#[derive(Clone, Debug, Serialize)] -#[serde(rename_all = "snake_case")] -pub struct GenerationCompleteEvent { - pub action: Option, - pub service: GenerationServiceProvider, - pub model: Option, -} - -impl BasicSendableEvent for GenerationCompleteEvent { - const FRONTEND_EVENT_NAME: TauriEventName = TauriEventName::GenerationCompleteEvent; - const EVENT_STATUS: BasicEventStatus = BasicEventStatus::Success; -} diff --git a/crates/desktop/artcraft/src/core/events/generation_events/generation_enqueue_failure_event.rs b/crates/desktop/artcraft/src/core/events/generation_events/generation_enqueue_failure_event.rs deleted file mode 100644 index c55620f983..0000000000 --- a/crates/desktop/artcraft/src/core/events/generation_events/generation_enqueue_failure_event.rs +++ /dev/null @@ -1,40 +0,0 @@ -use crate::core::events::basic_sendable_event_trait::{BasicEventStatus, BasicSendableEvent}; -use crate::core::events::generation_events::common::{GenerationAction, GenerationModel, GenerationServiceProvider}; -use enums::tauri::ux::tauri_event_name::TauriEventName; -use serde_derive::Serialize; - -#[derive(Clone, Debug, Serialize)] -#[serde(rename_all = "snake_case")] -pub struct GenerationEnqueueFailureEvent { - pub action: GenerationAction, - pub service: GenerationServiceProvider, - pub model: Option, - - /// User-facing reason for the failure, if available. - pub reason: Option, -} - -impl BasicSendableEvent for GenerationEnqueueFailureEvent { - const FRONTEND_EVENT_NAME: TauriEventName = TauriEventName::GenerationEnqueueFailureEvent; - const EVENT_STATUS: BasicEventStatus = BasicEventStatus::Failure; -} - -impl GenerationEnqueueFailureEvent { - pub fn no_artcraft_credentials(action: GenerationAction) -> Self { - Self { - action, - service: GenerationServiceProvider::Artcraft, - model: None, - reason: Some("Please log into Artcraft.".to_string()), - } - } - - pub fn no_fal_api_key(action: GenerationAction) -> Self { - Self { - action, - service: GenerationServiceProvider::Fal, - model: None, - reason: Some("No FAL API key is set. Configure this in your settings.".to_string()), - } - } -} diff --git a/crates/desktop/artcraft/src/core/events/generation_events/generation_enqueue_success_event.rs b/crates/desktop/artcraft/src/core/events/generation_events/generation_enqueue_success_event.rs deleted file mode 100644 index 7737d3477a..0000000000 --- a/crates/desktop/artcraft/src/core/events/generation_events/generation_enqueue_success_event.rs +++ /dev/null @@ -1,17 +0,0 @@ -use crate::core::events::basic_sendable_event_trait::{BasicEventStatus, BasicSendableEvent}; -use crate::core::events::generation_events::common::{GenerationAction, GenerationModel, GenerationServiceProvider}; -use enums::tauri::ux::tauri_event_name::TauriEventName; -use serde_derive::Serialize; - -#[derive(Clone, Debug, Serialize)] -#[serde(rename_all = "snake_case")] -pub struct GenerationEnqueueSuccessEvent { - pub action: GenerationAction, - pub service: GenerationServiceProvider, - pub model: Option, -} - -impl BasicSendableEvent for GenerationEnqueueSuccessEvent { - const FRONTEND_EVENT_NAME: TauriEventName = TauriEventName::GenerationEnqueueSuccessEvent; - const EVENT_STATUS: BasicEventStatus = BasicEventStatus::Success; -} diff --git a/crates/desktop/artcraft/src/core/events/generation_events/generation_failed_event.rs b/crates/desktop/artcraft/src/core/events/generation_events/generation_failed_event.rs deleted file mode 100644 index f4d580fc43..0000000000 --- a/crates/desktop/artcraft/src/core/events/generation_events/generation_failed_event.rs +++ /dev/null @@ -1,20 +0,0 @@ -use crate::core::events::basic_sendable_event_trait::{BasicEventStatus, BasicSendableEvent}; -use crate::core::events::generation_events::common::{GenerationAction, GenerationModel, GenerationServiceProvider}; -use enums::tauri::ux::tauri_event_name::TauriEventName; -use serde_derive::Serialize; - -#[derive(Clone, Debug, Serialize)] -#[serde(rename_all = "snake_case")] -pub struct GenerationFailedEvent { - pub action: GenerationAction, - pub service: GenerationServiceProvider, - pub model: Option, - - /// User-facing reason for the failure, if available. - pub reason: Option, -} - -impl BasicSendableEvent for GenerationFailedEvent { - const FRONTEND_EVENT_NAME: TauriEventName = TauriEventName::GenerationFailedEvent; - const EVENT_STATUS: BasicEventStatus = BasicEventStatus::Failure; -} diff --git a/crates/desktop/artcraft/src/core/events/generation_events/mod.rs b/crates/desktop/artcraft/src/core/events/generation_events/mod.rs deleted file mode 100644 index 67ff3ba2df..0000000000 --- a/crates/desktop/artcraft/src/core/events/generation_events/mod.rs +++ /dev/null @@ -1,5 +0,0 @@ -pub mod common; -pub mod generation_enqueue_failure_event; -pub mod generation_enqueue_success_event; -pub mod generation_complete_event; -pub mod generation_failed_event; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/core/events/mod.rs b/crates/desktop/artcraft/src/core/events/mod.rs deleted file mode 100644 index f3e7c25b00..0000000000 --- a/crates/desktop/artcraft/src/core/events/mod.rs +++ /dev/null @@ -1,6 +0,0 @@ -pub mod basic_sendable_event_trait; -pub mod functional_events; -pub mod generation_events; -pub mod sendable_event_error; -pub mod sendable_event_trait; -pub mod warning_events; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/core/events/sendable_event_error.rs b/crates/desktop/artcraft/src/core/events/sendable_event_error.rs deleted file mode 100644 index 25d4a57433..0000000000 --- a/crates/desktop/artcraft/src/core/events/sendable_event_error.rs +++ /dev/null @@ -1,31 +0,0 @@ -use std::error::Error; -use std::fmt::{Display, Formatter}; - -#[derive(Debug)] -pub enum SendableEventError { - TauriError(tauri::Error), - AnyhowError(anyhow::Error), -} - -impl Error for SendableEventError {} - -impl Display for SendableEventError { - fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { - match self { - Self::TauriError(err) => write!(f, "SendableEventError::TauriError: {}", err), - Self::AnyhowError(err) => write!(f, "SendableEventError::AnyhowError: {}", err), - } - } -} - -impl From for SendableEventError { - fn from(err: anyhow::Error) -> Self { - SendableEventError::AnyhowError(err) - } -} - -impl From for SendableEventError { - fn from(err: tauri::Error) -> Self { - SendableEventError::TauriError(err) - } -} diff --git a/crates/desktop/artcraft/src/core/events/sendable_event_trait.rs b/crates/desktop/artcraft/src/core/events/sendable_event_trait.rs deleted file mode 100644 index 11641ba869..0000000000 --- a/crates/desktop/artcraft/src/core/events/sendable_event_trait.rs +++ /dev/null @@ -1,23 +0,0 @@ -use crate::core::events::sendable_event_error::SendableEventError; -use log::info; -use serde::Serialize; -use tauri::{AppHandle, Emitter}; - -/// Implement this on a Serializable object to be able to send it as an event to the frontend. -#[deprecated(note = "Use BasicSendableEvent instead as it wraps the event with status and data fields.")] -pub trait SendableEvent : Serialize { - /// This is the name of the event that the frontend subscribes to. - const FRONTEND_EVENT_NAME: &'static str; - - /// Default implementation of send(). - /// This serializes and sends the event to the frontend. - #[deprecated(note = "Use BasicSendableEvent instead as it wraps the event with status and data fields.")] - fn send(&self, app: &AppHandle) -> Result<(), SendableEventError> { - info!("Sending event to frontend: {}", Self::FRONTEND_EVENT_NAME); - let result = app.emit(Self::FRONTEND_EVENT_NAME, self); - if let Err(err) = result { - return Err(SendableEventError::from(err)); - } - Ok(()) - } -} diff --git a/crates/desktop/artcraft/src/core/events/warning_events/flash_file_download_error_event.rs b/crates/desktop/artcraft/src/core/events/warning_events/flash_file_download_error_event.rs deleted file mode 100644 index a1bea798a4..0000000000 --- a/crates/desktop/artcraft/src/core/events/warning_events/flash_file_download_error_event.rs +++ /dev/null @@ -1,26 +0,0 @@ -use crate::core::events::basic_sendable_event_trait::{BasicEventStatus, BasicSendableEvent}; -use enums::tauri::ux::tauri_event_name::TauriEventName; -use serde_derive::Serialize; -use std::path::PathBuf; - -#[derive(Clone, Debug, Serialize)] -#[serde(rename_all = "snake_case")] -pub struct FlashFileDownloadErrorEvent { - pub error_type: FlashFileDownloadErrorType, - pub filename: Option, - pub message: Option, -} - -#[derive(Clone, Debug, Serialize)] -#[serde(rename_all = "snake_case")] -pub enum FlashFileDownloadErrorType { - FileAlreadyDownloaded, - FilesystemError, - NetworkError, - UnknownError, -} - -impl BasicSendableEvent for FlashFileDownloadErrorEvent { - const FRONTEND_EVENT_NAME: TauriEventName = TauriEventName::FlashFileDownloadErrorEvent; - const EVENT_STATUS: BasicEventStatus = BasicEventStatus::Failure; -} diff --git a/crates/desktop/artcraft/src/core/events/warning_events/flash_user_input_error_event.rs b/crates/desktop/artcraft/src/core/events/warning_events/flash_user_input_error_event.rs deleted file mode 100644 index 8586d52a34..0000000000 --- a/crates/desktop/artcraft/src/core/events/warning_events/flash_user_input_error_event.rs +++ /dev/null @@ -1,14 +0,0 @@ -use crate::core::events::basic_sendable_event_trait::{BasicEventStatus, BasicSendableEvent}; -use enums::tauri::ux::tauri_event_name::TauriEventName; -use serde_derive::Serialize; - -#[derive(Clone, Debug, Serialize)] -#[serde(rename_all = "snake_case")] -pub struct FlashUserInputErrorEvent { - pub message: String, -} - -impl BasicSendableEvent for FlashUserInputErrorEvent { - const FRONTEND_EVENT_NAME: TauriEventName = TauriEventName::FlashUserInputErrorEvent; - const EVENT_STATUS: BasicEventStatus = BasicEventStatus::Failure; -} diff --git a/crates/desktop/artcraft/src/core/events/warning_events/mod.rs b/crates/desktop/artcraft/src/core/events/warning_events/mod.rs deleted file mode 100644 index c7d712d92d..0000000000 --- a/crates/desktop/artcraft/src/core/events/warning_events/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod flash_file_download_error_event; -pub mod flash_user_input_error_event; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/core/lifecycle/mod.rs b/crates/desktop/artcraft/src/core/lifecycle/mod.rs deleted file mode 100644 index f58fb458ae..0000000000 --- a/crates/desktop/artcraft/src/core/lifecycle/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod startup; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/core/lifecycle/startup/handle_tauri_startup.rs b/crates/desktop/artcraft/src/core/lifecycle/startup/handle_tauri_startup.rs deleted file mode 100644 index 033ea2236e..0000000000 --- a/crates/desktop/artcraft/src/core/lifecycle/startup/handle_tauri_startup.rs +++ /dev/null @@ -1,136 +0,0 @@ -use crate::core::lifecycle::startup::tasks::bootstrap_task_database::bootstrap_task_database; -use crate::core::lifecycle::startup::tasks::initially_size_and_position_windows::initially_size_and_position_windows; -use crate::core::lifecycle::startup::tasks::load_provider_priority_state::load_provider_priority_state; -use crate::core::lifecycle::startup::tasks::set_app_log_level::set_app_log_level; -use crate::core::lifecycle::startup::tasks::spawn_discord_presence_thread::spawn_discord_presence_thread; -use crate::core::lifecycle::startup::tasks::spawn_main_window_thread::spawn_main_window_thread; -use crate::core::lifecycle::startup::tasks::spawn_sora_task_polling_thread::spawn_sora_task_polling_thread; -use crate::core::lifecycle::startup::tasks::spawn_storyteller_threads::spawn_storyteller_threads; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; -use crate::core::state::artcraft_platform_info::ArtcraftPlatformInfo; -use crate::core::state::artcraft_usage_tracker::artcraft_usage_tracker::ArtcraftUsageTracker; -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::services::grok::state::grok_credential_manager::GrokCredentialManager; -use crate::services::grok::state::grok_image_prompt_queue::GrokImagePromptQueue; -use crate::services::grok::threads::grok_image_websocket_thread::grok_image_websocket_thread::grok_image_websocket_thread; -use crate::services::grok::threads::grok_video_task_polling::grok_video_task_polling_thread::grok_video_task_polling_thread; -use crate::services::midjourney::state::midjourney_credential_manager::MidjourneyCredentialManager; -use crate::services::midjourney::threads::midjourney_long_polling_thread::midjourney_long_polling_thread; -use crate::services::sora::state::sora_credential_manager::SoraCredentialManager; -use crate::services::sora::state::sora_task_queue::SoraTaskQueue; -use crate::services::storyteller::state::storyteller_credential_manager::StorytellerCredentialManager; -use crate::services::worldlabs::state::worldlabs_bearer_bridge::WorldlabsBearerBridge; -use crate::services::worldlabs::state::worldlabs_credential_manager::WorldlabsCredentialManager; -use crate::core::providers::credentials::provider_credential_loading_cache::ProviderCredentialLoadingCache; -use crate::core::threads::third_party_task_polling_thread::third_party_task_polling_thread::third_party_task_polling_thread; -use crate::services::worldlabs::threads::worldlabs_marble_task_polling::worldlabs_marble_task_polling; -use errors::AnyhowResult; -use tauri::{AppHandle, Manager}; - -pub async fn handle_tauri_startup( - app: AppHandle, - root: AppDataRoot, - app_env_configs: AppEnvConfigs, - artcraft_platform_info: ArtcraftPlatformInfo, - artcraft_usage_tracker: ArtcraftUsageTracker, - storyteller_creds_manager: StorytellerCredentialManager, - sora_credential_manager: SoraCredentialManager, - sora_task_queue: SoraTaskQueue, - mj_creds_manager: MidjourneyCredentialManager, - grok_creds_manager: GrokCredentialManager, - grok_image_prompt_queue: GrokImagePromptQueue, - worldlabs_bearer_bridge: WorldlabsBearerBridge, - worldlabs_creds_manager: WorldlabsCredentialManager, - credential_cache: ProviderCredentialLoadingCache, -) -> AnyhowResult<()> { - - set_app_log_level( - &app, - &root, - )?; - - let task_database = - bootstrap_task_database(&app, &root).await?; - - load_provider_priority_state( - &app, - &root, - )?; - - spawn_main_window_thread( - &app, - &root, - &storyteller_creds_manager, - )?; - - spawn_storyteller_threads( - &app, - &app_env_configs, - &artcraft_usage_tracker, - &artcraft_platform_info, - &task_database, - &storyteller_creds_manager, - )?; - - spawn_sora_task_polling_thread( - &app, - &root, - &app_env_configs, - &task_database, - &sora_credential_manager, - &storyteller_creds_manager, - &sora_task_queue, - )?; - - tauri::async_runtime::spawn(grok_video_task_polling_thread( - app.clone(), - app_env_configs.clone(), - root.clone(), - task_database.clone(), - grok_creds_manager.clone(), - storyteller_creds_manager.clone(), - )); - - tauri::async_runtime::spawn(grok_image_websocket_thread( - app.clone(), - app_env_configs.clone(), - root.clone(), - task_database.clone(), - grok_creds_manager.clone(), - grok_image_prompt_queue.clone(), - storyteller_creds_manager.clone(), - )); - - tauri::async_runtime::spawn(midjourney_long_polling_thread( - app.clone(), - app_env_configs.clone(), - root.clone(), - task_database.clone(), - mj_creds_manager.clone(), - storyteller_creds_manager.clone(), - )); - - tauri::async_runtime::spawn(worldlabs_marble_task_polling( - app.clone(), - app_env_configs.clone(), - root.clone(), - task_database.clone(), - worldlabs_creds_manager.clone(), - storyteller_creds_manager.clone(), - )); - - tauri::async_runtime::spawn(third_party_task_polling_thread( - app.clone(), - app_env_configs.clone(), - root.clone(), - task_database.clone(), - storyteller_creds_manager.clone(), - credential_cache, - )); - - spawn_discord_presence_thread()?; - - initially_size_and_position_windows(&app, &root); - - Ok(()) -} diff --git a/crates/desktop/artcraft/src/core/lifecycle/startup/mod.rs b/crates/desktop/artcraft/src/core/lifecycle/startup/mod.rs deleted file mode 100644 index 07db4020c0..0000000000 --- a/crates/desktop/artcraft/src/core/lifecycle/startup/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -mod tasks; -pub mod handle_tauri_startup; -pub mod setup_main_window; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/core/lifecycle/startup/setup_main_window.rs b/crates/desktop/artcraft/src/core/lifecycle/startup/setup_main_window.rs deleted file mode 100644 index 391b638296..0000000000 --- a/crates/desktop/artcraft/src/core/lifecycle/startup/setup_main_window.rs +++ /dev/null @@ -1,99 +0,0 @@ -use crate::core::windows::main_window::constants::MAIN_WINDOW_NAME; -use errors::AnyhowResult; -use tauri::window::Color; -use tauri::{AppHandle, TitleBarStyle, WebviewUrl, WebviewWindowBuilder}; - -pub async fn setup_main_window( - app: &AppHandle, -) -> AnyhowResult<()> { - - let win_builder = - WebviewWindowBuilder::new(app, MAIN_WINDOW_NAME, WebviewUrl::default()) - .title("ArtCraft") - .resizable(true) - .fullscreen(false) - .background_color(Color(0, 0, 0, 0)) - .enable_clipboard_access() - .inner_size(2400.0, 1300.0); - - #[cfg(target_os = "macos")] - let win_builder = win_builder - .decorations(true) // NB: Mac requires decorations. Tons of capabilities disappear otherwise. - .title_bar_style(TitleBarStyle::Overlay) - .hidden_title(true) - .accept_first_mouse(true) // https://github.com/tauri-apps/tauri/issues/11605#issuecomment-2460112096 - .focusable(true) - .focused(true); - - // NB: Setting decorations(false) "breaks" Mac, though I never documented how/why. - // NB: On Linux, setting decorations(false) will cause the window to be unable to be - // resized, despite the arrow cursor indicating resize is possible. This might be - // fixable another way, but for now it seems fine to disable this. There also seem to - // be some performance loss with decorations(false), but I might be imagining it. - #[cfg(target_os = "windows")] - let win_builder = win_builder - .decorations(false); // NB: This breaks Mac! (And breaks resize on Linux) - - // On macOS, Cmd+A/C/V/X/Z and friends are dispatched by AppKit through the application - // menu. Without an Edit submenu containing the standard predefined items, these - // shortcuts never reach the WKWebView and text inputs behave as if Cmd is unmapped. - #[cfg(target_os = "macos")] - install_macos_app_menu(app)?; - - let _window = win_builder.build()?; - - Ok(()) -} - -#[cfg(target_os = "macos")] -fn install_macos_app_menu(app: &AppHandle) -> AnyhowResult<()> { - use tauri::menu::{Menu, PredefinedMenuItem, Submenu}; - - let app_submenu = Submenu::with_items( - app, - "ArtCraft", - true, - &[ - &PredefinedMenuItem::about(app, None, None)?, - &PredefinedMenuItem::separator(app)?, - &PredefinedMenuItem::services(app, None)?, - &PredefinedMenuItem::separator(app)?, - &PredefinedMenuItem::hide(app, None)?, - &PredefinedMenuItem::hide_others(app, None)?, - &PredefinedMenuItem::show_all(app, None)?, - &PredefinedMenuItem::separator(app)?, - &PredefinedMenuItem::quit(app, None)?, - ], - )?; - - let edit_submenu = Submenu::with_items( - app, - "Edit", - true, - &[ - &PredefinedMenuItem::undo(app, None)?, - &PredefinedMenuItem::redo(app, None)?, - &PredefinedMenuItem::separator(app)?, - &PredefinedMenuItem::cut(app, None)?, - &PredefinedMenuItem::copy(app, None)?, - &PredefinedMenuItem::paste(app, None)?, - &PredefinedMenuItem::select_all(app, None)?, - ], - )?; - - let window_submenu = Submenu::with_items( - app, - "Window", - true, - &[ - &PredefinedMenuItem::minimize(app, None)?, - &PredefinedMenuItem::maximize(app, None)?, - &PredefinedMenuItem::separator(app)?, - &PredefinedMenuItem::close_window(app, None)?, - ], - )?; - - let menu = Menu::with_items(app, &[&app_submenu, &edit_submenu, &window_submenu])?; - app.set_menu(menu)?; - Ok(()) -} diff --git a/crates/desktop/artcraft/src/core/lifecycle/startup/tasks/bootstrap_task_database.rs b/crates/desktop/artcraft/src/core/lifecycle/startup/tasks/bootstrap_task_database.rs deleted file mode 100644 index 343241fd17..0000000000 --- a/crates/desktop/artcraft/src/core/lifecycle/startup/tasks/bootstrap_task_database.rs +++ /dev/null @@ -1,10 +0,0 @@ -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::core::state::task_database::TaskDatabase; -use errors::AnyhowResult; -use tauri::{AppHandle, Manager}; - -pub async fn bootstrap_task_database(app: &AppHandle, root: &AppDataRoot) -> AnyhowResult { - let task_database = TaskDatabase::connect(root).await?; - app.manage(task_database.clone()); - Ok(task_database) -} diff --git a/crates/desktop/artcraft/src/core/lifecycle/startup/tasks/initially_size_and_position_windows.rs b/crates/desktop/artcraft/src/core/lifecycle/startup/tasks/initially_size_and_position_windows.rs deleted file mode 100644 index c2c04e51d3..0000000000 --- a/crates/desktop/artcraft/src/core/lifecycle/startup/tasks/initially_size_and_position_windows.rs +++ /dev/null @@ -1,42 +0,0 @@ -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::core::state::window::main_window_position::MainWindowPosition; -use crate::core::state::window::main_window_size::MainWindowSize; -use crate::core::utils::window::position_main_window::position_main_window; -use crate::core::utils::window::resize_main_window::resize_main_window; -use tauri::AppHandle; - -pub fn initially_size_and_position_windows( - app: &AppHandle, - root: &AppDataRoot, -) { - - println!("Sizing and positioning window..."); - - match MainWindowSize::from_filesystem_configs(&root) { - Ok(None) => {} - Ok(Some(size)) => { - println!("Resizing window to: {:?}", size); - let result = resize_main_window(app, &size); - if let Err(err) = result { - eprintln!("Could not set window size: {:?}", err); - } - } - Err(err) => { - eprintln!("Failed to read window size from disk: {:?}", err); - } - } - - match MainWindowPosition::from_filesystem_configs(&root) { - Ok(None) => {} - Ok(Some(pos)) => { - println!("Moving window to: {:?}", pos); - let result = position_main_window(app, &pos); - if let Err(err) = result { - eprintln!("Could not set window position: {:?}", err); - } - } - Err(err) => { - eprintln!("Failed to read window position from disk: {:?}", err); - } - } -} \ No newline at end of file diff --git a/crates/desktop/artcraft/src/core/lifecycle/startup/tasks/load_provider_priority_state.rs b/crates/desktop/artcraft/src/core/lifecycle/startup/tasks/load_provider_priority_state.rs deleted file mode 100644 index 58d300d5a8..0000000000 --- a/crates/desktop/artcraft/src/core/lifecycle/startup/tasks/load_provider_priority_state.rs +++ /dev/null @@ -1,34 +0,0 @@ -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::core::state::provider_priority::ProviderPriorityStore; -use anyhow::anyhow; -use errors::AnyhowResult; -use tauri::{AppHandle, Manager}; - -pub fn load_provider_priority_state( - app: &AppHandle, - root: &AppDataRoot, -) -> AnyhowResult<()> { - let provider_priority = match ProviderPriorityStore::from_filesystem_configs(root) { - Ok(Some(priority)) => { - println!("Loaded provider priority from disk: {:?}", priority.get_priority()); - priority - } - Ok(None) => { - println!("No provider priority found on disk, using default."); - ProviderPriorityStore::default() - } - Err(err) => { - eprintln!("Failed to read provider priority from disk: {:?}", err); - ProviderPriorityStore::default() - } - }; - - let success = app.manage(provider_priority); - - if !success { - eprintln!("Failed to manage provider priority state."); - return Err(anyhow!("Failed to manage provider priority state.")); - } - - Ok(()) -} diff --git a/crates/desktop/artcraft/src/core/lifecycle/startup/tasks/mod.rs b/crates/desktop/artcraft/src/core/lifecycle/startup/tasks/mod.rs deleted file mode 100644 index b69bc77f05..0000000000 --- a/crates/desktop/artcraft/src/core/lifecycle/startup/tasks/mod.rs +++ /dev/null @@ -1,8 +0,0 @@ -pub (super) mod bootstrap_task_database; -pub (super) mod set_app_log_level; -pub (super) mod initially_size_and_position_windows; -pub (super) mod spawn_discord_presence_thread; -pub (super) mod spawn_main_window_thread; -pub (super) mod spawn_sora_task_polling_thread; -pub (super) mod spawn_storyteller_threads; -pub (super) mod load_provider_priority_state; diff --git a/crates/desktop/artcraft/src/core/lifecycle/startup/tasks/set_app_log_level.rs b/crates/desktop/artcraft/src/core/lifecycle/startup/tasks/set_app_log_level.rs deleted file mode 100644 index 471b24866a..0000000000 --- a/crates/desktop/artcraft/src/core/lifecycle/startup/tasks/set_app_log_level.rs +++ /dev/null @@ -1,73 +0,0 @@ -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use errors::AnyhowResult; -use log::LevelFilter; -use std::env; -use std::env::VarError; -use tauri::AppHandle; -use tauri_plugin_log::{Target, TargetKind}; - -const RUST_LOG: &str = "RUST_LOG"; - -pub fn set_app_log_level( - app: &AppHandle, - root: &AppDataRoot, -) -> AnyhowResult<()> { - - //print_env_var(RUST_LOG); - - // NB: The semantics of this do not match `RUST_LOG` exactly as it's not set per-package. - let maybe_level = env::var(RUST_LOG) - .map(|value| value.trim().to_ascii_lowercase()); - - let mut log_level = LevelFilter::Info; - - match maybe_level { - Ok(level) => { - println!("The `RUST_LOG` environment variable was set to: `{}`.", level); - - if level.contains("debug") { - log_level = LevelFilter::Debug; - } else if level.contains("info") { - log_level = LevelFilter::Info; - } else if level.contains("warn") { - log_level = LevelFilter::Warn; - } else if level.contains("error") { - log_level = LevelFilter::Error; - } else if level.contains("off") { - log_level = LevelFilter::Off; - } - } - Err(VarError::NotPresent) => { - // NB: This demonstrably tests stderr output in the default case. - eprintln!("No `RUST_LOG` environment variable found."); - } - Err(VarError::NotUnicode(_)) => { - // NB: This demonstrably tests stderr output in the default case. - eprintln!("Could not parse `RUST_LOG` environment variable; not unicode."); - } - } - - println!("Setting app log level to: {:?}", log_level); - - app.plugin( - tauri_plugin_log::Builder::default() - .level(log_level) - .targets(vec![ - Target::new(TargetKind::Stdout), - Target::new(TargetKind::LogDir { - file_name: Some(root.log_file_name_str().to_string()) - }), - ]) - .build(), - )?; - - Ok(()) -} - -// pub fn print_env_var(var_name: &str) { -// match env::var(var_name) { -// Ok(value) => println!("Environment variable `{}` = {}", var_name, value), -// Err(VarError::NotPresent) => println!("Environment variable `{}` is not set.", var_name), -// Err(VarError::NotUnicode(_)) => println!("Environment variable `{}` is not a valid Unicode string", var_name), -// } -// } diff --git a/crates/desktop/artcraft/src/core/lifecycle/startup/tasks/spawn_discord_presence_thread.rs b/crates/desktop/artcraft/src/core/lifecycle/startup/tasks/spawn_discord_presence_thread.rs deleted file mode 100644 index 24b12c0d52..0000000000 --- a/crates/desktop/artcraft/src/core/lifecycle/startup/tasks/spawn_discord_presence_thread.rs +++ /dev/null @@ -1,10 +0,0 @@ -use crate::core::threads::discord_presence_thread::discord_presence_thread; -use errors::AnyhowResult; - -pub fn spawn_discord_presence_thread( -) -> AnyhowResult<()> { - - tauri::async_runtime::spawn(discord_presence_thread()); - - Ok(()) -} diff --git a/crates/desktop/artcraft/src/core/lifecycle/startup/tasks/spawn_main_window_thread.rs b/crates/desktop/artcraft/src/core/lifecycle/startup/tasks/spawn_main_window_thread.rs deleted file mode 100644 index 85b54a4e56..0000000000 --- a/crates/desktop/artcraft/src/core/lifecycle/startup/tasks/spawn_main_window_thread.rs +++ /dev/null @@ -1,20 +0,0 @@ -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::core::threads::main_window_thread::main_window_thread::main_window_thread; -use crate::services::storyteller::state::storyteller_credential_manager::StorytellerCredentialManager; -use errors::AnyhowResult; -use tauri::{AppHandle, Manager}; - -pub fn spawn_main_window_thread( - app: &AppHandle, - root: &AppDataRoot, - storyteller_creds_manager: &StorytellerCredentialManager, -) -> AnyhowResult<()> { - - tauri::async_runtime::spawn(main_window_thread( - app.clone(), - root.clone(), - storyteller_creds_manager.clone(), - )); - - Ok(()) -} diff --git a/crates/desktop/artcraft/src/core/lifecycle/startup/tasks/spawn_sora_task_polling_thread.rs b/crates/desktop/artcraft/src/core/lifecycle/startup/tasks/spawn_sora_task_polling_thread.rs deleted file mode 100644 index 8606e95140..0000000000 --- a/crates/desktop/artcraft/src/core/lifecycle/startup/tasks/spawn_sora_task_polling_thread.rs +++ /dev/null @@ -1,32 +0,0 @@ -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::core::state::task_database::TaskDatabase; -use crate::services::sora::state::sora_credential_manager::SoraCredentialManager; -use crate::services::sora::state::sora_task_queue::SoraTaskQueue; -use crate::services::sora::threads::sora_task_polling::sora_task_polling_thread::sora_task_polling_thread; -use crate::services::storyteller::state::storyteller_credential_manager::StorytellerCredentialManager; -use errors::AnyhowResult; -use tauri::{AppHandle, Manager}; - -pub fn spawn_sora_task_polling_thread( - app: &AppHandle, - root: &AppDataRoot, - app_env_configs: &AppEnvConfigs, - task_database: &TaskDatabase, - sora_credential_manager: &SoraCredentialManager, - storyteller_creds_manager: &StorytellerCredentialManager, - sora_task_queue: &SoraTaskQueue, -) -> AnyhowResult<()> { - - tauri::async_runtime::spawn(sora_task_polling_thread( - app.clone(), - app_env_configs.clone(), - root.clone(), - task_database.clone(), - sora_credential_manager.clone(), - storyteller_creds_manager.clone(), - sora_task_queue.clone(), - )); - - Ok(()) -} diff --git a/crates/desktop/artcraft/src/core/lifecycle/startup/tasks/spawn_storyteller_threads.rs b/crates/desktop/artcraft/src/core/lifecycle/startup/tasks/spawn_storyteller_threads.rs deleted file mode 100644 index 680c21c414..0000000000 --- a/crates/desktop/artcraft/src/core/lifecycle/startup/tasks/spawn_storyteller_threads.rs +++ /dev/null @@ -1,35 +0,0 @@ -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; -use crate::core::state::artcraft_platform_info::ArtcraftPlatformInfo; -use crate::core::state::artcraft_usage_tracker::artcraft_usage_tracker::ArtcraftUsageTracker; -use crate::core::state::task_database::TaskDatabase; -use crate::services::storyteller::state::storyteller_credential_manager::StorytellerCredentialManager; -use crate::services::storyteller::threads::storyteller_activity_thread::storyteller_activity_thread; -use crate::services::storyteller::threads::storyteller_task_polling_thread::storyteller_task_polling_thread::storyteller_task_polling_thread; -use errors::AnyhowResult; -use tauri::{AppHandle, Manager}; - -pub fn spawn_storyteller_threads( - app: &AppHandle, - app_env_configs: &AppEnvConfigs, - artcraft_usage_tracker: &ArtcraftUsageTracker, - artcraft_platform_info: &ArtcraftPlatformInfo, - task_database: &TaskDatabase, - storyteller_creds_manager: &StorytellerCredentialManager, -) -> AnyhowResult<()> { - - tauri::async_runtime::spawn(storyteller_task_polling_thread( - app.clone(), - app_env_configs.clone(), - task_database.clone(), - storyteller_creds_manager.clone(), - )); - - tauri::async_runtime::spawn(storyteller_activity_thread( - app_env_configs.clone(), - artcraft_platform_info.clone(), - artcraft_usage_tracker.clone(), - storyteller_creds_manager.clone(), - )); - - Ok(()) -} diff --git a/crates/desktop/artcraft/src/core/mod.rs b/crates/desktop/artcraft/src/core/mod.rs deleted file mode 100644 index cbdc9bd9fb..0000000000 --- a/crates/desktop/artcraft/src/core/mod.rs +++ /dev/null @@ -1,10 +0,0 @@ -pub mod api_adapters; -pub mod artcraft_error; -pub mod commands; -pub mod events; -pub mod lifecycle; -pub mod providers; -pub mod state; -pub mod threads; -pub mod utils; -pub mod windows; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/core/providers/credentials/mod.rs b/crates/desktop/artcraft/src/core/providers/credentials/mod.rs deleted file mode 100644 index 1af6c8b918..0000000000 --- a/crates/desktop/artcraft/src/core/providers/credentials/mod.rs +++ /dev/null @@ -1,4 +0,0 @@ -pub mod payload; -pub mod provider_credential_key; -pub mod provider_credential_loading_cache; -pub mod provider_credential_type; diff --git a/crates/desktop/artcraft/src/core/providers/credentials/payload/api_key.rs b/crates/desktop/artcraft/src/core/providers/credentials/payload/api_key.rs deleted file mode 100644 index c00bfedcde..0000000000 --- a/crates/desktop/artcraft/src/core/providers/credentials/payload/api_key.rs +++ /dev/null @@ -1,100 +0,0 @@ -use std::error::Error; -use std::fmt::Display; -use std::path::Path; - -#[derive(Clone)] -pub struct ApiKeyData(String); - -impl ApiKeyData { - pub fn from_str(s: &str) -> Self { - Self(s.trim().to_string()) - } - - pub fn as_str(&self) -> &str { - self.0.as_str() - } - - pub fn load_from_file>(file_path: P) -> Result { - let contents = std::fs::read_to_string(file_path) - .map_err(ApiKeyDataError::IoError)?; - Ok(Self(contents.trim().to_string())) - } - - pub fn save_to_file>(&self, file_path: P) -> Result<(), ApiKeyDataError> { - std::fs::write(file_path, self.0.trim()) - .map_err(ApiKeyDataError::IoError)?; - Ok(()) - } -} - -#[derive(Debug)] -pub enum ApiKeyDataError { - IoError(std::io::Error), -} - -impl Error for ApiKeyDataError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match self { - ApiKeyDataError::IoError(e) => Some(e), - } - } -} - -impl Display for ApiKeyDataError { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - ApiKeyDataError::IoError(e) => write!(f, "IO error: {}", e), - } - } -} - -#[cfg(test)] -mod tests { - use super::*; - use tempfile::NamedTempFile; - use std::io::Write; - - #[test] - fn load_trims_whitespace() { - let mut file = NamedTempFile::new().unwrap(); - write!(file, " sk-abc123 \n").unwrap(); - - let data = ApiKeyData::load_from_file(file.path()).unwrap(); - assert_eq!(data.as_str(), "sk-abc123"); - } - - #[test] - fn load_trims_newlines() { - let mut file = NamedTempFile::new().unwrap(); - write!(file, "\nmy_secret_key\n\n").unwrap(); - - let data = ApiKeyData::load_from_file(file.path()).unwrap(); - assert_eq!(data.as_str(), "my_secret_key"); - } - - #[test] - fn save_trims_whitespace() { - let file = NamedTempFile::new().unwrap(); - let data = ApiKeyData::from_str(" sk-padded "); - data.save_to_file(file.path()).unwrap(); - - let contents = std::fs::read_to_string(file.path()).unwrap(); - assert_eq!(contents, "sk-padded"); - } - - #[test] - fn round_trip() { - let file = NamedTempFile::new().unwrap(); - let original = ApiKeyData::from_str("sk-round-trip-test-key"); - original.save_to_file(file.path()).unwrap(); - - let loaded = ApiKeyData::load_from_file(file.path()).unwrap(); - assert_eq!(loaded.as_str(), "sk-round-trip-test-key"); - } - - #[test] - fn load_nonexistent_file_returns_io_error() { - let result = ApiKeyData::load_from_file("/tmp/nonexistent_api_key_file_12345.txt"); - assert!(result.is_err()); - } -} diff --git a/crates/desktop/artcraft/src/core/providers/credentials/payload/mod.rs b/crates/desktop/artcraft/src/core/providers/credentials/payload/mod.rs deleted file mode 100644 index 8d5083bee3..0000000000 --- a/crates/desktop/artcraft/src/core/providers/credentials/payload/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub mod provider_credential_payload; -pub mod api_key; -pub mod web_login; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/core/providers/credentials/payload/provider_credential_payload.rs b/crates/desktop/artcraft/src/core/providers/credentials/payload/provider_credential_payload.rs deleted file mode 100644 index c2b8ab562c..0000000000 --- a/crates/desktop/artcraft/src/core/providers/credentials/payload/provider_credential_payload.rs +++ /dev/null @@ -1,10 +0,0 @@ -use crate::core::providers::credentials::payload::api_key::ApiKeyData; -use crate::core::providers::credentials::payload::web_login::WebLoginData; - -#[derive(Clone)] -pub enum ProviderCredentialPayload { - ApiKey(ApiKeyData), - - // TODO: There might be logins in the future that use weird header states, etc. - WebLogin(WebLoginData), -} diff --git a/crates/desktop/artcraft/src/core/providers/credentials/payload/web_login.rs b/crates/desktop/artcraft/src/core/providers/credentials/payload/web_login.rs deleted file mode 100644 index 4f9a41766e..0000000000 --- a/crates/desktop/artcraft/src/core/providers/credentials/payload/web_login.rs +++ /dev/null @@ -1,251 +0,0 @@ -use chrono::{DateTime, Utc}; -use serde_derive::{Deserialize, Serialize}; -use std::collections::HashMap; -use std::error::Error; -use std::fmt::Display; -use std::path::Path; - -const CURRENT_VERSION: u8 = 1; - -#[derive(Clone)] -pub struct WebLoginData { - pub cookies_header: Option, - pub additional_headers: Option>, - - pub username: Option, - pub email_address: Option, - - pub created_at: Option>, - pub updated_at: Option>, -} - -impl WebLoginData { - pub fn new() -> Self { - Self { - cookies_header: None, - additional_headers: None, - username: None, - email_address: None, - created_at: None, - updated_at: None, - } - } - - pub fn load_from_file>(file_path: P) -> Result { - let contents = std::fs::read_to_string(file_path) - .map_err(WebLoginDataError::IoError)?; - - let serializable: WebLoginDataSerializable = serde_json::from_str(&contents) - .map_err(WebLoginDataError::DeserializeError)?; - - Ok(Self { - cookies_header: serializable.cookies_header, - additional_headers: serializable.additional_headers, - username: serializable.username, - email_address: serializable.email_address, - created_at: serializable.created_at, - updated_at: serializable.updated_at, - }) - } - - pub fn save_to_file>(&self, file_path: P) -> Result<(), WebLoginDataError> { - let serializable = WebLoginDataSerializable { - version: CURRENT_VERSION, - cookies_header: self.cookies_header.clone(), - additional_headers: self.additional_headers.clone(), - username: self.username.clone(), - email_address: self.email_address.clone(), - created_at: self.created_at, - updated_at: self.updated_at, - }; - - let contents = serde_json::to_string_pretty(&serializable) - .map_err(WebLoginDataError::SerializeError)?; - - std::fs::write(file_path, contents) - .map_err(WebLoginDataError::IoError)?; - - Ok(()) - } -} - -#[derive(Debug)] -pub enum WebLoginDataError { - IoError(std::io::Error), - DeserializeError(serde_json::Error), - SerializeError(serde_json::Error), -} - -impl Error for WebLoginDataError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match self { - WebLoginDataError::IoError(e) => Some(e), - WebLoginDataError::DeserializeError(e) => Some(e), - WebLoginDataError::SerializeError(e) => Some(e), - _ => None, - } - } -} - -impl Display for WebLoginDataError { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - WebLoginDataError::IoError(e) => write!(f, "IO error: {}", e), - WebLoginDataError::DeserializeError(e) => write!(f, "Deserialization error: {}", e), - WebLoginDataError::SerializeError(e) => write!(f, "Serialization error: {}", e), - } - } -} - -#[derive(Serialize, Deserialize)] -#[serde(rename_all = "snake_case")] -struct WebLoginDataSerializable { - version: u8, - - #[serde(skip_serializing_if = "Option::is_none")] - cookies_header: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - additional_headers: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - username: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - email_address: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - created_at: Option>, - - #[serde(skip_serializing_if = "Option::is_none")] - updated_at: Option>, -} - -#[cfg(test)] -mod tests { - use super::*; - use tempfile::NamedTempFile; - use std::io::Write; - - #[test] - fn save_writes_version() { - let file = NamedTempFile::new().unwrap(); - let data = WebLoginData::new(); - data.save_to_file(file.path()).unwrap(); - - let contents = std::fs::read_to_string(file.path()).unwrap(); - assert!(contents.contains("\"version\": 1")); - } - - #[test] - fn load_reads_all_fields() { - let mut file = NamedTempFile::new().unwrap(); - write!(file, r#"{{ - "version": 1, - "cookies_header": "session=abc123; visitor=xyz", - "additional_headers": {{"Authorization": "Bearer tok"}}, - "username": "testuser", - "email_address": "test@example.com", - "created_at": "2026-01-01T00:00:00Z", - "updated_at": "2026-05-10T12:00:00Z" - }}"#).unwrap(); - - let data = WebLoginData::load_from_file(file.path()).unwrap(); - assert_eq!(data.cookies_header.as_deref(), Some("session=abc123; visitor=xyz")); - assert_eq!(data.username.as_deref(), Some("testuser")); - assert_eq!(data.email_address.as_deref(), Some("test@example.com")); - assert!(data.additional_headers.is_some()); - let headers = data.additional_headers.unwrap(); - assert_eq!(headers.get("Authorization").unwrap(), "Bearer tok"); - assert!(data.created_at.is_some()); - assert!(data.updated_at.is_some()); - } - - #[test] - fn load_tolerates_absent_optional_fields() { - let mut file = NamedTempFile::new().unwrap(); - write!(file, r#"{{"version": 1}}"#).unwrap(); - - let data = WebLoginData::load_from_file(file.path()).unwrap(); - assert!(data.cookies_header.is_none()); - assert!(data.additional_headers.is_none()); - assert!(data.username.is_none()); - assert!(data.email_address.is_none()); - assert!(data.created_at.is_none()); - assert!(data.updated_at.is_none()); - } - - #[test] - fn load_tolerates_null_fields() { - let mut file = NamedTempFile::new().unwrap(); - write!(file, r#"{{ - "version": 1, - "cookies_header": null, - "username": null, - "email_address": null - }}"#).unwrap(); - - let data = WebLoginData::load_from_file(file.path()).unwrap(); - assert!(data.cookies_header.is_none()); - assert!(data.username.is_none()); - assert!(data.email_address.is_none()); - } - - #[test] - fn load_invalid_json_returns_error() { - let mut file = NamedTempFile::new().unwrap(); - write!(file, "not valid json at all").unwrap(); - - let result = WebLoginData::load_from_file(file.path()); - assert!(result.is_err()); - } - - #[test] - fn load_nonexistent_file_returns_io_error() { - let result = WebLoginData::load_from_file("/tmp/nonexistent_web_login_12345.json"); - assert!(result.is_err()); - } - - #[test] - fn round_trip_full() { - let file = NamedTempFile::new().unwrap(); - - let mut headers = HashMap::new(); - headers.insert("X-Custom".to_string(), "value".to_string()); - - let now = Utc::now(); - - let original = WebLoginData { - cookies_header: Some("session=roundtrip".to_string()), - additional_headers: Some(headers), - username: Some("round_trip_user".to_string()), - email_address: Some("rt@example.com".to_string()), - created_at: Some(now), - updated_at: Some(now), - }; - - original.save_to_file(file.path()).unwrap(); - let loaded = WebLoginData::load_from_file(file.path()).unwrap(); - - assert_eq!(loaded.cookies_header.as_deref(), Some("session=roundtrip")); - assert_eq!(loaded.username.as_deref(), Some("round_trip_user")); - assert_eq!(loaded.email_address.as_deref(), Some("rt@example.com")); - assert_eq!(loaded.additional_headers.as_ref().unwrap().get("X-Custom").unwrap(), "value"); - assert!(loaded.created_at.is_some()); - assert!(loaded.updated_at.is_some()); - } - - #[test] - fn round_trip_minimal() { - let file = NamedTempFile::new().unwrap(); - - let original = WebLoginData::new(); - original.save_to_file(file.path()).unwrap(); - - let loaded = WebLoginData::load_from_file(file.path()).unwrap(); - assert!(loaded.cookies_header.is_none()); - assert!(loaded.additional_headers.is_none()); - assert!(loaded.username.is_none()); - assert!(loaded.email_address.is_none()); - } -} diff --git a/crates/desktop/artcraft/src/core/providers/credentials/provider_credential_key.rs b/crates/desktop/artcraft/src/core/providers/credentials/provider_credential_key.rs deleted file mode 100644 index 4ba3f3ce3b..0000000000 --- a/crates/desktop/artcraft/src/core/providers/credentials/provider_credential_key.rs +++ /dev/null @@ -1,50 +0,0 @@ -use serde_derive::{Deserialize, Serialize}; -use crate::core::providers::credentials::provider_credential_type::ProviderCredentialType; - -#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] -#[serde(rename_all = "snake_case")] -pub enum ProviderCredentialKey { - - // ========== API KEYS========== - - FalApiKey, - ReplicateApiKey, - - // ========== WEB LOGINS ========== - - GrokWebLogin, - HiggsfieldWebLogin, - MidjourneyLogin, - RunwayWebLogin, -} - - -impl ProviderCredentialKey { - pub fn get_type(&self) -> ProviderCredentialType { - match self { - // Api keys - Self::FalApiKey => ProviderCredentialType::ApiKey, - Self::ReplicateApiKey => ProviderCredentialType::ApiKey, - // Web logins - Self::GrokWebLogin => ProviderCredentialType::WebLogin, - Self::HiggsfieldWebLogin => ProviderCredentialType::WebLogin, - Self::MidjourneyLogin => ProviderCredentialType::WebLogin, - Self::RunwayWebLogin => ProviderCredentialType::WebLogin, - } - } - - pub fn get_filename(&self) -> &'static str { - match self { - // Api keys - ProviderCredentialKey::FalApiKey => "fal.api_key.txt", - ProviderCredentialKey::ReplicateApiKey => "replicate.api_key.txt", - // Web logins - ProviderCredentialKey::GrokWebLogin => "grok.web_login.toml", - ProviderCredentialKey::HiggsfieldWebLogin => "higgsfield.web_login.toml", - ProviderCredentialKey::MidjourneyLogin => "midjourney.web_login.toml", - ProviderCredentialKey::RunwayWebLogin => "runway.web_login.toml", - } - } -} - - diff --git a/crates/desktop/artcraft/src/core/providers/credentials/provider_credential_loading_cache.rs b/crates/desktop/artcraft/src/core/providers/credentials/provider_credential_loading_cache.rs deleted file mode 100644 index deed0e0636..0000000000 --- a/crates/desktop/artcraft/src/core/providers/credentials/provider_credential_loading_cache.rs +++ /dev/null @@ -1,187 +0,0 @@ -use std::collections::HashMap; -use std::error::Error; -use std::fmt::Display; -use std::sync::{Arc, RwLock}; -use std::time::{Duration, Instant}; - -use log::{info, warn}; - -use crate::core::providers::credentials::payload::api_key::{ApiKeyData, ApiKeyDataError}; -use crate::core::providers::credentials::payload::provider_credential_payload::ProviderCredentialPayload; -use crate::core::providers::credentials::payload::web_login::{WebLoginData, WebLoginDataError}; -use crate::core::providers::credentials::provider_credential_key::ProviderCredentialKey; -use crate::core::providers::credentials::provider_credential_type::ProviderCredentialType; -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::core::state::data_dir::trait_data_subdir::DataSubdir; - -struct CacheEntry { - payload: ProviderCredentialPayload, - loaded_at: Instant, -} - -#[derive(Clone)] -pub struct ProviderCredentialLoadingCache { - inner: Arc>>, - app_data_root: AppDataRoot, - ttl: Duration, -} - -impl ProviderCredentialLoadingCache { - pub fn new(app_data_root: AppDataRoot) -> Self { - Self { - inner: Arc::new(RwLock::new(HashMap::new())), - app_data_root, - ttl: Duration::from_secs(300), // 5 minutes - } - } - - pub fn new_with_ttl(app_data_root: AppDataRoot, ttl: Duration) -> Self { - Self { - inner: Arc::new(RwLock::new(HashMap::new())), - app_data_root, - ttl, - } - } - - pub fn get_credentials( - &self, - key: ProviderCredentialKey, - ) -> Result, ProviderCredentialLoadingCacheError> { - // Check cache first. - { - let cache = self.inner.read() - .map_err(|_| ProviderCredentialLoadingCacheError::LockPoisoned)?; - - if let Some(entry) = cache.get(&key) { - if entry.loaded_at.elapsed() < self.ttl { - return Ok(Some(entry.payload.clone())); - } - } - } - - // Cache miss or expired — load from disk. - let file_path = self.app_data_root.credentials_dir().path().join(key.get_filename()); - - if !file_path.exists() { - return Ok(None); - } - - info!("Loading credential from disk: {:?}", file_path); - - let payload = match key.get_type() { - ProviderCredentialType::ApiKey => { - let data = ApiKeyData::load_from_file(&file_path) - .map_err(ProviderCredentialLoadingCacheError::ApiKeyError)?; - ProviderCredentialPayload::ApiKey(data) - } - ProviderCredentialType::WebLogin => { - let data = WebLoginData::load_from_file(&file_path) - .map_err(ProviderCredentialLoadingCacheError::WebLoginError)?; - ProviderCredentialPayload::WebLogin(data) - } - }; - - // Store in cache. - { - let mut cache = self.inner.write() - .map_err(|_| ProviderCredentialLoadingCacheError::LockPoisoned)?; - - cache.insert(key, CacheEntry { - payload: payload.clone(), - loaded_at: Instant::now(), - }); - } - - Ok(Some(payload)) - } - - pub fn save_credentials( - &self, - key: ProviderCredentialKey, - payload: ProviderCredentialPayload, - ) -> Result<(), ProviderCredentialLoadingCacheError> { - let file_path = self.app_data_root.credentials_dir().path().join(key.get_filename()); - - info!("Saving credential to disk: {:?}", file_path); - - match (&payload, key.get_type()) { - (ProviderCredentialPayload::ApiKey(data), ProviderCredentialType::ApiKey) => { - data.save_to_file(&file_path) - .map_err(ProviderCredentialLoadingCacheError::ApiKeyError)?; - } - (ProviderCredentialPayload::WebLogin(data), ProviderCredentialType::WebLogin) => { - data.save_to_file(&file_path) - .map_err(ProviderCredentialLoadingCacheError::WebLoginError)?; - } - _ => { - warn!("Credential type mismatch for key {:?}", key); - return Err(ProviderCredentialLoadingCacheError::TypeMismatch); - } - } - - // Update cache. - { - let mut cache = self.inner.write() - .map_err(|_| ProviderCredentialLoadingCacheError::LockPoisoned)?; - - cache.insert(key, CacheEntry { - payload, - loaded_at: Instant::now(), - }); - } - - Ok(()) - } - - /// Invalidate a cached entry, forcing a re-read from disk on next access. - pub fn invalidate(&self, key: ProviderCredentialKey) { - if let Ok(mut cache) = self.inner.write() { - cache.remove(&key); - } - } - - pub fn delete_credentials(&self, key: ProviderCredentialKey) -> Result<(), ProviderCredentialLoadingCacheError> { - let file_path = self.app_data_root.credentials_dir().path().join(key.get_filename()); - - if file_path.exists() { - std::fs::remove_file(file_path) - .map_err(|e| ProviderCredentialLoadingCacheError::IoError(e))?; - } - - self.invalidate(key); - - Ok(()) - } -} - -#[derive(Debug)] -pub enum ProviderCredentialLoadingCacheError { - IoError(std::io::Error), - ApiKeyError(ApiKeyDataError), - WebLoginError(WebLoginDataError), - TypeMismatch, - LockPoisoned, -} - -impl Error for ProviderCredentialLoadingCacheError { - fn source(&self) -> Option<&(dyn Error + 'static)> { - match self { - Self::IoError(err) => Some(err), - Self::ApiKeyError(err) => Some(err), - Self::WebLoginError(err) => Some(err), - _ => None, - } - } -} - -impl Display for ProviderCredentialLoadingCacheError { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - Self::IoError(e) => write!(f, "IO error: {}", e), - Self::ApiKeyError(e) => write!(f, "API key error: {}", e), - Self::WebLoginError(e) => write!(f, "Web login error: {}", e), - Self::TypeMismatch => write!(f, "Credential type does not match key type"), - Self::LockPoisoned => write!(f, "Internal lock poisoned"), - } - } -} diff --git a/crates/desktop/artcraft/src/core/providers/credentials/provider_credential_type.rs b/crates/desktop/artcraft/src/core/providers/credentials/provider_credential_type.rs deleted file mode 100644 index fd113fcec8..0000000000 --- a/crates/desktop/artcraft/src/core/providers/credentials/provider_credential_type.rs +++ /dev/null @@ -1,9 +0,0 @@ -use serde_derive::{Deserialize, Serialize}; - -#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)] -#[serde(rename_all = "snake_case")] -pub enum ProviderCredentialType { - ApiKey, - WebLogin, -} - diff --git a/crates/desktop/artcraft/src/core/providers/mod.rs b/crates/desktop/artcraft/src/core/providers/mod.rs deleted file mode 100644 index 48c828e752..0000000000 --- a/crates/desktop/artcraft/src/core/providers/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod credentials; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/core/state/app_env_configs/app_env_configs.rs b/crates/desktop/artcraft/src/core/state/app_env_configs/app_env_configs.rs deleted file mode 100644 index 930ca5858e..0000000000 --- a/crates/desktop/artcraft/src/core/state/app_env_configs/app_env_configs.rs +++ /dev/null @@ -1,37 +0,0 @@ -use crate::core::state::app_env_configs::app_env_configs_serializeable::{AppEnvConfigsSerializable, StorytellerApiHost}; -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use errors::AnyhowResult; -use artcraft_client::utils::api_host::ApiHost; - -#[derive(Clone)] -pub struct AppEnvConfigs { - pub storyteller_host: ApiHost, -} - -impl AppEnvConfigs { - - pub fn load_from_filesystem(root: &AppDataRoot) -> AnyhowResult { - println!("Loading app environmental configs from filesystem..."); - let input = AppEnvConfigsSerializable::load_from_filesystem(root)?; - - let storyteller = input.as_ref() - .map(|i| i.storyteller_host) - .flatten(); - - let storyteller_api = match storyteller { - Some(StorytellerApiHost::Localhost) => ApiHost::Localhost { - port: input.as_ref() - .and_then(|i| i.storyteller_port) - .unwrap_or(12345) - }, - Some(StorytellerApiHost::Production) => ApiHost::Storyteller, - _ => ApiHost::Storyteller, - }; - - println!("Using storyteller API host: {:?}", storyteller_api); - - Ok(Self { - storyteller_host: storyteller_api, - }) - } -} diff --git a/crates/desktop/artcraft/src/core/state/app_env_configs/app_env_configs_serializeable.rs b/crates/desktop/artcraft/src/core/state/app_env_configs/app_env_configs_serializeable.rs deleted file mode 100644 index 16eb34e4db..0000000000 --- a/crates/desktop/artcraft/src/core/state/app_env_configs/app_env_configs_serializeable.rs +++ /dev/null @@ -1,34 +0,0 @@ -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use errors::AnyhowResult; -use serde_derive::{Deserialize, Serialize}; - -const CURRENT_VERSION: &str = "1"; - -#[derive(Debug, Copy, Clone, Serialize, Deserialize)] -#[serde(rename_all = "snake_case")] -pub enum StorytellerApiHost { - Production, - Localhost, -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(rename_all = "snake_case")] -pub struct AppEnvConfigsSerializable { - /// Versioning string. - pub version: Option, - pub storyteller_port: Option, - pub storyteller_host: Option, -} - -impl AppEnvConfigsSerializable { - pub fn load_from_filesystem(app_data_root: &AppDataRoot) -> AnyhowResult> { - let filename = app_data_root.settings_dir().get_app_env_configs_path(); - if !filename.exists() { - return Ok(None); - } - - let contents = std::fs::read_to_string(filename)?; - let data: Self = serde_json::from_str(&contents)?; - Ok(Some(data)) - } -} diff --git a/crates/desktop/artcraft/src/core/state/app_env_configs/mod.rs b/crates/desktop/artcraft/src/core/state/app_env_configs/mod.rs deleted file mode 100644 index be171e276d..0000000000 --- a/crates/desktop/artcraft/src/core/state/app_env_configs/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod app_env_configs; -pub mod app_env_configs_serializeable; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/core/state/app_preferences/app_preferences.rs b/crates/desktop/artcraft/src/core/state/app_preferences/app_preferences.rs deleted file mode 100644 index 8178bfca2e..0000000000 --- a/crates/desktop/artcraft/src/core/state/app_preferences/app_preferences.rs +++ /dev/null @@ -1,75 +0,0 @@ -use crate::core::state::app_preferences::app_preferences_serializable::AppPreferencesSerializable; -use crate::core::state::app_preferences::preferred_download_directory::{PreferredDownloadDirectory, SystemDownloadDirectory}; -use crate::core::state::data_dir::app_data_root::AppDataRoot; - -#[derive(Clone)] -pub struct AppPreferences { - /// The downloads directory to use when a user downloads a file. - pub preferred_download_directory: PreferredDownloadDirectory, - - /// Play sounds on events. - pub play_sounds: bool, - - /// Key pointing to file; defined in the frontend code. - pub delete_file_sound: Option, - - /// Key pointing to file; defined in the frontend code. - /// Defined for enqueue since image enqueue can be async - pub enqueue_success_sound: Option, - - /// Key pointing to file; defined in the frontend code. - /// Defined for enqueue since image enqueue can be async - pub enqueue_failure_sound: Option, - - /// Key pointing to file; defined in the frontend code. - pub generation_success_sound: Option, - - /// Key pointing to file; defined in the frontend code. - pub generation_failure_sound: Option, - - /// Key pointing to file; defined in the frontend code. - #[deprecated] - pub generation_enqueue_sound: Option, -} - -impl Default for AppPreferences { - fn default() -> Self { - Self { - preferred_download_directory: PreferredDownloadDirectory::System(SystemDownloadDirectory::Downloads), - play_sounds: true, - // NB: These are defined in the frontend. - enqueue_success_sound: Some("done".to_string()), - enqueue_failure_sound: Some("spike_throw".to_string()), - generation_success_sound: Some("special_flower".to_string()), - generation_failure_sound: Some("crumble".to_string()), - generation_enqueue_sound: Some("done".to_string()), - delete_file_sound: Some("trash".to_string()), - } - } -} - -impl AppPreferences { - pub fn load_from_file_or_default(data_root: &AppDataRoot) -> Self { - let filename = data_root.settings_dir().get_app_preferences_path(); - if !filename.exists() { - return Self::default(); - } - - match AppPreferencesSerializable::load_from_file(data_root) { - Ok(Some(serializable)) => { - serializable.to_preferences() - } - Ok(None) => { - Self::default() - } - Err(err) => { - println!("Error loading app preferences: {}", err); - Self::default() - } - } - } - - pub fn to_serializable(&self) -> AppPreferencesSerializable { - AppPreferencesSerializable::from_preferences(self) - } -} diff --git a/crates/desktop/artcraft/src/core/state/app_preferences/app_preferences_manager.rs b/crates/desktop/artcraft/src/core/state/app_preferences/app_preferences_manager.rs deleted file mode 100644 index 23282364a9..0000000000 --- a/crates/desktop/artcraft/src/core/state/app_preferences/app_preferences_manager.rs +++ /dev/null @@ -1,10 +0,0 @@ -use crate::core::state::app_preferences::app_preferences::AppPreferences; -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use memory_store::clone_cell::CloneCell; - -pub type AppPreferencesManager = CloneCell; - -pub fn load_app_preferences_or_default(data_root: &AppDataRoot) -> AppPreferencesManager { - let prefs = AppPreferences::load_from_file_or_default(data_root); - AppPreferencesManager::with_owned(prefs) -} diff --git a/crates/desktop/artcraft/src/core/state/app_preferences/app_preferences_serializable.rs b/crates/desktop/artcraft/src/core/state/app_preferences/app_preferences_serializable.rs deleted file mode 100644 index e795d44cc2..0000000000 --- a/crates/desktop/artcraft/src/core/state/app_preferences/app_preferences_serializable.rs +++ /dev/null @@ -1,83 +0,0 @@ -use crate::core::state::app_preferences::app_preferences::AppPreferences; -use crate::core::state::app_preferences::preferred_download_directory::PreferredDownloadDirectory; -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use errors::AnyhowResult; -use serde_derive::{Deserialize, Serialize}; - -/// Vector clock versioning string rather than semver. -/// - Version 1 - initial version. -/// - Version 2 - added "delete_file_sound", marked optionals "skip_serializing_if" -const CURRENT_VERSION: &str = "2"; - -#[derive(Debug, Clone, Serialize, Deserialize)] -pub struct AppPreferencesSerializable { - /// Versioning string. - pub version: String, - - /// The downloads directory to use when a user downloads a file. - pub preferred_download_directory: Option, - - /// Play sounds on events. - #[serde(skip_serializing_if = "Option::is_none")] - pub play_sounds: Option, - - /// Key pointing to file; defined in the frontend code. - #[serde(skip_serializing_if = "Option::is_none")] - pub delete_file_sound: Option, - - /// Key pointing to file; defined in the frontend code. - #[serde(skip_serializing_if = "Option::is_none")] - pub generation_success_sound: Option, - - /// Key pointing to file; defined in the frontend code. - #[serde(skip_serializing_if = "Option::is_none")] - pub generation_failure_sound: Option, - - /// Key pointing to file; defined in the frontend code. - #[serde(skip_serializing_if = "Option::is_none")] - pub generation_enqueue_sound: Option, -} - -impl AppPreferencesSerializable { - pub fn load_from_file(app_data_root: &AppDataRoot) -> AnyhowResult> { - let filename = app_data_root.settings_dir().get_app_preferences_path(); - if !filename.exists() { - return Ok(None); - } - - let contents = std::fs::read_to_string(filename)?; - let data: Self = serde_json::from_str(&contents)?; - Ok(Some(data)) - } - - pub fn from_preferences(preferences: &AppPreferences) -> Self { - Self { - version: CURRENT_VERSION.to_string(), - preferred_download_directory: Some(preferences.preferred_download_directory.clone()), - play_sounds: Some(preferences.play_sounds), - delete_file_sound: preferences.delete_file_sound.clone(), - generation_success_sound: preferences.generation_success_sound.clone(), - generation_failure_sound: preferences.generation_failure_sound.clone(), - generation_enqueue_sound: preferences.generation_enqueue_sound.clone(), - } - } - - pub fn to_preferences(&self) -> AppPreferences { - let mut preferences = AppPreferences::default(); - - if let Some(preferred_download_directory) = &self.preferred_download_directory { - preferences.preferred_download_directory = preferred_download_directory.clone(); - } - - if let Some(play_sounds) = self.play_sounds { - preferences.play_sounds = play_sounds; - } - - preferences.delete_file_sound = self.delete_file_sound.clone(); - preferences.generation_success_sound = self.generation_success_sound.clone(); - preferences.generation_failure_sound = self.generation_failure_sound.clone(); - preferences.generation_enqueue_sound = self.generation_enqueue_sound.clone(); - - preferences - } -} diff --git a/crates/desktop/artcraft/src/core/state/app_preferences/mod.rs b/crates/desktop/artcraft/src/core/state/app_preferences/mod.rs deleted file mode 100644 index d2385da909..0000000000 --- a/crates/desktop/artcraft/src/core/state/app_preferences/mod.rs +++ /dev/null @@ -1,4 +0,0 @@ -pub mod app_preferences; -pub mod app_preferences_manager; -pub mod app_preferences_serializable; -pub mod preferred_download_directory; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/core/state/app_preferences/preferred_download_directory.rs b/crates/desktop/artcraft/src/core/state/app_preferences/preferred_download_directory.rs deleted file mode 100644 index dd065998f8..0000000000 --- a/crates/desktop/artcraft/src/core/state/app_preferences/preferred_download_directory.rs +++ /dev/null @@ -1,105 +0,0 @@ -use errors::AnyhowError; -use serde_derive::{Deserialize, Serialize}; -use std::fmt::{Display, Formatter}; -use std::path::{Path, PathBuf}; -use std::str::FromStr; -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::core::state::data_dir::trait_data_subdir::DataSubdir; - -const SYSTEM_DEFAULT_SENTINEL_VALUE: &str = "system_default"; - -/// NB: The reason these are not flat is so that they serialize/deserialize nicely to/from JSON. -#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq)] -#[serde(rename_all = "snake_case")] -pub enum PreferredDownloadDirectory { - /// The system-default downloads directory, which varies by OS. - /// NB: Serializes as `"system_default"` in JSON. - System(SystemDownloadDirectory), - - /// A user-defined path - /// NB: Serializes as `{"custom": "/path/to/dir"}` in JSON. - Custom(PathBuf), -} - -#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq)] -#[serde(rename_all = "snake_case")] -pub enum SystemDownloadDirectory { - Downloads, - Documents, -} - -impl PreferredDownloadDirectory { - /// This doesn't have a fallback. - pub fn maybe_to_download_directory(&self) -> Option { - match self { - PreferredDownloadDirectory::Custom(path) => Some(path.clone()), - PreferredDownloadDirectory::System(SystemDownloadDirectory::Documents) => { - dirs::document_dir() - } - PreferredDownloadDirectory::System(SystemDownloadDirectory::Downloads) => { - dirs::download_dir() - } - } - } - - /// Fallback to the Artcraft directory. - pub fn download_directory(&self, root: &AppDataRoot) -> PathBuf { - let maybe_path = self.maybe_to_download_directory(); - maybe_path.unwrap_or_else(|| root.downloads_dir().path().to_path_buf()) - } -} - -impl FromStr for SystemDownloadDirectory { - type Err = AnyhowError; - - fn from_str(s: &str) -> Result { - match (s) { - "downloads" => Ok(SystemDownloadDirectory::Downloads), - "documents" => Ok(SystemDownloadDirectory::Documents), - _ => Err(AnyhowError::msg(format!("Invalid system download directory: {}", s))), - } - } -} - -impl Display for PreferredDownloadDirectory { - fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { - match self { - PreferredDownloadDirectory::System(system) => system.fmt(f), - PreferredDownloadDirectory::Custom(path) => write!(f, "{}", path.to_string_lossy()), - } - } -} - -impl Display for SystemDownloadDirectory { - fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { - match self { - SystemDownloadDirectory::Downloads => write!(f, "downloads"), - SystemDownloadDirectory::Documents => write!(f, "documents"), - } - } -} - -#[cfg(test)] -mod tests { - use crate::core::state::app_preferences::preferred_download_directory::PreferredDownloadDirectory; - use crate::core::state::app_preferences::preferred_download_directory::SystemDownloadDirectory; - - - mod json { - use super::*; - - #[test] - fn to_json_system_default() { - let val = PreferredDownloadDirectory::System(SystemDownloadDirectory::Documents); - let val = serde_json::to_string(&val).unwrap(); - assert_eq!(&val, "{\"system\":\"documents\"}"); - } - - #[test] - fn to_json_custom() { - let val = PreferredDownloadDirectory::Custom("/tmp".into()); - let val = serde_json::to_string(&val).unwrap(); - assert_eq!(&val, "{\"custom\":\"/tmp\"}"); - } - } -} diff --git a/crates/desktop/artcraft/src/core/state/app_startup_time.rs b/crates/desktop/artcraft/src/core/state/app_startup_time.rs deleted file mode 100644 index 900797ebd7..0000000000 --- a/crates/desktop/artcraft/src/core/state/app_startup_time.rs +++ /dev/null @@ -1,22 +0,0 @@ -use chrono::{DateTime, TimeDelta, Utc}; - -pub struct AppStartupTime { - startup_time: DateTime, -} - -impl AppStartupTime { - pub fn new() -> Self { - Self { - startup_time: Utc::now(), - } - } - - pub fn get_startup_time(&self) -> DateTime { - self.startup_time - } - - pub fn time_delta_since(&self) -> TimeDelta { - let now = Utc::now(); - now.signed_duration_since(self.startup_time) - } -} diff --git a/crates/desktop/artcraft/src/core/state/artcraft_platform_info.rs b/crates/desktop/artcraft/src/core/state/artcraft_platform_info.rs deleted file mode 100644 index c042c4d2fe..0000000000 --- a/crates/desktop/artcraft/src/core/state/artcraft_platform_info.rs +++ /dev/null @@ -1,68 +0,0 @@ -use crate::core::state::os_platform::OsPlatform; -use crate::version::ARTCRAFT_VERSION; -use chrono::{DateTime, Utc}; - -#[derive(Clone, Debug)] -pub struct ArtcraftPlatformInfo { - pub artcraft_version: String, - - pub os_platform: ArtcraftOs, - pub os_version: String, - - pub build_timestamp: DateTime, - - pub git_commit_id: Option, - pub git_commit_short_id: Option, - pub git_commit_timestamp: Option>, -} - -#[derive(Copy, Clone, Debug)] -pub enum ArtcraftOs { - Windows, - MacOS, - Linux, - Unknown, -} - -impl ArtcraftPlatformInfo { - - pub fn get() -> Self { - let build_timestamp = build_metadata::build_timestamp(); - let git_commit_id = build_metadata::git_commit_id().map(|s| s.to_string()); - let git_commit_short_id = build_metadata::git_commit_short_id().map(|s| s.to_string()); - let git_commit_timestamp = build_metadata::git_commit_timestamp(); - - let os_info = os_info::get(); - - let maybe_os_version = Some(os_info.version().to_string()) - .map(|s| s.trim().to_string()) - .filter(|s| !s.is_empty()) - .unwrap_or_else(|| "unknown".to_string()); - - Self { - artcraft_version: ARTCRAFT_VERSION.to_string(), - os_platform: match OsPlatform::maybe_get() { - Some(OsPlatform::Linux) => ArtcraftOs::Linux, - Some(OsPlatform::MacOs) => ArtcraftOs::MacOS, - Some(OsPlatform::Windows) => ArtcraftOs::Windows, - None => ArtcraftOs::Unknown, - }, - os_version: maybe_os_version, - build_timestamp, - git_commit_id, - git_commit_short_id, - git_commit_timestamp, - } - } -} - -impl ArtcraftOs { - pub fn as_str(&self) -> &'static str { - match self { - ArtcraftOs::Windows => "windows", - ArtcraftOs::MacOS => "macos", - ArtcraftOs::Linux => "linux", - ArtcraftOs::Unknown => "unknown", - } - } -} diff --git a/crates/desktop/artcraft/src/core/state/artcraft_usage_tracker/artcraft_usage_tracker.rs b/crates/desktop/artcraft/src/core/state/artcraft_usage_tracker/artcraft_usage_tracker.rs deleted file mode 100644 index fca429d97a..0000000000 --- a/crates/desktop/artcraft/src/core/state/artcraft_usage_tracker/artcraft_usage_tracker.rs +++ /dev/null @@ -1,135 +0,0 @@ -use crate::core::state::artcraft_usage_tracker::artcraft_usage_tracker_data::ArtcraftUsageTrackerData; -use std::sync::{Arc, LockResult, RwLock}; -use log::{error, warn}; -use crate::core::artcraft_error::ArtcraftError; -use crate::core::state::artcraft_usage_tracker::artcraft_usage_type::{ArtcraftUsagePage, ArtcraftUsageType}; - -/// Track generation volume so we know which areas to focus efforts on. -/// But also note: https://en.wikipedia.org/wiki/Survivorship_bias -#[derive(Clone)] -pub struct ArtcraftUsageTracker { - data: Arc>, -} - - -impl ArtcraftUsageTracker { - pub fn new() -> Self { - Self { - data: Arc::new(RwLock::new(ArtcraftUsageTrackerData::new())), - } - } - - pub fn record_image_generation(&self, num_images: u16, usage_type: ArtcraftUsageType, page: ArtcraftUsagePage) -> Result<(), ArtcraftError> { - let mut data = self.get()?; - data.total_generation_count += num_images; - data.image_generation_count += num_images; - match usage_type { - ArtcraftUsageType::TextToResult => { - data.text_to_image_count += num_images; - } - ArtcraftUsageType::ImageToResult => { - data.image_to_image_count += num_images; - } - ArtcraftUsageType::Other => {} - } - match page { - ArtcraftUsagePage::ImagePage => { - data.image_page_prompt_count += num_images; - } - ArtcraftUsagePage::EditPage => { - data.edit_page_prompt_count += num_images; - } - ArtcraftUsagePage::StagePage => { - data.stage_page_prompt_count += num_images; - } - ArtcraftUsagePage::OtherPage => { - data.other_page_prompt_count += num_images; - } - ArtcraftUsagePage::VideoPage => {} // NB: Does not generate images. - ArtcraftUsagePage::ObjectPage => {} // NB: Does not generate images. - } - self.set(data)?; - Ok(()) - } - - pub fn record_video_generation(&self, num_videos: u16, usage_type: ArtcraftUsageType, page: ArtcraftUsagePage) -> Result<(), ArtcraftError> { - let mut data = self.get()?; - data.total_generation_count += num_videos; - data.video_generation_count += num_videos; - match usage_type { - ArtcraftUsageType::TextToResult => { - data.text_to_video_count += num_videos; - } - ArtcraftUsageType::ImageToResult => { - data.image_to_video_count += num_videos; - } - ArtcraftUsageType::Other => {} - } - match page { - ArtcraftUsagePage::VideoPage => { - data.video_page_prompt_count += num_videos; - } - ArtcraftUsagePage::OtherPage => { - data.other_page_prompt_count += num_videos; - } - ArtcraftUsagePage::ImagePage => {} // NB: Does not generate videos. - ArtcraftUsagePage::EditPage => {} // NB: Does not generate videos. - ArtcraftUsagePage::StagePage => {} // NB: Does not generate videos. - ArtcraftUsagePage::ObjectPage => {} // NB: Does not generate videos. - } - self.set(data)?; - Ok(()) - } - - pub fn record_object_generation(&self, num_objects: u16, usage_type: ArtcraftUsageType, page: ArtcraftUsagePage) -> Result<(), ArtcraftError> { - let mut data = self.get()?; - data.total_generation_count += num_objects; - data.object_generation_count += num_objects; - match usage_type { - ArtcraftUsageType::TextToResult => { - data.text_to_object_count += num_objects; - } - ArtcraftUsageType::ImageToResult => { - data.image_to_object_count += num_objects; - } - ArtcraftUsageType::Other => {} - } - match page { - ArtcraftUsagePage::ObjectPage => { - data.object_page_prompt_count += num_objects; - } - ArtcraftUsagePage::OtherPage => { - data.other_page_prompt_count += num_objects; - } - ArtcraftUsagePage::ImagePage => {} // NB: Does not generate objects. - ArtcraftUsagePage::VideoPage => {} // NB: Does not generate objects. - ArtcraftUsagePage::EditPage => {} // NB: Does not generate objects. - ArtcraftUsagePage::StagePage => {} // NB: Does not generate objects. - } - self.set(data)?; - Ok(()) - } - - pub fn get(&self) -> Result { - match self.data.read() { - Ok(data) => Ok(data.clone()), - Err(err) => { - error!("Lock read error: {:?}", err); - Err(ArtcraftError::RwLockReadError) - } - } - } - - fn set(&self, data: ArtcraftUsageTrackerData) -> Result<(), ArtcraftError> { - match self.data.write() { - Ok(mut lock) => { - *lock = data; - Ok(()) - }, - Err(err) => { - error!("Lock write error: {:?}", err); - Err(ArtcraftError::RwLockWriteError) - } - } - } -} diff --git a/crates/desktop/artcraft/src/core/state/artcraft_usage_tracker/artcraft_usage_tracker_data.rs b/crates/desktop/artcraft/src/core/state/artcraft_usage_tracker/artcraft_usage_tracker_data.rs deleted file mode 100644 index 725c7609d9..0000000000 --- a/crates/desktop/artcraft/src/core/state/artcraft_usage_tracker/artcraft_usage_tracker_data.rs +++ /dev/null @@ -1,46 +0,0 @@ - -/// Track generation volume so we know which areas to focus efforts on. -/// But also note: https://en.wikipedia.org/wiki/Survivorship_bias -#[derive(Clone)] -pub struct ArtcraftUsageTrackerData { - pub total_generation_count: u16, - pub image_generation_count: u16, - pub video_generation_count: u16, - pub object_generation_count: u16, - pub text_to_image_count: u16, - pub image_to_image_count: u16, - pub text_to_video_count: u16, - pub image_to_video_count: u16, - pub text_to_object_count: u16, - pub image_to_object_count: u16, - pub image_page_prompt_count: u16, - pub video_page_prompt_count: u16, - pub edit_page_prompt_count: u16, - pub stage_page_prompt_count: u16, - pub object_page_prompt_count: u16, - pub other_page_prompt_count: u16, -} - -impl ArtcraftUsageTrackerData { - pub fn new() -> Self { - Self { - total_generation_count: 0, - image_generation_count: 0, - video_generation_count: 0, - object_generation_count: 0, - text_to_image_count: 0, - image_to_image_count: 0, - text_to_video_count: 0, - image_to_video_count: 0, - text_to_object_count: 0, - image_to_object_count: 0, - image_page_prompt_count: 0, - video_page_prompt_count: 0, - edit_page_prompt_count: 0, - stage_page_prompt_count: 0, - object_page_prompt_count: 0, - other_page_prompt_count: 0, - } - } -} - diff --git a/crates/desktop/artcraft/src/core/state/artcraft_usage_tracker/artcraft_usage_type.rs b/crates/desktop/artcraft/src/core/state/artcraft_usage_tracker/artcraft_usage_type.rs deleted file mode 100644 index 6fe8684bcd..0000000000 --- a/crates/desktop/artcraft/src/core/state/artcraft_usage_tracker/artcraft_usage_type.rs +++ /dev/null @@ -1,18 +0,0 @@ - - -#[derive(Clone, Copy, Debug, PartialEq)] -pub enum ArtcraftUsageType { - TextToResult, - ImageToResult, - Other, -} - -#[derive(Clone, Copy, Debug, PartialEq)] -pub enum ArtcraftUsagePage { - ImagePage, - VideoPage, - EditPage, - StagePage, - ObjectPage, - OtherPage, -} diff --git a/crates/desktop/artcraft/src/core/state/artcraft_usage_tracker/mod.rs b/crates/desktop/artcraft/src/core/state/artcraft_usage_tracker/mod.rs deleted file mode 100644 index 8a61045b3d..0000000000 --- a/crates/desktop/artcraft/src/core/state/artcraft_usage_tracker/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub mod artcraft_usage_tracker; -pub mod artcraft_usage_type; -mod artcraft_usage_tracker_data; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/core/state/data_dir/app_assets_dir.rs b/crates/desktop/artcraft/src/core/state/data_dir/app_assets_dir.rs deleted file mode 100644 index 154eb799ae..0000000000 --- a/crates/desktop/artcraft/src/core/state/data_dir/app_assets_dir.rs +++ /dev/null @@ -1,36 +0,0 @@ -use crate::core::state::data_dir::trait_data_subdir::DataSubdir; -use chrono::{DateTime, Local}; -use std::path::{Path, PathBuf}; - -#[derive(Clone)] -pub struct AppAssetsDir { - path: PathBuf, -} - -impl DataSubdir for AppAssetsDir { - const DIRECTORY_NAME: &'static str = "assets"; - - fn new_from>(dir: P) -> Self { - Self { - path: dir.as_ref().to_path_buf(), - } - } - - fn path(&self) -> &Path { - &self.path - } -} - -impl AppAssetsDir { - /// Return the current date asset directory - /// If it doesn't exist, create it. - pub fn make_or_get_current_date_dir(&self) -> anyhow::Result { - let format: DateTime = Local::now(); - let date_directory_name = format.format("%Y-%d-%m").to_string(); - let full_path = self.path.join(date_directory_name); - if !full_path.exists() { - std::fs::create_dir(&full_path)?; - } - Ok(full_path) - } -} diff --git a/crates/desktop/artcraft/src/core/state/data_dir/app_credentials_dir.rs b/crates/desktop/artcraft/src/core/state/data_dir/app_credentials_dir.rs deleted file mode 100644 index 31f4ba8f77..0000000000 --- a/crates/desktop/artcraft/src/core/state/data_dir/app_credentials_dir.rs +++ /dev/null @@ -1,80 +0,0 @@ -use crate::core::state::data_dir::trait_data_subdir::DataSubdir; -use std::path::{Path, PathBuf}; - -#[derive(Clone)] -pub struct AppCredentialsDir { - path: PathBuf, -} - -impl DataSubdir for AppCredentialsDir { - const DIRECTORY_NAME: &'static str = "credentials"; - - fn new_from> (dir: P) -> Self { - Self { - path: dir.as_ref().to_path_buf(), - } - } - - fn path(&self) -> &Path { - &self.path - } -} - -impl AppCredentialsDir { - pub fn get_grok_state_path(&self) -> PathBuf { - self.path.join("grok_state.json") - } - - pub fn get_grok_cookies_path(&self) -> PathBuf { - self.path.join("grok_cookies.txt") - } - - pub fn get_sora_cookie_file_path(&self) -> PathBuf { - self.path.join("sora_cookies.txt") - } - - pub fn get_sora_bearer_token_file_path(&self) -> PathBuf { - self.path.join("sora_bearer_token.txt") - } - - #[deprecated(note="use the new sentinel token methods")] - pub fn get_sora_legacy_sentinel_file_path(&self) -> PathBuf { - self.path.join("sora_sentinel.txt") - } - - pub fn get_sora_sentinel_token_file_path(&self) -> PathBuf { - self.path.join("sora_sentinel_token_store.json") - } - - pub fn get_storyteller_avt_cookie_file_path(&self) -> PathBuf { - self.path.join("artcraft_avt.txt") - } - - pub fn get_storyteller_session_cookie_file_path(&self) -> PathBuf { - self.path.join("artcraft_session.txt") - } - - pub fn get_fal_api_key_file_path(&self) -> PathBuf { - self.path.join("fal_api_key.txt") - } - - pub fn get_midjourney_state_path(&self) -> PathBuf { - self.path.join("midjourney_state.json") - } - - pub fn get_worldlabs_state_path(&self) -> PathBuf { - self.path.join("worldlabs_state.json") - } - - pub fn get_worldlabs_cookies_path(&self) -> PathBuf { - self.path.join("worldlabs_cookies.txt") - } - - pub fn get_worldlabs_bearer_path(&self) -> PathBuf { - self.path.join("worldlabs_bearer.txt") - } - - pub fn get_worldlabs_refresh_path(&self) -> PathBuf { - self.path.join("worldlabs_refresh.txt") - } -} diff --git a/crates/desktop/artcraft/src/core/state/data_dir/app_data_root.rs b/crates/desktop/artcraft/src/core/state/data_dir/app_data_root.rs deleted file mode 100644 index 5ca486fbc9..0000000000 --- a/crates/desktop/artcraft/src/core/state/data_dir/app_data_root.rs +++ /dev/null @@ -1,158 +0,0 @@ -use crate::core::state::data_dir::app_assets_dir::AppAssetsDir; -use crate::core::state::data_dir::app_credentials_dir::AppCredentialsDir; -use crate::core::state::data_dir::app_downloads_dir::AppDownloadsDir; -use crate::core::state::data_dir::app_settings_dir::AppSettingsDir; -use crate::core::state::data_dir::app_state_dir::AppStateDir; -use crate::core::state::data_dir::temporary_dir::TemporaryDir; -use crate::core::state::data_dir::trait_data_subdir::DataSubdir; -use crate::core::state::expanduser::expanduser; -use crate::core::state::os_platform::OsPlatform; -use anyhow::anyhow; -use directories::UserDirs; -use std::path::{Path, PathBuf}; - -const DEFAULT_DATA_DIR : &str = "Artcraft"; - -/// Note: Tauri appends ".log" to the end of the filename. -const LOG_FILE_NAME : &str = "artcraft_debug"; - -/// The path to the application data directory, which includes "asset" and "weights" data. -#[derive(Clone)] -pub struct AppDataRoot { - path: PathBuf, - - log_file_name: PathBuf, - log_file_name_string: String, - - assets_dir: AppAssetsDir, - credentials_dir: AppCredentialsDir, - downloads_dir: AppDownloadsDir, - settings_dir: AppSettingsDir, - state_dir: AppStateDir, - temp_dir: TemporaryDir, -} - -impl AppDataRoot { - pub fn create_default() -> anyhow::Result { - let directory = get_default_data_dir()?; - println!("App data directory: {:?}", directory); - Self::create_existing(directory) - } - - pub fn create_existing>(dir: P) -> anyhow::Result { - let mut dir = dir.as_ref().to_path_buf(); - - match OsPlatform::get() { - OsPlatform::Linux | OsPlatform::MacOs => { - if let Some(d) = dir.as_os_str().to_str() { - dir = expanduser(d)?; - } - }, - OsPlatform::Windows => {} - } - - if !dir.is_dir() { - println!("Creating directory {:?}", dir); - std::fs::create_dir_all(&dir)?; - } - - match dir.canonicalize() { - Ok(d) => dir = d, - Err(err) => { - println!("Error canonicalizing {:?}: {}", dir, err); - } - } - - let assets_dir = AppAssetsDir::get_or_create_in_root_dir(&dir)?; - let credentials_dir = AppCredentialsDir::get_or_create_in_root_dir(&dir)?; - let downloads_dir = AppDownloadsDir::get_or_create_in_root_dir(&dir)?; - let settings_dir = AppSettingsDir::get_or_create_in_root_dir(&dir)?; - let state_dir = AppStateDir::get_or_create_in_root_dir(&dir)?; - let temp_dir = TemporaryDir::get_or_create_in_root_dir(&dir)?; - let log_file_name = dir.join(LOG_FILE_NAME); - let log_file_name_string = log_file_name - .to_str() - .ok_or(anyhow!("couldn't convert log path to str"))? - .to_string(); - - Ok(Self { - path: dir, - log_file_name, - log_file_name_string, - assets_dir, - credentials_dir, - downloads_dir, - settings_dir, - state_dir, - temp_dir, - }) - } - - pub fn assets_dir(&self) -> &AppAssetsDir { - &self.assets_dir - } - - pub fn credentials_dir(&self) -> &AppCredentialsDir { - &self.credentials_dir - } - - pub fn downloads_dir(&self) -> &AppDownloadsDir { - &self.downloads_dir - } - - pub fn settings_dir(&self) -> &AppSettingsDir { - &self.settings_dir - } - - pub fn state_dir(&self) -> &AppStateDir { - &self.state_dir - } - - pub fn temp_dir(&self) -> &TemporaryDir { - &self.temp_dir - } - - pub fn path(&self) -> &Path { - &self.path - } - - pub fn log_file_name(&self) -> &Path { - &self.log_file_name - } - - pub fn log_file_name_str(&self) -> &str { - &self.log_file_name_string - } - - pub fn get_sora_cookie_file_path(&self) -> PathBuf { - self.credentials_dir().get_sora_cookie_file_path() - } - - pub fn get_sora_bearer_token_file_path(&self) -> PathBuf { - self.credentials_dir().get_sora_bearer_token_file_path() - } - - pub fn get_sora_legacy_sentinel_file_path(&self) -> PathBuf { - self.credentials_dir().get_sora_legacy_sentinel_file_path() - } - - pub fn get_sora_sentinel_token_file_path(&self) -> PathBuf { - self.credentials_dir().get_sora_sentinel_token_file_path() - } - - pub fn get_window_size_config_file(&self) -> PathBuf { - self.state_dir.get_window_size_config_file() - } - - pub fn get_window_position_config_file(&self) -> PathBuf { - self.state_dir.get_window_position_config_file() - } -} - -// eg. /home/bob/artcraft, /Users/alice/artcraft, or C:\Users\Taylor\artcraft -fn get_default_data_dir() -> anyhow::Result { - Ok(UserDirs::new() - .ok_or_else(|| anyhow!("could not determine user home directory"))? - .home_dir() - .join(DEFAULT_DATA_DIR)) -} diff --git a/crates/desktop/artcraft/src/core/state/data_dir/app_downloads_dir.rs b/crates/desktop/artcraft/src/core/state/data_dir/app_downloads_dir.rs deleted file mode 100644 index f08250686f..0000000000 --- a/crates/desktop/artcraft/src/core/state/data_dir/app_downloads_dir.rs +++ /dev/null @@ -1,21 +0,0 @@ -use crate::core::state::data_dir::trait_data_subdir::DataSubdir; -use std::path::{Path, PathBuf}; - -#[derive(Clone)] -pub struct AppDownloadsDir { - path: PathBuf, -} - -impl DataSubdir for AppDownloadsDir { - const DIRECTORY_NAME: &'static str = "downloads"; - - fn new_from>(dir: P) -> Self { - Self { - path: dir.as_ref().to_path_buf(), - } - } - - fn path(&self) -> &Path { - &self.path - } -} diff --git a/crates/desktop/artcraft/src/core/state/data_dir/app_settings_dir.rs b/crates/desktop/artcraft/src/core/state/data_dir/app_settings_dir.rs deleted file mode 100644 index 55cb1fd9f5..0000000000 --- a/crates/desktop/artcraft/src/core/state/data_dir/app_settings_dir.rs +++ /dev/null @@ -1,64 +0,0 @@ -use crate::core::state::app_preferences::app_preferences::AppPreferences; -use crate::core::state::data_dir::trait_data_subdir::DataSubdir; -use errors::AnyhowResult; -use serde::Serialize; -use std::fs::OpenOptions; -use std::io::Write; -use std::path::{Path, PathBuf}; - -/// For now, let's just keep a collection of loose json files in a settings dir. -/// Once we know the structure and schema, we can standardize on a single json file. -#[derive(Clone)] -pub struct AppSettingsDir { - path: PathBuf, -} - -impl DataSubdir for AppSettingsDir { - const DIRECTORY_NAME: &'static str = "settings"; - - fn new_from> (dir: P) -> Self { - Self { - path: dir.as_ref().to_path_buf(), - } - } - - fn path(&self) -> &Path { - &self.path - } -} - -impl AppSettingsDir { - pub fn get_app_preferences_path(&self) -> PathBuf { - self.path.join("app_preferences.json") - } - - pub fn get_app_env_configs_path(&self) -> PathBuf { - self.path.join("env_configs.json") - } - - pub fn get_provider_preferences_path(&self) -> PathBuf { - self.path.join("provider_preferences.json") - } - - pub fn write_app_preferences(&self, prefs: &AppPreferences) -> AnyhowResult<()> { - let serializable = prefs.to_serializable(); - - let formatter = serde_json::ser::PrettyFormatter::with_indent(b" "); - let mut buf = Vec::new(); - let mut ser = serde_json::Serializer::with_formatter(&mut buf, formatter); - serializable.serialize(&mut ser)?; - - let filename = self.get_app_preferences_path(); - - let mut file = OpenOptions::new() - .create(true) - .write(true) - .truncate(true) - .open(filename)?; - - file.write_all(&buf)?; - file.flush()?; - - Ok(()) - } -} diff --git a/crates/desktop/artcraft/src/core/state/data_dir/app_state_dir.rs b/crates/desktop/artcraft/src/core/state/data_dir/app_state_dir.rs deleted file mode 100644 index 66223b5a40..0000000000 --- a/crates/desktop/artcraft/src/core/state/data_dir/app_state_dir.rs +++ /dev/null @@ -1,38 +0,0 @@ -use crate::core::state::data_dir::trait_data_subdir::DataSubdir; -use crate::core::state::task_database_version::TASK_DATABASE_VERSION; -use std::path::{Path, PathBuf}; - -#[derive(Clone)] -pub struct AppStateDir { - path: PathBuf, -} - -impl DataSubdir for AppStateDir{ - const DIRECTORY_NAME: &'static str = "state"; - - fn new_from>(dir: P) -> Self { - Self { - path: dir.as_ref().to_path_buf(), - } - } - - fn path(&self) -> &Path { - &self.path - } -} - -impl AppStateDir { - pub fn get_tasks_sqlite_database_path(&self) -> PathBuf { - // NB: This must be incremented on any change to the database schema (including comments). - // The database houses ephemeral content and will be migrated automatically. - self.path.join(format!("tasks_v{TASK_DATABASE_VERSION}.sqlite")) - } - - pub fn get_window_size_config_file(&self) -> PathBuf { - self.path.join("window_size.json") - } - - pub fn get_window_position_config_file(&self) -> PathBuf { - self.path.join("window_position.json") - } -} diff --git a/crates/desktop/artcraft/src/core/state/data_dir/app_weights_dir.rs b/crates/desktop/artcraft/src/core/state/data_dir/app_weights_dir.rs deleted file mode 100644 index e670f15d5f..0000000000 --- a/crates/desktop/artcraft/src/core/state/data_dir/app_weights_dir.rs +++ /dev/null @@ -1,21 +0,0 @@ -use crate::core::state::data_dir::trait_data_subdir::DataSubdir; -use std::path::{Path, PathBuf}; - -#[derive(Clone)] -pub struct AppWeightsDir { - path: PathBuf, -} - -impl DataSubdir for AppWeightsDir { - const DIRECTORY_NAME: &'static str = "weights"; - - fn new_from>(dir: P) -> Self { - Self { - path: dir.as_ref().to_path_buf(), - } - } - - fn path(&self) -> &Path { - &self.path - } -} diff --git a/crates/desktop/artcraft/src/core/state/data_dir/mod.rs b/crates/desktop/artcraft/src/core/state/data_dir/mod.rs deleted file mode 100644 index 439208b8a0..0000000000 --- a/crates/desktop/artcraft/src/core/state/data_dir/mod.rs +++ /dev/null @@ -1,9 +0,0 @@ -pub mod app_assets_dir; -pub mod app_credentials_dir; -pub mod app_data_root; -pub mod app_downloads_dir; -pub mod app_settings_dir; -pub mod app_state_dir; -pub mod app_weights_dir; -pub mod temporary_dir; -pub mod trait_data_subdir; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/core/state/data_dir/temporary_dir.rs b/crates/desktop/artcraft/src/core/state/data_dir/temporary_dir.rs deleted file mode 100644 index 4456562e35..0000000000 --- a/crates/desktop/artcraft/src/core/state/data_dir/temporary_dir.rs +++ /dev/null @@ -1,51 +0,0 @@ -use crate::core::state::data_dir::trait_data_subdir::DataSubdir; -use std::path::{Path, PathBuf}; -use tempdir::TempDir; -use tempfile::{Builder, NamedTempFile}; - -#[derive(Clone)] -pub struct TemporaryDir { - path: PathBuf, -} - -impl DataSubdir for TemporaryDir { - const DIRECTORY_NAME: &'static str = "temp"; - - fn new_from>(dir: P) -> Self { - Self { - path: dir.as_ref().to_path_buf(), - } - } - - fn path(&self) -> &Path { - &self.path - } -} - -impl TemporaryDir { - pub fn with_prefix(&self, prefix: &str) -> anyhow::Result { - let tempdir = TempDir::new_in(&self.path, prefix)?; - Ok(tempdir) - } - - pub fn new_named_temp_file(&self) -> anyhow::Result { - let tempfile = Builder::new() - .prefix("temp_") - .suffix(".bin") - .tempfile_in(&self.path)?; - Ok(tempfile) - } - - pub fn new_named_temp_file_with_extension(&self, extension: &str) -> Result { - let extension = if extension.starts_with(".") { - extension.to_string() - } else { - format!(".{}", extension) - }; - let tempfile = Builder::new() - .prefix("temp_") - .suffix(&extension) - .tempfile_in(&self.path)?; - Ok(tempfile) - } -} diff --git a/crates/desktop/artcraft/src/core/state/data_dir/trait_data_subdir.rs b/crates/desktop/artcraft/src/core/state/data_dir/trait_data_subdir.rs deleted file mode 100644 index eb44a402a1..0000000000 --- a/crates/desktop/artcraft/src/core/state/data_dir/trait_data_subdir.rs +++ /dev/null @@ -1,31 +0,0 @@ -use std::path::Path; - -pub trait DataSubdir : Sized { - const DIRECTORY_NAME: &'static str; - - fn new_from>(dir: P) -> Self; - - fn path(&self) -> &Path; - - fn get_or_create_in_root_dir>(root_dir: P) -> anyhow::Result { - Self::get_or_create_dir(root_dir.as_ref().join(Self::DIRECTORY_NAME)) - } - - fn get_or_create_dir>(dir: P) -> anyhow::Result { - let mut dir = dir.as_ref().to_path_buf(); - - match dir.canonicalize() { - Ok(d) => dir = d, - Err(err) => { - println!("Error canonicalizing {:?}: {}", dir, err); - } - } - - if !dir.exists() { - println!("Creating directory {:?}", dir); - std::fs::create_dir(&dir)?; - } - - Ok(Self::new_from(dir)) - } -} diff --git a/crates/desktop/artcraft/src/core/state/expanduser.rs b/crates/desktop/artcraft/src/core/state/expanduser.rs deleted file mode 100644 index 0db8d5cec2..0000000000 --- a/crates/desktop/artcraft/src/core/state/expanduser.rs +++ /dev/null @@ -1,73 +0,0 @@ -use once_cell::sync::Lazy; -use std::io; -use std::path::{PathBuf, MAIN_SEPARATOR}; - -static PREFIX: Lazy = Lazy::new(|| format!("~{}", MAIN_SEPARATOR)); - -/// The "expanduser" crate doesn't compile on Windows, so we replace its functionality slightly -pub fn expanduser>(path: P) -> io::Result { - - Ok(match path.as_ref() { - // matches an exact "~" - s if s == "~" => { - home_dir()? - }, - // matches paths that start with `~/` - s if s.starts_with(&*PREFIX) => { - let home = home_dir()?; - home.join(&s[2..]) - }, - // // matches paths that start with `~` but not `~/`, might be a `~username/` path - // s if s.starts_with("~") => { - // let mut parts = s[1..].splitn(2, MAIN_SEPARATOR); - // let user = parts.next() - // .ok_or_else(|| io::Error::new(io::ErrorKind::Other, "malformed path"))?; - // let user = Passwd::from_name(&user) - // .map_err(|_| io::Error::new(io::ErrorKind::Other, "error searching for user"))? - // .ok_or_else(|| io::Error::new(io::ErrorKind::Other, format!("user '{}', does not exist", &user)))?; - // if let Some(ref path) = parts.next() { - // PathBuf::from(user.dir).join(&path) - // } else { - // PathBuf::from(user.dir) - // } - // }, - // nothing to expand, just make a PathBuf - s => PathBuf::from(s) - }) -} - -pub fn home_dir() -> io::Result { - dirs::home_dir() - .ok_or_else(|| io::Error::new(io::ErrorKind::Other, "no home directory is set")) -} - -#[cfg(test)] -mod tests { - use crate::core::state::expanduser::expanduser; - use std::env; - use std::path::PathBuf; - - #[test] - #[serial_test::serial] - fn test_success() { - let old_home = env::var("HOME").expect("no home dir set"); - let new_home = "/home/foo"; - env::set_var("HOME", new_home); - let path = expanduser("~/path/to/directory"); - env::set_var("HOME", old_home); - assert_eq!(path.expect("io error"), PathBuf::from("/home/foo/path/to/directory")); - } - - #[test] - #[serial_test::serial] - fn test_only_tilde() { - let old_home = env::var("HOME").expect("no home dir set"); - let new_home = "/home/foo"; - env::set_var("HOME", new_home); - let pathstr = "~"; - let path = expanduser(pathstr); - env::set_var("HOME", old_home); - assert_eq!(path.expect("io error"), PathBuf::from("/home/foo")); - } - -} \ No newline at end of file diff --git a/crates/desktop/artcraft/src/core/state/mod.rs b/crates/desktop/artcraft/src/core/state/mod.rs deleted file mode 100644 index 5a4a453b21..0000000000 --- a/crates/desktop/artcraft/src/core/state/mod.rs +++ /dev/null @@ -1,12 +0,0 @@ -pub mod app_env_configs; -pub mod app_preferences; -pub mod app_startup_time; -pub mod artcraft_platform_info; -pub mod artcraft_usage_tracker; -pub mod data_dir; -pub mod expanduser; -pub mod os_platform; -pub mod provider_priority; -pub mod task_database; -pub mod task_database_version; -pub mod window; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/core/state/os_platform.rs b/crates/desktop/artcraft/src/core/state/os_platform.rs deleted file mode 100644 index 1d4e933ae4..0000000000 --- a/crates/desktop/artcraft/src/core/state/os_platform.rs +++ /dev/null @@ -1,33 +0,0 @@ - -#[derive(Copy,Clone,Eq,PartialEq,Debug)] -pub enum OsPlatform { - Linux, - MacOs, - Windows, -} - -impl OsPlatform { - pub fn maybe_get() -> Option { - // Totally scientific. - // https://doc.rust-lang.org/std/env/consts/constant.OS.html - match std::env::consts::OS { - "linux" => Some(Self::Linux), - "windows" => Some(Self::Windows), - "macos" | "apple" => Some(Self::MacOs), - _ => None, - } - } - - pub fn maybe_get_str() -> Option<&'static str> { - match Self::maybe_get() { - Some(Self::Linux) => Some("linux"), - Some(Self::Windows) => Some("windows"), - Some(Self::MacOs) => Some("macos"), // NB: "apple" can become "macos". - None => None, - } - } - - pub fn get() -> Self { - Self::maybe_get().unwrap_or(Self::Linux) - } -} diff --git a/crates/desktop/artcraft/src/core/state/provider_priority.rs b/crates/desktop/artcraft/src/core/state/provider_priority.rs deleted file mode 100644 index 395ae3dd68..0000000000 --- a/crates/desktop/artcraft/src/core/state/provider_priority.rs +++ /dev/null @@ -1,162 +0,0 @@ -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use errors::AnyhowResult; -use serde_derive::{Deserialize, Serialize}; -use std::collections::HashSet; -use std::fs::OpenOptions; -use std::io::Write; -use std::sync::{Arc, RwLock}; - -#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)] -#[serde(rename_all = "snake_case")] -pub enum Provider { - Artcraft, - Fal, - Sora, -} - -#[derive(Clone, Debug, Serialize, Deserialize)] -#[serde(rename_all = "snake_case")] -pub struct ProviderPriority { - /// Providers may occur zero or one time. - /// They are ordered by priority, highest to lowest. - provider_priority: Vec, -} - -#[derive(Clone)] -pub struct ProviderPriorityStore { - provider_priority: Arc>, -} - -impl ProviderPriority { - pub fn default() -> Self { - Self { - provider_priority: vec![ - Provider::Artcraft, - Provider::Sora, - Provider::Fal, - ], - } - } - - pub fn set_priority(&mut self, ordered_list: &[Provider]) -> AnyhowResult<()> { - let set : HashSet<&Provider> = HashSet::from_iter(ordered_list.iter()); - - if set.len() != ordered_list.len() { - return Err(anyhow::anyhow!("Duplicate providers in the ordered list")); - } - - self.provider_priority = ordered_list.to_vec(); - Ok(()) - } - - pub fn get_priority(&self) -> &[Provider] { - &self.provider_priority - } - - pub fn from_filesystem_configs(app_data_root: &AppDataRoot) -> AnyhowResult> { - let filename = app_data_root.settings_dir().get_provider_preferences_path(); - if !filename.exists() { - return Ok(None); - } - let contents = std::fs::read_to_string(filename)?; - let providers : Self = serde_json::from_str(&contents)?; - Ok(Some(providers)) - } - - pub fn persist_to_filesystem(&self, app_data_root: &AppDataRoot) -> AnyhowResult<()> { - let filename = app_data_root.settings_dir().get_provider_preferences_path(); - let json = serde_json::to_string(self)?; - let mut file = OpenOptions::new() - .create(true) - .write(true) - .truncate(true) - .open(filename)?; - file.write_all(json.as_bytes())?; - file.flush()?; - Ok(()) - } -} - -impl ProviderPriorityStore { - pub fn default() -> Self { - Self { - provider_priority: Arc::new(RwLock::new(ProviderPriority::default())), - } - } - - pub fn set_priority(&self, ordered_list: &[Provider]) -> AnyhowResult<()> { - match self.provider_priority.write() { - Err(err) => { - Err(anyhow::anyhow!("Failed to acquire write lock on provider priority: {}", err)) - } - Ok(mut providers) => { - providers.set_priority(ordered_list)?; - Ok(()) - } - } - } - - pub fn get_priority(&self) -> AnyhowResult> { - match self.provider_priority.read() { - Err(err) => { - Err(anyhow::anyhow!("Failed to acquire read lock on provider priority: {}", err)) - } - Ok(providers) => { - Ok(providers.get_priority().to_vec()) - } - } - } - - pub fn from_filesystem_configs(app_data_root: &AppDataRoot) -> AnyhowResult> { - match ProviderPriority::from_filesystem_configs(app_data_root) { - Err(err) => { - Err(anyhow::anyhow!("Failed to read provider preferences from filesystem: {}", err)) - } - Ok(None) => Ok(None), - Ok(Some(providers)) => { - Ok(Some(Self { - provider_priority: Arc::new(RwLock::new(providers)), - })) - } - } - } - - pub fn persist_to_filesystem(&self, app_data_root: &AppDataRoot) -> AnyhowResult<()> { - match self.provider_priority.read() { - Err(err) => { - Err(anyhow::anyhow!("Failed to acquire read lock on provider priority: {}", err)) - } - Ok(providers) => { - providers.persist_to_filesystem(app_data_root)?; - Ok(()) - } - } - } -} - - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn test_default_priority() { - let priority = ProviderPriority::default(); - assert_eq!(priority.get_priority(), &[Provider::Artcraft, Provider::Sora, Provider::Fal]); - } - - #[test] - fn test_set_priority() -> AnyhowResult<()> { - let mut priority = ProviderPriority::default(); - priority.set_priority(&[Provider::Fal, Provider::Artcraft])?; - assert_eq!(priority.get_priority(), &[Provider::Fal, Provider::Artcraft]); - Ok(()) - } - - #[test] - fn test_set_priority_with_duplicates() { - let mut priority = ProviderPriority::default(); - let result = priority.set_priority(&[Provider::Artcraft, Provider::Artcraft]); - assert!(result.is_err()); - } -} diff --git a/crates/desktop/artcraft/src/core/state/task_database.rs b/crates/desktop/artcraft/src/core/state/task_database.rs deleted file mode 100644 index 4467785f0d..0000000000 --- a/crates/desktop/artcraft/src/core/state/task_database.rs +++ /dev/null @@ -1,20 +0,0 @@ -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use errors::AnyhowResult; -use sqlite_tasks::connection::TaskDbConnection; - -#[derive(Clone)] -pub struct TaskDatabase { - connection: TaskDbConnection, -} - -impl TaskDatabase { - pub async fn connect(root: &AppDataRoot) -> AnyhowResult { - let path = root.state_dir().get_tasks_sqlite_database_path(); - let connection = TaskDbConnection::connect_and_migrate(path).await?; - Ok(Self { connection}) - } - - pub fn get_connection(&self) -> &TaskDbConnection { - &self.connection - } -} \ No newline at end of file diff --git a/crates/desktop/artcraft/src/core/state/task_database_version.rs b/crates/desktop/artcraft/src/core/state/task_database_version.rs deleted file mode 100644 index d4a7d8c32b..0000000000 --- a/crates/desktop/artcraft/src/core/state/task_database_version.rs +++ /dev/null @@ -1,10 +0,0 @@ - - -/// Used to bump the task database schema version. -/// Migrations on customers' machines tend to fail on existing databases, -/// even if we instruct that the database file be deleted first. -/// It's easiest to just write to a new file and migrate from scratch. -/// We increment this whenever we make a change to the database schema. -/// This prevents deadlock on startup if the schema has changed from the -/// previous version. -pub const TASK_DATABASE_VERSION: u32 = 7; diff --git a/crates/desktop/artcraft/src/core/state/window/main_window_position.rs b/crates/desktop/artcraft/src/core/state/window/main_window_position.rs deleted file mode 100644 index e11b6d8ffb..0000000000 --- a/crates/desktop/artcraft/src/core/state/window/main_window_position.rs +++ /dev/null @@ -1,65 +0,0 @@ -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::core::windows::main_window::constants::MAIN_WINDOW_NAME; -use errors::AnyhowResult; -use serde_derive::{Deserialize, Serialize}; -use std::fs::OpenOptions; -use std::io::Write; -use tauri::{AppHandle, Manager, PhysicalPosition, Window}; - -#[derive(Serialize, Deserialize, Clone, Debug, Eq, PartialEq)] -pub struct MainWindowPosition { - pub x: i32, - pub y: i32, -} - -impl MainWindowPosition { - pub fn new(x: i32, y: i32) -> Self { - Self { x, y } - } - - pub fn from_main_window(app: &AppHandle) -> AnyhowResult { - let windows = app.windows(); - windows.get(MAIN_WINDOW_NAME) - .map(|window| Self::from_window(window)) - .unwrap_or_else(|| Err(anyhow::anyhow!("Main window not found"))) - } - - pub fn from_window(window: &Window) -> AnyhowResult { - let position = window.outer_position()?; - Ok(Self { - x: position.x, - y: position.y, - }) - } - - pub fn from_filesystem_configs(app_data_root: &AppDataRoot) -> AnyhowResult> { - let filename = app_data_root.get_window_position_config_file(); - if !filename.exists() { - return Ok(None); - } - let contents = std::fs::read_to_string(filename)?; - let pos : MainWindowPosition = serde_json::from_str(&contents)?; - Ok(Some(pos)) - } - - pub fn persist_to_filesystem(&self, app_data_root: &AppDataRoot) -> AnyhowResult<()> { - let filename = app_data_root.get_window_position_config_file(); - let json = serde_json::to_string(self)?; - let mut file = OpenOptions::new() - .create(true) - .write(true) - .truncate(true) - .open(filename)?; - file.write_all(json.as_bytes())?; - file.flush()?; - Ok(()) - } - - pub fn to_physical_position(&self) -> PhysicalPosition { - PhysicalPosition::new(self.x, self.y) - } - - pub fn matches_physical_position(&self, pos: &PhysicalPosition) -> bool { - self.x == pos.x && self.y == pos.y - } -} diff --git a/crates/desktop/artcraft/src/core/state/window/main_window_size.rs b/crates/desktop/artcraft/src/core/state/window/main_window_size.rs deleted file mode 100644 index 0735b19545..0000000000 --- a/crates/desktop/artcraft/src/core/state/window/main_window_size.rs +++ /dev/null @@ -1,82 +0,0 @@ -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::core::utils::window::get_window_size_heuristic::get_window_size_heuristic; -use crate::core::windows::main_window::constants::{MAIN_WINDOW_MIN_HEIGHT, MAIN_WINDOW_MIN_WIDTH, MAIN_WINDOW_NAME}; -use errors::AnyhowResult; -use serde_derive::{Deserialize, Serialize}; -use std::fs::OpenOptions; -use std::io::Write; -use tauri::{AppHandle, Manager, PhysicalSize, Window}; - - -#[derive(Serialize, Deserialize, Clone, Debug, Eq, PartialEq)] -pub struct MainWindowSize { - pub width: u32, - pub height: u32, -} - -impl MainWindowSize { - pub fn new(width: u32, height: u32) -> Self { - Self { width, height } - } - - pub fn from_main_window(app: &AppHandle) -> AnyhowResult { - let windows = app.windows(); - windows.get(MAIN_WINDOW_NAME) - .map(|window| Self::from_window(window)) - .unwrap_or_else(|| Err(anyhow::anyhow!("Main window not found"))) - } - - pub fn from_window(window: &Window) -> AnyhowResult { - let size = get_window_size_heuristic(window)?; - Ok(Self { - width: size.width, - height: size.height, - }) - } - - pub fn from_filesystem_configs(app_data_root: &AppDataRoot) -> AnyhowResult> { - let filename = app_data_root.get_window_size_config_file(); - if !filename.exists() { - return Ok(None); - } - let contents = std::fs::read_to_string(filename)?; - let size: MainWindowSize = serde_json::from_str(&contents)?; - Ok(Some(size)) - } - - pub fn persist_to_filesystem(&self, app_data_root: &AppDataRoot) -> AnyhowResult<()> { - let filename = app_data_root.get_window_size_config_file(); - let json = serde_json::to_string(self)?; - let mut file = OpenOptions::new() - .create(true) - .write(true) - .truncate(true) - .open(filename)?; - file.write_all(json.as_bytes())?; - file.flush()?; - Ok(()) - } - - /// Window size is not wide enough to persist or apply. - pub fn is_not_wide_enough(&self) -> bool { - self.width < MAIN_WINDOW_MIN_WIDTH - } - - /// Window size is not tall enough to persist or apply. - pub fn is_not_tall_enough(&self) -> bool { - self.height < MAIN_WINDOW_MIN_HEIGHT - } - - /// Window size is not big enough (tall or wide) to persist or apply. - pub fn is_not_big_enough(&self) -> bool { - self.is_not_wide_enough() || self.is_not_tall_enough() - } - - pub fn to_physical_size(&self) -> PhysicalSize { - PhysicalSize::new(self.width, self.height) - } - - pub fn matches_physical_size(&self, size: &PhysicalSize) -> bool { - self.width == size.width && self.height == size.height - } -} diff --git a/crates/desktop/artcraft/src/core/state/window/mod.rs b/crates/desktop/artcraft/src/core/state/window/mod.rs deleted file mode 100644 index 697e172a0a..0000000000 --- a/crates/desktop/artcraft/src/core/state/window/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod main_window_position; -pub mod main_window_size; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/core/threads/discord_presence_thread.rs b/crates/desktop/artcraft/src/core/threads/discord_presence_thread.rs deleted file mode 100644 index c11ff89e25..0000000000 --- a/crates/desktop/artcraft/src/core/threads/discord_presence_thread.rs +++ /dev/null @@ -1,63 +0,0 @@ -use anyhow::anyhow; -use discord_rich_presence::{DiscordIpc, DiscordIpcClient}; -use errors::AnyhowResult; -use log::{debug, info}; -use rand::random_range; - -/// Our Discord App ID. Not sure if this is a secret. -const DISCORD_APP_ID : &str = "1366596912593113138"; - -const DISCORD_ARTCRAFT_LOGO_SPIN : &str = "https://getartcraft.com/discord-status-icons/artcraft-a-spin-512x512.webp"; -const DISCORD_ARTCRAFT_LOGO_STATIC : &str = "https://getartcraft.com/discord-status-icons/artcraft-a-512x512.png"; -const DISCORD_KITSUNE_MASK_LOGO : &str = "https://getartcraft.com/discord-status-icons/kitsune-mask-512x512.png"; -const DISCORD_LINK_SPIN: &str = "https://getartcraft.com/discord-status-icons/link-spin-200x216.webp"; - -pub async fn discord_presence_thread() -> ! { - loop { - let client = DiscordIpcClient::new(DISCORD_APP_ID); - let _err = discord_main_loop(client).await; - tokio::time::sleep(std::time::Duration::from_millis(10_000)).await; - } -} - -async fn discord_main_loop(mut client: DiscordIpcClient) -> AnyhowResult<()> { - info!("(Re)-connecting Discord IPC client..."); - - client.connect() - .map_err(|err| anyhow!("Error connecting to Discord IPC: {:?}", err))?; - - loop { - debug!("Notifying discord presence API..."); - - let discord_logo_image = get_random_discord_icon(); - - let assets = discord_rich_presence::activity::Assets::new() - .large_image(discord_logo_image) - .large_text("https://GetArtCraft.com"); - //.small_image("https://storyteller.ai/android-chrome-192x192.png") - //.small_text("small text"); - - client.set_activity(discord_rich_presence::activity::Activity::new() - //.state("Anyone can make arts!") - .state("GetArtCraft.com") - .details("Crafting Arts with ArtCraft") - .activity_type(discord_rich_presence::activity::ActivityType::Playing) - .assets(assets)) - .map_err(|err| anyhow!("Error setting Discord activity: {:?}", err))?; - - tokio::time::sleep(std::time::Duration::from_millis(60_000)).await; - } -} - -fn get_random_discord_icon() -> &'static str { - let value = random_range(0..10u8); - if value < 6 { - DISCORD_ARTCRAFT_LOGO_SPIN - } else if value < 7 { - DISCORD_ARTCRAFT_LOGO_STATIC - } else if value < 8 { - DISCORD_KITSUNE_MASK_LOGO - } else { - DISCORD_LINK_SPIN - } -} diff --git a/crates/desktop/artcraft/src/core/threads/main_window_thread/main_window_thread.rs b/crates/desktop/artcraft/src/core/threads/main_window_thread/main_window_thread.rs deleted file mode 100644 index 720a8ed896..0000000000 --- a/crates/desktop/artcraft/src/core/threads/main_window_thread/main_window_thread.rs +++ /dev/null @@ -1,90 +0,0 @@ -use crate::core::state::app_startup_time::AppStartupTime; -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::core::state::window::main_window_position::MainWindowPosition; -use crate::core::state::window::main_window_size::MainWindowSize; -use crate::core::threads::main_window_thread::persist_storyteller_cookies_task::persist_storyteller_cookies_task; -use crate::core::threads::main_window_thread::persist_window_position_task::persist_window_position_task; -use crate::core::threads::main_window_thread::persist_window_resize_task::persist_window_resize_task; -use crate::core::windows::main_window::constants::MAIN_WINDOW_NAME; -use crate::services::storyteller::state::storyteller_credential_manager::StorytellerCredentialManager; -use errors::AnyhowResult; -use log::{error, info, warn}; -use memory_store::clone_slot::CloneSlot; -use tauri::{AppHandle, Manager, Window}; - -pub async fn main_window_thread( - app: AppHandle, - app_data_root: AppDataRoot, - storyteller_creds_manager: StorytellerCredentialManager, -) -> ! { - // TODO: Move these into some kind of dependency injection framework - let window_size_slot: CloneSlot = CloneSlot::empty(); - let window_pos_slot: CloneSlot = CloneSlot::empty(); - let app_startup_time = AppStartupTime::new(); - - // Emit debugging information to the logs (do not remove this!) - info!("git commit id: {:?}", build_metadata::git_commit_id() - .unwrap_or_else(|| "unknown")); - info!("git commit timestamp: {:?}", build_metadata::git_commit_timestamp() - .map(|t| t.to_string()) - .unwrap_or_else(|| "unknown".to_string())); - info!("build timestamp: {:?}", build_metadata::build_timestamp() - .to_string()); - - // debug_try_clear_all_webview_data(&app); - - loop { - for (window_name, window) in app.windows() { - if window_name == MAIN_WINDOW_NAME { - let result = handle_main_window( - &app, - &window, - &app_data_root, - &storyteller_creds_manager, - &window_size_slot, - &window_pos_slot, - &app_startup_time, - ).await; - if let Err(err) = result { - error!("Error handling main window: {:?}", err); - } - } - } - tokio::time::sleep(std::time::Duration::from_millis(1_000)).await; - } -} - -pub async fn handle_main_window( - app: &AppHandle, - window: &Window, - app_data_root: &AppDataRoot, - storyteller_creds_manager: &StorytellerCredentialManager, - window_size_slot: &CloneSlot, - window_pos_slot: &CloneSlot, - app_startup_time: &AppStartupTime, -) -> AnyhowResult<()> { - loop { - log_errors(persist_window_resize_task(window, app_data_root, window_size_slot).await); - log_errors(persist_window_position_task(window, app_data_root, window_pos_slot).await); - log_errors(persist_storyteller_cookies_task(app, storyteller_creds_manager, app_startup_time).await); - tokio::time::sleep(std::time::Duration::from_millis(1_000)).await; - } -} - -pub fn log_errors(result: AnyhowResult) { - if let Err(err) = result { - error!("Error persisting window size: {:?}", err); - } -} - -fn debug_try_clear_all_webview_data(app: &AppHandle) { - warn!("[!!!] THIS IS ONLY FOR DEBUGGING PURPOSES: Attempting to clear webview data..."); - - for (name, webview) in app.webviews() { - if let Err(err) = webview.clear_all_browsing_data() { - error!("Failed to clear cookies for '{}' window webview: {:?}", name, err); - } else { - warn!("Successfully cleared cookies for '{}' window webview", name); - } - } -} diff --git a/crates/desktop/artcraft/src/core/threads/main_window_thread/mod.rs b/crates/desktop/artcraft/src/core/threads/main_window_thread/mod.rs deleted file mode 100644 index db7084f698..0000000000 --- a/crates/desktop/artcraft/src/core/threads/main_window_thread/mod.rs +++ /dev/null @@ -1,4 +0,0 @@ -pub mod main_window_thread; -pub mod persist_storyteller_cookies_task; -pub mod persist_window_position_task; -pub mod persist_window_resize_task; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/core/threads/main_window_thread/persist_storyteller_cookies_task.rs b/crates/desktop/artcraft/src/core/threads/main_window_thread/persist_storyteller_cookies_task.rs deleted file mode 100644 index 1c26f73623..0000000000 --- a/crates/desktop/artcraft/src/core/threads/main_window_thread/persist_storyteller_cookies_task.rs +++ /dev/null @@ -1,108 +0,0 @@ -use crate::core::state::app_startup_time::AppStartupTime; -use crate::services::storyteller::state::storyteller_credential_manager::StorytellerCredentialManager; -use anyhow::anyhow; -use chrono::TimeDelta; -use errors::AnyhowResult; -use log::{error, info}; -use once_cell::sync::Lazy; -use reqwest::Url; -use artcraft_client::credentials::storyteller_avt_cookie::StorytellerAvtCookie; -use artcraft_client::credentials::storyteller_credential_set::StorytellerCredentialSet; -use artcraft_client::credentials::storyteller_session_cookie::StorytellerSessionCookie; -use tauri::{AppHandle, Manager}; -use tauri_plugin_http::reqwest_cookie_store::CookieStore; -use tauri_plugin_http::Http; - -const STORYTELLER_ROOT_COOKIE_URL_STR: &str = "https://api.storyteller.ai/"; - -static STORYTELLER_ROOT_COOKIE_URL: Lazy = Lazy::new(|| { - Url::parse(STORYTELLER_ROOT_COOKIE_URL_STR).expect("URL should parse") -}); - -const AVT_COOKIE_NAME : &str = "visitor"; -const SESSION_COOKIE_NAME : &str = "session"; - -/// There's some kind of race condition that we need to wait for before inspecting cookies. -const RACE_CONDITION_WAIT_TIME: TimeDelta = TimeDelta::milliseconds(5000); - -pub async fn persist_storyteller_cookies_task( - app: &AppHandle, - storyteller_credential_manager: &StorytellerCredentialManager, - app_startup_time: &AppStartupTime, -) -> AnyhowResult<()> { - - //if app_startup_time.time_delta_since() < RACE_CONDITION_WAIT_TIME { - // // NB: There's an issue when the "main window thread" inquires about the - // // webview cookies shortly after app startup. When it attempts to dump the - // // cookies within a few milliseconds of app launch, it deadlocks and the - // // app never launches correctly. The entire webview goes blank and the app - // // freezes. This hack seems to fix the problem. - // return Ok(()) - //} - - let maybe_http = app.try_state::(); - - let http = match maybe_http { - None => { - error!("No HTTP plugin found"); - return Err(anyhow!("No HTTP plugin found")); - } - Some(http) => http, - }; - - match http.cookies_jar.store.lock() { - Err(err) => { - error!("Failed to lock cookie jar: {:?}", err); - return Err(anyhow!("Failed to lock cookie jar")); - } - Ok(cookie_jar) => { - sync_tauri_credentials(&cookie_jar, storyteller_credential_manager)?; - } - } - - Ok(()) -} - -fn sync_tauri_credentials( - cookie_store: &CookieStore, - storyteller_credential_manager: &StorytellerCredentialManager, -) -> AnyhowResult<()> { - let current_http_plugin_credentials = get_credentials_from_cookie_store(cookie_store)?; - - let mut replace_credentials = true; - - let maybe_old_credentials = storyteller_credential_manager.get_credentials()?; - - if let Some(old_credentials) = maybe_old_credentials { - if old_credentials.equals(¤t_http_plugin_credentials) { - replace_credentials = false; - } - } - - if replace_credentials { - info!("Syncing ArtCraft credentials ..."); - storyteller_credential_manager.set_credentials(¤t_http_plugin_credentials)?; - // NB: tauri-plugin-http stores the credentials on disk, so we can defer to that for now. - //storyteller_credential_manager.persist_all_to_disk()?; - } - - Ok(()) -} - -pub fn get_credentials_from_cookie_store(cookie_jar: &CookieStore) -> AnyhowResult { - let mut avt_cookie = None; - let mut session_cookie = None; - - for cookie in cookie_jar.iter_unexpired() { - if let Some(avt) = StorytellerAvtCookie::maybe_from_cookie(&cookie) { - avt_cookie = Some(avt); - } else if let Some(session) = StorytellerSessionCookie::maybe_from_cookie(&cookie) { - session_cookie = Some(session); - } - } - - Ok(StorytellerCredentialSet::initialize( - avt_cookie, - session_cookie, - )) -} diff --git a/crates/desktop/artcraft/src/core/threads/main_window_thread/persist_window_position_task.rs b/crates/desktop/artcraft/src/core/threads/main_window_thread/persist_window_position_task.rs deleted file mode 100644 index b1ca129ac7..0000000000 --- a/crates/desktop/artcraft/src/core/threads/main_window_thread/persist_window_position_task.rs +++ /dev/null @@ -1,32 +0,0 @@ -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::core::state::window::main_window_position::MainWindowPosition; -use errors::AnyhowResult; -use log::info; -use memory_store::clone_slot::CloneSlot; -use tauri::Window; - -pub async fn persist_window_position_task( - window: &Window, - app_data_root: &AppDataRoot, - window_pos_slot: &CloneSlot, -) -> AnyhowResult<()> { - - let current_window_position = MainWindowPosition::from_window(window)?; - let current_physical_pos = window.outer_position()?; - - let mut save_size_to_disk = true; - - if let Ok(Some(old_size)) = window_pos_slot.get_clone() { - if old_size.matches_physical_position(¤t_physical_pos) { - save_size_to_disk = false; - } - } - - if save_size_to_disk { - info!("Saving window position configs to disk..."); - current_window_position.persist_to_filesystem(app_data_root)?; - window_pos_slot.set_clone(¤t_window_position)?; - } - - Ok(()) -} diff --git a/crates/desktop/artcraft/src/core/threads/main_window_thread/persist_window_resize_task.rs b/crates/desktop/artcraft/src/core/threads/main_window_thread/persist_window_resize_task.rs deleted file mode 100644 index 4ab91c5035..0000000000 --- a/crates/desktop/artcraft/src/core/threads/main_window_thread/persist_window_resize_task.rs +++ /dev/null @@ -1,37 +0,0 @@ -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::core::state::window::main_window_size::MainWindowSize; -use crate::core::utils::window::get_window_size_heuristic::get_window_size_heuristic; -use errors::AnyhowResult; -use log::info; -use memory_store::clone_slot::CloneSlot; -use tauri::Window; - -pub async fn persist_window_resize_task( - window: &Window, - app_data_root: &AppDataRoot, - window_size_slot: &CloneSlot, -) -> AnyhowResult<()> { - - let current_window_size = MainWindowSize::from_window(window)?; - let current_physical_size = get_window_size_heuristic(window)?; - - let mut save_size_to_disk = true; - - if let Ok(Some(old_size)) = window_size_slot.get_clone() { - if old_size.matches_physical_size(¤t_physical_size) { - save_size_to_disk = false; - } - } - - if current_window_size.is_not_big_enough() { - save_size_to_disk = false; - } - - if save_size_to_disk { - info!("Saving window size configs to disk..."); - current_window_size.persist_to_filesystem(app_data_root)?; - window_size_slot.set_clone(¤t_window_size)?; - } - - Ok(()) -} diff --git a/crates/desktop/artcraft/src/core/threads/mod.rs b/crates/desktop/artcraft/src/core/threads/mod.rs deleted file mode 100644 index 85518c0d82..0000000000 --- a/crates/desktop/artcraft/src/core/threads/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub mod discord_presence_thread; -pub mod main_window_thread; -pub mod third_party_task_polling_thread; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/core/threads/third_party_task_polling_thread/events/mod.rs b/crates/desktop/artcraft/src/core/threads/third_party_task_polling_thread/events/mod.rs deleted file mode 100644 index 911c8e7130..0000000000 --- a/crates/desktop/artcraft/src/core/threads/third_party_task_polling_thread/events/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod notify_frontend_of_completion; diff --git a/crates/desktop/artcraft/src/core/threads/third_party_task_polling_thread/events/notify_frontend_of_completion.rs b/crates/desktop/artcraft/src/core/threads/third_party_task_polling_thread/events/notify_frontend_of_completion.rs deleted file mode 100644 index 508a3b1549..0000000000 --- a/crates/desktop/artcraft/src/core/threads/third_party_task_polling_thread/events/notify_frontend_of_completion.rs +++ /dev/null @@ -1,349 +0,0 @@ -use crate::core::events::basic_sendable_event_trait::BasicSendableEvent; -use crate::core::events::generation_events::common::{GenerationAction, GenerationModel, GenerationServiceProvider}; -use crate::core::events::generation_events::generation_complete_event::GenerationCompleteEvent; -use crate::core::events::functional_events::canvas_background_removal_complete_event::CanvasBackgroundRemovalCompleteEvent; -use crate::core::events::functional_events::gaussian_generation_complete_event::{GaussianGenerationCompleteEvent, GeneratedGaussian}; -use crate::core::events::functional_events::image_edit_complete_event::{EditedImage, ImageEditCompleteEvent}; -use crate::core::events::functional_events::object_generation_complete_event::{GeneratedObject, ObjectGenerationCompleteEvent}; -use crate::core::events::functional_events::text_to_image_generation_complete_event::{GeneratedImage, TextToImageGenerationCompleteEvent}; -use crate::core::events::functional_events::video_generation_complete_event::{GeneratedVideo, VideoGenerationCompleteEvent}; -use artcraft_api_defs::utils::media_links_to_thumbnail_template::media_links_to_thumbnail_template; -use artcraft_client::endpoints::media_files::get_media_file::get_media_file; -use artcraft_client::endpoints::media_files::list_batch_generated_redux_media_files::list_batch_generated_redux_media_files; -use artcraft_client::credentials::storyteller_credential_set::StorytellerCredentialSet; -use artcraft_client::utils::api_host::ApiHost; -use enums::common::generation_provider::GenerationProvider; -use enums::tauri::tasks::task_media_file_class::TaskMediaFileClass; -use enums::tauri::tasks::task_model_type::TaskModelType; -use enums::tauri::tasks::task_type::TaskType; -use log::{error, info, warn}; -use sqlite_tasks::queries::task::Task; -use tauri::AppHandle; -use reqwest::Url; -use tokens::tokens::batch_generations::BatchGenerationToken; -use tokens::tokens::media_files::MediaFileToken; - -/// Data about a successfully completed third-party generation. -pub struct CompletionData { - /// The primary media file token (first uploaded file). - pub primary_media_file_token: MediaFileToken, - - /// The CDN URL for the primary media file, if looked up. - pub maybe_cdn_url: Option, - - /// A thumbnail URL template for the primary media file, if available. - pub maybe_thumbnail_url_template: Option, - - /// The batch token, if multiple files were generated. - pub maybe_batch_token: Option, - - /// The media class of the generated output. - pub media_class: TaskMediaFileClass, -} - -/// Notify the frontend that a third-party job has completed, sending the -/// appropriate typed event based on the task type. -/// -/// This is the cross-cutting equivalent of the Storyteller-specific -/// `maybe_handle_frontend_caller_notification` — it works for any provider. -pub async fn notify_frontend_of_completion( - app: &AppHandle, - api_host: &ApiHost, - maybe_creds: Option<&StorytellerCredentialSet>, - task: &Task, - completion: &CompletionData, -) { - // Fire the generic generation-complete event (for the task queue UI). - let generation_action = task_type_to_generation_action(task.task_type); - let generation_model = task.model_type.clone().and_then(task_model_type_to_generation_model); - let generation_service = provider_to_generation_service(task.provider); - - let complete_event = GenerationCompleteEvent { - action: Some(generation_action), - service: generation_service, - model: generation_model, - }; - complete_event.send_infallible(app); - - // Fire the typed frontend notification (for the specific page/component that initiated the job). - let result = match task.task_type { - // Audio pages consume the common completion event and refresh their feed. - TaskType::AudioGeneration => Ok(()), - TaskType::ImageGeneration => { - notify_image_generation(app, api_host, maybe_creds, task, completion).await - } - TaskType::ImageInpaintEdit => { - notify_image_edit(app, api_host, maybe_creds, task, completion).await - } - TaskType::VideoGeneration => { - notify_video_generation(app, task, completion) - } - TaskType::ObjectGeneration => { - notify_object_generation(app, task, completion) - } - TaskType::GaussianGeneration => { - notify_gaussian_generation(app, task, completion) - } - TaskType::BackgroundRemoval => { - notify_background_removal(app, task, completion) - } - }; - - if let Err(err) = result { - error!("[ThirdPartyEvents] Failed to send frontend notification for task {}: {:?}", task.id.as_str(), err); - } -} - -// ── Per-type handlers ── - -async fn notify_image_generation( - app: &AppHandle, - api_host: &ApiHost, - maybe_creds: Option<&StorytellerCredentialSet>, - task: &Task, - completion: &CompletionData, -) -> Result<(), Box> { - let generated_images = collect_generated_images( - api_host, - maybe_creds, - completion, - ).await; - - let event = TextToImageGenerationCompleteEvent { - generated_images, - maybe_frontend_subscriber_id: task.frontend_subscriber_id.clone(), - maybe_frontend_subscriber_payload: task.frontend_subscriber_payload.clone(), - }; - - event.send_infallible(app); - Ok(()) -} - -async fn notify_image_edit( - app: &AppHandle, - api_host: &ApiHost, - maybe_creds: Option<&StorytellerCredentialSet>, - task: &Task, - completion: &CompletionData, -) -> Result<(), Box> { - let images = collect_generated_images(api_host, maybe_creds, completion).await; - - let edited_images: Vec = images.into_iter() - .map(|img| EditedImage { - media_token: img.media_token, - cdn_url: img.cdn_url, - maybe_thumbnail_template: img.maybe_thumbnail_template, - }) - .collect(); - - let event = ImageEditCompleteEvent { - edited_images, - maybe_frontend_subscriber_id: task.frontend_subscriber_id.clone(), - maybe_frontend_subscriber_payload: task.frontend_subscriber_payload.clone(), - }; - - event.send_infallible(app); - Ok(()) -} - -fn notify_video_generation( - app: &AppHandle, - task: &Task, - completion: &CompletionData, -) -> Result<(), Box> { - let event = VideoGenerationCompleteEvent { - generated_video: Some(GeneratedVideo { - media_token: completion.primary_media_file_token.clone(), - cdn_url: completion.maybe_cdn_url.clone().unwrap_or_else(|| Url::parse("https://cdn.artcraft.ai/placeholder").unwrap()), - maybe_thumbnail_template: completion.maybe_thumbnail_url_template.clone(), - }), - maybe_frontend_subscriber_id: task.frontend_subscriber_id.clone(), - maybe_frontend_subscriber_payload: task.frontend_subscriber_payload.clone(), - }; - - event.send_infallible(app); - Ok(()) -} - -fn notify_object_generation( - app: &AppHandle, - task: &Task, - completion: &CompletionData, -) -> Result<(), Box> { - let event = ObjectGenerationCompleteEvent { - generated_object: Some(GeneratedObject { - media_token: completion.primary_media_file_token.clone(), - cdn_url: completion.maybe_cdn_url.clone().unwrap_or_else(|| Url::parse("https://cdn.artcraft.ai/placeholder").unwrap()), - maybe_thumbnail_template: completion.maybe_thumbnail_url_template.clone(), - }), - maybe_frontend_subscriber_id: task.frontend_subscriber_id.clone(), - maybe_frontend_subscriber_payload: task.frontend_subscriber_payload.clone(), - }; - - event.send_infallible(app); - Ok(()) -} - -fn notify_gaussian_generation( - app: &AppHandle, - task: &Task, - completion: &CompletionData, -) -> Result<(), Box> { - let event = GaussianGenerationCompleteEvent { - generated_gaussian: Some(GeneratedGaussian { - media_token: completion.primary_media_file_token.clone(), - cdn_url: completion.maybe_cdn_url.clone().unwrap_or_else(|| Url::parse("https://cdn.artcraft.ai/placeholder").unwrap()), - maybe_thumbnail_template: completion.maybe_thumbnail_url_template.clone(), - }), - maybe_frontend_subscriber_id: task.frontend_subscriber_id.clone(), - maybe_frontend_subscriber_payload: task.frontend_subscriber_payload.clone(), - }; - - event.send_infallible(app); - Ok(()) -} - -fn notify_background_removal( - app: &AppHandle, - task: &Task, - completion: &CompletionData, -) -> Result<(), Box> { - let event = CanvasBackgroundRemovalCompleteEvent { - media_token: completion.primary_media_file_token.clone(), - image_cdn_url: completion.maybe_cdn_url.clone().unwrap_or_else(|| Url::parse("https://cdn.artcraft.ai/placeholder").unwrap()), - maybe_frontend_subscriber_id: task.frontend_subscriber_id.clone(), - maybe_frontend_subscriber_payload: task.frontend_subscriber_payload.clone(), - }; - - event.send_infallible(app); - Ok(()) -} - -// ── Helpers ── - -/// Collect generated images. If there's a batch token, fetch all files in the batch. -/// Otherwise, return a single-element list with the primary file. -async fn collect_generated_images( - api_host: &ApiHost, - maybe_creds: Option<&StorytellerCredentialSet>, - completion: &CompletionData, -) -> Vec { - // If we have a batch token, try to fetch all files in the batch. - if let Some(batch_token) = &completion.maybe_batch_token { - match list_batch_generated_redux_media_files(api_host, maybe_creds, batch_token).await { - Ok(result) if !result.media_files.is_empty() => { - return result.media_files.into_iter() - .map(|file| GeneratedImage { - media_token: file.token, - cdn_url: file.media_links.cdn_url, - maybe_thumbnail_template: file.media_links.maybe_thumbnail_template, - }) - .collect(); - } - Ok(_) => { - warn!("[ThirdPartyEvents] Batch token {} returned no media files, falling back to primary", batch_token); - } - Err(err) => { - error!("[ThirdPartyEvents] Failed to list batch media files: {:?}, falling back to primary", err); - } - } - } - - // Fallback: single image from primary token. - vec![GeneratedImage { - media_token: completion.primary_media_file_token.clone(), - cdn_url: completion.maybe_cdn_url.clone().unwrap_or_else(|| Url::parse("https://cdn.artcraft.ai/placeholder").unwrap()), - maybe_thumbnail_template: completion.maybe_thumbnail_url_template.clone(), - }] -} - -fn task_type_to_generation_action(task_type: TaskType) -> GenerationAction { - match task_type { - TaskType::ImageGeneration => GenerationAction::GenerateImage, - TaskType::VideoGeneration => GenerationAction::GenerateVideo, - TaskType::AudioGeneration => GenerationAction::GenerateAudio, - TaskType::BackgroundRemoval => GenerationAction::RemoveBackground, - TaskType::ObjectGeneration => GenerationAction::ImageTo3d, - TaskType::GaussianGeneration => GenerationAction::GenerateGaussian, - TaskType::ImageInpaintEdit => GenerationAction::ImageInpaintEdit, - } -} - -fn provider_to_generation_service(provider: GenerationProvider) -> GenerationServiceProvider { - match provider { - GenerationProvider::Artcraft => GenerationServiceProvider::Artcraft, - GenerationProvider::Fal => GenerationServiceProvider::Fal, - GenerationProvider::Grok => GenerationServiceProvider::Grok, - GenerationProvider::Midjourney => GenerationServiceProvider::Midjourney, - GenerationProvider::Sora => GenerationServiceProvider::Sora, - GenerationProvider::WorldLabs => GenerationServiceProvider::WorldLabs, - GenerationProvider::Higgsfield => GenerationServiceProvider::Higgsfield, - GenerationProvider::Krea => GenerationServiceProvider::Krea, - GenerationProvider::Leonardo => GenerationServiceProvider::Leonardo, - GenerationProvider::Magnific => GenerationServiceProvider::Magnific, - GenerationProvider::Openart => GenerationServiceProvider::Openart, - GenerationProvider::Picsart => GenerationServiceProvider::Picsart, - GenerationProvider::Pixverse => GenerationServiceProvider::Pixverse, - GenerationProvider::Runway => GenerationServiceProvider::Runway, - } -} - -fn task_model_type_to_generation_model(model: TaskModelType) -> Option { - match model { - TaskModelType::Unknown(model) => Some(GenerationModel::Unknown(model)), - TaskModelType::Flux1Dev => Some(GenerationModel::Flux1Dev), - TaskModelType::Flux1Schnell => Some(GenerationModel::Flux1Schnell), - TaskModelType::FluxPro1 => Some(GenerationModel::FluxPro1), - TaskModelType::FluxPro11 => Some(GenerationModel::FluxPro11), - TaskModelType::FluxPro11Ultra => Some(GenerationModel::FluxPro11Ultra), - TaskModelType::FluxProKontextMax => Some(GenerationModel::FluxProKontextMax), - TaskModelType::FluxDevJuggernaut => Some(GenerationModel::FluxDevJuggernaut), - TaskModelType::Flux2LoraAngles => Some(GenerationModel::Flux2LoraAngles), - TaskModelType::GptImage1 => Some(GenerationModel::GptImage1), - TaskModelType::GptImage1p5 => Some(GenerationModel::GptImage1p5), - TaskModelType::GptImage2 => Some(GenerationModel::GptImage2), - TaskModelType::GptImage2p5Flare => Some(GenerationModel::GptImage2p5Flare), - TaskModelType::GptImage2p5Sunburst => Some(GenerationModel::GptImage2p5Sunburst), - TaskModelType::NanoBanana => Some(GenerationModel::NanoBanana), - TaskModelType::NanoBanana2 => Some(GenerationModel::NanoBanana2), - TaskModelType::NanoBananaPro => Some(GenerationModel::NanoBananaPro), - TaskModelType::Seedream4 => Some(GenerationModel::Seedream4), - TaskModelType::Seedream4p5 => Some(GenerationModel::Seedream4p5), - TaskModelType::Seedream5Lite => Some(GenerationModel::Seedream5Lite), - TaskModelType::QwenEdit2511Angles => Some(GenerationModel::QwenEdit2511Angles), - TaskModelType::GrokImage => Some(GenerationModel::GrokImage), - TaskModelType::Recraft3 => Some(GenerationModel::Recraft3), - TaskModelType::Midjourney7 => Some(GenerationModel::Midjourney7), - TaskModelType::Midjourney7Niji => Some(GenerationModel::Midjourney7Niji), - TaskModelType::Midjourney8 => Some(GenerationModel::Midjourney8), - TaskModelType::GrokVideo => Some(GenerationModel::GrokVideo), - TaskModelType::GrokImagineVideo1p5 => Some(GenerationModel::GrokImagineVideo1p5), - TaskModelType::Kling16Pro => Some(GenerationModel::Kling1_6), - TaskModelType::Kling21Pro => Some(GenerationModel::Kling21Pro), - TaskModelType::Kling21Master => Some(GenerationModel::Kling21Master), - TaskModelType::Kling2p5TurboPro => Some(GenerationModel::Kling2p5TurboPro), - TaskModelType::Kling2p6Pro => Some(GenerationModel::Kling2p6Pro), - TaskModelType::Kling3p0Standard => Some(GenerationModel::Kling3p0Standard), - TaskModelType::Kling3p0Pro => Some(GenerationModel::Kling3p0Pro), - TaskModelType::HappyHorse1p0 => Some(GenerationModel::HappyHorse1p0), - TaskModelType::Seedance10Lite => Some(GenerationModel::Seedance10Lite), - TaskModelType::Seedance1p5Pro => Some(GenerationModel::Seedance1p5Pro), - TaskModelType::Seedance2p0 => Some(GenerationModel::Seedance2p0), - TaskModelType::Seedance2p0Fast => Some(GenerationModel::Seedance2p0Fast), - TaskModelType::Sora2 => Some(GenerationModel::Sora2), - TaskModelType::Sora2Pro => Some(GenerationModel::Sora2Pro), - TaskModelType::Veo2 => Some(GenerationModel::Veo2), - TaskModelType::Veo3 => Some(GenerationModel::Veo3), - TaskModelType::Veo3Fast => Some(GenerationModel::Veo3Fast), - TaskModelType::Veo3p1 => Some(GenerationModel::Veo3p1), - TaskModelType::Veo3p1Fast => Some(GenerationModel::Veo3p1Fast), - TaskModelType::Hunyuan3d2_0 => Some(GenerationModel::Hunyuan3d2_0), - TaskModelType::Hunyuan3d2_1 => Some(GenerationModel::Hunyuan3d2_1), - TaskModelType::Hunyuan3d3 => Some(GenerationModel::Hunyuan3d3), - TaskModelType::Midjourney => Some(GenerationModel::Midjourney), - TaskModelType::Gemini25Flash => Some(GenerationModel::Gemini25Flash), - TaskModelType::WorldlabsMarble => Some(GenerationModel::WorldlabsMarble), - TaskModelType::WorldlabsMarble0p1Mini => Some(GenerationModel::WorldlabsMarble0p1Mini), - TaskModelType::WorldlabsMarble0p1Plus => Some(GenerationModel::WorldlabsMarble0p1Plus), - } -} diff --git a/crates/desktop/artcraft/src/core/threads/third_party_task_polling_thread/handlers/fal/handle_fal_complete.rs b/crates/desktop/artcraft/src/core/threads/third_party_task_polling_thread/handlers/fal/handle_fal_complete.rs deleted file mode 100644 index de3ddd51fe..0000000000 --- a/crates/desktop/artcraft/src/core/threads/third_party_task_polling_thread/handlers/fal/handle_fal_complete.rs +++ /dev/null @@ -1,344 +0,0 @@ -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; -use crate::core::threads::third_party_task_polling_thread::events::notify_frontend_of_completion::{ - notify_frontend_of_completion, CompletionData, -}; -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::core::state::data_dir::trait_data_subdir::DataSubdir; -use crate::core::state::task_database::TaskDatabase; -use crate::services::storyteller::state::storyteller_credential_manager::StorytellerCredentialManager; -use artcraft_api_defs::utils::media_links_to_thumbnail_template::media_links_to_thumbnail_template; -use artcraft_client::credentials::storyteller_credential_set::StorytellerCredentialSet; -use artcraft_client::error::api_error::ApiError; -use artcraft_client::error::storyteller_error::StorytellerError; -use artcraft_client::endpoints::media_files::get_media_file::get_media_file; -use artcraft_client::endpoints::media_files::legacy_upload_media_file_from_file::{ - legacy_upload_media_file_from_file, LegacyUploadMediaFileFromFileArgs, -}; -use artcraft_client::endpoints::media_files::upload_image_media_file_from_file::{ - upload_image_media_file_from_file, UploadImageFromFileArgs, -}; -use artcraft_client::endpoints::media_files::upload_video_media_file_from_file::{ - upload_video_media_file_from_file, UploadVideoFromFileArgs, -}; -use enums::common::generation_provider::GenerationProvider; -use enums::tauri::tasks::task_media_file_class::TaskMediaFileClass; -use enums::tauri::tasks::task_type::TaskType; -use fal_client::polling::poll_job_response::poll_job_response::PollJobResponse; -use fal_client::polling::poll_job_response::success_case_extractors::PollResponseExtractedContents; -use log::{error, info, warn}; -use sqlite_tasks::queries::task::Task; -use sqlite_tasks::queries::update_successful_task_status_with_metadata::{ - update_successful_task_status_with_metadata, UpdateSuccessfulTaskArgs, -}; -use std::fs::File; -use std::io::Write; -use std::path::PathBuf; -use std::time::Duration; -use tauri::AppHandle; -use tokens::tokens::batch_generations::BatchGenerationToken; -use tokens::tokens::media_files::MediaFileToken; -use tokens::tokens::prompts::PromptToken; -use uuid_utils::uuid::generate_random_uuid; - -pub async fn handle_fal_complete( - app_handle: &AppHandle, - app_env_configs: &AppEnvConfigs, - app_data_root: &AppDataRoot, - task_database: &TaskDatabase, - storyteller_creds_manager: &StorytellerCredentialManager, - task: &Task, - job_response: PollJobResponse, -) { - info!("[FalComplete] Handling completed task {}", task.id.as_str()); - - let result = handle_fal_complete_inner( - app_handle, - app_env_configs, - app_data_root, - task_database, - storyteller_creds_manager, - task, - job_response, - ).await; - - if let Err(err) = result { - error!("[FalComplete] Failed to handle task {}: {:?}", task.id.as_str(), err); - } -} - -async fn handle_fal_complete_inner( - app_handle: &AppHandle, - app_env_configs: &AppEnvConfigs, - app_data_root: &AppDataRoot, - task_database: &TaskDatabase, - storyteller_creds_manager: &StorytellerCredentialManager, - task: &Task, - job_response: PollJobResponse, -) -> Result<(), Box> { - let creds = storyteller_creds_manager.get_credentials()? - .ok_or("No Storyteller credentials available")?; - - let extracted = job_response.extracted_contents; - - // Determine what kind of media we got and collect download URLs. - let (urls, media_class) = collect_media_urls(task, &extracted)?; - - if urls.is_empty() { - warn!("[FalComplete] Task {} completed but no downloadable media found in response", task.id.as_str()); - //warn!("[FalComplete] Raw body: {}", &job_response.raw_body[..job_response.raw_body.len().min(500)]); - return Ok(()); - } - - // Use the prompt token from the task record (created at generation time). - let maybe_prompt_token = task.prompt_token.as_ref() - .map(|s| PromptToken::new_from_str(s)); - - if maybe_prompt_token.is_some() { - info!("[FalComplete] Using prompt token from task: {:?}", maybe_prompt_token); - } else { - warn!("[FalComplete] Task {} has no prompt token, uploading without prompt association", task.id.as_str()); - } - - let maybe_batch_token = if urls.len() > 1 { - let token = BatchGenerationToken::generate(); - info!("[FalComplete] Using batch token for {} files: {:?}", urls.len(), token); - Some(token) - } else { - None - }; - - let mut maybe_primary_media_file_token: Option = None; - - for (i, url) in urls.iter().enumerate() { - info!("[FalComplete] Downloading result {} from: {}", i, url); - - let download_path = download_file(url, app_data_root, i).await?; - - info!("[FalComplete] Uploading result {} to backend...", i); - - let media_token = upload_to_backend( - &creds, - app_env_configs, - &download_path, - maybe_prompt_token.as_ref(), - maybe_batch_token.as_ref(), - media_class, - ).await?; - - info!("[FalComplete] Uploaded as media file: {:?}", media_token); - - if maybe_primary_media_file_token.is_none() { - maybe_primary_media_file_token = Some(media_token); - } - } - - // Look up CDN/thumbnail URLs for the primary media file - let mut maybe_cdn_url: Option = None; - let mut maybe_cdn_url_str: Option = None; - let mut maybe_thumbnail_url_template = None; - - if let Some(media_file_token) = maybe_primary_media_file_token.as_ref() { - match get_media_file(&app_env_configs.storyteller_host, media_file_token).await { - Ok(response) => { - maybe_cdn_url = Some(response.media_file.media_links.cdn_url.clone()); - maybe_cdn_url_str = Some(response.media_file.media_links.cdn_url.to_string()); - maybe_thumbnail_url_template = media_links_to_thumbnail_template(&response.media_file.media_links) - .map(|s| s.to_string()); - } - Err(err) => { - error!("[FalComplete] Failed to look up media file after upload: {:?} (failing open)", err); - } - } - } - - // Mark the task as completed in the local database - let updated = update_successful_task_status_with_metadata(UpdateSuccessfulTaskArgs { - db: task_database.get_connection(), - task_id: &task.id, - maybe_batch_token: maybe_batch_token.as_ref(), - maybe_primary_media_file_token: maybe_primary_media_file_token.as_ref(), - maybe_primary_media_file_class: Some(media_class), - maybe_primary_media_file_cdn_url: maybe_cdn_url_str.as_deref(), - maybe_primary_media_file_thumbnail_url_template: maybe_thumbnail_url_template.as_deref(), - }).await?; - - if updated { - if let Some(primary_token) = maybe_primary_media_file_token { - let completion = CompletionData { - primary_media_file_token: primary_token, - maybe_cdn_url, - maybe_thumbnail_url_template, - maybe_batch_token, - media_class, - }; - - notify_frontend_of_completion( - app_handle, - &app_env_configs.storyteller_host, - Some(&creds), - task, - &completion, - ).await; - } - } - - info!("[FalComplete] Task {} fully handled", task.id.as_str()); - - Ok(()) -} - -// ── Helpers ── - -/// Collect downloadable media URLs from the extracted response contents. -fn collect_media_urls( - task: &Task, - extracted: &Option, -) -> Result<(Vec, TaskMediaFileClass), Box> { - let extracted = match extracted { - Some(e) => e, - None => return Ok((vec![], TaskMediaFileClass::Image)), - }; - - // Images (batch) - if let Some(images) = &extracted.images { - let urls: Vec = images.iter() - .filter_map(|img| img.url.clone()) - .collect(); - if !urls.is_empty() { - return Ok((urls, TaskMediaFileClass::Image)); - } - } - - // Single image (e.g. background removal) - if let Some(image) = &extracted.image { - if let Some(url) = &image.url { - return Ok((vec![url.clone()], TaskMediaFileClass::Image)); - } - } - - // Video - if let Some(video) = &extracted.video { - if let Some(url) = &video.url { - return Ok((vec![url.clone()], TaskMediaFileClass::Video)); - } - } - - // 3D model (GLB) - if let Some(glb) = &extracted.model_glb { - if let Some(url) = &glb.url { - return Ok((vec![url.clone()], TaskMediaFileClass::Dimensional)); - } - } - - Ok((vec![], TaskMediaFileClass::Image)) -} - -async fn download_file( - url: &str, - app_data_root: &AppDataRoot, - index: usize, -) -> Result> { - let response = reqwest::get(url).await?; - let bytes = response.bytes().await?; - - let extension = url_utils::download_extension::extract_download_extension_from_url::extract_download_extension_from_url_str(url) - .map(|ext| ext.as_extension_without_period()) - .unwrap_or("bin"); - - let tempdir = app_data_root.temp_dir().path(); - let filename = format!("fal_{}_{}.{}", generate_random_uuid(), index, extension); - let download_path = tempdir.join(filename); - - let mut file = File::create(&download_path)?; - file.write_all(&bytes)?; - - Ok(download_path) -} - -const MAX_UPLOAD_RETRIES: u32 = 5; -const INITIAL_RETRY_DELAY_SECS: u64 = 10; - -async fn upload_to_backend( - creds: &StorytellerCredentialSet, - app_env_configs: &AppEnvConfigs, - download_path: &PathBuf, - maybe_prompt_token: Option<&PromptToken>, - maybe_batch_token: Option<&BatchGenerationToken>, - media_class: TaskMediaFileClass, -) -> Result> { - let mut retry_delay_secs = INITIAL_RETRY_DELAY_SECS; - - for attempt in 0..MAX_UPLOAD_RETRIES { - let result = try_upload(creds, app_env_configs, download_path, maybe_prompt_token, maybe_batch_token, media_class).await; - - match result { - Ok(token) => return Ok(token), - Err(StorytellerError::Api(ApiError::TooManyRequests(_))) => { - if attempt + 1 < MAX_UPLOAD_RETRIES { - warn!( - "[FalComplete] Upload rate-limited (429), retrying in {}s (attempt {}/{})", - retry_delay_secs, - attempt + 1, - MAX_UPLOAD_RETRIES, - ); - tokio::time::sleep(Duration::from_secs(retry_delay_secs)).await; - retry_delay_secs = (retry_delay_secs * 2).min(60); - } else { - error!("[FalComplete] Upload rate-limited after {} attempts, giving up", MAX_UPLOAD_RETRIES); - return Err(Box::new(StorytellerError::Api(ApiError::TooManyRequests( - "Max retries exceeded".to_string(), - )))); - } - } - Err(err) => return Err(Box::new(err)), - } - } - - unreachable!() -} - -async fn try_upload( - creds: &StorytellerCredentialSet, - app_env_configs: &AppEnvConfigs, - download_path: &PathBuf, - maybe_prompt_token: Option<&PromptToken>, - maybe_batch_token: Option<&BatchGenerationToken>, - media_class: TaskMediaFileClass, -) -> Result { - let media_token = match media_class { - TaskMediaFileClass::Video => { - let result = upload_video_media_file_from_file(UploadVideoFromFileArgs { - api_host: &app_env_configs.storyteller_host, - maybe_creds: Some(creds), - path: download_path, - maybe_prompt_token, - maybe_generation_provider: Some(GenerationProvider::Fal), - }).await?; - result.media_file_token - } - TaskMediaFileClass::Dimensional => { - let result = legacy_upload_media_file_from_file(LegacyUploadMediaFileFromFileArgs { - api_host: &app_env_configs.storyteller_host, - maybe_creds: Some(creds), - path: download_path, - maybe_generation_provider: Some(GenerationProvider::Fal), - }).await?; - result.media_file_token - } - _ => { - let result = upload_image_media_file_from_file(UploadImageFromFileArgs { - api_host: &app_env_configs.storyteller_host, - maybe_creds: Some(creds), - path: download_path, - is_intermediate_system_file: false, - maybe_prompt_token, - maybe_batch_token, - maybe_generation_provider: Some(GenerationProvider::Fal), - }).await?; - result.media_file_token - } - }; - - Ok(media_token) -} - diff --git a/crates/desktop/artcraft/src/core/threads/third_party_task_polling_thread/handlers/fal/handle_fal_failure.rs b/crates/desktop/artcraft/src/core/threads/third_party_task_polling_thread/handlers/fal/handle_fal_failure.rs deleted file mode 100644 index 3398dac7bb..0000000000 --- a/crates/desktop/artcraft/src/core/threads/third_party_task_polling_thread/handlers/fal/handle_fal_failure.rs +++ /dev/null @@ -1,52 +0,0 @@ -use crate::core::events::basic_sendable_event_trait::BasicSendableEvent; -use crate::core::events::generation_events::common::{GenerationAction, GenerationServiceProvider}; -use crate::core::events::generation_events::generation_failed_event::GenerationFailedEvent; -use crate::core::state::task_database::TaskDatabase; -use enums::tauri::tasks::task_status::TaskStatus; -use enums::tauri::tasks::task_type::TaskType; -use log::{error, info}; -use sqlite_tasks::queries::task::Task; -use sqlite_tasks::queries::update_task_status::{update_task_status, UpdateTaskArgs}; -use tauri::AppHandle; - -pub async fn handle_fal_failure( - app_handle: &AppHandle, - task_database: &TaskDatabase, - task: &Task, - reason: &str, -) { - info!("[FalPolling] Marking task {} as failed: {}", task.id.as_str(), reason); - - let update_result = update_task_status(UpdateTaskArgs { - db: task_database.get_connection(), - task_id: &task.id, - status: TaskStatus::CompleteFailure, - }).await; - - if let Err(err) = update_result { - error!("[FalPolling] Failed to update task status for {}: {:?}", task.id.as_str(), err); - } - - let action = task_type_to_generation_action(task.task_type); - - let event = GenerationFailedEvent { - action, - service: GenerationServiceProvider::Fal, - model: None, - reason: Some(reason.to_string()), - }; - - event.send_infallible(app_handle); -} - -fn task_type_to_generation_action(task_type: TaskType) -> GenerationAction { - match task_type { - TaskType::ImageGeneration => GenerationAction::GenerateImage, - TaskType::VideoGeneration => GenerationAction::GenerateVideo, - TaskType::AudioGeneration => GenerationAction::GenerateAudio, - TaskType::BackgroundRemoval => GenerationAction::RemoveBackground, - TaskType::ObjectGeneration => GenerationAction::ImageTo3d, - TaskType::GaussianGeneration => GenerationAction::GenerateGaussian, - TaskType::ImageInpaintEdit => GenerationAction::ImageInpaintEdit, - } -} diff --git a/crates/desktop/artcraft/src/core/threads/third_party_task_polling_thread/handlers/fal/mod.rs b/crates/desktop/artcraft/src/core/threads/third_party_task_polling_thread/handlers/fal/mod.rs deleted file mode 100644 index 95e4589169..0000000000 --- a/crates/desktop/artcraft/src/core/threads/third_party_task_polling_thread/handlers/fal/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub mod handle_fal_complete; -pub mod handle_fal_failure; -pub mod poll_fal_tasks; diff --git a/crates/desktop/artcraft/src/core/threads/third_party_task_polling_thread/handlers/fal/poll_fal_tasks.rs b/crates/desktop/artcraft/src/core/threads/third_party_task_polling_thread/handlers/fal/poll_fal_tasks.rs deleted file mode 100644 index 81f9f585ac..0000000000 --- a/crates/desktop/artcraft/src/core/threads/third_party_task_polling_thread/handlers/fal/poll_fal_tasks.rs +++ /dev/null @@ -1,183 +0,0 @@ -use crate::core::providers::credentials::provider_credential_loading_cache::ProviderCredentialLoadingCache; -use crate::core::providers::credentials::payload::provider_credential_payload::ProviderCredentialPayload; -use crate::core::providers::credentials::provider_credential_key::ProviderCredentialKey; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::core::state::task_database::TaskDatabase; -use crate::core::threads::third_party_task_polling_thread::handlers::fal::handle_fal_complete::handle_fal_complete; -use crate::core::threads::third_party_task_polling_thread::handlers::fal::handle_fal_failure::handle_fal_failure; -use crate::services::storyteller::state::storyteller_credential_manager::StorytellerCredentialManager; -use enums::tauri::tasks::task_status::TaskStatus; -use fal_client::creds::fal_api_key::FalApiKey; -use fal_client::polling::poll_job_response::poll_job_response::{poll_job_response, PollJobResponseArgs}; -use fal_client::polling::poll_job_status::poll_job_status::{poll_job_status, FalJobStatus, PollJobStatusArgs}; -use log::{error, info, warn}; -use sqlite_tasks::queries::task::Task; -use sqlite_tasks::queries::update_task_status::{update_task_status, UpdateTaskArgs}; -use tauri::AppHandle; - -pub async fn poll_fal_tasks( - app_handle: &AppHandle, - app_env_configs: &AppEnvConfigs, - app_data_root: &AppDataRoot, - task_database: &TaskDatabase, - storyteller_creds_manager: &StorytellerCredentialManager, - credential_cache: &ProviderCredentialLoadingCache, - fal_tasks: &[&Task], -) { - let api_key = match load_fal_api_key(credential_cache) { - Some(key) => key, - None => { - warn!("[FalPolling] No FAL API key configured, skipping poll"); - return; - } - }; - - for task in fal_tasks { - let result = poll_single_fal_task( - app_handle, - app_env_configs, - app_data_root, - task_database, - storyteller_creds_manager, - &api_key, - task, - ).await; - - if let Err(err) = result { - error!( - "[FalPolling] Error processing task {}: {:?}", - task.id.as_str(), - err, - ); - } - } -} - -async fn poll_single_fal_task( - app_handle: &AppHandle, - app_env_configs: &AppEnvConfigs, - app_data_root: &AppDataRoot, - task_database: &TaskDatabase, - storyteller_creds_manager: &StorytellerCredentialManager, - api_key: &FalApiKey, - task: &Task, -) -> Result<(), Box> { - let status_url = match &task.queue_status_url { - Some(url) => url.as_str(), - None => { - warn!("[FalPolling] Task {} has no queue_status_url, marking as failed", task.id.as_str()); - handle_fal_failure( - app_handle, - task_database, - task, - "No queue status URL to check", - ).await; - return Ok(()); - } - }; - - // Step 1: Check job status - info!("[FalPolling] Checking status for task {}: {}", task.id.as_str(), status_url); - - let status_response = poll_job_status(PollJobStatusArgs { - status_url, - api_key, - }).await?; - - match status_response.status { - FalJobStatus::InQueue | FalJobStatus::InProgress => { - info!( - "[FalPolling] Task {} still {:?} (queue_position={:?})", - task.id.as_str(), - status_response.status, - status_response.maybe_queue_position, - ); - return Ok(()); - } - FalJobStatus::Unknown(ref status) => { - warn!("[FalPolling] Task {} has unknown status: {}", task.id.as_str(), status); - return Ok(()); - } - FalJobStatus::Completed => { - info!("[FalPolling] Task {} completed, fetching results...", task.id.as_str()); - } - } - - // Step 2: Fetch the response - let response_url = pick_response_url(task, &status_response.response_url); - - let response_url = match response_url { - Some(url) => url, - None => { - warn!("[FalPolling] Task {} completed but has no response URL, marking as failed", task.id.as_str()); - handle_fal_failure( - app_handle, - task_database, - task, - "Job completed but no response URL available", - ).await; - return Ok(()); - } - }; - - let job_response = match poll_job_response(PollJobResponseArgs { - response_url: &response_url, - api_key, - }).await { - Ok(response) => response, - Err(err) => { - error!( - "[FalPolling] Failed to fetch response for task {}: {}. Skipping for now.", - task.id.as_str(), - err, - ); - return Ok(()); - } - }; - - // Step 3: Handle completed job - handle_fal_complete( - app_handle, - app_env_configs, - app_data_root, - task_database, - storyteller_creds_manager, - task, - job_response, - ).await; - - Ok(()) -} - -// ── Helpers ── - -fn load_fal_api_key(credential_cache: &ProviderCredentialLoadingCache) -> Option { - match credential_cache.get_credentials(ProviderCredentialKey::FalApiKey) { - Ok(Some(ProviderCredentialPayload::ApiKey(data))) => { - Some(FalApiKey::from_str(data.as_str())) - } - _ => None, - } -} - -/// Use the task's stored response URL first; fall back to the one from the status poll. -/// Log if they differ. -fn pick_response_url(task: &Task, polled_response_url: &Option) -> Option { - match (&task.queue_response_url, polled_response_url) { - (Some(db_url), Some(polled_url)) => { - if db_url != polled_url { - warn!( - "[FalPolling] Task {} response URLs differ: db={}, polled={}. Using db URL.", - task.id.as_str(), - db_url, - polled_url, - ); - } - Some(db_url.clone()) - } - (Some(db_url), None) => Some(db_url.clone()), - (None, Some(polled_url)) => Some(polled_url.clone()), - (None, None) => None, - } -} diff --git a/crates/desktop/artcraft/src/core/threads/third_party_task_polling_thread/handlers/mod.rs b/crates/desktop/artcraft/src/core/threads/third_party_task_polling_thread/handlers/mod.rs deleted file mode 100644 index e02f03de99..0000000000 --- a/crates/desktop/artcraft/src/core/threads/third_party_task_polling_thread/handlers/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod fal; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/core/threads/third_party_task_polling_thread/mod.rs b/crates/desktop/artcraft/src/core/threads/third_party_task_polling_thread/mod.rs deleted file mode 100644 index 3c01673afd..0000000000 --- a/crates/desktop/artcraft/src/core/threads/third_party_task_polling_thread/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub mod events; -pub mod handlers; -pub mod third_party_task_polling_thread; diff --git a/crates/desktop/artcraft/src/core/threads/third_party_task_polling_thread/third_party_task_polling_thread.rs b/crates/desktop/artcraft/src/core/threads/third_party_task_polling_thread/third_party_task_polling_thread.rs deleted file mode 100644 index 552633c4cd..0000000000 --- a/crates/desktop/artcraft/src/core/threads/third_party_task_polling_thread/third_party_task_polling_thread.rs +++ /dev/null @@ -1,138 +0,0 @@ -use crate::core::providers::credentials::provider_credential_loading_cache::ProviderCredentialLoadingCache; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::core::state::task_database::TaskDatabase; -use crate::core::threads::third_party_task_polling_thread::handlers::fal::poll_fal_tasks::poll_fal_tasks; -use crate::core::utils::task_database_pending_statuses::TASK_DATABASE_PENDING_STATUSES; -use crate::services::storyteller::state::storyteller_credential_manager::StorytellerCredentialManager; -use enums::common::generation_provider::GenerationProvider; -use log::{error, info, warn}; -use sqlite_tasks::queries::list_non_artcraft_pending_tasks::{ - list_non_artcraft_pending_tasks, ListNonArtcraftPendingTasksArgs, -}; -use sqlite_tasks::queries::task::Task; -use std::time::Duration; -use tauri::AppHandle; - -const SLEEP_NO_THIRD_PARTY_JOBS_SEEN: Duration = Duration::from_secs(10); -const SLEEP_THIRD_PARTY_JOBS_SEEN: Duration = Duration::from_secs(2); -const SLEEP_BETWEEN_FAL_POLLS: Duration = Duration::from_secs(1); -const SLEEP_ON_ERROR: Duration = Duration::from_secs(30); - -pub async fn third_party_task_polling_thread( - app_handle: AppHandle, - app_env_configs: AppEnvConfigs, - app_data_root: AppDataRoot, - task_database: TaskDatabase, - storyteller_creds_manager: StorytellerCredentialManager, - credential_cache: ProviderCredentialLoadingCache, -) -> ! { - let mut has_ever_seen_third_party_jobs = false; - - loop { - let result = poll_iteration( - &app_handle, - &app_env_configs, - &app_data_root, - &task_database, - &storyteller_creds_manager, - &credential_cache, - &mut has_ever_seen_third_party_jobs, - ).await; - - if let Err(err) = result { - error!("[ThirdPartyPolling] Error in polling loop: {:?}", err); - tokio::time::sleep(SLEEP_ON_ERROR).await; - } - } -} - -async fn poll_iteration( - app_handle: &AppHandle, - app_env_configs: &AppEnvConfigs, - app_data_root: &AppDataRoot, - task_database: &TaskDatabase, - storyteller_creds_manager: &StorytellerCredentialManager, - credential_cache: &ProviderCredentialLoadingCache, - has_ever_seen_third_party_jobs: &mut bool, -) -> Result<(), PollError> { - let task_list = list_non_artcraft_pending_tasks(ListNonArtcraftPendingTasksArgs { - db: task_database.get_connection(), - task_statuses: &TASK_DATABASE_PENDING_STATUSES, - }).await?; - - let tasks = task_list.tasks; - - if tasks.is_empty() { - let sleep_duration = if *has_ever_seen_third_party_jobs { - SLEEP_THIRD_PARTY_JOBS_SEEN - } else { - SLEEP_NO_THIRD_PARTY_JOBS_SEEN - }; - tokio::time::sleep(sleep_duration).await; - return Ok(()); - } - - *has_ever_seen_third_party_jobs = true; - - let fal_tasks: Vec<&Task> = tasks.iter() - .filter(|t| t.provider == GenerationProvider::Fal) - .collect(); - - let non_fal_tasks: Vec<&Task> = tasks.iter() - .filter(|t| t.provider != GenerationProvider::Fal) - .collect(); - - if !non_fal_tasks.is_empty() { - for task in &non_fal_tasks { - warn!( - "[ThirdPartyPolling] Skipping non-FAL task: id={}, provider={:?}, type={:?}", - task.id.as_str(), - task.provider, - task.task_type, - ); - } - } - - if fal_tasks.is_empty() { - tokio::time::sleep(SLEEP_THIRD_PARTY_JOBS_SEEN).await; - return Ok(()); - } - - info!("[ThirdPartyPolling] {} FAL job(s) ready to check", fal_tasks.len()); - - poll_fal_tasks( - app_handle, - app_env_configs, - app_data_root, - task_database, - storyteller_creds_manager, - credential_cache, - &fal_tasks, - ).await; - - tokio::time::sleep(SLEEP_BETWEEN_FAL_POLLS).await; - - Ok(()) -} - -// ── Error ── - -#[derive(Debug)] -enum PollError { - SqliteTasksError(sqlite_tasks::error::SqliteTasksError), -} - -impl From for PollError { - fn from(err: sqlite_tasks::error::SqliteTasksError) -> Self { - Self::SqliteTasksError(err) - } -} - -impl std::fmt::Display for PollError { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - Self::SqliteTasksError(err) => write!(f, "SQLite error: {:?}", err), - } - } -} diff --git a/crates/desktop/artcraft/src/core/utils/clear_all_webview_cookies.rs b/crates/desktop/artcraft/src/core/utils/clear_all_webview_cookies.rs deleted file mode 100644 index fb39071dbf..0000000000 --- a/crates/desktop/artcraft/src/core/utils/clear_all_webview_cookies.rs +++ /dev/null @@ -1,7 +0,0 @@ -use errors::AnyhowResult; -use tauri::Webview; - -pub fn clear_all_webview_cookies(webview: &Webview) -> AnyhowResult<()> { - webview.clear_all_browsing_data()?; - Ok(()) -} diff --git a/crates/desktop/artcraft/src/core/utils/download_media_file_to_temp_dir.rs b/crates/desktop/artcraft/src/core/utils/download_media_file_to_temp_dir.rs deleted file mode 100644 index c064f74c35..0000000000 --- a/crates/desktop/artcraft/src/core/utils/download_media_file_to_temp_dir.rs +++ /dev/null @@ -1,31 +0,0 @@ -use crate::core::artcraft_error::ArtcraftError; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::core::utils::get_url_file_extension::get_url_file_extension; -use crate::core::utils::simple_http_download_to_tempfile::simple_http_download_to_tempfile; -use artcraft_client::endpoints::media_files::get_media_file::get_media_file; -use tempfile::NamedTempFile; -use tokens::tokens::media_files::MediaFileToken; -// TODO: Better more concrete error handling - -pub async fn download_media_file_to_temp_dir(app_env_configs: &AppEnvConfigs, app_data_root: &AppDataRoot, token: &MediaFileToken) -> Result { - let response = get_media_file( - &app_env_configs.storyteller_host, - token - ).await?; - - let media_file_url = &response.media_file.media_links.cdn_url; - - let extension_with_dot = get_url_file_extension(media_file_url) - .map(|ext| format!(".{}", ext)) - .unwrap_or_else(|| ".png".to_string()); // TODO: Better default extension passed by caller as heuristic. - - //let filename = format!("{}{}", response.media_file.token.as_str(), extension_with_dot); - //let filename = app_data_root.downloads_dir().path().join(&filename); - - let mut file = app_data_root.temp_dir().new_named_temp_file_with_extension(&extension_with_dot)?; - - simple_http_download_to_tempfile(&media_file_url, &mut file).await?; - - Ok(file) // NB: Must return TempFile to not drop / delete it -} diff --git a/crates/desktop/artcraft/src/core/utils/download_url_to_temp_dir.rs b/crates/desktop/artcraft/src/core/utils/download_url_to_temp_dir.rs deleted file mode 100644 index 60122a08d5..0000000000 --- a/crates/desktop/artcraft/src/core/utils/download_url_to_temp_dir.rs +++ /dev/null @@ -1,20 +0,0 @@ -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use errors::AnyhowResult; -use std::io::Write; -use tempfile::NamedTempFile; -use url::Url; - -pub async fn download_url_to_temp_dir(url: &str, app_data_root: &AppDataRoot) -> AnyhowResult { - let url = Url::parse(&url)?; - - let response = reqwest::get(url.clone()).await?; - let response_bytes = response.bytes().await?; - - let ext = url.path().split(".").last().unwrap_or("png"); - - let mut temp_file = app_data_root.temp_dir().new_named_temp_file_with_extension(ext)?; - - temp_file.write_all(&response_bytes)?; - - Ok(temp_file) -} diff --git a/crates/desktop/artcraft/src/core/utils/download_url_to_user_download_dir.rs b/crates/desktop/artcraft/src/core/utils/download_url_to_user_download_dir.rs deleted file mode 100644 index 7196ef45ae..0000000000 --- a/crates/desktop/artcraft/src/core/utils/download_url_to_user_download_dir.rs +++ /dev/null @@ -1,127 +0,0 @@ -use crate::core::artcraft_error::ArtcraftError; -use crate::core::state::app_preferences::app_preferences::AppPreferences; -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use anyhow::anyhow; -use errors::AnyhowResult; -use log::{error, info}; -use std::fs::OpenOptions; -use std::io::Write; -use std::path::PathBuf; -use url::Url; - -pub async fn download_url_to_user_download_dir( - url: &Url, - app_data_root: &AppDataRoot, - app_prefs: &AppPreferences, -) -> Result { - - let url_file_name = { - let path_segments = url.path_segments() - .ok_or_else(|| ArtcraftError::AnyhowError(anyhow!("URL does not have path segments (1): {:?}", url)))?; - - let mut url_file_name = path_segments.last() - .ok_or_else(|| ArtcraftError::AnyhowError(anyhow!("URL does not have path segments (2): {:?}", url)))? - .trim() - .to_string(); - - if !url_file_name.to_lowercase().starts_with("artcraft") { - url_file_name = format!("artcraft_{}", url_file_name); - } - - url_file_name - }; - - check_url_file_name_for_downloadability(&url_file_name)?; - - let download_directory = app_prefs - .preferred_download_directory - .download_directory(app_data_root); - - info!("Pushing path `{}` onto downloaded directory `{:?}`", url_file_name, download_directory); - - let download_filename = { - let mut download_filename = download_directory.clone(); - download_filename.push(&url_file_name); - download_filename - }; - - info!("Download filename: `{:?}`", download_filename); - - if download_filename == download_directory { - return Err(ArtcraftError::AnyhowError(anyhow!("Download filename resolved to directory: {:?}", download_filename)))?; - } - - if download_filename.exists() { - if download_filename.is_dir() { - return Err(ArtcraftError::AnyhowError(anyhow!("Download path exists and resolved to directory: {:?}", download_filename))); - } else { - return Err(ArtcraftError::CannotDownloadFilePathAlreadyExists { path: download_filename }.into()); - } - } - - info!("Downloading bytes from url: {:?}", url); - - let response = reqwest::get(url.clone()).await?; - let response_bytes = response.bytes().await?; - - info!("Writing file: {:?}", download_filename); - - let mut file = OpenOptions::new() - .create(true) - .write(true) - .truncate(true) - .open(&download_filename)?; - - file.write_all(&response_bytes)?; - - Ok(download_filename) -} - -// TODO: This likely needs more protections. -fn check_url_file_name_for_downloadability(filename: &str) -> Result<(), ArtcraftError> { - if filename.trim().is_empty() { - error!("Download filename is empty!"); - return Err(ArtcraftError::BadDownloadFilename { path: "".into() }.into()); - } - - if !filename.is_ascii() { - error!("Download filename is not completely ASCII: {:?}", filename); - return Err(ArtcraftError::BadDownloadFilename { path: filename.into() }.into()); - } - - if filename.contains("/") - || filename.contains("..") - || filename.contains("\\") - { - error!("Cannot download filename that has relative path components: {:?}", filename); - return Err(ArtcraftError::BadDownloadFilename { path: filename.into() }.into()); - } - - if filename.contains("'") - || filename.contains("\"") - || filename.contains("%") - || filename.contains("<") - || filename.contains(">") - || filename.contains("|") - { - error!("Download filename has dangerous path components: {:?}", filename); - return Err(ArtcraftError::BadDownloadFilename { path: filename.into() }.into()); - } - - if filename.ends_with(".apk") - || filename.ends_with(".app") - || filename.ends_with(".bat") - || filename.ends_with(".cmd") - || filename.ends_with(".com") - || filename.ends_with(".ps1") - || filename.ends_with(".sh") - || filename.ends_with(".so") - || filename.ends_with("dll") // Don't even risk the '.' - || filename.ends_with("exe") // Don't even risk the '.' - { - error!("Cannot download filename that resembles executable: {:?}", filename); - return Err(ArtcraftError::BadDownloadFilename { path: filename.into() }.into()); - } - - Ok(()) -} diff --git a/crates/desktop/artcraft/src/core/utils/enum_conversion/generation_provider.rs b/crates/desktop/artcraft/src/core/utils/enum_conversion/generation_provider.rs deleted file mode 100644 index 7da9a460e9..0000000000 --- a/crates/desktop/artcraft/src/core/utils/enum_conversion/generation_provider.rs +++ /dev/null @@ -1,22 +0,0 @@ -use crate::core::events::generation_events::common::GenerationServiceProvider; -use enums::common::generation_provider::GenerationProvider; - -// TODO(bt,2025-07-15): Get rid of GenerationServiceProvider -pub fn to_generation_service_provider(provider: GenerationProvider) -> GenerationServiceProvider { - match provider { - GenerationProvider::Artcraft => GenerationServiceProvider::Artcraft, - GenerationProvider::Fal => GenerationServiceProvider::Fal, - GenerationProvider::Grok => GenerationServiceProvider::Grok, - GenerationProvider::Midjourney => GenerationServiceProvider::Midjourney, - GenerationProvider::Sora => GenerationServiceProvider::Sora, - GenerationProvider::WorldLabs => GenerationServiceProvider::WorldLabs, - GenerationProvider::Higgsfield => GenerationServiceProvider::Higgsfield, - GenerationProvider::Krea => GenerationServiceProvider::Krea, - GenerationProvider::Leonardo => GenerationServiceProvider::Leonardo, - GenerationProvider::Magnific => GenerationServiceProvider::Magnific, - GenerationProvider::Openart => GenerationServiceProvider::Openart, - GenerationProvider::Picsart => GenerationServiceProvider::Picsart, - GenerationProvider::Pixverse => GenerationServiceProvider::Pixverse, - GenerationProvider::Runway => GenerationServiceProvider::Runway, - } -} diff --git a/crates/desktop/artcraft/src/core/utils/enum_conversion/mod.rs b/crates/desktop/artcraft/src/core/utils/enum_conversion/mod.rs deleted file mode 100644 index 67b4f3707f..0000000000 --- a/crates/desktop/artcraft/src/core/utils/enum_conversion/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod generation_provider; -pub mod task_type; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/core/utils/enum_conversion/task_type.rs b/crates/desktop/artcraft/src/core/utils/enum_conversion/task_type.rs deleted file mode 100644 index 54f73cbd8e..0000000000 --- a/crates/desktop/artcraft/src/core/utils/enum_conversion/task_type.rs +++ /dev/null @@ -1,14 +0,0 @@ -use crate::core::events::generation_events::common::GenerationAction; -use enums::tauri::tasks::task_type::TaskType; - -pub fn to_generation_action(task_type: TaskType) -> GenerationAction { - match task_type { - TaskType::ImageGeneration => GenerationAction::GenerateImage, - TaskType::VideoGeneration => GenerationAction::GenerateVideo, - TaskType::AudioGeneration => GenerationAction::GenerateAudio, - TaskType::BackgroundRemoval => GenerationAction::RemoveBackground, - TaskType::ObjectGeneration => GenerationAction::ImageTo3d, - TaskType::GaussianGeneration => GenerationAction::GenerateGaussian, - TaskType::ImageInpaintEdit => GenerationAction::ImageInpaintEdit, - } -} diff --git a/crates/desktop/artcraft/src/core/utils/get_url_file_extension.rs b/crates/desktop/artcraft/src/core/utils/get_url_file_extension.rs deleted file mode 100644 index 9acf0cfae2..0000000000 --- a/crates/desktop/artcraft/src/core/utils/get_url_file_extension.rs +++ /dev/null @@ -1,35 +0,0 @@ -use reqwest::Url; -use std::path::Path; - -pub fn get_url_file_extension(url: &Url) -> Option<&str> { - Path::new(url.path()) - .extension() - .filter(|ext| !ext.is_empty()) - .and_then(|ext| ext.to_str()) -} - -#[cfg(test)] -mod tests { - use reqwest::Url; - - #[test] - fn extension_exists() { - let url = Url::parse("https://example.com/image.png").unwrap(); - let extension = super::get_url_file_extension(&url); - assert_eq!(extension, Some("png")); - } - - #[test] - fn extension_does_not_exist() { - let url = Url::parse("https://example.com/foo").unwrap(); - let extension = super::get_url_file_extension(&url); - assert_eq!(extension, None); - } - - #[test] - fn period_not_in_path() { - let url = Url::parse("https://example.com/invalid.period/foo").unwrap(); - let extension = super::get_url_file_extension(&url); - assert_eq!(extension, None); - } -} \ No newline at end of file diff --git a/crates/desktop/artcraft/src/core/utils/image/decode_base64_image.rs b/crates/desktop/artcraft/src/core/utils/image/decode_base64_image.rs deleted file mode 100644 index d8ebb2b148..0000000000 --- a/crates/desktop/artcraft/src/core/utils/image/decode_base64_image.rs +++ /dev/null @@ -1,14 +0,0 @@ -use base64::prelude::BASE64_STANDARD; -use base64::Engine; -use image::{DynamicImage, ImageReader}; -use std::io::Cursor; - -pub fn decode_base64_image(base64_image: &str) -> anyhow::Result { - let bytes = BASE64_STANDARD.decode(base64_image)?; - - let image = ImageReader::new(Cursor::new(bytes)) - .with_guessed_format()? - .decode()?; - - Ok(image) -} diff --git a/crates/desktop/artcraft/src/core/utils/image/encode_dynamic_image_base64_png.rs b/crates/desktop/artcraft/src/core/utils/image/encode_dynamic_image_base64_png.rs deleted file mode 100644 index cb68e228aa..0000000000 --- a/crates/desktop/artcraft/src/core/utils/image/encode_dynamic_image_base64_png.rs +++ /dev/null @@ -1,14 +0,0 @@ -use base64::prelude::BASE64_STANDARD; -use base64::Engine; -use image::{DynamicImage, ImageFormat}; -use std::io::Cursor; - -pub fn encode_dynamic_image_base64_png(image: DynamicImage) -> anyhow::Result { - let mut bytes = Vec::with_capacity(1024*1024); - - image.write_to(&mut Cursor::new(&mut bytes), ImageFormat::Png)?; - - let bytes = BASE64_STANDARD.encode(bytes); - - Ok(bytes) -} diff --git a/crates/desktop/artcraft/src/core/utils/image/encode_rgb_image_base64_png.rs b/crates/desktop/artcraft/src/core/utils/image/encode_rgb_image_base64_png.rs deleted file mode 100644 index 76eb333de0..0000000000 --- a/crates/desktop/artcraft/src/core/utils/image/encode_rgb_image_base64_png.rs +++ /dev/null @@ -1,16 +0,0 @@ -use base64::prelude::BASE64_STANDARD; -use base64::Engine; -use image::{ImageFormat, RgbImage}; -use std::io::Cursor; - -pub fn encode_rgb_image_base64_png( - image: RgbImage -) -> anyhow::Result { - let mut bytes = Vec::with_capacity(1024*1024); - - image.write_to(&mut Cursor::new(&mut bytes), ImageFormat::Png)?; - - let bytes = (&BASE64_STANDARD).encode(bytes); - - Ok(bytes) -} diff --git a/crates/desktop/artcraft/src/core/utils/image/mod.rs b/crates/desktop/artcraft/src/core/utils/image/mod.rs deleted file mode 100644 index 3b7d7a6b76..0000000000 --- a/crates/desktop/artcraft/src/core/utils/image/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub mod decode_base64_image; -pub mod encode_dynamic_image_base64_png; -pub mod encode_rgb_image_base64_png; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/core/utils/large_file_transfer/download.rs b/crates/desktop/artcraft/src/core/utils/large_file_transfer/download.rs deleted file mode 100644 index 14222bdc6b..0000000000 --- a/crates/desktop/artcraft/src/core/utils/large_file_transfer/download.rs +++ /dev/null @@ -1,239 +0,0 @@ -//! Implemented from https://github.com/huggingface/hf_transfer/blob/main/src/lib.rs - -use crate::core::utils::large_file_transfer::error::Error; -use crate::core::utils::large_file_transfer::util::{exponential_backoff, BASE_WAIT_TIME, MAX_WAIT_TIME}; -use futures::stream::FuturesUnordered; -use futures::StreamExt; -use log::info; -use reqwest::header::{ - HeaderMap, HeaderName, HeaderValue, AUTHORIZATION, CONTENT_RANGE, - RANGE, -}; -use reqwest::Url; -use std::collections::HashMap; -use std::io::SeekFrom; -use std::path::Path; -use std::sync::atomic::{AtomicUsize, Ordering}; -use std::sync::mpsc::Sender; -use std::sync::Arc; -use std::time::Duration; -use tempfile::NamedTempFile; -use tokio::fs::OpenOptions; -use tokio::io::AsyncSeekExt; -use tokio::io::AsyncWriteExt; -use tokio::sync::Semaphore; -use tokio::time::sleep; - -pub struct ProgressUpdate { - pub complete: usize, - pub total_length: usize, -} - -/// max_files: Number of open file handles, which determines the maximum number of parallel downloads -/// parallel_failures: Number of maximum failures of different chunks in parallel (cannot exceed max_files) -/// max_retries: Number of maximum attempts per chunk. (Retries are exponentially backed off + jitter) -/// -/// The number of threads can be tuned by the environment variable `TOKIO_WORKER_THREADS` as documented in -/// https://docs.rs/tokio/latest/tokio/runtime/struct.Builder.html#method.worker_threads -#[allow(clippy::too_many_arguments)] -pub async fn download_async>( - url: String, - filename: NamedTempFile, - final_filename: P, - max_files: usize, - chunk_size: usize, - parallel_failures: usize, - max_retries: usize, - input_headers: Option>, - maybe_progress_sender: Option>, -) -> Result<(), Error> { - info!(">>> Downloading: {}", filename.as_ref().display()); - - let client = reqwest::Client::builder() - // https://github.com/hyperium/hyper/issues/2136#issuecomment-589488526 - .http2_keep_alive_timeout(Duration::from_secs(15)) - .build()?; - - let mut headers = HeaderMap::new(); - let mut auth_token = None; - if let Some(input_headers) = input_headers { - headers.reserve(input_headers.len()); - for (k, v) in input_headers { - let name: HeaderName = k - .try_into() - .map_err(|err| Error::new_err(format!("Invalid header: {err}")))?; - let value: HeaderValue = AsRef::::as_ref(&v) - .try_into() - .map_err(|err| Error::new_err(format!("Invalid header value: {err}")))?; - if name == AUTHORIZATION { - auth_token = Some(value); - } else { - headers.insert(name, value); - } - } - }; - - let response = if let Some(token) = auth_token.as_ref() { - client.get(&url).header(AUTHORIZATION, token) - } else { - client.get(&url) - } - .headers(headers.clone()) - .header(RANGE, "bytes=0-0") - .send() - .await - .map_err(|err| Error::new_err(format!("Error while downloading: {err}")))? - .error_for_status() - .map_err(|err| Error::new_err(err.to_string()))?; - - // Only call the final redirect URL to avoid overloading the Hub with requests and also - // altering the download count - let redirected_url = response.url(); - if Url::parse(&url) - .map_err(|err| Error::new_err(format!("failed to parse url: {err}")))? - .host() - == redirected_url.host() - { - if let Some(token) = auth_token { - headers.insert(AUTHORIZATION, token); - } - } - - let content_range = response - .headers() - .get(CONTENT_RANGE) - .ok_or(Error::new_err("No content length".to_string()))? - .to_str() - .map_err(|err| Error::new_err(format!("Error while downloading: {err}")))?; - - let size: Vec<&str> = content_range.split('/').collect(); - // Content-Range: bytes 0-0/702517648 - // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Range - let length: usize = size - .last() - .ok_or(Error::new_err( - "Error while downloading: No size was detected".to_string(), - ))? - .parse() - .map_err(|err| Error::new_err(format!("Error while downloading: {err}")))?; - - - info!("File {:?} is {:?} length", filename.as_ref(), length); - - let mut handles = FuturesUnordered::new(); - let semaphore = Arc::new(Semaphore::new(max_files)); - let parallel_failures_semaphore = Arc::new(Semaphore::new(parallel_failures)); - let max_chunk_complete = Arc::new(AtomicUsize::new(0)); - - for start in (0..length).step_by(chunk_size) { - let url = redirected_url.to_string(); - let filename = filename.as_ref().to_owned(); - let client = client.clone(); - let headers = headers.clone(); - - let stop = std::cmp::min(start + chunk_size - 1, length); - let semaphore = semaphore.clone(); - let parallel_failures_semaphore = parallel_failures_semaphore.clone(); - let maybe_progress = maybe_progress_sender.clone(); - let max_chunk_complete = max_chunk_complete.clone(); - handles.push(tokio::spawn(async move { - let permit = semaphore - .acquire_owned() - .await - .map_err(|err| Error::new_err(format!("Error while downloading: {err}")))?; - let mut chunk = download_chunk(&client, &url, &filename, start, stop, headers.clone()).await; - let mut i = 0; - if parallel_failures > 0 { - while let Err(dlerr) = chunk { - if i >= max_retries { - return Err(Error::new_err(format!( - "Failed after too many retries ({max_retries}): {dlerr}" - ))); - } - let parallel_failure_permit = parallel_failures_semaphore.clone().try_acquire_owned().map_err(|err| { - Error::new_err(format!( - "Failed too many failures in parallel ({parallel_failures}): {dlerr} ({err})" - )) - })?; - - let wait_time = exponential_backoff(BASE_WAIT_TIME, i, MAX_WAIT_TIME); - sleep(Duration::from_millis(wait_time as u64)).await; - - chunk = download_chunk(&client, &url, &filename, start, stop, headers.clone()).await; - i += 1; - drop(parallel_failure_permit); - - if let Some(sender) = maybe_progress.as_ref() { - // NB: Calling fetch_max twice. First call will return the lower value. - let _old = max_chunk_complete.fetch_max(stop, Ordering::SeqCst); - let max_chunk = max_chunk_complete.fetch_max(stop, Ordering::SeqCst); - let progress_update = ProgressUpdate { - complete: max_chunk, - total_length: length, - }; - if let Err(_err) = sender.send(progress_update) { - // Fail silently, not essential to issue progress updates - } - } - } - } - drop(permit); - chunk.map_err(|e| Error::new_err(format!("Downloading error {e}"))).and(Ok(stop - start)) - })); - } - - // Output the chained result - while let Some(result) = handles.next().await { - match result { - Ok(Ok(size)) => { - //if let Some(ref callback) = callback { - // callback.call((size,), None)?; - //} - } - Ok(Err(py_err)) => { - return Err(py_err); - } - Err(err) => { - return Err(Error::new_err(format!( - "Error while downloading: {err}" - ))); - } - } - } - - let file = filename.persist(final_filename) - .map_err(|e| Error::new_err(format!("Could not rename to final filename: {:?}", e)))?; - - file.sync_all()?; - - Ok(()) -} - -async fn download_chunk>( - client: &reqwest::Client, - url: &str, - filename: P, - start: usize, - stop: usize, - headers: HeaderMap, -) -> Result<(), Error> { - // Process each socket concurrently. - let range = format!("bytes={start}-{stop}"); - let mut file = OpenOptions::new() - .write(true) - .truncate(false) - .create(true) - .open(filename) - .await?; - file.seek(SeekFrom::Start(start as u64)).await?; - let response = client - .get(url) - .headers(headers) - .header(RANGE, range) - .send() - .await? - .error_for_status()?; - let content = response.bytes().await?; - file.write_all(&content).await?; - Ok(()) -} diff --git a/crates/desktop/artcraft/src/core/utils/large_file_transfer/error.rs b/crates/desktop/artcraft/src/core/utils/large_file_transfer/error.rs deleted file mode 100644 index 4411edb4e8..0000000000 --- a/crates/desktop/artcraft/src/core/utils/large_file_transfer/error.rs +++ /dev/null @@ -1,49 +0,0 @@ -//! Implemented from https://github.com/huggingface/hf_transfer/blob/main/src/lib.rs - -use reqwest::header::ToStrError; -use std::fmt::Display; - -#[derive(Debug)] -pub enum Error { - Io(std::io::Error), - Request(reqwest::Error), - ToStrError(ToStrError), - Misc(String), -} - -impl From for Error { - fn from(value: std::io::Error) -> Self { - Self::Io(value) - } -} - -impl From for Error { - fn from(value: reqwest::Error) -> Self { - Self::Request(value) - } -} - -impl From for Error { - fn from(value: ToStrError) -> Self { - Self::ToStrError(value) - } -} - -impl Display for Error { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - Self::Io(io) => write!(f, "Io: {io}"), - Self::Request(req) => write!(f, "Request: {req}"), - Self::ToStrError(req) => write!(f, "Response non ascii: {req}"), - Self::Misc(err) => write!(f, "Misc error: {err}"), - } - } -} - -impl std::error::Error for Error {} - -impl Error { - pub fn new_err(reason: String) -> Self { - Self::Misc(reason) - } -} diff --git a/crates/desktop/artcraft/src/core/utils/large_file_transfer/mod.rs b/crates/desktop/artcraft/src/core/utils/large_file_transfer/mod.rs deleted file mode 100644 index cd6facd1b6..0000000000 --- a/crates/desktop/artcraft/src/core/utils/large_file_transfer/mod.rs +++ /dev/null @@ -1,4 +0,0 @@ -pub mod download; -pub mod upload; -pub mod util; -pub mod error; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/core/utils/large_file_transfer/upload.rs b/crates/desktop/artcraft/src/core/utils/large_file_transfer/upload.rs deleted file mode 100644 index e0e2a7e021..0000000000 --- a/crates/desktop/artcraft/src/core/utils/large_file_transfer/upload.rs +++ /dev/null @@ -1,188 +0,0 @@ -//! Implemented from https://github.com/huggingface/hf_transfer/blob/main/src/lib.rs - -use crate::core::utils::large_file_transfer::error::Error; -use crate::core::utils::large_file_transfer::util::{exponential_backoff, BASE_WAIT_TIME, MAX_WAIT_TIME}; -use futures::stream::FuturesUnordered; -use futures::StreamExt; -use reqwest::header::CONTENT_LENGTH; -use std::collections::HashMap; -use std::io::SeekFrom; -use std::sync::Arc; -use std::time::Duration; -use tokio::fs::OpenOptions; -use tokio::io::{AsyncReadExt, AsyncSeekExt}; -use tokio::sync::Semaphore; -use tokio::time::sleep; -use tokio_util::codec::{BytesCodec, FramedRead}; - -/// parts_urls: Dictionary consisting of part numbers as keys and the associated url as values -/// completion_url: The url that should be called when the upload is finished -/// max_files: Number of open file handles, which determines the maximum number of parallel uploads -/// parallel_failures: Number of maximum failures of different chunks in parallel (cannot exceed max_files) -/// max_retries: Number of maximum attempts per chunk. (Retries are exponentially backed off + jitter) -/// -/// The number of threads can be tuned by the environment variable `TOKIO_WORKER_THREADS` as documented in -/// https://docs.rs/tokio/latest/tokio/runtime/struct.Builder.html#method.worker_threads -/// -/// See https://docs.aws.amazon.com/AmazonS3/latest/userguide/mpuoverview.html for more information -/// on the multipart upload -#[allow(clippy::too_many_arguments)] -fn multipart_upload( - file_path: String, - parts_urls: Vec, - chunk_size: u64, - max_files: usize, - parallel_failures: usize, - max_retries: usize, -) -> Result>, Error> { - if parallel_failures > max_files { - return Err(Error::new_err( - "Error parallel_failures cannot be > max_files".to_string(), - )); - } - if (parallel_failures == 0) != (max_retries == 0) { - return Err(Error::new_err( - "For retry mechanism you need to set both `parallel_failures` and `max_retries`" - .to_string(), - )); - } - - tokio::runtime::Builder::new_multi_thread() - .enable_all() - .build()? - .block_on(async { - upload_async( - file_path, - parts_urls, - chunk_size, - max_files, - parallel_failures, - max_retries, - ) - .await - }) -} - - - -#[allow(clippy::too_many_arguments)] -async fn upload_async( - file_path: String, - parts_urls: Vec, - chunk_size: u64, - max_files: usize, - parallel_failures: usize, - max_retries: usize, -) -> Result>, Error> { - let client = reqwest::Client::new(); - - let mut handles = FuturesUnordered::new(); - let semaphore = Arc::new(Semaphore::new(max_files)); - let parallel_failures_semaphore = Arc::new(Semaphore::new(parallel_failures)); - - for (part_number, part_url) in parts_urls.iter().enumerate() { - let url = part_url.to_string(); - let path = file_path.to_owned(); - let client = client.clone(); - - let start = (part_number as u64) * chunk_size; - let semaphore = semaphore.clone(); - let parallel_failures_semaphore = parallel_failures_semaphore.clone(); - handles.push(tokio::spawn(async move { - let permit = semaphore - .clone() - .acquire_owned() - .await - .map_err(|err| Error::new_err(format!("Error acquiring semaphore: {err}")))?; - let mut chunk = upload_chunk(&client, &url, &path, start, chunk_size).await; - let mut i = 0; - if parallel_failures > 0 { - while let Err(ul_err) = chunk { - if i >= max_retries { - return Err(Error::new_err(format!( - "Failed after too many retries ({max_retries}): {ul_err}" - ))); - } - - let parallel_failure_permit = parallel_failures_semaphore.clone().try_acquire_owned().map_err(|err| { - Error::new_err(format!( - "Failed too many failures in parallel ({parallel_failures}): {ul_err} ({err})" - )) - })?; - - let wait_time = exponential_backoff(BASE_WAIT_TIME, i, MAX_WAIT_TIME); - sleep(Duration::from_millis(wait_time as u64)).await; - - chunk = upload_chunk(&client, &url, &path, start, chunk_size).await; - i += 1; - drop(parallel_failure_permit); - } - } - drop(permit); - chunk.map_err(|e|{ - //match e { - // Error::Io(io) => Error::new_err(format!("Io error {io}")), - // Error::Request(req) => Error::new_err(format!("Error while sending chunk {req}")), - // Error::ToStrError(req) => Error::new_err(format!("Response header contains non ASCII chars: {req}")), - //} - e - }).map(|chunk| (part_number, chunk, chunk_size)) - })); - } - - let mut results: Vec> = vec![HashMap::default(); parts_urls.len()]; - - while let Some(result) = handles.next().await { - match result { - Ok(Ok((part_number, headers, size))) => { - //if let Some(ref callback) = callback { - // callback.call((size,), None)?; - //} - results[part_number] = headers; - } - Ok(Err(py_err)) => { - return Err(py_err); - } - Err(err) => { - return Err(Error::new_err(format!( - "Error occurred while uploading: {err}" - ))); - } - } - } - - Ok(results) -} - -async fn upload_chunk( - client: &reqwest::Client, - url: &str, - path: &str, - start: u64, - chunk_size: u64, -) -> Result, Error> { - let mut options = OpenOptions::new(); - let mut file = options.read(true).open(path).await?; - let file_size = file.metadata().await?.len(); - let bytes_transferred = std::cmp::min(file_size - start, chunk_size); - - file.seek(SeekFrom::Start(start)).await?; - let chunk = file.take(chunk_size); - - let response = client - .put(url) - .header(CONTENT_LENGTH, bytes_transferred) - .body(reqwest::Body::wrap_stream(FramedRead::new( - chunk, - BytesCodec::new(), - ))) - .send() - .await?; - let response = response.error_for_status()?; - let mut headers = HashMap::new(); - for (name, value) in response.headers().into_iter() { - headers.insert(name.to_string(), value.to_str()?.to_owned()); - } - Ok(headers) -} - diff --git a/crates/desktop/artcraft/src/core/utils/large_file_transfer/util.rs b/crates/desktop/artcraft/src/core/utils/large_file_transfer/util.rs deleted file mode 100644 index e58da7d5ac..0000000000 --- a/crates/desktop/artcraft/src/core/utils/large_file_transfer/util.rs +++ /dev/null @@ -1,14 +0,0 @@ -//! Implemented from https://github.com/huggingface/hf_transfer/blob/main/src/lib.rs - -use rand::{thread_rng, Rng}; - -pub const BASE_WAIT_TIME: usize = 300; -pub const MAX_WAIT_TIME: usize = 10_000; - -fn jitter() -> usize { - thread_rng().gen_range(0..=500) -} - -pub fn exponential_backoff(base_wait_time: usize, n: usize, max: usize) -> usize { - (base_wait_time + n.pow(2) + jitter()).min(max) -} diff --git a/crates/desktop/artcraft/src/core/utils/mod.rs b/crates/desktop/artcraft/src/core/utils/mod.rs deleted file mode 100644 index 5ea5eb93de..0000000000 --- a/crates/desktop/artcraft/src/core/utils/mod.rs +++ /dev/null @@ -1,15 +0,0 @@ -pub mod clear_all_webview_cookies; -pub mod download_media_file_to_temp_dir; -pub mod download_url_to_temp_dir; -pub mod download_url_to_user_download_dir; -pub mod enum_conversion; -pub mod get_url_file_extension; -pub mod image; -pub mod large_file_transfer; -pub mod object_store; -pub mod save_base64_image_to_temp_dir; -pub mod simple_http_download; -pub mod simple_http_download_to_tempfile; -pub mod task_database_pending_statuses; -pub mod upload_bytes_to_media_file; -pub mod window; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/core/utils/object_store.rs b/crates/desktop/artcraft/src/core/utils/object_store.rs deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/crates/desktop/artcraft/src/core/utils/save_base64_image_to_temp_dir.rs b/crates/desktop/artcraft/src/core/utils/save_base64_image_to_temp_dir.rs deleted file mode 100644 index 4ae504376d..0000000000 --- a/crates/desktop/artcraft/src/core/utils/save_base64_image_to_temp_dir.rs +++ /dev/null @@ -1,22 +0,0 @@ -use crate::core::artcraft_error::ArtcraftError; -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use mimetypes::mimetype_info::mimetype_info::MimetypeInfo; -use std::io::Write; -use tempfile::NamedTempFile; -use web_base64::web_base64_decode::web_base64_decode; - -pub async fn save_base64_image_to_temp_dir(app_data_root: &AppDataRoot, base64_image: &str) -> Result { - let bytes = web_base64_decode(base64_image)?; - - let extension = MimetypeInfo::get_for_bytes(&bytes) - .map(|info| info.file_extension()) - .flatten() - .map(|ext| ext.extension_with_period().to_string()) - .unwrap_or_else(|| ".png".to_string()); - - let mut file = app_data_root.temp_dir().new_named_temp_file_with_extension(&extension)?; - - file.write_all(bytes.as_ref())?; - - Ok(file) // NB: Must return TempFile to not drop / delete it -} diff --git a/crates/desktop/artcraft/src/core/utils/simple_http_download.rs b/crates/desktop/artcraft/src/core/utils/simple_http_download.rs deleted file mode 100644 index 966b71950c..0000000000 --- a/crates/desktop/artcraft/src/core/utils/simple_http_download.rs +++ /dev/null @@ -1,34 +0,0 @@ -use errors::AnyhowResult; -use reqwest::Client; -use reqwest::Url; -use std::fs::OpenOptions; -use std::io::Write; -use std::path::Path; - -const USER_AGENT: &str = "storyteller-client/1.0"; - -/// Downloads a (binary) file to a filesystem path. Good for images, etc. Not great for large files. -pub async fn simple_http_download>(url: &Url, download_path: P) -> AnyhowResult<()> { - let client = Client::builder() - .gzip(true) - .build()?; - - let response = client.get(url.clone()) // NB: No IntoUrl for &Url. - .header("User-Agent", USER_AGENT) - .header("Accept", "*/*") - .send() - .await?; - - //let response : Response = reqwest::get(url).await?; - let bytes = response.bytes().await?; - - let mut file = OpenOptions::new() - .create(true) // To create a new file - .write(true) - .truncate(true) - .open(download_path)?; - - file.write_all(&bytes)?; - - Ok(()) -} diff --git a/crates/desktop/artcraft/src/core/utils/simple_http_download_to_tempfile.rs b/crates/desktop/artcraft/src/core/utils/simple_http_download_to_tempfile.rs deleted file mode 100644 index b1ae596fd3..0000000000 --- a/crates/desktop/artcraft/src/core/utils/simple_http_download_to_tempfile.rs +++ /dev/null @@ -1,26 +0,0 @@ -use errors::AnyhowResult; -use reqwest::Client; -use reqwest::Url; -use std::io::Write; -use tempfile::NamedTempFile; - -const USER_AGENT: &str = "storyteller-client/1.0"; - -/// Downloads a (binary) file to a filesystem path. Good for images, etc. Not great for large files. -pub async fn simple_http_download_to_tempfile(url: &Url, temp_file: &mut NamedTempFile) -> AnyhowResult<()> { - let client = Client::builder() - .gzip(true) - .build()?; - - let response = client.get(url.clone()) // NB: No IntoUrl for &Url. - .header("User-Agent", USER_AGENT) - .header("Accept", "*/*") - .send() - .await?; - - let bytes = response.bytes().await?; - - temp_file.write_all(&bytes)?; - - Ok(()) -} diff --git a/crates/desktop/artcraft/src/core/utils/task_database_pending_statuses.rs b/crates/desktop/artcraft/src/core/utils/task_database_pending_statuses.rs deleted file mode 100644 index f74e5e9703..0000000000 --- a/crates/desktop/artcraft/src/core/utils/task_database_pending_statuses.rs +++ /dev/null @@ -1,12 +0,0 @@ -use enums::tauri::tasks::task_status::TaskStatus; -use once_cell::sync::Lazy; -use std::collections::HashSet; - -/// Reused predicate for querying pending SQLite tasks -pub static TASK_DATABASE_PENDING_STATUSES: Lazy> = Lazy::new(|| { - let mut statuses = HashSet::new(); - statuses.insert(TaskStatus::Pending); - statuses.insert(TaskStatus::Started); - statuses.insert(TaskStatus::AttemptFailed); - statuses -}); diff --git a/crates/desktop/artcraft/src/core/utils/upload_bytes_to_media_file/mod.rs b/crates/desktop/artcraft/src/core/utils/upload_bytes_to_media_file/mod.rs deleted file mode 100644 index 9f4a49e121..0000000000 --- a/crates/desktop/artcraft/src/core/utils/upload_bytes_to_media_file/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod upload_image_bytes_as_media_file; -pub mod upload_mask_image_bytes_as_media_file; diff --git a/crates/desktop/artcraft/src/core/utils/upload_bytes_to_media_file/upload_image_bytes_as_media_file.rs b/crates/desktop/artcraft/src/core/utils/upload_bytes_to_media_file/upload_image_bytes_as_media_file.rs deleted file mode 100644 index 497bcc3544..0000000000 --- a/crates/desktop/artcraft/src/core/utils/upload_bytes_to_media_file/upload_image_bytes_as_media_file.rs +++ /dev/null @@ -1,38 +0,0 @@ -use log::info; - -use artcraft_client::credentials::storyteller_credential_set::StorytellerCredentialSet; -use artcraft_client::endpoints::media_files::upload_image_media_file_from_bytes::{ - upload_image_media_file_from_bytes, ImageType, UploadImageBytesArgs, -}; -use artcraft_client::utils::api_host::ApiHost; -use tokens::tokens::media_files::MediaFileToken; - -use crate::core::commands::enqueue::generate_error::GenerateError; - -/// Upload raw image bytes to ArtCraft, returning the resulting MediaFileToken. -/// -/// This is NOT marked as an intermediate system file — the image will appear -/// in the user's gallery. -pub async fn upload_image_bytes_as_media_file( - creds: &StorytellerCredentialSet, - api_host: &ApiHost, - image_bytes: Vec, -) -> Result { - info!("Uploading image bytes ({} bytes) as media file...", image_bytes.len()); - - let result = upload_image_media_file_from_bytes(UploadImageBytesArgs { - api_host, - maybe_creds: Some(creds), - image_bytes, - image_type: ImageType::Png, - is_intermediate_system_file: false, - maybe_generation_provider: None, - }).await.map_err(|err| { - log::error!("Failed to upload image bytes as media file: {:?}", err); - GenerateError::from(err) - })?; - - info!("Uploaded image bytes as media file: {}", result.media_file_token.as_str()); - - Ok(result.media_file_token) -} diff --git a/crates/desktop/artcraft/src/core/utils/upload_bytes_to_media_file/upload_mask_image_bytes_as_media_file.rs b/crates/desktop/artcraft/src/core/utils/upload_bytes_to_media_file/upload_mask_image_bytes_as_media_file.rs deleted file mode 100644 index 7807ae8bcb..0000000000 --- a/crates/desktop/artcraft/src/core/utils/upload_bytes_to_media_file/upload_mask_image_bytes_as_media_file.rs +++ /dev/null @@ -1,48 +0,0 @@ -use log::{error, info}; - -use artcraft_client::credentials::storyteller_credential_set::StorytellerCredentialSet; -use artcraft_client::endpoints::media_files::upload_image_media_file_from_bytes::{ - upload_image_media_file_from_bytes, ImageType, UploadImageBytesArgs, -}; -use artcraft_client::utils::api_host::ApiHost; -use images::mask_images::normalize_image_bytes_to_flux_mask::normalize_image_bytes_to_flux_mask; -use tokens::tokens::media_files::MediaFileToken; - -use crate::core::commands::enqueue::generate_error::GenerateError; - -/// Upload raw mask image bytes to ArtCraft, returning the resulting MediaFileToken. -/// -/// The mask bytes are first normalized via `normalize_image_bytes_to_flux_mask` -/// (transparent pixels → black/ignore, opaque pixels → white/interest region), -/// then uploaded as an intermediate system file (hidden from the user's gallery). -pub async fn upload_mask_image_bytes_as_media_file( - creds: &StorytellerCredentialSet, - api_host: &ApiHost, - mask_image_bytes: &[u8], -) -> Result { - info!("Normalizing mask image bytes ({} bytes)...", mask_image_bytes.len()); - - let normalized = normalize_image_bytes_to_flux_mask(mask_image_bytes) - .map_err(|err| { - error!("Failed to normalize mask image bytes: {:?}", err); - GenerateError::AnyhowError(anyhow::anyhow!("Failed to normalize mask image bytes")) - })?; - - info!("Uploading normalized mask ({} bytes) as intermediate system file...", normalized.0.len()); - - let result = upload_image_media_file_from_bytes(UploadImageBytesArgs { - api_host, - maybe_creds: Some(creds), - image_bytes: normalized.0, - image_type: ImageType::Png, - is_intermediate_system_file: true, - maybe_generation_provider: None, - }).await.map_err(|err| { - error!("Failed to upload mask image bytes: {:?}", err); - GenerateError::from(err) - })?; - - info!("Uploaded mask as media file: {}", result.media_file_token.as_str()); - - Ok(result.media_file_token) -} diff --git a/crates/desktop/artcraft/src/core/utils/window/get_webview_window_hostname.rs b/crates/desktop/artcraft/src/core/utils/window/get_webview_window_hostname.rs deleted file mode 100644 index 4fd10cd58f..0000000000 --- a/crates/desktop/artcraft/src/core/utils/window/get_webview_window_hostname.rs +++ /dev/null @@ -1,11 +0,0 @@ -use anyhow::anyhow; -use tauri::WebviewWindow; -use errors::AnyhowResult; - -pub fn get_webview_window_hostname(webview: &WebviewWindow) -> AnyhowResult { - let url = webview.url()?; - let url_hostname= url.host() - .ok_or(anyhow!("no host in url"))? - .to_string(); - Ok(url_hostname) -} diff --git a/crates/desktop/artcraft/src/core/utils/window/get_webview_window_url_path.rs b/crates/desktop/artcraft/src/core/utils/window/get_webview_window_url_path.rs deleted file mode 100644 index 0cdec49494..0000000000 --- a/crates/desktop/artcraft/src/core/utils/window/get_webview_window_url_path.rs +++ /dev/null @@ -1,7 +0,0 @@ -use errors::AnyhowResult; -use tauri::WebviewWindow; - -pub fn get_webview_window_url_path(webview: &WebviewWindow) -> AnyhowResult { - let url = webview.url()?; - Ok(url.path().to_string()) -} diff --git a/crates/desktop/artcraft/src/core/utils/window/get_window_size_heuristic.rs b/crates/desktop/artcraft/src/core/utils/window/get_window_size_heuristic.rs deleted file mode 100644 index 6631f783b0..0000000000 --- a/crates/desktop/artcraft/src/core/utils/window/get_window_size_heuristic.rs +++ /dev/null @@ -1,25 +0,0 @@ -use errors::AnyhowResult; -use tauri::{PhysicalSize, Window}; - -// A typical height difference when dev tools are open: -// Window inner size = PhysicalSize { width: 3704, height: 732 } -// Window outer size = PhysicalSize { width: 3704, height: 1476 } -const DEV_TOOLS_HEIGHT_DIFFERENCE_THRESHOLD: u32 = 300; - -/// Get the best window size -pub fn get_window_size_heuristic(window: &Window) -> AnyhowResult> { - // NB: Ordinarily we'd use inner size, as the outer size includes the window decorations. - // However, dev tools contract the inner size, and in the event they're open, we should - // prefer the outer size. - let inner = window.inner_size()?; - let outer = window.outer_size()?; - - let height_delta = outer.height.saturating_sub(inner.height); - if height_delta > DEV_TOOLS_HEIGHT_DIFFERENCE_THRESHOLD { - // Dev tools are open, use the outer size - Ok(outer) - } else { - // Dev tools are not open, use the inner size - Ok(inner) - } -} diff --git a/crates/desktop/artcraft/src/core/utils/window/mod.rs b/crates/desktop/artcraft/src/core/utils/window/mod.rs deleted file mode 100644 index bc3d5e1a84..0000000000 --- a/crates/desktop/artcraft/src/core/utils/window/mod.rs +++ /dev/null @@ -1,5 +0,0 @@ -pub mod get_webview_window_hostname; -pub mod get_window_size_heuristic; -pub mod position_main_window; -pub mod resize_main_window; -pub mod get_webview_window_url_path; diff --git a/crates/desktop/artcraft/src/core/utils/window/position_main_window.rs b/crates/desktop/artcraft/src/core/utils/window/position_main_window.rs deleted file mode 100644 index 5d01076995..0000000000 --- a/crates/desktop/artcraft/src/core/utils/window/position_main_window.rs +++ /dev/null @@ -1,65 +0,0 @@ -use crate::core::state::window::main_window_position::MainWindowPosition; -use crate::core::windows::main_window::constants::MAIN_WINDOW_NAME; -use errors::AnyhowResult; -use tauri::{AppHandle, Manager, PhysicalPosition}; - -/// Try to position the main window at startup. -/// If it doesn't meet certain placement heuristics, abandon manual placement and let the OS -/// decide where to place the app. -pub fn position_main_window( - app: &AppHandle, - position: &MainWindowPosition, -) -> AnyhowResult<()> { - - // NB: This non-negative position heuristic is good for MacBook (single screen). - // Not sure how this fares on Windows, Linux, or multiscreen setups. - // On Mac, this prevents the windows from being positioned off to the top-left, - // as (0,0) is the top left directly under the top menu bar. - if position.x < 0 { - // TODO(bt,2025-07-16): just in the case of x/width, allow slight placement off - // screen as long as the app is wide enough. - return Err(anyhow::anyhow!("X position must be non-negative")); - } else if position.y < 0 { - return Err(anyhow::anyhow!("Y position must be non-negative")); - } - - let windows = app.windows(); - - let window = windows.get(MAIN_WINDOW_NAME) - .ok_or_else(|| anyhow::anyhow!("Main window not found"))?; - - if let Ok(Some(monitor)) = window.current_monitor() { - // Reports the size of the monitor, e.g. PhysicalSize { width: 4112, height: 2658 } - // This is not impacted by `scale_factor`, even if that's a multiple like "2". - // i.e., positioning the app at `monitor.size().width/2` and `monitor.size().height/2` - // will place the **top left corner of the app** in roughly the center of the monitor. - let monitor_size = monitor.size(); - - println!("Current monitor - size: {:?}", monitor_size); - println!("Current monitor - scale factor: {:?}", monitor.scale_factor()); - println!("Current monitor - position: {:?}", monitor.position()); - - let width_padding = monitor_size.width.div_ceil(6); - let height_padding = monitor_size.height.div_ceil(6); - - let max_width = monitor_size.width.saturating_sub(width_padding); - let max_height = monitor_size.height.saturating_sub(height_padding); - - let max_width = i32::try_from(max_width)?; - let max_height = i32::try_from(max_height)?; - - // Prevent the window from being positioned off the screen to the bottom, right, and bottom right. - // This works on MacBook (single screen), but should be tested on Windows, Linux, and multiscreen setups. - if position.x > max_width { - return Err(anyhow::anyhow!("X position must be less than or equal to {} (monitor width {})", - max_width, monitor_size.width)); - } else if position.y > max_height { - return Err(anyhow::anyhow!("Y position must be less than or equal to {} (monitor height {})", - max_height, monitor_size.height)); - } - } - - window.set_position(PhysicalPosition::new(position.x, position.y))?; - - Ok(()) -} \ No newline at end of file diff --git a/crates/desktop/artcraft/src/core/utils/window/resize_main_window.rs b/crates/desktop/artcraft/src/core/utils/window/resize_main_window.rs deleted file mode 100644 index 76accb3814..0000000000 --- a/crates/desktop/artcraft/src/core/utils/window/resize_main_window.rs +++ /dev/null @@ -1,63 +0,0 @@ -use crate::core::state::window::main_window_size::MainWindowSize; -use crate::core::windows::main_window::constants::{MAIN_WINDOW_MIN_HEIGHT, MAIN_WINDOW_MIN_WIDTH, MAIN_WINDOW_NAME}; -use tauri::{AppHandle, Manager, PhysicalSize}; - -/// Try to resize the main window at startup. -/// If it doesn't meet certain sizing heuristics, abandon manual resize and let the OS -/// decide how to size the app. -pub fn resize_main_window( - app: &AppHandle, - size: &MainWindowSize, -) -> errors::AnyhowResult<()> { - - let mut resize_width = size.width; - let mut resize_height = size.height; - let mut resize_was_corrected = false; - - if resize_width < MAIN_WINDOW_MIN_WIDTH { - resize_width = MAIN_WINDOW_MIN_WIDTH; - resize_was_corrected = true; - } - if resize_height < MAIN_WINDOW_MIN_HEIGHT { - resize_height = MAIN_WINDOW_MIN_HEIGHT; - resize_was_corrected = true; - } - - let windows = app.windows(); - let window = windows.get(MAIN_WINDOW_NAME) - .ok_or_else(|| anyhow::anyhow!("Main window not found"))?; - - if let Ok(Some(monitor)) = window.current_monitor() { - let scale_factor = monitor.scale_factor(); - - if scale_factor > 1.0 { - - let min_width = MAIN_WINDOW_MIN_WIDTH as f64 * scale_factor; - let min_height = MAIN_WINDOW_MIN_HEIGHT as f64 * scale_factor; - - // Is this safe? https://users.rust-lang.org/t/convert-an-f64-to-an-i32/50991/4 - let min_width = min_width as u32; - let min_height = min_height as u32; - - if resize_width < min_width { - resize_width = min_width; - resize_was_corrected = true; - } - if resize_height < min_height { - resize_height = min_height; - resize_was_corrected = true; - } - } - } - - if resize_was_corrected { - println!("Resizing window to: {}x{} (corrected from {}x{})", - resize_width, resize_height, size.width, size.height); - } else { - println!("Resizing window to: {}x{} (no correction needed)", resize_width, resize_height); - } - - window.set_size(PhysicalSize::new(resize_width, resize_height))?; - - Ok(()) -} diff --git a/crates/desktop/artcraft/src/core/windows/main_window/constants.rs b/crates/desktop/artcraft/src/core/windows/main_window/constants.rs deleted file mode 100644 index 62c6e0e84f..0000000000 --- a/crates/desktop/artcraft/src/core/windows/main_window/constants.rs +++ /dev/null @@ -1,15 +0,0 @@ - -/// The name of the main application window. -/// This is the Artcraft application UX itself. -pub const MAIN_WINDOW_NAME : &str = "main"; - -/// This is the name of the main window's main webview. -pub const MAIN_WEBVIEW_NAME: &str = "main"; - -// TODO: handle pixel density, eg. retina displays -/// This is the minimum width to resize the main window in an automated fashion -pub const MAIN_WINDOW_MIN_WIDTH : u32 = 800; - -// TODO: handle pixel density, eg. retina displays -/// This is the minimum height to resize the main window in an automated fashion -pub const MAIN_WINDOW_MIN_HEIGHT : u32 = 600; diff --git a/crates/desktop/artcraft/src/core/windows/main_window/mod.rs b/crates/desktop/artcraft/src/core/windows/main_window/mod.rs deleted file mode 100644 index 987b09fc8a..0000000000 --- a/crates/desktop/artcraft/src/core/windows/main_window/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod constants; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/core/windows/mod.rs b/crates/desktop/artcraft/src/core/windows/mod.rs deleted file mode 100644 index 84cc560f4b..0000000000 --- a/crates/desktop/artcraft/src/core/windows/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod main_window; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/lib.rs b/crates/desktop/artcraft/src/lib.rs deleted file mode 100644 index f1e56503c9..0000000000 --- a/crates/desktop/artcraft/src/lib.rs +++ /dev/null @@ -1,279 +0,0 @@ -use crate::core::commands::cost_estimate::estimate_audio_cost_command::estimate_audio_cost_command; -use crate::core::commands::cost_estimate::estimate_mesh_cost_command::estimate_mesh_cost_command; -use crate::core::commands::generate::generate_splat_command::generate_splat_command; -use crate::core::commands::generate::generate_audio_command::generate_audio_command; -use crate::core::commands::generate::generate_mesh_command::generate_mesh_command; -pub mod core; -pub mod services; -pub mod version; - -use tauri::Manager; - -use crate::core::commands::app_preferences::get_app_preferences_command::get_app_preferences_command; -use crate::core::commands::app_preferences::update_app_preference_command::update_app_preferences_command; -use crate::core::commands::cost_estimate::estimate_image_cost_command::estimate_image_cost_command; -use crate::core::commands::cost_estimate::estimate_splat_cost_command::estimate_splat_cost_command; -use crate::core::commands::cost_estimate::estimate_video_cost_command::estimate_video_cost_command; -use crate::core::commands::generate::models::image::list_image_models_command::list_image_models_command; -use crate::core::commands::generate::models::video::list_video_models_command::list_video_models_command; -use crate::core::commands::download::download_directory_reveal_command::download_directory_reveal_command; -use crate::core::commands::download::download_media_file_command::download_media_file_command; -use crate::core::commands::download::download_url_command::download_url_command; -use crate::core::commands::enqueue::image_bg_removal::enqueue_image_bg_removal_command::enqueue_image_bg_removal_command; -use crate::core::commands::enqueue::image_to_gaussian::enqueue_image_to_gaussian_command::enqueue_image_to_gaussian_command; -use crate::core::commands::enqueue::image_to_object::enqueue_image_to_3d_object_command::enqueue_image_to_3d_object_command; -use crate::core::commands::generate::generate_image::generate_image_command::generate_image_command; -use crate::core::commands::generate::generate_video::generate_video_command::generate_video_command; -use crate::core::commands::flip_image::flip_image; -use crate::core::commands::get_app_info_command::get_app_info_command; -use crate::core::commands::load_without_cors_command::load_without_cors_command; -use crate::core::commands::media_files::media_file_delete_command::media_file_delete_command; -use crate::core::commands::platform_info_command::platform_info_command; -use crate::core::commands::providers::deprecated::get_provider_order_command::get_provider_order_command; -use crate::core::commands::providers::deprecated::set_provider_order_command::set_provider_order_command; -use crate::core::commands::providers::provider_clear_command::provider_clear_command; -use crate::core::commands::providers::provider_list_command::provider_list_command; -use crate::core::commands::providers::provider_set_api_key_command::provider_set_api_key_command; -use crate::core::commands::task_queue::get_task_queue_command::get_task_queue_command; -use crate::core::commands::task_queue::mark_task_as_dismissed_command::mark_task_as_dismissed_command; -use crate::core::commands::task_queue::tasks_nuke_all_command::tasks_nuke_all_command; -use crate::core::lifecycle::startup::handle_tauri_startup::handle_tauri_startup; -use crate::core::lifecycle::startup::setup_main_window::setup_main_window; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; -use crate::core::state::app_preferences::app_preferences_manager::load_app_preferences_or_default; -use crate::core::state::artcraft_platform_info::ArtcraftPlatformInfo; -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::core::state::provider_priority::ProviderPriorityStore; -use crate::core::threads::discord_presence_thread::discord_presence_thread; -use crate::core::threads::main_window_thread::main_window_thread::main_window_thread; -use crate::services::grok::commands::grok_clear_credentials_command::grok_clear_credentials_command; -use crate::services::grok::commands::grok_get_credential_info_command::grok_get_credential_info_command; -use crate::services::grok::commands::grok_open_login_command::grok_open_login_command; -use crate::services::grok::state::grok_credential_manager::GrokCredentialManager; -use crate::services::grok::state::grok_image_prompt_queue::GrokImagePromptQueue; -use crate::services::midjourney::commands::midjourney_clear_credentials_command::midjourney_clear_credentials_command; -use crate::services::midjourney::commands::midjourney_get_credential_info_command::midjourney_get_credential_info_command; -use crate::services::midjourney::commands::midjourney_open_login_command::midjourney_open_login_command; -use crate::services::midjourney::state::midjourney_credential_manager::MidjourneyCredentialManager; -use crate::services::sora::commands::check_sora_session_command::check_sora_session_command; -use crate::services::sora::commands::open_sora_login_command::open_sora_login_command; -use crate::services::sora::commands::sora_get_credential_info_command::sora_get_credential_info_command; -use crate::services::sora::commands::sora_logout_command::sora_logout_command; -use crate::services::sora::state::sora_credential_manager::SoraCredentialManager; -use crate::services::sora::state::sora_task_queue::SoraTaskQueue; -use crate::services::sora::threads::sora_task_polling::sora_task_polling_thread::sora_task_polling_thread; -use crate::services::storyteller::commands::storyteller_get_credits_command::storyteller_get_credits_command; -use crate::services::storyteller::commands::storyteller_get_subscription_command::storyteller_get_subscription_command; -use crate::services::storyteller::commands::storyteller_purge_credentials_command::storyteller_purge_credentials_command; -use crate::services::storyteller::commands::stripe_checkout::storyteller_open_credits_purchase_command::storyteller_open_credits_purchase_command; -use crate::services::storyteller::commands::stripe_checkout::storyteller_open_subscription_purchase_command::storyteller_open_subscription_purchase_command; -use crate::services::storyteller::commands::stripe_customer_portal::storyteller_open_customer_portal_cancel_plan_command::storyteller_open_customer_portal_cancel_plan_command; -use crate::services::storyteller::commands::stripe_customer_portal::storyteller_open_customer_portal_manage_plan_command::storyteller_open_customer_portal_manage_plan_command; -use crate::services::storyteller::commands::stripe_customer_portal::storyteller_open_customer_portal_switch_plan_command::storyteller_open_customer_portal_switch_plan_command; -use crate::services::storyteller::commands::stripe_customer_portal::storyteller_open_customer_portal_update_payment_method_command::storyteller_open_customer_portal_update_payment_method_command; -use crate::services::storyteller::state::storyteller_credential_manager::StorytellerCredentialManager; -use crate::services::worldlabs::commands::worldlabs_clear_credentials_command::worldlabs_clear_credentials_command; -use crate::services::worldlabs::commands::worldlabs_get_credential_info_command::worldlabs_get_credential_info_command; -use crate::services::worldlabs::commands::worldlabs_open_login_command::worldlabs_open_login_command; -use crate::services::worldlabs::commands::worldlabs_receive_bearer_command::worldlabs_receive_bearer_command; -use crate::services::worldlabs::state::worldlabs_bearer_bridge::WorldlabsBearerBridge; -use crate::services::worldlabs::state::worldlabs_credential_manager::WorldlabsCredentialManager; -use log::error; - -use crate::core::state::artcraft_usage_tracker::artcraft_usage_tracker::ArtcraftUsageTracker; -use tauri_plugin_dialog; -use tauri_plugin_http; -use tauri_plugin_log::Target; -use tauri_plugin_log::TargetKind; - -#[cfg_attr(mobile, tauri::mobile_entry_point)] -pub fn run() { - // NB: Tauri wants to install the logger itself, so we can't rely on the logger crate - // until the tauri runtime begins. - println!("Loading config..."); - let app_data_root = AppDataRoot::create_default().expect("data directory should be created"); - let app_data_root_2 = app_data_root.clone(); - - println!("Getting platform info..."); - let artcraft_platform_info = ArtcraftPlatformInfo::get(); - let artcraft_platform_info_2 = artcraft_platform_info.clone(); - - println!("Platform info: {:?}", artcraft_platform_info); - - println!("Loading app preferences..."); - let app_preferences = load_app_preferences_or_default(&app_data_root); - - let provider_credential_cache = crate::core::providers::credentials::provider_credential_loading_cache::ProviderCredentialLoadingCache::new(app_data_root.clone()); - let provider_credential_cache_2 = provider_credential_cache.clone(); - - // NB: tauri-plugin-http stores the credentials on disk, so we can defer to that for now. - // println!("Attempting to read existing artcraft credentials..."); - // let storyteller_creds_manager = StorytellerCredentialManager::initialize_from_disk_infallible(&app_data_root); - let storyteller_creds_manager = StorytellerCredentialManager::initialize_empty(&app_data_root); - let storyteller_creds_manager_2 = storyteller_creds_manager.clone(); - let storyteller_creds_manager_3 = storyteller_creds_manager.clone(); - - println!("Attempting to read existing sora credentials..."); - let sora_creds_manager = SoraCredentialManager::initialize_from_disk_infallible(&app_data_root); - let sora_creds_manager_2 = sora_creds_manager.clone(); - - // Other state - let sora_task_queue = SoraTaskQueue::new(); - let sora_task_queue_2 = sora_task_queue.clone(); - - let app_env_configs = AppEnvConfigs::load_from_filesystem(&app_data_root) - .expect("AppEnvConfigs should be loaded from disk"); - - let app_env_configs_2 = app_env_configs.clone(); - - let midjourney_creds_manager = MidjourneyCredentialManager::initialize_from_disk_infallible(&app_data_root); - let midjourney_creds_manager_2 = midjourney_creds_manager.clone(); - - let grok_creds_manager = GrokCredentialManager::initialize_from_disk_infallible(&app_data_root); - let grok_creds_manager_2 = grok_creds_manager.clone(); - - let grok_prompt_queue = GrokImagePromptQueue::new(); - let grok_prompt_queue_2 = grok_prompt_queue.clone(); - - let worldlabs_creds_manager = WorldlabsCredentialManager::initialize_from_disk_infallible(&app_data_root); - let worldlabs_creds_manager_2 = worldlabs_creds_manager.clone(); - - let worldlabs_bearer_bridge = WorldlabsBearerBridge::empty(); - let worldlabs_bearer_bridge_2 = worldlabs_bearer_bridge.clone(); - - let artcraft_usage_tracker = ArtcraftUsageTracker::new(); - let artcraft_usage_tracker_2 = artcraft_usage_tracker.clone(); - - println!("Initializing backend runtime..."); - - let builder = tauri::Builder::default() - .plugin(tauri_plugin_dialog::init()) - .plugin(tauri_plugin_http::init()) - .plugin(tauri_plugin_opener::init()) - .plugin(tauri_plugin_upload::init()) - .setup(move |app| { - // TODO(bt): This is broken on windows - // log_environment_details(); - - //if cfg!(debug_assertions) { - // app.handle().plugin( - // tauri_plugin_log::Builder::default() - // .level(log::LevelFilter::Info) - // .build(), - // )?; - //} - let app = app.handle().clone(); - let handle = app.clone(); - let root = app_data_root_2.clone(); - let env_config = app_env_configs_2.clone(); - let storyteller_creds = storyteller_creds_manager_2.clone(); - let sora_creds = sora_creds_manager_2.clone(); - let sora_tasks = sora_task_queue_2.clone(); - - tauri::async_runtime::block_on(async move { - let result = setup_main_window(&app).await; - - let result = handle_tauri_startup( - handle, - root, - env_config, - artcraft_platform_info_2, - artcraft_usage_tracker_2, - storyteller_creds, - sora_creds, - sora_tasks, - midjourney_creds_manager_2, - grok_creds_manager_2, - grok_prompt_queue_2, - worldlabs_bearer_bridge_2, - worldlabs_creds_manager_2, - provider_credential_cache_2, - ).await; - - if let Err(err) = result { - error!("Failed to handle Tauri startup: {:?}", err); - panic!("Failed to handle Tauri startup: {:?}", err); - } - }); - - Ok(()) - }) - .manage(app_data_root) - .manage(app_env_configs) - .manage(app_preferences) - .manage(artcraft_platform_info) - .manage(artcraft_usage_tracker) - .manage(grok_creds_manager) - .manage(grok_prompt_queue) - .manage(midjourney_creds_manager) - .manage(sora_creds_manager) - .manage(sora_task_queue) - .manage(storyteller_creds_manager_3) - .manage(worldlabs_bearer_bridge) - .manage(provider_credential_cache) - .manage(worldlabs_creds_manager); - - // TODO: Break this out into another module, because RustRover/IntelliJ lags with these macros. - // My first attempt at naively doing this didn't work because the macros can't find their codegen'd targets. - let builder = builder.invoke_handler(tauri::generate_handler![ - check_sora_session_command, - download_directory_reveal_command, - download_media_file_command, - download_url_command, - enqueue_image_bg_removal_command, - enqueue_image_to_3d_object_command, - enqueue_image_to_gaussian_command, - estimate_image_cost_command, - estimate_splat_cost_command, - estimate_video_cost_command, - estimate_audio_cost_command, - estimate_mesh_cost_command, - list_image_models_command, - list_video_models_command, - flip_image, - generate_image_command, - generate_video_command, - generate_splat_command, - generate_audio_command, - generate_mesh_command, - get_app_info_command, - get_app_preferences_command, - get_provider_order_command, - get_task_queue_command, - provider_clear_command, - provider_list_command, - provider_set_api_key_command, - grok_clear_credentials_command, - grok_get_credential_info_command, - grok_open_login_command, - load_without_cors_command, - mark_task_as_dismissed_command, - media_file_delete_command, - midjourney_clear_credentials_command, - midjourney_get_credential_info_command, - midjourney_open_login_command, - open_sora_login_command, - platform_info_command, - set_provider_order_command, - sora_get_credential_info_command, - sora_logout_command, - storyteller_get_credits_command, - storyteller_get_subscription_command, - storyteller_open_credits_purchase_command, - storyteller_open_customer_portal_cancel_plan_command, - storyteller_open_customer_portal_manage_plan_command, - storyteller_open_customer_portal_switch_plan_command, - storyteller_open_customer_portal_update_payment_method_command, - storyteller_open_subscription_purchase_command, - storyteller_purge_credentials_command, - tasks_nuke_all_command, - update_app_preferences_command, - worldlabs_clear_credentials_command, - worldlabs_get_credential_info_command, - worldlabs_open_login_command, - worldlabs_receive_bearer_command, - ]); - - builder.run(tauri::generate_context!("tauri.conf.json")) - .expect("error while running tauri application"); -} diff --git a/crates/desktop/artcraft/src/main.rs b/crates/desktop/artcraft/src/main.rs deleted file mode 100644 index 50008bc51b..0000000000 --- a/crates/desktop/artcraft/src/main.rs +++ /dev/null @@ -1,6 +0,0 @@ -// Prevents additional console window on Windows in release, DO NOT REMOVE!! -#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] - -fn main() { - artcraft_app_lib::run(); -} diff --git a/crates/desktop/artcraft/src/services/grok/commands/grok_clear_credentials_command.rs b/crates/desktop/artcraft/src/services/grok/commands/grok_clear_credentials_command.rs deleted file mode 100644 index 164a68c2da..0000000000 --- a/crates/desktop/artcraft/src/services/grok/commands/grok_clear_credentials_command.rs +++ /dev/null @@ -1,45 +0,0 @@ -use crate::core::commands::response::shorthand::{Response, SimpleResponse}; -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::services::grok::state::grok_credential_manager::GrokCredentialManager; -use crate::services::midjourney::state::midjourney_credential_manager::MidjourneyCredentialManager; -use errors::AnyhowResult; -use log::{error, info}; -use serde_derive::Deserialize; -use tauri::State; - -#[tauri::command] -pub async fn grok_clear_credentials_command( - root: State<'_, AppDataRoot>, - creds_manager: State<'_, GrokCredentialManager>, -) -> SimpleResponse { - info!("grok_clear_credentials_command called"); - - clear_creds(&root, &creds_manager) - .map_err(|err| { - error!("Error clearing creds: {:?}", err); - "error clearing creds" - })?; - - Ok(().into()) -} - -fn clear_creds( - root: &AppDataRoot, - creds: &GrokCredentialManager, -) -> AnyhowResult<()> { - - info!("Clearing credentials..."); - creds.clear_credentials()?; - - info!("Persisting to disk..."); - creds.persist_to_disk()?; - - let creds_path = root.credentials_dir().get_grok_state_path(); - - if creds_path.exists() { - info!("Removing from disk..."); - std::fs::remove_file(creds_path)?; - } - - Ok(()) -} diff --git a/crates/desktop/artcraft/src/services/grok/commands/grok_get_credential_info_command.rs b/crates/desktop/artcraft/src/services/grok/commands/grok_get_credential_info_command.rs deleted file mode 100644 index 673a1061ab..0000000000 --- a/crates/desktop/artcraft/src/services/grok/commands/grok_get_credential_info_command.rs +++ /dev/null @@ -1,54 +0,0 @@ -use crate::core::commands::response::shorthand::{Response, ResponseOrErrorMessage}; -use crate::core::commands::response::success_response_wrapper::SerializeMarker; -use crate::services::grok::state::grok_credential_manager::GrokCredentialManager; -use crate::services::midjourney::state::midjourney_credential_manager::MidjourneyCredentialManager; -use errors::AnyhowResult; -use log::{error, info}; -use serde_derive::Serialize; -use tauri::State; - -#[derive(Serialize)] -pub struct GrokGetCredentialInfoResponse { - pub maybe_email: Option, - pub can_clear_state: bool, -} - -impl SerializeMarker for GrokGetCredentialInfoResponse {} - -#[tauri::command] -pub async fn grok_get_credential_info_command( - creds_manager: State<'_, GrokCredentialManager>, -) -> ResponseOrErrorMessage { - info!("grok_get_credential_info_command called"); - - let info = get_info(&creds_manager) - .map_err(|err| { - error!("Error getting info: {:?}", err); - "error getting info" - })?; - - Ok(info.into()) -} - -fn get_info( - creds: &GrokCredentialManager, -) -> AnyhowResult { - let mut can_clear_state = true; - - let maybe_cookies = creds.maybe_copy_cookie_store()?; - let maybe_full_credentials = creds.maybe_copy_full_credentials()?; - - if maybe_cookies.is_none() && maybe_full_credentials.is_none() { - can_clear_state = false; - } - - let maybe_email = maybe_full_credentials - .map(|full_creds| full_creds.client_secrets.user_email) - .map(|maybe_email| maybe_email.map(|email| email.to_string())) - .flatten(); - - Ok(GrokGetCredentialInfoResponse { - maybe_email, - can_clear_state, - }) -} diff --git a/crates/desktop/artcraft/src/services/grok/commands/grok_open_login_command.rs b/crates/desktop/artcraft/src/services/grok/commands/grok_open_login_command.rs deleted file mode 100644 index 6d60b4155f..0000000000 --- a/crates/desktop/artcraft/src/services/grok/commands/grok_open_login_command.rs +++ /dev/null @@ -1,38 +0,0 @@ -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::services::grok::windows::grok_login_window::grok_login_window_open::grok_login_window_open; -use crate::services::midjourney::state::midjourney_credential_manager::MidjourneyCredentialManager; -use errors::AnyhowResult; -use log::{error, info}; -use tauri::{AppHandle, State}; -use crate::services::grok::state::grok_credential_manager::GrokCredentialManager; - -#[tauri::command] -pub async fn grok_open_login_command( - app: AppHandle, - app_data_root: State<'_, AppDataRoot>, - grok_creds_manager: State<'_, GrokCredentialManager>, -) -> Result { - info!("grok_open_login_command called"); - - do_open_login(&app, &app_data_root, &grok_creds_manager) - .await - .map_err(|err| { - error!("Error opening login: {:?}", err); - format!("Error opening login: {:?}", err) - })?; - - Ok("result".to_string()) -} - -async fn do_open_login( - app: &AppHandle, - app_data_root: &AppDataRoot, - grok_creds_manager: &GrokCredentialManager, -) -> AnyhowResult<()> { - info!("Building login window..."); - - grok_login_window_open(app, app_data_root, grok_creds_manager).await?; - - info!("Done."); - Ok(()) -} diff --git a/crates/desktop/artcraft/src/services/grok/commands/mod.rs b/crates/desktop/artcraft/src/services/grok/commands/mod.rs deleted file mode 100644 index 4162aedac7..0000000000 --- a/crates/desktop/artcraft/src/services/grok/commands/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub mod grok_open_login_command; -pub mod grok_get_credential_info_command; -pub mod grok_clear_credentials_command; diff --git a/crates/desktop/artcraft/src/services/grok/mod.rs b/crates/desktop/artcraft/src/services/grok/mod.rs deleted file mode 100644 index 285ecaa7e1..0000000000 --- a/crates/desktop/artcraft/src/services/grok/mod.rs +++ /dev/null @@ -1,5 +0,0 @@ -pub mod commands; -pub mod state; -pub mod threads; -pub mod util; -pub mod windows; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/services/grok/state/grok_credential_holder.rs b/crates/desktop/artcraft/src/services/grok/state/grok_credential_holder.rs deleted file mode 100644 index 2969a15894..0000000000 --- a/crates/desktop/artcraft/src/services/grok/state/grok_credential_holder.rs +++ /dev/null @@ -1,25 +0,0 @@ -use cookie_store::cookie_store::CookieStore; -use grok_consumer_client::credentials::grok_client_secrets::GrokClientSecrets; -use grok_consumer_client::credentials::grok_full_credentials::GrokFullCredentials; -use grok_consumer_client::credentials::grok_user_data::GrokUserData; - -#[derive(Clone)] -pub struct GrokCredentialHolder { - /// Directly off the Tauri browser session. - /// Read once, write to disk - /// The Grok client consumes a string-only form (rather than this cookie jar) - pub browser_cookies: Option, - - /// Full credentials. - /// NOT PERSISTED TO DISK. - pub grok_full_credentials: Option, -} - -impl GrokCredentialHolder { - pub fn empty() -> Self { - Self { - browser_cookies: None, - grok_full_credentials: None, - } - } -} diff --git a/crates/desktop/artcraft/src/services/grok/state/grok_credential_manager.rs b/crates/desktop/artcraft/src/services/grok/state/grok_credential_manager.rs deleted file mode 100644 index 1e7ea6548e..0000000000 --- a/crates/desktop/artcraft/src/services/grok/state/grok_credential_manager.rs +++ /dev/null @@ -1,216 +0,0 @@ -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::services::grok::state::grok_credential_holder::GrokCredentialHolder; -use crate::services::grok::state::grok_serializable_state::{GrokSerializableState, SERIALIZABLE_GROK_STATE_VERSION}; -use cookie_store::cookie_store::CookieStore; -use errors::AnyhowResult; -use grok_consumer_client::credentials::grok_client_secrets::GrokClientSecrets; -use grok_consumer_client::credentials::grok_cookies::GrokCookies; -use grok_consumer_client::credentials::grok_full_credentials::GrokFullCredentials; -use grok_consumer_client::credentials::grok_user_data::GrokUserData; -use log::{info, warn}; -use std::fs::read_to_string; -use std::sync::{Arc, RwLock}; - -#[derive(Clone)] -pub struct GrokCredentialManager { - // TODO: Put last write/last read timestamps on these. - credential_data: Arc>, - - //user_info: Arc>>, - app_data_root: AppDataRoot, -} - -impl GrokCredentialManager { - pub fn initialize_empty(app_data_root: &AppDataRoot) -> Self { - Self { - credential_data: Arc::new(RwLock::new(GrokCredentialHolder::empty())), - app_data_root: app_data_root.clone(), - } - } - - pub fn initialize_from_disk_infallible(app_data_root: &AppDataRoot) -> Self { - let mut credential_data; - - let result = GrokSerializableState::read_from_disk(app_data_root); - match result { - Err(err) => { - warn!("Failed to read grok state from disk: {:?}", err); - credential_data = Arc::new(RwLock::new(GrokCredentialHolder::empty())); - }, - Ok(None) => { - credential_data = Arc::new(RwLock::new(GrokCredentialHolder::empty())); - } - Ok(Some(state)) => { - let maybe_cookies = state.user_cookies - .map(|cookies| cookies.to_cookie_store()); - - let mut user_data = None; - if let Some(user_id) = state.user_id { - user_data = Some(GrokUserData::from_id_and_email(user_id, state.user_email)); - } - - credential_data = Arc::new(RwLock::new(GrokCredentialHolder { - browser_cookies: maybe_cookies, - grok_full_credentials: None, // NB: We don't want to keep this on disk. It goes stale. - })); - } - }; - - Self { - credential_data, - app_data_root: app_data_root.clone(), - } - } - - pub fn maybe_copy_cookie_store(&self) -> anyhow::Result> { - match self.credential_data.read() { - Err(err) => Err(anyhow::anyhow!("Failed to acquire write lock: {:?}", err)), - Ok(holder) => Ok(holder.browser_cookies.clone()), - } - } - - pub fn maybe_copy_cookie_header_string(&self) -> anyhow::Result> { - let maybe_cookies = self.maybe_copy_cookie_store()?; - let maybe_cookies = maybe_cookies.map(|cookies| { - cookies.to_cookie_string() - }); - Ok(maybe_cookies) - } - - pub fn maybe_copy_typed_cookies(&self) -> anyhow::Result> { - let maybe_cookies = self.maybe_copy_cookie_header_string()?; - let maybe_cookies = maybe_cookies.map(|cookies| { - GrokCookies::new(cookies) - }); - Ok(maybe_cookies) - } - - pub fn maybe_copy_full_credentials(&self) -> anyhow::Result> { - match self.credential_data.read() { - Err(err) => Err(anyhow::anyhow!("Failed to acquire read lock: {:?}", err)), - Ok(holder) => Ok(holder.grok_full_credentials.clone()), - } - } - - pub fn replace_cookie_store(&self, store: CookieStore) -> anyhow::Result<()> { - match self.credential_data.write() { - Err(err) => Err(anyhow::anyhow!("Failed to acquire write lock: {:?}", err)), - Ok(mut holder) => { - holder.browser_cookies = Some(store); - Ok(()) - } - } - } - - pub fn replace_full_credentials(&self, creds: GrokFullCredentials) -> anyhow::Result<()> { - match self.credential_data.write() { - Err(err) => Err(anyhow::anyhow!("Failed to acquire write lock: {:?}", err)), - Ok(mut holder) => { - holder.grok_full_credentials = Some(creds); - Ok(()) - } - } - } - - pub fn replace_client_secrets_only(&self, secrets: GrokClientSecrets) -> anyhow::Result<()> { - match self.credential_data.write() { - Err(err) => Err(anyhow::anyhow!("Failed to acquire write lock: {:?}", err)), - Ok(mut holder) => { - let mut maybe_full_creds = holder.grok_full_credentials.clone(); - if let Some(creds) = maybe_full_creds.as_mut() { - creds.client_secrets = secrets; - } else { - warn!("No existing credentials to replace secrets into."); - } - holder.grok_full_credentials = maybe_full_creds; - Ok(()) - } - } - } - - // NB: This is just a heuristic. We'll add better checks later. - pub fn do_task_polling(&self) -> anyhow::Result { - self.session_appears_active() - } - - // NB: This is just a heuristic. We'll add better checks later. - pub fn session_appears_active(&self) -> anyhow::Result { - let holder = match self.credential_data.read() { - Err(err) => return Err(anyhow::anyhow!("Failed to acquire read lock: {:?}", err)), - Ok(store) => store.clone(), - }; - - if holder.grok_full_credentials.is_some() { - return Ok(true); - } - - if holder.browser_cookies.is_none() { - return Ok(false); - } - - // TODO: Heuristic - Ok(true) - - //let cookies = match holder.browser_cookies.as_ref() { - // None => return Ok(false), - // Some(cookies) => cookies, - //}; - //// NB: We consider the session active if we have auth cookies and a user id. - ////let has_user_id = user_info.user_id.is_some(); - ////let maybe_has_auth_cookies = cookie_store_has_auth_cookies(&cookies); - //let maybe_has_auth_cookies = true; // TODO TODO TODO - fix this - //// Misc cookies without login cookies are ~1055 length - //// AUTH_I is ~1500 length - //// AUTH_R is ~500 length - //let maybe_has_big_enough_cookie = cookies.calculate_approx_cookie_character_length() > 2100; - //// TODO: Heuristic should count. - //// TODO: Consolidate with "login window thread" logic. - //// TODO: Check timestamp of last valid request. - //Ok((maybe_has_auth_cookies && maybe_has_big_enough_cookie && maybe_has_big_enough_cookie)) - } - - pub fn clear_credentials(&self) -> anyhow::Result<()> { - match self.credential_data.write() { - Err(err) => return Err(anyhow::anyhow!("Failed to acquire write lock: {:?}", err)), - Ok(mut store) => *store = GrokCredentialHolder::empty(), - } - Ok(()) - } - - pub fn persist_to_disk(&self) -> anyhow::Result<()> { - let creds = match self.credential_data.read() { - Err(err) => return Err(anyhow::anyhow!("Failed to acquire read lock: {:?}", err)), - Ok(store) => store.clone(), - }; - - let state = GrokSerializableState { - version: SERIALIZABLE_GROK_STATE_VERSION, - user_cookies: creds.browser_cookies - .as_ref() - .map(|cookies| cookies.to_serializable()), - user_id: creds.grok_full_credentials - .as_ref() - .map(|creds| creds.client_secrets.user_id.to_string()), - user_email: creds.grok_full_credentials - .as_ref() - .map(|data| data.client_secrets.user_email.as_ref()) - .flatten() - .map(|email| email.to_string()), - }; - - let path = self.app_data_root.credentials_dir().get_grok_state_path(); - let serialized = serde_json::to_string(&state)?; - - std::fs::write(path, serialized)?; - - // TODO: This is just for building the client and testing. - if let Some(cookies) = creds.browser_cookies.as_ref() { - let cookies_header = cookies.to_cookie_string(); - let path = self.app_data_root.credentials_dir().get_grok_cookies_path(); - std::fs::write(path, cookies_header)?; - } - - Ok(()) - } -} - diff --git a/crates/desktop/artcraft/src/services/grok/state/grok_image_prompt_queue.rs b/crates/desktop/artcraft/src/services/grok/state/grok_image_prompt_queue.rs deleted file mode 100644 index e3e71340df..0000000000 --- a/crates/desktop/artcraft/src/services/grok/state/grok_image_prompt_queue.rs +++ /dev/null @@ -1,80 +0,0 @@ -use crate::core::artcraft_error::ArtcraftError; -use log::error; -use std::collections::VecDeque; -use std::sync::{Arc, Mutex}; -use grok_consumer_client::requests::image_websocket::messages::websocket_client_message::ClientMessageAspectRatio; - -#[derive(Clone)] -pub struct GrokImagePromptQueue { - pub prompt_queue: Arc>>, -} - - -#[derive(Clone, Debug)] -pub struct PromptItem { - /// Local database task ID - pub task_id: String, - - /// Text prompt - pub prompt: String, - - /// The aspect ratio of the image - pub aspect_ratio: ClientMessageAspectRatio, -} - -impl GrokImagePromptQueue { - pub fn new() -> Self { - Self { - prompt_queue: Arc::new(Mutex::new(VecDeque::new())), - } - } - - pub fn enqueue(&self, prompt_item: PromptItem) -> Result<(), ArtcraftError> { - match self.prompt_queue.lock() { - Ok(mut queue) => { - queue.push_back(prompt_item); - Ok(()) - }, - Err(err) => { - error!("Error locking prompt queue: {:?}", err); - Err(ArtcraftError::MutexLockError) - }, - } - } - - pub fn dequeue(&self) -> Result, ArtcraftError> { - match self.prompt_queue.lock() { - Ok(mut queue) => { - Ok(queue.pop_front()) - }, - Err(err) => { - error!("Error locking prompt queue: {:?}", err); - Err(ArtcraftError::MutexLockError) - }, - } - } - - pub fn is_empty(&self) -> Result { - match self.prompt_queue.lock() { - Ok(mut queue) => { - Ok(queue.is_empty()) - }, - Err(err) => { - error!("Error locking prompt queue: {:?}", err); - Err(ArtcraftError::MutexLockError) - }, - } - } - - pub fn len(&self) -> Result { - match self.prompt_queue.lock() { - Ok(mut queue) => { - Ok(queue.len()) - }, - Err(err) => { - error!("Error locking prompt queue: {:?}", err); - Err(ArtcraftError::MutexLockError) - }, - } - } -} diff --git a/crates/desktop/artcraft/src/services/grok/state/grok_serializable_state.rs b/crates/desktop/artcraft/src/services/grok/state/grok_serializable_state.rs deleted file mode 100644 index 4379a4c1f9..0000000000 --- a/crates/desktop/artcraft/src/services/grok/state/grok_serializable_state.rs +++ /dev/null @@ -1,43 +0,0 @@ -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use cookie_store::serialized_cookie_store::SerializableCookieStore; -use serde_derive::{Deserialize, Serialize}; -use std::fs::read_to_string; - -/// History -/// v1 - initial -pub (super) const SERIALIZABLE_GROK_STATE_VERSION: u32 = 1; - -/// We only need to serialize Grok cookies. -/// Most of the other state (verification_token, etc.) can be pulled at runtime. -/// We will cache the `user_id` and `user_email`. -#[derive(Serialize, Deserialize)] -pub (super) struct GrokSerializableState { - pub (super) version: u32, - - #[serde(skip_serializing_if = "Option::is_none")] - pub (super) user_cookies: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - pub (super) user_id: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - pub (super) user_email: Option, -} - -impl GrokSerializableState { - pub fn read_from_disk(root: &AppDataRoot) -> anyhow::Result> { - let state_path = root.credentials_dir().get_grok_state_path(); - - if !state_path.exists() { - return Ok(None); - } - - let contents = read_to_string(&state_path)? - .trim() - .to_string(); - - let state: GrokSerializableState = serde_json::from_str(&contents)?; - - Ok(Some(state)) - } -} diff --git a/crates/desktop/artcraft/src/services/grok/state/grok_websocket_manager.rs b/crates/desktop/artcraft/src/services/grok/state/grok_websocket_manager.rs deleted file mode 100644 index ff41ef8aad..0000000000 --- a/crates/desktop/artcraft/src/services/grok/state/grok_websocket_manager.rs +++ /dev/null @@ -1,62 +0,0 @@ -use crate::core::artcraft_error::ArtcraftError; -use errors::AnyhowResult; -use grok_consumer_client::requests::image_websocket::grok_wrapped_websocket::GrokWrappedWebsocket; -use log::error; -use std::sync::{Arc, RwLock}; - - -/// NB: This is inefficient because the websockets are locked at two layers. -/// Should be fine for our performance needs, though. -#[derive(Clone)] -pub struct GrokWebsocketManager { - //websocket: Arc>>, - websocket: Arc>>, -} - -impl GrokWebsocketManager { - pub fn new() -> Self { - Self { - websocket: Arc::new(RwLock::new(None)), - } - } - - pub fn set_websocket(&self, websocket: GrokWrappedWebsocket) -> Result<(), ArtcraftError> { - match self.websocket.write() { - Ok(mut guard) => { - //*guard = Some(websocket); - *guard = Some(()); - Ok(()) - } - Err(err) => { - error!("Error writing locked websocket: {}", err); - Err(ArtcraftError::RwLockWriteError) - } - } - } - - pub fn clear_websocket(&self) -> Result<(), ArtcraftError> { - match self.websocket.write() { - Ok(mut guard) => { - *guard = None; - Ok(()) - } - Err(err) => { - error!("Error writing locked websocket: {}", err); - Err(ArtcraftError::RwLockWriteError) - } - } - } - - pub fn grab_websocket(&self) -> Result, ArtcraftError> { - match self.websocket.read() { - Ok(guard) => { - //Ok(guard.clone()) - Ok(None) - } - Err(err) => { - error!("Error reading locked websocket: {}", err); - Err(ArtcraftError::RwLockReadError) - } - } - } -} diff --git a/crates/desktop/artcraft/src/services/grok/state/mod.rs b/crates/desktop/artcraft/src/services/grok/state/mod.rs deleted file mode 100644 index 5b557e4567..0000000000 --- a/crates/desktop/artcraft/src/services/grok/state/mod.rs +++ /dev/null @@ -1,7 +0,0 @@ -pub mod grok_credential_manager; -pub mod grok_image_prompt_queue; -pub mod grok_serializable_state; -pub mod grok_websocket_manager; - -// Private -mod grok_credential_holder; diff --git a/crates/desktop/artcraft/src/services/grok/threads/grok_image_websocket_thread/grok_image_websocket_thread.rs b/crates/desktop/artcraft/src/services/grok/threads/grok_image_websocket_thread/grok_image_websocket_thread.rs deleted file mode 100644 index 178002053d..0000000000 --- a/crates/desktop/artcraft/src/services/grok/threads/grok_image_websocket_thread/grok_image_websocket_thread.rs +++ /dev/null @@ -1,351 +0,0 @@ -use crate::core::events::basic_sendable_event_trait::BasicSendableEvent; -use crate::core::events::functional_events::text_to_image_generation_complete_event::{GeneratedImage, TextToImageGenerationCompleteEvent}; -use crate::core::events::generation_events::common::{GenerationAction, GenerationServiceProvider}; -use crate::core::events::generation_events::generation_complete_event::GenerationCompleteEvent; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::core::state::task_database::TaskDatabase; -use crate::core::utils::download_url_to_temp_dir::download_url_to_temp_dir; -use crate::core::utils::task_database_pending_statuses::TASK_DATABASE_PENDING_STATUSES; -use crate::services::grok::state::grok_credential_manager::GrokCredentialManager; -use crate::services::grok::state::grok_image_prompt_queue::{GrokImagePromptQueue, PromptItem}; -use crate::services::storyteller::state::storyteller_credential_manager::StorytellerCredentialManager; -use anyhow::anyhow; -use artcraft_api_defs::prompts::create_prompt::CreatePromptRequest; -use artcraft_api_defs::utils::media_links_to_thumbnail_template::media_links_to_thumbnail_template; -use enums::common::generation_provider::GenerationProvider; -use enums::common::generation::common_model_type::CommonModelType; -use enums::tauri::tasks::task_media_file_class::TaskMediaFileClass; -use errors::AnyhowResult; -use grok_consumer_client::recipes::prompt_websocket_image_with_retry::{prompt_websocket_image_with_retry, PromptWebsocketImageWithRetryArgs}; -use grok_consumer_client::requests::image_websocket::create_listen_websocket::{create_listen_websocket, CreateListenWebsocketArgs}; -use grok_consumer_client::requests::image_websocket::grok_websocket::GrokWebsocket; -use grok_consumer_client::requests::image_websocket::grok_wrapped_websocket::GrokWrappedWebsocket; -use grok_consumer_client::requests::image_websocket::listen_for_websocket_images::{listen_for_websocket_images, ImageResults, ListenForWebsocketImagesArgs}; -use grok_consumer_client::requests::image_websocket::messages::websocket_client_message::ClientMessageAspectRatio; -use grok_consumer_client::requests::image_websocket::prompt_websocket_image::{prompt_websocket_image, PromptWebsocketImageArgs}; -use uuid_utils::uuid::generate_random_uuid; -use log::{error, info, warn}; -use sqlite_tasks::queries::get_task_by_provider_and_provider_job_id::{get_task_by_provider_and_provider_job_id, GetTaskByProviderAndProviderJobIdArgs}; -use sqlite_tasks::queries::list_tasks_by_provider_and_status::{list_tasks_by_provider_and_status, ListTasksByProviderAndStatusArgs}; -use sqlite_tasks::queries::task::Task; -use sqlite_tasks::queries::update_successful_task_status_with_metadata::{update_successful_task_status_with_metadata, UpdateSuccessfulTaskArgs}; -use sqlite_tasks::queries::update_successful_task_status_with_metadata_by_provider::{update_successful_task_status_with_metadata_by_provider, UpdateSuccessfulTaskByProviderArgs}; -use std::time::Duration; -use artcraft_client::credentials::storyteller_credential_set::StorytellerCredentialSet; -use artcraft_client::endpoints::media_files::get_media_file::get_media_file; -use artcraft_client::endpoints::media_files::list_batch_generated_redux_media_files::list_batch_generated_redux_media_files; -use artcraft_client::endpoints::media_files::upload_image_media_file_from_file::{upload_image_media_file_from_file, UploadImageFromFileArgs, UploadImageMediaFileSuccessResponse}; -use artcraft_client::endpoints::prompts::create_prompt::create_prompt; -use artcraft_client::error::api_error::ApiError; -use artcraft_client::error::storyteller_error::StorytellerError; -use tauri::AppHandle; -use tokens::tokens::batch_generations::BatchGenerationToken; -use tokens::tokens::sqlite::tasks::TaskId; - -pub async fn grok_image_websocket_thread( - app_handle: AppHandle, - app_env_configs: AppEnvConfigs, - app_data_root: AppDataRoot, - task_database: TaskDatabase, - creds: GrokCredentialManager, - prompt_queue: GrokImagePromptQueue, - storyteller_creds_manager: StorytellerCredentialManager, -) -> ! { - loop { - let res = inner_loop( - &app_handle, - &app_env_configs, - &app_data_root, - &task_database, - &creds, - &prompt_queue, - &storyteller_creds_manager, - ).await; - if let Err(err) = res { - error!("An error occurred: {:?}", err); - } - // NB: Only sleep if an error occurs. - tokio::time::sleep(std::time::Duration::from_millis(30_000)).await; - } -} - -async fn inner_loop( - app_handle: &AppHandle, - app_env_configs: &AppEnvConfigs, - app_data_root: &AppDataRoot, - task_database: &TaskDatabase, - grok_creds: &GrokCredentialManager, - prompt_queue: &GrokImagePromptQueue, - storyteller_creds_manager: &StorytellerCredentialManager, -) -> AnyhowResult<()> { - - loop { - if !grok_creds.do_task_polling()? { - tokio::time::sleep(std::time::Duration::from_millis(10_000)).await; - continue; - } - - let maybe_cookies = grok_creds.maybe_copy_typed_cookies()?; - - //let maybe_cookie_header = grok_creds.maybe_copy_cookie_header_string()?; - - let cookies = match maybe_cookies { - Some(cookies) => cookies, - None => { - tokio::time::sleep(std::time::Duration::from_millis(10_000)).await; - continue; - }, - }; - - //let cookie_header = match maybe_cookie_header { - // Some(cookie_header) => cookie_header, - // None => { - // tokio::time::sleep(std::time::Duration::from_millis(10_000)).await; - // continue; - // } - //}; - - let websocket = create_listen_websocket(CreateListenWebsocketArgs { - cookies: cookies.as_str(), - }).await?; - - let mut websocket = GrokWebsocket::new(websocket); - - loop { - let maybe_prompt = prompt_queue.dequeue()?; - - let prompt_item = match maybe_prompt { - Some(prompt_item) => prompt_item, - None => { - tokio::time::sleep(std::time::Duration::from_millis(1_000)).await; - continue; - } - }; - - info!("Prompt received over in-memory queue. Prompting Grok websocket: {}", prompt_item.prompt); - - let result = prompt_websocket_image_with_retry(PromptWebsocketImageWithRetryArgs { - websocket: &mut websocket, - prompt: &prompt_item.prompt, - aspect_ratio: prompt_item.aspect_ratio, - cookies: &cookies, - }).await?; - - if let Some(new_websocket) = result.maybe_new_websocket { - info!("Replacing websocket with new one..."); - websocket = new_websocket; - } - - let images = listen_for_websocket_images(ListenForWebsocketImagesArgs { - websocket: &mut websocket, - timeout: Duration::from_millis(30_000), - }).await?; - - upload_images_to_storyteller( - &app_handle, - &app_env_configs, - &app_data_root, - &task_database, - &storyteller_creds_manager, - &prompt_item, - &images, - ).await? - } - - } -} - -async fn upload_images_to_storyteller( - app_handle: &AppHandle, - app_env_configs: &AppEnvConfigs, - app_data_root: &AppDataRoot, - task_database: &TaskDatabase, - storyteller_creds_manager: &StorytellerCredentialManager, - prompt_item: &PromptItem, - images: &ImageResults, -) -> AnyhowResult<()> { - - loop { - let storyteller_creds = match storyteller_creds_manager.get_credentials()? { - Some(creds) => creds, - None => { - error!("No Storyteller credentials found. Cannot proceed with Grok polling."); - tokio::time::sleep(std::time::Duration::from_millis(5_000)).await; - continue; - } - }; - - let prompt = prompt_item.prompt.trim().to_string(); - - let request = CreatePromptRequest { - uuid_idempotency_token: generate_random_uuid(), - positive_prompt: Some(prompt), - negative_prompt: None, - model_type: Some(CommonModelType::GrokImage), - generation_provider: Some(GenerationProvider::Grok), - maybe_generation_mode: None, - maybe_aspect_ratio: None, - maybe_resolution: None, - maybe_batch_count: None, - maybe_generate_audio: None, - maybe_duration_seconds: None, }; - - let prompt_response = create_prompt( - &app_env_configs.storyteller_host, - Some(&storyteller_creds), - request - ).await?; - - info!("Created prompt: {:?}", &prompt_response.prompt_token); - - // TODO: Move this from clientside to the backend. - // The first upload should produce a batch token that we can reuse. - let batch_token = BatchGenerationToken::generate(); - - let mut maybe_primary_media_file_token = None; - - for (i, image) in images.images.iter().enumerate() { - loop { - let url = image.url.to_string(); - let file = download_url_to_temp_dir(&url, app_data_root).await?; - - info!("Uploading image {} of {} ...", i, images.images.len()); - - let result = upload_image_media_file_from_file(UploadImageFromFileArgs { - api_host: &app_env_configs.storyteller_host, - maybe_creds: Some(&storyteller_creds), - path: file.path(), - is_intermediate_system_file: false, - maybe_prompt_token: Some(&prompt_response.prompt_token), - maybe_batch_token: Some(&batch_token), - maybe_generation_provider: Some(GenerationProvider::Grok), - }).await; - - match result { - Ok(uploaded) => { - if maybe_primary_media_file_token.is_none() { - maybe_primary_media_file_token = Some(uploaded.media_file_token); - } - break; // Break retry loop. - } - Err(StorytellerError::Api(ApiError::TooManyRequests(_))) => { - tokio::time::sleep(std::time::Duration::from_millis(10_000)).await; - continue; - } - Err(err) => { - error!("Error uploading image: {}", err); - break; - } - } - } // Retry on 429s, etc. - } - - let event = GenerationCompleteEvent { - //media_file_token: result.media_file_token, - action: Some(GenerationAction::GenerateImage), - service: GenerationServiceProvider::Grok, - model: None, - }; - - event.send_infallible(&app_handle); - - let task = get_task_by_provider_and_provider_job_id(GetTaskByProviderAndProviderJobIdArgs { - db: task_database.get_connection(), - provider: GenerationProvider::Grok, - provider_job_id: &prompt_item.task_id, - }).await?; - - let task = match task { - Some(task) => task, - None => { - warn!("Couldn't find local sqlite task by id: {}", &prompt_item.task_id); - return Ok(()); - } - }; - - let mut maybe_cdn_url = None; - let mut maybe_thumbnail_url_template = None; - - if let Some(media_file_token) = maybe_primary_media_file_token.as_ref() { - info!("Looking up file to grab CDN and thumbnail URLs: {:?} ...", media_file_token); - - let lookup_result = get_media_file( - &app_env_configs.storyteller_host, - media_file_token, - ).await; - match lookup_result { - Ok(response) => { - maybe_cdn_url = Some(response.media_file.media_links.cdn_url.to_string()); - maybe_thumbnail_url_template = media_links_to_thumbnail_template(&response.media_file.media_links) - .map(|s| s.to_string()); - } - Err(err) => { - error!("Failed to look up media file after upload: {:?} (failing open)", err); - } - } - } - - let updated = update_successful_task_status_with_metadata(UpdateSuccessfulTaskArgs { - db: task_database.get_connection(), - task_id: &task.id, - maybe_batch_token: Some(&batch_token), - maybe_primary_media_file_token: maybe_primary_media_file_token.as_ref(), - maybe_primary_media_file_class: Some(TaskMediaFileClass::Image), - maybe_primary_media_file_thumbnail_url_template: maybe_thumbnail_url_template.as_deref(), - maybe_primary_media_file_cdn_url: maybe_cdn_url.as_deref(), - }).await?; - - if !updated { - return Ok(()); // If anything breaks with queries, don't spam events. - } - - send_frontend_ui_update( - app_handle, - app_env_configs, - Some(&storyteller_creds), - &task, - &batch_token, - ).await?; - - return Ok(()) - } -} - -async fn send_frontend_ui_update( - app: &AppHandle, - app_env_configs: &AppEnvConfigs, - maybe_creds: Option<&StorytellerCredentialSet>, - task: &Task, - batch_token: &BatchGenerationToken, -) -> AnyhowResult<()> { - - let result = list_batch_generated_redux_media_files( - &app_env_configs.storyteller_host, - maybe_creds, - batch_token, - ).await?; - - if result.media_files.is_empty() { - return Err(anyhow!("No media files found for batch token: {}", batch_token)); - } - - let media_files = result.media_files - .into_iter() - .map(|file| GeneratedImage { - media_token: file.token, - cdn_url: file.media_links.cdn_url, - maybe_thumbnail_template: file.media_links.maybe_thumbnail_template, - }) - .collect(); - - let event = TextToImageGenerationCompleteEvent { - generated_images: media_files, - maybe_frontend_subscriber_id: task.frontend_subscriber_id.clone(), - maybe_frontend_subscriber_payload: task.frontend_subscriber_payload.clone(), - }; - - event.send_infallible(app); - - Ok(()) -} diff --git a/crates/desktop/artcraft/src/services/grok/threads/grok_image_websocket_thread/mod.rs b/crates/desktop/artcraft/src/services/grok/threads/grok_image_websocket_thread/mod.rs deleted file mode 100644 index 5021bcae7c..0000000000 --- a/crates/desktop/artcraft/src/services/grok/threads/grok_image_websocket_thread/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod grok_image_websocket_thread; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/services/grok/threads/grok_video_task_polling/grok_video_task_polling_thread.rs b/crates/desktop/artcraft/src/services/grok/threads/grok_video_task_polling/grok_video_task_polling_thread.rs deleted file mode 100644 index c622cfde68..0000000000 --- a/crates/desktop/artcraft/src/services/grok/threads/grok_video_task_polling/grok_video_task_polling_thread.rs +++ /dev/null @@ -1,368 +0,0 @@ -use crate::core::events::basic_sendable_event_trait::BasicSendableEvent; -use crate::core::events::generation_events::common::{GenerationAction, GenerationServiceProvider}; -use crate::core::events::generation_events::generation_complete_event::GenerationCompleteEvent; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::core::state::data_dir::trait_data_subdir::DataSubdir; -use crate::core::state::task_database::TaskDatabase; -use crate::core::utils::task_database_pending_statuses::TASK_DATABASE_PENDING_STATUSES; -use crate::services::grok::state::grok_credential_manager::GrokCredentialManager; -use crate::services::grok::util::get_or_upgrade_grok_full_credentials::get_or_update_grok_full_credentials; -use crate::services::midjourney::state::midjourney_credential_manager::MidjourneyCredentialManager; -use crate::services::midjourney::utils::download_midjourney_image::download_midjourney_image; -use crate::services::storyteller::state::storyteller_credential_manager::StorytellerCredentialManager; -use artcraft_api_defs::prompts::create_prompt::CreatePromptRequest; -use artcraft_api_defs::utils::media_links_to_thumbnail_template::media_links_to_thumbnail_template; -use cookie_store::cookie_store::CookieStore; -use enums::common::generation_provider::GenerationProvider; -use enums::common::generation::common_model_type::CommonModelType; -use enums::tauri::tasks::task_media_file_class::TaskMediaFileClass; -use errors::AnyhowResult; -use grok_consumer_client::credentials::grok_full_credentials::GrokFullCredentials; -use grok_consumer_client::error::grok_error::GrokError; -use grok_consumer_client::requests::download_video_file::download_video_file::{download_video_file, DownloadVideoFileArgs}; -use grok_consumer_client::requests::download_video_file::grok_download_video::GrokDownloadVideo; -use grok_consumer_client::requests::media_posts::list_media_posts::grok_list_media_posts::{GrokMediaPostList, GrokMediaPostListRequest, VideoData}; -use uuid_utils::uuid::generate_random_uuid; -use log::{error, info}; -use midjourney_client::client::midjourney_hostname::MidjourneyHostname; -use midjourney_client::credentials::midjourney_user_id::MidjourneyUserId; -use midjourney_client::endpoints::imagine::{imagine, ImagineItem, ImagineRequest, MidjourneyJobType}; -use midjourney_client::utils::get_image_url::get_image_url; -use midjourney_client::utils::image_downloader_client::ImageDownloaderClient; -use once_cell::sync::Lazy; -use sqlite_tasks::queries::list_tasks_by_provider_and_status::{list_tasks_by_provider_and_status, ListTasksByProviderAndStatusArgs, TaskList}; -use sqlite_tasks::queries::task::Task; -use sqlite_tasks::queries::update_successful_task_status_with_metadata::{update_successful_task_status_with_metadata, UpdateSuccessfulTaskArgs}; -use sqlite_tasks::queries::update_task_status::{update_task_status, UpdateTaskArgs}; -use std::collections::{HashMap, HashSet}; -use std::fs::File; -use std::io::Write; -use std::path::PathBuf; -use std::time::Duration; -use artcraft_client::credentials::storyteller_credential_set::StorytellerCredentialSet; -use artcraft_client::endpoints::media_files::get_media_file::get_media_file; -use artcraft_client::endpoints::media_files::upload_image_media_file_from_file::{upload_image_media_file_from_file, UploadImageFromFileArgs}; -use artcraft_client::endpoints::media_files::upload_video_media_file_from_file::{upload_video_media_file_from_file, UploadVideoFromFileArgs}; -use artcraft_client::endpoints::prompts::create_prompt::create_prompt; -use artcraft_client::error::api_error::ApiError; -use artcraft_client::error::storyteller_error::StorytellerError; -use tauri::AppHandle; -use tokens::tokens::batch_generations::BatchGenerationToken; -use url::Url; - -pub async fn grok_video_task_polling_thread( - app_handle: AppHandle, - app_env_configs: AppEnvConfigs, - app_data_root: AppDataRoot, - task_database: TaskDatabase, - creds: GrokCredentialManager, - storyteller_creds_manager: StorytellerCredentialManager, -) -> ! { - loop { - let res = polling_loop( - &app_handle, - &app_env_configs, - &app_data_root, - &task_database, - &creds, - &storyteller_creds_manager, - ).await; - if let Err(err) = res { - error!("An error occurred: {:?}", err); - } - // NB: Only sleep if an error occurs. - tokio::time::sleep(std::time::Duration::from_millis(30_000)).await; - } -} - -async fn polling_loop( - app_handle: &AppHandle, - app_env_configs: &AppEnvConfigs, - app_data_root: &AppDataRoot, - task_database: &TaskDatabase, - grok_creds: &GrokCredentialManager, - storyteller_creds_manager: &StorytellerCredentialManager, -) -> AnyhowResult<()> { - loop { - if !grok_creds.do_task_polling()? { - tokio::time::sleep(std::time::Duration::from_millis(10_000)).await; - continue; - } - - // TODO: Graceful wait, fix this long function body - let storyteller_creds = match storyteller_creds_manager.get_credentials()? { - Some(creds) => creds, - None => { - error!("No Storyteller credentials found. Cannot proceed with Grok polling."); - tokio::time::sleep(std::time::Duration::from_millis(5_000)).await; - continue; - } - }; - - let grok_full_creds = match get_or_update_grok_full_credentials(&grok_creds).await { - Ok(creds) => creds, - Err(err) => { - info!("No full grok credentials: {:?}", err); - tokio::time::sleep(std::time::Duration::from_millis(30_000)).await; - continue; - } - }; - - let local_tasks = list_tasks_by_provider_and_status(ListTasksByProviderAndStatusArgs { - db: task_database.get_connection(), - provider: GenerationProvider::Grok, - task_statuses: &TASK_DATABASE_PENDING_STATUSES, - }).await?; - - poll_grok_tasks( - app_handle, - app_env_configs, - app_data_root, - task_database, - &grok_full_creds, - &storyteller_creds, - local_tasks, - ).await?; - - tokio::time::sleep(std::time::Duration::from_millis(2_000)).await; - } -} - -async fn poll_grok_tasks( - app_handle: &AppHandle, - app_env_configs: &AppEnvConfigs, - app_data_root: &AppDataRoot, - task_database: &TaskDatabase, - grok_full_creds: &GrokFullCredentials, - storyteller_creds: &StorytellerCredentialSet, - local_tasks: TaskList, -) -> AnyhowResult<()> { - let local_tasks = local_tasks.tasks; - - if local_tasks.is_empty() { - return Ok(()) - } - - info!("Grok tasks waiting: {:?}", local_tasks.len()); - - // Map of Grok Post ID to Local Task. - let local_tasks_by_grok_post_id = local_tasks.iter() - .filter_map(|task| { - if let Some(provider_job_id) = &task.provider_job_id { - Some((provider_job_id.clone(), task.clone())) - } else { - None - } - }) - .collect::>(); - - let list_media_request = GrokMediaPostListRequest { - cookie: grok_full_creds.cookies.as_str(), - cursor: None, - request_timeout: Some(Duration::from_millis(20_000)), - }; - - let list_result = list_media_request.send().await?; - - let grok_posts = list_result.posts; - - let grok_video_posts_by_id = { - let mut hash = HashMap::new(); - for post in grok_posts.iter() { - if let Some(video_data) = &post.video_data { - hash.insert(post.post_id.to_string(), video_data.clone()); - } - } - hash - }; - - for (grok_post_id, local_task) in local_tasks_by_grok_post_id.iter() { - // TODO: Copy prompt from this. - let grok_video_data = match grok_video_posts_by_id.get(grok_post_id) { - Some(video_data) => video_data, - None => continue, - }; - - upload_grok_video( - &app_handle, - &app_env_configs, - app_data_root, - task_database, - &storyteller_creds, - grok_full_creds, - grok_post_id, - &local_task, - grok_video_data - ).await?; - - tokio::time::sleep(std::time::Duration::from_millis(2_000)).await; - } - - tokio::time::sleep(std::time::Duration::from_millis(60_000)).await; - - Ok(()) -} - -async fn upload_grok_video( - app_handle: &AppHandle, - app_env_configs: &AppEnvConfigs, - app_data_root: &AppDataRoot, - task_database: &TaskDatabase, - storyteller_creds: &StorytellerCredentialSet, - grok_full_creds: &GrokFullCredentials, - grok_post_id: &String, - local_task: &Task, - grok_video_post: &VideoData -) -> AnyhowResult<()> { - - let request = CreatePromptRequest { - uuid_idempotency_token: generate_random_uuid(), - positive_prompt: grok_video_post.prompt.clone(), - negative_prompt: None, - model_type: Some(CommonModelType::GrokVideo), - generation_provider: Some(GenerationProvider::Grok), - maybe_generation_mode: None, - maybe_aspect_ratio: None, - maybe_resolution: None, - maybe_batch_count: None, - maybe_generate_audio: None, - maybe_duration_seconds: None, }; - - let prompt_response = create_prompt( - &app_env_configs.storyteller_host, - Some(storyteller_creds), - request - ).await?; - - info!("Created prompt: {:?}", &prompt_response.prompt_token); - - let mut maybe_primary_media_file_token = None; - - info!("Downloading generated Grok video ..."); - - let tempdir = app_data_root.temp_dir().path(); - let download_filename = format!("{}.mp4", grok_post_id); - let download_path = tempdir.join(download_filename); - - let download = GrokDownloadVideo { - cookies: grok_full_creds.cookies.as_str(), - user_id: grok_full_creds.get_user_id_ref(), - file_id: &grok_video_post.file_id, - request_timeout: None, - }; - - download.download_to_path(&download_path).await?; - - let mut wait_delay = 0; - - loop { - info!("Uploading to backend..."); - - // TODO: media_files.origin_category - // TODO: media_files.maybe_prompt_token - // TODO: media_files.maybe_generation_provider - // TODO: media_files.maybe_origin_model_type - // TODO: media_files.maybe_origin_model_token (sref?) - // TODO: media_files.maybe_batch_token - // TODO: media_files.is_user_upload - - // TODO: batch_generations.token - // TODO: batch_generations.entity_type - // TODO: batch_generations.entity_token - - let result = upload_video_media_file_from_file(UploadVideoFromFileArgs { - api_host: &app_env_configs.storyteller_host, - maybe_creds: Some(&storyteller_creds), - path: &download_path, - maybe_prompt_token: Some(&prompt_response.prompt_token), - maybe_generation_provider: Some(GenerationProvider::Grok), - }).await; - - match result { - Ok(result) => { - info!("Successfully uploaded to backend: {:?}", result.media_file_token); - if maybe_primary_media_file_token.is_none() { - maybe_primary_media_file_token = Some(result.media_file_token); - } - break; - }, - Err(ApiError::TooManyRequests(_)) => { - error!("Too many requests, retrying upload after delay..."); - // If we hit a rate limit, we can retry after a short delay. - wait_delay += 10; - if wait_delay > 60 { - wait_delay = 60; - } - tokio::time::sleep(std::time::Duration::from_secs(wait_delay)).await; - continue; // Retry the upload. - } - Err(err) => { - error!("Failed to upload to backend: {:?}", err); - return Err(err.into()) - }, - } - } // End loop - - let mut maybe_cdn_url = None; - let mut maybe_thumbnail_url_template = None; - - if let Some(media_file_token) = maybe_primary_media_file_token.as_ref() { - info!("Looking up file to grab CDN and thumbnail URLs: {:?} ...", media_file_token); - - let lookup_result = get_media_file( - &app_env_configs.storyteller_host, - media_file_token, - ).await; - match lookup_result { - Ok(response) => { - maybe_cdn_url = Some(response.media_file.media_links.cdn_url.to_string()); - maybe_thumbnail_url_template = media_links_to_thumbnail_template(&response.media_file.media_links) - .map(|s| s.to_string()); - } - Err(err) => { - error!("Failed to look up media file after upload: {:?} (failing open)", err); - } - } - } - - let updated = update_successful_task_status_with_metadata(UpdateSuccessfulTaskArgs { - db: task_database.get_connection(), - task_id: &local_task.id, - maybe_batch_token: None, - maybe_primary_media_file_token: maybe_primary_media_file_token.as_ref(), - maybe_primary_media_file_class: Some(TaskMediaFileClass::Video), - maybe_primary_media_file_thumbnail_url_template: maybe_thumbnail_url_template.as_deref(), - maybe_primary_media_file_cdn_url: maybe_cdn_url.as_deref(), - }).await?; - - if !updated { - return Ok(()); // If anything breaks with queries, don't spam events. - } - - let event = GenerationCompleteEvent { - //media_file_token: result.media_file_token, - action: Some(GenerationAction::GenerateVideo), - service: GenerationServiceProvider::Grok, - model: None, - }; - - if let Err(err) = event.send(&app_handle) { - error!("Failed to send GenerationCompleteEvent: {:?}", err); // Fail open - } - - //let result = maybe_handle_text_to_image_complete_event( - // app_handle, - // app_env_configs, - // Some(storyteller_creds), - // local_task, - // &batch_token, - //).await; - - //if let Err(err) = result { - // error!("Failed to send text-to-image complete event: {:?}", err); - //} - - Ok(()) -} - diff --git a/crates/desktop/artcraft/src/services/grok/threads/grok_video_task_polling/mod.rs b/crates/desktop/artcraft/src/services/grok/threads/grok_video_task_polling/mod.rs deleted file mode 100644 index 8a7f640414..0000000000 --- a/crates/desktop/artcraft/src/services/grok/threads/grok_video_task_polling/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod grok_video_task_polling_thread; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/services/grok/threads/mod.rs b/crates/desktop/artcraft/src/services/grok/threads/mod.rs deleted file mode 100644 index 07dab82921..0000000000 --- a/crates/desktop/artcraft/src/services/grok/threads/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod grok_video_task_polling; -pub mod grok_image_websocket_thread; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/services/grok/util/get_or_upgrade_grok_full_credentials.rs b/crates/desktop/artcraft/src/services/grok/util/get_or_upgrade_grok_full_credentials.rs deleted file mode 100644 index ab4b7ce415..0000000000 --- a/crates/desktop/artcraft/src/services/grok/util/get_or_upgrade_grok_full_credentials.rs +++ /dev/null @@ -1,49 +0,0 @@ -use crate::core::commands::enqueue::generate_error::GenerateError; -use crate::core::events::functional_events::show_provider_login_modal_event::ShowProviderLoginModalEvent; -use crate::services::grok::state::grok_credential_manager::GrokCredentialManager; -use grok_consumer_client::credentials::grok_cookies::GrokCookies; -use grok_consumer_client::credentials::grok_full_credentials::GrokFullCredentials; -use grok_consumer_client::error::grok_client_error::GrokClientError; -use grok_consumer_client::error::grok_error::GrokError; -use grok_consumer_client::recipes::request_client_secrets::{request_client_secrets, RequestClientSecretsArgs}; -use log::{error, info, warn}; -use tauri::AppHandle; -use crate::core::artcraft_error::ArtcraftError; - -pub async fn get_or_update_grok_full_credentials(grok_credential_manager: &GrokCredentialManager) -> Result { - if let Some(creds) = grok_credential_manager.maybe_copy_full_credentials()? { - return Ok(creds); - } - - let cookies = match grok_credential_manager.maybe_copy_cookie_store()? { - Some(cookies) => cookies.to_cookie_string(), - None => { - return Err(GrokError::Client(GrokClientError::NoCookiesPresent).into()) - } - }; - - let cookies = GrokCookies::new(cookies); - - info!("Requesting Grok client secrets..."); - - let upgraded = request_client_secrets(RequestClientSecretsArgs { - cookies: &cookies, - }).await; - - match upgraded { - Err(err) => { - error!("Failed to fetch Grok client secrets: {}", err); // NB: Fall-through - return Err(ArtcraftError::from(err)); - } - Ok(secrets) => { - info!("Grok client secrets successfully upgraded..."); - let full_creds = GrokFullCredentials::from_cookies_and_client_secrets(cookies, secrets); - grok_credential_manager.replace_full_credentials(full_creds.clone())?; - info!("Persisting grok credentials to disk..."); - grok_credential_manager.persist_to_disk()?; - return Ok(full_creds) - } - } - - warn!("Grok upgrade failed. Try logging in again..."); -} diff --git a/crates/desktop/artcraft/src/services/grok/util/mod.rs b/crates/desktop/artcraft/src/services/grok/util/mod.rs deleted file mode 100644 index c3ec90aebb..0000000000 --- a/crates/desktop/artcraft/src/services/grok/util/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod get_or_upgrade_grok_full_credentials; -pub mod upload_image_media_file_to_grok; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/services/grok/util/upload_image_media_file_to_grok.rs b/crates/desktop/artcraft/src/services/grok/util/upload_image_media_file_to_grok.rs deleted file mode 100644 index 661166285b..0000000000 --- a/crates/desktop/artcraft/src/services/grok/util/upload_image_media_file_to_grok.rs +++ /dev/null @@ -1,80 +0,0 @@ -use crate::core::state::app_env_configs::app_env_configs_serializeable::StorytellerApiHost; -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::core::state::data_dir::trait_data_subdir::DataSubdir; -use crate::core::utils::get_url_file_extension::get_url_file_extension; -use crate::core::utils::simple_http_download::simple_http_download; -use crate::services::grok::state::grok_credential_manager::GrokCredentialManager; -use crate::services::sora::state::sora_credential_manager::SoraCredentialManager; -use crate::services::storyteller::state::storyteller_credential_manager::StorytellerCredentialManager; -use anyhow::anyhow; -use errors::AnyhowResult; -use grok_consumer_client::datatypes::api::file_id::FileId; -use grok_consumer_client::datatypes::file_upload_spec::FileUploadSpec; -use grok_consumer_client::requests::upload_file::grok_upload_file::GrokUploadFile; -use log::{error, info}; -use openai_sora_client::creds::sora_credential_set::SoraCredentialSet; -use openai_sora_client::recipes::image_upload_from_file_with_session_auto_renew::{image_upload_from_file_with_session_auto_renew, ImageUploadFromFileAutoRenewRequest}; -use openai_sora_client::recipes::maybe_upgrade_or_renew_session::maybe_upgrade_or_renew_session; -use std::time::Duration; -use artcraft_client::credentials::storyteller_credential_set::StorytellerCredentialSet; -use artcraft_client::endpoints::media_files::get_media_file::get_media_file; -use artcraft_client::utils::api_host::ApiHost; -use tokens::tokens::media_files::MediaFileToken; - -const GROK_IMAGE_UPLOAD_TIMEOUT: Duration = Duration::from_millis(1000 * 30); // 30 seconds - -pub struct UploadImageMediaFileToGrok<'a> { - pub storyteller_host: &'a ApiHost, - pub image_media_token: &'a MediaFileToken, - - pub app_data_root: &'a AppDataRoot, - pub grok_creds_manager: &'a GrokCredentialManager, -} - -pub struct UploadImageMediaFileToGrokResult { - pub grok_file_id: FileId, -} - -pub async fn upload_image_media_file_to_grok( - args: UploadImageMediaFileToGrok<'_>, -) -> AnyhowResult { - - info!("Calling get media file API: {:?}", args.storyteller_host); - - info!("Using media token: {:?}", args.image_media_token); - - let response = get_media_file( - args.storyteller_host, - args.image_media_token - ).await?; - - let media_file_url = &response.media_file.media_links.cdn_url; - let extension_with_dot = get_url_file_extension(media_file_url) - .map(|ext| format!(".{}", ext)) - .unwrap_or_else(|| ".png".to_string()); - - let filename = format!("{}{}", response.media_file.token.as_str(), extension_with_dot); - let filename = args.app_data_root.downloads_dir().path().join(&filename); - - simple_http_download(&media_file_url, &filename).await?; - - let cookies = args.grok_creds_manager.maybe_copy_cookie_header_string()? - .ok_or_else(|| anyhow!("Missing Grok cookies"))?; - - info!("Uploading image to Grok..."); - - let upload = GrokUploadFile { - file: FileUploadSpec::Path(filename), - cookie: cookies, - request_timeout: Some(GROK_IMAGE_UPLOAD_TIMEOUT), - }; - - let response = upload.upload().await?; - - let file_id = response.file_id - .ok_or_else(|| anyhow!("Media upload did not produce a file_id!"))?; - - Ok(UploadImageMediaFileToGrokResult { - grok_file_id: file_id, - }) -} diff --git a/crates/desktop/artcraft/src/services/grok/windows/grok_login_window/grok_login_webview_extract_cookies.rs b/crates/desktop/artcraft/src/services/grok/windows/grok_login_window/grok_login_webview_extract_cookies.rs deleted file mode 100644 index 45f7dbe795..0000000000 --- a/crates/desktop/artcraft/src/services/grok/windows/grok_login_window/grok_login_webview_extract_cookies.rs +++ /dev/null @@ -1,44 +0,0 @@ -use cookie_store::cookie_store::CookieStore; -use errors::AnyhowResult; -use once_cell::sync::Lazy; -use reqwest::Url; -use std::collections::HashSet; -use tauri::webview::Cookie; -use tauri::WebviewWindow; - -//static WWW_COOKIE_URL: Lazy = Lazy::new(|| { -// Url::parse("https://www.grok.com").expect("URL should parse") -//}); - -static ROOT_COOKIE_URL: Lazy = Lazy::new(|| { - Url::parse("https://grok.com").expect("URL should parse") -}); - -pub fn grok_login_webview_extract_cookies(webview: &WebviewWindow) -> AnyhowResult { - let mut cookie_store = CookieStore::empty(); - let cookies = get_all_grok_cookies(webview)?; - for cookie in cookies.iter() { - cookie_store.add_cookie_name_and_value( - cookie.name().to_string(), - cookie.value().to_string(), - ); - } - Ok(cookie_store) -} - -fn get_all_grok_cookies(webview: &WebviewWindow) -> AnyhowResult> { - //let www_cookies = webview.cookies_for_url(WWW_COOKIE_URL.clone())?; - let root_cookies = webview.cookies_for_url(ROOT_COOKIE_URL.clone())?; - - let mut all_cookies = root_cookies; - //let mut cookie_names = HashSet::new(); - - //for cookie in root_cookies.iter() { - // if !cookie_names.contains(cookie.name()) { - // cookie_names.insert(cookie.name().to_string()); - // all_cookies.push(cookie.clone()); - // } - //} - - Ok(all_cookies) -} diff --git a/crates/desktop/artcraft/src/services/grok/windows/grok_login_window/grok_login_window_open.rs b/crates/desktop/artcraft/src/services/grok/windows/grok_login_window/grok_login_window_open.rs deleted file mode 100644 index 2eeb173593..0000000000 --- a/crates/desktop/artcraft/src/services/grok/windows/grok_login_window/grok_login_window_open.rs +++ /dev/null @@ -1,74 +0,0 @@ -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::core::utils::clear_all_webview_cookies::clear_all_webview_cookies; -use crate::services::midjourney::state::midjourney_credential_manager::MidjourneyCredentialManager; -use crate::services::midjourney::windows::midjourney_login_window_thread::midjourney_login_window_thread; -use anyhow::anyhow; -use errors::AnyhowResult; -use once_cell::sync::Lazy; -use reqwest::Url; -use std::time::Duration; -use tauri::{AppHandle, Manager, WebviewUrl, WebviewWindowBuilder}; -use crate::services::grok::state::grok_credential_manager::GrokCredentialManager; -use crate::services::grok::windows::grok_login_window::grok_login_window_thread::grok_login_window_thread; - -/// Name of the window -pub (super) const GROK_LOGIN_WINDOW_NAME: &str = "grok_login_window"; - -pub (super) static START_URL: Lazy = Lazy::new(|| { - Url::parse("https://google.com").expect("URL should parse") -}); - -pub (super) static GROK_HOMEPAGE_URL: Lazy = Lazy::new(|| { - Url::parse("https://grok.com/").expect("URL should parse") -}); - -pub (super) static GROK_LOGIN_URL: Lazy = Lazy::new(|| { - Url::parse("https://accounts.x.ai/sign-in?redirect=grok-com").expect("URL should parse") -}); - -pub async fn grok_login_window_open( - app: &AppHandle, - app_data_root: &AppDataRoot, - grok_creds_manager: &GrokCredentialManager, -) -> AnyhowResult<()> { - if app.get_window(GROK_LOGIN_WINDOW_NAME).is_some() { - return Err(anyhow!("Login window already open")); - } - - let url = WebviewUrl::External(START_URL.clone()); - - let window = WebviewWindowBuilder::new(app, GROK_LOGIN_WINDOW_NAME, url) - //.user_agent(openai_sora_client::credentials::USER_AGENT) - .always_on_top(false) - .title("Login to Grok") - .center() - .resizable(true) - .visible(true) - .closable(true) - .min_inner_size(200.0, 800.0) - .focused(true) - .devtools(true) - .build()?; - - let webview = window.get_webview(GROK_LOGIN_WINDOW_NAME) - .ok_or_else(|| anyhow!("no webview found"))?; - - clear_all_webview_cookies(&webview)?; - - webview.navigate(GROK_HOMEPAGE_URL.clone())?; - - // NB: We're starting to get Cloudflare protection screens. Let's try to avoid. - tokio::time::sleep(Duration::from_millis(100)).await; - - webview.navigate(GROK_LOGIN_URL.clone())?; - - let app_handle = app.clone(); - let app_data_root = app_data_root.clone(); - let grok_creds_manager= grok_creds_manager.clone(); - - let _ = tauri::async_runtime::spawn(async move { - grok_login_window_thread(app_handle, app_data_root, grok_creds_manager).await; - }); - - Ok(()) -} diff --git a/crates/desktop/artcraft/src/services/grok/windows/grok_login_window/grok_login_window_thread.rs b/crates/desktop/artcraft/src/services/grok/windows/grok_login_window/grok_login_window_thread.rs deleted file mode 100644 index 672e1d011c..0000000000 --- a/crates/desktop/artcraft/src/services/grok/windows/grok_login_window/grok_login_window_thread.rs +++ /dev/null @@ -1,182 +0,0 @@ -use crate::core::events::basic_sendable_event_trait::BasicSendableEvent; -use crate::core::events::functional_events::refresh_account_state_event::RefreshAccountStateEvent; -use crate::core::events::generation_events::common::{GenerationAction, GenerationServiceProvider}; -use crate::core::events::generation_events::generation_complete_event::GenerationCompleteEvent; -use crate::core::events::sendable_event_trait::SendableEvent; -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::core::utils::window::get_webview_window_hostname::get_webview_window_hostname; -use crate::services::grok::state::grok_credential_manager::GrokCredentialManager; -use crate::services::grok::windows::grok_login_window::grok_login_webview_extract_cookies::grok_login_webview_extract_cookies; -use crate::services::grok::windows::grok_login_window::grok_login_window_open::GROK_LOGIN_WINDOW_NAME; -use crate::services::sora::events::sora_login_success_event::SoraLoginSuccessEvent; -use crate::services::sora::state::sora_credential_manager::SoraCredentialManager; -use crate::services::sora::windows::sora_login_window::extract_sora_webview_cookies::extract_sora_webview_cookies; -use anyhow::anyhow; -use cookie_store::cookie_store::CookieStore; -use enums::common::generation_provider::GenerationProvider; -use errors::AnyhowResult; -use log::{error, info}; -use openai_sora_client::creds::sora_credential_set::SoraCredentialSet; -use openai_sora_client::recipes::maybe_upgrade_or_renew_session::maybe_upgrade_or_renew_session; -use openai_sora_client::utils::has_session_cookie::{has_session_cookie, SessionCookiePresence}; -use tauri::{AppHandle, Manager, WebviewWindow}; - -pub async fn grok_login_window_thread( - app: AppHandle, - app_data_root: AppDataRoot, - grok_creds_manager: GrokCredentialManager, -) { - let mut visited_login = false; - - loop { - let login_webview_window = match app.get_webview_window(GROK_LOGIN_WINDOW_NAME) { - Some(webview) => webview, - None => { - info!("Exit Grok login thread."); - return; // NB: Only exit if we don't have the webview. - } - }; - - let result = check_login_window( - &app, - &login_webview_window, - &app_data_root, - &grok_creds_manager, - &mut visited_login, - ).await; - - match result { - Err(err) => { - error!("Error checking Grok login window: {:?}", err); - } - Ok(false) => {} // Continue iteration and try again... - Ok(true) => { - info!("Successfully saved cookies from login window. Closing."); - if let Err(err) = login_webview_window.close() { - error!("Error closing login window: {:?}", err); - } - return; - } - } - - tokio::time::sleep(std::time::Duration::from_millis(2_000)).await; - } -} - -/// Returns true if we can exit. -async fn check_login_window( - app_handle: &AppHandle, - webview_window: &WebviewWindow, - app_data_root: &AppDataRoot, - grok_creds_manager: &GrokCredentialManager, - visited_login: &mut bool, -) -> AnyhowResult { - - /* Login flow looks like this: - - 1. Start: https://accounts.x.ai/sign-in?redirect=grok-com - 2. SSO / Google Login (etc): https://accounts.google.com/v3/signin/challenge/pwd?[query] - 3. Done / Landing: https://grok.com/... - */ - - let hostname = get_webview_window_hostname(webview_window)?; - - let mut maybe_at_destination = false; - - match hostname.as_str() { - "www.grok.com" | - "grok.com" - => { - maybe_at_destination = true; - } - // chatgpt.com/auth is also an auth domain - "accounts.x.ai" | - "auth.openai.com" | - "accounts.google.com" | - "accounts.youtube.com" | - "login.live.com" | - "appleid.apple.com" - => { - // NB: We're in auth flow. - info!("Grok webview is in auth flow; hostname `{}`.", hostname); - *visited_login = true; - return Ok(false) - } - _ => {}, // We just don't know... - } - - let cookie_store = grok_login_webview_extract_cookies(webview_window)?; - - let maybe_has_auth_cookies = true; //cookie_store_has_auth_cookies(&cookie_store); // TODO TODO FIXME - let maybe_has_enough_cookies = cookie_store.len() > 6; - let maybe_completed_login_cycle = *visited_login && maybe_at_destination; - - // Misc cookies without login cookies are ~1055 length - // AUTH_I is ~1500 length - // AUTH_R is ~500 length - let maybe_has_big_enough_cookie = cookie_store.calculate_approx_cookie_character_length() > 2100; - - let mut heuristic_count = 0; - - if maybe_has_auth_cookies { - heuristic_count += 1; - } - if maybe_has_enough_cookies { - heuristic_count += 1; - } - if maybe_completed_login_cycle { - heuristic_count += 1; - } - if maybe_has_big_enough_cookie { - heuristic_count += 1; - } - - if heuristic_count < 3 { - return Ok(false); - } - - info!("Heuristic count is ({}); we're likely done.", heuristic_count); - - info!("Current cookies (len {}): {:?}", cookie_store.len(), cookie_store.to_cookie_string()); - - //let response = get_user_info(GetUserInfoRequest { - // hostname: MidjourneyHostname::Standard, - // cookie_header: cookie_store.to_cookie_string(), - //}).await; - - //match response { - // Err(err) => { - // error!("Error getting midjourney user info: {:?}", err); - // // NB: Fall through. Allow us to update the cookies. - // } - // Ok(user_info) => { - // info!("Got midjourney user info: {:?}", user_info); - // let user_info = MidjourneyUserInfo::from_api_response(user_info); - // - // //if let Err(err) = grok_creds_manager.replace_user_info(user_info) { - // // error!("Error saving midjourney user info: {:?}", err); - // // // NB: Fall through. Allow us to update the cookies. - // //} - // } - //} - - grok_creds_manager.replace_cookie_store(cookie_store)?; - - let result = grok_creds_manager.persist_to_disk(); - - if let Err(err) = result { - error!("Error persisting grok cookies to disk: {:?}", err); - return Ok(false); - } - - let event = RefreshAccountStateEvent { - provider: Some(GenerationProvider::Grok), - }; - - if let Err(err) = event.send(&app_handle) { - error!("Failed to send RefreshAccountStateEvent: {:?}", err); // Fail open - } - - Ok(true) -} - diff --git a/crates/desktop/artcraft/src/services/grok/windows/grok_login_window/mod.rs b/crates/desktop/artcraft/src/services/grok/windows/grok_login_window/mod.rs deleted file mode 100644 index 5f818a63fe..0000000000 --- a/crates/desktop/artcraft/src/services/grok/windows/grok_login_window/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub mod grok_login_window_open; -pub (super) mod grok_login_window_thread; -pub (super) mod grok_login_webview_extract_cookies; diff --git a/crates/desktop/artcraft/src/services/grok/windows/mod.rs b/crates/desktop/artcraft/src/services/grok/windows/mod.rs deleted file mode 100644 index 66ef2bb3e8..0000000000 --- a/crates/desktop/artcraft/src/services/grok/windows/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod grok_login_window; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/services/midjourney/commands/midjourney_clear_credentials_command.rs b/crates/desktop/artcraft/src/services/midjourney/commands/midjourney_clear_credentials_command.rs deleted file mode 100644 index da44996e06..0000000000 --- a/crates/desktop/artcraft/src/services/midjourney/commands/midjourney_clear_credentials_command.rs +++ /dev/null @@ -1,39 +0,0 @@ -use crate::core::commands::response::shorthand::{Response, SimpleResponse}; -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::services::midjourney::state::midjourney_credential_manager::MidjourneyCredentialManager; -use errors::AnyhowResult; -use log::{error, info}; -use serde_derive::Deserialize; -use tauri::State; - -#[tauri::command] -pub async fn midjourney_clear_credentials_command( - root: State<'_, AppDataRoot>, - creds_manager: State<'_, MidjourneyCredentialManager>, -) -> SimpleResponse { - info!("midjourney_clear_credentials_command called"); - - clear_creds(&root, &creds_manager) - .map_err(|err| { - error!("Error clearing creds: {:?}", err); - "error clearing creds" - })?; - - Ok(().into()) -} - -fn clear_creds( - root: &AppDataRoot, - creds: &MidjourneyCredentialManager, -) -> AnyhowResult<()> { - - creds.clear_credentials()?; - creds.persist_to_disk()?; - - let creds_path = root.credentials_dir().get_midjourney_state_path(); - if creds_path.exists() { - std::fs::remove_file(creds_path)?; - } - - Ok(()) -} diff --git a/crates/desktop/artcraft/src/services/midjourney/commands/midjourney_get_credential_info_command.rs b/crates/desktop/artcraft/src/services/midjourney/commands/midjourney_get_credential_info_command.rs deleted file mode 100644 index bfe4286bb8..0000000000 --- a/crates/desktop/artcraft/src/services/midjourney/commands/midjourney_get_credential_info_command.rs +++ /dev/null @@ -1,52 +0,0 @@ -use crate::core::commands::response::shorthand::{Response, ResponseOrErrorMessage}; -use crate::core::commands::response::success_response_wrapper::SerializeMarker; -use crate::services::midjourney::state::midjourney_credential_manager::MidjourneyCredentialManager; -use errors::AnyhowResult; -use log::{error, info}; -use serde_derive::Serialize; -use tauri::State; - -#[derive(Serialize)] -pub struct MidjourneyGetCredentialInfoResponse { - pub maybe_email: Option, - pub can_clear_state: bool, -} - -impl SerializeMarker for MidjourneyGetCredentialInfoResponse {} - -#[tauri::command] -pub async fn midjourney_get_credential_info_command( - creds_manager: State<'_, MidjourneyCredentialManager>, -) -> ResponseOrErrorMessage { - info!("midjourney_get_credential_info_command called"); - - let info = get_info(&creds_manager) - .map_err(|err| { - error!("Error getting info: {:?}", err); - "error getting info" - })?; - - Ok(info.into()) -} - -fn get_info( - creds: &MidjourneyCredentialManager, -) -> AnyhowResult { - let mut can_clear_state = true; - - let maybe_cookies = creds.maybe_copy_cookie_store()?; - let maybe_user_info = creds.maybe_copy_user_info()?; - - if maybe_cookies.is_none() && maybe_user_info.is_none() { - can_clear_state = false; - } - - let maybe_email = maybe_user_info - .map(|info| info.email.clone()) - .flatten(); - - Ok(MidjourneyGetCredentialInfoResponse { - maybe_email, - can_clear_state, - }) -} diff --git a/crates/desktop/artcraft/src/services/midjourney/commands/midjourney_open_login_command.rs b/crates/desktop/artcraft/src/services/midjourney/commands/midjourney_open_login_command.rs deleted file mode 100644 index b774410195..0000000000 --- a/crates/desktop/artcraft/src/services/midjourney/commands/midjourney_open_login_command.rs +++ /dev/null @@ -1,38 +0,0 @@ -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::services::midjourney::state::midjourney_credential_manager::MidjourneyCredentialManager; -use crate::services::midjourney::windows::open_midjourney_login_window::open_midjourney_login_window; -use crate::services::sora::windows::sora_login_window::open_sora_login_window::open_sora_login_window; -use errors::AnyhowResult; -use log::{error, info}; -use tauri::{AppHandle, State}; - -#[tauri::command] -pub async fn midjourney_open_login_command( - app: AppHandle, - app_data_root: State<'_, AppDataRoot>, - mj_creds_manager: State<'_, MidjourneyCredentialManager>, -) -> Result { - info!("midjourney_open_login_command called"); - - do_open_login(&app, &app_data_root, &mj_creds_manager) - .await - .map_err(|err| { - error!("Error opening login: {:?}", err); - format!("Error opening login: {:?}", err) - })?; - - Ok("result".to_string()) -} - -async fn do_open_login( - app: &AppHandle, - app_data_root: &AppDataRoot, - mj_creds_manager: &MidjourneyCredentialManager, -) -> AnyhowResult<()> { - info!("Building login window..."); - - open_midjourney_login_window(app, app_data_root, mj_creds_manager).await?; - - info!("Done."); - Ok(()) -} diff --git a/crates/desktop/artcraft/src/services/midjourney/commands/mod.rs b/crates/desktop/artcraft/src/services/midjourney/commands/mod.rs deleted file mode 100644 index b31d0a1ed6..0000000000 --- a/crates/desktop/artcraft/src/services/midjourney/commands/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub mod midjourney_clear_credentials_command; -pub mod midjourney_get_credential_info_command; -pub mod midjourney_open_login_command; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/services/midjourney/mod.rs b/crates/desktop/artcraft/src/services/midjourney/mod.rs deleted file mode 100644 index 9e15c7b3a9..0000000000 --- a/crates/desktop/artcraft/src/services/midjourney/mod.rs +++ /dev/null @@ -1,5 +0,0 @@ -pub mod commands; -pub mod state; -pub mod threads; -pub mod utils; -pub mod windows; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/services/midjourney/state/midjourney_credential_manager.rs b/crates/desktop/artcraft/src/services/midjourney/state/midjourney_credential_manager.rs deleted file mode 100644 index efe80dea02..0000000000 --- a/crates/desktop/artcraft/src/services/midjourney/state/midjourney_credential_manager.rs +++ /dev/null @@ -1,196 +0,0 @@ -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::services::midjourney::state::midjourney_user_info::MidjourneyUserInfo; -use crate::services::midjourney::state::serializable_midjourney_state::{SerializableMidjourneyState, SERIALIZABLE_MIDJOURNEY_STATE_VERSION}; -use crate::services::storyteller::state::read_storyteller_credentials_from_disk::read_storyteller_credentials_from_disk; -use crate::services::storyteller::state::storyteller_credential_holder::StorytellerCredentialHolder; -use cookie_store::cookie_store::CookieStore; -use errors::AnyhowResult; -use log::{info, warn}; -use std::fs::read_to_string; -use std::sync::{Arc, RwLock}; -use midjourney_client::credentials::cookie_store_has_auth_cookies::cookie_store_has_auth_cookies; -use artcraft_client::credentials::storyteller_avt_cookie::StorytellerAvtCookie; -use artcraft_client::credentials::storyteller_credential_set::StorytellerCredentialSet; -use artcraft_client::credentials::storyteller_session_cookie::StorytellerSessionCookie; - -#[derive(Clone)] -pub struct MidjourneyCredentialManager { - // TODO: Put last write/last read timestamps on these. - cookies: Arc>>, - user_info: Arc>>, - app_data_root: AppDataRoot, -} - -impl MidjourneyCredentialManager { - pub fn initialize_empty(app_data_root: &AppDataRoot) -> Self { - Self { - cookies: Arc::new(RwLock::new(None)), - user_info: Arc::new(RwLock::new(None)), - app_data_root: app_data_root.clone(), - } - } - - pub fn initialize_from_disk_infallible(app_data_root: &AppDataRoot) -> Self { - let mut cookies; - let mut user_info; - - match read_midjourney_state_from_disk(app_data_root) { - Err(err) => { - warn!("Failed to read midjourney state from disk: {:?}", err); - cookies = Arc::new(RwLock::new(None)); - user_info = Arc::new(RwLock::new(None)); - }, - Ok(None) => { - cookies = Arc::new(RwLock::new(None)); - user_info = Arc::new(RwLock::new(None)); - } - Ok(Some(state)) => { - let maybe_cookies = state.user_cookies - .map(|cookies| cookies.to_cookie_store()); - let maybe_user_info = state.user_info - .map(|info| info.to_user_info()); - cookies = Arc::new(RwLock::new(maybe_cookies)); - user_info = Arc::new(RwLock::new(maybe_user_info)); - } - }; - - Self { - cookies, - user_info, - app_data_root: app_data_root.clone(), - } - } - - pub fn maybe_copy_cookie_store(&self) -> anyhow::Result> { - match self.cookies.read() { - Err(err) => Err(anyhow::anyhow!("Failed to acquire write lock: {:?}", err)), - Ok(store) => Ok(store.clone()), - } - } - - pub fn maybe_copy_user_info(&self) -> anyhow::Result> { - match self.user_info.read() { - Err(err) => Err(anyhow::anyhow!("Failed to acquire read lock: {:?}", err)), - Ok(info) => Ok(info.clone()), - } - } - - pub fn replace_cookie_store(&self, store: CookieStore) -> anyhow::Result<()> { - match self.cookies.write() { - Err(err) => Err(anyhow::anyhow!("Failed to acquire write lock: {:?}", err)), - Ok(mut current_store) => { - *current_store = Some(store); - Ok(()) - } - } - } - - pub fn replace_user_info(&self, user_info: MidjourneyUserInfo) -> anyhow::Result<()> { - match self.user_info.write() { - Err(err) => Err(anyhow::anyhow!("Failed to acquire write lock: {:?}", err)), - Ok(mut current_info) => { - *current_info = Some(user_info); - Ok(()) - } - } - } - - // NB: This is just a heuristic. We'll add better checks later. - pub fn session_appears_active(&self) -> anyhow::Result { - let maybe_cookies = match self.cookies.read() { - Err(err) => return Err(anyhow::anyhow!("Failed to acquire read lock: {:?}", err)), - Ok(store) => store.clone(), - }; - - let maybe_user_info = match self.user_info.read() { - Err(err) => return Err(anyhow::anyhow!("Failed to acquire read lock: {:?}", err)), - Ok(info) => info.clone(), - }; - - if maybe_cookies.is_none() || maybe_user_info.is_none() { - return Ok(false); - } - - let cookies = maybe_cookies.unwrap(); - let user_info = maybe_user_info.unwrap(); - - // NB: We consider the session active if we have auth cookies and a user id. - let has_user_id = user_info.user_id.is_some(); - let maybe_has_auth_cookies = cookie_store_has_auth_cookies(&cookies); - - // Misc cookies without login cookies are ~1055 length - // AUTH_I is ~1500 length - // AUTH_R is ~500 length - let maybe_has_big_enough_cookie = cookies.calculate_approx_cookie_character_length() > 2100; - - // TODO: Heuristic should count. - // TODO: Consolidate with "login window thread" logic. - // TODO: Check timestamp of last valid request. - Ok(has_user_id && maybe_has_auth_cookies && maybe_has_big_enough_cookie && maybe_has_big_enough_cookie) - } - - pub fn clear_credentials(&self) -> anyhow::Result<()> { - match self.cookies.write() { - Err(err) => return Err(anyhow::anyhow!("Failed to acquire write lock: {:?}", err)), - Ok(mut store) => *store = None, - } - match self.user_info.write() { - Err(err) => return Err(anyhow::anyhow!("Failed to acquire write lock: {:?}", err)), - Ok(mut info) => *info = None, - } - Ok(()) - } - - pub fn persist_to_disk(&self) -> anyhow::Result<()> { - let maybe_cookies = match self.cookies.read() { - Err(err) => return Err(anyhow::anyhow!("Failed to acquire read lock: {:?}", err)), - Ok(store) => store.clone(), - }; - - let maybe_user_info = match self.user_info.read() { - Err(err) => return Err(anyhow::anyhow!("Failed to acquire read lock: {:?}", err)), - Ok(info) => info.clone(), - }; - - let maybe_cookies= maybe_cookies - .map(|cookies| cookies.to_serializable()); - - let maybe_user_info= maybe_user_info - .map(|info| info.to_serializable()); - - if maybe_cookies.is_none() && maybe_user_info.is_none() { - info!("Nothing to write to disk, skipping."); - return Ok(()); - - } - - let state = SerializableMidjourneyState { - version: SERIALIZABLE_MIDJOURNEY_STATE_VERSION, - user_cookies: maybe_cookies, - user_info: maybe_user_info, - }; - - let path = self.app_data_root.credentials_dir().get_midjourney_state_path(); - let serialized = serde_json::to_string(&state)?; - - std::fs::write(path, serialized)?; - - Ok(()) - } -} - -fn read_midjourney_state_from_disk(root: &AppDataRoot) -> AnyhowResult> { - let midjourney_state_path= root.credentials_dir().get_midjourney_state_path(); - - if !midjourney_state_path.exists() { - return Ok(None); - } - - let contents = read_to_string(&midjourney_state_path)? - .trim() - .to_string(); - - let state: SerializableMidjourneyState = serde_json::from_str(&contents)?; - - Ok(Some(state)) -} diff --git a/crates/desktop/artcraft/src/services/midjourney/state/midjourney_user_info.rs b/crates/desktop/artcraft/src/services/midjourney/state/midjourney_user_info.rs deleted file mode 100644 index 258804ff97..0000000000 --- a/crates/desktop/artcraft/src/services/midjourney/state/midjourney_user_info.rs +++ /dev/null @@ -1,30 +0,0 @@ -use midjourney_client::credentials::midjourney_user_id::MidjourneyUserId; -use midjourney_client::recipes::get_user_info::GetUserInfoResponse; -use crate::services::midjourney::state::serializable_midjourney_state::SerializableMidjourneyUserInfo; - -#[derive(Clone)] -pub struct MidjourneyUserInfo { - pub user_id: Option, - pub email: Option, - pub websocket_token: Option, -} - -impl MidjourneyUserInfo { - pub fn to_serializable(&self) -> SerializableMidjourneyUserInfo { - SerializableMidjourneyUserInfo { - user_id: self.user_id - .as_ref() - .map(|id| id.to_string()), - email: self.email.clone(), - websocket_token: self.websocket_token.clone(), - } - } - - pub fn from_api_response(response: GetUserInfoResponse) -> Self { - Self { - user_id: response.user_id, - email: response.email, - websocket_token: response.websocket_token, - } - } -} diff --git a/crates/desktop/artcraft/src/services/midjourney/state/mod.rs b/crates/desktop/artcraft/src/services/midjourney/state/mod.rs deleted file mode 100644 index 4dd0dd83ff..0000000000 --- a/crates/desktop/artcraft/src/services/midjourney/state/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub (super) mod serializable_midjourney_state; -pub mod midjourney_credential_manager; -pub mod midjourney_user_info; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/services/midjourney/state/serializable_midjourney_state.rs b/crates/desktop/artcraft/src/services/midjourney/state/serializable_midjourney_state.rs deleted file mode 100644 index e379f61db0..0000000000 --- a/crates/desktop/artcraft/src/services/midjourney/state/serializable_midjourney_state.rs +++ /dev/null @@ -1,41 +0,0 @@ -use crate::services::midjourney::state::midjourney_user_info::MidjourneyUserInfo; -use cookie_store::serialized_cookie_store::SerializableCookieStore; -use midjourney_client::credentials::midjourney_user_id::MidjourneyUserId; -use serde_derive::{Deserialize, Serialize}; - -pub (super) const SERIALIZABLE_MIDJOURNEY_STATE_VERSION: u32 = 1; - -#[derive(Serialize, Deserialize)] -pub (super) struct SerializableMidjourneyState { - pub (super) version: u32, - - #[serde(skip_serializing_if = "Option::is_none")] - pub (super) user_cookies: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - pub (super) user_info: Option, -} - -#[derive(Serialize, Deserialize)] -pub (super) struct SerializableMidjourneyUserInfo { - #[serde(skip_serializing_if = "Option::is_none")] - pub (super) user_id: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - pub (super) email: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - pub (super) websocket_token: Option, -} - -impl SerializableMidjourneyUserInfo { - pub fn to_user_info(&self) -> MidjourneyUserInfo { - MidjourneyUserInfo { - user_id: self.user_id - .as_deref() - .map(|id| MidjourneyUserId::from_str(id)), - email: self.email.clone(), - websocket_token: self.websocket_token.clone(), - } - } -} diff --git a/crates/desktop/artcraft/src/services/midjourney/threads/events/maybe_handle_text_to_image_complete_event.rs b/crates/desktop/artcraft/src/services/midjourney/threads/events/maybe_handle_text_to_image_complete_event.rs deleted file mode 100644 index 1f3a1449c0..0000000000 --- a/crates/desktop/artcraft/src/services/midjourney/threads/events/maybe_handle_text_to_image_complete_event.rs +++ /dev/null @@ -1,83 +0,0 @@ -use crate::core::events::basic_sendable_event_trait::BasicSendableEvent; -use crate::core::events::functional_events::text_to_image_generation_complete_event::{GeneratedImage, TextToImageGenerationCompleteEvent}; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; -use anyhow::anyhow; -use artcraft_api_defs::jobs::list_session_jobs::{ListSessionJobsItem, ListSessionResultDetailsResponse}; -use enums::tauri::tasks::task_type::TaskType; -use enums::tauri::ux::tauri_command_caller::TauriCommandCaller; -use errors::AnyhowResult; -use log::{error, warn}; -use sqlite_tasks::queries::list_tasks_by_provider_and_status::{list_tasks_by_provider_and_status, ListTasksByProviderAndStatusArgs, TaskList}; -use sqlite_tasks::queries::task::Task; -use artcraft_client::credentials::storyteller_credential_set::StorytellerCredentialSet; -use artcraft_client::endpoints::media_files::list_batch_generated_redux_media_files::list_batch_generated_redux_media_files; -use tauri::AppHandle; -use tokens::tokens::batch_generations::BatchGenerationToken; -use tokens::tokens::media_files::MediaFileToken; - -pub async fn maybe_handle_text_to_image_complete_event( - app: &AppHandle, - app_env_configs: &AppEnvConfigs, - maybe_creds: Option<&StorytellerCredentialSet>, - task: &Task, - batch_token: &BatchGenerationToken, -) -> AnyhowResult<()> { - - match task.task_type { - TaskType::ImageGeneration => {} // NB: Fall-through - _ => return Ok(()), - } - - match task.frontend_caller { - Some(TauriCommandCaller::TextToImage) => {} // NB: Fall-through - _ => return Ok(()), - } - - let event = handle_batch( - app, - app_env_configs, - maybe_creds, - task, - batch_token, - ).await?; - - if let Err(err) = event.send(&app) { - error!("Failed to send TextToImageGenerationCompleteEvent: {:?}", err); // Fail open - } - - Ok(()) -} - -async fn handle_batch( - app: &AppHandle, - app_env_configs: &AppEnvConfigs, - maybe_creds: Option<&StorytellerCredentialSet>, - task: &Task, - batch_token: &BatchGenerationToken, -) -> AnyhowResult { - - let result = list_batch_generated_redux_media_files( - &app_env_configs.storyteller_host, - maybe_creds, - batch_token, - ).await?; - - if result.media_files.is_empty() { - return Err(anyhow!("No media files found for batch token: {}", batch_token)); - } - - let media_files = result.media_files - .into_iter() - .map(|file| GeneratedImage { - media_token: file.token, - cdn_url: file.media_links.cdn_url, - maybe_thumbnail_template: file.media_links.maybe_thumbnail_template, - }) - .collect(); - - Ok(TextToImageGenerationCompleteEvent { - generated_images: media_files, - maybe_frontend_subscriber_id: task.frontend_subscriber_id.clone(), - maybe_frontend_subscriber_payload: task.frontend_subscriber_payload.clone(), - }) -} diff --git a/crates/desktop/artcraft/src/services/midjourney/threads/events/mod.rs b/crates/desktop/artcraft/src/services/midjourney/threads/events/mod.rs deleted file mode 100644 index 3475003cdb..0000000000 --- a/crates/desktop/artcraft/src/services/midjourney/threads/events/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub (super) mod maybe_handle_text_to_image_complete_event; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/services/midjourney/threads/midjourney_long_polling_thread.rs b/crates/desktop/artcraft/src/services/midjourney/threads/midjourney_long_polling_thread.rs deleted file mode 100644 index 001f2b628f..0000000000 --- a/crates/desktop/artcraft/src/services/midjourney/threads/midjourney_long_polling_thread.rs +++ /dev/null @@ -1,403 +0,0 @@ -use crate::core::events::basic_sendable_event_trait::BasicSendableEvent; -use crate::core::events::generation_events::common::{GenerationAction, GenerationServiceProvider}; -use crate::core::events::generation_events::generation_complete_event::GenerationCompleteEvent; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::core::state::data_dir::trait_data_subdir::DataSubdir; -use crate::core::state::task_database::TaskDatabase; -use crate::core::utils::task_database_pending_statuses::TASK_DATABASE_PENDING_STATUSES; -use crate::services::midjourney::state::midjourney_credential_manager::MidjourneyCredentialManager; -use crate::services::midjourney::threads::events::maybe_handle_text_to_image_complete_event::maybe_handle_text_to_image_complete_event; -use crate::services::midjourney::utils::download_midjourney_image::download_midjourney_image; -use crate::services::storyteller::state::storyteller_credential_manager::StorytellerCredentialManager; -use artcraft_api_defs::prompts::create_prompt::CreatePromptRequest; -use artcraft_api_defs::utils::media_links_to_thumbnail_template::media_links_to_thumbnail_template; -use cookie_store::cookie_store::CookieStore; -use enums::common::generation_provider::GenerationProvider; -use enums::common::generation::common_model_type::CommonModelType; -use enums::tauri::tasks::task_media_file_class::TaskMediaFileClass; -use errors::AnyhowResult; -use uuid_utils::uuid::generate_random_uuid; -use log::{error, info}; -use midjourney_client::client::midjourney_hostname::MidjourneyHostname; -use midjourney_client::credentials::midjourney_user_id::MidjourneyUserId; -use midjourney_client::endpoints::imagine::{imagine, ImagineItem, ImagineRequest, MidjourneyJobType}; -use midjourney_client::utils::get_image_url::get_image_url; -use midjourney_client::utils::image_downloader_client::ImageDownloaderClient; -use once_cell::sync::Lazy; -use sqlite_tasks::queries::list_tasks_by_provider_and_status::{list_tasks_by_provider_and_status, ListTasksByProviderAndStatusArgs, TaskList}; -use sqlite_tasks::queries::task::Task; -use sqlite_tasks::queries::update_successful_task_status_with_metadata::{update_successful_task_status_with_metadata, UpdateSuccessfulTaskArgs}; -use sqlite_tasks::queries::update_task_status::{update_task_status, UpdateTaskArgs}; -use std::collections::{HashMap, HashSet}; -use std::fs::File; -use std::io::Write; -use std::path::PathBuf; -use artcraft_client::credentials::storyteller_credential_set::StorytellerCredentialSet; -use artcraft_client::endpoints::media_files::get_media_file::get_media_file; -use artcraft_client::endpoints::media_files::upload_image_media_file_from_file::{upload_image_media_file_from_file, UploadImageFromFileArgs}; -use artcraft_client::endpoints::prompts::create_prompt::create_prompt; -use artcraft_client::error::api_error::ApiError; -use artcraft_client::error::storyteller_error::StorytellerError; -use tauri::AppHandle; -use tokens::tokens::batch_generations::BatchGenerationToken; -use url::Url; - -/// This thread is responsible for picking up tasks that fell through the cracks of -/// the faster websocket thread. -pub async fn midjourney_long_polling_thread( - app_handle: AppHandle, - app_env_configs: AppEnvConfigs, - app_data_root: AppDataRoot, - task_database: TaskDatabase, - creds: MidjourneyCredentialManager, - storyteller_creds_manager: StorytellerCredentialManager, -) -> ! { - loop { - let res = polling_loop( - &app_handle, - &app_env_configs, - &app_data_root, - &task_database, - &creds, - &storyteller_creds_manager, - ).await; - if let Err(err) = res { - error!("An error occurred: {:?}", err); - } - // NB: Only sleep if an error occurs. - tokio::time::sleep(std::time::Duration::from_millis(30_000)).await; - } -} - -async fn polling_loop( - app_handle: &AppHandle, - app_env_configs: &AppEnvConfigs, - app_data_root: &AppDataRoot, - task_database: &TaskDatabase, - creds: &MidjourneyCredentialManager, - storyteller_creds_manager: &StorytellerCredentialManager, -) -> AnyhowResult<()> { - loop { - if !creds.session_appears_active()? { - tokio::time::sleep(std::time::Duration::from_millis(30_000)).await; - continue; - } - - // TODO: Graceful wait, fix this long function body - let storyteller_creds = match storyteller_creds_manager.get_credentials()? { - Some(creds) => creds, - None => { - error!("No Storyteller credentials found. Cannot proceed with Midjourney polling."); - tokio::time::sleep(std::time::Duration::from_millis(5_000)).await; - continue; - } - }; - - let cookies = creds.maybe_copy_cookie_store()?; - - let cookies = match cookies { - Some(cookies) => cookies, - None => { - tokio::time::sleep(std::time::Duration::from_millis(30_000)).await; - continue; - } - }; - - let user_info = creds.maybe_copy_user_info()?; - - let maybe_user_id = user_info - .map(|info| info.user_id) - .flatten(); - - let user_id = match maybe_user_id { - Some(user_id) => user_id, - None => { - tokio::time::sleep(std::time::Duration::from_millis(30_000)).await; - continue; - } - }; - - let local_tasks = list_tasks_by_provider_and_status(ListTasksByProviderAndStatusArgs { - db: task_database.get_connection(), - provider: GenerationProvider::Midjourney, - task_statuses: &TASK_DATABASE_PENDING_STATUSES, - }).await?; - - poll_midjourney_tasks( - app_handle, - app_env_configs, - app_data_root, - task_database, - &cookies, - &user_id, - &storyteller_creds, - local_tasks, - ).await?; - - tokio::time::sleep(std::time::Duration::from_millis(2_000)).await; - } -} - -async fn poll_midjourney_tasks( - app_handle: &AppHandle, - app_env_configs: &AppEnvConfigs, - app_data_root: &AppDataRoot, - task_database: &TaskDatabase, - mj_cookies: &CookieStore, - mj_user_id: &MidjourneyUserId, - storyteller_creds: &StorytellerCredentialSet, - local_tasks: TaskList, -) -> AnyhowResult<()> { - let local_tasks = local_tasks.tasks; - - if local_tasks.is_empty() { - return Ok(()) - } - - // Map of Midjourney Job ID to Local Task. - let local_tasks_by_midjourney_job_id = local_tasks.iter() - .filter_map(|task| { - if let Some(provider_job_id) = &task.provider_job_id { - Some((provider_job_id.clone(), task.clone())) - } else { - None - } - }) - .collect::>(); - - let cookie_header = mj_cookies.to_cookie_string(); - - let midjourney_result = imagine(ImagineRequest { - hostname: MidjourneyHostname::Standard, - cookie_header, - user_id: mj_user_id, - page_size: None, - }).await?; - - let midjourney_items = midjourney_result.items; - - let midjourney_items_by_id = { - let mut hash = HashMap::new(); - for item in midjourney_items.iter() { - if let Some(id) = &item.id { - hash.insert(id.to_string(), item.clone()); - } - } - hash - }; - - // TODO: If we introduce another job polling mechanism, we may need to handle concurrency. - // One idea might be to add a new job state that acts as an optimistic lock - - let image_downloader = ImageDownloaderClient::create()?; - - for (midjourney_job_id, local_task) in local_tasks_by_midjourney_job_id.iter() { - // TODO: Copy prompt from this. - let midjourney_item = match midjourney_items_by_id.get(midjourney_job_id) { - Some(item) => item, - None => continue, - }; - - upload_midjourney_batch( - &app_handle, - &app_env_configs, - app_data_root, - task_database, - &storyteller_creds, - &image_downloader, - midjourney_job_id, - &local_task, - midjourney_item - ).await?; - - tokio::time::sleep(std::time::Duration::from_millis(2_000)).await; - } - - tokio::time::sleep(std::time::Duration::from_millis(60_000)).await; - - Ok(()) -} - -async fn upload_midjourney_batch( - app_handle: &AppHandle, - app_env_configs: &AppEnvConfigs, - app_data_root: &AppDataRoot, - task_database: &TaskDatabase, - storyteller_creds: &StorytellerCredentialSet, - image_downloader: &ImageDownloaderClient, - midjourney_job_id: &String, - local_task: &Task, - midjourney_item: &ImagineItem -) -> AnyhowResult<()> { - let model_type = match midjourney_item.job_type { - Some(MidjourneyJobType::V6Diffusion) => CommonModelType::MidjourneyV6, - Some(MidjourneyJobType::V6p1Diffusion) => CommonModelType::MidjourneyV6p1, - Some(MidjourneyJobType::V6p1RawDiffusion) => CommonModelType::MidjourneyV6p1Raw, - Some(MidjourneyJobType::V7Diffusion) => CommonModelType::MidjourneyV7, - Some(MidjourneyJobType::V7RawDiffusion) => CommonModelType::MidjourneyV7Raw, - Some(MidjourneyJobType::V7DraftDiffusion) => CommonModelType::MidjourneyV7Draft, - Some(MidjourneyJobType::V7DraftRawDiffusion) => CommonModelType::MidjourneyV7DraftRaw, - Some(MidjourneyJobType::Other(ref other)) => { - info!("Unknown Midjourney job type (for job id {}): {}", midjourney_job_id, other); - CommonModelType::Midjourney - }, - _ => CommonModelType::Midjourney, - }; - - let request = CreatePromptRequest { - uuid_idempotency_token: generate_random_uuid(), - positive_prompt: midjourney_item.full_command.clone(), - negative_prompt: None, - model_type: Some(model_type), - generation_provider: Some(GenerationProvider::Midjourney), - maybe_generation_mode: None, - maybe_aspect_ratio: None, - maybe_resolution: None, - maybe_batch_count: None, - maybe_generate_audio: None, - maybe_duration_seconds: None, }; - - let prompt_response = create_prompt( - &app_env_configs.storyteller_host, - Some(storyteller_creds), - request - ).await?; - - info!("Created prompt: {:?}", &prompt_response.prompt_token); - - // TODO: Move this from clientside to the backend. - // The first upload should produce a batch token that we can reuse. - let batch_token = BatchGenerationToken::generate(); - - info!("Using synthetic batch token: {:?}", &batch_token); - - let mut maybe_primary_media_file_token = None; - - for index in 0..4 { - info!("Downloading generated Midjourney file..."); - - let download_path = download_midjourney_image( - &image_downloader, - midjourney_job_id, - index, - app_data_root - ).await?; - - let mut wait_delay = 0; - - loop { - info!("Uploading to backend..."); - - // TODO: media_files.origin_category - // TODO: media_files.maybe_prompt_token - // TODO: media_files.maybe_generation_provider - // TODO: media_files.maybe_origin_model_type - // TODO: media_files.maybe_origin_model_token (sref?) - // TODO: media_files.maybe_batch_token - // TODO: media_files.is_user_upload - - // TODO: batch_generations.token - // TODO: batch_generations.entity_type - // TODO: batch_generations.entity_token - - let result = upload_image_media_file_from_file(UploadImageFromFileArgs { - api_host: &app_env_configs.storyteller_host, - maybe_creds: Some(&storyteller_creds), - path: &download_path, - is_intermediate_system_file: false, - maybe_prompt_token: Some(&prompt_response.prompt_token), - maybe_batch_token: Some(&batch_token), - maybe_generation_provider: Some(GenerationProvider::Midjourney), - }).await; - - match result { - Ok(result) => { - info!("Successfully uploaded to backend: {:?}", result.media_file_token); - if maybe_primary_media_file_token.is_none() { - maybe_primary_media_file_token = Some(result.media_file_token); - } - break; - }, - Err(StorytellerError::Api(ApiError::TooManyRequests(_))) => { - error!("Too many requests, retrying upload after delay..."); - // If we hit a rate limit, we can retry after a short delay. - wait_delay += 10; - if wait_delay > 60 { - wait_delay = 60; - } - tokio::time::sleep(std::time::Duration::from_secs(wait_delay)).await; - continue; // Retry the upload. - } - Err(err) => { - error!("Failed to upload to backend: {:?}", err); - return Err(err.into()) - }, - } - } // End loop - - tokio::time::sleep(std::time::Duration::from_millis(100)).await; - } - - let mut maybe_cdn_url = None; - let mut maybe_thumbnail_url_template = None; - - if let Some(media_file_token) = maybe_primary_media_file_token.as_ref() { - info!("Looking up file to grab CDN and thumbnail URLs: {:?} ...", media_file_token); - - let lookup_result = get_media_file( - &app_env_configs.storyteller_host, - media_file_token, - ).await; - match lookup_result { - Ok(response) => { - maybe_cdn_url = Some(response.media_file.media_links.cdn_url.to_string()); - maybe_thumbnail_url_template = media_links_to_thumbnail_template(&response.media_file.media_links) - .map(|s| s.to_string()); - } - Err(err) => { - error!("Failed to look up media file after upload: {:?} (failing open)", err); - } - } - } - - let updated = update_successful_task_status_with_metadata(UpdateSuccessfulTaskArgs { - db: task_database.get_connection(), - task_id: &local_task.id, - maybe_batch_token: Some(&batch_token), - maybe_primary_media_file_token: maybe_primary_media_file_token.as_ref(), - maybe_primary_media_file_class: Some(TaskMediaFileClass::Image), - maybe_primary_media_file_thumbnail_url_template: maybe_thumbnail_url_template.as_deref(), - maybe_primary_media_file_cdn_url: maybe_cdn_url.as_deref(), - }).await?; - - if !updated { - return Ok(()); // If anything breaks with queries, don't spam events. - } - - let event = GenerationCompleteEvent { - //media_file_token: result.media_file_token, - action: Some(GenerationAction::GenerateImage), - service: GenerationServiceProvider::Midjourney, - model: None, - }; - - if let Err(err) = event.send(&app_handle) { - error!("Failed to send GenerationCompleteEvent: {:?}", err); // Fail open - } - - let result = maybe_handle_text_to_image_complete_event( - app_handle, - app_env_configs, - Some(storyteller_creds), - local_task, - &batch_token, - ).await; - - if let Err(err) = result { - error!("Failed to send text-to-image complete event: {:?}", err); - } - - Ok(()) -} - diff --git a/crates/desktop/artcraft/src/services/midjourney/threads/mod.rs b/crates/desktop/artcraft/src/services/midjourney/threads/mod.rs deleted file mode 100644 index b4be5d8ad1..0000000000 --- a/crates/desktop/artcraft/src/services/midjourney/threads/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod midjourney_long_polling_thread; -mod events; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/services/midjourney/utils/download_midjourney_image.rs b/crates/desktop/artcraft/src/services/midjourney/utils/download_midjourney_image.rs deleted file mode 100644 index fb63021c15..0000000000 --- a/crates/desktop/artcraft/src/services/midjourney/utils/download_midjourney_image.rs +++ /dev/null @@ -1,35 +0,0 @@ -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::core::state::data_dir::trait_data_subdir::DataSubdir; -use errors::AnyhowResult; -use midjourney_client::utils::get_image_url::get_image_url; -use std::fs::File; -use std::io::Write; -use std::path::PathBuf; -use url::Url; -use midjourney_client::utils::image_downloader_client::ImageDownloaderClient; - -pub async fn download_midjourney_image( - image_downloader: &ImageDownloaderClient, - job_id: &str, - index: u8, - app_data_root: &AppDataRoot -) -> AnyhowResult { - let url = get_image_url(job_id, index)?; - let parsed_url = Url::parse(&url)?; - - //let response = reqwest::get(&url).await?; - //let image_bytes = response.bytes().await?; - - let image_bytes = image_downloader.download_image(job_id, index).await?; - - let ext = parsed_url.path().split(".").last().unwrap_or("png"); - - let tempdir = app_data_root.temp_dir().path(); - let download_filename = format!("{}_{}.{}", job_id, index, ext); - let download_path = tempdir.join(download_filename); - - let mut file = File::create(&download_path)?; - file.write_all(&image_bytes)?; - - Ok(download_path) -} diff --git a/crates/desktop/artcraft/src/services/midjourney/utils/mod.rs b/crates/desktop/artcraft/src/services/midjourney/utils/mod.rs deleted file mode 100644 index acf0cc90dc..0000000000 --- a/crates/desktop/artcraft/src/services/midjourney/utils/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod download_midjourney_image; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/services/midjourney/windows/extract_midjourney_webview_cookies.rs b/crates/desktop/artcraft/src/services/midjourney/windows/extract_midjourney_webview_cookies.rs deleted file mode 100644 index 9c348c2de8..0000000000 --- a/crates/desktop/artcraft/src/services/midjourney/windows/extract_midjourney_webview_cookies.rs +++ /dev/null @@ -1,46 +0,0 @@ -use cookie_store::cookie_store::CookieStore; -use errors::AnyhowResult; -use once_cell::sync::Lazy; -use reqwest::Url; -use std::collections::HashSet; -use tauri::webview::Cookie; -use tauri::WebviewWindow; - -static WWW_COOKIE_URL: Lazy = Lazy::new(|| { - Url::parse("https://www.midjourney.com").expect("URL should parse") -}); - -static ROOT_COOKIE_URL: Lazy = Lazy::new(|| { - Url::parse("https://midjourney.com").expect("URL should parse") -}); - -pub fn extract_midjourney_webview_cookies(webview: &WebviewWindow) -> AnyhowResult { - let mut cookie_store = CookieStore::empty(); - let cookies = get_all_midjourney_cookies(webview)?; - for cookie in cookies.iter() { - cookie_store.add_cookie_name_and_value( - cookie.name().to_string(), - cookie.value().to_string(), - ); - } - Ok(cookie_store) -} - -fn get_all_midjourney_cookies(webview: &WebviewWindow) -> AnyhowResult> { - // NB: WWW domain contains the auth/session cookies. - // Root domain contains some other cookies, such as Cloudflare. - let www_cookies = webview.cookies_for_url(WWW_COOKIE_URL.clone())?; - let root_cookies = webview.cookies_for_url(ROOT_COOKIE_URL.clone())?; - - let mut all_cookies = www_cookies; - let mut cookie_names = HashSet::new(); - - for cookie in root_cookies.iter() { - if !cookie_names.contains(cookie.name()) { - cookie_names.insert(cookie.name().to_string()); - all_cookies.push(cookie.clone()); - } - } - - Ok(all_cookies) -} diff --git a/crates/desktop/artcraft/src/services/midjourney/windows/midjourney_login_window_thread.rs b/crates/desktop/artcraft/src/services/midjourney/windows/midjourney_login_window_thread.rs deleted file mode 100644 index 55a267eb51..0000000000 --- a/crates/desktop/artcraft/src/services/midjourney/windows/midjourney_login_window_thread.rs +++ /dev/null @@ -1,185 +0,0 @@ -use crate::core::events::basic_sendable_event_trait::BasicSendableEvent; -use crate::core::events::functional_events::refresh_account_state_event::RefreshAccountStateEvent; -use crate::core::events::generation_events::common::{GenerationAction, GenerationServiceProvider}; -use crate::core::events::generation_events::generation_complete_event::GenerationCompleteEvent; -use crate::core::events::sendable_event_trait::SendableEvent; -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::core::utils::window::get_webview_window_hostname::get_webview_window_hostname; -use crate::services::midjourney::state::midjourney_credential_manager::MidjourneyCredentialManager; -use crate::services::midjourney::state::midjourney_user_info::MidjourneyUserInfo; -use crate::services::midjourney::windows::extract_midjourney_webview_cookies::extract_midjourney_webview_cookies; -use crate::services::midjourney::windows::open_midjourney_login_window::MIDJOURNEY_LOGIN_WINDOW_NAME; -use crate::services::sora::events::sora_login_success_event::SoraLoginSuccessEvent; -use crate::services::sora::state::sora_credential_manager::SoraCredentialManager; -use crate::services::sora::windows::sora_login_window::extract_sora_webview_cookies::extract_sora_webview_cookies; -use anyhow::anyhow; -use cookie_store::cookie_store::CookieStore; -use enums::common::generation_provider::GenerationProvider; -use errors::AnyhowResult; -use log::{error, info}; -use midjourney_client::client::midjourney_hostname::MidjourneyHostname; -use midjourney_client::credentials::cookie_store_has_auth_cookies::cookie_store_has_auth_cookies; -use midjourney_client::recipes::get_user_info::{get_user_info, GetUserInfoRequest}; -use openai_sora_client::creds::sora_credential_set::SoraCredentialSet; -use openai_sora_client::recipes::maybe_upgrade_or_renew_session::maybe_upgrade_or_renew_session; -use openai_sora_client::utils::has_session_cookie::{has_session_cookie, SessionCookiePresence}; -use tauri::{AppHandle, Manager, WebviewWindow}; - -pub async fn midjourney_login_window_thread( - app: AppHandle, - app_data_root: AppDataRoot, - mj_creds_manager: MidjourneyCredentialManager, -) { - let mut visited_login = false; - - loop { - let login_webview_window = match app.get_webview_window(MIDJOURNEY_LOGIN_WINDOW_NAME) { - Some(webview) => webview, - None => { - info!("Exit midjourney login thread."); - return; // NB: Only exit if we don't have the webview. - } - }; - - let result = check_login_window( - &app, - &login_webview_window, - &app_data_root, - &mj_creds_manager, - &mut visited_login, - ).await; - - match result { - Err(err) => { - error!("Error checking login window: {:?}", err); - } - Ok(false) => {} // Continue iteration and try again... - Ok(true) => { - info!("Successfully saved cookies from login window. Closing."); - if let Err(err) = login_webview_window.close() { - error!("Error closing login window: {:?}", err); - } - return; - } - } - - tokio::time::sleep(std::time::Duration::from_millis(2_000)).await; - } -} - -/// Returns true if we can exit. -async fn check_login_window( - app_handle: &AppHandle, - webview_window: &WebviewWindow, - app_data_root: &AppDataRoot, - mj_creds_manager: &MidjourneyCredentialManager, - visited_login: &mut bool, -) -> AnyhowResult { - - /* Login flow looks like this: - - 1. Start: https://www.midjourney.com/auth/signin - 2. SSO / Google Login (etc): https://accounts.google.com/v3/signin/challenge/pwd?[query] - 3. Done / Landing: https://www.midjourney.com/... - */ - - let hostname = get_webview_window_hostname(webview_window)?; - - let mut maybe_at_destination = false; - - match hostname.as_str() { - "www.midjourney.com" | - "midjourney.com" - => { - maybe_at_destination = true; - } - // chatgpt.com/auth is also an auth domain - "auth.openai.com" | - "accounts.google.com" | - "accounts.youtube.com" | - "login.live.com" | - "appleid.apple.com" - => { - // NB: We're in auth flow. - info!("Midjourney webview is in auth flow; hostname `{}`.", hostname); - *visited_login = true; - return Ok(false) - } - _ => {}, // We just don't know... - } - - let cookie_store = extract_midjourney_webview_cookies(webview_window)?; - - let maybe_has_auth_cookies = cookie_store_has_auth_cookies(&cookie_store); - let maybe_has_enough_cookies = cookie_store.len() > 6; - let maybe_completed_login_cycle = *visited_login && maybe_at_destination; - - // Misc cookies without login cookies are ~1055 length - // AUTH_I is ~1500 length - // AUTH_R is ~500 length - let maybe_has_big_enough_cookie = cookie_store.calculate_approx_cookie_character_length() > 2100; - - let mut heuristic_count = 0; - - if maybe_has_auth_cookies { - heuristic_count += 1; - } - if maybe_has_enough_cookies { - heuristic_count += 1; - } - if maybe_completed_login_cycle { - heuristic_count += 1; - } - if maybe_has_big_enough_cookie { - heuristic_count += 1; - } - - if heuristic_count < 3 { - return Ok(false); - } - - info!("Heuristic count is ({}); we're likely done.", heuristic_count); - - info!("Current cookies (len {}): {:?}", cookie_store.len(), cookie_store.to_cookie_string()); - - let response = get_user_info(GetUserInfoRequest { - hostname: MidjourneyHostname::Standard, - cookie_header: cookie_store.to_cookie_string(), - }).await; - - match response { - Err(err) => { - error!("Error getting midjourney user info: {:?}", err); - // NB: Fall through. Allow us to update the cookies. - } - Ok(user_info) => { - info!("Got midjourney user info: {:?}", user_info); - let user_info = MidjourneyUserInfo::from_api_response(user_info); - - if let Err(err) = mj_creds_manager.replace_user_info(user_info) { - error!("Error saving midjourney user info: {:?}", err); - // NB: Fall through. Allow us to update the cookies. - } - } - } - - mj_creds_manager.replace_cookie_store(cookie_store)?; - - let result = mj_creds_manager.persist_to_disk(); - - if let Err(err) = result { - error!("Error persisting midjourney cookies to disk: {:?}", err); - return Ok(false); - } - - let event = RefreshAccountStateEvent { - provider: Some(GenerationProvider::Midjourney), - }; - - if let Err(err) = event.send(&app_handle) { - error!("Failed to send RefreshAccountStateEvent: {:?}", err); // Fail open - } - - Ok(true) -} - diff --git a/crates/desktop/artcraft/src/services/midjourney/windows/mod.rs b/crates/desktop/artcraft/src/services/midjourney/windows/mod.rs deleted file mode 100644 index b5417787da..0000000000 --- a/crates/desktop/artcraft/src/services/midjourney/windows/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub mod extract_midjourney_webview_cookies; -pub mod midjourney_login_window_thread; -pub mod open_midjourney_login_window; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/services/midjourney/windows/open_midjourney_login_window.rs b/crates/desktop/artcraft/src/services/midjourney/windows/open_midjourney_login_window.rs deleted file mode 100644 index 8d536c08ea..0000000000 --- a/crates/desktop/artcraft/src/services/midjourney/windows/open_midjourney_login_window.rs +++ /dev/null @@ -1,78 +0,0 @@ -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::core::utils::clear_all_webview_cookies::clear_all_webview_cookies; -use crate::services::midjourney::state::midjourney_credential_manager::MidjourneyCredentialManager; -use crate::services::midjourney::windows::midjourney_login_window_thread::midjourney_login_window_thread; -use anyhow::anyhow; -use errors::AnyhowResult; -use once_cell::sync::Lazy; -use reqwest::Url; -use std::time::Duration; -use tauri::{AppHandle, Manager, WebviewUrl, WebviewWindowBuilder}; - -/// Name of the window -pub (super) const MIDJOURNEY_LOGIN_WINDOW_NAME: &str = "midjourney_login_window"; - -pub (super) const MIDJOURNEY_START_URL_STR: &str = "https://google.com"; - -pub (super) static START_URL: Lazy = Lazy::new(|| { - Url::parse(MIDJOURNEY_START_URL_STR).expect("URL should parse") -}); - -pub (super) const MIDJOURNEY_HOMEPAGE_URL_STR: &str = "https://www.midjourney.com/"; - -pub (super) static MIDJOURNEY_HOMEPAGE_URL: Lazy = Lazy::new(|| { - Url::parse(MIDJOURNEY_HOMEPAGE_URL_STR).expect("URL should parse") -}); - -pub (super) const MIDJOURNEY_LOGIN_URL_STR: &str = "https://www.midjourney.com/auth/signin"; - -pub (super) static MIDJOURNEY_LOGIN_URL: Lazy = Lazy::new(|| { - Url::parse(MIDJOURNEY_LOGIN_URL_STR).expect("URL should parse") -}); - -pub async fn open_midjourney_login_window( - app: &AppHandle, - app_data_root: &AppDataRoot, - mj_creds_manager: &MidjourneyCredentialManager, -) -> AnyhowResult<()> { - if app.get_window(MIDJOURNEY_LOGIN_WINDOW_NAME).is_some() { - return Err(anyhow!("Login window already open")); - } - - let url = WebviewUrl::External(START_URL.clone()); - - let window = WebviewWindowBuilder::new(app, MIDJOURNEY_LOGIN_WINDOW_NAME, url) - //.user_agent(openai_sora_client::credentials::USER_AGENT) - .always_on_top(false) - .title("Login to Midjourney") - .center() - .resizable(true) - .visible(true) - .closable(true) - .min_inner_size(200.0, 800.0) - .focused(true) - .devtools(true) - .build()?; - - let webview = window.get_webview(MIDJOURNEY_LOGIN_WINDOW_NAME) - .ok_or_else(|| anyhow!("no webview found"))?; - - clear_all_webview_cookies(&webview)?; - - webview.navigate(MIDJOURNEY_HOMEPAGE_URL.clone())?; - - // NB: We're starting to get Cloudflare protection screens. Let's try to avoid. - tokio::time::sleep(Duration::from_millis(100)).await; - - webview.navigate(MIDJOURNEY_LOGIN_URL.clone())?; - - let app_handle = app.clone(); - let app_data_root = app_data_root.clone(); - let mj_creds_manager= mj_creds_manager.clone(); - - let _ = tauri::async_runtime::spawn(async move { - midjourney_login_window_thread(app_handle, app_data_root, mj_creds_manager).await; - }); - - Ok(()) -} diff --git a/crates/desktop/artcraft/src/services/mod.rs b/crates/desktop/artcraft/src/services/mod.rs deleted file mode 100644 index cea58b5941..0000000000 --- a/crates/desktop/artcraft/src/services/mod.rs +++ /dev/null @@ -1,5 +0,0 @@ -pub mod grok; -pub mod midjourney; -pub mod sora; -pub mod storyteller; -pub mod worldlabs; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/services/sora/commands/check_sora_session_command.rs b/crates/desktop/artcraft/src/services/sora/commands/check_sora_session_command.rs deleted file mode 100644 index 8bb241e972..0000000000 --- a/crates/desktop/artcraft/src/services/sora/commands/check_sora_session_command.rs +++ /dev/null @@ -1,109 +0,0 @@ -use crate::services::sora::state::sora_credential_manager::SoraCredentialManager; -use chrono::{TimeDelta, Utc}; -use errors::AnyhowResult; -use log::{error, info}; -use openai_sora_client::recipes::maybe_upgrade_or_renew_session::maybe_upgrade_or_renew_session; -use openai_sora_client::requests::list_classic_tasks::list_classic_tasks::list_classic_tasks; -use serde_derive::Serialize; -use std::ops::Add; -use tauri::{AppHandle, State}; - -const CACHE_PERIOD : TimeDelta = TimeDelta::milliseconds(1000 * 60 * 5); // 5 minutes - -#[derive(Serialize)] -#[serde(rename_all = "snake_case")] -pub struct CheckSoraSessionCommand { - pub state: SoraSessionState, - pub maybe_account_email: Option, -} - -#[derive(Serialize)] -#[serde(rename_all = "snake_case")] -pub enum SoraSessionState{ - #[serde(rename = "not_set_up")] - NotSetUp, - #[serde(rename = "expired_or_error")] - ExpiredOrError, - #[serde(rename = "valid")] - Valid, -} - -// TODO: Deprecate this -#[deprecated(note="Not 100% deprecated yet - it may still have uses. But use sora_get_credential_info_command instead.")] -#[tauri::command] -pub async fn check_sora_session_command( - app: AppHandle, - sora_creds_manager: State<'_, SoraCredentialManager>, -) -> Result { - info!("check_sora_session_command called"); - - match do_check(&sora_creds_manager).await { - Ok(state) => Ok(state), - Err(err) => { - error!("Error checking session state: {:?}", err); - Err(CheckSoraSessionCommand { - state: SoraSessionState::ExpiredOrError, - maybe_account_email: None, - }) - } - } -} - -async fn do_check( - sora_creds_manager: &SoraCredentialManager, -) -> AnyhowResult { - - let mut creds = match sora_creds_manager.get_credentials()? { - Some(creds) => creds, - None => { - return Ok(CheckSoraSessionCommand { - state: SoraSessionState::NotSetUp, - maybe_account_email: None, - }); - } - }; - - let mut needs_upgrade_or_check = false; - - let stats = sora_creds_manager.get_credential_stats()?; - - match stats.last_consecutive_credential_success { - None => { - info!("Session never checked, needs upgrade or status checking."); - needs_upgrade_or_check= true; - } - Some(last_success) => { - let now = chrono::Utc::now(); - let expires = last_success.add(CACHE_PERIOD); - if now.gt(&expires) { - info!("Session success expired, needs upgrade or status checking."); - needs_upgrade_or_check = true; - } - } - } - - let mut upgraded = false; - - if needs_upgrade_or_check { - info!("Attempting to upgrade session..."); - upgraded = maybe_upgrade_or_renew_session(&mut creds).await?; - info!("Attempting to check session..."); - list_classic_tasks(&creds).await?; // Intent here is to make sure the upgrade request worked. - sora_creds_manager.record_credential_success()?; - } - - if upgraded { - info!("Saving upgraded session to manager and disk..."); - sora_creds_manager.set_credentials(&creds)?; - sora_creds_manager.persist_all_to_disk()?; - } - - let maybe_account_email = creds - .jwt_bearer_token - .map(|token| token.jwt_claims().email.clone()); - - Ok(CheckSoraSessionCommand { - state: SoraSessionState::Valid, - maybe_account_email, - }) -} diff --git a/crates/desktop/artcraft/src/services/sora/commands/mod.rs b/crates/desktop/artcraft/src/services/sora/commands/mod.rs deleted file mode 100644 index 1693c5059c..0000000000 --- a/crates/desktop/artcraft/src/services/sora/commands/mod.rs +++ /dev/null @@ -1,4 +0,0 @@ -pub mod check_sora_session_command; -pub mod open_sora_login_command; -pub mod sora_get_credential_info_command; -pub mod sora_logout_command; diff --git a/crates/desktop/artcraft/src/services/sora/commands/open_sora_login_command.rs b/crates/desktop/artcraft/src/services/sora/commands/open_sora_login_command.rs deleted file mode 100644 index 946a969d2d..0000000000 --- a/crates/desktop/artcraft/src/services/sora/commands/open_sora_login_command.rs +++ /dev/null @@ -1,37 +0,0 @@ -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::services::sora::state::sora_credential_manager::SoraCredentialManager; -use crate::services::sora::windows::sora_login_window::open_sora_login_window::open_sora_login_window; -use errors::AnyhowResult; -use log::{error, info}; -use tauri::{AppHandle, State}; - -#[tauri::command] -pub async fn open_sora_login_command( - app: AppHandle, - app_data_root: State<'_, AppDataRoot>, - sora_creds_manager: State<'_, SoraCredentialManager>, -) -> Result { - info!("open_login_command called"); - - do_open_login(&app, &app_data_root, &sora_creds_manager) - .await - .map_err(|err| { - error!("Error opening login: {:?}", err); - format!("Error opening login: {:?}", err) - })?; - - Ok("result".to_string()) -} - -async fn do_open_login( - app: &AppHandle, - app_data_root: &AppDataRoot, - sora_creds_manager: &SoraCredentialManager, -) -> AnyhowResult<()> { - info!("Building login window..."); - - open_sora_login_window(app, app_data_root, sora_creds_manager).await?; - - info!("Done."); - Ok(()) -} diff --git a/crates/desktop/artcraft/src/services/sora/commands/sora_get_credential_info_command.rs b/crates/desktop/artcraft/src/services/sora/commands/sora_get_credential_info_command.rs deleted file mode 100644 index 3675f58ec0..0000000000 --- a/crates/desktop/artcraft/src/services/sora/commands/sora_get_credential_info_command.rs +++ /dev/null @@ -1,59 +0,0 @@ -use crate::core::commands::response::shorthand::{Response, ResponseOrErrorMessage}; -use crate::core::commands::response::success_response_wrapper::SerializeMarker; -use crate::services::midjourney::state::midjourney_credential_manager::MidjourneyCredentialManager; -use crate::services::sora::state::sora_credential_manager::SoraCredentialManager; -use errors::AnyhowResult; -use log::{error, info}; -use serde_derive::Serialize; -use tauri::State; - -#[derive(Serialize)] -pub struct SoraGetCredentialInfoResponse { - pub maybe_email: Option, - pub can_clear_state: bool, -} - -impl SerializeMarker for SoraGetCredentialInfoResponse {} - -#[tauri::command] -pub async fn sora_get_credential_info_command( - sora_creds_manager: State<'_, SoraCredentialManager>, -) -> ResponseOrErrorMessage { - info!("sora_get_credential_info_command called"); - - let info = get_info(&sora_creds_manager) - .map_err(|err| { - error!("Error getting info: {:?}", err); - "error getting info" - })?; - - Ok(info.into()) -} - -fn get_info( - sora_creds_manager: &SoraCredentialManager, -) -> AnyhowResult { - - let maybe_creds = sora_creds_manager.get_credentials()?; - - let mut can_clear_state = maybe_creds.is_some(); - let mut maybe_email = None; - - if let Some(creds) = maybe_creds { - if let Some(jwt) = &creds.jwt_bearer_token { - maybe_email = Some(jwt.jwt_claims().email.clone()); - } - - // TODO: This was cargo culted from Midjourney. Probably not quite right. - // We probably need an Option for cookie rather than an empty / partial string as - // well as timestamps, invalidation states, etc. - if creds.jwt_bearer_token.is_none() && creds.sora_sentinel.is_none() { - can_clear_state = false; - } - } - - Ok(SoraGetCredentialInfoResponse { - maybe_email, - can_clear_state, - }) -} diff --git a/crates/desktop/artcraft/src/services/sora/commands/sora_logout_command.rs b/crates/desktop/artcraft/src/services/sora/commands/sora_logout_command.rs deleted file mode 100644 index cfd8a51c2e..0000000000 --- a/crates/desktop/artcraft/src/services/sora/commands/sora_logout_command.rs +++ /dev/null @@ -1,28 +0,0 @@ -use crate::core::commands::response::shorthand::SimpleResponse; -use crate::services::sora::state::sora_credential_manager::SoraCredentialManager; -use log::{error, info}; -use tauri::State; - -#[tauri::command] -pub async fn sora_logout_command( - sora_creds_manager: State<'_, SoraCredentialManager>, -) -> SimpleResponse { - info!("sora_logout_command called"); - - if let Err(err) = sora_creds_manager.purge_credentials_from_disk() { - error!("Error purging credentials from disk: {:?}", err); - return Err("error purging credentials from disk".into()); - } - - if let Err(err) = sora_creds_manager.clear_credentials() { - error!("Error clearing credentials from memory: {:?}", err); - return Err("error clearing credentials from memory".into()); - } - - if let Err(err) = sora_creds_manager.reset_credential_stats() { - error!("Error resetting credential stats: {:?}", err); - return Err("error resetting credential stats".into()); - } - - Ok(().into()) -} diff --git a/crates/desktop/artcraft/src/services/sora/events/mod.rs b/crates/desktop/artcraft/src/services/sora/events/mod.rs deleted file mode 100644 index 770ae70f8d..0000000000 --- a/crates/desktop/artcraft/src/services/sora/events/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod sora_login_success_event; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/services/sora/events/sora_login_success_event.rs b/crates/desktop/artcraft/src/services/sora/events/sora_login_success_event.rs deleted file mode 100644 index cd09847a48..0000000000 --- a/crates/desktop/artcraft/src/services/sora/events/sora_login_success_event.rs +++ /dev/null @@ -1,11 +0,0 @@ -use crate::core::events::sendable_event_trait::SendableEvent; -use serde_derive::Serialize; - -#[derive(Debug, Clone, Serialize)] -pub struct SoraLoginSuccessEvent { - // TODO: Reason. -} - -impl SendableEvent for SoraLoginSuccessEvent { - const FRONTEND_EVENT_NAME: &'static str = "sora-login-success"; -} diff --git a/crates/desktop/artcraft/src/services/sora/mod.rs b/crates/desktop/artcraft/src/services/sora/mod.rs deleted file mode 100644 index 6f644a1f33..0000000000 --- a/crates/desktop/artcraft/src/services/sora/mod.rs +++ /dev/null @@ -1,9 +0,0 @@ -//! Deprecated direct Sora integration. Retained for legacy handlers and task polling. -//! New desktop generations use ArtCraft; account management is no longer exposed in the frontend. - -pub mod commands; -pub mod events; -pub mod state; -pub mod threads; -pub mod windows; -pub mod utils; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/services/sora/state/initialize_sora_jwt_bearer_token.rs b/crates/desktop/artcraft/src/services/sora/state/initialize_sora_jwt_bearer_token.rs deleted file mode 100644 index 5705cb165f..0000000000 --- a/crates/desktop/artcraft/src/services/sora/state/initialize_sora_jwt_bearer_token.rs +++ /dev/null @@ -1,28 +0,0 @@ -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use anyhow::anyhow; -use errors::AnyhowResult; -use log::info; -use openai_sora_client::requests::auth_bearer::generate_bearer_jwt_with_cookie::generate_bearer_jwt_with_cookie; - -/// Loading the JWT bearer token for the first time. -pub async fn initialize_sora_jwt_bearer_token(app_data_root: &AppDataRoot) -> AnyhowResult<()> { - if !app_data_root.get_sora_cookie_file_path().exists() { - return Err(anyhow!("Cookie file does not exist")); - } - - if app_data_root.get_sora_bearer_token_file_path().exists() { - return Ok(()); // Bearer token already exists. - } - - let cookie = std::fs::read_to_string(app_data_root.get_sora_cookie_file_path())? - .trim() - .to_string(); - - info!("Requesting initial JWT bearer token..."); - - let bearer = generate_bearer_jwt_with_cookie(&cookie).await?; - - std::fs::write(app_data_root.get_sora_bearer_token_file_path(), bearer)?; - - Ok(()) -} diff --git a/crates/desktop/artcraft/src/services/sora/state/mod.rs b/crates/desktop/artcraft/src/services/sora/state/mod.rs deleted file mode 100644 index ddc54a9f97..0000000000 --- a/crates/desktop/artcraft/src/services/sora/state/mod.rs +++ /dev/null @@ -1,7 +0,0 @@ -pub mod initialize_sora_jwt_bearer_token; -pub mod read_sora_credentials_from_disk; -pub mod read_sora_credentials_from_disk_with_upgrade; -pub mod sora_credential_holder; -pub mod sora_credential_manager; -pub mod sora_credential_stats; -pub mod sora_task_queue; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/services/sora/state/read_sora_credentials_from_disk.rs b/crates/desktop/artcraft/src/services/sora/state/read_sora_credentials_from_disk.rs deleted file mode 100644 index 7f4e2a6b48..0000000000 --- a/crates/desktop/artcraft/src/services/sora/state/read_sora_credentials_from_disk.rs +++ /dev/null @@ -1,60 +0,0 @@ -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use anyhow::anyhow; -use errors::AnyhowResult; -use openai_sora_client::creds::sora_cookies::SoraCookies; -use openai_sora_client::creds::sora_credential_set::SoraCredentialSet; -use openai_sora_client::creds::sora_jwt_bearer_token::SoraJwtBearerToken; -use openai_sora_client::creds::sora_sentinel::SoraSentinel; -use std::fs::read_to_string; -use openai_sora_client::creds::sora_sentinel_token::SoraSentinelToken; - -pub fn read_sora_credentials_from_disk(app_data_root: &AppDataRoot) -> AnyhowResult { - let cookie_file = app_data_root.get_sora_cookie_file_path(); - let bearer_file = app_data_root.get_sora_bearer_token_file_path(); - let legacy_sentinel_file = app_data_root.get_sora_legacy_sentinel_file_path(); - let sentinel_token_file = app_data_root.get_sora_sentinel_token_file_path(); - - if !cookie_file.exists() { - return Err(anyhow!("Cookie file does not exist: {:?}", cookie_file)); - } - - let value = read_to_string(cookie_file)? - .trim() - .to_string(); - - let cookie = SoraCookies::new(value); - - let mut bearer = None; - let mut sentinel = None; - let mut sentinel_token = None; - - if bearer_file.exists() { - let value = read_to_string(&bearer_file)? - .trim() - .to_string(); - bearer = Some(SoraJwtBearerToken::new(value)?); - } - - if legacy_sentinel_file.exists() { - let value = read_to_string(&legacy_sentinel_file)? - .trim() - .to_string(); - - sentinel = Some(SoraSentinel::new(value)); - } - - if sentinel_token_file.exists() { - let value = read_to_string(&sentinel_token_file)? - .trim() - .to_string(); - - sentinel_token = Some(SoraSentinelToken::from_persistent_storage_json(&value)?); - } - - Ok(SoraCredentialSet::initialize( - cookie, - bearer, - sentinel, - sentinel_token, - )) -} diff --git a/crates/desktop/artcraft/src/services/sora/state/read_sora_credentials_from_disk_with_upgrade.rs b/crates/desktop/artcraft/src/services/sora/state/read_sora_credentials_from_disk_with_upgrade.rs deleted file mode 100644 index 7538a1a067..0000000000 --- a/crates/desktop/artcraft/src/services/sora/state/read_sora_credentials_from_disk_with_upgrade.rs +++ /dev/null @@ -1,120 +0,0 @@ -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use anyhow::anyhow; -use errors::AnyhowResult; -use log::{info, warn}; -use openai_sora_client::creds::sora_cookies::SoraCookies; -use openai_sora_client::creds::sora_credential_set::SoraCredentialSet; -use openai_sora_client::creds::sora_jwt_bearer_token::SoraJwtBearerToken; -use openai_sora_client::creds::sora_sentinel::SoraSentinel; -use openai_sora_client::creds::sora_sentinel_token::SoraSentinelToken; -use openai_sora_client::recipes::maybe_upgrade_or_renew_session::maybe_upgrade_or_renew_session; -use std::fs::{read_to_string, OpenOptions}; -use std::io::Write; - -pub async fn read_sora_credentials_from_disk_with_upgrade(app_data_root: &AppDataRoot) -> AnyhowResult { - let cookie_file = app_data_root.get_sora_cookie_file_path(); - let bearer_file = app_data_root.get_sora_bearer_token_file_path(); - let legacy_sentinel_file = app_data_root.get_sora_legacy_sentinel_file_path(); - let sentinel_token_file = app_data_root.get_sora_sentinel_token_file_path(); - - if !cookie_file.exists() { - return Err(anyhow!("Cookie file does not exist: {:?}", cookie_file)); - } - - let value = read_to_string(cookie_file)? - .trim() - .to_string(); - - let cookie = SoraCookies::new(value); - - let mut bearer = None; - let mut sentinel = None; - let mut sentinel_token = None; - - if bearer_file.exists() { - let value = read_to_string(&bearer_file)? - .trim() - .to_string(); - bearer = Some(SoraJwtBearerToken::new(value)?); - } - - if legacy_sentinel_file.exists() { - let value = read_to_string(&legacy_sentinel_file)? - .trim() - .to_string(); - - sentinel = Some(SoraSentinel::new(value)); - } - - if sentinel_token_file.exists() { - let value = read_to_string(&sentinel_token_file)? - .trim() - .to_string(); - - sentinel_token = Some(SoraSentinelToken::from_persistent_storage_json(&value)?); - } - - let mut credentials = SoraCredentialSet::initialize( - cookie, - bearer, - sentinel, - sentinel_token, - ); - - let response = maybe_upgrade_or_renew_session(&mut credentials).await; - - if let Err(err) = response { - // NB: Make this portion infallible. Don't die on setup. We can recover downstream. - warn!("Failed to upgrade or renew session: {:?}", err); - } - - if !bearer_file.exists() { - if let Some(bearer) = &credentials.jwt_bearer_token { - info!("Persisting bearer token value..."); - let value = bearer.token_str(); - - let mut file = OpenOptions::new() - .create(true) - .write(true) - .truncate(true) - .open(&bearer_file)?; - - file.write_all(value.as_bytes())?; - file.flush()?; - } - } - - if !legacy_sentinel_file.exists() { - if let Some(sentinel) = &credentials.sora_sentinel { - info!("Persisting sentinel value..."); - let value = sentinel.get_sentinel(); - - let mut file = OpenOptions::new() - .create(true) - .write(true) - .truncate(true) - .open(&legacy_sentinel_file)?; - - file.write_all(value.as_bytes())?; - file.flush()?; - } - } - - if !sentinel_token_file.exists() { - if let Some(sentinel_token) = &credentials.sora_sentinel_token { - info!("Persisting sentinel token..."); - let value = sentinel_token.to_persistent_storage_json()?; - - let mut file = OpenOptions::new() - .create(true) - .write(true) - .truncate(true) - .open(&sentinel_token_file)?; - - file.write_all(value.as_bytes())?; - file.flush()?; - } - } - - Ok(credentials) -} diff --git a/crates/desktop/artcraft/src/services/sora/state/sora_credential_holder.rs b/crates/desktop/artcraft/src/services/sora/state/sora_credential_holder.rs deleted file mode 100644 index 4efff6a551..0000000000 --- a/crates/desktop/artcraft/src/services/sora/state/sora_credential_holder.rs +++ /dev/null @@ -1,73 +0,0 @@ -use anyhow::anyhow; -use errors::AnyhowResult; -use openai_sora_client::creds::sora_credential_set::SoraCredentialSet; -use std::sync::{Arc, RwLock}; - -/// Hold credentials for the application. -#[derive(Clone)] -pub struct SoraCredentialHolder { - credentials: Arc>>, -} - -impl SoraCredentialHolder { - pub fn new() -> Self { - Self { - credentials: Arc::new(RwLock::new(None)), - } - } - - pub fn set_credentials(&self, credentials: &SoraCredentialSet) -> AnyhowResult<()> { - match self.credentials.write() { - Err(err) => Err(anyhow!("Failed to acquire write lock: {:?}", err)), - Ok(mut creds) => { - *creds = Some(credentials.clone()); - Ok(()) - } - } - } - - pub fn clear_credentials(&self) -> AnyhowResult<()> { - match self.credentials.write() { - Err(err) => Err(anyhow!("Failed to acquire write lock: {:?}", err)), - Ok(mut creds) => { - *creds = None; - Ok(()) - } - } - } - - pub fn get_credentials(&self) -> AnyhowResult> { - match self.credentials.read() { - Err(err) => Err(anyhow!("Failed to acquire read lock: {:?}", err)), - Ok(creds) => { - Ok(creds.clone()) - } - } - } - - pub fn get_credentials_required(&self) -> AnyhowResult { - match self.credentials.read() { - Err(err) => Err(anyhow!("Failed to acquire read lock: {:?}", err)), - Ok(creds) => match &*creds { - None => Err(anyhow!("Credentials not set")), - Some(creds) => Ok(creds.clone()), - } - } - } - - /// This does not guarantee the credentials are correct, just that they're set. - pub fn has_apparently_complete_credentials(&self) -> AnyhowResult { - match self.credentials.read() { - Err(err) => Err(anyhow!("Failed to acquire read lock: {:?}", err)), - Ok(creds) => match &*creds { - None => Ok(false), - Some(creds) => { - let has_cookies = !creds.cookies.as_str().is_empty(); - let has_bearer = creds.jwt_bearer_token.is_some(); - let has_sentinel = creds.sora_sentinel.is_some(); - Ok(has_cookies && has_bearer && has_sentinel) - }, - } - } - } -} diff --git a/crates/desktop/artcraft/src/services/sora/state/sora_credential_manager.rs b/crates/desktop/artcraft/src/services/sora/state/sora_credential_manager.rs deleted file mode 100644 index e10ddcf3f6..0000000000 --- a/crates/desktop/artcraft/src/services/sora/state/sora_credential_manager.rs +++ /dev/null @@ -1,229 +0,0 @@ -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::services::sora::state::read_sora_credentials_from_disk::read_sora_credentials_from_disk; -use crate::services::sora::state::sora_credential_holder::SoraCredentialHolder; -use crate::services::sora::state::sora_credential_stats::SoraCredentialStats; -use errors::AnyhowResult; -use log::{error, info, warn}; -use memory_store::clone_cell::CloneCell; -use openai_sora_client::creds::sora_cookies::SoraCookies; -use openai_sora_client::creds::sora_credential_set::SoraCredentialSet; -use openai_sora_client::creds::sora_jwt_bearer_token::SoraJwtBearerToken; -use openai_sora_client::creds::sora_sentinel::SoraSentinel; -use openai_sora_client::requests::auth_sentinel::generate_sentinel_token::generate_sentinel_token; -use std::fs::OpenOptions; -use std::io::Write; -use std::path::Path; -use std::{fs, io}; - -#[derive(Clone)] -pub struct SoraCredentialManager { - holder: SoraCredentialHolder, - app_data_root: AppDataRoot, - - /// This is meant to help debug credential issues, keep credentials cached, fresh, etc. - // TODO: Put this into the same structure as the credentials and also persist to disk. - stats: CloneCell, -} - -impl SoraCredentialManager { - - pub fn initialize_from_disk_infallible(app_data_root: &AppDataRoot) -> Self { - let holder = SoraCredentialHolder::new(); - - match read_sora_credentials_from_disk(app_data_root) { - Err(err) => warn!("Failed to read credentials from disk: {:?}", err), - Ok(creds) => { - holder.set_credentials(&creds).expect("Failed to set credentials"); - } - } - - Self { - holder, - app_data_root: app_data_root.clone(), - stats: CloneCell::with_owned(SoraCredentialStats::new()), - } - } - - pub fn record_credential_success(&self) -> AnyhowResult<()> { - let mut stats = self.stats.get_clone()?; - stats.record_credential_success(); - self.stats.set_owned(stats)?; - Ok(()) - } - - pub fn record_credential_failure(&self) -> AnyhowResult<()> { - let mut stats = self.stats.get_clone()?; - stats.record_credential_failure(); - self.stats.set_owned(stats)?; - Ok(()) - } - - pub fn reset_credential_stats(&self) -> AnyhowResult<()> { - self.stats.set_owned(SoraCredentialStats::new()) - } - - /// This does not guarantee the credentials are correct - pub fn has_apparently_complete_credentials(&self) -> AnyhowResult { - self.holder.has_apparently_complete_credentials() - } - - pub fn get_credential_stats(&self) -> AnyhowResult { - self.stats.get_clone() - } - - pub fn set_credential_stats(&self, stats: SoraCredentialStats) -> AnyhowResult<()> { - self.stats.set_owned(stats) - } - - pub fn set_credentials(&self, creds: &SoraCredentialSet) -> AnyhowResult<()> { - self.holder.set_credentials(creds) - } - - pub fn clear_credentials(&self) -> AnyhowResult<()> { - self.holder.clear_credentials()?; - Ok(()) - } - - /// This is meant to be infallible. - pub fn purge_credentials_from_disk(&self) -> Result<(), io::Error> { - let creds_dir = self.app_data_root.credentials_dir(); - - remove_file_if_exists(creds_dir.get_sora_cookie_file_path())?; - remove_file_if_exists(creds_dir.get_sora_bearer_token_file_path())?; - remove_file_if_exists(creds_dir.get_sora_legacy_sentinel_file_path())?; - - Ok(()) - } - - /// This is meant to be infallible. - pub fn try_purge_credentials_from_disk(&self) { - let creds_dir = self.app_data_root.credentials_dir(); - if let Err(err) = fs::remove_file(creds_dir.get_sora_cookie_file_path()) { - error!("Failed to remove cookie file: {:?}", err); - } - if let Err(err) = fs::remove_file(creds_dir.get_sora_bearer_token_file_path()) { - error!("Failed to remove bearer token file: {:?}", err); - } - if let Err(err) = fs::remove_file(creds_dir.get_sora_legacy_sentinel_file_path()) { - error!("Failed to remove sentinel file: {:?}", err); - } - } - - pub fn get_credentials(&self) -> AnyhowResult> { - self.holder.get_credentials() - } - - pub fn get_credentials_required(&self) -> AnyhowResult { - self.holder.get_credentials_required() - } - - pub fn reset_from_disk(&self) -> AnyhowResult { - let creds = read_sora_credentials_from_disk(&self.app_data_root)?; - self.holder.set_credentials(&creds)?; - Ok(creds) - } - - pub fn persist_all_to_disk(&self) -> AnyhowResult<()> { - let credentials = self.holder.get_credentials_required()?; - - info!("Persisting cookies to disk..."); - persist_cookies_to_disk(&credentials.cookies, &self.app_data_root)?; - - if let Some(bearer) = &credentials.jwt_bearer_token { - info!("Persisting JWT to disk..."); - persist_jwt_bearer_to_disk(bearer, &self.app_data_root)?; - } - - if let Some(sentinel) = &credentials.sora_sentinel { - info!("Persisting sentinel to disk..."); - persist_sentinel_to_disk(sentinel, &self.app_data_root)?; - } - - Ok(()) - } - - /// Refresh the sentinel token from Sora's API - pub async fn call_sentinel_refresh(&self) -> AnyhowResult { - // NB(bt,2025-04-21): Technically we don't need credentials to get a sentinel. - let mut creds = self.holder.get_credentials_required()?; - - info!("Generating token..."); - - let sentinel = generate_sentinel_token() - .await - .map_err(|err| { - error!("Failed to refresh: {:?}", err); - err - })?; - - info!("Token obtained."); - - creds.sora_sentinel = Some(SoraSentinel::new(sentinel.clone())); - - self.holder.set_credentials(&creds)?; - - let mut file = OpenOptions::new() - .create(true) - .write(true) - .truncate(true) - .open(self.app_data_root.get_sora_legacy_sentinel_file_path())?; - - file.write_all(sentinel.as_bytes())?; - file.flush()?; - - Ok(creds) - } -} - -fn persist_cookies_to_disk(cookies: &SoraCookies, app_data_root: &AppDataRoot) -> AnyhowResult<()> { - let filename = app_data_root.get_sora_cookie_file_path(); - - let mut file = OpenOptions::new() - .create(true) - .write(true) - .truncate(true) - .open(filename)?; - - file.write_all(cookies.as_bytes())?; - file.flush()?; - - Ok(()) -} - -fn persist_jwt_bearer_to_disk(bearer: &SoraJwtBearerToken, app_data_root: &AppDataRoot) -> AnyhowResult<()> { - let filename = app_data_root.get_sora_bearer_token_file_path(); - - let mut file = OpenOptions::new() - .create(true) - .write(true) - .truncate(true) - .open(filename)?; - - file.write_all(bearer.as_bytes())?; - file.flush()?; - - Ok(()) -} - -fn persist_sentinel_to_disk(sentinel: &SoraSentinel, app_data_root: &AppDataRoot) -> AnyhowResult<()> { - let filename = app_data_root.get_sora_legacy_sentinel_file_path(); - - let mut file = OpenOptions::new() - .create(true) - .write(true) - .truncate(true) - .open(filename)?; - - file.write_all(sentinel.as_bytes())?; - file.flush()?; - - Ok(()) -} - -fn remove_file_if_exists>(path: P) -> Result<(), io::Error> { - let p = path.as_ref(); - if p.exists() && p.is_file() { - fs::remove_file(p)?; - } - Ok(()) -} diff --git a/crates/desktop/artcraft/src/services/sora/state/sora_credential_stats.rs b/crates/desktop/artcraft/src/services/sora/state/sora_credential_stats.rs deleted file mode 100644 index dad71f43fd..0000000000 --- a/crates/desktop/artcraft/src/services/sora/state/sora_credential_stats.rs +++ /dev/null @@ -1,47 +0,0 @@ - -/// This is meant to track 401s and other credential failures, not 500s. -#[derive(Clone)] -pub struct SoraCredentialStats { - pub last_credential_failure: Option>, - pub last_credential_success: Option>, - pub credential_success_count: u32, - pub credential_failure_count: u32, - /// This resets on each failure - pub last_consecutive_credential_success: Option>, - /// This resets on each failure - pub consecutive_credential_success_count: u32, - /// This resets on each success - pub consecutive_credential_failure_count: u32, -} - -impl SoraCredentialStats { - pub fn new() -> Self { - Self { - last_credential_failure: None, - last_credential_success: None, - last_consecutive_credential_success: None, - credential_success_count: 0, - credential_failure_count: 0, - consecutive_credential_success_count: 0, - consecutive_credential_failure_count: 0, - } - } - - pub fn record_credential_success(&mut self) { - let now = chrono::Utc::now(); - self.last_credential_success = Some(now); - self.last_consecutive_credential_success = Some(now); - self.credential_success_count += 1; - self.consecutive_credential_success_count += 1; - self.consecutive_credential_failure_count = 0; - } - - pub fn record_credential_failure(&mut self) { - let now = chrono::Utc::now(); - self.last_credential_failure = Some(now); - self.last_consecutive_credential_success = None; - self.credential_failure_count += 1; - self.consecutive_credential_failure_count += 1; - self.consecutive_credential_success_count = 0; - } -} diff --git a/crates/desktop/artcraft/src/services/sora/state/sora_task_queue.rs b/crates/desktop/artcraft/src/services/sora/state/sora_task_queue.rs deleted file mode 100644 index 632272f9be..0000000000 --- a/crates/desktop/artcraft/src/services/sora/state/sora_task_queue.rs +++ /dev/null @@ -1,231 +0,0 @@ -use chrono::{DateTime, Utc}; -use errors::AnyhowResult; -use indexmap::IndexMap; -use openai_sora_client::requests::common::task_id::TaskId; -use std::collections::HashSet; -use std::sync::{Arc, RwLock}; - -#[derive(Clone)] -pub struct TaskDetails { - pub enqueue_time: DateTime -} - -impl TaskDetails { - pub fn new() -> Self { - Self { - enqueue_time: Utc::now() - } - } -} - -#[derive(Clone)] -pub struct TaskIdAndDetails { - pub task_id: TaskId, - pub details: TaskDetails, -} - -#[derive(Clone)] -pub struct SoraTaskQueue { - // Insertion-order map of task IDs to task details - queue: Arc>> -} - -impl SoraTaskQueue { - pub fn new() -> Self { - Self { - queue: Arc::new(RwLock::new(IndexMap::new())) - } - } - - /// Determine if queue is empty - /// This is an O(1) operation. - pub fn is_empty(&self) -> AnyhowResult { - match self.queue.read() { - Err(err) => { - Err(anyhow::anyhow!("Failed to acquire read lock: {:?}", err)) - } - Ok(lock) => Ok(lock.is_empty()) - } - } - - /// Get length of set - /// This is an O(1) operation. - pub fn len(&self) -> AnyhowResult { - match self.queue.read() { - Err(err) => { - Err(anyhow::anyhow!("Failed to acquire read lock: {:?}", err)) - } - Ok(lock) => Ok(lock.len()) - } - } - - /// Determine if the key is in the queue - /// This is an O(1) operation. - pub fn contains_key(&self, task_id: &TaskId) -> AnyhowResult { - match self.queue.read() { - Err(err) => { - Err(anyhow::anyhow!("Failed to acquire read lock: {:?}", err)) - } - Ok(lock) => Ok(lock.contains_key(task_id)) - } - } - - /// Get the first enqueued task - /// This is an O(1) operation. - pub fn first(&self) -> AnyhowResult> { - match self.queue.read() { - Err(err) => { - Err(anyhow::anyhow!("Failed to acquire read lock: {:?}", err)) - } - Ok(lock) => match lock.first() { - None => Ok(None), - Some((task_id, task_details)) => Ok(Some(TaskIdAndDetails { - task_id: task_id.clone(), - details: task_details.clone(), - })) - } - } - } - - /// Get the last enqueued task - /// This is an O(1) operation. - pub fn last(&self) -> AnyhowResult> { - match self.queue.read() { - Err(err) => { - Err(anyhow::anyhow!("Failed to acquire read lock: {:?}", err)) - } - Ok(lock) => match lock.last() { - None => Ok(None), - Some((task_id, task_details)) => Ok(Some(TaskIdAndDetails { - task_id: task_id.clone(), - details: task_details.clone(), - })) - } - } - } - - /// Insert a new task. If a task already exists, we update its value. - /// This is an O(1) operation. - pub fn insert(&self, task_id: &TaskId) -> AnyhowResult> { - match self.queue.write() { - Err(err) => { - Err(anyhow::anyhow!("Failed to acquire write lock: {:?}", err)) - } - Ok(mut lock) => { - // NB: Probably fine to compute TaskDetails here for now. We may eventually expose this if we include additional info. - let task_details = TaskDetails::new(); - Ok(lock.insert(task_id.clone(), task_details)) - } - } - } - - /// Remove a task by ID. - /// This is an O(n) operation. - pub fn remove(&self, task_id: &TaskId) -> AnyhowResult> { - match self.queue.write() { - Err(err) => { - Err(anyhow::anyhow!("Failed to acquire write lock: {:?}", err)) - } - Ok(mut lock) => { - Ok(lock.shift_remove(task_id)) - } - } - } - - /// Remove a list of tasks by ID. - /// This is an O(n) operation. - pub fn remove_list(&self, task_ids: &[&TaskId]) -> AnyhowResult<()> { - match self.queue.write() { - Err(err) => { - Err(anyhow::anyhow!("Failed to acquire write lock: {:?}", err)) - } - Ok(mut lock) => { - // TODO: Cleaner way to do this? - let mut set : HashSet<&TaskId, _> = HashSet::with_capacity(task_ids.len()); - set.extend(task_ids); - lock.retain(|k, v| !set.contains(k)); - Ok(()) - } - } - } -} - -#[cfg(test)] -mod tests { - use crate::services::sora::state::sora_task_queue::SoraTaskQueue; - use errors::AnyhowResult; - use openai_sora_client::requests::common::task_id::TaskId; - - #[test] - fn remove_list() -> AnyhowResult<()> { - let task_queue = SoraTaskQueue::new(); - - assert!(task_queue.is_empty()?); - assert_eq!(task_queue.len()?, 0); - - task_queue.insert(&TaskId("a".to_string()))?; - task_queue.insert(&TaskId("b".to_string()))?; - task_queue.insert(&TaskId("c".to_string()))?; - task_queue.insert(&TaskId("d".to_string()))?; - task_queue.insert(&TaskId("e".to_string()))?; - task_queue.insert(&TaskId("f".to_string()))?; - - assert!(!task_queue.is_empty()?); - assert_eq!(task_queue.len()?, 6); - - task_queue.insert(&TaskId("a".to_string()))?; - task_queue.insert(&TaskId("b".to_string()))?; - task_queue.insert(&TaskId("c".to_string()))?; - task_queue.insert(&TaskId("d".to_string()))?; - task_queue.insert(&TaskId("e".to_string()))?; - task_queue.insert(&TaskId("f".to_string()))?; - - assert!(!task_queue.is_empty()?); - assert_eq!(task_queue.len()?, 6); - - task_queue.remove_list(&[ - &TaskId("a".to_string()), - &TaskId("c".to_string()), - &TaskId("e".to_string()), - ])?; - - assert!(!task_queue.is_empty()?); - assert_eq!(task_queue.len()?, 3); - - assert!(task_queue.contains_key(&TaskId("b".to_string()))?); - assert!(task_queue.contains_key(&TaskId("d".to_string()))?); - assert!(task_queue.contains_key(&TaskId("f".to_string()))?); - - assert!(!task_queue.contains_key(&TaskId("a".to_string()))?); - assert!(!task_queue.contains_key(&TaskId("c".to_string()))?); - assert!(!task_queue.contains_key(&TaskId("e".to_string()))?); - - task_queue.remove_list(&[ - &TaskId("foo".to_string()), - &TaskId("bar".to_string()), - &TaskId("baz".to_string()), - ])?; - - assert!(!task_queue.is_empty()?); - assert_eq!(task_queue.len()?, 3); - - assert!(task_queue.contains_key(&TaskId("b".to_string()))?); - assert!(task_queue.contains_key(&TaskId("d".to_string()))?); - assert!(task_queue.contains_key(&TaskId("f".to_string()))?); - - task_queue.remove_list(&[ - &TaskId("b".to_string()), - &TaskId("d".to_string()), - &TaskId("f".to_string()), - ])?; - - assert!(task_queue.is_empty()?); - assert_eq!(task_queue.len()?, 0); - - assert!(!task_queue.contains_key(&TaskId("b".to_string()))?); - assert!(!task_queue.contains_key(&TaskId("d".to_string()))?); - assert!(!task_queue.contains_key(&TaskId("f".to_string()))?); - - Ok(()) - } -} \ No newline at end of file diff --git a/crates/desktop/artcraft/src/services/sora/threads/mod.rs b/crates/desktop/artcraft/src/services/sora/threads/mod.rs deleted file mode 100644 index eed888f841..0000000000 --- a/crates/desktop/artcraft/src/services/sora/threads/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod sora_task_polling; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/services/sora/threads/sora_task_polling/helpers/download_extension.rs b/crates/desktop/artcraft/src/services/sora/threads/sora_task_polling/helpers/download_extension.rs deleted file mode 100644 index a6841377a0..0000000000 --- a/crates/desktop/artcraft/src/services/sora/threads/sora_task_polling/helpers/download_extension.rs +++ /dev/null @@ -1,15 +0,0 @@ - -#[derive(Clone, Copy)] -pub enum DownloadExtension { - Png, - Mp4, -} - -impl DownloadExtension { - pub fn as_extension_without_period(&self) -> &'static str { - match self { - DownloadExtension::Png => "png", - DownloadExtension::Mp4 => "mp4", - } - } -} diff --git a/crates/desktop/artcraft/src/services/sora/threads/sora_task_polling/helpers/generation_type.rs b/crates/desktop/artcraft/src/services/sora/threads/sora_task_polling/helpers/generation_type.rs deleted file mode 100644 index 69f04c4911..0000000000 --- a/crates/desktop/artcraft/src/services/sora/threads/sora_task_polling/helpers/generation_type.rs +++ /dev/null @@ -1,6 +0,0 @@ - -#[derive(Copy, Clone, Eq, PartialEq)] -pub (super) enum GenerationType { - Image, - Video, -} diff --git a/crates/desktop/artcraft/src/services/sora/threads/sora_task_polling/helpers/handle_failed_generations.rs b/crates/desktop/artcraft/src/services/sora/threads/sora_task_polling/helpers/handle_failed_generations.rs deleted file mode 100644 index f5635c1c66..0000000000 --- a/crates/desktop/artcraft/src/services/sora/threads/sora_task_polling/helpers/handle_failed_generations.rs +++ /dev/null @@ -1,63 +0,0 @@ -use crate::core::events::basic_sendable_event_trait::BasicSendableEvent; -use crate::core::events::generation_events::common::{GenerationAction, GenerationServiceProvider}; -use crate::core::events::generation_events::generation_failed_event::GenerationFailedEvent; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::core::state::task_database::TaskDatabase; -use crate::services::sora::state::sora_task_queue::SoraTaskQueue; -use crate::services::sora::threads::sora_task_polling::helpers::handle_successful_generations::GenerationItem; -use enums::tauri::tasks::task_status; -use errors::AnyhowResult; -use log::info; -use openai_sora_client::requests::common::task_id::TaskId; -use openai_sora_client::requests::list_classic_tasks::list_classic_tasks::PartialTaskResponse; -use sqlite_tasks::queries::task::Task; -use sqlite_tasks::queries::update_task_status::{update_task_status, UpdateTaskArgs}; -use std::collections::HashMap; -use artcraft_client::credentials::storyteller_credential_set::StorytellerCredentialSet; -use tauri::AppHandle; - -pub struct FailedGeneration { - pub reason: Option, -} - -pub async fn handle_classic_failed_generations( - app_handle: &AppHandle, - task_database: &TaskDatabase, - local_sqlite_tasks_by_sora_task_id: &HashMap, - sora_failed_tasks_by_id: &HashMap, - sora_task_queue: &SoraTaskQueue, -) -> AnyhowResult<()> { - - for (task_id, task) in sora_failed_tasks_by_id.iter() { - // Emit events for failed tasks. - if local_sqlite_tasks_by_sora_task_id.contains_key(task_id.as_str()) { - let event = GenerationFailedEvent { - action: GenerationAction::GenerateImage, - service: GenerationServiceProvider::Sora, - model: None, - reason: task.reason.clone(), - }; - - event.send_infallible(&app_handle); - } - - // Clear from SQLite task database. - if let Some(local_task) = local_sqlite_tasks_by_sora_task_id.get(task_id.as_str()) { - info!("Marking local task as failed: {:?}", local_task.id); - - let _updated = update_task_status(UpdateTaskArgs { - db: task_database.get_connection(), - task_id: &local_task.id, - status: task_status::TaskStatus::CompleteFailure, - }).await?; - } - } - - // Clear from in memory DB - // TODO: Remove the in-memory queue in favor of SQLite only. - let failed_task_ids: Vec<&TaskId> = sora_failed_tasks_by_id.keys().collect(); - sora_task_queue.remove_list(&failed_task_ids)?; - - Ok(()) -} diff --git a/crates/desktop/artcraft/src/services/sora/threads/sora_task_polling/helpers/handle_successful_generations.rs b/crates/desktop/artcraft/src/services/sora/threads/sora_task_polling/helpers/handle_successful_generations.rs deleted file mode 100644 index 64bf2042c8..0000000000 --- a/crates/desktop/artcraft/src/services/sora/threads/sora_task_polling/helpers/handle_successful_generations.rs +++ /dev/null @@ -1,214 +0,0 @@ -use crate::core::events::basic_sendable_event_trait::BasicSendableEvent; -use crate::core::events::generation_events::common::{GenerationAction, GenerationServiceProvider}; -use crate::core::events::generation_events::generation_complete_event::GenerationCompleteEvent; -use crate::core::events::generation_events::generation_failed_event::GenerationFailedEvent; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::core::state::data_dir::trait_data_subdir::DataSubdir; -use crate::core::state::task_database::TaskDatabase; -use crate::core::utils::task_database_pending_statuses::TASK_DATABASE_PENDING_STATUSES; -use crate::services::sora::state::sora_credential_manager::SoraCredentialManager; -use crate::services::sora::state::sora_task_queue::SoraTaskQueue; -use crate::services::sora::threads::sora_task_polling::helpers::download_extension::DownloadExtension; -use crate::services::sora::threads::sora_task_polling::helpers::generation_type::GenerationType; -use crate::services::sora::threads::sora_task_polling::helpers::upload_generation_to_backend::{upload_generation_to_backend, UploadGenerationToBackendArgs}; -use crate::services::storyteller::state::storyteller_credential_manager::StorytellerCredentialManager; -use artcraft_api_defs::prompts::create_prompt::CreatePromptRequest; -use artcraft_api_defs::utils::media_links_to_thumbnail_template::media_links_to_thumbnail_template; -use enums::common::generation_provider::GenerationProvider; -use enums::common::generation::common_model_type::CommonModelType; -use enums::tauri::tasks::task_media_file_class::TaskMediaFileClass; -use errors::AnyhowResult; -use uuid_utils::uuid::generate_random_uuid; -use log::{error, info, warn}; -use once_cell::sync::Lazy; -use openai_sora_client::creds::sora_credential_set::SoraCredentialSet; -use openai_sora_client::recipes::list_classic_sora_tasks_with_session_auto_renew::list_classic_sora_tasks_with_session_auto_renew; -use openai_sora_client::requests::common::task_id::TaskId; -use openai_sora_client::requests::list_classic_tasks::list_classic_tasks::{PartialGeneration, PartialTaskResponse}; -use reqwest::Url; -use sqlite_tasks::queries::list_tasks_by_provider_and_status::{list_tasks_by_provider_and_status, ListTasksByProviderAndStatusArgs, TaskList}; -use sqlite_tasks::queries::task::Task; -use sqlite_tasks::queries::update_successful_task_status_with_metadata::{update_successful_task_status_with_metadata, UpdateSuccessfulTaskArgs}; -use sqlite_tasks::queries::update_task_status::{update_task_status, UpdateTaskArgs}; -use std::collections::{HashMap, HashSet}; -use std::fs::File; -use std::io::Write; -use std::path::PathBuf; -use artcraft_client::credentials::storyteller_credential_set::StorytellerCredentialSet; -use artcraft_client::endpoints::media_files::get_media_file::get_media_file; -use artcraft_client::endpoints::media_files::upload_image_media_file_from_file::{upload_image_media_file_from_file, UploadImageFromFileArgs}; -use artcraft_client::endpoints::media_files::upload_video_media_file_from_file::{upload_video_media_file_from_file, UploadVideoFromFileArgs}; -use artcraft_client::endpoints::prompts::create_prompt::create_prompt; -use tauri::AppHandle; -use tempdir::TempDir; -use url_utils::download_extension::extract_download_extension_from_url::{extract_download_extension_from_url, extract_download_extension_from_url_str}; - -pub struct SuccessfulGeneration { - pub prompt: Option, - pub items: Vec, - pub model_type: CommonModelType, -} - -pub struct GenerationItem { - pub item_id: String, - pub url: String, -} - -pub async fn handle_classic_successful_generations( - app_handle: &AppHandle, - app_data_root: &AppDataRoot, - app_env_configs: &AppEnvConfigs, - task_database: &TaskDatabase, - storyteller_creds: &StorytellerCredentialSet, - succeeded_tasks_by_id: &HashMap, - sqlite_tasks_by_sora_task_id: &HashMap, - recommended_download_extension: DownloadExtension, -) -> AnyhowResult<()> { - - for (task_id, generation) in succeeded_tasks_by_id.iter() { - if !sqlite_tasks_by_sora_task_id.contains_key(task_id.as_str()) { - continue; // Task is irrelevant - previously completed, generated elsewhere, etc. - } - - info!("Task succeeded: {:?}", task_id); - - let generation_type = match generation.model_type { - CommonModelType::GptImage1 => GenerationType::Image, - CommonModelType::Sora2 => GenerationType::Video, - _ => { - // Fallback - warn!("Unexpected model type: {:?}", generation.model_type); - GenerationType::Image - }, - }; - - let prompt_request = CreatePromptRequest { - uuid_idempotency_token: generate_random_uuid(), - positive_prompt: generation.prompt.clone(), - negative_prompt: None, - model_type: Some(generation.model_type), - generation_provider: Some(GenerationProvider::Sora), - maybe_generation_mode: None, - maybe_aspect_ratio: None, - maybe_resolution: None, - maybe_batch_count: None, - maybe_generate_audio: None, - maybe_duration_seconds: None, - }; - - let prompt_response = create_prompt( - &app_env_configs.storyteller_host, - Some(&storyteller_creds), - prompt_request - ).await?; - - info!("Created prompt: {:?}", &prompt_response.prompt_token); - - let mut maybe_primary_media_file_token = None; - - for (_i, item) in generation.items.iter().enumerate() { - info!("Downloading generated file..."); - let download_path = download_generation_item(item, &app_data_root, recommended_download_extension).await?; - - info!("Uploading to backend..."); - - let media_token = upload_generation_to_backend(UploadGenerationToBackendArgs { - storyteller_api_host: &app_env_configs.storyteller_host, - storyteller_creds: &storyteller_creds, - upload_path: download_path, - maybe_prompt_token: Some(&prompt_response.prompt_token), - maybe_batch_token: None, // TODO: This should be added soon. - generation_type, - }).await?; - - if maybe_primary_media_file_token.is_none() { - maybe_primary_media_file_token = Some(media_token.clone()); - } - } - - // Clear from SQLite task database. - if let Some(local_task) = sqlite_tasks_by_sora_task_id.get(task_id.as_str()) { - info!("Marking local task as succeeded: {:?}", local_task.id); - - let generation_class = match generation_type { - GenerationType::Image => TaskMediaFileClass::Image, - GenerationType::Video => TaskMediaFileClass::Video, - }; - - let mut maybe_cdn_url = None; - let mut maybe_thumbnail_url_template = None; - - if let Some(media_file_token) = maybe_primary_media_file_token.as_ref() { - info!("Looking up file to grab CDN and thumbnail URLs: {:?} ...", media_file_token); - - let lookup_result = get_media_file( - &app_env_configs.storyteller_host, - media_file_token, - ).await; - match lookup_result { - Ok(response) => { - maybe_cdn_url = Some(response.media_file.media_links.cdn_url.to_string()); - maybe_thumbnail_url_template = media_links_to_thumbnail_template(&response.media_file.media_links) - .map(|s| s.to_string()); - } - Err(err) => { - error!("Failed to look up media file after upload: {:?} (failing open)", err); - } - } - } - - let updated = update_successful_task_status_with_metadata(UpdateSuccessfulTaskArgs { - db: task_database.get_connection(), - task_id: &local_task.id, - maybe_batch_token: None, // TODO: Support when we have batches of items. - maybe_primary_media_file_token: maybe_primary_media_file_token.as_ref(), - maybe_primary_media_file_class: Some(generation_class), - maybe_primary_media_file_thumbnail_url_template: maybe_thumbnail_url_template.as_deref(), - maybe_primary_media_file_cdn_url: maybe_cdn_url.as_deref(), - }).await?; - - if updated { - // If anything breaks with queries, don't spam events. - let event = GenerationCompleteEvent { - action: Some(match generation_type { - GenerationType::Image => GenerationAction::GenerateImage, - GenerationType::Video => GenerationAction::GenerateVideo, - }), - service: GenerationServiceProvider::Sora, - model: None, - }; - - event.send_infallible(&app_handle); - } - } - } - - Ok(()) -} - -async fn download_generation_item( - generation: &GenerationItem, - app_data_root: &AppDataRoot, - recommended_download_extension: DownloadExtension -) -> AnyhowResult { - info!("Downloading generation item from URL: {}", generation.url.as_str()); - - let response = reqwest::get(&generation.url).await?; - let image_bytes = response.bytes().await?; - - let extension = extract_download_extension_from_url_str(&generation.url) - .map(|ext| ext.as_extension_without_period()) - .unwrap_or_else(|| recommended_download_extension.as_extension_without_period()); - - let tempdir = app_data_root.temp_dir().path(); - let download_filename = format!("{}.{}", generation.item_id, extension); - let download_path = tempdir.join(download_filename); - - info!("Writing to path: {:?}", download_path); - - let mut file = File::create(&download_path)?; - file.write_all(&image_bytes)?; - - Ok(download_path) -} diff --git a/crates/desktop/artcraft/src/services/sora/threads/sora_task_polling/helpers/mod.rs b/crates/desktop/artcraft/src/services/sora/threads/sora_task_polling/helpers/mod.rs deleted file mode 100644 index af3bc2a813..0000000000 --- a/crates/desktop/artcraft/src/services/sora/threads/sora_task_polling/helpers/mod.rs +++ /dev/null @@ -1,8 +0,0 @@ -pub (super) mod handle_successful_generations; -pub (super) mod handle_failed_generations; -pub (super) mod poll_classic_sora_tasks; -pub (super) mod poll_sora_2_tasks; -mod download_extension; -mod upload_metadata; -mod upload_generation_to_backend; -mod generation_type; diff --git a/crates/desktop/artcraft/src/services/sora/threads/sora_task_polling/helpers/poll_classic_sora_tasks.rs b/crates/desktop/artcraft/src/services/sora/threads/sora_task_polling/helpers/poll_classic_sora_tasks.rs deleted file mode 100644 index d09f6256fa..0000000000 --- a/crates/desktop/artcraft/src/services/sora/threads/sora_task_polling/helpers/poll_classic_sora_tasks.rs +++ /dev/null @@ -1,124 +0,0 @@ -use crate::core::events::basic_sendable_event_trait::BasicSendableEvent; -use crate::core::events::generation_events::common::{GenerationAction, GenerationServiceProvider}; -use crate::core::events::generation_events::generation_complete_event::GenerationCompleteEvent; -use crate::core::events::generation_events::generation_failed_event::GenerationFailedEvent; -use crate::core::events::sendable_event_trait::SendableEvent; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::core::state::data_dir::trait_data_subdir::DataSubdir; -use crate::core::state::task_database::TaskDatabase; -use crate::core::utils::task_database_pending_statuses::TASK_DATABASE_PENDING_STATUSES; -use crate::services::sora::state::sora_credential_manager::SoraCredentialManager; -use crate::services::sora::state::sora_task_queue::SoraTaskQueue; -use crate::services::sora::threads::sora_task_polling::helpers::download_extension::DownloadExtension; -use crate::services::sora::threads::sora_task_polling::helpers::handle_failed_generations::{handle_classic_failed_generations, FailedGeneration}; -use crate::services::sora::threads::sora_task_polling::helpers::handle_successful_generations::{handle_classic_successful_generations, GenerationItem, SuccessfulGeneration}; -use crate::services::storyteller::state::storyteller_credential_manager::StorytellerCredentialManager; -use artcraft_api_defs::prompts::create_prompt::CreatePromptRequest; -use enums::common::generation::common_model_type::CommonModelType; -use errors::AnyhowResult; -use uuid_utils::uuid::generate_random_uuid; -use log::{error, info, warn}; -use once_cell::sync::Lazy; -use openai_sora_client::creds::sora_credential_set::SoraCredentialSet; -use openai_sora_client::recipes::list_classic_sora_tasks_with_session_auto_renew::list_classic_sora_tasks_with_session_auto_renew; -use openai_sora_client::requests::common::task_id::TaskId; -use openai_sora_client::requests::list_classic_tasks::list_classic_tasks::TaskStatus; -use reqwest::Url; -use sqlite_tasks::queries::list_tasks_by_provider_and_status::{list_tasks_by_provider_and_status, ListTasksByProviderAndStatusArgs, TaskList}; -use sqlite_tasks::queries::task::Task; -use sqlite_tasks::queries::update_task_status::{update_task_status, UpdateTaskArgs}; -use std::collections::{HashMap, HashSet}; -use std::fs::File; -use std::io::Write; -use std::path::PathBuf; -use artcraft_client::endpoints::media_files::upload_image_media_file_from_file::{upload_image_media_file_from_file, UploadImageFromFileArgs}; -use artcraft_client::endpoints::prompts::create_prompt::create_prompt; -use tauri::AppHandle; -use tempdir::TempDir; - -pub async fn poll_classic_sora_tasks( - app_handle: &AppHandle, - app_env_configs: &AppEnvConfigs, - task_database: &TaskDatabase, - sora_creds_manager: &SoraCredentialManager, - sora_creds: &SoraCredentialSet, - storyteller_creds_manager: &StorytellerCredentialManager, - sora_task_queue: &SoraTaskQueue, - app_data_root: &AppDataRoot, - local_sqlite_tasks_by_sora_task_id: &HashMap, -) -> AnyhowResult<()> { - - let (sora_response, maybe_new_creds) = - list_classic_sora_tasks_with_session_auto_renew(&sora_creds).await?; - - if let Some(new_creds) = maybe_new_creds { - info!("Saving new credentials."); - sora_creds_manager.set_credentials(&new_creds)?; - } - - let sora_items = sora_response.task_responses; - - let mut sora_succeeded_tasks_by_id = HashMap::new(); - let mut sora_failed_tasks_by_id = HashMap::new(); - - let storyteller_creds = storyteller_creds_manager.get_credentials_required()?; - - for task in sora_items.iter() { - - match &task.status { - TaskStatus::Succeeded => { - sora_succeeded_tasks_by_id.insert( - task.id.clone(), - SuccessfulGeneration { - prompt: task.prompt.clone(), - model_type: CommonModelType::GptImage1, - items: task.generations.iter() - .map(|gen| { - GenerationItem { - item_id: gen.id.clone(), - url: gen.url.clone(), - } - }) - .collect(), - }); - } - TaskStatus::Failed => { - sora_failed_tasks_by_id.insert( - task.id.clone(), - FailedGeneration { - reason: None, // TODO: Add reason if available. - } - ); - } - TaskStatus::Queued => {} - TaskStatus::Running => {} - TaskStatus::Unknown(unknown_status) => { - warn!("Unknown task status: {:?}", unknown_status); - } - } - } - - // Clear dead tasks. - handle_classic_failed_generations( - &app_handle, - &task_database, - &local_sqlite_tasks_by_sora_task_id, - &sora_failed_tasks_by_id, - &sora_task_queue, - ).await?; - - // Process succeeded tasks. - handle_classic_successful_generations( - &app_handle, - &app_data_root, - &app_env_configs, - &task_database, - &storyteller_creds, - &sora_succeeded_tasks_by_id, - &local_sqlite_tasks_by_sora_task_id, - DownloadExtension::Png, - ).await?; - - Ok(()) -} diff --git a/crates/desktop/artcraft/src/services/sora/threads/sora_task_polling/helpers/poll_sora_2_tasks.rs b/crates/desktop/artcraft/src/services/sora/threads/sora_task_polling/helpers/poll_sora_2_tasks.rs deleted file mode 100644 index 65e96161fd..0000000000 --- a/crates/desktop/artcraft/src/services/sora/threads/sora_task_polling/helpers/poll_sora_2_tasks.rs +++ /dev/null @@ -1,117 +0,0 @@ -use crate::core::events::basic_sendable_event_trait::BasicSendableEvent; -use crate::core::events::generation_events::common::{GenerationAction, GenerationServiceProvider}; -use crate::core::events::generation_events::generation_complete_event::GenerationCompleteEvent; -use crate::core::events::generation_events::generation_failed_event::GenerationFailedEvent; -use crate::core::events::sendable_event_trait::SendableEvent; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::core::state::data_dir::trait_data_subdir::DataSubdir; -use crate::core::state::task_database::TaskDatabase; -use crate::core::utils::task_database_pending_statuses::TASK_DATABASE_PENDING_STATUSES; -use crate::services::sora::state::sora_credential_manager::SoraCredentialManager; -use crate::services::sora::state::sora_task_queue::SoraTaskQueue; -use crate::services::sora::threads::sora_task_polling::helpers::download_extension::DownloadExtension; -use crate::services::sora::threads::sora_task_polling::helpers::handle_failed_generations::{handle_classic_failed_generations, FailedGeneration}; -use crate::services::sora::threads::sora_task_polling::helpers::handle_successful_generations::{handle_classic_successful_generations, GenerationItem, SuccessfulGeneration}; -use crate::services::storyteller::state::storyteller_credential_manager::StorytellerCredentialManager; -use artcraft_api_defs::prompts::create_prompt::CreatePromptRequest; -use enums::common::generation::common_model_type::CommonModelType; -use errors::AnyhowResult; -use uuid_utils::uuid::generate_random_uuid; -use log::{error, info, warn}; -use once_cell::sync::Lazy; -use openai_sora_client::creds::sora_credential_set::SoraCredentialSet; -use openai_sora_client::recipes::list_classic_sora_tasks_with_session_auto_renew::list_classic_sora_tasks_with_session_auto_renew; -use openai_sora_client::recipes::list_sora2_drafts::list_sora2_drafts_with_session_auto_renew::list_sora2_drafts_with_session_auto_renew; -use openai_sora_client::requests::common::task_id::TaskId; -use openai_sora_client::requests::list_classic_tasks::list_classic_tasks::TaskStatus; -use openai_sora_client::requests::list_sora2_drafts::list_sora2_drafts::Draft; -use reqwest::Url; -use sqlite_tasks::queries::list_tasks_by_provider_and_status::{list_tasks_by_provider_and_status, ListTasksByProviderAndStatusArgs, TaskList}; -use sqlite_tasks::queries::task::Task; -use sqlite_tasks::queries::update_task_status::{update_task_status, UpdateTaskArgs}; -use std::collections::{HashMap, HashSet}; -use std::fs::File; -use std::io::Write; -use std::path::PathBuf; -use artcraft_client::endpoints::media_files::upload_image_media_file_from_file::{upload_image_media_file_from_file, UploadImageFromFileArgs}; -use artcraft_client::endpoints::prompts::create_prompt::create_prompt; -use tauri::AppHandle; -use tempdir::TempDir; - -pub async fn poll_sora_2_tasks( - app_handle: &AppHandle, - app_env_configs: &AppEnvConfigs, - task_database: &TaskDatabase, - sora_creds_manager: &SoraCredentialManager, - sora_creds: &SoraCredentialSet, - storyteller_creds_manager: &StorytellerCredentialManager, - sora_task_queue: &SoraTaskQueue, - app_data_root: &AppDataRoot, - local_sqlite_tasks_by_sora_task_id: &HashMap, -) -> AnyhowResult<()> { - - let (sora_response, maybe_new_creds) = - list_sora2_drafts_with_session_auto_renew(&sora_creds).await?; - - if let Some(new_creds) = maybe_new_creds { - info!("Saving new credentials."); - sora_creds_manager.set_credentials(&new_creds)?; - } - - let drafts = sora_response.drafts; - - let mut sora_succeeded_drafts_by_id = HashMap::new(); - let mut sora_failed_drafts_by_id = HashMap::new(); - - let storyteller_creds = storyteller_creds_manager.get_credentials_required()?; - - for draft in drafts.into_iter() { - match draft { - Draft::Success(success_draft) => { - sora_succeeded_drafts_by_id.insert( - success_draft.task_id, - SuccessfulGeneration { - prompt: Some(success_draft.prompt), - model_type: CommonModelType::Sora2, - items: vec![GenerationItem { - item_id: success_draft.id, - url: success_draft.url, - }] - }); - } - Draft::Failure(failed_draft) => { - sora_failed_drafts_by_id.insert( - failed_draft.task_id, - FailedGeneration { - reason: Some(failed_draft.reason_message) - } - ); - } - } - } - - // Clear dead tasks. - handle_classic_failed_generations( - &app_handle, - &task_database, - &local_sqlite_tasks_by_sora_task_id, - &sora_failed_drafts_by_id, - &sora_task_queue, - ).await?; - - // Process succeeded tasks. - handle_classic_successful_generations( - &app_handle, - &app_data_root, - &app_env_configs, - &task_database, - &storyteller_creds, - &sora_succeeded_drafts_by_id, - &local_sqlite_tasks_by_sora_task_id, - DownloadExtension::Mp4, - ).await?; - - Ok(()) -} - diff --git a/crates/desktop/artcraft/src/services/sora/threads/sora_task_polling/helpers/upload_generation_to_backend.rs b/crates/desktop/artcraft/src/services/sora/threads/sora_task_polling/helpers/upload_generation_to_backend.rs deleted file mode 100644 index 807feaa7b1..0000000000 --- a/crates/desktop/artcraft/src/services/sora/threads/sora_task_polling/helpers/upload_generation_to_backend.rs +++ /dev/null @@ -1,72 +0,0 @@ -use crate::services::sora::threads::sora_task_polling::helpers::generation_type::GenerationType; -use errors::AnyhowResult; -use log::info; -use std::path::Path; -use artcraft_client::credentials::storyteller_credential_set::StorytellerCredentialSet; -use artcraft_client::endpoints::media_files::upload_image_media_file_from_file::{upload_image_media_file_from_file, UploadImageFromFileArgs}; -use artcraft_client::endpoints::media_files::upload_video_media_file_from_file::{upload_video_media_file_from_file, UploadVideoFromFileArgs}; -use artcraft_client::utils::api_host::ApiHost; -use enums::common::generation_provider::GenerationProvider; -use tokens::tokens::batch_generations::BatchGenerationToken; -use tokens::tokens::media_files::MediaFileToken; -use tokens::tokens::prompts::PromptToken; - -pub(super) struct UploadGenerationToBackendArgs<'a, P: AsRef> { - pub storyteller_api_host: &'a ApiHost, - pub storyteller_creds: &'a StorytellerCredentialSet, - - /// The file we're uploading. - /// NB: Path needs to be owned for the request. - pub upload_path: P, - - /// If provided, this is the prompt that this image is associated with. - /// NOTE: Cannot set `is_intermediate_system_file = true` if this is set. - pub maybe_prompt_token: Option<&'a PromptToken>, - - // /// If provided, this is the service provider that created the image. - // /// NOTE: Cannot set `is_intermediate_system_file = true` if this is set. - // pub maybe_generation_provider: Option, - - /// If provided, this groups the file into a batch - /// TODO: This shouldn't be set clientside without the backend generating the token - /// and cryptographically securing it. But we need to go fast here. - pub maybe_batch_token: Option<&'a BatchGenerationToken>, - - /// The type of generation (image or video). - pub generation_type: GenerationType, -} - -pub(super) async fn upload_generation_to_backend>(args: UploadGenerationToBackendArgs<'_, P>) -> AnyhowResult { - let media_token; - - match args.generation_type { - GenerationType::Image => { - let result = upload_image_media_file_from_file(UploadImageFromFileArgs { - api_host: &args.storyteller_api_host, - maybe_creds: Some(&args.storyteller_creds), - path: args.upload_path, - is_intermediate_system_file: false, - maybe_prompt_token: args.maybe_prompt_token, - maybe_batch_token: None, // TODO: This should be added soon. - maybe_generation_provider: Some(GenerationProvider::Sora), - }).await?; - - info!("Uploaded image to API backend: {:?}", result.media_file_token); - media_token = result.media_file_token; - } - GenerationType::Video => { - let result = upload_video_media_file_from_file(UploadVideoFromFileArgs { - api_host: &args.storyteller_api_host, - maybe_creds: Some(&args.storyteller_creds), - path: args.upload_path, - maybe_prompt_token: args.maybe_prompt_token, - maybe_generation_provider: Some(GenerationProvider::Sora), - }).await?; - - info!("Uploaded video to API backend: {:?}", result.media_file_token); - media_token = result.media_file_token; - } - } - - Ok(media_token) -} diff --git a/crates/desktop/artcraft/src/services/sora/threads/sora_task_polling/helpers/upload_metadata.rs b/crates/desktop/artcraft/src/services/sora/threads/sora_task_polling/helpers/upload_metadata.rs deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/crates/desktop/artcraft/src/services/sora/threads/sora_task_polling/mod.rs b/crates/desktop/artcraft/src/services/sora/threads/sora_task_polling/mod.rs deleted file mode 100644 index 15821b2734..0000000000 --- a/crates/desktop/artcraft/src/services/sora/threads/sora_task_polling/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod sora_task_polling_thread; -pub mod helpers; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/services/sora/threads/sora_task_polling/sora_task_polling_thread.rs b/crates/desktop/artcraft/src/services/sora/threads/sora_task_polling/sora_task_polling_thread.rs deleted file mode 100644 index c1cca02a6c..0000000000 --- a/crates/desktop/artcraft/src/services/sora/threads/sora_task_polling/sora_task_polling_thread.rs +++ /dev/null @@ -1,134 +0,0 @@ -use crate::core::events::basic_sendable_event_trait::BasicSendableEvent; -use crate::core::events::generation_events::common::{GenerationAction, GenerationServiceProvider}; -use crate::core::events::generation_events::generation_complete_event::GenerationCompleteEvent; -use crate::core::events::generation_events::generation_failed_event::GenerationFailedEvent; -use crate::core::events::sendable_event_trait::SendableEvent; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::core::state::data_dir::trait_data_subdir::DataSubdir; -use crate::core::state::task_database::TaskDatabase; -use crate::core::utils::task_database_pending_statuses::TASK_DATABASE_PENDING_STATUSES; -use crate::services::sora::state::sora_credential_manager::SoraCredentialManager; -use crate::services::sora::state::sora_task_queue::SoraTaskQueue; -use crate::services::sora::threads::sora_task_polling::helpers::handle_failed_generations::handle_classic_failed_generations; -use crate::services::sora::threads::sora_task_polling::helpers::handle_successful_generations::handle_classic_successful_generations; -use crate::services::sora::threads::sora_task_polling::helpers::poll_classic_sora_tasks::poll_classic_sora_tasks; -use crate::services::sora::threads::sora_task_polling::helpers::poll_sora_2_tasks::poll_sora_2_tasks; -use crate::services::storyteller::state::storyteller_credential_manager::StorytellerCredentialManager; -use artcraft_api_defs::prompts::create_prompt::CreatePromptRequest; -use enums::common::generation_provider::GenerationProvider; -use errors::AnyhowResult; -use uuid_utils::uuid::generate_random_uuid; -use log::{error, info, warn}; -use once_cell::sync::Lazy; -use openai_sora_client::creds::sora_credential_set::SoraCredentialSet; -use openai_sora_client::recipes::list_classic_sora_tasks_with_session_auto_renew::list_classic_sora_tasks_with_session_auto_renew; -use openai_sora_client::requests::common::task_id::TaskId; -use openai_sora_client::requests::list_classic_tasks::list_classic_tasks::TaskStatus; -use reqwest::Url; -use sqlite_tasks::queries::list_tasks_by_provider_and_status::{list_tasks_by_provider_and_status, ListTasksByProviderAndStatusArgs, TaskList}; -use sqlite_tasks::queries::task::Task; -use sqlite_tasks::queries::update_task_status::{update_task_status, UpdateTaskArgs}; -use std::collections::{HashMap, HashSet}; -use std::fs::File; -use std::io::Write; -use std::path::PathBuf; -use artcraft_client::endpoints::media_files::upload_image_media_file_from_file::{upload_image_media_file_from_file, UploadImageFromFileArgs}; -use artcraft_client::endpoints::prompts::create_prompt::create_prompt; -use tauri::AppHandle; -use tempdir::TempDir; - -#[deprecated(note = "Retained to poll legacy direct-provider tasks; new generations use ArtCraft.")] -pub async fn sora_task_polling_thread( - app_handle: AppHandle, - app_env_configs: AppEnvConfigs, - app_data_root: AppDataRoot, - task_database: TaskDatabase, - sora_creds_manager: SoraCredentialManager, - storyteller_creds_manager: StorytellerCredentialManager, - sora_task_queue: SoraTaskQueue, -) -> ! { - loop { - let res = local_task_polling_loop( - &app_handle, - &app_env_configs, - &task_database, - &sora_creds_manager, - &storyteller_creds_manager, - &sora_task_queue, - &app_data_root, - ).await; - if let Err(err) = res { - error!("An error occurred: {:?}", err); - } - tokio::time::sleep(std::time::Duration::from_millis(30_000)).await; - } -} - -async fn local_task_polling_loop( - app_handle: &AppHandle, - app_env_configs: &AppEnvConfigs, - task_database: &TaskDatabase, - sora_creds_manager: &SoraCredentialManager, - storyteller_creds_manager: &StorytellerCredentialManager, - sora_task_queue: &SoraTaskQueue, - app_data_root: &AppDataRoot, -) -> AnyhowResult<()> { - loop { - let local_sqlite_tasks = list_tasks_by_provider_and_status(ListTasksByProviderAndStatusArgs { - db: task_database.get_connection(), - provider: GenerationProvider::Sora, - task_statuses: &TASK_DATABASE_PENDING_STATUSES, - }).await?; - - if local_sqlite_tasks.tasks.is_empty() { - // No need to poll if we don't have pending tasks. - tokio::time::sleep(std::time::Duration::from_millis(2_000)).await; - continue; - } - - let creds = sora_creds_manager.get_credentials_required()?; - - // Map of Sora Task ID to Local Task. - let local_sqlite_tasks_by_sora_task_id = local_sqlite_tasks.tasks.iter() - .filter_map(|task| { - if let Some(provider_job_id) = &task.provider_job_id { - Some((provider_job_id.clone(), task.clone())) - } else { - None - } - }) - .collect::>(); - - // TODO: Only poll if we have classic items - - poll_classic_sora_tasks( - &app_handle, - &app_env_configs, - &task_database, - &sora_creds_manager, - &creds, - &storyteller_creds_manager, - &sora_task_queue, - &app_data_root, - &local_sqlite_tasks_by_sora_task_id, - ).await?; - - // TODO: Only poll if we have new items - - poll_sora_2_tasks( - &app_handle, - &app_env_configs, - &task_database, - &sora_creds_manager, - &creds, - &storyteller_creds_manager, - &sora_task_queue, - &app_data_root, - &local_sqlite_tasks_by_sora_task_id, - ).await?; - - tokio::time::sleep(std::time::Duration::from_millis(2_000)).await; - } -} - diff --git a/crates/desktop/artcraft/src/services/sora/utils/mod.rs b/crates/desktop/artcraft/src/services/sora/utils/mod.rs deleted file mode 100644 index 8b3cb94146..0000000000 --- a/crates/desktop/artcraft/src/services/sora/utils/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod upload_images_to_sora; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/services/sora/utils/upload_images_to_sora.rs b/crates/desktop/artcraft/src/services/sora/utils/upload_images_to_sora.rs deleted file mode 100644 index 668df7c2c3..0000000000 --- a/crates/desktop/artcraft/src/services/sora/utils/upload_images_to_sora.rs +++ /dev/null @@ -1,114 +0,0 @@ -use crate::core::state::app_env_configs::app_env_configs_serializeable::StorytellerApiHost; -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::core::state::data_dir::trait_data_subdir::DataSubdir; -use crate::core::utils::get_url_file_extension::get_url_file_extension; -use crate::core::utils::simple_http_download::simple_http_download; -use crate::services::sora::state::sora_credential_manager::SoraCredentialManager; -use crate::services::storyteller::state::storyteller_credential_manager::StorytellerCredentialManager; -use errors::AnyhowResult; -use log::{error, info}; -use openai_sora_client::creds::sora_credential_set::SoraCredentialSet; -use openai_sora_client::recipes::image_upload_from_file_with_session_auto_renew::{image_upload_from_file_with_session_auto_renew, ImageUploadFromFileAutoRenewRequest}; -use openai_sora_client::recipes::maybe_upgrade_or_renew_session::maybe_upgrade_or_renew_session; -use std::time::Duration; -use artcraft_client::credentials::storyteller_credential_set::StorytellerCredentialSet; -use artcraft_client::endpoints::media_files::get_media_file::get_media_file; -use artcraft_client::utils::api_host::ApiHost; -use tokens::tokens::media_files::MediaFileToken; - -const SORA_IMAGE_UPLOAD_TIMEOUT: Duration = Duration::from_millis(1000 * 30); // 30 seconds - -pub struct UploadImagesToSoraArgs<'a> { - pub storyteller_host: &'a ApiHost, - pub image_media_tokens: &'a [MediaFileToken], - - pub app_data_root: &'a AppDataRoot, - pub sora_creds_manager: &'a SoraCredentialManager, -} - -pub struct UploadImagesToSoraResult { - pub sora_media_tokens: Vec, - pub maybe_new_sora_credentials: Option, -} - -pub async fn upload_images_to_sora( - args: UploadImagesToSoraArgs<'_>, -) -> AnyhowResult { - - let mut updated_sora_creds = false; - - info!("Calling get media file API: {:?}", args.storyteller_host); - - let mut files_to_upload_to_sora = Vec::with_capacity(10); - - // TODO(bt,2025-07-07): This is inefficient. Cache and parallelize this. - for media_token in args.image_media_tokens.iter() { - info!("Using media token: {:?}", media_token); - - let response = get_media_file( - args.storyteller_host, - media_token - ).await?; - - let media_file_url = &response.media_file.media_links.cdn_url; - let extension_with_dot = get_url_file_extension(media_file_url) - .map(|ext| format!(".{}", ext)) - .unwrap_or_else(|| ".png".to_string()); - - let filename = format!("{}{}", response.media_file.token.as_str(), extension_with_dot); - let filename = args.app_data_root.downloads_dir().path().join(&filename); - - simple_http_download(&media_file_url, &filename).await?; - - files_to_upload_to_sora.push(filename); - } - - let mut sora_creds = args.sora_creds_manager.get_credentials_required()?; - - // TODO: We don't need sentinel anymore? - let credential_updated = maybe_upgrade_or_renew_session(&mut sora_creds) - .await - .map_err(|err| { - error!("Failed to upgrade or renew session: {:?}", err); - err - })?; - - if credential_updated { - info!("Storing updated credentials"); - args.sora_creds_manager.set_credentials(&sora_creds)?; - updated_sora_creds = true; - } - - let mut sora_media_tokens = Vec::with_capacity(files_to_upload_to_sora.len()); - - for (i, file_path) in files_to_upload_to_sora.iter().enumerate() { - info!("Uploading image {} of {}...", (i+1), files_to_upload_to_sora.len()); - - let (response, maybe_new_credentials) = - image_upload_from_file_with_session_auto_renew(ImageUploadFromFileAutoRenewRequest { - file_path, - credentials: &sora_creds, - request_timeout: Some(SORA_IMAGE_UPLOAD_TIMEOUT), // TODO: Centralize and make configurable. - }).await?; - - if let Some(new_creds) = maybe_new_credentials { - info!("Storing updated credentials."); - args.sora_creds_manager.set_credentials(&new_creds)?; - sora_creds = new_creds; - updated_sora_creds = true; - } - - sora_media_tokens.push(response.id); - } - - let maybe_new_sora_credentials = if updated_sora_creds { - Some(sora_creds) - } else { - None - }; - - Ok(UploadImagesToSoraResult { - sora_media_tokens, - maybe_new_sora_credentials, - }) -} diff --git a/crates/desktop/artcraft/src/services/sora/windows/mod.rs b/crates/desktop/artcraft/src/services/sora/windows/mod.rs deleted file mode 100644 index 3843c67df6..0000000000 --- a/crates/desktop/artcraft/src/services/sora/windows/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod sora_login_window; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/services/sora/windows/sora_login_window/clear_browsing_on_test_domain.rs b/crates/desktop/artcraft/src/services/sora/windows/sora_login_window/clear_browsing_on_test_domain.rs deleted file mode 100644 index 525ec16752..0000000000 --- a/crates/desktop/artcraft/src/services/sora/windows/sora_login_window/clear_browsing_on_test_domain.rs +++ /dev/null @@ -1,20 +0,0 @@ -use anyhow::anyhow; -use errors::AnyhowResult; -use log::info; -use tauri::Webview; - -// This is just so we have a way to clear browsing data while debugging / building. -pub fn clear_browsing_data_on_test_domain(webview: &Webview) -> AnyhowResult<()> { - let url = webview.url()?; - let hostname= url.host() - .ok_or(anyhow!("no host in url"))? - .to_string(); - match hostname.as_str() { - "storyteller.ai" => { - info!("Clearing all browsing data..."); - webview.clear_all_browsing_data()?; - } - _ => {} - } - Ok(()) -} diff --git a/crates/desktop/artcraft/src/services/sora/windows/sora_login_window/extract_sora_webview_cookies.rs b/crates/desktop/artcraft/src/services/sora/windows/sora_login_window/extract_sora_webview_cookies.rs deleted file mode 100644 index 03696c522a..0000000000 --- a/crates/desktop/artcraft/src/services/sora/windows/sora_login_window/extract_sora_webview_cookies.rs +++ /dev/null @@ -1,28 +0,0 @@ -use errors::AnyhowResult; -use once_cell::sync::Lazy; -use reqwest::Url; -use tauri::webview::Cookie; -use tauri::WebviewWindow; - -const CHAT_GPT_ROOT_COOKIE_URL_STR: &str = "https://chatgpt.com"; - -static CHAT_GPT_ROOT_COOKIE_URL: Lazy = Lazy::new(|| { - Url::parse(CHAT_GPT_ROOT_COOKIE_URL_STR).expect("URL should parse") -}); - -pub fn extract_sora_webview_cookies(webview: &WebviewWindow) -> AnyhowResult { - // NB(bt): Cookies were originally on sora.com, but now they're located on - // the sora.chatgpt.com / *.chatgpt.com domains. - let cookies = get_all_chatgpt_cookies(webview)?; - let cookie_string = cookies - .iter() - .map(|cookie| format!("{}={}", cookie.name(), cookie.value())) - .collect::>() - .join("; "); - Ok(cookie_string) -} - -fn get_all_chatgpt_cookies(webview: &WebviewWindow) -> AnyhowResult> { - let cookies = webview.cookies_for_url(CHAT_GPT_ROOT_COOKIE_URL.clone())?; - Ok(cookies) -} diff --git a/crates/desktop/artcraft/src/services/sora/windows/sora_login_window/keep_on_login_domains.rs b/crates/desktop/artcraft/src/services/sora/windows/sora_login_window/keep_on_login_domains.rs deleted file mode 100644 index 6edb1de357..0000000000 --- a/crates/desktop/artcraft/src/services/sora/windows/sora_login_window/keep_on_login_domains.rs +++ /dev/null @@ -1,28 +0,0 @@ -use crate::services::sora::windows::sora_login_window::open_sora_login_window::SORA_LOGIN_URL; -use anyhow::anyhow; -use errors::AnyhowResult; -use log::info; -use tauri::Webview; - -// NB: Probably best not to use this. -pub fn keep_on_login_domains(webview: &Webview) -> AnyhowResult<()> { - let url = webview.url()?; - let hostname= url.host() - .ok_or(anyhow!("no host in url"))? - .to_string(); - match hostname.as_str() { - "auth.openai.com" => {}, - "openai.com" => {}, - "sora.com" => {}, - // Third party SSO - "accounts.google.com" => {}, - "accounts.youtube.com" => {}, - "login.live.com" => {}, - "appleid.apple.com" => {}, - _ => { - info!("Non login hostname: {}", hostname); - webview.navigate(SORA_LOGIN_URL.clone())?; - } - } - Ok(()) -} diff --git a/crates/desktop/artcraft/src/services/sora/windows/sora_login_window/mod.rs b/crates/desktop/artcraft/src/services/sora/windows/sora_login_window/mod.rs deleted file mode 100644 index 0ff8648e3b..0000000000 --- a/crates/desktop/artcraft/src/services/sora/windows/sora_login_window/mod.rs +++ /dev/null @@ -1,5 +0,0 @@ -pub mod clear_browsing_on_test_domain; -pub mod extract_sora_webview_cookies; -pub mod keep_on_login_domains; -pub mod open_sora_login_window; -pub mod sora_login_thread; diff --git a/crates/desktop/artcraft/src/services/sora/windows/sora_login_window/open_sora_login_window.rs b/crates/desktop/artcraft/src/services/sora/windows/sora_login_window/open_sora_login_window.rs deleted file mode 100644 index c18d63745c..0000000000 --- a/crates/desktop/artcraft/src/services/sora/windows/sora_login_window/open_sora_login_window.rs +++ /dev/null @@ -1,78 +0,0 @@ -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::core::utils::clear_all_webview_cookies::clear_all_webview_cookies; -use crate::services::sora::state::sora_credential_manager::SoraCredentialManager; -use crate::services::sora::windows::sora_login_window::sora_login_thread::sora_login_thread; -use anyhow::anyhow; -use errors::AnyhowResult; -use once_cell::sync::Lazy; -use reqwest::Url; -use std::time::Duration; -use tauri::{AppHandle, Manager, WebviewUrl, WebviewWindowBuilder}; - -/// Name of the window -pub (super) const LOGIN_WINDOW_NAME: &str = "login_window"; - -pub (super) static START_URL: Lazy = Lazy::new(|| { - Url::parse("https://google.com").expect("URL should parse") -}); - -pub (super) static SORA_HOMEPAGE_URL : Lazy = Lazy::new(|| { - Url::parse("https://sora.com/").expect("URL should parse") -}); - -pub (super) static SORA_LOGIN_URL: Lazy = Lazy::new(|| { - Url::parse("https://chatgpt.com/auth/login?next=%2Fsora%2F").expect("URL should parse") -}); - -//pub const SORA_ROOT_URL_STR: &str = "https://sora.com/"; -// -//pub static SORA_ROOT_URL: Lazy = Lazy::new(|| { -// Url::parse(SORA_ROOT_URL_STR).expect("URL should parse") -//}); - -pub async fn open_sora_login_window( - app: &AppHandle, - app_data_root: &AppDataRoot, - sora_creds_manager: &SoraCredentialManager, -) -> AnyhowResult<()> { - if app.get_window(LOGIN_WINDOW_NAME).is_some() { - return Err(anyhow!("Login window already open")); - } - - let url = WebviewUrl::External(START_URL.clone()); - - let window = WebviewWindowBuilder::new(app, LOGIN_WINDOW_NAME, url) - //.user_agent(openai_sora_client::credentials::USER_AGENT) - .always_on_top(true) - .title("Login to OpenAI's Sora") - .center() - .resizable(true) - .visible(true) - .closable(true) - .min_inner_size(200.0, 800.0) - .focused(true) - .devtools(true) - .build()?; - - let webview = window.get_webview(LOGIN_WINDOW_NAME) - .ok_or_else(|| anyhow!("no webview found"))?; - - clear_all_webview_cookies(&webview)?; - - webview.navigate(SORA_HOMEPAGE_URL.clone())?; - - // NB: We're starting to get Cloudflare protection screens. Let's try to avoid. - tokio::time::sleep(Duration::from_millis(100)).await; - - webview.navigate(SORA_LOGIN_URL.clone())?; - - let app_handle = app.clone(); - let app_data_root = app_data_root.clone(); - let sora_creds_manager = sora_creds_manager.clone(); - - let _ = tauri::async_runtime::spawn(async move { - sora_login_thread(app_handle, app_data_root, sora_creds_manager).await; - }); - - Ok(()) -} diff --git a/crates/desktop/artcraft/src/services/sora/windows/sora_login_window/sora_login_thread.rs b/crates/desktop/artcraft/src/services/sora/windows/sora_login_window/sora_login_thread.rs deleted file mode 100644 index e7d6fe5614..0000000000 --- a/crates/desktop/artcraft/src/services/sora/windows/sora_login_window/sora_login_thread.rs +++ /dev/null @@ -1,155 +0,0 @@ -use crate::core::events::basic_sendable_event_trait::BasicSendableEvent; -use crate::core::events::functional_events::refresh_account_state_event::RefreshAccountStateEvent; -use crate::core::events::sendable_event_trait::SendableEvent; -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::core::utils::window::get_webview_window_hostname::get_webview_window_hostname; -use crate::services::sora::events::sora_login_success_event::SoraLoginSuccessEvent; -use crate::services::sora::state::sora_credential_manager::SoraCredentialManager; -use crate::services::sora::windows::sora_login_window::extract_sora_webview_cookies::extract_sora_webview_cookies; -use crate::services::sora::windows::sora_login_window::open_sora_login_window::LOGIN_WINDOW_NAME; -use anyhow::anyhow; -use enums::common::generation_provider::GenerationProvider; -use errors::AnyhowResult; -use log::{error, info}; -use openai_sora_client::creds::sora_credential_set::SoraCredentialSet; -use openai_sora_client::recipes::maybe_upgrade_or_renew_session::maybe_upgrade_or_renew_session; -use openai_sora_client::utils::has_session_cookie::{has_session_cookie, SessionCookiePresence}; -use tauri::{AppHandle, Manager, WebviewWindow}; - -pub async fn sora_login_thread( - app: AppHandle, - app_data_root: AppDataRoot, - sora_creds_manager: SoraCredentialManager -) { - loop { - let login_webview_window = match app.get_webview_window(LOGIN_WINDOW_NAME) { - Some(webview) => webview, - None => { - info!("Exit sora login thread."); - return; // NB: Only exit if we don't have the webview. - } - }; - - let result = check_login_window( - &app, - &login_webview_window, - &app_data_root, - &sora_creds_manager, - ).await; - - match result { - Err(err) => { - error!("Error checking login window: {:?}", err); - } - Ok(false) => {} // Continue iteration and try again... - Ok(true) => { - info!("Successfully saved cookies from login window. Closing."); - if let Err(err) = login_webview_window.close() { - error!("Error closing login window: {:?}", err); - } - return; - } - } - - tokio::time::sleep(std::time::Duration::from_millis(2_000)).await; - } -} - -/// Returns true if we can exit. -async fn check_login_window( - app_handle: &AppHandle, - webview_window: &WebviewWindow, - app_data_root: &AppDataRoot, - sora_credential_manager: &SoraCredentialManager, -) -> AnyhowResult { - - /* Login flow looks like this: - - 1. Start: https://sora.chatgpt.com/ - 2. Login Start: https://chatgpt.com/auth/login?next=%2Fsora%2F [this is where we start] - 3. Login Continue: https://auth.openai.com/log-in - 4. SSO / Google Login (etc): https://accounts.google.com/v3/signin/challenge/pwd?[query] - 5. Done / Landing: https://sora.chatgpt.com/explore - */ - - /* - - Do not use credential manager until the end (we don't load old cookies!) - - Check if we're on the correct domain, if not exit? (or inverse, that we're not in login flow) - */ - - let hostname = get_webview_window_hostname(webview_window)?; - - let mut maybe_at_destination = false; - - match hostname.as_str() { - "sora.com" | // Old destination - "sora.chatgpt.com" // New destination - => { - maybe_at_destination = true; - } - // chatgpt.com/auth is also an auth domain - "auth.openai.com" | - "accounts.google.com" | - "accounts.youtube.com" | - "login.live.com" | - "appleid.apple.com" - => { - // NB: We're in auth flow. - info!("Sora login webview is in auth flow; hostname `{}`.", hostname); - return Ok(false) - } - _ => {}, // We just don't know... - } - - let webview_cookies = extract_sora_webview_cookies(webview_window)?.trim().to_string(); - - let session_cookie_presence = has_session_cookie(&webview_cookies) - .unwrap_or_else(|err| { - error!("Failed to check for session cookie: {:?}", err); - SessionCookiePresence::MaybePresent - }); - - info!("Sora login webview is at hostname `{}`; cookie status: {:?}.", hostname, session_cookie_presence); - - match session_cookie_presence { - SessionCookiePresence::Absent => { - info!("Session cookies are absent."); - return Ok(false); - } - _ => {}, - } - - let mut new_credentials = - SoraCredentialSet::initialize_with_just_cookies_str(&webview_cookies); - - let _upgraded = maybe_upgrade_or_renew_session(&mut new_credentials).await?; - - // TODO(bt): Race conditions ahead. - - sora_credential_manager.clear_credentials()?; - sora_credential_manager.try_purge_credentials_from_disk(); - - sora_credential_manager.set_credentials(&new_credentials)?; - sora_credential_manager.persist_all_to_disk()?; - - send_frontend_login_events(app_handle); - - Ok(true) -} - -fn send_frontend_login_events(app_handle: &AppHandle) { - let event = RefreshAccountStateEvent { - provider: Some(GenerationProvider::Sora), - }; - - event.send_infallible(app_handle); - - // TODO: Remove this legacy event when we're done with it. - // NB: Event sent to the frontend for the login flow. We shouldn't rely on just this - // alone as it could be brittle if the events aren't caught. - let event = SoraLoginSuccessEvent {}; - - if let Err(err) = event.send(app_handle) { - error!("Error sending Sora login success event: {:?}", err); - } -} diff --git a/crates/desktop/artcraft/src/services/storyteller/commands/mod.rs b/crates/desktop/artcraft/src/services/storyteller/commands/mod.rs deleted file mode 100644 index 294ba3f6cd..0000000000 --- a/crates/desktop/artcraft/src/services/storyteller/commands/mod.rs +++ /dev/null @@ -1,5 +0,0 @@ -pub mod storyteller_purge_credentials_command; -pub mod storyteller_get_credits_command; -pub mod storyteller_get_subscription_command; -pub mod stripe_checkout; -pub mod stripe_customer_portal; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/services/storyteller/commands/storyteller_get_credits_command.rs b/crates/desktop/artcraft/src/services/storyteller/commands/storyteller_get_credits_command.rs deleted file mode 100644 index be02b1cd53..0000000000 --- a/crates/desktop/artcraft/src/services/storyteller/commands/storyteller_get_credits_command.rs +++ /dev/null @@ -1,71 +0,0 @@ -use crate::core::commands::deprecated::image_edit::enqueue_edit_image_command::{ImageEditModel, EditImageQuality, EditImageSize}; -use crate::core::commands::response::shorthand::ResponseOrErrorMessage; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::core::state::provider_priority::Provider; -use crate::services::midjourney::state::midjourney_credential_manager::MidjourneyCredentialManager; -use crate::services::midjourney::windows::open_midjourney_login_window::open_midjourney_login_window; -use crate::services::sora::windows::sora_login_window::open_sora_login_window::open_sora_login_window; -use crate::services::storyteller::state::storyteller_credential_manager::StorytellerCredentialManager; -use crate::services::storyteller::windows::open_storyteller_billing_window::{open_storyteller_billing_window, OpenStorytellerBillingWindowArgs, BillingWindowCase}; -use artcraft_api_defs::stripe_artcraft::create_subscription_checkout::PlanBillingCadence; -use enums::common::payments_namespace::PaymentsNamespace; -use errors::AnyhowResult; -use log::{error, info}; -use serde_derive::{Deserialize, Serialize}; -use artcraft_client::endpoints::credits::get_session_credits::get_session_credits; -use tauri::{AppHandle, State}; -use crate::core::commands::providers::deprecated::get_provider_order_command::GetProviderOrderResponse; -use crate::core::commands::response::success_response_wrapper::SerializeMarker; -// TODO(bt,2025-09-12): Cache credits and clear cache on generate calls. - -#[derive(Serialize)] -pub struct GetCreditsResponse { - pub free_credits: u64, - pub monthly_credits: u64, - pub banked_credits: u64, - pub sum_total_credits: u64, -} - -impl SerializeMarker for GetCreditsResponse {} - -#[tauri::command] -pub async fn storyteller_get_credits_command( - app_env_configs: State<'_, AppEnvConfigs>, - storyteller_creds_manager: State<'_, StorytellerCredentialManager>, -) -> ResponseOrErrorMessage { - - info!("storyteller_get_credits_command called"); - - let credits = get_credits( - &app_env_configs, - &storyteller_creds_manager) - .await - .map_err(|err| { - error!("Error getting credits: {:?}", err); - format!("Error getting credits: {:?}", err) - })?; - - Ok(credits.into()) -} - -async fn get_credits( - app_env_configs: &AppEnvConfigs, - storyteller_creds_manager: &StorytellerCredentialManager, -) -> AnyhowResult { - - let maybe_creds = storyteller_creds_manager.get_credentials()?; - - let response = get_session_credits( - &app_env_configs.storyteller_host, - maybe_creds.as_ref(), - PaymentsNamespace::Artcraft, - ).await?; - - Ok(GetCreditsResponse { - free_credits: response.free_credits, - monthly_credits: response.monthly_credits, - banked_credits: response.banked_credits, - sum_total_credits: response.sum_total_credits, - }) -} diff --git a/crates/desktop/artcraft/src/services/storyteller/commands/storyteller_get_subscription_command.rs b/crates/desktop/artcraft/src/services/storyteller/commands/storyteller_get_subscription_command.rs deleted file mode 100644 index 98cdf3e429..0000000000 --- a/crates/desktop/artcraft/src/services/storyteller/commands/storyteller_get_subscription_command.rs +++ /dev/null @@ -1,100 +0,0 @@ -use chrono::{DateTime, Utc}; -use crate::core::commands::deprecated::image_edit::enqueue_edit_image_command::{ImageEditModel, EditImageQuality, EditImageSize}; -use crate::core::commands::providers::deprecated::get_provider_order_command::GetProviderOrderResponse; -use crate::core::commands::response::shorthand::ResponseOrErrorMessage; -use crate::core::commands::response::success_response_wrapper::SerializeMarker; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::core::state::provider_priority::Provider; -use crate::services::midjourney::state::midjourney_credential_manager::MidjourneyCredentialManager; -use crate::services::midjourney::windows::open_midjourney_login_window::open_midjourney_login_window; -use crate::services::sora::windows::sora_login_window::open_sora_login_window::open_sora_login_window; -use crate::services::storyteller::state::storyteller_credential_manager::StorytellerCredentialManager; -use crate::services::storyteller::windows::open_storyteller_billing_window::{open_storyteller_billing_window, OpenStorytellerBillingWindowArgs, BillingWindowCase}; -use artcraft_api_defs::stripe_artcraft::create_subscription_checkout::PlanBillingCadence; -use enums::common::artcraft_subscription_slug::ArtcraftSubscriptionSlug; -use enums::common::payments_namespace::PaymentsNamespace; -use errors::AnyhowResult; -use log::{error, info}; -use serde_derive::{Deserialize, Serialize}; -use artcraft_client::endpoints::credits::get_session_credits::get_session_credits; -use artcraft_client::endpoints::subscriptions::get_session_subscription::get_session_subscription; -use tauri::{AppHandle, State}; -use tokens::tokens::user_subscriptions::UserSubscriptionToken; -// TODO(bt,2025-09-12): Cache credits and clear cache on generate calls. - -#[derive(Serialize)] -pub struct GetSubscriptionResponse { - /// Information about the subscription, if any. - pub active_subscription: Option, -} - -#[derive(Serialize)] -pub struct ActiveSubscriptionInfo { - pub subscription_token: UserSubscriptionToken, - pub product_slug: ArtcraftSubscriptionSlug, - pub namespace: PaymentsNamespace, - - /// If the subscription is active, this is the next bill date - pub next_bill_at: Option>, - - /// If the subscription is expired or is set to expire, this is the end date of the subscription. - pub subscription_end_at: Option>, -} - -impl SerializeMarker for GetSubscriptionResponse {} - -#[tauri::command] -pub async fn storyteller_get_subscription_command( - app_env_configs: State<'_, AppEnvConfigs>, - storyteller_creds_manager: State<'_, StorytellerCredentialManager>, -) -> ResponseOrErrorMessage { - - info!("storyteller_get_subscription_command called"); - - let credits = get( - &app_env_configs, - &storyteller_creds_manager) - .await - .map_err(|err| { - error!("Error getting credits: {:?}", err); - format!("Error getting credits: {:?}", err) - })?; - - Ok(credits.into()) -} - -async fn get( - app_env_configs: &AppEnvConfigs, - storyteller_creds_manager: &StorytellerCredentialManager, -) -> AnyhowResult { - - let maybe_creds = storyteller_creds_manager.get_credentials()?; - - let response = get_session_subscription( - &app_env_configs.storyteller_host, - maybe_creds.as_ref(), - PaymentsNamespace::Artcraft, - ).await?; - - Ok(GetSubscriptionResponse { - active_subscription: response.active_subscription - .map(|sub| { - let product_slug = match ArtcraftSubscriptionSlug::from_str(&sub.product_slug) { - Ok(product_slug) => product_slug, - Err(err) => { - error!("Received unknown product slug from storyteller: {:?}, error: {:?}", sub.product_slug, err); - return None; - }, - }; - Some(ActiveSubscriptionInfo { - subscription_token: sub.subscription_token, - product_slug, - namespace: sub.namespace, - next_bill_at: sub.next_bill_at, - subscription_end_at: sub.subscription_end_at, - }) - }) - .flatten(), - }) -} diff --git a/crates/desktop/artcraft/src/services/storyteller/commands/storyteller_purge_credentials_command.rs b/crates/desktop/artcraft/src/services/storyteller/commands/storyteller_purge_credentials_command.rs deleted file mode 100644 index f842c948a8..0000000000 --- a/crates/desktop/artcraft/src/services/storyteller/commands/storyteller_purge_credentials_command.rs +++ /dev/null @@ -1,56 +0,0 @@ -use crate::core::commands::deprecated::image_edit::enqueue_edit_image_command::EnqueueEditImageSuccessResponse; -use crate::core::commands::response::shorthand::ResponseOrErrorMessage; -use crate::core::commands::response::success_response_wrapper::SerializeMarker; -use crate::core::state::app_preferences::app_preferences_manager::AppPreferencesManager; -use crate::core::state::app_preferences::preferred_download_directory::PreferredDownloadDirectory; -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::services::storyteller::state::storyteller_credential_manager::StorytellerCredentialManager; -use crate::services::storyteller::windows::clear_main_webview_window_storyteller_cookies::clear_main_webview_window_storyteller_cookies; -use anyhow::anyhow; -use errors::AnyhowResult; -use log::{error, info}; -use serde_derive::{Deserialize, Serialize}; -use tauri::{AppHandle, State}; - -#[derive(Serialize)] -pub struct PurgeStorytellerCredentialsCommandResponse { - pub success: bool, -} - -impl SerializeMarker for PurgeStorytellerCredentialsCommandResponse {} - -#[tauri::command] -pub async fn storyteller_purge_credentials_command( - app: AppHandle, - storyteller_creds_manager: State<'_, StorytellerCredentialManager>, -) -> ResponseOrErrorMessage { - info!("storyteller_purge_credentials_command called"); - - reset(&app, &storyteller_creds_manager) - .await - .map_err(|err| { - error!("Error purging credentials: {:?}", err); - format!("Error purging credentials: {:?}", err) - })?; - - Ok(PurgeStorytellerCredentialsCommandResponse { - success: true, - }.into()) -} - -async fn reset( - app: &AppHandle, - storyteller_creds_manager: &StorytellerCredentialManager -) -> AnyhowResult<()> { - - clear_main_webview_window_storyteller_cookies(&app)?; - - storyteller_creds_manager.clear_credentials()?; - storyteller_creds_manager.delete_persisted_copies_on_disk()?; - - // NB: Twice to be sure. - storyteller_creds_manager.clear_credentials()?; - storyteller_creds_manager.delete_persisted_copies_on_disk()?; - - Ok(()) -} diff --git a/crates/desktop/artcraft/src/services/storyteller/commands/stripe_checkout/mod.rs b/crates/desktop/artcraft/src/services/storyteller/commands/stripe_checkout/mod.rs deleted file mode 100644 index 698f284ef3..0000000000 --- a/crates/desktop/artcraft/src/services/storyteller/commands/stripe_checkout/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod storyteller_open_credits_purchase_command; -pub mod storyteller_open_subscription_purchase_command; diff --git a/crates/desktop/artcraft/src/services/storyteller/commands/stripe_checkout/storyteller_open_credits_purchase_command.rs b/crates/desktop/artcraft/src/services/storyteller/commands/stripe_checkout/storyteller_open_credits_purchase_command.rs deleted file mode 100644 index 021e599576..0000000000 --- a/crates/desktop/artcraft/src/services/storyteller/commands/stripe_checkout/storyteller_open_credits_purchase_command.rs +++ /dev/null @@ -1,71 +0,0 @@ -use crate::core::commands::deprecated::image_edit::enqueue_edit_image_command::{ImageEditModel, EditImageQuality, EditImageSize}; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::services::midjourney::state::midjourney_credential_manager::MidjourneyCredentialManager; -use crate::services::midjourney::windows::open_midjourney_login_window::open_midjourney_login_window; -use crate::services::sora::windows::sora_login_window::open_sora_login_window::open_sora_login_window; -use crate::services::storyteller::state::storyteller_credential_manager::StorytellerCredentialManager; -use crate::services::storyteller::windows::open_storyteller_billing_window::{open_storyteller_billing_window, OpenStorytellerBillingWindowArgs, BillingWindowCase}; -use artcraft_api_defs::stripe_artcraft::create_subscription_checkout::PlanBillingCadence; -use enums::common::artcraft_credits_pack_slug::ArtcraftCreditsPackSlug; -use errors::AnyhowResult; -use log::{error, info}; -use serde_derive::Deserialize; -use tauri::{AppHandle, State}; -use tokens::tokens::media_files::MediaFileToken; - -#[derive(Deserialize, Debug)] -pub struct StorytellerOpenCreditsPurchaseCommand { - pub credits_pack: Option, -} - -#[tauri::command] -pub async fn storyteller_open_credits_purchase_command( - app: AppHandle, - request: StorytellerOpenCreditsPurchaseCommand, - app_data_root: State<'_, AppDataRoot>, - app_env_configs: State<'_, AppEnvConfigs>, - storyteller_creds_manager: State<'_, StorytellerCredentialManager>, -) -> Result { - info!("storyteller_open_credits_purchase_command called"); - - let credits_pack = request.credits_pack.ok_or("Credits pack is required")?; - - do_open_billing( - &app, - &app_data_root, - &app_env_configs, - &storyteller_creds_manager, - credits_pack, - ) - .await - .map_err(|err| { - error!("Error opening credits purchase window: {:?}", err); - format!("Error opening credits purchase window: {:?}", err) - })?; - - Ok("result".to_string()) -} - -async fn do_open_billing( - app: &AppHandle, - app_data_root: &AppDataRoot, - app_env_configs: &AppEnvConfigs, - storyteller_creds_manager: &StorytellerCredentialManager, - credits_pack: ArtcraftCreditsPackSlug, -) -> AnyhowResult<()> { - info!("Building billing window..."); - - open_storyteller_billing_window(OpenStorytellerBillingWindowArgs { - app, - app_data_root, - app_env_configs, - storyteller_creds_manager, - billing_window_case: BillingWindowCase::CreditsPack { - credits_pack, - } - }).await?; - - info!("Done."); - Ok(()) -} diff --git a/crates/desktop/artcraft/src/services/storyteller/commands/stripe_checkout/storyteller_open_subscription_purchase_command.rs b/crates/desktop/artcraft/src/services/storyteller/commands/stripe_checkout/storyteller_open_subscription_purchase_command.rs deleted file mode 100644 index bcb06fdc85..0000000000 --- a/crates/desktop/artcraft/src/services/storyteller/commands/stripe_checkout/storyteller_open_subscription_purchase_command.rs +++ /dev/null @@ -1,76 +0,0 @@ -use crate::core::commands::deprecated::image_edit::enqueue_edit_image_command::{ImageEditModel, EditImageQuality, EditImageSize}; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::services::midjourney::state::midjourney_credential_manager::MidjourneyCredentialManager; -use crate::services::midjourney::windows::open_midjourney_login_window::open_midjourney_login_window; -use crate::services::sora::windows::sora_login_window::open_sora_login_window::open_sora_login_window; -use crate::services::storyteller::state::storyteller_credential_manager::StorytellerCredentialManager; -use crate::services::storyteller::windows::open_storyteller_billing_window::{open_storyteller_billing_window, OpenStorytellerBillingWindowArgs, BillingWindowCase}; -use artcraft_api_defs::stripe_artcraft::create_subscription_checkout::PlanBillingCadence; -use enums::common::artcraft_subscription_slug::ArtcraftSubscriptionSlug; -use errors::AnyhowResult; -use log::{error, info}; -use serde_derive::Deserialize; -use tauri::{AppHandle, State}; -use tokens::tokens::media_files::MediaFileToken; - -#[derive(Deserialize, Debug)] -pub struct StorytellerOpenSubscriptionPurchaseCommand { - pub plan: Option, - pub cadence: Option, -} - -#[tauri::command] -pub async fn storyteller_open_subscription_purchase_command( - app: AppHandle, - request: StorytellerOpenSubscriptionPurchaseCommand, - app_data_root: State<'_, AppDataRoot>, - app_env_configs: State<'_, AppEnvConfigs>, - storyteller_creds_manager: State<'_, StorytellerCredentialManager>, -) -> Result { - info!("storyteller_open_subscription_purchase_command called"); - - let plan = request.plan.ok_or("Plan is required")?; - let cadence = request.cadence.ok_or("Cadence is required")?; - - do_open_billing( - &app, - &app_data_root, - &app_env_configs, - &storyteller_creds_manager, - plan, - cadence, - ) - .await - .map_err(|err| { - error!("Error opening subscription purchase window: {:?}", err); - format!("Error opening subscription purchase window: {:?}", err) - })?; - - Ok("result".to_string()) -} - -async fn do_open_billing( - app: &AppHandle, - app_data_root: &AppDataRoot, - app_env_configs: &AppEnvConfigs, - storyteller_creds_manager: &StorytellerCredentialManager, - plan: ArtcraftSubscriptionSlug, - cadence: PlanBillingCadence, -) -> AnyhowResult<()> { - info!("Building billing window..."); - - open_storyteller_billing_window(OpenStorytellerBillingWindowArgs { - app, - app_env_configs, - app_data_root, - storyteller_creds_manager, - billing_window_case: BillingWindowCase::Subscription { - plan, - cadence, - } - }).await?; - - info!("Done."); - Ok(()) -} diff --git a/crates/desktop/artcraft/src/services/storyteller/commands/stripe_customer_portal/mod.rs b/crates/desktop/artcraft/src/services/storyteller/commands/stripe_customer_portal/mod.rs deleted file mode 100644 index 6d4213482e..0000000000 --- a/crates/desktop/artcraft/src/services/storyteller/commands/stripe_customer_portal/mod.rs +++ /dev/null @@ -1,4 +0,0 @@ -pub mod storyteller_open_customer_portal_cancel_plan_command; -pub mod storyteller_open_customer_portal_manage_plan_command; -pub mod storyteller_open_customer_portal_switch_plan_command; -pub mod storyteller_open_customer_portal_update_payment_method_command; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/services/storyteller/commands/stripe_customer_portal/storyteller_open_customer_portal_cancel_plan_command.rs b/crates/desktop/artcraft/src/services/storyteller/commands/stripe_customer_portal/storyteller_open_customer_portal_cancel_plan_command.rs deleted file mode 100644 index 8eb091a294..0000000000 --- a/crates/desktop/artcraft/src/services/storyteller/commands/stripe_customer_portal/storyteller_open_customer_portal_cancel_plan_command.rs +++ /dev/null @@ -1,58 +0,0 @@ -use crate::core::commands::deprecated::image_edit::enqueue_edit_image_command::{ImageEditModel, EditImageQuality, EditImageSize}; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::services::midjourney::state::midjourney_credential_manager::MidjourneyCredentialManager; -use crate::services::midjourney::windows::open_midjourney_login_window::open_midjourney_login_window; -use crate::services::sora::windows::sora_login_window::open_sora_login_window::open_sora_login_window; -use crate::services::storyteller::state::storyteller_credential_manager::StorytellerCredentialManager; -use crate::services::storyteller::windows::open_storyteller_billing_window::{open_storyteller_billing_window, BillingWindowCase, OpenStorytellerBillingWindowArgs}; -use artcraft_api_defs::stripe_artcraft::create_subscription_checkout::PlanBillingCadence; -use errors::AnyhowResult; -use log::{error, info}; -use serde_derive::Deserialize; -use tauri::{AppHandle, State}; -use tokens::tokens::media_files::MediaFileToken; - -#[tauri::command] -pub async fn storyteller_open_customer_portal_cancel_plan_command( - app: AppHandle, - app_data_root: State<'_, AppDataRoot>, - app_env_configs: State<'_, AppEnvConfigs>, - storyteller_creds_manager: State<'_, StorytellerCredentialManager>, -) -> Result { - info!("storyteller_open_customer_portal_cancel_plan_command called"); - - do_open_portal( - &app, - &app_data_root, - &app_env_configs, - &storyteller_creds_manager, - ) - .await - .map_err(|err| { - error!("Error opening customer portal window: {:?}", err); - format!("Error opening customer portal window: {:?}", err) - })?; - - Ok("result".to_string()) -} - -async fn do_open_portal( - app: &AppHandle, - app_data_root: &AppDataRoot, - app_env_configs: &AppEnvConfigs, - storyteller_creds_manager: &StorytellerCredentialManager, -) -> AnyhowResult<()> { - info!("Building billing window..."); - - open_storyteller_billing_window(OpenStorytellerBillingWindowArgs { - app, - app_data_root, - app_env_configs, - storyteller_creds_manager, - billing_window_case: BillingWindowCase::CustomerPortalCancelPlan, - }).await?; - - info!("Done."); - Ok(()) -} diff --git a/crates/desktop/artcraft/src/services/storyteller/commands/stripe_customer_portal/storyteller_open_customer_portal_manage_plan_command.rs b/crates/desktop/artcraft/src/services/storyteller/commands/stripe_customer_portal/storyteller_open_customer_portal_manage_plan_command.rs deleted file mode 100644 index 2b40db7f45..0000000000 --- a/crates/desktop/artcraft/src/services/storyteller/commands/stripe_customer_portal/storyteller_open_customer_portal_manage_plan_command.rs +++ /dev/null @@ -1,58 +0,0 @@ -use crate::core::commands::deprecated::image_edit::enqueue_edit_image_command::{ImageEditModel, EditImageQuality, EditImageSize}; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::services::midjourney::state::midjourney_credential_manager::MidjourneyCredentialManager; -use crate::services::midjourney::windows::open_midjourney_login_window::open_midjourney_login_window; -use crate::services::sora::windows::sora_login_window::open_sora_login_window::open_sora_login_window; -use crate::services::storyteller::state::storyteller_credential_manager::StorytellerCredentialManager; -use crate::services::storyteller::windows::open_storyteller_billing_window::{open_storyteller_billing_window, BillingWindowCase, OpenStorytellerBillingWindowArgs}; -use artcraft_api_defs::stripe_artcraft::create_subscription_checkout::PlanBillingCadence; -use errors::AnyhowResult; -use log::{error, info}; -use serde_derive::Deserialize; -use tauri::{AppHandle, State}; -use tokens::tokens::media_files::MediaFileToken; - -#[tauri::command] -pub async fn storyteller_open_customer_portal_manage_plan_command( - app: AppHandle, - app_data_root: State<'_, AppDataRoot>, - app_env_configs: State<'_, AppEnvConfigs>, - storyteller_creds_manager: State<'_, StorytellerCredentialManager>, -) -> Result { - info!("storyteller_open_customer_portal_manage_plan_command called"); - - do_open_portal( - &app, - &app_data_root, - &app_env_configs, - &storyteller_creds_manager, - ) - .await - .map_err(|err| { - error!("Error opening customer portal window: {:?}", err); - format!("Error opening customer portal window: {:?}", err) - })?; - - Ok("result".to_string()) -} - -async fn do_open_portal( - app: &AppHandle, - app_data_root: &AppDataRoot, - app_env_configs: &AppEnvConfigs, - storyteller_creds_manager: &StorytellerCredentialManager, -) -> AnyhowResult<()> { - info!("Building billing window..."); - - open_storyteller_billing_window(OpenStorytellerBillingWindowArgs { - app, - app_data_root, - app_env_configs, - storyteller_creds_manager, - billing_window_case: BillingWindowCase::CustomerPortalManagePlan, - }).await?; - - info!("Done."); - Ok(()) -} diff --git a/crates/desktop/artcraft/src/services/storyteller/commands/stripe_customer_portal/storyteller_open_customer_portal_switch_plan_command.rs b/crates/desktop/artcraft/src/services/storyteller/commands/stripe_customer_portal/storyteller_open_customer_portal_switch_plan_command.rs deleted file mode 100644 index 4db1bd595c..0000000000 --- a/crates/desktop/artcraft/src/services/storyteller/commands/stripe_customer_portal/storyteller_open_customer_portal_switch_plan_command.rs +++ /dev/null @@ -1,77 +0,0 @@ -use crate::core::commands::deprecated::image_edit::enqueue_edit_image_command::{ImageEditModel, EditImageQuality, EditImageSize}; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::services::midjourney::state::midjourney_credential_manager::MidjourneyCredentialManager; -use crate::services::midjourney::windows::open_midjourney_login_window::open_midjourney_login_window; -use crate::services::sora::windows::sora_login_window::open_sora_login_window::open_sora_login_window; -use crate::services::storyteller::state::storyteller_credential_manager::StorytellerCredentialManager; -use crate::services::storyteller::windows::open_storyteller_billing_window::{open_storyteller_billing_window, BillingWindowCase, OpenStorytellerBillingWindowArgs}; -use artcraft_api_defs::stripe_artcraft::create_subscription_checkout::PlanBillingCadence; -use artcraft_api_defs::stripe_artcraft::customer_portal_switch_plan::PlanBillingCadenceConfirmation; -use enums::common::artcraft_subscription_slug::ArtcraftSubscriptionSlug; -use errors::AnyhowResult; -use log::{error, info}; -use serde_derive::Deserialize; -use tauri::{AppHandle, State}; -use tokens::tokens::media_files::MediaFileToken; - -#[derive(Deserialize, Debug)] -pub struct StorytellerOpenCustomerPortalSwitchPlanCommand { - pub plan: Option, - pub cadence: Option, -} - -#[tauri::command] -pub async fn storyteller_open_customer_portal_switch_plan_command( - app: AppHandle, - request: StorytellerOpenCustomerPortalSwitchPlanCommand, - app_data_root: State<'_, AppDataRoot>, - app_env_configs: State<'_, AppEnvConfigs>, - storyteller_creds_manager: State<'_, StorytellerCredentialManager>, -) -> Result { - info!("storyteller_open_customer_portal_switch_plan_command called"); - - let plan = request.plan.ok_or("Plan is required")?; - let cadence = request.cadence.ok_or("Cadence is required")?; - - do_open_portal( - &app, - &app_data_root, - &app_env_configs, - &storyteller_creds_manager, - plan, - cadence, - ) - .await - .map_err(|err| { - error!("Error opening customer portal window: {:?}", err); - format!("Error opening customer portal window: {:?}", err) - })?; - - Ok("result".to_string()) -} - -async fn do_open_portal( - app: &AppHandle, - app_data_root: &AppDataRoot, - app_env_configs: &AppEnvConfigs, - storyteller_creds_manager: &StorytellerCredentialManager, - plan: ArtcraftSubscriptionSlug, - cadence: PlanBillingCadenceConfirmation, -) -> AnyhowResult<()> { - info!("Building billing window..."); - - open_storyteller_billing_window(OpenStorytellerBillingWindowArgs { - app, - app_data_root, - app_env_configs, - storyteller_creds_manager, - billing_window_case: BillingWindowCase::CustomerPortalSwitchPlan { - plan, - cadence, - } - }).await?; - - info!("Done."); - Ok(()) -} diff --git a/crates/desktop/artcraft/src/services/storyteller/commands/stripe_customer_portal/storyteller_open_customer_portal_update_payment_method_command.rs b/crates/desktop/artcraft/src/services/storyteller/commands/stripe_customer_portal/storyteller_open_customer_portal_update_payment_method_command.rs deleted file mode 100644 index 71cde4d1f5..0000000000 --- a/crates/desktop/artcraft/src/services/storyteller/commands/stripe_customer_portal/storyteller_open_customer_portal_update_payment_method_command.rs +++ /dev/null @@ -1,59 +0,0 @@ -use crate::core::commands::deprecated::image_edit::enqueue_edit_image_command::{ImageEditModel, EditImageQuality, EditImageSize}; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::services::midjourney::state::midjourney_credential_manager::MidjourneyCredentialManager; -use crate::services::midjourney::windows::open_midjourney_login_window::open_midjourney_login_window; -use crate::services::sora::windows::sora_login_window::open_sora_login_window::open_sora_login_window; -use crate::services::storyteller::state::storyteller_credential_manager::StorytellerCredentialManager; -use crate::services::storyteller::windows::open_storyteller_billing_window::{open_storyteller_billing_window, BillingWindowCase, OpenStorytellerBillingWindowArgs}; -use artcraft_api_defs::stripe_artcraft::create_subscription_checkout::PlanBillingCadence; -use artcraft_api_defs::stripe_artcraft::customer_portal_switch_plan::PlanBillingCadenceConfirmation; -use errors::AnyhowResult; -use log::{error, info}; -use serde_derive::Deserialize; -use tauri::{AppHandle, State}; -use tokens::tokens::media_files::MediaFileToken; - -#[tauri::command] -pub async fn storyteller_open_customer_portal_update_payment_method_command( - app: AppHandle, - app_data_root: State<'_, AppDataRoot>, - app_env_configs: State<'_, AppEnvConfigs>, - storyteller_creds_manager: State<'_, StorytellerCredentialManager>, -) -> Result { - info!("storyteller_open_customer_portal_update_payment_method_command called"); - - do_open_portal( - &app, - &app_data_root, - &app_env_configs, - &storyteller_creds_manager, - ) - .await - .map_err(|err| { - error!("Error opening customer portal window: {:?}", err); - format!("Error opening customer portal window: {:?}", err) - })?; - - Ok("result".to_string()) -} - -async fn do_open_portal( - app: &AppHandle, - app_data_root: &AppDataRoot, - app_env_configs: &AppEnvConfigs, - storyteller_creds_manager: &StorytellerCredentialManager, -) -> AnyhowResult<()> { - info!("Building billing window..."); - - open_storyteller_billing_window(OpenStorytellerBillingWindowArgs { - app, - app_data_root, - app_env_configs, - storyteller_creds_manager, - billing_window_case: BillingWindowCase::CustomerPortalUpdatePaymentMethod, - }).await?; - - info!("Done."); - Ok(()) -} diff --git a/crates/desktop/artcraft/src/services/storyteller/mod.rs b/crates/desktop/artcraft/src/services/storyteller/mod.rs deleted file mode 100644 index 7b5a42c0bf..0000000000 --- a/crates/desktop/artcraft/src/services/storyteller/mod.rs +++ /dev/null @@ -1,4 +0,0 @@ -pub mod state; -pub mod threads; -pub mod windows; -pub mod commands; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/services/storyteller/state/mod.rs b/crates/desktop/artcraft/src/services/storyteller/state/mod.rs deleted file mode 100644 index 25b606ffdf..0000000000 --- a/crates/desktop/artcraft/src/services/storyteller/state/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub mod read_storyteller_credentials_from_disk; -pub mod storyteller_credential_holder; -pub mod storyteller_credential_manager; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/services/storyteller/state/read_storyteller_credentials_from_disk.rs b/crates/desktop/artcraft/src/services/storyteller/state/read_storyteller_credentials_from_disk.rs deleted file mode 100644 index ad021dce5e..0000000000 --- a/crates/desktop/artcraft/src/services/storyteller/state/read_storyteller_credentials_from_disk.rs +++ /dev/null @@ -1,39 +0,0 @@ -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use errors::AnyhowResult; -use std::fs::read_to_string; -use artcraft_client::credentials::storyteller_avt_cookie::StorytellerAvtCookie; -use artcraft_client::credentials::storyteller_credential_set::StorytellerCredentialSet; -use artcraft_client::credentials::storyteller_session_cookie::StorytellerSessionCookie; - -pub fn read_storyteller_credentials_from_disk(app_data_root: &AppDataRoot) -> AnyhowResult { - let creds_dir= app_data_root.credentials_dir(); - - let mut avt = None; - - { - let avt_file = creds_dir.get_storyteller_avt_cookie_file_path(); - if avt_file.exists() { - let contents = read_to_string(&avt_file)? - .trim() - .to_string(); - avt = Some(StorytellerAvtCookie::new(contents)); - } - } - - let mut session = None; - - { - let session_file = creds_dir.get_storyteller_session_cookie_file_path(); - if session_file.exists() { - let contents = read_to_string(&session_file)? - .trim() - .to_string(); - session = Some(StorytellerSessionCookie::new(contents)); - } - } - - Ok(StorytellerCredentialSet::initialize( - avt, - session, - )) -} diff --git a/crates/desktop/artcraft/src/services/storyteller/state/storyteller_credential_holder.rs b/crates/desktop/artcraft/src/services/storyteller/state/storyteller_credential_holder.rs deleted file mode 100644 index 5759f413c3..0000000000 --- a/crates/desktop/artcraft/src/services/storyteller/state/storyteller_credential_holder.rs +++ /dev/null @@ -1,57 +0,0 @@ -use anyhow::anyhow; -use errors::AnyhowResult; -use std::sync::{Arc, RwLock}; -use artcraft_client::credentials::storyteller_credential_set::StorytellerCredentialSet; - -/// Hold credentials for the application. -#[derive(Clone)] -pub struct StorytellerCredentialHolder { - credentials: Arc>>, -} - -impl StorytellerCredentialHolder { - pub fn new() -> Self { - Self { - credentials: Arc::new(RwLock::new(None)), - } - } - - pub fn set_credentials(&self, credentials: &StorytellerCredentialSet) -> AnyhowResult<()> { - match self.credentials.write() { - Err(err) => Err(anyhow!("Failed to acquire write lock: {:?}", err)), - Ok(mut creds) => { - *creds = Some(credentials.clone()); - Ok(()) - } - } - } - - pub fn clear_credentials(&self) -> AnyhowResult<()> { - match self.credentials.write() { - Err(err) => Err(anyhow!("Failed to acquire write lock: {:?}", err)), - Ok(mut creds) => { - *creds = None; - Ok(()) - } - } - } - - pub fn get_credentials(&self) -> AnyhowResult> { - match self.credentials.read() { - Err(err) => Err(anyhow!("Failed to acquire read lock: {:?}", err)), - Ok(creds) => { - Ok(creds.clone()) - } - } - } - - pub fn get_credentials_required(&self) -> AnyhowResult { - match self.credentials.read() { - Err(err) => Err(anyhow!("Failed to acquire read lock: {:?}", err)), - Ok(creds) => match &*creds { - None => Err(anyhow!("Storyteller credentials not set")), - Some(creds) => Ok(creds.clone()), - } - } - } -} diff --git a/crates/desktop/artcraft/src/services/storyteller/state/storyteller_credential_manager.rs b/crates/desktop/artcraft/src/services/storyteller/state/storyteller_credential_manager.rs deleted file mode 100644 index cb792bdee6..0000000000 --- a/crates/desktop/artcraft/src/services/storyteller/state/storyteller_credential_manager.rs +++ /dev/null @@ -1,129 +0,0 @@ -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::services::storyteller::state::read_storyteller_credentials_from_disk::read_storyteller_credentials_from_disk; -use crate::services::storyteller::state::storyteller_credential_holder::StorytellerCredentialHolder; -use errors::AnyhowResult; -use log::{info, warn}; -use std::fs::OpenOptions; -use std::io::Write; -use artcraft_client::credentials::storyteller_avt_cookie::StorytellerAvtCookie; -use artcraft_client::credentials::storyteller_credential_set::StorytellerCredentialSet; -use artcraft_client::credentials::storyteller_session_cookie::StorytellerSessionCookie; - -#[derive(Clone)] -pub struct StorytellerCredentialManager { - holder: StorytellerCredentialHolder, - app_data_root: AppDataRoot, -} - -impl StorytellerCredentialManager { - - pub fn initialize_empty(app_data_root: &AppDataRoot) -> Self { - Self { - holder: StorytellerCredentialHolder::new(), - app_data_root: app_data_root.clone(), - } - } - - pub fn initialize_from_disk_infallible(app_data_root: &AppDataRoot) -> Self { - let holder = StorytellerCredentialHolder::new(); - - match read_storyteller_credentials_from_disk(app_data_root) { - Err(err) => warn!("Failed to read credentials from disk: {:?}", err), - Ok(creds) => { - holder.set_credentials(&creds).expect("Failed to set credentials"); - } - } - - Self { - holder, - app_data_root: app_data_root.clone(), - } - } - - pub fn set_credentials(&self, creds: &StorytellerCredentialSet) -> AnyhowResult<()> { - self.holder.set_credentials(creds) - } - - pub fn clear_credentials(&self) -> AnyhowResult<()> { - self.holder.clear_credentials()?; - Ok(()) - } - - pub fn get_credentials(&self) -> AnyhowResult> { - self.holder.get_credentials() - } - - pub fn get_credentials_required(&self) -> AnyhowResult { - self.holder.get_credentials_required() - } - - pub fn reset_from_disk(&self) -> AnyhowResult { - let creds = read_storyteller_credentials_from_disk(&self.app_data_root)?; - self.holder.set_credentials(&creds)?; - Ok(creds) - } - - pub fn persist_all_to_disk(&self) -> AnyhowResult<()> { - let credentials = self.holder.get_credentials_required()?; - - info!("Persisting avt cookie to disk..."); - if let Some(avt) = credentials.avt.as_ref() { - persist_avt_to_disk(&avt, &self.app_data_root)?; - } - - info!("Persisting session cookie to disk..."); - if let Some(session) = credentials.session.as_ref() { - persist_session_to_disk(&session, &self.app_data_root)?; - } - - Ok(()) - } - - pub fn delete_persisted_copies_on_disk(&self) -> AnyhowResult<()> { - let creds_dir = self.app_data_root.credentials_dir(); - - let session_file = creds_dir.get_storyteller_session_cookie_file_path(); - if session_file.exists() { - std::fs::remove_file(session_file)?; - } - - let avt_file = creds_dir.get_storyteller_avt_cookie_file_path(); - if avt_file.exists() { - std::fs::remove_file(avt_file)?; - } - - Ok(()) - } -} - -fn persist_session_to_disk(session: &StorytellerSessionCookie, app_data_root: &AppDataRoot) -> AnyhowResult<()> { - let creds_dir = app_data_root.credentials_dir(); - let filename = creds_dir.get_storyteller_session_cookie_file_path(); - - let mut file = OpenOptions::new() - .create(true) - .write(true) - .truncate(true) - .open(filename)?; - - file.write_all(session.as_bytes())?; - file.flush()?; - - Ok(()) -} - -fn persist_avt_to_disk(avt: &StorytellerAvtCookie, app_data_root: &AppDataRoot) -> AnyhowResult<()> { - let creds_dir = app_data_root.credentials_dir(); - let filename = creds_dir.get_storyteller_avt_cookie_file_path(); - - let mut file = OpenOptions::new() - .create(true) - .write(true) - .truncate(true) - .open(filename)?; - - file.write_all(avt.as_bytes())?; - file.flush()?; - - Ok(()) -} diff --git a/crates/desktop/artcraft/src/services/storyteller/threads/mod.rs b/crates/desktop/artcraft/src/services/storyteller/threads/mod.rs deleted file mode 100644 index 663bd6cd82..0000000000 --- a/crates/desktop/artcraft/src/services/storyteller/threads/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod storyteller_activity_thread; -pub mod storyteller_task_polling_thread; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/services/storyteller/threads/storyteller_activity_thread.rs b/crates/desktop/artcraft/src/services/storyteller/threads/storyteller_activity_thread.rs deleted file mode 100644 index dae9c58222..0000000000 --- a/crates/desktop/artcraft/src/services/storyteller/threads/storyteller_activity_thread.rs +++ /dev/null @@ -1,129 +0,0 @@ -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; -use crate::core::state::artcraft_platform_info::ArtcraftPlatformInfo; -use crate::core::state::artcraft_usage_tracker::artcraft_usage_tracker::ArtcraftUsageTracker; -use crate::services::storyteller::state::storyteller_credential_manager::StorytellerCredentialManager; -use anyhow::anyhow; -use artcraft_api_defs::analytics::log_active_user::LogAppActiveUserRequest; -use artcraft_client::endpoints::analytics::log_active_user_v2::log_active_user_v2; -use artcraft_client::error::api_error::ApiError; -use artcraft_client::error::storyteller_error::StorytellerError; -use errors::AnyhowResult; -use log::{debug, error, info}; -use sqlite_tasks::queries::list_tasks_by_provider_and_tokens::{list_tasks_by_provider_and_tokens, ListTasksArgs}; -use std::time::Instant; -use tokens::tokens::app_session::AppSessionToken; - -const CLIENT_NAME : &str = "artcraft"; - -const ERROR_SLEEP_MILLIS : u64 = 1_000 * 60 * 3; // 3 minutes; - -pub async fn storyteller_activity_thread( - app_env_configs: AppEnvConfigs, - artcraft_platform_info: ArtcraftPlatformInfo, - artcraft_usage_tracker: ArtcraftUsageTracker, - storyteller_creds_manager: StorytellerCredentialManager, -) -> ! { - let startup = Instant::now(); - let app_session_token = AppSessionToken::generate(); - - info!("Session started at {:?} with token: {:?}", startup, app_session_token); - - loop { - let res = polling_loop( - &app_env_configs, - &artcraft_usage_tracker, - &storyteller_creds_manager, - startup, - &artcraft_platform_info, - &app_session_token, - ).await; - if let Err(err) = res { - error!("An error occurred: {:?}", err); - } - // NB: Sleep if an error occurs. - tokio::time::sleep(std::time::Duration::from_millis(ERROR_SLEEP_MILLIS)).await; - } -} - -async fn polling_loop( - app_env_configs: &AppEnvConfigs, - artcraft_usage_tracker: &ArtcraftUsageTracker, - storyteller_creds_manager: &StorytellerCredentialManager, - startup: Instant, - artcraft_platform_info: &ArtcraftPlatformInfo, - app_session_token: &AppSessionToken, -) -> AnyhowResult<()> { - loop { - let creds = storyteller_creds_manager.get_credentials()?; - - let creds = match creds { - None => { - tokio::time::sleep(std::time::Duration::from_millis(5_000)).await; - continue; - } - Some(creds) => { - if creds.is_empty() { - tokio::time::sleep(std::time::Duration::from_millis(5_000)).await; - continue; - } - creds - }, - }; - - let usage_data = artcraft_usage_tracker.get()?; - - let time_since_startup = Instant::now().duration_since(startup); - - let request = LogAppActiveUserRequest { - maybe_app_session_token: Some(app_session_token.clone()), - maybe_app_name: Some(CLIENT_NAME.to_string()), - maybe_app_version: Some(artcraft_platform_info.artcraft_version.clone()), - maybe_os_platform: Some(artcraft_platform_info.os_platform.as_str().to_owned()), - maybe_os_version: Some(artcraft_platform_info.os_version.clone()), - maybe_session_duration_seconds: Some(time_since_startup.as_secs()), - total_generation_count: Some(usage_data.total_generation_count), - image_generation_count: Some(usage_data.image_generation_count), - video_generation_count: Some(usage_data.video_generation_count), - object_generation_count: Some(usage_data.object_generation_count), - text_to_image_count: Some(usage_data.text_to_image_count), - image_to_image_count: Some(usage_data.image_to_image_count), - text_to_video_count: Some(usage_data.text_to_video_count), - image_to_video_count: Some(usage_data.image_to_video_count), - text_to_object_count: Some(usage_data.text_to_object_count), - image_to_object_count: Some(usage_data.image_to_object_count), - image_page_prompt_count: Some(usage_data.image_page_prompt_count), - video_page_prompt_count: Some(usage_data.video_page_prompt_count), - edit_page_prompt_count: Some(usage_data.edit_page_prompt_count), - stage_page_prompt_count: Some(usage_data.stage_page_prompt_count), - object_page_prompt_count: Some(usage_data.object_page_prompt_count), - other_page_prompt_count: Some(usage_data.other_page_prompt_count), - }; - - debug!("Logging active user with storyteller."); - - let result = log_active_user_v2( - &app_env_configs.storyteller_host, - Some(&creds), - request, - ).await; - - let wait_millis = match result { - Ok(result) => result.wait_for_retry_millis, - Err(err) => { - match &err { - StorytellerError::Api(ApiError::TooManyRequests(message)) => { - error!("Too many requests (sleeping): {:?}", message); - tokio::time::sleep(std::time::Duration::from_millis(ERROR_SLEEP_MILLIS)).await; - continue; - } - _ => {} - } - return Err(anyhow!(err)); - } - }; - - // Wait at least a minute, no matter what the server tells us. - let wait_millis = std::cmp::min(wait_millis, 60_000); - tokio::time::sleep(std::time::Duration::from_millis(wait_millis)).await; - } -} diff --git a/crates/desktop/artcraft/src/services/storyteller/threads/storyteller_task_polling_thread/events/maybe_handle_frontend_caller_notification.rs b/crates/desktop/artcraft/src/services/storyteller/threads/storyteller_task_polling_thread/events/maybe_handle_frontend_caller_notification.rs deleted file mode 100644 index efcbff57d5..0000000000 --- a/crates/desktop/artcraft/src/services/storyteller/threads/storyteller_task_polling_thread/events/maybe_handle_frontend_caller_notification.rs +++ /dev/null @@ -1,276 +0,0 @@ -use crate::core::events::basic_sendable_event_trait::BasicSendableEvent; -use crate::core::events::functional_events::canvas_background_removal_complete_event::CanvasBackgroundRemovalCompleteEvent; -use crate::core::events::functional_events::gaussian_generation_complete_event::{GaussianGenerationCompleteEvent, GeneratedGaussian}; -use crate::core::events::functional_events::image_edit_complete_event::{EditedImage, ImageEditCompleteEvent}; -use crate::core::events::functional_events::object_generation_complete_event::{GeneratedObject, ObjectGenerationCompleteEvent}; -use crate::core::events::functional_events::text_to_image_generation_complete_event::{GeneratedImage, TextToImageGenerationCompleteEvent}; -use crate::core::events::functional_events::video_generation_complete_event::{GeneratedVideo, VideoGenerationCompleteEvent}; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; -use anyhow::anyhow; -use artcraft_api_defs::jobs::list_session_jobs::{ListSessionJobsItem, ListSessionResultDetailsResponse}; -use artcraft_api_defs::utils::media_links_to_thumbnail_template::media_links_to_thumbnail_template; -use enums::tauri::tasks::task_type::TaskType; -use errors::AnyhowResult; -use log::{error, warn}; -use sqlite_tasks::queries::list_tasks_by_provider_and_tokens::{list_tasks_by_provider_and_tokens, ListTasksArgs}; -use sqlite_tasks::queries::task::Task; -use artcraft_client::credentials::storyteller_credential_set::StorytellerCredentialSet; -use artcraft_client::endpoints::media_files::list_batch_generated_redux_media_files::list_batch_generated_redux_media_files; -use tauri::AppHandle; -use tokens::tokens::batch_generations::BatchGenerationToken; -use tokens::tokens::media_files::MediaFileToken; - -pub async fn maybe_handle_frontend_caller_notification( - app: &AppHandle, - app_env_configs: &AppEnvConfigs, - maybe_creds: Option<&StorytellerCredentialSet>, - task: &Task, - job: &ListSessionJobsItem, -) -> AnyhowResult<()> { - - let job_result = match job.maybe_result { - Some(ref res) => res, - None => { - warn!("Job result is None for task: {:?}", task); - return Ok(()); // No result, nothing to do - }, - }; - - match task.task_type { - // Audio uses the session-job feed and the common task completion event. - TaskType::AudioGeneration => {}, - TaskType::ImageGeneration => { - let _r = handle_image_generation( - app, - task, - job_result, - app_env_configs, - maybe_creds, - ).await?; - } - TaskType::ImageInpaintEdit => { - let _r = handle_inpaint_image_generation( - app, - task, - job_result, - app_env_configs, - maybe_creds, - ).await?; - } - TaskType::VideoGeneration => { - let _r = handle_video_generation( - app, - task, - job_result, - ).await?; - } - TaskType::ObjectGeneration => { - let _r = handle_object_generation( - app, - task, - job_result, - ).await?; - } - TaskType::GaussianGeneration => { - let _r = handle_gaussian_generation( - app, - task, - job_result, - ).await?; - } - TaskType::BackgroundRemoval => { - let _r = handle_background_removal_generation( - app, - task, - job_result, - ).await?; - } - } - - Ok(()) -} - -async fn handle_image_generation( - app: &AppHandle, - task: &Task, - job_result: &ListSessionResultDetailsResponse, - app_env_configs: &AppEnvConfigs, - maybe_creds: Option<&StorytellerCredentialSet>, -) -> AnyhowResult<()> { - - let generated_images = match job_result.maybe_batch_token.as_ref() { - None => { - vec![GeneratedImage { - media_token: MediaFileToken::new_from_str(&job_result.entity_token), - cdn_url: job_result.media_links.cdn_url.clone(), - maybe_thumbnail_template: job_result.media_links.maybe_thumbnail_template.clone(), - }] - } - Some(batch_token) => { - let result = list_batch_generated_redux_media_files( - &app_env_configs.storyteller_host, - maybe_creds, - batch_token, - ).await?; - - if result.media_files.is_empty() { - return Err(anyhow!("No media files found for batch token: {}", batch_token)); - } - - result.media_files - .into_iter() - .map(|file| GeneratedImage { - media_token: file.token, - cdn_url: file.media_links.cdn_url, - maybe_thumbnail_template: file.media_links.maybe_thumbnail_template, - }) - .collect() - } - }; - - let event = TextToImageGenerationCompleteEvent { - generated_images, - maybe_frontend_subscriber_id: task.frontend_subscriber_id.clone(), - maybe_frontend_subscriber_payload: task.frontend_subscriber_payload.clone(), - }; - - event.send_infallible(&app); - - Ok(()) -} - -async fn handle_inpaint_image_generation( - app: &AppHandle, - task: &Task, - job_result: &ListSessionResultDetailsResponse, - app_env_configs: &AppEnvConfigs, - maybe_creds: Option<&StorytellerCredentialSet>, -) -> AnyhowResult<()> { - - let edited_images = match job_result.maybe_batch_token.as_ref() { - None => { - vec![EditedImage { - media_token: MediaFileToken::new_from_str(&job_result.entity_token), - cdn_url: job_result.media_links.cdn_url.clone(), - maybe_thumbnail_template: job_result.media_links.maybe_thumbnail_template.clone(), - }] - } - Some(batch_token) => { - let result = list_batch_generated_redux_media_files( - &app_env_configs.storyteller_host, - maybe_creds, - batch_token, - ).await?; - - if result.media_files.is_empty() { - return Err(anyhow!("No media files found for batch token: {}", batch_token)); - } - - result.media_files - .into_iter() - .map(|file| EditedImage { - media_token: file.token, - cdn_url: file.media_links.cdn_url, - maybe_thumbnail_template: file.media_links.maybe_thumbnail_template, - }) - .collect() - } - }; - - let event = ImageEditCompleteEvent { - edited_images, - maybe_frontend_subscriber_id: task.frontend_subscriber_id.clone(), - maybe_frontend_subscriber_payload: task.frontend_subscriber_payload.clone(), - }; - - event.send_infallible(&app); - - Ok(()) -} - -async fn handle_video_generation( - app: &AppHandle, - task: &Task, - job_result: &ListSessionResultDetailsResponse, -) -> AnyhowResult<()> { - - // NB: For now, we only generate one video at a time. - let event = VideoGenerationCompleteEvent { - generated_video: Some(GeneratedVideo { - media_token: MediaFileToken::new_from_str(&job_result.entity_token), - cdn_url: job_result.media_links.cdn_url.clone(), - maybe_thumbnail_template: media_links_to_thumbnail_template(&job_result.media_links) - .map(|s| s.to_owned()), - }), - maybe_frontend_subscriber_id: task.frontend_subscriber_id.clone(), - maybe_frontend_subscriber_payload: task.frontend_subscriber_payload.clone(), - }; - - event.send_infallible(&app); - - Ok(()) -} - -async fn handle_object_generation( - app: &AppHandle, - task: &Task, - job_result: &ListSessionResultDetailsResponse, -) -> AnyhowResult<()> { - - // NB: For now, we only generate one object (3d mesh) at a time. - let event = ObjectGenerationCompleteEvent { - generated_object: Some(GeneratedObject { - media_token: MediaFileToken::new_from_str(&job_result.entity_token), - cdn_url: job_result.media_links.cdn_url.clone(), - maybe_thumbnail_template: media_links_to_thumbnail_template(&job_result.media_links) - .map(|s| s.to_owned()), - }), - maybe_frontend_subscriber_id: task.frontend_subscriber_id.clone(), - maybe_frontend_subscriber_payload: task.frontend_subscriber_payload.clone(), - }; - - event.send_infallible(&app); - - Ok(()) -} - -async fn handle_gaussian_generation( - app: &AppHandle, - task: &Task, - job_result: &ListSessionResultDetailsResponse, -) -> AnyhowResult<()> { - - // NB: For now, we only generate one object (gaussian) at a time. - let event = GaussianGenerationCompleteEvent { - generated_gaussian: Some(GeneratedGaussian { - media_token: MediaFileToken::new_from_str(&job_result.entity_token), - cdn_url: job_result.media_links.cdn_url.clone(), - maybe_thumbnail_template: media_links_to_thumbnail_template(&job_result.media_links) - .map(|s| s.to_owned()), - }), - maybe_frontend_subscriber_id: task.frontend_subscriber_id.clone(), - maybe_frontend_subscriber_payload: task.frontend_subscriber_payload.clone(), - }; - - event.send_infallible(&app); - - Ok(()) -} - -async fn handle_background_removal_generation( - app: &AppHandle, - task: &Task, - job_result: &ListSessionResultDetailsResponse, -) -> AnyhowResult<()> { - - let event = CanvasBackgroundRemovalCompleteEvent { - media_token: MediaFileToken::new_from_str(&job_result.entity_token), - image_cdn_url: job_result.media_links.cdn_url.clone(), - maybe_frontend_subscriber_id: task.frontend_subscriber_id.clone(), - maybe_frontend_subscriber_payload: task.frontend_subscriber_payload.clone(), - }; - - event.send_infallible(&app); - - Ok(()) -} diff --git a/crates/desktop/artcraft/src/services/storyteller/threads/storyteller_task_polling_thread/events/maybe_handle_inpainting_complete_event.rs b/crates/desktop/artcraft/src/services/storyteller/threads/storyteller_task_polling_thread/events/maybe_handle_inpainting_complete_event.rs deleted file mode 100644 index c1e6e24791..0000000000 --- a/crates/desktop/artcraft/src/services/storyteller/threads/storyteller_task_polling_thread/events/maybe_handle_inpainting_complete_event.rs +++ /dev/null @@ -1,126 +0,0 @@ -use crate::core::events::basic_sendable_event_trait::BasicSendableEvent; -use crate::core::events::functional_events::canvas_background_removal_complete_event::CanvasBackgroundRemovalCompleteEvent; -use crate::core::events::functional_events::image_edit_complete_event::{EditedImage, ImageEditCompleteEvent}; -use crate::core::events::generation_events::generation_complete_event::GenerationCompleteEvent; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; -use anyhow::anyhow; -use artcraft_api_defs::jobs::list_session_jobs::{ListSessionJobsItem, ListSessionResultDetailsResponse}; -use enums::tauri::tasks::task_type::TaskType; -use enums::tauri::ux::tauri_command_caller::TauriCommandCaller; -use errors::AnyhowResult; -use log::{error, warn}; -use sqlite_tasks::queries::list_tasks_by_provider_and_tokens::{list_tasks_by_provider_and_tokens, ListTasksArgs}; -use sqlite_tasks::queries::task::Task; -use artcraft_client::credentials::storyteller_credential_set::StorytellerCredentialSet; -use artcraft_client::endpoints::media_files::list_batch_generated_redux_media_files::list_batch_generated_redux_media_files; -use tauri::AppHandle; -use tokens::tokens::batch_generations::BatchGenerationToken; -use tokens::tokens::media_files::MediaFileToken; - -pub async fn maybe_handle_inpainting_complete_event( - app: &AppHandle, - app_env_configs: &AppEnvConfigs, - maybe_creds: Option<&StorytellerCredentialSet>, - task: &Task, - job: &ListSessionJobsItem, -) -> AnyhowResult<()> { - - match task.task_type { - TaskType::ImageInpaintEdit => {} // NB: Fall-through - _ => return Ok(()), - } - - match task.frontend_caller { - Some(TauriCommandCaller::ImageEditor) => {} // NB: Fall-through - _ => return Ok(()), - } - - let job_result = match job.maybe_result { - Some(ref res) => res, - None => { - warn!("Job result is None for task: {:?}", task); - return Ok(()); // No result, nothing to do - }, - }; - - let event = match job_result.maybe_batch_token.as_ref() { - Some(batch_token) => { - handle_batch( - app, - app_env_configs, - maybe_creds, - task, - job, - job_result, - batch_token - ).await? - } - None => { - handle_single( - app, - task, - job, - job_result, - ).await? - } - }; - - if let Err(err) = event.send(&app) { - error!("Failed to send ImageEditCompleteEvent: {:?}", err); // Fail open - } - - Ok(()) -} - -pub async fn handle_single( - app: &AppHandle, - task: &Task, - job: &ListSessionJobsItem, - job_result: &ListSessionResultDetailsResponse, -) -> AnyhowResult { - Ok(ImageEditCompleteEvent { - edited_images: vec![EditedImage { - media_token: MediaFileToken::new_from_str(&job_result.entity_token), - cdn_url: job_result.media_links.cdn_url.clone(), - maybe_thumbnail_template: job_result.media_links.maybe_thumbnail_template.clone(), - }], - maybe_frontend_subscriber_id: task.frontend_subscriber_id.clone(), - maybe_frontend_subscriber_payload: task.frontend_subscriber_payload.clone(), - }) -} - -pub async fn handle_batch( - app: &AppHandle, - app_env_configs: &AppEnvConfigs, - maybe_creds: Option<&StorytellerCredentialSet>, - task: &Task, - job: &ListSessionJobsItem, - job_result: &ListSessionResultDetailsResponse, - batch_token: &BatchGenerationToken, -) -> AnyhowResult { - - let result = list_batch_generated_redux_media_files( - &app_env_configs.storyteller_host, - maybe_creds, - batch_token, - ).await?; - - if result.media_files.is_empty() { - return Err(anyhow!("No media files found for batch token: {}", batch_token)); - } - - let media_files = result.media_files - .into_iter() - .map(|file| EditedImage { - media_token: file.token, - cdn_url: file.media_links.cdn_url, - maybe_thumbnail_template: file.media_links.maybe_thumbnail_template, - }) - .collect(); - - Ok(ImageEditCompleteEvent { - edited_images: media_files, - maybe_frontend_subscriber_id: task.frontend_subscriber_id.clone(), - maybe_frontend_subscriber_payload: task.frontend_subscriber_payload.clone(), - }) -} diff --git a/crates/desktop/artcraft/src/services/storyteller/threads/storyteller_task_polling_thread/events/maybe_handle_text_to_image_complete_event.rs b/crates/desktop/artcraft/src/services/storyteller/threads/storyteller_task_polling_thread/events/maybe_handle_text_to_image_complete_event.rs deleted file mode 100644 index d3bffd2d0f..0000000000 --- a/crates/desktop/artcraft/src/services/storyteller/threads/storyteller_task_polling_thread/events/maybe_handle_text_to_image_complete_event.rs +++ /dev/null @@ -1,124 +0,0 @@ -use crate::core::events::basic_sendable_event_trait::BasicSendableEvent; -use crate::core::events::functional_events::text_to_image_generation_complete_event::{GeneratedImage, TextToImageGenerationCompleteEvent}; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; -use anyhow::anyhow; -use artcraft_api_defs::jobs::list_session_jobs::{ListSessionJobsItem, ListSessionResultDetailsResponse}; -use enums::tauri::tasks::task_type::TaskType; -use enums::tauri::ux::tauri_command_caller::TauriCommandCaller; -use errors::AnyhowResult; -use log::{error, warn}; -use sqlite_tasks::queries::list_tasks_by_provider_and_tokens::{list_tasks_by_provider_and_tokens, ListTasksArgs}; -use sqlite_tasks::queries::task::Task; -use artcraft_client::credentials::storyteller_credential_set::StorytellerCredentialSet; -use artcraft_client::endpoints::media_files::list_batch_generated_redux_media_files::list_batch_generated_redux_media_files; -use tauri::AppHandle; -use tokens::tokens::batch_generations::BatchGenerationToken; -use tokens::tokens::media_files::MediaFileToken; - -pub async fn maybe_handle_text_to_image_complete_event( - app: &AppHandle, - app_env_configs: &AppEnvConfigs, - maybe_creds: Option<&StorytellerCredentialSet>, - task: &Task, - job: &ListSessionJobsItem, -) -> AnyhowResult<()> { - - match task.task_type { - TaskType::ImageGeneration => {} // NB: Fall-through - _ => return Ok(()), - } - - match task.frontend_caller { - Some(TauriCommandCaller::TextToImage) => {} // NB: Fall-through - _ => return Ok(()), - } - - let job_result = match job.maybe_result { - Some(ref res) => res, - None => { - warn!("Job result is None for task: {:?}", task); - return Ok(()); // No result, nothing to do - }, - }; - - let event = match job_result.maybe_batch_token.as_ref() { - Some(batch_token) => { - handle_batch( - app, - app_env_configs, - maybe_creds, - task, - job, - job_result, - batch_token - ).await? - } - None => { - handle_single( - app, - task, - job, - job_result, - ).await? - } - }; - - if let Err(err) = event.send(&app) { - error!("Failed to send TextToImageGenerationCompleteEvent: {:?}", err); // Fail open - } - - Ok(()) -} - -async fn handle_single( - app: &AppHandle, - task: &Task, - job: &ListSessionJobsItem, - job_result: &ListSessionResultDetailsResponse, -) -> AnyhowResult { - Ok(TextToImageGenerationCompleteEvent { - generated_images: vec![GeneratedImage { - media_token: MediaFileToken::new_from_str(&job_result.entity_token), - cdn_url: job_result.media_links.cdn_url.clone(), - maybe_thumbnail_template: job_result.media_links.maybe_thumbnail_template.clone(), - }], - maybe_frontend_subscriber_id: task.frontend_subscriber_id.clone(), - maybe_frontend_subscriber_payload: task.frontend_subscriber_payload.clone(), - }) -} - -async fn handle_batch( - app: &AppHandle, - app_env_configs: &AppEnvConfigs, - maybe_creds: Option<&StorytellerCredentialSet>, - task: &Task, - job: &ListSessionJobsItem, - job_result: &ListSessionResultDetailsResponse, - batch_token: &BatchGenerationToken, -) -> AnyhowResult { - - let result = list_batch_generated_redux_media_files( - &app_env_configs.storyteller_host, - maybe_creds, - batch_token, - ).await?; - - if result.media_files.is_empty() { - return Err(anyhow!("No media files found for batch token: {}", batch_token)); - } - - let media_files = result.media_files - .into_iter() - .map(|file| GeneratedImage { - media_token: file.token, - cdn_url: file.media_links.cdn_url, - maybe_thumbnail_template: file.media_links.maybe_thumbnail_template, - }) - .collect(); - - Ok(TextToImageGenerationCompleteEvent { - generated_images: media_files, - maybe_frontend_subscriber_id: task.frontend_subscriber_id.clone(), - maybe_frontend_subscriber_payload: task.frontend_subscriber_payload.clone(), - }) -} diff --git a/crates/desktop/artcraft/src/services/storyteller/threads/storyteller_task_polling_thread/events/maybe_send_background_removal_complete_event.rs b/crates/desktop/artcraft/src/services/storyteller/threads/storyteller_task_polling_thread/events/maybe_send_background_removal_complete_event.rs deleted file mode 100644 index f5fa250e7d..0000000000 --- a/crates/desktop/artcraft/src/services/storyteller/threads/storyteller_task_polling_thread/events/maybe_send_background_removal_complete_event.rs +++ /dev/null @@ -1,49 +0,0 @@ -use crate::core::events::basic_sendable_event_trait::BasicSendableEvent; -use crate::core::events::functional_events::canvas_background_removal_complete_event::CanvasBackgroundRemovalCompleteEvent; -use crate::core::events::generation_events::generation_complete_event::GenerationCompleteEvent; -use artcraft_api_defs::jobs::list_session_jobs::ListSessionJobsItem; -use enums::tauri::tasks::task_type::TaskType; -use enums::tauri::ux::tauri_command_caller::TauriCommandCaller; -use errors::AnyhowResult; -use log::error; -use sqlite_tasks::queries::list_tasks_by_provider_and_tokens::{list_tasks_by_provider_and_tokens, ListTasksArgs}; -use sqlite_tasks::queries::task::Task; -use tokens::tokens::media_files::MediaFileToken; - -pub async fn maybe_send_background_removal_complete_event( - app: &tauri::AppHandle, - task: &Task, - job: &ListSessionJobsItem, -) -> AnyhowResult<()> { - - match task.task_type { - TaskType::BackgroundRemoval => {} // NB: Fall-through - _ => return Ok(()), - } - - match task.frontend_caller { - Some(TauriCommandCaller::Canvas) => {} // NB: Fall-through - _ => return Ok(()), - } - - let result = match job.maybe_result { - Some(ref res) => res, - None => { - error!("Job result is None for task: {:?}", task); - return Ok(()); // No result, nothing to do - }, - }; - - let event = CanvasBackgroundRemovalCompleteEvent { - media_token: MediaFileToken::new_from_str(&result.entity_token), - image_cdn_url: result.media_links.cdn_url.clone(), - maybe_frontend_subscriber_id: task.frontend_subscriber_id.clone(), - maybe_frontend_subscriber_payload: task.frontend_subscriber_payload.clone(), - }; - - if let Err(err) = event.send(&app) { - error!("Failed to send CanvasBackgroundRemovalCompleteEvent: {:?}", err); // Fail open - } - - Ok(()) -} \ No newline at end of file diff --git a/crates/desktop/artcraft/src/services/storyteller/threads/storyteller_task_polling_thread/events/mod.rs b/crates/desktop/artcraft/src/services/storyteller/threads/storyteller_task_polling_thread/events/mod.rs deleted file mode 100644 index c9ae78ea32..0000000000 --- a/crates/desktop/artcraft/src/services/storyteller/threads/storyteller_task_polling_thread/events/mod.rs +++ /dev/null @@ -1,4 +0,0 @@ -pub (super) mod maybe_handle_frontend_caller_notification; -pub (super) mod maybe_handle_inpainting_complete_event; -pub (super) mod maybe_handle_text_to_image_complete_event; -pub (super) mod maybe_send_background_removal_complete_event; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/services/storyteller/threads/storyteller_task_polling_thread/handle_storyteller_failed_job.rs b/crates/desktop/artcraft/src/services/storyteller/threads/storyteller_task_polling_thread/handle_storyteller_failed_job.rs deleted file mode 100644 index 78a3bc71d0..0000000000 --- a/crates/desktop/artcraft/src/services/storyteller/threads/storyteller_task_polling_thread/handle_storyteller_failed_job.rs +++ /dev/null @@ -1,53 +0,0 @@ -use crate::core::events::generation_events::common::GenerationModel; -use crate::core::events::basic_sendable_event_trait::BasicSendableEvent; -use crate::core::events::generation_events::generation_failed_event::GenerationFailedEvent; -use crate::core::state::task_database::TaskDatabase; -use crate::core::utils::enum_conversion::generation_provider::to_generation_service_provider; -use crate::core::utils::enum_conversion::task_type::to_generation_action; -use artcraft_api_defs::jobs::list_session_jobs::ListSessionJobsItem; -use enums::tauri::tasks::task_status::TaskStatus; -use errors::AnyhowResult; -use log::info; -use sqlite_tasks::queries::task::Task; -use sqlite_tasks::queries::update_task_status::{update_task_status, UpdateTaskArgs}; -use tauri::AppHandle; -use enums::tauri::tasks::task_failure_type::TaskFailureType; -use sqlite_tasks::queries::update_task_status_with_rich_failure::{update_task_status_with_rich_failure, UpdateTaskWithRichFailureArgs}; - -pub async fn handle_failed_job( - app_handle: &AppHandle, - job: &ListSessionJobsItem, - task: &Task, - task_database: &TaskDatabase, -) -> AnyhowResult<()> { - info!("Marking storyteller job as failed: {:?}", task.id); - - let maybe_failure_type = job.status - .maybe_failure_category_updated - .as_ref() - .map(|val| TaskFailureType::from_frontend_failure_category_for_api(val)); - - let maybe_failure_message = job.status.maybe_failure_message.as_deref(); - - update_task_status_with_rich_failure(UpdateTaskWithRichFailureArgs { - db: task_database.get_connection(), - task_id: &task.id, - status: TaskStatus::CompleteFailure, - maybe_failure_type, - maybe_failure_message, - }).await?; - - let service = to_generation_service_provider(task.provider); - let action = to_generation_action(task.task_type); - - let event = GenerationFailedEvent { - action, - service, - model: task.model_type.as_ref().map(|model| GenerationModel::Unknown(model.to_str().to_owned())), - reason: None, - }; - - event.send_infallible(app_handle); - - Ok(()) -} diff --git a/crates/desktop/artcraft/src/services/storyteller/threads/storyteller_task_polling_thread/handle_storyteller_successful_job.rs b/crates/desktop/artcraft/src/services/storyteller/threads/storyteller_task_polling_thread/handle_storyteller_successful_job.rs deleted file mode 100644 index 3393bb955c..0000000000 --- a/crates/desktop/artcraft/src/services/storyteller/threads/storyteller_task_polling_thread/handle_storyteller_successful_job.rs +++ /dev/null @@ -1,179 +0,0 @@ -use crate::core::events::basic_sendable_event_trait::BasicSendableEvent; -use crate::core::events::generation_events::common::{GenerationAction, GenerationModel}; -use crate::core::events::generation_events::generation_complete_event::GenerationCompleteEvent; -use crate::core::events::sendable_event_trait::SendableEvent; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; -use crate::core::state::task_database::TaskDatabase; -use crate::core::utils::enum_conversion::generation_provider::to_generation_service_provider; -use crate::core::utils::enum_conversion::task_type::to_generation_action; -use super::events::maybe_handle_frontend_caller_notification::maybe_handle_frontend_caller_notification; -use artcraft_api_defs::jobs::list_session_jobs::ListSessionJobsItem; -use artcraft_api_defs::utils::media_links_to_thumbnail_template::media_links_to_thumbnail_template; -use artcraft_client::credentials::storyteller_credential_set::StorytellerCredentialSet; -use enums::by_table::generic_inference_jobs::inference_category::InferenceCategory; -use enums::tauri::tasks::task_media_file_class::TaskMediaFileClass; -use errors::AnyhowResult; -use log::error; -use log::info; -use sqlite_tasks::queries::task::Task; -use sqlite_tasks::queries::update_successful_task_status_with_metadata::{update_successful_task_status_with_metadata, UpdateSuccessfulTaskArgs}; -use tauri::AppHandle; -use tokens::tokens::media_files::MediaFileToken; - -pub async fn handle_successful_job( - app_handle: &AppHandle, - app_env_configs: &AppEnvConfigs, - creds: Option<&StorytellerCredentialSet>, - job: &ListSessionJobsItem, - task: &Task, - task_database: &TaskDatabase, -) -> AnyhowResult<()> { - let maybe_primary_media_file_token = job.maybe_result - .as_ref() - .map(|result| MediaFileToken::new_from_str(&result.entity_token)); - - let updated = update_successful_task_status_with_metadata(UpdateSuccessfulTaskArgs { - db: task_database.get_connection(), - task_id: &task.id, - maybe_batch_token: job.maybe_result - .as_ref() - .map(|result| result.maybe_batch_token.as_ref()) - .flatten(), - maybe_primary_media_file_token: maybe_primary_media_file_token.as_ref(), - maybe_primary_media_file_class: get_media_file_class(job), - maybe_primary_media_file_thumbnail_url_template: get_thumbnail_template(job), - maybe_primary_media_file_cdn_url: job.maybe_result - .as_ref() - .map(|result| result.media_links.cdn_url.as_str()), - }).await?; - - if !updated { - return Ok(()); // If anything breaks with queries, don't spam events. - } - - send_additional_success_events(app_handle, app_env_configs, creds, job, task).await; - - let service = to_generation_service_provider(task.provider); - let action = to_generation_action(task.task_type); - - let event = GenerationCompleteEvent { - action: Some(action), - service, - model: task.model_type.as_ref().map(|model| GenerationModel::Unknown(model.to_str().to_owned())), - }; - - if let Err(err) = event.send(app_handle) { - error!("Failed to send GenerationCompleteEvent: {:?}", err); // Fail open - } - - Ok(()) -} - -async fn send_additional_success_events( - app_handle: &AppHandle, - app_env_configs: &AppEnvConfigs, - creds: Option<&StorytellerCredentialSet>, - job: &ListSessionJobsItem, - task: &Task -) { - info!("Attempting to dispatch events for completed Storyteller job: {:?}", task); - - let result = maybe_handle_frontend_caller_notification( - app_handle, - app_env_configs, - creds, - task, - job, - ).await; - - if let Err(err) = result { - error!("Failed to send generation complete event: {:?}", err); - } - - //let result = maybe_handle_text_to_image_complete_event( - // app_handle, - // app_env_configs, - // creds, - // task, - // job, - //).await; - - //if let Err(err) = result { - // error!("Failed to send text-to-image complete event: {:?}", err); - //} - - //let result = maybe_handle_inpainting_complete_event( - // app_handle, - // app_env_configs, - // creds, - // task, - // job, - //).await; - - //if let Err(err) = result { - // error!("Failed to send image inpainting complete event: {:?}", err); - //} - - //let result = maybe_send_background_removal_complete_event( - // app_handle, - // task, - // job, - //).await; - - //if let Err(err) = result { - // error!("Failed to send background removal complete event: {:?}", err); - //} -} - -fn get_thumbnail_template<'a>(job: &'a ListSessionJobsItem) -> Option<&'a str> { - let links = match job.maybe_result.as_ref() { - None => return None, - Some(result) => &result.media_links, - }; - - media_links_to_thumbnail_template(links) -} - -fn get_media_file_class(job: &ListSessionJobsItem) -> Option { - match job.request.inference_category { - InferenceCategory::BackgroundRemoval => return Some(TaskMediaFileClass::Image), - InferenceCategory::ImageGeneration => return Some(TaskMediaFileClass::Image), - InferenceCategory::VideoGeneration => return Some(TaskMediaFileClass::Video), - InferenceCategory::AudioGeneration | InferenceCategory::TextToSpeech => return Some(TaskMediaFileClass::Audio), - InferenceCategory::SplatGeneration => return Some(TaskMediaFileClass::Dimensional), - InferenceCategory::ObjectGeneration => return Some(TaskMediaFileClass::Dimensional), - _ => {}, // Fall-through - } - - let result = match job.maybe_result.as_ref() { - None => return None, - Some(result) => result, - }; - - let url = result.media_links.cdn_url.as_str(); - - if url.ends_with("jpg") - || url.ends_with("jpeg") - || url.ends_with("png") - { - return Some(TaskMediaFileClass::Image); - } - - if url.ends_with("mp4") - || url.ends_with("webm") - { - return Some(TaskMediaFileClass::Video); - } - - if url.ends_with("glb") { - return Some(TaskMediaFileClass::Dimensional); - } - - if url.ends_with("wav") - || url.ends_with("mp3") - { - return Some(TaskMediaFileClass::Audio); - } - - None -} diff --git a/crates/desktop/artcraft/src/services/storyteller/threads/storyteller_task_polling_thread/mod.rs b/crates/desktop/artcraft/src/services/storyteller/threads/storyteller_task_polling_thread/mod.rs deleted file mode 100644 index d0222b171f..0000000000 --- a/crates/desktop/artcraft/src/services/storyteller/threads/storyteller_task_polling_thread/mod.rs +++ /dev/null @@ -1,4 +0,0 @@ -mod events; -mod handle_storyteller_failed_job; -mod handle_storyteller_successful_job; -pub mod storyteller_task_polling_thread; diff --git a/crates/desktop/artcraft/src/services/storyteller/threads/storyteller_task_polling_thread/storyteller_task_polling_thread.rs b/crates/desktop/artcraft/src/services/storyteller/threads/storyteller_task_polling_thread/storyteller_task_polling_thread.rs deleted file mode 100644 index ee94c674e6..0000000000 --- a/crates/desktop/artcraft/src/services/storyteller/threads/storyteller_task_polling_thread/storyteller_task_polling_thread.rs +++ /dev/null @@ -1,126 +0,0 @@ -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; -use crate::core::state::task_database::TaskDatabase; -use crate::services::storyteller::state::storyteller_credential_manager::StorytellerCredentialManager; -use crate::services::storyteller::threads::storyteller_task_polling_thread::handle_storyteller_failed_job::handle_failed_job; -use crate::services::storyteller::threads::storyteller_task_polling_thread::handle_storyteller_successful_job::handle_successful_job; -use anyhow::anyhow; -use artcraft_client::endpoints::jobs::list_session_jobs::{list_session_jobs, States}; -use artcraft_client::error::api_error::ApiError; -use artcraft_client::error::storyteller_error::StorytellerError; -use enums::common::generation_provider::GenerationProvider; -use enums::common::job_status_plus::JobStatusPlus; -use enums::tauri::tasks::task_status::TaskStatus; -use errors::AnyhowResult; -use log::error; -use sqlite_tasks::queries::list_tasks_by_provider_and_tokens::{list_tasks_by_provider_and_tokens, ListTasksArgs}; -use sqlite_tasks::queries::task::Task; -use std::collections::HashMap; -use tauri::AppHandle; - -pub async fn storyteller_task_polling_thread( - app_handle: AppHandle, - app_env_configs: AppEnvConfigs, - task_database: TaskDatabase, - storyteller_creds_manager: StorytellerCredentialManager, -) -> ! { - loop { - let res = polling_loop( - &app_handle, - &app_env_configs, - &task_database, - &storyteller_creds_manager, - ).await; - if let Err(err) = res { - error!("An error occurred: {:?}", err); - } - // NB: Only sleep if an error occurs. - tokio::time::sleep(std::time::Duration::from_millis(30_000)).await; - } -} - -async fn polling_loop( - app_handle: &AppHandle, - app_env_configs: &AppEnvConfigs, - task_database: &TaskDatabase, - storyteller_creds_manager: &StorytellerCredentialManager, -) -> AnyhowResult<()> { - loop { - // Wait before next request for jobs. - tokio::time::sleep(std::time::Duration::from_millis(5_000)).await; - - let creds = storyteller_creds_manager.get_credentials()?; - - let result = list_session_jobs( - &app_env_configs.storyteller_host, - creds.as_ref(), - States::All, - ).await; - - let jobs = match result { - Ok(result) => result.jobs, - Err(err) => { - match &err { - StorytellerError::Api(ApiError::TooManyRequests(message)) => { - error!("Too many requests (sleeping): {:?}", message); - tokio::time::sleep(std::time::Duration::from_millis(60_000)).await; - } - _ => {} - } - return Err(anyhow!(err)); - } - }; - - let job_ids = jobs.iter() - .map(|job| job.job_token.to_string()) - .collect::>(); - - let tasks = list_tasks_by_provider_and_tokens(ListTasksArgs { - db: task_database.get_connection(), - provider: GenerationProvider::Artcraft, - provider_job_ids: Some(job_ids), - }).await?; - - let tasks = tasks.tasks; - - let jobs_by_id = jobs.iter() - .map(|job| (job.job_token.to_string(), job)) - .collect::>(); - - let tasks_by_provider_job_id = tasks.iter() - .filter_map(|task| { - if let Some(provider_job_id) = &task.provider_job_id { - Some((provider_job_id.clone(), task.clone())) - } else { - None - } - }) - //.map(|task| (task.provider_job_id.clone(), task.clone())) - .collect::>(); - - for job in jobs.iter() { - let task = match tasks_by_provider_job_id.get(job.job_token.as_str()) { - Some(task) => task, - None => continue, - }; - - match job.status.status { - JobStatusPlus::CompleteSuccess => { - match task.status { - TaskStatus::CompleteSuccess => continue, // NB: We're done with this task. - _ => {} - } - handle_successful_job(app_handle, app_env_configs, creds.as_ref(), job, task, task_database).await?; - } - JobStatusPlus::CompleteFailure => { - match task.status { - TaskStatus::CompleteFailure => continue, // NB: We're done with this task. - _ => {} - } - handle_failed_job(app_handle, job, task, task_database).await?; - } - _ => continue, - } - } - - } -} diff --git a/crates/desktop/artcraft/src/services/storyteller/windows/clear_main_webview_window_storyteller_cookies.rs b/crates/desktop/artcraft/src/services/storyteller/windows/clear_main_webview_window_storyteller_cookies.rs deleted file mode 100644 index 1ab9df358b..0000000000 --- a/crates/desktop/artcraft/src/services/storyteller/windows/clear_main_webview_window_storyteller_cookies.rs +++ /dev/null @@ -1,59 +0,0 @@ -use crate::core::windows::main_window::constants::MAIN_WINDOW_NAME; -use errors::AnyhowResult; -use log::warn; -use tauri::webview::Cookie; -use tauri::{AppHandle, Manager}; - -pub fn clear_main_webview_window_storyteller_cookies(app: &AppHandle) -> AnyhowResult<()> { - let main_webview_window = app.get_webview_window(MAIN_WINDOW_NAME) - .ok_or_else(|| anyhow::anyhow!("Main window not found"))?; - - let cookies = main_webview_window.cookies()?; - - let cookies_to_delete = get_cookies_to_delete(cookies); - - let mut maybe_error = None; - - for cookie in cookies_to_delete { - if let Err(err) = main_webview_window.delete_cookie(cookie) { - warn!("Failed to delete cookie: {:?}", err); - maybe_error = Some(err); - } - } - - if let Some(err) = maybe_error { - return Err(anyhow::anyhow!("Failed to delete some cookies. Here's one failure: {:?}", err)); - } - - Ok(()) -} - -// TODO: This will need to handle local development, too. -fn get_cookies_to_delete(cookies: Vec) -> Vec { - cookies.into_iter() - .filter(|cookie| { - // Define your filtering logic here - // For example, delete cookies with a specific name or domain - match cookie.domain() { - // storyteller.ai - Some("api.storyteller.ai") => true, - Some("storyteller.ai") => true, - Some(domain) if domain.ends_with(".storyteller.ai") => true, - // getartcraft.com - Some("api.getartcraft.com") => true, - Some("getartcraft.com") => true, - Some(domain) if domain.ends_with(".getartcraft.com") => true, - // artcraft.ai - Some("api.artcraft.ai") => true, - Some("artcraft.ai") => true, - Some(domain) if domain.ends_with(".artcraft.ai") => true, - // ignore all others - None => false, - Some(domain) => { - warn!("Ignoring cookie with unrecognized domain: {}", domain); - false - } - } - }) - .collect() -} \ No newline at end of file diff --git a/crates/desktop/artcraft/src/services/storyteller/windows/mod.rs b/crates/desktop/artcraft/src/services/storyteller/windows/mod.rs deleted file mode 100644 index ef56e02566..0000000000 --- a/crates/desktop/artcraft/src/services/storyteller/windows/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub mod clear_main_webview_window_storyteller_cookies; -pub mod open_storyteller_billing_window; -pub mod storyteller_billing_window_thread; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/services/storyteller/windows/open_storyteller_billing_window.rs b/crates/desktop/artcraft/src/services/storyteller/windows/open_storyteller_billing_window.rs deleted file mode 100644 index 0f228059f7..0000000000 --- a/crates/desktop/artcraft/src/services/storyteller/windows/open_storyteller_billing_window.rs +++ /dev/null @@ -1,298 +0,0 @@ -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::services::sora::windows::sora_login_window::sora_login_thread::sora_login_thread; -use crate::services::storyteller::state::storyteller_credential_manager::StorytellerCredentialManager; -use crate::services::storyteller::windows::storyteller_billing_window_thread::storyteller_billing_window_thread; -use anyhow::anyhow; -use artcraft_api_defs::stripe_artcraft::create_credits_pack_checkout::StripeArtcraftCreateCreditsPackCheckoutRequest; -use artcraft_api_defs::stripe_artcraft::create_subscription_checkout::{PlanBillingCadence, StripeArtcraftCreateSubscriptionCheckoutRequest}; -use artcraft_api_defs::stripe_artcraft::customer_portal_cancel_plan::StripeArtcraftCustomerPortalCancelPlanRequest; -use artcraft_api_defs::stripe_artcraft::customer_portal_manage_plan::StripeArtcraftCustomerPortalManagePlanRequest; -use artcraft_api_defs::stripe_artcraft::customer_portal_switch_plan::{PlanBillingCadenceConfirmation, StripeArtcraftCustomerPortalSwitchPlanRequest}; -use artcraft_api_defs::stripe_artcraft::customer_portal_update_payment_method::StripeArtcraftCustomerPortalUpdatePaymentMethodRequest; -use enums::common::artcraft_credits_pack_slug::ArtcraftCreditsPackSlug; -use enums::common::artcraft_subscription_slug::ArtcraftSubscriptionSlug; -use errors::AnyhowResult; -use log::info; -use reqwest::Url; -use artcraft_client::credentials::storyteller_credential_set::StorytellerCredentialSet; -use artcraft_client::endpoints::stripe_artcraft::create_credits_pack_checkout::create_credits_pack_checkout; -use artcraft_client::endpoints::stripe_artcraft::create_subscription_checkout::create_subscription_checkout; -use artcraft_client::endpoints::stripe_artcraft::customer_portal_cancel_plan::customer_portal_cancel_plan; -use artcraft_client::endpoints::stripe_artcraft::customer_portal_manage_plan::customer_portal_manage_plan; -use artcraft_client::endpoints::stripe_artcraft::customer_portal_switch_plan::customer_portal_switch_plan; -use artcraft_client::endpoints::stripe_artcraft::customer_portal_update_payment_method::customer_portal_update_payment_method; -use tauri::{AppHandle, Manager, WebviewUrl, WebviewWindowBuilder}; - -pub const BILLING_WINDOW_NAME: &str = "artcraft_billing_window"; - -pub struct OpenStorytellerBillingWindowArgs<'a> { - pub app: &'a AppHandle, - pub app_env_configs: &'a AppEnvConfigs, - pub app_data_root: &'a AppDataRoot, - pub storyteller_creds_manager: &'a StorytellerCredentialManager, - pub billing_window_case: BillingWindowCase, -} - -pub enum BillingWindowCase { - /// Purchase a subscription plan with the billing cadence supplied. - Subscription { - plan: ArtcraftSubscriptionSlug, - cadence: PlanBillingCadence, - }, - - /// Purchase a credits pack. - CreditsPack { - credits_pack: ArtcraftCreditsPackSlug, - }, - - /// Cancel the user's subscription. - /// Stripe shows a confirmation and then cancels the subscription. - CustomerPortalCancelPlan, - - /// Manage the user's subscription. - /// Stripe shows complete controls for updating the plan, payment method, etc. - CustomerPortalManagePlan, - - /// Switch the user's subscription plan. - /// Stripe pre-fills to the selected plan and cadence. - CustomerPortalSwitchPlan { - plan: ArtcraftSubscriptionSlug, - cadence: PlanBillingCadenceConfirmation, - }, - - /// Change the payment method attached to the customer / subscription. - CustomerPortalUpdatePaymentMethod, -} - -pub async fn open_storyteller_billing_window( - args: OpenStorytellerBillingWindowArgs<'_>, -) -> AnyhowResult<()> { - - if args.app.get_window(BILLING_WINDOW_NAME).is_some() { - return Err(anyhow!("Billing window already open")); - } - - info!("Building Stripe Checkout session..."); - - let creds = args.storyteller_creds_manager.get_credentials_required()?; - - let checkout_url = match args.billing_window_case { - BillingWindowCase::Subscription { plan, cadence } => { - get_subscription_url( - args.app_env_configs, - &creds, - plan, - cadence, - ).await? - }, - BillingWindowCase::CreditsPack { credits_pack } => { - get_credits_pack_url( - args.app_env_configs, - &creds, - credits_pack, - ).await? - }, - BillingWindowCase::CustomerPortalCancelPlan => { - get_customer_portal_cancel_plan_url( - args.app_env_configs, - &creds, - ).await? - }, - BillingWindowCase::CustomerPortalManagePlan => { - get_customer_portal_manage_plan_url( - args.app_env_configs, - &creds, - ).await? - }, - BillingWindowCase::CustomerPortalSwitchPlan { plan, cadence } => { - get_customer_portal_switch_plan_url( - args.app_env_configs, - &creds, - plan, - cadence, - ).await? - }, - BillingWindowCase::CustomerPortalUpdatePaymentMethod => { - get_customer_portal_update_payment_method_url( - args.app_env_configs, - &creds, - ).await? - } - }; - - do_open_window(args.app, args.app_data_root, checkout_url).await?; - - Ok(()) -} - -async fn get_subscription_url( - app_env_configs: &AppEnvConfigs, - storyteller_creds: &StorytellerCredentialSet, - plan: ArtcraftSubscriptionSlug, - cadence: PlanBillingCadence, -) -> AnyhowResult { - - info!("Getting URL for subscription checkout..."); - - let request = StripeArtcraftCreateSubscriptionCheckoutRequest { - plan: Some(plan), - cadence: Some(cadence), - }; - - let result = create_subscription_checkout( - &app_env_configs.storyteller_host, - Some(&storyteller_creds), - request, - ).await?; - - info!("Checkout session created..."); - - let url = Url::parse(&result.stripe_checkout_redirect_url)?; - Ok(url) -} - -async fn get_credits_pack_url( - app_env_configs: &AppEnvConfigs, - storyteller_creds: &StorytellerCredentialSet, - credits_pack: ArtcraftCreditsPackSlug, -) -> AnyhowResult { - - info!("Getting URL for credits pack checkout..."); - - let request = StripeArtcraftCreateCreditsPackCheckoutRequest { - credits_pack: Some(credits_pack), - }; - - let result = create_credits_pack_checkout( - &app_env_configs.storyteller_host, - Some(&storyteller_creds), - request, - ).await?; - - info!("Credits pack checkout session created..."); - Ok(Url::parse(&result.stripe_checkout_redirect_url)?) -} - -async fn get_customer_portal_cancel_plan_url( - app_env_configs: &AppEnvConfigs, - storyteller_creds: &StorytellerCredentialSet, -) -> AnyhowResult { - - info!("Getting customer portal cancel plan session..."); - - let request = StripeArtcraftCustomerPortalCancelPlanRequest { - portal_config_id: None, - }; - - let result = customer_portal_cancel_plan( - &app_env_configs.storyteller_host, - Some(&storyteller_creds), - request, - ).await?; - - info!("Customer portal cancel plan session created..."); - Ok(Url::parse(&result.stripe_portal_url)?) -} - -async fn get_customer_portal_manage_plan_url( - app_env_configs: &AppEnvConfigs, - storyteller_creds: &StorytellerCredentialSet, -) -> AnyhowResult { - - info!("Getting customer portal manage plan session..."); - - let request = StripeArtcraftCustomerPortalManagePlanRequest { - portal_config_id: None, - }; - - let result = customer_portal_manage_plan( - &app_env_configs.storyteller_host, - Some(&storyteller_creds), - request, - ).await?; - - info!("Customer portal manage plan session created..."); - Ok(Url::parse(&result.stripe_portal_url)?) -} - -async fn get_customer_portal_switch_plan_url( - app_env_configs: &AppEnvConfigs, - storyteller_creds: &StorytellerCredentialSet, - plan: ArtcraftSubscriptionSlug, - cadence: PlanBillingCadenceConfirmation, -) -> AnyhowResult { - - info!("Getting customer portal switch plan session..."); - - let request = StripeArtcraftCustomerPortalSwitchPlanRequest { - portal_config_id: None, - plan: Some(plan), - cadence: Some(cadence), - }; - - let result = customer_portal_switch_plan( - &app_env_configs.storyteller_host, - Some(&storyteller_creds), - request, - ).await?; - - info!("Customer portal switch plan session created..."); - Ok(Url::parse(&result.stripe_portal_url)?) -} - -async fn get_customer_portal_update_payment_method_url( - app_env_configs: &AppEnvConfigs, - storyteller_creds: &StorytellerCredentialSet, -) -> AnyhowResult { - - info!("Getting customer portal update payment method session..."); - - let request = StripeArtcraftCustomerPortalUpdatePaymentMethodRequest { - portal_config_id: None, - }; - - let result = customer_portal_update_payment_method( - &app_env_configs.storyteller_host, - Some(&storyteller_creds), - request, - ).await?; - - info!("Customer portal update payment method created..."); - Ok(Url::parse(&result.stripe_portal_url)?) -} - -async fn do_open_window( - app: &AppHandle, - app_data_root: &AppDataRoot, - url: Url, -) -> AnyhowResult<()> { - let url = WebviewUrl::External(url); - - info!("Opening checkout window..."); - - // TODO(bt,2025-09-01): We probably need to open this in a real browser to get autocomplete. - let _window = WebviewWindowBuilder::new(app, BILLING_WINDOW_NAME, url) - .always_on_top(false) - .title("ArtCraft Billing") - .center() - .resizable(true) - .visible(true) - .closable(true) - .min_inner_size(1000.0, 800.0) - .focused(true) - .devtools(true) - .build()?; - - //let _webview = window.get_webview(BILLING_WINDOW_NAME) - // .ok_or_else(|| anyhow!("no webview found"))?; - - let app_handle = app.clone(); - let app_data_root = app_data_root.clone(); - - let _ = tauri::async_runtime::spawn(async move { - storyteller_billing_window_thread(app_handle, app_data_root).await; - }); - - Ok(()) -} diff --git a/crates/desktop/artcraft/src/services/storyteller/windows/storyteller_billing_window_thread.rs b/crates/desktop/artcraft/src/services/storyteller/windows/storyteller_billing_window_thread.rs deleted file mode 100644 index 2f44f0b68f..0000000000 --- a/crates/desktop/artcraft/src/services/storyteller/windows/storyteller_billing_window_thread.rs +++ /dev/null @@ -1,125 +0,0 @@ -use crate::core::events::basic_sendable_event_trait::BasicSendableEvent; -use crate::core::events::functional_events::credits_balance_changed_event::CreditsBalanceChangedEvent; -use crate::core::events::functional_events::refresh_account_state_event::RefreshAccountStateEvent; -use crate::core::events::functional_events::subscription_plan_changed_event::SubscriptionPlanChangedEvent; -use crate::core::events::generation_events::common::{GenerationAction, GenerationServiceProvider}; -use crate::core::events::generation_events::generation_complete_event::GenerationCompleteEvent; -use crate::core::events::sendable_event_trait::SendableEvent; -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::core::utils::window::get_webview_window_hostname::get_webview_window_hostname; -use crate::services::midjourney::state::midjourney_credential_manager::MidjourneyCredentialManager; -use crate::services::midjourney::state::midjourney_user_info::MidjourneyUserInfo; -use crate::services::midjourney::windows::extract_midjourney_webview_cookies::extract_midjourney_webview_cookies; -use crate::services::sora::events::sora_login_success_event::SoraLoginSuccessEvent; -use crate::services::sora::state::sora_credential_manager::SoraCredentialManager; -use crate::services::sora::windows::sora_login_window::extract_sora_webview_cookies::extract_sora_webview_cookies; -use crate::services::storyteller::windows::open_storyteller_billing_window::BILLING_WINDOW_NAME; -use anyhow::anyhow; -use cookie_store::cookie_store::CookieStore; -use enums::common::generation_provider::GenerationProvider; -use errors::AnyhowResult; -use log::{error, info}; -use midjourney_client::client::midjourney_hostname::MidjourneyHostname; -use midjourney_client::credentials::cookie_store_has_auth_cookies::cookie_store_has_auth_cookies; -use midjourney_client::recipes::get_user_info::{get_user_info, GetUserInfoRequest}; -use openai_sora_client::creds::sora_credential_set::SoraCredentialSet; -use openai_sora_client::recipes::maybe_upgrade_or_renew_session::maybe_upgrade_or_renew_session; -use tauri::{AppHandle, Manager, WebviewWindow}; - -pub async fn storyteller_billing_window_thread( - app: AppHandle, - app_data_root: AppDataRoot, -) { - loop { - let billing_webview_window = match app.get_webview_window(BILLING_WINDOW_NAME) { - Some(webview) => webview, - None => { - info!("Exit billing window thread."); - return; // NB: Only exit if we don't have the webview. - } - }; - - let result = check_billing_window( - &app, - &billing_webview_window, - ).await; - - match result { - Err(err) => { - error!("Error checking billing window: {:?}", err); - } - Ok(false) => {} // Continue iteration and try again... - Ok(true) => { - info!("Checkout complete; exiting"); - if let Err(err) = billing_webview_window.close() { - error!("Error closing billing window: {:?}", err); - } - - // TODO: We can distinguish between subscription and credits impacts if we send a parameter - // from the webview. For now, just refresh everything. - - // Refresh the credits view - CreditsBalanceChangedEvent{}.send_infallible(&app); - SubscriptionPlanChangedEvent{}.send_infallible(&app); - - // And in case there's a race condition (likely), do it again after a delay. - tokio::time::sleep(std::time::Duration::from_millis(5_000)).await; - CreditsBalanceChangedEvent{}.send_infallible(&app); - SubscriptionPlanChangedEvent{}.send_infallible(&app); - - return; - } - } - - tokio::time::sleep(std::time::Duration::from_millis(1_000)).await; - } -} - -/// Returns true if we can exit. -async fn check_billing_window( - app_handle: &AppHandle, - webview_window: &WebviewWindow, -) -> AnyhowResult { - - let url = webview_window.url()?; - - let hostname= url - .host() - .ok_or(anyhow!("no host in url"))? - .to_string(); - - match hostname.as_str() { - "getartcraft.com" | - "storyteller.ai" => { - // Checkout done. Fall-through. - }, - "stripe.com" | "checkout.stripe.com" => { - return Ok(false) // Still in checkout flow. - } - _ => { - return Ok(false) // Unknown hostname... - } - } - - let path = url - .path() - .to_string(); - - // TODO: This is brittle. - - let success = path.contains("checkout_success"); - - info!("Checkout success: {}", success); - - // TODO: Send success events: - - // let event = RefreshAccountStateEvent { - // provider: Some(GenerationProvider::Midjourney), - // }; - // - // if let Err(err) = event.send(&app_handle) { - // error!("Failed to send RefreshAccountStateEvent: {:?}", err); // Fail open - // } - - Ok(true) -} diff --git a/crates/desktop/artcraft/src/services/worldlabs/commands/mod.rs b/crates/desktop/artcraft/src/services/worldlabs/commands/mod.rs deleted file mode 100644 index 77c3621ea1..0000000000 --- a/crates/desktop/artcraft/src/services/worldlabs/commands/mod.rs +++ /dev/null @@ -1,4 +0,0 @@ -pub mod worldlabs_open_login_command; -pub mod worldlabs_get_credential_info_command; -pub mod worldlabs_clear_credentials_command; -pub mod worldlabs_receive_bearer_command; diff --git a/crates/desktop/artcraft/src/services/worldlabs/commands/worldlabs_clear_credentials_command.rs b/crates/desktop/artcraft/src/services/worldlabs/commands/worldlabs_clear_credentials_command.rs deleted file mode 100644 index f829c45249..0000000000 --- a/crates/desktop/artcraft/src/services/worldlabs/commands/worldlabs_clear_credentials_command.rs +++ /dev/null @@ -1,44 +0,0 @@ -use crate::core::commands::response::shorthand::{Response, SimpleResponse}; -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::services::worldlabs::state::worldlabs_credential_manager::WorldlabsCredentialManager; -use errors::AnyhowResult; -use log::{error, info}; -use serde_derive::Deserialize; -use tauri::State; - -#[tauri::command] -pub async fn worldlabs_clear_credentials_command( - root: State<'_, AppDataRoot>, - creds_manager: State<'_, WorldlabsCredentialManager>, -) -> SimpleResponse { - info!("worldlabs_clear_credentials_command called"); - - clear_creds(&root, &creds_manager) - .map_err(|err| { - error!("Error clearing creds: {:?}", err); - "error clearing creds" - })?; - - Ok(().into()) -} - -fn clear_creds( - root: &AppDataRoot, - creds: &WorldlabsCredentialManager, -) -> AnyhowResult<()> { - - info!("Clearing credentials..."); - creds.clear_credentials()?; - - info!("Persisting to disk..."); - creds.persist_to_disk()?; - - let creds_path = root.credentials_dir().get_worldlabs_state_path(); - - if creds_path.exists() { - info!("Removing from disk..."); - std::fs::remove_file(creds_path)?; - } - - Ok(()) -} diff --git a/crates/desktop/artcraft/src/services/worldlabs/commands/worldlabs_get_credential_info_command.rs b/crates/desktop/artcraft/src/services/worldlabs/commands/worldlabs_get_credential_info_command.rs deleted file mode 100644 index 5637024096..0000000000 --- a/crates/desktop/artcraft/src/services/worldlabs/commands/worldlabs_get_credential_info_command.rs +++ /dev/null @@ -1,63 +0,0 @@ -use crate::core::commands::response::shorthand::{Response, ResponseOrErrorMessage}; -use crate::core::commands::response::success_response_wrapper::SerializeMarker; -use crate::services::worldlabs::state::worldlabs_credential_manager::WorldlabsCredentialManager; -use errors::AnyhowResult; -use log::{error, info}; -use serde_derive::Serialize; -use tauri::State; -use worldlabs_consumer_client::credentials::jwt_claims::JwtClaims; -use worldlabs_consumer_client::error::world_labs_error::WorldLabsError; - -#[derive(Serialize)] -pub struct WorldlabsGetCredentialInfoResponse { - pub maybe_email: Option, - pub can_clear_state: bool, -} - -impl SerializeMarker for WorldlabsGetCredentialInfoResponse {} - -#[tauri::command] -pub async fn worldlabs_get_credential_info_command( - creds_manager: State<'_, WorldlabsCredentialManager>, -) -> ResponseOrErrorMessage { - info!("worldlabs_get_credential_info_command called"); - - let info = get_info(&creds_manager) - .map_err(|err| { - error!("Error getting info: {:?}", err); - "error getting info" - })?; - - Ok(info.into()) -} - -fn get_info( - creds: &WorldlabsCredentialManager, -) -> AnyhowResult { - let mut can_clear_state = true; - - let maybe_cookies = creds.maybe_copy_cookie_store()?; - let maybe_bearer = creds.maybe_copy_bearer_token()?; - - if maybe_cookies.is_none() && maybe_bearer.is_none() { - can_clear_state = false; - } - - let mut maybe_email = None; - - if let Some(bearer) = maybe_bearer { - match bearer.parse_jwt_claims() { - Ok(claims) => { - maybe_email = claims.email; - } - Err(err) => { - error!("Failed to parse JWT bearer claims: {}", err); - } - } - } - - Ok(WorldlabsGetCredentialInfoResponse { - maybe_email, - can_clear_state, - }) -} diff --git a/crates/desktop/artcraft/src/services/worldlabs/commands/worldlabs_open_login_command.rs b/crates/desktop/artcraft/src/services/worldlabs/commands/worldlabs_open_login_command.rs deleted file mode 100644 index e0a7b5b7bd..0000000000 --- a/crates/desktop/artcraft/src/services/worldlabs/commands/worldlabs_open_login_command.rs +++ /dev/null @@ -1,45 +0,0 @@ -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::services::worldlabs::state::worldlabs_bearer_bridge::WorldlabsBearerBridge; -use crate::services::worldlabs::state::worldlabs_credential_manager::WorldlabsCredentialManager; -use crate::services::worldlabs::windows::worldlabs_login_window::worldlabs_login_window_open::worldlabs_login_window_open; -use errors::AnyhowResult; -use log::{error, info}; -use tauri::{AppHandle, State}; - -#[tauri::command] -pub async fn worldlabs_open_login_command( - app: AppHandle, - app_data_root: State<'_, AppDataRoot>, - worldlabs_bearer_bridge: State<'_, WorldlabsBearerBridge>, - worldlabs_creds_manager: State<'_, WorldlabsCredentialManager>, -) -> Result { - info!("worldlabs_open_login_command called"); - - do_open_login(&app, &app_data_root, &worldlabs_bearer_bridge, &worldlabs_creds_manager) - .await - .map_err(|err| { - error!("Error opening login: {:?}", err); - format!("Error opening login: {:?}", err) - })?; - - Ok("result".to_string()) -} - -async fn do_open_login( - app: &AppHandle, - app_data_root: &AppDataRoot, - worldlabs_bearer_bridge: &WorldlabsBearerBridge, - worldlabs_creds_manager: &WorldlabsCredentialManager, -) -> AnyhowResult<()> { - info!("Building login window..."); - - worldlabs_login_window_open( - app, - app_data_root, - worldlabs_bearer_bridge, - worldlabs_creds_manager - ).await?; - - info!("Done."); - Ok(()) -} diff --git a/crates/desktop/artcraft/src/services/worldlabs/commands/worldlabs_receive_bearer_command.rs b/crates/desktop/artcraft/src/services/worldlabs/commands/worldlabs_receive_bearer_command.rs deleted file mode 100644 index 0a9004df86..0000000000 --- a/crates/desktop/artcraft/src/services/worldlabs/commands/worldlabs_receive_bearer_command.rs +++ /dev/null @@ -1,59 +0,0 @@ -use crate::core::commands::response::shorthand::{Response, SimpleResponse}; -use crate::core::commands::response::success_response_wrapper::SerializeMarker; -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::services::worldlabs::state::worldlabs_bearer_bridge::{WorldlabsBearerBridge, WorldlabsBearerBridgeInner}; -use crate::services::worldlabs::state::worldlabs_credential_manager::WorldlabsCredentialManager; -use errors::AnyhowResult; -use log::{error, info}; -use serde_derive::{Deserialize, Serialize}; -use tauri::State; -use tokens::tokens::media_files::MediaFileToken; - - -#[derive(Deserialize, Debug)] -pub struct WorldlabsReceiveBearerRequest { - /// REQUIRED. - pub bearer_token: String, - - /// REQUIRED. - pub refresh_token: String, -} - -#[derive(Serialize)] -pub struct WorldlabsReceiveBearerResponse { -} - -impl SerializeMarker for WorldlabsReceiveBearerResponse {} - - -#[tauri::command] -pub async fn worldlabs_receive_bearer_command( - root: State<'_, AppDataRoot>, - request: WorldlabsReceiveBearerRequest, - bearer_bridge: State<'_, WorldlabsBearerBridge>, -) -> SimpleResponse { - info!("worldlabs_receive_bearer_command called"); - - info!("Request: {:?}", request); - - set_bearer(request, &bearer_bridge) - .map_err(|err| { - error!("Error setting bearer: {:?}", err); - "error setting bearer" - })?; - - Ok(().into()) -} - -fn set_bearer( - request: WorldlabsReceiveBearerRequest, - bearer_bridge: &WorldlabsBearerBridge, -) -> AnyhowResult<()> { - - bearer_bridge.set(WorldlabsBearerBridgeInner { - bearer_token: request.bearer_token, - refresh_token: request.refresh_token, - })?; - - Ok(()) -} diff --git a/crates/desktop/artcraft/src/services/worldlabs/mod.rs b/crates/desktop/artcraft/src/services/worldlabs/mod.rs deleted file mode 100644 index faed1e2dde..0000000000 --- a/crates/desktop/artcraft/src/services/worldlabs/mod.rs +++ /dev/null @@ -1,7 +0,0 @@ -//! Deprecated direct WorldLabs integration. Retained for legacy handlers and task polling. -//! New desktop generations use ArtCraft; account management is no longer exposed in the frontend. - -pub mod commands; -pub mod state; -pub mod threads; -pub mod windows; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/services/worldlabs/state/mod.rs b/crates/desktop/artcraft/src/services/worldlabs/state/mod.rs deleted file mode 100644 index ef22d19e2b..0000000000 --- a/crates/desktop/artcraft/src/services/worldlabs/state/mod.rs +++ /dev/null @@ -1,6 +0,0 @@ -pub mod worldlabs_credential_manager; -pub mod worldlabs_serializable_state; -pub mod worldlabs_bearer_bridge; - -// Private -mod worldlabs_credential_holder; diff --git a/crates/desktop/artcraft/src/services/worldlabs/state/worldlabs_bearer_bridge.rs b/crates/desktop/artcraft/src/services/worldlabs/state/worldlabs_bearer_bridge.rs deleted file mode 100644 index f177a867ff..0000000000 --- a/crates/desktop/artcraft/src/services/worldlabs/state/worldlabs_bearer_bridge.rs +++ /dev/null @@ -1,60 +0,0 @@ -use std::sync::{Arc, RwLock}; -use log::error; -use crate::core::artcraft_error::ArtcraftError; - -#[derive(Clone)] -pub struct WorldlabsBearerBridge { - state: Arc>> -} - -#[derive(Clone, Debug)] -pub struct WorldlabsBearerBridgeInner { - pub bearer_token: String, - pub refresh_token: String, -} - -impl WorldlabsBearerBridge { - pub fn empty() -> Self { - Self { - state: Arc::new(RwLock::new(None)), - } - } - - pub fn clear(&self) -> Result<(), ArtcraftError> { - match self.state.write() { - Ok(mut state) => { - *state = None; - Ok(()) - } - Err(err) => { - error!("Lock poisoned: {:?}", err); - Err(ArtcraftError::RwLockWriteError) - } - } - } - - pub fn get(&self) -> Result, ArtcraftError> { - match self.state.read() { - Ok(state) => { - Ok(state.clone()) - } - Err(err) => { - error!("Lock poisoned: {:?}", err); - Err(ArtcraftError::RwLockReadError) - } - } - } - - pub fn set(&self, new_state: WorldlabsBearerBridgeInner) -> Result<(), ArtcraftError> { - match self.state.write() { - Ok(mut state) => { - *state = Some(new_state); - Ok(()) - } - Err(err) => { - error!("Lock poisoned: {:?}", err); - Err(ArtcraftError::RwLockReadError) - } - } - } -} diff --git a/crates/desktop/artcraft/src/services/worldlabs/state/worldlabs_credential_holder.rs b/crates/desktop/artcraft/src/services/worldlabs/state/worldlabs_credential_holder.rs deleted file mode 100644 index cd2ea123d4..0000000000 --- a/crates/desktop/artcraft/src/services/worldlabs/state/worldlabs_credential_holder.rs +++ /dev/null @@ -1,35 +0,0 @@ -use cookie_store::cookie_store::CookieStore; -use worldlabs_consumer_client::credentials::world_labs_bearer_token::WorldLabsBearerToken; -use worldlabs_consumer_client::credentials::world_labs_cookies::WorldLabsCookies; -use worldlabs_consumer_client::credentials::worldlabs_refresh_token::WorldLabsRefreshToken; - -#[derive(Clone)] -pub struct WorldlabsCredentialHolder { - /// Directly off the Tauri browser session. - /// Read once, write to disk - /// The Worldlabs client consumes a string-only form (rather than this cookie jar) - pub browser_cookies: Option, - - /// Copy of cookies, specifically for the client library. - /// NOT PERSISTED TO DISK. - pub world_labs_cookies: Option, - - /// Bearer token - /// This needs to be persisted to disk. - pub world_labs_bearer_token: Option, - - /// Refresh token - /// This needs to be persisted to disk. - pub world_labs_refresh_token: Option, -} - -impl WorldlabsCredentialHolder { - pub fn empty() -> Self { - Self { - browser_cookies: None, - world_labs_cookies: None, - world_labs_bearer_token: None, - world_labs_refresh_token: None, - } - } -} diff --git a/crates/desktop/artcraft/src/services/worldlabs/state/worldlabs_credential_manager.rs b/crates/desktop/artcraft/src/services/worldlabs/state/worldlabs_credential_manager.rs deleted file mode 100644 index f0b7a87e8c..0000000000 --- a/crates/desktop/artcraft/src/services/worldlabs/state/worldlabs_credential_manager.rs +++ /dev/null @@ -1,232 +0,0 @@ -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::services::worldlabs::state::worldlabs_credential_holder::WorldlabsCredentialHolder; -use crate::services::worldlabs::state::worldlabs_serializable_state::{WorldlabsSerializableState, SERIALIZABLE_WORLDLABS_STATE_VERSION}; -use cookie_store::cookie_store::CookieStore; -use errors::AnyhowResult; -use log::{info, warn}; -use std::fs::read_to_string; -use std::sync::{Arc, RwLock}; -use worldlabs_consumer_client::credentials::world_labs_bearer_token::WorldLabsBearerToken; -use worldlabs_consumer_client::credentials::world_labs_cookies::WorldLabsCookies; -use worldlabs_consumer_client::credentials::worldlabs_refresh_token::WorldLabsRefreshToken; - -#[derive(Clone)] -pub struct WorldlabsCredentialManager { - // TODO: Put last write/last read timestamps on these. - credential_data: Arc>, - - //user_info: Arc>>, - app_data_root: AppDataRoot, -} - -impl WorldlabsCredentialManager { - pub fn initialize_empty(app_data_root: &AppDataRoot) -> Self { - Self { - credential_data: Arc::new(RwLock::new(WorldlabsCredentialHolder::empty())), - app_data_root: app_data_root.clone(), - } - } - - pub fn initialize_from_disk_infallible(app_data_root: &AppDataRoot) -> Self { - let mut credential_data; - - let result = WorldlabsSerializableState::read_from_disk(app_data_root); - match result { - Err(err) => { - warn!("Failed to read worldlabs state from disk: {:?}", err); - credential_data = Arc::new(RwLock::new(WorldlabsCredentialHolder::empty())); - }, - Ok(None) => { - credential_data = Arc::new(RwLock::new(WorldlabsCredentialHolder::empty())); - } - Ok(Some(state)) => { - let maybe_browser_cookies = state.user_cookies - .as_ref() - .map(|cookies| cookies.to_cookie_store()); - - let maybe_cookies = maybe_browser_cookies - .as_ref() - .map(|cookies| cookies.to_cookie_string()) - .map(|cookies| WorldLabsCookies::new(cookies)); - - let maybe_bearer = state.bearer_token - .map(|bearer| WorldLabsBearerToken::new(bearer)); - - let maybe_refresh = state.refresh_token - .map(|bearer| WorldLabsRefreshToken::new(bearer)); - - credential_data = Arc::new(RwLock::new(WorldlabsCredentialHolder { - browser_cookies: maybe_browser_cookies, - world_labs_cookies: maybe_cookies, - world_labs_bearer_token: maybe_bearer, - world_labs_refresh_token: maybe_refresh, - })); - } - }; - - Self { - credential_data, - app_data_root: app_data_root.clone(), - } - } - - pub fn maybe_copy_cookie_store(&self) -> anyhow::Result> { - match self.credential_data.read() { - Err(err) => Err(anyhow::anyhow!("Failed to acquire read lock: {:?}", err)), - Ok(holder) => Ok(holder.browser_cookies.clone()), - } - } - - pub fn maybe_copy_cookie_header_string(&self) -> anyhow::Result> { - let maybe_cookies = self.maybe_copy_cookie_store()?; - let maybe_cookies = maybe_cookies.map(|cookies| { - cookies.to_cookie_string() - }); - Ok(maybe_cookies) - } - - pub fn maybe_copy_typed_cookies(&self) -> anyhow::Result> { - let maybe_cookies = self.maybe_copy_cookie_header_string()?; - let maybe_cookies = maybe_cookies.map(|cookies| { - WorldLabsCookies::new(cookies) - }); - Ok(maybe_cookies) - } - - pub fn maybe_copy_bearer_token(&self) -> anyhow::Result> { - match self.credential_data.read() { - Err(err) => Err(anyhow::anyhow!("Failed to acquire read lock: {:?}", err)), - Ok(holder) => Ok(holder.world_labs_bearer_token.clone()), - } - } - - pub fn maybe_copy_refresh_token(&self) -> anyhow::Result> { - match self.credential_data.read() { - Err(err) => Err(anyhow::anyhow!("Failed to acquire read lock: {:?}", err)), - Ok(holder) => Ok(holder.world_labs_refresh_token.clone()), - } - } - - pub fn replace_cookie_store(&self, store: CookieStore) -> anyhow::Result<()> { - match self.credential_data.write() { - Err(err) => Err(anyhow::anyhow!("Failed to acquire write lock: {:?}", err)), - Ok(mut holder) => { - holder.browser_cookies = Some(store); - Ok(()) - } - } - } - - pub fn replace_bearer_token(&self, token: WorldLabsBearerToken) -> anyhow::Result<()> { - match self.credential_data.write() { - Err(err) => Err(anyhow::anyhow!("Failed to acquire write lock: {:?}", err)), - Ok(mut holder) => { - holder.world_labs_bearer_token = Some(token); - Ok(()) - } - } - } - - pub fn replace_refresh_token(&self, token: WorldLabsRefreshToken) -> anyhow::Result<()> { - match self.credential_data.write() { - Err(err) => Err(anyhow::anyhow!("Failed to acquire write lock: {:?}", err)), - Ok(mut holder) => { - holder.world_labs_refresh_token = Some(token); - Ok(()) - } - } - } - - pub fn replace_bearer_and_refresh_token(&self, bearer_token: WorldLabsBearerToken, refresh_token: WorldLabsRefreshToken) -> anyhow::Result<()> { - match self.credential_data.write() { - Err(err) => Err(anyhow::anyhow!("Failed to acquire write lock: {:?}", err)), - Ok(mut holder) => { - holder.world_labs_bearer_token = Some(bearer_token); - holder.world_labs_refresh_token = Some(refresh_token); - Ok(()) - } - } - } - - // NB: This is just a heuristic. We'll add better checks later. - pub fn do_task_polling(&self) -> anyhow::Result { - self.session_appears_active() - } - - // NB: This is just a heuristic. We'll add better checks later. - pub fn session_appears_active(&self) -> anyhow::Result { - let holder = match self.credential_data.read() { - Err(err) => return Err(anyhow::anyhow!("Failed to acquire read lock: {:?}", err)), - Ok(store) => store.clone(), - }; - - if holder.world_labs_bearer_token.is_some() { - return Ok(true); - } - - if holder.browser_cookies.is_none() { - return Ok(false); - } - - Ok(false) - } - - pub fn clear_credentials(&self) -> anyhow::Result<()> { - match self.credential_data.write() { - Err(err) => return Err(anyhow::anyhow!("Failed to acquire write lock: {:?}", err)), - Ok(mut store) => *store = WorldlabsCredentialHolder::empty(), - } - Ok(()) - } - - pub fn persist_to_disk(&self) -> anyhow::Result<()> { - let creds = match self.credential_data.read() { - Err(err) => return Err(anyhow::anyhow!("Failed to acquire read lock: {:?}", err)), - Ok(store) => store.clone(), - }; - - let state = WorldlabsSerializableState { - version: SERIALIZABLE_WORLDLABS_STATE_VERSION, - user_cookies: creds.browser_cookies - .as_ref() - .map(|cookies| cookies.to_serializable()), - user_id: None, // TODO - user_email: None, // TODO - bearer_token: creds.world_labs_bearer_token - .as_ref() - .map(|token| token.to_raw_string()), - refresh_token: creds.world_labs_refresh_token - .as_ref() - .map(|token| token.to_raw_string()), - }; - - let path = self.app_data_root.credentials_dir().get_worldlabs_state_path(); - let serialized = serde_json::to_string(&state)?; - - std::fs::write(path, serialized)?; - - // TODO: This is just for building the client and testing. - { - if let Some(cookies) = creds.browser_cookies.as_ref() { - let cookies_header = cookies.to_cookie_string(); - let path = self.app_data_root.credentials_dir().get_worldlabs_cookies_path(); - std::fs::write(path, cookies_header)?; - } - - // TODO: This is just for building the client and testing. - if let Some(bearer) = creds.world_labs_bearer_token.as_ref() { - let value = bearer.to_raw_string(); - let path = self.app_data_root.credentials_dir().get_worldlabs_bearer_path(); - std::fs::write(path, value)?; - } - - if let Some(refresh) = creds.world_labs_refresh_token.as_ref() { - let value = refresh.to_raw_string(); - let path = self.app_data_root.credentials_dir().get_worldlabs_refresh_path(); - std::fs::write(path, value)?; - } - } - - Ok(()) - } -} diff --git a/crates/desktop/artcraft/src/services/worldlabs/state/worldlabs_serializable_state.rs b/crates/desktop/artcraft/src/services/worldlabs/state/worldlabs_serializable_state.rs deleted file mode 100644 index cbf57429ba..0000000000 --- a/crates/desktop/artcraft/src/services/worldlabs/state/worldlabs_serializable_state.rs +++ /dev/null @@ -1,49 +0,0 @@ -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use cookie_store::serialized_cookie_store::SerializableCookieStore; -use serde_derive::{Deserialize, Serialize}; -use std::fs::read_to_string; - -/// History -/// v1 - initial -pub (super) const SERIALIZABLE_WORLDLABS_STATE_VERSION: u32 = 1; - -/// We only need to serialize Grok cookies. -/// Most of the other state (verification_token, etc.) can be pulled at runtime. -/// We will cache the `user_id` and `user_email`. -#[derive(Serialize, Deserialize)] -pub (super) struct WorldlabsSerializableState { - pub (super) version: u32, - - #[serde(skip_serializing_if = "Option::is_none")] - pub (super) user_cookies: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - pub (super) bearer_token: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - pub (super) refresh_token: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - pub (super) user_id: Option, - - #[serde(skip_serializing_if = "Option::is_none")] - pub (super) user_email: Option, -} - -impl WorldlabsSerializableState { - pub fn read_from_disk(root: &AppDataRoot) -> anyhow::Result> { - let state_path = root.credentials_dir().get_worldlabs_state_path(); - - if !state_path.exists() { - return Ok(None); - } - - let contents = read_to_string(&state_path)? - .trim() - .to_string(); - - let state: WorldlabsSerializableState = serde_json::from_str(&contents)?; - - Ok(Some(state)) - } -} diff --git a/crates/desktop/artcraft/src/services/worldlabs/threads/mod.rs b/crates/desktop/artcraft/src/services/worldlabs/threads/mod.rs deleted file mode 100644 index e03acdf874..0000000000 --- a/crates/desktop/artcraft/src/services/worldlabs/threads/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod worldlabs_marble_task_polling; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/services/worldlabs/threads/worldlabs_marble_task_polling.rs b/crates/desktop/artcraft/src/services/worldlabs/threads/worldlabs_marble_task_polling.rs deleted file mode 100644 index 74b1d61fb9..0000000000 --- a/crates/desktop/artcraft/src/services/worldlabs/threads/worldlabs_marble_task_polling.rs +++ /dev/null @@ -1,381 +0,0 @@ -use crate::core::commands::enqueue::generate_error::{GenerateError, MissingCredentialsReason}; -use crate::core::events::basic_sendable_event_trait::BasicSendableEvent; -use crate::core::events::generation_events::common::{GenerationAction, GenerationServiceProvider}; -use crate::core::events::generation_events::generation_complete_event::GenerationCompleteEvent; -use crate::core::state::app_env_configs::app_env_configs::AppEnvConfigs; -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::core::state::data_dir::trait_data_subdir::DataSubdir; -use crate::core::state::task_database::TaskDatabase; -use crate::core::utils::task_database_pending_statuses::TASK_DATABASE_PENDING_STATUSES; -use crate::services::grok::state::grok_credential_manager::GrokCredentialManager; -use crate::services::grok::util::get_or_upgrade_grok_full_credentials::get_or_update_grok_full_credentials; -use crate::services::midjourney::state::midjourney_credential_manager::MidjourneyCredentialManager; -use crate::services::midjourney::utils::download_midjourney_image::download_midjourney_image; -use crate::services::storyteller::state::storyteller_credential_manager::StorytellerCredentialManager; -use crate::services::worldlabs::state::worldlabs_credential_manager::WorldlabsCredentialManager; -use artcraft_api_defs::prompts::create_prompt::CreatePromptRequest; -use artcraft_api_defs::utils::media_links_to_thumbnail_template::media_links_to_thumbnail_template; -use cookie_store::cookie_store::CookieStore; -use enums::common::generation_provider::GenerationProvider; -use enums::tauri::tasks::task_media_file_class::TaskMediaFileClass; -use errors::AnyhowResult; -use futures::poll; -use grok_consumer_client::credentials::grok_full_credentials::GrokFullCredentials; -use grok_consumer_client::error::grok_error::GrokError; -use grok_consumer_client::requests::download_video_file::download_video_file::{download_video_file, DownloadVideoFileArgs}; -use grok_consumer_client::requests::download_video_file::grok_download_video::GrokDownloadVideo; -use grok_consumer_client::requests::media_posts::list_media_posts::grok_list_media_posts::{GrokMediaPostList, GrokMediaPostListRequest, VideoData}; -use uuid_utils::uuid::generate_random_uuid; -use log::{error, info}; -use midjourney_client::client::midjourney_hostname::MidjourneyHostname; -use midjourney_client::credentials::midjourney_user_id::MidjourneyUserId; -use midjourney_client::endpoints::imagine::{imagine, ImagineItem, ImagineRequest, MidjourneyJobType}; -use midjourney_client::utils::get_image_url::get_image_url; -use midjourney_client::utils::image_downloader_client::ImageDownloaderClient; -use once_cell::sync::Lazy; -use sqlite_tasks::queries::list_tasks_by_provider_and_status::{list_tasks_by_provider_and_status, ListTasksByProviderAndStatusArgs, TaskList}; -use sqlite_tasks::queries::task::Task; -use sqlite_tasks::queries::update_successful_task_status_with_metadata::{update_successful_task_status_with_metadata, UpdateSuccessfulTaskArgs}; -use sqlite_tasks::queries::update_task_status::{update_task_status, UpdateTaskArgs}; -use std::collections::{HashMap, HashSet}; -use std::fs::File; -use std::io::Write; -use std::path::PathBuf; -use std::time::Duration; -use artcraft_client::credentials::storyteller_credential_set::StorytellerCredentialSet; -use artcraft_client::endpoints::media_files::get_media_file::get_media_file; -use artcraft_client::endpoints::media_files::legacy_upload_media_file_from_file::{legacy_upload_media_file_from_file, LegacyUploadMediaFileFromFileArgs}; -use artcraft_client::endpoints::media_files::upload_image_media_file_from_file::{upload_image_media_file_from_file, UploadImageFromFileArgs}; -use artcraft_client::endpoints::media_files::upload_video_media_file_from_file::{upload_video_media_file_from_file, UploadVideoFromFileArgs}; -use artcraft_client::endpoints::prompts::create_prompt::create_prompt; -use artcraft_client::error::api_error::ApiError; -use artcraft_client::error::storyteller_error::StorytellerError; -use artcraft_client::recipes::upload_media_file_from_file::upload_media_file_from_file; -use tauri::AppHandle; -use tokens::tokens::batch_generations::BatchGenerationToken; -use url::Url; -use url_utils::download_extension::extract_download_extension_from_url::extract_download_extension_from_url_str; -use worldlabs_consumer_client::api::api_types::world_id::WorldObjectId; -use worldlabs_consumer_client::api::requests::worlds::poll_world_status::{poll_world_status, PollWorldStatusArgs}; -use worldlabs_consumer_client::credentials::world_labs_bearer_token::WorldLabsBearerToken; -use worldlabs_consumer_client::credentials::world_labs_cookies::WorldLabsCookies; -use worldlabs_consumer_client::credentials::worldlabs_refresh_token::WorldLabsRefreshToken; - -#[deprecated(note = "Retained to poll legacy direct-provider tasks; new generations use ArtCraft.")] -pub async fn worldlabs_marble_task_polling( - app_handle: AppHandle, - app_env_configs: AppEnvConfigs, - app_data_root: AppDataRoot, - task_database: TaskDatabase, - creds: WorldlabsCredentialManager, - storyteller_creds_manager: StorytellerCredentialManager, -) -> ! { - loop { - let res = polling_loop( - &app_handle, - &app_env_configs, - &app_data_root, - &task_database, - &creds, - &storyteller_creds_manager, - ).await; - if let Err(err) = res { - error!("An error occurred: {:?}", err); - } - // NB: Only sleep if an error occurs. - tokio::time::sleep(Duration::from_millis(30_000)).await; - } -} - -async fn polling_loop( - app_handle: &AppHandle, - app_env_configs: &AppEnvConfigs, - app_data_root: &AppDataRoot, - task_database: &TaskDatabase, - worldlabs_creds: &WorldlabsCredentialManager, - storyteller_creds_manager: &StorytellerCredentialManager, -) -> AnyhowResult<()> { - loop { - if !worldlabs_creds.do_task_polling()? { - tokio::time::sleep(Duration::from_millis(10_000)).await; - continue; - } - - // TODO: Graceful wait, fix this long function body - let storyteller_creds = match storyteller_creds_manager.get_credentials()? { - Some(creds) => creds, - None => { - error!("No Storyteller credentials found. Cannot proceed with WorldLabs polling."); - tokio::time::sleep(Duration::from_millis(5_000)).await; - continue; - } - }; - - let world_labs_cookies = match worldlabs_creds.maybe_copy_typed_cookies()? { - Some(cookies) => cookies, - None => { - info!("No full WorldLabs cookies"); - tokio::time::sleep(Duration::from_millis(30_000)).await; - continue; - } - }; - - let world_labs_bearer = match worldlabs_creds.maybe_copy_bearer_token()? { - Some(bearer) => bearer, - None => { - info!("No full WorldLabs bearer"); - tokio::time::sleep(Duration::from_millis(30_000)).await; - continue; - } - }; - - let world_labs_refresh = match worldlabs_creds.maybe_copy_refresh_token()? { - Some(bearer) => bearer, - None => { - info!("No full WorldLabs refresh"); - tokio::time::sleep(Duration::from_millis(30_000)).await; - continue; - } - }; - - let local_tasks = list_tasks_by_provider_and_status(ListTasksByProviderAndStatusArgs { - db: task_database.get_connection(), - provider: GenerationProvider::WorldLabs, - task_statuses: &TASK_DATABASE_PENDING_STATUSES, - }).await?; - - poll_grok_tasks( - app_handle, - app_env_configs, - app_data_root, - task_database, - &world_labs_cookies, - &world_labs_bearer, - &world_labs_refresh, - &storyteller_creds, - local_tasks, - ).await?; - - tokio::time::sleep(Duration::from_millis(2_000)).await; - } -} - -async fn poll_grok_tasks( - app_handle: &AppHandle, - app_env_configs: &AppEnvConfigs, - app_data_root: &AppDataRoot, - task_database: &TaskDatabase, - world_labs_cookies: &WorldLabsCookies, - world_labs_bearer: &WorldLabsBearerToken, - world_labs_refresh: &WorldLabsRefreshToken, - storyteller_creds: &StorytellerCredentialSet, - local_tasks: TaskList, -) -> AnyhowResult<()> { - let local_tasks = local_tasks.tasks; - - if local_tasks.is_empty() { - return Ok(()) - } - - info!("WorldLabs tasks waiting: {:?}", local_tasks.len()); - - // Map of WorldLabs World ID to Local Task. - let local_tasks_by_world_labs_world_id = local_tasks.iter() - .filter_map(|task| { - if let Some(provider_job_id) = &task.provider_job_id { - Some((provider_job_id.clone(), task.clone())) - } else { - None - } - }) - .collect::>(); - - for (world_id, local_task) in local_tasks_by_world_labs_world_id.iter() { - let world_id = WorldObjectId(world_id.to_string()); - - let poll_world_response = poll_world_status(PollWorldStatusArgs { - cookies: &world_labs_cookies, - bearer_token: &world_labs_bearer, - world_id: &world_id, - request_timeout: None, - }).await?; - - if !poll_world_response.is_complete { - tokio::time::sleep(Duration::from_millis(2_000)).await; - continue; - } - - let spz_url = match poll_world_response.spz_splat_url { - Some(url) => url, - None => { - error!("No spz splat URL despite being marked complete"); - continue; - } - }; - - upload_spz_splat( - &app_handle, - &app_env_configs, - app_data_root, - task_database, - &storyteller_creds, - &local_task, - &spz_url, - ).await?; - } - - tokio::time::sleep(Duration::from_millis(5_000)).await; - - Ok(()) -} - -async fn upload_spz_splat( - app_handle: &AppHandle, - app_env_configs: &AppEnvConfigs, - app_data_root: &AppDataRoot, - task_database: &TaskDatabase, - storyteller_creds: &StorytellerCredentialSet, - local_task: &Task, - spz_url: &str, -) -> AnyhowResult<()> { - - let mut maybe_primary_media_file_token = None; - - info!("Downloading generated spz splat ..."); - - let spz_download_filename = download_spz(spz_url, app_data_root).await?; - - let mut wait_delay = 0; - - loop { - info!("Uploading to backend..."); - - // TODO: media_files.origin_category - // TODO: media_files.maybe_prompt_token - // TODO: media_files.maybe_generation_provider - // TODO: media_files.maybe_origin_model_type - // TODO: media_files.maybe_origin_model_token (sref?) - // TODO: media_files.maybe_batch_token - // TODO: media_files.is_user_upload - - // TODO: batch_generations.token - // TODO: batch_generations.entity_type - // TODO: batch_generations.entity_token - - let result = legacy_upload_media_file_from_file(LegacyUploadMediaFileFromFileArgs { - api_host: &app_env_configs.storyteller_host, - maybe_creds: Some(&storyteller_creds), - path: &spz_download_filename, - maybe_generation_provider: Some(GenerationProvider::WorldLabs), - }).await; - - match result { - Ok(result) => { - info!("Successfully uploaded to backend: {:?}", result.media_file_token); - if maybe_primary_media_file_token.is_none() { - maybe_primary_media_file_token = Some(result.media_file_token); - } - break; - }, - Err(StorytellerError::Api(ApiError::TooManyRequests(_))) => { - error!("Too many requests, retrying upload after delay..."); - // If we hit a rate limit, we can retry after a short delay. - wait_delay += 10; - if wait_delay > 60 { - wait_delay = 60; - } - tokio::time::sleep(Duration::from_secs(wait_delay)).await; - continue; // Retry the upload. - } - Err(err) => { - error!("Failed to upload to backend: {:?}", err); - return Err(err.into()) - }, - } - } // End loop - - let mut maybe_cdn_url = None; - let mut maybe_thumbnail_url_template = None; - - if let Some(media_file_token) = maybe_primary_media_file_token.as_ref() { - info!("Looking up file to grab CDN and thumbnail URLs: {:?} ...", media_file_token); - - let lookup_result = get_media_file( - &app_env_configs.storyteller_host, - media_file_token, - ).await; - match lookup_result { - Ok(response) => { - maybe_cdn_url = Some(response.media_file.media_links.cdn_url.to_string()); - maybe_thumbnail_url_template = media_links_to_thumbnail_template(&response.media_file.media_links) - .map(|s| s.to_string()); - } - Err(err) => { - error!("Failed to look up media file after upload: {:?} (failing open)", err); - } - } - } - - let updated = update_successful_task_status_with_metadata(UpdateSuccessfulTaskArgs { - db: task_database.get_connection(), - task_id: &local_task.id, - maybe_batch_token: None, - maybe_primary_media_file_token: maybe_primary_media_file_token.as_ref(), - maybe_primary_media_file_class: Some(TaskMediaFileClass::Dimensional), - maybe_primary_media_file_thumbnail_url_template: maybe_thumbnail_url_template.as_deref(), - maybe_primary_media_file_cdn_url: maybe_cdn_url.as_deref(), - }).await?; - - if !updated { - return Ok(()); // If anything breaks with queries, don't spam events. - } - - let event = GenerationCompleteEvent { - //media_file_token: result.media_file_token, - action: Some(GenerationAction::GenerateGaussian), - service: GenerationServiceProvider::WorldLabs, - model: None, - }; - - if let Err(err) = event.send(&app_handle) { - error!("Failed to send GenerationCompleteEvent: {:?}", err); // Fail open - } - - //let result = maybe_handle_text_to_image_complete_event( - // app_handle, - // app_env_configs, - // Some(storyteller_creds), - // local_task, - // &batch_token, - //).await; - - //if let Err(err) = result { - // error!("Failed to send text-to-image complete event: {:?}", err); - //} - - Ok(()) -} - -async fn download_spz( - spz_url: &str, - app_data_root: &AppDataRoot, -) -> AnyhowResult { - info!("Downloading splat from URL: {}", spz_url); - - let response = reqwest::get(spz_url).await?; - let image_bytes = response.bytes().await?; - - let uuid = generate_random_uuid(); - let extension_without_period = "ceramic.spz"; - - let tempdir = app_data_root.temp_dir().path(); - let download_filename = format!("{}.{}", uuid, extension_without_period); - let download_path = tempdir.join(download_filename); - - info!("Writing to path: {:?}", download_path); - - let mut file = File::create(&download_path)?; - file.write_all(&image_bytes)?; - - Ok(download_path) -} diff --git a/crates/desktop/artcraft/src/services/worldlabs/windows/mod.rs b/crates/desktop/artcraft/src/services/worldlabs/windows/mod.rs deleted file mode 100644 index b4a0713003..0000000000 --- a/crates/desktop/artcraft/src/services/worldlabs/windows/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod worldlabs_login_window; \ No newline at end of file diff --git a/crates/desktop/artcraft/src/services/worldlabs/windows/worldlabs_login_window/mod.rs b/crates/desktop/artcraft/src/services/worldlabs/windows/worldlabs_login_window/mod.rs deleted file mode 100644 index b1a1c8bbc7..0000000000 --- a/crates/desktop/artcraft/src/services/worldlabs/windows/worldlabs_login_window/mod.rs +++ /dev/null @@ -1,4 +0,0 @@ -pub mod worldlabs_login_window_open; -pub (super) mod worldlabs_login_window_thread; -pub (super) mod worldlabs_login_webview_extract_cookies; -pub (super) mod worldlabs_javascript; diff --git a/crates/desktop/artcraft/src/services/worldlabs/windows/worldlabs_login_window/worldlabs_javascript.rs b/crates/desktop/artcraft/src/services/worldlabs/windows/worldlabs_login_window/worldlabs_javascript.rs deleted file mode 100644 index 097520e099..0000000000 --- a/crates/desktop/artcraft/src/services/worldlabs/windows/worldlabs_login_window/worldlabs_javascript.rs +++ /dev/null @@ -1,91 +0,0 @@ - - - -pub (super) const WORLDLABS_JAVASCRIPT_EXPORT_BEARER_TOKENS : &str = r#" - (async () => { - if (window.tokensExported) { - return; - } - - const request = indexedDB.open("firebaseLocalStorageDb"); - - request.onerror = (event) => {}; - - request.onsuccess = (event) => { - const db = event.target.result; - - const tx = db.transaction("firebaseLocalStorage", "readonly"); - const store = tx.objectStore("firebaseLocalStorage"); - - const keysRequest = store.getAllKeys(); - - keysRequest.onerror = (event) => {}; - - keysRequest.onsuccess = () => { - const keys = keysRequest.result; // array of keys - if (keys.length < 1) { - return; - } - - const key = keys[0]; - const getKeyRequest = store.getKey(key); - - getKeyRequest.onsuccess = () => {}; - - store.openCursor().onsuccess = async (event) => { - const cursor = event.target.result; - - if (cursor) { - let tokens = cursor.value?.value?.stsTokenManager; - - if (tokens?.accessToken && tokens?.refreshToken) { - // Send to Tauri - let result = await window.__TAURI__.core.invoke("worldlabs_receive_bearer_command", { - request: { - bearer_token: tokens.accessToken, - refresh_token: tokens.refreshToken, - } - }); - window.tokensExported = true; - } - cursor.continue(); - } - }; // end cursor - - }; // end keyRequest - }; // end DB - })(); - "#; - - -/// Take the Bearer tokens and send them to Tauri -pub (super) const WORLDLABS_JAVASCRIPT_SEND_BEARER_TO_TAURI : &str = r#" - (async () => { - if (!(window.tokens?.accessToken && window.tokens?.refreshToken)) { - return; - } - - let result = await window.__TAURI__.core.invoke("worldlabs_receive_bearer_command", { - request: { - bearer_token: window.tokens.accessToken, - refresh_token: window.tokens.refreshToken, - } - }); - - error.log('>>> result', result); - - })(); - "#; - - -/// See if the pricing button exists. -/// This is only for the logged-in state. -/// We can use redirection to detect completion. -pub (super) const WORLDLABS_JAVASCRIPT_SEE_IF_PRICING_EXISTS : &str = r#" - (() => { - let pricing = document.querySelectorAll("a[href='/pricing']"); - if (pricing.length > 0) { - window.location.href = "https://www.worldlabs.ai/about"; - } - })(); - "#; diff --git a/crates/desktop/artcraft/src/services/worldlabs/windows/worldlabs_login_window/worldlabs_login_webview_extract_cookies.rs b/crates/desktop/artcraft/src/services/worldlabs/windows/worldlabs_login_window/worldlabs_login_webview_extract_cookies.rs deleted file mode 100644 index cf2e62f475..0000000000 --- a/crates/desktop/artcraft/src/services/worldlabs/windows/worldlabs_login_window/worldlabs_login_webview_extract_cookies.rs +++ /dev/null @@ -1,39 +0,0 @@ -use cookie_store::cookie_store::CookieStore; -use errors::AnyhowResult; -use once_cell::sync::Lazy; -use reqwest::Url; -use tauri::webview::Cookie; -use tauri::WebviewWindow; - -static ROOT_COOKIE_URL: Lazy = Lazy::new(|| { - Url::parse("https://worldlabs.ai").expect("URL should parse") -}); - -pub fn worldlabs_login_webview_extract_cookies(webview: &WebviewWindow) -> AnyhowResult { - let mut cookie_store = CookieStore::empty(); - let cookies = get_all_worldlabs_cookies(webview)?; - for cookie in cookies.iter() { - cookie_store.add_cookie_name_and_value( - cookie.name().to_string(), - cookie.value().to_string(), - ); - } - Ok(cookie_store) -} - -fn get_all_worldlabs_cookies(webview: &WebviewWindow) -> AnyhowResult> { - //let www_cookies = webview.cookies_for_url(WWW_COOKIE_URL.clone())?; - let root_cookies = webview.cookies_for_url(ROOT_COOKIE_URL.clone())?; - - let mut all_cookies = root_cookies; - //let mut cookie_names = HashSet::new(); - - //for cookie in root_cookies.iter() { - // if !cookie_names.contains(cookie.name()) { - // cookie_names.insert(cookie.name().to_string()); - // all_cookies.push(cookie.clone()); - // } - //} - - Ok(all_cookies) -} diff --git a/crates/desktop/artcraft/src/services/worldlabs/windows/worldlabs_login_window/worldlabs_login_window_open.rs b/crates/desktop/artcraft/src/services/worldlabs/windows/worldlabs_login_window/worldlabs_login_window_open.rs deleted file mode 100644 index 6fb5a3e208..0000000000 --- a/crates/desktop/artcraft/src/services/worldlabs/windows/worldlabs_login_window/worldlabs_login_window_open.rs +++ /dev/null @@ -1,108 +0,0 @@ -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::core::utils::clear_all_webview_cookies::clear_all_webview_cookies; -use crate::services::worldlabs::state::worldlabs_bearer_bridge::WorldlabsBearerBridge; -use crate::services::worldlabs::state::worldlabs_credential_manager::WorldlabsCredentialManager; -use crate::services::worldlabs::windows::worldlabs_login_window::worldlabs_login_window_thread::worldlabs_login_window_thread; -use anyhow::anyhow; -use errors::AnyhowResult; -use log::info; -use once_cell::sync::Lazy; -use reqwest::Url; -use std::time::Duration; -use tauri::webview::NewWindowResponse; -use tauri::{AppHandle, Manager, WebviewUrl, WebviewWindowBuilder}; - -/// Name of the window -pub (super) const WORLDLABS_LOGIN_WINDOW_NAME: &str = "worldlabs_login_window"; - -pub (super) static START_URL: Lazy = Lazy::new(|| { - Url::parse("https://google.com").expect("URL should parse") -}); - -pub (super) static WORLDLABS_HOMEPAGE_URL: Lazy = Lazy::new(|| { - Url::parse("https://marble.worldlabs.ai/").expect("URL should parse") -}); - -pub (super) static WORLDLABS_LOGIN_URL: Lazy = Lazy::new(|| { - Url::parse("https://marble.worldlabs.ai/").expect("URL should parse") -}); - -pub async fn worldlabs_login_window_open( - app: &AppHandle, - app_data_root: &AppDataRoot, - worldlabs_bearer_bridge: &WorldlabsBearerBridge, - worldlabs_creds_manager: &WorldlabsCredentialManager, -) -> AnyhowResult<()> { - - if app.get_window(WORLDLABS_LOGIN_WINDOW_NAME).is_some() { - return Err(anyhow!("Login window already open")); - } - - info!("Clearing bearer bridge..."); - - worldlabs_bearer_bridge.clear()?; - - let url = WebviewUrl::External(START_URL.clone()); - - let window = WebviewWindowBuilder::new(app, WORLDLABS_LOGIN_WINDOW_NAME, url) - //.user_agent(openai_sora_client::credentials::USER_AGENT) - .on_new_window(move |url, features| { - // WorldLabs needs popups as they (1) don't have a distinct login page - // (it's embedded) and (2) they don't redirect with OAuth, but rather - // open a popup to Google. It still works, but it's annoying. - NewWindowResponse::Allow - }) - .always_on_top(false) - .title("Login to WorldLabs") - .center() - .resizable(true) - .visible(true) - .closable(true) - .min_inner_size(800.0, 800.0) - .focused(true) - .devtools(true) - .build()?; - - let webview = window.get_webview(WORLDLABS_LOGIN_WINDOW_NAME) - .ok_or_else(|| anyhow!("no webview found"))?; - - clear_all_webview_cookies(&webview)?; - - webview.navigate(WORLDLABS_HOMEPAGE_URL.clone())?; - - tokio::time::sleep(Duration::from_millis(200)).await; - - info!("Running script..."); - - for _ in 0 .. 10 { - tokio::time::sleep(Duration::from_millis(100)).await; - - // Close the "welcome" modal - webview.eval(r#"document.querySelectorAll("div:has(h2) ~ button[data-slot=dialog-close]").forEach((el) => el.click())"#)?; - } - - for _ in 0 .. 10 { - tokio::time::sleep(Duration::from_millis(100)).await; - - // Open the "login" modal - webview.eval(r#"document.querySelectorAll("button:has(span[data-slot=avatar])").forEach((el) => el.click())"#)?; - } - - info!("Script done..."); - - let app_handle = app.clone(); - let app_data_root = app_data_root.clone(); - let worldlabs_creds_manager = worldlabs_creds_manager.clone(); - let worldlabs_bearer_bridge = worldlabs_bearer_bridge.clone(); - - let _ = tauri::async_runtime::spawn(async move { - worldlabs_login_window_thread( - app_handle, - app_data_root, - worldlabs_bearer_bridge, - worldlabs_creds_manager - ).await; - }); - - Ok(()) -} diff --git a/crates/desktop/artcraft/src/services/worldlabs/windows/worldlabs_login_window/worldlabs_login_window_thread.rs b/crates/desktop/artcraft/src/services/worldlabs/windows/worldlabs_login_window/worldlabs_login_window_thread.rs deleted file mode 100644 index d8d0640d77..0000000000 --- a/crates/desktop/artcraft/src/services/worldlabs/windows/worldlabs_login_window/worldlabs_login_window_thread.rs +++ /dev/null @@ -1,129 +0,0 @@ -use crate::core::events::basic_sendable_event_trait::BasicSendableEvent; -use crate::core::events::functional_events::refresh_account_state_event::RefreshAccountStateEvent; -use crate::core::events::generation_events::common::{GenerationAction, GenerationServiceProvider}; -use crate::core::events::generation_events::generation_complete_event::GenerationCompleteEvent; -use crate::core::events::sendable_event_trait::SendableEvent; -use crate::core::state::data_dir::app_data_root::AppDataRoot; -use crate::core::utils::window::get_webview_window_hostname::get_webview_window_hostname; -use crate::core::utils::window::get_webview_window_url_path::get_webview_window_url_path; -use crate::services::grok::state::grok_credential_manager::GrokCredentialManager; -use crate::services::sora::events::sora_login_success_event::SoraLoginSuccessEvent; -use crate::services::sora::state::sora_credential_manager::SoraCredentialManager; -use crate::services::sora::windows::sora_login_window::extract_sora_webview_cookies::extract_sora_webview_cookies; -use crate::services::worldlabs::state::worldlabs_bearer_bridge::WorldlabsBearerBridge; -use crate::services::worldlabs::state::worldlabs_credential_manager::WorldlabsCredentialManager; -use crate::services::worldlabs::windows::worldlabs_login_window::worldlabs_javascript::WORLDLABS_JAVASCRIPT_EXPORT_BEARER_TOKENS; -use crate::services::worldlabs::windows::worldlabs_login_window::worldlabs_login_webview_extract_cookies::worldlabs_login_webview_extract_cookies; -use crate::services::worldlabs::windows::worldlabs_login_window::worldlabs_login_window_open::WORLDLABS_LOGIN_WINDOW_NAME; -use anyhow::anyhow; -use cookie_store::cookie_store::CookieStore; -use enums::common::generation_provider::GenerationProvider; -use errors::AnyhowResult; -use log::{error, info}; -use openai_sora_client::creds::sora_credential_set::SoraCredentialSet; -use openai_sora_client::recipes::maybe_upgrade_or_renew_session::maybe_upgrade_or_renew_session; -use openai_sora_client::utils::has_session_cookie::{has_session_cookie, SessionCookiePresence}; -use tauri::{AppHandle, Manager, WebviewWindow}; -use worldlabs_consumer_client::credentials::world_labs_bearer_token::WorldLabsBearerToken; -use worldlabs_consumer_client::credentials::worldlabs_refresh_token::WorldLabsRefreshToken; - -pub async fn worldlabs_login_window_thread( - app: AppHandle, - app_data_root: AppDataRoot, - worldlabs_bearer_bridge: WorldlabsBearerBridge, - worldlabs_creds_manager: WorldlabsCredentialManager, -) { - let mut visited_login = false; - - loop { - let login_webview_window = match app.get_webview_window(WORLDLABS_LOGIN_WINDOW_NAME) { - Some(webview) => webview, - None => { - info!("Exit WorldLabs login thread."); - return; // NB: Only exit if we don't have the webview. - } - }; - - let result = check_login_window( - &app, - &login_webview_window, - &app_data_root, - &worldlabs_bearer_bridge, - &worldlabs_creds_manager, - &mut visited_login, - ).await; - - match result { - Err(err) => { - error!("Error checking Grok login window: {:?}", err); - } - Ok(false) => {} // Continue iteration and try again... - Ok(true) => { - info!("Successfully saved cookies from login window. Closing."); - if let Err(err) = login_webview_window.close() { - error!("Error closing login window: {:?}", err); - } - return; - } - } - - tokio::time::sleep(std::time::Duration::from_millis(2_000)).await; - } -} - -/// NOTE: THERE IS THIS - https://marble.worldlabs.ai/sign-in?redirect=%2Fworlds - -/// Returns true if we can exit. -async fn check_login_window( - app_handle: &AppHandle, - webview_window: &WebviewWindow, - app_data_root: &AppDataRoot, - worldlabs_bearer_bridge: &WorldlabsBearerBridge, - worldlabs_creds_manager: &WorldlabsCredentialManager, - visited_login: &mut bool, -) -> AnyhowResult { - - // World labs has no distinct login page. Everything is in a single SPA. - - webview_window.eval(WORLDLABS_JAVASCRIPT_EXPORT_BEARER_TOKENS)?; - - let maybe_bearer = worldlabs_bearer_bridge.get()?; - - let bearer_info = match maybe_bearer { - Some(bearer) => bearer, - None => { - return Ok(false); // Not logged in. - } - }; - - let cookie_store = worldlabs_login_webview_extract_cookies(webview_window)?; - - info!("Current cookies (len {}): {:?}", cookie_store.len(), cookie_store.to_cookie_string()); - - worldlabs_creds_manager.replace_cookie_store(cookie_store)?; - - let bearer_token = WorldLabsBearerToken::new(bearer_info.bearer_token); - - worldlabs_creds_manager.replace_bearer_token(bearer_token)?; - - let refresh_token = WorldLabsRefreshToken::new(bearer_info.refresh_token); - - worldlabs_creds_manager.replace_refresh_token(refresh_token)?; - - let result = worldlabs_creds_manager.persist_to_disk(); - - if let Err(err) = result { - error!("Error persisting WorldLabs credentials to disk: {:?}", err); - return Ok(false); - } - - let event = RefreshAccountStateEvent { - provider: Some(GenerationProvider::WorldLabs), - }; - - if let Err(err) = event.send(&app_handle) { - error!("Failed to send RefreshAccountStateEvent: {:?}", err); // Fail open - } - - Ok(true) -} diff --git a/crates/desktop/artcraft/src/version.rs b/crates/desktop/artcraft/src/version.rs deleted file mode 100644 index 0d6316ccd5..0000000000 --- a/crates/desktop/artcraft/src/version.rs +++ /dev/null @@ -1,4 +0,0 @@ - -/// The version of the ArtCraft desktop app reported in the UI and via Analytics. -/// This should match the CI builds. -pub const ARTCRAFT_VERSION: &str = "0.37.0"; diff --git a/crates/desktop/artcraft/tauri-dev-hot-reload.conf.json b/crates/desktop/artcraft/tauri-dev-hot-reload.conf.json deleted file mode 100644 index cc9f901ccb..0000000000 --- a/crates/desktop/artcraft/tauri-dev-hot-reload.conf.json +++ /dev/null @@ -1,95 +0,0 @@ -{ - "build": { - "frontendDist": "../../../frontend/apps/artcraft/dist", - "beforeDevCommand": "echo 'no dev'", - "devUrl": "http://localhost:5173", - "beforeBuildCommand": "npx nx run artcraft:build" - }, - "app": { - "withGlobalTauri": true, - "windows": [ - ], - "security": { - "assetProtocol": { - "enable": true, - "scope": ["**"] - }, - "csp": { - "default-src": [ - "'self'", - "'unsafe-eval'", - "'unsafe-inline'", - "blob:", - "data:", - "https://*.fakeyou.com", - "https://*.storyteller.ai", - "https://www.google-analytics.com", - "https://www.googletagmanager.com", - "ipc://localhost", - "tauri://localhost" - ], - "connect-src": [ - "'self'", - "'unsafe-eval'", - "'unsafe-inline'", - "asset:", - "blob:", - "data:", - "http://ipc.localhost", - "https://*.clarity.ms", - "https://*.fakeyou.com", - "https://*.storyteller.ai", - "https://asset.localhost", - "https://unpkg.com/detect-gpu@5.0.70/", - "https://www.google-analytics.com", - "https://www.googletagmanager.com", - "ipc://localhost", - "tauri://localhost" - ], - "font-src": "*", - "img-src": [ - "", - "'self'", - "'unsafe-inline'", - "*", - "blob:", - "data:", - "https://*.fakeyou.com", - "https://*.storyteller.ai", - "ipc://localhost", - "tauri://localhost" - ], - "script-src": [ - "'self'", - "'unsafe-eval'", - "'unsafe-inline'", - "'wasm-unsafe-eval'", - "asset:", - "blob:", - "data:", - "https://*.clarity.ms", - "https://*.fakeyou.com", - "https://*.storyteller.ai", - "https://*.unpkg.com", - "https://clarity.ms", - "https://unpkg.com", - "ipc://localhost", - "tauri:", - "tauri://localhost" - ], - "style-src": [ - "'self'", - "'unsafe-eval'", - "'unsafe-inline'", - "blob:", - "data:", - "https://*.fakeyou.com", - "https://*.storyteller.ai", - "https://fonts.googleapis.com", - "ipc://localhost", - "tauri://localhost" - ] - } - } - } -} diff --git a/crates/desktop/artcraft/tauri-dev-static.conf.json b/crates/desktop/artcraft/tauri-dev-static.conf.json deleted file mode 100644 index a6cb5eb3e1..0000000000 --- a/crates/desktop/artcraft/tauri-dev-static.conf.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "build": { - "frontendDist": "../../../frontend/apps/artcraft/dist", - "beforeDevCommand": "echo 'this is static development; no live reload'", - "beforeBuildCommand": "echo 'this is static development; no live reload'", - "devUrl": null - }, - "app": { - "withGlobalTauri": true, - "windows": [ - ] - } -} diff --git a/crates/desktop/artcraft/tauri-mac.conf.json b/crates/desktop/artcraft/tauri-mac.conf.json deleted file mode 100644 index 3ba4a1728f..0000000000 --- a/crates/desktop/artcraft/tauri-mac.conf.json +++ /dev/null @@ -1,110 +0,0 @@ -{ - "$schema": "https://schema.tauri.app/config/2.0.0-rc", - "productName": "ArtCraft", - "version": "0.37.0", - "identifier": "ai.artcraft.app", - "build": { - "frontendDist": "../../../frontend/apps/artcraft/dist", - "devUrl": "http://localhost:5173", - "beforeDevCommand": "nx run artcraft:dev", - "beforeBuildCommand": "nx run artcraft:build" - }, - "app": { - "withGlobalTauri": true, - "windows": [ - ], - "security": { - "assetProtocol": { - "enable": true, - "scope": ["**"] - }, - "csp": { - "default-src": [ - "'self'", - "'unsafe-eval'", - "'unsafe-inline'", - "blob:", - "data:", - "https://*.fakeyou.com", - "https://*.storyteller.ai", - "https://www.google-analytics.com", - "https://www.googletagmanager.com", - "ipc://localhost", - "tauri://localhost" - ], - "connect-src": [ - "'self'", - "'unsafe-eval'", - "'unsafe-inline'", - "asset:", - "blob:", - "data:", - "http://ipc.localhost", - "https://*.clarity.ms", - "https://*.fakeyou.com", - "https://*.storyteller.ai", - "https://asset.localhost", - "https://unpkg.com/detect-gpu@5.0.70/", - "https://www.google-analytics.com", - "https://www.googletagmanager.com", - "ipc://localhost", - "tauri://localhost" - ], - "font-src": "*", - "img-src": [ - "", - "'self'", - "'unsafe-inline'", - "*", - "blob:", - "data:", - "https://*.fakeyou.com", - "https://*.storyteller.ai", - "ipc://localhost", - "tauri://localhost" - ], - "script-src": [ - "'self'", - "'unsafe-eval'", - "'unsafe-inline'", - "'wasm-unsafe-eval'", - "asset:", - "blob:", - "data:", - "https://*.clarity.ms", - "https://*.fakeyou.com", - "https://*.storyteller.ai", - "https://*.unpkg.com", - "https://clarity.ms", - "https://unpkg.com", - "ipc://localhost", - "tauri:", - "tauri://localhost" - ], - "style-src": [ - "'self'", - "'unsafe-eval'", - "'unsafe-inline'", - "blob:", - "data:", - "https://*.fakeyou.com", - "https://*.storyteller.ai", - "https://fonts.googleapis.com", - "ipc://localhost", - "tauri://localhost" - ] - } - } - }, - "bundle": { - "active": true, - "targets": "all", - "icon": [ - "icons/32x32.png", - "icons/128x128.png", - "icons/128x128@2x.png", - "icons/icon.icns", - "icons/icon.ico" - ] - } -} diff --git a/crates/desktop/artcraft/tauri.conf.json b/crates/desktop/artcraft/tauri.conf.json deleted file mode 100644 index 7da06d861e..0000000000 --- a/crates/desktop/artcraft/tauri.conf.json +++ /dev/null @@ -1,109 +0,0 @@ -{ - "$schema": "https://schema.tauri.app/config/2.0.0-rc", - "productName": "ArtCraft", - "version": "0.37.0", - "identifier": "ai.artcraft.app", - "build": { - "frontendDist": "../../../frontend/apps/artcraft/dist", - "devUrl": "http://localhost:5173", - "beforeDevCommand": "nx run artcraft:dev", - "beforeBuildCommand": "npx run artcraft:build" - }, - "app": { - "withGlobalTauri": true, - "windows": [], - "security": { - "assetProtocol": { - "enable": true, - "scope": ["**"] - }, - "csp": { - "default-src": [ - "'self'", - "'unsafe-eval'", - "'unsafe-inline'", - "blob:", - "data:", - "https://*.fakeyou.com", - "https://*.storyteller.ai", - "https://www.google-analytics.com", - "https://www.googletagmanager.com", - "ipc://localhost", - "tauri://localhost" - ], - "connect-src": [ - "'self'", - "'unsafe-eval'", - "'unsafe-inline'", - "asset:", - "blob:", - "data:", - "http://ipc.localhost", - "https://*.clarity.ms", - "https://*.fakeyou.com", - "https://*.storyteller.ai", - "https://asset.localhost", - "https://unpkg.com/detect-gpu@5.0.70/", - "https://www.google-analytics.com", - "https://www.googletagmanager.com", - "ipc://localhost", - "tauri://localhost" - ], - "font-src": "*", - "img-src": [ - "", - "'self'", - "'unsafe-inline'", - "*", - "blob:", - "data:", - "https://*.fakeyou.com", - "https://*.storyteller.ai", - "ipc://localhost", - "tauri://localhost" - ], - "script-src": [ - "'self'", - "'unsafe-eval'", - "'unsafe-inline'", - "'wasm-unsafe-eval'", - "asset:", - "blob:", - "data:", - "https://*.clarity.ms", - "https://*.fakeyou.com", - "https://*.storyteller.ai", - "https://*.unpkg.com", - "https://clarity.ms", - "https://unpkg.com", - "ipc://localhost", - "tauri:", - "tauri://localhost" - ], - "style-src": [ - "'self'", - "'unsafe-eval'", - "'unsafe-inline'", - "blob:", - "data:", - "https://*.fakeyou.com", - "https://*.storyteller.ai", - "https://fonts.googleapis.com", - "ipc://localhost", - "tauri://localhost" - ] - } - } - }, - "bundle": { - "active": true, - "targets": "all", - "icon": [ - "icons/32x32.png", - "icons/128x128.png", - "icons/128x128@2x.png", - "icons/icon.icns", - "icons/icon.ico" - ] - } -} diff --git a/crates/lib/build_metadata/Cargo.toml b/crates/lib/build_metadata/Cargo.toml deleted file mode 100644 index bd768bfb0f..0000000000 --- a/crates/lib/build_metadata/Cargo.toml +++ /dev/null @@ -1,34 +0,0 @@ -[package] -name = "build_metadata" -resolver = "2" # NB: Required by `build-info` -edition = "2024" -version = "0.0.1" -authors = [ - "Brandon Thomas ", - "Brandon Thomas ", -] -publish = false - -[lib] -name = "build_metadata" -path = "src/lib.rs" - -[package.metadata.cargo-udeps.ignore] -normal = ["workspace-build-acceleration"] - -[dependencies] -# Workspace hack (faster compile times) -workspace-build-acceleration = { workspace = true } - -# Internal -# (None yet) - -# External -build-info = "0.0.40" - -[dev-dependencies] -# None yet - -[build-dependencies] -build-info-build = "0.0.40" - diff --git a/crates/lib/build_metadata/build.rs b/crates/lib/build_metadata/build.rs deleted file mode 100644 index 3ed1729c88..0000000000 --- a/crates/lib/build_metadata/build.rs +++ /dev/null @@ -1,9 +0,0 @@ - -fn main() { - // Tell Cargo that if the given file changes, to rerun this build script. - // TODO: Use this to test the GIT_SHA, etc. files that CI dumps into the working directory - // println!("cargo::rerun-if-changed=Cargo.toml"); - - // Make build info available in the main crate sources. - build_info_build::build_script(); -} diff --git a/crates/lib/build_metadata/src/lib.rs b/crates/lib/build_metadata/src/lib.rs deleted file mode 100644 index 91d84b5aa8..0000000000 --- a/crates/lib/build_metadata/src/lib.rs +++ /dev/null @@ -1,43 +0,0 @@ -use std::ops::Deref; -use build_info::chrono::{DateTime, Utc}; - -build_info::build_info!(fn version); - -pub fn build_timestamp() -> DateTime { - version().timestamp -} - -pub fn git_commit_id() -> Option<&'static str> { - version().version_control - .as_ref() - .map(|vc| vc.git()) - .flatten() - .map(|git| git.commit_id.deref()) -} - -pub fn git_commit_short_id() -> Option<&'static str> { - version().version_control - .as_ref() - .map(|vc| vc.git()) - .flatten() - .map(|git| git.commit_short_id.deref()) -} - -pub fn git_commit_timestamp() -> Option> { - version().version_control - .as_ref() - .map(|vc| vc.git()) - .flatten() - .map(|git| git.commit_timestamp) -} - -#[cfg(test)] -mod tests { - use crate::git_commit_id; - - #[test] - #[ignore] // Run manually for testing, not in CI - fn test_git_commit_id() { - assert_eq!(git_commit_id(), None); - } -} diff --git a/crates/lib/caching/memory_store/Cargo.toml b/crates/lib/caching/memory_store/Cargo.toml deleted file mode 100644 index 0c30db2ab2..0000000000 --- a/crates/lib/caching/memory_store/Cargo.toml +++ /dev/null @@ -1,26 +0,0 @@ -[package] -name = "memory_store" -edition = "2018" -version = "0.0.1" -authors = [ - "Brandon Thomas ", - "Brandon Thomas ", -] -publish = false - -[lib] -name = "memory_store" -path = "src/lib.rs" - -[package.metadata.cargo-udeps.ignore] -normal = ["workspace-build-acceleration"] - -[dependencies] -# Workspace hack (faster compile times) -workspace-build-acceleration = { workspace = true } - -# Internal -errors = { workspace = true } - -# External -anyhow = { workspace = true } diff --git a/crates/lib/caching/memory_store/src/clone_cell.rs b/crates/lib/caching/memory_store/src/clone_cell.rs deleted file mode 100644 index aba8cdb954..0000000000 --- a/crates/lib/caching/memory_store/src/clone_cell.rs +++ /dev/null @@ -1,54 +0,0 @@ -use anyhow::anyhow; -use errors::AnyhowResult; -use std::sync::{Arc, RwLock}; - -/// Store a threadsafe value that can be passed around and cloned. -/// The object is interior mutable so it can be changed without mut/&mut references. -/// This is useful for storing a value that may or may not be set between threads. -/// -/// Unlike `CloneSlot`, this always holds an object. -#[derive(Clone)] -pub struct CloneCell { - pub store: Arc>, -} - -impl CloneCell { - pub fn with_clone(object: &T) -> Self { - Self { - store: Arc::new(RwLock::new(object.clone())), - } - } - - pub fn with_owned(object: T) -> Self { - Self { - store: Arc::new(RwLock::new(object)), - } - } - - pub fn get_clone(&self) -> AnyhowResult { - match self.store.read() { - Err(err) => Err(anyhow!("Failed to acquire read lock: {:?}", err)), - Ok(store) => Ok(store.clone()), - } - } - - pub fn set_clone(&self, value: &T) -> AnyhowResult<()> { - match self.store.write() { - Err(err) => Err(anyhow!("Failed to acquire write lock: {:?}", err)), - Ok(mut store) => { - *store = value.clone(); - Ok(()) - } - } - } - - pub fn set_owned(&self, value: T) -> AnyhowResult<()> { - match self.store.write() { - Err(err) => Err(anyhow!("Failed to acquire write lock: {:?}", err)), - Ok(mut store) => { - *store = value; - Ok(()) - } - } - } -} diff --git a/crates/lib/caching/memory_store/src/clone_slot.rs b/crates/lib/caching/memory_store/src/clone_slot.rs deleted file mode 100644 index ef2a3d1001..0000000000 --- a/crates/lib/caching/memory_store/src/clone_slot.rs +++ /dev/null @@ -1,87 +0,0 @@ -use anyhow::anyhow; -use errors::AnyhowResult; -use std::sync::{Arc, RwLock}; - -/// Store a threadsafe value that can be passed around and cloned. -/// The object is interior mutable so it can be changed without mut/&mut references. -/// This is useful for storing a value that may or may not be set between threads. -/// -/// Unlike `CloneCell`, this holds an optional object. -#[derive(Clone)] -pub struct CloneSlot { - pub store: Arc>>, -} - -impl CloneSlot { - pub fn empty() -> Self { - Self { - store: Arc::new(RwLock::new(None)), - } - } - - pub fn with_clone(object: &T) -> Self { - Self { - store: Arc::new(RwLock::new(Some(object.clone()))), - } - } - - pub fn get_clone(&self) -> AnyhowResult> { - match self.store.read() { - Err(err) => Err(anyhow!("Failed to acquire read lock: {:?}", err)), - Ok(store) => Ok(store.clone()), - } - } - - pub fn get_clone_required(&self) -> AnyhowResult { - match self.store.read() { - Err(err) => Err(anyhow!("Failed to acquire read lock: {:?}", err)), - Ok(store) => match &*store { - None => Err(anyhow!("Required stored item is not set")), - Some(inner) => Ok(inner.clone()), - } - } - } - - pub fn set_clone(&self, value: &T) -> AnyhowResult<()> { - match self.store.write() { - Err(err) => Err(anyhow!("Failed to acquire write lock: {:?}", err)), - Ok(mut store) => { - *store = Some(value.clone()); - Ok(()) - } - } - } - - pub fn clear(&self) -> AnyhowResult<()> { - match self.store.write() { - Err(err) => Err(anyhow!("Failed to acquire write lock: {:?}", err)), - Ok(mut store) => { - *store = None; - Ok(()) - } - } - } - - pub fn take(&self) -> AnyhowResult> { - match self.store.write() { - Err(err) => Err(anyhow!("Failed to acquire write lock: {:?}", err)), - Ok(mut store) => { - Ok(store.take()) - } - } - } - - pub fn is_some(&self) -> AnyhowResult { - match self.store.read() { - Err(err) => Err(anyhow!("Failed to acquire read lock: {:?}", err)), - Ok(store) => Ok(store.is_some()), - } - } - - pub fn is_none(&self) -> AnyhowResult { - match self.store.read() { - Err(err) => Err(anyhow!("Failed to acquire read lock: {:?}", err)), - Ok(store) => Ok(store.is_none()), - } - } -} diff --git a/crates/lib/caching/memory_store/src/lib.rs b/crates/lib/caching/memory_store/src/lib.rs deleted file mode 100644 index 19f70cae0f..0000000000 --- a/crates/lib/caching/memory_store/src/lib.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod clone_cell; -pub mod clone_slot; \ No newline at end of file diff --git a/crates/lib/cloudflare_mitigation/Cargo.toml b/crates/lib/cloudflare_mitigation/Cargo.toml deleted file mode 100644 index 03da787814..0000000000 --- a/crates/lib/cloudflare_mitigation/Cargo.toml +++ /dev/null @@ -1,26 +0,0 @@ -[package] -name = "cloudflare_mitigation" -edition = "2024" -version = "0.0.1" -publish = false - -[package.metadata.cargo-udeps.ignore] -normal = ["workspace-build-acceleration"] - -[lib] -name = "cloudflare_mitigation" -path = "src/lib.rs" - -[dependencies] -# cargo-hakari workspace hack (faster compile times) -workspace-build-acceleration.workspace = true - -# Internal -# (None) - -# External -once_cell.workspace = true -wreq.workspace = true - -[dev-dependencies] -# (None) diff --git a/crates/lib/cloudflare_mitigation/src/headers/firefox_websocket_http_1_1_headers.rs b/crates/lib/cloudflare_mitigation/src/headers/firefox_websocket_http_1_1_headers.rs deleted file mode 100644 index 3502b9fe06..0000000000 --- a/crates/lib/cloudflare_mitigation/src/headers/firefox_websocket_http_1_1_headers.rs +++ /dev/null @@ -1,33 +0,0 @@ -use once_cell::sync::Lazy; -use wreq::header::OrigHeaderMap; - -/// Header casing and order needed to bypass Cloudflare WebSocket HTTP/1.1 checks. -/// This is the set of headers sent by Firefox 143 on macOS. -static FIREFOX_WEBSOCKET_HTTP_1_1_HEADERS : Lazy = Lazy::new(|| { - let mut original_headers = OrigHeaderMap::new(); - - original_headers.insert("Host"); - original_headers.insert("User-Agent"); - original_headers.insert("Accept"); - original_headers.insert("Accept-Language"); - original_headers.insert("Accept-Encoding"); - original_headers.insert("Sec-WebSocket-Version"); - original_headers.insert("Origin"); - original_headers.insert("Sec-WebSocket-Extensions"); - original_headers.insert("Sec-WebSocket-Key"); - original_headers.insert("Connection"); - original_headers.insert("Cookie"); - original_headers.insert("Sec-Fetch-Dest"); - original_headers.insert("Sec-Fetch-Mode"); - original_headers.insert("Sec-Fetch-Site"); - original_headers.insert("Pragma"); - original_headers.insert("Cache-Control"); - original_headers.insert("Upgrade"); - - original_headers -}); - -/// Wreq expects an owned copy, so we are required to clone. -pub fn get_firefox_websocket_http_1_1_headers() -> OrigHeaderMap { - FIREFOX_WEBSOCKET_HTTP_1_1_HEADERS.clone() -} \ No newline at end of file diff --git a/crates/lib/cloudflare_mitigation/src/headers/mod.rs b/crates/lib/cloudflare_mitigation/src/headers/mod.rs deleted file mode 100644 index 6352f64f1d..0000000000 --- a/crates/lib/cloudflare_mitigation/src/headers/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod firefox_websocket_http_1_1_headers; \ No newline at end of file diff --git a/crates/lib/cloudflare_mitigation/src/lib.rs b/crates/lib/cloudflare_mitigation/src/lib.rs deleted file mode 100644 index a97581c44d..0000000000 --- a/crates/lib/cloudflare_mitigation/src/lib.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod headers; \ No newline at end of file diff --git a/crates/lib/cookie_store/Cargo.toml b/crates/lib/cookie_store/Cargo.toml deleted file mode 100644 index 593e7a131f..0000000000 --- a/crates/lib/cookie_store/Cargo.toml +++ /dev/null @@ -1,27 +0,0 @@ -[package] -name = "cookie_store" -edition = "2024" -version = "0.0.1" -publish = false - -[package.metadata.cargo-udeps.ignore] -normal = ["workspace-build-acceleration"] - -[lib] -name = "cookie_store" -path = "src/lib.rs" - -[dependencies] -# Workspace hack (faster compile times) -workspace-build-acceleration.workspace = true - -# Internal -errors.workspace = true - -# External -serde.workspace = true -serde_derive.workspace = true -serde_json.workspace = true - -[dev-dependencies] -# None yet diff --git a/crates/lib/cookie_store/src/cookie.rs b/crates/lib/cookie_store/src/cookie.rs deleted file mode 100644 index e292df4068..0000000000 --- a/crates/lib/cookie_store/src/cookie.rs +++ /dev/null @@ -1,34 +0,0 @@ - -#[derive(Clone)] -pub struct Cookie { - pub name: String, - pub value: String, - - // TODO: Later. - // pub domain: String, - // pub path: String, - // pub secure: bool, - // pub http_only: bool, - // pub expires: Option, -} - -impl Cookie { - pub fn new(name: String, value: String) -> Self { - Self { name, value } - } - - pub fn new_from_str(name: &str, value: &str) -> Self { - Self { - name: name.to_string(), - value: value.to_string(), - } - } - - pub fn name(&self) -> &str { - &self.name - } - - pub fn value(&self) -> &str { - &self.value - } -} diff --git a/crates/lib/cookie_store/src/cookie_set.rs b/crates/lib/cookie_store/src/cookie_set.rs deleted file mode 100644 index 3c1efa991a..0000000000 --- a/crates/lib/cookie_store/src/cookie_set.rs +++ /dev/null @@ -1,36 +0,0 @@ -use crate::cookie::Cookie; -use std::collections::HashMap; - -pub struct CookieSet { - // TODO: This doesn't yet handle partial paths, subddomain rules, etc. - pub cookies: HashMap, -} - -impl CookieSet { - pub fn new() -> Self { - Self { - cookies: HashMap::new(), - } - } - - pub fn add_cookie(&mut self, cookie: Cookie) { - self.cookies.insert(cookie.name.clone(), cookie); - } - - pub fn get_cookie(&self, name: &str) -> Option<&Cookie> { - self.cookies.get(name) - } - - pub fn remove_cookie(&mut self, name: &str) { - self.cookies.remove(name); - } - - pub fn to_cookie_string(&self) -> String { - self - .cookies - .values() - .map(|cookie| format!("{}={}", cookie.name, cookie.value)) - .collect::>() - .join("; ") - } -} diff --git a/crates/lib/cookie_store/src/cookie_store.rs b/crates/lib/cookie_store/src/cookie_store.rs deleted file mode 100644 index ca1c0757c7..0000000000 --- a/crates/lib/cookie_store/src/cookie_store.rs +++ /dev/null @@ -1,78 +0,0 @@ -use crate::cookie::Cookie; -use crate::serialized_cookie_store::{SerializableCookieStore, SerializedCookie}; -use std::collections::HashMap; - -#[derive(Clone)] -pub struct CookieStore { - // TODO: This doesn't yet handle partial paths, subdomain rules, etc. - pub cookies: HashMap, -} - -impl CookieStore { - pub fn empty() -> Self { - Self { - cookies: HashMap::new(), - } - } - - pub fn add_cookie(&mut self, cookie: Cookie) { - self.cookies.insert(cookie.name.clone(), cookie); - } - - pub fn add_cookie_name_and_value(&mut self, name: String, value: String) { - self.add_cookie(Cookie { - name, - value, - }); - } - - pub fn get_cookie(&self, name: &str) -> Option<&Cookie> { - self.cookies.get(name) - } - - pub fn has_cookie(&self, name: &str) -> bool { - self.cookies.contains_key(name) - } - - pub fn remove_cookie(&mut self, name: &str) { - self.cookies.remove(name); - } - - pub fn len(&self) -> usize { - self.cookies.len() - } - - pub fn clear_all(&mut self) { - self.cookies.clear(); - } - - /// NB: Just use this as a heuristic, and do not call it in a loop. - pub fn calculate_approx_cookie_character_length(&self) -> usize { - const COOKIE_SEP_LENGTH: usize = 2; // '=' and ';' - self.cookies - .values() - .map(|cookie| cookie.name.len() + cookie.value.len() + COOKIE_SEP_LENGTH) - .sum() - } - - pub fn to_cookie_string(&self) -> String { - self - .cookies - .values() - .map(|cookie| format!("{}={}", cookie.name, cookie.value)) - .collect::>() - .join("; ") - } - - pub fn to_serializable(&self) -> SerializableCookieStore { - let cookies = self - .cookies - .values() - .map(|cookie| SerializedCookie { - name: cookie.name.clone(), - value: cookie.value.clone(), - }) - .collect(); - SerializableCookieStore { cookies } - } -} diff --git a/crates/lib/cookie_store/src/lib.rs b/crates/lib/cookie_store/src/lib.rs deleted file mode 100644 index 4fdfa2f6c6..0000000000 --- a/crates/lib/cookie_store/src/lib.rs +++ /dev/null @@ -1,24 +0,0 @@ -//! cookie_store -//! -//! Lightweight cookie jar -//! - -// Never allow these -#![forbid(private_bounds)] -#![forbid(private_interfaces)] -#![forbid(unused_must_use)] // NB: It's unsafe to not close/check some things - -// Okay to toggle -#![forbid(unreachable_patterns)] -#![forbid(unused_imports)] -#![forbid(unused_mut)] -#![forbid(unused_variables)] - -// Always allow -#![allow(dead_code)] -#![allow(non_snake_case)] - -pub mod cookie; -pub mod cookie_set; -pub mod cookie_store; -pub mod serialized_cookie_store; \ No newline at end of file diff --git a/crates/lib/cookie_store/src/serialized_cookie_store.rs b/crates/lib/cookie_store/src/serialized_cookie_store.rs deleted file mode 100644 index 22956c115d..0000000000 --- a/crates/lib/cookie_store/src/serialized_cookie_store.rs +++ /dev/null @@ -1,66 +0,0 @@ -use crate::cookie::Cookie; -use crate::cookie_store::CookieStore; -use serde::{Deserialize, Serialize}; -use std::error::Error; -use std::fmt::{Debug, Display, Formatter}; -use std::path::Path; - -#[derive(Serialize, Deserialize)] -pub struct SerializableCookieStore { - pub (crate) cookies: Vec, -} - -#[derive(Serialize, Deserialize)] -pub (crate) struct SerializedCookie { - pub (crate) name: String, - pub (crate) value: String, -} - -#[derive(Debug)] -pub enum SerializableCookieStoreError { - IoError(std::io::Error), - SerializationError(serde_json::Error), -} - -impl Error for SerializableCookieStoreError {} - -impl Display for SerializableCookieStoreError { - fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { - match self { - Self::IoError(err) => write!(f, "IO error: {}", err), - Self::SerializationError(err) => write!(f, "Serialization error: {}", err), - } - } -} - -impl SerializableCookieStore { - pub fn read_from_file>( - file_path: P, - ) -> Result { - let content = std::fs::read_to_string(file_path) - .map_err(|err| SerializableCookieStoreError::IoError(err))?; - serde_json::from_str(&content) - .map_err(|err| SerializableCookieStoreError::SerializationError(err)) - } - - pub fn write_to_file>( - &self, - file_path: P, - ) -> Result<(), SerializableCookieStoreError> { - let serialized = serde_json::to_string(self) - .map_err(|err| SerializableCookieStoreError::SerializationError(err))?; - std::fs::write(file_path, serialized) - .map_err(|err| SerializableCookieStoreError::IoError(err)) - } - - pub fn to_cookie_store(&self) -> CookieStore { - let mut store = CookieStore::empty(); - for serialized_cookie in &self.cookies { - store.add_cookie(Cookie::new_from_str( - &serialized_cookie.name, - &serialized_cookie.value - )); - } - store - } -} diff --git a/crates/lib/data/web_base64/Cargo.toml b/crates/lib/data/web_base64/Cargo.toml deleted file mode 100644 index ff3818572c..0000000000 --- a/crates/lib/data/web_base64/Cargo.toml +++ /dev/null @@ -1,25 +0,0 @@ -[package] -name = "web_base64" -edition = "2024" -version = "0.0.1" -publish = false - -[package.metadata.cargo-udeps.ignore] -normal = ["workspace-build-acceleration"] - -[lib] -name = "web_base64" -path = "src/lib.rs" - -[dependencies] -# Workspace hack (faster compile times) -workspace-build-acceleration = { workspace = true } - -# Internal -# (None) - -# External -base64 = { workspace = true } - -[dev-dependencies] -# (None) diff --git a/crates/lib/data/web_base64/src/lib.rs b/crates/lib/data/web_base64/src/lib.rs deleted file mode 100644 index c5c08aeb78..0000000000 --- a/crates/lib/data/web_base64/src/lib.rs +++ /dev/null @@ -1,5 +0,0 @@ -//! Base64 encoding and decoding library that handles data from the web. -//! Most of the base64 we receive from the web is of a particular encoding -//! type, and we also have to juggle URL prefixes. - -pub mod web_base64_decode; diff --git a/crates/lib/data/web_base64/src/web_base64_decode.rs b/crates/lib/data/web_base64/src/web_base64_decode.rs deleted file mode 100644 index f80161118c..0000000000 --- a/crates/lib/data/web_base64/src/web_base64_decode.rs +++ /dev/null @@ -1,14 +0,0 @@ -use base64::prelude::BASE64_STANDARD; -use base64::Engine; - -pub fn web_base64_decode(base64_string: &str) -> Result, base64::DecodeError> { - // Remove the data URL prefix if it exists - // eg: "data:image/png;base64,..." - let base64_data = if base64_string.starts_with("data:") { - base64_string.split(',').nth(1).unwrap_or(base64_string) - } else { - base64_string - }; - - BASE64_STANDARD.decode(base64_data) -} diff --git a/crates/schema/database/sqlite_tasks/Cargo.toml b/crates/schema/database/sqlite_tasks/Cargo.toml deleted file mode 100644 index 7937087d01..0000000000 --- a/crates/schema/database/sqlite_tasks/Cargo.toml +++ /dev/null @@ -1,47 +0,0 @@ -[package] -name = "sqlite_tasks" -edition = "2024" -version = "0.0.1" -publish = false - -[package.metadata.cargo-udeps.ignore] -normal = ["workspace-build-acceleration"] - -[lib] -name = "sqlite_tasks" -path = "src/lib.rs" - -[dependencies] -# cargo-hakari workspace hack (faster compile times) -workspace-build-acceleration.workspace = true - -# Internal -enums.workspace = true -errors.workspace = true -tokens.workspace = true - -# External -anyhow.workspace = true -chrono.workspace = true -log.workspace = true - -# TODO(bt,2025-07-09): Update sqlx ASAP. We're stuck on 0.7 because of the complex use of internal types and macros in the database crate. -# We're going to embed in-memory SQLite -sqlx = { package = "sqlx", version = "0.7.4", features = ["runtime-tokio-rustls", "sqlite", "chrono"] } - -# Needed to safety check some queries we can't use escaping for -once_cell.workspace = true -regex.workspace = true - -# Serialization -serde.workspace = true -serde_derive.workspace = true -serde_json.workspace = true - -[dev-dependencies] -# serial_test = "3.0.0" - -[build-dependencies] -tempfile.workspace = true -sqlx = { package = "sqlx", version = "0.7.4", features = ["runtime-tokio-rustls", "sqlite", "chrono"] } -#rusqlite = "0.25.4" # NB: For the build.rs file diff --git a/crates/schema/database/sqlite_tasks/build.rs b/crates/schema/database/sqlite_tasks/build.rs deleted file mode 100644 index 2296d83bc1..0000000000 --- a/crates/schema/database/sqlite_tasks/build.rs +++ /dev/null @@ -1,40 +0,0 @@ -use std::env; -use std::path::PathBuf; - -pub fn main() { - // NB: This should help JetBrains' RustRover from highlighting failing query macros, - // but we do not want to interfere with the following: - // - // (1) User development builds - // (2) Tooling to cache offline queries - // (3) CI builds - let family = env::var("CARGO_CFG_TARGET_FAMILY").ok(); - - match family.as_deref() { - Some("unix") => unix_temp_database_pathing(), - Some("windows") => windows_temp_database_pathing(), - _ => { - println!("cargo:warning=Unsupported target family, using Unix temp database pathing."); - unix_temp_database_pathing(); - }, - } -} - -fn unix_temp_database_pathing() { - println!("cargo:rustc-env=DATABASE_URL=sqlite:/tmp/tasks.sqlite"); -} - -fn windows_temp_database_pathing() { - if let Ok(local_app_data) = env::var("LOCALAPPDATA") { - let path = PathBuf::from(local_app_data); - let path = path.join("Temp\\tasks.sqlite"); - let path = path - .to_str() - .expect("path should be valid") - .to_string(); - println!("cargo:warning=LocalAppData path: {}", path); - println!("cargo:rustc-env=DATABASE_URL=sqlite:{}", path); - } else { - panic!("LOCALAPPDATA environment variable not set"); - } -} diff --git a/crates/schema/database/sqlite_tasks/src/connection.rs b/crates/schema/database/sqlite_tasks/src/connection.rs deleted file mode 100644 index bd9af2bbb7..0000000000 --- a/crates/schema/database/sqlite_tasks/src/connection.rs +++ /dev/null @@ -1,64 +0,0 @@ -use errors::AnyhowResult; -use log::{error, info}; -use sqlx::migrate::MigrateError; -use sqlx::sqlite::{SqliteConnectOptions, SqliteJournalMode}; -use sqlx::{Pool, Sqlite, SqlitePool}; -use std::path::Path; - -#[derive(Clone)] -pub struct TaskDbConnection { - pool: Pool, -} - -impl TaskDbConnection { - pub async fn connect_and_migrate>(database_file: P) -> AnyhowResult { - { - match run_migrations(&database_file).await { - Ok(pool) => return Ok(Self { pool }), - Err(err) => { - error!("Error running SQLite migrations: {:?}", err); - } - } - - info!("Deleting and recreating SQLite database at {:?}", database_file.as_ref()); - - if let Err(err) = std::fs::remove_file(&database_file) { - error!("Error deleting SQLite database file: {:?}", err); - } - - // NB: Scope change here is an attempt to drop the open file connection for Windows. - // On Windows, we've observed that the file might still be open, preventing deletion: - // [2025-08-08][06:42:29][sqlite_tasks::connection][INFO] Deleting and recreating SQLite - // database at "C:\Users\User\Artcraft\state\tasks_v2.sqlite" - // [2025-08-08][06:42:29][sqlite_tasks::connection][ERROR] Error deleting SQLite database - // file: Os { code: 32, kind: Uncategorized, message: "The process cannot access the file - // because it is being used by another process." } - } - - let pool = run_migrations(database_file).await?; - - Ok(Self { pool }) - } - - pub fn get_pool(&self) -> &Pool { - &self.pool - } -} - -async fn run_migrations>(database_file: P) -> Result { - let connection_options = SqliteConnectOptions::new() - .filename(database_file) - .create_if_missing(true) - .journal_mode(SqliteJournalMode::Wal); - - let pool = SqlitePool::connect_with(connection_options).await?; - - // Run migrations regardless of whether the database is new, SQLx will track which migrations - // have been run. - // The migrations text get compiled into the binary, so no worries about build inclusion. - // Since the task database is being treated as ephemeral, we can always run migrations without - // worrying about previous state if we simply blow away old versions of the schema. - sqlx::migrate!("../../../../_database/sql/artcraft_migrations").run(&pool).await?; - - Ok(pool) -} diff --git a/crates/schema/database/sqlite_tasks/src/error.rs b/crates/schema/database/sqlite_tasks/src/error.rs deleted file mode 100644 index 7224709e95..0000000000 --- a/crates/schema/database/sqlite_tasks/src/error.rs +++ /dev/null @@ -1,37 +0,0 @@ -use enums::error::enum_error::EnumError; -use std::error::Error; -use std::fmt::{Display, Formatter}; - -#[derive(Debug)] -pub enum SqliteTasksError { - SqlxError(sqlx::Error), - EnumError(EnumError), - //TaskNotFound, - //TaskAlreadyExists, - //InvalidTaskStatus, - //InvalidTaskType, - //InvalidGenerationProvider, -} - -impl Error for SqliteTasksError {} - -impl Display for SqliteTasksError { - fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { - match self { - SqliteTasksError::SqlxError(err) => write!(f, "SQLx error: {:?}", err), - SqliteTasksError::EnumError(err) => write!(f, "Error parsing enum: {:?}", err), - } - } -} - -impl From for SqliteTasksError { - fn from(err: sqlx::Error) -> Self { - SqliteTasksError::SqlxError(err) - } -} - -impl From for SqliteTasksError { - fn from(err: EnumError) -> Self { - SqliteTasksError::EnumError(err) - } -} diff --git a/crates/schema/database/sqlite_tasks/src/lib.rs b/crates/schema/database/sqlite_tasks/src/lib.rs deleted file mode 100644 index 9bb94dc5b6..0000000000 --- a/crates/schema/database/sqlite_tasks/src/lib.rs +++ /dev/null @@ -1,23 +0,0 @@ -//! sqlite_tasks -//! -//! sqlx is happier with different compilation units? So be it! -//! - -// Never allow these -#![forbid(private_bounds)] -#![forbid(private_interfaces)] -#![forbid(unused_must_use)] // NB: It's unsafe to not close/check some things - -// Okay to toggle -#![forbid(unreachable_patterns)] -#![forbid(unused_imports)] -#![forbid(unused_mut)] -#![forbid(unused_variables)] - -// Always allow -#![allow(dead_code)] -#![allow(non_snake_case)] - -pub mod connection; -pub mod error; -pub mod queries; diff --git a/crates/schema/database/sqlite_tasks/src/queries/create_task.rs b/crates/schema/database/sqlite_tasks/src/queries/create_task.rs deleted file mode 100644 index 457d2d29f6..0000000000 --- a/crates/schema/database/sqlite_tasks/src/queries/create_task.rs +++ /dev/null @@ -1,74 +0,0 @@ -use crate::connection::TaskDbConnection; -use crate::error::SqliteTasksError; -use enums::common::generation_provider::GenerationProvider; -use enums::tauri::tasks::task_model_type::TaskModelType; -use enums::tauri::tasks::task_status::TaskStatus; -use enums::tauri::tasks::task_type::TaskType; -use enums::tauri::ux::tauri_command_caller::TauriCommandCaller; -use tokens::tokens::prompts::PromptToken; -use tokens::tokens::sqlite::tasks::TaskId; - -pub struct CreateTaskArgs<'a> { - pub db: &'a TaskDbConnection, - pub status: TaskStatus, - pub task_type: TaskType, - pub model_type: Option, - pub provider: GenerationProvider, - pub provider_job_id: Option<&'a str>, - pub queue_status_url: Option<&'a str>, - pub queue_response_url: Option<&'a str>, - pub prompt_token: Option<&'a PromptToken>, - pub frontend_caller: Option, - pub frontend_subscriber_id: Option<&'a str>, - pub frontend_subscriber_payload: Option<&'a str>, -} - -pub async fn create_task( - args: CreateTaskArgs<'_>, -) -> Result { - let task_id = TaskId::generate(); - - // TODO(bt,2025-07-12): Fix this. The sqlx mysql queries never required temporaries - let task_id_temp = task_id.as_str(); - let status_temp = args.status.to_str(); - let task_type_temp = args.task_type.to_str(); - let model_type_temp = args.model_type.as_ref().map(|s| s.to_str()); - let provider_temp = args.provider.to_string(); - let prompt_token_temp = args.prompt_token.map(|t| t.as_str()); - let frontend_caller_temp = args.frontend_caller.map(|s| s.to_str()); - - let query = sqlx::query!(r#" - INSERT INTO tasks ( - id, - task_status, - task_type, - model_type, - provider, - provider_job_id, - queue_status_url, - queue_response_url, - prompt_token, - frontend_caller, - frontend_subscriber_id, - frontend_subscriber_payload - ) - VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) - "#, - task_id_temp, - status_temp, - task_type_temp, - model_type_temp, - provider_temp, - args.provider_job_id, - args.queue_status_url, - args.queue_response_url, - prompt_token_temp, - frontend_caller_temp, - args.frontend_subscriber_id, - args.frontend_subscriber_payload - ); - - let _r = query.execute(args.db.get_pool()).await?; - - Ok(task_id) -} diff --git a/crates/schema/database/sqlite_tasks/src/queries/dismiss_all_tasks.rs b/crates/schema/database/sqlite_tasks/src/queries/dismiss_all_tasks.rs deleted file mode 100644 index fb2e7c7e5d..0000000000 --- a/crates/schema/database/sqlite_tasks/src/queries/dismiss_all_tasks.rs +++ /dev/null @@ -1,19 +0,0 @@ -use crate::connection::TaskDbConnection; -use crate::error::SqliteTasksError; - -/// Mark everything as dismissed. -pub async fn dismiss_all_tasks( - db: &TaskDbConnection, -) -> Result { - - let query = sqlx::query!(r#" - UPDATE tasks - SET is_dismissed_by_user = 1 - WHERE is_dismissed_by_user != 1 - "#); - - let res = query.execute(db.get_pool()).await?; - let rows_updated = res.rows_affected() > 0; - - Ok(rows_updated) -} diff --git a/crates/schema/database/sqlite_tasks/src/queries/get_task_by_provider_and_provider_job_id.rs b/crates/schema/database/sqlite_tasks/src/queries/get_task_by_provider_and_provider_job_id.rs deleted file mode 100644 index d110377bf7..0000000000 --- a/crates/schema/database/sqlite_tasks/src/queries/get_task_by_provider_and_provider_job_id.rs +++ /dev/null @@ -1,84 +0,0 @@ -use crate::connection::TaskDbConnection; -use crate::error::SqliteTasksError; -use crate::queries::task::Task; -use enums::common::generation_provider::GenerationProvider; -use enums::tauri::tasks::task_model_type::TaskModelType; -use enums::tauri::tasks::task_status::TaskStatus; -use enums::tauri::tasks::task_type::TaskType; -use enums::tauri::ux::tauri_command_caller::TauriCommandCaller; -use sqlx::Error; -use tokens::tokens::sqlite::tasks::TaskId; - -pub struct GetTaskByProviderAndProviderJobIdArgs<'a> { - pub db: &'a TaskDbConnection, - pub provider: GenerationProvider, - pub provider_job_id: &'a str, -} - - -pub async fn get_task_by_provider_and_provider_job_id( - args: GetTaskByProviderAndProviderJobIdArgs<'_>, -) -> Result, SqliteTasksError> { - - // TODO(bt,2025-07-12): Fix this. The sqlx mysql queries never required temporaries - let temp_provider = args.provider.to_str(); - let temp_provider_job_id = args.provider_job_id; - - let query = sqlx::query!(r#" - SELECT - id, - task_status, - task_type, - model_type, - provider, - provider_job_id, - frontend_caller, - queue_status_url, - queue_response_url, - prompt_token, - frontend_subscriber_id, - frontend_subscriber_payload - FROM tasks - WHERE - provider = ? - AND provider_job_id = ? - "#, - temp_provider, - temp_provider_job_id, - ); - - // info!("Query: {:?}", query.sql()); - - let result = query.fetch_one(args.db.get_pool()).await; - - let record = match result { - Ok(record) => record, - Err(err) => return match err { - Error::RowNotFound => Ok(None), - _ => Err(err.into()), - }, - }; - - // NB: Not sure why query can't figure out this isn't nullable - let provider = record.provider.as_deref() - .unwrap_or_else(|| args.provider.to_str()); - - Ok(Some(Task { - id: TaskId::new_from_str(&record.id), - status: TaskStatus::from_str(&record.task_status)?, - task_type: TaskType::from_str(&record.task_type)?, - model_type: record.model_type - .map(|model| TaskModelType::from_str(&model)) - .transpose()?, - provider: GenerationProvider::from_str(provider)?, - provider_job_id: record.provider_job_id, - queue_status_url: record.queue_status_url, - queue_response_url: record.queue_response_url, - prompt_token: record.prompt_token, - frontend_caller: record.frontend_caller - .map(|caller| TauriCommandCaller::from_str(&caller)) - .transpose()?, - frontend_subscriber_id: record.frontend_subscriber_id, - frontend_subscriber_payload: record.frontend_subscriber_payload, - })) -} diff --git a/crates/schema/database/sqlite_tasks/src/queries/list_non_artcraft_pending_tasks.rs b/crates/schema/database/sqlite_tasks/src/queries/list_non_artcraft_pending_tasks.rs deleted file mode 100644 index 3467258099..0000000000 --- a/crates/schema/database/sqlite_tasks/src/queries/list_non_artcraft_pending_tasks.rs +++ /dev/null @@ -1,84 +0,0 @@ -use crate::connection::TaskDbConnection; -use crate::error::SqliteTasksError; -use crate::queries::task::{RawTask, Task}; -use enums::common::generation_provider::GenerationProvider; -use enums::tauri::tasks::task_model_type::TaskModelType; -use enums::tauri::tasks::task_status::TaskStatus; -use enums::tauri::tasks::task_type::TaskType; -use enums::tauri::ux::tauri_command_caller::TauriCommandCaller; -use sqlx::{QueryBuilder, Sqlite}; -use std::collections::HashSet; -use tokens::tokens::sqlite::tasks::TaskId; - -pub struct ListNonArtcraftPendingTasksArgs<'a> { - pub db: &'a TaskDbConnection, - pub task_statuses: &'a HashSet, -} - -pub struct NonArtcraftTaskList { - pub tasks: Vec, -} - -/// List all tasks that are NOT from the Artcraft provider and match the given statuses. -pub async fn list_non_artcraft_pending_tasks( - args: ListNonArtcraftPendingTasksArgs<'_>, -) -> Result { - let artcraft_provider = GenerationProvider::Artcraft.to_string(); - - let mut query_builder: QueryBuilder = QueryBuilder::new(r#" - SELECT - id, - task_status, - task_type, - model_type, - provider, - provider_job_id, - queue_status_url, - queue_response_url, - prompt_token, - frontend_caller, - frontend_subscriber_id, - frontend_subscriber_payload - FROM tasks - WHERE provider != - "#); - - query_builder.push_bind(artcraft_provider); - - if !args.task_statuses.is_empty() { - query_builder.push(" AND task_status IN ("); - let mut separated = query_builder.separated(", "); - for task_status in args.task_statuses.into_iter() { - separated.push_bind(task_status.to_str()); - } - separated.push_unseparated(") "); - } - - let query = query_builder.build_query_as::(); - let results = query.fetch_all(args.db.get_pool()).await?; - - let mut tasks: Vec = Vec::new(); - - for task in results { - tasks.push(Task { - id: TaskId::new_from_str(&task.id), - status: TaskStatus::from_str(&task.task_status)?, - task_type: TaskType::from_str(&task.task_type)?, - model_type: task.model_type - .map(|model| TaskModelType::from_str(&model)) - .transpose()?, - provider: GenerationProvider::from_str(&task.provider)?, - provider_job_id: task.provider_job_id, - queue_status_url: task.queue_status_url, - queue_response_url: task.queue_response_url, - prompt_token: task.prompt_token, - frontend_caller: task.frontend_caller - .map(|caller| TauriCommandCaller::from_str(&caller)) - .transpose()?, - frontend_subscriber_id: task.frontend_subscriber_id, - frontend_subscriber_payload: task.frontend_subscriber_payload, - }); - } - - Ok(NonArtcraftTaskList { tasks }) -} diff --git a/crates/schema/database/sqlite_tasks/src/queries/list_tasks_by_provider_and_status.rs b/crates/schema/database/sqlite_tasks/src/queries/list_tasks_by_provider_and_status.rs deleted file mode 100644 index 2a63aed853..0000000000 --- a/crates/schema/database/sqlite_tasks/src/queries/list_tasks_by_provider_and_status.rs +++ /dev/null @@ -1,93 +0,0 @@ -use crate::connection::TaskDbConnection; -use crate::error::SqliteTasksError; -use crate::queries::task::{RawTask, Task}; -use enums::common::generation_provider::GenerationProvider; -use enums::tauri::tasks::task_model_type::TaskModelType; -use enums::tauri::tasks::task_status::TaskStatus; -use enums::tauri::tasks::task_type::TaskType; -use enums::tauri::ux::tauri_command_caller::TauriCommandCaller; -use sqlx::{QueryBuilder, Sqlite}; -use std::collections::HashSet; -use tokens::tokens::sqlite::tasks::TaskId; - -pub struct ListTasksByProviderAndStatusArgs<'a> { - pub db: &'a TaskDbConnection, - pub provider: GenerationProvider, - pub task_statuses: &'a HashSet, -} - -pub struct TaskList { - pub tasks: Vec, -} - -pub async fn list_tasks_by_provider_and_status( - args: ListTasksByProviderAndStatusArgs<'_>, -) -> Result { - - let mut query_builder: QueryBuilder = QueryBuilder::new(r#" - SELECT - id, - task_status, - task_type, - model_type, - provider, - provider_job_id, - queue_status_url, - queue_response_url, - prompt_token, - frontend_caller, - frontend_subscriber_id, - frontend_subscriber_payload - FROM tasks - WHERE provider = - "#); - - // TODO(bt,2025-07-15): Fix this. The sqlx mysql queries never required temporaries - let provider = args.provider.to_string(); - - query_builder.push_bind(provider); - - if !args.task_statuses.is_empty() { - query_builder.push(" AND task_status IN ("); - let mut separated = query_builder.separated(", "); - - for task_status in args.task_statuses.into_iter() { - separated.push_bind(task_status.to_str()); - } - - separated.push_unseparated(") "); - } - - let query = query_builder.build_query_as::(); - - // info!("Query: {:?}", query.sql()); - - let results = query.fetch_all(args.db.get_pool()).await?; - - let mut tasks: Vec = Vec::new(); - - for task in results { - tasks.push(Task { - id: TaskId::new_from_str(&task.id), - status: TaskStatus::from_str(&task.task_status)?, - task_type: TaskType::from_str(&task.task_type)?, - model_type: task.model_type - .map(|model| TaskModelType::from_str(&model)) - .transpose()?, - provider: GenerationProvider::from_str(&task.provider)?, - provider_job_id: task.provider_job_id, - queue_status_url: task.queue_status_url, - queue_response_url: task.queue_response_url, - prompt_token: task.prompt_token, - frontend_caller: task.frontend_caller - .map(|caller| TauriCommandCaller::from_str(&caller)) - .transpose()?, - frontend_subscriber_id: task.frontend_subscriber_id, - frontend_subscriber_payload: task.frontend_subscriber_payload, - }); - } - - Ok(TaskList { - tasks, - }) -} diff --git a/crates/schema/database/sqlite_tasks/src/queries/list_tasks_by_provider_and_tokens.rs b/crates/schema/database/sqlite_tasks/src/queries/list_tasks_by_provider_and_tokens.rs deleted file mode 100644 index bb9419af69..0000000000 --- a/crates/schema/database/sqlite_tasks/src/queries/list_tasks_by_provider_and_tokens.rs +++ /dev/null @@ -1,92 +0,0 @@ -use crate::connection::TaskDbConnection; -use crate::error::SqliteTasksError; -use crate::queries::task::{RawTask, Task}; -use enums::common::generation_provider::GenerationProvider; -use enums::tauri::tasks::task_model_type::TaskModelType; -use enums::tauri::tasks::task_status::TaskStatus; -use enums::tauri::tasks::task_type::TaskType; -use enums::tauri::ux::tauri_command_caller::TauriCommandCaller; -use sqlx::{QueryBuilder, Sqlite}; -use tokens::tokens::sqlite::tasks::TaskId; - -pub struct ListTasksArgs<'a> { - pub db: &'a TaskDbConnection, - pub provider: GenerationProvider, - pub provider_job_ids: Option>, -} - -pub struct TaskList { - pub tasks: Vec, -} - -pub async fn list_tasks_by_provider_and_tokens( - args: ListTasksArgs<'_>, -) -> Result { - - let mut query_builder: QueryBuilder = QueryBuilder::new(r#" - SELECT - id, - task_status, - task_type, - model_type, - provider, - provider_job_id, - frontend_caller, - queue_status_url, - queue_response_url, - prompt_token, - frontend_subscriber_id, - frontend_subscriber_payload - FROM tasks - WHERE provider = - "#); - - // TODO(bt,2025-07-15): Fix this. The sqlx mysql queries never required temporaries - let provider = args.provider.to_string(); - - query_builder.push_bind(provider); - - if let Some(provider_job_ids) = args.provider_job_ids { - query_builder.push(" AND provider_job_id IN ("); - let mut separated = query_builder.separated(", "); - - for job_id in provider_job_ids.into_iter() { - separated.push_bind(job_id); - } - - separated.push_unseparated(") "); - } - - let query = query_builder.build_query_as::(); - - // info!("Query: {:?}", query.sql()); - - let results = query.fetch_all(args.db.get_pool()).await?; - - let mut tasks: Vec = Vec::new(); - - for task in results { - tasks.push(Task { - id: TaskId::new_from_str(&task.id), - status: TaskStatus::from_str(&task.task_status)?, - task_type: TaskType::from_str(&task.task_type)?, - model_type: task.model_type - .map(|model| TaskModelType::from_str(&model)) - .transpose()?, - provider: GenerationProvider::from_str(&task.provider)?, - provider_job_id: task.provider_job_id, - queue_status_url: task.queue_status_url, - queue_response_url: task.queue_response_url, - prompt_token: task.prompt_token, - frontend_caller: task.frontend_caller - .map(|caller| TauriCommandCaller::from_str(&caller)) - .transpose()?, - frontend_subscriber_id: task.frontend_subscriber_id, - frontend_subscriber_payload: task.frontend_subscriber_payload, - }); - } - - Ok(TaskList { - tasks, - }) -} diff --git a/crates/schema/database/sqlite_tasks/src/queries/list_tasks_for_frontend.rs b/crates/schema/database/sqlite_tasks/src/queries/list_tasks_for_frontend.rs deleted file mode 100644 index 6156218347..0000000000 --- a/crates/schema/database/sqlite_tasks/src/queries/list_tasks_for_frontend.rs +++ /dev/null @@ -1,135 +0,0 @@ -use crate::connection::TaskDbConnection; -use crate::error::SqliteTasksError; -use chrono::{DateTime, Utc}; -use enums::common::generation_provider::GenerationProvider; -use enums::tauri::tasks::task_failure_type::TaskFailureType; -use enums::tauri::tasks::task_media_file_class::TaskMediaFileClass; -use enums::tauri::tasks::task_model_type::TaskModelType; -use enums::tauri::tasks::task_status::TaskStatus; -use enums::tauri::tasks::task_type::TaskType; -use enums::tauri::ux::tauri_command_caller::TauriCommandCaller; -use tokens::tokens::batch_generations::BatchGenerationToken; -use tokens::tokens::media_files::MediaFileToken; -use tokens::tokens::sqlite::tasks::TaskId; - -pub struct TaskList { - pub tasks: Vec, -} - -pub struct TaskItem { - pub id: TaskId, - pub status: TaskStatus, - pub task_type: TaskType, - pub model_type: Option, - pub provider: Option, - pub provider_job_id: Option, - pub frontend_caller: Option, - pub frontend_subscriber_id: Option, - pub frontend_subscriber_payload: Option, - pub on_complete_primary_media_file_token: Option, - pub on_complete_primary_media_file_class: Option, - pub on_complete_batch_token: Option, - pub on_complete_primary_media_file_cdn_url: Option, - pub on_complete_primary_media_file_thumbnail_url_template: Option, - pub on_failure_type: Option, - pub on_failure_message: Option, - pub created_at: DateTime, - pub updated_at: DateTime, - pub completed_at: Option>, -} - -pub async fn list_tasks_for_frontend( - db: & TaskDbConnection -) -> Result { - let query = sqlx::query_as!( - TaskItemRaw, - r#" - SELECT - id, - task_status, - task_type, - model_type, - provider, - provider_job_id, - frontend_caller, - frontend_subscriber_id, - frontend_subscriber_payload, - on_complete_primary_media_file_token, - on_complete_primary_media_file_class, - on_complete_batch_token, - on_complete_primary_media_file_cdn_url, - on_complete_primary_media_file_thumbnail_url_template, - on_failure_type, - on_failure_message, - created_at as "created_at: DateTime", - updated_at as "updated_at: DateTime", - completed_at as "completed_at: DateTime" - FROM tasks - WHERE is_dismissed_by_user == 0 - "#); - - let result = query.fetch_all(db.get_pool()) - .await?; - - let mut tasks = Vec::with_capacity(result.len()); - - for raw in result.into_iter() { - tasks.push(TaskItem { - id: TaskId::new(raw.id), - status: TaskStatus::from_str(&raw.task_status)?, - task_type: TaskType::from_str(&raw.task_type)?, - model_type: raw.model_type - .map(|model| TaskModelType::from_str(&model)) - .transpose()?, - provider: raw.provider - .map(|provider| GenerationProvider::from_str(&provider)) - .transpose()?, - provider_job_id: raw.provider_job_id, - frontend_caller: raw.frontend_caller - .map(|caller| TauriCommandCaller::from_str(&caller)) - .transpose()?, - frontend_subscriber_id: raw.frontend_subscriber_id, - frontend_subscriber_payload: raw.frontend_subscriber_payload, - on_complete_primary_media_file_token: raw.on_complete_primary_media_file_token.map(|t| MediaFileToken::new_from_str(&t)), - on_complete_primary_media_file_class: raw.on_complete_primary_media_file_class - .map(|c| TaskMediaFileClass::from_str(&c)) - .transpose()?, - on_complete_batch_token: raw.on_complete_batch_token.map(|t| BatchGenerationToken::new_from_str(&t)), - on_complete_primary_media_file_cdn_url: raw.on_complete_primary_media_file_cdn_url, - on_complete_primary_media_file_thumbnail_url_template: raw.on_complete_primary_media_file_thumbnail_url_template, - on_failure_type: raw.on_failure_type - .map(|t| TaskFailureType::from_str(&t)) - .transpose()?, - on_failure_message: raw.on_failure_message, - created_at: raw.created_at, - updated_at: raw.updated_at, - completed_at: raw.completed_at, - }) - } - - Ok(TaskList { - tasks, - }) -} - -struct TaskItemRaw { - id: String, - task_status: String, - task_type: String, - model_type: Option, - provider: Option, - provider_job_id: Option, - frontend_caller: Option, - frontend_subscriber_id: Option, - frontend_subscriber_payload: Option, - on_complete_primary_media_file_token: Option, - on_complete_primary_media_file_class: Option, - on_complete_batch_token: Option, - on_complete_primary_media_file_cdn_url: Option, - on_complete_primary_media_file_thumbnail_url_template: Option, - on_failure_type: Option, - on_failure_message: Option, - created_at: DateTime, - updated_at: DateTime, - completed_at: Option>, -} diff --git a/crates/schema/database/sqlite_tasks/src/queries/mark_task_as_dismissed.rs b/crates/schema/database/sqlite_tasks/src/queries/mark_task_as_dismissed.rs deleted file mode 100644 index 26f3c0b88b..0000000000 --- a/crates/schema/database/sqlite_tasks/src/queries/mark_task_as_dismissed.rs +++ /dev/null @@ -1,27 +0,0 @@ -use crate::connection::TaskDbConnection; -use crate::error::SqliteTasksError; -use tokens::tokens::sqlite::tasks::TaskId; - -/// Returns true if rows were updated. -pub async fn mark_task_as_dismissed( - db: &TaskDbConnection, - task_id: &TaskId, -) -> Result { - - // TODO(bt,2025-07-12): Fix this. The sqlx mysql queries never required temporaries - let task_id_temp = task_id.as_str(); - - // TODO(bt,2025-07-15): We can't set a LIMIT without a certain compiler flag for SQLite ? - let query = sqlx::query!(r#" - UPDATE tasks - SET is_dismissed_by_user = 1 - WHERE id = ? - "#, - task_id_temp, - ); - - let res = query.execute(db.get_pool()).await?; - let rows_updated = res.rows_affected() > 0; - - Ok(rows_updated) -} diff --git a/crates/schema/database/sqlite_tasks/src/queries/mod.rs b/crates/schema/database/sqlite_tasks/src/queries/mod.rs deleted file mode 100644 index 86b20be6e8..0000000000 --- a/crates/schema/database/sqlite_tasks/src/queries/mod.rs +++ /dev/null @@ -1,14 +0,0 @@ -pub mod create_task; -pub mod dismiss_all_tasks; -pub mod list_non_artcraft_pending_tasks; -pub mod get_task_by_provider_and_provider_job_id; -pub mod list_tasks_by_provider_and_status; -pub mod list_tasks_by_provider_and_tokens; -pub mod list_tasks_for_frontend; -pub mod mark_task_as_dismissed; -pub mod nuke_all_tasks; -pub mod task; -pub mod update_successful_task_status_with_metadata; -pub mod update_successful_task_status_with_metadata_by_provider; -pub mod update_task_status; -pub mod update_task_status_with_rich_failure; \ No newline at end of file diff --git a/crates/schema/database/sqlite_tasks/src/queries/nuke_all_tasks.rs b/crates/schema/database/sqlite_tasks/src/queries/nuke_all_tasks.rs deleted file mode 100644 index 48edfb749c..0000000000 --- a/crates/schema/database/sqlite_tasks/src/queries/nuke_all_tasks.rs +++ /dev/null @@ -1,28 +0,0 @@ -use crate::connection::TaskDbConnection; -use crate::error::SqliteTasksError; - -/// Abandon all in-progress tasks. -/// Marked as user cancellation. -pub async fn nuke_all_tasks( - db: &TaskDbConnection, -) -> Result { - - // TODO(bt,2025-07-15): We can't set a LIMIT without a certain compiler flag for SQLite ? - let query = sqlx::query!(r#" - UPDATE tasks - SET task_status = "cancelled_by_user" - WHERE task_status NOT IN ( - "complete_success", - "complete_failure", - "dead", - "cancelled_by_user", - "cancelled_by_provider", - "cancelled_by_us" - ) - "#); - - let res = query.execute(db.get_pool()).await?; - let rows_updated = res.rows_affected() > 0; - - Ok(rows_updated) -} diff --git a/crates/schema/database/sqlite_tasks/src/queries/task.rs b/crates/schema/database/sqlite_tasks/src/queries/task.rs deleted file mode 100644 index 06bc701bd3..0000000000 --- a/crates/schema/database/sqlite_tasks/src/queries/task.rs +++ /dev/null @@ -1,39 +0,0 @@ -use enums::common::generation_provider::GenerationProvider; -use enums::tauri::tasks::task_model_type::TaskModelType; -use enums::tauri::tasks::task_status::TaskStatus; -use enums::tauri::tasks::task_type::TaskType; -use enums::tauri::ux::tauri_command_caller::TauriCommandCaller; -use tokens::tokens::sqlite::tasks::TaskId; - -#[derive(Debug, Clone)] -pub struct Task { - pub id: TaskId, - pub status: TaskStatus, - pub task_type: TaskType, - pub model_type: Option, - pub provider: GenerationProvider, - pub provider_job_id: Option, - pub queue_status_url: Option, - pub queue_response_url: Option, - pub prompt_token: Option, - pub frontend_caller: Option, - pub frontend_subscriber_id: Option, - pub frontend_subscriber_payload: Option, -} - -#[derive(Debug)] -#[derive(sqlx::FromRow)] -pub (crate) struct RawTask { - pub (crate) id: String, - pub (crate) task_status: String, - pub (crate) task_type: String, - pub (crate) model_type: Option, - pub (crate) provider: String, - pub (crate) provider_job_id: Option, - pub (crate) queue_status_url: Option, - pub (crate) queue_response_url: Option, - pub (crate) prompt_token: Option, - pub (crate) frontend_caller: Option, - pub (crate) frontend_subscriber_id: Option, - pub (crate) frontend_subscriber_payload: Option, -} diff --git a/crates/schema/database/sqlite_tasks/src/queries/update_successful_task_status_with_metadata.rs b/crates/schema/database/sqlite_tasks/src/queries/update_successful_task_status_with_metadata.rs deleted file mode 100644 index 7b46d0b690..0000000000 --- a/crates/schema/database/sqlite_tasks/src/queries/update_successful_task_status_with_metadata.rs +++ /dev/null @@ -1,59 +0,0 @@ -use crate::connection::TaskDbConnection; -use crate::error::SqliteTasksError; -use enums::tauri::tasks::task_media_file_class::TaskMediaFileClass; -use enums::tauri::tasks::task_status::TaskStatus; -use tokens::tokens::batch_generations::BatchGenerationToken; -use tokens::tokens::media_files::MediaFileToken; -use tokens::tokens::sqlite::tasks::TaskId; - -const SUCCESSFUL_STATUS : &str = TaskStatus::CompleteSuccess.to_str(); - -pub struct UpdateSuccessfulTaskArgs<'a> { - pub db: &'a TaskDbConnection, - pub task_id: &'a TaskId, - pub maybe_batch_token: Option<&'a BatchGenerationToken>, - pub maybe_primary_media_file_token: Option<&'a MediaFileToken>, - pub maybe_primary_media_file_class: Option, - pub maybe_primary_media_file_cdn_url: Option<&'a str>, - pub maybe_primary_media_file_thumbnail_url_template: Option<&'a str>, -} - -/// Returns true if rows were updated. -pub async fn update_successful_task_status_with_metadata( - args: UpdateSuccessfulTaskArgs<'_>, -) -> Result { - - // TODO(bt,2025-07-12): Fix this. The sqlx mysql queries never required temporaries - let task_id_temp = args.task_id.as_str(); - let maybe_batch_token_temp = args.maybe_batch_token.map(|t| t.as_str()); - let maybe_primary_media_token_temp = args.maybe_primary_media_file_token.map(|t| t.as_str()); - let maybe_primary_media_class = args.maybe_primary_media_file_class.map(|c| c.to_str()); - - // TODO(bt,2025-07-15): We can't set a LIMIT without a certain compiler flag for SQLite ? - let query = sqlx::query!(r#" - UPDATE tasks - SET - task_status = ?, - on_complete_batch_token = ?, - on_complete_primary_media_file_token = ?, - on_complete_primary_media_file_class = ?, - on_complete_primary_media_file_cdn_url = ?, - on_complete_primary_media_file_thumbnail_url_template = ? - WHERE id = ? - "#, - SUCCESSFUL_STATUS, - maybe_batch_token_temp, - maybe_primary_media_token_temp, - maybe_primary_media_class, - args.maybe_primary_media_file_cdn_url, - args.maybe_primary_media_file_thumbnail_url_template, - task_id_temp, - ); - - // info!("query: {:?}", query.sql()); - - let res = query.execute(args.db.get_pool()).await?; - let rows_updated = res.rows_affected() > 0; - - Ok(rows_updated) -} diff --git a/crates/schema/database/sqlite_tasks/src/queries/update_successful_task_status_with_metadata_by_provider.rs b/crates/schema/database/sqlite_tasks/src/queries/update_successful_task_status_with_metadata_by_provider.rs deleted file mode 100644 index 12b25cc63f..0000000000 --- a/crates/schema/database/sqlite_tasks/src/queries/update_successful_task_status_with_metadata_by_provider.rs +++ /dev/null @@ -1,64 +0,0 @@ -use enums::common::generation_provider::GenerationProvider; -use crate::connection::TaskDbConnection; -use crate::error::SqliteTasksError; -use enums::tauri::tasks::task_media_file_class::TaskMediaFileClass; -use enums::tauri::tasks::task_status::TaskStatus; -use tokens::tokens::batch_generations::BatchGenerationToken; -use tokens::tokens::media_files::MediaFileToken; - -const SUCCESSFUL_STATUS : &str = TaskStatus::CompleteSuccess.to_str(); - -pub struct UpdateSuccessfulTaskByProviderArgs<'a> { - pub db: &'a TaskDbConnection, - pub provider: GenerationProvider, - pub provider_job_id: &'a str, - pub maybe_batch_token: Option<&'a BatchGenerationToken>, - pub maybe_primary_media_file_token: Option<&'a MediaFileToken>, - pub maybe_primary_media_file_class: Option, - pub maybe_primary_media_file_cdn_url: Option<&'a str>, - pub maybe_primary_media_file_thumbnail_url_template: Option<&'a str>, -} - -/// Returns true if rows were updated. -pub async fn update_successful_task_status_with_metadata_by_provider( - args: UpdateSuccessfulTaskByProviderArgs<'_>, -) -> Result { - - // TODO(bt,2025-07-12): Fix this. The sqlx mysql queries never required temporaries - let provider_temp = args.provider.to_str(); - let provider_job_id_temp = args.provider_job_id; - let maybe_batch_token_temp = args.maybe_batch_token.map(|t| t.as_str()); - let maybe_primary_media_token_temp = args.maybe_primary_media_file_token.map(|t| t.as_str()); - let maybe_primary_media_class = args.maybe_primary_media_file_class.map(|c| c.to_str()); - - // TODO(bt,2025-07-15): We can't set a LIMIT without a certain compiler flag for SQLite ? - let query = sqlx::query!(r#" - UPDATE tasks - SET - task_status = ?, - on_complete_batch_token = ?, - on_complete_primary_media_file_token = ?, - on_complete_primary_media_file_class = ?, - on_complete_primary_media_file_cdn_url = ?, - on_complete_primary_media_file_thumbnail_url_template = ? - WHERE - provider = ? - AND provider_job_id = ? - "#, - SUCCESSFUL_STATUS, - maybe_batch_token_temp, - maybe_primary_media_token_temp, - maybe_primary_media_class, - args.maybe_primary_media_file_cdn_url, - args.maybe_primary_media_file_thumbnail_url_template, - provider_temp, - provider_job_id_temp, - ); - - // info!("query: {:?}", query.sql()); - - let res = query.execute(args.db.get_pool()).await?; - let rows_updated = res.rows_affected() > 0; - - Ok(rows_updated) -} diff --git a/crates/schema/database/sqlite_tasks/src/queries/update_task_status.rs b/crates/schema/database/sqlite_tasks/src/queries/update_task_status.rs deleted file mode 100644 index ead78ece46..0000000000 --- a/crates/schema/database/sqlite_tasks/src/queries/update_task_status.rs +++ /dev/null @@ -1,39 +0,0 @@ -use crate::connection::TaskDbConnection; -use crate::error::SqliteTasksError; -use enums::tauri::tasks::task_status::TaskStatus; -use tokens::tokens::sqlite::tasks::TaskId; - -pub struct UpdateTaskArgs<'a> { - pub db: &'a TaskDbConnection, - pub task_id: &'a TaskId, - pub status: TaskStatus, -} - -/// Returns true if rows were updated. -pub async fn update_task_status( - args: UpdateTaskArgs<'_>, -) -> Result { - - // TODO(bt,2025-07-12): Fix this. The sqlx mysql queries never required temporaries - let task_id_temp = args.task_id.as_str(); - let status_temp = args.status.to_str(); - - // info!("Update task id: {}, status: {}", task_id_temp, status_temp); - - // TODO(bt,2025-07-15): We can't set a LIMIT without a certain compiler flag for SQLite ? - let query = sqlx::query!(r#" - UPDATE tasks - SET task_status = ? - WHERE id = ? - "#, - status_temp, - task_id_temp, - ); - - // info!("query: {:?}", query.sql()); - - let res = query.execute(args.db.get_pool()).await?; - let rows_updated = res.rows_affected() > 0; - - Ok(rows_updated) -} diff --git a/crates/schema/database/sqlite_tasks/src/queries/update_task_status_with_rich_failure.rs b/crates/schema/database/sqlite_tasks/src/queries/update_task_status_with_rich_failure.rs deleted file mode 100644 index 896d6c5cd4..0000000000 --- a/crates/schema/database/sqlite_tasks/src/queries/update_task_status_with_rich_failure.rs +++ /dev/null @@ -1,51 +0,0 @@ -use enums::tauri::tasks::task_failure_type::TaskFailureType; -use crate::connection::TaskDbConnection; -use crate::error::SqliteTasksError; -use enums::tauri::tasks::task_status::TaskStatus; -use tokens::tokens::sqlite::tasks::TaskId; - -pub struct UpdateTaskWithRichFailureArgs<'a> { - pub db: &'a TaskDbConnection, - pub task_id: &'a TaskId, - pub status: TaskStatus, - pub maybe_failure_type: Option, - pub maybe_failure_message: Option<&'a str>, -} - -/// Returns true if rows were updated. -pub async fn update_task_status_with_rich_failure( - args: UpdateTaskWithRichFailureArgs<'_>, -) -> Result { - - // TODO(bt,2025-07-12): Fix this. The sqlx mysql queries never required temporaries - let task_id_temp = args.task_id.as_str(); - let status_temp = args.status.to_str(); - let maybe_failure_type_temp = args.maybe_failure_type.map(|val| val.to_str()); - - // Trim the message so it doesn't overflow the database column - let maybe_failure_message_temp = args.maybe_failure_message - .map(|s| if s.len() > 255 { &s[..255] } else { s }); - - // info!("Update task id: {}, status: {}", task_id_temp, status_temp); - - // TODO(bt,2025-07-15): We can't set a LIMIT without a certain compiler flag for SQLite ? - let query = sqlx::query!(r#" - UPDATE tasks - SET task_status = ?, - on_failure_type = ?, - on_failure_message = ? - WHERE id = ? - "#, - status_temp, - maybe_failure_type_temp, - maybe_failure_message_temp, - task_id_temp, - ); - - // info!("query: {:?}", query.sql()); - - let res = query.execute(args.db.get_pool()).await?; - let rows_updated = res.rows_affected() > 0; - - Ok(rows_updated) -} diff --git a/crates/schema/public/enums/src/lib.rs b/crates/schema/public/enums/src/lib.rs index ece0ad8b1d..e89ff45fa4 100644 --- a/crates/schema/public/enums/src/lib.rs +++ b/crates/schema/public/enums/src/lib.rs @@ -35,6 +35,5 @@ pub mod by_table; pub mod common; pub mod error; pub mod no_table; -pub mod tauri; pub mod traits; pub mod api_safe; diff --git a/crates/schema/public/enums/src/tauri/mod.rs b/crates/schema/public/enums/src/tauri/mod.rs deleted file mode 100644 index b6956616d1..0000000000 --- a/crates/schema/public/enums/src/tauri/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod tasks; -pub mod ux; \ No newline at end of file diff --git a/crates/schema/public/enums/src/tauri/tasks/mod.rs b/crates/schema/public/enums/src/tauri/tasks/mod.rs deleted file mode 100644 index 780c9c03db..0000000000 --- a/crates/schema/public/enums/src/tauri/tasks/mod.rs +++ /dev/null @@ -1,5 +0,0 @@ -pub mod task_failure_type; -pub mod task_media_file_class; -pub mod task_model_type; -pub mod task_status; -pub mod task_type; \ No newline at end of file diff --git a/crates/schema/public/enums/src/tauri/tasks/task_failure_type.rs b/crates/schema/public/enums/src/tauri/tasks/task_failure_type.rs deleted file mode 100644 index f531dcd6d9..0000000000 --- a/crates/schema/public/enums/src/tauri/tasks/task_failure_type.rs +++ /dev/null @@ -1,253 +0,0 @@ -use std::collections::BTreeSet; - -use crate::api_safe::by_table::generic_inference_jobs::frontend_failure_category_for_api_clients::FrontendFailureCategoryForApiClients; -use crate::by_table::generic_inference_jobs::frontend_failure_category::FrontendFailureCategory; -use crate::error::enum_error::EnumError; -#[cfg(test)] -use strum::EnumCount; -#[cfg(test)] -use strum::EnumIter; -use utoipa::ToSchema; - -/// Failure type for tasks in the Tauri desktop app. -/// -/// Mirrors the relevant variants from `FrontendFailureCategory` so the desktop -/// client can display localized failure information without depending / breaking on the -/// server-side enum directly. -#[cfg_attr(test, derive(EnumIter, EnumCount))] -#[derive(Clone, Copy, PartialEq, Eq, Hash, Ord, PartialOrd, Serialize, Deserialize, ToSchema)] -#[serde(rename_all = "snake_case")] -pub enum TaskFailureType { - /// Catch-all for unknown failures. - Unknown, - - RuleBansUserImage, - RuleBansUserImageWithFaces, - RuleBansUserTextPrompt, - RuleBansUserContent, - - RuleBansGeneratedVideo, - RuleBansGeneratedAudio, - RuleBansGeneratedContent, - - /// No foreground subject could be detected in the input image after - /// background removal (e.g. TripoSplat image-to-splat). - NoForegroundSubjectDetected, - - /// The input file's format isn't supported by the model (e.g. Hunyuan 3D - /// Part only accepts FBX input). - FormatNotSupported, - - /// No reason given for generation failure, but this matches what we were told. - GenerationFailed, -} - -impl_enum_display_and_debug_using_to_str!(TaskFailureType); - -impl TaskFailureType { - - /// Convert the web API's `FrontendFailureCategory` to a Tauri-facing type, if there is a matching variant. - /// If there isn't a matching variant, return `Unknown`. - pub fn from_frontend_failure_category(category: FrontendFailureCategory) -> Self { - match category { - FrontendFailureCategory::ModelRulesViolation => Self::RuleBansUserContent, // NB: This is a legacy enum value. - FrontendFailureCategory::RuleBansUserImage => Self::RuleBansUserImage, - FrontendFailureCategory::RuleBansUserImageWithFaces => Self::RuleBansUserImageWithFaces, - FrontendFailureCategory::RuleBansUserTextPrompt => Self::RuleBansUserTextPrompt, - FrontendFailureCategory::RuleBansUserContent => Self::RuleBansUserContent, - FrontendFailureCategory::RuleBansGeneratedVideo => Self::RuleBansGeneratedVideo, - FrontendFailureCategory::RuleBansGeneratedAudio => Self::RuleBansGeneratedAudio, - FrontendFailureCategory::RuleBansGeneratedContent => Self::RuleBansGeneratedContent, - FrontendFailureCategory::NoForegroundSubjectDetected => Self::NoForegroundSubjectDetected, - FrontendFailureCategory::FormatNotSupported => Self::FormatNotSupported, - FrontendFailureCategory::GenerationFailed => Self::GenerationFailed, - _ => Self::Unknown, - } - } - - /// Convert the API-client-facing `FrontendFailureCategoryForApiClients` to a Tauri-facing type. - /// `Unknown(String)` maps to `Unknown` with a debug log. - pub fn from_frontend_failure_category_for_api(category: &FrontendFailureCategoryForApiClients) -> Self { - match category { - FrontendFailureCategoryForApiClients::ModelRulesViolation => Self::RuleBansUserContent, - FrontendFailureCategoryForApiClients::RuleBansUserImage => Self::RuleBansUserImage, - FrontendFailureCategoryForApiClients::RuleBansUserImageWithFaces => Self::RuleBansUserImageWithFaces, - FrontendFailureCategoryForApiClients::RuleBansUserTextPrompt => Self::RuleBansUserTextPrompt, - FrontendFailureCategoryForApiClients::RuleBansUserContent => Self::RuleBansUserContent, - FrontendFailureCategoryForApiClients::RuleBansGeneratedVideo => Self::RuleBansGeneratedVideo, - FrontendFailureCategoryForApiClients::RuleBansGeneratedAudio => Self::RuleBansGeneratedAudio, - FrontendFailureCategoryForApiClients::RuleBansGeneratedContent => Self::RuleBansGeneratedContent, - FrontendFailureCategoryForApiClients::NoForegroundSubjectDetected => Self::NoForegroundSubjectDetected, - FrontendFailureCategoryForApiClients::FormatNotSupported => Self::FormatNotSupported, - FrontendFailureCategoryForApiClients::GenerationFailed => Self::GenerationFailed, - - // Types ArtCraft doesn't care about - FrontendFailureCategoryForApiClients::FaceNotDetected => Self::Unknown, - FrontendFailureCategoryForApiClients::KeepAliveElapsed => Self::Unknown, - FrontendFailureCategoryForApiClients::NotYetImplemented => Self::Unknown, - FrontendFailureCategoryForApiClients::RetryableWorkerError => Self::Unknown, - FrontendFailureCategoryForApiClients::FilesizeTooLarge => Self::Unknown, - FrontendFailureCategoryForApiClients::ImageDimensionsTooSmall => Self::Unknown, - FrontendFailureCategoryForApiClients::ImageDimensionsTooLarge => Self::Unknown, - - // Unknown (future-proof) variant - FrontendFailureCategoryForApiClients::Unknown(ref value) => { - log::debug!("Unknown FrontendFailureCategoryForApiClients variant: {}", value); - Self::Unknown - } - } - } - - pub const fn to_str(&self) -> &'static str { - match self { - Self::Unknown => "unknown", - Self::RuleBansUserImage => "rule_bans_user_image", - Self::RuleBansUserImageWithFaces => "rule_bans_user_image_with_faces", - Self::RuleBansUserTextPrompt => "rule_bans_user_text_prompt", - Self::RuleBansUserContent => "rule_bans_user_content", - Self::RuleBansGeneratedVideo => "rule_bans_generated_video", - Self::RuleBansGeneratedAudio => "rule_bans_generated_audio", - Self::RuleBansGeneratedContent => "rule_bans_generated_content", - Self::NoForegroundSubjectDetected => "no_foreground_subject_detected", - Self::FormatNotSupported => "format_not_supported", - Self::GenerationFailed => "generation_failed", - } - } - - pub fn from_str(value: &str) -> Result { - match value { - "unknown" => Ok(Self::Unknown), - "rule_bans_user_image" => Ok(Self::RuleBansUserImage), - "rule_bans_user_image_with_faces" => Ok(Self::RuleBansUserImageWithFaces), - "rule_bans_user_text_prompt" => Ok(Self::RuleBansUserTextPrompt), - "rule_bans_user_content" => Ok(Self::RuleBansUserContent), - "rule_bans_generated_video" => Ok(Self::RuleBansGeneratedVideo), - "rule_bans_generated_audio" => Ok(Self::RuleBansGeneratedAudio), - "rule_bans_generated_content" => Ok(Self::RuleBansGeneratedContent), - "no_foreground_subject_detected" => Ok(Self::NoForegroundSubjectDetected), - "format_not_supported" => Ok(Self::FormatNotSupported), - "generation_failed" => Ok(Self::GenerationFailed), - _ => Err(EnumError::CouldNotConvertFromString(value.to_string())), - } - } - - pub fn all_variants() -> BTreeSet { - BTreeSet::from([ - Self::Unknown, - Self::RuleBansUserImage, - Self::RuleBansUserImageWithFaces, - Self::RuleBansUserTextPrompt, - Self::RuleBansUserContent, - Self::RuleBansGeneratedVideo, - Self::RuleBansGeneratedAudio, - Self::RuleBansGeneratedContent, - Self::NoForegroundSubjectDetected, - Self::FormatNotSupported, - Self::GenerationFailed, - ]) - } -} - -#[cfg(test)] -mod tests { - use crate::tauri::tasks::task_failure_type::TaskFailureType; - use crate::test_helpers::assert_serialization; - - mod explicit_checks { - use super::*; - use crate::error::enum_error::EnumError; - - #[test] - fn test_serialization() { - assert_serialization(TaskFailureType::Unknown, "unknown"); - assert_serialization(TaskFailureType::RuleBansUserImage, "rule_bans_user_image"); - assert_serialization(TaskFailureType::RuleBansUserImageWithFaces, "rule_bans_user_image_with_faces"); - assert_serialization(TaskFailureType::RuleBansUserTextPrompt, "rule_bans_user_text_prompt"); - assert_serialization(TaskFailureType::RuleBansUserContent, "rule_bans_user_content"); - assert_serialization(TaskFailureType::RuleBansGeneratedVideo, "rule_bans_generated_video"); - assert_serialization(TaskFailureType::RuleBansGeneratedAudio, "rule_bans_generated_audio"); - assert_serialization(TaskFailureType::RuleBansGeneratedContent, "rule_bans_generated_content"); - assert_serialization(TaskFailureType::NoForegroundSubjectDetected, "no_foreground_subject_detected"); - assert_serialization(TaskFailureType::FormatNotSupported, "format_not_supported"); - assert_serialization(TaskFailureType::GenerationFailed, "generation_failed"); - } - - #[test] - fn to_str() { - assert_eq!(TaskFailureType::Unknown.to_str(), "unknown"); - assert_eq!(TaskFailureType::RuleBansUserImage.to_str(), "rule_bans_user_image"); - assert_eq!(TaskFailureType::RuleBansUserImageWithFaces.to_str(), "rule_bans_user_image_with_faces"); - assert_eq!(TaskFailureType::RuleBansUserTextPrompt.to_str(), "rule_bans_user_text_prompt"); - assert_eq!(TaskFailureType::RuleBansUserContent.to_str(), "rule_bans_user_content"); - assert_eq!(TaskFailureType::RuleBansGeneratedVideo.to_str(), "rule_bans_generated_video"); - assert_eq!(TaskFailureType::RuleBansGeneratedAudio.to_str(), "rule_bans_generated_audio"); - assert_eq!(TaskFailureType::RuleBansGeneratedContent.to_str(), "rule_bans_generated_content"); - assert_eq!(TaskFailureType::NoForegroundSubjectDetected.to_str(), "no_foreground_subject_detected"); - assert_eq!(TaskFailureType::FormatNotSupported.to_str(), "format_not_supported"); - assert_eq!(TaskFailureType::GenerationFailed.to_str(), "generation_failed"); - } - - #[test] - fn from_str() { - assert_eq!(TaskFailureType::from_str("unknown").unwrap(), TaskFailureType::Unknown); - assert_eq!(TaskFailureType::from_str("rule_bans_user_image").unwrap(), TaskFailureType::RuleBansUserImage); - assert_eq!(TaskFailureType::from_str("rule_bans_user_image_with_faces").unwrap(), TaskFailureType::RuleBansUserImageWithFaces); - assert_eq!(TaskFailureType::from_str("rule_bans_user_text_prompt").unwrap(), TaskFailureType::RuleBansUserTextPrompt); - assert_eq!(TaskFailureType::from_str("rule_bans_user_content").unwrap(), TaskFailureType::RuleBansUserContent); - assert_eq!(TaskFailureType::from_str("rule_bans_generated_video").unwrap(), TaskFailureType::RuleBansGeneratedVideo); - assert_eq!(TaskFailureType::from_str("rule_bans_generated_audio").unwrap(), TaskFailureType::RuleBansGeneratedAudio); - assert_eq!(TaskFailureType::from_str("rule_bans_generated_content").unwrap(), TaskFailureType::RuleBansGeneratedContent); - assert_eq!(TaskFailureType::from_str("no_foreground_subject_detected").unwrap(), TaskFailureType::NoForegroundSubjectDetected); - assert_eq!(TaskFailureType::from_str("format_not_supported").unwrap(), TaskFailureType::FormatNotSupported); - assert_eq!(TaskFailureType::from_str("generation_failed").unwrap(), TaskFailureType::GenerationFailed); - } - - #[test] - fn from_str_err() { - let result = TaskFailureType::from_str("asdf"); - assert!(result.is_err()); - if let Err(EnumError::CouldNotConvertFromString(value)) = result { - assert_eq!(value, "asdf"); - } else { - panic!("Expected EnumError::CouldNotConvertFromString"); - } - } - - #[test] - fn all_variants() { - let mut variants = TaskFailureType::all_variants(); - assert_eq!(variants.len(), 11); - assert_eq!(variants.pop_first(), Some(TaskFailureType::Unknown)); - assert_eq!(variants.pop_first(), Some(TaskFailureType::RuleBansUserImage)); - assert_eq!(variants.pop_first(), Some(TaskFailureType::RuleBansUserImageWithFaces)); - assert_eq!(variants.pop_first(), Some(TaskFailureType::RuleBansUserTextPrompt)); - assert_eq!(variants.pop_first(), Some(TaskFailureType::RuleBansUserContent)); - assert_eq!(variants.pop_first(), Some(TaskFailureType::RuleBansGeneratedVideo)); - assert_eq!(variants.pop_first(), Some(TaskFailureType::RuleBansGeneratedAudio)); - assert_eq!(variants.pop_first(), Some(TaskFailureType::RuleBansGeneratedContent)); - assert_eq!(variants.pop_first(), Some(TaskFailureType::NoForegroundSubjectDetected)); - assert_eq!(variants.pop_first(), Some(TaskFailureType::FormatNotSupported)); - assert_eq!(variants.pop_first(), Some(TaskFailureType::GenerationFailed)); - assert_eq!(variants.pop_first(), None); - } - } - - mod mechanical_checks { - use super::*; - - #[test] - fn variant_length() { - use strum::IntoEnumIterator; - assert_eq!(TaskFailureType::all_variants().len(), TaskFailureType::iter().len()); - } - - #[test] - fn round_trip() { - for variant in TaskFailureType::all_variants() { - assert_eq!(variant, TaskFailureType::from_str(variant.to_str()).unwrap()); - assert_eq!(variant, TaskFailureType::from_str(&format!("{}", variant)).unwrap()); - assert_eq!(variant, TaskFailureType::from_str(&format!("{:?}", variant)).unwrap()); - } - } - } -} diff --git a/crates/schema/public/enums/src/tauri/tasks/task_media_file_class.rs b/crates/schema/public/enums/src/tauri/tasks/task_media_file_class.rs deleted file mode 100644 index 3f6515915b..0000000000 --- a/crates/schema/public/enums/src/tauri/tasks/task_media_file_class.rs +++ /dev/null @@ -1,140 +0,0 @@ -use std::collections::BTreeSet; - -use crate::error::enum_error::EnumError; -#[cfg(test)] -use strum::EnumCount; -#[cfg(test)] -use strum::EnumIter; -use utoipa::ToSchema; - -#[cfg_attr(test, derive(EnumIter, EnumCount))] -#[derive(Clone, Copy, PartialEq, Eq, Hash, Ord, PartialOrd, Serialize, Deserialize, ToSchema)] -#[serde(rename_all = "snake_case")] -pub enum TaskMediaFileClass { - /// Audio files: wav, mp3, etc. - Audio, - - /// Image files: png, jpeg, etc. - Image, - - /// Video files: mp4, etc. - Video, - - /// 3D engine data: glb, gltf, etc. - Dimensional, -} - -impl_enum_display_and_debug_using_to_str!(TaskMediaFileClass); -//impl_mysql_enum_coders!(TaskMediaFileType); -//impl_mysql_from_row!(TaskMediaFileType); - -// NB: We can derive `sqlx::Type` instead of using `impl_mysql_enum_coders` - -impl TaskMediaFileClass { - pub fn to_str(&self) -> &'static str { - match self { - Self::Audio => "audio", - Self::Image => "image", - Self::Video => "video", - Self::Dimensional => "dimensional", - } - } - - pub fn from_str(value: &str) -> Result { - match value { - "audio" => Ok(Self::Audio), - "image" => Ok(Self::Image), - "video" => Ok(Self::Video), - "dimensional" => Ok(Self::Dimensional), - _ => Err(EnumError::CouldNotConvertFromString(value.to_string())), - } - } - - pub fn all_variants() -> BTreeSet { - // NB: BTreeSet is sorted - // NB: BTreeSet::from() isn't const, but not worth using LazyStatic, etc. - BTreeSet::from([ - Self::Audio, - Self::Image, - Self::Video, - Self::Dimensional, - ]) - } -} - -#[cfg(test)] -mod tests { - use crate::tauri::tasks::task_media_file_class::TaskMediaFileClass; - use crate::test_helpers::assert_serialization; - - mod explicit_checks { - use super::*; - use crate::error::enum_error::EnumError; - - #[test] - fn test_serialization() { - assert_serialization(TaskMediaFileClass::Audio, "audio"); - assert_serialization(TaskMediaFileClass::Image, "image"); - assert_serialization(TaskMediaFileClass::Video, "video"); - assert_serialization(TaskMediaFileClass::Dimensional, "dimensional"); - } - - #[test] - fn to_str() { - assert_eq!(TaskMediaFileClass::Audio.to_str(), "audio"); - assert_eq!(TaskMediaFileClass::Image.to_str(), "image"); - assert_eq!(TaskMediaFileClass::Video.to_str(), "video"); - assert_eq!(TaskMediaFileClass::Dimensional.to_str(), "dimensional"); - } - - #[test] - fn from_str() { - assert_eq!(TaskMediaFileClass::from_str("audio").unwrap(), TaskMediaFileClass::Audio); - assert_eq!(TaskMediaFileClass::from_str("image").unwrap(), TaskMediaFileClass::Image); - assert_eq!(TaskMediaFileClass::from_str("video").unwrap(), TaskMediaFileClass::Video); - assert_eq!(TaskMediaFileClass::from_str("dimensional").unwrap(), TaskMediaFileClass::Dimensional); - } - - #[test] - fn from_str_err() { - let result = TaskMediaFileClass::from_str("asdf"); - assert!(result.is_err()); - if let Err(EnumError::CouldNotConvertFromString(value)) = result { - assert_eq!(value, "asdf"); - } else { - panic!("Expected EnumError::CouldNotConvertFromString"); - } - } - - #[test] - fn all_variants() { - let mut variants = TaskMediaFileClass::all_variants(); - assert_eq!(variants.len(), 4); - assert_eq!(variants.pop_first(), Some(TaskMediaFileClass::Audio)); - assert_eq!(variants.pop_first(), Some(TaskMediaFileClass::Image)); - assert_eq!(variants.pop_first(), Some(TaskMediaFileClass::Video)); - assert_eq!(variants.pop_first(), Some(TaskMediaFileClass::Dimensional)); - assert_eq!(variants.pop_first(), None); - } - } - - mod mechanical_checks { - use super::*; - - #[test] - fn variant_length() { - use strum::IntoEnumIterator; - assert_eq!(TaskMediaFileClass::all_variants().len(), TaskMediaFileClass::iter().len()); - } - - #[test] - fn round_trip() { - for variant in TaskMediaFileClass::all_variants() { - // Test to_str(), from_str(), Display, and Debug. - assert_eq!(variant, TaskMediaFileClass::from_str(variant.to_str()).unwrap()); - assert_eq!(variant, TaskMediaFileClass::from_str(&format!("{}", variant)).unwrap()); - assert_eq!(variant, TaskMediaFileClass::from_str(&format!("{:?}", variant)).unwrap()); - } - } - } -} diff --git a/crates/schema/public/enums/src/tauri/tasks/task_model_type.rs b/crates/schema/public/enums/src/tauri/tasks/task_model_type.rs deleted file mode 100644 index 7a948839fd..0000000000 --- a/crates/schema/public/enums/src/tauri/tasks/task_model_type.rs +++ /dev/null @@ -1,622 +0,0 @@ -use std::collections::BTreeSet; - -use crate::error::enum_error::EnumError; -#[cfg(test)] -use strum::EnumCount; -#[cfg(test)] -use strum::EnumIter; -use utoipa::ToSchema; - -#[cfg_attr(test, derive(EnumIter, EnumCount))] -#[derive(Clone, PartialEq, Eq, Hash, Ord, PartialOrd, Serialize, Deserialize, ToSchema)] -#[serde(rename_all = "snake_case")] -pub enum TaskModelType { - // Image models - #[serde(rename = "flux_1_dev")] - Flux1Dev, - #[serde(rename = "flux_1_schnell")] - Flux1Schnell, - #[serde(rename = "flux_dev_juggernaut")] - FluxDevJuggernaut, - // NB: For inpainting for now - #[serde(rename = "flux_pro_1")] - FluxPro1, - #[serde(rename = "flux_pro_1.1")] - FluxPro11, - #[serde(rename = "flux_pro_1.1_ultra")] - FluxPro11Ultra, - #[serde(rename = "flux_pro_kontext_max")] - FluxProKontextMax, - #[serde(rename = "gemini_25_flash")] - Gemini25Flash, - #[serde(rename = "nano_banana")] - NanoBanana, - #[serde(rename = "nano_banana_2")] - NanoBanana2, - #[serde(rename = "nano_banana_pro")] - NanoBananaPro, - #[serde(rename = "gpt_image_1")] - GptImage1, - #[serde(rename = "gpt_image_1p5")] - GptImage1p5, - #[serde(rename = "gpt_image_2")] - GptImage2, - #[serde(rename = "gpt_image_2p5_flare")] - GptImage2p5Flare, - #[serde(rename = "gpt_image_2p5_sunburst")] - GptImage2p5Sunburst, - #[serde(rename = "seedream_4")] - Seedream4, - #[serde(rename = "seedream_4p5")] - Seedream4p5, - #[serde(rename = "seedream_5_lite")] - Seedream5Lite, - #[serde(rename = "qwen_edit_2511_angles")] - QwenEdit2511Angles, - #[serde(rename = "flux_2_lora_angles")] - Flux2LoraAngles, - #[serde(rename = "grok_image")] - GrokImage, - #[serde(rename = "recraft_3")] - Recraft3, - - // Generic Midjourney model, version unknown. - #[serde(rename = "midjourney")] - Midjourney, - #[serde(rename = "midjourney_7")] - Midjourney7, - #[serde(rename = "midjourney_7_niji")] - Midjourney7Niji, - #[serde(rename = "midjourney_8")] - Midjourney8, - - // Video models - #[serde(rename = "grok_video")] - GrokVideo, // Video version unspecified/unknown - #[serde(rename = "grok_imagine_video_1p5")] - GrokImagineVideo1p5, - #[serde(rename = "kling_1.6_pro")] - Kling16Pro, - #[serde(rename = "kling_2.1_pro")] - Kling21Pro, - #[serde(rename = "kling_2.1_master")] - Kling21Master, - #[serde(rename = "kling_2p5_turbo_pro")] - Kling2p5TurboPro, - #[serde(rename = "kling_2p6_pro")] - Kling2p6Pro, - #[serde(rename = "kling_3p0_standard")] - Kling3p0Standard, - #[serde(rename = "kling_3p0_pro")] - Kling3p0Pro, - #[serde(rename = "happy_horse_1p0")] - HappyHorse1p0, - #[serde(rename = "seedance_1.0_lite")] - Seedance10Lite, - #[serde(rename = "seedance_1p5_pro")] - Seedance1p5Pro, - #[serde(rename = "seedance_2p0")] - Seedance2p0, - #[serde(rename = "seedance_2p0_fast")] - Seedance2p0Fast, - #[serde(rename = "sora_2")] - Sora2, - #[serde(rename = "sora_2_pro")] - Sora2Pro, - #[serde(rename = "veo_2")] - Veo2, - #[serde(rename = "veo_3")] - Veo3, - #[serde(rename = "veo_3_fast")] - Veo3Fast, - #[serde(rename = "veo_3p1")] - Veo3p1, - #[serde(rename = "veo_3p1_fast")] - Veo3p1Fast, - - // 3D Object generation models - #[serde(rename = "hunyuan_3d_2.0")] - Hunyuan3d2_0, - #[serde(rename = "hunyuan_3d_2.1")] - Hunyuan3d2_1, - #[serde(rename = "hunyuan_3d_3")] - Hunyuan3d3, - #[serde(rename = "worldlabs_marble")] - WorldlabsMarble, - #[serde(rename = "marble_0p1_mini")] - WorldlabsMarble0p1Mini, - #[serde(rename = "marble_0p1_plus")] - WorldlabsMarble0p1Plus, - - /// Preserve catalog IDs introduced after this desktop build. - #[serde(untagged)] - #[cfg_attr(test, strum(disabled))] - Unknown(String), -} - -impl_enum_display_and_debug_using_to_str!(TaskModelType); -//impl_mysql_enum_coders!(TaskModelType); -//impl_mysql_from_row!(TaskModelType); - -// NB: We can derive `sqlx::Type` instead of using `impl_mysql_enum_coders` - -impl TaskModelType { - pub fn to_str(&self) -> &str { - match self { - Self::Unknown(value) => value, - // Image models - Self::Flux1Dev => "flux_1_dev", - Self::Flux1Schnell => "flux_1_schnell", - Self::FluxDevJuggernaut => "flux_dev_juggernaut", - Self::FluxPro1 => "flux_pro_1", - Self::FluxPro11 => "flux_pro_1.1", - Self::FluxPro11Ultra => "flux_pro_1.1_ultra", - Self::FluxProKontextMax => "flux_pro_kontext_max", - Self::Gemini25Flash => "gemini_25_flash", - Self::NanoBanana => "nano_banana", - Self::NanoBanana2 => "nano_banana_2", - Self::NanoBananaPro => "nano_banana_pro", - Self::GptImage1 => "gpt_image_1", - Self::GptImage1p5 => "gpt_image_1p5", - Self::GptImage2 => "gpt_image_2", - Self::GptImage2p5Flare => "gpt_image_2p5_flare", - Self::GptImage2p5Sunburst => "gpt_image_2p5_sunburst", - Self::Seedream4 => "seedream_4", - Self::Seedream4p5 => "seedream_4p5", - Self::Seedream5Lite => "seedream_5_lite", - Self::QwenEdit2511Angles => "qwen_edit_2511_angles", - Self::Flux2LoraAngles => "flux_2_lora_angles", - Self::GrokImage => "grok_image", - Self::Recraft3 => "recraft_3", - Self::Midjourney => "midjourney", - Self::Midjourney7 => "midjourney_7", - Self::Midjourney7Niji => "midjourney_7_niji", - Self::Midjourney8 => "midjourney_8", - // Video models - Self::GrokVideo => "grok_video", - Self::GrokImagineVideo1p5 => "grok_imagine_video_1p5", - Self::Kling16Pro => "kling_1.6_pro", - Self::Kling21Pro => "kling_2.1_pro", - Self::Kling21Master => "kling_2.1_master", - Self::Kling2p5TurboPro => "kling_2p5_turbo_pro", - Self::Kling2p6Pro => "kling_2p6_pro", - Self::Kling3p0Standard => "kling_3p0_standard", - Self::Kling3p0Pro => "kling_3p0_pro", - Self::HappyHorse1p0 => "happy_horse_1p0", - Self::Seedance10Lite => "seedance_1.0_lite", - Self::Seedance1p5Pro => "seedance_1p5_pro", - Self::Seedance2p0 => "seedance_2p0", - Self::Seedance2p0Fast => "seedance_2p0_fast", - Self::Sora2 => "sora_2", - Self::Sora2Pro => "sora_2_pro", - Self::Veo2 => "veo_2", - Self::Veo3 => "veo_3", - Self::Veo3Fast => "veo_3_fast", - Self::Veo3p1 => "veo_3p1", - Self::Veo3p1Fast => "veo_3p1_fast", - // 3D Object generation models - Self::Hunyuan3d2_0 => "hunyuan_3d_2.0", - Self::Hunyuan3d2_1 => "hunyuan_3d_2.1", - Self::Hunyuan3d3 => "hunyuan_3d_3", - Self::WorldlabsMarble => "worldlabs_marble", - Self::WorldlabsMarble0p1Mini => "marble_0p1_mini", - Self::WorldlabsMarble0p1Plus => "marble_0p1_plus", - } - } - - pub fn from_str(value: &str) -> Result { - match value { - // Image models - "flux_1_dev" => Ok(Self::Flux1Dev), - "flux_1_schnell" => Ok(Self::Flux1Schnell), - "flux_dev_juggernaut" => Ok(Self::FluxDevJuggernaut), - "flux_pro_1" => Ok(Self::FluxPro1), - "flux_pro_1.1" => Ok(Self::FluxPro11), - "flux_pro_1.1_ultra" => Ok(Self::FluxPro11Ultra), - "flux_pro_kontext_max" => Ok(Self::FluxProKontextMax), - "gemini_25_flash" => Ok(Self::Gemini25Flash), - "nano_banana" => Ok(Self::NanoBanana), - "nano_banana_2" => Ok(Self::NanoBanana2), - "nano_banana_pro" => Ok(Self::NanoBananaPro), - "gpt_image_1" => Ok(Self::GptImage1), - "gpt_image_1p5" => Ok(Self::GptImage1p5), - "gpt_image_2" => Ok(Self::GptImage2), - "gpt_image_2p5_flare" => Ok(Self::GptImage2p5Flare), - "gpt_image_2p5_sunburst" => Ok(Self::GptImage2p5Sunburst), - "seedream_4" => Ok(Self::Seedream4), - "seedream_4p5" => Ok(Self::Seedream4p5), - "seedream_5_lite" => Ok(Self::Seedream5Lite), - "qwen_edit_2511_angles" => Ok(Self::QwenEdit2511Angles), - "flux_2_lora_angles" => Ok(Self::Flux2LoraAngles), - "grok_image" => Ok(Self::GrokImage), - "recraft_3" => Ok(Self::Recraft3), - "midjourney" => Ok(Self::Midjourney), - "midjourney_7" => Ok(Self::Midjourney7), - "midjourney_7_niji" => Ok(Self::Midjourney7Niji), - "midjourney_8" => Ok(Self::Midjourney8), - // Video models - "grok_video" => Ok(Self::GrokVideo), - "grok_imagine_video_1p5" => Ok(Self::GrokImagineVideo1p5), - "kling_1.6_pro" => Ok(Self::Kling16Pro), - "kling_2.1_pro" => Ok(Self::Kling21Pro), - "kling_2.1_master" => Ok(Self::Kling21Master), - "kling_2p5_turbo_pro" => Ok(Self::Kling2p5TurboPro), - "kling_2p6_pro" => Ok(Self::Kling2p6Pro), - "kling_3p0_standard" => Ok(Self::Kling3p0Standard), - "kling_3p0_pro" => Ok(Self::Kling3p0Pro), - "happy_horse_1p0" => Ok(Self::HappyHorse1p0), - "seedance_1.0_lite" => Ok(Self::Seedance10Lite), - "seedance_1p5_pro" => Ok(Self::Seedance1p5Pro), - "seedance_2p0" => Ok(Self::Seedance2p0), - "seedance_2p0_fast" => Ok(Self::Seedance2p0Fast), - "sora_2" => Ok(Self::Sora2), - "sora_2_pro" => Ok(Self::Sora2Pro), - "veo_2" => Ok(Self::Veo2), - "veo_3" => Ok(Self::Veo3), - "veo_3_fast" => Ok(Self::Veo3Fast), - "veo_3p1" => Ok(Self::Veo3p1), - "veo_3p1_fast" => Ok(Self::Veo3p1Fast), - // 3D Object generation models - "hunyuan_3d_2.0" => Ok(Self::Hunyuan3d2_0), - "hunyuan_3d_2.1" => Ok(Self::Hunyuan3d2_1), - "hunyuan_3d_3" => Ok(Self::Hunyuan3d3), - "worldlabs_marble" => Ok(Self::WorldlabsMarble), - "marble_0p1_mini" => Ok(Self::WorldlabsMarble0p1Mini), - "marble_0p1_plus" => Ok(Self::WorldlabsMarble0p1Plus), - _ => Ok(Self::Unknown(value.to_owned())), - } - } - - pub fn all_variants() -> BTreeSet { - // NB: BTreeSet is sorted - // NB: BTreeSet::from() isn't const, but not worth using LazyStatic, etc. - BTreeSet::from([ - // Image models - Self::Flux1Dev, - Self::Flux1Schnell, - Self::FluxDevJuggernaut, - Self::FluxPro1, - Self::FluxPro11, - Self::FluxPro11Ultra, - Self::FluxProKontextMax, - Self::Gemini25Flash, - Self::NanoBanana, - Self::NanoBanana2, - Self::NanoBananaPro, - Self::GptImage1, - Self::GptImage1p5, - Self::GptImage2, - Self::GptImage2p5Flare, - Self::GptImage2p5Sunburst, - Self::Seedream4, - Self::Seedream4p5, - Self::Seedream5Lite, - Self::QwenEdit2511Angles, - Self::Flux2LoraAngles, - Self::GrokImage, - Self::Recraft3, - Self::Midjourney, - Self::Midjourney7, - Self::Midjourney7Niji, - Self::Midjourney8, - // Video models - Self::GrokVideo, - Self::GrokImagineVideo1p5, - Self::Kling16Pro, - Self::Kling21Pro, - Self::Kling21Master, - Self::Kling2p5TurboPro, - Self::Kling2p6Pro, - Self::Kling3p0Standard, - Self::Kling3p0Pro, - Self::HappyHorse1p0, - Self::Seedance10Lite, - Self::Seedance1p5Pro, - Self::Seedance2p0, - Self::Seedance2p0Fast, - Self::Sora2, - Self::Sora2Pro, - Self::Veo2, - Self::Veo3, - Self::Veo3Fast, - Self::Veo3p1, - Self::Veo3p1Fast, - // 3D Object generation models - Self::Hunyuan3d2_0, - Self::Hunyuan3d2_1, - Self::Hunyuan3d3, - Self::WorldlabsMarble, - Self::WorldlabsMarble0p1Mini, - Self::WorldlabsMarble0p1Plus, - ]) - } -} - -#[cfg(test)] -mod tests { - use crate::tauri::tasks::task_model_type::TaskModelType; - use crate::test_helpers::assert_serialization; - - mod explicit_checks { - use super::*; - - #[test] - fn test_serialization() { - // Image models - assert_serialization(TaskModelType::Flux1Dev, "flux_1_dev"); - assert_serialization(TaskModelType::Flux1Schnell, "flux_1_schnell"); - assert_serialization(TaskModelType::FluxDevJuggernaut, "flux_dev_juggernaut"); - assert_serialization(TaskModelType::FluxPro1, "flux_pro_1"); - assert_serialization(TaskModelType::FluxPro11, "flux_pro_1.1"); - assert_serialization(TaskModelType::FluxPro11Ultra, "flux_pro_1.1_ultra"); - assert_serialization(TaskModelType::FluxProKontextMax, "flux_pro_kontext_max"); - assert_serialization(TaskModelType::Gemini25Flash, "gemini_25_flash"); - assert_serialization(TaskModelType::NanoBanana, "nano_banana"); - assert_serialization(TaskModelType::NanoBanana2, "nano_banana_2"); - assert_serialization(TaskModelType::NanoBananaPro, "nano_banana_pro"); - assert_serialization(TaskModelType::GptImage1, "gpt_image_1"); - assert_serialization(TaskModelType::GptImage1p5, "gpt_image_1p5"); - assert_serialization(TaskModelType::GptImage2, "gpt_image_2"); - assert_serialization(TaskModelType::GptImage2p5Flare, "gpt_image_2p5_flare"); - assert_serialization(TaskModelType::GptImage2p5Sunburst, "gpt_image_2p5_sunburst"); - assert_serialization(TaskModelType::Seedream4, "seedream_4"); - assert_serialization(TaskModelType::Seedream4p5, "seedream_4p5"); - assert_serialization(TaskModelType::Seedream5Lite, "seedream_5_lite"); - assert_serialization(TaskModelType::QwenEdit2511Angles, "qwen_edit_2511_angles"); - assert_serialization(TaskModelType::Flux2LoraAngles, "flux_2_lora_angles"); - assert_serialization(TaskModelType::GrokImage, "grok_image"); - assert_serialization(TaskModelType::Recraft3, "recraft_3"); - assert_serialization(TaskModelType::Midjourney, "midjourney"); - // Video models - assert_serialization(TaskModelType::Midjourney7, "midjourney_7"); - assert_serialization(TaskModelType::Midjourney7Niji, "midjourney_7_niji"); - assert_serialization(TaskModelType::Midjourney8, "midjourney_8"); - assert_serialization(TaskModelType::GrokVideo, "grok_video"); - assert_serialization(TaskModelType::GrokImagineVideo1p5, "grok_imagine_video_1p5"); - assert_serialization(TaskModelType::Kling16Pro, "kling_1.6_pro"); - assert_serialization(TaskModelType::Kling21Pro, "kling_2.1_pro"); - assert_serialization(TaskModelType::Kling21Master, "kling_2.1_master"); - assert_serialization(TaskModelType::Kling2p5TurboPro, "kling_2p5_turbo_pro"); - assert_serialization(TaskModelType::Kling2p6Pro, "kling_2p6_pro"); - assert_serialization(TaskModelType::Kling3p0Standard, "kling_3p0_standard"); - assert_serialization(TaskModelType::Kling3p0Pro, "kling_3p0_pro"); - assert_serialization(TaskModelType::HappyHorse1p0, "happy_horse_1p0"); - assert_serialization(TaskModelType::Seedance10Lite, "seedance_1.0_lite"); - assert_serialization(TaskModelType::Seedance1p5Pro, "seedance_1p5_pro"); - assert_serialization(TaskModelType::Seedance2p0, "seedance_2p0"); - assert_serialization(TaskModelType::Seedance2p0Fast, "seedance_2p0_fast"); - assert_serialization(TaskModelType::Sora2, "sora_2"); - assert_serialization(TaskModelType::Sora2Pro, "sora_2_pro"); - assert_serialization(TaskModelType::Veo2, "veo_2"); - assert_serialization(TaskModelType::Veo3, "veo_3"); - assert_serialization(TaskModelType::Veo3Fast, "veo_3_fast"); - assert_serialization(TaskModelType::Veo3p1, "veo_3p1"); - assert_serialization(TaskModelType::Veo3p1Fast, "veo_3p1_fast"); - // 3D Object generation models - assert_serialization(TaskModelType::Hunyuan3d2_0, "hunyuan_3d_2.0"); - assert_serialization(TaskModelType::Hunyuan3d2_1, "hunyuan_3d_2.1"); - assert_serialization(TaskModelType::Hunyuan3d3, "hunyuan_3d_3"); - assert_serialization(TaskModelType::WorldlabsMarble, "worldlabs_marble"); - assert_serialization(TaskModelType::WorldlabsMarble0p1Mini, "marble_0p1_mini"); - assert_serialization(TaskModelType::WorldlabsMarble0p1Plus, "marble_0p1_plus"); - } - - #[test] - fn to_str() { - // Image models - assert_eq!(TaskModelType::Flux1Dev.to_str(), "flux_1_dev"); - assert_eq!(TaskModelType::Flux1Schnell.to_str(), "flux_1_schnell"); - assert_eq!(TaskModelType::FluxDevJuggernaut.to_str(), "flux_dev_juggernaut"); - assert_eq!(TaskModelType::FluxPro1.to_str(), "flux_pro_1"); - assert_eq!(TaskModelType::FluxPro11.to_str(), "flux_pro_1.1"); - assert_eq!(TaskModelType::FluxPro11Ultra.to_str(), "flux_pro_1.1_ultra"); - assert_eq!(TaskModelType::FluxProKontextMax.to_str(), "flux_pro_kontext_max"); - assert_eq!(TaskModelType::Gemini25Flash.to_str(), "gemini_25_flash"); - assert_eq!(TaskModelType::NanoBanana.to_str(), "nano_banana"); - assert_eq!(TaskModelType::NanoBanana2.to_str(), "nano_banana_2"); - assert_eq!(TaskModelType::NanoBananaPro.to_str(), "nano_banana_pro"); - assert_eq!(TaskModelType::GptImage1.to_str(), "gpt_image_1"); - assert_eq!(TaskModelType::GptImage1p5.to_str(), "gpt_image_1p5"); - assert_eq!(TaskModelType::GptImage2.to_str(), "gpt_image_2"); - assert_eq!(TaskModelType::GptImage2p5Flare.to_str(), "gpt_image_2p5_flare"); - assert_eq!(TaskModelType::GptImage2p5Sunburst.to_str(), "gpt_image_2p5_sunburst"); - assert_eq!(TaskModelType::Seedream4.to_str(), "seedream_4"); - assert_eq!(TaskModelType::Seedream4p5.to_str(), "seedream_4p5"); - assert_eq!(TaskModelType::Seedream5Lite.to_str(), "seedream_5_lite"); - assert_eq!(TaskModelType::QwenEdit2511Angles.to_str(), "qwen_edit_2511_angles"); - assert_eq!(TaskModelType::Flux2LoraAngles.to_str(), "flux_2_lora_angles"); - assert_eq!(TaskModelType::GrokImage.to_str(), "grok_image"); - assert_eq!(TaskModelType::Recraft3.to_str(), "recraft_3"); - assert_eq!(TaskModelType::Midjourney.to_str(), "midjourney"); - // Video models - assert_eq!(TaskModelType::GrokVideo.to_str(), "grok_video"); - assert_eq!(TaskModelType::GrokImagineVideo1p5.to_str(), "grok_imagine_video_1p5"); - assert_eq!(TaskModelType::Kling16Pro.to_str(), "kling_1.6_pro"); - assert_eq!(TaskModelType::Kling21Pro.to_str(), "kling_2.1_pro"); - assert_eq!(TaskModelType::Kling21Master.to_str(), "kling_2.1_master"); - assert_eq!(TaskModelType::Kling2p5TurboPro.to_str(), "kling_2p5_turbo_pro"); - assert_eq!(TaskModelType::Kling2p6Pro.to_str(), "kling_2p6_pro"); - assert_eq!(TaskModelType::Kling3p0Standard.to_str(), "kling_3p0_standard"); - assert_eq!(TaskModelType::Kling3p0Pro.to_str(), "kling_3p0_pro"); - assert_eq!(TaskModelType::HappyHorse1p0.to_str(), "happy_horse_1p0"); - assert_eq!(TaskModelType::Seedance10Lite.to_str(), "seedance_1.0_lite"); - assert_eq!(TaskModelType::Seedance1p5Pro.to_str(), "seedance_1p5_pro"); - assert_eq!(TaskModelType::Seedance2p0.to_str(), "seedance_2p0"); - assert_eq!(TaskModelType::Seedance2p0Fast.to_str(), "seedance_2p0_fast"); - assert_eq!(TaskModelType::Sora2.to_str(), "sora_2"); - assert_eq!(TaskModelType::Sora2Pro.to_str(), "sora_2_pro"); - assert_eq!(TaskModelType::Veo2.to_str(), "veo_2"); - assert_eq!(TaskModelType::Veo3.to_str(), "veo_3"); - assert_eq!(TaskModelType::Veo3Fast.to_str(), "veo_3_fast"); - assert_eq!(TaskModelType::Veo3p1.to_str(), "veo_3p1"); - assert_eq!(TaskModelType::Veo3p1Fast.to_str(), "veo_3p1_fast"); - // 3D Object generation models - assert_eq!(TaskModelType::Hunyuan3d2_0.to_str(), "hunyuan_3d_2.0"); - assert_eq!(TaskModelType::Hunyuan3d2_1.to_str(), "hunyuan_3d_2.1"); - assert_eq!(TaskModelType::Hunyuan3d3.to_str(), "hunyuan_3d_3"); - assert_eq!(TaskModelType::WorldlabsMarble.to_str(), "worldlabs_marble"); - assert_eq!(TaskModelType::WorldlabsMarble0p1Mini.to_str(), "marble_0p1_mini"); - assert_eq!(TaskModelType::WorldlabsMarble0p1Plus.to_str(), "marble_0p1_plus"); - } - - #[test] - fn from_str() { - // Image models - assert_eq!(TaskModelType::from_str("flux_1_dev").unwrap(), TaskModelType::Flux1Dev); - assert_eq!(TaskModelType::from_str("flux_1_schnell").unwrap(), TaskModelType::Flux1Schnell); - assert_eq!(TaskModelType::from_str("flux_dev_juggernaut").unwrap(), TaskModelType::FluxDevJuggernaut); - assert_eq!(TaskModelType::from_str("flux_pro_1").unwrap(), TaskModelType::FluxPro1); - assert_eq!(TaskModelType::from_str("flux_pro_1.1").unwrap(), TaskModelType::FluxPro11); - assert_eq!(TaskModelType::from_str("flux_pro_1.1_ultra").unwrap(), TaskModelType::FluxPro11Ultra); - assert_eq!(TaskModelType::from_str("flux_pro_kontext_max").unwrap(), TaskModelType::FluxProKontextMax); - assert_eq!(TaskModelType::from_str("gemini_25_flash").unwrap(), TaskModelType::Gemini25Flash); - assert_eq!(TaskModelType::from_str("nano_banana").unwrap(), TaskModelType::NanoBanana); - assert_eq!(TaskModelType::from_str("nano_banana_2").unwrap(), TaskModelType::NanoBanana2); - assert_eq!(TaskModelType::from_str("nano_banana_pro").unwrap(), TaskModelType::NanoBananaPro); - assert_eq!(TaskModelType::from_str("gpt_image_1").unwrap(), TaskModelType::GptImage1); - assert_eq!(TaskModelType::from_str("gpt_image_1p5").unwrap(), TaskModelType::GptImage1p5); - assert_eq!(TaskModelType::from_str("gpt_image_2").unwrap(), TaskModelType::GptImage2); - assert_eq!(TaskModelType::from_str("gpt_image_2p5_flare").unwrap(), TaskModelType::GptImage2p5Flare); - assert_eq!(TaskModelType::from_str("gpt_image_2p5_sunburst").unwrap(), TaskModelType::GptImage2p5Sunburst); - assert_eq!(TaskModelType::from_str("seedream_4").unwrap(), TaskModelType::Seedream4); - assert_eq!(TaskModelType::from_str("seedream_4p5").unwrap(), TaskModelType::Seedream4p5); - assert_eq!(TaskModelType::from_str("seedream_5_lite").unwrap(), TaskModelType::Seedream5Lite); - assert_eq!(TaskModelType::from_str("qwen_edit_2511_angles").unwrap(), TaskModelType::QwenEdit2511Angles); - assert_eq!(TaskModelType::from_str("flux_2_lora_angles").unwrap(), TaskModelType::Flux2LoraAngles); - assert_eq!(TaskModelType::from_str("grok_image").unwrap(), TaskModelType::GrokImage); - assert_eq!(TaskModelType::from_str("recraft_3").unwrap(), TaskModelType::Recraft3); - assert_eq!(TaskModelType::from_str("midjourney").unwrap(), TaskModelType::Midjourney); - // Video models - assert_eq!(TaskModelType::from_str("grok_video").unwrap(), TaskModelType::GrokVideo); - assert_eq!(TaskModelType::from_str("grok_imagine_video_1p5").unwrap(), TaskModelType::GrokImagineVideo1p5); - assert_eq!(TaskModelType::from_str("kling_1.6_pro").unwrap(), TaskModelType::Kling16Pro); - assert_eq!(TaskModelType::from_str("kling_2.1_pro").unwrap(), TaskModelType::Kling21Pro); - assert_eq!(TaskModelType::from_str("kling_2.1_master").unwrap(), TaskModelType::Kling21Master); - assert_eq!(TaskModelType::from_str("kling_2p5_turbo_pro").unwrap(), TaskModelType::Kling2p5TurboPro); - assert_eq!(TaskModelType::from_str("kling_2p6_pro").unwrap(), TaskModelType::Kling2p6Pro); - assert_eq!(TaskModelType::from_str("kling_3p0_standard").unwrap(), TaskModelType::Kling3p0Standard); - assert_eq!(TaskModelType::from_str("kling_3p0_pro").unwrap(), TaskModelType::Kling3p0Pro); - assert_eq!(TaskModelType::from_str("happy_horse_1p0").unwrap(), TaskModelType::HappyHorse1p0); - assert_eq!(TaskModelType::from_str("seedance_1.0_lite").unwrap(), TaskModelType::Seedance10Lite); - assert_eq!(TaskModelType::from_str("seedance_1p5_pro").unwrap(), TaskModelType::Seedance1p5Pro); - assert_eq!(TaskModelType::from_str("seedance_2p0").unwrap(), TaskModelType::Seedance2p0); - assert_eq!(TaskModelType::from_str("seedance_2p0_fast").unwrap(), TaskModelType::Seedance2p0Fast); - assert_eq!(TaskModelType::from_str("sora_2").unwrap(), TaskModelType::Sora2); - assert_eq!(TaskModelType::from_str("sora_2_pro").unwrap(), TaskModelType::Sora2Pro); - assert_eq!(TaskModelType::from_str("veo_2").unwrap(), TaskModelType::Veo2); - assert_eq!(TaskModelType::from_str("veo_3").unwrap(), TaskModelType::Veo3); - assert_eq!(TaskModelType::from_str("veo_3_fast").unwrap(), TaskModelType::Veo3Fast); - assert_eq!(TaskModelType::from_str("veo_3p1").unwrap(), TaskModelType::Veo3p1); - assert_eq!(TaskModelType::from_str("veo_3p1_fast").unwrap(), TaskModelType::Veo3p1Fast); - // 3D Object generation models - assert_eq!(TaskModelType::from_str("hunyuan_3d_2.0").unwrap(), TaskModelType::Hunyuan3d2_0); - assert_eq!(TaskModelType::from_str("hunyuan_3d_2.1").unwrap(), TaskModelType::Hunyuan3d2_1); - assert_eq!(TaskModelType::from_str("hunyuan_3d_3").unwrap(), TaskModelType::Hunyuan3d3); - assert_eq!(TaskModelType::from_str("worldlabs_marble").unwrap(), TaskModelType::WorldlabsMarble); - assert_eq!(TaskModelType::from_str("marble_0p1_mini").unwrap(), TaskModelType::WorldlabsMarble0p1Mini); - assert_eq!(TaskModelType::from_str("marble_0p1_plus").unwrap(), TaskModelType::WorldlabsMarble0p1Plus); - } - - #[test] - fn unknown_catalog_id_round_trips() { - let model = TaskModelType::from_str("future_video_v9").unwrap(); - assert_eq!(model.to_str(), "future_video_v9"); - assert_eq!(serde_json::to_string(&model).unwrap(), "\"future_video_v9\""); - assert_eq!(serde_json::from_str::("\"future_video_v9\"").unwrap(), model); - } - - #[test] - fn all_variants() { - let mut variants = TaskModelType::all_variants(); - assert_eq!(variants.len(), 54); - // Image models - assert_eq!(variants.pop_first(), Some(TaskModelType::Flux1Dev)); - assert_eq!(variants.pop_first(), Some(TaskModelType::Flux1Schnell)); - assert_eq!(variants.pop_first(), Some(TaskModelType::FluxDevJuggernaut)); - assert_eq!(variants.pop_first(), Some(TaskModelType::FluxPro1)); - assert_eq!(variants.pop_first(), Some(TaskModelType::FluxPro11)); - assert_eq!(variants.pop_first(), Some(TaskModelType::FluxPro11Ultra)); - assert_eq!(variants.pop_first(), Some(TaskModelType::FluxProKontextMax)); - assert_eq!(variants.pop_first(), Some(TaskModelType::Gemini25Flash)); - assert_eq!(variants.pop_first(), Some(TaskModelType::NanoBanana)); - assert_eq!(variants.pop_first(), Some(TaskModelType::NanoBanana2)); - assert_eq!(variants.pop_first(), Some(TaskModelType::NanoBananaPro)); - assert_eq!(variants.pop_first(), Some(TaskModelType::GptImage1)); - assert_eq!(variants.pop_first(), Some(TaskModelType::GptImage1p5)); - assert_eq!(variants.pop_first(), Some(TaskModelType::GptImage2)); - assert_eq!(variants.pop_first(), Some(TaskModelType::GptImage2p5Flare)); - assert_eq!(variants.pop_first(), Some(TaskModelType::GptImage2p5Sunburst)); - assert_eq!(variants.pop_first(), Some(TaskModelType::Seedream4)); - assert_eq!(variants.pop_first(), Some(TaskModelType::Seedream4p5)); - assert_eq!(variants.pop_first(), Some(TaskModelType::Seedream5Lite)); - assert_eq!(variants.pop_first(), Some(TaskModelType::QwenEdit2511Angles)); - assert_eq!(variants.pop_first(), Some(TaskModelType::Flux2LoraAngles)); - assert_eq!(variants.pop_first(), Some(TaskModelType::GrokImage)); - assert_eq!(variants.pop_first(), Some(TaskModelType::Recraft3)); - assert_eq!(variants.pop_first(), Some(TaskModelType::Midjourney)); - assert_eq!(variants.pop_first(), Some(TaskModelType::Midjourney7)); - assert_eq!(variants.pop_first(), Some(TaskModelType::Midjourney7Niji)); - assert_eq!(variants.pop_first(), Some(TaskModelType::Midjourney8)); - // Video models - assert_eq!(variants.pop_first(), Some(TaskModelType::GrokVideo)); - assert_eq!(variants.pop_first(), Some(TaskModelType::GrokImagineVideo1p5)); - assert_eq!(variants.pop_first(), Some(TaskModelType::Kling16Pro)); - assert_eq!(variants.pop_first(), Some(TaskModelType::Kling21Pro)); - assert_eq!(variants.pop_first(), Some(TaskModelType::Kling21Master)); - assert_eq!(variants.pop_first(), Some(TaskModelType::Kling2p5TurboPro)); - assert_eq!(variants.pop_first(), Some(TaskModelType::Kling2p6Pro)); - assert_eq!(variants.pop_first(), Some(TaskModelType::Kling3p0Standard)); - assert_eq!(variants.pop_first(), Some(TaskModelType::Kling3p0Pro)); - assert_eq!(variants.pop_first(), Some(TaskModelType::HappyHorse1p0)); - assert_eq!(variants.pop_first(), Some(TaskModelType::Seedance10Lite)); - assert_eq!(variants.pop_first(), Some(TaskModelType::Seedance1p5Pro)); - assert_eq!(variants.pop_first(), Some(TaskModelType::Seedance2p0)); - assert_eq!(variants.pop_first(), Some(TaskModelType::Seedance2p0Fast)); - assert_eq!(variants.pop_first(), Some(TaskModelType::Sora2)); - assert_eq!(variants.pop_first(), Some(TaskModelType::Sora2Pro)); - assert_eq!(variants.pop_first(), Some(TaskModelType::Veo2)); - assert_eq!(variants.pop_first(), Some(TaskModelType::Veo3)); - assert_eq!(variants.pop_first(), Some(TaskModelType::Veo3Fast)); - assert_eq!(variants.pop_first(), Some(TaskModelType::Veo3p1)); - assert_eq!(variants.pop_first(), Some(TaskModelType::Veo3p1Fast)); - // 3D Object generation models - assert_eq!(variants.pop_first(), Some(TaskModelType::Hunyuan3d2_0)); - assert_eq!(variants.pop_first(), Some(TaskModelType::Hunyuan3d2_1)); - assert_eq!(variants.pop_first(), Some(TaskModelType::Hunyuan3d3)); - assert_eq!(variants.pop_first(), Some(TaskModelType::WorldlabsMarble)); - assert_eq!(variants.pop_first(), Some(TaskModelType::WorldlabsMarble0p1Mini)); - assert_eq!(variants.pop_first(), Some(TaskModelType::WorldlabsMarble0p1Plus)); - assert_eq!(variants.pop_first(), None); - } - } - - mod mechanical_checks { - use super::*; - - #[test] - fn variant_length() { - use strum::IntoEnumIterator; - assert_eq!(TaskModelType::all_variants().len(), TaskModelType::iter().len()); - } - - #[test] - fn round_trip() { - for variant in TaskModelType::all_variants() { - // Test to_str(), from_str(), Display, and Debug. - assert_eq!(variant, TaskModelType::from_str(variant.to_str()).unwrap()); - assert_eq!(variant, TaskModelType::from_str(&format!("{}", variant)).unwrap()); - assert_eq!(variant, TaskModelType::from_str(&format!("{:?}", variant)).unwrap()); - } - } - - #[test] - fn serialized_length_ok_for_database() { - const MAX_LENGTH : usize = 24; - for variant in TaskModelType::all_variants() { - let serialized = variant.to_str(); - assert!(serialized.len() > 0, "variant {:?} is too short", variant); - assert!(serialized.len() <= MAX_LENGTH, "variant {:?} is too long", variant); - } - } - } -} diff --git a/crates/schema/public/enums/src/tauri/tasks/task_status.rs b/crates/schema/public/enums/src/tauri/tasks/task_status.rs deleted file mode 100644 index cc130c8c77..0000000000 --- a/crates/schema/public/enums/src/tauri/tasks/task_status.rs +++ /dev/null @@ -1,184 +0,0 @@ -use std::collections::BTreeSet; - -use crate::error::enum_error::EnumError; -#[cfg(test)] -use strum::EnumCount; -#[cfg(test)] -use strum::EnumIter; -use utoipa::ToSchema; - -#[cfg_attr(test, derive(EnumIter, EnumCount))] -#[derive(Clone, Copy, PartialEq, Eq, Hash, Ord, PartialOrd, Serialize, Deserialize, ToSchema)] -#[serde(rename_all = "snake_case")] -pub enum TaskStatus { - Pending, - Started, - CompleteSuccess, - CompleteFailure, - AttemptFailed, - Dead, - CancelledByUser, - CancelledByProvider, - CancelledByUs, -} - -impl_enum_display_and_debug_using_to_str!(TaskStatus); -//impl_mysql_enum_coders!(TaskStatus); -//impl_mysql_from_row!(TaskStatus); - -// NB: We can derive `sqlx::Type` instead of using `impl_mysql_enum_coders` - -impl Default for TaskStatus { - fn default() -> Self { - Self::Pending - } -} - -impl TaskStatus { - pub const fn to_str(&self) -> &'static str { - match self { - Self::Pending => "pending", - Self::Started => "started", - Self::CompleteSuccess => "complete_success", - Self::CompleteFailure => "complete_failure", - Self::AttemptFailed => "attempt_failed", - Self::Dead => "dead", - Self::CancelledByUser => "cancelled_by_user", - Self::CancelledByProvider => "cancelled_by_provider", - Self::CancelledByUs => "cancelled_by_us", - } - } - - pub fn from_str(value: &str) -> Result { - match value { - "pending" => Ok(Self::Pending), - "started" => Ok(Self::Started), - "complete_success" => Ok(Self::CompleteSuccess), - "complete_failure" => Ok(Self::CompleteFailure), - "attempt_failed" => Ok(Self::AttemptFailed), - "dead" => Ok(Self::Dead), - "cancelled_by_user" => Ok(Self::CancelledByUser), - "cancelled_by_provider" => Ok(Self::CancelledByProvider), - "cancelled_by_us" => Ok(Self::CancelledByUs), - _ => Err(EnumError::CouldNotConvertFromString(value.to_string())), - } - } - - pub fn all_variants() -> BTreeSet { - // NB: BTreeSet is sorted - // NB: BTreeSet::from() isn't const, but not worth using LazyStatic, etc. - BTreeSet::from([ - Self::Pending, - Self::Started, - Self::CompleteSuccess, - Self::CompleteFailure, - Self::AttemptFailed, - Self::Dead, - Self::CancelledByUser, - Self::CancelledByProvider, - Self::CancelledByUs, - ]) - } -} - -#[cfg(test)] -mod tests { - use crate::tauri::tasks::task_status::TaskStatus; - use crate::test_helpers::assert_serialization; - - mod explicit_checks { - use super::*; - use crate::error::enum_error::EnumError; - - #[test] - fn test_default() { - assert_eq!(TaskStatus::default(), TaskStatus::Pending); - } - - #[test] - fn test_serialization() { - assert_serialization(TaskStatus::Pending, "pending"); - assert_serialization(TaskStatus::Started, "started"); - assert_serialization(TaskStatus::CompleteSuccess, "complete_success"); - assert_serialization(TaskStatus::CompleteFailure, "complete_failure"); - assert_serialization(TaskStatus::AttemptFailed, "attempt_failed"); - assert_serialization(TaskStatus::Dead, "dead"); - assert_serialization(TaskStatus::CancelledByUser, "cancelled_by_user"); - assert_serialization(TaskStatus::CancelledByProvider, "cancelled_by_provider"); - assert_serialization(TaskStatus::CancelledByUs, "cancelled_by_us"); - } - - #[test] - fn to_str() { - assert_eq!(TaskStatus::Pending.to_str(), "pending"); - assert_eq!(TaskStatus::Started.to_str(), "started"); - assert_eq!(TaskStatus::CompleteSuccess.to_str(), "complete_success"); - assert_eq!(TaskStatus::CompleteFailure.to_str(), "complete_failure"); - assert_eq!(TaskStatus::AttemptFailed.to_str(), "attempt_failed"); - assert_eq!(TaskStatus::Dead.to_str(), "dead"); - assert_eq!(TaskStatus::CancelledByUser.to_str(), "cancelled_by_user"); - assert_eq!(TaskStatus::CancelledByProvider.to_str(), "cancelled_by_provider"); - assert_eq!(TaskStatus::CancelledByUs.to_str(), "cancelled_by_us"); - } - - #[test] - fn from_str() { - assert_eq!(TaskStatus::from_str("pending").unwrap(), TaskStatus::Pending); - assert_eq!(TaskStatus::from_str("started").unwrap(), TaskStatus::Started); - assert_eq!(TaskStatus::from_str("complete_success").unwrap(), TaskStatus::CompleteSuccess); - assert_eq!(TaskStatus::from_str("complete_failure").unwrap(), TaskStatus::CompleteFailure); - assert_eq!(TaskStatus::from_str("attempt_failed").unwrap(), TaskStatus::AttemptFailed); - assert_eq!(TaskStatus::from_str("dead").unwrap(), TaskStatus::Dead); - assert_eq!(TaskStatus::from_str("cancelled_by_user").unwrap(), TaskStatus::CancelledByUser); - assert_eq!(TaskStatus::from_str("cancelled_by_provider").unwrap(), TaskStatus::CancelledByProvider); - assert_eq!(TaskStatus::from_str("cancelled_by_us").unwrap(), TaskStatus::CancelledByUs); - } - - #[test] - fn from_str_err() { - let result = TaskStatus::from_str("asdf"); - assert!(result.is_err()); - if let Err(EnumError::CouldNotConvertFromString(value)) = result { - assert_eq!(value, "asdf"); - } else { - panic!("Expected EnumError::CouldNotConvertFromString"); - } - } - - #[test] - fn all_variants() { - let mut variants = TaskStatus::all_variants(); - assert_eq!(variants.len(), 9); - assert_eq!(variants.pop_first(), Some(TaskStatus::Pending)); - assert_eq!(variants.pop_first(), Some(TaskStatus::Started)); - assert_eq!(variants.pop_first(), Some(TaskStatus::CompleteSuccess)); - assert_eq!(variants.pop_first(), Some(TaskStatus::CompleteFailure)); - assert_eq!(variants.pop_first(), Some(TaskStatus::AttemptFailed)); - assert_eq!(variants.pop_first(), Some(TaskStatus::Dead)); - assert_eq!(variants.pop_first(), Some(TaskStatus::CancelledByUser)); - assert_eq!(variants.pop_first(), Some(TaskStatus::CancelledByProvider)); - assert_eq!(variants.pop_first(), Some(TaskStatus::CancelledByUs)); - assert_eq!(variants.pop_first(), None); - } - } - - mod mechanical_checks { - use super::*; - - #[test] - fn variant_length() { - use strum::IntoEnumIterator; - assert_eq!(TaskStatus::all_variants().len(), TaskStatus::iter().len()); - } - - #[test] - fn round_trip() { - for variant in TaskStatus::all_variants() { - // Test to_str(), from_str(), Display, and Debug. - assert_eq!(variant, TaskStatus::from_str(variant.to_str()).unwrap()); - assert_eq!(variant, TaskStatus::from_str(&format!("{}", variant)).unwrap()); - assert_eq!(variant, TaskStatus::from_str(&format!("{:?}", variant)).unwrap()); - } - } - } -} diff --git a/crates/schema/public/enums/src/tauri/tasks/task_type.rs b/crates/schema/public/enums/src/tauri/tasks/task_type.rs deleted file mode 100644 index 97e8863336..0000000000 --- a/crates/schema/public/enums/src/tauri/tasks/task_type.rs +++ /dev/null @@ -1,154 +0,0 @@ -use std::collections::BTreeSet; - -use crate::error::enum_error::EnumError; -#[cfg(test)] -use strum::EnumCount; -#[cfg(test)] -use strum::EnumIter; -use utoipa::ToSchema; - -#[cfg_attr(test, derive(EnumIter, EnumCount))] -#[derive(Clone, Copy, PartialEq, Eq, Hash, Ord, PartialOrd, Serialize, Deserialize, ToSchema)] -#[serde(rename_all = "snake_case")] -pub enum TaskType { - ImageGeneration, - ImageInpaintEdit, - VideoGeneration, - AudioGeneration, - ObjectGeneration, - GaussianGeneration, - BackgroundRemoval, -} - -impl_enum_display_and_debug_using_to_str!(TaskType); -//impl_mysql_enum_coders!(TaskType); -//impl_mysql_from_row!(TaskType); - -// NB: We can derive `sqlx::Type` instead of using `impl_mysql_enum_coders` - -impl TaskType { - pub fn to_str(&self) -> &'static str { - match self { - Self::ImageGeneration => "image_generation", - Self::ImageInpaintEdit => "image_inpaint_edit", - Self::VideoGeneration => "video_generation", - Self::AudioGeneration => "audio_generation", - Self::ObjectGeneration => "object_generation", - Self::GaussianGeneration => "gaussian_generation", - Self::BackgroundRemoval => "background_removal", - } - } - - pub fn from_str(value: &str) -> Result { - match value { - "image_generation" => Ok(Self::ImageGeneration), - "image_inpaint_edit" => Ok(Self::ImageInpaintEdit), - "video_generation" => Ok(Self::VideoGeneration), - "audio_generation" => Ok(Self::AudioGeneration), - "object_generation" => Ok(Self::ObjectGeneration), - "gaussian_generation" => Ok(Self::GaussianGeneration), - "background_removal" => Ok(Self::BackgroundRemoval), - _ => Err(EnumError::CouldNotConvertFromString(value.to_string())), - } - } - - pub fn all_variants() -> BTreeSet { - // NB: BTreeSet is sorted - // NB: BTreeSet::from() isn't const, but not worth using LazyStatic, etc. - BTreeSet::from([ - Self::ImageGeneration, - Self::ImageInpaintEdit, - Self::VideoGeneration, - Self::AudioGeneration, - Self::ObjectGeneration, - Self::GaussianGeneration, - Self::BackgroundRemoval, - ]) - } -} - -#[cfg(test)] -mod tests { - use crate::tauri::tasks::task_type::TaskType; - use crate::test_helpers::assert_serialization; - - mod explicit_checks { - use super::*; - use crate::error::enum_error::EnumError; - - #[test] - fn test_serialization() { - assert_serialization(TaskType::ImageGeneration, "image_generation"); - assert_serialization(TaskType::ImageInpaintEdit, "image_inpaint_edit"); - assert_serialization(TaskType::VideoGeneration, "video_generation"); - assert_serialization(TaskType::ObjectGeneration, "object_generation"); - assert_serialization(TaskType::GaussianGeneration, "gaussian_generation"); - assert_serialization(TaskType::BackgroundRemoval, "background_removal"); - } - - #[test] - fn to_str() { - assert_eq!(TaskType::ImageGeneration.to_str(), "image_generation"); - assert_eq!(TaskType::ImageInpaintEdit.to_str(), "image_inpaint_edit"); - assert_eq!(TaskType::VideoGeneration.to_str(), "video_generation"); - assert_eq!(TaskType::ObjectGeneration.to_str(), "object_generation"); - assert_eq!(TaskType::GaussianGeneration.to_str(), "gaussian_generation"); - assert_eq!(TaskType::BackgroundRemoval.to_str(), "background_removal"); - } - - #[test] - fn from_str() { - assert_eq!(TaskType::from_str("image_generation").unwrap(), TaskType::ImageGeneration); - assert_eq!(TaskType::from_str("image_inpaint_edit").unwrap(), TaskType::ImageInpaintEdit); - assert_eq!(TaskType::from_str("video_generation").unwrap(), TaskType::VideoGeneration); - assert_eq!(TaskType::from_str("object_generation").unwrap(), TaskType::ObjectGeneration); - assert_eq!(TaskType::from_str("gaussian_generation").unwrap(), TaskType::GaussianGeneration); - assert_eq!(TaskType::from_str("background_removal").unwrap(), TaskType::BackgroundRemoval); - } - - #[test] - fn from_str_err() { - let result = TaskType::from_str("asdf"); - assert!(result.is_err()); - if let Err(EnumError::CouldNotConvertFromString(value)) = result { - assert_eq!(value, "asdf"); - } else { - panic!("Expected EnumError::CouldNotConvertFromString"); - } - } - - #[test] - fn all_variants() { - let mut variants = TaskType::all_variants(); - assert_eq!(variants.len(), 7); - assert_eq!(variants.pop_first(), Some(TaskType::ImageGeneration)); - assert_eq!(variants.pop_first(), Some(TaskType::ImageInpaintEdit)); - assert_eq!(variants.pop_first(), Some(TaskType::VideoGeneration)); - assert_eq!(variants.pop_first(), Some(TaskType::AudioGeneration)); - assert_eq!(variants.pop_first(), Some(TaskType::ObjectGeneration)); - assert_eq!(variants.pop_first(), Some(TaskType::GaussianGeneration)); - assert_eq!(variants.pop_first(), Some(TaskType::BackgroundRemoval)); - assert_eq!(variants.pop_first(), None); - } - } - - mod mechanical_checks { - use super::*; - - #[test] - fn variant_length() { - use strum::IntoEnumIterator; - assert_eq!(TaskType::all_variants().len(), TaskType::iter().len()); - } - - #[test] - fn round_trip() { - for variant in TaskType::all_variants() { - // Test to_str(), from_str(), Display, and Debug. - assert_eq!(variant, TaskType::from_str(variant.to_str()).unwrap()); - assert_eq!(variant, TaskType::from_str(&format!("{}", variant)).unwrap()); - assert_eq!(variant, TaskType::from_str(&format!("{:?}", variant)).unwrap()); - } - } - } -} diff --git a/crates/schema/public/enums/src/tauri/ux/mod.rs b/crates/schema/public/enums/src/tauri/ux/mod.rs deleted file mode 100644 index 40215426d6..0000000000 --- a/crates/schema/public/enums/src/tauri/ux/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod tauri_command_caller; -pub mod tauri_event_name; diff --git a/crates/schema/public/enums/src/tauri/ux/tauri_command_caller.rs b/crates/schema/public/enums/src/tauri/ux/tauri_command_caller.rs deleted file mode 100644 index 82b8d07993..0000000000 --- a/crates/schema/public/enums/src/tauri/ux/tauri_command_caller.rs +++ /dev/null @@ -1,158 +0,0 @@ -use std::collections::BTreeSet; - -use crate::error::enum_error::EnumError; -#[cfg(test)] -use strum::EnumCount; -#[cfg(test)] -use strum::EnumIter; -use utoipa::ToSchema; - -/// Defines the names of the Tauri-sent events that the frontend subscribes to. -/// These event names are also stored in the database, so keep them short-ish. -#[cfg_attr(test, derive(EnumIter, EnumCount))] -#[derive(Clone, Copy, PartialEq, Eq, Hash, Ord, PartialOrd, Serialize, Deserialize, ToSchema)] -#[serde(rename_all = "snake_case")] -pub enum TauriCommandCaller { - /// The 2D canvas - Canvas, - /// The inpainting editor - ImageEditor, - /// The text-to-image page - TextToImage, - /// The image-to-video page - ImageToVideo, - /// A mini-app (doesn't specify which one) - MiniApp, -} - -impl_enum_display_and_debug_using_to_str!(TauriCommandCaller); -impl_mysql_enum_coders!(TauriCommandCaller); -impl_mysql_from_row!(TauriCommandCaller); - -// NB: We can derive `sqlx::Type` instead of using `impl_mysql_enum_coders` - -impl TauriCommandCaller { - pub fn to_str(&self) -> &'static str { - match self { - Self::Canvas => "canvas", - Self::ImageEditor => "image_editor", - Self::TextToImage => "text_to_image", - Self::ImageToVideo => "image_to_video", - Self::MiniApp => "mini_app", - } - } - - pub fn from_str(value: &str) -> Result { - match value { - "canvas" => Ok(Self::Canvas), - "image_editor" => Ok(Self::ImageEditor), - "text_to_image" => Ok(Self::TextToImage), - "image_to_video" => Ok(Self::ImageToVideo), - "mini_app" => Ok(Self::MiniApp), - _ => Err(EnumError::CouldNotConvertFromString(value.to_string())), - } - } - - pub fn all_variants() -> BTreeSet { - // NB: BTreeSet is sorted - // NB: BTreeSet::from() isn't const, but not worth using LazyStatic, etc. - BTreeSet::from([ - Self::Canvas, - Self::ImageEditor, - Self::TextToImage, - Self::ImageToVideo, - Self::MiniApp, - ]) - } -} - -#[cfg(test)] -mod tests { - use crate::error::enum_error::EnumError; - use crate::tauri::ux::tauri_command_caller::TauriCommandCaller; - use crate::test_helpers::assert_serialization; - - mod explicit_checks { - use super::*; - - #[test] - fn test_serialization() { - assert_serialization(TauriCommandCaller::Canvas, "canvas"); - assert_serialization(TauriCommandCaller::ImageEditor, "image_editor"); - assert_serialization(TauriCommandCaller::TextToImage, "text_to_image"); - assert_serialization(TauriCommandCaller::ImageToVideo, "image_to_video"); - assert_serialization(TauriCommandCaller::MiniApp, "mini_app"); - } - - #[test] - fn to_str() { - assert_eq!(TauriCommandCaller::Canvas.to_str(), "canvas"); - assert_eq!(TauriCommandCaller::ImageEditor.to_str(), "image_editor"); - assert_eq!(TauriCommandCaller::TextToImage.to_str(), "text_to_image"); - assert_eq!(TauriCommandCaller::ImageToVideo.to_str(), "image_to_video"); - assert_eq!(TauriCommandCaller::MiniApp.to_str(), "mini_app"); - } - - #[test] - fn from_str() { - assert_eq!(TauriCommandCaller::from_str("canvas").unwrap(), TauriCommandCaller::Canvas); - assert_eq!(TauriCommandCaller::from_str("image_editor").unwrap(), TauriCommandCaller::ImageEditor); - assert_eq!(TauriCommandCaller::from_str("text_to_image").unwrap(), TauriCommandCaller::TextToImage); - assert_eq!(TauriCommandCaller::from_str("image_to_video").unwrap(), TauriCommandCaller::ImageToVideo); - assert_eq!(TauriCommandCaller::from_str("mini_app").unwrap(), TauriCommandCaller::MiniApp); - } - - #[test] - fn from_str_err() { - let result = TauriCommandCaller::from_str("asdf"); - assert!(result.is_err()); - if let Err(EnumError::CouldNotConvertFromString(value)) = result { - assert_eq!(value, "asdf"); - } else { - panic!("Expected EnumError::CouldNotConvertFromString"); - } - } - - #[test] - fn all_variants() { - let mut variants = TauriCommandCaller::all_variants(); - assert_eq!(variants.len(), 5); - assert_eq!(variants.pop_first(), Some(TauriCommandCaller::Canvas)); - assert_eq!(variants.pop_first(), Some(TauriCommandCaller::ImageEditor)); - assert_eq!(variants.pop_first(), Some(TauriCommandCaller::TextToImage)); - assert_eq!(variants.pop_first(), Some(TauriCommandCaller::ImageToVideo)); - assert_eq!(variants.pop_first(), Some(TauriCommandCaller::MiniApp)); - assert_eq!(variants.pop_first(), None); - } - } - - mod mechanical_checks { - use super::*; - use strum::IntoEnumIterator; - - #[test] - fn variant_length() { - assert_eq!(TauriCommandCaller::all_variants().len(), TauriCommandCaller::iter().len()); - } - - #[test] - fn round_trip() { - for variant in TauriCommandCaller::all_variants() { - // Test to_str(), from_str(), Display, and Debug. - assert_eq!(variant, TauriCommandCaller::from_str(variant.to_str()).unwrap()); - assert_eq!(variant, TauriCommandCaller::from_str(&format!("{}", variant)).unwrap()); - assert_eq!(variant, TauriCommandCaller::from_str(&format!("{:?}", variant)).unwrap()); - } - } - - //#[test] - //fn serialized_length_ok_for_database() { - // const MAX_LENGTH : usize = 16; - // for variant in TauriCommandCaller::all_variants() { - // let serialized = variant.to_str(); - // assert!(serialized.len() > 0, "variant {:?} is too short", variant); - // assert!(serialized.len() <= MAX_LENGTH, "variant {:?} is too long", variant); - // } - //} - } -} diff --git a/crates/schema/public/enums/src/tauri/ux/tauri_event_name.rs b/crates/schema/public/enums/src/tauri/ux/tauri_event_name.rs deleted file mode 100644 index de161cd8e6..0000000000 --- a/crates/schema/public/enums/src/tauri/ux/tauri_event_name.rs +++ /dev/null @@ -1,321 +0,0 @@ -use std::collections::BTreeSet; - -#[cfg(test)] -use strum::EnumCount; -#[cfg(test)] -use strum::EnumIter; -use utoipa::ToSchema; - -/// Defines the names of the Tauri-sent events that the frontend subscribes to. -/// These event names are also stored in the database, so keep them short-ish. -/// -/// NB: Events should end in "_event" so they're easy to grep for in Javascript. -#[cfg_attr(test, derive(EnumIter, EnumCount))] -#[derive(Clone, Copy, PartialEq, Eq, Hash, Ord, PartialOrd, Serialize, Deserialize, ToSchema)] -#[serde(rename_all = "snake_case")] -pub enum TauriEventName { - // TODO: Get rid of kebab case. - /// General purpose event: - /// Generation enqueued - #[serde(rename = "generation-enqueue-success-event")] - GenerationEnqueueSuccessEvent, - - // TODO: Get rid of kebab case. - /// General purpose event: - /// Generation failed to enqueue - #[serde(rename = "generation-enqueue-failure-event")] - GenerationEnqueueFailureEvent, - - // TODO: Get rid of kebab case. - /// General purpose event: - /// Generation completed successfully - #[serde(rename = "generation-complete-event")] - GenerationCompleteEvent, - - // TODO: Get rid of kebab case. - /// General purpose event: - /// Generation failed - #[serde(rename = "generation-failed-event")] - GenerationFailedEvent, - - /// Informational event: - /// Credits were purchased or spent (but we don't know how much) - #[serde(rename = "credits_balance_changed_event")] - CreditsBalanceChangedEvent, - - /// Informational event: - /// Subscription was changed (but we don't know the details - upgrade, cancel, etc.) - #[serde(rename = "subscription_plan_changed_event")] - SubscriptionPlanChangedEvent, - - /// Informational event: - /// A media file was deleted (and we'll send the token) - #[serde(rename = "media_file_deleted_event")] - MediaFileDeletedEvent, - - /// Special event: - /// Background removal is complete - #[serde(rename = "canvas_bg_removed_event")] - CanvasBgRemovedEvent, - - /// Special event: - /// Image generation is complete - #[serde(rename = "text_to_image_generation_complete_event")] - TextToImageGenerationCompleteEvent, - - /// Special event: - /// Image edit is complete - #[serde(rename = "image_edit_complete_event")] - ImageEditCompleteEvent, - - /// Special event: - /// Object (3D mesh) generation is complete - #[serde(rename = "object_generation_complete_event")] - ObjectGenerationCompleteEvent, - - /// Special event: - /// Gaussian generation is complete - #[serde(rename = "gaussian_generation_complete_event")] - GaussianGenerationCompleteEvent, - - /// Special event: - /// Video generation is complete - #[serde(rename = "video_generation_complete_event")] - VideoGenerationCompleteEvent, - - /// Special event: - /// Refresh account states - #[serde(rename = "refresh_account_state_event")] - RefreshAccountStateEvent, - - /// Special event: - /// Show a billing modal (a suggestion to pay, etc. for a specific provider) - #[serde(rename = "show_provider_billing_modal_event")] - ShowProviderBillingModalEvent, - - /// Special event: - /// Show a login modal (or a suggestion to login) - #[serde(rename = "show_provider_login_modal_event")] - ShowProviderLoginModalEvent, - - /// Warning event: - /// Flash a user input error message - #[serde(rename = "flash_user_input_error_event")] - FlashUserInputErrorEvent, - - /// Warning event: - /// File with that name was already downloaded - #[serde(rename = "flash_file_download_error_event")] - FlashFileDownloadErrorEvent, -} - -impl_enum_display_and_debug_using_to_str!(TauriEventName); -impl_mysql_enum_coders!(TauriEventName); -impl_mysql_from_row!(TauriEventName); - -// NB: We can derive `sqlx::Type` instead of using `impl_mysql_enum_coders` - -impl TauriEventName { - pub fn to_str(&self) -> &'static str { - match self { - Self::GenerationEnqueueSuccessEvent => "generation-enqueue-success-event", - Self::GenerationEnqueueFailureEvent => "generation-enqueue-failure-event", - Self::GenerationCompleteEvent => "generation-complete-event", - Self::GenerationFailedEvent => "generation-failed-event", - Self::CreditsBalanceChangedEvent => "credits_balance_changed_event", - Self::SubscriptionPlanChangedEvent => "subscription_plan_changed_event", - Self::MediaFileDeletedEvent => "media_file_deleted_event", - Self::CanvasBgRemovedEvent => "canvas_bg_removed_event", - Self::TextToImageGenerationCompleteEvent => "text_to_image_generation_complete_event", - Self::ImageEditCompleteEvent => "image_edit_complete_event", - Self::ObjectGenerationCompleteEvent => "object_generation_complete_event", - Self::GaussianGenerationCompleteEvent => "gaussian_generation_complete_event", - Self::VideoGenerationCompleteEvent => "video_generation_complete_event", - Self::RefreshAccountStateEvent => "refresh_account_state_event", - Self::ShowProviderBillingModalEvent => "show_provider_billing_modal_event", - Self::ShowProviderLoginModalEvent => "show_provider_login_modal_event", - Self::FlashUserInputErrorEvent => "flash_user_input_error_event", - Self::FlashFileDownloadErrorEvent => "flash_file_download_error_event", - } - } - - pub fn from_str(job_status: &str) -> Result { - match job_status { - "generation-enqueue-success-event" => Ok(Self::GenerationEnqueueSuccessEvent), - "generation-enqueue-failure-event" => Ok(Self::GenerationEnqueueFailureEvent), - "generation-complete-event" => Ok(Self::GenerationCompleteEvent), - "generation-failed-event" => Ok(Self::GenerationFailedEvent), - "credits_balance_changed_event" => Ok(Self::CreditsBalanceChangedEvent), - "subscription_plan_changed_event" => Ok(Self::SubscriptionPlanChangedEvent), - "media_file_deleted_event" => Ok(Self::MediaFileDeletedEvent), - "canvas_bg_removed_event" => Ok(Self::CanvasBgRemovedEvent), - "text_to_image_generation_complete_event" => Ok(Self::TextToImageGenerationCompleteEvent), - "image_edit_complete_event" => Ok(Self::ImageEditCompleteEvent), - "object_generation_complete_event" => Ok(Self::ObjectGenerationCompleteEvent), - "gaussian_generation_complete_event" => Ok(Self::GaussianGenerationCompleteEvent), - "video_generation_complete_event" => Ok(Self::VideoGenerationCompleteEvent), - "refresh_account_state_event" => Ok(Self::RefreshAccountStateEvent), - "show_provider_billing_modal_event" => Ok(Self::ShowProviderBillingModalEvent), - "show_provider_login_modal_event" => Ok(Self::ShowProviderLoginModalEvent), - "flash_user_input_error_event" => Ok(Self::FlashUserInputErrorEvent), - "flash_file_download_error_event" => Ok(Self::FlashFileDownloadErrorEvent), - _ => Err(format!("invalid tauri_event_name: {:?}", job_status)), - } - } - - pub fn all_variants() -> BTreeSet { - // NB: BTreeSet is sorted - // NB: BTreeSet::from() isn't const, but not worth using LazyStatic, etc. - BTreeSet::from([ - Self::GenerationEnqueueSuccessEvent, - Self::GenerationEnqueueFailureEvent, - Self::GenerationCompleteEvent, - Self::GenerationFailedEvent, - Self::CreditsBalanceChangedEvent, - Self::SubscriptionPlanChangedEvent, - Self::MediaFileDeletedEvent, - Self::CanvasBgRemovedEvent, - Self::TextToImageGenerationCompleteEvent, - Self::ImageEditCompleteEvent, - Self::ObjectGenerationCompleteEvent, - Self::GaussianGenerationCompleteEvent, - Self::VideoGenerationCompleteEvent, - Self::RefreshAccountStateEvent, - Self::ShowProviderBillingModalEvent, - Self::ShowProviderLoginModalEvent, - Self::FlashUserInputErrorEvent, - Self::FlashFileDownloadErrorEvent, - ]) - } -} - -#[cfg(test)] -mod tests { - use crate::tauri::ux::tauri_event_name::TauriEventName; - use crate::test_helpers::assert_serialization; - - mod explicit_checks { - use super::*; - - #[test] - fn test_serialization() { - assert_serialization(TauriEventName::GenerationEnqueueSuccessEvent, "generation-enqueue-success-event"); - assert_serialization(TauriEventName::GenerationEnqueueFailureEvent, "generation-enqueue-failure-event"); - assert_serialization(TauriEventName::GenerationCompleteEvent, "generation-complete-event"); - assert_serialization(TauriEventName::GenerationFailedEvent, "generation-failed-event"); - assert_serialization(TauriEventName::CreditsBalanceChangedEvent, "credits_balance_changed_event"); - assert_serialization(TauriEventName::SubscriptionPlanChangedEvent, "subscription_plan_changed_event"); - assert_serialization(TauriEventName::MediaFileDeletedEvent, "media_file_deleted_event"); - assert_serialization(TauriEventName::CanvasBgRemovedEvent, "canvas_bg_removed_event"); - assert_serialization(TauriEventName::TextToImageGenerationCompleteEvent, "text_to_image_generation_complete_event"); - assert_serialization(TauriEventName::ImageEditCompleteEvent, "image_edit_complete_event"); - assert_serialization(TauriEventName::ObjectGenerationCompleteEvent, "object_generation_complete_event"); - assert_serialization(TauriEventName::GaussianGenerationCompleteEvent, "gaussian_generation_complete_event"); - assert_serialization(TauriEventName::VideoGenerationCompleteEvent, "video_generation_complete_event"); - assert_serialization(TauriEventName::RefreshAccountStateEvent, "refresh_account_state_event"); - assert_serialization(TauriEventName::ShowProviderBillingModalEvent, "show_provider_billing_modal_event"); - assert_serialization(TauriEventName::ShowProviderLoginModalEvent, "show_provider_login_modal_event"); - assert_serialization(TauriEventName::FlashUserInputErrorEvent, "flash_user_input_error_event"); - assert_serialization(TauriEventName::FlashFileDownloadErrorEvent, "flash_file_download_error_event"); - } - - #[test] - fn to_str() { - assert_eq!(TauriEventName::GenerationEnqueueSuccessEvent.to_str(), "generation-enqueue-success-event"); - assert_eq!(TauriEventName::GenerationEnqueueFailureEvent.to_str(), "generation-enqueue-failure-event"); - assert_eq!(TauriEventName::GenerationCompleteEvent.to_str(), "generation-complete-event"); - assert_eq!(TauriEventName::GenerationFailedEvent.to_str(), "generation-failed-event"); - assert_eq!(TauriEventName::CreditsBalanceChangedEvent.to_str(), "credits_balance_changed_event"); - assert_eq!(TauriEventName::SubscriptionPlanChangedEvent.to_str(), "subscription_plan_changed_event"); - assert_eq!(TauriEventName::MediaFileDeletedEvent.to_str(), "media_file_deleted_event"); - assert_eq!(TauriEventName::CanvasBgRemovedEvent.to_str(), "canvas_bg_removed_event"); - assert_eq!(TauriEventName::TextToImageGenerationCompleteEvent.to_str(), "text_to_image_generation_complete_event"); - assert_eq!(TauriEventName::ImageEditCompleteEvent.to_str(), "image_edit_complete_event"); - assert_eq!(TauriEventName::ObjectGenerationCompleteEvent.to_str(), "object_generation_complete_event"); - assert_eq!(TauriEventName::GaussianGenerationCompleteEvent.to_str(), "gaussian_generation_complete_event"); - assert_eq!(TauriEventName::VideoGenerationCompleteEvent.to_str(), "video_generation_complete_event"); - assert_eq!(TauriEventName::RefreshAccountStateEvent.to_str(), "refresh_account_state_event"); - assert_eq!(TauriEventName::ShowProviderBillingModalEvent.to_str(), "show_provider_billing_modal_event"); - assert_eq!(TauriEventName::ShowProviderLoginModalEvent.to_str(), "show_provider_login_modal_event"); - assert_eq!(TauriEventName::FlashUserInputErrorEvent.to_str(), "flash_user_input_error_event"); - assert_eq!(TauriEventName::FlashFileDownloadErrorEvent.to_str(), "flash_file_download_error_event"); - } - - #[test] - fn from_str() { - assert_eq!(TauriEventName::from_str("generation-enqueue-success-event").unwrap(), TauriEventName::GenerationEnqueueSuccessEvent); - assert_eq!(TauriEventName::from_str("generation-enqueue-failure-event").unwrap(), TauriEventName::GenerationEnqueueFailureEvent); - assert_eq!(TauriEventName::from_str("generation-complete-event").unwrap(), TauriEventName::GenerationCompleteEvent); - assert_eq!(TauriEventName::from_str("generation-failed-event").unwrap(), TauriEventName::GenerationFailedEvent); - assert_eq!(TauriEventName::from_str("credits_balance_changed_event").unwrap(), TauriEventName::CreditsBalanceChangedEvent); - assert_eq!(TauriEventName::from_str("subscription_plan_changed_event").unwrap(), TauriEventName::SubscriptionPlanChangedEvent); - assert_eq!(TauriEventName::from_str("media_file_deleted_event").unwrap(), TauriEventName::MediaFileDeletedEvent); - assert_eq!(TauriEventName::from_str("canvas_bg_removed_event").unwrap(), TauriEventName::CanvasBgRemovedEvent); - assert_eq!(TauriEventName::from_str("text_to_image_generation_complete_event").unwrap(), TauriEventName::TextToImageGenerationCompleteEvent); - assert_eq!(TauriEventName::from_str("image_edit_complete_event").unwrap(), TauriEventName::ImageEditCompleteEvent); - assert_eq!(TauriEventName::from_str("object_generation_complete_event").unwrap(), TauriEventName::ObjectGenerationCompleteEvent); - assert_eq!(TauriEventName::from_str("gaussian_generation_complete_event").unwrap(), TauriEventName::GaussianGenerationCompleteEvent); - assert_eq!(TauriEventName::from_str("video_generation_complete_event").unwrap(), TauriEventName::VideoGenerationCompleteEvent); - assert_eq!(TauriEventName::from_str("refresh_account_state_event").unwrap(), TauriEventName::RefreshAccountStateEvent); - assert_eq!(TauriEventName::from_str("show_provider_billing_modal_event").unwrap(), TauriEventName::ShowProviderBillingModalEvent); - assert_eq!(TauriEventName::from_str("show_provider_login_modal_event").unwrap(), TauriEventName::ShowProviderLoginModalEvent); - assert_eq!(TauriEventName::from_str("flash_user_input_error_event").unwrap(), TauriEventName::FlashUserInputErrorEvent); - assert_eq!(TauriEventName::from_str("flash_file_download_error_event").unwrap(), TauriEventName::FlashFileDownloadErrorEvent); - } - - #[test] - fn all_variants() { - let mut variants = TauriEventName::all_variants(); - assert_eq!(variants.len(), 18); - assert_eq!(variants.pop_first(), Some(TauriEventName::GenerationEnqueueSuccessEvent)); - assert_eq!(variants.pop_first(), Some(TauriEventName::GenerationEnqueueFailureEvent)); - assert_eq!(variants.pop_first(), Some(TauriEventName::GenerationCompleteEvent)); - assert_eq!(variants.pop_first(), Some(TauriEventName::GenerationFailedEvent)); - assert_eq!(variants.pop_first(), Some(TauriEventName::CreditsBalanceChangedEvent)); - assert_eq!(variants.pop_first(), Some(TauriEventName::SubscriptionPlanChangedEvent)); - assert_eq!(variants.pop_first(), Some(TauriEventName::MediaFileDeletedEvent)); - assert_eq!(variants.pop_first(), Some(TauriEventName::CanvasBgRemovedEvent)); - assert_eq!(variants.pop_first(), Some(TauriEventName::TextToImageGenerationCompleteEvent)); - assert_eq!(variants.pop_first(), Some(TauriEventName::ImageEditCompleteEvent)); - assert_eq!(variants.pop_first(), Some(TauriEventName::ObjectGenerationCompleteEvent)); - assert_eq!(variants.pop_first(), Some(TauriEventName::GaussianGenerationCompleteEvent)); - assert_eq!(variants.pop_first(), Some(TauriEventName::VideoGenerationCompleteEvent)); - assert_eq!(variants.pop_first(), Some(TauriEventName::RefreshAccountStateEvent)); - assert_eq!(variants.pop_first(), Some(TauriEventName::ShowProviderBillingModalEvent)); - assert_eq!(variants.pop_first(), Some(TauriEventName::ShowProviderLoginModalEvent)); - assert_eq!(variants.pop_first(), Some(TauriEventName::FlashUserInputErrorEvent)); - assert_eq!(variants.pop_first(), Some(TauriEventName::FlashFileDownloadErrorEvent)); - assert_eq!(variants.pop_first(), None); - } - } - - mod mechanical_checks { - use super::*; - use strum::IntoEnumIterator; - - #[test] - fn variant_length() { - assert_eq!(TauriEventName::all_variants().len(), TauriEventName::iter().len()); - } - - #[test] - fn round_trip() { - for variant in TauriEventName::all_variants() { - // Test to_str(), from_str(), Display, and Debug. - assert_eq!(variant, TauriEventName::from_str(variant.to_str()).unwrap()); - assert_eq!(variant, TauriEventName::from_str(&format!("{}", variant)).unwrap()); - assert_eq!(variant, TauriEventName::from_str(&format!("{:?}", variant)).unwrap()); - } - } - - //#[test] - //fn serialized_length_ok_for_database() { - // const MAX_LENGTH : usize = 16; - // for variant in TauriEventName::all_variants() { - // let serialized = variant.to_str(); - // assert!(serialized.len() > 0, "variant {:?} is too short", variant); - // assert!(serialized.len() <= MAX_LENGTH, "variant {:?} is too long", variant); - // } - //} - } -} diff --git a/crates/schema/public/tokens/src/prefixes.rs b/crates/schema/public/tokens/src/prefixes.rs index e292922499..0398811f01 100644 --- a/crates/schema/public/tokens/src/prefixes.rs +++ b/crates/schema/public/tokens/src/prefixes.rs @@ -67,13 +67,6 @@ pub(crate) enum TokenPrefix { ZsVoiceDatasetSample, } -/// These are tokens for Tauri / Sqlite -#[derive(Debug, Copy, Clone, Eq, PartialEq)] -#[cfg_attr(test, derive(EnumIter, EnumCount))] -pub(crate) enum TauriTokenPrefix { - Task, -} - /// These are old-style prefixes that end in colon (:). /// Don't do this anymore, since tokens built like this are difficult to "double click to select". /// The modern, Stripe-style token prefixes (which use underscores) are much better. @@ -165,14 +158,6 @@ impl PrefixGenerator for TokenPrefix { } } -impl PrefixGenerator for TauriTokenPrefix { - fn prefix(self) -> &'static str { - match self { - TauriTokenPrefix::Task => "task_", - } - } -} - impl PrefixGenerator for LegacyTokenPrefix { fn prefix(self) -> &'static str { // NB: Old-style colon-suffixed prefixes. Do not use for future tokens! diff --git a/crates/schema/public/tokens/src/tokens/sqlite/mod.rs b/crates/schema/public/tokens/src/tokens/sqlite/mod.rs index e639c06e93..2bb50da5b7 100644 --- a/crates/schema/public/tokens/src/tokens/sqlite/mod.rs +++ b/crates/schema/public/tokens/src/tokens/sqlite/mod.rs @@ -1,3 +1,2 @@ pub mod news_stories; -pub mod tasks; pub mod tts_render_tasks; diff --git a/crates/schema/public/tokens/src/tokens/sqlite/tasks.rs b/crates/schema/public/tokens/src/tokens/sqlite/tasks.rs deleted file mode 100644 index 1a42d6a536..0000000000 --- a/crates/schema/public/tokens/src/tokens/sqlite/tasks.rs +++ /dev/null @@ -1,15 +0,0 @@ -use std::fmt::Debug; - -use serde::Deserialize; -use serde::Serialize; - -use crate::prefixes::TauriTokenPrefix; - -/// The primary key for tasks (Tauri / Sqlite) -#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)] -#[cfg_attr(feature = "database", derive(sqlx::Type))] -#[cfg_attr(feature = "database", sqlx(transparent))] -pub struct TaskId(pub String); - -impl_string_token!(TaskId); -impl_crockford_generator!(TaskId, 32usize, TauriTokenPrefix::Task, CrockfordMixed); diff --git a/crates/tools/servers/agent_notify_server/config/notify_config.yaml b/crates/tools/servers/agent_notify_server/config/notify_config.yaml index b084db7574..53dcfcc09b 100644 --- a/crates/tools/servers/agent_notify_server/config/notify_config.yaml +++ b/crates/tools/servers/agent_notify_server/config/notify_config.yaml @@ -16,20 +16,20 @@ # Paths can be absolute, or relative to this YAML file's directory. alert_beep_sound: test_beep.wav -alert_done_sound: ../../../../../frontend/apps/artcraft/app/public/resources/sound/smrpg_flower.wav -alert_await_user_input_sound: ../../../../../frontend/apps/artcraft/app/public/resources/sound/smrpg_ghost.wav +alert_done_sound: sounds/smrpg_flower.wav +alert_await_user_input_sound: sounds/smrpg_ghost.wav extra_alert_beep_sounds: [] extra_alert_done_sounds: - - ../../../../../frontend/apps/artcraft/app/public/resources/sound/smrpg_specialflower.wav - - ../../../../../frontend/apps/artcraft/app/public/resources/sound/smrpg_correct.wav - - ../../../../../frontend/apps/artcraft/app/public/resources/sound/smrpg_character_extrapower.wav + - sounds/smrpg_specialflower.wav + - sounds/smrpg_correct.wav + - sounds/smrpg_character_extrapower.wav extra_alert_await_sounds: - - ../../../../../frontend/apps/artcraft/app/public/resources/sound/smrpg_wrong.wav - - ../../../../../frontend/apps/artcraft/app/public/resources/sound/smrpg_drybones_crumble.wav - - ../../../../../frontend/apps/artcraft/app/public/resources/sound/smrpg_enemy_spikethrow.wav + - sounds/smrpg_wrong.wav + - sounds/smrpg_drybones_crumble.wav + - sounds/smrpg_enemy_spikethrow.wav loop_alert_timeout_millis: 2000 diff --git a/frontend/apps/artcraft/app/public/resources/sound/smrpg_character_extrapower.wav b/crates/tools/servers/agent_notify_server/config/sounds/smrpg_character_extrapower.wav similarity index 100% rename from frontend/apps/artcraft/app/public/resources/sound/smrpg_character_extrapower.wav rename to crates/tools/servers/agent_notify_server/config/sounds/smrpg_character_extrapower.wav diff --git a/frontend/apps/artcraft/app/public/resources/sound/smrpg_correct.wav b/crates/tools/servers/agent_notify_server/config/sounds/smrpg_correct.wav similarity index 100% rename from frontend/apps/artcraft/app/public/resources/sound/smrpg_correct.wav rename to crates/tools/servers/agent_notify_server/config/sounds/smrpg_correct.wav diff --git a/frontend/apps/artcraft/app/public/resources/sound/smrpg_drybones_crumble.wav b/crates/tools/servers/agent_notify_server/config/sounds/smrpg_drybones_crumble.wav similarity index 100% rename from frontend/apps/artcraft/app/public/resources/sound/smrpg_drybones_crumble.wav rename to crates/tools/servers/agent_notify_server/config/sounds/smrpg_drybones_crumble.wav diff --git a/frontend/apps/artcraft/app/public/resources/sound/smrpg_enemy_spikethrow.wav b/crates/tools/servers/agent_notify_server/config/sounds/smrpg_enemy_spikethrow.wav similarity index 100% rename from frontend/apps/artcraft/app/public/resources/sound/smrpg_enemy_spikethrow.wav rename to crates/tools/servers/agent_notify_server/config/sounds/smrpg_enemy_spikethrow.wav diff --git a/frontend/apps/artcraft/app/public/resources/sound/smrpg_flower.wav b/crates/tools/servers/agent_notify_server/config/sounds/smrpg_flower.wav similarity index 100% rename from frontend/apps/artcraft/app/public/resources/sound/smrpg_flower.wav rename to crates/tools/servers/agent_notify_server/config/sounds/smrpg_flower.wav diff --git a/frontend/apps/artcraft/app/public/resources/sound/smrpg_ghost.wav b/crates/tools/servers/agent_notify_server/config/sounds/smrpg_ghost.wav similarity index 100% rename from frontend/apps/artcraft/app/public/resources/sound/smrpg_ghost.wav rename to crates/tools/servers/agent_notify_server/config/sounds/smrpg_ghost.wav diff --git a/frontend/apps/artcraft/app/public/resources/sound/smrpg_specialflower.wav b/crates/tools/servers/agent_notify_server/config/sounds/smrpg_specialflower.wav similarity index 100% rename from frontend/apps/artcraft/app/public/resources/sound/smrpg_specialflower.wav rename to crates/tools/servers/agent_notify_server/config/sounds/smrpg_specialflower.wav diff --git a/frontend/apps/artcraft/app/public/resources/sound/smrpg_wrong.wav b/crates/tools/servers/agent_notify_server/config/sounds/smrpg_wrong.wav similarity index 100% rename from frontend/apps/artcraft/app/public/resources/sound/smrpg_wrong.wav rename to crates/tools/servers/agent_notify_server/config/sounds/smrpg_wrong.wav diff --git a/crates/vendor/tauri-plugin-http/CHANGELOG.md b/crates/vendor/tauri-plugin-http/CHANGELOG.md deleted file mode 100644 index 4e1fb76b87..0000000000 --- a/crates/vendor/tauri-plugin-http/CHANGELOG.md +++ /dev/null @@ -1,249 +0,0 @@ -# Changelog - -## \[2.4.3] - -- [`37c0477a`](https://github.com/tauri-apps/plugins-workspace/commit/37c0477afe926d326573f1827045875ce8bf8187) ([#2561](https://github.com/tauri-apps/plugins-workspace/pull/2561)) Add `zstd` cargo feature flag to enable `reqwest/zstd` flag. -- [`9ebbfb2e`](https://github.com/tauri-apps/plugins-workspace/commit/9ebbfb2e3ccef8e0f277a0c02fe6b399b41feeb6) ([#1978](https://github.com/tauri-apps/plugins-workspace/pull/1978)) Persist cookies to disk and load it on next app start. - -### Dependencies - -- Upgraded to `fs-js@2.2.1` - -## \[2.4.2] - -- [`a15eedf3`](https://github.com/tauri-apps/plugins-workspace/commit/a15eedf37854344f7ffbcb0d373d848563817011) ([#2535](https://github.com/tauri-apps/plugins-workspace/pull/2535) by [@amrbashir](https://github.com/tauri-apps/plugins-workspace/../../amrbashir)) Fix `fetch` occasionally throwing an error due to trying to close the underline stream twice. - -## \[2.4.1] - -- [`d3183aa9`](https://github.com/tauri-apps/plugins-workspace/commit/d3183aa99da7ca67e627394132ddeb3b85ccef06) ([#2522](https://github.com/tauri-apps/plugins-workspace/pull/2522) by [@adrieljss](https://github.com/tauri-apps/plugins-workspace/../../adrieljss)) Fix `fetch` blocking until the whole response is read even if it was a streaming response. - -## \[2.4.0] - -- [`cb38f54f`](https://github.com/tauri-apps/plugins-workspace/commit/cb38f54f4a4ef30995283cd82166c62da17bac44) ([#2479](https://github.com/tauri-apps/plugins-workspace/pull/2479) by [@adrieljss](https://github.com/tauri-apps/plugins-workspace/../../adrieljss)) Add stream support for HTTP stream responses. - -## \[2.3.0] - -- [`10513649`](https://github.com/tauri-apps/plugins-workspace/commit/105136494c5a5bf4b1f1cc06cc71815412d17ec8) ([#2204](https://github.com/tauri-apps/plugins-workspace/pull/2204) by [@RickeyWard](https://github.com/tauri-apps/plugins-workspace/../../RickeyWard)) Add `dangerous-settings` feature flag and new JS `danger` option to disable tls hostname/certificate validation. - -## \[2.2.0] - -- [`3a79266b`](https://github.com/tauri-apps/plugins-workspace/commit/3a79266b8cf96a55b1ae6339d725567d45a44b1d) ([#2173](https://github.com/tauri-apps/plugins-workspace/pull/2173) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) Bumped all plugins to `v2.2.0`. From now, the versions for the Rust and JavaScript packages of each plugin will be in sync with each other. - -### Dependencies - -- Upgraded to `fs@2.2.0` - -## \[2.0.2] - -### Dependencies - -- Upgraded to `fs-js@2.0.4` - -## \[2.0.4] - -- [`a3b553dd`](https://github.com/tauri-apps/plugins-workspace/commit/a3b553ddb403771aa699362c4e69a064b7731da5) ([#2079](https://github.com/tauri-apps/plugins-workspace/pull/2079) by [@amrbashir](https://github.com/tauri-apps/plugins-workspace/../../amrbashir)) Add tracing logs for requestes and responses behind `tracing` feature flag. - -### Dependencies - -- Upgraded to `fs@2.1.0` - -## \[2.0.3] - -### Dependencies - -- Upgraded to `fs@2.0.3` - -## \[2.0.1] - -- [`cfd48b3b`](https://github.com/tauri-apps/plugins-workspace/commit/cfd48b3b2ec0fccfc162197518694ed59ceda22c) ([#1941](https://github.com/tauri-apps/plugins-workspace/pull/1941) by [@Nipsuli](https://github.com/tauri-apps/plugins-workspace/../../Nipsuli)) Allow skipping sending `Origin` header in HTTP requests by setting `Origin` header to an empty string when calling `fetch`. -- [`9b2840db`](https://github.com/tauri-apps/plugins-workspace/commit/9b2840db9464cf08db75806270e4441f0af81e5d) ([#1884](https://github.com/tauri-apps/plugins-workspace/pull/1884) by [@amrbashir](https://github.com/tauri-apps/plugins-workspace/../../amrbashir)) Retain headers order. - -## \[2.0.1] - -- [`a1a82208`](https://github.com/tauri-apps/plugins-workspace/commit/a1a82208ed4ab87f83310be0dc95428aec9ab241) ([#1873](https://github.com/tauri-apps/plugins-workspace/pull/1873) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Downgrade MSRV to 1.77.2 to support Windows 7. - -### Dependencies - -- Upgraded to `fs@2.0.1` - -## \[2.0.0] - -- [`e2c4dfb6`](https://github.com/tauri-apps/plugins-workspace/commit/e2c4dfb6af43e5dd8d9ceba232c315f5febd55c1) Update to tauri v2 stable release. - -### Dependencies - -- Upgraded to `fs@2.0.0` - -## \[2.0.0-rc.6] - -### Dependencies - -- Upgraded to `fs@2.0.0-rc.6` - -## \[2.0.0-rc.5] - -### Dependencies - -- Upgraded to `fs@2.0.0-rc.5` - -## \[2.0.0-rc.4] - -### Dependencies - -- Upgraded to `fs@2.0.0-rc.4` - -## \[2.0.0-rc.3] - -### Dependencies - -- Upgraded to `fs@2.0.0-rc.3` - -## \[2.0.0-rc.2] - -### Dependencies - -- Upgraded to `fs@2.0.0-rc.2` - -## \[2.0.0-rc.2] - -- [`e2e97db5`](https://github.com/tauri-apps/plugins-workspace/commit/e2e97db51983267f5be84d4f6f0278d58834d1f5) ([#1701](https://github.com/tauri-apps/plugins-workspace/pull/1701) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Update to tauri 2.0.0-rc.8 - -## \[2.0.0-rc.1] - -- [`84f8bd5e`](https://github.com/tauri-apps/plugins-workspace/commit/84f8bd5e1ef22e664267380b5bbf756ebc5389c3) ([#1662](https://github.com/tauri-apps/plugins-workspace/pull/1662) by [@twlite](https://github.com/tauri-apps/plugins-workspace/../../twlite)) Fixed an issue with abort signal not aborting the fetch request. - -## \[2.0.0-rc.0] - -- [`9887d1`](https://github.com/tauri-apps/plugins-workspace/commit/9887d14bd0e971c4c0f5c1188fc4005d3fc2e29e) Update to tauri RC. - -### Dependencies - -- Upgraded to `fs@2.0.0-rc.0` - -## \[2.0.0-beta.9] - -- [`99d6ac0f`](https://github.com/tauri-apps/plugins-workspace/commit/99d6ac0f9506a6a4a1aa59c728157190a7441af6) ([#1606](https://github.com/tauri-apps/plugins-workspace/pull/1606) by [@FabianLars](https://github.com/tauri-apps/plugins-workspace/../../FabianLars)) The JS packages now specify the *minimum* `@tauri-apps/api` version instead of a single exact version. -- [`6de87966`](https://github.com/tauri-apps/plugins-workspace/commit/6de87966ecc00ad9d91c25be452f1f46bd2b7e1f) ([#1597](https://github.com/tauri-apps/plugins-workspace/pull/1597) by [@Legend-Master](https://github.com/tauri-apps/plugins-workspace/../../Legend-Master)) Update to tauri beta.25. - -## \[2.0.0-beta.8] - -- [`ac9a25cc`](https://github.com/tauri-apps/plugins-workspace/commit/ac9a25cc12ee2b325f00212ba74316da3369bde5) ([#1395](https://github.com/tauri-apps/plugins-workspace/pull/1395) by [@amrbashir](https://github.com/tauri-apps/plugins-workspace/../../amrbashir)) Fix cancelling requests using `AbortSignal`. -- [`a6654932`](https://github.com/tauri-apps/plugins-workspace/commit/a66549329c60dea35e3a06a38c357e368c9053a1) ([#1526](https://github.com/tauri-apps/plugins-workspace/pull/1526) by [@amrbashir](https://github.com/tauri-apps/plugins-workspace/../../amrbashir)) Fix missing `Set-Cookie` headers in the response which meant `request.headers.getSetCookie()` always returned empty array. -- [`22a17980`](https://github.com/tauri-apps/plugins-workspace/commit/22a17980ff4f6f8c40adb1b8f4ffc6dae2fe7e30) ([#1537](https://github.com/tauri-apps/plugins-workspace/pull/1537) by [@lucasfernog](https://github.com/tauri-apps/plugins-workspace/../../lucasfernog)) Update to tauri beta.24. - -## \[2.0.0-beta.7] - -- [`76daee7a`](https://github.com/tauri-apps/plugins-workspace/commit/76daee7aafece34de3092c86e531cf9eb1138989) ([#1512](https://github.com/tauri-apps/plugins-workspace/pull/1512) by [@renovate](https://github.com/tauri-apps/plugins-workspace/../../renovate)) Update to tauri beta.23. - -## \[2.0.0-beta.6] - -- [`0f739dbc`](https://github.com/tauri-apps/plugins-workspace/commit/0f739dbc483a1f091977cbe575c3862fd39f8cf1) ([#1392](https://github.com/tauri-apps/plugins-workspace/pull/1392) by [@amrbashir](https://github.com/tauri-apps/plugins-workspace/../../amrbashir)) Allow setting `Origin` header when `unsafe-headers` feature flag is active. - -## \[2.0.0-beta.5] - -- [`9013854f`](https://github.com/tauri-apps/plugins-workspace/commit/9013854f42a49a230b9dbb9d02774765528a923f)([#1382](https://github.com/tauri-apps/plugins-workspace/pull/1382)) Update to tauri beta.22. - -## \[2.0.0-beta.4] - -- [`9d7ae45b`](https://github.com/tauri-apps/plugins-workspace/commit/9d7ae45b0edf9b22c73e7d7c413a784bb35c3d77)([#1354](https://github.com/tauri-apps/plugins-workspace/pull/1354)) Include headers created by browser if not declared by user, which fixes missing headers like `Content-Type` when using `FormData`. -- [`430bd6f4`](https://github.com/tauri-apps/plugins-workspace/commit/430bd6f4f379bee5d232ae6b098ae131db7f178a)([#1363](https://github.com/tauri-apps/plugins-workspace/pull/1363)) Update to tauri beta.20. - -## \[2.0.0-beta.3] - -- [`bd1ed590`](https://github.com/tauri-apps/plugins-workspace/commit/bd1ed5903ffcce5500310dac1e59e8c67674ef1e)([#1237](https://github.com/tauri-apps/plugins-workspace/pull/1237)) Update to tauri beta.17. - -## \[2.0.0-beta.6] - -### Dependencies - -- Upgraded to `fs@2.0.0-beta.6` - -## \[2.0.0-beta.5] - -- [`500ff10`](https://github.com/tauri-apps/plugins-workspace/commit/500ff10fbd89fdfc73caf9d153029dad567b4ff1)([#1166](https://github.com/tauri-apps/plugins-workspace/pull/1166)) **Breaking change:** Removed the `default-tls` feature flag. The `rustls-tls`, `http2`, `macos-system-configuration`, and `charset` feature flags are now enabled by default. -- [`e3d41f4`](https://github.com/tauri-apps/plugins-workspace/commit/e3d41f4011bd3ea3ce281bb38bbe31d3709f8e0f)([#1191](https://github.com/tauri-apps/plugins-workspace/pull/1191)) Internally use the webview scoped resources table instead of the app one, so other webviews can't access other webviews resources. -- [`7e2fcc5`](https://github.com/tauri-apps/plugins-workspace/commit/7e2fcc5e74df7c3c718e40f75bfb0eafc7d69d8d)([#1146](https://github.com/tauri-apps/plugins-workspace/pull/1146)) Update dependencies to align with tauri 2.0.0-beta.14. -- [`e3d41f4`](https://github.com/tauri-apps/plugins-workspace/commit/e3d41f4011bd3ea3ce281bb38bbe31d3709f8e0f)([#1191](https://github.com/tauri-apps/plugins-workspace/pull/1191)) Update for tauri 2.0.0-beta.15. - -### Dependencies - -- Upgraded to `fs@2.0.0-beta.5` - -## \[2.0.0-beta.4] - -### Dependencies - -- Upgraded to `fs@2.0.0-beta.4` - -## \[2.0.0-beta.3] - -- [`c873e4d`](https://github.com/tauri-apps/plugins-workspace/commit/c873e4d6c74e759742f7c9a88e35cff10a75122a)([#1059](https://github.com/tauri-apps/plugins-workspace/pull/1059)) Fixes scope not allowing subpaths, query parameters and hash when those values are empty. -- [`a04ea2f`](https://github.com/tauri-apps/plugins-workspace/commit/a04ea2f38294d5a3987578283badc8eec87a7752)([#1071](https://github.com/tauri-apps/plugins-workspace/pull/1071)) The global API script is now only added to the binary when the `withGlobalTauri` config is true. -- [`753c7be`](https://github.com/tauri-apps/plugins-workspace/commit/753c7be0a6a78121d2e88ea0efc3040580c885b4)([#1050](https://github.com/tauri-apps/plugins-workspace/pull/1050)) Add `unsafe-headers` cargo feature flag to allow using [forbidden headers](https://fetch.spec.whatwg.org/#terminology-headers). - -### Dependencies - -- Upgraded to `fs@2.0.0-beta.3` - -## \[2.0.0-beta.2] - -- [`ae56b13`](https://github.com/tauri-apps/plugins-workspace/commit/ae56b13a4d49dbf922b8a0fbb0d557bb63c1d72b)([#983](https://github.com/tauri-apps/plugins-workspace/pull/983)) Allow `User-Agent` header to be set. -- [`99bea25`](https://github.com/tauri-apps/plugins-workspace/commit/99bea2559c2c0648c2519c50a18cd124dacef57b)([#1005](https://github.com/tauri-apps/plugins-workspace/pull/1005)) Update to tauri beta.8. - -## \[2.0.0-beta.1] - -- [`569defb`](https://github.com/tauri-apps/plugins-workspace/commit/569defbe9492e38938554bb7bdc1be9151456d21) Update to tauri beta.4. - -## \[2.0.0-beta.0] - -- [`d198c01`](https://github.com/tauri-apps/plugins-workspace/commit/d198c014863ee260cb0de88a14b7fc4356ef7474)([#862](https://github.com/tauri-apps/plugins-workspace/pull/862)) Update to tauri beta. -- [`1a34720`](https://github.com/tauri-apps/plugins-workspace/commit/1a347203a54eccc954749d11c4ee81fdd9a0cde7)([#858](https://github.com/tauri-apps/plugins-workspace/pull/858)) Fix http fetch client option init with parameter `connectTimeout` - -## \[2.0.0-alpha.9] - -### Dependencies - -- Upgraded to `fs@2.0.0-alpha.7` - -## \[2.0.0-alpha.6] - -- [`bfa87da`](https://github.com/tauri-apps/plugins-workspace/commit/bfa87da848f9f1da2abae3354eed632881eddf11)([#824](https://github.com/tauri-apps/plugins-workspace/pull/824)) Add `proxy` field to `fetch` options to configure proxy. - -## \[2.0.0-alpha.5] - -- [`387c2f9`](https://github.com/tauri-apps/plugins-workspace/commit/387c2f9e0ce4c75c07ffa3fd76391a25b58f5daf)([#802](https://github.com/tauri-apps/plugins-workspace/pull/802)) Update to @tauri-apps/api v2.0.0-alpha.13. - -## \[2.0.0-alpha.4] - -- [`387c2f9`](https://github.com/tauri-apps/plugins-workspace/commit/387c2f9e0ce4c75c07ffa3fd76391a25b58f5daf)([#802](https://github.com/tauri-apps/plugins-workspace/pull/802)) Update to @tauri-apps/api v2.0.0-alpha.12. - -## \[2.0.0-alpha.3] - -- [`e438e0a`](https://github.com/tauri-apps/plugins-workspace/commit/e438e0a62d4b430a5159f05f13ecd397dd891a0d)([#676](https://github.com/tauri-apps/plugins-workspace/pull/676)) Update to @tauri-apps/api v2.0.0-alpha.11. - -## \[2.0.0-alpha.2] - -- [`5c13736`](https://github.com/tauri-apps/plugins-workspace/commit/5c137365c60790e8d4037d449e8237aa3fffdab0)([#673](https://github.com/tauri-apps/plugins-workspace/pull/673)) Update to @tauri-apps/api v2.0.0-alpha.9. - -## \[2.0.0-alpha.3] - -- [`2cb0fa7`](https://github.com/tauri-apps/plugins-workspace/commit/2cb0fa719b8b1f5ac07dada93520dbbcf637d64c)([#587](https://github.com/tauri-apps/plugins-workspace/pull/587)) Remove `cmd` property which breaks invoke call. -- [`4e2cef9`](https://github.com/tauri-apps/plugins-workspace/commit/4e2cef9b702bbbb9cf4ee17de50791cb21f1b2a4)([#593](https://github.com/tauri-apps/plugins-workspace/pull/593)) Update to alpha.12. - -### Dependencies - -- Upgraded to `fs@2.0.0-alpha.2` - -## \[2.0.0-alpha.2] - -- [`aec17a9`](https://github.com/tauri-apps/plugins-workspace/commit/aec17a90fc365774c70c4876b94a899416120e26)([#558](https://github.com/tauri-apps/plugins-workspace/pull/558)) Improve response performance by using the new IPC streaming data. - -## \[2.0.0-alpha.1] - -- [`7d9df72`](https://github.com/tauri-apps/plugins-workspace/commit/7d9df7297a221a64d9de945ffc2cd8313d3104dc)([#428](https://github.com/tauri-apps/plugins-workspace/pull/428)) Multipart requests are now handled in JavaScript by the `Request` JavaScript class so you just need to use a `FormData` body and not set the content-type header to `multipart/form-data`. `application/x-www-form-urlencoded` requests must be done manually. -- [`7d9df72`](https://github.com/tauri-apps/plugins-workspace/commit/7d9df7297a221a64d9de945ffc2cd8313d3104dc)([#428](https://github.com/tauri-apps/plugins-workspace/pull/428)) The http plugin has been rewritten from scratch and now only exposes a `fetch` function in Javascript and Re-exports `reqwest` crate in Rust. The new `fetch` method tries to be as close and compliant to the `fetch` Web API as possible. -- [`d74fc0a`](https://github.com/tauri-apps/plugins-workspace/commit/d74fc0a097996e90a37be8f57d50b7d1f6ca616f)([#555](https://github.com/tauri-apps/plugins-workspace/pull/555)) Update to alpha.11. - -## \[2.0.0-alpha.0] - -- [`717ae67`](https://github.com/tauri-apps/plugins-workspace/commit/717ae670978feb4492fac1f295998b93f2b9347f)([#371](https://github.com/tauri-apps/plugins-workspace/pull/371)) First v2 alpha release! diff --git a/crates/vendor/tauri-plugin-http/Cargo.toml b/crates/vendor/tauri-plugin-http/Cargo.toml deleted file mode 100644 index fd5fb7c577..0000000000 --- a/crates/vendor/tauri-plugin-http/Cargo.toml +++ /dev/null @@ -1,88 +0,0 @@ -# NB(bt): We've made some changes to the packages and directives. -# The original values are commented out. - -[package] -name = "tauri-plugin-http" -version = "2.4.3" -description = "Access an HTTP client written in Rust." -#edition = { workspace = true } -edition = "2021" -#authors = { workspace = true } -#license = { workspace = true } -#rust-version = { workspace = true } -rust-version = "1.77.2" -#repository = { workspace = true } -links = "tauri-plugin-http" - -[package.metadata.docs.rs] -rustc-args = ["--cfg", "docsrs"] -rustdoc-args = ["--cfg", "docsrs"] - -[package.metadata.platforms.support] -windows = { level = "full", notes = "" } -linux = { level = "full", notes = "" } -macos = { level = "full", notes = "" } -android = { level = "full", notes = "" } -ios = { level = "full", notes = "" } - -[build-dependencies] -#tauri-plugin = { workspace = true, features = ["build"] } -tauri-plugin = { version = "2.6.2", features = ["build"] } -#schemars = { workspace = true } -schemars = { version = "0.8" } -serde = { workspace = true } -url = { workspace = true } -urlpattern = "0.3" -regex = "1" - -[dependencies] -serde = { workspace = true } -serde_json = { workspace = true } -tauri = { workspace = true } -thiserror = { workspace = true } -tokio = { version = "1", features = ["sync", "macros"] } -#tauri-plugin-fs = { path = "../fs", version = "2.2.1" } -tauri-plugin-fs = { workspace = true } -urlpattern = "0.3" -regex = "1" -http = "1" -reqwest = { version = "0.12", default-features = false } -url = { workspace = true } -data-url = "0.3" -cookie_store = { version = "0.21.1", optional = true, features = ["serde"] } -bytes = { version = "1.9", optional = true } -#tracing = { workspace = true, optional = true } -tracing = { version = "0.1", optional = true } - -[features] -default = [ - "rustls-tls", - "http2", - "charset", - "macos-system-configuration", - "cookies", -] -multipart = ["reqwest/multipart"] -json = ["reqwest/json"] -stream = ["reqwest/stream"] -native-tls = ["reqwest/native-tls"] -native-tls-vendored = ["reqwest/native-tls-vendored"] -native-tls-alpn = ["reqwest/native-tls-alpn"] -rustls-tls = ["reqwest/rustls-tls"] -rustls-tls-manual-roots = ["reqwest/rustls-tls-manual-roots"] -rustls-tls-webpki-roots = ["reqwest/rustls-tls-webpki-roots"] -rustls-tls-native-roots = ["reqwest/rustls-tls-native-roots"] -blocking = ["reqwest/blocking"] -cookies = ["reqwest/cookies", "dep:cookie_store", "dep:bytes"] -gzip = ["reqwest/gzip"] -brotli = ["reqwest/brotli"] -deflate = ["reqwest/deflate"] -zstd = ["reqwest/zstd"] -trust-dns = ["reqwest/trust-dns"] -socks = ["reqwest/socks"] -http2 = ["reqwest/http2"] -charset = ["reqwest/charset"] -macos-system-configuration = ["reqwest/macos-system-configuration"] -unsafe-headers = [] -tracing = ["dep:tracing"] -dangerous-settings = [] diff --git a/crates/vendor/tauri-plugin-http/LICENSE.spdx b/crates/vendor/tauri-plugin-http/LICENSE.spdx deleted file mode 100644 index cdd0df5ad7..0000000000 --- a/crates/vendor/tauri-plugin-http/LICENSE.spdx +++ /dev/null @@ -1,20 +0,0 @@ -SPDXVersion: SPDX-2.1 -DataLicense: CC0-1.0 -PackageName: tauri -DataFormat: SPDXRef-1 -PackageSupplier: Organization: The Tauri Programme in the Commons Conservancy -PackageHomePage: https://tauri.app -PackageLicenseDeclared: Apache-2.0 -PackageLicenseDeclared: MIT -PackageCopyrightText: 2019-2022, The Tauri Programme in the Commons Conservancy -PackageSummary: Tauri is a rust project that enables developers to make secure -and small desktop applications using a web frontend. - -PackageComment: The package includes the following libraries; see -Relationship information. - -Created: 2019-05-20T09:00:00Z -PackageDownloadLocation: git://github.com/tauri-apps/tauri -PackageDownloadLocation: git+https://github.com/tauri-apps/tauri.git -PackageDownloadLocation: git+ssh://github.com/tauri-apps/tauri.git -Creator: Person: Daniel Thompson-Yvetot \ No newline at end of file diff --git a/crates/vendor/tauri-plugin-http/LICENSE_APACHE-2.0 b/crates/vendor/tauri-plugin-http/LICENSE_APACHE-2.0 deleted file mode 100644 index 4947287f7b..0000000000 --- a/crates/vendor/tauri-plugin-http/LICENSE_APACHE-2.0 +++ /dev/null @@ -1,177 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS \ No newline at end of file diff --git a/crates/vendor/tauri-plugin-http/LICENSE_MIT b/crates/vendor/tauri-plugin-http/LICENSE_MIT deleted file mode 100644 index 4d75472566..0000000000 --- a/crates/vendor/tauri-plugin-http/LICENSE_MIT +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2017 - Present Tauri Apps Contributors - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file diff --git a/crates/vendor/tauri-plugin-http/README.md b/crates/vendor/tauri-plugin-http/README.md deleted file mode 100644 index 5c3cd9c2e2..0000000000 --- a/crates/vendor/tauri-plugin-http/README.md +++ /dev/null @@ -1,102 +0,0 @@ -![plugin-http](https://github.com/tauri-apps/plugins-workspace/raw/v2/plugins/http/banner.png) - -Access the HTTP client written in Rust. - -| Platform | Supported | -| -------- | --------- | -| Linux | ✓ | -| Windows | ✓ | -| macOS | ✓ | -| Android | ✓ | -| iOS | ✓ | - -## Install - -_This plugin requires a Rust version of at least **1.77.2**_ - -There are three general methods of installation that we can recommend. - -1. Use crates.io and npm (easiest, and requires you to trust that our publishing pipeline worked) -2. Pull sources directly from Github using git tags / revision hashes (most secure) -3. Git submodule install this repo in your tauri project and then use file protocol to ingest the source (most secure, but inconvenient to use) - -Install the Core plugin by adding the following to your `Cargo.toml` file: - -`src-tauri/Cargo.toml` - -```toml -[dependencies] -tauri-plugin-http = "2.0.0" -# alternatively with Git: -tauri-plugin-http = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } -``` - -You can install the JavaScript Guest bindings using your preferred JavaScript package manager: - -> Note: Since most JavaScript package managers are unable to install packages from git monorepos we provide read-only mirrors of each plugin. This makes installation option 2 more ergonomic to use. - -```sh -pnpm add @tauri-apps/plugin-http -# or -npm add @tauri-apps/plugin-http -# or -yarn add @tauri-apps/plugin-http - -# alternatively with Git: -pnpm add https://github.com/tauri-apps/tauri-plugin-http#v2 -# or -npm add https://github.com/tauri-apps/tauri-plugin-http#v2 -# or -yarn add https://github.com/tauri-apps/tauri-plugin-http#v2 -``` - -## Usage - -First you need to register the core plugin with Tauri: - -`src-tauri/src/lib.rs` - -```rust -fn main() { - tauri::Builder::default() - .plugin(tauri_plugin_http::init()) - .run(tauri::generate_context!()) - .expect("error while running tauri application"); -} -``` - -Afterwards all the plugin's APIs are available through the JavaScript guest bindings: - -```javascript -import { fetch } from '@tauri-apps/plugin-http' -const response = await fetch('http://localhost:3003/users/2', { - method: 'GET', - timeout: 30 -}) -``` - -## Contributing - -PRs accepted. Please make sure to read the Contributing Guide before making a pull request. - -## Partners - - - - - - - -
- - CrabNebula - -
- -For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri). - -## License - -Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy. - -MIT or MIT/Apache 2.0 where applicable. diff --git a/crates/vendor/tauri-plugin-http/SECURITY.md b/crates/vendor/tauri-plugin-http/SECURITY.md deleted file mode 100644 index 4f09bbacd4..0000000000 --- a/crates/vendor/tauri-plugin-http/SECURITY.md +++ /dev/null @@ -1,23 +0,0 @@ -# Security Policy - -**Do not report security vulnerabilities through public GitHub issues.** - -**Please use the [Private Vulnerability Disclosure](https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing-information-about-vulnerabilities/privately-reporting-a-security-vulnerability#privately-reporting-a-security-vulnerability) feature of GitHub.** - -Include as much of the following information: - -- Type of issue (e.g. improper input parsing, privilege escalation, etc.) -- The location of the affected source code (tag/branch/commit or direct URL) -- Any special configuration required to reproduce the issue -- The distribution affected or used to help us with reproduction of the issue -- Step-by-step instructions to reproduce the issue -- Ideally a reproduction repository -- Impact of the issue, including how an attacker might exploit the issue - -We prefer to receive reports in English. - -## Contact - -Please disclose a vulnerability or security relevant issue here: [https://github.com/tauri-apps/plugins-workspace/security/advisories/new](https://github.com/tauri-apps/plugins-workspace/security/advisories/new). - -Alternatively, you can also contact us by email via [security@tauri.app](mailto:security@tauri.app). diff --git a/crates/vendor/tauri-plugin-http/api-iife.js b/crates/vendor/tauri-plugin-http/api-iife.js deleted file mode 100644 index 70b99c24e6..0000000000 --- a/crates/vendor/tauri-plugin-http/api-iife.js +++ /dev/null @@ -1 +0,0 @@ -if("__TAURI__"in window){var __TAURI_PLUGIN_HTTP__=function(e){"use strict";function t(e,t,r,n){if("function"==typeof t||!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(e):n?n.value:t.get(e)}function r(e,t,r,n,s){if("function"==typeof t||!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return t.set(e,r),r}var n,s,i,a;"function"==typeof SuppressedError&&SuppressedError;const o="__TAURI_TO_IPC_KEY__";class c{constructor(e){n.set(this,void 0),s.set(this,0),i.set(this,[]),a.set(this,void 0),r(this,n,e||(()=>{})),this.id=function(e,t=!1){return window.__TAURI_INTERNALS__.transformCallback(e,t)}((e=>{const o=e.index;if("end"in e)return void(o==t(this,s,"f")?this.cleanupCallback():r(this,a,o));const c=e.message;if(o==t(this,s,"f")){for(t(this,n,"f").call(this,c),r(this,s,t(this,s,"f")+1);t(this,s,"f")in t(this,i,"f");){const e=t(this,i,"f")[t(this,s,"f")];t(this,n,"f").call(this,e),delete t(this,i,"f")[t(this,s,"f")],r(this,s,t(this,s,"f")+1)}t(this,s,"f")===t(this,a,"f")&&this.cleanupCallback()}else t(this,i,"f")[o]=c}))}cleanupCallback(){Reflect.deleteProperty(window,`_${this.id}`)}set onmessage(e){r(this,n,e)}get onmessage(){return t(this,n,"f")}[(n=new WeakMap,s=new WeakMap,i=new WeakMap,a=new WeakMap,o)](){return`__CHANNEL__:${this.id}`}toJSON(){return this[o]()}}async function d(e,t={},r){return window.__TAURI_INTERNALS__.invoke(e,t,r)}const h="Request cancelled";return e.fetch=async function(e,t){const r=t?.signal;if(r?.aborted)throw new Error(h);const n=t?.maxRedirections,s=t?.connectTimeout,i=t?.proxy,a=t?.danger;t&&(delete t.maxRedirections,delete t.connectTimeout,delete t.proxy,delete t.danger);const o=t?.headers?t.headers instanceof Headers?t.headers:new Headers(t.headers):new Headers,f=new Request(e,t),l=await f.arrayBuffer(),u=0!==l.byteLength?Array.from(new Uint8Array(l)):null;for(const[e,t]of f.headers)o.get(e)||o.set(e,t);const _=(o instanceof Headers?Array.from(o.entries()):Array.isArray(o)?o:Object.entries(o)).map((([e,t])=>[e,"string"==typeof t?t:t.toString()]));if(r?.aborted)throw new Error(h);const w=await d("plugin:http|fetch",{clientConfig:{method:f.method,url:f.url,headers:_,data:u,maxRedirections:n,connectTimeout:s,proxy:i,danger:a}}),p=()=>d("plugin:http|fetch_cancel",{rid:w});if(r?.aborted)throw p(),new Error(h);r?.addEventListener("abort",(()=>{p()}));const{status:y,statusText:m,url:b,headers:g,rid:T}=await d("plugin:http|fetch_send",{rid:w}),R=[101,103,204,205,304].includes(y)?null:new ReadableStream({start:e=>{const t=new c;t.onmessage=t=>{if(r?.aborted)return void e.error(h);const n=new Uint8Array(t),s=n[n.byteLength-1],i=n.slice(0,n.byteLength-1);1!=s?e.enqueue(i):e.close()},d("plugin:http|fetch_read_body",{rid:T,streamChannel:t}).catch((t=>{e.error(t)}))}}),A=new Response(R,{status:y,statusText:m});return Object.defineProperty(A,"url",{value:b}),Object.defineProperty(A,"headers",{value:new Headers(g)}),A},e}({});Object.defineProperty(window.__TAURI__,"http",{value:__TAURI_PLUGIN_HTTP__})} diff --git a/crates/vendor/tauri-plugin-http/banner.png b/crates/vendor/tauri-plugin-http/banner.png deleted file mode 100644 index 121741e51b..0000000000 Binary files a/crates/vendor/tauri-plugin-http/banner.png and /dev/null differ diff --git a/crates/vendor/tauri-plugin-http/build.rs b/crates/vendor/tauri-plugin-http/build.rs deleted file mode 100644 index a4b802adf5..0000000000 --- a/crates/vendor/tauri-plugin-http/build.rs +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2019-2023 Tauri Programme within The Commons Conservancy -// SPDX-License-Identifier: Apache-2.0 -// SPDX-License-Identifier: MIT - -#[path = "src/scope.rs"] -#[allow(dead_code)] -mod scope; - -const COMMANDS: &[&str] = &["fetch", "fetch_cancel", "fetch_send", "fetch_read_body"]; - -/// HTTP scope entry. -#[derive(schemars::JsonSchema)] -#[serde(untagged)] -#[allow(unused)] -enum HttpScopeEntry { - /// A URL that can be accessed by the webview when using the HTTP APIs. - /// Wildcards can be used following the URL pattern standard. - /// - /// See [the URL Pattern spec](https://urlpattern.spec.whatwg.org/) for more information. - /// - /// Examples: - /// - /// - "https://*" : allows all HTTPS origin on port 443 - /// - /// - "https://*:*" : allows all HTTPS origin on any port - /// - /// - "https://*.github.com/tauri-apps/tauri": allows any subdomain of "github.com" with the "tauri-apps/api" path - /// - /// - "https://myapi.service.com/users/*": allows access to any URLs that begins with "https://myapi.service.com/users/" - Value(String), - Object { - /// A URL that can be accessed by the webview when using the HTTP APIs. - /// Wildcards can be used following the URL pattern standard. - /// - /// See [the URL Pattern spec](https://urlpattern.spec.whatwg.org/) for more information. - /// - /// Examples: - /// - /// - "https://*" : allows all HTTPS origin on port 443 - /// - /// - "https://*:*" : allows all HTTPS origin on any port - /// - /// - "https://*.github.com/tauri-apps/tauri": allows any subdomain of "github.com" with the "tauri-apps/api" path - /// - /// - "https://myapi.service.com/users/*": allows access to any URLs that begins with "https://myapi.service.com/users/" - url: String, - }, -} - -// Ensure `HttpScopeEntry` and `scope::EntryRaw` is kept in sync -fn _f() { - match scope::EntryRaw::Value(String::new()) { - scope::EntryRaw::Value(url) => HttpScopeEntry::Value(url), - scope::EntryRaw::Object { url } => HttpScopeEntry::Object { url }, - }; - match HttpScopeEntry::Value(String::new()) { - HttpScopeEntry::Value(url) => scope::EntryRaw::Value(url), - HttpScopeEntry::Object { url } => scope::EntryRaw::Object { url }, - }; -} - -fn main() { - tauri_plugin::Builder::new(COMMANDS) - .global_api_script_path("./api-iife.js") - .global_scope_schema(schemars::schema_for!(HttpScopeEntry)) - .build(); -} diff --git a/crates/vendor/tauri-plugin-http/dist-js/index.cjs b/crates/vendor/tauri-plugin-http/dist-js/index.cjs deleted file mode 100644 index 93f343848c..0000000000 --- a/crates/vendor/tauri-plugin-http/dist-js/index.cjs +++ /dev/null @@ -1,166 +0,0 @@ -'use strict'; - -var core = require('@tauri-apps/api/core'); - -// Copyright 2019-2023 Tauri Programme within The Commons Conservancy -// SPDX-License-Identifier: Apache-2.0 -// SPDX-License-Identifier: MIT -/** - * Make HTTP requests with the Rust backend. - * - * ## Security - * - * This API has a scope configuration that forces you to restrict the URLs that can be accessed using glob patterns. - * - * For instance, this scope configuration only allows making HTTP requests to all subdomains for `tauri.app` except for `https://private.tauri.app`: - * ```json - * { - * "permissions": [ - * { - * "identifier": "http:default", - * "allow": [{ "url": "https://*.tauri.app" }], - * "deny": [{ "url": "https://private.tauri.app" }] - * } - * ] - * } - * ``` - * Trying to execute any API with a URL not configured on the scope results in a promise rejection due to denied access. - * - * @module - */ -const ERROR_REQUEST_CANCELLED = 'Request cancelled'; -/** - * Fetch a resource from the network. It returns a `Promise` that resolves to the - * `Response` to that `Request`, whether it is successful or not. - * - * @example - * ```typescript - * const response = await fetch("http://my.json.host/data.json"); - * console.log(response.status); // e.g. 200 - * console.log(response.statusText); // e.g. "OK" - * const jsonData = await response.json(); - * ``` - * - * @since 2.0.0 - */ -async function fetch(input, init) { - // abort early here if needed - const signal = init?.signal; - if (signal?.aborted) { - throw new Error(ERROR_REQUEST_CANCELLED); - } - const maxRedirections = init?.maxRedirections; - const connectTimeout = init?.connectTimeout; - const proxy = init?.proxy; - const danger = init?.danger; - // Remove these fields before creating the request - if (init) { - delete init.maxRedirections; - delete init.connectTimeout; - delete init.proxy; - delete init.danger; - } - const headers = init?.headers - ? init.headers instanceof Headers - ? init.headers - : new Headers(init.headers) - : new Headers(); - const req = new Request(input, init); - const buffer = await req.arrayBuffer(); - const data = buffer.byteLength !== 0 ? Array.from(new Uint8Array(buffer)) : null; - // append new headers created by the browser `Request` implementation, - // if not already declared by the caller of this function - for (const [key, value] of req.headers) { - if (!headers.get(key)) { - headers.set(key, value); - } - } - const headersArray = headers instanceof Headers - ? Array.from(headers.entries()) - : Array.isArray(headers) - ? headers - : Object.entries(headers); - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment - const mappedHeaders = headersArray.map(([name, val]) => [ - name, - // we need to ensure we have all header values as strings - // eslint-disable-next-line - typeof val === 'string' ? val : val.toString() - ]); - // abort early here if needed - if (signal?.aborted) { - throw new Error(ERROR_REQUEST_CANCELLED); - } - const rid = await core.invoke('plugin:http|fetch', { - clientConfig: { - method: req.method, - url: req.url, - headers: mappedHeaders, - data, - maxRedirections, - connectTimeout, - proxy, - danger - } - }); - const abort = () => core.invoke('plugin:http|fetch_cancel', { rid }); - // abort early here if needed - if (signal?.aborted) { - // we don't care about the result of this proimse - // eslint-disable-next-line @typescript-eslint/no-floating-promises - abort(); - throw new Error(ERROR_REQUEST_CANCELLED); - } - signal?.addEventListener('abort', () => void abort()); - const { status, statusText, url, headers: responseHeaders, rid: responseRid } = await core.invoke('plugin:http|fetch_send', { - rid - }); - // no body for 101, 103, 204, 205 and 304 - // see https://fetch.spec.whatwg.org/#null-body-status - const body = [101, 103, 204, 205, 304].includes(status) - ? null - : new ReadableStream({ - start: (controller) => { - const streamChannel = new core.Channel(); - streamChannel.onmessage = (res) => { - // close early if aborted - if (signal?.aborted) { - controller.error(ERROR_REQUEST_CANCELLED); - return; - } - const resUint8 = new Uint8Array(res); - const lastByte = resUint8[resUint8.byteLength - 1]; - const actualRes = resUint8.slice(0, resUint8.byteLength - 1); - // close when the signal to close (last byte is 1) is sent from the IPC. - if (lastByte == 1) { - controller.close(); - return; - } - controller.enqueue(actualRes); - }; - // run a non-blocking body stream fetch - core.invoke('plugin:http|fetch_read_body', { - rid: responseRid, - streamChannel - }).catch((e) => { - controller.error(e); - }); - } - }); - const res = new Response(body, { - status, - statusText - }); - // Set `Response` properties that are ignored by the - // constructor, like url and some headers - // - // Since url and headers are read only properties - // this is the only way to set them. - Object.defineProperty(res, 'url', { value: url }); - Object.defineProperty(res, 'headers', { - value: new Headers(responseHeaders) - }); - return res; -} - -exports.fetch = fetch; diff --git a/crates/vendor/tauri-plugin-http/dist-js/index.d.ts b/crates/vendor/tauri-plugin-http/dist-js/index.d.ts deleted file mode 100644 index b030d62112..0000000000 --- a/crates/vendor/tauri-plugin-http/dist-js/index.d.ts +++ /dev/null @@ -1,89 +0,0 @@ -/** - * Configuration of a proxy that a Client should pass requests to. - * - * @since 2.0.0 - */ -export interface Proxy { - /** - * Proxy all traffic to the passed URL. - */ - all?: string | ProxyConfig; - /** - * Proxy all HTTP traffic to the passed URL. - */ - http?: string | ProxyConfig; - /** - * Proxy all HTTPS traffic to the passed URL. - */ - https?: string | ProxyConfig; -} -export interface ProxyConfig { - /** - * The URL of the proxy server. - */ - url: string; - /** - * Set the `Proxy-Authorization` header using Basic auth. - */ - basicAuth?: { - username: string; - password: string; - }; - /** - * A configuration for filtering out requests that shouldn't be proxied. - * Entries are expected to be comma-separated (whitespace between entries is ignored) - */ - noProxy?: string; -} -/** - * Options to configure the Rust client used to make fetch requests - * - * @since 2.0.0 - */ -export interface ClientOptions { - /** - * Defines the maximum number of redirects the client should follow. - * If set to 0, no redirects will be followed. - */ - maxRedirections?: number; - /** Timeout in milliseconds */ - connectTimeout?: number; - /** - * Configuration of a proxy that a Client should pass requests to. - */ - proxy?: Proxy; - /** - * Configuration for dangerous settings on the client such as disabling SSL verification. - */ - danger?: DangerousSettings; -} -/** - * Configuration for dangerous settings on the client such as disabling SSL verification. - * - * @since 2.3.0 - */ -export interface DangerousSettings { - /** - * Disables SSL verification. - */ - acceptInvalidCerts?: boolean; - /** - * Disables hostname verification. - */ - acceptInvalidHostnames?: boolean; -} -/** - * Fetch a resource from the network. It returns a `Promise` that resolves to the - * `Response` to that `Request`, whether it is successful or not. - * - * @example - * ```typescript - * const response = await fetch("http://my.json.host/data.json"); - * console.log(response.status); // e.g. 200 - * console.log(response.statusText); // e.g. "OK" - * const jsonData = await response.json(); - * ``` - * - * @since 2.0.0 - */ -export declare function fetch(input: URL | Request | string, init?: RequestInit & ClientOptions): Promise; diff --git a/crates/vendor/tauri-plugin-http/dist-js/index.js b/crates/vendor/tauri-plugin-http/dist-js/index.js deleted file mode 100644 index f4db76b005..0000000000 --- a/crates/vendor/tauri-plugin-http/dist-js/index.js +++ /dev/null @@ -1,164 +0,0 @@ -import { invoke, Channel } from '@tauri-apps/api/core'; - -// Copyright 2019-2023 Tauri Programme within The Commons Conservancy -// SPDX-License-Identifier: Apache-2.0 -// SPDX-License-Identifier: MIT -/** - * Make HTTP requests with the Rust backend. - * - * ## Security - * - * This API has a scope configuration that forces you to restrict the URLs that can be accessed using glob patterns. - * - * For instance, this scope configuration only allows making HTTP requests to all subdomains for `tauri.app` except for `https://private.tauri.app`: - * ```json - * { - * "permissions": [ - * { - * "identifier": "http:default", - * "allow": [{ "url": "https://*.tauri.app" }], - * "deny": [{ "url": "https://private.tauri.app" }] - * } - * ] - * } - * ``` - * Trying to execute any API with a URL not configured on the scope results in a promise rejection due to denied access. - * - * @module - */ -const ERROR_REQUEST_CANCELLED = 'Request cancelled'; -/** - * Fetch a resource from the network. It returns a `Promise` that resolves to the - * `Response` to that `Request`, whether it is successful or not. - * - * @example - * ```typescript - * const response = await fetch("http://my.json.host/data.json"); - * console.log(response.status); // e.g. 200 - * console.log(response.statusText); // e.g. "OK" - * const jsonData = await response.json(); - * ``` - * - * @since 2.0.0 - */ -async function fetch(input, init) { - // abort early here if needed - const signal = init?.signal; - if (signal?.aborted) { - throw new Error(ERROR_REQUEST_CANCELLED); - } - const maxRedirections = init?.maxRedirections; - const connectTimeout = init?.connectTimeout; - const proxy = init?.proxy; - const danger = init?.danger; - // Remove these fields before creating the request - if (init) { - delete init.maxRedirections; - delete init.connectTimeout; - delete init.proxy; - delete init.danger; - } - const headers = init?.headers - ? init.headers instanceof Headers - ? init.headers - : new Headers(init.headers) - : new Headers(); - const req = new Request(input, init); - const buffer = await req.arrayBuffer(); - const data = buffer.byteLength !== 0 ? Array.from(new Uint8Array(buffer)) : null; - // append new headers created by the browser `Request` implementation, - // if not already declared by the caller of this function - for (const [key, value] of req.headers) { - if (!headers.get(key)) { - headers.set(key, value); - } - } - const headersArray = headers instanceof Headers - ? Array.from(headers.entries()) - : Array.isArray(headers) - ? headers - : Object.entries(headers); - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment - const mappedHeaders = headersArray.map(([name, val]) => [ - name, - // we need to ensure we have all header values as strings - // eslint-disable-next-line - typeof val === 'string' ? val : val.toString() - ]); - // abort early here if needed - if (signal?.aborted) { - throw new Error(ERROR_REQUEST_CANCELLED); - } - const rid = await invoke('plugin:http|fetch', { - clientConfig: { - method: req.method, - url: req.url, - headers: mappedHeaders, - data, - maxRedirections, - connectTimeout, - proxy, - danger - } - }); - const abort = () => invoke('plugin:http|fetch_cancel', { rid }); - // abort early here if needed - if (signal?.aborted) { - // we don't care about the result of this proimse - // eslint-disable-next-line @typescript-eslint/no-floating-promises - abort(); - throw new Error(ERROR_REQUEST_CANCELLED); - } - signal?.addEventListener('abort', () => void abort()); - const { status, statusText, url, headers: responseHeaders, rid: responseRid } = await invoke('plugin:http|fetch_send', { - rid - }); - // no body for 101, 103, 204, 205 and 304 - // see https://fetch.spec.whatwg.org/#null-body-status - const body = [101, 103, 204, 205, 304].includes(status) - ? null - : new ReadableStream({ - start: (controller) => { - const streamChannel = new Channel(); - streamChannel.onmessage = (res) => { - // close early if aborted - if (signal?.aborted) { - controller.error(ERROR_REQUEST_CANCELLED); - return; - } - const resUint8 = new Uint8Array(res); - const lastByte = resUint8[resUint8.byteLength - 1]; - const actualRes = resUint8.slice(0, resUint8.byteLength - 1); - // close when the signal to close (last byte is 1) is sent from the IPC. - if (lastByte == 1) { - controller.close(); - return; - } - controller.enqueue(actualRes); - }; - // run a non-blocking body stream fetch - invoke('plugin:http|fetch_read_body', { - rid: responseRid, - streamChannel - }).catch((e) => { - controller.error(e); - }); - } - }); - const res = new Response(body, { - status, - statusText - }); - // Set `Response` properties that are ignored by the - // constructor, like url and some headers - // - // Since url and headers are read only properties - // this is the only way to set them. - Object.defineProperty(res, 'url', { value: url }); - Object.defineProperty(res, 'headers', { - value: new Headers(responseHeaders) - }); - return res; -} - -export { fetch }; diff --git a/crates/vendor/tauri-plugin-http/guest-js/index.ts b/crates/vendor/tauri-plugin-http/guest-js/index.ts deleted file mode 100644 index 4b38f8bfaa..0000000000 --- a/crates/vendor/tauri-plugin-http/guest-js/index.ts +++ /dev/null @@ -1,285 +0,0 @@ -// Copyright 2019-2023 Tauri Programme within The Commons Conservancy -// SPDX-License-Identifier: Apache-2.0 -// SPDX-License-Identifier: MIT - -/** - * Make HTTP requests with the Rust backend. - * - * ## Security - * - * This API has a scope configuration that forces you to restrict the URLs that can be accessed using glob patterns. - * - * For instance, this scope configuration only allows making HTTP requests to all subdomains for `tauri.app` except for `https://private.tauri.app`: - * ```json - * { - * "permissions": [ - * { - * "identifier": "http:default", - * "allow": [{ "url": "https://*.tauri.app" }], - * "deny": [{ "url": "https://private.tauri.app" }] - * } - * ] - * } - * ``` - * Trying to execute any API with a URL not configured on the scope results in a promise rejection due to denied access. - * - * @module - */ - -import { Channel, invoke } from '@tauri-apps/api/core' - -/** - * Configuration of a proxy that a Client should pass requests to. - * - * @since 2.0.0 - */ -export interface Proxy { - /** - * Proxy all traffic to the passed URL. - */ - all?: string | ProxyConfig - /** - * Proxy all HTTP traffic to the passed URL. - */ - http?: string | ProxyConfig - /** - * Proxy all HTTPS traffic to the passed URL. - */ - https?: string | ProxyConfig -} - -export interface ProxyConfig { - /** - * The URL of the proxy server. - */ - url: string - /** - * Set the `Proxy-Authorization` header using Basic auth. - */ - basicAuth?: { - username: string - password: string - } - /** - * A configuration for filtering out requests that shouldn't be proxied. - * Entries are expected to be comma-separated (whitespace between entries is ignored) - */ - noProxy?: string -} - -/** - * Options to configure the Rust client used to make fetch requests - * - * @since 2.0.0 - */ -export interface ClientOptions { - /** - * Defines the maximum number of redirects the client should follow. - * If set to 0, no redirects will be followed. - */ - maxRedirections?: number - /** Timeout in milliseconds */ - connectTimeout?: number - /** - * Configuration of a proxy that a Client should pass requests to. - */ - proxy?: Proxy - /** - * Configuration for dangerous settings on the client such as disabling SSL verification. - */ - danger?: DangerousSettings -} - -/** - * Configuration for dangerous settings on the client such as disabling SSL verification. - * - * @since 2.3.0 - */ -export interface DangerousSettings { - /** - * Disables SSL verification. - */ - acceptInvalidCerts?: boolean - /** - * Disables hostname verification. - */ - acceptInvalidHostnames?: boolean -} - -const ERROR_REQUEST_CANCELLED = 'Request cancelled' - -/** - * Fetch a resource from the network. It returns a `Promise` that resolves to the - * `Response` to that `Request`, whether it is successful or not. - * - * @example - * ```typescript - * const response = await fetch("http://my.json.host/data.json"); - * console.log(response.status); // e.g. 200 - * console.log(response.statusText); // e.g. "OK" - * const jsonData = await response.json(); - * ``` - * - * @since 2.0.0 - */ -export async function fetch( - input: URL | Request | string, - init?: RequestInit & ClientOptions -): Promise { - // abort early here if needed - const signal = init?.signal - if (signal?.aborted) { - throw new Error(ERROR_REQUEST_CANCELLED) - } - - const maxRedirections = init?.maxRedirections - const connectTimeout = init?.connectTimeout - const proxy = init?.proxy - const danger = init?.danger - - // Remove these fields before creating the request - if (init) { - delete init.maxRedirections - delete init.connectTimeout - delete init.proxy - delete init.danger - } - - const headers = init?.headers - ? init.headers instanceof Headers - ? init.headers - : new Headers(init.headers) - : new Headers() - - const req = new Request(input, init) - const buffer = await req.arrayBuffer() - const data = - buffer.byteLength !== 0 ? Array.from(new Uint8Array(buffer)) : null - - // append new headers created by the browser `Request` implementation, - // if not already declared by the caller of this function - for (const [key, value] of req.headers) { - if (!headers.get(key)) { - headers.set(key, value) - } - } - - const headersArray = - headers instanceof Headers - ? Array.from(headers.entries()) - : Array.isArray(headers) - ? headers - : Object.entries(headers) - - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment - const mappedHeaders: Array<[string, string]> = headersArray.map( - ([name, val]) => [ - name, - // we need to ensure we have all header values as strings - // eslint-disable-next-line - typeof val === 'string' ? val : (val as any).toString() - ] - ) - - // abort early here if needed - if (signal?.aborted) { - throw new Error(ERROR_REQUEST_CANCELLED) - } - - const rid = await invoke('plugin:http|fetch', { - clientConfig: { - method: req.method, - url: req.url, - headers: mappedHeaders, - data, - maxRedirections, - connectTimeout, - proxy, - danger - } - }) - - const abort = () => invoke('plugin:http|fetch_cancel', { rid }) - - // abort early here if needed - if (signal?.aborted) { - // we don't care about the result of this proimse - // eslint-disable-next-line @typescript-eslint/no-floating-promises - abort() - throw new Error(ERROR_REQUEST_CANCELLED) - } - - signal?.addEventListener('abort', () => void abort()) - - interface FetchSendResponse { - status: number - statusText: string - headers: [[string, string]] - url: string - rid: number - } - - const { - status, - statusText, - url, - headers: responseHeaders, - rid: responseRid - } = await invoke('plugin:http|fetch_send', { - rid - }) - - // no body for 101, 103, 204, 205 and 304 - // see https://fetch.spec.whatwg.org/#null-body-status - const body = [101, 103, 204, 205, 304].includes(status) - ? null - : new ReadableStream({ - start: (controller) => { - const streamChannel = new Channel() - streamChannel.onmessage = (res: ArrayBuffer | number[]) => { - // close early if aborted - if (signal?.aborted) { - controller.error(ERROR_REQUEST_CANCELLED) - return - } - - const resUint8 = new Uint8Array(res) - const lastByte = resUint8[resUint8.byteLength - 1] - const actualRes = resUint8.slice(0, resUint8.byteLength - 1) - - // close when the signal to close (last byte is 1) is sent from the IPC. - if (lastByte == 1) { - controller.close() - return - } - - controller.enqueue(actualRes) - } - - // run a non-blocking body stream fetch - invoke('plugin:http|fetch_read_body', { - rid: responseRid, - streamChannel - }).catch((e) => { - controller.error(e) - }) - } - }) - - const res = new Response(body, { - status, - statusText - }) - - // Set `Response` properties that are ignored by the - // constructor, like url and some headers - // - // Since url and headers are read only properties - // this is the only way to set them. - Object.defineProperty(res, 'url', { value: url }) - Object.defineProperty(res, 'headers', { - value: new Headers(responseHeaders) - }) - - return res -} diff --git a/crates/vendor/tauri-plugin-http/package.json b/crates/vendor/tauri-plugin-http/package.json deleted file mode 100644 index 7439c46167..0000000000 --- a/crates/vendor/tauri-plugin-http/package.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "name": "@tauri-apps/plugin-http", - "version": "2.4.3", - "license": "MIT OR Apache-2.0", - "authors": [ - "Tauri Programme within The Commons Conservancy" - ], - "repository": "https://github.com/tauri-apps/plugins-workspace", - "type": "module", - "types": "./dist-js/index.d.ts", - "main": "./dist-js/index.cjs", - "module": "./dist-js/index.js", - "exports": { - "types": "./dist-js/index.d.ts", - "import": "./dist-js/index.js", - "require": "./dist-js/index.cjs" - }, - "scripts": { - "build": "rollup -c" - }, - "files": [ - "dist-js", - "README.md", - "LICENSE" - ], - "dependencies": { - "@tauri-apps/api": "^2.0.0" - } -} diff --git a/crates/vendor/tauri-plugin-http/permissions/autogenerated/commands/fetch.toml b/crates/vendor/tauri-plugin-http/permissions/autogenerated/commands/fetch.toml deleted file mode 100644 index c4e068a7ce..0000000000 --- a/crates/vendor/tauri-plugin-http/permissions/autogenerated/commands/fetch.toml +++ /dev/null @@ -1,13 +0,0 @@ -# Automatically generated - DO NOT EDIT! - -"$schema" = "../../schemas/schema.json" - -[[permission]] -identifier = "allow-fetch" -description = "Enables the fetch command without any pre-configured scope." -commands.allow = ["fetch"] - -[[permission]] -identifier = "deny-fetch" -description = "Denies the fetch command without any pre-configured scope." -commands.deny = ["fetch"] diff --git a/crates/vendor/tauri-plugin-http/permissions/autogenerated/commands/fetch_cancel.toml b/crates/vendor/tauri-plugin-http/permissions/autogenerated/commands/fetch_cancel.toml deleted file mode 100644 index 70c1139b51..0000000000 --- a/crates/vendor/tauri-plugin-http/permissions/autogenerated/commands/fetch_cancel.toml +++ /dev/null @@ -1,13 +0,0 @@ -# Automatically generated - DO NOT EDIT! - -"$schema" = "../../schemas/schema.json" - -[[permission]] -identifier = "allow-fetch-cancel" -description = "Enables the fetch_cancel command without any pre-configured scope." -commands.allow = ["fetch_cancel"] - -[[permission]] -identifier = "deny-fetch-cancel" -description = "Denies the fetch_cancel command without any pre-configured scope." -commands.deny = ["fetch_cancel"] diff --git a/crates/vendor/tauri-plugin-http/permissions/autogenerated/commands/fetch_read_body.toml b/crates/vendor/tauri-plugin-http/permissions/autogenerated/commands/fetch_read_body.toml deleted file mode 100644 index b5867e99fa..0000000000 --- a/crates/vendor/tauri-plugin-http/permissions/autogenerated/commands/fetch_read_body.toml +++ /dev/null @@ -1,13 +0,0 @@ -# Automatically generated - DO NOT EDIT! - -"$schema" = "../../schemas/schema.json" - -[[permission]] -identifier = "allow-fetch-read-body" -description = "Enables the fetch_read_body command without any pre-configured scope." -commands.allow = ["fetch_read_body"] - -[[permission]] -identifier = "deny-fetch-read-body" -description = "Denies the fetch_read_body command without any pre-configured scope." -commands.deny = ["fetch_read_body"] diff --git a/crates/vendor/tauri-plugin-http/permissions/autogenerated/commands/fetch_send.toml b/crates/vendor/tauri-plugin-http/permissions/autogenerated/commands/fetch_send.toml deleted file mode 100644 index f6a55d2808..0000000000 --- a/crates/vendor/tauri-plugin-http/permissions/autogenerated/commands/fetch_send.toml +++ /dev/null @@ -1,13 +0,0 @@ -# Automatically generated - DO NOT EDIT! - -"$schema" = "../../schemas/schema.json" - -[[permission]] -identifier = "allow-fetch-send" -description = "Enables the fetch_send command without any pre-configured scope." -commands.allow = ["fetch_send"] - -[[permission]] -identifier = "deny-fetch-send" -description = "Denies the fetch_send command without any pre-configured scope." -commands.deny = ["fetch_send"] diff --git a/crates/vendor/tauri-plugin-http/permissions/autogenerated/reference.md b/crates/vendor/tauri-plugin-http/permissions/autogenerated/reference.md deleted file mode 100644 index 40c41cac16..0000000000 --- a/crates/vendor/tauri-plugin-http/permissions/autogenerated/reference.md +++ /dev/null @@ -1,133 +0,0 @@ -## Default Permission - -This permission set configures what kind of -fetch operations are available from the http plugin. - -This enables all fetch operations but does not -allow explicitly any origins to be fetched. This needs to -be manually configured before usage. - -#### Granted Permissions - -All fetch operations are enabled. - -#### This default permission set includes the following: - -- `allow-fetch` -- `allow-fetch-cancel` -- `allow-fetch-read-body` -- `allow-fetch-send` - -## Permission Table - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
IdentifierDescription
- -`http:allow-fetch` - - - -Enables the fetch command without any pre-configured scope. - -
- -`http:deny-fetch` - - - -Denies the fetch command without any pre-configured scope. - -
- -`http:allow-fetch-cancel` - - - -Enables the fetch_cancel command without any pre-configured scope. - -
- -`http:deny-fetch-cancel` - - - -Denies the fetch_cancel command without any pre-configured scope. - -
- -`http:allow-fetch-read-body` - - - -Enables the fetch_read_body command without any pre-configured scope. - -
- -`http:deny-fetch-read-body` - - - -Denies the fetch_read_body command without any pre-configured scope. - -
- -`http:allow-fetch-send` - - - -Enables the fetch_send command without any pre-configured scope. - -
- -`http:deny-fetch-send` - - - -Denies the fetch_send command without any pre-configured scope. - -
diff --git a/crates/vendor/tauri-plugin-http/permissions/default.toml b/crates/vendor/tauri-plugin-http/permissions/default.toml deleted file mode 100644 index b469536ddc..0000000000 --- a/crates/vendor/tauri-plugin-http/permissions/default.toml +++ /dev/null @@ -1,22 +0,0 @@ -"$schema" = "schemas/schema.json" - -[default] -description = """ -This permission set configures what kind of -fetch operations are available from the http plugin. - -This enables all fetch operations but does not -allow explicitly any origins to be fetched. This needs to -be manually configured before usage. - -#### Granted Permissions - -All fetch operations are enabled. - -""" -permissions = [ - "allow-fetch", - "allow-fetch-cancel", - "allow-fetch-read-body", - "allow-fetch-send", -] diff --git a/crates/vendor/tauri-plugin-http/permissions/schemas/schema.json b/crates/vendor/tauri-plugin-http/permissions/schemas/schema.json deleted file mode 100644 index ea774399d5..0000000000 --- a/crates/vendor/tauri-plugin-http/permissions/schemas/schema.json +++ /dev/null @@ -1,354 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "PermissionFile", - "description": "Permission file that can define a default permission, a set of permissions or a list of inlined permissions.", - "type": "object", - "properties": { - "default": { - "description": "The default permission set for the plugin", - "anyOf": [ - { - "$ref": "#/definitions/DefaultPermission" - }, - { - "type": "null" - } - ] - }, - "set": { - "description": "A list of permissions sets defined", - "type": "array", - "items": { - "$ref": "#/definitions/PermissionSet" - } - }, - "permission": { - "description": "A list of inlined permissions", - "default": [], - "type": "array", - "items": { - "$ref": "#/definitions/Permission" - } - } - }, - "definitions": { - "DefaultPermission": { - "description": "The default permission set of the plugin.\n\nWorks similarly to a permission with the \"default\" identifier.", - "type": "object", - "required": [ - "permissions" - ], - "properties": { - "version": { - "description": "The version of the permission.", - "type": [ - "integer", - "null" - ], - "format": "uint64", - "minimum": 1.0 - }, - "description": { - "description": "Human-readable description of what the permission does. Tauri convention is to use `

` headings in markdown content for Tauri documentation generation purposes.", - "type": [ - "string", - "null" - ] - }, - "permissions": { - "description": "All permissions this set contains.", - "type": "array", - "items": { - "type": "string" - } - } - } - }, - "PermissionSet": { - "description": "A set of direct permissions grouped together under a new name.", - "type": "object", - "required": [ - "description", - "identifier", - "permissions" - ], - "properties": { - "identifier": { - "description": "A unique identifier for the permission.", - "type": "string" - }, - "description": { - "description": "Human-readable description of what the permission does.", - "type": "string" - }, - "permissions": { - "description": "All permissions this set contains.", - "type": "array", - "items": { - "$ref": "#/definitions/PermissionKind" - } - } - } - }, - "Permission": { - "description": "Descriptions of explicit privileges of commands.\n\nIt can enable commands to be accessible in the frontend of the application.\n\nIf the scope is defined it can be used to fine grain control the access of individual or multiple commands.", - "type": "object", - "required": [ - "identifier" - ], - "properties": { - "version": { - "description": "The version of the permission.", - "type": [ - "integer", - "null" - ], - "format": "uint64", - "minimum": 1.0 - }, - "identifier": { - "description": "A unique identifier for the permission.", - "type": "string" - }, - "description": { - "description": "Human-readable description of what the permission does. Tauri internal convention is to use `

` headings in markdown content for Tauri documentation generation purposes.", - "type": [ - "string", - "null" - ] - }, - "commands": { - "description": "Allowed or denied commands when using this permission.", - "default": { - "allow": [], - "deny": [] - }, - "allOf": [ - { - "$ref": "#/definitions/Commands" - } - ] - }, - "scope": { - "description": "Allowed or denied scoped when using this permission.", - "allOf": [ - { - "$ref": "#/definitions/Scopes" - } - ] - }, - "platforms": { - "description": "Target platforms this permission applies. By default all platforms are affected by this permission.", - "type": [ - "array", - "null" - ], - "items": { - "$ref": "#/definitions/Target" - } - } - } - }, - "Commands": { - "description": "Allowed and denied commands inside a permission.\n\nIf two commands clash inside of `allow` and `deny`, it should be denied by default.", - "type": "object", - "properties": { - "allow": { - "description": "Allowed command.", - "default": [], - "type": "array", - "items": { - "type": "string" - } - }, - "deny": { - "description": "Denied command, which takes priority.", - "default": [], - "type": "array", - "items": { - "type": "string" - } - } - } - }, - "Scopes": { - "description": "An argument for fine grained behavior control of Tauri commands.\n\nIt can be of any serde serializable type and is used to allow or prevent certain actions inside a Tauri command. The configured scope is passed to the command and will be enforced by the command implementation.\n\n## Example\n\n```json { \"allow\": [{ \"path\": \"$HOME/**\" }], \"deny\": [{ \"path\": \"$HOME/secret.txt\" }] } ```", - "type": "object", - "properties": { - "allow": { - "description": "Data that defines what is allowed by the scope.", - "type": [ - "array", - "null" - ], - "items": { - "$ref": "#/definitions/Value" - } - }, - "deny": { - "description": "Data that defines what is denied by the scope. This should be prioritized by validation logic.", - "type": [ - "array", - "null" - ], - "items": { - "$ref": "#/definitions/Value" - } - } - } - }, - "Value": { - "description": "All supported ACL values.", - "anyOf": [ - { - "description": "Represents a null JSON value.", - "type": "null" - }, - { - "description": "Represents a [`bool`].", - "type": "boolean" - }, - { - "description": "Represents a valid ACL [`Number`].", - "allOf": [ - { - "$ref": "#/definitions/Number" - } - ] - }, - { - "description": "Represents a [`String`].", - "type": "string" - }, - { - "description": "Represents a list of other [`Value`]s.", - "type": "array", - "items": { - "$ref": "#/definitions/Value" - } - }, - { - "description": "Represents a map of [`String`] keys to [`Value`]s.", - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/Value" - } - } - ] - }, - "Number": { - "description": "A valid ACL number.", - "anyOf": [ - { - "description": "Represents an [`i64`].", - "type": "integer", - "format": "int64" - }, - { - "description": "Represents a [`f64`].", - "type": "number", - "format": "double" - } - ] - }, - "Target": { - "description": "Platform target.", - "oneOf": [ - { - "description": "MacOS.", - "type": "string", - "enum": [ - "macOS" - ] - }, - { - "description": "Windows.", - "type": "string", - "enum": [ - "windows" - ] - }, - { - "description": "Linux.", - "type": "string", - "enum": [ - "linux" - ] - }, - { - "description": "Android.", - "type": "string", - "enum": [ - "android" - ] - }, - { - "description": "iOS.", - "type": "string", - "enum": [ - "iOS" - ] - } - ] - }, - "PermissionKind": { - "type": "string", - "oneOf": [ - { - "description": "Enables the fetch command without any pre-configured scope.", - "type": "string", - "const": "allow-fetch", - "markdownDescription": "Enables the fetch command without any pre-configured scope." - }, - { - "description": "Denies the fetch command without any pre-configured scope.", - "type": "string", - "const": "deny-fetch", - "markdownDescription": "Denies the fetch command without any pre-configured scope." - }, - { - "description": "Enables the fetch_cancel command without any pre-configured scope.", - "type": "string", - "const": "allow-fetch-cancel", - "markdownDescription": "Enables the fetch_cancel command without any pre-configured scope." - }, - { - "description": "Denies the fetch_cancel command without any pre-configured scope.", - "type": "string", - "const": "deny-fetch-cancel", - "markdownDescription": "Denies the fetch_cancel command without any pre-configured scope." - }, - { - "description": "Enables the fetch_read_body command without any pre-configured scope.", - "type": "string", - "const": "allow-fetch-read-body", - "markdownDescription": "Enables the fetch_read_body command without any pre-configured scope." - }, - { - "description": "Denies the fetch_read_body command without any pre-configured scope.", - "type": "string", - "const": "deny-fetch-read-body", - "markdownDescription": "Denies the fetch_read_body command without any pre-configured scope." - }, - { - "description": "Enables the fetch_send command without any pre-configured scope.", - "type": "string", - "const": "allow-fetch-send", - "markdownDescription": "Enables the fetch_send command without any pre-configured scope." - }, - { - "description": "Denies the fetch_send command without any pre-configured scope.", - "type": "string", - "const": "deny-fetch-send", - "markdownDescription": "Denies the fetch_send command without any pre-configured scope." - }, - { - "description": "This permission set configures what kind of\nfetch operations are available from the http plugin.\n\nThis enables all fetch operations but does not\nallow explicitly any origins to be fetched. This needs to\nbe manually configured before usage.\n\n#### Granted Permissions\n\nAll fetch operations are enabled.\n\n\n#### This default permission set includes:\n\n- `allow-fetch`\n- `allow-fetch-cancel`\n- `allow-fetch-read-body`\n- `allow-fetch-send`", - "type": "string", - "const": "default", - "markdownDescription": "This permission set configures what kind of\nfetch operations are available from the http plugin.\n\nThis enables all fetch operations but does not\nallow explicitly any origins to be fetched. This needs to\nbe manually configured before usage.\n\n#### Granted Permissions\n\nAll fetch operations are enabled.\n\n\n#### This default permission set includes:\n\n- `allow-fetch`\n- `allow-fetch-cancel`\n- `allow-fetch-read-body`\n- `allow-fetch-send`" - } - ] - } - } -} \ No newline at end of file diff --git a/crates/vendor/tauri-plugin-http/rollup.config.js b/crates/vendor/tauri-plugin-http/rollup.config.js deleted file mode 100644 index 1f349ec8a2..0000000000 --- a/crates/vendor/tauri-plugin-http/rollup.config.js +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright 2019-2023 Tauri Programme within The Commons Conservancy -// SPDX-License-Identifier: Apache-2.0 -// SPDX-License-Identifier: MIT - -import { createConfig } from '../../shared/rollup.config.js' - -export default createConfig() diff --git a/crates/vendor/tauri-plugin-http/src/commands.rs b/crates/vendor/tauri-plugin-http/src/commands.rs deleted file mode 100644 index 7093a7270b..0000000000 --- a/crates/vendor/tauri-plugin-http/src/commands.rs +++ /dev/null @@ -1,490 +0,0 @@ -// Copyright 2019-2023 Tauri Programme within The Commons Conservancy -// SPDX-License-Identifier: Apache-2.0 -// SPDX-License-Identifier: MIT - -use std::{future::Future, pin::Pin, str::FromStr, sync::Arc, time::Duration}; - -use http::{header, HeaderMap, HeaderName, HeaderValue, Method, StatusCode}; -use reqwest::{redirect::Policy, NoProxy}; -use serde::{Deserialize, Serialize}; -use tauri::{ - async_runtime::Mutex, - command, - ipc::{Channel, CommandScope, GlobalScope}, - Manager, ResourceId, ResourceTable, Runtime, State, Webview, -}; -use tokio::sync::oneshot::{channel, Receiver, Sender}; - -use crate::{ - scope::{Entry, Scope}, - Error, Http, Result, -}; - -const HTTP_USER_AGENT: &str = concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION"),); - -struct ReqwestResponse(reqwest::Response); -impl tauri::Resource for ReqwestResponse {} - -type CancelableResponseResult = Result; -type CancelableResponseFuture = - Pin + Send + Sync>>; - -struct FetchRequest { - fut: Mutex, - abort_tx_rid: ResourceId, - abort_rx_rid: ResourceId, -} -impl tauri::Resource for FetchRequest {} - -struct AbortSender(Sender<()>); -impl tauri::Resource for AbortRecveiver {} - -impl AbortSender { - fn abort(self) { - let _ = self.0.send(()); - } -} - -struct AbortRecveiver(Receiver<()>); -impl tauri::Resource for AbortSender {} - -trait AddRequest { - fn add_request(&mut self, fut: CancelableResponseFuture) -> ResourceId; -} - -impl AddRequest for ResourceTable { - fn add_request(&mut self, fut: CancelableResponseFuture) -> ResourceId { - let (tx, rx) = channel::<()>(); - let (tx, rx) = (AbortSender(tx), AbortRecveiver(rx)); - let req = FetchRequest { - fut: Mutex::new(fut), - abort_tx_rid: self.add(tx), - abort_rx_rid: self.add(rx), - }; - self.add(req) - } -} - -#[derive(Serialize)] -#[serde(rename_all = "camelCase")] -pub struct FetchResponse { - status: u16, - status_text: String, - headers: Vec<(String, String)>, - url: String, - rid: ResourceId, -} - -#[derive(Debug, Deserialize)] -#[serde(rename_all = "camelCase")] -#[allow(dead_code)] //feature flags shoudln't affect api -pub struct DangerousSettings { - accept_invalid_certs: bool, - accept_invalid_hostnames: bool, -} - -#[derive(Debug, Deserialize)] -#[serde(rename_all = "camelCase")] -pub struct ClientConfig { - method: String, - url: url::Url, - headers: Vec<(String, String)>, - data: Option>, - connect_timeout: Option, - max_redirections: Option, - proxy: Option, - danger: Option, -} - -#[derive(Debug, Deserialize)] -#[serde(rename_all = "camelCase")] -pub struct Proxy { - all: Option, - http: Option, - https: Option, -} - -#[derive(Debug, Deserialize)] -#[serde(rename_all = "camelCase")] -#[serde(untagged)] -pub enum UrlOrConfig { - Url(String), - Config(ProxyConfig), -} - -#[derive(Debug, Deserialize)] -#[serde(rename_all = "camelCase")] -pub struct ProxyConfig { - url: String, - basic_auth: Option, - no_proxy: Option, -} - -#[derive(Debug, Deserialize)] -pub struct BasicAuth { - username: String, - password: String, -} - -#[inline] -fn proxy_creator( - url_or_config: UrlOrConfig, - proxy_fn: fn(String) -> reqwest::Result, -) -> reqwest::Result { - match url_or_config { - UrlOrConfig::Url(url) => Ok(proxy_fn(url)?), - UrlOrConfig::Config(ProxyConfig { - url, - basic_auth, - no_proxy, - }) => { - let mut proxy = proxy_fn(url)?; - if let Some(basic_auth) = basic_auth { - proxy = proxy.basic_auth(&basic_auth.username, &basic_auth.password); - } - if let Some(no_proxy) = no_proxy { - proxy = proxy.no_proxy(NoProxy::from_string(&no_proxy)); - } - Ok(proxy) - } - } -} - -fn attach_proxy( - proxy: Proxy, - mut builder: reqwest::ClientBuilder, -) -> crate::Result { - let Proxy { all, http, https } = proxy; - - if let Some(all) = all { - let proxy = proxy_creator(all, reqwest::Proxy::all)?; - builder = builder.proxy(proxy); - } - - if let Some(http) = http { - let proxy = proxy_creator(http, reqwest::Proxy::http)?; - builder = builder.proxy(proxy); - } - - if let Some(https) = https { - let proxy = proxy_creator(https, reqwest::Proxy::https)?; - builder = builder.proxy(proxy); - } - - Ok(builder) -} - -#[command] -pub async fn fetch( - webview: Webview, - state: State<'_, Http>, - client_config: ClientConfig, - command_scope: CommandScope, - global_scope: GlobalScope, -) -> crate::Result { - let ClientConfig { - method, - url, - headers: headers_raw, - data, - connect_timeout, - max_redirections, - proxy, - danger, - } = client_config; - - let scheme = url.scheme(); - let method = Method::from_bytes(method.as_bytes())?; - - let mut headers = HeaderMap::new(); - for (h, v) in headers_raw { - let name = HeaderName::from_str(&h)?; - #[cfg(not(feature = "unsafe-headers"))] - if is_unsafe_header(&name) { - #[cfg(debug_assertions)] - { - eprintln!("[\x1b[33mWARNING\x1b[0m] Skipping {name} header as it is a forbidden header per fetch spec https://fetch.spec.whatwg.org/#terminology-headers"); - eprintln!("[\x1b[33mWARNING\x1b[0m] if keeping the header is a desired behavior, you can enable `unsafe-headers` feature flag in your Cargo.toml"); - } - continue; - } - - headers.append(name, HeaderValue::from_str(&v)?); - } - - match scheme { - "http" | "https" => { - if Scope::new( - command_scope - .allows() - .iter() - .chain(global_scope.allows()) - .collect(), - command_scope - .denies() - .iter() - .chain(global_scope.denies()) - .collect(), - ) - .is_allowed(&url) - { - let mut builder = reqwest::ClientBuilder::new(); - - if let Some(danger_config) = danger { - #[cfg(not(feature = "dangerous-settings"))] - { - #[cfg(debug_assertions)] - { - eprintln!("[\x1b[33mWARNING\x1b[0m] using dangerous settings requires `dangerous-settings` feature flag in your Cargo.toml"); - } - let _ = danger_config; - return Err(Error::DangerousSettings); - } - #[cfg(feature = "dangerous-settings")] - { - builder = builder - .danger_accept_invalid_certs(danger_config.accept_invalid_certs) - .danger_accept_invalid_hostnames(danger_config.accept_invalid_hostnames) - } - } - - if let Some(timeout) = connect_timeout { - builder = builder.connect_timeout(Duration::from_millis(timeout)); - } - - if let Some(max_redirections) = max_redirections { - builder = builder.redirect(if max_redirections == 0 { - Policy::none() - } else { - Policy::limited(max_redirections) - }); - } - - if let Some(proxy_config) = proxy { - builder = attach_proxy(proxy_config, builder)?; - } - - #[cfg(feature = "cookies")] - { - builder = builder.cookie_provider(state.cookies_jar.clone()); - } - - let mut request = builder.build()?.request(method.clone(), url); - - // POST and PUT requests should always have a 0 length content-length, - // if there is no body. https://fetch.spec.whatwg.org/#http-network-or-cache-fetch - if data.is_none() && matches!(method, Method::POST | Method::PUT) { - headers.append(header::CONTENT_LENGTH, HeaderValue::from_str("0")?); - } - - if headers.contains_key(header::RANGE) { - // https://fetch.spec.whatwg.org/#http-network-or-cache-fetch step 18 - // If httpRequest’s header list contains `Range`, then append (`Accept-Encoding`, `identity`) - headers.append(header::ACCEPT_ENCODING, HeaderValue::from_str("identity")?); - } - - if !headers.contains_key(header::USER_AGENT) { - headers.append(header::USER_AGENT, HeaderValue::from_str(HTTP_USER_AGENT)?); - } - - // ensure we have an Origin header set - if cfg!(not(feature = "unsafe-headers")) || !headers.contains_key(header::ORIGIN) { - if let Ok(url) = webview.url() { - headers.append( - header::ORIGIN, - HeaderValue::from_str(&url.origin().ascii_serialization())?, - ); - } - } - - // In case empty origin is passed, remove it. Some services do not like Origin header - // so this way we can remove it in explicit way. The default behaviour is still to set it - if cfg!(feature = "unsafe-headers") - && headers.get(header::ORIGIN) == Some(&HeaderValue::from_static("")) - { - headers.remove(header::ORIGIN); - }; - - // NB(bt): In production builds, the origin seems to be "null". This is what our server CORS filter sees: - // [2025-05-01T23:42:35Z WARN actix_cors_configs::configs::fakeyou] Invalid origin: "null" - // [2025-05-01T23:42:35Z WARN actix_cors_configs::util::netlify_branch_domain_matches] Invalid origin: "null" - // [2025-05-01T23:42:35Z WARN actix_cors_configs::util::netlify_branch_domain_matches] Invalid origin: "null" - // ... - // [2025-05-01T23:42:35Z WARN actix_cors_configs::util::netlify_branch_domain_matches] Invalid origin: "null" - // [2025-05-01T23:42:35Z INFO actix_web::middleware::logger] [storyteller-web-85f9b4974-ddvq7] IP=[redact] - // 939322e1095ee5e4-IAD "POST /v1/login HTTP/1.1" 400 42 "-" "tauri-plugin-http/2.4.3" 0.000076 - let mut maybe_origin_header = headers.get(header::ORIGIN); - - let replace_origin_header = maybe_origin_header.is_none() - || maybe_origin_header == Some(&HeaderValue::from_static("null")) // Above error (Mac) - || maybe_origin_header == Some(&HeaderValue::from_static("http://tauri.localhost")) // Windows - || maybe_origin_header == Some(&HeaderValue::from_static("tauri://localhost")); // Mac plausibly causes this - - if replace_origin_header { - // TODO(bt): Make this a sentinel origin, eg. sentinel.storyteller.ai. - // NB: HeadersMap is a multimap, but this should ensure we just have one value. - headers.insert(header::ORIGIN, HeaderValue::from_static("https://studio.storyteller.ai")); - } - - if let Some(data) = data { - request = request.body(data); - } - - request = request.headers(headers); - - #[cfg(feature = "tracing")] - tracing::trace!("{:?}", request); - - let fut = async move { request.send().await.map_err(Into::into) }; - - let mut resources_table = webview.resources_table(); - let rid = resources_table.add_request(Box::pin(fut)); - - Ok(rid) - } else { - Err(Error::UrlNotAllowed(url)) - } - } - "data" => { - let data_url = - data_url::DataUrl::process(url.as_str()).map_err(|_| Error::DataUrlError)?; - let (body, _) = data_url - .decode_to_vec() - .map_err(|_| Error::DataUrlDecodeError)?; - - let response = http::Response::builder() - .status(StatusCode::OK) - .header(header::CONTENT_TYPE, data_url.mime_type().to_string()) - .body(reqwest::Body::from(body))?; - - #[cfg(feature = "tracing")] - tracing::trace!("{:?}", response); - - let fut = async move { Ok(reqwest::Response::from(response)) }; - let mut resources_table = webview.resources_table(); - let rid = resources_table.add_request(Box::pin(fut)); - Ok(rid) - } - _ => Err(Error::SchemeNotSupport(scheme.to_string())), - } -} - -#[command] -pub fn fetch_cancel(webview: Webview, rid: ResourceId) -> crate::Result<()> { - let mut resources_table = webview.resources_table(); - let req = resources_table.get::(rid)?; - let abort_tx = resources_table.take::(req.abort_tx_rid)?; - if let Some(abort_tx) = Arc::into_inner(abort_tx) { - abort_tx.abort(); - } - Ok(()) -} - -#[command] -pub async fn fetch_send( - webview: Webview, - rid: ResourceId, -) -> crate::Result { - let (req, abort_rx) = { - let mut resources_table = webview.resources_table(); - let req = resources_table.get::(rid)?; - let abort_rx = resources_table.take::(req.abort_rx_rid)?; - (req, abort_rx) - }; - - let Some(abort_rx) = Arc::into_inner(abort_rx) else { - return Err(Error::RequestCanceled); - }; - - let mut fut = req.fut.lock().await; - - let res = tokio::select! { - res = fut.as_mut() => res?, - _ = abort_rx.0 => { - let mut resources_table = webview.resources_table(); - resources_table.close(rid)?; - return Err(Error::RequestCanceled); - } - }; - - #[cfg(feature = "tracing")] - tracing::trace!("{:?}", res); - - let status = res.status(); - let url = res.url().to_string(); - let mut headers = Vec::new(); - for (key, val) in res.headers().iter() { - headers.push(( - key.as_str().into(), - String::from_utf8(val.as_bytes().to_vec())?, - )); - } - - let mut resources_table = webview.resources_table(); - let rid = resources_table.add(ReqwestResponse(res)); - - Ok(FetchResponse { - status: status.as_u16(), - status_text: status.canonical_reason().unwrap_or_default().to_string(), - headers, - url, - rid, - }) -} - -#[command] -pub async fn fetch_read_body( - webview: Webview, - rid: ResourceId, - stream_channel: Channel, -) -> crate::Result<()> { - let res = { - let mut resources_table = webview.resources_table(); - resources_table.take::(rid)? - }; - - let mut res = Arc::into_inner(res).unwrap().0; - - // send response through IPC channel - while let Some(chunk) = res.chunk().await? { - let mut chunk = chunk.to_vec(); - // append 0 to indicate we are not done yet - chunk.push(0); - stream_channel.send(tauri::ipc::InvokeResponseBody::Raw(chunk))?; - } - - // send 1 to indicate we are done - stream_channel.send(tauri::ipc::InvokeResponseBody::Raw(vec![1]))?; - - Ok(()) -} - -// forbidden headers per fetch spec https://fetch.spec.whatwg.org/#terminology-headers -#[cfg(not(feature = "unsafe-headers"))] -fn is_unsafe_header(header: &HeaderName) -> bool { - matches!( - *header, - header::ACCEPT_CHARSET - | header::ACCEPT_ENCODING - | header::ACCESS_CONTROL_REQUEST_HEADERS - | header::ACCESS_CONTROL_REQUEST_METHOD - | header::CONNECTION - | header::CONTENT_LENGTH - | header::COOKIE - | header::DATE - | header::DNT - | header::EXPECT - | header::HOST - | header::ORIGIN - | header::REFERER - | header::SET_COOKIE - | header::TE - | header::TRAILER - | header::TRANSFER_ENCODING - | header::UPGRADE - | header::VIA - ) || { - let lower = header.as_str().to_lowercase(); - lower.starts_with("proxy-") || lower.starts_with("sec-") - } -} diff --git a/crates/vendor/tauri-plugin-http/src/error.rs b/crates/vendor/tauri-plugin-http/src/error.rs deleted file mode 100644 index ef8de0c526..0000000000 --- a/crates/vendor/tauri-plugin-http/src/error.rs +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright 2019-2023 Tauri Programme within The Commons Conservancy -// SPDX-License-Identifier: Apache-2.0 -// SPDX-License-Identifier: MIT - -use serde::{Serialize, Serializer}; -use url::Url; - -#[derive(Debug, thiserror::Error)] -pub enum Error { - #[error(transparent)] - Json(#[from] serde_json::Error), - #[error(transparent)] - Io(#[from] std::io::Error), - #[error(transparent)] - Network(#[from] reqwest::Error), - #[error(transparent)] - Http(#[from] http::Error), - #[error(transparent)] - HttpInvalidHeaderName(#[from] http::header::InvalidHeaderName), - #[error(transparent)] - HttpInvalidHeaderValue(#[from] http::header::InvalidHeaderValue), - /// URL not allowed by the scope. - #[error("url not allowed on the configured scope: {0}")] - UrlNotAllowed(Url), - #[error(transparent)] - UrlParseError(#[from] url::ParseError), - /// HTTP method error. - #[error(transparent)] - HttpMethod(#[from] http::method::InvalidMethod), - #[error("scheme {0} not supported")] - SchemeNotSupport(String), - #[error("Request canceled")] - RequestCanceled, - #[error(transparent)] - FsError(#[from] tauri_plugin_fs::Error), - #[error("failed to process data url")] - DataUrlError, - #[error("failed to decode data url into bytes")] - DataUrlDecodeError, - #[error(transparent)] - Tauri(#[from] tauri::Error), - #[error(transparent)] - Utf8(#[from] std::string::FromUtf8Error), - #[error("dangerous settings used but are not enabled")] - DangerousSettings, -} - -impl Serialize for Error { - fn serialize(&self, serializer: S) -> std::result::Result - where - S: Serializer, - { - serializer.serialize_str(self.to_string().as_ref()) - } -} - -pub type Result = std::result::Result; diff --git a/crates/vendor/tauri-plugin-http/src/lib.rs b/crates/vendor/tauri-plugin-http/src/lib.rs deleted file mode 100644 index 1da8993fba..0000000000 --- a/crates/vendor/tauri-plugin-http/src/lib.rs +++ /dev/null @@ -1,96 +0,0 @@ -// Copyright 2019-2023 Tauri Programme within The Commons Conservancy -// SPDX-License-Identifier: Apache-2.0 -// SPDX-License-Identifier: MIT - -//! Access the HTTP client written in Rust. - -pub use reqwest; -use tauri::{ - plugin::{Builder, TauriPlugin}, - Manager, Runtime, -}; - -pub use error::{Error, Result}; - -// NB(bt): We're making everything public so we can access it. -pub mod commands; -pub mod error; -#[cfg(feature = "cookies")] -pub mod reqwest_cookie_store; -pub mod scope; - -#[cfg(feature = "cookies")] -const COOKIES_FILENAME: &str = ".cookies"; - -// NB(bt): We've vendored in this library so we can poke at the cookie data store. -pub struct Http { - #[cfg(feature = "cookies")] - pub cookies_jar: std::sync::Arc, -} - -pub fn init() -> TauriPlugin { - Builder::::new("http") - .setup(|app, _| { - #[cfg(feature = "cookies")] - let cookies_jar = { - use crate::reqwest_cookie_store::*; - use std::fs::File; - use std::io::BufReader; - - let cache_dir = app.path().app_cache_dir()?; - std::fs::create_dir_all(&cache_dir)?; - - let path = cache_dir.join(COOKIES_FILENAME); - - // NB(bt): Let's always log this. - println!("Tauri plugin http: using cookie store at {}", path.display()); - - let file = File::options() - .create(true) - .append(true) - .read(true) - .open(&path)?; - - let reader = BufReader::new(file); - CookieStoreMutex::load(path.clone(), reader).unwrap_or_else(|_e| { - #[cfg(feature = "tracing")] - tracing::warn!( - "failed to load cookie store: {_e}, falling back to empty store" - ); - CookieStoreMutex::new(path, Default::default()) - }) - }; - - let state = Http { - #[cfg(feature = "cookies")] - cookies_jar: std::sync::Arc::new(cookies_jar), - }; - - app.manage(state); - - Ok(()) - }) - .on_event(|app, event| { - #[cfg(feature = "cookies")] - if let tauri::RunEvent::Exit = event { - let state = app.state::(); - - match state.cookies_jar.request_save() { - Ok(rx) => { - let _ = rx.recv(); - } - Err(_e) => { - #[cfg(feature = "tracing")] - tracing::error!("failed to save cookie jar: {_e}"); - } - } - } - }) - .invoke_handler(tauri::generate_handler![ - commands::fetch, - commands::fetch_cancel, - commands::fetch_send, - commands::fetch_read_body - ]) - .build() -} diff --git a/crates/vendor/tauri-plugin-http/src/reqwest_cookie_store.rs b/crates/vendor/tauri-plugin-http/src/reqwest_cookie_store.rs deleted file mode 100644 index be4215ca1a..0000000000 --- a/crates/vendor/tauri-plugin-http/src/reqwest_cookie_store.rs +++ /dev/null @@ -1,135 +0,0 @@ -// Copyright 2019-2023 Tauri Programme within The Commons Conservancy -// SPDX-License-Identifier: Apache-2.0 -// SPDX-License-Identifier: MIT - -// taken from https://github.com/pfernie/reqwest_cookie_store/blob/2ec4afabcd55e24d3afe3f0626ee6dc97bed938d/src/lib.rs - -use std::{ - path::PathBuf, - sync::{mpsc::Receiver, Mutex}, -}; - -// NB(bt): Re-export these for reuse -pub use cookie_store::{CookieStore, RawCookie, RawCookieParseError}; -use reqwest::header::HeaderValue; - -fn set_cookies( - cookie_store: &mut CookieStore, - cookie_headers: &mut dyn Iterator, - url: &url::Url, -) { - let cookies = cookie_headers.filter_map(|val| { - std::str::from_utf8(val.as_bytes()) - .map_err(RawCookieParseError::from) - .and_then(RawCookie::parse) - .map(|c| c.into_owned()) - .ok() - }); - cookie_store.store_response_cookies(cookies, url); -} - -fn cookies(cookie_store: &CookieStore, url: &url::Url) -> Option { - let s = cookie_store - .get_request_values(url) - .map(|(name, value)| format!("{}={}", name, value)) - .collect::>() - .join("; "); - - if s.is_empty() { - return None; - } - - HeaderValue::from_maybe_shared(bytes::Bytes::from(s)).ok() -} - -/// A [`cookie_store::CookieStore`] wrapped internally by a [`std::sync::Mutex`], suitable for use in -/// async/concurrent contexts. -#[derive(Debug)] -pub struct CookieStoreMutex { - pub path: PathBuf, - // NB(bt): We've made both of these public so we can access them. - pub store: Mutex, - pub save_task: Mutex>, -} - -impl CookieStoreMutex { - /// Create a new [`CookieStoreMutex`] from an existing [`cookie_store::CookieStore`]. - pub fn new(path: PathBuf, cookie_store: CookieStore) -> CookieStoreMutex { - CookieStoreMutex { - path, - store: Mutex::new(cookie_store), - save_task: Default::default(), - } - } - - pub fn load( - path: PathBuf, - reader: R, - ) -> cookie_store::Result { - cookie_store::serde::load(reader, |c| serde_json::from_str(c)) - .map(|store| CookieStoreMutex::new(path, store)) - } - - fn cookies_to_str(&self) -> Result { - let mut cookies = Vec::new(); - for cookie in self - .store - .lock() - .expect("poisoned cookie jar mutex") - .iter_unexpired() - { - if cookie.is_persistent() { - cookies.push(cookie.clone()); - } - } - serde_json::to_string(&cookies) - } - - pub fn request_save(&self) -> cookie_store::Result> { - let cookie_str = self.cookies_to_str()?; - let path = self.path.clone(); - let (tx, rx) = std::sync::mpsc::channel(); - let task = tauri::async_runtime::spawn(async move { - match tokio::fs::write(&path, &cookie_str).await { - Ok(()) => { - let _ = tx.send(()); - } - Err(_e) => { - #[cfg(feature = "tracing")] - tracing::error!("failed to save cookie jar: {_e}"); - } - } - }); - self.save_task - .lock() - .unwrap() - .replace(CancellableTask(task)); - Ok(rx) - } -} - -impl reqwest::cookie::CookieStore for CookieStoreMutex { - fn set_cookies(&self, cookie_headers: &mut dyn Iterator, url: &url::Url) { - set_cookies(&mut self.store.lock().unwrap(), cookie_headers, url); - - // try to persist cookies immediately asynchronously - if let Err(_e) = self.request_save() { - #[cfg(feature = "tracing")] - tracing::error!("failed to save cookie jar: {_e}"); - } - } - - fn cookies(&self, url: &url::Url) -> Option { - let store = self.store.lock().unwrap(); - cookies(&store, url) - } -} - -#[derive(Debug)] -struct CancellableTask(tauri::async_runtime::JoinHandle<()>); - -impl Drop for CancellableTask { - fn drop(&mut self) { - self.0.abort(); - } -} diff --git a/crates/vendor/tauri-plugin-http/src/scope.rs b/crates/vendor/tauri-plugin-http/src/scope.rs deleted file mode 100644 index 2123f215ad..0000000000 --- a/crates/vendor/tauri-plugin-http/src/scope.rs +++ /dev/null @@ -1,231 +0,0 @@ -// Copyright 2019-2023 Tauri Programme within The Commons Conservancy -// SPDX-License-Identifier: Apache-2.0 -// SPDX-License-Identifier: MIT - -use std::sync::Arc; - -use serde::{Deserialize, Deserializer}; -use url::Url; -use urlpattern::{UrlPattern, UrlPatternMatchInput}; - -#[allow(rustdoc::bare_urls)] -#[derive(Debug)] -pub struct Entry { - pub url: UrlPattern, -} - -fn parse_url_pattern(s: &str) -> Result { - let mut init = urlpattern::UrlPatternInit::parse_constructor_string::(s, None)?; - if init.search.as_ref().map(|p| p.is_empty()).unwrap_or(true) { - init.search.replace("*".to_string()); - } - if init.hash.as_ref().map(|p| p.is_empty()).unwrap_or(true) { - init.hash.replace("*".to_string()); - } - if init - .pathname - .as_ref() - .map(|p| p.is_empty() || p == "/") - .unwrap_or(true) - { - init.pathname.replace("*".to_string()); - } - UrlPattern::parse(init, Default::default()) -} - -#[derive(Deserialize)] -#[serde(untagged)] -pub(crate) enum EntryRaw { - Value(String), - Object { url: String }, -} - -impl<'de> Deserialize<'de> for Entry { - fn deserialize(deserializer: D) -> std::result::Result - where - D: Deserializer<'de>, - { - EntryRaw::deserialize(deserializer).and_then(|raw| { - let url = match raw { - EntryRaw::Value(url) => url, - EntryRaw::Object { url } => url, - }; - Ok(Entry { - url: parse_url_pattern(&url).map_err(|e| { - serde::de::Error::custom(format!("`{}` is not a valid URL pattern: {e}", url)) - })?, - }) - }) - } -} - -/// Scope for filesystem access. -#[derive(Debug)] -pub struct Scope<'a> { - allowed: Vec<&'a Arc>, - denied: Vec<&'a Arc>, -} - -impl<'a> Scope<'a> { - /// Creates a new scope from the scope configuration. - pub(crate) fn new(allowed: Vec<&'a Arc>, denied: Vec<&'a Arc>) -> Self { - Self { allowed, denied } - } - - /// Determines if the given URL is allowed on this scope. - pub fn is_allowed(&self, url: &Url) -> bool { - let denied = self.denied.iter().any(|entry| { - entry - .url - .test(UrlPatternMatchInput::Url(url.clone())) - .unwrap_or_default() - }); - if denied { - false - } else { - self.allowed.iter().any(|entry| { - entry - .url - .test(UrlPatternMatchInput::Url(url.clone())) - .unwrap_or_default() - }) - } - } -} - -#[cfg(test)] -mod tests { - use std::{str::FromStr, sync::Arc}; - - use super::Entry; - - impl FromStr for Entry { - type Err = urlpattern::quirks::Error; - - fn from_str(s: &str) -> Result { - let pattern = super::parse_url_pattern(s)?; - Ok(Self { url: pattern }) - } - } - - #[test] - fn denied_takes_precedence() { - let allow = Arc::new("http://localhost:8080/file.png".parse().unwrap()); - let deny = Arc::new("http://localhost:8080/*".parse().unwrap()); - let scope = super::Scope::new(vec![&allow], vec![&deny]); - assert!(!scope.is_allowed(&"http://localhost:8080/file.png".parse().unwrap())); - assert!(!scope.is_allowed(&"http://localhost:8080?framework=tauri".parse().unwrap())); - } - - #[test] - fn fixed_url() { - // plain URL - let entry = Arc::new("http://localhost:8080".parse().unwrap()); - let scope = super::Scope::new(vec![&entry], Vec::new()); - assert!(scope.is_allowed(&"http://localhost:8080".parse().unwrap())); - assert!(scope.is_allowed(&"http://localhost:8080/".parse().unwrap())); - assert!(scope.is_allowed(&"http://localhost:8080/file".parse().unwrap())); - assert!(scope.is_allowed(&"http://localhost:8080/path/to/asset.png".parse().unwrap())); - assert!(scope.is_allowed(&"http://localhost:8080/path/list?limit=50".parse().unwrap())); - - assert!(!scope.is_allowed(&"https://localhost:8080".parse().unwrap())); - assert!(!scope.is_allowed(&"http://localhost:8081".parse().unwrap())); - assert!(!scope.is_allowed(&"http://local:8080".parse().unwrap())); - } - - #[test] - fn fixed_path() { - // URL with fixed path - let entry = Arc::new("http://localhost:8080/file.png".parse().unwrap()); - let scope = super::Scope::new(vec![&entry], Vec::new()); - - assert!(scope.is_allowed(&"http://localhost:8080/file.png".parse().unwrap())); - assert!(scope.is_allowed(&"http://localhost:8080/file.png?q=1".parse().unwrap())); - - assert!(!scope.is_allowed(&"http://localhost:8080".parse().unwrap())); - assert!(!scope.is_allowed(&"http://localhost:8080/file".parse().unwrap())); - assert!(!scope.is_allowed(&"http://localhost:8080/file.png/other.jpg".parse().unwrap())); - } - - #[test] - fn pattern_wildcard() { - let entry = Arc::new("http://localhost:8080/*.png".parse().unwrap()); - let scope = super::Scope::new(vec![&entry], Vec::new()); - - assert!(scope.is_allowed(&"http://localhost:8080/file.png".parse().unwrap())); - assert!(scope.is_allowed(&"http://localhost:8080/file.png#head".parse().unwrap())); - assert!(scope.is_allowed(&"http://localhost:8080/assets/file.png".parse().unwrap())); - assert!(scope.is_allowed( - &"http://localhost:8080/assets/file.png?width=100&height=200" - .parse() - .unwrap() - )); - - assert!(!scope.is_allowed(&"http://localhost:8080/file.jpeg".parse().unwrap())); - } - - #[test] - fn domain_wildcard() { - let entry = Arc::new("http://*".parse().unwrap()); - let scope = super::Scope::new(vec![&entry], Vec::new()); - - assert!(scope.is_allowed(&"http://something.else".parse().unwrap())); - assert!(scope.is_allowed(&"http://something.else#tauri".parse().unwrap())); - assert!(scope.is_allowed(&"http://something.else/path/to/file".parse().unwrap())); - assert!(scope.is_allowed(&"http://something.else?rel=tauri".parse().unwrap())); - assert!(scope.is_allowed( - &"http://something.else/path/to/file.mp4?start=500" - .parse() - .unwrap() - )); - - assert!(!scope.is_allowed(&"https://something.else".parse().unwrap())); - - let entry = Arc::new("http://*/*".parse().unwrap()); - let scope = super::Scope::new(vec![&entry], Vec::new()); - - assert!(scope.is_allowed(&"http://something.else".parse().unwrap())); - assert!(scope.is_allowed(&"http://something.else/path/to/file".parse().unwrap())); - } - - #[test] - fn scheme_wildcard() { - let entry = Arc::new("*://*".parse().unwrap()); - let scope = super::Scope::new(vec![&entry], Vec::new()); - - assert!(scope.is_allowed(&"http://something.else".parse().unwrap())); - assert!(scope.is_allowed(&"http://something.else/path/to/file".parse().unwrap())); - assert!(scope.is_allowed(&"file://path".parse().unwrap())); - assert!(scope.is_allowed(&"file://path/to/file".parse().unwrap())); - assert!(scope.is_allowed(&"https://something.else".parse().unwrap())); - assert!(scope.is_allowed(&"https://something.else?x=1#frag".parse().unwrap())); - - let entry = Arc::new("*://*/*".parse().unwrap()); - let scope = super::Scope::new(vec![&entry], Vec::new()); - - assert!(scope.is_allowed(&"http://something.else".parse().unwrap())); - assert!(scope.is_allowed(&"http://something.else/path/to/file".parse().unwrap())); - assert!(scope.is_allowed(&"file://path/to/file".parse().unwrap())); - assert!(scope.is_allowed(&"https://something.else".parse().unwrap())); - } - - #[test] - fn validate_query() { - let entry = Arc::new("https://tauri.app/path?x=*".parse().unwrap()); - let scope = super::Scope::new(vec![&entry], Vec::new()); - - assert!(scope.is_allowed(&"https://tauri.app/path?x=5".parse().unwrap())); - - assert!(!scope.is_allowed(&"https://tauri.app/path?y=5".parse().unwrap())); - } - - #[test] - fn validate_hash() { - let entry = Arc::new("https://tauri.app/path#frame*".parse().unwrap()); - let scope = super::Scope::new(vec![&entry], Vec::new()); - - assert!(scope.is_allowed(&"https://tauri.app/path#frame".parse().unwrap())); - - assert!(!scope.is_allowed(&"https://tauri.app/path#work".parse().unwrap())); - } -} diff --git a/crates/vendor/tauri-plugin-http/tsconfig.json b/crates/vendor/tauri-plugin-http/tsconfig.json deleted file mode 100644 index 5098169aa9..0000000000 --- a/crates/vendor/tauri-plugin-http/tsconfig.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "extends": "../../tsconfig.base.json", - "include": ["guest-js/*.ts"] -} diff --git a/crates/workspace-build-acceleration/Cargo.toml b/crates/workspace-build-acceleration/Cargo.toml index a64782fada..76d4a82afd 100644 --- a/crates/workspace-build-acceleration/Cargo.toml +++ b/crates/workspace-build-acceleration/Cargo.toml @@ -17,250 +17,237 @@ publish = false [dependencies] actix-router = { version = "0.5.4" } actix-rt = { version = "2.11.0" } -ahash = { version = "0.8.11" } -anstream = { version = "0.6.14" } +ahash = { version = "0.8.12" } +anstream = { version = "0.6.21" } arrayvec = { version = "0.7.6" } -base64-3c51e837cfc5589a = { package = "base64", version = "0.22.1" } -base64-647d43efb71741da = { package = "base64", version = "0.21.7" } +async-stripe-shared = { version = "1.0.0-alpha.2", default-features = false, features = ["deserialize"] } +async-stripe-types = { version = "1.0.0-alpha.2", default-features = false, features = ["deserialize"] } +base64 = { version = "0.22.1" } base64ct = { version = "1.6.0", default-features = false, features = ["alloc"] } -bitflags = { version = "2.5.0", default-features = false, features = ["serde", "std"] } +bitflags = { version = "2.11.0", default-features = false, features = ["serde", "std"] } block-buffer = { version = "0.9.0", default-features = false, features = ["block-padding"] } bytemuck = { version = "1.16.0", default-features = false, features = ["extern_crate_alloc"] } byteorder = { version = "1.5.0" } -bytes = { version = "1.10.0", features = ["serde"] } -chrono = { version = "0.4.41", features = ["serde"] } -clap = { version = "4.5.13", features = ["derive"] } +chrono = { version = "0.4.44", features = ["serde"] } +clap = { version = "4.5.60", features = ["derive"] } +combine = { version = "4.6.6", features = ["tokio"] } cookie = { version = "0.18.1", default-features = false, features = ["percent-encode"] } crossbeam-utils = { version = "0.8.20" } crypto-common = { version = "0.1.6", default-features = false, features = ["std"] } deranged = { version = "0.3.11", default-features = false, features = ["powerfmt", "serde", "std"] } digest = { version = "0.10.7", features = ["mac", "oid", "std"] } either = { version = "1.12.0", features = ["serde"] } -flate2 = { version = "1.0.30" } -form_urlencoded = { version = "1.2.1" } -futures = { version = "0.3.31", features = ["thread-pool"] } -futures-channel = { version = "0.3.31", features = ["sink"] } -futures-core = { version = "0.3.31" } -futures-executor = { version = "0.3.31", features = ["thread-pool"] } -futures-io = { version = "0.3.31" } -futures-sink = { version = "0.3.31" } -futures-task = { version = "0.3.31", default-features = false, features = ["std"] } -futures-util = { version = "0.3.31", features = ["channel", "io", "sink"] } +flate2 = { version = "1.1.2", features = ["zlib-rs"] } +form_urlencoded = { version = "1.2.2" } +futures = { version = "0.3.32", features = ["thread-pool"] } +futures-channel = { version = "0.3.32", features = ["sink"] } +futures-core = { version = "0.3.32" } +futures-executor = { version = "0.3.32", features = ["thread-pool"] } +futures-io = { version = "0.3.32" } +futures-sink = { version = "0.3.32" } +futures-task = { version = "0.3.32", default-features = false, features = ["std"] } +futures-util = { version = "0.3.32", features = ["channel", "io", "sink"] } generic-array = { version = "0.14.7", default-features = false, features = ["more_lengths", "zeroize"] } +getrandom-468e82937335b1c9 = { package = "getrandom", version = "0.3.1", default-features = false, features = ["std", "wasm_js"] } getrandom-6f8ce4dd05d13bba = { package = "getrandom", version = "0.2.14", default-features = false, features = ["js", "std"] } -hashbrown = { version = "0.14.5" } +getrandom-9fbad63c4bcf4a8f = { package = "getrandom", version = "0.4.1", default-features = false, features = ["std", "sys_rng", "wasm_js"] } +hashbrown-582f2526e08bb6a0 = { package = "hashbrown", version = "0.14.5", features = ["raw"] } +hashbrown-986da7b5efc2b80e = { package = "hashbrown", version = "0.16.1" } hmac = { version = "0.12.1", default-features = false, features = ["reset"] } -idna = { version = "1.0.3" } -indexmap-dff4ba8e3ae991db = { package = "indexmap", version = "1.9.3", default-features = false, features = ["serde-1"] } -indexmap-f595c2ba2a3f28df = { package = "indexmap", version = "2.9.0", features = ["serde"] } +hyper-582f2526e08bb6a0 = { package = "hyper", version = "0.14.28", features = ["full"] } +hyper-dff4ba8e3ae991db = { package = "hyper", version = "1.6.0", features = ["client", "http1", "http2"] } +hyper-rustls-754bda37e0fb3874 = { package = "hyper-rustls", version = "0.27.3", default-features = false, features = ["aws-lc-rs", "http1", "http2", "logging", "ring", "rustls-native-certs", "tls12", "webpki-tokio"] } +hyper-util = { version = "0.1.16", features = ["client-legacy", "client-proxy", "client-proxy-system", "http1", "http2"] } +idna = { version = "1.1.0" } +indexmap-dff4ba8e3ae991db = { package = "indexmap", version = "1.9.3", default-features = false, features = ["std"] } +indexmap-f595c2ba2a3f28df = { package = "indexmap", version = "2.13.0", features = ["serde"] } +itertools = { version = "0.13.0" } lazy_static = { version = "1.4.0", default-features = false, features = ["spin_no_std"] } -libc = { version = "0.2.170", features = ["extra_traits"] } -log = { version = "0.4.27", default-features = false, features = ["kv_unstable", "std"] } +log = { version = "0.4.29", default-features = false, features = ["release_max_level_info", "std"] } md-5 = { version = "0.10.6" } -memchr = { version = "2.7.4", features = ["use_std"] } +memchr = { version = "2.7.4" } mime_guess = { version = "2.0.4" } +miniz_oxide = { version = "0.8.9", features = ["simd"] } +mio = { version = "1.0.2", features = ["net", "os-ext"] } +nom = { version = "7.1.3" } num-bigint = { version = "0.4.6" } num-integer = { version = "0.1.46", features = ["i128"] } num-iter = { version = "0.1.45", default-features = false, features = ["i128", "std"] } num-rational = { version = "0.4.2", features = ["num-bigint-std", "serde"] } num-traits = { version = "0.2.19", features = ["i128", "libm"] } -once_cell = { version = "1.21.3" } -parking_lot = { version = "0.12.2" } -percent-encoding = { version = "2.3.1" } -proc-macro2 = { version = "1.0.85", features = ["span-locations"] } -quote = { version = "1.0.36" } -rand-c38e5c1d305a1b54 = { package = "rand", version = "0.8.5", features = ["small_rng"] } -rand-ca01ad9e24f5d932 = { package = "rand", version = "0.7.3", features = ["small_rng"] } +once_cell = { version = "1.21.4" } +parking_lot = { version = "0.12.5" } +percent-encoding = { version = "2.3.2" } +proc-macro2 = { version = "1.0.106", features = ["span-locations"] } +quote = { version = "1.0.45" } +rand = { version = "0.8.5", features = ["small_rng"] } rand_chacha = { version = "0.3.1" } rand_core = { version = "0.6.4", default-features = false, features = ["std"] } -regex = { version = "1.11.1" } -regex-automata = { version = "0.4.9", default-features = false, features = ["dfa-onepass", "hybrid", "meta", "nfa-backtrack", "perf-inline", "perf-literal", "unicode"] } +regex = { version = "1.12.3" } +regex-automata = { version = "0.4.13", default-features = false, features = ["dfa-onepass", "hybrid", "meta", "nfa-backtrack", "perf-inline", "perf-literal", "std", "unicode"] } regex-syntax = { version = "0.8.5" } +reqwest = { version = "0.12.23", default-features = false, features = ["blocking", "charset", "cookies", "gzip", "http2", "json", "multipart", "rustls-tls", "stream", "system-proxy"] } rsa = { version = "0.9.6", features = ["getrandom", "hazmat", "sha2"] } -schemars = { version = "0.8.21", features = ["preserve_order", "url", "uuid1"] } -scopeguard = { version = "1.2.0" } -semver = { version = "1.0.23", features = ["serde"] } -serde = { version = "1.0.219", features = ["alloc", "derive", "rc"] } -serde_json = { version = "1.0.140", features = ["alloc", "preserve_order", "raw_value", "unbounded_depth"] } +rustls-2b5c6dc72f624058 = { package = "rustls", version = "0.23.36", features = ["ring"] } +rustls-647d43efb71741da = { package = "rustls", version = "0.21.12", features = ["dangerous_configuration"] } +rustls-pki-types = { version = "1.12.0", features = ["std"] } +rustls-webpki = { version = "0.103.9", default-features = false, features = ["aws-lc-rs", "ring", "std"] } +serde = { version = "1.0.228", features = ["alloc", "derive", "rc"] } +serde_core = { version = "1.0.228", default-features = false, features = ["alloc", "rc", "result", "std"] } +serde_json = { version = "1.0.149", features = ["preserve_order", "raw_value"] } sha1 = { version = "0.10.6" } sha2 = { version = "0.10.8", features = ["oid"] } -smallvec = { version = "1.13.2", default-features = false, features = ["const_new", "union"] } -socket2 = { version = "0.5.7", default-features = false, features = ["all"] } -sqlx-mysql = { version = "0.7.3", default-features = false, features = ["any", "bigdecimal", "chrono", "json", "migrate", "offline"] } -sqlx-sqlite = { version = "0.7.3", default-features = false, features = ["any", "chrono", "json", "migrate", "offline"] } -stable_deref_trait = { version = "1.2.0" } +simd-adler32 = { version = "0.3.7" } +slab = { version = "0.4.9" } +smallvec = { version = "1.15.1", default-features = false, features = ["const_new"] } +socket2 = { version = "0.5.10", default-features = false, features = ["all"] } +sqlx = { version = "0.7.4", features = ["bigdecimal", "chrono", "mysql", "runtime-tokio-rustls", "sqlite"] } +sqlx-core = { version = "0.7.4", features = ["_rt-tokio", "_tls-rustls", "any", "bigdecimal", "chrono", "json", "migrate", "offline"] } +sqlx-mysql = { version = "0.7.4", default-features = false, features = ["any", "bigdecimal", "chrono", "json", "migrate", "offline"] } +sqlx-sqlite = { version = "0.7.4", default-features = false, features = ["any", "chrono", "json", "migrate", "offline"] } subtle = { version = "2.5.0", default-features = false, features = ["i128"] } -syn-f595c2ba2a3f28df = { package = "syn", version = "2.0.87", features = ["extra-traits", "fold", "full", "visit", "visit-mut"] } -tauri-utils = { version = "2.9.2", default-features = false, features = ["build", "compression", "resources"] } -time = { version = "0.3.36", features = ["local-offset", "macros", "serde-well-known"] } -tokio = { version = "1.45.1", features = ["full"] } -tokio-stream = { version = "0.1.16", features = ["fs"] } -tracing = { version = "0.1.40", features = ["log"] } +syn-f595c2ba2a3f28df = { package = "syn", version = "2.0.117", features = ["extra-traits", "fold", "full", "visit", "visit-mut"] } +time = { version = "0.3.36", features = ["macros", "serde-well-known"] } +tokio = { version = "1.50.0", features = ["full"] } +tokio-rustls-2f80eeee3b1b6c7e = { package = "tokio-rustls", version = "0.26.0", default-features = false, features = ["aws-lc-rs", "logging", "ring", "tls12"] } +tokio-rustls-adf3d7031871b0af = { package = "tokio-rustls", version = "0.24.1" } +tokio-stream = { version = "0.1.18", features = ["fs"] } +tower-http = { version = "0.6.8", default-features = false, features = ["decompression-br", "decompression-deflate", "decompression-gzip", "decompression-zstd", "follow-redirect"] } +typenum = { version = "1.17.0", default-features = false, features = ["const-generics"] } unicode-bidi = { version = "0.3.15" } unicode-normalization = { version = "0.1.23" } -url = { version = "2.5.4", features = ["serde"] } -uuid = { version = "1.8.0", features = ["serde", "v4"] } -void = { version = "1.0.2" } +url = { version = "2.5.8", features = ["serde"] } +uuid = { version = "1.22.0", features = ["v4"] } zeroize = { version = "1.8.1", features = ["zeroize_derive"] } +zstd = { version = "0.13.3" } +zstd-safe = { version = "7.1.0", default-features = false, features = ["arrays", "legacy", "std", "zdict_builder"] } +zstd-sys = { version = "2.0.10", default-features = false, features = ["legacy", "std", "zdict_builder"] } [build-dependencies] actix-router = { version = "0.5.4" } -ahash = { version = "0.8.11" } -base64-3c51e837cfc5589a = { package = "base64", version = "0.22.1" } -base64-647d43efb71741da = { package = "base64", version = "0.21.7" } +ahash = { version = "0.8.12" } base64ct = { version = "1.6.0", default-features = false, features = ["alloc"] } -bitflags = { version = "2.5.0", default-features = false, features = ["serde", "std"] } +bitflags = { version = "2.11.0", default-features = false, features = ["serde", "std"] } byteorder = { version = "1.5.0" } -bytes = { version = "1.10.0", features = ["serde"] } -cc = { version = "1.0.99", default-features = false, features = ["parallel"] } -chrono = { version = "0.4.41", features = ["serde"] } +cc = { version = "1.2.56", default-features = false, features = ["parallel"] } +chrono = { version = "0.4.44", features = ["serde"] } crossbeam-utils = { version = "0.8.20" } crypto-common = { version = "0.1.6", default-features = false, features = ["std"] } -derive_more = { version = "0.99.17", features = ["nightly"] } digest = { version = "0.10.7", features = ["mac", "oid", "std"] } either = { version = "1.12.0", features = ["serde"] } -flate2 = { version = "1.0.30" } -form_urlencoded = { version = "1.2.1" } -futures-channel = { version = "0.3.31", features = ["sink"] } -futures-core = { version = "0.3.31" } -futures-executor = { version = "0.3.31", features = ["thread-pool"] } -futures-io = { version = "0.3.31" } -futures-sink = { version = "0.3.31" } -futures-task = { version = "0.3.31", default-features = false, features = ["std"] } -futures-util = { version = "0.3.31", features = ["channel", "io", "sink"] } +flate2 = { version = "1.1.2", features = ["zlib-rs"] } +form_urlencoded = { version = "1.2.2" } +futures-channel = { version = "0.3.32", features = ["sink"] } +futures-core = { version = "0.3.32" } +futures-executor = { version = "0.3.32", features = ["thread-pool"] } +futures-io = { version = "0.3.32" } +futures-sink = { version = "0.3.32" } +futures-task = { version = "0.3.32", default-features = false, features = ["std"] } +futures-util = { version = "0.3.32", features = ["channel", "io", "sink"] } generic-array = { version = "0.14.7", default-features = false, features = ["more_lengths", "zeroize"] } +getrandom-468e82937335b1c9 = { package = "getrandom", version = "0.3.1", default-features = false, features = ["std", "wasm_js"] } getrandom-6f8ce4dd05d13bba = { package = "getrandom", version = "0.2.14", default-features = false, features = ["js", "std"] } -hashbrown = { version = "0.14.5" } +hashbrown-582f2526e08bb6a0 = { package = "hashbrown", version = "0.14.5", features = ["raw"] } +hashbrown-986da7b5efc2b80e = { package = "hashbrown", version = "0.16.1" } hmac = { version = "0.12.1", default-features = false, features = ["reset"] } -idna = { version = "1.0.3" } -indexmap-dff4ba8e3ae991db = { package = "indexmap", version = "1.9.3", default-features = false, features = ["serde-1"] } -indexmap-f595c2ba2a3f28df = { package = "indexmap", version = "2.9.0", features = ["serde"] } +idna = { version = "1.1.0" } +indexmap-f595c2ba2a3f28df = { package = "indexmap", version = "2.13.0", features = ["serde"] } +itertools = { version = "0.13.0" } lazy_static = { version = "1.4.0", default-features = false, features = ["spin_no_std"] } -libc = { version = "0.2.170", features = ["extra_traits"] } -log = { version = "0.4.27", default-features = false, features = ["kv_unstable", "std"] } +log = { version = "0.4.29", default-features = false, features = ["release_max_level_info", "std"] } md-5 = { version = "0.10.6" } -memchr = { version = "2.7.4", features = ["use_std"] } +memchr = { version = "2.7.4" } +miniz_oxide = { version = "0.8.9", features = ["simd"] } +mio = { version = "1.0.2", features = ["net", "os-ext"] } +nom = { version = "7.1.3" } num-bigint = { version = "0.4.6" } num-integer = { version = "0.1.46", features = ["i128"] } num-iter = { version = "0.1.45", default-features = false, features = ["i128", "std"] } num-traits = { version = "0.2.19", features = ["i128", "libm"] } -once_cell = { version = "1.21.3" } -parking_lot = { version = "0.12.2" } -percent-encoding = { version = "2.3.1" } -proc-macro2 = { version = "1.0.85", features = ["span-locations"] } -quote = { version = "1.0.36" } -rand-c38e5c1d305a1b54 = { package = "rand", version = "0.8.5", features = ["small_rng"] } -rand-ca01ad9e24f5d932 = { package = "rand", version = "0.7.3", features = ["small_rng"] } +once_cell = { version = "1.21.4" } +parking_lot = { version = "0.12.5" } +percent-encoding = { version = "2.3.2" } +proc-macro2 = { version = "1.0.106", features = ["span-locations"] } +quote = { version = "1.0.45" } +rand = { version = "0.8.5", features = ["small_rng"] } rand_chacha = { version = "0.3.1" } rand_core = { version = "0.6.4", default-features = false, features = ["std"] } -regex = { version = "1.11.1" } -regex-automata = { version = "0.4.9", default-features = false, features = ["dfa-onepass", "hybrid", "meta", "nfa-backtrack", "perf-inline", "perf-literal", "unicode"] } +regex = { version = "1.12.3" } +regex-automata = { version = "0.4.13", default-features = false, features = ["dfa-onepass", "hybrid", "meta", "nfa-backtrack", "perf-inline", "perf-literal", "std", "unicode"] } regex-syntax = { version = "0.8.5" } rsa = { version = "0.9.6", features = ["getrandom", "hazmat", "sha2"] } -schemars = { version = "0.8.21", features = ["preserve_order", "url", "uuid1"] } -scopeguard = { version = "1.2.0" } -semver = { version = "1.0.23", features = ["serde"] } -serde = { version = "1.0.219", features = ["alloc", "derive", "rc"] } -serde_json = { version = "1.0.140", features = ["alloc", "preserve_order", "raw_value", "unbounded_depth"] } +rustls-647d43efb71741da = { package = "rustls", version = "0.21.12", features = ["dangerous_configuration"] } +serde = { version = "1.0.228", features = ["alloc", "derive", "rc"] } +serde_core = { version = "1.0.228", default-features = false, features = ["alloc", "rc", "result", "std"] } +serde_json = { version = "1.0.149", features = ["preserve_order", "raw_value"] } sha1 = { version = "0.10.6" } sha2 = { version = "0.10.8", features = ["oid"] } -smallvec = { version = "1.13.2", default-features = false, features = ["const_new", "union"] } -sqlx-mysql = { version = "0.7.3", default-features = false, features = ["any", "bigdecimal", "chrono", "json", "migrate", "offline"] } -sqlx-sqlite = { version = "0.7.3", default-features = false, features = ["any", "chrono", "json", "migrate", "offline"] } -stable_deref_trait = { version = "1.2.0" } +simd-adler32 = { version = "0.3.7" } +slab = { version = "0.4.9" } +smallvec = { version = "1.15.1", default-features = false, features = ["const_new"] } +sqlx-core = { version = "0.7.4", features = ["_rt-tokio", "_tls-rustls", "any", "bigdecimal", "chrono", "json", "migrate", "offline"] } +sqlx-macros = { version = "0.7.4", features = ["_rt-tokio", "_tls-rustls", "bigdecimal", "chrono", "json", "migrate", "mysql", "sqlite"] } +sqlx-macros-core = { version = "0.7.4", features = ["_rt-tokio", "_tls-rustls", "bigdecimal", "chrono", "json", "migrate", "mysql", "sqlite"] } +sqlx-mysql = { version = "0.7.4", default-features = false, features = ["any", "bigdecimal", "chrono", "json", "migrate", "offline"] } +sqlx-sqlite = { version = "0.7.4", default-features = false, features = ["any", "chrono", "json", "migrate", "offline"] } subtle = { version = "2.5.0", default-features = false, features = ["i128"] } -syn-dff4ba8e3ae991db = { package = "syn", version = "1.0.109", features = ["extra-traits", "fold", "full", "visit-mut"] } -syn-f595c2ba2a3f28df = { package = "syn", version = "2.0.87", features = ["extra-traits", "fold", "full", "visit", "visit-mut"] } -tauri-build = { version = "2.6.2" } -tauri-utils = { version = "2.9.2", default-features = false, features = ["build", "compression", "resources"] } +syn-dff4ba8e3ae991db = { package = "syn", version = "1.0.109", features = ["extra-traits", "full"] } +syn-f595c2ba2a3f28df = { package = "syn", version = "2.0.117", features = ["extra-traits", "fold", "full", "visit", "visit-mut"] } time-macros = { version = "0.2.18", default-features = false, features = ["formatting", "parsing", "serde"] } -tokio = { version = "1.45.1", features = ["full"] } -tokio-stream = { version = "0.1.16", features = ["fs"] } -tracing = { version = "0.1.40", features = ["log"] } +tokio = { version = "1.50.0", features = ["full"] } +tokio-stream = { version = "0.1.18", features = ["fs"] } +typenum = { version = "1.17.0", default-features = false, features = ["const-generics"] } unicode-bidi = { version = "0.3.15" } unicode-normalization = { version = "0.1.23" } -url = { version = "2.5.4", features = ["serde"] } -uuid = { version = "1.8.0", features = ["serde", "v4"] } +url = { version = "2.5.8", features = ["serde"] } zeroize = { version = "1.8.1", features = ["zeroize_derive"] } [target.x86_64-unknown-linux-gnu.dependencies] -async-compression = { version = "0.4.5", default-features = false, features = ["brotli", "gzip", "tokio", "zlib", "zstd"] } -getrandom-468e82937335b1c9 = { package = "getrandom", version = "0.3.1", default-features = false, features = ["std"] } -rustls-pki-types = { version = "1.7.0", features = ["std"] } +async-compression = { version = "0.4.27", default-features = false, features = ["brotli", "gzip", "tokio", "zlib", "zstd"] } +hyper-rustls-adf3d7031871b0af = { package = "hyper-rustls", version = "0.24.2", default-features = false, features = ["http1", "http2", "logging", "native-tokio", "tls12"] } +libc = { version = "0.2.183", features = ["extra_traits"] } spin = { version = "0.9.8" } -tokio-util = { version = "0.7.12", features = ["codec", "io"] } -toml_edit = { version = "0.19.15", features = ["serde"] } -zstd = { version = "0.13.1" } -zstd-safe = { version = "7.1.0", default-features = false, features = ["arrays", "legacy", "std", "zdict_builder"] } -zstd-sys = { version = "2.0.10", default-features = false, features = ["legacy", "std", "zdict_builder"] } +tokio-util = { version = "0.7.18", features = ["codec", "io"] } +tracing = { version = "0.1.41", features = ["log"] } [target.x86_64-unknown-linux-gnu.build-dependencies] -getrandom-468e82937335b1c9 = { package = "getrandom", version = "0.3.1", default-features = false, features = ["std"] } -heck = { version = "0.4.1", features = ["unicode"] } -socket2 = { version = "0.5.7", default-features = false, features = ["all"] } +getrandom-9fbad63c4bcf4a8f = { package = "getrandom", version = "0.4.1", default-features = false, features = ["std", "sys_rng", "wasm_js"] } +libc = { version = "0.2.183", features = ["extra_traits"] } spin = { version = "0.9.8" } -toml_edit = { version = "0.19.15", features = ["serde"] } -zstd = { version = "0.13.1" } -zstd-safe = { version = "7.1.0", default-features = false, features = ["arrays", "legacy", "std", "zdict_builder"] } -zstd-sys = { version = "2.0.10", default-features = false, features = ["legacy", "std", "zdict_builder"] } +tracing = { version = "0.1.41", features = ["log"] } [target.x86_64-apple-darwin.dependencies] -async-compression = { version = "0.4.5", default-features = false, features = ["brotli", "gzip", "tokio", "zlib", "zstd"] } -core-foundation-sys = { version = "0.8.7" } -getrandom-468e82937335b1c9 = { package = "getrandom", version = "0.3.1", default-features = false, features = ["std"] } -quick-xml = { version = "0.32.0", features = ["serialize"] } -rustls-pki-types = { version = "1.7.0", features = ["std"] } -security-framework = { version = "2.10.0", features = ["alpn"] } +async-compression = { version = "0.4.27", default-features = false, features = ["brotli", "gzip", "tokio", "zlib", "zstd"] } +hyper-rustls-adf3d7031871b0af = { package = "hyper-rustls", version = "0.24.2", default-features = false, features = ["http1", "http2", "logging", "native-tokio", "tls12"] } +libc = { version = "0.2.183", features = ["extra_traits"] } +security-framework-sys = { version = "2.17.0", features = ["OSX_10_10", "OSX_10_11", "OSX_10_9"] } spin = { version = "0.9.8" } -tokio-util = { version = "0.7.12", features = ["codec", "io"] } -zstd = { version = "0.13.1" } -zstd-safe = { version = "7.1.0", default-features = false, features = ["arrays", "legacy", "std", "zdict_builder"] } -zstd-sys = { version = "2.0.10", default-features = false, features = ["legacy", "std", "zdict_builder"] } +tokio-util = { version = "0.7.18", features = ["codec", "io"] } +tracing = { version = "0.1.41", features = ["log"] } [target.x86_64-apple-darwin.build-dependencies] -core-foundation-sys = { version = "0.8.7" } -deranged = { version = "0.3.11", default-features = false, features = ["powerfmt", "serde", "std"] } -getrandom-468e82937335b1c9 = { package = "getrandom", version = "0.3.1", default-features = false, features = ["std"] } -quick-xml = { version = "0.32.0", features = ["serialize"] } -security-framework = { version = "2.10.0", features = ["alpn"] } -socket2 = { version = "0.5.7", default-features = false, features = ["all"] } +getrandom-9fbad63c4bcf4a8f = { package = "getrandom", version = "0.4.1", default-features = false, features = ["std", "sys_rng", "wasm_js"] } +libc = { version = "0.2.183", features = ["extra_traits"] } spin = { version = "0.9.8" } -time = { version = "0.3.36", features = ["local-offset", "macros", "serde-well-known"] } -zstd = { version = "0.13.1" } -zstd-safe = { version = "7.1.0", default-features = false, features = ["arrays", "legacy", "std", "zdict_builder"] } -zstd-sys = { version = "2.0.10", default-features = false, features = ["legacy", "std", "zdict_builder"] } +tracing = { version = "0.1.41", features = ["log"] } [target.x86_64-pc-windows-msvc.dependencies] -async-compression = { version = "0.4.5", default-features = false, features = ["brotli", "gzip", "tokio", "zlib", "zstd"] } -getrandom-468e82937335b1c9 = { package = "getrandom", version = "0.3.1", default-features = false, features = ["std"] } -rustls-pki-types = { version = "1.7.0", features = ["std"] } +async-compression = { version = "0.4.27", default-features = false, features = ["brotli", "gzip", "tokio", "zlib", "zstd"] } +hyper-rustls-adf3d7031871b0af = { package = "hyper-rustls", version = "0.24.2", default-features = false, features = ["http1", "http2", "logging", "native-tokio", "tls12"] } spin = { version = "0.9.8" } -tokio-util = { version = "0.7.12", features = ["codec", "io"] } -winapi = { version = "0.3.9", default-features = false, features = ["basetsd", "consoleapi", "dbghelp", "errhandlingapi", "fibersapi", "fileapi", "handleapi", "libloaderapi", "memoryapi", "minwindef", "namedpipeapi", "ntsecapi", "ntstatus", "processenv", "processthreadsapi", "profileapi", "std", "synchapi", "sysinfoapi", "winbase", "wincon", "winerror", "winnt", "winsock2", "ws2def", "ws2ipdef", "ws2tcpip"] } -windows-sys-73dcd821b1037cfd = { package = "windows-sys", version = "0.59.0", features = ["Win32_Globalization", "Win32_Graphics_Dwm", "Win32_Graphics_Gdi", "Win32_Networking_WinSock", "Win32_Storage_FileSystem", "Win32_System_Com", "Win32_System_Diagnostics_Debug", "Win32_System_LibraryLoader", "Win32_System_SystemInformation", "Win32_System_SystemServices", "Win32_UI_Accessibility", "Win32_UI_Controls", "Win32_UI_HiDpi", "Win32_UI_Input_KeyboardAndMouse", "Win32_UI_Shell", "Win32_UI_WindowsAndMessaging"] } -windows-sys-b21d60becc0929df = { package = "windows-sys", version = "0.52.0", features = ["Wdk_Foundation", "Wdk_Storage_FileSystem", "Wdk_System_IO", "Win32_Foundation", "Win32_Networking_WinSock", "Win32_Security_Authentication_Identity", "Win32_Security_Credentials", "Win32_Security_Cryptography", "Win32_Storage_FileSystem", "Win32_System_Console", "Win32_System_IO", "Win32_System_Memory", "Win32_System_Pipes", "Win32_System_SystemServices", "Win32_System_Threading", "Win32_System_WindowsProgramming"] } -windows-sys-c8eced492e86ede7 = { package = "windows-sys", version = "0.48.0", features = ["Win32_Foundation", "Win32_Networking_WinSock", "Win32_Security", "Win32_Storage_FileSystem", "Win32_System_Com", "Win32_System_Diagnostics_Debug", "Win32_System_IO", "Win32_System_Registry", "Win32_System_Time", "Win32_System_WindowsProgramming", "Win32_UI_Controls", "Win32_UI_Shell_Common", "Win32_UI_WindowsAndMessaging"] } -zstd = { version = "0.13.1" } -zstd-safe = { version = "7.1.0", default-features = false, features = ["arrays", "legacy", "std", "zdict_builder"] } -zstd-sys = { version = "2.0.10", default-features = false, features = ["legacy", "std", "zdict_builder"] } +tokio-util = { version = "0.7.18", features = ["codec", "io"] } +tracing = { version = "0.1.41", features = ["log"] } +winapi = { version = "0.3.9", default-features = false, features = ["audioclient", "audiosessiontypes", "combaseapi", "coml2api", "consoleapi", "debug", "devpkey", "errhandlingapi", "fibersapi", "fileapi", "handleapi", "ksmedia", "memoryapi", "minwinbase", "minwindef", "mmdeviceapi", "namedpipeapi", "ntsecapi", "ntstatus", "objbase", "processenv", "processthreadsapi", "profileapi", "std", "synchapi", "sysinfoapi", "winbase", "wincon", "winerror", "winnt", "winsock2", "winuser"] } +windows-sys-b21d60becc0929df = { package = "windows-sys", version = "0.52.0", features = ["Wdk_Foundation", "Wdk_Storage_FileSystem", "Wdk_System_IO", "Win32_Foundation", "Win32_Networking_WinSock", "Win32_Security", "Win32_Storage_FileSystem", "Win32_System_Console", "Win32_System_IO", "Win32_System_Pipes", "Win32_System_Threading", "Win32_System_WindowsProgramming"] } +windows-sys-c8eced492e86ede7 = { package = "windows-sys", version = "0.48.0", features = ["Win32_Foundation", "Win32_Security", "Win32_Storage_FileSystem", "Win32_System_Diagnostics_Debug", "Win32_System_Registry", "Win32_System_Time", "Win32_UI_Shell"] } +windows-sys-d4189bed749088b6 = { package = "windows-sys", version = "0.61.2", features = ["Win32_Networking_WinSock", "Win32_Security_Authentication_Identity", "Win32_Security_Credentials", "Win32_Security_Cryptography", "Win32_Storage_FileSystem", "Win32_System_Console", "Win32_System_LibraryLoader", "Win32_System_Memory", "Win32_System_Pipes", "Win32_System_SystemInformation", "Win32_System_SystemServices", "Win32_System_Threading", "Win32_System_WindowsProgramming"] } [target.x86_64-pc-windows-msvc.build-dependencies] -async-compression = { version = "0.4.5", default-features = false, features = ["brotli", "gzip", "tokio", "zlib", "zstd"] } -cookie = { version = "0.18.1", default-features = false, features = ["percent-encode"] } -deranged = { version = "0.3.11", default-features = false, features = ["powerfmt", "serde", "std"] } -getrandom-468e82937335b1c9 = { package = "getrandom", version = "0.3.1", default-features = false, features = ["std"] } -mime_guess = { version = "2.0.4" } -rustls-pki-types = { version = "1.7.0", features = ["std"] } -socket2 = { version = "0.5.7", default-features = false, features = ["all"] } +getrandom-9fbad63c4bcf4a8f = { package = "getrandom", version = "0.4.1", default-features = false, features = ["std", "sys_rng", "wasm_js"] } spin = { version = "0.9.8" } -time = { version = "0.3.36", features = ["local-offset", "macros", "serde-well-known"] } -tokio-util = { version = "0.7.12", features = ["codec", "io"] } -winapi = { version = "0.3.9", default-features = false, features = ["basetsd", "consoleapi", "dbghelp", "errhandlingapi", "fibersapi", "fileapi", "handleapi", "libloaderapi", "memoryapi", "minwindef", "namedpipeapi", "ntsecapi", "ntstatus", "processenv", "processthreadsapi", "profileapi", "std", "synchapi", "sysinfoapi", "winbase", "wincon", "winerror", "winnt", "winsock2", "ws2def", "ws2ipdef", "ws2tcpip"] } -windows-sys-73dcd821b1037cfd = { package = "windows-sys", version = "0.59.0", features = ["Win32_Globalization", "Win32_Graphics_Dwm", "Win32_Graphics_Gdi", "Win32_Networking_WinSock", "Win32_Storage_FileSystem", "Win32_System_Com", "Win32_System_Diagnostics_Debug", "Win32_System_LibraryLoader", "Win32_System_SystemInformation", "Win32_System_SystemServices", "Win32_UI_Accessibility", "Win32_UI_Controls", "Win32_UI_HiDpi", "Win32_UI_Input_KeyboardAndMouse", "Win32_UI_Shell", "Win32_UI_WindowsAndMessaging"] } -windows-sys-b21d60becc0929df = { package = "windows-sys", version = "0.52.0", features = ["Wdk_Foundation", "Wdk_Storage_FileSystem", "Wdk_System_IO", "Win32_Foundation", "Win32_Networking_WinSock", "Win32_Security_Authentication_Identity", "Win32_Security_Credentials", "Win32_Security_Cryptography", "Win32_Storage_FileSystem", "Win32_System_Console", "Win32_System_IO", "Win32_System_Memory", "Win32_System_Pipes", "Win32_System_SystemServices", "Win32_System_Threading", "Win32_System_WindowsProgramming"] } -windows-sys-c8eced492e86ede7 = { package = "windows-sys", version = "0.48.0", features = ["Win32_Foundation", "Win32_Networking_WinSock", "Win32_Security", "Win32_Storage_FileSystem", "Win32_System_Com", "Win32_System_Diagnostics_Debug", "Win32_System_IO", "Win32_System_Registry", "Win32_System_Time", "Win32_System_WindowsProgramming", "Win32_UI_Controls", "Win32_UI_Shell_Common", "Win32_UI_WindowsAndMessaging"] } -zstd = { version = "0.13.1" } -zstd-safe = { version = "7.1.0", default-features = false, features = ["arrays", "legacy", "std", "zdict_builder"] } -zstd-sys = { version = "2.0.10", default-features = false, features = ["legacy", "std", "zdict_builder"] } +tracing = { version = "0.1.41", features = ["log"] } +winapi = { version = "0.3.9", default-features = false, features = ["audioclient", "audiosessiontypes", "combaseapi", "coml2api", "consoleapi", "debug", "devpkey", "errhandlingapi", "fibersapi", "fileapi", "handleapi", "ksmedia", "memoryapi", "minwinbase", "minwindef", "mmdeviceapi", "namedpipeapi", "ntsecapi", "ntstatus", "objbase", "processenv", "processthreadsapi", "profileapi", "std", "synchapi", "sysinfoapi", "winbase", "wincon", "winerror", "winnt", "winsock2", "winuser"] } +windows-sys-b21d60becc0929df = { package = "windows-sys", version = "0.52.0", features = ["Wdk_Foundation", "Wdk_Storage_FileSystem", "Wdk_System_IO", "Win32_Foundation", "Win32_Networking_WinSock", "Win32_Security", "Win32_Storage_FileSystem", "Win32_System_Console", "Win32_System_IO", "Win32_System_Pipes", "Win32_System_Threading", "Win32_System_WindowsProgramming"] } +windows-sys-d4189bed749088b6 = { package = "windows-sys", version = "0.61.2", features = ["Win32_Networking_WinSock", "Win32_Security_Authentication_Identity", "Win32_Security_Credentials", "Win32_Security_Cryptography", "Win32_Storage_FileSystem", "Win32_System_Console", "Win32_System_LibraryLoader", "Win32_System_Memory", "Win32_System_Pipes", "Win32_System_SystemInformation", "Win32_System_SystemServices", "Win32_System_Threading", "Win32_System_WindowsProgramming"] } ### END HAKARI SECTION diff --git a/frontend/README.md b/frontend/README.md index cd38d0d3cb..bbf219fbe4 100644 --- a/frontend/README.md +++ b/frontend/README.md @@ -1,6 +1,7 @@ # Frontend -This is an `nx` monorepo that can contain multiple apps and shared libraries. +This is the Nx workspace for ArtCraft web apps and shared libraries. The desktop +frontend is maintained in [storytold/artcraft](https://github.com/storytold/artcraft). All commands to run these projects are performed from _this_ directory (except the repo-root launcher scripts noted below). @@ -30,9 +31,8 @@ From the **repository root**, the launcher scripts (these preflight your environment, install dependencies, and free the dev port first): ```bash -./script/website/unix_frontend_dev.sh # artcraft-website (marketing site), port 4200 -./script/website/unix_frontend_webapp_dev.sh # artcraft-webapp (user dashboard), port 4201 -./script/artcraft/unix_frontend_dev.sh # artcraft (Tauri app frontend), port 5173 +./script/website/unix_frontend_website_dev.sh # artcraft-website (marketing site), port 4200 +./script/website/unix_frontend_webapp_dev.sh # artcraft-webapp (user dashboard), port 4201 ``` Or directly from this directory: @@ -40,8 +40,6 @@ Or directly from this directory: ```bash nx dev artcraft-website nx dev artcraft-webapp -nx dev artcraft # NB: the Tauri app also needs the Rust dev server running -nx dev editor2d ``` ## Building @@ -49,8 +47,6 @@ nx dev editor2d ```bash npx nx build artcraft-website npx nx build artcraft-webapp -npx nx build artcraft -npx nx build editor2d ``` Netlify deploys run `apps//script/netlify_build.sh` (see each app's diff --git a/frontend/apps/artcraft/.env-local-proxy b/frontend/apps/artcraft/.env-local-proxy deleted file mode 100644 index 6366906887..0000000000 --- a/frontend/apps/artcraft/.env-local-proxy +++ /dev/null @@ -1,9 +0,0 @@ -BASE_API="http://localhost:3000" -GOOGLE_API="http://localhost:3000/google" -FUNNEL_API="http://localhost:3000/funnel" -CDN_API="http://localhost:3000/cdn" -GRAVATAR_API="https://www.gravatar.com" -DEPLOY_PRIME_URL="http://localhost:5173" -REACT_APP_PUBLIC_POSTHOG_KEY="phc_jBFgac0mVALAFk3negnSfYCcHgvkT00yBLQDmCDYNBb" -REACT_APP_PUBLIC_POSTHOG_UI="https://us.i.posthog.com" -CONTEXT="DEVELOPMENT" \ No newline at end of file diff --git a/frontend/apps/artcraft/.env-no-proxy b/frontend/apps/artcraft/.env-no-proxy deleted file mode 100644 index 466e082fed..0000000000 --- a/frontend/apps/artcraft/.env-no-proxy +++ /dev/null @@ -1,9 +0,0 @@ -BASE_API="https://localhost:12345" -GOOGLE_API="https://storage.googleapis.com" -FUNNEL_API="https://style.storyteller.ai" -CDN_API="https://cdn.storyteller.ai" -GRAVATAR_API="https://www.gravatar.com" -DEPLOY_PRIME_URL="https://studio.storyteller.ai" -REACT_APP_PUBLIC_POSTHOG_KEY="phc_jBFgac0mVALAFk3negnSfYCcHgvkT00yBLQDmCDYNBb" -REACT_APP_PUBLIC_POSTHOG_UI="https://us.i.posthog.com" -CONTEXT="DEVELOPMENT" \ No newline at end of file diff --git a/frontend/apps/artcraft/.eslintrc.cjs b/frontend/apps/artcraft/.eslintrc.cjs deleted file mode 100644 index b96f4b9848..0000000000 --- a/frontend/apps/artcraft/.eslintrc.cjs +++ /dev/null @@ -1,95 +0,0 @@ -/** - * This is intended to be a basic starting point for linting in your app. - * It relies on recommended configs out of the box for simplicity, but you can - * and should modify this configuration to best suit your team's needs. - */ -const SEVERITY = { - OFF: 0, - WARN: 1, - ERROR: 2, -}; - -/** @type {import('eslint').Linter.Config} */ -module.exports = { - root: true, - parserOptions: { - ecmaVersion: "latest", - sourceType: "module", - ecmaFeatures: { - jsx: true, - }, - }, - env: { - browser: true, - commonjs: true, - es6: true, - }, - - // Base config - extends: ["eslint:recommended"], - - overrides: [ - // React - { - files: ["**/*.{js,jsx,ts,tsx}"], - plugins: ["react", "jsx-a11y"], - extends: [ - "plugin:react/recommended", - "plugin:react/jsx-runtime", - "plugin:react-hooks/recommended", - "plugin:jsx-a11y/recommended", - ], - settings: { - react: { - version: "detect", - }, - formComponents: ["Form"], - linkComponents: [ - { name: "Link", linkAttribute: "to" }, - { name: "NavLink", linkAttribute: "to" }, - ], - "import/resolver": { - typescript: {}, - }, - }, - rules: { - // we are incapable to provide support for blind people atm - "jsx-a11y/click-events-have-key-events": SEVERITY.OFF, - "jsx-a11y/no-static-element-interactions": SEVERITY.OFF, - "jsx-a11y/media-has-caption": SEVERITY.OFF, - "jsx-a11y/no-autofocus": SEVERITY.OFF, - }, - }, - - // Typescript - { - files: ["**/*.{ts,tsx}"], - plugins: ["@typescript-eslint", "import"], - parser: "@typescript-eslint/parser", - settings: { - "import/internal-regex": "^~/", - "import/resolver": { - node: { - extensions: [".ts", ".tsx"], - }, - typescript: { - alwaysTryTypes: true, - }, - }, - }, - extends: [ - "plugin:@typescript-eslint/recommended", - "plugin:import/recommended", - "plugin:import/typescript", - ], - }, - - // Node - { - files: [".eslintrc.js"], - env: { - node: true, - }, - }, - ], -}; diff --git a/frontend/apps/artcraft/.github/workflows/sync-studio-staging-branch.yml b/frontend/apps/artcraft/.github/workflows/sync-studio-staging-branch.yml deleted file mode 100644 index 4bc7a27fba..0000000000 --- a/frontend/apps/artcraft/.github/workflows/sync-studio-staging-branch.yml +++ /dev/null @@ -1,33 +0,0 @@ -# This action syncs "studio-staging" with "main" by force pushing every time it is run. -# Adapted from: -# https://github.community/t/user-github-pages-site-auto-deploy-from-another-branch-on-push/17912/2 -on: - push: - branches: - - main - -jobs: - sync_studio_staging_branch: - runs-on: [ubuntu-latest] - steps: - - name: checkout main branch - uses: actions/checkout@v2 - with: - persist-credentials: false - - name: sync main to studio-staging - run: | - git config --local user.email "action@github.com" - git config --local user.name "GitHub Action" - git checkout -b studio-staging - - name: push changes - uses: ad-m/github-push-action@0fafdd62b84042d49ec0cb92d9cac7f7ce4ec79e - with: - # Note: Github does not allow the default access token to push to - # protected branches. Using a PAT with permissions can bypass this, - # but it triggers recursive Github Actions calls on branch updates - # (which the default access token does not). Ultimately, it's better - # to leave the studio-staging branch unprotected. - github_token: ${{ secrets.GITHUB_TOKEN }} - branch: studio-staging - force: true - diff --git a/frontend/apps/artcraft/.gitignore b/frontend/apps/artcraft/.gitignore deleted file mode 100644 index 1d7b8398d9..0000000000 --- a/frontend/apps/artcraft/.gitignore +++ /dev/null @@ -1,30 +0,0 @@ -.env -.eslintcache -.vite -.notes -node_modules -/~/ -proxy/~/ -/.cache -/public/build -/build -/backup -.idea -$ - -# VS Code Setting -.vscode - -# Local Netlify folder -.netlify -# Mac -.DS_Store - -# Assets to ignore -public/resources/movie/Big_Buck_Bunny_180_10s.webm -public/resources/models/room/room_with_girl.glb - -*storybook.log - -# VIM -*~ diff --git a/frontend/apps/artcraft/.prettierrc b/frontend/apps/artcraft/.prettierrc deleted file mode 100644 index 7ff0eaa385..0000000000 --- a/frontend/apps/artcraft/.prettierrc +++ /dev/null @@ -1,11 +0,0 @@ -{ - "plugins": ["prettier-plugin-tailwindcss"], - "semi": true, - "singleQuote": false, - "trailingComma": "all", - "bracketSpacing": true, - "bracketSameLine": false, - "arrowParens": "always", - "useTabs": false, - "tabWidth": 2 -} diff --git a/frontend/apps/artcraft/README.md b/frontend/apps/artcraft/README.md deleted file mode 100644 index f341c53f7c..0000000000 --- a/frontend/apps/artcraft/README.md +++ /dev/null @@ -1,130 +0,0 @@ -# Storyteller GGF - -## Coding Rules and Styles - -``` -Short Style Guide TS React and Engine: - -No use of lets - -No basic for loop operators. -Use the collection operators and array operators. - -React Side / No modules over 200 lines. ( loose rule ) - -Don't do: -if (condition) return; - -Do: -if (condition) { - return; -} - -No use of any type. -If you can use chat gpt to create the interface. -``` - -## Branches - -- `main` - The main branch is the production source of truth. - - Changes to main will automatically build, but will not auto-deploy to production. You'll have to promote changes to production using the Netlify control panel. - - Merge your code to main frequently. If you have to have a long-lived set of changes, ask yourself whether it might be better to feature flag your code off and - land it to main rather than fight rebasing against the whole team. - -- `studio-staging` - The staging auto-deploy branch. - - You do not ever need to interact with this branch. Changes to `main` will automatically be pushed to `studio-staging` and auto-deployed to - https://studio-staging.studio.storyteller.ai . You can test changes that have landed in `main` here before promoting them to production. - -- `studio-testing` - The testing branch. - -Anyone can push their changes to this branch for testing in a production-like environment. Since it is built and hosted on https://studio-testing.studio.storyteller.ai , -you won't face CORS issues, same-site cookie issues, or have to use a local development proxy. (This doesn't obviate the need for a development -proxy for fast development iteration, but is a fantastic way to test your changes in a "production-like" environment.) - -Force push to this branch by using `git push -f origin studio-testing` - -## API Docs - -Server API docs live here: https://storyteller-docs.netlify.app/ - -## Local Testing & Development - -### Apple Silicon package installation issues - -Installation of some dependencies via npm may fail on M-series macs (like node-canvas) and may require additional setup including python3 and some brew dependencies: - -``` -brew install pkg-config cairo pango libpng jpeg giflib librsvg pixman python-setuptools -``` - -### Set up `.env` and the Proxy Server - -Copy & paste the env settings from `.env-local-proxy` to `.env`, (if the file `.env` do not exist, simply create one at the root of this project's folder beside the other env settings files). - -The settings from `.env-local-proxy` directs all requests to `localhost:3000`, this will relieve us from having to deal with CORS between various services. - -Then, start the proxy server in the folder `/proxy`. Before running the proxy for the first time, run: - -``` -npm i -``` - -To start the proxy run: - -``` -npm run dev -``` - -If the proxy fails, make sure your node version is 18.18. If you need to change the node version -run `npm rebuild` once before re-running `npm run dev` - -### Run the Code Locally - -To setup and run this project's code locally: - -``` -npm install -npm run dev -``` - -## PostHog - -PostHog is installed and working. To create a feature flag go to https://us.posthog.com/project/75284/feature_flags -Add the feature flag for all users. - -To check the feature flag in the app use code similar to this - -```ts -import { usePosthogFeatureFlag } from "~/hooks/usePosthogFeatureflag"; -import { FeatureFlags } from "~/enums"; - -const Component = () => { - const flag = usePosthogFeatureFlag(FeaturesFlags.FLAG_NAME); - // if flag is true, the feature shoud be executed & showed; - // if flag is false, the feature should be disabled & hid; - // for example - return( - <> - {flag && } - - ); -}; -``` - -## Other Documentation - -Here is the Swagger documentation for the backend endpoints - -- https://storyteller-docs.netlify.app/ - -This project uses Remix for routing and Tailwind for styling: - -- [Remix Docs](https://remix.run/docs) -- [Tailwind Docs](https://tailwindcss.com/docs) - -On Netlify, we use functions: - -- [Netlify Functions Overview](https://docs.netlify.com/functions/overview) diff --git a/frontend/apps/artcraft/_headers b/frontend/apps/artcraft/_headers deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/frontend/apps/artcraft/app/index.html b/frontend/apps/artcraft/app/index.html deleted file mode 100644 index 166218c75f..0000000000 --- a/frontend/apps/artcraft/app/index.html +++ /dev/null @@ -1,44 +0,0 @@ - - - - - ArtCraft - - - - - - - - - - - - - - - - - - - - - - -
- - - - diff --git a/frontend/apps/artcraft/app/public/android-chrome-192x192.png b/frontend/apps/artcraft/app/public/android-chrome-192x192.png deleted file mode 100644 index fb053ce95d..0000000000 Binary files a/frontend/apps/artcraft/app/public/android-chrome-192x192.png and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/android-chrome-512x512.png b/frontend/apps/artcraft/app/public/android-chrome-512x512.png deleted file mode 100644 index a471729992..0000000000 Binary files a/frontend/apps/artcraft/app/public/android-chrome-512x512.png and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/apple-touch-icon.png b/frontend/apps/artcraft/app/public/apple-touch-icon.png deleted file mode 100644 index e22536b60d..0000000000 Binary files a/frontend/apps/artcraft/app/public/apple-touch-icon.png and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/favicon-16x16.png b/frontend/apps/artcraft/app/public/favicon-16x16.png deleted file mode 100644 index bd6bec4d5c..0000000000 Binary files a/frontend/apps/artcraft/app/public/favicon-16x16.png and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/favicon-32x32.png b/frontend/apps/artcraft/app/public/favicon-32x32.png deleted file mode 100644 index 6deb0f9af9..0000000000 Binary files a/frontend/apps/artcraft/app/public/favicon-32x32.png and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/favicon.ico b/frontend/apps/artcraft/app/public/favicon.ico deleted file mode 100644 index df243d83f7..0000000000 Binary files a/frontend/apps/artcraft/app/public/favicon.ico and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/jsm/libs/ammo.js b/frontend/apps/artcraft/app/public/jsm/libs/ammo.js deleted file mode 100644 index 112cdb6a1e..0000000000 --- a/frontend/apps/artcraft/app/public/jsm/libs/ammo.js +++ /dev/null @@ -1,957 +0,0 @@ -// This is ammo.js, a port of Bullet Physics to JavaScript. zlib licensed. - -var Ammo = (() => { - var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined; - if (typeof __filename !== 'undefined') _scriptDir = _scriptDir || __filename; - return ( -function(Ammo = {}) { - -function aa(a,c){return Object.prototype.hasOwnProperty.call(a,c)}var ba="function"==typeof Object.defineProperties?Object.defineProperty:function(a,c,d){if(a==Array.prototype||a==Object.prototype)return a;a[c]=d.value;return a};function da(a){a=["object"==typeof globalThis&&globalThis,a,"object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof global&&global];for(var c=0;c=m}}); -function ia(a){var c=0;return function(){return c=0;--c){h[48+c]=52+c;h[65+c]=c;h[97+c]=26+c}h[43]=62;h[47]=63;function n(o,p,q){var i,j,c=0,k=p,l=q.length,m=p+(l*3>>2)-(q[l-2]=="=")-(q[l-1]=="=");for(;c>4;if(k>2;if(k>2];if(f){ha[L[L[f>>2]>>2]](f)|0;f=L[a+52>>2];if(f){L[8514]=L[8514]+1;ha[L[6799]](f)}}L[8513]=L[8513]+1;f=ha[L[6798]](132,16)|0;J[f+20|0]=1;L[f>>2]=15788;L[f+16>>2]=0;J[f+40|0]=1;L[f+8>>2]=0;L[f+12>>2]=0;L[f+36>>2]=0;J[f+60|0]=1;L[f+28>>2]=0;L[f+32>>2]=0;L[f+56>>2]=0;L[f+48>>2]=0;L[f+52>>2]=0;L[a+52>>2]=f;L[d+184>>2]=0;L[d+176>>2]=0;L[d+180>>2]=0;J[d+188|0]=1;f=0;if((ha[L[L[a>>2]+96>>2]](a)|0)>0){t=L[d+176>>2];p=t-1|0;f=L[d+184>>2];e=M[d+188|0];g=L[d+180>>2];while(1){a:{if((g|0)!=(t|0)){break a}o=t?t<<1:1;if((o|0)<=(t|0)){break a}if(o){L[8513]=L[8513]+1;f=ha[L[6798]](o<<4,16)|0}else{f=0}b:{if((t|0)<=0){break b}r=0;g=0;if(j+p>>>0>=3){h=t&-4;v=0;while(1){l=g<<4;q=l+f|0;n=c+l|0;i=L[n+4>>2];L[q>>2]=L[n>>2];L[q+4>>2]=i;i=L[n+12>>2];L[q+8>>2]=L[n+8>>2];L[q+12>>2]=i;i=l|16;q=i+f|0;n=c+i|0;i=L[n+12>>2];L[q+8>>2]=L[n+8>>2];L[q+12>>2]=i;i=L[n+4>>2];L[q>>2]=L[n>>2];L[q+4>>2]=i;i=l|32;q=i+f|0;n=c+i|0;i=L[n+12>>2];L[q+8>>2]=L[n+8>>2];L[q+12>>2]=i;i=L[n+4>>2];L[q>>2]=L[n>>2];L[q+4>>2]=i;i=l|48;q=i+f|0;n=c+i|0;i=L[n+12>>2];L[q+8>>2]=L[n+8>>2];L[q+12>>2]=i;i=L[n+4>>2];L[q>>2]=L[n>>2];L[q+4>>2]=i;g=g+4|0;v=v+4|0;if((h|0)!=(v|0)){continue}break}}h=t&3;if(!h){break b}while(1){i=g<<4;q=i+f|0;n=c+i|0;i=L[n+4>>2];L[q>>2]=L[n>>2];L[q+4>>2]=i;i=L[n+12>>2];L[q+8>>2]=L[n+8>>2];L[q+12>>2]=i;g=g+1|0;r=r+1|0;if((h|0)!=(r|0)){continue}break}}if(!(c?!c|!(e&255):1)){L[8514]=L[8514]+1;ha[L[6799]](c)}e=1;g=o}ha[L[L[a>>2]+108>>2]](a,j,(t<<4)+f|0);t=t+1|0;c=f;j=j+1|0;if((ha[L[L[a>>2]+96>>2]](a)|0)>(j|0)){continue}break}J[d+188|0]=e;L[d+180>>2]=g;L[d+176>>2]=t;L[d+184>>2]=f}J[d+148|0]=1;L[d+144>>2]=0;J[d+168|0]=1;L[d+136>>2]=0;L[d+140>>2]=0;L[d+164>>2]=0;L[d+156>>2]=0;L[d+160>>2]=0;L[d+124>>2]=0;J[d+128|0]=1;L[d+116>>2]=0;L[d+120>>2]=0;c:{d:{if(b){t=0;L[d+28>>2]=0;J[d+32|0]=1;L[d+20>>2]=0;L[d+24>>2]=0;c=0;x=L[d+176>>2];if((x|0)>0){while(1){b=c;c=c+1|0;if((x|0)>(c|0)){z=L[d+184>>2]+(b<<4)|0;b=c;while(1){f=b;b=b+1|0;if((x|0)>(b|0)){A=L[d+184>>2]+(f<<4)|0;f=b;while(1){K=P[z>>2];w=S(P[A>>2]-K);g=L[d+184>>2];j=g+(f<<4)|0;N=P[z+4>>2];y=S(P[j+4>>2]-N);u=S(P[j>>2]-K);m=S(P[A+4>>2]-N);C=S(S(w*y)-S(u*m));H=P[z+8>>2];s=S(P[j+8>>2]-H);B=S(m*s);m=S(P[A+8>>2]-H);y=S(B-S(y*m));u=S(S(m*u)-S(s*w));s=S(S(C*C)+S(S(y*y)+S(u*u)));p=s>S(9999999747378752e-20);e:{if(!p){break e}m=S(S(1)/S(_(s)));D=S(C*m);F=S(u*m);w=S(y*m);i=L[d+20>>2];if((i|0)>0){e=0;o=L[d+28>>2];if(S(S(D*P[o+8>>2])+S(S(w*P[o>>2])+S(F*P[o+4>>2])))>S(.9990000128746033)){break e}while(1){e=e+1|0;if((i|0)!=(e|0)){j=o+(e<<4)|0;if(!(S(S(D*P[j+8>>2])+S(S(w*P[j>>2])+S(F*P[j+4>>2])))>S(.9990000128746033))){continue}}break}if((e|0)<(i|0)){break e}}m=S(S(D*H)+S(S(w*K)+S(F*N)));o=L[d+176>>2];if((o|0)>0){e=0;if(S(S(S(S(D*P[g+8>>2])+S(S(w*P[g>>2])+S(F*P[g+4>>2])))-m)+S(-.009999999776482582))>S(0)){break e}while(1){e=e+1|0;if((o|0)!=(e|0)){j=g+(e<<4)|0;if(!(S(S(S(S(D*P[j+8>>2])+S(S(w*P[j>>2])+S(F*P[j+4>>2])))-m)+S(-.009999999776482582))>S(0))){continue}}break}if((e|0)<(o|0)){break e}}m=S(-m);f:{if(L[d+24>>2]!=(i|0)){break f}k=i?i<<1:1;if((k|0)<=(i|0)){break f}g:{if(!k){j=0;break g}L[8513]=L[8513]+1;j=ha[L[6798]](k<<4,16)|0;i=L[d+20>>2]}h:{if((i|0)<=0){break h}h=i&1;e=0;if((i|0)!=1){q=i&-2;i=0;while(1){n=e<<4;g=n+j|0;l=n+L[d+28>>2]|0;o=L[l+4>>2];L[g>>2]=L[l>>2];L[g+4>>2]=o;o=L[l+12>>2];L[g+8>>2]=L[l+8>>2];L[g+12>>2]=o;o=n|16;g=o+j|0;n=o+L[d+28>>2]|0;o=L[n+4>>2];L[g>>2]=L[n>>2];L[g+4>>2]=o;o=L[n+12>>2];L[g+8>>2]=L[n+8>>2];L[g+12>>2]=o;e=e+2|0;i=i+2|0;if((q|0)!=(i|0)){continue}break}}if(!h){break h}e=e<<4;o=e+j|0;i=e+L[d+28>>2]|0;e=L[i+4>>2];L[o>>2]=L[i>>2];L[o+4>>2]=e;e=L[i+12>>2];L[o+8>>2]=L[i+8>>2];L[o+12>>2]=e}e=L[d+28>>2];if(!(e?!e|!M[d+32|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](e)}L[d+28>>2]=j;J[d+32|0]=1;L[d+24>>2]=k;i=L[d+20>>2]}j=L[d+28>>2]+(i<<4)|0;P[j+12>>2]=m;P[j+8>>2]=D;P[j+4>>2]=F;P[j>>2]=w;L[d+20>>2]=L[d+20>>2]+1}i:{if(!p){break i}m=S(S(1)/S(_(s)));w=S(m*S(-C));u=S(m*S(-u));s=S(m*S(-y));i=L[d+20>>2];if((i|0)>0){e=0;o=L[d+28>>2];if(S(S(w*P[o+8>>2])+S(S(s*P[o>>2])+S(u*P[o+4>>2])))>S(.9990000128746033)){break i}while(1){e=e+1|0;if((i|0)!=(e|0)){j=o+(e<<4)|0;if(!(S(S(w*P[j+8>>2])+S(S(s*P[j>>2])+S(u*P[j+4>>2])))>S(.9990000128746033))){continue}}break}if((e|0)<(i|0)){break i}}m=S(S(w*P[z+8>>2])+S(S(s*P[z>>2])+S(u*P[z+4>>2])));o=L[d+176>>2];if((o|0)>0){e=0;g=L[d+184>>2];if(S(S(S(S(w*P[g+8>>2])+S(S(s*P[g>>2])+S(u*P[g+4>>2])))-m)+S(-.009999999776482582))>S(0)){break i}while(1){e=e+1|0;if((o|0)!=(e|0)){j=g+(e<<4)|0;if(!(S(S(S(S(w*P[j+8>>2])+S(S(s*P[j>>2])+S(u*P[j+4>>2])))-m)+S(-.009999999776482582))>S(0))){continue}}break}if((e|0)<(o|0)){break i}}m=S(-m);j:{if(L[d+24>>2]!=(i|0)){break j}l=i?i<<1:1;if((l|0)<=(i|0)){break j}k:{if(!l){j=0;break k}L[8513]=L[8513]+1;j=ha[L[6798]](l<<4,16)|0;i=L[d+20>>2]}l:{if((i|0)<=0){break l}h=i&1;e=0;if((i|0)!=1){q=i&-2;i=0;while(1){p=e<<4;g=p+j|0;n=p+L[d+28>>2]|0;o=L[n+4>>2];L[g>>2]=L[n>>2];L[g+4>>2]=o;o=L[n+12>>2];L[g+8>>2]=L[n+8>>2];L[g+12>>2]=o;o=p|16;g=o+j|0;p=o+L[d+28>>2]|0;o=L[p+4>>2];L[g>>2]=L[p>>2];L[g+4>>2]=o;o=L[p+12>>2];L[g+8>>2]=L[p+8>>2];L[g+12>>2]=o;e=e+2|0;i=i+2|0;if((q|0)!=(i|0)){continue}break}}if(!h){break l}e=e<<4;o=e+j|0;i=e+L[d+28>>2]|0;e=L[i+4>>2];L[o>>2]=L[i>>2];L[o+4>>2]=e;e=L[i+12>>2];L[o+8>>2]=L[i+8>>2];L[o+12>>2]=e}e=L[d+28>>2];if(!(e?!e|!M[d+32|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](e)}L[d+28>>2]=j;J[d+32|0]=1;L[d+24>>2]=l;i=L[d+20>>2]}j=L[d+28>>2]+(i<<4)|0;P[j+12>>2]=m;P[j+8>>2]=w;P[j+4>>2]=u;P[j>>2]=s;L[d+20>>2]=L[d+20>>2]+1}f=f+1|0;if((x|0)>(f|0)){continue}break}}if((b|0)!=(x|0)){continue}break}}if((c|0)!=(x|0)){continue}break}}L[d+104>>2]=0;J[d+108|0]=1;L[d+96>>2]=0;L[d+100>>2]=0;if(L[d+20>>2]<=0){break d}while(1){b=L[d+28>>2]+(t<<4)|0;L[d+80>>2]=L[b+8>>2];c=L[b+4>>2];L[d+72>>2]=L[b>>2];L[d+76>>2]=c;m=S(P[b+12>>2]-S(ha[L[L[a>>2]+48>>2]](a)));f=L[d+96>>2];m:{if((f|0)!=L[d+100>>2]){break m}h=f?f<<1:1;if((h|0)<=(f|0)){break m}n:{if(!h){c=0;break n}L[8513]=L[8513]+1;c=ha[L[6798]](h<<4,16)|0;f=L[d+96>>2]}o:{if((f|0)<=0){break o}g=0;if((f|0)!=1){o=f&-2;e=0;while(1){i=g<<4;j=i+c|0;q=i+L[d+104>>2]|0;b=L[q+4>>2];L[j>>2]=L[q>>2];L[j+4>>2]=b;b=L[q+12>>2];L[j+8>>2]=L[q+8>>2];L[j+12>>2]=b;b=i|16;j=b+c|0;i=b+L[d+104>>2]|0;b=L[i+4>>2];L[j>>2]=L[i>>2];L[j+4>>2]=b;b=L[i+12>>2];L[j+8>>2]=L[i+8>>2];L[j+12>>2]=b;g=g+2|0;e=e+2|0;if((o|0)!=(e|0)){continue}break}}if(!(f&1)){break o}b=g<<4;f=b+c|0;j=b+L[d+104>>2]|0;b=L[j+4>>2];L[f>>2]=L[j>>2];L[f+4>>2]=b;b=L[j+12>>2];L[f+8>>2]=L[j+8>>2];L[f+12>>2]=b}b=L[d+104>>2];if(!(b?!b|!M[d+108|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[d+104>>2]=c;J[d+108|0]=1;L[d+100>>2]=h;f=L[d+96>>2]}b=L[d+76>>2];c=L[d+104>>2]+(f<<4)|0;L[c>>2]=L[d+72>>2];L[c+4>>2]=b;b=L[d+80>>2];P[c+12>>2]=m;L[c+8>>2]=b;L[d+96>>2]=L[d+96>>2]+1;t=t+1|0;if((t|0)>2]){continue}break}break d}ag(d+112|0,f,L[d+176>>2]);break c}L[d+84>>2]=0;J[d+88|0]=1;L[d+76>>2]=0;L[d+80>>2]=0;c=0;k=L[d+96>>2];if((k|0)>0){while(1){b=c;c=c+1|0;if((k|0)>(c|0)){l=L[d+104>>2]+(b<<4)|0;b=c;while(1){f=b;b=b+1|0;if((k|0)>(b|0)){n=L[d+104>>2]+(f<<4)|0;f=b;while(1){$=P[n>>2];o=L[d+104>>2];j=o+(f<<4)|0;w=P[j+4>>2];y=P[j>>2];u=P[n+4>>2];B=S(S($*w)-S(y*u));s=P[j+8>>2];m=P[n+8>>2];D=S(S(u*s)-S(w*m));F=S(S(m*y)-S(s*$));p:{if(!(S(S(B*B)+S(S(D*D)+S(F*F)))>S(9999999747378752e-20))){break p}U=P[l+4>>2];X=P[l>>2];C=S(S(y*U)-S(X*w));Y=P[l+8>>2];K=S(S(w*Y)-S(U*s));N=S(S(s*X)-S(Y*y));if(!(S(S(C*C)+S(S(K*K)+S(N*N)))>S(9999999747378752e-20))){break p}s=S(S(X*u)-S($*U));H=S(S(U*m)-S(u*Y));w=S(S(Y*$)-S(m*X));if(!(S(S(s*s)+S(S(H*H)+S(w*w)))>S(9999999747378752e-20))){break p}m=S(S(Y*B)+S(S(X*D)+S(U*F)));if(!(S(T(m))>S(9.999999974752427e-7))){break p}y=S(S(-1)/m);u=P[j+12>>2];U=S(s*u);s=P[l+12>>2];m=P[n+12>>2];C=S(y*S(U+S(S(B*s)+S(C*m))));w=S(y*S(S(w*u)+S(S(F*s)+S(N*m))));m=S(y*S(S(H*u)+S(S(D*s)+S(K*m))));j=L[d+96>>2];if((j|0)>0){i=0;if(S(S(P[o+12>>2]+S(S(P[o+8>>2]*C)+S(S(P[o>>2]*m)+S(w*P[o+4>>2]))))+S(-.009999999776482582))>S(0)){break p}while(1){i=i+1|0;if((j|0)!=(i|0)){e=o+(i<<4)|0;if(!(S(S(P[e+12>>2]+S(S(P[e+8>>2]*C)+S(S(P[e>>2]*m)+S(w*P[e+4>>2]))))+S(-.009999999776482582))>S(0))){continue}}break}if((i|0)<(j|0)){break p}}e=L[d+76>>2];q:{if((e|0)!=L[d+80>>2]){break q}p=e?e<<1:1;if((p|0)<=(e|0)){break q}r:{if(!p){i=0;break r}L[8513]=L[8513]+1;i=ha[L[6798]](p<<4,16)|0;e=L[d+76>>2]}s:{if((e|0)<=0){break s}A=0;if((e|0)!=1){g=e&-2;E=0;while(1){q=A<<4;o=q+i|0;h=q+L[d+84>>2]|0;j=L[h+4>>2];L[o>>2]=L[h>>2];L[o+4>>2]=j;j=L[h+12>>2];L[o+8>>2]=L[h+8>>2];L[o+12>>2]=j;j=q|16;o=j+i|0;q=j+L[d+84>>2]|0;j=L[q+4>>2];L[o>>2]=L[q>>2];L[o+4>>2]=j;j=L[q+12>>2];L[o+8>>2]=L[q+8>>2];L[o+12>>2]=j;A=A+2|0;E=E+2|0;if((g|0)!=(E|0)){continue}break}}if(!(e&1)){break s}j=A<<4;e=j+i|0;o=j+L[d+84>>2]|0;j=L[o+4>>2];L[e>>2]=L[o>>2];L[e+4>>2]=j;j=L[o+12>>2];L[e+8>>2]=L[o+8>>2];L[e+12>>2]=j}j=L[d+84>>2];if(!(j?!j|!M[d+88|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](j)}L[d+84>>2]=i;J[d+88|0]=1;L[d+80>>2]=p;e=L[d+76>>2]}j=L[d+84>>2]+(e<<4)|0;L[j+12>>2]=0;P[j+8>>2]=C;P[j+4>>2]=w;P[j>>2]=m;L[d+76>>2]=L[d+76>>2]+1}f=f+1|0;if((k|0)>(f|0)){continue}break}}if((b|0)!=(k|0)){continue}break}}if((c|0)!=(k|0)){continue}break}}ag(d+112|0,L[d+84>>2],L[d+76>>2]);b=L[d+84>>2];if(!(b?!b|!M[d+88|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}b=L[d+104>>2];if(!(b?!b|!M[d+108|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}b=L[d+28>>2];if(!b|!M[d+32|0]){break c}if(b){L[8514]=L[8514]+1;ha[L[6799]](b)}}t:{u:{o=L[d+156>>2];if((o|0)>=0){if(o){break u}L[d+32>>2]=0;L[d+36>>2]=0;L[d+48>>2]=0;L[d+40>>2]=0;L[d+44>>2]=0;L[d+24>>2]=0;L[d+28>>2]=0;J[d+32|0]=1;L[d+16>>2]=0;L[d+20>>2]=0;L[d+20>>2]=0;E=0;break t}L[d+32>>2]=0;L[d+36>>2]=0;L[d+48>>2]=0;L[d+40>>2]=0;L[d+44>>2]=0;L[d+24>>2]=0;L[d+28>>2]=0;J[d+32|0]=1;L[d+16>>2]=0;L[d+20>>2]=0;L[d+20>>2]=0;f=o;while(1){c=R(f,36);b=L[c+12>>2];if(!(b?!b|!M[c+16|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[c+12>>2]=0;J[c+16|0]=1;L[c+4>>2]=0;L[c+8>>2]=0;E=0;f=f+1|0;if(f){continue}break}break t}L[8513]=L[8513]+1;Z=ha[L[6798]](o<<4,16)|0;L[d+32>>2]=0;L[d+36>>2]=0;g=0;L[d+48>>2]=0;L[d+40>>2]=0;L[d+44>>2]=0;L[d+24>>2]=0;L[d+28>>2]=0;J[d+32|0]=1;L[d+16>>2]=0;L[d+20>>2]=0;L[d+20>>2]=0;L[8513]=L[8513]+1;E=ha[L[6798]](R(o,36),16)|0;while(1){c=R(g,36)+E|0;Jc(c,d+16|0);b=L[d+48>>2];L[c+28>>2]=L[d+44>>2];L[c+32>>2]=b;b=L[d+40>>2];L[c+20>>2]=L[d+36>>2];L[c+24>>2]=b;g=g+1|0;if((o|0)!=(g|0)){continue}break}}b=L[d+28>>2];if(!(b?!b|!M[d+32|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}h=L[a+52>>2];c=L[h+8>>2];q=L[d+116>>2];if(!((c|0)>=(q|0)|(q|0)<=L[h+12>>2])){v:{if(!q){r=0;break v}L[8513]=L[8513]+1;r=ha[L[6798]](q<<4,16)|0;c=L[h+8>>2]}w:{if((c|0)<=0){break w}f=0;if((c|0)!=1){e=c&-2;v=0;while(1){i=f<<4;j=i+r|0;g=i+L[h+16>>2]|0;b=L[g+4>>2];L[j>>2]=L[g>>2];L[j+4>>2]=b;b=L[g+12>>2];L[j+8>>2]=L[g+8>>2];L[j+12>>2]=b;b=i|16;j=b+r|0;i=b+L[h+16>>2]|0;b=L[i+4>>2];L[j>>2]=L[i>>2];L[j+4>>2]=b;b=L[i+12>>2];L[j+8>>2]=L[i+8>>2];L[j+12>>2]=b;f=f+2|0;v=v+2|0;if((e|0)!=(v|0)){continue}break}}if(!(c&1)){break w}b=f<<4;c=b+r|0;f=b+L[h+16>>2]|0;b=L[f+4>>2];L[c>>2]=L[f>>2];L[c+4>>2]=b;b=L[f+12>>2];L[c+8>>2]=L[f+8>>2];L[c+12>>2]=b}b=L[h+16>>2];if(!(b?!b|!M[h+20|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[h+16>>2]=r;J[h+20|0]=1;L[h+12>>2]=q}L[h+8>>2]=q;x:{if((q|0)<=0){break x}g=0;if((q|0)!=1){j=q&-2;c=0;while(1){e=g<<4;f=e+L[L[a+52>>2]+16>>2]|0;i=e+L[d+124>>2]|0;b=L[i+4>>2];L[f>>2]=L[i>>2];L[f+4>>2]=b;b=L[i+12>>2];L[f+8>>2]=L[i+8>>2];L[f+12>>2]=b;b=e|16;f=b+L[L[a+52>>2]+16>>2]|0;e=b+L[d+124>>2]|0;b=L[e+4>>2];L[f>>2]=L[e>>2];L[f+4>>2]=b;b=L[e+12>>2];L[f+8>>2]=L[e+8>>2];L[f+12>>2]=b;g=g+2|0;c=c+2|0;if((j|0)!=(c|0)){continue}break}}if(!(q&1)){break x}b=g<<4;c=b+L[L[a+52>>2]+16>>2]|0;f=b+L[d+124>>2]|0;b=L[f+4>>2];L[c>>2]=L[f>>2];L[c+4>>2]=b;b=L[f+12>>2];L[c+8>>2]=L[f+8>>2];L[c+12>>2]=b}y:{z:{A:{B:{if((o|0)<=0){break B}b=0;while(1){k=R(b,36)+E|0;e=L[k+4>>2];j=0;h=L[d+144>>2]+R(L[L[d+164>>2]+(b<<2)>>2],12)|0;t=h;C:{while(1){q=L[(R(L[t+4>>2],12)+t|0)+8>>2];D:{if(L[k+8>>2]!=(e|0)){break D}p=e?e<<1:1;if((p|0)<=(e|0)){break D}E:{if(!p){f=0;break E}L[8513]=L[8513]+1;f=ha[L[6798]](p<<2,16)|0;e=L[k+4>>2]}l=L[k+12>>2];F:{G:{if((e|0)>0){r=0;g=0;if(e>>>0>=4){i=e&-4;v=0;while(1){n=g<<2;L[n+f>>2]=L[l+n>>2];c=n|4;L[c+f>>2]=L[c+l>>2];c=n|8;L[c+f>>2]=L[c+l>>2];c=n|12;L[c+f>>2]=L[c+l>>2];g=g+4|0;v=v+4|0;if((i|0)!=(v|0)){continue}break}}e=e&3;if(!e){break G}while(1){c=g<<2;L[c+f>>2]=L[c+l>>2];g=g+1|0;r=r+1|0;if((e|0)!=(r|0)){continue}break}break G}if(!l){break F}}if(l?M[k+16|0]:0){L[8514]=L[8514]+1;ha[L[6799]](l)}e=L[k+4>>2]}L[k+12>>2]=f;J[k+16|0]=1;L[k+8>>2]=p}L[L[k+12>>2]+(e<<2)>>2]=q;e=L[k+4>>2]+1|0;L[k+4>>2]=e;H:{if((j|0)<=1){c=L[d+124>>2];f=c+(q<<4)|0;H=P[f+8>>2];c=c+(L[t+8>>2]<<4)|0;w=P[c+8>>2];y=P[f>>2];u=P[c>>2];s=P[f+4>>2];m=P[c+4>>2];c=(d+16|0)+(j<<4)|0;L[c+12>>2]=0;w=S(w-H);u=S(u-y);m=S(m-s);s=S(S(1)/S(_(S(S(w*w)+S(S(u*u)+S(m*m))))));P[c+8>>2]=w*s;P[c+4>>2]=m*s;P[c>>2]=u*s;j=j+1|0;c=R(L[t+4>>2],12)+t|0;t=R(L[c>>2],12)+c|0;if((h|0)!=(t|0)){continue}if((j|0)==2){break H}c=(b<<4)+Z|0;L[c>>2]=0;L[c+4>>2]=0;L[c+8>>2]=0;L[c+12>>2]=0;break C}j=2;c=R(L[t+4>>2],12)+t|0;t=R(L[c>>2],12)+c|0;if((h|0)!=(t|0)){continue}}break}N=P[d+20>>2];s=P[d+36>>2];H=P[d+32>>2];w=P[d+24>>2];y=P[d+16>>2];m=P[d+40>>2];c=(b<<4)+Z|0;L[c+12>>2]=0;u=S(S(y*s)-S(H*N));s=S(S(N*m)-S(s*w));m=S(S(w*H)-S(m*y));y=S(S(1)/S(_(S(S(u*u)+S(S(s*s)+S(m*m))))));P[c+8>>2]=u*y;P[c+4>>2]=m*y;m=S(s*y);P[c>>2]=m;P[k+20>>2]=m;P[k+24>>2]=P[c+4>>2];m=P[c+8>>2];L[k+32>>2]=1900671690;P[k+28>>2]=m}f=L[k+4>>2];I:{if((f|0)<=0){B=S(1.0000000150474662e30);break I}j=f&1;c=(b<<4)+Z|0;w=P[c+8>>2];y=P[c+4>>2];u=P[c>>2];q=L[L[a+52>>2]+16>>2];i=L[k+12>>2];J:{if((f|0)==1){B=S(1.0000000150474662e30);g=0;break J}f=f&-2;B=S(1.0000000150474662e30);g=0;r=0;while(1){c=g<<2;e=q+(L[i+(c|4)>>2]<<4)|0;s=S(S(P[e+8>>2]*w)+S(S(P[e>>2]*u)+S(P[e+4>>2]*y)));c=q+(L[c+i>>2]<<4)|0;m=S(S(P[c+8>>2]*w)+S(S(P[c>>2]*u)+S(P[c+4>>2]*y)));m=ms?s:m;g=g+2|0;r=r+2|0;if((f|0)!=(r|0)){continue}break}}if(!j){break I}c=q+(L[i+(g<<2)>>2]<<4)|0;m=S(S(P[c+8>>2]*w)+S(S(P[c>>2]*u)+S(P[c+4>>2]*y)));B=m>2]=-B;b=b+1|0;if((o|0)!=(b|0)){continue}break}e=0;if((o|0)<=0){break B}q=0;c=0;while(1){K:{if((c|0)!=(e|0)){break K}c=e?e<<1:1;if(e>>>0>=c>>>0){c=e;break K}L[8513]=L[8513]+1;b=ha[L[6798]](c<<2,16)|0;L:{M:{if(e){r=0;g=0;if(e>>>0>=4){j=e&2147483644;v=0;while(1){i=g<<2;L[i+b>>2]=L[i+q>>2];f=i|4;L[f+b>>2]=L[f+q>>2];f=i|8;L[f+b>>2]=L[f+q>>2];f=i|12;L[f+b>>2]=L[f+q>>2];g=g+4|0;v=v+4|0;if((j|0)!=(v|0)){continue}break}}j=e&3;if(!j){break M}while(1){f=g<<2;L[f+b>>2]=L[f+q>>2];g=g+1|0;r=r+1|0;if((j|0)!=(r|0)){continue}break}break M}if(q){break M}c=1;break L}if(q){L[8514]=L[8514]+1;ha[L[6799]](q)}}q=b}L[(e<<2)+q>>2]=e;e=e+1|0;if((o|0)!=(e|0)){continue}break}j=o;while(1){b=j-1|0;c=L[(b<<2)+q>>2];L[8513]=L[8513]+1;i=ha[L[6798]](4,16)|0;L[i>>2]=c;N:{O:{if((j|0)<2){j=b;O=1;break O}c=R(c,36)+E|0;u=P[c+20>>2];s=P[c+28>>2];m=P[c+24>>2];g=j-2|0;e=1;j=b;O=1;while(1){b=g;n=L[(b<<2)+q>>2];c=R(n,36)+E|0;if(S(S(s*P[c+28>>2])+S(S(u*P[c+20>>2])+S(m*P[c+24>>2])))>S(.9990000128746033)){P:{Q:{if((e|0)!=(O|0)){break Q}c=e?e<<1:1;if((e|0)>=(c|0)){break Q}if(c){L[8513]=L[8513]+1;f=ha[L[6798]](c<<2,16)|0}else{f=0}R:{if((e|0)>0){r=0;g=0;if(e>>>0>=4){p=e&-4;t=0;while(1){l=g<<2;L[l+f>>2]=L[i+l>>2];h=l|4;L[h+f>>2]=L[h+i>>2];h=l|8;L[h+f>>2]=L[h+i>>2];h=l|12;L[h+f>>2]=L[h+i>>2];g=g+4|0;t=t+4|0;if((p|0)!=(t|0)){continue}break}}h=e&3;if(!h){break R}while(1){e=g<<2;L[e+f>>2]=L[e+i>>2];g=g+1|0;r=r+1|0;if((h|0)!=(r|0)){continue}break}break R}if(!i){break P}}if(i){L[8514]=L[8514]+1;ha[L[6799]](i)}break P}c=e;f=i}L[(O<<2)+f>>2]=n;O=O+1|0;g=0;S:{if((j|0)<=0){break S}while(1){e=(g<<2)+q|0;if((n|0)!=L[e>>2]){g=g+1|0;if((j|0)!=(g|0)){continue}break S}break}if((g|0)>=(j|0)){break S}g=e;j=j-1|0;e=(j<<2)+q|0;L[g>>2]=L[e>>2];L[e>>2]=n}i=f;e=c}g=b-1|0;if((b|0)>0){continue}break}T:{if((O|0)>1){f=0;L[d+104>>2]=0;J[d+108|0]=1;L[d+96>>2]=0;L[d+100>>2]=0;L[d+8>>2]=0;L[d+12>>2]=0;L[d>>2]=0;L[d+4>>2]=0;b=0;while(1){A=R(L[(b<<2)+i>>2],36)+E|0;s=P[A+28>>2];m=P[A+24>>2];P[d>>2]=P[A+20>>2]+P[d>>2];P[d+4>>2]=m+P[d+4>>2];P[d+8>>2]=s+P[d+8>>2];r=L[A+4>>2];if((r|0)>0){c=0;while(1){l=L[L[A+12>>2]+(c<<2)>>2];h=L[L[a+52>>2]+16>>2];U:{if((f|0)>0){g=0;e=L[d+104>>2];while(1){if((l|0)==L[(e+R(g,24)|0)+20>>2]){break U}g=g+1|0;if((g|0)!=(f|0)){continue}break}}g=h+(l<<4)|0;e=L[g+12>>2];L[d+24>>2]=L[g+8>>2];L[d+28>>2]=e;e=L[g+4>>2];L[d+16>>2]=L[g>>2];L[d+20>>2]=e;V:{if(L[d+100>>2]!=(f|0)){break V}n=f?f<<1:1;if((n|0)<=(f|0)){break V}W:{if(!n){r=0;break W}L[8513]=L[8513]+1;r=ha[L[6798]](R(n,24),16)|0;f=L[d+96>>2]}x=L[d+104>>2];X:{if((f|0)<=0){break X}v=0;g=0;if(f>>>0>=4){p=f&-4;t=0;while(1){e=R(g,24);h=e+r|0;k=e+x|0;e=L[k+4>>2];L[h>>2]=L[k>>2];L[h+4>>2]=e;e=L[k+20>>2];L[h+16>>2]=L[k+16>>2];L[h+20>>2]=e;e=L[k+12>>2];L[h+8>>2]=L[k+8>>2];L[h+12>>2]=e;e=R(g|1,24);h=e+r|0;k=e+x|0;e=L[k+20>>2];L[h+16>>2]=L[k+16>>2];L[h+20>>2]=e;e=L[k+12>>2];L[h+8>>2]=L[k+8>>2];L[h+12>>2]=e;e=L[k+4>>2];L[h>>2]=L[k>>2];L[h+4>>2]=e;e=R(g|2,24);h=e+r|0;k=e+x|0;e=L[k+20>>2];L[h+16>>2]=L[k+16>>2];L[h+20>>2]=e;e=L[k+12>>2];L[h+8>>2]=L[k+8>>2];L[h+12>>2]=e;e=L[k+4>>2];L[h>>2]=L[k>>2];L[h+4>>2]=e;e=R(g|3,24);h=e+r|0;k=e+x|0;e=L[k+20>>2];L[h+16>>2]=L[k+16>>2];L[h+20>>2]=e;e=L[k+12>>2];L[h+8>>2]=L[k+8>>2];L[h+12>>2]=e;e=L[k+4>>2];L[h>>2]=L[k>>2];L[h+4>>2]=e;g=g+4|0;t=t+4|0;if((p|0)!=(t|0)){continue}break}}p=f&3;if(!p){break X}while(1){e=R(g,24);h=e+r|0;k=e+x|0;e=L[k+4>>2];L[h>>2]=L[k>>2];L[h+4>>2]=e;e=L[k+20>>2];L[h+16>>2]=L[k+16>>2];L[h+20>>2]=e;e=L[k+12>>2];L[h+8>>2]=L[k+8>>2];L[h+12>>2]=e;g=g+1|0;v=v+1|0;if((p|0)!=(v|0)){continue}break}}if(!(!x|!M[d+108|0])){if(x){L[8514]=L[8514]+1;ha[L[6799]](x)}f=L[d+96>>2]}L[d+104>>2]=r;J[d+108|0]=1;L[d+100>>2]=n}h=L[d+104>>2]+R(f,24)|0;e=h;f=L[d+20>>2];L[e>>2]=L[d+16>>2];L[e+4>>2]=f;g=L[d+28>>2];e=L[d+24>>2];f=L[d+32>>2];L[h+20>>2]=l;L[h+16>>2]=f;L[h+8>>2]=e;L[h+12>>2]=g;f=L[d+96>>2]+1|0;L[d+96>>2]=f;r=L[A+4>>2]}c=c+1|0;if((r|0)>(c|0)){continue}break}}b=b+1|0;if((O|0)!=(b|0)){continue}break}break T}b=(O|0)!=1;O=1;if(b){break N}break O}L[d+28>>2]=0;J[d+32|0]=1;L[d+20>>2]=0;L[d+24>>2]=0;b=R(L[i>>2],36)+E|0;P[d+36>>2]=P[b+20>>2];P[d+40>>2]=P[b+24>>2];P[d+44>>2]=P[b+28>>2];P[d+48>>2]=P[b+32>>2];L[d+84>>2]=0;J[d+88|0]=1;L[d+76>>2]=0;L[d+80>>2]=0;u=P[d+8>>2];s=P[d>>2];m=P[d+4>>2];y=S(S(1)/S(_(S(S(u*u)+S(S(s*s)+S(m*m))))));P[d+8>>2]=u*y;P[d+4>>2]=m*y;P[d>>2]=s*y;x=d+92|0;r=0;g=0;z=fa-32|0;fa=z;u=P[d+8>>2];Y:{if(S(T(u))>S(.7071067690849304)){s=P[d+4>>2];m=S(S(1)/S(_(S(S(s*s)+S(u*u)))));B=S(s*m);D=S(m*S(-u));m=S(0);break Y}u=P[d>>2];s=P[d+4>>2];m=S(S(1)/S(_(S(S(u*u)+S(s*s)))));D=S(u*m);B=S(0);m=S(m*S(-s))}Z:{_:{$:{aa:{f=L[x+4>>2];if((f|0)>=2){while(1){h=L[x+12>>2];e=R(g,24);b=h+e|0;if(S(S(P[b+8>>2]*B)+S(S(P[b>>2]*m)+S(D*P[b+4>>2])))>2]*B)+S(S(P[h>>2]*m)+S(D*P[h+4>>2])))){c=L[h+20>>2];L[z+24>>2]=L[h+16>>2];L[z+28>>2]=c;c=L[h+12>>2];L[z+16>>2]=L[h+8>>2];L[z+20>>2]=c;c=L[h+4>>2];L[z+8>>2]=L[h>>2];L[z+12>>2]=c;c=L[b+4>>2];L[h>>2]=L[b>>2];L[h+4>>2]=c;c=L[b+12>>2];L[h+8>>2]=L[b+8>>2];L[h+12>>2]=c;c=L[b+20>>2];L[h+16>>2]=L[b+16>>2];L[h+20>>2]=c;b=L[z+12>>2];c=e+L[x+12>>2]|0;L[c>>2]=L[z+8>>2];L[c+4>>2]=b;b=L[z+28>>2];L[c+16>>2]=L[z+24>>2];L[c+20>>2]=b;b=L[z+20>>2];L[c+8>>2]=L[z+16>>2];L[c+12>>2]=b;f=L[x+4>>2]}g=g+1|0;if((g|0)<(f|0)){continue}break}e=L[x+12>>2];L[e+16>>2]=-246811958;if((f|0)>=2){N=P[e+8>>2];H=P[e+4>>2];w=P[e>>2];y=S(-D);u=S(-m);s=S(-B);c=1;while(1){b=e+R(c,24)|0;F=S(P[b+4>>2]-H);C=S(P[b>>2]-w);K=S(P[b+8>>2]-N);P[b+16>>2]=S(S(S(S(m*F)+S(C*y))*P[d+8>>2])+S(S(S(S(D*K)+S(F*s))*P[d>>2])+S(P[d+4>>2]*S(S(B*C)+S(K*u)))))/S(_(S(S(K*K)+S(S(C*C)+S(F*F)))));c=c+1|0;if((f|0)!=(c|0)){continue}break}}b=L[e+12>>2];L[z+16>>2]=L[e+8>>2];L[z+20>>2]=b;b=L[e+4>>2];L[z+8>>2]=L[e>>2];L[z+12>>2]=b;cm(x,z+8|0,1,f-1|0);e=L[x+12>>2];c=L[d+76>>2];if((c|0)!=L[d+80>>2]){break _}l=c?c<<1:1;if((l|0)<=(c|0)){break _}if(l){break aa}f=0;break $}if((f|0)!=1){break Z}c=L[d+76>>2];while(1){e=L[x+12>>2];ba:{if(L[d+80>>2]!=(c|0)){break ba}n=c?c<<1:1;if((n|0)<=(c|0)){break ba}ca:{if(!n){f=0;break ca}L[8513]=L[8513]+1;f=ha[L[6798]](R(n,24),16)|0;c=L[d+76>>2]}da:{if((c|0)<=0){break da}b=0;if((c|0)!=1){p=c&-2;A=0;while(1){g=R(b,24);h=g+f|0;l=g+L[d+84>>2]|0;g=L[l+4>>2];L[h>>2]=L[l>>2];L[h+4>>2]=g;g=L[l+20>>2];L[h+16>>2]=L[l+16>>2];L[h+20>>2]=g;g=L[l+12>>2];L[h+8>>2]=L[l+8>>2];L[h+12>>2]=g;g=R(b|1,24);h=g+f|0;l=g+L[d+84>>2]|0;g=L[l+4>>2];L[h>>2]=L[l>>2];L[h+4>>2]=g;g=L[l+12>>2];L[h+8>>2]=L[l+8>>2];L[h+12>>2]=g;g=L[l+20>>2];L[h+16>>2]=L[l+16>>2];L[h+20>>2]=g;b=b+2|0;A=A+2|0;if((p|0)!=(A|0)){continue}break}}if(!(c&1)){break da}b=R(b,24);c=b+f|0;g=b+L[d+84>>2]|0;b=L[g+4>>2];L[c>>2]=L[g>>2];L[c+4>>2]=b;b=L[g+20>>2];L[c+16>>2]=L[g+16>>2];L[c+20>>2]=b;b=L[g+12>>2];L[c+8>>2]=L[g+8>>2];L[c+12>>2]=b}b=L[d+84>>2];if(!(b?!b|!M[d+88|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[d+84>>2]=f;J[d+88|0]=1;L[d+80>>2]=n;c=L[d+76>>2]}b=L[e+4>>2];c=L[d+84>>2]+R(c,24)|0;L[c>>2]=L[e>>2];L[c+4>>2]=b;b=L[e+20>>2];L[c+16>>2]=L[e+16>>2];L[c+20>>2]=b;b=L[e+12>>2];L[c+8>>2]=L[e+8>>2];L[c+12>>2]=b;c=L[d+76>>2]+1|0;L[d+76>>2]=c;r=r+1|0;if((r|0)>2]){continue}break}break Z}L[8513]=L[8513]+1;f=ha[L[6798]](R(l,24),16)|0;c=L[d+76>>2]}ea:{if((c|0)<=0){break ea}b=0;if((c|0)!=1){n=c&-2;g=0;while(1){h=R(b,24);p=h+f|0;k=h+L[d+84>>2]|0;h=L[k+4>>2];L[p>>2]=L[k>>2];L[p+4>>2]=h;h=L[k+20>>2];L[p+16>>2]=L[k+16>>2];L[p+20>>2]=h;h=L[k+12>>2];L[p+8>>2]=L[k+8>>2];L[p+12>>2]=h;h=R(b|1,24);p=h+f|0;k=h+L[d+84>>2]|0;h=L[k+4>>2];L[p>>2]=L[k>>2];L[p+4>>2]=h;h=L[k+12>>2];L[p+8>>2]=L[k+8>>2];L[p+12>>2]=h;h=L[k+20>>2];L[p+16>>2]=L[k+16>>2];L[p+20>>2]=h;b=b+2|0;g=g+2|0;if((n|0)!=(g|0)){continue}break}}if(!(c&1)){break ea}b=R(b,24);c=b+f|0;g=b+L[d+84>>2]|0;b=L[g+4>>2];L[c>>2]=L[g>>2];L[c+4>>2]=b;b=L[g+20>>2];L[c+16>>2]=L[g+16>>2];L[c+20>>2]=b;b=L[g+12>>2];L[c+8>>2]=L[g+8>>2];L[c+12>>2]=b}b=L[d+84>>2];if(!(b?!b|!M[d+88|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[d+84>>2]=f;J[d+88|0]=1;L[d+80>>2]=l;c=L[d+76>>2]}b=L[e+4>>2];c=L[d+84>>2]+R(c,24)|0;L[c>>2]=L[e>>2];L[c+4>>2]=b;b=L[e+20>>2];L[c+16>>2]=L[e+16>>2];L[c+20>>2]=b;b=L[e+12>>2];L[c+8>>2]=L[e+8>>2];L[c+12>>2]=b;c=L[d+76>>2]+1|0;L[d+76>>2]=c;e=L[x+12>>2];fa:{if(L[d+80>>2]!=(c|0)){break fa}l=c?c<<1:1;if((l|0)<=(c|0)){break fa}ga:{if(!l){f=0;break ga}L[8513]=L[8513]+1;f=ha[L[6798]](R(l,24),16)|0;c=L[d+76>>2]}ha:{if((c|0)<=0){break ha}b=0;if((c|0)!=1){n=c&-2;g=0;while(1){h=R(b,24);p=h+f|0;k=h+L[d+84>>2]|0;h=L[k+4>>2];L[p>>2]=L[k>>2];L[p+4>>2]=h;h=L[k+20>>2];L[p+16>>2]=L[k+16>>2];L[p+20>>2]=h;h=L[k+12>>2];L[p+8>>2]=L[k+8>>2];L[p+12>>2]=h;h=R(b|1,24);p=h+f|0;k=h+L[d+84>>2]|0;h=L[k+4>>2];L[p>>2]=L[k>>2];L[p+4>>2]=h;h=L[k+12>>2];L[p+8>>2]=L[k+8>>2];L[p+12>>2]=h;h=L[k+20>>2];L[p+16>>2]=L[k+16>>2];L[p+20>>2]=h;b=b+2|0;g=g+2|0;if((n|0)!=(g|0)){continue}break}}if(!(c&1)){break ha}b=R(b,24);c=b+f|0;g=b+L[d+84>>2]|0;b=L[g+4>>2];L[c>>2]=L[g>>2];L[c+4>>2]=b;b=L[g+20>>2];L[c+16>>2]=L[g+16>>2];L[c+20>>2]=b;b=L[g+12>>2];L[c+8>>2]=L[g+8>>2];L[c+12>>2]=b}b=L[d+84>>2];if(!(b?!b|!M[d+88|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[d+84>>2]=f;J[d+88|0]=1;L[d+80>>2]=l;c=L[d+76>>2]}b=L[e+28>>2];c=L[d+84>>2]+R(c,24)|0;L[c>>2]=L[e+24>>2];L[c+4>>2]=b;b=L[e+44>>2];L[c+16>>2]=L[e+40>>2];L[c+20>>2]=b;b=L[e+36>>2];L[c+8>>2]=L[e+32>>2];L[c+12>>2]=b;f=L[d+76>>2];b=f+1|0;L[d+76>>2]=b;g=2;c=L[x+4>>2];if((c|0)==2|(f|0)<=0){break Z}while(1){if((b|0)>=2){e=L[x+12>>2]+R(g,24)|0;D=P[e+8>>2];F=P[e+4>>2];C=P[e>>2];K=P[d+8>>2];N=P[d+4>>2];H=P[d>>2];f=L[d+84>>2];ia:{while(1){c=R(b,24)+f|0;h=c-48|0;s=P[h>>2];c=c-24|0;w=S(s-P[c>>2]);m=P[h+4>>2];y=S(m-F);u=S(s-C);m=S(m-P[c+4>>2]);U=S(S(S(w*y)-S(u*m))*K);B=m;m=P[h+8>>2];s=S(m-D);m=S(m-P[c+8>>2]);if(S(U+S(S(S(S(B*s)-S(y*m))*H)+S(N*S(S(m*u)-S(s*w)))))>S(0)){ja:{if(L[d+80>>2]!=(b|0)){break ja}n=b<<1;if((n|0)<=(b|0)){break ja}L[8513]=L[8513]+1;f=ha[L[6798]](R(b,48),16)|0;l=L[d+76>>2];ka:{if((l|0)<=0){break ka}b=0;if((l|0)!=1){p=l&-2;r=0;while(1){c=R(b,24);h=c+f|0;k=c+L[d+84>>2]|0;c=L[k+4>>2];L[h>>2]=L[k>>2];L[h+4>>2]=c;c=L[k+20>>2];L[h+16>>2]=L[k+16>>2];L[h+20>>2]=c;c=L[k+12>>2];L[h+8>>2]=L[k+8>>2];L[h+12>>2]=c;c=R(b|1,24);h=c+f|0;k=c+L[d+84>>2]|0;c=L[k+4>>2];L[h>>2]=L[k>>2];L[h+4>>2]=c;c=L[k+12>>2];L[h+8>>2]=L[k+8>>2];L[h+12>>2]=c;c=L[k+20>>2];L[h+16>>2]=L[k+16>>2];L[h+20>>2]=c;b=b+2|0;r=r+2|0;if((p|0)!=(r|0)){continue}break}}if(!(l&1)){break ka}b=R(b,24);c=b+f|0;h=b+L[d+84>>2]|0;b=L[h+4>>2];L[c>>2]=L[h>>2];L[c+4>>2]=b;b=L[h+20>>2];L[c+16>>2]=L[h+16>>2];L[c+20>>2]=b;b=L[h+12>>2];L[c+8>>2]=L[h+8>>2];L[c+12>>2]=b}b=L[d+84>>2];if(!(b?!b|!M[d+88|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[d+84>>2]=f;J[d+88|0]=1;L[d+80>>2]=n;b=L[d+76>>2]}c=R(b,24)+f|0;b=L[e+4>>2];L[c>>2]=L[e>>2];L[c+4>>2]=b;b=L[e+20>>2];L[c+16>>2]=L[e+16>>2];L[c+20>>2]=b;b=L[e+12>>2];L[c+8>>2]=L[e+8>>2];L[c+12>>2]=b;b=L[d+76>>2]+1|0;L[d+76>>2]=b;break ia}c=b-1|0;L[d+76>>2]=c;h=b>>>0<3;b=c;if(!h){continue}break}b=1}c=L[x+4>>2]}g=g+1|0;if((g|0)!=(c|0)){continue}break}}fa=z+32|0;la:{if(L[d+76>>2]<=0){f=L[d+96>>2];break la}t=0;v=L[d+20>>2];while(1){h=R(t,24);e=h+L[d+84>>2]|0;ma:{if(L[d+24>>2]!=(v|0)){break ma}n=v?v<<1:1;if((n|0)<=(v|0)){break ma}na:{if(!n){f=0;break na}L[8513]=L[8513]+1;f=ha[L[6798]](n<<2,16)|0;v=L[d+20>>2]}k=L[d+28>>2];oa:{pa:{if((v|0)>0){p=v&3;r=0;g=0;if(v>>>0>=4){c=v&-4;v=0;while(1){l=g<<2;L[l+f>>2]=L[k+l>>2];b=l|4;L[b+f>>2]=L[b+k>>2];b=l|8;L[b+f>>2]=L[b+k>>2];b=l|12;L[b+f>>2]=L[b+k>>2];g=g+4|0;v=v+4|0;if((c|0)!=(v|0)){continue}break}}if(!p){break pa}while(1){b=g<<2;L[b+f>>2]=L[b+k>>2];g=g+1|0;r=r+1|0;if((p|0)!=(r|0)){continue}break}break pa}if(!k){break oa}}if(k?M[d+32|0]:0){L[8514]=L[8514]+1;ha[L[6799]](k)}v=L[d+20>>2]}L[d+28>>2]=f;J[d+32|0]=1;L[d+24>>2]=n}L[L[d+28>>2]+(v<<2)>>2]=L[e+20>>2];v=L[d+20>>2]+1|0;L[d+20>>2]=v;f=L[d+96>>2];qa:{if((f|0)<=0){break qa}e=L[(h+L[d+84>>2]|0)+20>>2];g=0;c=L[d+104>>2];while(1){b=c+R(g,24)|0;if((e|0)!=L[b+20>>2]){g=g+1|0;if((g|0)!=(f|0)){continue}break qa}break}L[b+20>>2]=-1}t=t+1|0;if((t|0)>2]){continue}break}}ra:{if((f|0)>0){t=0;h=L[d+104>>2];while(1){p=L[(h+R(t,24)|0)+20>>2];sa:{if((p|0)==-1|(o|0)<=0){break sa}c=0;if((O|0)>0){while(1){b=R(c,36)+E|0;g=0;ta:{while(1){if(L[(g<<2)+i>>2]==(c|0)){break ta}g=g+1|0;if((O|0)!=(g|0)){continue}break}e=L[b+4>>2];if((e|0)<=0){break ta}b=L[b+12>>2];g=0;while(1){if((p|0)!=L[b+(g<<2)>>2]){g=g+1|0;if((e|0)!=(g|0)){continue}break ta}break}b=1;break ra}c=c+1|0;if((o|0)!=(c|0)){continue}break sa}}while(1){ua:{b=R(c,36)+E|0;e=L[b+4>>2];if((e|0)<=0){break ua}b=L[b+12>>2];g=0;while(1){if((p|0)!=L[b+(g<<2)>>2]){g=g+1|0;if((e|0)!=(g|0)){continue}break ua}break}b=1;break ra}c=c+1|0;if((o|0)!=(c|0)){continue}break}}t=t+1|0;if((t|0)!=(f|0)){continue}break}}e=L[a+52>>2];f=L[e+28>>2];if((f|0)==L[e+32>>2]){Fh(e+24|0,f?f<<1:1);f=L[e+28>>2]}c=L[e+36>>2]+R(f,36)|0;Jc(c,d+16|0);b=L[d+48>>2];L[c+28>>2]=L[d+44>>2];L[c+32>>2]=b;b=L[d+40>>2];L[c+20>>2]=L[d+36>>2];L[c+24>>2]=b;L[e+28>>2]=L[e+28>>2]+1;b=0}c=L[d+84>>2];if(!(c?!c|!M[d+88|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](c)}c=L[d+28>>2];if(!(c?!c|!M[d+32|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](c)}c=L[d+104>>2];if(!(c?!c|!M[d+108|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](c)}if(!(b&(O|0)>0)){break N}}A=0;while(1){t=0;b=R(L[(A<<2)+i>>2],36)+E|0;Q=L[b+4>>2];va:{if((Q|0)<=0){break va}r=0;L[8513]=L[8513]+1;c=Q<<2;t=ha[L[6798]](c,16)|0;p=pa(t,0,c);h=L[b+12>>2];g=0;if(Q>>>0>=4){f=Q&-4;v=0;while(1){e=g<<2;L[e+p>>2]=L[e+h>>2];c=e|4;L[c+p>>2]=L[c+h>>2];c=e|8;L[c+p>>2]=L[c+h>>2];c=e|12;L[c+p>>2]=L[c+h>>2];g=g+4|0;v=v+4|0;if((f|0)!=(v|0)){continue}break}}f=Q&3;if(!f){break va}while(1){c=g<<2;L[c+p>>2]=L[c+h>>2];g=g+1|0;r=r+1|0;if((f|0)!=(r|0)){continue}break}}f=M[b+24|0]|M[b+25|0]<<8|(M[b+26|0]<<16|M[b+27|0]<<24);c=M[b+20|0]|M[b+21|0]<<8|(M[b+22|0]<<16|M[b+23|0]<<24);J[d+19|0]=c;J[d+20|0]=c>>>8;J[d+21|0]=c>>>16;J[d+22|0]=c>>>24;J[d+23|0]=f;J[d+24|0]=f>>>8;J[d+25|0]=f>>>16;J[d+26|0]=f>>>24;c=M[b+32|0]|M[b+33|0]<<8|(M[b+34|0]<<16|M[b+35|0]<<24);b=M[b+28|0]|M[b+29|0]<<8|(M[b+30|0]<<16|M[b+31|0]<<24);J[d+27|0]=b;J[d+28|0]=b>>>8;J[d+29|0]=b>>>16;J[d+30|0]=b>>>24;J[d+31|0]=c;J[d+32|0]=c>>>8;J[d+33|0]=c>>>16;J[d+34|0]=c>>>24;I=L[a+52>>2];b=L[I+28>>2];wa:{if((b|0)!=L[I+32>>2]){break wa}k=b?b<<1:1;if((k|0)<=(b|0)){break wa}xa:{if(!k){l=0;break xa}L[8513]=L[8513]+1;l=ha[L[6798]](R(k,36),16)|0;b=L[I+28>>2]}ya:{if((b|0)<=0){break ya}e=0;while(1){f=L[I+36>>2];c=R(e,36);G=c+l|0;L[G+12>>2]=0;J[G+16|0]=1;L[G+4>>2]=0;L[G+8>>2]=0;c=c+f|0;V=L[c+4>>2];za:{if((V|0)<=0){L[G+4>>2]=V;break za}L[8513]=L[8513]+1;p=V<<2;z=ha[L[6798]](p,16)|0;W=L[G+12>>2];n=L[G+4>>2];Aa:{Ba:{if((n|0)>0){r=0;g=0;if(n>>>0>=4){h=n&-4;v=0;while(1){x=g<<2;L[x+z>>2]=L[x+W>>2];f=x|4;L[f+z>>2]=L[f+W>>2];f=x|8;L[f+z>>2]=L[f+W>>2];f=x|12;L[f+z>>2]=L[f+W>>2];g=g+4|0;v=v+4|0;if((h|0)!=(v|0)){continue}break}}h=n&3;if(h){while(1){f=g<<2;L[f+z>>2]=L[f+W>>2];g=g+1|0;r=r+1|0;if((h|0)!=(r|0)){continue}break}}if(M[G+16|0]){break Ba}break Aa}if(!W|!M[G+16|0]){break Aa}}if(W){L[8514]=L[8514]+1;ha[L[6799]](W)}}L[G+12>>2]=z;J[G+16|0]=1;L[G+8>>2]=V;r=0;x=pa(z,0,p);L[G+4>>2]=V;n=L[c+12>>2];g=0;if(V>>>0>=4){h=V&-4;v=0;while(1){p=g<<2;L[p+x>>2]=L[n+p>>2];f=p|4;L[f+x>>2]=L[f+n>>2];f=p|8;L[f+x>>2]=L[f+n>>2];f=p|12;L[f+x>>2]=L[f+n>>2];g=g+4|0;v=v+4|0;if((h|0)!=(v|0)){continue}break}}h=V&3;if(!h){break za}while(1){f=g<<2;L[f+x>>2]=L[f+n>>2];g=g+1|0;r=r+1|0;if((h|0)!=(r|0)){continue}break}}f=L[c+24>>2];L[G+20>>2]=L[c+20>>2];L[G+24>>2]=f;f=L[c+32>>2];L[G+28>>2]=L[c+28>>2];L[G+32>>2]=f;e=e+1|0;if((e|0)!=(b|0)){continue}break}f=0;b=L[I+28>>2];if((b|0)<=0){break ya}while(1){e=L[I+36>>2]+R(f,36)|0;c=L[e+12>>2];if(!(c?!c|!M[e+16|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](c)}L[e+12>>2]=0;J[e+16|0]=1;L[e+4>>2]=0;L[e+8>>2]=0;f=f+1|0;if((b|0)!=(f|0)){continue}break}}b=L[I+36>>2];if(!(b?!b|!M[I+40|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[I+36>>2]=l;J[I+40|0]=1;L[I+32>>2]=k;b=L[I+28>>2]}l=L[I+36>>2]+R(b,36)|0;L[l+12>>2]=0;J[l+16|0]=1;L[l+4>>2]=0;L[l+8>>2]=0;Ca:{if((Q|0)<=0){L[l+4>>2]=Q;break Ca}L[8513]=L[8513]+1;f=Q<<2;p=ha[L[6798]](f,16)|0;n=L[l+12>>2];e=L[l+4>>2];Da:{Ea:{if((e|0)>0){r=0;g=0;if(e>>>0>=4){c=e&-4;v=0;while(1){h=g<<2;L[h+p>>2]=L[h+n>>2];b=h|4;L[b+p>>2]=L[b+n>>2];b=h|8;L[b+p>>2]=L[b+n>>2];b=h|12;L[b+p>>2]=L[b+n>>2];g=g+4|0;v=v+4|0;if((c|0)!=(v|0)){continue}break}}c=e&3;if(c){while(1){b=g<<2;L[b+p>>2]=L[b+n>>2];g=g+1|0;r=r+1|0;if((c|0)!=(r|0)){continue}break}}if(M[l+16|0]){break Ea}break Da}if(!n|!M[l+16|0]){break Da}}if(n){L[8514]=L[8514]+1;ha[L[6799]](n)}}L[l+12>>2]=p;J[l+16|0]=1;L[l+8>>2]=Q;e=0;h=pa(p,0,f);L[l+4>>2]=Q;g=0;if(Q>>>0>=4){c=Q&-4;r=0;while(1){f=g<<2;L[f+h>>2]=L[f+t>>2];b=f|4;L[b+h>>2]=L[b+t>>2];b=f|8;L[b+h>>2]=L[b+t>>2];b=f|12;L[b+h>>2]=L[b+t>>2];g=g+4|0;r=r+4|0;if((c|0)!=(r|0)){continue}break}}c=Q&3;if(!c){break Ca}while(1){b=g<<2;L[b+h>>2]=L[b+t>>2];g=g+1|0;e=e+1|0;if((c|0)!=(e|0)){continue}break}}c=M[d+23|0]|M[d+24|0]<<8|(M[d+25|0]<<16|M[d+26|0]<<24);b=M[d+19|0]|M[d+20|0]<<8|(M[d+21|0]<<16|M[d+22|0]<<24);J[l+20|0]=b;J[l+21|0]=b>>>8;J[l+22|0]=b>>>16;J[l+23|0]=b>>>24;J[l+24|0]=c;J[l+25|0]=c>>>8;J[l+26|0]=c>>>16;J[l+27|0]=c>>>24;c=M[d+31|0]|M[d+32|0]<<8|(M[d+33|0]<<16|M[d+34|0]<<24);b=M[d+27|0]|M[d+28|0]<<8|(M[d+29|0]<<16|M[d+30|0]<<24);J[l+28|0]=b;J[l+29|0]=b>>>8;J[l+30|0]=b>>>16;J[l+31|0]=b>>>24;J[l+32|0]=c;J[l+33|0]=c>>>8;J[l+34|0]=c>>>16;J[l+35|0]=c>>>24;L[I+28>>2]=L[I+28>>2]+1;if(t){L[8514]=L[8514]+1;ha[L[6799]](t)}A=A+1|0;if((O|0)!=(A|0)){continue}break}}if(i){L[8514]=L[8514]+1;ha[L[6799]](i)}if(j){continue}break}dm(L[a+52>>2]);if(q){L[8514]=L[8514]+1;ha[L[6799]](q)}if((o|0)<=0){break A}f=0;while(1){b=R(f,36)+E|0;a=L[b+12>>2];if(!(a?!a|!M[b+16|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](a)}L[b+12>>2]=0;J[b+16|0]=1;L[b+4>>2]=0;L[b+8>>2]=0;f=f+1|0;if((o|0)!=(f|0)){continue}break}break z}dm(L[a+52>>2])}if(!E){break y}}if(E){L[8514]=L[8514]+1;ha[L[6799]](E)}}if(Z){L[8514]=L[8514]+1;ha[L[6799]](Z)}a=L[d+164>>2];if(!(a?!a|!M[d+168|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](a)}L[d+164>>2]=0;J[d+168|0]=1;L[d+156>>2]=0;L[d+160>>2]=0;a=L[d+144>>2];if(!(a?!a|!M[d+148|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](a)}L[d+144>>2]=0;J[d+148|0]=1;L[d+136>>2]=0;L[d+140>>2]=0;a=L[d+124>>2];if(!(a?!a|!M[d+128|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](a)}a=L[d+184>>2];if(!(a?!a|!M[d+188|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](a)}fa=d+192|0;return 1}function xk(a,b,c){var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=S(0),r=0,s=S(0),t=0,u=S(0),v=S(0),w=S(0),x=S(0),y=S(0),z=S(0),A=S(0),B=0,C=S(0),D=S(0),E=0,F=S(0),G=S(0),H=S(0);E=fa-16|0;fa=E;f=L[a+1112>>2];if((f|0)>0){while(1){kg(a,0);f=L[a+1112>>2];if((f|0)>0){continue}break}}d=L[a+712>>2];d=(b|0)>(d|0)?d:b;a:{if((d|0)<=(f|0)){break a}if(L[a+1116>>2]<(d|0)){b:{if(!d){break b}L[8513]=L[8513]+1;h=ha[L[6798]](d<<2,16)|0;k=L[a+1112>>2];if((k|0)<=0){break b}b=0;if(k>>>0>=4){l=k&-4;while(1){m=b<<2;L[m+h>>2]=L[m+L[a+1120>>2]>>2];j=m|4;L[j+h>>2]=L[j+L[a+1120>>2]>>2];j=m|8;L[j+h>>2]=L[j+L[a+1120>>2]>>2];j=m|12;L[j+h>>2]=L[j+L[a+1120>>2]>>2];b=b+4|0;e=e+4|0;if((l|0)!=(e|0)){continue}break}}j=k&3;if(!j){break b}while(1){e=b<<2;L[e+h>>2]=L[e+L[a+1120>>2]>>2];b=b+1|0;o=o+1|0;if((j|0)!=(o|0)){continue}break}}b=L[a+1120>>2];if(!(b?!b|!M[a+1124|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+1120>>2]=h;J[a+1124|0]=1;L[a+1116>>2]=d}j=(f^-1)+d|0;e=d-f&3;if(e){b=0;while(1){L[L[a+1120>>2]+(f<<2)>>2]=0;f=f+1|0;b=b+1|0;if((e|0)!=(b|0)){continue}break}}if(j>>>0<3){break a}while(1){b=f<<2;L[b+L[a+1120>>2]>>2]=0;L[(b+L[a+1120>>2]|0)+4>>2]=0;L[(b+L[a+1120>>2]|0)+8>>2]=0;L[(b+L[a+1120>>2]|0)+12>>2]=0;f=f+4|0;if((d|0)!=(f|0)){continue}break}}L[a+1112>>2]=d;c:{d:{e:{f:{if((d|0)<=0){break f}b=0;while(1){L[8513]=L[8513]+1;d=ha[L[6798]](384,16)|0;L[d+4>>2]=0;L[d+8>>2]=0;L[d+12>>2]=0;J[d+16|0]=1;L[d+348>>2]=0;L[d+352>>2]=0;J[d+376|0]=0;L[d+368>>2]=1120403456;L[d+372>>2]=1008981770;J[d+36|0]=1;L[d+32>>2]=0;J[d+56|0]=1;L[d+24>>2]=0;L[d+28>>2]=0;L[d+52>>2]=0;L[d+44>>2]=0;L[d+48>>2]=0;L[d+356>>2]=0;L[d+360>>2]=0;L[d+364>>2]=0;e=b<<2;L[e+L[a+1120>>2]>>2]=d;J[L[e+L[a+1120>>2]>>2]+377|0]=1;b=b+1|0;d=L[a+1112>>2];if((b|0)<(d|0)){continue}break}if((d|0)<=0){break f}b=L[a+712>>2];if((b|0)>0){while(1){k=L[a+720>>2]+R(t,104)|0;x=P[k+8>>2];s=P[k+16>>2];q=P[k+12>>2];g=L[L[a+1120>>2]+((R(t,29873)|0)%L[a+1112>>2]<<2)>>2];e=L[g+24>>2];g:{if((e|0)!=L[g+28>>2]){break g}l=e?e<<1:1;if((l|0)<=(e|0)){break g}h:{if(!l){h=0;break h}L[8513]=L[8513]+1;h=ha[L[6798]](l<<2,16)|0;e=L[g+24>>2]}i:{if((e|0)<=0){break i}o=0;b=0;if(e>>>0>=4){f=e&-4;r=0;while(1){m=b<<2;L[m+h>>2]=L[m+L[g+32>>2]>>2];j=m|4;L[j+h>>2]=L[j+L[g+32>>2]>>2];j=m|8;L[j+h>>2]=L[j+L[g+32>>2]>>2];j=m|12;L[j+h>>2]=L[j+L[g+32>>2]>>2];b=b+4|0;r=r+4|0;if((f|0)!=(r|0)){continue}break}}f=e&3;if(!f){break i}while(1){j=b<<2;L[j+h>>2]=L[j+L[g+32>>2]>>2];b=b+1|0;o=o+1|0;if((f|0)!=(o|0)){continue}break}}b=L[g+32>>2];if(!(!b|!M[g+36|0])){if(b){L[8514]=L[8514]+1;ha[L[6799]](b)}e=L[g+24>>2]}L[g+32>>2]=h;J[g+36|0]=1;L[g+28>>2]=l;b=L[a+712>>2]}v=S(v+x);u=S(u+s);w=S(w+q);L[L[g+32>>2]+(e<<2)>>2]=k;L[g+24>>2]=e+1;t=t+1|0;if((t|0)<(b|0)){continue}break}}q=S(S(1)/S(b|0));x=S(u*q);s=S(w*q);q=S(v*q);e=0;L[8513]=L[8513]+1;B=ha[L[6798]](d<<4,16)|0;f=0;if(d>>>0>=4){b=d&-4;o=0;while(1){l=f<<4;j=l+B|0;L[j+12>>2]=0;P[j+8>>2]=x;P[j+4>>2]=s;P[j>>2]=q;j=B+(l|16)|0;L[j+12>>2]=0;P[j+8>>2]=x;P[j+4>>2]=s;P[j>>2]=q;j=B+(l|32)|0;L[j+12>>2]=0;P[j+8>>2]=x;P[j+4>>2]=s;P[j>>2]=q;j=B+(l|48)|0;L[j+12>>2]=0;P[j+8>>2]=x;P[j+4>>2]=s;P[j>>2]=q;f=f+4|0;o=o+4|0;if((b|0)!=(o|0)){continue}break}}b=d&3;if(b){while(1){j=B+(f<<4)|0;L[j+12>>2]=0;P[j+8>>2]=x;P[j+4>>2]=s;P[j>>2]=q;f=f+1|0;e=e+1|0;if((b|0)!=(e|0)){continue}break}}while(1){q=S(S(i|0)*S(.0625));D=S(S(2)-(q>S(1)?S(1):q));i=i+1|0;g=0;t=0;while(1){l=t<<2;b=L[l+L[a+1120>>2]>>2];p=L[b+24>>2];j:{if((p|0)<=0){u=S(0);w=S(0);v=S(0);break j}j=p&1;m=L[b+32>>2];k:{if((p|0)==1){v=S(0);f=0;w=S(0);u=S(0);break k}e=p&-2;v=S(0);f=0;w=S(0);u=S(0);o=0;while(1){b=f<<2;k=L[b+m>>2];b=L[m+(b|4)>>2];u=S(S(u+P[k+8>>2])+P[b+8>>2]);v=S(S(v+P[k+16>>2])+P[b+16>>2]);w=S(S(w+P[k+12>>2])+P[b+12>>2]);f=f+2|0;o=o+2|0;if((e|0)!=(o|0)){continue}break}}if(!j){break j}b=L[m+(f<<2)>>2];u=S(u+P[b+8>>2]);v=S(v+P[b+16>>2]);w=S(w+P[b+12>>2])}if(p){b=B+(t<<4)|0;L[b+12>>2]=0;C=P[b+8>>2];s=S(S(1)/S(p|0));q=S(C+S(D*S(S(v*s)-C)));P[b+8>>2]=q;z=P[b+4>>2];x=S(z+S(D*S(S(w*s)-z)));P[b+4>>2]=x;A=P[b>>2];s=S(A+S(D*S(S(u*s)-A)));P[b>>2]=s;q=S(q-C);F=S(q*q);q=S(s-A);C=S(q*q);q=S(x-z);j=S(F+S(C+S(q*q)))>S(1.1920928955078125e-7);l=L[l+L[a+1120>>2]>>2];b=L[l+24>>2];l:{if((b|0)>=0){break l}if(L[l+28>>2]<0){e=L[l+32>>2];if(!(e?!e|!M[l+36|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](e)}J[l+36|0]=1;L[l+28>>2]=0;L[l+32>>2]=0}h=0;f=b;e=0-b&3;if(e){while(1){L[L[l+32>>2]+(f<<2)>>2]=0;f=f+1|0;h=h+1|0;if((e|0)!=(h|0)){continue}break}}if(b>>>0>4294967292){break l}while(1){b=f<<2;L[b+L[l+32>>2]>>2]=0;L[(b+L[l+32>>2]|0)+4>>2]=0;L[(b+L[l+32>>2]|0)+8>>2]=0;L[(b+L[l+32>>2]|0)+12>>2]=0;f=f+4|0;if(f){continue}break}}L[l+24>>2]=0;g=g|j}t=t+1|0;if((t|0)!=(d|0)){continue}break}n=0;e=L[a+712>>2];if((e|0)>0){while(1){m=L[a+720>>2]+R(n,104)|0;h=0;if((d|0)>=2){A=P[m+8>>2];x=P[m+12>>2];s=P[m+16>>2];u=S(S(S(T(S(P[B>>2]-A)))+S(T(S(P[B+4>>2]-x))))+S(T(S(P[B+8>>2]-s))));f=1;while(1){b=B+(f<<4)|0;q=S(S(S(T(S(P[b>>2]-A)))+S(T(S(P[b+4>>2]-x))))+S(T(S(P[b+8>>2]-s))));b=q>2]+(h<<2)>>2];r=L[p+24>>2];m:{if((r|0)!=L[p+28>>2]){break m}l=r?r<<1:1;if((l|0)<=(r|0)){break m}n:{if(!l){h=0;break n}L[8513]=L[8513]+1;h=ha[L[6798]](l<<2,16)|0;r=L[p+24>>2]}o:{if((r|0)<=0){break o}o=0;b=0;if(r>>>0>=4){f=r&-4;j=0;while(1){k=b<<2;L[k+h>>2]=L[k+L[p+32>>2]>>2];e=k|4;L[e+h>>2]=L[e+L[p+32>>2]>>2];e=k|8;L[e+h>>2]=L[e+L[p+32>>2]>>2];e=k|12;L[e+h>>2]=L[e+L[p+32>>2]>>2];b=b+4|0;j=j+4|0;if((f|0)!=(j|0)){continue}break}}j=r&3;if(!j){break o}while(1){e=b<<2;L[e+h>>2]=L[e+L[p+32>>2]>>2];b=b+1|0;o=o+1|0;if((j|0)!=(o|0)){continue}break}}b=L[p+32>>2];if(!(!b|!M[p+36|0])){if(b){L[8514]=L[8514]+1;ha[L[6799]](b)}r=L[p+24>>2]}L[p+32>>2]=h;J[p+36|0]=1;L[p+28>>2]=l;e=L[a+712>>2]}L[L[p+32>>2]+(r<<2)>>2]=m;L[p+24>>2]=r+1;n=n+1|0;if((n|0)<(e|0)){continue}break}}if((c|0)>(i|0)&g){continue}break}p:{if((e|0)<=0){r=0;break p}L[8513]=L[8513]+1;b=e<<2;r=ha[L[6798]](b,16)|0;pa(r,255,b)}e=L[a+1112>>2];if((e|0)>0){j=L[a+720>>2];d=L[a+1120>>2];b=0;while(1){l=L[d+(b<<2)>>2];if(L[l+24>>2]>0){c=L[l+32>>2];f=0;while(1){L[((L[c+(f<<2)>>2]-j|0)/104<<2)+r>>2]=b;f=f+1|0;if((f|0)>2]){continue}break}e=L[a+1112>>2]}b=b+1|0;if((e|0)>(b|0)){continue}break}}if(L[a+752>>2]>0){e=0;while(1){c=L[a+760>>2]+R(e,44)|0;b=L[a+720>>2];L[E+4>>2]=(L[c+8>>2]-b|0)/104;L[E+8>>2]=(L[c+12>>2]-b|0)/104;L[E+12>>2]=(L[c+16>>2]-b|0)/104;j=0;while(1){b=j;j=b+1|0;k=(j|0)==3;d=E+4|0;c=L[d+((k?0:j)<<2)>>2];g=L[(L[d+(b<<2)>>2]<<2)+r>>2];q:{if(L[(c<<2)+r>>2]==(g|0)){break q}l=L[a+720>>2]+R(c,104)|0;i=L[L[a+1120>>2]+(g<<2)>>2];h=L[i+24>>2];r:{if((h|0)<=0){break r}c=L[i+32>>2];f=0;while(1){if((l|0)!=L[c+(f<<2)>>2]){f=f+1|0;if((h|0)!=(f|0)){continue}break r}break}if((f|0)!=(h|0)){break q}}s:{if(L[i+28>>2]!=(h|0)){break s}m=h?h<<1:1;if((m|0)<=(h|0)){break s}t:{if(!m){o=0;break t}L[8513]=L[8513]+1;o=ha[L[6798]](m<<2,16)|0;h=L[i+24>>2]}u:{if((h|0)<=0){break u}t=0;f=0;if(h>>>0>=4){d=h&-4;n=0;while(1){p=f<<2;L[p+o>>2]=L[p+L[i+32>>2]>>2];c=p|4;L[c+o>>2]=L[c+L[i+32>>2]>>2];c=p|8;L[c+o>>2]=L[c+L[i+32>>2]>>2];c=p|12;L[c+o>>2]=L[c+L[i+32>>2]>>2];f=f+4|0;n=n+4|0;if((d|0)!=(n|0)){continue}break}}d=h&3;if(!d){break u}while(1){c=f<<2;L[c+o>>2]=L[c+L[i+32>>2]>>2];f=f+1|0;t=t+1|0;if((d|0)!=(t|0)){continue}break}}c=L[i+32>>2];if(!(!c|!M[i+36|0])){if(c){L[8514]=L[8514]+1;ha[L[6799]](c)}h=L[i+24>>2]}L[i+32>>2]=o;J[i+36|0]=1;L[i+28>>2]=m}L[L[i+32>>2]+(h<<2)>>2]=l;L[i+24>>2]=h+1}b=L[(E+4|0)+((b+2>>>0)%3<<2)>>2];v:{if((g|0)==L[(b<<2)+r>>2]){break v}d=L[a+720>>2]+R(b,104)|0;g=L[L[a+1120>>2]+(g<<2)>>2];h=L[g+24>>2];w:{if((h|0)<=0){break w}b=L[g+32>>2];f=0;while(1){if((d|0)!=L[b+(f<<2)>>2]){f=f+1|0;if((h|0)!=(f|0)){continue}break w}break}if((f|0)!=(h|0)){break v}}x:{if(L[g+28>>2]!=(h|0)){break x}l=h?h<<1:1;if((l|0)<=(h|0)){break x}y:{if(!l){o=0;break y}L[8513]=L[8513]+1;o=ha[L[6798]](l<<2,16)|0;h=L[g+24>>2]}z:{if((h|0)<=0){break z}t=0;f=0;if(h>>>0>=4){c=h&-4;i=0;while(1){m=f<<2;L[m+o>>2]=L[m+L[g+32>>2]>>2];b=m|4;L[b+o>>2]=L[b+L[g+32>>2]>>2];b=m|8;L[b+o>>2]=L[b+L[g+32>>2]>>2];b=m|12;L[b+o>>2]=L[b+L[g+32>>2]>>2];f=f+4|0;i=i+4|0;if((c|0)!=(i|0)){continue}break}}c=h&3;if(!c){break z}while(1){b=f<<2;L[b+o>>2]=L[b+L[g+32>>2]>>2];f=f+1|0;t=t+1|0;if((c|0)!=(t|0)){continue}break}}b=L[g+32>>2];if(!(!b|!M[g+36|0])){if(b){L[8514]=L[8514]+1;ha[L[6799]](b)}h=L[g+24>>2]}L[g+32>>2]=o;J[g+36|0]=1;L[g+28>>2]=l}L[L[g+32>>2]+(h<<2)>>2]=d;L[g+24>>2]=h+1}if(!k){continue}break}e=e+1|0;if((e|0)>2]){continue}break}e=L[a+1112>>2]}if((e|0)<2){break d}L[8513]=L[8513]+1;g=ha[L[6798]](384,16)|0;L[g+348>>2]=0;L[g+352>>2]=0;L[g+12>>2]=0;J[g+16|0]=1;L[g+4>>2]=0;L[g+8>>2]=0;K[g+376>>1]=0;L[g+368>>2]=1120403456;L[g+372>>2]=1008981770;L[g+44>>2]=0;L[g+48>>2]=0;J[g+36|0]=1;L[g+32>>2]=0;J[g+56|0]=1;L[g+24>>2]=0;L[g+28>>2]=0;L[g+52>>2]=0;L[g+356>>2]=0;L[g+360>>2]=0;L[g+364>>2]=0;e=L[a+712>>2];if((e|0)<=0){break e}L[8513]=L[8513]+1;m=ha[L[6798]](e<<2,16)|0;l=L[g+24>>2];A:{if((l|0)<=0){break A}d=0;b=0;if(l>>>0>=4){f=l&-4;j=0;while(1){k=b<<2;L[k+m>>2]=L[k+L[g+32>>2]>>2];c=k|4;L[c+m>>2]=L[c+L[g+32>>2]>>2];c=k|8;L[c+m>>2]=L[c+L[g+32>>2]>>2];c=k|12;L[c+m>>2]=L[c+L[g+32>>2]>>2];b=b+4|0;j=j+4|0;if((f|0)!=(j|0)){continue}break}}j=l&3;if(!j){break A}while(1){c=b<<2;L[c+m>>2]=L[c+L[g+32>>2]>>2];b=b+1|0;d=d+1|0;if((j|0)!=(d|0)){continue}break}}b=L[g+32>>2];if(!(b?!b|!M[g+36|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[g+32>>2]=m;J[g+36|0]=1;L[g+28>>2]=e;b=L[a+712>>2];if((b|0)<=0){break e}d=L[g+24>>2];t=0;while(1){l=L[a+720>>2]+R(t,104)|0;B:{if((d|0)!=(e|0)){break B}c=e?e<<1:1;if((c|0)<=(e|0)){d=e;break B}C:{if(!c){h=0;break C}L[8513]=L[8513]+1;h=ha[L[6798]](c<<2,16)|0;e=L[g+24>>2]}d=e;D:{if((d|0)<=0){break D}o=0;b=0;if(d>>>0>=4){f=d&-4;j=0;while(1){k=b<<2;L[k+h>>2]=L[k+L[g+32>>2]>>2];e=k|4;L[e+h>>2]=L[e+L[g+32>>2]>>2];e=k|8;L[e+h>>2]=L[e+L[g+32>>2]>>2];e=k|12;L[e+h>>2]=L[e+L[g+32>>2]>>2];b=b+4|0;j=j+4|0;if((f|0)!=(j|0)){continue}break}}j=d&3;if(!j){break D}while(1){e=b<<2;L[e+h>>2]=L[e+L[g+32>>2]>>2];b=b+1|0;o=o+1|0;if((j|0)!=(o|0)){continue}break}}b=L[g+32>>2];if(!(!b|!M[g+36|0])){if(b){L[8514]=L[8514]+1;ha[L[6799]](b)}d=L[g+24>>2]}L[g+32>>2]=h;J[g+36|0]=1;L[g+28>>2]=c;b=L[a+712>>2];e=c}L[L[g+32>>2]+(d<<2)>>2]=l;d=d+1|0;L[g+24>>2]=d;t=t+1|0;if((t|0)<(b|0)){continue}break}break e}m=L[a+772>>2];if(m){E:{if((d|0)>=(m|0)){break E}if((m|0)>L[a+1116>>2]){L[8513]=L[8513]+1;k=ha[L[6798]](m<<2,16)|0;j=L[a+1112>>2];F:{if((j|0)<=0){break F}o=0;f=0;if(j>>>0>=4){c=j&-4;e=0;while(1){l=f<<2;L[l+k>>2]=L[l+L[a+1120>>2]>>2];b=l|4;L[b+k>>2]=L[b+L[a+1120>>2]>>2];b=l|8;L[b+k>>2]=L[b+L[a+1120>>2]>>2];b=l|12;L[b+k>>2]=L[b+L[a+1120>>2]>>2];f=f+4|0;e=e+4|0;if((c|0)!=(e|0)){continue}break}}c=j&3;if(!c){break F}while(1){b=f<<2;L[b+k>>2]=L[b+L[a+1120>>2]>>2];f=f+1|0;o=o+1|0;if((c|0)!=(o|0)){continue}break}}b=L[a+1120>>2];if(!(b?!b|!M[a+1124|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+1120>>2]=k;J[a+1124|0]=1;L[a+1116>>2]=m}c=m+(d^-1)|0;b=m-d&3;if(b){f=0;while(1){L[L[a+1120>>2]+(d<<2)>>2]=0;d=d+1|0;f=f+1|0;if((b|0)!=(f|0)){continue}break}}if(c>>>0<3){break E}while(1){b=d<<2;L[b+L[a+1120>>2]>>2]=0;L[(b+L[a+1120>>2]|0)+4>>2]=0;L[(b+L[a+1120>>2]|0)+8>>2]=0;L[(b+L[a+1120>>2]|0)+12>>2]=0;d=d+4|0;if((m|0)!=(d|0)){continue}break}}L[a+1112>>2]=m;if((m|0)>0){b=0;while(1){L[8513]=L[8513]+1;e=ha[L[6798]](384,16)|0;L[e+4>>2]=0;L[e+8>>2]=0;L[e+12>>2]=0;J[e+16|0]=1;L[e+348>>2]=0;L[e+352>>2]=0;J[e+376|0]=0;L[e+368>>2]=1120403456;L[e+372>>2]=1008981770;J[e+36|0]=1;L[e+32>>2]=0;J[e+56|0]=1;L[e+24>>2]=0;L[e+28>>2]=0;L[e+52>>2]=0;L[e+44>>2]=0;L[e+48>>2]=0;L[e+356>>2]=0;L[e+360>>2]=0;L[e+364>>2]=0;c=b<<2;L[c+L[a+1120>>2]>>2]=e;J[L[c+L[a+1120>>2]>>2]+377|0]=1;b=b+1|0;if((b|0)>2]){continue}break}}if(L[a+772>>2]<=0){break c}j=0;while(1){g=R(j,104);l=g+L[a+780>>2]|0;m=j<<2;n=L[m+L[a+1120>>2]>>2];d=L[n+24>>2];G:{if((d|0)!=L[n+28>>2]){break G}k=d?d<<1:1;if((k|0)<=(d|0)){break G}H:{if(!k){h=0;break H}L[8513]=L[8513]+1;h=ha[L[6798]](k<<2,16)|0;d=L[n+24>>2]}I:{if((d|0)<=0){break I}o=0;b=0;if(d>>>0>=4){f=d&-4;e=0;while(1){p=b<<2;L[p+h>>2]=L[p+L[n+32>>2]>>2];c=p|4;L[c+h>>2]=L[c+L[n+32>>2]>>2];c=p|8;L[c+h>>2]=L[c+L[n+32>>2]>>2];c=p|12;L[c+h>>2]=L[c+L[n+32>>2]>>2];b=b+4|0;e=e+4|0;if((f|0)!=(e|0)){continue}break}}e=d&3;if(!e){break I}while(1){c=b<<2;L[c+h>>2]=L[c+L[n+32>>2]>>2];b=b+1|0;o=o+1|0;if((e|0)!=(o|0)){continue}break}}b=L[n+32>>2];if(!(!b|!M[n+36|0])){if(b){L[8514]=L[8514]+1;ha[L[6799]](b)}d=L[n+24>>2]}L[n+32>>2]=h;J[n+36|0]=1;L[n+28>>2]=k}L[L[n+32>>2]+(d<<2)>>2]=L[l+8>>2];L[n+24>>2]=d+1;l=g+L[a+780>>2]|0;n=L[m+L[a+1120>>2]>>2];d=L[n+24>>2];J:{if((d|0)!=L[n+28>>2]){break J}k=d?d<<1:1;if((k|0)<=(d|0)){break J}K:{if(!k){h=0;break K}L[8513]=L[8513]+1;h=ha[L[6798]](k<<2,16)|0;d=L[n+24>>2]}L:{if((d|0)<=0){break L}o=0;b=0;if(d>>>0>=4){f=d&-4;e=0;while(1){p=b<<2;L[p+h>>2]=L[p+L[n+32>>2]>>2];c=p|4;L[c+h>>2]=L[c+L[n+32>>2]>>2];c=p|8;L[c+h>>2]=L[c+L[n+32>>2]>>2];c=p|12;L[c+h>>2]=L[c+L[n+32>>2]>>2];b=b+4|0;e=e+4|0;if((f|0)!=(e|0)){continue}break}}e=d&3;if(!e){break L}while(1){c=b<<2;L[c+h>>2]=L[c+L[n+32>>2]>>2];b=b+1|0;o=o+1|0;if((e|0)!=(o|0)){continue}break}}b=L[n+32>>2];if(!(!b|!M[n+36|0])){if(b){L[8514]=L[8514]+1;ha[L[6799]](b)}d=L[n+24>>2]}L[n+32>>2]=h;J[n+36|0]=1;L[n+28>>2]=k}L[L[n+32>>2]+(d<<2)>>2]=L[l+12>>2];L[n+24>>2]=d+1;l=g+L[a+780>>2]|0;n=L[m+L[a+1120>>2]>>2];d=L[n+24>>2];M:{if((d|0)!=L[n+28>>2]){break M}k=d?d<<1:1;if((k|0)<=(d|0)){break M}N:{if(!k){h=0;break N}L[8513]=L[8513]+1;h=ha[L[6798]](k<<2,16)|0;d=L[n+24>>2]}O:{if((d|0)<=0){break O}o=0;b=0;if(d>>>0>=4){f=d&-4;e=0;while(1){p=b<<2;L[p+h>>2]=L[p+L[n+32>>2]>>2];c=p|4;L[c+h>>2]=L[c+L[n+32>>2]>>2];c=p|8;L[c+h>>2]=L[c+L[n+32>>2]>>2];c=p|12;L[c+h>>2]=L[c+L[n+32>>2]>>2];b=b+4|0;e=e+4|0;if((f|0)!=(e|0)){continue}break}}e=d&3;if(!e){break O}while(1){c=b<<2;L[c+h>>2]=L[c+L[n+32>>2]>>2];b=b+1|0;o=o+1|0;if((e|0)!=(o|0)){continue}break}}b=L[n+32>>2];if(!(!b|!M[n+36|0])){if(b){L[8514]=L[8514]+1;ha[L[6799]](b)}d=L[n+24>>2]}L[n+32>>2]=h;J[n+36|0]=1;L[n+28>>2]=k}L[L[n+32>>2]+(d<<2)>>2]=L[l+16>>2];L[n+24>>2]=d+1;l=g+L[a+780>>2]|0;g=L[m+L[a+1120>>2]>>2];d=L[g+24>>2];P:{if((d|0)!=L[g+28>>2]){break P}k=d?d<<1:1;if((k|0)<=(d|0)){break P}Q:{if(!k){h=0;break Q}L[8513]=L[8513]+1;h=ha[L[6798]](k<<2,16)|0;d=L[g+24>>2]}R:{if((d|0)<=0){break R}o=0;b=0;if(d>>>0>=4){f=d&-4;e=0;while(1){m=b<<2;L[m+h>>2]=L[m+L[g+32>>2]>>2];c=m|4;L[c+h>>2]=L[c+L[g+32>>2]>>2];c=m|8;L[c+h>>2]=L[c+L[g+32>>2]>>2];c=m|12;L[c+h>>2]=L[c+L[g+32>>2]>>2];b=b+4|0;e=e+4|0;if((f|0)!=(e|0)){continue}break}}e=d&3;if(!e){break R}while(1){c=b<<2;L[c+h>>2]=L[c+L[g+32>>2]>>2];b=b+1|0;o=o+1|0;if((e|0)!=(o|0)){continue}break}}b=L[g+32>>2];if(!(!b|!M[g+36|0])){if(b){L[8514]=L[8514]+1;ha[L[6799]](b)}d=L[g+24>>2]}L[g+32>>2]=h;J[g+36|0]=1;L[g+28>>2]=k}L[L[g+32>>2]+(d<<2)>>2]=L[l+20>>2];L[g+24>>2]=d+1;j=j+1|0;if((j|0)>2]){continue}break}break c}k=L[a+752>>2];S:{if((k|0)<=(d|0)){break S}if((k|0)>L[a+1116>>2]){T:{if(!k){h=0;break T}L[8513]=L[8513]+1;h=ha[L[6798]](k<<2,16)|0;j=L[a+1112>>2];if((j|0)<=0){break T}o=0;f=0;if(j>>>0>=4){c=j&-4;e=0;while(1){l=f<<2;L[l+h>>2]=L[l+L[a+1120>>2]>>2];b=l|4;L[b+h>>2]=L[b+L[a+1120>>2]>>2];b=l|8;L[b+h>>2]=L[b+L[a+1120>>2]>>2];b=l|12;L[b+h>>2]=L[b+L[a+1120>>2]>>2];f=f+4|0;e=e+4|0;if((c|0)!=(e|0)){continue}break}}c=j&3;if(!c){break T}while(1){b=f<<2;L[b+h>>2]=L[b+L[a+1120>>2]>>2];f=f+1|0;o=o+1|0;if((c|0)!=(o|0)){continue}break}}b=L[a+1120>>2];if(!(b?!b|!M[a+1124|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+1120>>2]=h;J[a+1124|0]=1;L[a+1116>>2]=k}c=k+(d^-1)|0;b=k-d&3;if(b){f=0;while(1){L[L[a+1120>>2]+(d<<2)>>2]=0;d=d+1|0;f=f+1|0;if((b|0)!=(f|0)){continue}break}}if(c>>>0<3){break S}while(1){b=d<<2;L[b+L[a+1120>>2]>>2]=0;L[(b+L[a+1120>>2]|0)+4>>2]=0;L[(b+L[a+1120>>2]|0)+8>>2]=0;L[(b+L[a+1120>>2]|0)+12>>2]=0;d=d+4|0;if((k|0)!=(d|0)){continue}break}}L[a+1112>>2]=k;if((k|0)>0){b=0;while(1){L[8513]=L[8513]+1;e=ha[L[6798]](384,16)|0;L[e+4>>2]=0;L[e+8>>2]=0;L[e+12>>2]=0;J[e+16|0]=1;L[e+348>>2]=0;L[e+352>>2]=0;J[e+376|0]=0;L[e+368>>2]=1120403456;L[e+372>>2]=1008981770;J[e+36|0]=1;L[e+32>>2]=0;J[e+56|0]=1;L[e+24>>2]=0;L[e+28>>2]=0;L[e+52>>2]=0;L[e+44>>2]=0;L[e+48>>2]=0;L[e+356>>2]=0;L[e+360>>2]=0;L[e+364>>2]=0;c=b<<2;L[c+L[a+1120>>2]>>2]=e;J[L[c+L[a+1120>>2]>>2]+377|0]=1;b=b+1|0;if((b|0)>2]){continue}break}}if(L[a+752>>2]<=0){break c}j=0;while(1){m=R(j,44);l=m+L[a+760>>2]|0;k=j<<2;n=L[k+L[a+1120>>2]>>2];d=L[n+24>>2];U:{if((d|0)!=L[n+28>>2]){break U}g=d?d<<1:1;if((g|0)<=(d|0)){break U}V:{if(!g){h=0;break V}L[8513]=L[8513]+1;h=ha[L[6798]](g<<2,16)|0;d=L[n+24>>2]}W:{if((d|0)<=0){break W}o=0;b=0;if(d>>>0>=4){f=d&-4;e=0;while(1){p=b<<2;L[p+h>>2]=L[p+L[n+32>>2]>>2];c=p|4;L[c+h>>2]=L[c+L[n+32>>2]>>2];c=p|8;L[c+h>>2]=L[c+L[n+32>>2]>>2];c=p|12;L[c+h>>2]=L[c+L[n+32>>2]>>2];b=b+4|0;e=e+4|0;if((f|0)!=(e|0)){continue}break}}e=d&3;if(!e){break W}while(1){c=b<<2;L[c+h>>2]=L[c+L[n+32>>2]>>2];b=b+1|0;o=o+1|0;if((e|0)!=(o|0)){continue}break}}b=L[n+32>>2];if(!(!b|!M[n+36|0])){if(b){L[8514]=L[8514]+1;ha[L[6799]](b)}d=L[n+24>>2]}L[n+32>>2]=h;J[n+36|0]=1;L[n+28>>2]=g}L[L[n+32>>2]+(d<<2)>>2]=L[l+8>>2];L[n+24>>2]=d+1;l=m+L[a+760>>2]|0;n=L[k+L[a+1120>>2]>>2];d=L[n+24>>2];X:{if((d|0)!=L[n+28>>2]){break X}g=d?d<<1:1;if((g|0)<=(d|0)){break X}Y:{if(!g){h=0;break Y}L[8513]=L[8513]+1;h=ha[L[6798]](g<<2,16)|0;d=L[n+24>>2]}Z:{if((d|0)<=0){break Z}o=0;b=0;if(d>>>0>=4){f=d&-4;e=0;while(1){p=b<<2;L[p+h>>2]=L[p+L[n+32>>2]>>2];c=p|4;L[c+h>>2]=L[c+L[n+32>>2]>>2];c=p|8;L[c+h>>2]=L[c+L[n+32>>2]>>2];c=p|12;L[c+h>>2]=L[c+L[n+32>>2]>>2];b=b+4|0;e=e+4|0;if((f|0)!=(e|0)){continue}break}}e=d&3;if(!e){break Z}while(1){c=b<<2;L[c+h>>2]=L[c+L[n+32>>2]>>2];b=b+1|0;o=o+1|0;if((e|0)!=(o|0)){continue}break}}b=L[n+32>>2];if(!(!b|!M[n+36|0])){if(b){L[8514]=L[8514]+1;ha[L[6799]](b)}d=L[n+24>>2]}L[n+32>>2]=h;J[n+36|0]=1;L[n+28>>2]=g}L[L[n+32>>2]+(d<<2)>>2]=L[l+12>>2];L[n+24>>2]=d+1;l=m+L[a+760>>2]|0;g=L[k+L[a+1120>>2]>>2];d=L[g+24>>2];_:{if((d|0)!=L[g+28>>2]){break _}k=d?d<<1:1;if((k|0)<=(d|0)){break _}$:{if(!k){h=0;break $}L[8513]=L[8513]+1;h=ha[L[6798]](k<<2,16)|0;d=L[g+24>>2]}aa:{if((d|0)<=0){break aa}o=0;b=0;if(d>>>0>=4){f=d&-4;e=0;while(1){m=b<<2;L[m+h>>2]=L[m+L[g+32>>2]>>2];c=m|4;L[c+h>>2]=L[c+L[g+32>>2]>>2];c=m|8;L[c+h>>2]=L[c+L[g+32>>2]>>2];c=m|12;L[c+h>>2]=L[c+L[g+32>>2]>>2];b=b+4|0;e=e+4|0;if((f|0)!=(e|0)){continue}break}}e=d&3;if(!e){break aa}while(1){c=b<<2;L[c+h>>2]=L[c+L[g+32>>2]>>2];b=b+1|0;o=o+1|0;if((e|0)!=(o|0)){continue}break}}b=L[g+32>>2];if(!(!b|!M[g+36|0])){if(b){L[8514]=L[8514]+1;ha[L[6799]](b)}d=L[g+24>>2]}L[g+32>>2]=h;J[g+36|0]=1;L[g+28>>2]=k}L[L[g+32>>2]+(d<<2)>>2]=L[l+16>>2];L[g+24>>2]=d+1;j=j+1|0;if((j|0)>2]){continue}break}break c}d=L[a+1112>>2];ba:{if((d|0)!=L[a+1116>>2]){break ba}f=d?d<<1:1;if((f|0)<=(d|0)){break ba}ca:{if(!f){h=0;break ca}L[8513]=L[8513]+1;h=ha[L[6798]](f<<2,16)|0;d=L[a+1112>>2]}da:{if((d|0)<=0){break da}o=0;b=0;if(d>>>0>=4){e=d&-4;j=0;while(1){l=b<<2;L[l+h>>2]=L[l+L[a+1120>>2]>>2];c=l|4;L[c+h>>2]=L[c+L[a+1120>>2]>>2];c=l|8;L[c+h>>2]=L[c+L[a+1120>>2]>>2];c=l|12;L[c+h>>2]=L[c+L[a+1120>>2]>>2];b=b+4|0;j=j+4|0;if((e|0)!=(j|0)){continue}break}}e=d&3;if(!e){break da}while(1){c=b<<2;L[c+h>>2]=L[c+L[a+1120>>2]>>2];b=b+1|0;o=o+1|0;if((e|0)!=(o|0)){continue}break}}b=L[a+1120>>2];if(!(!b|!M[a+1124|0])){if(b){L[8514]=L[8514]+1;ha[L[6799]](b)}d=L[a+1112>>2]}L[a+1120>>2]=h;J[a+1124|0]=1;L[a+1116>>2]=f}b=d<<2;L[b+L[a+1120>>2]>>2]=g;e=d+1|0;L[a+1112>>2]=e;d=L[a+1120>>2];c=L[d>>2];b=b+d|0;L[d>>2]=L[b>>2];L[b>>2]=c}if((e|0)>0){f=0;while(1){if(!L[L[L[a+1120>>2]+(f<<2)>>2]+24>>2]){kg(a,f);f=f-1|0;e=L[a+1112>>2]}f=f+1|0;if((e|0)>(f|0)){continue}break}}if(r){L[8514]=L[8514]+1;ha[L[6799]](r)}if(!B){break c}if(B){L[8514]=L[8514]+1;ha[L[6799]](B)}}ea:{if(!L[a+1112>>2]){r=0;break ea}n=0;if(L[a+1112>>2]>0){while(1){i=L[L[a+1120>>2]+(n<<2)>>2];L[i+128>>2]=0;k=L[i+24>>2];e=k;j=L[i+4>>2];if((e|0)>(j|0)){fa:{if((k|0)<=L[i+8>>2]){d=L[i+12>>2];break fa}ga:{if(!k){d=0;b=j;break ga}L[8513]=L[8513]+1;d=ha[L[6798]](k<<2,16)|0;b=L[i+4>>2]}m=L[i+12>>2];c=b;ha:{ia:{if((b|0)>0){o=0;b=0;if(c>>>0>=4){f=c&-4;t=0;while(1){l=b<<2;P[l+d>>2]=P[l+m>>2];e=l|4;P[e+d>>2]=P[e+m>>2];e=l|8;P[e+d>>2]=P[e+m>>2];e=l|12;P[e+d>>2]=P[e+m>>2];b=b+4|0;t=t+4|0;if((f|0)!=(t|0)){continue}break}}e=c&3;if(!e){break ia}while(1){c=b<<2;P[c+d>>2]=P[c+m>>2];b=b+1|0;o=o+1|0;if((e|0)!=(o|0)){continue}break}break ia}if(!m){break ha}}if(!M[i+16|0]){break ha}if(m){L[8514]=L[8514]+1;ha[L[6799]](m)}}L[i+12>>2]=d;J[i+16|0]=1;L[i+8>>2]=k}pa((j<<2)+d|0,0,k-j<<2);e=L[i+24>>2]}L[i+4>>2]=k;ja:{ka:{l=(e|0)>0;la:{if(!l){y=S(S(1)/P[i+128>>2]);P[i+128>>2]=y;break la}f=L[i+32>>2];j=L[i+12>>2];b=0;while(1){d=b<<2;c=d+j|0;q=P[L[d+f>>2]+88>>2];ma:{if(q==S(0)){J[i+376|0]=1;q=S(0xde0b6b000000000);break ma}q=S(S(1)/q)}P[c>>2]=q;q=S(q+P[i+128>>2]);P[i+128>>2]=q;b=b+1|0;if((e|0)!=(b|0)){continue}break}y=S(S(1)/q);P[i+128>>2]=y;if((e|0)>0){break ka}}v=S(0);w=S(0);u=S(0);break ja}f=e&1;p=L[i+32>>2];g=L[i+12>>2];na:{if((e|0)==1){u=S(0);b=0;w=S(0);v=S(0);break na}j=e&-2;u=S(0);b=0;w=S(0);v=S(0);d=0;while(1){c=b<<2;m=L[c+p>>2];s=P[c+g>>2];c=c|4;k=L[c+p>>2];q=P[c+g>>2];v=S(S(v+S(P[m+8>>2]*s))+S(P[k+8>>2]*q));u=S(S(u+S(s*P[m+16>>2]))+S(q*P[k+16>>2]));w=S(S(w+S(s*P[m+12>>2]))+S(q*P[k+12>>2]));b=b+2|0;d=d+2|0;if((j|0)!=(d|0)){continue}break}}if(!f){break ja}b=b<<2;c=L[b+p>>2];q=P[b+g>>2];v=S(v+S(P[c+8>>2]*q));u=S(u+S(q*P[c+16>>2]));w=S(w+S(q*P[c+12>>2]))}L[i+316>>2]=0;L[i+320>>2]=0;L[i+132>>2]=0;L[i+136>>2]=0;L[i+240>>2]=0;z=S(y*u);P[i+236>>2]=z;A=S(y*w);P[i+232>>2]=A;x=S(y*v);P[i+228>>2]=x;L[i+324>>2]=0;L[i+328>>2]=0;L[i+332>>2]=0;L[i+336>>2]=0;L[i+340>>2]=0;L[i+344>>2]=0;L[i+348>>2]=0;L[i+140>>2]=0;L[i+144>>2]=0;L[i+148>>2]=0;L[i+152>>2]=0;L[i+156>>2]=0;L[i+160>>2]=0;L[i+164>>2]=0;L[i+168>>2]=0;L[i+172>>2]=0;L[i+176>>2]=0;oa:{if(!l){G=P[i+152>>2];v=P[i+156>>2];u=P[i+140>>2];y=P[i+136>>2];w=S(0);H=S(0);break oa}v=P[i+156>>2];u=P[i+140>>2];y=P[i+136>>2];G=P[i+152>>2];j=L[i+32>>2];d=L[i+12>>2];b=0;H=S(0);w=S(0);while(1){c=b<<2;f=L[c+j>>2];s=P[f+12>>2];C=S(P[f+8>>2]-x);F=P[c+d>>2];q=S(C*S(-F));D=S(P[f+16>>2]-z);u=S(S(q*D)+u);P[i+140>>2]=u;s=S(s-A);y=S(S(q*s)+y);P[i+136>>2]=y;v=S(v-S(S(s*F)*D));P[i+156>>2]=v;q=S(C*C);s=S(s*s);H=S(S(F*S(q+s))+H);P[i+172>>2]=H;C=q;q=S(D*D);G=S(S(F*S(C+q))+G);P[i+152>>2]=G;w=S(S(F*S(s+q))+w);P[i+132>>2]=w;b=b+1|0;if((e|0)!=(b|0)){continue}break}}L[i+176>>2]=0;L[i+60>>2]=1065353216;L[i+160>>2]=0;L[i+144>>2]=0;b=i- -64|0;L[b>>2]=0;L[b+4>>2]=0;L[i+72>>2]=0;L[i+76>>2]=0;L[i+84>>2]=0;L[i+88>>2]=0;L[i+80>>2]=1065353216;L[i+92>>2]=0;L[i+96>>2]=0;s=S(S(y*v)-S(G*u));A=S(S(G*H)-S(v*v));x=S(S(v*u)-S(H*y));z=S(S(1)/S(S(u*s)+S(S(w*A)+S(x*y))));P[i+172>>2]=S(S(w*G)-S(y*y))*z;q=S(S(S(u*y)-S(v*w))*z);P[i+168>>2]=q;s=S(s*z);P[i+164>>2]=s;P[i+156>>2]=q;P[i+152>>2]=S(S(w*H)-S(u*u))*z;q=S(x*z);P[i+148>>2]=q;P[i+140>>2]=s;P[i+136>>2]=q;P[i+132>>2]=A*z;L[i+100>>2]=1065353216;L[i+104>>2]=0;b=L[i+232>>2];L[i+108>>2]=L[i+228>>2];L[i+112>>2]=b;b=L[i+240>>2];L[i+116>>2]=L[i+236>>2];L[i+120>>2]=b;d=L[i+44>>2];m=L[i+24>>2];if(!((d|0)>=(m|0)|(m|0)<=L[i+48>>2])){pa:{if(!m){e=0;break pa}L[8513]=L[8513]+1;e=ha[L[6798]](m<<4,16)|0;d=L[i+44>>2]}qa:{if((d|0)<=0){break qa}b=0;if((d|0)!=1){j=d&-2;r=0;while(1){f=b<<4;k=f+e|0;l=f+L[i+52>>2]|0;c=L[l+4>>2];L[k>>2]=L[l>>2];L[k+4>>2]=c;c=L[l+12>>2];L[k+8>>2]=L[l+8>>2];L[k+12>>2]=c;c=f|16;l=c+e|0;f=c+L[i+52>>2]|0;c=L[f+4>>2];L[l>>2]=L[f>>2];L[l+4>>2]=c;c=L[f+12>>2];L[l+8>>2]=L[f+8>>2];L[l+12>>2]=c;b=b+2|0;r=r+2|0;if((j|0)!=(r|0)){continue}break}}if(!(d&1)){break qa}b=b<<4;d=b+e|0;c=b+L[i+52>>2]|0;b=L[c+4>>2];L[d>>2]=L[c>>2];L[d+4>>2]=b;b=L[c+12>>2];L[d+8>>2]=L[c+8>>2];L[d+12>>2]=b}b=L[i+52>>2];if(!(b?!b|!M[i+56|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[i+52>>2]=e;J[i+56|0]=1;L[i+48>>2]=m}L[i+44>>2]=m;if((m|0)>0){b=0;while(1){c=L[L[i+32>>2]+(b<<2)>>2];C=P[c+12>>2];z=P[c+16>>2];A=P[c+8>>2];x=P[i+232>>2];s=P[i+236>>2];q=P[i+228>>2];c=L[i+52>>2]+(b<<4)|0;L[c+12>>2]=0;P[c>>2]=A-q;P[c+8>>2]=z-s;P[c+4>>2]=C-x;b=b+1|0;if((b|0)>2]){continue}break}}n=n+1|0;if((n|0)>2]){continue}break}}wk(a);r=L[a+1112>>2];k=R(r,r);d=L[a+1132>>2];if((k|0)>(d|0)){ra:{if((k|0)<=L[a+1136>>2]){b=L[a+1140>>2];break ra}sa:{if(!r){b=0;c=d;break sa}L[8513]=L[8513]+1;b=ha[L[6798]](k,16)|0;c=L[a+1132>>2]}m=L[a+1140>>2];ta:{if((c|0)>0){e=0;f=0;if(c>>>0>=4){l=c&-4;o=0;while(1){J[b+f|0]=M[f+m|0];j=f|1;J[j+b|0]=M[j+m|0];j=f|2;J[j+b|0]=M[j+m|0];j=f|3;J[j+b|0]=M[j+m|0];f=f+4|0;o=o+4|0;if((l|0)!=(o|0)){continue}break}}c=c&3;if(!c){break ta}while(1){J[b+f|0]=M[f+m|0];f=f+1|0;e=e+1|0;if((c|0)!=(e|0)){continue}break}break ta}if(m){break ta}L[a+1140>>2]=b;L[a+1136>>2]=k;J[a+1144|0]=1;break ra}if(m?M[a+1144|0]:0){L[8514]=L[8514]+1;ha[L[6799]](m)}L[a+1140>>2]=b;J[a+1144|0]=1;L[a+1136>>2]=k}pa(b+d|0,0,k-d|0);r=L[a+1112>>2]}L[a+1132>>2]=k;if((r|0)<=0){break ea}k=L[a+1140>>2];n=L[a+1120>>2];t=0;while(1){p=L[n+(t<<2)>>2];L[p+380>>2]=t;g=L[p+24>>2];a=(g|0)>0;l=a?g:0;e=0;while(1){d=a;ua:{if((g|0)<=0){break ua}j=L[n+(e<<2)>>2];m=L[j+24>>2];o=0;while(1){if((m|0)>0){c=L[L[p+32>>2]+(o<<2)>>2];b=L[j+32>>2];f=0;while(1){if((c|0)==L[b+(f<<2)>>2]){break ua}f=f+1|0;if((m|0)!=(f|0)){continue}break}}o=o+1|0;d=(l|0)!=(o|0);if(d){continue}break}}J[k+(R(e,r)+t|0)|0]=d&1;e=e+1|0;if((r|0)!=(e|0)){continue}break}t=t+1|0;if((t|0)!=(r|0)){continue}break}}fa=E+16|0;return r}function gz(a){a=a|0;var b=0,c=0,d=0,e=0,f=S(0),g=S(0),h=S(0),i=0,j=0,k=0,l=S(0),m=S(0),n=0,o=0,p=S(0),q=S(0),r=S(0),s=S(0),t=S(0),u=S(0),v=S(0),w=S(0),x=0,y=S(0),z=S(0),A=0,B=0,C=0,D=0,E=0,F=S(0),G=S(0),H=S(0),I=S(0),K=S(0),N=S(0),O=S(0),Q=S(0),T=S(0),U=S(0),V=S(0),W=S(0),X=0;Vk(a);if(!(!(ha[L[L[a>>2]+20>>2]](a)|0)|L[a+328>>2]<=0)){while(1){k=L[L[a+336>>2]+(E<<2)>>2];a:{if(!(ha[L[L[a>>2]+20>>2]](a)|0)){break a}d=ha[L[L[a>>2]+20>>2]](a)|0;if(!(ha[L[L[d>>2]+48>>2]](d)&1)){break a}i=L[a+72>>2];d=fa+-64|0;fa=d;b:{if(!M[k+473|0]){break b}c=L[k+532>>2];L[d+24>>2]=L[k+528>>2];L[d+28>>2]=c;c=L[k+524>>2];L[d+16>>2]=L[k+520>>2];L[d+20>>2]=c;f=P[k+576>>2];h=P[k+568>>2];g=P[k+572>>2];l=P[k+544>>2];m=P[k+536>>2];p=P[k+540>>2];r=P[k+624>>2];s=P[k+592>>2];t=P[k+608>>2];q=P[k+620>>2];u=P[k+588>>2];v=P[k+604>>2];w=P[k+616>>2];y=P[k+560>>2];z=P[k+584>>2];F=P[k+552>>2];G=P[k+600>>2];H=P[k+556>>2];L[d+60>>2]=0;I=S(S(r*f)+S(S(s*h)+S(t*g)));T=S(I*S(0));K=S(S(w*f)+S(S(z*h)+S(G*g)));N=S(S(q*f)+S(S(u*h)+S(v*g)));U=S(N*S(0));h=S(T+S(K+U));O=S(S(r*l)+S(S(s*m)+S(p*t)));V=S(O*S(0));Q=S(S(w*l)+S(S(z*m)+S(G*p)));p=S(S(q*l)+S(S(u*m)+S(p*v)));m=S(p*S(0));g=S(V+S(Q+m));r=S(S(r*y)+S(S(s*F)+S(t*H)));W=S(r*S(0));s=S(S(w*y)+S(S(z*F)+S(G*H)));t=S(S(q*y)+S(S(u*F)+S(v*H)));q=S(t*S(0));l=S(W+S(s+q));f=S(S(1)/S(_(S(S(h*h)+S(S(g*g)+S(l*l))))));P[d+56>>2]=P[d+24>>2]+S(S(h*f)*S(10));P[d+52>>2]=P[d+20>>2]+S(S(l*f)*S(10));P[d+48>>2]=P[d+16>>2]+S(S(g*f)*S(10));L[d+40>>2]=0;L[d+44>>2]=0;L[d+32>>2]=1065353216;L[d+36>>2]=0;c=d+16|0;b=d+48|0;j=d+32|0;ha[L[L[i>>2]+8>>2]](i,c,b,j);L[d+60>>2]=0;u=S(K*S(0));h=S(T+S(u+N));v=S(Q*S(0));g=S(V+S(v+p));w=S(s*S(0));l=S(W+S(w+t));f=S(S(1)/S(_(S(S(h*h)+S(S(g*g)+S(l*l))))));P[d+56>>2]=S(S(h*f)*S(10))+P[d+24>>2];P[d+52>>2]=S(S(l*f)*S(10))+P[d+20>>2];P[d+48>>2]=S(S(g*f)*S(10))+P[d+16>>2];L[d+40>>2]=0;L[d+44>>2]=0;L[d+32>>2]=0;L[d+36>>2]=1065353216;ha[L[L[i>>2]+8>>2]](i,c,b,j);L[d+60>>2]=0;h=S(I+S(u+U));g=S(S(v+m)+O);l=S(r+S(w+q));f=S(S(1)/S(_(S(S(h*h)+S(S(g*g)+S(l*l))))));P[d+56>>2]=S(S(h*f)*S(10))+P[d+24>>2];P[d+52>>2]=S(S(l*f)*S(10))+P[d+20>>2];P[d+48>>2]=S(S(g*f)*S(10))+P[d+16>>2];L[d+40>>2]=1065353216;L[d+44>>2]=0;L[d+32>>2]=0;L[d+36>>2]=0;ha[L[L[i>>2]+8>>2]](i,c,b,j);if(L[k+484>>2]<=0){break b}c=0;while(1){b=L[k+492>>2]+(c<<4)|0;g=P[b+8>>2];l=P[b>>2];m=P[b+4>>2];q=P[d+16>>2];h=P[d+20>>2];f=P[d+24>>2];L[d+8>>2]=1065353216;L[d+12>>2]=0;L[d>>2]=1065353216;L[d+4>>2]=0;L[d+60>>2]=0;f=S(f+S(S(I*g)+S(S(K*l)+S(N*m))));P[d+56>>2]=f;h=S(h+S(S(r*g)+S(S(s*l)+S(t*m))));P[d+52>>2]=h;g=S(q+S(S(O*g)+S(S(Q*l)+S(p*m))));P[d+48>>2]=g+S(-.10000000149011612);L[d+44>>2]=0;l=S(f+S(0));P[d+40>>2]=l;m=S(h+S(0));P[d+36>>2]=m;P[d+32>>2]=g+S(.10000000149011612);b=d+48|0;j=d+32|0;ha[L[L[i>>2]+8>>2]](i,b,j,d);L[d+60>>2]=0;P[d+56>>2]=f;P[d+52>>2]=h+S(-.10000000149011612);P[d+48>>2]=g;L[d+44>>2]=0;P[d+40>>2]=l;P[d+36>>2]=h+S(.10000000149011612);l=S(g+S(0));P[d+32>>2]=l;ha[L[L[i>>2]+8>>2]](i,b,j,d);L[d+60>>2]=0;P[d+56>>2]=f+S(-.10000000149011612);P[d+52>>2]=h;P[d+48>>2]=g;L[d+44>>2]=0;P[d+40>>2]=f+S(.10000000149011612);P[d+36>>2]=m;P[d+32>>2]=l;ha[L[L[i>>2]+8>>2]](i,b,j,d);c=c+1|0;if((c|0)>2]){continue}break}}fa=d- -64|0;j=L[a+72>>2];o=L[a+344>>2];d=0;C=0;b=fa-176|0;fa=b;L[b+152>>2]=0;L[b+156>>2]=0;L[b+144>>2]=0;L[b+148>>2]=0;L[b+136>>2]=1065353216;L[b+140>>2]=0;L[b+128>>2]=1065353216;L[b+132>>2]=1065353216;L[b+120>>2]=0;L[b+124>>2]=0;L[b+112>>2]=1065353216;L[b+116>>2]=0;c:{if(o&256){L[8528]=1805;L[8529]=0;e=L[k+1112>>2];if((e|0)<=0){break c}while(1){x=C<<2;if(M[L[x+L[k+1120>>2]>>2]+377|0]){D=0;c=mI(L[8528],L[8529],1284865837,1481765933);d=ga;c=c+1|0;d=c?d:d+1|0;L[8528]=c;L[8529]=d;i=mI(L[8528],L[8529],1284865837,1481765933);c=ga;i=i+1|0;c=i?c:c+1|0;L[8528]=i;L[8529]=c;e=mI(L[8528],L[8529],1284865837,1481765933);i=ga;e=e+1|0;i=e?i:i+1|0;L[8528]=e;L[8529]=i;L[b+172>>2]=0;f=S(S(i>>>1|0)*S(4.656612873077393e-10));m=f;q=S(f*f);f=S(S(d>>>1|0)*S(4.656612873077393e-10));h=S(S(c>>>1|0)*S(4.656612873077393e-10));g=S(S(1)/S(_(S(q+S(S(f*f)+S(h*h))))));P[b+168>>2]=S(m*g)*S(.75);P[b+164>>2]=S(h*g)*S(.75);P[b+160>>2]=S(f*g)*S(.75);n=0;d=L[L[x+L[k+1120>>2]>>2]+24>>2];d:{if((d|0)<=0){break d}e=0;L[8513]=L[8513]+1;n=ha[L[6798]](d<<4,16)|0;if((d|0)!=1){X=d&-2;i=0;while(1){c=L[L[L[x+L[k+1120>>2]>>2]+32>>2]+(e<<2)>>2];B=L[c+12>>2];A=(e<<4)+n|0;L[A>>2]=L[c+8>>2];L[A+4>>2]=B;B=L[c+20>>2];L[A+8>>2]=L[c+16>>2];L[A+12>>2]=B;c=e|1;A=(c<<4)+n|0;c=L[L[L[x+L[k+1120>>2]>>2]+32>>2]+(c<<2)>>2];B=L[c+12>>2];L[A>>2]=L[c+8>>2];L[A+4>>2]=B;B=L[c+20>>2];L[A+8>>2]=L[c+16>>2];L[A+12>>2]=B;e=e+2|0;i=i+2|0;if((X|0)!=(i|0)){continue}break}}if(!(d&1)){break d}i=(e<<4)+n|0;c=L[L[L[x+L[k+1120>>2]>>2]+32>>2]+(e<<2)>>2];e=L[c+12>>2];L[i>>2]=L[c+8>>2];L[i+4>>2]=e;e=L[c+20>>2];L[i+8>>2]=L[c+16>>2];L[i+12>>2]=e}L[b+60>>2]=0;J[b+64|0]=1;J[b+84|0]=1;L[b+52>>2]=0;L[b+56>>2]=0;L[b+80>>2]=0;J[b+104|0]=1;L[b+72>>2]=0;L[b+76>>2]=0;L[b+100>>2]=0;L[b+92>>2]=0;L[b+96>>2]=0;ag(b+48|0,n,d);i=L[b+92>>2];if((i|0)>0){while(1){x=L[b+80>>2]+R(L[L[b+100>>2]+(D<<2)>>2],12)|0;d=R(L[x+4>>2],12)+x|0;e=R(L[d>>2],12)+d|0;if((e|0)!=(x|0)){c=L[d+8>>2];d=L[x+8>>2];while(1){A=c<<4;c=L[b+60>>2];i=L[e+8>>2];ha[L[L[j>>2]+28>>2]](j,A+c|0,c+(d<<4)|0,c+(i<<4)|0,b+160|0,S(1));c=d;d=i;i=R(L[e+4>>2],12)+e|0;e=R(L[i>>2],12)+i|0;if((x|0)!=(e|0)){continue}break}i=L[b+92>>2]}D=D+1|0;if((i|0)>(D|0)){continue}break}}d=L[b+100>>2];if(!(d?!d|!M[b+104|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](d)}L[b+100>>2]=0;J[b+104|0]=1;L[b+92>>2]=0;L[b+96>>2]=0;d=L[b+80>>2];if(!(d?!d|!M[b+84|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](d)}L[b+80>>2]=0;J[b+84|0]=1;L[b+72>>2]=0;L[b+76>>2]=0;d=L[b+60>>2];if(!(d?!d|!M[b+64|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](d)}if(n){L[8514]=L[8514]+1;ha[L[6799]](n)}e=L[k+1112>>2]}C=C+1|0;if((C|0)<(e|0)){continue}break}break c}e:{if(!(o&1)){break e}i=L[k+712>>2];if((i|0)<=0){break e}while(1){c=L[k+720>>2]+R(d,104)|0;if(J[L[c+4>>2]+16|0]&1){f=P[c+8>>2];i=L[c+12>>2];e=L[c+16>>2];L[b+60>>2]=0;L[b+52>>2]=i;L[b+56>>2]=e;P[b+48>>2]=f+S(-.10000000149011612);f=P[c+8>>2];h=P[c+12>>2];g=P[c+16>>2];L[b+172>>2]=0;P[b+168>>2]=g+S(0);P[b+164>>2]=h+S(0);P[b+160>>2]=f+S(.10000000149011612);L[b+40>>2]=0;L[b+44>>2]=0;L[b+32>>2]=1065353216;L[b+36>>2]=0;i=b+48|0;e=b+160|0;n=b+32|0;ha[L[L[j>>2]+8>>2]](j,i,e,n);f=P[c+12>>2];h=P[c+8>>2];g=P[c+16>>2];L[b+60>>2]=0;P[b+56>>2]=g;P[b+48>>2]=h;P[b+52>>2]=f+S(-.10000000149011612);f=P[c+8>>2];h=P[c+12>>2];g=P[c+16>>2];L[b+172>>2]=0;P[b+168>>2]=g+S(0);P[b+164>>2]=h+S(.10000000149011612);P[b+160>>2]=f+S(0);L[b+40>>2]=0;L[b+44>>2]=0;L[b+32>>2]=0;L[b+36>>2]=1065353216;ha[L[L[j>>2]+8>>2]](j,i,e,n);f=P[c+16>>2];x=L[c+8>>2];C=L[c+12>>2];L[b+60>>2]=0;L[b+48>>2]=x;L[b+52>>2]=C;P[b+56>>2]=f+S(-.10000000149011612);f=P[c+8>>2];h=P[c+12>>2];g=P[c+16>>2];L[b+172>>2]=0;P[b+168>>2]=g+S(.10000000149011612);P[b+164>>2]=h+S(0);P[b+160>>2]=f+S(0);L[b+40>>2]=1065353216;L[b+44>>2]=0;L[b+32>>2]=0;L[b+36>>2]=0;ha[L[L[j>>2]+8>>2]](j,i,e,n);i=L[k+712>>2]}d=d+1|0;if((i|0)>(d|0)){continue}break}}f:{if(!(o&2)){break f}i=L[k+732>>2];if((i|0)<=0){break f}e=0;while(1){d=L[k+740>>2]+R(e,52)|0;if(J[L[d+4>>2]+16|0]&1){ha[L[L[j>>2]+8>>2]](j,L[d+8>>2]+8|0,L[d+12>>2]+8|0,b+144|0);i=L[k+732>>2]}e=e+1|0;if((i|0)>(e|0)){continue}break}}g:{if(!(o&16)){break g}i=L[k+712>>2];if((i|0)<=0){break g}d=0;while(1){c=L[k+720>>2]+R(d,104)|0;if(J[L[c+4>>2]+16|0]&1){f=P[c+72>>2];h=P[c+76>>2];g=P[c+80>>2];l=P[c+8>>2];m=P[c+12>>2];p=P[c+16>>2];L[b+60>>2]=0;g=S(g*S(.5));P[b+56>>2]=p+g;h=S(h*S(.5));P[b+52>>2]=m+h;f=S(f*S(.5));P[b+48>>2]=l+f;i=c+8|0;e=b+48|0;ha[L[L[j>>2]+8>>2]](j,i,e,b+128|0);l=P[c+8>>2];m=P[c+12>>2];p=P[c+16>>2];L[b+60>>2]=0;P[b+56>>2]=p-g;P[b+52>>2]=m-h;P[b+48>>2]=l-f;L[b+172>>2]=0;P[b+168>>2]=P[b+136>>2]*S(.5);P[b+164>>2]=P[b+132>>2]*S(.5);P[b+160>>2]=P[b+128>>2]*S(.5);ha[L[L[j>>2]+8>>2]](j,i,e,b+160|0);i=L[k+712>>2]}d=d+1|0;if((i|0)>(d|0)){continue}break}}h:{if(!(o&32)){break h}if(!M[34048]){L[8501]=0;L[8502]=0;L[8500]=1065353216;L[8503]=0;L[8504]=0;L[8506]=0;L[8507]=0;L[8505]=1065353216;L[8508]=0;L[8509]=0;L[8510]=1065353216;L[8511]=0;J[34048]=1}if(L[k+812>>2]<=0){break h}d=0;while(1){c=L[k+820>>2]+R(d,104)|0;r=P[c+20>>2];f=P[c+12>>2];i=L[c+24>>2];h=P[i+16>>2];g=P[c+8>>2];l=P[i+12>>2];m=P[c+4>>2];p=P[i+8>>2];L[b+60>>2]=0;q=m;m=S(r+S(S(h*f)+S(S(p*m)+S(l*g))));p=S(p-S(q*m));P[b+48>>2]=p;r=S(l-S(g*m));P[b+52>>2]=r;m=S(h-S(f*m));P[b+56>>2]=m;f=P[c+4>>2];h=P[c+8>>2];i=f>2];i=(g>(i?f:h)?!i:2)<<4;l=P[i+34004>>2];s=P[i+34e3>>2];t=P[i+34008>>2];L[b+172>>2]=0;q=S(S(f*l)-S(s*h));u=S(S(h*t)-S(l*g));s=S(S(g*s)-S(t*f));l=S(S(1)/S(_(S(S(q*q)+S(S(u*u)+S(s*s))))));t=S(q*l);q=S(t*S(.5));P[b+168>>2]=m-q;s=S(s*l);v=S(s*S(.5));P[b+164>>2]=r-v;l=S(u*l);u=S(l*S(.5));P[b+160>>2]=p-u;L[b+44>>2]=0;P[b+40>>2]=m+q;P[b+36>>2]=r+v;P[b+32>>2]=p+u;i=b+160|0;e=b+32|0;n=b+112|0;ha[L[L[j>>2]+8>>2]](j,i,e,n);L[b+172>>2]=0;m=S(S(l*h)-S(f*s));h=S(S(s*g)-S(h*t));g=S(S(t*f)-S(g*l));f=S(S(1)/S(_(S(S(m*m)+S(S(h*h)+S(g*g))))));l=P[b+56>>2];m=S(S(m*f)*S(.5));P[b+168>>2]=l-m;p=P[b+52>>2];g=S(S(g*f)*S(.5));P[b+164>>2]=p-g;r=P[b+48>>2];f=S(S(h*f)*S(.5));P[b+160>>2]=r-f;L[b+44>>2]=0;P[b+40>>2]=m+l;P[b+36>>2]=g+p;P[b+32>>2]=f+r;ha[L[L[j>>2]+8>>2]](j,i,e,n);f=P[c+4>>2];h=P[c+8>>2];g=P[c+12>>2];L[b+172>>2]=0;P[b+168>>2]=S(S(g*S(.5))*S(3))+P[b+56>>2];P[b+164>>2]=S(S(h*S(.5))*S(3))+P[b+52>>2];P[b+160>>2]=S(S(f*S(.5))*S(3))+P[b+48>>2];L[b+40>>2]=0;L[b+44>>2]=0;L[b+32>>2]=1065353216;L[b+36>>2]=1065353216;ha[L[L[j>>2]+8>>2]](j,b+48|0,i,e);d=d+1|0;if((d|0)>2]){continue}break}}i:{if(!(o&4)){break i}L[b+56>>2]=0;L[b+60>>2]=0;L[b+48>>2]=0;L[b+52>>2]=1060320051;i=L[k+752>>2];if((i|0)<=0){break i}e=0;while(1){d=L[k+760>>2]+R(e,44)|0;if(J[L[d+4>>2]+16|0]&1){c=L[d+16>>2];l=P[c+12>>2];i=L[d+8>>2];m=P[i+12>>2];d=L[d+12>>2];p=P[d+12>>2];r=P[c+16>>2];g=P[i+16>>2];s=P[d+16>>2];t=P[c+8>>2];h=P[i+8>>2];q=P[d+8>>2];L[b+172>>2]=0;f=S(S(t+S(h+q))*S(.3333333432674408));P[b+160>>2]=f+S(S(h-f)*S(.800000011920929));h=S(S(r+S(g+s))*S(.3333333432674408));P[b+168>>2]=h+S(S(g-h)*S(.800000011920929));g=S(S(l+S(m+p))*S(.3333333432674408));P[b+164>>2]=g+S(S(m-g)*S(.800000011920929));L[b+44>>2]=0;P[b+40>>2]=h+S(S(s-h)*S(.800000011920929));P[b+36>>2]=g+S(S(p-g)*S(.800000011920929));P[b+32>>2]=f+S(S(q-f)*S(.800000011920929));L[b+28>>2]=0;P[b+24>>2]=h+S(S(r-h)*S(.800000011920929));P[b+20>>2]=g+S(S(l-g)*S(.800000011920929));P[b+16>>2]=f+S(S(t-f)*S(.800000011920929));ha[L[L[j>>2]+28>>2]](j,b+160|0,b+32|0,b+16|0,b+48|0,S(1));i=L[k+752>>2]}e=e+1|0;if((i|0)>(e|0)){continue}break}}if(!(o&8)){break c}L[b+56>>2]=1060320051;L[b+60>>2]=0;L[b+48>>2]=1050253722;L[b+52>>2]=1050253722;i=L[k+772>>2];if((i|0)<=0){break c}e=0;while(1){d=L[k+780>>2]+R(e,104)|0;if(J[L[d+4>>2]+16|0]&1){c=L[d+20>>2];l=P[c+12>>2];i=L[d+16>>2];m=P[i+12>>2];n=L[d+8>>2];p=P[n+12>>2];d=L[d+12>>2];r=P[d+12>>2];s=P[c+16>>2];t=P[i+16>>2];g=P[n+16>>2];q=P[d+16>>2];u=P[c+8>>2];v=P[i+8>>2];h=P[n+8>>2];w=P[d+8>>2];L[b+172>>2]=0;f=S(S(u+S(v+S(h+w)))*S(.25));y=S(f+S(S(h-f)*S(.800000011920929)));P[b+160>>2]=y;h=S(S(s+S(t+S(g+q)))*S(.25));z=S(h+S(S(g-h)*S(.800000011920929)));P[b+168>>2]=z;g=S(S(l+S(m+S(p+r)))*S(.25));p=S(g+S(S(p-g)*S(.800000011920929)));P[b+164>>2]=p;L[b+44>>2]=0;q=S(h+S(S(q-h)*S(.800000011920929)));P[b+40>>2]=q;r=S(g+S(S(r-g)*S(.800000011920929)));P[b+36>>2]=r;w=S(f+S(S(w-f)*S(.800000011920929)));P[b+32>>2]=w;L[b+28>>2]=0;t=S(h+S(S(t-h)*S(.800000011920929)));P[b+24>>2]=t;m=S(g+S(S(m-g)*S(.800000011920929)));P[b+20>>2]=m;v=S(f+S(S(v-f)*S(.800000011920929)));P[b+16>>2]=v;d=b+160|0;c=b+32|0;i=b+16|0;n=b+48|0;ha[L[L[j>>2]+28>>2]](j,d,c,i,n,S(1));L[b+172>>2]=0;P[b+168>>2]=z;P[b+164>>2]=p;P[b+160>>2]=y;L[b+44>>2]=0;P[b+40>>2]=q;P[b+36>>2]=r;P[b+32>>2]=w;L[b+28>>2]=0;h=S(h+S(S(s-h)*S(.800000011920929)));P[b+24>>2]=h;g=S(g+S(S(l-g)*S(.800000011920929)));P[b+20>>2]=g;f=S(f+S(S(u-f)*S(.800000011920929)));P[b+16>>2]=f;ha[L[L[j>>2]+28>>2]](j,d,c,i,n,S(1));L[b+172>>2]=0;P[b+168>>2]=q;P[b+164>>2]=r;P[b+160>>2]=w;L[b+44>>2]=0;P[b+40>>2]=t;P[b+36>>2]=m;P[b+32>>2]=v;L[b+28>>2]=0;P[b+24>>2]=h;P[b+20>>2]=g;P[b+16>>2]=f;ha[L[L[j>>2]+28>>2]](j,d,c,i,n,S(1));L[b+172>>2]=0;P[b+168>>2]=t;P[b+164>>2]=m;P[b+160>>2]=v;L[b+44>>2]=0;P[b+40>>2]=z;P[b+36>>2]=p;P[b+32>>2]=y;L[b+28>>2]=0;P[b+24>>2]=h;P[b+20>>2]=g;P[b+16>>2]=f;ha[L[L[j>>2]+28>>2]](j,d,c,i,n,S(1));i=L[k+772>>2]}e=e+1|0;if((i|0)>(e|0)){continue}break}}j:{if(!(o&64)){break j}if(L[k+792>>2]>0){i=0;while(1){e=L[k+800>>2]+R(i,96)|0;d=L[e+20>>2];l=P[d+52>>2];m=P[d+12>>2];p=P[d+8>>2];r=P[d+4>>2];s=P[d+56>>2];t=P[d+28>>2];q=P[d+20>>2];u=P[d+24>>2];v=P[d+60>>2];f=P[e+12>>2];w=P[d+44>>2];h=P[e+4>>2];y=P[d+36>>2];g=P[e+8>>2];z=P[d+40>>2];L[b+44>>2]=0;P[b+40>>2]=v+S(S(f*w)+S(S(h*y)+S(g*z)));P[b+36>>2]=s+S(S(f*t)+S(S(h*q)+S(g*u)));P[b+32>>2]=l+S(S(f*m)+S(S(h*r)+S(g*p)));d=L[e>>2];L[b+24>>2]=0;L[b+28>>2]=0;L[b+16>>2]=1065353216;L[b+20>>2]=0;f=P[d+8>>2];h=P[d+12>>2];g=P[d+16>>2];L[b+60>>2]=0;P[b+56>>2]=g;P[b+52>>2]=h;P[b+48>>2]=f+S(-.25);L[b+172>>2]=0;P[b+168>>2]=g+S(0);P[b+164>>2]=h+S(0);P[b+160>>2]=f+S(.25);c=b+48|0;n=b+160|0;x=b+16|0;ha[L[L[j>>2]+8>>2]](j,c,n,x);f=P[d+12>>2];h=P[d+8>>2];g=P[d+16>>2];L[b+60>>2]=0;P[b+56>>2]=g;P[b+48>>2]=h;P[b+52>>2]=f+S(-.25);L[b+172>>2]=0;P[b+168>>2]=g+S(0);P[b+164>>2]=f+S(.25);P[b+160>>2]=h+S(0);ha[L[L[j>>2]+8>>2]](j,c,n,x);f=P[d+16>>2];h=P[d+8>>2];g=P[d+12>>2];L[b+60>>2]=0;P[b+52>>2]=g;P[b+48>>2]=h;P[b+56>>2]=f+S(-.25);L[b+172>>2]=0;P[b+168>>2]=f+S(.25);P[b+164>>2]=g+S(0);P[b+160>>2]=h+S(0);ha[L[L[j>>2]+8>>2]](j,c,n,x);L[b+24>>2]=0;L[b+28>>2]=0;L[b+16>>2]=0;L[b+20>>2]=1065353216;L[b+60>>2]=0;f=P[b+40>>2];P[b+56>>2]=f;h=P[b+36>>2];P[b+52>>2]=h;g=P[b+32>>2];P[b+48>>2]=g+S(-.25);L[b+172>>2]=0;P[b+168>>2]=f+S(0);P[b+164>>2]=h+S(0);P[b+160>>2]=g+S(.25);ha[L[L[j>>2]+8>>2]](j,c,n,x);L[b+60>>2]=0;f=P[b+40>>2];P[b+56>>2]=f;h=P[b+36>>2];P[b+52>>2]=h+S(-.25);g=P[b+32>>2];P[b+48>>2]=g;L[b+172>>2]=0;P[b+168>>2]=f+S(0);P[b+164>>2]=h+S(.25);P[b+160>>2]=g+S(0);ha[L[L[j>>2]+8>>2]](j,c,n,x);L[b+60>>2]=0;f=P[b+40>>2];P[b+56>>2]=f+S(-.25);h=P[b+36>>2];P[b+52>>2]=h;g=P[b+32>>2];P[b+48>>2]=g;L[b+172>>2]=0;P[b+168>>2]=f+S(.25);P[b+164>>2]=h+S(0);P[b+160>>2]=g+S(0);ha[L[L[j>>2]+8>>2]](j,c,n,x);d=L[e>>2];L[b+56>>2]=1065353216;L[b+60>>2]=0;L[b+48>>2]=1065353216;L[b+52>>2]=1065353216;ha[L[L[j>>2]+8>>2]](j,d+8|0,b+32|0,c);i=i+1|0;if((i|0)>2]){continue}break}}i=L[k+712>>2];if((i|0)<=0){break j}d=0;while(1){c=L[k+720>>2]+R(d,104)|0;if(!(!(J[L[c+4>>2]+16|0]&1)|!(P[c+88>>2]<=S(0)))){L[b+40>>2]=0;L[b+44>>2]=0;L[b+32>>2]=1065353216;L[b+36>>2]=0;f=P[c+8>>2];h=P[c+12>>2];g=P[c+16>>2];L[b+60>>2]=0;P[b+56>>2]=g;P[b+52>>2]=h;P[b+48>>2]=f+S(-.25);L[b+172>>2]=0;P[b+168>>2]=g+S(0);P[b+164>>2]=h+S(0);P[b+160>>2]=f+S(.25);i=b+48|0;e=b+160|0;n=b+32|0;ha[L[L[j>>2]+8>>2]](j,i,e,n);f=P[c+12>>2];h=P[c+8>>2];g=P[c+16>>2];L[b+60>>2]=0;P[b+56>>2]=g;P[b+48>>2]=h;P[b+52>>2]=f+S(-.25);L[b+172>>2]=0;P[b+168>>2]=g+S(0);P[b+164>>2]=f+S(.25);P[b+160>>2]=h+S(0);ha[L[L[j>>2]+8>>2]](j,i,e,n);f=P[c+16>>2];h=P[c+8>>2];g=P[c+12>>2];L[b+60>>2]=0;P[b+52>>2]=g;P[b+48>>2]=h;P[b+56>>2]=f+S(-.25);L[b+172>>2]=0;P[b+168>>2]=f+S(.25);P[b+164>>2]=g+S(0);P[b+160>>2]=h+S(0);ha[L[L[j>>2]+8>>2]](j,i,e,n);i=L[k+712>>2]}d=d+1|0;if((i|0)>(d|0)){continue}break}}if(!(!(o&128)|L[k+692>>2]<=0)){c=0;while(1){d=L[k+700>>2]+R(c,60)|0;i=L[d+20>>2];L[b+56>>2]=L[d+16>>2];L[b+60>>2]=i;i=L[d+12>>2];L[b+48>>2]=L[d+8>>2];L[b+52>>2]=i;n=L[d+24>>2];if((n|0)>0){e=0;f=P[b+56>>2];h=P[b+52>>2];g=P[b+48>>2];while(1){x=d+(e<<2)|0;i=L[x+28>>2];m=P[i+12>>2];p=P[i+16>>2];l=P[x+44>>2];g=S(S(P[i+8>>2]*l)+g);P[b+48>>2]=g;f=S(S(l*p)+f);P[b+56>>2]=f;h=S(S(l*m)+h);P[b+52>>2]=h;e=e+1|0;if((n|0)!=(e|0)){continue}break}}ha[L[L[j>>2]+40>>2]](j,b+48|0,L[d+4>>2]);c=c+1|0;if((c|0)>2]){continue}break}}if(o&512){d=L[k+928>>2];L[b+56>>2]=1065353216;L[b+60>>2]=0;L[b+48>>2]=1065353216;L[b+52>>2]=0;L[b+168>>2]=1065353216;L[b+172>>2]=0;L[b+160>>2]=1065353216;L[b+164>>2]=1065353216;Ob(j,d,0,b+48|0,b+160|0,0,-1)}if(o&1024){d=L[k+988>>2];L[b+56>>2]=0;L[b+60>>2]=0;L[b+48>>2]=0;L[b+52>>2]=1065353216;L[b+168>>2]=0;L[b+172>>2]=0;L[b+160>>2]=1065353216;L[b+164>>2]=0;Ob(j,d,0,b+48|0,b+160|0,0,-1)}if(o&2048){d=L[k+1048>>2];L[b+56>>2]=1065353216;L[b+60>>2]=0;L[b+48>>2]=0;L[b+52>>2]=1065353216;L[b+168>>2]=0;L[b+172>>2]=0;L[b+160>>2]=1065353216;L[b+164>>2]=0;Ob(j,d,0,b+48|0,b+160|0,0,-1)}if(!(!(o&4096)|L[k+852>>2]<=0)){i=0;while(1){k:{l:{m:{d=L[L[k+860>>2]+(i<<2)>>2];switch(ha[L[L[d>>2]+20>>2]](d)|0){case 1:break l;case 0:break m;default:break k}}c=M[33872];if(!(c&1)){c=$a();e=L[c+4>>2];L[8452]=L[c>>2];L[8453]=e;e=L[c+12>>2];L[8454]=L[c+8>>2];L[8455]=e;e=L[c+20>>2];L[8456]=L[c+16>>2];L[8457]=e;e=L[c+28>>2];L[8458]=L[c+24>>2];L[8459]=e;e=L[c+36>>2];L[8460]=L[c+32>>2];L[8461]=e;e=L[c+44>>2];L[8462]=L[c+40>>2];L[8463]=e;e=L[c+56>>2];o=L[c+60>>2];n=L[c+48>>2];c=L[c+52>>2];J[33872]=1;L[8466]=e;L[8467]=o;L[8464]=n;L[8465]=c;c=1}e=L[d+12>>2];o=L[d+4>>2];e=e?e+4|0:o?o+60|0:33808;l=P[e+52>>2];m=P[e+24>>2];p=P[e+20>>2];r=P[e+16>>2];s=P[e+56>>2];t=P[e+40>>2];q=P[e+36>>2];u=P[e+32>>2];v=P[e+48>>2];w=P[e+8>>2];y=P[e>>2];z=P[e+4>>2];f=P[d+36>>2];h=P[d+32>>2];g=P[d+28>>2];L[b+44>>2]=0;P[b+32>>2]=v+S(S(f*w)+S(S(g*y)+S(h*z)));P[b+40>>2]=s+S(S(f*t)+S(S(g*u)+S(h*q)));P[b+36>>2]=l+S(S(f*m)+S(S(g*r)+S(h*p)));if(!(c&1)){c=$a();e=L[c+4>>2];L[8452]=L[c>>2];L[8453]=e;e=L[c+12>>2];L[8454]=L[c+8>>2];L[8455]=e;e=L[c+20>>2];L[8456]=L[c+16>>2];L[8457]=e;e=L[c+28>>2];L[8458]=L[c+24>>2];L[8459]=e;e=L[c+36>>2];L[8460]=L[c+32>>2];L[8461]=e;e=L[c+44>>2];L[8462]=L[c+40>>2];L[8463]=e;e=L[c+56>>2];o=L[c+60>>2];n=L[c+48>>2];c=L[c+52>>2];J[33872]=1;L[8466]=e;L[8467]=o;L[8464]=n;L[8465]=c;c=1}e=L[d+24>>2];o=L[d+16>>2];e=e?e+4|0:o?o+60|0:33808;l=P[e+52>>2];m=P[e+24>>2];p=P[e+20>>2];r=P[e+16>>2];s=P[e+56>>2];t=P[e+40>>2];q=P[e+36>>2];u=P[e+32>>2];v=P[e+48>>2];w=P[e+8>>2];y=P[e>>2];z=P[e+4>>2];f=P[d+52>>2];h=P[d+44>>2];g=P[d+48>>2];L[b+28>>2]=0;P[b+16>>2]=v+S(S(f*w)+S(S(h*y)+S(g*z)));P[b+24>>2]=s+S(S(f*t)+S(S(h*u)+S(g*q)));P[b+20>>2]=l+S(S(f*m)+S(S(h*r)+S(g*p)));if(!(c&1)){c=$a();e=L[c+4>>2];L[8452]=L[c>>2];L[8453]=e;e=L[c+12>>2];L[8454]=L[c+8>>2];L[8455]=e;e=L[c+20>>2];L[8456]=L[c+16>>2];L[8457]=e;e=L[c+28>>2];L[8458]=L[c+24>>2];L[8459]=e;e=L[c+36>>2];L[8460]=L[c+32>>2];L[8461]=e;e=L[c+44>>2];L[8462]=L[c+40>>2];L[8463]=e;e=L[c+56>>2];o=L[c+60>>2];n=L[c+48>>2];c=L[c+52>>2];J[33872]=1;L[8466]=e;L[8467]=o;L[8464]=n;L[8465]=c}c=L[d+12>>2];e=L[d+4>>2];L[b+56>>2]=0;L[b+60>>2]=0;L[b+48>>2]=1065353216;L[b+52>>2]=1065353216;ha[L[L[j>>2]+8>>2]](j,(c?c+4|0:e?e+60|0:33808)+48|0,b+32|0,b+48|0);if(!(J[33872]&1)){c=$a();e=L[c+4>>2];L[8452]=L[c>>2];L[8453]=e;e=L[c+12>>2];L[8454]=L[c+8>>2];L[8455]=e;e=L[c+20>>2];L[8456]=L[c+16>>2];L[8457]=e;e=L[c+28>>2];L[8458]=L[c+24>>2];L[8459]=e;e=L[c+36>>2];L[8460]=L[c+32>>2];L[8461]=e;e=L[c+44>>2];L[8462]=L[c+40>>2];L[8463]=e;e=L[c+56>>2];o=L[c+60>>2];n=L[c+48>>2];c=L[c+52>>2];J[33872]=1;L[8466]=e;L[8467]=o;L[8464]=n;L[8465]=c}c=L[d+24>>2];d=L[d+16>>2];L[b+56>>2]=1065353216;L[b+60>>2]=0;L[b+48>>2]=0;L[b+52>>2]=1065353216;c=(c?c+4|0:d?d+60|0:33808)+48|0;d=b+48|0;ha[L[L[j>>2]+8>>2]](j,c,b+16|0,d);L[b+8>>2]=0;L[b+12>>2]=0;L[b>>2]=1065353216;L[b+4>>2]=1065353216;L[b+60>>2]=0;f=P[b+40>>2];P[b+56>>2]=f;h=P[b+36>>2];P[b+52>>2]=h;g=P[b+32>>2];P[b+48>>2]=g+S(-.25);L[b+172>>2]=0;P[b+168>>2]=f+S(0);P[b+164>>2]=h+S(0);P[b+160>>2]=g+S(.25);c=b+160|0;ha[L[L[j>>2]+8>>2]](j,d,c,b);L[b+60>>2]=0;f=P[b+40>>2];P[b+56>>2]=f;h=P[b+36>>2];P[b+52>>2]=h+S(-.25);g=P[b+32>>2];P[b+48>>2]=g;L[b+172>>2]=0;P[b+168>>2]=f+S(0);P[b+164>>2]=h+S(.25);P[b+160>>2]=g+S(0);ha[L[L[j>>2]+8>>2]](j,d,c,b);L[b+60>>2]=0;f=P[b+40>>2];P[b+56>>2]=f+S(-.25);h=P[b+36>>2];P[b+52>>2]=h;g=P[b+32>>2];P[b+48>>2]=g;L[b+172>>2]=0;P[b+168>>2]=f+S(.25);P[b+164>>2]=h+S(0);P[b+160>>2]=g+S(0);ha[L[L[j>>2]+8>>2]](j,d,c,b);L[b+8>>2]=1065353216;L[b+12>>2]=0;L[b>>2]=0;L[b+4>>2]=1065353216;L[b+60>>2]=0;f=P[b+24>>2];P[b+56>>2]=f;h=P[b+20>>2];P[b+52>>2]=h;g=P[b+16>>2];P[b+48>>2]=g+S(-.25);L[b+172>>2]=0;P[b+168>>2]=f+S(0);P[b+164>>2]=h+S(0);P[b+160>>2]=g+S(.25);ha[L[L[j>>2]+8>>2]](j,d,c,b);L[b+60>>2]=0;f=P[b+24>>2];P[b+56>>2]=f;h=P[b+20>>2];P[b+52>>2]=h+S(-.25);g=P[b+16>>2];P[b+48>>2]=g;L[b+172>>2]=0;P[b+168>>2]=f+S(0);P[b+164>>2]=h+S(.25);P[b+160>>2]=g+S(0);ha[L[L[j>>2]+8>>2]](j,d,c,b);L[b+60>>2]=0;f=P[b+24>>2];P[b+56>>2]=f+S(-.25);h=P[b+20>>2];P[b+52>>2]=h;g=P[b+16>>2];P[b+48>>2]=g;L[b+172>>2]=0;P[b+168>>2]=f+S(.25);P[b+164>>2]=h+S(0);P[b+160>>2]=g+S(0);ha[L[L[j>>2]+8>>2]](j,d,c,b);break k}c=M[33872];if(!(c&1)){c=$a();e=L[c+4>>2];L[8452]=L[c>>2];L[8453]=e;e=L[c+12>>2];L[8454]=L[c+8>>2];L[8455]=e;e=L[c+20>>2];L[8456]=L[c+16>>2];L[8457]=e;e=L[c+28>>2];L[8458]=L[c+24>>2];L[8459]=e;e=L[c+36>>2];L[8460]=L[c+32>>2];L[8461]=e;e=L[c+44>>2];L[8462]=L[c+40>>2];L[8463]=e;e=L[c+56>>2];o=L[c+60>>2];n=L[c+48>>2];c=L[c+52>>2];J[33872]=1;L[8466]=e;L[8467]=o;L[8464]=n;L[8465]=c;c=1}e=L[d+12>>2];o=L[d+4>>2];e=e?e+4|0:o?o+60|0:33808;o=L[e+60>>2];L[b+56>>2]=L[e+56>>2];L[b+60>>2]=o;o=L[e+52>>2];L[b+48>>2]=L[e+48>>2];L[b+52>>2]=o;if(!(c&1)){c=$a();e=L[c+4>>2];L[8452]=L[c>>2];L[8453]=e;e=L[c+12>>2];L[8454]=L[c+8>>2];L[8455]=e;e=L[c+20>>2];L[8456]=L[c+16>>2];L[8457]=e;e=L[c+28>>2];L[8458]=L[c+24>>2];L[8459]=e;e=L[c+36>>2];L[8460]=L[c+32>>2];L[8461]=e;e=L[c+44>>2];L[8462]=L[c+40>>2];L[8463]=e;e=L[c+56>>2];o=L[c+60>>2];n=L[c+48>>2];c=L[c+52>>2];J[33872]=1;L[8466]=e;L[8467]=o;L[8464]=n;L[8465]=c;c=1}e=L[d+24>>2];o=L[d+16>>2];e=e?e+4|0:o?o+60|0:33808;o=L[e+60>>2];L[b+168>>2]=L[e+56>>2];L[b+172>>2]=o;o=L[e+52>>2];L[b+160>>2]=L[e+48>>2];L[b+164>>2]=o;if(!(c&1)){c=$a();e=L[c+4>>2];L[8452]=L[c>>2];L[8453]=e;e=L[c+12>>2];L[8454]=L[c+8>>2];L[8455]=e;e=L[c+20>>2];L[8456]=L[c+16>>2];L[8457]=e;e=L[c+28>>2];L[8458]=L[c+24>>2];L[8459]=e;e=L[c+36>>2];L[8460]=L[c+32>>2];L[8461]=e;e=L[c+44>>2];L[8462]=L[c+40>>2];L[8463]=e;e=L[c+56>>2];o=L[c+60>>2];n=L[c+48>>2];c=L[c+52>>2];J[33872]=1;L[8466]=e;L[8467]=o;L[8464]=n;L[8465]=c;c=1}e=L[d+12>>2];o=L[d+4>>2];e=e?e+4|0:o?o+60|0:33808;f=P[d+36>>2];h=P[d+28>>2];g=P[d+32>>2];l=S(S(P[e+8>>2]*f)+S(S(P[e>>2]*h)+S(P[e+4>>2]*g)));m=S(S(P[e+40>>2]*f)+S(S(P[e+32>>2]*h)+S(g*P[e+36>>2])));p=S(S(P[e+24>>2]*f)+S(S(P[e+16>>2]*h)+S(g*P[e+20>>2])));if(!(c&1)){c=$a();e=L[c+4>>2];L[8452]=L[c>>2];L[8453]=e;e=L[c+12>>2];L[8454]=L[c+8>>2];L[8455]=e;e=L[c+20>>2];L[8456]=L[c+16>>2];L[8457]=e;e=L[c+28>>2];L[8458]=L[c+24>>2];L[8459]=e;e=L[c+36>>2];L[8460]=L[c+32>>2];L[8461]=e;e=L[c+44>>2];L[8462]=L[c+40>>2];L[8463]=e;e=L[c+56>>2];o=L[c+60>>2];n=L[c+48>>2];c=L[c+52>>2];J[33872]=1;L[8466]=e;L[8467]=o;L[8464]=n;L[8465]=c}c=L[d+24>>2];e=L[d+16>>2];c=c?c+4|0:e?e+60|0:33808;r=P[c+8>>2];s=P[c>>2];t=P[c+4>>2];q=P[c+24>>2];u=P[c+20>>2];v=P[c+16>>2];w=P[c+40>>2];y=P[c+36>>2];z=P[c+32>>2];f=P[d+52>>2];h=P[d+48>>2];g=P[d+44>>2];L[b+44>>2]=0;m=S(m*S(10));P[b+40>>2]=m+P[b+56>>2];p=S(p*S(10));P[b+36>>2]=p+P[b+52>>2];l=S(l*S(10));P[b+32>>2]=l+P[b+48>>2];L[b+24>>2]=0;L[b+28>>2]=0;L[b+16>>2]=1065353216;L[b+20>>2]=1065353216;e=b+48|0;d=b+32|0;c=b+16|0;ha[L[L[j>>2]+8>>2]](j,e,d,c);L[b+44>>2]=0;w=S(S(S(w*f)+S(S(z*g)+S(h*y)))*S(10));P[b+40>>2]=w+P[b+56>>2];q=S(S(S(q*f)+S(S(v*g)+S(h*u)))*S(10));P[b+36>>2]=q+P[b+52>>2];f=S(S(S(r*f)+S(S(s*g)+S(t*h)))*S(10));P[b+32>>2]=f+P[b+48>>2];L[b+24>>2]=0;L[b+28>>2]=0;L[b+16>>2]=1065353216;L[b+20>>2]=1065353216;ha[L[L[j>>2]+8>>2]](j,e,d,c);L[b+44>>2]=0;P[b+40>>2]=m+P[b+168>>2];P[b+36>>2]=p+P[b+164>>2];P[b+32>>2]=l+P[b+160>>2];L[b+24>>2]=1065353216;L[b+28>>2]=0;L[b+16>>2]=0;L[b+20>>2]=1065353216;e=b+160|0;ha[L[L[j>>2]+8>>2]](j,e,d,c);L[b+44>>2]=0;P[b+40>>2]=w+P[b+168>>2];P[b+36>>2]=q+P[b+164>>2];P[b+32>>2]=f+P[b+160>>2];L[b+24>>2]=1065353216;L[b+28>>2]=0;L[b+16>>2]=0;L[b+20>>2]=1065353216;ha[L[L[j>>2]+8>>2]](j,e,d,c)}i=i+1|0;if((i|0)>2]){continue}break}}fa=b+176|0}d=L[a+72>>2];n:{if(!d){break n}if(!(ha[L[L[d>>2]+48>>2]](d)&2)){break n}if(M[a+348|0]){c=L[a+72>>2];d=fa-32|0;fa=d;i=L[k+928>>2];L[d+24>>2]=1065353216;L[d+28>>2]=0;L[d+16>>2]=1065353216;L[d+20>>2]=0;L[d+8>>2]=1065353216;L[d+12>>2]=0;L[d>>2]=1065353216;L[d+4>>2]=1065353216;Ob(c,i,0,d+16|0,d,0,-1);fa=d+32|0}if(M[a+349|0]){c=L[a+72>>2];d=fa-32|0;fa=d;i=L[k+988>>2];L[d+24>>2]=0;L[d+28>>2]=0;L[d+16>>2]=0;L[d+20>>2]=1065353216;L[d+8>>2]=0;L[d+12>>2]=0;L[d>>2]=1065353216;L[d+4>>2]=0;Ob(c,i,0,d+16|0,d,0,-1);fa=d+32|0}if(!M[a+350|0]){break n}c=L[a+72>>2];d=fa-32|0;fa=d;i=L[k+1048>>2];L[d+24>>2]=1065353216;L[d+28>>2]=0;L[d+16>>2]=0;L[d+20>>2]=1065353216;L[d+8>>2]=0;L[d+12>>2]=0;L[d>>2]=1065353216;L[d+4>>2]=0;Ob(c,i,0,d+16|0,d,0,-1);fa=d+32|0}E=E+1|0;if((E|0)>2]){continue}break}}}function XG(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=S(0),g=0,h=0,i=S(0),j=S(0),k=S(0),l=0,m=0,n=0,o=S(0),p=0,q=0,r=S(0),s=0,t=0,u=S(0),v=S(0),w=S(0),x=0,y=S(0),z=S(0),A=S(0),B=0,C=0,D=S(0),E=S(0),F=S(0),G=S(0),H=S(0),I=S(0),K=S(0),N=S(0),O=0,Q=S(0),U=0,V=S(0),W=S(0),X=S(0),Y=S(0),Z=S(0),$=S(0),aa=S(0),ba=S(0),ca=S(0),da=S(0),ea=0,ga=S(0),ia=S(0),ja=S(0),ka=S(0),la=S(0),ma=S(0),na=S(0),oa=0,pa=0,qa=S(0),ra=S(0),sa=S(0),ta=S(0),ua=S(0),va=S(0),wa=0,xa=0,ya=0;g=fa-544|0;fa=g;s=L[a+20>>2];if(!s){h=L[a+4>>2];s=ha[L[L[h>>2]+12>>2]](h,L[b+8>>2],L[c+8>>2])|0;J[a+16|0]=1;L[a+20>>2]=s}L[e+4>>2]=s;O=L[b+4>>2];C=L[c+4>>2];a:{if(!(L[O+4>>2]!=10|L[C+4>>2]!=10)){u=P[s+752>>2];a=L[b+12>>2];h=L[O+52>>2];p=h<<2;d=a+p|0;G=P[d+32>>2];b=L[c+12>>2];Z=P[b+56>>2];y=S(Z-P[a+56>>2]);N=P[d>>2];$=P[b+48>>2];H=S($-P[a+48>>2]);D=P[d+16>>2];ba=P[b+52>>2];F=S(ba-P[a+52>>2]);j=S(S(G*y)+S(S(N*H)+S(D*F)));a=b;b=L[C+52>>2];c=b<<2;a=a+c|0;r=P[a+32>>2];v=P[a>>2];Y=P[a+16>>2];o=S(-S(S(r*y)+S(S(v*H)+S(Y*F))));a=C+28|0;i=P[a+c>>2];c=O+28|0;z=P[c+p>>2];a=a+((b+2|0)%3<<2)|0;b=c+((h+2|0)%3<<2)|0;K=S(S(G*r)+S(S(N*v)+S(D*Y)));k=S(S(1)-S(K*K));b:{if(k==S(0)){break b}f=S(-z);k=S(S(S(o*K)+j)/k);if(f>k){break b}f=k;if(!(z>2];E=P[b>>2];k=S(S(f*K)+o);o=S(-i);c:{d:{if(ki){k=o;break c}if(!(i>z)){k=o;f=i;break c}i=o;break d}if(!(io){k=i;break c}if(!(o>z)){k=i;f=o;break c}}k=i;f=z}K=S(r*k);i=S(K+S(y-S(G*f)));j=S(v*k);o=S(j+S(H-S(N*f)));y=S(Y*k);k=S(y+S(F-S(D*f)));f=S(S(i*i)+S(S(o*o)+S(k*k)));H=S(_(f));z=S(S(H-E)-w);if(!(z>u)){e:{if(f<=S(14210854715202004e-30)){if(S(T(G))>S(.7071067690849304)){L[g+4>>2]=0;k=S(S(1)/S(_(S(S(D*D)+S(G*G)))));f=S(D*k);P[g+12>>2]=f;k=S(k*S(-G));P[g+8>>2]=k;i=S(0);break e}L[g+12>>2]=0;f=S(S(1)/S(_(S(S(N*N)+S(D*D)))));k=S(N*f);P[g+8>>2]=k;i=S(f*S(-D));P[g+4>>2]=i;f=S(0);break e}L[g+16>>2]=0;f=i;i=S(S(-1)/H);f=S(f*i);P[g+12>>2]=f;k=S(k*i);P[g+8>>2]=k;i=S(o*i);P[g+4>>2]=i}L[g+420>>2]=0;P[g+416>>2]=S(w*f)+S(K+Z);P[g+412>>2]=S(w*k)+S(y+ba);P[g+408>>2]=S(w*i)+S(j+$)}if(u>z){ha[L[L[e>>2]+16>>2]](e,g+4|0,g+408|0,z)}a=L[e+4>>2];if(!L[a+748>>2]){break a}c=L[a+740>>2];d=L[L[e+8>>2]+8>>2];b=(c|0)==(d|0);h=a;a=L[L[e+12>>2]+8>>2];_a(h,(b?c:a)+4|0,(b?a:d)+4|0);break a}L[g+536>>2]=1566444395;l=yg(g+328|0,O,C,L[a+8>>2],L[a+12>>2]);L[l+32>>2]=C;L[l+28>>2]=O;k=S(S(S(ha[L[L[O>>2]+48>>2]](O))+S(ha[L[L[C>>2]+48>>2]](C)))+P[L[a+20>>2]+752>>2]);P[g+536>>2]=k*k;h=L[b+12>>2];p=L[h+12>>2];L[g+416>>2]=L[h+8>>2];L[g+420>>2]=p;p=L[h+4>>2];L[g+408>>2]=L[h>>2];L[g+412>>2]=p;p=L[h+28>>2];L[g+432>>2]=L[h+24>>2];L[g+436>>2]=p;p=L[h+20>>2];L[g+424>>2]=L[h+16>>2];L[g+428>>2]=p;p=L[h+44>>2];L[g+448>>2]=L[h+40>>2];L[g+452>>2]=p;p=L[h+36>>2];L[g+440>>2]=L[h+32>>2];L[g+444>>2]=p;p=L[h+60>>2];L[g+464>>2]=L[h+56>>2];L[g+468>>2]=p;p=L[h+52>>2];L[g+456>>2]=L[h+48>>2];L[g+460>>2]=p;h=L[c+12>>2];p=L[h+12>>2];L[g+480>>2]=L[h+8>>2];L[g+484>>2]=p;p=L[h+4>>2];L[g+472>>2]=L[h>>2];L[g+476>>2]=p;s=L[h+20>>2];p=g+488|0;L[p>>2]=L[h+16>>2];L[p+4>>2]=s;s=L[h+28>>2];L[g+496>>2]=L[h+24>>2];L[g+500>>2]=s;q=L[h+36>>2];s=g+504|0;L[s>>2]=L[h+32>>2];L[s+4>>2]=q;q=L[h+44>>2];L[g+512>>2]=L[h+40>>2];L[g+516>>2]=q;n=L[h+52>>2];q=g+520|0;L[q>>2]=L[h+48>>2];L[q+4>>2]=n;n=L[h+60>>2];L[g+528>>2]=L[h+56>>2];L[g+532>>2]=n;f:{n=L[O+4>>2];if((n|0)>6){break f}h=L[C+4>>2];if((h|0)>6){break f}L[g+324>>2]=8956;k=S(0);if(n){k=S(ha[L[L[O>>2]+48>>2]](O));h=L[C+4>>2]}if(h){f=S(ha[L[L[C>>2]+48>>2]](C))}J[g+40|0]=0;P[g+32>>2]=f;P[g+28>>2]=k;L[g+8>>2]=e;L[g+4>>2]=9188;if(!L[O+52>>2]){break f}if(L[C+52>>2]){ba=P[L[a+20>>2]+752>>2];g:{h:{if(M[d+24|0]){k=S(-1.0000000150474662e30);x=L[O+52>>2];t=L[C+52>>2];q=L[b+12>>2];n=L[c+12>>2];l=fa-96|0;fa=l;L[8117]=L[8117]+1;f=P[x+72>>2];i=P[x+64>>2];w=P[x+68>>2];j=P[t+72>>2];u=P[t+64>>2];y=P[t+68>>2];Y=S(S(S(S(f*P[q+40>>2])+S(S(i*P[q+32>>2])+S(w*P[q+36>>2])))+P[q+56>>2])-S(S(S(j*P[n+40>>2])+S(S(u*P[n+32>>2])+S(y*P[n+36>>2])))+P[n+56>>2]));Z=S(S(S(S(f*P[q+24>>2])+S(S(i*P[q+16>>2])+S(w*P[q+20>>2])))+P[q+52>>2])-S(S(S(j*P[n+24>>2])+S(S(u*P[n+16>>2])+S(y*P[n+20>>2])))+P[n+52>>2]));$=S(S(S(S(f*P[q+8>>2])+S(S(i*P[q>>2])+S(w*P[q+4>>2])))+P[q+48>>2])-S(S(S(j*P[n+8>>2])+S(S(u*P[n>>2])+S(y*P[n+4>>2])))+P[n+48>>2]));i=S(34028234663852886e22);i:{j:{h=L[x+28>>2];if((h|0)>0){while(1){d=L[x+36>>2]+R(B,36)|0;w=P[d+28>>2];j=P[d+20>>2];u=P[d+24>>2];y=P[q+8>>2];H=P[q>>2];F=P[q+4>>2];E=P[q+24>>2];Q=P[q+16>>2];I=P[q+20>>2];V=P[q+40>>2];W=P[q+32>>2];aa=P[q+36>>2];L[l+12>>2]=0;f=S(S(V*w)+S(S(W*j)+S(u*aa)));P[l+8>>2]=f;r=S(S(E*w)+S(S(Q*j)+S(u*I)));P[l+4>>2]=r;v=S(S(y*w)+S(S(H*j)+S(u*F)));P[l>>2]=v;if(S(S(Y*f)+S(S($*v)+S(Z*r)))>2]=f;r=S(-r);P[l+4>>2]=r;v=S(-v);P[l>>2]=v}L[8115]=L[8115]+1;k:{if(M[27181]){w=S(S(Y*f)+S(S($*v)+S(Z*r)));j=P[x+88>>2];X=S(-j);A=j;j=S(S(V*f)+S(S(y*v)+S(E*r)));E=S((j>2];X=S(-j);A=j;j=S(S(W*f)+S(S(H*v)+S(Q*r)));A=S((j>2];j=S(E+S(A+S(j*(j>2];F=j>u?j:u;j=P[t+88>>2];X=S(-j);A=j;j=S(S(P[n+40>>2]*f)+S(S(P[n+8>>2]*v)+S(r*P[n+24>>2])));E=S((j>2];X=S(-j);A=j;j=S(S(P[n+32>>2]*f)+S(S(P[n>>2]*v)+S(r*P[n+16>>2])));A=S((j>2]*f)+S(S(P[n+4>>2]*v)+S(r*P[n+20>>2])));j=P[t+84>>2];f=S(E+S(A+S(f*(f>2];f=S(F+(f>j?f:j));j=S(w+f);f=S(f-w);if((f>j?j:f)>i){break k}}L[8116]=L[8116]+1;Cc(x,q,l,l+92|0,l+88|0,l- -64|0,l+48|0);Cc(t,n,l,l+84|0,l+80|0,l+32|0,l+16|0);f=P[l+88>>2];w=P[l+84>>2];if(f>2];u=P[l+92>>2];if(j>2];L[g+240>>2]=L[l>>2];L[g+244>>2]=d;d=L[l+12>>2];L[g+248>>2]=L[l+8>>2];L[g+252>>2]=d;i=f}B=B+1|0;if((h|0)!=(B|0)){continue}break}}h=L[t+28>>2];if((h|0)>0){B=0;while(1){d=L[t+36>>2]+R(B,36)|0;w=P[d+28>>2];j=P[d+20>>2];u=P[d+24>>2];y=P[n+8>>2];H=P[n>>2];F=P[n+4>>2];E=P[n+24>>2];Q=P[n+16>>2];I=P[n+20>>2];V=P[n+40>>2];W=P[n+32>>2];aa=P[n+36>>2];L[l+12>>2]=0;f=S(S(V*w)+S(S(W*j)+S(u*aa)));P[l+8>>2]=f;r=S(S(E*w)+S(S(Q*j)+S(u*I)));P[l+4>>2]=r;v=S(S(y*w)+S(S(H*j)+S(u*F)));P[l>>2]=v;if(S(S(Y*f)+S(S($*v)+S(Z*r)))>2]=f;r=S(-r);P[l+4>>2]=r;v=S(-v);P[l>>2]=v}L[8115]=L[8115]+1;l:{if(M[27181]){w=S(S(Y*f)+S(S($*v)+S(Z*r)));j=P[x+88>>2];X=S(-j);A=j;j=S(S(P[q+40>>2]*f)+S(S(P[q+8>>2]*v)+S(r*P[q+24>>2])));ca=S((j>2];X=S(-j);A=j;j=S(S(P[q+32>>2]*f)+S(S(P[q>>2]*v)+S(r*P[q+16>>2])));A=S((j>2]*f)+S(S(P[q+4>>2]*v)+S(r*P[q+20>>2])));u=P[x+84>>2];j=S(ca+S(A+S(j*(j>2];u=j>u?j:u;j=P[t+88>>2];X=S(-j);A=j;j=S(S(V*f)+S(S(y*v)+S(E*r)));E=S((j>2];X=S(-j);A=j;j=S(S(W*f)+S(S(H*v)+S(Q*r)));A=S((j>2];f=S(E+S(A+S(f*(f>2];f=S(u+(f>j?f:j));j=S(w+f);f=S(f-w);if((f>j?j:f)>i){break l}}L[8116]=L[8116]+1;Cc(x,q,l,l+92|0,l+88|0,l- -64|0,l+48|0);Cc(t,n,l,l+84|0,l+80|0,l+32|0,l+16|0);f=P[l+88>>2];w=P[l+84>>2];if(f>2];u=P[l+92>>2];if(j>2];L[g+240>>2]=L[l>>2];L[g+244>>2]=d;d=L[l+12>>2];L[g+248>>2]=L[l+8>>2];L[g+252>>2]=d;i=f}B=B+1|0;if((h|0)!=(B|0)){continue}break}}m=1;d=L[x+48>>2];m:{if((d|0)<=0){break m}h=0;B=L[t+48>>2];if((B|0)<=0){break m}s=-1;p=-1;while(1){if((B|0)>0){d=L[x+56>>2]+(h<<4)|0;f=P[d+8>>2];u=P[d>>2];y=P[d+4>>2];w=S(S(P[q+24>>2]*f)+S(S(P[q+16>>2]*u)+S(y*P[q+20>>2])));qa=S(-w);j=S(S(P[q+8>>2]*f)+S(S(P[q>>2]*u)+S(y*P[q+4>>2])));ra=S(-j);u=S(S(P[q+40>>2]*f)+S(S(P[q+32>>2]*u)+S(y*P[q+36>>2])));sa=S(-u);d=0;while(1){B=L[t+56>>2]+(d<<4)|0;F=P[B+8>>2];r=P[B>>2];v=P[B+4>>2];E=P[n+40>>2];Q=P[n+32>>2];I=P[n+36>>2];V=P[n+24>>2];W=P[n+16>>2];aa=P[n+20>>2];ja=P[n+8>>2];ga=P[n>>2];ia=P[n+4>>2];L[l+12>>2]=0;y=S(S(V*F)+S(S(W*r)+S(v*aa)));H=S(S(ja*F)+S(S(ga*r)+S(v*ia)));f=S(S(j*y)+S(H*qa));F=S(S(E*F)+S(S(Q*r)+S(v*I)));r=S(S(u*H)+S(F*ra));v=S(S(w*F)+S(y*sa));n:{if(!(+S(T(v))>1e-6|+S(T(r))>1e-6|+S(T(f))>1e-6)){break n}da=S(S(1)/S(_(S(S(f*f)+S(S(v*v)+S(r*r))))));f=S(f*da);P[l+8>>2]=f;r=S(r*da);P[l+4>>2]=r;v=S(v*da);P[l>>2]=v;if(S(S(Y*f)+S(S($*v)+S(Z*r)))>2]=f;r=S(-r);P[l+4>>2]=r;v=S(-v);P[l>>2]=v}L[8115]=L[8115]+1;if(M[27181]){da=S(S(Y*f)+S(S($*v)+S(Z*r)));A=P[x+88>>2];ca=S(-A);X=A;A=S(S(P[q+40>>2]*f)+S(S(P[q+8>>2]*v)+S(r*P[q+24>>2])));ka=S((A>2];ca=S(-A);X=A;A=S(S(P[q+32>>2]*f)+S(S(P[q>>2]*v)+S(r*P[q+16>>2])));X=S((A>2]*f)+S(S(P[q+4>>2]*v)+S(r*P[q+20>>2])));ca=P[x+84>>2];A=S(ka+S(X+S(A*(A>2];ka=A>ca?A:ca;A=P[t+88>>2];E=S(S(E*f)+S(S(ja*v)+S(V*r)));ca=S((E>2];X=S(-E);A=E;E=S(S(Q*f)+S(S(ga*v)+S(W*r)));f=S(S(I*f)+S(S(ia*v)+S(aa*r)));r=P[t+84>>2];f=S(ca+S(S((E>2];f=S(ka+(f>r?f:r));r=S(da+f);f=S(f-da);if((f>r?r:f)>i){break n}}L[8116]=L[8116]+1;Cc(x,q,l,l+92|0,l+88|0,l- -64|0,l+48|0);Cc(t,n,l,l+84|0,l+80|0,l+32|0,l+16|0);f=P[l+88>>2];r=P[l+84>>2];if(f>2];E=P[l+92>>2];if(v>2];ma=P[p+4>>2];p=B?l+48|0:l- -64|0;ta=P[p+8>>2];ua=P[p+4>>2];i=P[l+16>>2];o=P[l+32>>2];z=P[l+64>>2];D=P[l+48>>2];p=L[l+4>>2];L[g+240>>2]=L[l>>2];L[g+244>>2]=p;p=L[l+12>>2];L[g+248>>2]=L[l+8>>2];L[g+252>>2]=p;va=B?D:z;na=B?o:i;o=H;z=y;D=F;G=j;N=w;K=u;p=h;s=d;i=f}d=d+1|0;B=L[t+48>>2];if((d|0)<(B|0)){continue}break}d=L[x+48>>2]}h=h+1|0;if((h|0)<(d|0)){continue}break}if((p|s)<0){break m}u=S(la-ta);y=S(na-va);H=S(ma-ua);j=S(S(K*u)+S(S(G*y)+S(N*H)));f=S(0);F=S(-S(S(D*u)+S(S(o*y)+S(z*H))));w=S(S(K*D)+S(S(G*o)+S(N*z)));i=S(S(1)-S(w*w));o:{if(i==S(0)){break o}f=S(-1.0000000150474662e30);i=S(S(S(F*w)+j)/i);if(iS(1.0000000150474662e30))){break o}f=S(1.0000000150474662e30)}r=S(S(f*w)+F);p:{if(rS(1.0000000150474662e30))){r=S(-1.0000000150474662e30);f=i;break p}r=S(-1.0000000150474662e30);break p}if(!(r>S(1.0000000150474662e30))){break p}f=S(-1.0000000150474662e30);r=S(1.0000000150474662e30);i=S(S(w*S(1.0000000150474662e30))+j);if(iS(1.0000000150474662e30))){break p}f=S(1.0000000150474662e30)}L[l+76>>2]=0;D=S(D*r);i=S(D+S(u-S(K*f)));K=S(o*r);o=S(K+S(y-S(G*f)));G=S(z*r);f=S(G+S(H-S(N*f)));z=S(S(i*i)+S(S(o*o)+S(f*f)));if(!(z>S(1.1920928955078125e-7))){break m}j=i;N=S(_(z));i=S(S(1)/N);z=S(j*i);P[l+72>>2]=z;f=S(f*i);P[l+68>>2]=f;i=S(o*i);P[l+64>>2]=i;if(S(S(z*Y)+S(S(i*$)+S(Z*f)))>2]=-z;P[l+68>>2]=-f;P[l+64>>2]=-i}L[l+60>>2]=0;P[l+56>>2]=la+D;P[l+52>>2]=ma+G;P[l+48>>2]=na+K;ha[L[L[e>>2]+16>>2]](e,l- -64|0,l+48|0,S(-N))}f=P[g+248>>2];i=P[g+240>>2];o=P[g+244>>2];if(!(S(S(Y*f)+S(S($*i)+S(Z*o)))>2]=0;P[g+248>>2]=-f;P[g+244>>2]=-o;P[g+240>>2]=-i;break i}m=0}fa=l+96|0;if(m){break h}break g}wb(l,g+408|0,g+4|0,L[d+20>>2],0);d=L[g+24>>2];L[g+248>>2]=L[g+20>>2];L[g+252>>2]=d;d=L[g+16>>2];L[g+240>>2]=L[g+12>>2];L[g+244>>2]=d;if(!M[g+40|0]){break g}k=P[g+36>>2];if(!(k>2];C=L[C+52>>2];xa=L[b+12>>2];s=L[c+12>>2];c=0;x=0;O=0;l=fa-48|0;fa=l;f=P[g+248>>2];i=P[g+240>>2];o=P[g+244>>2];P[l+44>>2]=P[g+252>>2];j=f;f=S(S(1)/S(_(S(S(f*f)+S(S(i*i)+S(o*o))))));D=S(j*f);P[l+40>>2]=D;G=S(o*f);P[l+36>>2]=G;N=S(i*f);P[l+32>>2]=N;b=L[C+36>>2];h=L[C+28>>2];q:{if((h|0)<=0){q=-1;break q}K=P[s+40>>2];w=P[s+36>>2];j=P[s+24>>2];u=P[s+20>>2];y=P[s+32>>2];H=P[s+16>>2];F=P[s+8>>2];r=P[s+4>>2];v=P[s>>2];p=0;f=S(-34028234663852886e22);q=-1;while(1){d=b+R(p,36)|0;i=P[d+28>>2];o=P[d+20>>2];z=P[d+24>>2];i=S(S(S(S(K*i)+S(S(y*o)+S(z*w)))*D)+S(S(S(S(F*i)+S(S(v*o)+S(z*r)))*N)+S(S(S(j*i)+S(S(H*o)+S(z*u)))*G)));d=i>f;f=d?i:f;q=d?p:q;p=p+1|0;if((h|0)!=(p|0)){continue}break}}oa=b+R(q,36)|0;pa=L[oa+4>>2];r:{if((pa|0)<=0){d=0;b=0;break r}b=0;d=0;while(1){h=L[C+16>>2]+(L[L[oa+12>>2]+(x<<2)>>2]<<4)|0;f=P[h+8>>2];i=P[h>>2];o=P[h+4>>2];z=S(S(S(f*P[s+40>>2])+S(S(i*P[s+32>>2])+S(o*P[s+36>>2])))+P[s+56>>2]);D=S(S(S(f*P[s+24>>2])+S(S(i*P[s+16>>2])+S(o*P[s+20>>2])))+P[s+52>>2]);f=S(S(S(f*P[s+8>>2])+S(S(i*P[s>>2])+S(o*P[s+4>>2])))+P[s+48>>2]);s:{if((b|0)!=(d|0)){break s}d=b?b<<1:1;if(d>>>0<=b>>>0){d=b;break s}L[8513]=L[8513]+1;h=ha[L[6798]](d<<4,16)|0;t:{u:{if(b){m=0;p=0;if(b>>>0>=4){ya=b&2147483644;B=0;while(1){n=p<<4;U=n+h|0;t=c+n|0;ea=L[t+4>>2];L[U>>2]=L[t>>2];L[U+4>>2]=ea;ea=L[t+12>>2];L[U+8>>2]=L[t+8>>2];L[U+12>>2]=ea;t=n|16;U=t+h|0;t=c+t|0;ea=L[t+12>>2];L[U+8>>2]=L[t+8>>2];L[U+12>>2]=ea;ea=L[t+4>>2];L[U>>2]=L[t>>2];L[U+4>>2]=ea;t=n|32;U=t+h|0;t=c+t|0;ea=L[t+12>>2];L[U+8>>2]=L[t+8>>2];L[U+12>>2]=ea;ea=L[t+4>>2];L[U>>2]=L[t>>2];L[U+4>>2]=ea;n=n|48;t=n+h|0;n=c+n|0;U=L[n+12>>2];L[t+8>>2]=L[n+8>>2];L[t+12>>2]=U;U=L[n+4>>2];L[t>>2]=L[n>>2];L[t+4>>2]=U;p=p+4|0;B=B+4|0;if((ya|0)!=(B|0)){continue}break}}B=b&3;if(!B){break u}while(1){n=p<<4;t=n+h|0;n=c+n|0;U=L[n+4>>2];L[t>>2]=L[n>>2];L[t+4>>2]=U;U=L[n+12>>2];L[t+8>>2]=L[n+8>>2];L[t+12>>2]=U;p=p+1|0;m=m+1|0;if((B|0)!=(m|0)){continue}break}break u}if(!c){break t}}if(c){L[8514]=L[8514]+1;ha[L[6799]](c)}}c=h}h=(b<<4)+c|0;L[h+12>>2]=0;P[h+8>>2]=z;P[h+4>>2]=D;P[h>>2]=f;b=b+1|0;x=x+1|0;if((pa|0)!=(x|0)){continue}break}}J[l+28|0]=1;L[l+24>>2]=c;L[l+20>>2]=d;L[l+16>>2]=b;if((q|0)>=0){wl(l+32|0,wa,xa,l+12|0,S(k-ba),ba,e);O=!M[l+28|0];c=L[l+24>>2]}if(!(c?O|!c:1)){L[8514]=L[8514]+1;ha[L[6799]](c)}fa=l+48|0}if(!M[a+16|0]){break a}a=L[e+4>>2];if(!L[a+748>>2]){break a}c=L[a+740>>2];d=L[L[e+8>>2]+8>>2];b=(c|0)==(d|0);h=a;a=L[L[e+12>>2]+8>>2];_a(h,(b?c:a)+4|0,(b?a:d)+4|0);break a}if(L[C+4>>2]!=1){break f}L[g+244>>2]=0;h=L[c+12>>2];o=P[h+52>>2];z=P[h+20>>2];D=P[h+24>>2];G=P[h+56>>2];N=P[h+36>>2];K=P[h+40>>2];f=P[C- -64>>2];k=P[C+60>>2];w=P[h+16>>2];j=P[h+32>>2];u=P[h+48>>2];y=P[h+8>>2];i=P[C+56>>2];H=P[h>>2];F=P[h+4>>2];L[8513]=L[8513]+1;h=ha[L[6798]](16,16)|0;L[g+252>>2]=h;J[g+256|0]=1;L[g+248>>2]=1;L[h+12>>2]=0;P[h>>2]=u+S(S(f*y)+S(S(i*H)+S(k*F)));P[h+8>>2]=G+S(S(f*K)+S(S(i*j)+S(k*N)));P[h+4>>2]=o+S(S(f*D)+S(S(i*w)+S(k*z)));s=L[g+244>>2];h=s+1|0;L[g+244>>2]=h;f=P[C+80>>2];p=L[c+12>>2];k=P[C+72>>2];i=P[C+76>>2];o=S(S(S(f*P[p+40>>2])+S(S(k*P[p+32>>2])+S(i*P[p+36>>2])))+P[p+56>>2]);z=S(S(S(f*P[p+24>>2])+S(S(k*P[p+16>>2])+S(i*P[p+20>>2])))+P[p+52>>2]);f=S(S(S(f*P[p+8>>2])+S(S(k*P[p>>2])+S(i*P[p+4>>2])))+P[p+48>>2]);v:{if(L[g+248>>2]!=(h|0)){break v}q=h?h<<1:1;if((q|0)<=(h|0)){break v}p=0;if(q){L[8513]=L[8513]+1;p=ha[L[6798]](q<<4,16)|0}w:{if((s|0)<0){break w}h=s+1|0;B=h&1;x:{if(!s){s=0;break x}m=h&-2;s=0;h=0;while(1){x=s<<4;t=x+p|0;n=x+L[g+252>>2]|0;U=L[n+4>>2];L[t>>2]=L[n>>2];L[t+4>>2]=U;U=L[n+12>>2];L[t+8>>2]=L[n+8>>2];L[t+12>>2]=U;n=x|16;x=n+p|0;n=n+L[g+252>>2]|0;t=L[n+4>>2];L[x>>2]=L[n>>2];L[x+4>>2]=t;t=L[n+12>>2];L[x+8>>2]=L[n+8>>2];L[x+12>>2]=t;s=s+2|0;h=h+2|0;if((m|0)!=(h|0)){continue}break}}if(!B){break w}h=s<<4;s=h+p|0;h=h+L[g+252>>2]|0;n=L[h+4>>2];L[s>>2]=L[h>>2];L[s+4>>2]=n;n=L[h+12>>2];L[s+8>>2]=L[h+8>>2];L[s+12>>2]=n}h=L[g+252>>2];if(!(h?!h|!M[g+256|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](h)}L[g+252>>2]=p;J[g+256|0]=1;L[g+248>>2]=q;h=L[g+244>>2]}h=L[g+252>>2]+(h<<4)|0;L[h+12>>2]=0;P[h+8>>2]=o;P[h+4>>2]=z;P[h>>2]=f;p=L[g+244>>2];h=p+1|0;L[g+244>>2]=h;f=P[C+96>>2];c=L[c+12>>2];k=P[C+88>>2];i=P[C+92>>2];o=S(S(S(f*P[c+40>>2])+S(S(k*P[c+32>>2])+S(i*P[c+36>>2])))+P[c+56>>2]);z=S(S(S(f*P[c+24>>2])+S(S(k*P[c+16>>2])+S(i*P[c+20>>2])))+P[c+52>>2]);f=S(S(S(f*P[c+8>>2])+S(S(k*P[c>>2])+S(i*P[c+4>>2])))+P[c+48>>2]);y:{if(L[g+248>>2]!=(h|0)){break y}c=h?h<<1:1;if((c|0)<=(h|0)){break y}h=0;if(c){L[8513]=L[8513]+1;h=ha[L[6798]](c<<4,16)|0}z:{if((p|0)<0){break z}s=p+1|0;t=s&1;A:{if(!p){s=0;break A}B=s&-2;s=0;p=0;while(1){n=s<<4;x=n+h|0;q=n+L[g+252>>2]|0;m=L[q+4>>2];L[x>>2]=L[q>>2];L[x+4>>2]=m;m=L[q+12>>2];L[x+8>>2]=L[q+8>>2];L[x+12>>2]=m;q=n|16;n=q+h|0;q=q+L[g+252>>2]|0;x=L[q+4>>2];L[n>>2]=L[q>>2];L[n+4>>2]=x;x=L[q+12>>2];L[n+8>>2]=L[q+8>>2];L[n+12>>2]=x;s=s+2|0;p=p+2|0;if((B|0)!=(p|0)){continue}break}}if(!t){break z}p=s<<4;s=p+h|0;p=p+L[g+252>>2]|0;q=L[p+4>>2];L[s>>2]=L[p>>2];L[s+4>>2]=q;q=L[p+12>>2];L[s+8>>2]=L[p+8>>2];L[s+12>>2]=q}p=L[g+252>>2];if(!(p?!p|!M[g+256|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](p)}L[g+252>>2]=h;J[g+256|0]=1;L[g+248>>2]=c;h=L[g+244>>2]}c=L[g+252>>2]+(h<<4)|0;L[c+12>>2]=0;P[c+8>>2]=o;P[c+4>>2]=z;P[c>>2]=f;L[g+244>>2]=L[g+244>>2]+1;f=P[L[a+20>>2]+752>>2];wb(l,g+408|0,g+324|0,L[d+20>>2],0);k=P[l+12>>2];i=P[l+4>>2];o=P[l+8>>2];z=S(S(k*k)+S(S(i*i)+S(o*o)));if(z>S(1.1920928955078125e-7)){L[g+320>>2]=0;j=k;k=S(S(1)/z);P[g+316>>2]=j*k;P[g+312>>2]=o*k;P[g+308>>2]=i*k;k=P[l+56>>2];i=S(ha[L[L[O>>2]+48>>2]](O));o=S(ha[L[L[C>>2]+48>>2]](C));wl(g+308|0,L[O+52>>2],L[b+12>>2],g+240|0,S(S(S(k-i)-o)-f),f,e)}B:{if(!M[a+16|0]){break B}a=L[e+4>>2];if(!L[a+748>>2]){break B}c=L[a+740>>2];d=L[L[e+8>>2]+8>>2];b=(c|0)==(d|0);h=a;a=L[L[e+12>>2]+8>>2];_a(h,(b?c:a)+4|0,(b?a:d)+4|0)}a=L[g+252>>2];if(!a|!M[g+256|0]){break a}if(a){L[8514]=L[8514]+1;ha[L[6799]](a)}break a}wb(l,g+408|0,e,L[d+20>>2],0);C:{if(!L[a+28>>2]|L[L[e+4>>2]+748>>2]>=L[a+32>>2]){break C}f=P[l+12>>2];k=P[l+4>>2];i=P[l+8>>2];o=S(S(f*f)+S(S(k*k)+S(i*i)));if(!(o>S(1.1920928955078125e-7))){break C}n=g+472|0;x=g+456|0;t=g+440|0;B=g+424|0;j=i;i=S(S(1)/o);z=S(j*i);w=S(k*i);j=S(f*i);D:{if(S(T(j))>S(.7071067690849304)){k=S(S(1)/S(_(S(S(z*z)+S(j*j)))));f=S(z*k);i=S(k*S(-j));k=S(0);break D}k=S(S(1)/S(_(S(S(w*w)+S(z*z)))));i=S(w*k);f=S(0);k=S(k*S(-z))}o=S(ha[L[L[O>>2]+16>>2]](O));D=S(ha[L[L[C>>2]+16>>2]](C));O=0;G=P[6794];C=o>2];L[g+248>>2]=L[h+8>>2];L[g+252>>2]=m;m=L[h+4>>2];L[g+240>>2]=L[h>>2];L[g+244>>2]=m;h=C?B:p;m=L[h+12>>2];L[g+264>>2]=L[h+8>>2];L[g+268>>2]=m;m=L[h+4>>2];L[g+256>>2]=L[h>>2];L[g+260>>2]=m;h=C?t:s;m=L[h+12>>2];L[g+280>>2]=L[h+8>>2];L[g+284>>2]=m;m=L[h+4>>2];L[g+272>>2]=L[h>>2];L[g+276>>2]=m;h=C?x:q;m=L[h+12>>2];L[g+296>>2]=L[h+8>>2];L[g+300>>2]=m;m=L[h+4>>2];L[g+288>>2]=L[h>>2];L[g+292>>2]=m;h=L[a+28>>2];if((h|0)<=0){break C}o=S(G/(C?o:D));o=S((o>S(.39269909262657166)?S(.39269909262657166):o)*S(.5));G=Ea(o);D=Fa(o);o=S(S(f*f)+S(S(k*k)+S(i*i)));if(!(o>S(1.1920928955078125e-7))){break C}A=f;f=S(G/S(_(o)));G=S(A*f);N=S(i*f);K=S(k*f);ja=S(_(S(S(j*j)+S(S(w*w)+S(z*z)))));while(1){o=S(S(S(S(6.2831854820251465)/S(h|0))*S(O|0))*S(.5));i=S(Ea(o)/ja);f=S(j*i);k=S(z*i);i=S(w*i);o=Fa(o);E:{if(!C){h=L[b+12>>2];m=L[h+12>>2];L[g+416>>2]=L[h+8>>2];L[g+420>>2]=m;m=L[h+4>>2];L[g+408>>2]=L[h>>2];L[g+412>>2]=m;m=L[h+28>>2];L[B+8>>2]=L[h+24>>2];L[B+12>>2]=m;m=L[h+20>>2];L[B>>2]=L[h+16>>2];L[B+4>>2]=m;m=L[h+44>>2];L[t+8>>2]=L[h+40>>2];L[t+12>>2]=m;m=L[h+36>>2];L[t>>2]=L[h+32>>2];L[t+4>>2]=m;m=L[h+60>>2];L[x+8>>2]=L[h+56>>2];L[x+12>>2]=m;m=L[h+52>>2];L[x>>2]=L[h+48>>2];L[x+4>>2]=m;h=L[c+12>>2];H=P[h+36>>2];F=P[h+20>>2];r=P[h+40>>2];v=P[h+24>>2];Y=P[h+32>>2];Z=P[h>>2];$=P[h+16>>2];ba=P[h+4>>2];E=P[h+8>>2];L[g+516>>2]=0;L[g+500>>2]=0;L[g+484>>2]=0;Q=S(S(i*G)+S(S(S(o*N)-S(D*k))-S(f*K)));I=S(S(f*G)+S(S(k*N)+S(S(o*D)+S(K*i))));V=S(S(f*N)+S(S(S(o*K)-S(D*i))-S(k*G)));W=S(S(k*K)+S(S(S(o*G)-S(D*f))-S(i*N)));u=S(S(S(Q*f)+S(S(I*i)+S(o*V)))-S(W*k));y=S(S(S(S(I*o)-S(i*V))-S(Q*k))-S(W*f));aa=S(S(S(V*k)+S(S(I*f)+S(o*W)))-S(Q*i));f=S(S(S(W*i)+S(S(I*k)+S(o*Q)))-S(V*f));k=S(S(2)/S(S(y*y)+S(S(aa*aa)+S(S(u*u)+S(f*f)))));I=S(u*k);V=S(u*I);i=S(f*k);W=S(f*i);o=S(S(1)-S(V+W));k=S(aa*k);ga=S(u*k);ia=S(y*i);Q=S(ga-ia);da=S(f*k);I=S(y*I);f=S(da+I);P[g+512>>2]=S(r*o)+S(S(E*Q)+S(v*f));P[g+508>>2]=S(H*o)+S(S(ba*Q)+S(f*F));P[g+504>>2]=S(Y*o)+S(S(Z*Q)+S(f*$));f=S(da-I);o=S(u*i);u=S(y*k);i=S(o+u);y=S(aa*k);k=S(S(1)-S(V+y));P[g+496>>2]=S(r*f)+S(S(E*i)+S(v*k));P[g+492>>2]=S(H*f)+S(S(ba*i)+S(k*F));P[g+488>>2]=S(Y*f)+S(S(Z*i)+S(k*$));f=S(ga+ia);k=S(S(1)-S(W+y));i=S(o-u);P[g+480>>2]=S(r*f)+S(S(E*k)+S(v*i));P[g+476>>2]=S(H*f)+S(S(ba*k)+S(i*F));P[g+472>>2]=S(Y*f)+S(S(Z*k)+S(i*$));break E}h=L[b+12>>2];H=P[h+36>>2];F=P[h+20>>2];r=P[h+40>>2];v=P[h+24>>2];Y=P[h+32>>2];Z=P[h>>2];$=P[h+16>>2];ba=P[h+4>>2];E=P[h+8>>2];L[g+452>>2]=0;L[g+436>>2]=0;L[g+420>>2]=0;Q=S(S(i*G)+S(S(S(o*N)-S(D*k))-S(f*K)));I=S(S(f*G)+S(S(k*N)+S(S(o*D)+S(K*i))));V=S(S(f*N)+S(S(S(o*K)-S(D*i))-S(k*G)));W=S(S(k*K)+S(S(S(o*G)-S(D*f))-S(i*N)));u=S(S(S(Q*f)+S(S(I*i)+S(o*V)))-S(W*k));y=S(S(S(S(I*o)-S(i*V))-S(Q*k))-S(W*f));aa=S(S(S(V*k)+S(S(I*f)+S(o*W)))-S(Q*i));f=S(S(S(W*i)+S(S(I*k)+S(o*Q)))-S(V*f));k=S(S(2)/S(S(y*y)+S(S(aa*aa)+S(S(u*u)+S(f*f)))));I=S(u*k);V=S(u*I);i=S(f*k);W=S(f*i);o=S(S(1)-S(V+W));k=S(aa*k);ga=S(u*k);ia=S(y*i);Q=S(ga-ia);da=S(f*k);I=S(y*I);f=S(da+I);P[g+448>>2]=S(r*o)+S(S(E*Q)+S(v*f));P[g+444>>2]=S(H*o)+S(S(ba*Q)+S(f*F));P[g+440>>2]=S(Y*o)+S(S(Z*Q)+S(f*$));f=S(da-I);o=S(u*i);u=S(y*k);i=S(o+u);y=S(aa*k);k=S(S(1)-S(V+y));P[g+432>>2]=S(r*f)+S(S(E*i)+S(v*k));P[g+428>>2]=S(H*f)+S(S(ba*i)+S(k*F));P[g+424>>2]=S(Y*f)+S(S(Z*i)+S(k*$));f=S(ga+ia);k=S(S(1)-S(W+y));i=S(o-u);P[g+416>>2]=S(r*f)+S(S(E*k)+S(v*i));P[g+412>>2]=S(H*f)+S(S(ba*k)+S(i*F));P[g+408>>2]=S(Y*f)+S(S(Z*k)+S(i*$));h=L[c+12>>2];m=L[h+4>>2];L[n>>2]=L[h>>2];L[n+4>>2]=m;m=L[h+12>>2];L[n+8>>2]=L[h+8>>2];L[n+12>>2]=m;m=L[h+28>>2];L[p+8>>2]=L[h+24>>2];L[p+12>>2]=m;m=L[h+20>>2];L[p>>2]=L[h+16>>2];L[p+4>>2]=m;m=L[h+44>>2];L[s+8>>2]=L[h+40>>2];L[s+12>>2]=m;m=L[h+36>>2];L[s>>2]=L[h+32>>2];L[s+4>>2]=m;m=L[h+60>>2];L[q+8>>2]=L[h+56>>2];L[q+12>>2]=m;m=L[h+52>>2];L[q>>2]=L[h+48>>2];L[q+4>>2]=m}h=L[d+20>>2];L[g+36>>2]=e;L[g+4>>2]=9372;m=L[g+420>>2];L[g+48>>2]=L[g+416>>2];L[g+52>>2]=m;m=L[g+412>>2];L[g+40>>2]=L[g+408>>2];L[g+44>>2]=m;m=L[B+12>>2];L[g+64>>2]=L[B+8>>2];L[g+68>>2]=m;m=L[B+4>>2];L[g+56>>2]=L[B>>2];L[g+60>>2]=m;m=L[t+12>>2];L[g+80>>2]=L[t+8>>2];L[g+84>>2]=m;m=L[t+4>>2];L[g+72>>2]=L[t>>2];L[g+76>>2]=m;m=L[x+12>>2];L[g+96>>2]=L[x+8>>2];L[g+100>>2]=m;m=L[x+4>>2];L[g+88>>2]=L[x>>2];L[g+92>>2]=m;m=L[n+12>>2];L[g+112>>2]=L[n+8>>2];L[g+116>>2]=m;m=L[n+4>>2];L[g+104>>2]=L[n>>2];L[g+108>>2]=m;m=L[p+12>>2];L[g+128>>2]=L[p+8>>2];L[g+132>>2]=m;m=L[p+4>>2];L[g+120>>2]=L[p>>2];L[g+124>>2]=m;m=L[s+12>>2];L[g+144>>2]=L[s+8>>2];L[g+148>>2]=m;m=L[s+4>>2];L[g+136>>2]=L[s>>2];L[g+140>>2]=m;m=L[q+12>>2];L[g+160>>2]=L[q+8>>2];L[g+164>>2]=m;m=L[q+4>>2];L[g+152>>2]=L[q>>2];L[g+156>>2]=m;m=L[g+252>>2];L[g+176>>2]=L[g+248>>2];L[g+180>>2]=m;m=L[g+244>>2];L[g+168>>2]=L[g+240>>2];L[g+172>>2]=m;m=L[g+268>>2];L[g+192>>2]=L[g+264>>2];L[g+196>>2]=m;m=L[g+260>>2];L[g+184>>2]=L[g+256>>2];L[g+188>>2]=m;m=L[g+284>>2];L[g+208>>2]=L[g+280>>2];L[g+212>>2]=m;m=L[g+276>>2];L[g+200>>2]=L[g+272>>2];L[g+204>>2]=m;m=L[g+292>>2];L[g+216>>2]=L[g+288>>2];L[g+220>>2]=m;m=L[g+300>>2];L[g+224>>2]=L[g+296>>2];L[g+228>>2]=m;L[g+236>>2]=h;J[g+232|0]=C;wb(l,g+408|0,g+4|0,h,0);h=L[a+28>>2];O=O+1|0;if((h|0)>(O|0)){continue}break}}if(!M[a+16|0]){break a}a=L[e+4>>2];if(!L[a+748>>2]){break a}c=L[a+740>>2];d=L[L[e+8>>2]+8>>2];b=(c|0)==(d|0);h=a;a=L[L[e+12>>2]+8>>2];_a(h,(b?c:a)+4|0,(b?a:d)+4|0)}fa=g+544|0}function ak(a,b,c){var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=S(0),m=S(0),n=0,o=0,p=S(0),q=0,r=S(0),s=S(0),t=S(0),u=S(0),v=S(0),w=0,x=0,y=S(0),z=S(0),A=S(0),B=0,C=0,D=0,E=0,F=0,G=S(0),H=S(0),I=S(0),K=S(0),N=S(0),O=0,Q=S(0),U=S(0),V=S(0),W=S(0),X=0,Y=0,Z=S(0),$=0,aa=S(0),ba=S(0),ca=0,da=S(0),ea=S(0),ga=S(0),ia=S(0),ja=S(0),ka=S(0);w=fa+-64|0;fa=w;L[w+52>>2]=0;X=1;J[w+56|0]=1;L[w+44>>2]=0;L[w+48>>2]=0;L[w+32>>2]=0;L[w+36>>2]=0;L[w+24>>2]=0;L[w+28>>2]=0;F=L[b+4>>2];d=F>>>0<=8?8:F;if((d|0)>=0){L[8513]=L[8513]+1;o=ha[L[6798]](d<<4,16)|0;F=L[b+4>>2]}k=a;g=L[b+8>>2];q=L[b+12>>2];l=P[b+16>>2];a:{if(!F){break a}d=L[k+24>>2];if((d|0)<0){a=L[k+32>>2];if(L[k+28>>2]<0){if(!(a?!a|!M[k+36|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](a)}J[k+36|0]=1;L[k+28>>2]=0;L[k+32>>2]=0;a=0}j=a;a=d<<2;pa(j+a|0,0,0-a|0)}L[k+24>>2]=0;L[w+4>>2]=0;L[w+16>>2]=1065353216;L[w+8>>2]=1065353216;L[w+12>>2]=1065353216;m=S(-34028234663852886e22);u=S(34028234663852886e22);v=S(34028234663852886e22);y=S(34028234663852886e22);r=S(-34028234663852886e22);s=S(-34028234663852886e22);a=g;while(1){p=P[a+8>>2];m=m>2];r=p>r?p:r;v=p>2];s=p>s?p:s;y=p>>0<3|vS(9.999999974752427e-7)?vS(9.999999974752427e-7)?l>m?m:l:l;l=p>S(9.999999974752427e-7)?l>p?p:l:l;d:{if(l==S(34028234663852886e22)){break d}y=S(l*S(.05000000074505806));s=m>2]=p;P[w+12>>2]=m;P[w+8>>2]=v;s=S(S(1)/p);r=S(u*s);y=t;t=S(S(1)/m);u=S(y*t);m=A;A=S(S(1)/v);v=S(m*A);while(1){p=S(s*P[g+8>>2]);y=S(t*P[g+4>>2]);m=S(A*P[g>>2]);a=0;d=0;e:{f:{g:{j=L[w+4>>2];if(!j){break g}while(1){h:{d=(a<<4)+o|0;z=P[d>>2];if(!(l>S(T(S(z-m))))){break h}H=P[d+4>>2];if(!(l>S(T(S(H-y))))){break h}I=P[d+8>>2];if(!(l>S(T(S(I-p))))){break h}G=S(p-r);K=S(G*G);G=S(m-v);U=S(G*G);G=S(y-u);I=S(I-r);z=S(z-v);Z=S(z*z);z=S(H-u);if(S(K+S(U+S(G*G)))>S(S(I*I)+S(Z+S(z*z)))){P[d+8>>2]=p;P[d+4>>2]=y;P[d>>2]=m}d=a;break g}a=a+1|0;if((j|0)!=(a|0)){continue}break}d=j;break f}if((d|0)!=(j|0)){break e}}a=(j<<4)+o|0;P[a+8>>2]=p;P[a+4>>2]=y;P[a>>2]=m;L[w+4>>2]=j+1}j=L[k+24>>2];i:{if((j|0)!=L[k+28>>2]){break i}C=j?j<<1:1;if((C|0)<=(j|0)){break i}j:{if(!C){h=0;break j}L[8513]=L[8513]+1;h=ha[L[6798]](C<<2,16)|0;j=L[k+24>>2]}e=L[k+32>>2];k:{l:{if((j|0)>0){x=0;a=0;if(j>>>0>=4){D=j&-4;B=0;while(1){n=a<<2;L[n+h>>2]=L[e+n>>2];O=n|4;L[O+h>>2]=L[e+O>>2];O=n|8;L[O+h>>2]=L[e+O>>2];n=n|12;L[n+h>>2]=L[e+n>>2];a=a+4|0;B=B+4|0;if((D|0)!=(B|0)){continue}break}}j=j&3;if(!j){break l}while(1){n=a<<2;L[n+h>>2]=L[e+n>>2];a=a+1|0;x=x+1|0;if((j|0)!=(x|0)){continue}break}break l}if(!e){break k}}if(e?M[k+36|0]:0){L[8514]=L[8514]+1;ha[L[6799]](e)}j=L[k+24>>2]}L[k+32>>2]=h;J[k+36|0]=1;L[k+28>>2]=C}g=g+q|0;L[L[k+32>>2]+(j<<2)>>2]=d;L[k+24>>2]=L[k+24>>2]+1;f=f+1|0;if((F|0)!=(f|0)){continue}break}y=S(-34028234663852886e22);p=S(34028234663852886e22);d=L[w+4>>2];m:{if(!d){u=S(34028234663852886e22);v=S(34028234663852886e22);m=S(-34028234663852886e22);r=S(-34028234663852886e22);break m}a=0;u=S(34028234663852886e22);v=S(34028234663852886e22);m=S(-34028234663852886e22);r=S(-34028234663852886e22);while(1){g=(a<<4)+o|0;l=P[g+8>>2];y=l>y?l:y;p=l>2];m=l>m?l:m;u=l>2];r=l>r?l:r;v=l>>0>=3){break a}}s=S(S(y*S(.5))+p);t=S(S(m*S(.5))+u);A=S(S(l*S(.5))+v);r=S(.009999999776482582);v=S(.009999999776482582);p=S(.009999999776482582);u=l>=S(9.999999974752427e-7)?l=S(9.999999974752427e-7)?m=S(9.999999974752427e-7)?u>y?y:u:u;n:{if(u==S(34028234663852886e22)){break n}p=S(u*S(.05000000074505806));v=m>2]=m;P[o+96>>2]=y;P[o+80>>2]=y;P[o+64>>2]=m;P[o+48>>2]=m;P[o+32>>2]=y;P[o+16>>2]=y;P[o+8>>2]=p;P[o+4>>2]=v;P[o>>2]=m;P[o+120>>2]=l;P[o+116>>2]=u;P[o+104>>2]=l;P[o+100>>2]=u;P[o+88>>2]=l;P[o+84>>2]=v;P[o+72>>2]=l;P[o+68>>2]=v;P[o+56>>2]=p;P[o+52>>2]=u;P[o+40>>2]=p;P[o+36>>2]=u;P[o+24>>2]=p;P[o+20>>2]=v;L[w+4>>2]=8}o:{if(!F){break o}C=L[w+4>>2];p:{if(!C){break p}d=0;p=P[w+16>>2];y=P[w+12>>2];m=P[w+8>>2];if((C|0)!=1){g=C&-2;while(1){f=d<<4;a=f+o|0;P[a>>2]=m*P[a>>2];P[a+4>>2]=y*P[a+4>>2];P[a+8>>2]=p*P[a+8>>2];a=(f|16)+o|0;P[a>>2]=m*P[a>>2];P[a+4>>2]=y*P[a+4>>2];P[a+8>>2]=p*P[a+8>>2];d=d+2|0;i=i+2|0;if((g|0)!=(i|0)){continue}break}}if(!(C&1)){break p}a=(d<<4)+o|0;P[a>>2]=m*P[a>>2];P[a+4>>2]=y*P[a+4>>2];P[a+8>>2]=p*P[a+8>>2]}$=L[b+20>>2];e=0;f=0;g=0;F=0;n=k;h=fa+-64|0;fa=h;k=C;q:{if((k|0)<4){break q}m=P[o+8>>2];v=P[o+4>>2];r=P[o>>2];L[8513]=L[8513]+1;a=k<<2;x=ha[L[6798]](a,16)|0;L[h+48>>2]=0;L[8513]=L[8513]+1;e=ha[L[6798]](a,16)|0;L[h+56>>2]=e;J[h+60|0]=1;L[h+52>>2]=k;p=m;y=v;u=r;d=k;while(1){q=L[h+48>>2];r:{if((q|0)!=L[h+52>>2]){break r}O=q?q<<1:1;if((O|0)<=(q|0)){break r}if(O){L[8513]=L[8513]+1;j=ha[L[6798]](O<<2,16)|0}else{j=0}s:{t:{if((q|0)>0){B=0;a=0;if(q>>>0>=4){ca=q&-4;i=0;while(1){D=a<<2;L[D+j>>2]=L[e+D>>2];Y=D|4;L[Y+j>>2]=L[e+Y>>2];Y=D|8;L[Y+j>>2]=L[e+Y>>2];D=D|12;L[D+j>>2]=L[e+D>>2];a=a+4|0;i=i+4|0;if((ca|0)!=(i|0)){continue}break}}i=q&3;if(!i){break t}while(1){q=a<<2;L[q+j>>2]=L[e+q>>2];a=a+1|0;B=B+1|0;if((i|0)!=(B|0)){continue}break}break t}if(!e){break s}}if(e){L[8514]=L[8514]+1;ha[L[6799]](e)}q=L[h+48>>2]}L[h+52>>2]=O;e=j}L[(q<<2)+e>>2]=1;L[h+48>>2]=L[h+48>>2]+1;u:{if((d|0)!=(f|0)){break u}d=f?f<<1:1;if(f>>>0>=d>>>0){d=f;break u}L[8513]=L[8513]+1;j=ha[L[6798]](d<<2,16)|0;v:{w:{if(f){B=0;a=0;if(f>>>0>=4){D=f&2147483644;i=0;while(1){q=a<<2;L[q+j>>2]=L[q+x>>2];O=q|4;L[O+j>>2]=L[x+O>>2];O=q|8;L[O+j>>2]=L[x+O>>2];q=q|12;L[q+j>>2]=L[q+x>>2];a=a+4|0;i=i+4|0;if((D|0)!=(i|0)){continue}break}}i=f&3;if(!i){break w}while(1){q=a<<2;L[q+j>>2]=L[q+x>>2];a=a+1|0;B=B+1|0;if((i|0)!=(B|0)){continue}break}break w}if(x){break w}d=1;break v}if(x){L[8514]=L[8514]+1;ha[L[6799]](x)}}x=j}L[(f<<2)+x>>2]=0;a=(f<<4)+o|0;l=P[a+8>>2];p=l>p?l:p;s=P[a+4>>2];y=s>y?s:y;t=P[a>>2];u=ut?t:r;f=f+1|0;if((k|0)!=(f|0)){continue}break}J[h+60|0]=1;L[h+56>>2]=e;a=fa+-64|0;fa=a;L[a+24>>2]=1065353216;L[a+28>>2]=0;L[a+16>>2]=1008981770;L[a+20>>2]=1017370378;q=h+44|0;j=Nb(o,k,a+16|0,q);L[a+12>>2]=0;P[a+8>>2]=-P[a+24>>2];P[a+4>>2]=-P[a+20>>2];P[a>>2]=-P[a+16>>2];i=Nb(o,k,a,q);f=(j<<4)+o|0;t=P[f>>2];B=(i<<4)+o|0;A=P[B>>2];s=P[f+4>>2];z=P[B+4>>2];l=P[f+8>>2];H=P[B+8>>2];L[a+28>>2]=0;l=S(l-H);P[a+24>>2]=l;s=S(s-z);P[a+20>>2]=s;t=S(t-A);P[a+16>>2]=t;x:{y:{if((i|0)!=(j|0)){if(l!=S(0)|s!=S(0)|t!=S(0)){break y}}L[h+28>>2]=-1;L[h+32>>2]=-1;L[h+36>>2]=-1;L[h+40>>2]=-1;break x}L[a+60>>2]=0;L[a+44>>2]=0;A=S(S(s*S(-.019999999552965164))-t);P[a+56>>2]=A;I=S(t*S(0));G=S(l*S(.019999999552965164));z=S(I+G);P[a+52>>2]=z;N=S(s*S(-0));H=S(l+N);P[a+48>>2]=H;d=a+48|0;e=a+32|0;z=S(_(S(S(A*A)+S(S(H*H)+S(z*z)))));s=S(s+S(t*S(-.019999999552965164)));t=S(G+N);l=S(I-l);A=S(_(S(S(s*s)+S(S(t*t)+S(l*l)))));z:{if(z>2];L[e>>2]=L[d>>2];L[e+4>>2]=D;D=L[d+12>>2];L[e+8>>2]=L[d+8>>2];L[e+12>>2]=D;l=P[a+40>>2];A=P[a+32>>2];z=P[a+36>>2];t=S(S(1)/S(_(S(S(l*l)+S(S(A*A)+S(z*z))))));s=S(l*t);l=S(z*t);t=S(A*t)}P[a+40>>2]=s;P[a+36>>2]=l;P[a+32>>2]=t;e=Nb(o,k,e,q);if(!((j|0)!=(e|0)&(e|0)!=(i|0))){L[a+12>>2]=0;P[a+8>>2]=-P[a+40>>2];P[a+4>>2]=-P[a+36>>2];P[a>>2]=-P[a+32>>2];e=Nb(o,k,a,q)}if(!((e|0)!=(j|0)&(e|0)!=(i|0))){L[h+28>>2]=-1;L[h+32>>2]=-1;L[h+36>>2]=-1;L[h+40>>2]=-1;break x}D=(e<<4)+o|0;H=P[D+4>>2];t=P[D+8>>2];l=P[D>>2];I=P[f+4>>2];A=P[f+8>>2];s=P[f>>2];L[a+44>>2]=0;L[a+60>>2]=0;l=S(l-s);P[a+32>>2]=l;s=P[a+24>>2];t=S(t-A);P[a+40>>2]=t;A=P[a+16>>2];z=P[a+20>>2];H=S(H-I);P[a+36>>2]=H;I=S(S(l*z)-S(A*H));z=S(S(H*s)-S(z*t));s=S(S(t*A)-S(s*l));l=S(S(1)/S(_(S(S(I*I)+S(S(z*z)+S(s*s))))));P[a+56>>2]=I*l;P[a+52>>2]=s*l;P[a+48>>2]=z*l;d=Nb(o,k,d,q);if(!(!((e|0)==(d|0)|(d|0)==(j|0))&(d|0)!=(i|0))){L[a+12>>2]=0;P[a+8>>2]=-P[a+56>>2];P[a+4>>2]=-P[a+52>>2];P[a>>2]=-P[a+48>>2];d=Nb(o,k,a,q)}if(!(!((d|0)==(e|0)|(d|0)==(j|0))&(d|0)!=(i|0))){L[h+28>>2]=-1;L[h+32>>2]=-1;L[h+36>>2]=-1;L[h+40>>2]=-1;break x}q=(d<<4)+o|0;A=P[q+8>>2];z=P[q>>2];H=P[q+4>>2];I=P[B+4>>2];G=P[D+4>>2];l=P[f+4>>2];N=P[B+8>>2];Q=P[D>>2];V=P[D+8>>2];s=P[f+8>>2];W=P[B>>2];t=P[f>>2];L[h+32>>2]=i;L[h+28>>2]=j;K=S(A-s);A=S(W-t);G=S(G-l);Q=S(Q-t);I=S(I-l);z=S(z-t);t=S(V-s);s=S(N-s);f=S(S(K*S(S(A*G)-S(Q*I)))+S(S(z*S(S(I*t)-S(G*s)))+S(S(H-l)*S(S(s*Q)-S(t*A)))))>2]=f?e:d;L[h+36>>2]=f?d:e}fa=a- -64|0;a=L[h+28>>2];A:{if((a|0)==-1){e=0;break A}d=L[h+40>>2];e=(d<<4)+o|0;I=P[e>>2];f=L[h+36>>2];i=(f<<4)+o|0;G=P[i>>2];j=L[h+32>>2];q=(j<<4)+o|0;N=P[q>>2];B=(a<<4)+o|0;Q=P[B>>2];V=P[e+4>>2];W=P[i+4>>2];da=P[q+4>>2];ea=P[B+4>>2];ga=P[e+8>>2];ia=P[i+8>>2];ja=P[q+8>>2];ka=P[B+8>>2];e=bc(n,f,d,j);L[e+12>>2]=2;L[e+16>>2]=3;L[e+20>>2]=1;e=bc(n,d,f,a);L[e+12>>2]=3;L[e+16>>2]=2;L[e+20>>2]=0;e=bc(n,a,j,d);L[e+12>>2]=0;L[e+16>>2]=1;L[e+20>>2]=3;e=bc(n,j,a,f);L[e+12>>2]=1;L[e+16>>2]=0;L[e+20>>2]=2;L[(d<<2)+x>>2]=1;L[(f<<2)+x>>2]=1;L[(j<<2)+x>>2]=1;L[(a<<2)+x>>2]=1;if(L[n+4>>2]>0){e=0;while(1){l=S(0);s=S(1);t=S(0);a=L[L[n+12>>2]+(e<<2)>>2];d=(L[a+4>>2]<<4)+o|0;A=P[d>>2];f=(L[a>>2]<<4)+o|0;H=S(A-P[f>>2]);j=(L[a+8>>2]<<4)+o|0;z=P[d+4>>2];K=S(P[j+4>>2]-z);aa=S(P[j>>2]-A);z=S(z-P[f+4>>2]);A=S(S(H*K)-S(aa*z));U=z;z=P[d+8>>2];ba=S(P[j+8>>2]-z);Z=K;K=S(z-P[f+8>>2]);z=S(S(U*ba)-S(Z*K));H=S(S(K*aa)-S(ba*H));K=S(_(S(S(A*A)+S(S(z*z)+S(H*H)))));if(K!=S(0)){s=S(S(1)/K);t=S(A*s);l=S(H*s);s=S(z*s)}L[h+24>>2]=0;P[h+20>>2]=t;P[h+16>>2]=l;P[h+12>>2]=s;d=Nb(o,k,h+12|0,h+44|0);L[a+28>>2]=d;j=a;d=(d<<4)+o|0;a=(L[a>>2]<<4)+o|0;P[j+32>>2]=S(P[h+20>>2]*S(P[d+8>>2]-P[a+8>>2]))+S(S(P[h+12>>2]*S(P[d>>2]-P[a>>2]))+S(S(P[d+4>>2]-P[a+4>>2])*P[h+16>>2]));e=e+1|0;if((e|0)>2]){continue}break}}e=1;a=$?$-4|0:999999996;if((a|0)<=0){break A}A=S(S(S(S(ka+ja)+ia)+ga)*S(.25));z=S(S(S(S(ea+da)+W)+V)*S(.25));H=S(S(S(S(Q+N)+G)+I)*S(.25));p=S(p-m);m=S(p*p);p=S(u-r);r=S(p*p);p=S(y-v);p=S(S(_(S(m+S(r+S(p*p)))))*S(.0010000000474974513));y=S(p*S(.009999999776482582));I=S(S(p*p)*S(.10000000149011612));while(1){j=a;d=L[n+4>>2];q=d&1;i=L[n+12>>2];a=0;e=0;if((d|0)!=1){B=d&2147483646;f=0;while(1){D=e<<2;d=L[D+i>>2];if(!(!d|!(P[a+32>>2]>2])?a:0)){a=d}d=L[i+(D|4)>>2];if(!(!d|!(P[a+32>>2]>2])?a:0)){a=d}e=e+2|0;f=f+2|0;if((B|0)!=(f|0)){continue}break}}B:{if(!q){break B}d=L[i+(e<<2)>>2];if(!d|!(P[a+32>>2]>2])?a:0){break B}a=d}e=1;if(!(p>2])|!a){break A}d=L[a+28>>2];L[(d<<2)+x>>2]=1;e=L[n+4>>2];C:{if(!e){break C}f=(d<<4)+o|0;while(1){e=e-1|0;a=L[L[n+12>>2]+(e<<2)>>2];D:{if(!a){break D}l=S(0);s=S(1);t=S(0);i=(L[a+4>>2]<<4)+o|0;m=P[i>>2];q=(L[a>>2]<<4)+o|0;u=P[q>>2];v=S(m-u);B=(L[a+8>>2]<<4)+o|0;r=P[i+4>>2];G=S(P[B+4>>2]-r);N=S(P[B>>2]-m);Q=P[q+4>>2];r=S(r-Q);m=S(S(v*G)-S(N*r));K=r;r=P[i+8>>2];V=S(P[B+8>>2]-r);U=G;G=P[q+8>>2];W=S(r-G);r=S(S(K*V)-S(U*W));v=S(S(W*N)-S(V*v));N=S(_(S(S(m*m)+S(S(r*r)+S(v*v)))));if(N!=S(0)){t=m;m=S(S(1)/N);t=S(t*m);s=S(r*m);l=S(v*m)}if(!(y>2]-G))+S(S(s*S(P[f>>2]-u))+S(l*S(P[f+4>>2]-Q)))))){break D}bk(n,a,d)}if(e){continue}break}e=L[n+4>>2];a=e;if(!a){break C}while(1){E:{D=L[n+12>>2];a=a-1|0;f=L[D+(a<<2)>>2];F:{if(!f){break F}i=L[f+8>>2];B=L[f>>2];q=L[f+4>>2];if(!((B|0)==(d|0)|(q|0)==(d|0))&(d|0)!=(i|0)){break E}l=S(0);s=S(1);t=S(0);q=(q<<4)+o|0;m=P[q>>2];B=(B<<4)+o|0;G=P[B>>2];v=S(m-G);i=(i<<4)+o|0;r=P[q+4>>2];u=S(P[i+4>>2]-r);N=S(P[i>>2]-m);Q=P[B+4>>2];r=S(r-Q);m=S(S(v*u)-S(N*r));K=r;r=P[q+8>>2];V=S(P[i+8>>2]-r);U=u;W=P[B+8>>2];u=S(r-W);r=S(S(K*V)-S(U*u));v=S(S(u*N)-S(V*v));u=S(_(S(S(m*m)+S(S(r*r)+S(v*v)))));if(u!=S(0)){t=m;m=S(S(1)/u);t=S(t*m);s=S(r*m);l=S(v*m)}if(!(y>2]<<2)>>2],d);e=L[n+4>>2];a=e}if(a){continue}}break}if(!e){break C}while(1){e=e-1|0;a=L[L[n+12>>2]+(e<<2)>>2];G:{if(!a){break G}if(L[a+28>>2]>=0){break C}l=S(0);s=S(1);t=S(0);d=(L[a+4>>2]<<4)+o|0;m=P[d>>2];f=(L[a>>2]<<4)+o|0;v=S(m-P[f>>2]);i=(L[a+8>>2]<<4)+o|0;r=P[d+4>>2];u=S(P[i+4>>2]-r);G=S(P[i>>2]-m);r=S(r-P[f+4>>2]);m=S(S(v*u)-S(G*r));K=r;r=P[d+8>>2];N=S(P[i+8>>2]-r);U=u;u=S(r-P[f+8>>2]);r=S(S(K*N)-S(U*u));v=S(S(u*G)-S(N*v));u=S(_(S(S(m*m)+S(S(r*r)+S(v*v)))));if(u!=S(0)){t=m;m=S(S(1)/u);t=S(t*m);s=S(r*m);l=S(v*m)}L[h+24>>2]=0;P[h+20>>2]=t;P[h+16>>2]=l;P[h+12>>2]=s;d=Nb(o,k,h+12|0,h+44|0);L[a+28>>2]=d;if(L[(d<<2)+x>>2]){L[a+28>>2]=-1;break G}f=a;d=(d<<4)+o|0;a=(L[a>>2]<<4)+o|0;P[f+32>>2]=S(P[h+20>>2]*S(P[d+8>>2]-P[a+8>>2]))+S(S(P[h+12>>2]*S(P[d>>2]-P[a>>2]))+S(S(P[d+4>>2]-P[a+4>>2])*P[h+16>>2]))}if(e){continue}break}}a=j-1|0;e=1;if((j|0)>1){continue}break}}a=L[h+56>>2];if(!(a?!a|!M[h+60|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](a)}if(!x){break q}if(x){L[8514]=L[8514]+1;ha[L[6799]](x)}}fa=h- -64|0;a=0;H:{if(!e){break H}k=L[n+4>>2];I:{if((k|0)<=0){f=0;break I}f=0;while(1){x=F<<2;i=L[x+L[n+12>>2]>>2];if(i){J:{K:{if((g|0)!=(E|0)){break K}j=g?g<<1:1;if((g|0)>=(j|0)){break K}if(j){L[8513]=L[8513]+1;k=ha[L[6798]](j<<2,16)|0}else{k=0}L:{if((g|0)>0){e=g&3;h=0;d=0;if(g>>>0>=4){q=g&-4;g=0;while(1){a=d<<2;L[a+k>>2]=L[a+f>>2];B=a|4;L[B+k>>2]=L[f+B>>2];B=a|8;L[B+k>>2]=L[f+B>>2];a=a|12;L[a+k>>2]=L[a+f>>2];d=d+4|0;g=g+4|0;if((q|0)!=(g|0)){continue}break}}if(!e){break L}while(1){a=d<<2;L[a+k>>2]=L[a+f>>2];d=d+1|0;h=h+1|0;if((e|0)!=(h|0)){continue}break}break L}if(!f){break J}}if(f){L[8514]=L[8514]+1;ha[L[6799]](f)}break J}j=g;k=f}L[(E<<2)+k>>2]=L[i>>2];i=L[x+L[n+12>>2]>>2];M:{N:{q=E+1|0;if((q|0)!=(j|0)){break N}a=j?j<<1:1;if((j|0)>=(a|0)){break N}if(a){L[8513]=L[8513]+1;d=ha[L[6798]](a<<2,16)|0}else{d=0}O:{if((j|0)<=0){break O}h=0;f=0;if(j>>>0>=4){B=j&-4;g=0;while(1){e=f<<2;L[e+d>>2]=L[e+k>>2];D=e|4;L[D+d>>2]=L[k+D>>2];D=e|8;L[D+d>>2]=L[k+D>>2];e=e|12;L[e+d>>2]=L[e+k>>2];f=f+4|0;g=g+4|0;if((B|0)!=(g|0)){continue}break}}g=j&3;if(!g){break O}while(1){j=f<<2;L[j+d>>2]=L[k+j>>2];f=f+1|0;h=h+1|0;if((g|0)!=(h|0)){continue}break}}if(k){L[8514]=L[8514]+1;ha[L[6799]](k)}break M}a=j;d=k}L[(q<<2)+d>>2]=L[i+4>>2];i=L[x+L[n+12>>2]>>2];P:{Q:{q=E+2|0;if((q|0)!=(a|0)){break Q}g=a?a<<1:1;if((g|0)<=(a|0)){break Q}if(g){L[8513]=L[8513]+1;f=ha[L[6798]](g<<2,16)|0}else{f=0}R:{if((a|0)<=0){break R}h=0;k=0;if(a>>>0>=4){B=a&-4;j=0;while(1){e=k<<2;L[e+f>>2]=L[d+e>>2];D=e|4;L[D+f>>2]=L[d+D>>2];D=e|8;L[D+f>>2]=L[d+D>>2];e=e|12;L[e+f>>2]=L[d+e>>2];k=k+4|0;j=j+4|0;if((B|0)!=(j|0)){continue}break}}a=a&3;if(!a){break R}while(1){j=k<<2;L[j+f>>2]=L[d+j>>2];k=k+1|0;h=h+1|0;if((a|0)!=(h|0)){continue}break}}if(d){L[8514]=L[8514]+1;ha[L[6799]](d)}break P}g=a;f=d}L[(q<<2)+f>>2]=L[i+8>>2];d=L[n+12>>2];a=L[d+x>>2];L[(L[a+24>>2]<<2)+d>>2]=0;if(a){L[8514]=L[8514]+1;ha[L[6799]](a)}E=E+3|0;k=L[n+4>>2]}F=F+1|0;if((F|0)<(k|0)){continue}break}}L[w+60>>2]=(E|0)/3;e=L[w+44>>2];if((e|0)<(E|0)){S:{if(L[w+48>>2]>=(E|0)){d=L[w+52>>2];break S}T:{if(!E){d=0;a=e;break T}L[8513]=L[8513]+1;d=ha[L[6798]](E<<2,16)|0;a=L[w+44>>2]}x=L[w+52>>2];U:{V:{if((a|0)>0){g=0;k=0;if(a>>>0>=4){i=a&-4;j=0;while(1){h=k<<2;L[h+d>>2]=L[h+x>>2];F=h|4;L[F+d>>2]=L[x+F>>2];F=h|8;L[F+d>>2]=L[x+F>>2];h=h|12;L[h+d>>2]=L[h+x>>2];k=k+4|0;j=j+4|0;if((i|0)!=(j|0)){continue}break}}a=a&3;if(!a){break V}while(1){j=k<<2;L[j+d>>2]=L[j+x>>2];k=k+1|0;g=g+1|0;if((a|0)!=(g|0)){continue}break}break V}if(x){break V}break U}if(x?M[w+56|0]:0){L[8514]=L[8514]+1;ha[L[6799]](x)}}L[w+52>>2]=d;J[w+56|0]=1;L[w+48>>2]=E}pa((e<<2)+d|0,0,E-e<<2)}L[w+44>>2]=E;W:{if((E|0)<=0){break W}g=E&3;a=L[w+52>>2];h=0;k=0;if(E>>>0>=4){j=E&-4;E=0;while(1){d=k<<2;L[d+a>>2]=L[d+f>>2];e=d|4;L[e+a>>2]=L[e+f>>2];e=d|8;L[e+a>>2]=L[e+f>>2];d=d|12;L[d+a>>2]=L[d+f>>2];k=k+4|0;E=E+4|0;if((j|0)!=(E|0)){continue}break}}if(!g){break W}while(1){d=k<<2;L[d+a>>2]=L[d+f>>2];k=k+1|0;h=h+1|0;if((g|0)!=(h|0)){continue}break}}a=L[n+4>>2];X:{if((a|0)>=0){break X}if(L[n+8>>2]<0){d=L[n+12>>2];if(!(d?!d|!M[n+16|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](d)}J[n+16|0]=1;L[n+8>>2]=0;L[n+12>>2]=0}d=0;k=a;g=0-a&3;if(g){while(1){L[L[n+12>>2]+(k<<2)>>2]=0;k=k+1|0;d=d+1|0;if((g|0)!=(d|0)){continue}break}}if(a>>>0>4294967292){break X}while(1){a=k<<2;L[a+L[n+12>>2]>>2]=0;L[(a+L[n+12>>2]|0)+4>>2]=0;L[(a+L[n+12>>2]|0)+8>>2]=0;L[(a+L[n+12>>2]|0)+12>>2]=0;k=k+4|0;if(k){continue}break}}L[n+4>>2]=0;if(f){L[8514]=L[8514]+1;ha[L[6799]](f)}a=1}if(!a){break o}L[w+36>>2]=o;x=L[w+60>>2];L[w+32>>2]=x;E=R(x,3);L[w+28>>2]=E;L[w+24>>2]=C;if((C|0)<=0){j=0}else{L[8513]=L[8513]+1;j=ha[L[6798]](C<<4,16)|0}k=L[w+52>>2];d=0;a=L[n+24>>2];Y:{if((a|0)<=0){i=0;break Y}L[8513]=L[8513]+1;a=a<<2;i=ha[L[6798]](a,16)|0;a=pa(i,0,a);if(L[n+24>>2]<=0){break Y}g=L[n+32>>2];while(1){f=d<<2;L[f+a>>2]=L[f+g>>2];d=d+1|0;if((d|0)>2]){continue}break}}d=C<<2;Z:{_:{$:{if((C|0)>0){L[8513]=L[8513]+1;a=ha[L[6798]](d,16)|0;d=pa(a,0,d);L[w+4>>2]=0;if((E|0)>0){break $}if(d){break _}break Z}a=0;L[w+4>>2]=pa(0,0,d);if((E|0)<=0){break Z}}F=0;while(1){d=k+(F<<2)|0;g=L[d>>2];C=(g<<2)+a|0;f=L[C>>2];aa:{if(f){L[d>>2]=f-1;break aa}L[d>>2]=L[w+4>>2];d=L[w+4>>2];f=j+(d<<4)|0;e=(g<<4)+o|0;P[f>>2]=P[e>>2];P[f+4>>2]=P[e+4>>2];P[f+8>>2]=P[e+8>>2];h=L[n+24>>2];if((h|0)>0){f=L[n+32>>2];d=0;while(1){e=d<<2;if((g|0)==L[e+i>>2]){L[e+f>>2]=L[w+4>>2];h=L[n+24>>2]}d=d+1|0;if((h|0)>(d|0)){continue}break}d=L[w+4>>2]}d=d+1|0;L[w+4>>2]=d;L[C>>2]=d}F=F+1|0;if((E|0)!=(F|0)){continue}break}}if(a){L[8514]=L[8514]+1;ha[L[6799]](a)}}if(i){L[8514]=L[8514]+1;ha[L[6799]](i)}ba:{ca:{da:{ea:{if(J[b|0]&1){J[c|0]=0;C=L[w+4>>2];L[c+4>>2]=C;d=L[c+12>>2];if(!((C|0)<=(d|0)|(C|0)<=L[c+16>>2])){fa:{if(!C){i=0;break fa}L[8513]=L[8513]+1;i=ha[L[6798]](C<<4,16)|0;d=L[c+12>>2]}ga:{if((d|0)<=0){break ga}g=0;if((d|0)!=1){h=d&-2;a=0;while(1){n=g<<4;f=n+i|0;e=n+L[c+20>>2]|0;F=L[e+4>>2];L[f>>2]=L[e>>2];L[f+4>>2]=F;F=L[e+12>>2];L[f+8>>2]=L[e+8>>2];L[f+12>>2]=F;e=n|16;f=e+i|0;e=e+L[c+20>>2]|0;n=L[e+4>>2];L[f>>2]=L[e>>2];L[f+4>>2]=n;n=L[e+12>>2];L[f+8>>2]=L[e+8>>2];L[f+12>>2]=n;g=g+2|0;a=a+2|0;if((h|0)!=(a|0)){continue}break}}if(!(d&1)){break ga}d=g<<4;a=d+i|0;d=d+L[c+20>>2]|0;g=L[d+4>>2];L[a>>2]=L[d>>2];L[a+4>>2]=g;g=L[d+12>>2];L[a+8>>2]=L[d+8>>2];L[a+12>>2]=g}a=L[c+20>>2];if(!(a?!a|!M[c+24|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](a)}L[c+20>>2]=i;J[c+24|0]=1;L[c+16>>2]=C}L[c+32>>2]=E;L[c+28>>2]=x;L[c+12>>2]=C;e=L[c+40>>2];if((e|0)>=(E|0)){break ca}if((E|0)<=L[c+44>>2]){d=L[c+48>>2];break da}ha:{if(!x){d=0;a=e;break ha}L[8513]=L[8513]+1;d=ha[L[6798]](R(x,12),16)|0;a=L[c+40>>2]}n=L[c+48>>2];if((a|0)>0){h=0;g=0;if(a>>>0>=4){F=a&-4;f=0;while(1){i=g<<2;L[i+d>>2]=L[i+n>>2];q=i|4;L[q+d>>2]=L[n+q>>2];q=i|8;L[q+d>>2]=L[n+q>>2];i=i|12;L[i+d>>2]=L[i+n>>2];g=g+4|0;f=f+4|0;if((F|0)!=(f|0)){continue}break}}a=a&3;if(!a){break ea}while(1){f=g<<2;L[f+d>>2]=L[f+n>>2];g=g+1|0;h=h+1|0;if((a|0)!=(h|0)){continue}break}break ea}if(n){break ea}L[c+48>>2]=d;L[c+44>>2]=E;J[c+52|0]=1;break da}J[c|0]=1;n=L[w+4>>2];L[c+4>>2]=n;d=L[c+12>>2];if(!((n|0)<=(d|0)|(n|0)<=L[c+16>>2])){ia:{if(!n){i=0;break ia}L[8513]=L[8513]+1;i=ha[L[6798]](n<<4,16)|0;d=L[c+12>>2]}ja:{if((d|0)<=0){break ja}g=0;if((d|0)!=1){h=d&-2;a=0;while(1){C=g<<4;f=C+i|0;e=C+L[c+20>>2]|0;E=L[e+4>>2];L[f>>2]=L[e>>2];L[f+4>>2]=E;E=L[e+12>>2];L[f+8>>2]=L[e+8>>2];L[f+12>>2]=E;e=C|16;f=e+i|0;e=e+L[c+20>>2]|0;C=L[e+4>>2];L[f>>2]=L[e>>2];L[f+4>>2]=C;C=L[e+12>>2];L[f+8>>2]=L[e+8>>2];L[f+12>>2]=C;g=g+2|0;a=a+2|0;if((h|0)!=(a|0)){continue}break}}if(!(d&1)){break ja}d=g<<4;a=d+i|0;d=d+L[c+20>>2]|0;g=L[d+4>>2];L[a>>2]=L[d>>2];L[a+4>>2]=g;g=L[d+12>>2];L[a+8>>2]=L[d+8>>2];L[a+12>>2]=g}a=L[c+20>>2];if(!(a?!a|!M[c+24|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](a)}L[c+20>>2]=i;J[c+24|0]=1;L[c+16>>2]=n}L[c+28>>2]=x;L[c+12>>2]=n;C=x<<2;L[c+32>>2]=C;f=L[c+40>>2];if((f|0)<(C|0)){ka:{if((C|0)<=L[c+44>>2]){d=L[c+48>>2];break ka}la:{if(!C){d=0;a=f;break la}L[8513]=L[8513]+1;d=ha[L[6798]](x<<4,16)|0;a=L[c+40>>2]}e=L[c+48>>2];ma:{if((a|0)>0){h=0;g=0;if(a>>>0>=4){E=a&-4;X=0;while(1){i=g<<2;L[i+d>>2]=L[e+i>>2];F=i|4;L[F+d>>2]=L[e+F>>2];F=i|8;L[F+d>>2]=L[e+F>>2];i=i|12;L[i+d>>2]=L[e+i>>2];g=g+4|0;X=X+4|0;if((E|0)!=(X|0)){continue}break}}a=a&3;if(!a){break ma}while(1){i=g<<2;L[i+d>>2]=L[e+i>>2];g=g+1|0;h=h+1|0;if((a|0)!=(h|0)){continue}break}break ma}if(e){break ma}L[c+48>>2]=d;L[c+44>>2]=C;J[c+52|0]=1;break ka}if(e?M[c+52|0]:0){L[8514]=L[8514]+1;ha[L[6799]](e)}L[c+48>>2]=d;J[c+52|0]=1;L[c+44>>2]=C}pa((f<<2)+d|0,0,C-f<<2)}L[c+40>>2]=C;qa(L[c+20>>2],j,n<<4);if(!x){break ba}g=L[c+48>>2];i=0;d=k;while(1){L[g>>2]=3;na:{if(M[b|0]&2){L[g+4>>2]=L[d+8>>2];L[g+8>>2]=L[d+4>>2];a=d;break na}L[g+4>>2]=L[d>>2];L[g+8>>2]=L[d+4>>2];a=d+8|0}L[g+12>>2]=L[a>>2];d=d+12|0;g=g+16|0;i=i+1|0;if((x|0)!=(i|0)){continue}break}break ba}if(n?M[c+52|0]:0){L[8514]=L[8514]+1;ha[L[6799]](n)}L[c+48>>2]=d;J[c+52|0]=1;L[c+44>>2]=E}a=e<<2;pa(a+d|0,0,R(x,12)-a|0)}L[c+40>>2]=E;qa(L[c+20>>2],j,C<<4);if(M[b|0]&2){if(!x){break ba}a=x&3;g=L[c+48>>2];oa:{if(x>>>0<4){d=k;break oa}b=x&-4;i=0;d=k;while(1){L[g>>2]=L[d+8>>2];L[g+4>>2]=L[d+4>>2];L[g+8>>2]=L[d>>2];L[g+12>>2]=L[d+20>>2];L[g+16>>2]=L[d+16>>2];L[g+20>>2]=L[d+12>>2];L[g+24>>2]=L[d+32>>2];L[g+28>>2]=L[d+28>>2];L[g+32>>2]=L[d+24>>2];L[g+36>>2]=L[d+44>>2];L[g+40>>2]=L[d+40>>2];L[g+44>>2]=L[d+36>>2];d=d+48|0;g=g+48|0;i=i+4|0;if((b|0)!=(i|0)){continue}break}}if(!a){break ba}i=0;while(1){L[g>>2]=L[d+8>>2];L[g+4>>2]=L[d+4>>2];L[g+8>>2]=L[d>>2];d=d+12|0;g=g+12|0;i=i+1|0;if((a|0)!=(i|0)){continue}break}break ba}qa(L[c+48>>2],k,R(x,12))}if(L[w+44>>2]){if(!(k?!k|!M[w+56|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](k)}L[w+52>>2]=0;J[w+56|0]=1}X=0;if(!j){break o}if(j){L[8514]=L[8514]+1;ha[L[6799]](j)}}if(o){L[8514]=L[8514]+1;ha[L[6799]](o)}a=L[w+52>>2];if(!(a?!a|!M[w+56|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](a)}fa=w- -64|0;return X}function Zm(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=0,g=S(0),h=S(0),i=S(0),j=S(0),k=S(0),l=0,m=S(0),n=S(0),o=0,p=S(0),q=S(0),r=S(0),s=S(0),t=0,u=0,v=S(0),w=S(0),x=0,y=S(0),z=S(0),A=S(0),B=S(0),C=0,D=0,E=S(0),F=S(0),G=0,H=S(0),I=S(0),J=S(0),K=S(0),M=S(0),N=S(0),O=S(0),Q=S(0),U=S(0),V=S(0),W=0,X=0,Y=S(0),Z=S(0),$=S(0),aa=S(0),ba=S(0),ca=S(0),da=S(0),ea=S(0),ga=0,ia=S(0),ja=S(0),ka=S(0),la=S(0),ma=S(0),na=S(0),oa=0,pa=0,ra=S(0),sa=0,ta=0,ua=0,va=S(0);d=fa-160|0;fa=d;P[d+112>>2]=P[b>>2];P[d+64>>2]=P[b+64>>2];P[d+116>>2]=P[b+4>>2];P[d+68>>2]=P[b+68>>2];P[d+120>>2]=P[b+8>>2];P[d+72>>2]=P[b+72>>2];P[d+128>>2]=P[b+16>>2];P[d+80>>2]=P[b+80>>2];P[d+132>>2]=P[b+20>>2];P[d+84>>2]=P[b+84>>2];P[d+136>>2]=P[b+24>>2];P[d+88>>2]=P[b+88>>2];P[d+144>>2]=P[b+32>>2];P[d+96>>2]=P[b+96>>2];P[d+148>>2]=P[b+36>>2];P[d+100>>2]=P[b+100>>2];P[d+152>>2]=P[b+40>>2];P[d+104>>2]=P[b+104>>2];e=L[a+4>>2];j=P[e+36>>2];i=P[e+32>>2];n=P[e+28>>2];g=S(ha[L[L[e>>2]+48>>2]](e));h=S(ha[L[L[e>>2]+48>>2]](e));k=S(ha[L[L[e>>2]+48>>2]](e));L[d+36>>2]=0;i=S(i+h);P[d+28>>2]=i+i;i=S(n+g);P[d+24>>2]=i+i;j=S(j+k);P[d+32>>2]=j+j;a=L[a+8>>2];j=P[a+36>>2];i=P[a+32>>2];n=P[a+28>>2];g=S(ha[L[L[a>>2]+48>>2]](a));h=S(ha[L[L[a>>2]+48>>2]](a));k=S(ha[L[L[a>>2]+48>>2]](a));L[d+20>>2]=0;i=S(i+h);P[d+12>>2]=i+i;i=S(n+g);P[d+8>>2]=i+i;j=S(j+k);P[d+16>>2]=j+j;W=c;f=fa-368|0;fa=f;a=d+112|0;J=P[a+36>>2];U=P[a+4>>2];F=P[a+20>>2];s=P[a+40>>2];ea=P[a+8>>2];K=P[a+24>>2];G=b+48|0;n=P[G+8>>2];c=b+112|0;g=P[c+8>>2];q=P[G>>2];r=P[c>>2];H=P[G+4>>2];A=P[c+4>>2];j=P[a+32>>2];ra=P[a>>2];i=P[a+16>>2];h=S(P[d+24>>2]*S(.5));P[f+356>>2]=h;k=S(P[d+28>>2]*S(.5));P[f+360>>2]=k;m=S(P[d+32>>2]*S(.5));P[f+364>>2]=m;v=S(P[d+8>>2]*S(.5));P[f+344>>2]=v;y=S(P[d+12>>2]*S(.5));P[f+348>>2]=y;p=S(P[d+16>>2]*S(.5));P[f+352>>2]=p;n=S(g-n);g=S(r-q);q=S(A-H);r=S(S(j*n)+S(S(ra*g)+S(i*q)));b=d- -64|0;Y=P[b+40>>2];Z=P[b+8>>2];M=P[b+24>>2];H=S(S(j*Y)+S(S(ra*Z)+S(i*M)));ia=S(T(H));V=P[b+36>>2];I=P[b+4>>2];$=P[b+20>>2];A=S(S(j*V)+S(S(ra*I)+S(i*$)));ja=S(T(A));aa=P[b+32>>2];ba=P[b>>2];ca=P[b+16>>2];B=S(S(j*aa)+S(S(ra*ba)+S(i*ca)));va=S(T(B));i=S(S(T(r))-S(S(p*ia)+S(S(y*ja)+S(S(v*va)+h))));a:{if(i>S(0)){break a}w=S(S(J*Y)+S(S(U*Z)+S(F*M)));ka=S(T(w));N=S(S(J*V)+S(S(U*I)+S(F*$)));O=S(T(N));Q=S(S(J*aa)+S(S(U*ba)+S(F*ca)));la=S(T(Q));j=S(-34028234663852886e22);if(i>S(-34028234663852886e22)){l=rS(0)){break a}F=S(S(s*Y)+S(S(ea*Z)+S(K*M)));ma=S(T(F));E=S(S(s*V)+S(S(ea*I)+S(K*$)));na=S(T(E));z=S(S(s*aa)+S(S(ea*ba)+S(K*ca)));da=S(T(z));if(jS(0)){break a}if(jS(0)){break a}if(jS(0)){break a}if(jS(0)){break a}if(jS(1.1920928955078125e-7)){break a}K=S(na+S(9999999747378752e-21));Y=S(O+S(9999999747378752e-21));Z=S(va+S(9999999747378752e-21));O=S(-J);q=S(0);la=S(Q*Q);na=S(S(z*z)+S(0));M=S(_(S(la+na)));b:{if(!(M>S(1.1920928955078125e-7))){g=S(0);n=S(0);break b}g=S(0);i=S(i/M);n=S(0);if(!(S(i*S(1.0499999523162842))>j)){break b}l=VS(1.1920928955078125e-7)){break a}M=S(ma+S(9999999747378752e-21));V=S(ka+S(9999999747378752e-21));ka=S(N*N);ma=S(S(E*E)+S(0));I=S(_(S(ka+ma)));c:{if(!(I>S(1.1920928955078125e-7))){break c}i=S(i/I);if(!(S(i*S(1.0499999523162842))>j)){break c}l=daS(1.1920928955078125e-7)){break a}da=S(w*w);ia=S(S(F*F)+S(0));I=S(_(S(da+ia)));d:{if(!(I>S(1.1920928955078125e-7))){break d}i=S(i/I);if(!(S(i*S(1.0499999523162842))>j)){break d}l=OS(1.1920928955078125e-7)){break a}I=S(-s);ja=S(B*B);s=S(_(S(ja+na)));e:{if(!(s>S(1.1920928955078125e-7))){break e}i=S(i/s);if(!(S(i*S(1.0499999523162842))>j)){break e}l=OS(1.1920928955078125e-7)){break a}O=S(A*A);z=S(_(S(O+ma)));f:{if(!(z>S(1.1920928955078125e-7))){break f}i=S(i/z);if(!(S(i*S(1.0499999523162842))>j)){break f}l=sS(1.1920928955078125e-7)){break a}s=S(H*H);E=S(_(S(s+ia)));g:{if(!(E>S(1.1920928955078125e-7))){break g}i=S(i/E);if(!(S(i*S(1.0499999523162842))>j)){break g}l=zS(1.1920928955078125e-7)){break a}F=S(-r);r=S(_(S(S(la+ja)+S(0))));h:{if(!(r>S(1.1920928955078125e-7))){break h}i=S(i/r);if(!(S(i*S(1.0499999523162842))>j)){break h}l=ES(1.1920928955078125e-7)){break a}p=S(_(S(S(ka+O)+S(0))));i:{if(!(p>S(1.1920928955078125e-7))){break i}i=S(i/p);if(!(S(i*S(1.0499999523162842))>j)){break i}l=rS(1.1920928955078125e-7)){break a}j:{k:{l:{m:{p=S(_(S(S(da+s)+S(0))));if(!(p>S(1.1920928955078125e-7))){break m}i=S(i/p);if(!(S(i*S(1.0499999523162842))>j)){break m}l=r>2]=p;r=S(S(P[a+24>>2]*g)+S(S(P[a+16>>2]*q)+S(n*P[a+20>>2])));P[d+52>>2]=r;j=S(S(P[a+40>>2]*g)+S(S(P[a+32>>2]*q)+S(n*P[a+36>>2])));break j}p=P[u>>2];P[d+48>>2]=p;r=P[u+16>>2];P[d+52>>2]=r;i=j;j=P[u+32>>2]}P[d+56>>2]=j;if(l){P[d+56>>2]=-j;P[d+52>>2]=-r;P[d+48>>2]=-p}P[d+44>>2]=-i;if(C>>>0>=7){L[f+120>>2]=L[G+8>>2];e=L[G+4>>2];L[f+112>>2]=L[G>>2];L[f+116>>2]=e;j=P[d+56>>2];q=P[a+40>>2];n=P[d+48>>2];p=P[a+8>>2];g=P[d+52>>2];r=P[a+24>>2];m=S(S(j*q)+S(S(n*p)+S(g*r)))>S(0)?m:S(-m);s=S(m*q);q=P[a+36>>2];H=P[a+4>>2];A=P[a+20>>2];k=S(S(j*q)+S(S(n*H)+S(g*A)))>S(0)?k:S(-k);z=S(k*q);q=P[a+32>>2];B=P[a>>2];w=P[a+16>>2];h=S(S(j*q)+S(S(n*B)+S(g*w)))>S(0)?h:S(-h);P[f+120>>2]=s+S(z+S(S(h*q)+P[f+120>>2]));P[f+112>>2]=S(m*p)+S(S(k*H)+S(S(h*B)+P[f+112>>2]));P[f+116>>2]=S(m*r)+S(S(k*A)+S(S(h*w)+P[f+116>>2]));L[f+216>>2]=L[c+8>>2];e=L[c+4>>2];L[f+208>>2]=L[c>>2];L[f+212>>2]=e;h=P[f+352>>2];k=P[b+40>>2];m=P[b+8>>2];q=P[b+24>>2];h=S(S(j*k)+S(S(n*m)+S(g*q)))>S(0)?S(-h):h;B=S(h*k);w=S(-y);s=y;y=P[b+36>>2];p=P[b+4>>2];r=P[b+20>>2];k=S(S(j*y)+S(S(n*p)+S(g*r)))>S(0)?w:s;z=S(-v);s=v;v=P[b+32>>2];w=n;n=P[b>>2];A=g;g=P[b+16>>2];j=S(S(j*v)+S(S(w*n)+S(A*g)))>S(0)?z:s;v=S(B+S(S(k*y)+S(S(j*v)+P[f+216>>2])));P[f+216>>2]=v;m=S(S(h*m)+S(S(k*p)+S(S(j*n)+P[f+208>>2])));P[f+208>>2]=m;g=S(S(h*q)+S(S(k*r)+S(S(j*g)+P[f+212>>2])));P[f+212>>2]=g;c=C-7&255;a=((c>>>0)/3<<2)+a|0;P[f+288>>2]=P[a>>2];P[f+292>>2]=P[a+16>>2];P[f+296>>2]=P[a+32>>2];a=b+((c>>>0)%3<<2)|0;h=P[a>>2];P[f+80>>2]=h;k=P[a+16>>2];P[f+84>>2]=k;y=P[a+32>>2];P[f+88>>2]=y;a=f+208|0;b=f- -64|0;n=S(0);q=P[f+296>>2];p=P[f+88>>2];r=P[f+288>>2];H=P[f+80>>2];A=P[f+292>>2];B=P[f+84>>2];j=S(S(q*p)+S(S(r*H)+S(A*B)));w=S(S(1)-S(j*j));if(w<=S(9999999747378752e-20)){j=S(0)}else{w=S(S(1)/w);n=S(P[a+8>>2]-P[f+120>>2]);s=S(q*n);q=S(P[a>>2]-P[f+112>>2]);z=S(r*q);r=S(P[a+4>>2]-P[f+116>>2]);A=S(s+S(z+S(A*r)));q=S(S(p*n)+S(S(H*q)+S(B*r)));n=S(w*S(S(j*A)-q));j=S(w*S(A-S(j*q)))}P[f+328>>2]=j;P[b>>2]=n;j=P[f+64>>2];P[f+216>>2]=S(y*j)+v;P[f+212>>2]=S(k*j)+g;P[f+208>>2]=S(h*j)+m;j=P[d+48>>2];n=P[d+52>>2];g=P[d+56>>2];L[f+44>>2]=0;P[f+40>>2]=-g;P[f+36>>2]=-n;P[f+32>>2]=-j;ha[L[L[W>>2]+16>>2]](W,f+32|0,a,i);L[d+40>>2]=C;break a}j=P[d+48>>2];n:{if(C>>>0<=3){n=P[d+56>>2];u=f+356|0;e=c;c=b;o=f+344|0;i=P[d+52>>2];break n}j=S(-j);n=S(-P[d+56>>2]);u=f+344|0;e=G;G=c;c=a;a=b;o=f+356|0;i=S(-P[d+52>>2])}h=S(S(P[c+32>>2]*n)+S(S(P[c>>2]*j)+S(i*P[c+16>>2])));P[f+328>>2]=h;k=S(S(P[c+36>>2]*n)+S(S(P[c+4>>2]*j)+S(i*P[c+20>>2])));P[f+332>>2]=k;g=S(S(P[c+40>>2]*n)+S(S(P[c+8>>2]*j)+S(i*P[c+24>>2])));P[f+336>>2]=g;g=S(T(g));k=S(T(k));h=S(T(h));o:{if(k>h){l=g>2];g=P[b+(f+328|0)>>2]>2])+S(P[e+8>>2]-P[G+8>>2]));y=S(S(g*P[b+16>>2])+S(P[e+4>>2]-P[G+4>>2]));q=S(S(g*P[b>>2])+S(P[e>>2]-P[G>>2]));sa=l?2:1;b=1;e=2;p:{q:{r:{ta=(C>>>0<4?-1:-4)+C|0;switch(ta|0){case 0:break p;case 1:break r;default:break q}}b=0;break p}e=1;b=0}l=b<<2;b=l+a|0;g=P[b+32>>2];h=P[b>>2];k=P[b+16>>2];b=e<<2;a=b+a|0;m=P[a+32>>2];p=P[a>>2];r=P[a+16>>2];H=S(S(v*m)+S(S(q*p)+S(y*r)));a=X<<2;oa=a+c|0;B=P[oa+32>>2];w=P[oa>>2];N=P[oa+16>>2];A=S(S(m*B)+S(S(p*w)+S(r*N)));Q=P[a+o>>2];J=S(A*Q);F=S(H+J);a=sa<<2;ga=a+c|0;E=P[ga+32>>2];z=P[ga>>2];s=P[ga+16>>2];p=S(S(m*E)+S(S(p*z)+S(r*s)));U=P[a+o>>2];m=S(p*U);P[f+316>>2]=F-m;r=S(S(v*g)+S(S(q*h)+S(y*k)));B=S(S(g*B)+S(S(h*w)+S(k*N)));N=S(Q*B);Q=S(r+N);w=S(S(g*E)+S(S(h*z)+S(k*s)));g=S(U*w);P[f+312>>2]=Q-g;P[f+308>>2]=F+m;P[f+304>>2]=Q+g;h=S(H-J);P[f+300>>2]=h+m;k=S(r-N);P[f+296>>2]=k+g;P[f+292>>2]=h-m;P[f+288>>2]=k-g;P[f+280>>2]=P[l+u>>2];P[f+284>>2]=P[b+u>>2];e=f+208|0;l=0;t=fa+-64|0;fa=t;g=P[f+280>>2];m=P[f+288>>2];h=S(-m);if(g>h){P[e>>2]=m;P[e+4>>2]=P[f+292>>2];g=P[f+280>>2];m=P[f+288>>2];h=S(-m);l=1;b=e+8|0}else{b=e}a=g>h;h=P[f+296>>2];k=S(-h);if((a|0)!=(k>2];P[b+4>>2]=S(S(S(P[f+300>>2]-k)/S(h-m))*S(S(-g)-m))+k;P[b>>2]=-P[f+280>>2];l=l+1|0;g=P[f+280>>2];h=P[f+296>>2];k=S(-h);b=b+8|0}if(g>k){P[b>>2]=h;P[b+4>>2]=P[f+300>>2];l=l+1|0;g=P[f+280>>2];h=P[f+296>>2];k=S(-h);b=b+8|0}a=g>k;k=P[f+304>>2];m=S(-k);if((a|0)!=(m>2];P[b+4>>2]=S(S(S(P[f+308>>2]-m)/S(k-h))*S(S(-g)-h))+m;P[b>>2]=-P[f+280>>2];l=l+1|0;g=P[f+280>>2];k=P[f+304>>2];m=S(-k);b=b+8|0}if(g>m){P[b>>2]=k;P[b+4>>2]=P[f+308>>2];l=l+1|0;g=P[f+280>>2];k=P[f+304>>2];m=S(-k);b=b+8|0}a=g>m;h=P[f+312>>2];m=S(-h);if((a|0)!=(m>2];P[b+4>>2]=S(S(S(P[f+316>>2]-m)/S(h-k))*S(S(-g)-k))+m;P[b>>2]=-P[f+280>>2];l=l+1|0;g=P[f+280>>2];h=P[f+312>>2];m=S(-h);b=b+8|0}if(g>m){P[b>>2]=h;P[b+4>>2]=P[f+316>>2];l=l+1|0;g=P[f+280>>2];h=P[f+312>>2];m=S(-h);b=b+8|0}s:{t:{u:{k=P[f+288>>2];if((S(-k)m|0)){m=P[f+316>>2];P[b+4>>2]=S(S(S(P[f+292>>2]-m)/S(k-h))*S(S(-g)-h))+m;P[b>>2]=-P[f+280>>2];b=8;l=l+1|0;if(l&8){break s}break u}if(l){break u}b=0;break t}g=P[f+280>>2];h=P[e>>2];v:{if(!(g>h)){b=0;a=t;break v}P[t>>2]=h;P[t+4>>2]=P[e+4>>2];g=P[f+280>>2];h=P[e>>2];b=1;a=t|8}o=e+8|0;x=l>>>0>1;k=P[e+(x<<3)>>2];if((kh|0)){m=P[e+4>>2];P[a+4>>2]=S(S(S(P[(x?o:e)+4>>2]-m)/S(k-h))*S(g-h))+m;P[a>>2]=P[f+280>>2];b=b+1|0;a=a+8|0}w:{if((l|0)<2){break w}g=P[o>>2];h=P[f+280>>2];if(g>2]=g;P[a+4>>2]=P[e+12>>2];b=b+1|0;h=P[f+280>>2];g=P[o>>2];a=a+8|0}o=e+16|0;x=l-3>>>0<4294967294;k=P[e+(x<<4)>>2];if((g>2];P[a+4>>2]=S(S(S(P[(x?o:e)+4>>2]-m)/S(k-g))*S(h-g))+m;P[a>>2]=P[f+280>>2];b=b+1|0;if(b&8){break t}a=a+8|0}if((l|0)<3){break w}g=P[o>>2];h=P[f+280>>2];if(g>2]=g;P[a+4>>2]=P[e+20>>2];b=b+1|0;if(b&8){break t}h=P[f+280>>2];g=P[o>>2];a=a+8|0}o=e+24|0;x=(l&254)==2;k=P[e+(x?0:24)>>2];if((g>2];P[a+4>>2]=S(S(S(P[(x?e:o)+4>>2]-m)/S(k-g))*S(h-g))+m;P[a>>2]=P[f+280>>2];b=b+1|0;if(b&8){break t}a=a+8|0}if((l|0)<4){break w}g=P[o>>2];h=P[f+280>>2];if(g>2]=g;P[a+4>>2]=P[e+28>>2];b=b+1|0;if(b&8){break t}h=P[f+280>>2];g=P[o>>2];a=a+8|0}o=e+32|0;x=l-5>>>0<4294967294;k=P[e+(x<<5)>>2];if((g>2];P[a+4>>2]=S(S(S(P[(x?o:e)+4>>2]-m)/S(k-g))*S(h-g))+m;P[a>>2]=P[f+280>>2];b=b+1|0;if(b&8){break t}a=a+8|0}if((l|0)<5){break w}g=P[o>>2];h=P[f+280>>2];if(g>2]=g;P[a+4>>2]=P[e+36>>2];b=b+1|0;if(b&8){break t}h=P[f+280>>2];g=P[o>>2];a=a+8|0}o=e+40|0;x=(l&254)==4;k=P[e+(x?0:40)>>2];if((g>2];P[a+4>>2]=S(S(S(P[(x?e:o)+4>>2]-m)/S(k-g))*S(h-g))+m;P[a>>2]=P[f+280>>2];b=b+1|0;if(b&8){break t}a=a+8|0}if((l|0)<6){break w}g=P[o>>2];h=P[f+280>>2];if(g>2]=g;P[a+4>>2]=P[e+44>>2];b=b+1|0;if(b&8){break t}h=P[f+280>>2];g=P[o>>2];a=a+8|0}o=e+48|0;x=l-7>>>0<4294967294;k=P[e+(x?48:0)>>2];if((g>2];P[a+4>>2]=S(S(S(P[(x?o:e)+4>>2]-m)/S(k-g))*S(h-g))+m;P[a>>2]=P[f+280>>2];b=b+1|0;if(b&8){break t}a=a+8|0}if((l|0)<7){break w}g=P[o>>2];h=P[f+280>>2];if(g>2]=g;P[a+4>>2]=P[e+52>>2];b=b+1|0;if(b&8){break t}h=P[f+280>>2];g=P[o>>2];a=a+8|0}o=e+56|0;x=(l&254)==6;k=P[e+(x?0:56)>>2];if((g>2];P[a+4>>2]=S(S(S(P[(x?e:o)+4>>2]-m)/S(k-g))*S(h-g))+m;P[a>>2]=P[f+280>>2];b=b+1|0;if(b&8){break t}a=a+8|0}if((l|0)<8){break w}g=P[o>>2];h=P[f+280>>2];if(g>2]=g;P[a+4>>2]=P[e+60>>2];b=b+1|0;if(b&8){break t}h=P[f+280>>2];g=P[o>>2];a=a+8|0}l=e+((l-9>>>0<4294967294)<<6)|0;k=P[l>>2];if((g>2];P[a+4>>2]=S(S(S(P[l+4>>2]-m)/S(k-g))*S(h-g))+m;P[a>>2]=P[f+280>>2];b=b+1|0;if(b&8){break t}}if((b|0)<=0){b=0;break t}pa=t|4;o=0;a=t;l=e;while(1){g=P[f+284>>2];k=P[a+4>>2];h=S(-k);if(g>h){P[l>>2]=P[a>>2];P[l+4>>2]=P[a+4>>2];o=o+1|0;if(o&8){b=o;break s}g=P[f+284>>2];k=P[a+4>>2];h=S(-k);l=l+8|0}x=a+8|0;ua=b>>>0>1;m=P[(ua?a+12|0:pa)>>2];if((S(-m)h|0)){h=P[a>>2];P[l>>2]=S(S(S(P[(ua?x:t)>>2]-h)/S(m-k))*S(S(-g)-k))+h;P[l+4>>2]=-P[f+284>>2];o=o+1|0;if(o&8){b=o;break s}l=l+8|0}ua=(b|0)>1;b=b-1|0;a=x;if(ua){continue}break}b=0;if((o|0)<=0){break t}l=t;a=e;while(1){g=P[f+284>>2];h=P[a+4>>2];if(g>h){P[l>>2]=P[a>>2];P[l+4>>2]=P[a+4>>2];b=b+1|0;if(b&8){break t}g=P[f+284>>2];h=P[a+4>>2];l=l+8|0}x=a+8|0;pa=o>>>0>1?x:e;k=P[pa+4>>2];if((kh|0)){m=P[a>>2];P[l>>2]=S(S(S(P[pa>>2]-m)/S(k-h))*S(g-h))+m;P[l+4>>2]=P[f+284>>2];b=b+1|0;if(b&8){break t}l=l+8|0}pa=(o|0)>1;o=o-1|0;a=x;if(pa){continue}break}}qa(e,t,b<<3)}fa=t- -64|0;if((b|0)<=0){break a}e=b;g=S(S(1)/S(S(B*p)-S(A*w)));k=S(g*S(-A));m=S(g*S(-w));p=S(p*g);A=S(B*g);B=P[(ta<<2)+u>>2];a=(sa<<2)+c|0;w=P[a+32>>2];b=(X<<2)+c|0;N=P[b+32>>2];Q=P[a+16>>2];J=P[b+16>>2];F=P[ga>>2];E=P[oa>>2];a=0;b=0;while(1){c=(f+112|0)+R(a,12)|0;l=(f+208|0)+(b<<3)|0;z=P[l>>2];h=S(z-r);s=P[l+4>>2];U=S(s-H);g=S(S(k*h)+S(A*U));h=S(S(p*h)+S(m*U));U=S(S(g*F)+S(S(h*E)+q));P[c>>2]=U;ea=S(S(g*Q)+S(S(h*J)+y));P[c+4>>2]=ea;g=S(S(g*w)+S(S(h*N)+v));P[c+8>>2]=g;g=S(B-S(S(n*g)+S(S(j*U)+S(i*ea))));P[(f+80|0)+(a<<2)>>2]=g;if(g>=S(0)){c=(f+208|0)+(a<<3)|0;P[c+4>>2]=s;P[c>>2]=z;a=a+1|0}b=b+1|0;if((e|0)!=(b|0)){continue}break}if((a|0)<=0){break a}b=(a|0)>=4?4:a;X=(b|0)<=1?1:b;x:{if(X>>>0>=a>>>0){if(C>>>0>=4){b=0;while(1){c=(f+112|0)+R(b,12)|0;i=P[d+48>>2];j=P[(f+80|0)+(b<<2)>>2];P[f+32>>2]=S(P[c>>2]+P[G>>2])-S(i*j);n=P[d+52>>2];P[f+36>>2]=S(P[c+4>>2]+P[G+4>>2])-S(j*n);g=P[d+56>>2];P[f+40>>2]=S(P[c+8>>2]+P[G+8>>2])-S(j*g);L[f+76>>2]=0;P[f+72>>2]=-g;P[f+68>>2]=-n;P[f+64>>2]=-i;ha[L[L[W>>2]+16>>2]](W,f- -64|0,f+32|0,S(-j));b=b+1|0;if((b|0)!=(a|0)){continue}break}break x}b=0;while(1){c=(f+112|0)+R(b,12)|0;P[f+32>>2]=P[c>>2]+P[G>>2];P[f+36>>2]=P[c+4>>2]+P[G+4>>2];P[f+40>>2]=P[c+8>>2]+P[G+8>>2];j=P[d+48>>2];i=P[d+52>>2];n=P[d+56>>2];L[f+76>>2]=0;P[f+72>>2]=-n;P[f+68>>2]=-i;P[f+64>>2]=-j;ha[L[L[W>>2]+16>>2]](W,f- -64|0,f+32|0,S(-P[(f+80|0)+(b<<2)>>2]));b=b+1|0;if((b|0)!=(a|0)){continue}break}break x}c=0;y:{if(a>>>0<2){break y}b=a-1|0;t=b&3;e=0;n=P[f+80>>2];z:{if(a-2>>>0<3){b=1;break z}oa=b&-4;b=1;while(1){l=f+80|0;ga=b+3|0;j=P[l+(ga<<2)>>2];i=P[l+(b<<2)>>2];u=i>n;sa=b+1|0;g=P[l+(sa<<2)>>2];i=u?i:n;o=g>i;ta=b+2|0;n=P[l+(ta<<2)>>2];i=o?g:i;l=n>i;i=l?n:i;x=i>2];l=j>n;n=l?j:n;c=l?b:c;b=b+1|0;e=e+1|0;if((t|0)!=(e|0)){continue}break}}t=f+208|0;u=f+32|0;e=0;i=S(0);g=S(0);h=S(0);l=fa+-64|0;fa=l;A:{B:{C:{D:{E:{b=a;switch(b-1|0){case 1:break C;case 0:break D;default:break E}}if((b|0)>=2){o=b-2|0;while(1){a=t+(e<<3)|0;n=P[a>>2];k=P[a+12>>2];m=P[a+4>>2];v=P[a+8>>2];j=S(S(n*k)-S(m*v));i=S(i+j);g=S(S(j*S(k+m))+g);h=S(S(j*S(n+v))+h);a=(e|0)!=(o|0);e=e+1|0;if(a){continue}break}}k=S(0xde0b6b000000000);y=i;a=t+(b<<3)|0;i=P[a-8>>2];n=P[t+4>>2];m=P[a-4>>2];v=P[t>>2];j=S(S(i*n)-S(m*v));y=S(y+j);if(S(T(y))>S(1.1920928955078125e-7)){k=S(S(1)/S(y*S(3)))}e=0;if((b|0)<=0){break A}g=S(S(S(j*S(n+m))+g)*k);j=S(S(S(j*S(i+v))+h)*k);break B}g=P[t+4>>2];j=P[t>>2];break B}g=S(S(P[t+4>>2]+P[t+12>>2])*S(.5));j=S(S(P[t>>2]+P[t+8>>2])*S(.5))}while(1){a=t+(e<<3)|0;P[(l+32|0)+(e<<2)>>2]=Za(S(P[a+4>>2]-g),S(P[a>>2]-j));e=e+1|0;if((b|0)!=(e|0)){continue}break}D=0;o=0;if(b-1>>>0>=7){t=b&-8;a=0;while(1){e=o<<2;L[e+l>>2]=1;L[l+(e|4)>>2]=1;L[l+(e|8)>>2]=1;L[l+(e|12)>>2]=1;L[l+(e|16)>>2]=1;L[l+(e|20)>>2]=1;L[l+(e|24)>>2]=1;L[l+(e|28)>>2]=1;o=o+8|0;a=a+8|0;if((t|0)!=(a|0)){continue}break}}a=b&7;if(!a){e=1;break A}while(1){e=1;L[l+(o<<2)>>2]=1;o=o+1|0;D=D+1|0;if((a|0)!=(D|0)){continue}break}}a=c<<2;L[a+l>>2]=0;L[u>>2]=c;F:{if((X|0)<2){break F}D=u+4|0;if(e){n=S(S(6.2831854820251465)/S(X|0));g=P[a+(l+32|0)>>2];u=1;while(1){L[D>>2]=c;j=S(S(S(u|0)*n)+g);h=j>S(3.1415927410125732)?S(j+S(-6.2831854820251465)):j;i=S(1e9);a=c;e=0;while(1){t=e<<2;G:{if(!L[t+l>>2]){break G}j=S(T(S(P[t+(l+32|0)>>2]-h)));j=j>S(3.1415927410125732)?S(S(6.2831854820251465)-j):j;if(!(j>2]=e;a=e;i=j}e=e+1|0;if((b|0)!=(e|0)){continue}break}L[l+(a<<2)>>2]=0;D=D+4|0;u=u+1|0;if((X|0)!=(u|0)){continue}break}break F}b=X-1|0;a=b&7;if(X-2>>>0>=7){b=b&-8;e=0;while(1){L[D+28>>2]=c;L[D+24>>2]=c;L[D+20>>2]=c;L[D+16>>2]=c;L[D+12>>2]=c;L[D+8>>2]=c;L[D+4>>2]=c;L[D>>2]=c;D=D+32|0;e=e+8|0;if((b|0)!=(e|0)){continue}break}}if(!a){break F}e=0;while(1){L[D>>2]=c;D=D+4|0;e=e+1|0;if((a|0)!=(e|0)){continue}break}}fa=l- -64|0;e=C>>>0>3;a=0;while(1){b=L[(f+32|0)+(a<<2)>>2];c=(f+112|0)+R(b,12)|0;g=S(P[c>>2]+P[G>>2]);P[f+64>>2]=g;h=S(P[c+4>>2]+P[G+4>>2]);P[f+68>>2]=h;k=S(P[c+8>>2]+P[G+8>>2]);P[f+72>>2]=k;H:{if(!e){j=P[d+48>>2];i=P[d+52>>2];n=P[d+56>>2];L[f+28>>2]=0;P[f+24>>2]=-n;P[f+20>>2]=-i;P[f+16>>2]=-j;ha[L[L[W>>2]+16>>2]](W,f+16|0,f- -64|0,S(-P[(f+80|0)+(b<<2)>>2]));break H}i=P[d+48>>2];n=P[d+52>>2];j=P[d+56>>2];L[f+28>>2]=0;P[f+24>>2]=-j;P[f+20>>2]=-n;P[f+16>>2]=-i;L[f+12>>2]=0;v=j;j=P[(f+80|0)+(b<<2)>>2];P[f+8>>2]=k-S(v*j);P[f+4>>2]=h-S(n*j);P[f>>2]=g-S(i*j);ha[L[L[W>>2]+16>>2]](W,f+16|0,f,S(-j))}a=a+1|0;if((X|0)!=(a|0)){continue}break}}L[d+40>>2]=C}fa=f+368|0;fa=d+160|0}function fB(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=S(0),f=0,g=S(0),h=S(0),i=S(0),j=0,k=S(0),l=S(0),m=S(0),n=0,o=0,p=0,q=0,r=S(0),s=S(0),t=S(0),u=S(0),v=0,w=0,x=S(0),y=S(0),z=0,A=S(0),B=0,C=S(0),D=S(0),E=0,F=S(0),G=0,H=0,I=S(0),K=S(0),N=S(0),O=S(0),Q=0,U=0,V=0,W=0,X=S(0),Y=S(0),Z=0,$=S(0),aa=0,ba=0,ca=0,da=0,ea=0,ga=0,ia=0,ja=0,ka=S(0),la=S(0),ma=S(0),na=S(0);if((c|0)>0){while(1){aa=0;p=fa-96|0;fa=p;Z=L[(ba<<2)+b>>2];n=L[Z+744>>2];o=L[Z+740>>2];G=vb(a,o,P[d+12>>2]);H=vb(a,n,P[d+12>>2]);f=L[a+16>>2];B=f+R(G,244)|0;a:{b:{if(P[B+128>>2]!=S(0)|P[B+132>>2]!=S(0)|P[B+136>>2]!=S(0)){break b}B=f+R(H,244)|0;if(P[B+128>>2]!=S(0)|P[B+132>>2]!=S(0)){break b}if(P[B+136>>2]==S(0)){break a}}j=L[Z+748>>2];if((j|0)<=0){break a}V=f+R(H,244)|0;W=f+R(G,244)|0;ca=1;while(1){v=R(aa,184)+Z|0;if(P[v+84>>2]<=P[Z+756>>2]){z=v+4|0;B=L[a+28>>2];j=B;c:{if((j|0)!=L[a+32>>2]){break c}w=j?B<<1:1;if((w|0)<=(j|0)){break c}d:{if(!w){q=0;f=B;break d}L[8513]=L[8513]+1;q=ha[L[6798]](R(w,152),16)|0;f=L[a+28>>2]}e:{if((f|0)<=0){break e}j=0;if((f|0)!=1){Q=f&-2;E=0;while(1){U=R(j,152);qa(U+q|0,U+L[a+36>>2]|0,152);U=R(j|1,152);qa(U+q|0,U+L[a+36>>2]|0,152);j=j+2|0;E=E+2|0;if((Q|0)!=(E|0)){continue}break}}if(!(f&1)){break e}f=R(j,152);qa(f+q|0,f+L[a+36>>2]|0,152)}f=L[a+36>>2];if(!(f?!f|!M[a+40|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](f)}L[a+36>>2]=q;J[a+40|0]=1;L[a+32>>2]=w;j=L[a+28>>2]}L[a+28>>2]=j+1;ia=L[o+236>>2];ja=L[n+236>>2];f=L[a+36>>2]+R(B,152)|0;L[f+148>>2]=H;L[f+144>>2]=G;L[f+132>>2]=z;i=P[v+52>>2];h=P[v+56>>2];e=P[v+60>>2];g=P[o+52>>2];l=P[o+56>>2];m=P[o+60>>2];L[p+92>>2]=0;e=S(e-m);P[p+88>>2]=e;h=S(h-l);P[p+84>>2]=h;i=S(i-g);P[p+80>>2]=i;m=P[v+36>>2];l=P[v+40>>2];g=P[v+44>>2];k=P[n+52>>2];y=P[n+56>>2];s=P[n+60>>2];L[p+76>>2]=0;g=S(g-s);P[p+72>>2]=g;l=S(l-y);P[p+68>>2]=l;m=S(m-k);P[p+64>>2]=m;y=S(0);O=S(0);I=S(0);K=S(0);if(L[W+240>>2]){k=S(P[W+192>>2]+P[W+224>>2]);s=S(P[W+196>>2]+P[W+228>>2]);O=S(S(P[W+184>>2]+P[W+216>>2])+S(S(k*h)-S(i*s)));t=S(P[W+200>>2]+P[W+232>>2]);I=S(S(P[W+180>>2]+P[W+212>>2])+S(S(t*i)-S(e*k)));K=S(S(P[W+176>>2]+P[W+208>>2])+S(S(s*e)-S(h*t)))}$=S(0);ka=S(0);if(L[V+240>>2]){e=S(P[V+192>>2]+P[V+224>>2]);h=S(P[V+196>>2]+P[V+228>>2]);y=S(S(P[V+184>>2]+P[V+216>>2])+S(S(e*l)-S(m*h)));i=S(P[V+200>>2]+P[V+232>>2]);$=S(S(P[V+180>>2]+P[V+212>>2])+S(S(i*m)-S(g*e)));ka=S(S(P[V+176>>2]+P[V+208>>2])+S(S(h*g)-S(l*i)))}la=P[v+76>>2];E=v+68|0;ma=P[E>>2];na=P[v+72>>2];m=S(0);Q=L[a+16>>2];da=Q+R(H,244)|0;j=L[da+240>>2];ea=Q+R(G,244)|0;q=L[ea+240>>2];L[p+60>>2]=1065353216;e=P[p+80>>2];h=P[z+68>>2];i=P[z+64>>2];g=P[p+84>>2];k=S(S(e*h)-S(i*g));l=P[p+88>>2];r=S(l*i);i=P[z+72>>2];s=S(r-S(i*e));t=S(S(g*i)-S(h*l));h=S(0);e=S(0);i=S(0);if(q){i=S(S(S(P[q+304>>2]*k)+S(S(P[q+296>>2]*t)+S(s*P[q+300>>2])))*P[q+552>>2]);h=S(S(S(P[q+272>>2]*k)+S(S(P[q+264>>2]*t)+S(s*P[q+268>>2])))*P[q+544>>2]);e=S(S(S(P[q+288>>2]*k)+S(S(P[q+280>>2]*t)+S(s*P[q+284>>2])))*P[q+548>>2])}P[f+64>>2]=h;L[f+76>>2]=0;P[f+72>>2]=i;P[f+68>>2]=e;w=p- -64|0;g=P[w>>2];l=P[z+68>>2];u=P[z+64>>2];C=P[w+4>>2];r=S(S(g*l)-S(u*C));D=P[w+8>>2];F=P[z+72>>2];u=S(S(D*u)-S(F*g));C=S(S(C*F)-S(l*D));g=S(0);l=S(0);if(j){m=S(-C);l=S(S(S(S(P[j+296>>2]*m)-S(P[j+300>>2]*u))-S(P[j+304>>2]*r))*P[j+552>>2]);g=S(S(S(S(P[j+280>>2]*m)-S(P[j+284>>2]*u))-S(P[j+288>>2]*r))*P[j+548>>2]);m=S(S(S(S(P[j+264>>2]*m)-S(P[j+268>>2]*u))-S(P[j+272>>2]*r))*P[j+544>>2])}P[f+80>>2]=m;L[f+92>>2]=0;P[f+88>>2]=l;P[f+84>>2]=g;x=P[p+60>>2];if(q){F=P[p+84>>2];N=P[p+80>>2];D=S(P[z+72>>2]*S(S(h*F)-S(N*e)));A=e;e=P[p+88>>2];e=S(P[q+344>>2]+S(D+S(S(P[z+64>>2]*S(S(A*e)-S(F*i)))+S(S(S(i*N)-S(e*h))*P[z+68>>2]))))}else{e=S(0)}if(j){h=P[w>>2];i=P[w+4>>2];A=S(P[z+72>>2]*S(S(g*h)-S(m*i)));D=S(l*i);i=P[w+8>>2];g=S(P[j+344>>2]+S(A+S(S(P[z+64>>2]*S(D-S(g*i)))+S(S(S(m*i)-S(l*h))*P[z+68>>2]))))}else{g=S(0)}P[f+108>>2]=x/S(e+g);f:{if(q){U=z- -64|0;ga=L[U+4>>2];L[f+16>>2]=L[U>>2];L[f+20>>2]=ga;ga=L[U+12>>2];L[f+24>>2]=L[U+8>>2];L[f+28>>2]=ga;L[f+12>>2]=0;P[f+8>>2]=k;P[f+4>>2]=s;P[f>>2]=t;break f}L[f>>2]=0;L[f+4>>2]=0;L[f+24>>2]=0;L[f+28>>2]=0;L[f+16>>2]=0;L[f+20>>2]=0;L[f+8>>2]=0;L[f+12>>2]=0}g:{if(j){e=P[z+64>>2];h=P[z+68>>2];i=P[z+72>>2];L[f+60>>2]=0;L[f+44>>2]=0;P[f+40>>2]=-r;P[f+36>>2]=-u;P[f+32>>2]=-C;P[f+56>>2]=-i;P[f+52>>2]=-h;P[f+48>>2]=-e;break g}L[f+32>>2]=0;L[f+36>>2]=0;L[f+56>>2]=0;L[f+60>>2]=0;L[f+48>>2]=0;L[f+52>>2]=0;L[f+40>>2]=0;L[f+44>>2]=0}m=S(0);h=S(0);e=S(0);i=S(0);if(q){e=P[q+328>>2];h=P[p+84>>2];g=P[p+80>>2];l=P[q+332>>2];i=S(S(S(e*h)-S(g*l))+P[q+320>>2]);k=P[q+336>>2];r=S(k*g);g=P[p+88>>2];e=S(S(r-S(g*e))+P[q+316>>2]);h=S(S(S(l*g)-S(h*k))+P[q+312>>2])}g=S(0);l=S(0);if(j){g=P[j+328>>2];m=P[w+4>>2];k=P[w>>2];s=P[j+332>>2];l=S(S(S(g*m)-S(k*s))+P[j+320>>2]);t=P[j+336>>2];r=S(t*k);k=P[w+8>>2];g=S(S(r-S(k*g))+P[j+316>>2]);m=S(S(S(s*k)-S(m*t))+P[j+312>>2])}F=P[d+56>>2];N=P[z+80>>2];k=P[z+72>>2];s=P[z+64>>2];t=P[z+68>>2];P[f+104>>2]=P[z+84>>2];m=S(P[z+92>>2]*S(-S(S(k*S(i-l))+S(S(s*S(h-m))+S(t*S(e-g))))));h:{if(M[d+64|0]&4){e=S(P[z+120>>2]*P[d+60>>2]);P[f+100>>2]=e;if(!(!q|!L[ea+240>>2])){h=P[q+356>>2];i=P[f+24>>2];g=P[q+352>>2];l=P[f+20>>2];w=Q+R(G,244)|0;P[w+64>>2]=S(P[w+112>>2]*S(e*S(S(P[f+16>>2]*P[w+128>>2])*P[q+348>>2])))+P[w+64>>2];P[w+68>>2]=S(S(e*S(g*S(l*P[w+132>>2])))*P[w+116>>2])+P[w+68>>2];P[w+72>>2]=S(S(e*S(h*S(i*P[w+136>>2])))*P[w+120>>2])+P[w+72>>2];h=P[f+72>>2];i=P[f+68>>2];P[w+80>>2]=S(S(e*P[w+96>>2])*P[f+64>>2])+P[w+80>>2];g=P[w+104>>2];P[w+84>>2]=S(i*S(e*P[w+100>>2]))+P[w+84>>2];P[w+88>>2]=S(h*S(e*g))+P[w+88>>2]}if(!j|!L[da+240>>2]){break h}q=Q+R(H,244)|0;h=P[q+120>>2];i=P[j+356>>2];g=P[f+56>>2];l=P[q+136>>2];k=P[q+116>>2];s=P[j+352>>2];t=P[f+52>>2];r=P[q+132>>2];u=P[f+88>>2];C=P[f+84>>2];D=P[f+80>>2];e=P[f+100>>2];P[q+64>>2]=P[q+64>>2]+S(P[q+112>>2]*S(S(S(P[q+128>>2]*P[f+48>>2])*P[j+348>>2])*e));P[q+80>>2]=P[q+80>>2]+S(D*S(e*P[q+96>>2]));P[q+84>>2]=P[q+84>>2]+S(C*S(e*P[q+100>>2]));P[q+88>>2]=P[q+88>>2]+S(u*S(e*P[q+104>>2]));P[q+68>>2]=P[q+68>>2]+S(k*S(e*S(s*S(r*t))));P[q+72>>2]=P[q+72>>2]+S(h*S(e*S(i*S(l*g))));break h}L[f+100>>2]=0}L[f+96>>2]=0;e=S(0);i=S(0);g=S(0);l=S(0);k=S(0);s=S(0);t=S(0);if(L[ea+240>>2]){j=Q+R(G,244)|0;t=P[j+224>>2];l=P[j+208>>2];k=P[j+232>>2];s=P[j+228>>2];g=P[j+212>>2];i=P[j+216>>2]}h=S(0);r=S(0);u=S(0);C=S(0);D=S(0);if(L[da+240>>2]){j=Q+R(H,244)|0;D=P[j+224>>2];u=P[j+232>>2];C=P[j+228>>2];r=P[j+216>>2];h=P[j+212>>2];e=P[j+208>>2]}j=Q+R(G,244)|0;k=S(S(S(P[f+24>>2]*S(i+P[j+184>>2]))+S(S(P[f+16>>2]*S(l+P[j+176>>2]))+S(S(g+P[j+180>>2])*P[f+20>>2])))+S(S(P[f+8>>2]*S(k+P[j+200>>2]))+S(S(P[f>>2]*S(t+P[j+192>>2]))+S(S(s+P[j+196>>2])*P[f+4>>2]))));j=Q+R(H,244)|0;h=S((m<=S(0)?S(0):m)-S(k+S(S(S(P[f+56>>2]*S(r+P[j+184>>2]))+S(S(P[f+48>>2]*S(e+P[j+176>>2]))+S(S(h+P[j+180>>2])*P[f+52>>2])))+S(S(P[f+40>>2]*S(u+P[j+200>>2]))+S(S(P[f+32>>2]*S(D+P[j+192>>2]))+S(S(C+P[j+196>>2])*P[f+36>>2]))))));i=S(N+F);j=!L[d+44>>2]|i>P[d+48>>2];e=S(0);i:{if(i>S(0)){h=S(h-S(i/P[d+12>>2]));break i}e=S(S(P[(j?32:36)+d>>2]*S(-i))/P[d+12>>2])}L[f+124>>2]=1343554297;L[f+116>>2]=0;L[f+120>>2]=0;k=e;e=P[f+108>>2];i=S(k*e);P[f+128>>2]=j?S(0):i;P[f+112>>2]=S(h*e)+(j?i:S(-0));L[f+140>>2]=L[a+68>>2];e=S(0);h=S(0);i=S(0);g=S(0);if(ia&2){j=ia<<30>>31&o;g=P[j+336>>2];i=P[j+332>>2];h=P[j+328>>2]}l=S(0);m=S(0);if(ja&2){j=ja<<30>>31&n;m=P[j+336>>2];l=P[j+332>>2];e=P[j+328>>2]}L[p+56>>2]=0;g=S(m-g);P[p+52>>2]=g;i=S(l-i);P[p+48>>2]=i;e=S(e-h);P[p+44>>2]=e;j:{if(!(P[v+92>>2]>S(0))|!ca){break j}h=S(_(S(S(g*g)+S(S(e*e)+S(i*i)))));if(h>P[d+80>>2]){k=g;g=S(S(1)/h);h=S(k*g);P[p+52>>2]=h;i=S(i*g);P[p+48>>2]=i;e=S(e*g);P[p+44>>2]=e;if(M[o+180|0]&2){m=P[o+44>>2];k=P[o+12>>2];s=P[o+28>>2];g=S(S(S(m*h)+S(S(k*e)+S(i*s)))*P[o+172>>2]);t=P[o+36>>2];r=P[o+4>>2];u=P[o+20>>2];l=S(S(S(t*h)+S(S(r*e)+S(i*u)))*P[o+164>>2]);C=P[o+40>>2];D=P[o+8>>2];A=i;i=P[o+24>>2];e=S(S(S(C*h)+S(S(D*e)+S(A*i)))*P[o+168>>2]);h=S(S(m*g)+S(S(t*l)+S(C*e)));P[p+52>>2]=h;i=S(S(s*g)+S(S(u*l)+S(i*e)));P[p+48>>2]=i;e=S(S(k*g)+S(S(r*l)+S(D*e)));P[p+44>>2]=e}if(M[n+180|0]&2){D=P[n+172>>2];g=P[n+44>>2];l=P[n+12>>2];m=P[n+28>>2];F=P[n+164>>2];k=P[n+36>>2];s=P[n+4>>2];t=P[n+20>>2];N=P[n+168>>2];r=P[n+40>>2];u=P[n+8>>2];C=P[n+24>>2];L[p+56>>2]=0;A=g;g=S(D*S(S(g*h)+S(S(l*e)+S(i*m))));x=k;k=S(F*S(S(k*h)+S(S(s*e)+S(t*i))));e=S(N*S(S(r*h)+S(S(u*e)+S(i*C))));h=S(S(A*g)+S(S(x*k)+S(r*e)));P[p+52>>2]=h;i=S(S(m*g)+S(S(t*k)+S(C*e)));P[p+48>>2]=i;e=S(S(l*g)+S(S(s*k)+S(u*e)));P[p+44>>2]=e}ca=0;if(!(+S(_(S(S(h*h)+S(S(e*e)+S(i*i)))))>.001)){break j}ze(a,p+44|0,G,H,B,z);break j}ze(a,E,G,H,B,z);e=P[E+8>>2];k:{if(S(T(e))>S(.7071067690849304)){h=P[E+4>>2];L[p+28>>2]=0;l=S(S(h*h)+S(e*e));g=S(S(1)/S(_(l)));i=S(h*g);P[p+36>>2]=i;h=S(g*S(-e));P[p+32>>2]=h;m=S(l*g);P[p+12>>2]=m;e=P[E>>2];l=S(i*S(-e));P[p+16>>2]=l;g=S(0);e=S(h*e);break k}h=P[E>>2];i=P[E+4>>2];L[p+36>>2]=0;s=S(S(h*h)+S(i*i));k=S(S(1)/S(_(s)));h=S(h*k);P[p+32>>2]=h;g=S(k*S(-i));P[p+28>>2]=g;l=S(e*g);P[p+16>>2]=l;m=S(h*S(-e));P[p+12>>2]=m;i=S(0);e=S(s*k)}P[p+20>>2]=e;if(M[o+180|0]&2){x=P[o+172>>2];k=P[o+44>>2];s=P[o+12>>2];t=P[o+28>>2];X=P[o+164>>2];r=P[o+36>>2];u=P[o+4>>2];C=P[o+20>>2];Y=P[o+168>>2];D=P[o+40>>2];F=P[o+8>>2];N=P[o+24>>2];L[p+40>>2]=0;A=k;k=S(x*S(S(k*i)+S(S(s*g)+S(h*t))));x=r;r=S(X*S(S(r*i)+S(S(u*g)+S(C*h))));g=S(Y*S(S(D*i)+S(S(F*g)+S(h*N))));i=S(S(A*k)+S(S(x*r)+S(D*g)));P[p+36>>2]=i;h=S(S(t*k)+S(S(C*r)+S(N*g)));P[p+32>>2]=h;g=S(S(s*k)+S(S(u*r)+S(F*g)));P[p+28>>2]=g}if(M[n+180|0]&2){x=P[n+172>>2];k=P[n+44>>2];s=P[n+12>>2];t=P[n+28>>2];X=P[n+164>>2];r=P[n+36>>2];u=P[n+4>>2];C=P[n+20>>2];Y=P[n+168>>2];D=P[n+40>>2];F=P[n+8>>2];N=P[n+24>>2];L[p+40>>2]=0;A=k;k=S(x*S(S(k*i)+S(S(s*g)+S(h*t))));x=r;r=S(X*S(S(r*i)+S(S(u*g)+S(C*h))));g=S(Y*S(S(D*i)+S(S(F*g)+S(h*N))));i=S(S(A*k)+S(S(x*r)+S(D*g)));P[p+36>>2]=i;h=S(S(t*k)+S(S(C*r)+S(N*g)));P[p+32>>2]=h;g=S(S(s*k)+S(S(u*r)+S(F*g)));P[p+28>>2]=g}if(M[o+180|0]&2){x=P[o+172>>2];k=P[o+44>>2];s=P[o+12>>2];t=P[o+28>>2];X=P[o+164>>2];r=P[o+36>>2];u=P[o+4>>2];C=P[o+20>>2];Y=P[o+168>>2];D=P[o+40>>2];F=P[o+8>>2];N=P[o+24>>2];L[p+24>>2]=0;A=k;k=S(x*S(S(k*e)+S(S(s*m)+S(l*t))));x=r;r=S(X*S(S(r*e)+S(S(u*m)+S(C*l))));m=S(Y*S(S(D*e)+S(S(F*m)+S(l*N))));e=S(S(A*k)+S(S(x*r)+S(D*m)));P[p+20>>2]=e;l=S(S(t*k)+S(S(C*r)+S(N*m)));P[p+16>>2]=l;m=S(S(s*k)+S(S(u*r)+S(F*m)));P[p+12>>2]=m}if(M[n+180|0]&2){x=P[n+172>>2];k=P[n+44>>2];s=P[n+12>>2];t=P[n+28>>2];X=P[n+164>>2];r=P[n+36>>2];u=P[n+4>>2];C=P[n+20>>2];Y=P[n+168>>2];D=P[n+40>>2];F=P[n+8>>2];N=P[n+24>>2];L[p+24>>2]=0;A=k;k=S(x*S(S(k*e)+S(S(s*m)+S(l*t))));x=r;r=S(X*S(S(r*e)+S(S(u*m)+S(C*l))));m=S(Y*S(S(D*e)+S(S(F*m)+S(l*N))));e=S(S(A*k)+S(S(x*r)+S(D*m)));P[p+20>>2]=e;l=S(S(t*k)+S(S(C*r)+S(N*m)));P[p+16>>2]=l;m=S(S(s*k)+S(S(u*r)+S(F*m)));P[p+12>>2]=m}if(+S(_(S(S(i*i)+S(S(g*g)+S(h*h)))))>.001){ze(a,p+28|0,G,H,B,z)}if(+S(_(S(S(e*e)+S(S(m*m)+S(l*l)))))>.001){ze(a,p+12|0,G,H,B,z)}ca=0}l:{if(!(M[v+120|0]?M[d+64|0]&32:0)){k=P[E>>2];e=P[E+4>>2];i=P[E+8>>2];L[v+168>>2]=0;g=S(O-y);m=S(K-ka);l=S(I-$);h=S(S(la*g)+S(S(ma*m)+S(l*na)));g=S(g-S(i*h));P[v+164>>2]=g;l=S(l-S(h*e));P[v+160>>2]=l;j=v+156|0;m=S(m-S(h*k));P[j>>2]=m;m:{if(M[d+64|0]&64){break m}h=S(S(g*g)+S(S(m*m)+S(l*l)));if(!(h>S(1.1920928955078125e-7))){break m}i=S(S(1)/S(_(h)));e=S(g*i);P[j+8>>2]=e;h=S(l*i);P[j+4>>2]=h;i=S(m*i);P[j>>2]=i;if(J[o+180|0]&1){O=P[o+172>>2];g=P[o+44>>2];l=P[o+12>>2];m=P[o+28>>2];I=P[o+164>>2];k=P[o+36>>2];y=P[o+4>>2];s=P[o+20>>2];K=P[o+168>>2];t=P[o+40>>2];r=P[o+8>>2];u=P[o+24>>2];L[j+12>>2]=0;A=g;g=S(O*S(S(g*e)+S(S(l*i)+S(h*m))));x=k;k=S(I*S(S(k*e)+S(S(y*i)+S(h*s))));i=S(K*S(S(t*e)+S(S(r*i)+S(h*u))));e=S(S(A*g)+S(S(x*k)+S(t*i)));P[j+8>>2]=e;h=S(S(m*g)+S(S(s*k)+S(u*i)));P[j+4>>2]=h;i=S(S(l*g)+S(S(y*k)+S(r*i)));P[j>>2]=i}if(J[n+180|0]&1){O=P[n+172>>2];g=P[n+44>>2];l=P[n+12>>2];m=P[n+28>>2];I=P[n+164>>2];k=P[n+36>>2];y=P[n+4>>2];s=P[n+20>>2];K=P[n+168>>2];t=P[n+40>>2];r=P[n+8>>2];u=P[n+24>>2];L[j+12>>2]=0;A=g;g=S(O*S(S(g*e)+S(S(l*i)+S(h*m))));x=k;k=S(I*S(S(k*e)+S(S(y*i)+S(s*h))));e=S(K*S(S(t*e)+S(S(r*i)+S(h*u))));P[j+8>>2]=S(A*g)+S(S(x*k)+S(t*e));P[j+4>>2]=S(m*g)+S(S(s*k)+S(u*e));P[j>>2]=S(l*g)+S(S(y*k)+S(r*e))}O=P[p+60>>2];Bc(a,j,G,H,B,z,p+80|0,p- -64|0,O,S(0),S(0));if(!(M[d+64|0]&16)){break l}e=P[j+4>>2];h=P[E+4>>2];i=P[E>>2];g=P[j+8>>2];l=P[j>>2];m=P[E+8>>2];L[v+184>>2]=0;k=S(S(l*h)-S(i*e));y=S(S(e*m)-S(h*g));h=S(S(g*i)-S(m*l));i=S(S(1)/S(_(S(S(k*k)+S(S(y*y)+S(h*h))))));e=S(k*i);P[v+180>>2]=e;h=S(h*i);P[v+176>>2]=h;j=v+172|0;i=S(y*i);P[j>>2]=i;if(J[o+180|0]&1){I=P[o+172>>2];g=P[o+44>>2];l=P[o+12>>2];m=P[o+28>>2];K=P[o+164>>2];k=P[o+36>>2];y=P[o+4>>2];s=P[o+20>>2];$=P[o+168>>2];t=P[o+40>>2];r=P[o+8>>2];u=P[o+24>>2];L[j+12>>2]=0;A=g;g=S(I*S(S(g*e)+S(S(l*i)+S(h*m))));x=k;k=S(K*S(S(k*e)+S(S(y*i)+S(h*s))));i=S($*S(S(t*e)+S(S(r*i)+S(h*u))));e=S(S(A*g)+S(S(x*k)+S(t*i)));P[j+8>>2]=e;h=S(S(m*g)+S(S(s*k)+S(u*i)));P[j+4>>2]=h;i=S(S(l*g)+S(S(y*k)+S(r*i)));P[j>>2]=i}if(J[n+180|0]&1){I=P[n+172>>2];g=P[n+44>>2];l=P[n+12>>2];m=P[n+28>>2];K=P[n+164>>2];k=P[n+36>>2];y=P[n+4>>2];s=P[n+20>>2];$=P[n+168>>2];t=P[n+40>>2];r=P[n+8>>2];u=P[n+24>>2];L[j+12>>2]=0;A=g;g=S(I*S(S(g*e)+S(S(l*i)+S(h*m))));x=k;k=S(K*S(S(k*e)+S(S(y*i)+S(s*h))));e=S($*S(S(t*e)+S(S(r*i)+S(h*u))));P[j+8>>2]=S(A*g)+S(S(x*k)+S(t*e));P[j+4>>2]=S(m*g)+S(S(s*k)+S(u*e));P[j>>2]=S(l*g)+S(S(y*k)+S(r*e))}Bc(a,j,G,H,B,z,p+80|0,p- -64|0,O,S(0),S(0));break l}q=v+172|0;n:{if(S(T(i))>S(.7071067690849304)){g=S(S(e*e)+S(i*i));h=S(S(1)/S(_(g)));l=S(g*h);g=S(h*S(-i));m=S(k*g);e=S(e*h);y=S(e*S(-k));h=S(0);break n}h=S(S(k*k)+S(e*e));g=S(S(1)/S(_(h)));m=S(h*g);h=S(g*S(-e));y=S(i*h);g=S(k*g);l=S(g*S(-i));e=S(0)}P[j+8>>2]=e;P[j+4>>2]=g;P[j>>2]=h;P[q+8>>2]=m;P[q+4>>2]=y;P[q>>2]=l;if(J[o+180|0]&1){O=P[o+172>>2];i=P[o+44>>2];l=P[o+12>>2];m=P[o+28>>2];I=P[o+164>>2];k=P[o+36>>2];y=P[o+4>>2];s=P[o+20>>2];K=P[o+168>>2];t=P[o+40>>2];r=P[o+8>>2];u=P[o+24>>2];L[j+12>>2]=0;A=i;i=S(O*S(S(i*e)+S(S(l*h)+S(g*m))));x=k;k=S(I*S(S(k*e)+S(S(y*h)+S(s*g))));h=S(K*S(S(t*e)+S(S(r*h)+S(g*u))));e=S(S(A*i)+S(S(x*k)+S(t*h)));P[j+8>>2]=e;g=S(S(m*i)+S(S(s*k)+S(u*h)));P[j+4>>2]=g;h=S(S(l*i)+S(S(y*k)+S(r*h)));P[j>>2]=h}if(J[n+180|0]&1){O=P[n+172>>2];i=P[n+44>>2];l=P[n+12>>2];m=P[n+28>>2];I=P[n+164>>2];k=P[n+36>>2];y=P[n+4>>2];s=P[n+20>>2];K=P[n+168>>2];t=P[n+40>>2];r=P[n+8>>2];u=P[n+24>>2];L[j+12>>2]=0;A=i;i=S(O*S(S(i*e)+S(S(l*h)+S(g*m))));x=k;k=S(I*S(S(k*e)+S(S(y*h)+S(s*g))));e=S(K*S(S(t*e)+S(S(r*h)+S(g*u))));P[j+8>>2]=S(A*i)+S(S(x*k)+S(t*e));P[j+4>>2]=S(m*i)+S(S(s*k)+S(u*e));P[j>>2]=S(l*i)+S(S(y*k)+S(r*e))}O=P[p+60>>2];Bc(a,j,G,H,B,z,p+80|0,p- -64|0,O,S(0),S(0));j=L[d+64>>2];if(j&16){if(J[o+180|0]&1){t=P[o+172>>2];e=P[o+44>>2];h=P[o+12>>2];i=P[o+28>>2];I=P[o+164>>2];g=P[o+36>>2];l=P[o+4>>2];m=P[o+20>>2];K=P[o+168>>2];k=P[o+40>>2];y=P[o+8>>2];s=P[o+24>>2];L[q+12>>2]=0;A=e;x=t;e=P[q+8>>2];t=P[q>>2];r=P[q+4>>2];u=S(x*S(S(A*e)+S(S(h*t)+S(i*r))));x=g;g=S(I*S(S(g*e)+S(S(l*t)+S(m*r))));e=S(K*S(S(k*e)+S(S(y*t)+S(r*s))));P[q+8>>2]=S(A*u)+S(S(x*g)+S(k*e));P[q+4>>2]=S(i*u)+S(S(m*g)+S(s*e));P[q>>2]=S(h*u)+S(S(l*g)+S(y*e))}if(J[n+180|0]&1){t=P[n+172>>2];e=P[n+44>>2];h=P[n+12>>2];i=P[n+28>>2];I=P[n+164>>2];g=P[n+36>>2];l=P[n+4>>2];m=P[n+20>>2];K=P[n+168>>2];k=P[n+40>>2];y=P[n+8>>2];s=P[n+24>>2];L[q+12>>2]=0;A=e;x=t;e=P[q+8>>2];t=P[q>>2];r=P[q+4>>2];u=S(x*S(S(A*e)+S(S(h*t)+S(i*r))));x=g;g=S(I*S(S(g*e)+S(S(l*t)+S(m*r))));e=S(K*S(S(k*e)+S(S(y*t)+S(r*s))));P[q+8>>2]=S(A*u)+S(S(x*g)+S(k*e));P[q+4>>2]=S(i*u)+S(S(m*g)+S(s*e));P[q>>2]=S(h*u)+S(S(l*g)+S(y*e))}Bc(a,q,G,H,B,z,p+80|0,p- -64|0,O,S(0),S(0));j=L[d+64>>2]}if((j&80)!=80){break l}J[v+120|0]=1;break l}e=P[p+60>>2];Bc(a,v+156|0,G,H,B,z,p+80|0,p- -64|0,e,P[v+136>>2],P[v+144>>2]);if(!(M[d+64|0]&16)){break l}Bc(a,v+172|0,G,H,B,z,p+80|0,p- -64|0,e,P[v+140>>2],P[v+148>>2])}q=L[a+76>>2];Q=L[f+140>>2];U=L[d+64>>2];o:{if(U&4){w=L[a+16>>2];B=L[(w+R(H,244)|0)+240>>2];j=L[(w+R(G,244)|0)+240>>2];v=q+R(Q,152)|0;e=S(P[z+124>>2]*P[d+60>>2]);P[v+100>>2]=e;if(j){i=P[j+356>>2];g=P[v+24>>2];l=P[j+352>>2];m=P[v+20>>2];f=w+R(G,244)|0;h=P[j+344>>2];P[f+64>>2]=S(S(e*S(S(h*P[v+16>>2])*P[j+348>>2]))*P[f+112>>2])+P[f+64>>2];P[f+68>>2]=S(S(e*S(l*S(h*m)))*P[f+116>>2])+P[f+68>>2];P[f+72>>2]=S(S(e*S(i*S(h*g)))*P[f+120>>2])+P[f+72>>2];h=P[v+72>>2];i=P[v+68>>2];P[f+80>>2]=S(S(e*P[f+96>>2])*P[v+64>>2])+P[f+80>>2];g=P[f+104>>2];P[f+84>>2]=S(i*S(e*P[f+100>>2]))+P[f+84>>2];P[f+88>>2]=S(h*S(e*g))+P[f+88>>2]}if(B){E=q+R(Q,152)|0;i=P[E+88>>2];g=P[E+84>>2];l=P[E+80>>2];m=P[B+356>>2];k=P[E+56>>2];y=P[B+352>>2];s=P[E+52>>2];f=w+R(H,244)|0;h=P[B+344>>2];e=P[v+100>>2];P[f+64>>2]=P[f+64>>2]+S(S(S(S(h*P[E+48>>2])*P[B+348>>2])*e)*P[f+112>>2]);P[f+68>>2]=P[f+68>>2]+S(S(e*S(y*S(h*s)))*P[f+116>>2]);P[f+72>>2]=P[f+72>>2]+S(S(e*S(m*S(h*k)))*P[f+120>>2]);P[f+80>>2]=P[f+80>>2]+S(l*S(e*P[f+96>>2]));h=P[f+104>>2];P[f+84>>2]=P[f+84>>2]+S(g*S(e*P[f+100>>2]));P[f+88>>2]=P[f+88>>2]+S(i*S(h*e))}if(!(U&16)){break o}E=Q+1|0;v=q+R(E,152)|0;e=S(P[z+128>>2]*P[d+60>>2]);P[v+100>>2]=e;if(j){i=P[v+24>>2];g=P[v+20>>2];f=w+R(G,244)|0;h=P[j+344>>2];P[f+64>>2]=S(S(e*S(h*P[v+16>>2]))*P[f+112>>2])+P[f+64>>2];P[f+68>>2]=S(S(e*S(h*g))*P[f+116>>2])+P[f+68>>2];P[f+72>>2]=S(S(e*S(h*i))*P[f+120>>2])+P[f+72>>2];h=P[v+72>>2];i=P[v+68>>2];P[f+80>>2]=S(S(e*P[f+96>>2])*P[v+64>>2])+P[f+80>>2];g=P[f+104>>2];P[f+84>>2]=S(i*S(e*P[f+100>>2]))+P[f+84>>2];P[f+88>>2]=S(h*S(e*g))+P[f+88>>2]}if(!B){break o}j=q+R(E,152)|0;i=P[j+88>>2];g=P[j+84>>2];l=P[j+56>>2];m=P[j+52>>2];k=P[j+48>>2];h=P[B+344>>2];f=w+R(H,244)|0;e=P[v+100>>2];P[f+80>>2]=P[f+80>>2]+S(P[j+80>>2]*S(P[f+96>>2]*e));P[f+64>>2]=P[f+64>>2]+S(S(e*S(h*k))*P[f+112>>2]);P[f+68>>2]=P[f+68>>2]+S(S(e*S(h*m))*P[f+116>>2]);P[f+72>>2]=P[f+72>>2]+S(S(e*S(h*l))*P[f+120>>2]);h=P[f+104>>2];P[f+84>>2]=P[f+84>>2]+S(g*S(e*P[f+100>>2]));P[f+88>>2]=P[f+88>>2]+S(i*S(h*e));break o}f=q+R(Q,152)|0;L[f+100>>2]=0;if(!(U&16)){break o}L[f+252>>2]=0}j=L[Z+748>>2]}aa=aa+1|0;if((aa|0)<(j|0)){continue}break}}fa=p+96|0;ba=ba+1|0;if((ba|0)!=(c|0)){continue}break}}}function Lz(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=S(0),y=S(0);l=fa-96|0;fa=l;oh(a,b,c);J[l+52|0]=1;L[l+48>>2]=0;J[l+72|0]=1;L[l+40>>2]=0;L[l+44>>2]=0;L[l+68>>2]=0;J[l+92|0]=1;L[l+60>>2]=0;L[l+64>>2]=0;L[l+88>>2]=0;L[l+80>>2]=0;L[l+84>>2]=0;L[l+28>>2]=0;J[l+32|0]=1;L[l+20>>2]=0;L[l+24>>2]=0;d=L[a+872>>2];L[b+292>>2]=d;a:{if(!d){L[b+260>>2]=0;break a}j=a+868|0;d=ha[L[L[c>>2]+28>>2]](c,j)|0;L[b+260>>2]=d;if(!d){break a}i=L[b+292>>2];h=ha[L[L[c>>2]+16>>2]](c,4,i)|0;if((i|0)>0){f=L[h+8>>2];while(1){d=L[L[a+880>>2]+(g<<2)>>2];if(d){e=ha[L[L[c>>2]+28>>2]](c,d)|0}else{e=0}L[f>>2]=e;if(!(ha[L[L[c>>2]+24>>2]](c,d)|0)){k=ha[L[L[c>>2]+16>>2]](c,16,1)|0;e=L[k+8>>2];L[e+12>>2]=L[d+16>>2];P[e+4>>2]=P[d+8>>2];P[e>>2]=P[d+4>>2];P[e+8>>2]=P[d+12>>2];ha[L[L[c>>2]+20>>2]](c,k,3766,1414349395,d)}f=f+4|0;g=g+1|0;if((i|0)!=(g|0)){continue}break}}ha[L[L[c>>2]+20>>2]](c,h,3766,1497453121,j)}d=L[a+712>>2];L[b+296>>2]=d;b:{if(!d){L[b+264>>2]=0;break b}v=a+708|0;d=ha[L[L[c>>2]+28>>2]](c,v)|0;L[b+264>>2]=d;if(!d){break b}t=L[b+296>>2];w=ha[L[L[c>>2]+16>>2]](c,100,t)|0;d=L[w+8>>2];g=0;L[l+12>>2]=0;if((t|0)>0){while(1){h=L[a+720>>2];f=h+R(g,104)|0;P[d+52>>2]=P[f+56>>2];P[d+56>>2]=P[f+60>>2];P[d+60>>2]=P[f- -64>>2];P[d- -64>>2]=P[f+68>>2];P[d+88>>2]=P[f+92>>2];e=0;L[d+92>>2]=0-(J[f+100|0]&1);P[d+84>>2]=P[f+88>>2];f=L[f+4>>2];if(f){e=ha[L[L[c>>2]+28>>2]](c,f)|0;g=L[l+12>>2];h=L[a+720>>2]}L[d>>2]=e;e=R(g,104)+h|0;P[d+68>>2]=P[e+72>>2];P[d+72>>2]=P[e+76>>2];P[d+76>>2]=P[e+80>>2];P[d+80>>2]=P[e+84>>2];P[d+4>>2]=P[e+8>>2];P[d+8>>2]=P[e+12>>2];P[d+12>>2]=P[e+16>>2];P[d+16>>2]=P[e+20>>2];P[d+20>>2]=P[e+24>>2];P[d+24>>2]=P[e+28>>2];P[d+28>>2]=P[e+32>>2];P[d+32>>2]=P[e+36>>2];P[d+36>>2]=P[e+40>>2];P[d+40>>2]=P[e+44>>2];P[d+44>>2]=P[e+48>>2];P[d+48>>2]=P[e+52>>2];L[l+4>>2]=e;g=0;o=0;c:{d:{e:{f:{g:{h:{j=l+16|0;i=L[j+48>>2];e=L[l+4>>2];f=(e<<15^-1)+e|0;f=R(f>>10^f,9);f=f>>6^f;f=(f<<11^-1)+f|0;r=i-1&(f>>16^f);i:{if(r>>>0>=O[j+4>>2]){break i}h=L[L[j+12>>2]+(r<<2)>>2];if((h|0)==-1){break i}f=L[j+32>>2];k=L[j+72>>2];while(1){if((e|0)==L[k+(h<<3)>>2]){break h}h=L[f+(h<<2)>>2];if((h|0)!=-1){continue}break}}m=L[j+44>>2];e=m;if((i|0)!=(e|0)){break d}e=i;n=e?e<<1:1;if((e|0)>=(n|0)){break d}j:{if(!n){k=0;e=i;break j}L[8513]=L[8513]+1;k=ha[L[6798]](n<<2,16)|0;e=L[j+44>>2]}f=L[j+52>>2];if((e|0)<=0){break g}h=0;if(e>>>0>=4){p=e&-4;while(1){q=h<<2;L[q+k>>2]=L[f+q>>2];s=q|4;L[s+k>>2]=L[f+s>>2];s=q|8;L[s+k>>2]=L[f+s>>2];q=q|12;L[q+k>>2]=L[f+q>>2];h=h+4|0;g=g+4|0;if((p|0)!=(g|0)){continue}break}}e=e&3;if(!e){break f}while(1){g=h<<2;L[g+k>>2]=L[f+g>>2];h=h+1|0;o=o+1|0;if((e|0)!=(o|0)){continue}break}break f}L[L[j+52>>2]+(h<<2)>>2]=L[l+12>>2];break c}if(!f){break e}}if(f?M[j+56|0]:0){L[8514]=L[8514]+1;ha[L[6799]](f)}e=L[j+44>>2]}L[j+52>>2]=k;L[j+48>>2]=n;J[j+56|0]=1}L[L[j+52>>2]+(e<<2)>>2]=L[l+12>>2];L[j+44>>2]=L[j+44>>2]+1;f=L[j- -64>>2];k:{if((f|0)!=L[j+68>>2]){break k}n=f?f<<1:1;if((n|0)<=(f|0)){break k}l:{if(!n){k=0;break l}L[8513]=L[8513]+1;k=ha[L[6798]](n<<3,16)|0;f=L[j+64>>2]}m:{if((f|0)<=0){break m}e=0;h=0;if(f>>>0>=4){q=f&-4;o=0;while(1){g=h<<3;p=g+k|0;s=g+L[j+72>>2]|0;u=L[s+4>>2];L[p>>2]=L[s>>2];L[p+4>>2]=u;p=g|8;s=p+k|0;p=p+L[j+72>>2]|0;u=L[p+4>>2];L[s>>2]=L[p>>2];L[s+4>>2]=u;p=g|16;s=p+k|0;p=p+L[j+72>>2]|0;u=L[p+4>>2];L[s>>2]=L[p>>2];L[s+4>>2]=u;g=g|24;p=g+k|0;g=g+L[j+72>>2]|0;s=L[g+4>>2];L[p>>2]=L[g>>2];L[p+4>>2]=s;h=h+4|0;o=o+4|0;if((q|0)!=(o|0)){continue}break}}f=f&3;if(!f){break m}while(1){g=h<<3;o=g+k|0;g=g+L[j+72>>2]|0;q=L[g+4>>2];L[o>>2]=L[g>>2];L[o+4>>2]=q;h=h+1|0;e=e+1|0;if((f|0)!=(e|0)){continue}break}}e=L[j+72>>2];if(!(e?!e|!M[j+76|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](e)}L[j+72>>2]=k;J[j+76|0]=1;L[j+68>>2]=n;f=L[j+64>>2]}e=L[j+72>>2]+(f<<3)|0;f=L[l+8>>2];L[e>>2]=L[l+4>>2];L[e+4>>2]=f;L[j+64>>2]=L[j+64>>2]+1;if((i|0)>2]){nn(j);e=L[l+4>>2];e=(e<<15^-1)+e|0;e=R(e>>10^e,9);e=e>>6^e;e=(e<<11^-1)+e|0;r=L[j+48>>2]-1&(e>>16^e)}e=L[j+12>>2]+(r<<2)|0;L[L[j+32>>2]+(m<<2)>>2]=L[e>>2];L[e>>2]=m}g=L[l+12>>2]+1|0;L[l+12>>2]=g;d=d+100|0;if((g|0)<(t|0)){continue}break}}ha[L[L[c>>2]+20>>2]](c,w,4078,1145979475,v)}d=L[a+732>>2];L[b+300>>2]=d;n:{if(!d){L[b+268>>2]=0;break n}d=ha[L[L[c>>2]+28>>2]](c,L[a+740>>2])|0;L[b+268>>2]=d;if(!d){break n}f=0;e=L[b+300>>2];i=ha[L[L[c>>2]+16>>2]](c,20,e)|0;o:{if((e|0)<=0){h=L[a+740>>2];break o}h=L[a+740>>2];d=L[i+8>>2];while(1){g=0;j=R(f,52);k=j+h|0;L[d+16>>2]=0-(J[k+20|0]&1);k=L[k+4>>2];if(k){g=ha[L[L[c>>2]+28>>2]](c,k)|0;h=L[a+740>>2]}L[d>>2]=g;g=h+j|0;j=L[g+8>>2];if(j){m=(j-L[a+720>>2]|0)/104|0}else{m=-1}L[d+4>>2]=m;j=L[g+12>>2];if(j){m=(j-L[a+720>>2]|0)/104|0}else{m=-1}L[d+8>>2]=m;P[d+12>>2]=P[g+16>>2];d=d+20|0;f=f+1|0;if((e|0)!=(f|0)){continue}break}}ha[L[L[c>>2]+20>>2]](c,i,3787,1497453121,h)}d=L[a+752>>2];L[b+304>>2]=d;p:{if(!d){L[b+272>>2]=0;break p}d=ha[L[L[c>>2]+28>>2]](c,L[a+760>>2])|0;L[b+272>>2]=d;if(!d){break p}g=0;j=L[b+304>>2];k=ha[L[L[c>>2]+16>>2]](c,36,j)|0;q:{if((j|0)<=0){e=L[a+760>>2];break q}e=L[a+760>>2];d=L[k+8>>2];while(1){f=R(g,44);i=L[(f+e|0)+4>>2];r:{if(!i){h=0;break r}h=ha[L[L[c>>2]+28>>2]](c,i)|0;e=L[a+760>>2]}L[d+16>>2]=h;f=e+f|0;P[d>>2]=P[f+20>>2];P[d+4>>2]=P[f+24>>2];P[d+8>>2]=P[f+28>>2];P[d+12>>2]=P[f+32>>2];i=L[a+720>>2];h=L[f+8>>2];if(h){m=(h-i|0)/104|0}else{m=-1}L[d+20>>2]=m;h=L[f+12>>2];if(h){m=(h-i|0)/104|0}else{m=-1}L[d+24>>2]=m;h=L[f+16>>2];if(h){i=(h-i|0)/104|0}else{i=-1}L[d+28>>2]=i;P[d+32>>2]=P[f+36>>2];d=d+36|0;g=g+1|0;if((j|0)!=(g|0)){continue}break}}ha[L[L[c>>2]+20>>2]](c,k,4169,1497453121,e)}d=L[a+772>>2];L[b+308>>2]=d;s:{if(!d){L[b+276>>2]=0;break s}d=ha[L[L[c>>2]+28>>2]](c,L[a+780>>2])|0;L[b+276>>2]=d;if(!d){break s}e=0;h=L[b+308>>2];j=ha[L[L[c>>2]+16>>2]](c,100,h)|0;t:{if((h|0)<=0){g=L[a+780>>2];break t}g=L[a+780>>2];d=L[j+8>>2];while(1){i=L[a+720>>2];o=R(e,104);f=o+g|0;P[d>>2]=P[f+32>>2];P[d+4>>2]=P[f+36>>2];P[d+8>>2]=P[f+40>>2];P[d+12>>2]=P[f+44>>2];k=L[g+8>>2];if(k){m=(k-i|0)/104|0}else{m=-1}L[d+68>>2]=m;P[d+16>>2]=P[f+48>>2];P[d+20>>2]=P[f+52>>2];P[d+24>>2]=P[f+56>>2];P[d+28>>2]=P[f+60>>2];k=L[g+116>>2];if(k){m=(k-i|0)/104|0}else{m=-1}L[d+72>>2]=m;P[d+32>>2]=P[f- -64>>2];P[d+36>>2]=P[f+68>>2];P[d+40>>2]=P[f+72>>2];P[d+44>>2]=P[f+76>>2];k=L[g+224>>2];if(k){m=(k-i|0)/104|0}else{m=-1}L[d+76>>2]=m;P[d+48>>2]=P[f+80>>2];P[d+52>>2]=P[f+84>>2];P[d+56>>2]=P[f+88>>2];P[d+60>>2]=P[f+92>>2];k=L[g+332>>2];if(k){i=(k-i|0)/104|0}else{i=-1}L[d+80>>2]=i;P[d+88>>2]=P[f+96>>2];P[d+92>>2]=P[f+100>>2];f=L[f+4>>2];u:{if(!f){f=0;break u}f=ha[L[L[c>>2]+28>>2]](c,f)|0;g=L[a+780>>2]}L[d+64>>2]=f;P[d+84>>2]=P[(g+o|0)+24>>2];d=d+100|0;e=e+1|0;if((h|0)!=(e|0)){continue}break}}ha[L[L[c>>2]+20>>2]](c,j,4211,1497453121,g)}d=L[a+792>>2];L[b+312>>2]=d;v:{if(!d){L[b+280>>2]=0;break v}d=ha[L[L[c>>2]+28>>2]](c,L[a+800>>2])|0;L[b+280>>2]=d;if(!d){break v}f=L[b+312>>2];i=ha[L[L[c>>2]+16>>2]](c,92,f)|0;if((f|0)>0){d=L[i+8>>2];g=0;while(1){e=L[a+800>>2]+R(g,96)|0;P[d>>2]=P[e+28>>2];P[d+4>>2]=P[e+32>>2];P[d+8>>2]=P[e+36>>2];P[d+12>>2]=P[e+40>>2];P[d+16>>2]=P[e+44>>2];P[d+20>>2]=P[e+48>>2];P[d+24>>2]=P[e+52>>2];P[d+28>>2]=P[e+56>>2];P[d+32>>2]=P[e+60>>2];P[d+36>>2]=P[e- -64>>2];P[d+40>>2]=P[e+68>>2];P[d+44>>2]=P[e+72>>2];P[d+48>>2]=P[e+76>>2];P[d+52>>2]=P[e+80>>2];P[d+56>>2]=P[e+84>>2];P[d+60>>2]=P[e+88>>2];P[d+88>>2]=P[e+92>>2];P[d+64>>2]=P[e+4>>2];P[d+68>>2]=P[e+8>>2];P[d+72>>2]=P[e+12>>2];P[d+76>>2]=P[e+16>>2];h=L[e>>2];if(h){m=(h-L[a+720>>2]|0)/104|0}else{m=-1}L[d+84>>2]=m;e=L[e+20>>2];if(e){e=ha[L[L[c>>2]+28>>2]](c,e)|0}else{e=0}L[d+80>>2]=e;d=d+92|0;g=g+1|0;if((f|0)!=(g|0)){continue}break}}ha[L[L[c>>2]+20>>2]](c,i,3705,1497453121,L[a+800>>2])}P[b+352>>2]=P[a+316>>2];P[b+328>>2]=P[a+292>>2];P[b+344>>2]=P[a+308>>2];L[b+324>>2]=L[a+288>>2];P[b+340>>2]=P[a+304>>2];P[b+336>>2]=P[a+300>>2];L[b+412>>2]=L[a+376>>2];L[b+416>>2]=L[a+380>>2];L[b+420>>2]=L[a+384>>2];L[b+408>>2]=L[a+372>>2];x=P[a+364>>2];P[b+332>>2]=P[a+296>>2];P[b+356>>2]=P[a+320>>2];L[b+424>>2]=L[a+388>>2];P[b+348>>2]=P[a+312>>2];P[b+360>>2]=P[a+324>>2];P[b+364>>2]=P[a+328>>2];P[b+368>>2]=P[a+332>>2];P[b+372>>2]=P[a+336>>2];y=P[a+368>>2];P[b+400>>2]=x;P[b+404>>2]=y;P[b+376>>2]=P[a+340>>2];P[b+380>>2]=P[a+344>>2];P[b+384>>2]=P[a+348>>2];P[b+388>>2]=P[a+352>>2];P[b+392>>2]=P[a+356>>2];P[b+396>>2]=P[a+360>>2];o=a+472|0;L[b+256>>2]=ha[L[L[c>>2]+28>>2]](c,o);n=ha[L[L[c>>2]+16>>2]](c,192,1)|0;d=L[n+8>>2];P[d+96>>2]=P[a+632>>2];P[d+100>>2]=P[a+636>>2];P[d+104>>2]=P[a+640>>2];P[d+108>>2]=P[a+644>>2];P[d+112>>2]=P[a+648>>2];P[d+116>>2]=P[a+652>>2];P[d+120>>2]=P[a+656>>2];P[d+124>>2]=P[a+660>>2];P[d+128>>2]=P[a+664>>2];P[d+132>>2]=P[a+668>>2];P[d+136>>2]=P[a+672>>2];P[d+140>>2]=P[a+676>>2];L[d+180>>2]=M[a+473|0];L[d+176>>2]=M[a+472|0];P[d+144>>2]=P[a+520>>2];P[d+148>>2]=P[a+524>>2];P[d+152>>2]=P[a+528>>2];P[d+156>>2]=P[a+532>>2];e=L[a+484>>2];L[d+168>>2]=e;w:{if(!e){L[d+160>>2]=0;break w}L[d+160>>2]=ha[L[L[c>>2]+28>>2]](c,L[a+492>>2]);i=L[d+168>>2];if(!i){break w}h=0;j=ha[L[L[c>>2]+16>>2]](c,16,i)|0;x:{if((i|0)<=0){e=L[a+492>>2];break x}e=L[a+492>>2];f=L[j+8>>2];if((i|0)!=1){q=i&-2;k=0;while(1){r=h<<4;g=r+e|0;P[f>>2]=P[g>>2];P[f+4>>2]=P[g+4>>2];P[f+8>>2]=P[g+8>>2];P[f+12>>2]=P[g+12>>2];g=(r|16)+e|0;P[f+16>>2]=P[g>>2];P[f+20>>2]=P[g+4>>2];P[f+24>>2]=P[g+8>>2];P[f+28>>2]=P[g+12>>2];f=f+32|0;h=h+2|0;k=k+2|0;if((q|0)!=(k|0)){continue}break}}if(!(i&1)){break x}i=(h<<4)+e|0;P[f>>2]=P[i>>2];P[f+4>>2]=P[i+4>>2];P[f+8>>2]=P[i+8>>2];P[f+12>>2]=P[i+12>>2]}ha[L[L[c>>2]+20>>2]](c,j,3686,1497453121,e)}P[d+184>>2]=P[a+476>>2];P[d>>2]=P[a+536>>2];P[d+4>>2]=P[a+540>>2];P[d+8>>2]=P[a+544>>2];P[d+12>>2]=P[a+548>>2];P[d+16>>2]=P[a+552>>2];P[d+20>>2]=P[a+556>>2];P[d+24>>2]=P[a+560>>2];P[d+28>>2]=P[a+564>>2];P[d+32>>2]=P[a+568>>2];P[d+36>>2]=P[a+572>>2];P[d+40>>2]=P[a+576>>2];P[d+44>>2]=P[a+580>>2];P[d+48>>2]=P[a+584>>2];P[d+52>>2]=P[a+588>>2];P[d+56>>2]=P[a+592>>2];P[d+60>>2]=P[a+596>>2];P[d- -64>>2]=P[a+600>>2];P[d+68>>2]=P[a+604>>2];P[d+72>>2]=P[a+608>>2];P[d+76>>2]=P[a+612>>2];P[d+80>>2]=P[a+616>>2];P[d+84>>2]=P[a+620>>2];P[d+88>>2]=P[a+624>>2];P[d+92>>2]=P[a+628>>2];e=L[a+504>>2];L[d+172>>2]=e;y:{if(!e){L[d+164>>2]=0;break y}L[d+164>>2]=ha[L[L[c>>2]+28>>2]](c,L[a+512>>2]);i=L[d+172>>2];if(!i){break y}f=0;j=ha[L[L[c>>2]+16>>2]](c,4,i)|0;z:{if((i|0)<=0){g=L[a+512>>2];break z}g=L[a+512>>2];d=L[j+8>>2];if(i>>>0>=4){k=i&-4;e=0;while(1){h=f<<2;P[d>>2]=P[h+g>>2];P[d+4>>2]=P[(h|4)+g>>2];P[d+8>>2]=P[(h|8)+g>>2];P[d+12>>2]=P[(h|12)+g>>2];d=d+16|0;f=f+4|0;e=e+4|0;if((k|0)!=(e|0)){continue}break}}e=i&3;if(!e){break z}h=0;while(1){P[d>>2]=P[(f<<2)+g>>2];d=d+4|0;f=f+1|0;h=h+1|0;if((e|0)!=(h|0)){continue}break}}ha[L[L[c>>2]+20>>2]](c,j,2508,1497453121,g)}ha[L[L[c>>2]+20>>2]](c,n,3804,1497453121,o);d=L[a+1112>>2];L[b+316>>2]=d;A:{if(!d){L[b+284>>2]=0;break A}L[b+284>>2]=ha[L[L[c>>2]+28>>2]](c,L[L[a+1120>>2]>>2]);j=L[b+316>>2];if(!j){break A}q=ha[L[L[c>>2]+16>>2]](c,348,j)|0;if((j|0)>0){e=L[q+8>>2];o=0;while(1){i=o<<2;d=L[i+L[a+1120>>2]>>2];P[e+320>>2]=P[d+360>>2];P[e+256>>2]=P[d+332>>2];P[e+260>>2]=P[d+336>>2];P[e+264>>2]=P[d+340>>2];P[e+268>>2]=P[d+344>>2];L[e+344>>2]=L[d+380>>2];L[e+340>>2]=M[d+377|0];P[e+160>>2]=P[d+228>>2];P[e+164>>2]=P[d+232>>2];P[e+168>>2]=P[d+236>>2];P[e+172>>2]=P[d+240>>2];L[e+336>>2]=M[d+376|0];P[e+208>>2]=P[d+276>>2];P[e+212>>2]=P[d+280>>2];P[e+216>>2]=P[d+284>>2];P[e+220>>2]=P[d+288>>2];P[e+224>>2]=P[d+292>>2];P[e+228>>2]=P[d+296>>2];P[e+232>>2]=P[d+300>>2];P[e+236>>2]=P[d+304>>2];P[e>>2]=P[d+60>>2];P[e+4>>2]=P[d- -64>>2];P[e+8>>2]=P[d+68>>2];P[e+12>>2]=P[d+72>>2];P[e+16>>2]=P[d+76>>2];P[e+20>>2]=P[d+80>>2];P[e+24>>2]=P[d+84>>2];P[e+28>>2]=P[d+88>>2];P[e+32>>2]=P[d+92>>2];P[e+36>>2]=P[d+96>>2];P[e+40>>2]=P[d+100>>2];P[e+44>>2]=P[d+104>>2];P[e+48>>2]=P[d+108>>2];P[e+52>>2]=P[d+112>>2];P[e+56>>2]=P[d+116>>2];P[e+60>>2]=P[d+120>>2];P[e+296>>2]=P[d+124>>2];P[e+300>>2]=P[d+128>>2];P[e+112>>2]=P[d+180>>2];P[e+116>>2]=P[d+184>>2];P[e+120>>2]=P[d+188>>2];P[e+124>>2]=P[d+192>>2];P[e+128>>2]=P[d+196>>2];P[e+132>>2]=P[d+200>>2];P[e+136>>2]=P[d+204>>2];P[e+140>>2]=P[d+208>>2];P[e+144>>2]=P[d+212>>2];P[e+148>>2]=P[d+216>>2];P[e+152>>2]=P[d+220>>2];P[e+156>>2]=P[d+224>>2];P[e+316>>2]=P[d+356>>2];P[e+64>>2]=P[d+132>>2];P[e+68>>2]=P[d+136>>2];P[e+72>>2]=P[d+140>>2];P[e+76>>2]=P[d+144>>2];P[e+80>>2]=P[d+148>>2];P[e+84>>2]=P[d+152>>2];P[e+88>>2]=P[d+156>>2];P[e+92>>2]=P[d+160>>2];P[e+96>>2]=P[d+164>>2];P[e+100>>2]=P[d+168>>2];P[e+104>>2]=P[d+172>>2];P[e+108>>2]=P[d+176>>2];P[e+240>>2]=P[d+316>>2];P[e+244>>2]=P[d+320>>2];P[e+248>>2]=P[d+324>>2];P[e+252>>2]=P[d+328>>2];P[e+324>>2]=P[d+364>>2];P[e+328>>2]=P[d+368>>2];P[e+312>>2]=P[d+352>>2];P[e+316>>2]=P[d+356>>2];P[e+320>>2]=P[d+360>>2];P[e+332>>2]=P[d+372>>2];f=L[d+44>>2];L[e+284>>2]=f;L[e+292>>2]=L[d+4>>2];L[e+288>>2]=L[d+24>>2];L[e+304>>2]=L[d+308>>2];P[e+176>>2]=P[d+244>>2];P[e+180>>2]=P[d+248>>2];P[e+184>>2]=P[d+252>>2];P[e+188>>2]=P[d+256>>2];P[e+192>>2]=P[d+260>>2];P[e+196>>2]=P[d+264>>2];P[e+200>>2]=P[d+268>>2];P[e+204>>2]=P[d+272>>2];L[e+308>>2]=L[d+312>>2];B:{if(!f){L[e+272>>2]=0;break B}d=ha[L[L[c>>2]+28>>2]](c,L[d+52>>2])|0;L[e+272>>2]=d;if(!d){break B}f=L[e+284>>2];r=ha[L[L[c>>2]+16>>2]](c,16,f)|0;C:{if((f|0)<=0){h=L[L[i+L[a+1120>>2]>>2]+52>>2];break C}h=L[L[i+L[a+1120>>2]>>2]+52>>2];d=L[r+8>>2];g=0;if((f|0)!=1){t=f&-2;k=0;while(1){m=g<<4;n=m+h|0;P[d>>2]=P[n>>2];P[d+4>>2]=P[n+4>>2];P[d+8>>2]=P[n+8>>2];P[d+12>>2]=P[n+12>>2];n=(m|16)+h|0;P[d+16>>2]=P[n>>2];P[d+20>>2]=P[n+4>>2];P[d+24>>2]=P[n+8>>2];P[d+28>>2]=P[n+12>>2];d=d+32|0;g=g+2|0;k=k+2|0;if((t|0)!=(k|0)){continue}break}}if(!(f&1)){break C}f=(g<<4)+h|0;P[d>>2]=P[f>>2];P[d+4>>2]=P[f+4>>2];P[d+8>>2]=P[f+8>>2];P[d+12>>2]=P[f+12>>2]}ha[L[L[c>>2]+20>>2]](c,r,3686,1497453121,h)}D:{if(!L[e+292>>2]){L[e+280>>2]=0;break D}d=ha[L[L[c>>2]+28>>2]](c,L[L[i+L[a+1120>>2]>>2]+12>>2])|0;L[e+280>>2]=d;if(!d){break D}f=L[e+292>>2];r=ha[L[L[c>>2]+16>>2]](c,4,f)|0;E:{if((f|0)<=0){g=L[L[i+L[a+1120>>2]>>2]+12>>2];break E}t=f&3;g=L[L[i+L[a+1120>>2]>>2]+12>>2];d=L[r+8>>2];k=0;F:{if(f>>>0<4){f=0;break F}m=f&-4;f=0;h=0;while(1){n=f<<2;P[d>>2]=P[n+g>>2];P[d+4>>2]=P[(n|4)+g>>2];P[d+8>>2]=P[(n|8)+g>>2];P[d+12>>2]=P[(n|12)+g>>2];d=d+16|0;f=f+4|0;h=h+4|0;if((m|0)!=(h|0)){continue}break}}if(!t){break E}while(1){P[d>>2]=P[(f<<2)+g>>2];d=d+4|0;f=f+1|0;k=k+1|0;if((t|0)!=(k|0)){continue}break}}ha[L[L[c>>2]+20>>2]](c,r,2508,1497453121,g)}G:{if(!L[e+288>>2]){L[e+276>>2]=0;break G}d=ha[L[L[c>>2]+28>>2]](c,L[i+L[a+1120>>2]>>2]+20|0)|0;L[e+276>>2]=d;if(!d){break G}g=L[e+292>>2];n=ha[L[L[c>>2]+16>>2]](c,4,g)|0;H:{if((g|0)<=0){f=L[i+L[a+1120>>2]>>2];break H}f=L[i+L[a+1120>>2]>>2];t=L[f+32>>2];k=L[n+8>>2];h=0;m=L[l+68>>2];r=L[l+88>>2];v=L[l+28>>2];while(1){i=L[t+(h<<2)>>2];d=(i<<15^-1)+i|0;d=R(d>>10^d,9);d=d>>6^d;d=(d<<11^-1)+d|0;d=L[v+((L[l+64>>2]-1&(d>>16^d))<<2)>>2];if(L[r+(d<<3)>>2]!=(i|0)){w=L[l+48>>2];while(1){d=L[w+(d<<2)>>2];if((i|0)!=L[r+(d<<3)>>2]){continue}break}}L[k>>2]=L[m+(d<<2)>>2];k=k+4|0;h=h+1|0;if((g|0)!=(h|0)){continue}break}}ha[L[L[c>>2]+20>>2]](c,n,2504,1497453121,f+20|0)}e=e+348|0;o=o+1|0;if((j|0)!=(o|0)){continue}break}}ha[L[L[c>>2]+20>>2]](c,q,3725,1497453121,L[L[a+1120>>2]>>2])}d=L[a+852>>2];L[b+320>>2]=d;I:{if(!d){L[b+288>>2]=0;break I}d=b;b=ha[L[L[c>>2]+28>>2]](c,L[a+860>>2])|0;L[d+288>>2]=b;if(!b){break I}i=L[a+852>>2];g=ha[L[L[c>>2]+16>>2]](c,104,i)|0;if((i|0)>0){d=L[g+8>>2];h=0;while(1){e=h<<2;b=L[e+L[a+860>>2]>>2];L[d+96>>2]=ha[L[L[b>>2]+20>>2]](b);f=e+L[a+860>>2]|0;b=L[f>>2];P[d+8>>2]=P[b+28>>2];P[d+12>>2]=P[b+32>>2];P[d+16>>2]=P[b+36>>2];P[d+20>>2]=P[b+40>>2];P[d+24>>2]=P[b+44>>2];P[d+28>>2]=P[b+48>>2];P[d+32>>2]=P[b+52>>2];P[d+36>>2]=P[b+56>>2];P[d+40>>2]=P[b+60>>2];P[d+44>>2]=P[b+64>>2];P[d+48>>2]=P[b+68>>2];b=M[b+152|0];L[d+56>>2]=0;L[d+60>>2]=0;L[d>>2]=0;L[d+4>>2]=0;L[d+52>>2]=b;b=d- -64|0;L[b>>2]=0;L[b+4>>2]=0;L[d+72>>2]=0;L[d+76>>2]=0;L[d+80>>2]=0;L[d+84>>2]=0;f=L[f>>2];b=L[f+4>>2];if(b){L[d+88>>2]=1;L[d>>2]=ha[L[L[c>>2]+28>>2]](c,b);f=L[e+L[a+860>>2]>>2]}b=L[f+12>>2];if(b){L[d+88>>2]=3;L[d>>2]=ha[L[L[c>>2]+28>>2]](c,b);f=L[e+L[a+860>>2]>>2]}b=L[f+8>>2];if(b){L[d+88>>2]=2;L[d>>2]=ha[L[L[c>>2]+28>>2]](c,b);f=L[e+L[a+860>>2]>>2]}b=L[f+16>>2];if(b){L[d+92>>2]=1;L[d+4>>2]=ha[L[L[c>>2]+28>>2]](c,b);f=L[e+L[a+860>>2]>>2]}b=L[f+24>>2];if(b){L[d+92>>2]=3;L[d+4>>2]=ha[L[L[c>>2]+28>>2]](c,b);f=L[e+L[a+860>>2]>>2]}b=L[f+20>>2];if(b){L[d+92>>2]=2;L[d+4>>2]=ha[L[L[c>>2]+28>>2]](c,b)}d=d+104|0;h=h+1|0;if((i|0)!=(h|0)){continue}break}}ha[L[L[c>>2]+20>>2]](c,g,3301,1497453121,L[a+860>>2])}a=L[l+88>>2];if(!(a?!a|!M[l+92|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](a)}L[l+88>>2]=0;J[l+92|0]=1;L[l+80>>2]=0;L[l+84>>2]=0;a=L[l+68>>2];if(!(a?!a|!M[l+72|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](a)}L[l+68>>2]=0;J[l+72|0]=1;L[l+60>>2]=0;L[l+64>>2]=0;a=L[l+48>>2];if(!(a?!a|!M[l+52|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](a)}L[l+48>>2]=0;J[l+52|0]=1;L[l+40>>2]=0;L[l+44>>2]=0;a=L[l+28>>2];if(!(a?!a|!M[l+32|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](a)}fa=l+96|0;return 3482}function Vk(a){a=a|0;var b=0,c=0,d=0,e=0,f=S(0),g=S(0),h=0,i=S(0),j=S(0),k=S(0),l=S(0),m=S(0),n=0,o=S(0),p=S(0),q=0,r=S(0),s=S(0),t=S(0),u=S(0),v=S(0),w=S(0),x=S(0),y=0,z=S(0),A=S(0),B=S(0),C=S(0),D=S(0),E=S(0),F=0,G=S(0),H=S(0),I=S(0),J=0,K=0;wa(3256);on(a);a:{if(!(ha[L[L[a>>2]+20>>2]](a)|0)){break a}c=ha[L[L[a>>2]+20>>2]](a)|0;if(!(ha[L[L[c>>2]+48>>2]](c)&6144)){break a}J=ha[L[L[a>>2]+104>>2]](a)|0;if((J|0)<=0){break a}while(1){K=J-1|0;d=ha[L[L[a>>2]+108>>2]](a,K)|0;b=fa-224|0;fa=b;c=ha[L[L[a>>2]+20>>2]](a)|0;c=ha[L[L[c>>2]+48>>2]](c)|0;e=ha[L[L[a>>2]+20>>2]](a)|0;e=ha[L[L[e>>2]+48>>2]](e)|0;z=P[d+40>>2];b:{if(z<=S(0)){break b}h=c&2048;q=e&4096;c:{switch(L[d+4>>2]-3|0){case 0:L[b+172>>2]=0;L[b+176>>2]=0;L[b+184>>2]=0;L[b+188>>2]=0;L[b+180>>2]=1065353216;L[b+192>>2]=0;L[b+196>>2]=0;L[b+200>>2]=1065353216;L[b+204>>2]=0;L[b+164>>2]=0;L[b+168>>2]=0;L[b+160>>2]=1065353216;c=L[d+28>>2];j=P[c+52>>2];k=P[c+8>>2];l=P[c+12>>2];m=P[c+56>>2];o=P[c+20>>2];p=P[c+24>>2];u=P[c+28>>2];r=P[c+60>>2];s=P[c+36>>2];f=P[d+304>>2];t=P[c+40>>2];g=P[d+308>>2];v=P[c+44>>2];w=P[c+4>>2];i=P[d+300>>2];L[b+220>>2]=0;P[b+216>>2]=r+S(S(g*v)+S(S(i*s)+S(f*t)));P[b+212>>2]=m+S(S(g*u)+S(S(i*o)+S(f*p)));P[b+208>>2]=j+S(S(g*l)+S(S(i*w)+S(f*k)));c=ha[L[L[a>>2]+20>>2]](a)|0;ha[L[L[c>>2]+56>>2]](c,b+160|0,z);c=L[d+32>>2];j=P[c+52>>2];k=P[c+8>>2];l=P[c+12>>2];m=P[c+56>>2];o=P[c+20>>2];p=P[c+24>>2];u=P[c+28>>2];r=P[c+60>>2];s=P[c+36>>2];f=P[d+320>>2];t=P[c+40>>2];g=P[d+324>>2];v=P[c+44>>2];w=P[c+4>>2];i=P[d+316>>2];L[b+220>>2]=0;P[b+216>>2]=r+S(S(g*v)+S(S(i*s)+S(f*t)));P[b+212>>2]=m+S(S(g*u)+S(S(i*o)+S(f*p)));P[b+208>>2]=j+S(S(g*l)+S(S(i*w)+S(f*k)));if(!h){break b}c=ha[L[L[a>>2]+20>>2]](a)|0;ha[L[L[c>>2]+56>>2]](c,b+160|0,z);break b;case 1:c=L[d+28>>2];G=P[c+52>>2];f=P[c+8>>2];g=P[c+12>>2];u=P[d+568>>2];r=P[d+584>>2];H=P[c+56>>2];I=P[c+60>>2];s=P[d+608>>2];t=P[d+600>>2];v=P[d+604>>2];i=P[c+28>>2];j=P[c+20>>2];k=P[c+24>>2];w=P[d+588>>2];x=P[d+556>>2];A=P[d+572>>2];B=P[d+592>>2];l=P[c+44>>2];C=P[d+560>>2];m=P[c+36>>2];D=P[d+576>>2];o=P[c+40>>2];p=P[c+4>>2];E=P[d+552>>2];L[b+220>>2]=0;L[b+204>>2]=0;L[b+188>>2]=0;P[b+200>>2]=S(B*l)+S(S(C*m)+S(D*o));P[b+196>>2]=S(w*l)+S(S(x*m)+S(A*o));P[b+184>>2]=S(B*i)+S(S(C*j)+S(D*k));P[b+180>>2]=S(w*i)+S(S(x*j)+S(A*k));P[b+216>>2]=I+S(S(s*l)+S(S(t*m)+S(o*v)));P[b+212>>2]=H+S(S(s*i)+S(S(t*j)+S(k*v)));L[b+172>>2]=0;P[b+192>>2]=S(r*l)+S(S(E*m)+S(u*o));P[b+176>>2]=S(r*i)+S(S(E*j)+S(u*k));P[b+168>>2]=S(B*g)+S(S(C*p)+S(f*D));P[b+164>>2]=S(w*g)+S(S(x*p)+S(f*A));P[b+160>>2]=S(r*g)+S(S(E*p)+S(u*f));P[b+208>>2]=G+S(S(s*g)+S(S(t*p)+S(f*v)));d:{if(h){c=ha[L[L[a>>2]+20>>2]](a)|0;e=b+160|0;ha[L[L[c>>2]+56>>2]](c,e,z);c=L[d+32>>2];G=P[c+52>>2];H=P[c+56>>2];I=P[c+60>>2];u=P[d+672>>2];r=P[d+664>>2];s=P[d+668>>2];f=P[c+8>>2];g=P[c+12>>2];i=P[c+28>>2];j=P[c+20>>2];k=P[c+24>>2];t=P[d+632>>2];v=P[d+648>>2];w=P[d+652>>2];x=P[d+620>>2];A=P[d+636>>2];B=P[d+656>>2];l=P[c+44>>2];C=P[d+624>>2];m=P[c+36>>2];D=P[d+640>>2];o=P[c+40>>2];p=P[c+4>>2];E=P[d+616>>2];L[b+220>>2]=0;L[b+204>>2]=0;L[b+188>>2]=0;L[b+172>>2]=0;P[b+200>>2]=S(B*l)+S(S(C*m)+S(D*o));P[b+196>>2]=S(w*l)+S(S(x*m)+S(A*o));P[b+192>>2]=S(v*l)+S(S(E*m)+S(t*o));P[b+184>>2]=S(B*i)+S(S(C*j)+S(D*k));P[b+180>>2]=S(w*i)+S(S(x*j)+S(A*k));P[b+176>>2]=S(v*i)+S(S(E*j)+S(t*k));P[b+168>>2]=S(B*g)+S(S(C*p)+S(f*D));P[b+164>>2]=S(w*g)+S(S(x*p)+S(f*A));P[b+160>>2]=S(v*g)+S(S(E*p)+S(t*f));P[b+216>>2]=I+S(S(u*l)+S(S(r*m)+S(o*s)));P[b+212>>2]=H+S(S(u*i)+S(S(r*j)+S(k*s)));P[b+208>>2]=G+S(S(u*g)+S(S(r*p)+S(f*s)));c=ha[L[L[a>>2]+20>>2]](a)|0;ha[L[L[c>>2]+56>>2]](c,e,z);break d}c=L[d+32>>2];G=P[c+52>>2];H=P[c+56>>2];I=P[c+60>>2];u=P[d+672>>2];r=P[d+664>>2];s=P[d+668>>2];f=P[c+8>>2];g=P[c+12>>2];i=P[c+28>>2];j=P[c+20>>2];k=P[c+24>>2];t=P[d+632>>2];v=P[d+648>>2];w=P[d+652>>2];x=P[d+620>>2];A=P[d+636>>2];B=P[d+656>>2];l=P[c+44>>2];C=P[d+624>>2];m=P[c+36>>2];D=P[d+640>>2];o=P[c+40>>2];p=P[c+4>>2];E=P[d+616>>2];L[b+220>>2]=0;L[b+204>>2]=0;L[b+188>>2]=0;L[b+172>>2]=0;P[b+200>>2]=S(B*l)+S(S(C*m)+S(D*o));P[b+196>>2]=S(w*l)+S(S(x*m)+S(A*o));P[b+192>>2]=S(v*l)+S(S(E*m)+S(t*o));P[b+184>>2]=S(B*i)+S(S(C*j)+S(D*k));P[b+180>>2]=S(w*i)+S(S(x*j)+S(A*k));P[b+176>>2]=S(v*i)+S(S(E*j)+S(t*k));P[b+168>>2]=S(B*g)+S(S(C*p)+S(f*D));P[b+164>>2]=S(w*g)+S(S(x*p)+S(f*A));P[b+160>>2]=S(v*g)+S(S(E*p)+S(t*f));P[b+216>>2]=I+S(S(u*l)+S(S(r*m)+S(o*s)));P[b+212>>2]=H+S(S(u*i)+S(S(r*j)+S(k*s)));P[b+208>>2]=G+S(S(u*g)+S(S(r*p)+S(f*s)))}c=d+688|0;f=we(c);g=xe(c);if(!q|f==g){break b}P[b+64>>2]=P[b+168>>2];P[b+68>>2]=P[b+184>>2];L[b+76>>2]=0;P[b+72>>2]=P[b+200>>2];P[b+144>>2]=P[b+160>>2];P[b+148>>2]=P[b+176>>2];L[b+156>>2]=0;P[b+152>>2]=P[b+192>>2];c=ha[L[L[a>>2]+20>>2]](a)|0;L[b+136>>2]=0;L[b+140>>2]=0;L[b+128>>2]=0;L[b+132>>2]=0;e=f>g;ha[L[L[c>>2]+60>>2]](c,b+208|0,b- -64|0,b+144|0,z,z,e?S(0):f,e?S(6.2831854820251465):g,b+128|0,!e,S(10));break b;case 2:c=L[d+28>>2];G=P[c+52>>2];f=P[c+8>>2];g=P[c+12>>2];u=P[d+316>>2];r=P[d+332>>2];H=P[c+56>>2];I=P[c+60>>2];s=P[d+356>>2];t=P[d+348>>2];v=P[d+352>>2];i=P[c+28>>2];j=P[c+20>>2];k=P[c+24>>2];w=P[d+336>>2];x=P[d+304>>2];A=P[d+320>>2];B=P[d+340>>2];l=P[c+44>>2];C=P[d+308>>2];m=P[c+36>>2];D=P[d+324>>2];o=P[c+40>>2];p=P[c+4>>2];E=P[d+300>>2];L[b+220>>2]=0;L[b+204>>2]=0;L[b+188>>2]=0;P[b+200>>2]=S(B*l)+S(S(C*m)+S(D*o));P[b+196>>2]=S(w*l)+S(S(x*m)+S(A*o));P[b+184>>2]=S(B*i)+S(S(C*j)+S(D*k));P[b+180>>2]=S(w*i)+S(S(x*j)+S(A*k));P[b+216>>2]=I+S(S(s*l)+S(S(t*m)+S(o*v)));P[b+212>>2]=H+S(S(s*i)+S(S(t*j)+S(k*v)));L[b+172>>2]=0;P[b+192>>2]=S(r*l)+S(S(E*m)+S(u*o));P[b+176>>2]=S(r*i)+S(S(E*j)+S(u*k));P[b+168>>2]=S(B*g)+S(S(C*p)+S(f*D));P[b+164>>2]=S(w*g)+S(S(x*p)+S(f*A));P[b+160>>2]=S(r*g)+S(S(E*p)+S(u*f));P[b+208>>2]=G+S(S(s*g)+S(S(t*p)+S(f*v)));e:{if(h){c=ha[L[L[a>>2]+20>>2]](a)|0;e=b+160|0;ha[L[L[c>>2]+56>>2]](c,e,z);c=L[d+32>>2];G=P[c+52>>2];H=P[c+56>>2];I=P[c+60>>2];u=P[d+420>>2];r=P[d+412>>2];s=P[d+416>>2];f=P[c+8>>2];g=P[c+12>>2];i=P[c+28>>2];j=P[c+20>>2];k=P[c+24>>2];t=P[d+380>>2];v=P[d+396>>2];w=P[d+400>>2];x=P[d+368>>2];A=P[d+384>>2];B=P[d+404>>2];l=P[c+44>>2];C=P[d+372>>2];m=P[c+36>>2];D=P[d+388>>2];o=P[c+40>>2];p=P[c+4>>2];E=P[d+364>>2];L[b+220>>2]=0;L[b+204>>2]=0;L[b+188>>2]=0;L[b+172>>2]=0;P[b+200>>2]=S(B*l)+S(S(C*m)+S(D*o));P[b+196>>2]=S(w*l)+S(S(x*m)+S(A*o));P[b+192>>2]=S(v*l)+S(S(E*m)+S(t*o));P[b+184>>2]=S(B*i)+S(S(C*j)+S(D*k));P[b+180>>2]=S(w*i)+S(S(x*j)+S(A*k));P[b+176>>2]=S(v*i)+S(S(E*j)+S(t*k));P[b+168>>2]=S(B*g)+S(S(C*p)+S(f*D));P[b+164>>2]=S(w*g)+S(S(x*p)+S(f*A));P[b+160>>2]=S(v*g)+S(S(E*p)+S(t*f));P[b+216>>2]=I+S(S(u*l)+S(S(r*m)+S(o*s)));P[b+212>>2]=H+S(S(u*i)+S(S(r*j)+S(k*s)));P[b+208>>2]=G+S(S(u*g)+S(S(r*p)+S(f*s)));c=ha[L[L[a>>2]+20>>2]](a)|0;ha[L[L[c>>2]+56>>2]](c,e,z);break e}c=L[d+32>>2];G=P[c+52>>2];H=P[c+56>>2];I=P[c+60>>2];u=P[d+420>>2];r=P[d+412>>2];s=P[d+416>>2];f=P[c+8>>2];g=P[c+12>>2];i=P[c+28>>2];j=P[c+20>>2];k=P[c+24>>2];t=P[d+380>>2];v=P[d+396>>2];w=P[d+400>>2];x=P[d+368>>2];A=P[d+384>>2];B=P[d+404>>2];l=P[c+44>>2];C=P[d+372>>2];m=P[c+36>>2];D=P[d+388>>2];o=P[c+40>>2];p=P[c+4>>2];E=P[d+364>>2];L[b+220>>2]=0;L[b+204>>2]=0;L[b+188>>2]=0;L[b+172>>2]=0;P[b+200>>2]=S(B*l)+S(S(C*m)+S(D*o));P[b+196>>2]=S(w*l)+S(S(x*m)+S(A*o));P[b+192>>2]=S(v*l)+S(S(E*m)+S(t*o));P[b+184>>2]=S(B*i)+S(S(C*j)+S(D*k));P[b+180>>2]=S(w*i)+S(S(x*j)+S(A*k));P[b+176>>2]=S(v*i)+S(S(E*j)+S(t*k));P[b+168>>2]=S(B*g)+S(S(C*p)+S(f*D));P[b+164>>2]=S(w*g)+S(S(x*p)+S(f*A));P[b+160>>2]=S(v*g)+S(S(E*p)+S(t*f));P[b+216>>2]=I+S(S(u*l)+S(S(r*m)+S(o*s)));P[b+212>>2]=H+S(S(u*i)+S(S(r*j)+S(k*s)));P[b+208>>2]=G+S(S(u*g)+S(S(r*p)+S(f*s)))}if(!q){break b}F=d+300|0;c=b+208|0;pl(b+144|0,d,S(6.0868353843688965),z);L[b+156>>2]=0;f=P[b+152>>2];g=P[b+144>>2];i=P[b+148>>2];P[b+152>>2]=S(S(f*P[b+200>>2])+S(S(g*P[b+192>>2])+S(i*P[b+196>>2])))+P[b+216>>2];P[b+148>>2]=S(S(f*P[b+184>>2])+S(S(g*P[b+176>>2])+S(i*P[b+180>>2])))+P[b+212>>2];P[b+144>>2]=S(S(f*P[b+168>>2])+S(S(g*P[b+160>>2])+S(i*P[b+164>>2])))+P[b+208>>2];e=0;while(1){q=b- -64|0;pl(q,d,S(S(S(e|0)*S(6.283185005187988))*S(.03125)),z);L[b+76>>2]=0;f=P[b+72>>2];g=P[b+64>>2];i=P[b+68>>2];P[b+72>>2]=S(S(f*P[b+200>>2])+S(S(g*P[b+192>>2])+S(i*P[b+196>>2])))+P[b+216>>2];P[b+68>>2]=S(S(f*P[b+184>>2])+S(S(g*P[b+176>>2])+S(i*P[b+180>>2])))+P[b+212>>2];P[b+64>>2]=S(S(f*P[b+168>>2])+S(S(g*P[b+160>>2])+S(i*P[b+164>>2])))+P[b+208>>2];h=ha[L[L[a>>2]+20>>2]](a)|0;L[b+136>>2]=0;L[b+140>>2]=0;L[b+128>>2]=0;L[b+132>>2]=0;ha[L[L[h>>2]+8>>2]](h,b+144|0,q,b+128|0);if(!(e&3)){h=ha[L[L[a>>2]+20>>2]](a)|0;L[b+136>>2]=0;L[b+140>>2]=0;L[b+128>>2]=0;L[b+132>>2]=0;ha[L[L[h>>2]+8>>2]](h,c,b- -64|0,b+128|0)}h=L[b+76>>2];L[b+152>>2]=L[b+72>>2];L[b+156>>2]=h;h=L[b+68>>2];L[b+144>>2]=L[b+64>>2];L[b+148>>2]=h;e=e+1|0;if((e|0)!=32){continue}break};f=P[d+512>>2];g=P[d+452>>2];e=L[d+32>>2];f:{if(P[e+344>>2]>S(0)){Td(b- -64|0,e+4|0,d+364|0);break f}Td(b- -64|0,L[d+28>>2]+4|0,F)}e=L[b+76>>2];L[b+168>>2]=L[b+72>>2];L[b+172>>2]=e;e=L[b+68>>2];L[b+160>>2]=L[b+64>>2];L[b+164>>2]=e;e=L[b+92>>2];L[b+184>>2]=L[b+88>>2];L[b+188>>2]=e;e=L[b+84>>2];L[b+176>>2]=L[b+80>>2];L[b+180>>2]=e;e=L[b+108>>2];L[b+200>>2]=L[b+104>>2];L[b+204>>2]=e;e=L[b+100>>2];L[b+192>>2]=L[b+96>>2];L[b+196>>2]=e;e=L[b+124>>2];L[c+8>>2]=L[b+120>>2];L[c+12>>2]=e;e=L[b+116>>2];L[c>>2]=L[b+112>>2];L[c+4>>2]=e;e=L[c+12>>2];L[b+72>>2]=L[c+8>>2];L[b+76>>2]=e;e=L[c+4>>2];L[b+64>>2]=L[c>>2];L[b+68>>2]=e;P[b+128>>2]=P[b+160>>2];P[b+132>>2]=P[b+176>>2];L[b+140>>2]=0;P[b+136>>2]=P[b+192>>2];P[b+48>>2]=P[b+164>>2];P[b+52>>2]=P[b+180>>2];L[b+60>>2]=0;P[b+56>>2]=P[b+196>>2];c=ha[L[L[a>>2]+20>>2]](a)|0;L[b+40>>2]=0;L[b+44>>2]=0;L[b+32>>2]=0;L[b+36>>2]=0;ha[L[L[c>>2]+60>>2]](c,b- -64|0,b+128|0,b+48|0,z,z,S(S(-f)-g),S(g-f),b+32|0,1,S(10));break b;case 3:case 6:c=d+1072|0;e=L[c+4>>2];L[b+168>>2]=L[c>>2];L[b+172>>2]=e;c=L[d+1068>>2];L[b+160>>2]=L[d+1064>>2];L[b+164>>2]=c;c=d+1088|0;e=L[c+4>>2];L[b+184>>2]=L[c>>2];L[b+188>>2]=e;F=d+1080|0;c=L[F+4>>2];L[b+176>>2]=L[F>>2];L[b+180>>2]=c;c=d+1104|0;e=L[c+4>>2];L[b+200>>2]=L[c>>2];L[b+204>>2]=e;c=d+1096|0;e=L[c+4>>2];L[b+192>>2]=L[c>>2];L[b+196>>2]=e;e=d+1120|0;n=L[e+4>>2];L[b+216>>2]=L[e>>2];L[b+220>>2]=n;e=d+1112|0;n=L[e+4>>2];L[b+208>>2]=L[e>>2];L[b+212>>2]=n;if(h){h=ha[L[L[a>>2]+20>>2]](a)|0;n=b+160|0;ha[L[L[h>>2]+56>>2]](h,n,z);h=d+1136|0;y=L[h+4>>2];L[b+168>>2]=L[h>>2];L[b+172>>2]=y;h=L[d+1132>>2];L[b+160>>2]=L[d+1128>>2];L[b+164>>2]=h;h=d+1152|0;y=L[h+4>>2];L[b+184>>2]=L[h>>2];L[b+188>>2]=y;h=d+1144|0;y=L[h+4>>2];L[b+176>>2]=L[h>>2];L[b+180>>2]=y;h=d+1168|0;y=L[h+4>>2];L[b+200>>2]=L[h>>2];L[b+204>>2]=y;h=d+1160|0;y=L[h+4>>2];L[b+192>>2]=L[h>>2];L[b+196>>2]=y;h=d+1184|0;y=L[h+4>>2];L[b+216>>2]=L[h>>2];L[b+220>>2]=y;h=d+1176|0;y=L[h+4>>2];L[b+208>>2]=L[h>>2];L[b+212>>2]=y;h=ha[L[L[a>>2]+20>>2]](a)|0;ha[L[L[h>>2]+56>>2]](h,n,z)}if(!q){break b}h=d+1064|0;q=L[h+12>>2];L[b+168>>2]=L[h+8>>2];L[b+172>>2]=q;q=L[h+4>>2];L[b+160>>2]=L[h>>2];L[b+164>>2]=q;q=L[F+12>>2];L[b+184>>2]=L[F+8>>2];L[b+188>>2]=q;q=L[F+4>>2];L[b+176>>2]=L[F>>2];L[b+180>>2]=q;q=L[c+12>>2];L[b+200>>2]=L[c+8>>2];L[b+204>>2]=q;q=L[c+4>>2];L[b+192>>2]=L[c>>2];L[b+196>>2]=q;q=L[e+12>>2];L[b+216>>2]=L[e+8>>2];L[b+220>>2]=q;q=L[e+4>>2];L[b+208>>2]=L[e>>2];L[b+212>>2]=q;P[b+64>>2]=P[b+168>>2];P[b+68>>2]=P[b+184>>2];L[b+76>>2]=0;P[b+72>>2]=P[b+200>>2];P[b+144>>2]=P[b+160>>2];P[b+148>>2]=P[b+176>>2];L[b+156>>2]=0;P[b+152>>2]=P[b+192>>2];f=P[d+1e3>>2];g=P[d+996>>2];i=P[d+936>>2];j=P[d+932>>2];n=ha[L[L[a>>2]+20>>2]](a)|0;L[b+136>>2]=0;L[b+140>>2]=0;L[b+128>>2]=0;L[b+132>>2]=0;q=d+1176|0;ha[L[L[n>>2]+64>>2]](n,q,b- -64|0,b+144|0,S(z*S(.8999999761581421)),j,i,g,f,b+128|0,S(10),1);L[b+156>>2]=0;P[b+152>>2]=P[b+196>>2];P[b+148>>2]=P[b+180>>2];P[b+144>>2]=P[b+164>>2];j=P[d+1196>>2];f=P[b+144>>2];i=P[d+1200>>2];g=Ea(i);k=P[b+148>>2];l=Fa(i);P[b+132>>2]=S(k*l)-S(g*f);i=Ea(j);m=P[b+152>>2];j=Fa(j);P[b+136>>2]=S(m*j)+S(S(f*S(i*l))+S(k*S(i*g)));P[b+128>>2]=S(S(f*S(j*l))+S(k*S(j*g)))-S(i*m);n=d+1136|0;y=L[n+4>>2];L[b+168>>2]=L[n>>2];L[b+172>>2]=y;n=L[d+1132>>2];L[b+160>>2]=L[d+1128>>2];L[b+164>>2]=n;n=d+1152|0;y=L[n+4>>2];L[b+184>>2]=L[n>>2];L[b+188>>2]=y;n=d+1144|0;y=L[n+4>>2];L[b+176>>2]=L[n>>2];L[b+180>>2]=y;n=d+1168|0;y=L[n+4>>2];L[b+200>>2]=L[n>>2];L[b+204>>2]=y;n=d+1160|0;y=L[n+4>>2];L[b+192>>2]=L[n>>2];L[b+196>>2]=y;n=d+1184|0;y=L[n+4>>2];L[b+216>>2]=L[n>>2];L[b+220>>2]=y;n=L[q+4>>2];L[b+208>>2]=L[q>>2];L[b+212>>2]=n;L[b+60>>2]=0;P[b+56>>2]=-P[b+192>>2];P[b+52>>2]=-P[b+176>>2];P[b+48>>2]=-P[b+160>>2];f=P[d+868>>2];g=P[d+872>>2];g:{if(f>g){n=ha[L[L[a>>2]+20>>2]](a)|0;L[b+40>>2]=0;L[b+44>>2]=0;L[b+32>>2]=0;L[b+36>>2]=0;ha[L[L[n>>2]+60>>2]](n,q,b+48|0,b+128|0,z,z,S(-3.1415927410125732),S(3.1415927410125732),b+32|0,0,S(10));break g}if(!(f>2]+20>>2]](a)|0;L[b+40>>2]=0;L[b+44>>2]=0;L[b+32>>2]=0;L[b+36>>2]=0;ha[L[L[n>>2]+60>>2]](n,q,b+48|0,b+128|0,z,z,f,g,b+32|0,1,S(10))}q=L[h+12>>2];L[b+168>>2]=L[h+8>>2];L[b+172>>2]=q;q=L[h+4>>2];L[b+160>>2]=L[h>>2];L[b+164>>2]=q;h=L[F+12>>2];L[b+184>>2]=L[F+8>>2];L[b+188>>2]=h;h=L[F+4>>2];L[b+176>>2]=L[F>>2];L[b+180>>2]=h;h=L[c+12>>2];L[b+200>>2]=L[c+8>>2];L[b+204>>2]=h;h=L[c+4>>2];L[b+192>>2]=L[c>>2];L[b+196>>2]=h;c=L[e+12>>2];L[b+216>>2]=L[e+8>>2];L[b+220>>2]=c;c=L[e+4>>2];L[b+208>>2]=L[e>>2];L[b+212>>2]=c;c=L[d+692>>2];L[b+40>>2]=L[d+688>>2];L[b+44>>2]=c;c=L[d+684>>2];L[b+32>>2]=L[d+680>>2];L[b+36>>2]=c;c=L[d+708>>2];L[b+24>>2]=L[d+704>>2];L[b+28>>2]=c;c=L[d+700>>2];L[b+16>>2]=L[d+696>>2];L[b+20>>2]=c;c=ha[L[L[a>>2]+20>>2]](a)|0;L[b+8>>2]=0;L[b+12>>2]=0;L[b>>2]=0;L[b+4>>2]=0;ha[L[L[c>>2]+72>>2]](c,b+32|0,b+16|0,b+160|0,b);break b;case 4:break c;default:break b}}c=L[d+836>>2];L[b+168>>2]=L[d+832>>2];L[b+172>>2]=c;c=L[d+828>>2];L[b+160>>2]=L[d+824>>2];L[b+164>>2]=c;c=L[d+852>>2];L[b+184>>2]=L[d+848>>2];L[b+188>>2]=c;c=L[d+844>>2];L[b+176>>2]=L[d+840>>2];L[b+180>>2]=c;c=L[d+868>>2];L[b+200>>2]=L[d+864>>2];L[b+204>>2]=c;c=L[d+860>>2];L[b+192>>2]=L[d+856>>2];L[b+196>>2]=c;c=L[d+884>>2];L[b+216>>2]=L[d+880>>2];L[b+220>>2]=c;c=L[d+876>>2];L[b+208>>2]=L[d+872>>2];L[b+212>>2]=c;h:{if(h){c=ha[L[L[a>>2]+20>>2]](a)|0;e=b+160|0;ha[L[L[c>>2]+56>>2]](c,e,z);c=L[d+900>>2];L[b+168>>2]=L[d+896>>2];L[b+172>>2]=c;c=L[d+892>>2];L[b+160>>2]=L[d+888>>2];L[b+164>>2]=c;c=L[d+916>>2];L[b+184>>2]=L[d+912>>2];L[b+188>>2]=c;c=L[d+908>>2];L[b+176>>2]=L[d+904>>2];L[b+180>>2]=c;c=L[d+932>>2];L[b+200>>2]=L[d+928>>2];L[b+204>>2]=c;c=L[d+924>>2];L[b+192>>2]=L[d+920>>2];L[b+196>>2]=c;c=L[d+948>>2];L[b+216>>2]=L[d+944>>2];L[b+220>>2]=c;c=L[d+940>>2];L[b+208>>2]=L[d+936>>2];L[b+212>>2]=c;c=ha[L[L[a>>2]+20>>2]](a)|0;ha[L[L[c>>2]+56>>2]](c,e,z);break h}c=L[d+900>>2];L[b+168>>2]=L[d+896>>2];L[b+172>>2]=c;c=L[d+892>>2];L[b+160>>2]=L[d+888>>2];L[b+164>>2]=c;c=L[d+916>>2];L[b+184>>2]=L[d+912>>2];L[b+188>>2]=c;c=L[d+908>>2];L[b+176>>2]=L[d+904>>2];L[b+180>>2]=c;c=L[d+932>>2];L[b+200>>2]=L[d+928>>2];L[b+204>>2]=c;c=L[d+924>>2];L[b+192>>2]=L[d+920>>2];L[b+196>>2]=c;c=L[d+948>>2];L[b+216>>2]=L[d+944>>2];L[b+220>>2]=c;c=L[d+940>>2];L[b+208>>2]=L[d+936>>2];L[b+212>>2]=c}if(!q){break b}c=M[d+180|0];f=P[d+(c?824:888)>>2];c=c?d+824|0:d+888|0;k=P[c+48>>2];r=P[c+8>>2];l=P[c+4>>2];m=P[c+52>>2];s=P[c+24>>2];g=P[c+16>>2];o=P[c+20>>2];p=P[c+56>>2];t=P[c+40>>2];i=P[c+32>>2];u=P[c+36>>2];j=P[d+184>>2];L[b+76>>2]=0;t=S(t*S(0));v=S(u*S(0));P[b+72>>2]=p+S(t+S(S(j*i)+v));s=S(s*S(0));w=S(o*S(0));P[b+68>>2]=m+S(s+S(S(j*g)+w));r=S(r*S(0));x=S(l*S(0));P[b+64>>2]=k+S(r+S(S(j*f)+x));j=P[d+188>>2];L[b+156>>2]=0;P[b+152>>2]=p+S(t+S(S(j*i)+v));P[b+148>>2]=m+S(s+S(S(j*g)+w));P[b+144>>2]=k+S(r+S(S(j*f)+x));c=ha[L[L[a>>2]+20>>2]](a)|0;L[b+136>>2]=0;L[b+140>>2]=0;L[b+128>>2]=0;L[b+132>>2]=0;e=b+128|0;ha[L[L[c>>2]+8>>2]](c,b- -64|0,b+144|0,e);L[b+140>>2]=0;P[b+136>>2]=i;P[b+132>>2]=g;P[b+128>>2]=f;L[b+60>>2]=0;P[b+56>>2]=u;P[b+52>>2]=o;P[b+48>>2]=l;f=P[d+196>>2];g=P[d+192>>2];c=ha[L[L[a>>2]+20>>2]](a)|0;L[b+40>>2]=0;L[b+44>>2]=0;L[b+32>>2]=0;L[b+36>>2]=0;ha[L[L[c>>2]+60>>2]](c,d+936|0,e,b+48|0,z,z,g,f,b+32|0,1,S(10))}fa=b+224|0;c=J>>>0>1;J=K;if(c){continue}break}}i:{if(!(ha[L[L[a>>2]+20>>2]](a)|0)){break i}c=ha[L[L[a>>2]+20>>2]](a)|0;if(!(ha[L[L[c>>2]+48>>2]](c)&16387)){break i}if(!(ha[L[L[a>>2]+20>>2]](a)|0)){break i}c=ha[L[L[a>>2]+20>>2]](a)|0;if(!(ha[L[L[c>>2]+48>>2]](c)|0)|L[a+280>>2]<=0){break i}J=0;while(1){c=L[L[a+288>>2]+(J<<2)>>2];ha[L[L[c>>2]+12>>2]](c,L[a+72>>2]);J=J+1|0;if((J|0)>2]){continue}break}}va()}function QB(a,b,c,d){a=a|0;b=b|0;c=c|0;d=S(d);var e=0,f=S(0),g=S(0),h=S(0),i=S(0),j=0,k=S(0),l=0,m=S(0),n=S(0),o=S(0),p=S(0),q=S(0),r=S(0),s=S(0),t=S(0),u=S(0),v=S(0),w=S(0),x=0,y=S(0),z=S(0),A=S(0),B=S(0),C=S(0),D=S(0),E=S(0),F=S(0),G=S(0),H=S(0),I=S(0),J=S(0),K=S(0),N=S(0),O=S(0),Q=S(0),T=S(0),U=S(0),V=S(0),W=S(0),X=S(0),Y=S(0),Z=S(0),$=S(0),aa=0,ba=S(0),ca=S(0),da=0,ea=0,ga=S(0),ha=S(0),ia=S(0),ja=S(0);e=fa-464|0;fa=e;a:{if(!M[a+527|0]){break a}j=L[a+32>>2];l=L[a+28>>2];if(!M[a+524|0]){o=S(P[b+192>>2]+P[b+80>>2]);f=P[a+356>>2];g=P[a+348>>2];h=P[a+352>>2];i=P[l+56>>2];q=S(S(S(f*P[l+28>>2])+S(S(g*P[l+20>>2])+S(h*P[l+24>>2])))+i);k=S(q-i);i=P[l+52>>2];s=S(S(S(f*P[l+12>>2])+S(S(g*P[l+4>>2])+S(h*P[l+8>>2])))+i);p=S(s-i);v=S(P[b+196>>2]+P[b+84>>2]);y=S(P[c+192>>2]+P[c+80>>2]);i=P[a+420>>2];r=P[a+412>>2];m=P[a+416>>2];n=P[j+56>>2];z=S(S(S(i*P[j+28>>2])+S(S(r*P[j+20>>2])+S(m*P[j+24>>2])))+n);n=S(z-n);t=P[j+52>>2];w=S(S(S(i*P[j+12>>2])+S(S(r*P[j+4>>2])+S(m*P[j+8>>2])))+t);t=S(w-t);A=S(P[c+196>>2]+P[c+84>>2]);D=S(S(S(P[b+184>>2]+P[b+72>>2])+S(S(o*k)-S(p*v)))-S(S(P[c+184>>2]+P[c+72>>2])+S(S(y*n)-S(t*A))));E=S(P[b+200>>2]+P[b+88>>2]);g=S(S(f*P[l+44>>2])+S(S(g*P[l+36>>2])+S(h*P[l+40>>2])));f=P[l+60>>2];g=S(g+f);u=S(g-f);f=S(P[c+200>>2]+P[c+88>>2]);h=P[j+60>>2];i=S(S(S(i*P[j+44>>2])+S(S(r*P[j+36>>2])+S(m*P[j+40>>2])))+h);r=S(i-h);y=S(S(S(P[b+180>>2]+P[b+68>>2])+S(S(E*p)-S(u*o)))-S(S(P[c+180>>2]+P[c+68>>2])+S(S(f*t)-S(r*y))));v=S(S(S(P[b+176>>2]+P[b+64>>2])+S(S(v*u)-S(k*E)))-S(S(P[c+176>>2]+P[c+64>>2])+S(S(A*r)-S(n*f))));A=S(g-i);z=S(q-z);s=S(s-w);w=S(-p);E=S(-u);I=S(-k);J=S(-n);K=S(-t);Z=S(-r);da=L[c+240>>2];ea=L[b+240>>2];while(1){x=R(aa,84)+a|0;g=P[x+56>>2];h=P[x+48>>2];i=P[x+52>>2];f=S(S(1)/P[x+128>>2]);f=S(S(S(S(S(S(A*g)+S(S(s*h)+S(z*i)))*S(-.30000001192092896))/d)*f)-S(f*S(S(g*D)+S(S(h*v)+S(y*i)))));P[a+36>>2]=P[a+36>>2]+f;if(ea){O=P[l+304>>2];C=P[l+296>>2];X=P[l+300>>2];Y=P[l+288>>2];Q=P[l+280>>2];F=P[l+284>>2];o=P[l+272>>2];q=P[l+264>>2];B=P[l+268>>2];m=P[l+344>>2];P[b+64>>2]=S(P[b+112>>2]*S(f*S(h*m)))+P[b+64>>2];P[b+68>>2]=S(S(f*S(i*m))*P[b+116>>2])+P[b+68>>2];P[b+72>>2]=S(S(f*S(g*m))*P[b+120>>2])+P[b+72>>2];m=S(S(p*i)+S(h*I));G=S(o*m);o=S(S(k*g)+S(i*E));H=S(q*o);q=S(S(u*h)+S(g*w));P[b+80>>2]=S(S(G+S(H+S(B*q)))*S(f*P[b+96>>2]))+P[b+80>>2];B=P[b+104>>2];P[b+84>>2]=S(S(S(Y*m)+S(S(Q*o)+S(q*F)))*S(f*P[b+100>>2]))+P[b+84>>2];P[b+88>>2]=S(S(S(O*m)+S(S(C*o)+S(q*X)))*S(f*B))+P[b+88>>2]}if(da){o=P[j+304>>2];q=P[j+296>>2];O=P[j+300>>2];C=P[j+288>>2];X=P[j+280>>2];Y=P[j+284>>2];Q=P[j+272>>2];F=P[j+264>>2];B=P[j+268>>2];G=P[c+120>>2];H=P[x+56>>2];N=P[c+116>>2];$=P[x+52>>2];m=P[j+344>>2];P[c+64>>2]=P[c+64>>2]-S(P[c+112>>2]*S(S(m*P[x+48>>2])*f));P[c+68>>2]=P[c+68>>2]-S(N*S(S(m*$)*f));P[c+72>>2]=P[c+72>>2]-S(G*S(S(m*H)*f));m=S(S(t*i)+S(h*J));i=S(S(n*g)+S(i*Z));g=S(S(r*h)+S(g*K));P[c+80>>2]=P[c+80>>2]-S(S(S(Q*m)+S(S(F*i)+S(B*g)))*S(P[c+96>>2]*f));P[c+84>>2]=P[c+84>>2]-S(S(S(C*m)+S(S(X*i)+S(g*Y)))*S(P[c+100>>2]*f));P[c+88>>2]=P[c+88>>2]-S(S(S(o*m)+S(S(q*i)+S(g*O)))*S(P[c+104>>2]*f))}aa=aa+1|0;if((aa|0)!=3){continue}break}}b:{if(M[a+552|0]){x=L[l+16>>2];L[e+384>>2]=L[l+12>>2];L[e+388>>2]=x;x=L[l+8>>2];L[e+376>>2]=L[l+4>>2];L[e+380>>2]=x;x=L[l+32>>2];L[e+400>>2]=L[l+28>>2];L[e+404>>2]=x;x=L[l+24>>2];L[e+392>>2]=L[l+20>>2];L[e+396>>2]=x;x=L[l+48>>2];L[e+416>>2]=L[l+44>>2];L[e+420>>2]=x;x=L[l+40>>2];L[e+408>>2]=L[l+36>>2];L[e+412>>2]=x;x=L[l+64>>2];L[e+432>>2]=L[l+60>>2];L[e+436>>2]=x;x=L[l+56>>2];L[e+424>>2]=L[l+52>>2];L[e+428>>2]=x;l=L[j+16>>2];L[e+320>>2]=L[j+12>>2];L[e+324>>2]=l;l=L[j+8>>2];L[e+312>>2]=L[j+4>>2];L[e+316>>2]=l;l=L[j+32>>2];L[e+336>>2]=L[j+28>>2];L[e+340>>2]=l;l=L[j+24>>2];L[e+328>>2]=L[j+20>>2];L[e+332>>2]=l;l=L[j+48>>2];L[e+352>>2]=L[j+44>>2];L[e+356>>2]=l;l=L[j+40>>2];L[e+344>>2]=L[j+36>>2];L[e+348>>2]=l;l=L[j+64>>2];L[e+368>>2]=L[j+60>>2];L[e+372>>2]=l;l=L[j+56>>2];L[e+360>>2]=L[j+52>>2];L[e+364>>2]=l;f=P[b+84>>2];g=P[b+196>>2];h=P[b+88>>2];i=P[b+200>>2];k=P[b+80>>2];p=P[b+192>>2];L[e+308>>2]=0;P[e+304>>2]=i+h;P[e+300>>2]=g+f;P[e+296>>2]=p+k;f=P[c+84>>2];g=P[c+196>>2];h=P[c+88>>2];i=P[c+200>>2];k=P[c+80>>2];p=P[c+192>>2];L[e+292>>2]=0;P[e+288>>2]=i+h;P[e+284>>2]=g+f;P[e+280>>2]=p+k;L[e+228>>2]=0;L[e+232>>2]=0;L[e+240>>2]=0;L[e+244>>2]=0;L[e+236>>2]=1065353216;L[e+248>>2]=0;L[e+252>>2]=0;L[e+260>>2]=0;L[e+264>>2]=0;L[e+256>>2]=1065353216;L[e+268>>2]=0;L[e+272>>2]=0;L[e+276>>2]=0;L[e+220>>2]=0;L[e+224>>2]=0;L[e+216>>2]=1065353216;L[e+208>>2]=0;L[e+212>>2]=0;L[e+200>>2]=0;L[e+204>>2]=0;j=e+376|0;l=e+200|0;Rb(j,l,e+296|0,d,e+216|0);L[e+148>>2]=0;L[e+152>>2]=0;L[e+160>>2]=0;L[e+164>>2]=0;L[e+156>>2]=1065353216;L[e+168>>2]=0;L[e+172>>2]=0;L[e+180>>2]=0;L[e+184>>2]=0;L[e+176>>2]=1065353216;L[e+188>>2]=0;L[e+192>>2]=0;L[e+196>>2]=0;L[e+140>>2]=0;L[e+144>>2]=0;L[e+136>>2]=1065353216;x=e+312|0;Rb(x,l,e+280|0,d,e+136|0);ga=P[a+420>>2];ha=P[a+416>>2];o=P[a+308>>2];q=P[a+304>>2];X=P[a+352>>2];Y=P[a+356>>2];n=P[a+324>>2];r=P[a+316>>2];m=P[a+320>>2];s=P[a+404>>2];v=P[a+400>>2];y=P[a+396>>2];z=P[a+372>>2];w=P[a+368>>2];A=P[a+340>>2];D=P[a+332>>2];E=P[a+336>>2];I=P[a+388>>2];J=P[a+384>>2];K=P[a+380>>2];g=P[a+568>>2];i=P[a+564>>2];h=P[a+560>>2];ia=P[a+412>>2];Z=P[a+300>>2];ja=P[a+348>>2];O=P[a+364>>2];f=P[a+556>>2];L[e+132>>2]=0;L[e+116>>2]=0;L[e+100>>2]=0;k=S(S(2)/S(S(g*g)+S(S(i*i)+S(S(f*f)+S(h*h)))));C=S(f*k);F=S(f*C);p=S(h*k);B=S(h*p);t=S(S(1)-S(F+B));k=S(i*k);G=S(f*k);H=S(g*p);u=S(G+H);h=S(h*k);N=S(g*C);C=S(h-N);Q=S(S(s*t)+S(S(y*u)+S(v*C)));T=S(G-H);i=S(i*k);U=S(S(1)-S(B+i));B=S(f*p);g=S(g*k);k=S(B+g);f=S(S(s*T)+S(S(y*U)+S(v*k)));p=S(h+N);V=S(B-g);W=S(S(1)-S(F+i));g=S(S(s*p)+S(S(y*V)+S(v*W)));h=S(S(A*Q)+S(S(D*f)+S(E*g)));F=P[e+176>>2];B=S(S(t*z)+S(S(u*O)+S(w*C)));G=S(S(T*z)+S(S(U*O)+S(w*k)));H=S(S(p*z)+S(S(V*O)+S(w*W)));i=S(S(A*B)+S(S(D*G)+S(E*H)));N=P[e+168>>2];$=S(S(t*I)+S(S(u*K)+S(J*C)));T=S(S(T*I)+S(S(U*K)+S(J*k)));U=S(S(p*I)+S(S(V*K)+S(J*W)));k=S(S(A*$)+S(S(D*T)+S(E*U)));V=P[e+172>>2];P[e+112>>2]=S(h*F)+S(S(i*N)+S(k*V));p=S(S(n*Q)+S(S(r*f)+S(g*m)));t=S(S(n*B)+S(S(r*G)+S(H*m)));u=S(S(n*$)+S(S(r*T)+S(U*m)));P[e+108>>2]=S(F*p)+S(S(N*t)+S(V*u));W=P[e+160>>2];ba=P[e+152>>2];ca=P[e+156>>2];P[e+96>>2]=S(h*W)+S(S(i*ba)+S(k*ca));P[e+92>>2]=S(p*W)+S(S(t*ba)+S(u*ca));C=S(0);y=S(ga+S(S(s*S(0))+S(S(y*S(0))+S(v*S(0)))));s=S(-ja);n=S(S(S(o*s)-S(n*X))-S(A*Y));v=S(S(S(Z*s)-S(r*X))-S(D*Y));m=S(S(S(q*s)-S(m*X))-S(E*Y));r=S(y+S(S(n*Q)+S(S(v*f)+S(g*m))));s=S(S(ia+S(S(z*S(0))+S(S(O*S(0))+S(w*S(0)))))+S(S(n*B)+S(S(v*G)+S(H*m))));m=S(S(ha+S(S(I*S(0))+S(S(K*S(0))+S(J*S(0)))))+S(S(n*$)+S(S(v*T)+S(U*m))));E=S(S(S(F*r)+S(S(N*s)+S(V*m)))+P[e+192>>2]);P[e+128>>2]=E;I=S(S(S(r*W)+S(S(s*ba)+S(m*ca)))+P[e+188>>2]);P[e+124>>2]=I;L[e+84>>2]=0;n=S(S(o*Q)+S(S(Z*f)+S(g*q)));g=S(S(o*B)+S(S(Z*G)+S(H*q)));f=S(S(o*$)+S(S(Z*T)+S(U*q)));P[e+104>>2]=S(F*n)+S(S(N*g)+S(V*f));P[e+88>>2]=S(n*W)+S(S(g*ba)+S(f*ca));o=P[e+144>>2];q=P[e+136>>2];v=P[e+140>>2];P[e+80>>2]=S(h*o)+S(S(i*q)+S(k*v));P[e+76>>2]=S(p*o)+S(S(t*q)+S(u*v));P[e+72>>2]=S(n*o)+S(S(g*q)+S(f*v));J=S(S(S(r*o)+S(S(s*q)+S(v*m)))+P[e+184>>2]);P[e+120>>2]=J;L[e+68>>2]=0;L[e+52>>2]=0;L[e+36>>2]=0;o=P[e+256>>2];q=P[e+248>>2];v=P[e+252>>2];P[e+48>>2]=S(h*o)+S(S(n*q)+S(p*v));P[e+44>>2]=S(k*o)+S(S(f*q)+S(u*v));y=P[e+240>>2];z=P[e+232>>2];w=P[e+236>>2];P[e+32>>2]=S(h*y)+S(S(n*z)+S(p*w));P[e+28>>2]=S(k*y)+S(S(f*z)+S(u*w));s=S(-s);A=S(S(S(i*s)-S(k*m))-S(h*r));D=S(S(S(g*s)-S(f*m))-S(n*r));m=S(S(S(t*s)-S(u*m))-S(p*r));s=S(S(S(o*A)+S(S(q*D)+S(v*m)))+P[e+272>>2]);P[e- -64>>2]=s;K=S(S(S(A*y)+S(S(D*z)+S(m*w)))+P[e+268>>2]);P[e+60>>2]=K;L[e+20>>2]=0;P[e+40>>2]=S(i*o)+S(S(g*q)+S(t*v));P[e+24>>2]=S(i*y)+S(S(g*z)+S(t*w));w=h;h=P[e+224>>2];r=P[e+216>>2];o=S(n*r);n=P[e+220>>2];P[e+16>>2]=S(w*h)+S(o+S(p*n));P[e+12>>2]=S(k*h)+S(S(f*r)+S(u*n));P[e+8>>2]=S(i*h)+S(S(g*r)+S(t*n));h=S(S(S(A*h)+S(S(D*r)+S(m*n)))+P[e+264>>2]);P[e+56>>2]=h;i=S(S(1)/d);P[e+208>>2]=i*S(E-P[e+432>>2]);L[e+212>>2]=0;P[e+200>>2]=i*S(J-P[e+424>>2]);P[e+204>>2]=i*S(I-P[e+428>>2]);aa=j;j=e+448|0;l=e+444|0;ec(aa,e+72|0,j,l);P[e+208>>2]=i*S(s-P[e+368>>2]);L[e+212>>2]=0;P[e+204>>2]=i*S(K-P[e+364>>2]);P[e+200>>2]=i*S(h-P[e+360>>2]);k=P[e+452>>2];h=P[e+444>>2];m=P[e+456>>2];o=P[e+448>>2];ec(x,e+8|0,j,l);p=P[e+444>>2];t=S(S(i*S(p*P[e+456>>2]))-P[e+288>>2]);u=S(S(i*S(p*P[e+452>>2]))-P[e+284>>2]);r=S(S(i*S(P[e+448>>2]*p))-P[e+280>>2]);p=S(0);m=S(S(i*S(h*m))-P[e+304>>2]);o=S(S(i*S(o*h))-P[e+296>>2]);q=S(S(i*S(h*k))-P[e+300>>2]);i=S(S(m*m)+S(S(o*o)+S(q*q)));if(i>S(1.1920928955078125e-7)){i=S(S(1)/S(_(i)));f=S(m*i);j=L[a+28>>2];n=S(o*i);g=S(q*i);p=S(S(f*S(S(f*P[j+304>>2])+S(S(P[j+272>>2]*n)+S(g*P[j+288>>2]))))+S(S(n*S(S(P[j+296>>2]*f)+S(S(n*P[j+264>>2])+S(g*P[j+280>>2]))))+S(g*S(S(P[j+300>>2]*f)+S(S(P[j+268>>2]*n)+S(g*P[j+284>>2]))))))}s=S(S(t*t)+S(S(r*r)+S(u*u)));if(s>S(1.1920928955078125e-7)){h=S(S(1)/S(_(s)));k=S(t*h);j=L[a+32>>2];i=S(r*h);h=S(u*h);C=S(S(k*S(S(k*P[j+304>>2])+S(S(P[j+272>>2]*i)+S(h*P[j+288>>2]))))+S(S(i*S(S(P[j+296>>2]*k)+S(S(i*P[j+264>>2])+S(h*P[j+280>>2]))))+S(h*S(S(P[j+300>>2]*k)+S(S(P[j+268>>2]*i)+S(h*P[j+284>>2]))))))}f=S(S(p*f)+S(C*k));i=S(S(p*n)+S(C*i));h=S(S(p*g)+S(C*h));g=S(S(f*f)+S(S(i*i)+S(h*h)));if(!(g>S(1.1920928955078125e-7))){break b}k=S(S(1)/S(_(g)));f=S(f*k);j=L[a+28>>2];g=S(i*k);h=S(h*k);n=S(S(f*S(S(f*P[j+304>>2])+S(S(P[j+272>>2]*g)+S(h*P[j+288>>2]))))+S(S(g*S(S(P[j+296>>2]*f)+S(S(g*P[j+264>>2])+S(h*P[j+280>>2]))))+S(h*S(S(P[j+300>>2]*f)+S(S(P[j+268>>2]*g)+S(h*P[j+284>>2]))))));l=L[a+32>>2];f=S(S(f*S(S(f*P[l+304>>2])+S(S(P[l+272>>2]*g)+S(h*P[l+288>>2]))))+S(S(g*S(S(P[l+296>>2]*f)+S(S(g*P[l+264>>2])+S(h*P[l+280>>2]))))+S(h*S(S(P[l+300>>2]*f)+S(S(P[l+268>>2]*g)+S(h*P[l+284>>2]))))));g=S(n+f);g=S(S(1)/S(g*g));p=S(S(S(m*n)-S(t*f))*g);h=S(S(S(q*n)-S(u*f))*g);f=S(S(S(o*n)-S(r*f))*g);m=P[a+572>>2];if(m>=S(0)){t=P[a+584>>2];i=S(p+t);u=P[a+576>>2];g=S(f+u);r=P[a+580>>2];k=S(h+r);o=S(_(S(S(i*i)+S(S(g*g)+S(k*k)))));n=S(m/(M[a+553|0]?n:S(1)));if(o>n){f=S(S(1)/o);p=S(S(n*S(i*f))-t);i=S(t+p);h=S(S(n*S(k*f))-r);k=S(r+h);f=S(S(n*S(g*f))-u);g=S(u+f)}P[a+584>>2]=i;P[a+580>>2]=k;P[a+576>>2]=g}g=S(_(S(S(p*p)+S(S(f*f)+S(h*h)))));k=S(S(1)/g);i=S(p*k);h=S(h*k);f=S(f*k);if(L[b+240>>2]){p=P[j+304>>2];n=P[j+296>>2];t=P[j+300>>2];u=P[j+288>>2];r=P[j+280>>2];m=P[j+284>>2];o=P[j+272>>2];q=P[j+264>>2];s=P[j+268>>2];k=S(g*S(0));P[b+64>>2]=S(k*P[b+112>>2])+P[b+64>>2];P[b+68>>2]=S(k*P[b+116>>2])+P[b+68>>2];P[b+72>>2]=S(k*P[b+120>>2])+P[b+72>>2];P[b+80>>2]=S(S(S(o*i)+S(S(q*f)+S(h*s)))*S(g*P[b+96>>2]))+P[b+80>>2];k=P[b+104>>2];P[b+84>>2]=S(S(S(u*i)+S(S(r*f)+S(h*m)))*S(g*P[b+100>>2]))+P[b+84>>2];P[b+88>>2]=S(S(S(p*i)+S(S(n*f)+S(h*t)))*S(g*k))+P[b+88>>2]}if(!L[c+240>>2]){break b}p=P[l+304>>2];n=P[l+296>>2];t=P[l+300>>2];u=P[l+288>>2];r=P[l+280>>2];m=P[l+284>>2];o=P[l+272>>2];q=P[l+264>>2];s=P[l+268>>2];k=S(g*S(-0));P[c+64>>2]=S(k*P[c+112>>2])+P[c+64>>2];P[c+68>>2]=S(k*P[c+116>>2])+P[c+68>>2];P[c+72>>2]=S(k*P[c+120>>2])+P[c+72>>2];P[c+80>>2]=P[c+80>>2]-S(S(S(o*i)+S(S(q*f)+S(h*s)))*S(P[c+96>>2]*g));k=P[c+104>>2];P[c+84>>2]=P[c+84>>2]-S(S(S(u*i)+S(S(r*f)+S(h*m)))*S(P[c+100>>2]*g));P[c+88>>2]=P[c+88>>2]-S(S(S(p*i)+S(S(n*f)+S(h*t)))*S(k*g));break b}g=P[a+440>>2];if(!(g>S(1.1920928955078125e-7))){break b}p=P[b+88>>2];f=S(S(P[c+200>>2]+P[c+88>>2])-S(P[b+200>>2]+p));n=P[b+80>>2];i=S(S(P[c+192>>2]+P[c+80>>2])-S(P[b+192>>2]+n));t=P[b+84>>2];k=S(S(P[c+196>>2]+P[c+84>>2])-S(P[b+196>>2]+t));h=S(S(f*f)+S(S(i*i)+S(k*k)));if(!(h>S(1.1920928955078125e-7))){break b}w=f;A=g;h=S(S(1)/S(_(h)));f=S(f*h);u=P[l+304>>2];r=P[l+272>>2];g=S(i*h);h=S(k*h);m=P[l+288>>2];o=P[l+296>>2];q=P[l+264>>2];s=P[l+280>>2];v=P[l+300>>2];y=P[l+268>>2];z=P[l+284>>2];f=S(A*S(S(1)/S(S(S(f*S(S(f*u)+S(S(r*g)+S(h*m))))+S(S(g*S(S(o*f)+S(S(g*q)+S(h*s))))+S(h*S(S(v*f)+S(S(y*g)+S(h*z))))))+S(S(f*S(S(f*P[j+304>>2])+S(S(P[j+272>>2]*g)+S(h*P[j+288>>2]))))+S(S(g*S(S(P[j+296>>2]*f)+S(S(g*P[j+264>>2])+S(h*P[j+280>>2]))))+S(h*S(S(P[j+300>>2]*f)+S(S(P[j+268>>2]*g)+S(h*P[j+284>>2])))))))));g=S(w*f);i=S(i*f);h=S(k*f);f=S(_(S(S(g*g)+S(S(i*i)+S(h*h)))));k=S(S(1)/f);g=S(g*k);h=S(h*k);i=S(i*k);if(L[b+240>>2]){k=S(f*S(0));P[b+64>>2]=S(k*P[b+112>>2])+P[b+64>>2];P[b+68>>2]=S(k*P[b+116>>2])+P[b+68>>2];P[b+72>>2]=S(k*P[b+120>>2])+P[b+72>>2];P[b+88>>2]=p+S(S(S(u*g)+S(S(o*i)+S(h*v)))*S(f*P[b+104>>2]));P[b+84>>2]=t+S(S(S(m*g)+S(S(s*i)+S(h*z)))*S(f*P[b+100>>2]));P[b+80>>2]=n+S(S(S(r*g)+S(S(q*i)+S(h*y)))*S(f*P[b+96>>2]))}if(!L[c+240>>2]){break b}p=P[j+304>>2];n=P[j+296>>2];t=P[j+300>>2];u=P[j+288>>2];r=P[j+280>>2];m=P[j+284>>2];o=P[j+272>>2];q=P[j+264>>2];s=P[j+268>>2];k=S(f*S(-0));P[c+64>>2]=S(k*P[c+112>>2])+P[c+64>>2];P[c+68>>2]=S(k*P[c+116>>2])+P[c+68>>2];P[c+72>>2]=S(k*P[c+120>>2])+P[c+72>>2];P[c+80>>2]=P[c+80>>2]-S(S(S(o*g)+S(S(q*i)+S(h*s)))*S(P[c+96>>2]*f));k=P[c+104>>2];P[c+84>>2]=P[c+84>>2]-S(S(S(u*g)+S(S(r*i)+S(h*m)))*S(P[c+100>>2]*f));P[c+88>>2]=P[c+88>>2]-S(S(S(p*g)+S(S(n*i)+S(h*t)))*S(k*f))}k=S(P[c+200>>2]+P[c+88>>2]);p=S(P[c+196>>2]+P[c+84>>2]);n=S(P[b+200>>2]+P[b+88>>2]);t=S(P[b+196>>2]+P[b+84>>2]);u=S(P[c+192>>2]+P[c+80>>2]);r=S(P[b+192>>2]+P[b+80>>2]);c:{if(!M[a+526|0]){break c}g=P[a+528>>2];f=S(S(S(g*P[a+504>>2])*P[a+432>>2])/d);h=P[a+516>>2];w=g;g=P[a+468>>2];i=P[a+460>>2];m=P[a+464>>2];o=S(S(S(k-n)*g)+S(S(S(u-r)*i)+S(S(p-t)*m)));f=S(h+S(P[a+492>>2]*(o>S(0)?S(S(S(w*o)*P[a+436>>2])+f):f)));f=f>S(0)?f:S(0);P[a+516>>2]=f;f=S(f-h);g=S(g*f);h=P[a+544>>2];i=S(i*f);o=P[a+536>>2];q=P[a+540>>2];s=S(m*f);f=S(S(g*h)+S(S(i*o)+S(q*s)));g=S(g-S(h*f));m=S(i-S(o*f));h=S(s-S(q*f));f=S(_(S(S(g*g)+S(S(m*m)+S(h*h)))));i=S(S(1)/f);g=S(g*i);h=S(h*i);i=S(m*i);if(L[b+240>>2]){j=L[a+28>>2];o=P[j+304>>2];q=P[j+296>>2];s=P[j+300>>2];v=P[j+288>>2];y=P[j+280>>2];z=P[j+284>>2];w=P[j+272>>2];A=P[j+268>>2];D=P[j+264>>2];m=S(f*S(0));P[b+64>>2]=S(m*P[b+112>>2])+P[b+64>>2];P[b+68>>2]=S(m*P[b+116>>2])+P[b+68>>2];P[b+72>>2]=S(m*P[b+120>>2])+P[b+72>>2];P[b+80>>2]=S(S(S(w*g)+S(S(D*i)+S(h*A)))*S(f*P[b+96>>2]))+P[b+80>>2];m=P[b+104>>2];P[b+84>>2]=S(S(S(v*g)+S(S(y*i)+S(h*z)))*S(f*P[b+100>>2]))+P[b+84>>2];P[b+88>>2]=S(S(S(o*g)+S(S(q*i)+S(h*s)))*S(f*m))+P[b+88>>2]}if(!L[c+240>>2]){break c}j=L[a+32>>2];o=P[j+304>>2];q=P[j+296>>2];s=P[j+300>>2];v=P[j+288>>2];y=P[j+280>>2];z=P[j+284>>2];w=P[j+272>>2];A=P[j+268>>2];D=P[j+264>>2];m=S(f*S(-0));P[c+64>>2]=S(m*P[c+112>>2])+P[c+64>>2];P[c+68>>2]=S(m*P[c+116>>2])+P[c+68>>2];P[c+72>>2]=S(m*P[c+120>>2])+P[c+72>>2];P[c+80>>2]=P[c+80>>2]-S(S(S(w*g)+S(S(D*i)+S(h*A)))*S(P[c+96>>2]*f));m=P[c+104>>2];P[c+84>>2]=P[c+84>>2]-S(S(S(v*g)+S(S(y*i)+S(h*z)))*S(P[c+100>>2]*f));P[c+88>>2]=P[c+88>>2]-S(S(S(o*g)+S(S(q*i)+S(h*s)))*S(m*f))}if(!M[a+525|0]){break a}f=P[a+532>>2];d=S(S(S(f*P[a+508>>2])*P[a+432>>2])/d);i=P[a+520>>2];w=f;f=P[a+484>>2];g=P[a+476>>2];h=P[a+480>>2];k=S(S(S(k-n)*f)+S(S(S(u-r)*g)+S(S(p-t)*h)));d=S(i+S(P[a+496>>2]*(k>S(0)?S(S(S(w*k)*P[a+436>>2])+d):d)));d=d>S(0)?d:S(0);P[a+520>>2]=d;d=S(d-i);if(L[b+240>>2]){j=L[a+28>>2];k=P[j+304>>2];p=P[j+296>>2];n=P[j+300>>2];t=P[j+288>>2];u=P[j+280>>2];r=P[j+284>>2];m=P[j+272>>2];o=P[j+268>>2];q=P[j+264>>2];i=S(d*S(0));P[b+64>>2]=S(i*P[b+112>>2])+P[b+64>>2];P[b+68>>2]=S(i*P[b+116>>2])+P[b+68>>2];P[b+72>>2]=S(i*P[b+120>>2])+P[b+72>>2];P[b+80>>2]=S(S(S(m*f)+S(S(q*g)+S(h*o)))*S(d*P[b+96>>2]))+P[b+80>>2];i=P[b+104>>2];P[b+84>>2]=S(S(S(t*f)+S(S(u*g)+S(h*r)))*S(d*P[b+100>>2]))+P[b+84>>2];P[b+88>>2]=S(S(S(k*f)+S(S(p*g)+S(h*n)))*S(d*i))+P[b+88>>2]}if(!L[c+240>>2]){break a}b=L[a+32>>2];k=P[b+304>>2];p=P[b+296>>2];n=P[b+300>>2];t=P[b+288>>2];u=P[b+280>>2];r=P[b+284>>2];m=P[b+272>>2];o=P[b+268>>2];q=P[c+120>>2];s=P[c+116>>2];f=P[a+484>>2];g=P[a+480>>2];h=P[a+476>>2];v=P[b+264>>2];i=S(d*S(-0));P[c+64>>2]=S(i*P[c+112>>2])+P[c+64>>2];P[c+68>>2]=S(i*s)+P[c+68>>2];P[c+72>>2]=S(i*q)+P[c+72>>2];P[c+80>>2]=P[c+80>>2]-S(S(S(m*f)+S(S(v*h)+S(g*o)))*S(P[c+96>>2]*d));P[c+84>>2]=P[c+84>>2]-S(S(S(t*f)+S(S(u*h)+S(g*r)))*S(P[c+100>>2]*d));P[c+88>>2]=P[c+88>>2]-S(S(S(k*f)+S(S(p*h)+S(g*n)))*S(P[c+104>>2]*d))}fa=e+464|0}function Uy(a,b){a=a|0;b=S(b);var c=0,d=0,e=0,f=S(0),g=S(0),h=S(0),i=0,j=S(0),k=S(0),l=0,m=S(0),n=S(0),o=S(0),p=S(0),q=S(0),r=0,s=S(0),t=S(0),u=0,v=S(0),w=S(0),x=S(0),y=0,z=S(0),A=S(0),B=S(0),C=S(0),D=0,E=0,F=0,G=S(0),H=S(0),I=S(0),K=S(0),N=S(0),O=0,Q=S(0),U=0,V=S(0),W=S(0),X=S(0),Y=S(0),Z=0,$=0,aa=0;d=L[a+24>>2];if((d|0)>0){while(1){a:{b:{e=L[L[a+32>>2]+(U<<2)>>2];switch(L[e+216>>2]-2|0){case 0:case 3:break a;default:break b}}d=0;O=0;r=fa-144|0;fa=r;c:{if(!M[e+924|0]){break c}J[e+924|0]=0;i=L[e+732>>2];if((i|0)>0){l=L[e+740>>2];while(1){c=l+R(d,52)|0;u=L[c+8>>2];y=L[c+12>>2];f=S(P[u+16>>2]-P[y+16>>2]);h=S(f*f);f=S(P[u+8>>2]-P[y+8>>2]);j=S(f*f);f=S(P[u+12>>2]-P[y+12>>2]);f=S(_(S(h+S(j+S(f*f)))));P[c+16>>2]=f;P[c+28>>2]=f*f;d=d+1|0;if((i|0)!=(d|0)){continue}break}d=0;while(1){c=l+R(d,52)|0;P[c+24>>2]=S(P[L[c+8>>2]+88>>2]+P[L[c+12>>2]+88>>2])/P[L[c+4>>2]+4>>2];d=d+1|0;if((i|0)!=(d|0)){continue}break}}hg(e);Gd(e+988|0);if(!(M[e+388|0]&16)){break c}vk(e)}f=S(P[e+368>>2]*b);P[e+452>>2]=f;P[e+460>>2]=f*S(3);P[e+456>>2]=S(1)/f;d=L[e+192>>2];f=S(ha[L[L[d>>2]+48>>2]](d));P[e+464>>2]=f;P[e+468>>2]=f*S(.25);i=L[e+712>>2];if((i|0)>0){f=P[e+452>>2];d=L[e+684>>2];h=S(f*P[d+48>>2]);k=S(f*P[d+44>>2]);f=S(P[d+40>>2]*f);l=L[e+720>>2];d=0;while(1){c=l+R(d,104)|0;if(P[c+88>>2]>S(0)){P[c+40>>2]=f+P[c+40>>2];P[c+44>>2]=k+P[c+44>>2];P[c+48>>2]=h+P[c+48>>2]}d=d+1|0;if((i|0)!=(d|0)){continue}break}}d=0;k=S(0);wa(2770);i=L[e+712>>2];n=P[e+312>>2];f=P[e+308>>2];d:{if(f==S(0)){h=S(0);if(!(n>S(0))){break d}}if((i|0)<=0){h=S(0)}else{y=L[e+752>>2];if((y|0)>0){c=L[e+720>>2];h=P[c+8>>2];o=P[c+16>>2];p=P[c+12>>2];D=L[e+760>>2];while(1){v=k;c=D+R(d,44)|0;l=L[c+8>>2];u=L[c+12>>2];k=S(P[u+8>>2]-h);c=L[c+16>>2];j=S(P[c+12>>2]-p);g=S(P[c+8>>2]-h);m=S(P[u+12>>2]-p);t=S(S(P[l+16>>2]-o)*S(S(k*j)-S(g*m)));q=m;m=S(P[c+16>>2]-o);s=j;j=S(P[u+16>>2]-o);k=S(v+S(t+S(S(S(P[l+8>>2]-h)*S(S(q*m)-S(s*j)))+S(S(P[l+12>>2]-p)*S(S(j*g)-S(m*k))))));d=d+1|0;if((y|0)!=(d|0)){continue}break}}h=S(k/S(6))}k=S(f*S(S(1)/S(T(h))));h=S(n*S(P[e+476>>2]-h))}e:{if((i|0)<=0){break e}l=P[e+304>>2]>S(0)|P[e+300>>2]>S(0);u=e+1212|0;if(f!=S(0)){c=0;while(1){d=L[e+720>>2]+R(c,104)|0;f:{if(!(P[d+88>>2]>S(0))){break f}if(l){se(e,u,c)}p=P[d+72>>2];o=P[d+92>>2];f=S(k*o);j=S(S(p*f)+P[d+56>>2]);P[d+56>>2]=j;g=P[d+76>>2];m=S(S(f*g)+P[d+60>>2]);P[d+60>>2]=m;t=P[d+80>>2];y=d- -64|0;f=S(S(f*t)+P[y>>2]);P[y>>2]=f;if(!(n>S(0))){break f}o=S(h*o);P[d+64>>2]=S(o*t)+f;P[d+60>>2]=S(o*g)+m;P[d+56>>2]=S(p*o)+j}c=c+1|0;if((i|0)!=(c|0)){continue}break}break e}if(n>S(0)){c=0;while(1){d=L[e+720>>2]+R(c,104)|0;if(P[d+88>>2]>S(0)){if(l){se(e,u,c)}f=S(h*P[d+92>>2]);P[d+56>>2]=S(P[d+72>>2]*f)+P[d+56>>2];P[d+60>>2]=S(f*P[d+76>>2])+P[d+60>>2];y=d- -64|0;P[y>>2]=S(f*P[d+80>>2])+P[y>>2]}c=c+1|0;if((i|0)!=(c|0)){continue}break}break e}if(!l){break e}d=0;while(1){if(P[(L[e+720>>2]+R(d,104)|0)+88>>2]>S(0)){se(e,u,d)}d=d+1|0;if((i|0)!=(d|0)){continue}break}}E=L[e+752>>2];if((E|0)>0){y=e+1212|0;d=0;while(1){z=P[e+304>>2];A=P[e+300>>2];g:{if(!(z>S(0)|A>S(0))){break g}F=L[e+288>>2];if((F|0)<4){break g}D=L[e+760>>2];u=D+R(d,44)|0;l=L[u+8>>2];g=P[l+48>>2];c=L[u+12>>2];i=L[u+16>>2];f=S(S(S(S(g+P[c+48>>2])+P[i+48>>2])*S(.3333333432674408))-P[y+8>>2]);m=P[l+40>>2];o=S(S(S(S(m+P[c+40>>2])+P[i+40>>2])*S(.3333333432674408))-P[y>>2]);t=P[l+44>>2];p=S(S(S(S(t+P[c+44>>2])+P[i+44>>2])*S(.3333333432674408))-P[y+4>>2]);x=S(S(f*f)+S(S(o*o)+S(p*p)));if(!(x>S(1.1920928955078125e-7))){break g}j=P[e+452>>2];B=P[L[e+684>>2]>>2];G=S(_(x));n=S(S(1)/G);h=S(f*n);k=S(p*n);n=S(o*n);q=P[u+20>>2];s=P[u+28>>2];w=P[u+24>>2];h:{switch(F-4|0){case 1:f=S(S(s*f)+S(S(q*o)+S(p*w)))>2]*S(.5));f=S(q*S(f*x));A=S(f*S(-h));H=S(f*S(-k));I=S(f*S(-n));o=S(0);p=S(0);f=S(0);i:{if(!(q>S(0))){break i}f=S(0);if(!(q>2];if(q>S(0)){s=S(S(h*q)*j);v=S(s*s);s=S(S(n*q)*j);j=S(S(k*q)*j);j=S(v+S(S(s*s)+S(j*j)));j:{if(!(j>S(0))){break j}g=S(S(g*g)+S(S(m*m)+S(t*t)));if(!(g<=j)){break j}j=S(S(S(_(g))/S(_(j)))*S(.800000011920929));h=S(h*j);k=S(k*j);n=S(n*j)}P[l+56>>2]=f+S(n+P[l+56>>2]);u=l- -64|0;P[u>>2]=p+S(h+P[u>>2]);P[l+60>>2]=o+S(k+P[l+60>>2])}j=P[c+88>>2];if(j>S(0)){g=P[e+452>>2];m=S(S(h*j)*g);v=S(m*m);m=S(S(n*j)*g);j=S(S(k*j)*g);j=S(v+S(S(m*m)+S(j*j)));k:{if(!(j>S(0))){break k}g=P[c+48>>2];m=S(g*g);g=P[c+40>>2];v=S(g*g);g=P[c+44>>2];g=S(m+S(v+S(g*g)));if(!(g<=j)){break k}j=S(S(S(_(g))/S(_(j)))*S(.800000011920929));h=S(h*j);k=S(k*j);n=S(n*j)}P[c+56>>2]=f+S(n+P[c+56>>2]);l=c- -64|0;P[l>>2]=p+S(h+P[l>>2]);P[c+60>>2]=o+S(k+P[c+60>>2])}j=P[i+88>>2];if(!(j>S(0))){break g}g=P[e+452>>2];m=S(S(h*j)*g);v=S(m*m);m=S(S(n*j)*g);j=S(S(k*j)*g);j=S(v+S(S(m*m)+S(j*j)));l:{if(!(j>S(0))){break l}g=P[i+48>>2];m=S(g*g);g=P[i+40>>2];v=S(g*g);g=P[i+44>>2];g=S(m+S(v+S(g*g)));if(!(g<=j)){break l}j=S(S(S(_(g))/S(_(j)))*S(.800000011920929));h=S(h*j);k=S(k*j);n=S(n*j)}P[i+56>>2]=f+S(n+P[i+56>>2]);c=i- -64|0;P[c>>2]=p+S(h+P[c>>2]);P[i+60>>2]=o+S(k+P[i+60>>2]);break g;case 0:case 2:break h;default:break g}}v=f;f=S(S(s*f)+S(S(q*o)+S(p*w)))S(0))){break g}f=S(B*S(x*S(f*S(-P[(D+R(d,44)|0)+36>>2]))));o=S(A*f);p=S(z*f);f=S(S(S(h*o)+S(S(s*p)+S(0)))*S(.3333333432674408));h=S(S(S(n*o)+S(S(q*p)+S(0)))*S(.3333333432674408));k=S(S(S(k*o)+S(S(w*p)+S(0)))*S(.3333333432674408));p=S(S(1)/S(_(S(S(f*f)+S(S(h*h)+S(k*k))))));n=S(f*p);o=S(k*p);p=S(h*p);q=S(j*P[l+88>>2]);s=S(f*q);v=S(s*s);s=S(h*q);w=S(s*s);s=S(k*q);m:{if(S(v+S(w+S(s*s)))>S(S(g*g)+S(S(m*m)+S(t*t)))){q=S(S(1)/q);g=S(S(g*n)+S(S(m*p)+S(o*t)));P[l+56>>2]=P[l+56>>2]-S(q*S(p*g));P[l+60>>2]=P[l+60>>2]-S(q*S(o*g));l=l- -64|0;P[l>>2]=P[l>>2]-S(q*S(n*g));break m}P[l+56>>2]=h+P[l+56>>2];P[l+60>>2]=k+P[l+60>>2];l=l- -64|0;P[l>>2]=f+P[l>>2]}g=S(j*P[c+88>>2]);m=S(f*g);v=S(m*m);m=S(h*g);q=S(m*m);m=S(k*g);v=S(v+S(q+S(m*m)));m=P[c+48>>2];t=P[c+40>>2];q=P[c+44>>2];n:{if(!(v>S(S(m*m)+S(S(t*t)+S(q*q))))){P[c+56>>2]=h+P[c+56>>2];P[c+60>>2]=k+P[c+60>>2];c=c- -64|0;P[c>>2]=f+P[c>>2];break n}g=S(S(1)/g);m=S(S(m*n)+S(S(t*p)+S(o*q)));P[c+56>>2]=P[c+56>>2]-S(g*S(p*m));P[c+60>>2]=P[c+60>>2]-S(g*S(o*m));c=c- -64|0;P[c>>2]=P[c>>2]-S(g*S(n*m))}j=S(j*P[i+88>>2]);g=S(f*j);m=S(g*g);g=S(h*j);v=S(g*g);g=S(k*j);v=S(m+S(v+S(g*g)));g=P[i+48>>2];m=P[i+40>>2];t=P[i+44>>2];if(!(v>S(S(g*g)+S(S(m*m)+S(t*t))))){P[i+56>>2]=h+P[i+56>>2];P[i+60>>2]=k+P[i+60>>2];c=i- -64|0;P[c>>2]=f+P[c>>2];break g}f=S(S(1)/j);h=S(S(g*n)+S(S(m*p)+S(o*t)));P[i+56>>2]=P[i+56>>2]-S(f*S(p*h));P[i+60>>2]=P[i+60>>2]-S(f*S(o*h));c=i- -64|0;P[c>>2]=P[c>>2]-S(f*S(n*h))}d=d+1|0;if((E|0)!=(d|0)){continue}break}}va();l=L[e+712>>2];if((l|0)>0){d=0;while(1){c=L[e+720>>2]+R(d,104)|0;i=L[c+12>>2];L[c+24>>2]=L[c+8>>2];L[c+28>>2]=i;i=L[c+20>>2];L[c+32>>2]=L[c+16>>2];L[c+36>>2]=i;k=P[e+452>>2];f=S(P[L[e+684>>2]+12>>2]/k);h=S(-f);n=P[c+88>>2];o=S(S(P[c+56>>2]*n)*k);o=fo?h:o)+P[c+40>>2]);P[c+40>>2]=o;p=S(k*S(n*P[c+60>>2]));p=fp?h:p)+P[c+44>>2]);P[c+44>>2]=p;i=c- -64|0;k=S(k*S(n*P[i>>2]));f=f>2]);P[c+48>>2]=h;f=P[e+452>>2];P[c+8>>2]=S(o*f)+P[c+8>>2];P[c+12>>2]=S(p*f)+P[c+12>>2];P[c+16>>2]=S(h*f)+P[c+16>>2];L[i>>2]=0;L[i+4>>2]=0;L[c+56>>2]=0;L[c+60>>2]=0;d=d+1|0;if((l|0)!=(d|0)){continue}break}}wk(e);d=L[e+928>>2];o:{if(d){c=L[e+192>>2];f=S(ha[L[L[c>>2]+48>>2]](c));h=P[d>>2];k=P[d+4>>2];n=P[d+8>>2];L[e+904>>2]=0;P[e+900>>2]=n-f;P[e+896>>2]=k-f;P[e+892>>2]=h-f;h=P[d+20>>2];k=P[d+24>>2];n=P[d+16>>2];L[e+920>>2]=0;P[e+916>>2]=f+k;P[e+912>>2]=f+h;d=e+908|0;P[d>>2]=f+n;c=L[e+188>>2];if(!c){break o}i=L[e+684>>2];l=L[i+32>>2];ha[L[L[l>>2]+16>>2]](l,c,e+892|0,d,L[i+36>>2]);break o}L[e+892>>2]=0;L[e+896>>2]=0;L[e+916>>2]=0;L[e+920>>2]=0;L[e+908>>2]=0;L[e+912>>2]=0;L[e+900>>2]=0;L[e+904>>2]=0}y=e+928|0;i=L[e+712>>2];if((i|0)>0){d=0;while(1){c=L[e+720>>2]+R(d,104)|0;h=P[c+12>>2];k=P[c+16>>2];n=P[c+8>>2];f=P[e+464>>2];L[r+140>>2]=0;P[r+128>>2]=f+n;L[r+124>>2]=0;P[r+112>>2]=n-f;P[r+136>>2]=f+k;P[r+132>>2]=f+h;P[r+120>>2]=k-f;P[r+116>>2]=h-f;l=L[c+96>>2];h=P[c+40>>2];k=P[c+44>>2];n=P[c+48>>2];f=P[e+460>>2];L[r+20>>2]=0;P[r+16>>2]=f*n;P[r+12>>2]=f*k;P[r+8>>2]=h*f;Dd(y,l,r+112|0,r+8|0,P[e+468>>2]);d=d+1|0;if((i|0)!=(d|0)){continue}break}}D=e+988|0;if(!(!L[e+988>>2]|L[e+752>>2]<=0)){l=0;while(1){u=L[e+760>>2]+R(l,44)|0;d=L[u+16>>2];x=P[d+40>>2];c=L[u+8>>2];B=P[c+40>>2];i=L[u+12>>2];z=P[i+40>>2];A=P[d+44>>2];v=P[c+44>>2];G=P[i+44>>2];H=P[d+48>>2];I=P[c+48>>2];Q=P[i+48>>2];h=P[d+12>>2];k=P[c+12>>2];n=P[i+12>>2];o=P[d+16>>2];p=P[c+16>>2];j=P[i+16>>2];g=P[d+8>>2];m=P[c+8>>2];t=P[i+8>>2];f=P[e+464>>2];q=P[d+20>>2];s=P[i+20>>2];w=P[c+20>>2];C=s>w?s:w;P[r+140>>2]=q>C?q:C;C=m>2]=f+(g>C?g:C);s=s>2]=qt?t:m;P[r+112>>2]=(gp?j:p;P[r+136>>2]=f+(g>2]=f+(h>g?h:g);p=j>2]=(on?n:k;P[r+116>>2]=(h>2];f=P[e+460>>2];L[r+20>>2]=0;P[r+16>>2]=f*S(S(H+S(I+Q))*S(.3333333432674408));P[r+12>>2]=f*S(S(A+S(v+G))*S(.3333333432674408));P[r+8>>2]=f*S(S(x+S(B+z))*S(.3333333432674408));Dd(D,d,r+112|0,r+8|0,P[e+468>>2]);l=l+1|0;if((l|0)>2]){continue}break}}h=S(0);c=0;k=S(0);n=S(0);f=S(0);j=S(0);d=fa-144|0;fa=d;p:{if(!M[e+473|0]){break p}i=L[e+712>>2];Z=(i|0)<=0;q:{if(Z){break q}l=L[e+512>>2];u=L[e+720>>2];if((i|0)!=1){aa=i&-2;while(1){E=u+R(c,104)|0;o=P[l+(c<<2)>>2];$=c|1;F=u+R($,104)|0;p=P[l+($<<2)>>2];n=S(S(n+S(P[E+8>>2]*o))+S(P[F+8>>2]*p));h=S(S(h+S(o*P[E+16>>2]))+S(p*P[F+16>>2]));k=S(S(k+S(o*P[E+12>>2]))+S(p*P[F+12>>2]));c=c+2|0;O=O+2|0;if((aa|0)!=(O|0)){continue}break}}if(!(i&1)){break q}u=u+R(c,104)|0;o=P[l+(c<<2)>>2];n=S(n+S(P[u+8>>2]*o));h=S(h+S(o*P[u+16>>2]));k=S(k+S(o*P[u+12>>2]))}L[e+532>>2]=0;P[e+528>>2]=h;P[e+524>>2]=k;P[e+520>>2]=n;L[d+132>>2]=0;L[d+136>>2]=0;L[d+116>>2]=0;L[d+120>>2]=0;L[d+140>>2]=0;L[d+124>>2]=0;L[d+128>>2]=0;L[d+108>>2]=0;L[d+112>>2]=0;L[d+136>>2]=884998144;L[d+116>>2]=880803840;L[d+100>>2]=0;L[d+104>>2]=0;L[d+96>>2]=872415232;if(!Z){O=L[e+492>>2];E=L[e+720>>2];F=L[e+512>>2];o=P[d+120>>2];p=S(3.5762786865234375e-7);g=S(2.384185791015625e-7);m=S(1.1920928955078125e-7);t=P[d+104>>2];q=P[d+100>>2];s=P[d+112>>2];l=0;while(1){u=E+R(l,104)|0;B=P[u+16>>2];z=P[u+12>>2];c=O+(l<<4)|0;A=P[c>>2];v=P[c+4>>2];w=P[F+(l<<2)>>2];x=S(S(P[u+8>>2]-n)*w);t=S(S(x*P[c+8>>2])+t);P[d+104>>2]=t;q=S(S(x*v)+q);P[d+100>>2]=q;m=S(S(x*A)+m);P[d+96>>2]=m;A=P[c>>2];v=P[c+4>>2];x=S(w*S(z-k));o=S(S(x*P[c+8>>2])+o);P[d+120>>2]=o;g=S(S(x*v)+g);P[d+116>>2]=g;s=S(S(x*A)+s);P[d+112>>2]=s;x=P[c>>2];z=P[c+4>>2];w=S(w*S(B-h));p=S(S(w*P[c+8>>2])+p);P[d+136>>2]=p;f=S(S(w*z)+f);P[d+132>>2]=f;j=S(S(w*x)+j);P[d+128>>2]=j;l=l+1|0;if((i|0)!=(l|0)){continue}break}}if(!M[33884]){f=P[5821];L[8470]=L[5822];P[8469]=f;J[33884]=1}Wj(d+96|0,d+48|0,d);c=L[d+60>>2];L[e+544>>2]=L[d+56>>2];L[e+548>>2]=c;c=L[d+52>>2];L[e+536>>2]=L[d+48>>2];L[e+540>>2]=c;c=L[d+76>>2];L[e+560>>2]=L[d+72>>2];L[e+564>>2]=c;c=L[d+68>>2];L[e+552>>2]=L[d+64>>2];L[e+556>>2]=c;c=L[d+84>>2];L[e+568>>2]=L[d+80>>2];L[e+572>>2]=c;c=L[d+92>>2];L[e+576>>2]=L[d+88>>2];L[e+580>>2]=c;f=P[e+640>>2];h=P[e+632>>2];k=P[e+636>>2];n=P[e+656>>2];o=P[e+648>>2];p=P[e+652>>2];j=P[e+672>>2];g=P[e+664>>2];m=P[e+668>>2];t=P[d+88>>2];q=P[d+84>>2];s=P[d+56>>2];w=P[d+120>>2];x=P[d+72>>2];B=P[d+68>>2];z=P[d+128>>2];A=P[d+96>>2];v=P[d+112>>2];G=P[d+132>>2];H=P[d+100>>2];I=P[d+116>>2];Q=P[d+136>>2];C=P[d+80>>2];V=P[d+104>>2];W=P[d+48>>2];X=P[d+52>>2];Y=P[d+64>>2];L[e+628>>2]=0;L[e+612>>2]=0;L[e+596>>2]=0;K=S(S(t*j)+S(S(C*g)+S(q*m)));N=S(S(s*j)+S(S(W*g)+S(X*m)));m=S(S(x*j)+S(S(Y*g)+S(B*m)));j=S(S(Q*K)+S(S(V*N)+S(w*m)));P[e+624>>2]=j;g=S(S(G*K)+S(S(H*N)+S(m*I)));P[e+620>>2]=g;m=S(S(z*K)+S(S(A*N)+S(v*m)));P[e+616>>2]=m;K=S(S(t*n)+S(S(C*o)+S(q*p)));N=S(S(s*n)+S(S(W*o)+S(X*p)));p=S(S(x*n)+S(S(Y*o)+S(B*p)));n=S(S(Q*K)+S(S(V*N)+S(w*p)));P[e+608>>2]=n;o=S(S(G*K)+S(S(H*N)+S(p*I)));P[e+604>>2]=o;p=S(S(z*K)+S(S(A*N)+S(p*v)));P[e+600>>2]=p;t=S(S(t*f)+S(S(C*h)+S(q*k)));q=S(S(s*f)+S(S(W*h)+S(X*k)));f=S(S(x*f)+S(S(Y*h)+S(B*k)));h=S(S(Q*t)+S(S(V*q)+S(w*f)));P[e+592>>2]=h;k=S(S(G*t)+S(S(H*q)+S(f*I)));P[e+588>>2]=k;t=S(S(z*t)+S(S(A*q)+S(f*v)));P[e+584>>2]=t;f=P[e+364>>2];if(!(f>S(1))){break p}v=j;j=S(S(1)/S(S(h*S(S(p*g)-S(m*o)))+S(S(t*S(S(o*j)-S(g*n)))+S(S(S(n*m)-S(j*p))*k))));f=j>2]=v*f;P[e+620>>2]=g*f;P[e+616>>2]=m*f;P[e+608>>2]=n*f;P[e+604>>2]=o*f;P[e+600>>2]=p*f;P[e+592>>2]=h*f;P[e+588>>2]=k*f;P[e+584>>2]=t*f}fa=d+144|0;r:{if(!M[e+473|0]|!(P[e+320>>2]>S(0))){break r}l=L[e+712>>2];if((l|0)<=0){break r}o=P[e+576>>2];p=P[e+572>>2];j=P[e+568>>2];g=P[e+560>>2];m=P[e+556>>2];t=P[e+552>>2];q=P[e+544>>2];s=P[e+540>>2];w=P[e+536>>2];d=0;while(1){c=L[e+720>>2]+R(d,104)|0;if(P[c+88>>2]>S(0)){i=L[e+492>>2]+(d<<4)|0;f=P[i+8>>2];h=P[i>>2];k=P[i+4>>2];x=P[e+520>>2];B=P[e+524>>2];n=P[e+320>>2];z=P[e+528>>2];L[c+20>>2]=0;A=P[c+16>>2];P[c+16>>2]=A+S(n*S(S(z+S(S(o*f)+S(S(j*h)+S(p*k))))-A));z=P[c+12>>2];P[c+12>>2]=z+S(n*S(S(B+S(S(g*f)+S(S(t*h)+S(m*k))))-z));B=P[c+8>>2];P[c+8>>2]=B+S(n*S(S(x+S(S(q*f)+S(S(w*h)+S(s*k))))-B))}d=d+1|0;if((l|0)!=(d|0)){continue}break}}pa(r+8|0,0,104);l=L[e+812>>2];if((l|0)<0){if(L[e+816>>2]<0){d=L[e+820>>2];if(!(d?!d|!M[e+824|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](d)}J[e+824|0]=1;L[e+816>>2]=0;L[e+820>>2]=0}while(1){d=L[e+820>>2]+R(l,104)|0;L[d>>2]=0;L[d+4>>2]=0;L[d+24>>2]=0;L[d+16>>2]=0;L[d+20>>2]=0;L[d+8>>2]=0;L[d+12>>2]=0;c=L[r+48>>2];L[d+36>>2]=L[r+44>>2];L[d+40>>2]=c;c=L[r+40>>2];L[d+28>>2]=L[r+36>>2];L[d+32>>2]=c;c=L[r+64>>2];L[d+52>>2]=L[r+60>>2];L[d+56>>2]=c;c=L[r+56>>2];L[d+44>>2]=L[r+52>>2];L[d+48>>2]=c;c=L[r+80>>2];L[d+68>>2]=L[r+76>>2];L[d+72>>2]=c;c=L[r+72>>2];L[d+60>>2]=L[r+68>>2];L[d+64>>2]=c;c=L[r+88>>2];L[d+76>>2]=L[r+84>>2];L[d+80>>2]=c;c=L[r+96>>2];L[d+84>>2]=L[r+92>>2];L[d+88>>2]=c;c=L[r+104>>2];L[d+92>>2]=L[r+100>>2];L[d+96>>2]=c;L[d+100>>2]=L[r+108>>2];l=l+1|0;if(l){continue}break}}L[e+812>>2]=0;c=L[e+832>>2];s:{if((c|0)>=0){break s}if(L[e+836>>2]<0){d=L[e+840>>2];if(!(d?!d|!M[e+844|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](d)}J[e+844|0]=1;L[e+836>>2]=0;L[e+840>>2]=0}l=0;d=c;u=0-c&3;if(u){while(1){i=L[e+840>>2]+R(d,56)|0;L[i>>2]=0;L[i+4>>2]=0;L[i+48>>2]=0;L[i+52>>2]=0;L[i+40>>2]=0;L[i+44>>2]=0;L[i+32>>2]=0;L[i+36>>2]=0;L[i+24>>2]=0;L[i+28>>2]=0;L[i+16>>2]=0;L[i+20>>2]=0;L[i+8>>2]=0;L[i+12>>2]=0;d=d+1|0;l=l+1|0;if((u|0)!=(l|0)){continue}break}}if(c>>>0>4294967292){break s}while(1){i=R(d,56);c=i+L[e+840>>2]|0;L[c>>2]=0;L[c+4>>2]=0;L[c+48>>2]=0;L[c+52>>2]=0;L[c+40>>2]=0;L[c+44>>2]=0;L[c+32>>2]=0;L[c+36>>2]=0;L[c+24>>2]=0;L[c+28>>2]=0;L[c+16>>2]=0;L[c+20>>2]=0;L[c+8>>2]=0;L[c+12>>2]=0;c=i+L[e+840>>2]|0;L[c+104>>2]=0;L[c+108>>2]=0;L[c+96>>2]=0;L[c+100>>2]=0;L[c+88>>2]=0;L[c+92>>2]=0;L[c+80>>2]=0;L[c+84>>2]=0;L[c+72>>2]=0;L[c+76>>2]=0;l=c- -64|0;L[l>>2]=0;L[l+4>>2]=0;L[c+56>>2]=0;L[c+60>>2]=0;c=i+L[e+840>>2]|0;L[c+160>>2]=0;L[c+164>>2]=0;L[c+152>>2]=0;L[c+156>>2]=0;L[c+144>>2]=0;L[c+148>>2]=0;L[c+136>>2]=0;L[c+140>>2]=0;L[c+128>>2]=0;L[c+132>>2]=0;L[c+120>>2]=0;L[c+124>>2]=0;L[c+112>>2]=0;L[c+116>>2]=0;c=i+L[e+840>>2]|0;L[c+216>>2]=0;L[c+220>>2]=0;L[c+208>>2]=0;L[c+212>>2]=0;L[c+200>>2]=0;L[c+204>>2]=0;L[c+192>>2]=0;L[c+196>>2]=0;L[c+184>>2]=0;L[c+188>>2]=0;L[c+176>>2]=0;L[c+180>>2]=0;L[c+168>>2]=0;L[c+172>>2]=0;d=d+4|0;if(d){continue}break}}L[e+832>>2]=0;Hc(y,1);Hc(D,1);Hc(e+1048|0,1);fa=r+144|0;d=L[a+24>>2]}U=U+1|0;if((U|0)<(d|0)){continue}break}}}function Hg(a,b,c,d,e){var f=0,g=0,h=0,i=0,j=0,k=S(0),l=0,m=S(0),n=0,o=0,p=S(0),q=S(0),r=S(0),s=0,t=S(0),u=0,v=S(0),w=0,x=S(0),y=S(0),z=S(0),A=S(0),B=S(0),C=0,D=S(0),E=S(0),F=S(0),G=S(0),H=S(0),I=S(0),K=S(0),N=0,O=0,Q=S(0),R=S(0),U=S(0),V=S(0),W=0,X=S(0),Y=0,Z=0,$=0,aa=S(0),ba=S(0),ca=S(0),da=S(0),ea=S(0),ia=S(0),ja=0,ka=S(0),la=S(0),ma=S(0),na=S(0),oa=S(0),pa=S(0),ra=S(0),sa=S(0),ta=S(0),ua=S(0),va=S(0),wa=S(0),xa=S(0),ya=S(0);f=fa-960|0;fa=f;a:{if((ha[L[L[d>>2]+80>>2]](d)|0)==2){g=L[d+152>>2];h=g-1|0;L[a+28>>2]=h;if(!g){break a}while(1){Hg(a,b,c,L[L[d+160>>2]+(h<<2)>>2],e);g=L[a+28>>2];h=g-1|0;L[a+28>>2]=h;if(g){continue}break}break a}if((ha[L[L[e>>2]+80>>2]](e)|0)==2){g=L[e+152>>2];h=g-1|0;L[a+36>>2]=h;if(!g){break a}while(1){Hg(a,b,c,d,L[L[e+160>>2]+(h<<2)>>2]);g=L[a+36>>2];h=g-1|0;L[a+36>>2]=h;if(g){continue}break}break a}h=L[b+12>>2];g=L[h+12>>2];L[f+904>>2]=L[h+8>>2];L[f+908>>2]=g;g=L[h+4>>2];L[f+896>>2]=L[h>>2];L[f+900>>2]=g;g=L[h+28>>2];L[f+920>>2]=L[h+24>>2];L[f+924>>2]=g;g=L[h+20>>2];L[f+912>>2]=L[h+16>>2];L[f+916>>2]=g;g=L[h+44>>2];L[f+936>>2]=L[h+40>>2];L[f+940>>2]=g;g=L[h+36>>2];L[f+928>>2]=L[h+32>>2];L[f+932>>2]=g;g=L[h+60>>2];L[f+952>>2]=L[h+56>>2];L[f+956>>2]=g;g=L[h+52>>2];L[f+944>>2]=L[h+48>>2];L[f+948>>2]=g;h=L[c+12>>2];g=L[h+12>>2];L[f+840>>2]=L[h+8>>2];L[f+844>>2]=g;g=L[h+4>>2];L[f+832>>2]=L[h>>2];L[f+836>>2]=g;g=L[h+28>>2];L[f+856>>2]=L[h+24>>2];L[f+860>>2]=g;g=L[h+20>>2];L[f+848>>2]=L[h+16>>2];L[f+852>>2]=g;g=L[h+44>>2];L[f+872>>2]=L[h+40>>2];L[f+876>>2]=g;g=L[h+36>>2];L[f+864>>2]=L[h+32>>2];L[f+868>>2]=g;g=L[h+60>>2];L[f+888>>2]=L[h+56>>2];L[f+892>>2]=g;g=L[h+52>>2];L[f+880>>2]=L[h+48>>2];L[f+884>>2]=g;L[f+816>>2]=0;L[8513]=L[8513]+1;L[f+824>>2]=ha[L[6798]](256,16);J[f+828|0]=1;L[f+820>>2]=32;l=f+896|0;s=f+832|0;o=f+812|0;i=fa+-64|0;fa=i;b:{if(!(!L[d+68>>2]|!L[e+68>>2])){j=fa-112|0;fa=j;g=d+68|0;h=e+68|0;if(!(!L[g>>2]|!L[h>>2])){Q=P[l+52>>2];D=P[l+56>>2];E=P[s+52>>2];F=P[s+56>>2];aa=P[l+20>>2];ba=P[l+36>>2];G=P[s+20>>2];H=P[s+36>>2];R=P[s+24>>2];ca=P[l+24>>2];m=P[s+40>>2];da=P[l+40>>2];U=P[l+48>>2];y=P[s+48>>2];ea=P[l+32>>2];ia=P[l+16>>2];z=P[l>>2];A=P[l+4>>2];X=P[s+32>>2];V=P[s+16>>2];I=P[s>>2];K=P[s+4>>2];k=P[s+8>>2];B=P[l+8>>2];L[j+60>>2]=0;L[j+44>>2]=0;L[j+28>>2]=0;x=S(S(m*da)+S(S(k*B)+S(ca*R)));P[j+56>>2]=x;v=S(S(H*da)+S(S(K*B)+S(ca*G)));P[j+52>>2]=v;r=S(S(X*da)+S(S(I*B)+S(ca*V)));P[j+48>>2]=r;p=S(S(m*ba)+S(S(k*A)+S(aa*R)));P[j+40>>2]=p;q=S(S(H*ba)+S(S(K*A)+S(aa*G)));P[j+36>>2]=q;t=S(S(X*ba)+S(S(I*A)+S(aa*V)));P[j+32>>2]=t;m=S(S(m*ea)+S(S(k*z)+S(ia*R)));P[j+24>>2]=m;k=S(S(H*ea)+S(S(K*z)+S(ia*G)));P[j+20>>2]=k;P[j+104>>2]=S(T(x))+S(9.999999974752427e-7);P[j+100>>2]=S(T(v))+S(9.999999974752427e-7);P[j+96>>2]=S(T(r))+S(9.999999974752427e-7);P[j+88>>2]=S(T(p))+S(9.999999974752427e-7);P[j+84>>2]=S(T(q))+S(9.999999974752427e-7);P[j+80>>2]=S(T(t))+S(9.999999974752427e-7);P[j+72>>2]=S(T(m))+S(9.999999974752427e-7);P[j+68>>2]=S(T(k))+S(9.999999974752427e-7);L[j+12>>2]=0;k=S(-U);P[j+8>>2]=S(S(S(B*k)-S(ca*Q))-S(da*D))+S(S(F*da)+S(S(y*B)+S(ca*E)));P[j+4>>2]=S(S(S(A*k)-S(aa*Q))-S(ba*D))+S(S(F*ba)+S(S(y*A)+S(aa*E)));P[j>>2]=S(S(S(z*k)-S(ia*Q))-S(ea*D))+S(S(F*ea)+S(S(y*z)+S(ia*E)));k=S(S(X*ea)+S(S(I*z)+S(ia*V)));P[j+16>>2]=k;P[j+64>>2]=S(T(k))+S(9.999999974752427e-7);xb(g,h,o,j,0,0,1)}fa=j+112|0;break b}W=ha[L[L[d>>2]+88>>2]](d)|0;if(!W){break b}N=i+16|0;u=i+48|0;while(1){W=W-1|0;ha[L[L[d>>2]+120>>2]](d,W,l,i+32|0,u);Y=ha[L[L[e>>2]+88>>2]](e)|0;if(Y){while(1){ha[L[L[e>>2]+120>>2]](e,W,s,i,N);Y=Y-1|0;c:{if(P[i+16>>2]>2]|P[i>>2]>P[i+48>>2]|(P[i+20>>2]>2]|P[i+4>>2]>P[i+52>>2])){break c}if(P[i+24>>2]>2]|P[i+8>>2]>P[i+56>>2]){break c}n=L[o+4>>2];d:{if((n|0)!=L[o+8>>2]){break d}O=n?n<<1:1;if((O|0)<=(n|0)){break d}e:{if(!O){C=0;break e}L[8513]=L[8513]+1;C=ha[L[6798]](O<<3,16)|0;n=L[o+4>>2]}w=L[o+12>>2];f:{g:{if((n|0)>0){Z=0;if((n|0)!=1){j=n&-2;ja=0;while(1){$=Z<<3;h=$+C|0;g=w+$|0;L[h>>2]=L[g>>2];L[h+4>>2]=L[g+4>>2];g=$|8;h=g+C|0;g=g+w|0;L[h>>2]=L[g>>2];L[h+4>>2]=L[g+4>>2];Z=Z+2|0;ja=ja+2|0;if((j|0)!=(ja|0)){continue}break}}if(n&1){g=Z<<3;h=g+C|0;g=g+w|0;L[h>>2]=L[g>>2];L[h+4>>2]=L[g+4>>2]}if(M[o+16|0]){break g}break f}if(!w|!M[o+16|0]){break f}}if(w){L[8514]=L[8514]+1;ha[L[6799]](w)}n=L[o+4>>2]}L[o+12>>2]=C;J[o+16|0]=1;L[o+8>>2]=O}g=L[o+12>>2]+(n<<3)|0;L[g+4>>2]=Y;L[g>>2]=W;L[o+4>>2]=n+1}if(Y){continue}break}}if(W){continue}break}}fa=i- -64|0;h:{if(!L[f+816>>2]){break h}i:{if((ha[L[L[d>>2]+80>>2]](d)|0)!=1){break i}if((ha[L[L[e>>2]+80>>2]](e)|0)!=1){break i}Y=L[f+824>>2];Z=L[f+816>>2];i=fa-432|0;fa=i;h=L[c+12>>2];ka=P[h+56>>2];la=P[h+52>>2];ma=P[h+40>>2];na=P[h+36>>2];oa=P[h+24>>2];pa=P[h+20>>2];g=L[b+12>>2];ra=P[g+56>>2];sa=P[g+52>>2];ta=P[g+40>>2];ua=P[g+36>>2];va=P[g+24>>2];wa=P[g+20>>2];xa=P[h+48>>2];ya=P[h+32>>2];aa=P[h+16>>2];ba=P[h+8>>2];ca=P[h+4>>2];da=P[h>>2];ea=P[g+48>>2];ia=P[g+32>>2];z=P[g+16>>2];A=P[g+8>>2];B=P[g+4>>2];Q=P[g>>2];L[i+424>>2]=1008981770;L[i+352>>2]=1008981770;ha[L[L[d>>2]+112>>2]](d);ha[L[L[e>>2]+112>>2]](e);if(Z){ja=i+16|0;while(1){h=L[Y>>2];L[a+24>>2]=h;L[a+32>>2]=L[Y+4>>2];g=ha[L[L[d>>2]+84>>2]](d)|0;ha[L[L[g>>2]+20>>2]](g,h,i+360|0);h=L[a+32>>2];g=ha[L[L[e>>2]+84>>2]](e)|0;ha[L[L[g>>2]+20>>2]](g,h,i+288|0);L[i+372>>2]=0;L[i+388>>2]=0;L[i+404>>2]=0;I=P[i+384>>2];K=P[i+376>>2];U=P[i+380>>2];X=S(sa+S(S(I*va)+S(S(K*z)+S(wa*U))));P[i+380>>2]=X;x=P[i+368>>2];v=P[i+360>>2];r=P[i+364>>2];D=S(sa+S(S(x*va)+S(S(v*z)+S(wa*r))));P[i+364>>2]=D;p=P[i+400>>2];m=P[i+392>>2];k=P[i+396>>2];V=S(sa+S(S(p*va)+S(S(m*z)+S(wa*k))));P[i+396>>2]=V;q=S(ra+S(S(I*ta)+S(S(K*ia)+S(ua*U))));P[i+384>>2]=q;t=S(ea+S(S(p*A)+S(S(m*Q)+S(B*k))));P[i+392>>2]=t;E=S(ra+S(S(x*ta)+S(S(v*ia)+S(ua*r))));P[i+368>>2]=E;m=S(ra+S(S(p*ta)+S(S(m*ia)+S(ua*k))));P[i+400>>2]=m;F=S(ea+S(S(x*A)+S(S(v*Q)+S(B*r))));P[i+360>>2]=F;k=S(ea+S(S(I*A)+S(S(K*Q)+S(B*U))));P[i+376>>2]=k;v=P[i+296>>2];r=P[i+288>>2];p=P[i+292>>2];L[i+300>>2]=0;G=S(la+S(S(v*oa)+S(S(r*aa)+S(pa*p))));P[i+292>>2]=G;H=S(ka+S(S(v*ma)+S(S(r*ya)+S(na*p))));P[i+296>>2]=H;R=S(xa+S(S(v*ba)+S(S(r*da)+S(ca*p))));P[i+288>>2]=R;v=P[i+312>>2];r=P[i+304>>2];p=P[i+308>>2];L[i+316>>2]=0;I=S(la+S(S(v*oa)+S(S(r*aa)+S(pa*p))));P[i+308>>2]=I;K=S(ka+S(S(v*ma)+S(S(r*ya)+S(na*p))));P[i+312>>2]=K;U=S(xa+S(S(v*ba)+S(S(r*da)+S(ca*p))));P[i+304>>2]=U;y=P[i+328>>2];r=P[i+320>>2];p=P[i+324>>2];L[i+332>>2]=0;x=S(la+S(S(y*oa)+S(S(r*aa)+S(pa*p))));P[i+324>>2]=x;v=S(xa+S(S(y*ba)+S(S(r*da)+S(ca*p))));P[i+320>>2]=v;r=S(ka+S(S(y*ma)+S(S(r*ya)+S(na*p))));P[i+328>>2]=r;p=S(q-E);q=S(t-F);t=S(m-E);k=S(k-F);y=S(S(p*q)-S(t*k));m=S(V-D);V=S(k*m);k=S(X-D);q=S(V-S(q*k));m=S(S(k*t)-S(m*p));k=S(S(1)/S(_(S(S(q*q)+S(S(m*m)+S(y*y))))));t=S(y*k);P[i+412>>2]=t;m=S(m*k);P[i+408>>2]=m;k=S(q*k);P[i+416>>2]=k;P[i+420>>2]=S(E*k)+S(S(F*m)+S(D*t));p=S(K-H);q=S(v-R);t=S(r-H);k=S(U-R);r=S(S(p*q)-S(t*k));m=S(x-G);v=S(k*m);k=S(I-G);q=S(v-S(q*k));m=S(S(k*t)-S(m*p));k=S(S(1)/S(_(S(S(q*q)+S(S(m*m)+S(r*r))))));t=S(r*k);P[i+340>>2]=t;m=S(m*k);P[i+336>>2]=m;k=S(q*k);P[i+344>>2]=k;P[i+348>>2]=S(H*k)+S(S(R*m)+S(G*t));Z=Z-1|0;q=P[i+416>>2];t=P[i+408>>2];m=P[i+412>>2];k=P[i+420>>2];p=S(P[i+424>>2]+P[i+352>>2]);j:{if(!(!(S(S(S(S(P[i+296>>2]*q)+S(S(P[i+288>>2]*t)+S(P[i+292>>2]*m)))-k)-p)>S(0))|!(S(S(S(S(P[i+312>>2]*q)+S(S(P[i+304>>2]*t)+S(m*P[i+308>>2])))-k)-p)>S(0)))){h=0;if(S(S(S(S(P[i+328>>2]*q)+S(S(P[i+320>>2]*t)+S(m*P[i+324>>2])))-k)-p)>S(0)){break j}}q=P[i+344>>2];t=P[i+336>>2];m=P[i+340>>2];k=P[i+348>>2];h=!(S(S(S(S(P[i+368>>2]*q)+S(S(P[i+360>>2]*t)+S(P[i+364>>2]*m)))-k)-p)>S(0))|!(S(S(S(S(P[i+384>>2]*q)+S(S(P[i+376>>2]*t)+S(m*P[i+380>>2])))-k)-p)>S(0))|!(S(S(S(S(P[i+400>>2]*q)+S(S(P[i+392>>2]*t)+S(m*P[i+396>>2])))-k)-p)>S(0))}k:{if(!h){break k}o=i+8|0;n=0;w=0;l=fa-880|0;fa=l;h=i+288|0;m=P[h+64>>2];g=i+360|0;k=P[g+64>>2];j=L[g+60>>2];L[l+296>>2]=L[g+56>>2];L[l+300>>2]=j;j=L[g+52>>2];L[l+288>>2]=L[g+48>>2];L[l+292>>2]=j;u=Ll(g,h,l+560|0);j=0;l:{if(!u){break l}j=0;if((u|0)<=0){break l}x=S(k+m);m=P[l+300>>2];r=P[l+296>>2];p=P[l+292>>2];t=S(-1e3);q=P[l+288>>2];m:{while(1){n:{o:{j=(l+560|0)+(n<<4)|0;k=S(x-S(S(S(P[j+8>>2]*r)+S(S(P[j>>2]*q)+S(P[j+4>>2]*p)))-m));p:{if(!(k>=S(0))){break p}if(k>t){break o}if(!(S(k+S(1.1920928955078125e-7))>=t)){break p}L[l+(w<<2)>>2]=n;w=w+1|0}n=n+1|0;if((u|0)!=(n|0)){continue}k=t;if((w|0)<=0){break m}break n}L[l>>2]=n;w=1;t=k;n=n+1|0;if((u|0)!=(n|0)){continue}}break}n=0;if((w|0)!=1){$=w&-2;O=l+304|0;C=0;while(1){N=l+560|0;W=N+(L[l+(n<<2)>>2]<<4)|0;j=L[W+12>>2];u=O+(n<<4)|0;L[u+8>>2]=L[W+8>>2];L[u+12>>2]=j;j=L[W+4>>2];L[u>>2]=L[W>>2];L[u+4>>2]=j;j=n|1;u=O+(j<<4)|0;N=N+(L[l+(j<<2)>>2]<<4)|0;j=L[N+12>>2];L[u+8>>2]=L[N+8>>2];L[u+12>>2]=j;j=L[N+4>>2];L[u>>2]=L[N>>2];L[u+4>>2]=j;n=n+2|0;C=C+2|0;if(($|0)!=(C|0)){continue}break}}if(w&1){N=(l+560|0)+(L[l+(n<<2)>>2]<<4)|0;j=L[N+4>>2];u=(l+280|0)+(n<<4)|0;L[u+24>>2]=L[N>>2];L[u+28>>2]=j;j=L[N+12>>2];L[u+32>>2]=L[N+8>>2];L[u+36>>2]=j}t=k}j=0;if(!w){break l}P[l+296>>2]=-r;P[l+292>>2]=-p;P[l+288>>2]=-q;j=L[h+60>>2];L[l+16>>2]=L[h+56>>2];L[l+20>>2]=j;j=L[h+52>>2];L[l+8>>2]=L[h+48>>2];L[l+12>>2]=j;h=Ll(h,g,l+560|0);j=0;if(!h){break l}j=0;if((h|0)<=0){break l}v=P[l+20>>2];r=P[l+16>>2];p=P[l+12>>2];m=S(-1e3);s=0;q=P[l+8>>2];n=0;q:{while(1){r:{s:{g=(l+560|0)+(n<<4)|0;k=S(x-S(S(S(P[g+8>>2]*r)+S(S(P[g>>2]*q)+S(P[g+4>>2]*p)))-v));t:{if(!(k>=S(0))){break t}if(k>m){break s}if(!(S(k+S(1.1920928955078125e-7))>=m)){break t}L[(l+816|0)+(s<<2)>>2]=n;s=s+1|0}n=n+1|0;if((h|0)!=(n|0)){continue}k=m;if((s|0)<=0){break q}break r}L[l+816>>2]=n;s=1;m=k;n=n+1|0;if((h|0)!=(n|0)){continue}}break}n=0;if((s|0)!=1){N=s&-2;$=l+24|0;C=0;while(1){j=l+560|0;u=l+816|0;O=j+(L[u+(n<<2)>>2]<<4)|0;g=L[O+12>>2];h=$+(n<<4)|0;L[h+8>>2]=L[O+8>>2];L[h+12>>2]=g;g=L[O+4>>2];L[h>>2]=L[O>>2];L[h+4>>2]=g;g=n|1;h=$+(g<<4)|0;j=j+(L[u+(g<<2)>>2]<<4)|0;g=L[j+12>>2];L[h+8>>2]=L[j+8>>2];L[h+12>>2]=g;g=L[j+4>>2];L[h>>2]=L[j>>2];L[h+4>>2]=g;n=n+2|0;C=C+2|0;if((N|0)!=(C|0)){continue}break}}if(s&1){j=(l+560|0)+(L[(l+816|0)+(n<<2)>>2]<<4)|0;g=L[j+4>>2];h=l+(n<<4)|0;L[h+24>>2]=L[j>>2];L[h+28>>2]=g;g=L[j+12>>2];L[h+32>>2]=L[j+8>>2];L[h+36>>2]=g}m=k}j=0;if(!s){break l}h=o+24|0;u:{if(m>2]=m;g=L[l+20>>2];L[o+16>>2]=L[l+16>>2];L[o+20>>2]=g;g=L[l+12>>2];L[o+8>>2]=L[l+8>>2];L[o+12>>2]=g;L[o+4>>2]=s;qa(h,l+24|0,s<<4);break u}P[o>>2]=t;g=L[l+300>>2];L[o+16>>2]=L[l+296>>2];L[o+20>>2]=g;g=L[l+292>>2];L[o+8>>2]=L[l+288>>2];L[o+12>>2]=g;L[o+4>>2]=w;qa(h,l+304|0,w<<4)}j=1}fa=l+880|0;if(!j){break k}u=L[i+12>>2];if(!u){break k}while(1){k=P[i+8>>2];g=L[a+16>>2];ha[L[L[g>>2]+8>>2]](g,L[a+28>>2],L[a+24>>2]);g=L[a+16>>2];ha[L[L[g>>2]+12>>2]](g,L[a+36>>2],L[a+32>>2]);u=u-1|0;h=(i+(u<<4)|0)+32|0;j=L[a+12>>2];if(!j){g=L[a+4>>2];j=ha[L[L[g>>2]+12>>2]](g,L[b+8>>2],L[c+8>>2])|0;L[a+12>>2]=j}g=L[a+16>>2];L[g+4>>2]=j;ha[L[L[g>>2]+16>>2]](g,ja,h,S(-k));if(u){continue}break}}Y=Y+8|0;if(Z){continue}break}}ha[L[L[d>>2]+116>>2]](d);ha[L[L[e>>2]+116>>2]](e);fa=i+432|0;break h}ha[L[L[d>>2]+112>>2]](d);ha[L[L[e>>2]+112>>2]](e);Y=yb(f+520|0);L[f+576>>2]=0;L[f+580>>2]=0;L[f+524>>2]=1;L[f+584>>2]=0;L[f+588>>2]=0;L[f+592>>2]=0;L[f+596>>2]=0;L[f+600>>2]=0;L[f+604>>2]=0;L[f+608>>2]=0;L[f+612>>2]=0;L[f+616>>2]=0;L[f+620>>2]=0;L[Y>>2]=2036;ja=Re(f+624|0);L[ja>>2]=4548;L[f+716>>2]=4;L[f+800>>2]=17472;L[f+792>>2]=17392;L[f+784>>2]=17320;L[f+516>>2]=d;h=f+792|0;v:{if(ha[L[L[d>>2]+96>>2]](d)|0){break v}g=L[f+516>>2];h=f+800|0;if(ha[L[L[g>>2]+100>>2]](g)|0){break v}h=f+784|0}L[f+808>>2]=h;L[h+4>>2]=f+516;Z=yb(f+224|0);L[f+280>>2]=0;L[f+284>>2]=0;L[f+228>>2]=1;L[f+288>>2]=0;L[f+292>>2]=0;L[f+296>>2]=0;L[f+300>>2]=0;L[f+304>>2]=0;L[f+308>>2]=0;L[f+312>>2]=0;L[f+316>>2]=0;L[f+320>>2]=0;L[f+324>>2]=0;L[Z>>2]=2036;$=Re(f+328|0);L[$>>2]=4548;L[f+420>>2]=4;L[f+504>>2]=17472;L[f+496>>2]=17392;L[f+488>>2]=17320;L[f+220>>2]=e;h=f+496|0;w:{if(ha[L[L[e>>2]+96>>2]](e)|0){break w}g=L[f+220>>2];h=f+504|0;if(ha[L[L[g>>2]+100>>2]](g)|0){break w}h=f+488|0}L[f+512>>2]=h;L[h+4>>2]=f+220;N=ha[L[L[d>>2]+92>>2]](d)|0;u=ha[L[L[e>>2]+92>>2]](e)|0;C=L[f+816>>2];if(C){while(1){C=C-1|0;g=L[f+824>>2]+(C<<3)|0;h=L[g>>2];L[a+24>>2]=h;L[a+32>>2]=L[g+4>>2];g=L[f+808>>2];O=ha[L[L[g>>2]>>2]](g,h)|0;g=L[f+512>>2];w=ha[L[L[g>>2]>>2]](g,L[a+32>>2])|0;h=L[b+12>>2];g=L[h+12>>2];L[f+160>>2]=L[h+8>>2];L[f+164>>2]=g;g=L[h+4>>2];L[f+152>>2]=L[h>>2];L[f+156>>2]=g;g=L[h+28>>2];L[f+176>>2]=L[h+24>>2];L[f+180>>2]=g;g=L[h+20>>2];L[f+168>>2]=L[h+16>>2];L[f+172>>2]=g;g=L[h+44>>2];L[f+192>>2]=L[h+40>>2];L[f+196>>2]=g;g=L[h+36>>2];L[f+184>>2]=L[h+32>>2];L[f+188>>2]=g;g=L[h+60>>2];L[f+208>>2]=L[h+56>>2];L[f+212>>2]=g;g=L[h+52>>2];L[f+200>>2]=L[h+48>>2];L[f+204>>2]=g;h=L[c+12>>2];g=L[h+12>>2];L[f+96>>2]=L[h+8>>2];L[f+100>>2]=g;g=L[h+4>>2];L[f+88>>2]=L[h>>2];L[f+92>>2]=g;g=L[h+28>>2];L[f+112>>2]=L[h+24>>2];L[f+116>>2]=g;g=L[h+20>>2];L[f+104>>2]=L[h+16>>2];L[f+108>>2]=g;g=L[h+44>>2];L[f+128>>2]=L[h+40>>2];L[f+132>>2]=g;g=L[h+36>>2];L[f+120>>2]=L[h+32>>2];L[f+124>>2]=g;g=L[h+60>>2];L[f+144>>2]=L[h+56>>2];L[f+148>>2]=g;g=L[h+52>>2];L[f+136>>2]=L[h+48>>2];L[f+140>>2]=g;if(N){ha[L[L[d>>2]+132>>2]](f+24|0,d,L[a+24>>2]);t=P[f+944>>2];m=P[f+948>>2];k=P[f+952>>2];R=P[f+80>>2];y=P[f+72>>2];X=P[f+76>>2];z=P[f+904>>2];A=P[f+896>>2];B=P[f+900>>2];Q=P[f+920>>2];D=P[f+912>>2];E=P[f+916>>2];V=P[f+56>>2];I=P[f+24>>2];K=P[f+40>>2];U=P[f+60>>2];x=P[f+28>>2];v=P[f+44>>2];F=P[f+936>>2];r=P[f+64>>2];G=P[f+928>>2];p=P[f+32>>2];H=P[f+932>>2];q=P[f+48>>2];L[f+212>>2]=0;L[f+196>>2]=0;L[f+180>>2]=0;L[f+164>>2]=0;P[f+192>>2]=S(r*F)+S(S(p*G)+S(q*H));P[f+188>>2]=S(U*F)+S(S(x*G)+S(v*H));P[f+184>>2]=S(V*F)+S(S(I*G)+S(K*H));P[f+176>>2]=S(r*Q)+S(S(p*D)+S(q*E));P[f+172>>2]=S(U*Q)+S(S(x*D)+S(v*E));P[f+168>>2]=S(V*Q)+S(S(I*D)+S(K*E));P[f+160>>2]=S(r*z)+S(S(p*A)+S(B*q));P[f+156>>2]=S(U*z)+S(S(x*A)+S(B*v));P[f+152>>2]=S(V*z)+S(S(I*A)+S(K*B));P[f+208>>2]=k+S(S(R*F)+S(S(y*G)+S(H*X)));P[f+204>>2]=m+S(S(R*Q)+S(S(y*D)+S(E*X)));P[f+200>>2]=t+S(S(R*z)+S(S(y*A)+S(B*X)))}if(u){ha[L[L[e>>2]+132>>2]](f+24|0,e,L[a+32>>2]);t=P[f+880>>2];m=P[f+884>>2];k=P[f+888>>2];R=P[f+80>>2];y=P[f+72>>2];X=P[f+76>>2];z=P[f+840>>2];A=P[f+832>>2];B=P[f+836>>2];Q=P[f+856>>2];D=P[f+848>>2];E=P[f+852>>2];V=P[f+56>>2];I=P[f+24>>2];K=P[f+40>>2];U=P[f+60>>2];x=P[f+28>>2];v=P[f+44>>2];F=P[f+872>>2];r=P[f+64>>2];G=P[f+864>>2];p=P[f+32>>2];H=P[f+868>>2];q=P[f+48>>2];L[f+148>>2]=0;L[f+132>>2]=0;L[f+116>>2]=0;L[f+100>>2]=0;P[f+128>>2]=S(r*F)+S(S(p*G)+S(q*H));P[f+124>>2]=S(U*F)+S(S(x*G)+S(v*H));P[f+120>>2]=S(V*F)+S(S(I*G)+S(K*H));P[f+112>>2]=S(r*Q)+S(S(p*D)+S(q*E));P[f+108>>2]=S(U*Q)+S(S(x*D)+S(v*E));P[f+104>>2]=S(V*Q)+S(S(I*D)+S(K*E));P[f+96>>2]=S(r*z)+S(S(p*A)+S(B*q));P[f+92>>2]=S(U*z)+S(S(x*A)+S(B*v));P[f+88>>2]=S(V*z)+S(S(I*A)+S(K*B));P[f+144>>2]=k+S(S(R*F)+S(S(y*G)+S(H*X)));P[f+140>>2]=m+S(S(R*Q)+S(S(y*D)+S(E*X)));P[f+136>>2]=t+S(S(R*z)+S(S(y*A)+S(B*X)))}j=L[a+28>>2];h=L[a+24>>2];g=L[b+8>>2];L[f+28>>2]=O;L[f+32>>2]=g;L[f+24>>2]=b;L[f+40>>2]=oI(h,j);L[f+44>>2]=ga;L[f+36>>2]=f+152;j=L[a+36>>2];h=L[a+32>>2];g=L[c+8>>2];L[f+4>>2]=w;L[f+8>>2]=g;L[f>>2]=c;L[f+16>>2]=oI(h,j);L[f+20>>2]=ga;L[f+12>>2]=f+88;o=fa-48|0;fa=o;g=L[a+16>>2];ha[L[L[g>>2]+8>>2]](g,L[a+28>>2],L[a+24>>2]);g=L[a+16>>2];ha[L[L[g>>2]+12>>2]](g,L[a+36>>2],L[a+32>>2]);j=L[a+28>>2];h=L[a+24>>2];g=L[f+36>>2];W=L[f+32>>2];L[o+28>>2]=O;L[o+32>>2]=W;L[o+36>>2]=g;L[o+24>>2]=f+24;L[o+40>>2]=oI(h,j);L[o+44>>2]=ga;j=L[a+36>>2];h=L[a+32>>2];g=L[f+12>>2];O=L[f+8>>2];L[o+4>>2]=w;L[o+8>>2]=O;L[o+12>>2]=g;L[o>>2]=f;L[o+16>>2]=oI(h,j);L[o+20>>2]=ga;s=L[a+8>>2];if(!s){s=L[a+12>>2];if(!s){g=L[a+4>>2];s=ha[L[L[g>>2]+12>>2]](g,W,O)|0;L[a+12>>2]=s}L[L[a+16>>2]+4>>2]=s;g=L[a+4>>2];s=ha[L[L[g>>2]+8>>2]](g,o+24|0,o,s)|0;L[a+8>>2]=s}ha[L[L[s>>2]+8>>2]](s,o+24|0,o,L[a+20>>2],L[a+16>>2]);fa=o+48|0;if(C){continue}break}}ha[L[L[d>>2]+116>>2]](d);ha[L[L[e>>2]+116>>2]](e);Oa($);Oa(Z);Oa(ja);Oa(Y)}a=L[f+824>>2];if(!a|!M[f+828|0]){break a}if(a){L[8514]=L[8514]+1;ha[L[6799]](a)}}fa=f+960|0}function eB(a,b,c,d,e,f,g,h,i){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;i=i|0;var j=0,k=0,l=0,m=0,n=0,o=S(0),p=0,q=S(0),r=0,s=0,t=S(0),u=S(0),v=0,w=0,x=S(0),y=S(0),z=S(0),A=S(0),B=S(0),C=S(0),D=S(0),E=S(0),F=S(0),G=0,H=S(0),I=S(0),K=S(0),N=S(0),O=S(0),Q=S(0),U=S(0),V=S(0),W=S(0),X=S(0),Y=S(0),Z=S(0),$=S(0),aa=S(0),ba=0,ca=0,da=S(0),ea=S(0),ga=S(0),ia=S(0),ja=S(0),ka=S(0),la=S(0),ma=0,na=S(0),oa=S(0),ra=S(0),sa=S(0);p=fa-256|0;fa=p;L[a+188>>2]=-1;wa(2882);i=0;L[a+184>>2]=0;a:{if((c|0)<=0){break a}if(c>>>0>=4){m=c&-4;while(1){j=i<<2;L[L[j+b>>2]+212>>2]=-1;L[L[(j|4)+b>>2]+212>>2]=-1;L[L[(j|8)+b>>2]+212>>2]=-1;L[L[(j|12)+b>>2]+212>>2]=-1;i=i+4|0;n=n+4|0;if((m|0)!=(n|0)){continue}break}}m=c&3;if(!m){break a}while(1){L[L[(i<<2)+b>>2]+212>>2]=-1;i=i+1|0;k=k+1|0;if((m|0)!=(k|0)){continue}break}}r=L[a+12>>2];if((r|0)<=(c|0)){r=c+1|0;if(r){L[8513]=L[8513]+1;i=ha[L[6798]](R(r,244),16)|0}else{i=0}j=L[a+8>>2];if((j|0)>0){n=0;while(1){m=R(n,244);s=m+i|0;l=m+L[a+16>>2]|0;m=L[l+4>>2];L[s>>2]=L[l>>2];L[s+4>>2]=m;m=L[l+12>>2];L[s+8>>2]=L[l+8>>2];L[s+12>>2]=m;m=L[l+28>>2];L[s+24>>2]=L[l+24>>2];L[s+28>>2]=m;m=L[l+20>>2];L[s+16>>2]=L[l+16>>2];L[s+20>>2]=m;m=L[l+44>>2];L[s+40>>2]=L[l+40>>2];L[s+44>>2]=m;m=L[l+36>>2];L[s+32>>2]=L[l+32>>2];L[s+36>>2]=m;m=L[l+52>>2];L[s+48>>2]=L[l+48>>2];L[s+52>>2]=m;m=L[l+60>>2];L[s+56>>2]=L[l+56>>2];L[s+60>>2]=m;qa(s- -64|0,l- -64|0,180);n=n+1|0;if((j|0)!=(n|0)){continue}break}}m=L[a+16>>2];if(!(m?!m|!M[a+20|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](m)}L[a+16>>2]=i;J[a+20|0]=1;L[a+12>>2]=r}pa(p+12|0,0,244);k=L[a+8>>2];if((k|0)<0){if((r|0)<0){i=L[a+16>>2];if(!(i?!i|!M[a+20|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](i)}J[a+20|0]=1;L[a+12>>2]=0;L[a+16>>2]=0}m=p+76|0;while(1){j=L[a+16>>2]+R(k,244)|0;L[j>>2]=0;L[j+4>>2]=0;L[j+8>>2]=0;L[j+12>>2]=0;i=L[p+40>>2];L[j+24>>2]=L[p+36>>2];L[j+28>>2]=i;i=L[p+32>>2];L[j+16>>2]=L[p+28>>2];L[j+20>>2]=i;i=L[p+48>>2];L[j+32>>2]=L[p+44>>2];L[j+36>>2]=i;i=L[p+56>>2];L[j+40>>2]=L[p+52>>2];L[j+44>>2]=i;i=L[p+64>>2];L[j+48>>2]=L[p+60>>2];L[j+52>>2]=i;i=L[p+72>>2];L[j+56>>2]=L[p+68>>2];L[j+60>>2]=i;qa(j- -64|0,m,180);k=k+1|0;if(k){continue}break}}L[a+8>>2]=0;if((c|0)>0){k=0;while(1){i=(k<<2)+b|0;m=vb(a,L[i>>2],P[h+12>>2]);j=L[i>>2];if(!(!(M[j+236|0]&2)|!j|(!(M[j+504|0]&2)|P[j+344>>2]==S(0)))){i=L[a+16>>2];z=P[h+76>>2];H=P[j+336>>2];W=P[j+44>>2];X=P[j+40>>2];Y=P[j+36>>2];I=P[j+332>>2];Z=P[j+28>>2];$=P[j+12>>2];q=P[j+404>>2];aa=P[j+24>>2];D=P[j+8>>2];u=P[j+400>>2];E=P[j+20>>2];K=P[j+328>>2];x=P[j+4>>2];o=P[j+396>>2];L[p+24>>2]=0;A=S(S(1)/q);t=S(Z*A);B=S(S(1)/o);q=S(E*B);C=S(S(1)/u);o=S(aa*C);u=S(S(H*S(S(W*t)+S(S(Y*q)+S(X*o))))+S(S(K*S(S($*t)+S(S(x*q)+S(D*o))))+S(I*S(S(Z*t)+S(S(E*q)+S(aa*o))))));t=S(A*$);q=S(B*x);o=S(C*D);o=S(S(H*S(S(W*t)+S(S(Y*q)+S(X*o))))+S(S(K*S(S($*t)+S(S(x*q)+S(D*o))))+S(I*S(S(Z*t)+S(S(E*q)+S(o*aa))))));y=S(S(K*u)-S(I*o));P[p+20>>2]=y;F=S(H*o);t=S(A*W);q=S(B*Y);o=S(C*X);o=S(S(H*S(S(W*t)+S(S(Y*q)+S(X*o))))+S(S(K*S(S($*t)+S(S(x*q)+S(D*o))))+S(I*S(S(Z*t)+S(S(E*q)+S(aa*o))))));q=S(F-S(K*o));P[p+16>>2]=q;u=S(S(I*o)-S(u*H));P[p+12>>2]=u;o=S(S(y*y)+S(S(u*u)+S(q*q)));if(o>S(z*z)){o=S(S(S(1)/S(_(o)))*z);P[p+20>>2]=y*o;P[p+16>>2]=q*o;P[p+12>>2]=u*o}B=P[j+304>>2];C=P[j+272>>2];t=P[j+288>>2];q=P[j+300>>2];u=P[j+268>>2];o=P[j+284>>2];i=i+R(m,244)|0;x=P[p+20>>2];z=P[p+12>>2];y=P[p+16>>2];A=P[h+12>>2];P[i+224>>2]=P[i+224>>2]-S(S(S(P[j+296>>2]*x)+S(S(P[j+264>>2]*z)+S(y*P[j+280>>2])))*A);P[i+228>>2]=P[i+228>>2]-S(A*S(S(q*x)+S(S(u*z)+S(y*o))));P[i+232>>2]=P[i+232>>2]-S(A*S(S(B*x)+S(S(C*z)+S(y*t))))}k=k+1|0;if((k|0)!=(c|0)){continue}break}}b:{if((g|0)<=0){break b}i=0;if((g|0)!=1){m=g&-2;b=0;while(1){c=i<<2;j=L[c+f>>2];ha[L[L[j>>2]+8>>2]](j);L[j+36>>2]=0;c=L[(c|4)+f>>2];ha[L[L[c>>2]+8>>2]](c);L[c+36>>2]=0;i=i+2|0;b=b+2|0;if((m|0)!=(b|0)){continue}break}}if(!(g&1)){break b}b=L[(i<<2)+f>>2];ha[L[L[b>>2]+8>>2]](b);L[b+36>>2]=0}b=L[a+168>>2];if(!((g|0)<=(b|0)|L[a+172>>2]>=(g|0))){c:{if(!g){k=0;break c}L[8513]=L[8513]+1;k=ha[L[6798]](g<<3,16)|0;b=L[a+168>>2]}d:{if((b|0)<=0){break d}n=0;i=0;if(b>>>0>=4){s=b&-4;c=0;while(1){G=i<<3;l=G+k|0;j=G+L[a+176>>2]|0;m=L[j+4>>2];L[l>>2]=L[j>>2];L[l+4>>2]=m;m=G|8;l=m+k|0;j=m+L[a+176>>2]|0;m=L[j+4>>2];L[l>>2]=L[j>>2];L[l+4>>2]=m;m=G|16;l=m+k|0;j=m+L[a+176>>2]|0;m=L[j+4>>2];L[l>>2]=L[j>>2];L[l+4>>2]=m;m=G|24;l=m+k|0;j=m+L[a+176>>2]|0;m=L[j+4>>2];L[l>>2]=L[j>>2];L[l+4>>2]=m;i=i+4|0;c=c+4|0;if((s|0)!=(c|0)){continue}break}}j=b&3;if(!j){break d}while(1){b=i<<3;m=b+k|0;c=b+L[a+176>>2]|0;b=L[c+4>>2];L[m>>2]=L[c>>2];L[m+4>>2]=b;i=i+1|0;n=n+1|0;if((j|0)!=(n|0)){continue}break}}b=L[a+176>>2];if(!(b?!b|!M[a+180|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+176>>2]=k;J[a+180|0]=1;L[a+172>>2]=g}L[a+168>>2]=g;n=0;if((g|0)>0){k=0;while(1){m=L[a+176>>2];i=(k<<2)+f|0;b=L[i>>2];c=L[b+44>>2];if(c){L[c>>2]=0;L[c+4>>2]=0;L[c+56>>2]=0;L[c+60>>2]=0;L[c+48>>2]=0;L[c+52>>2]=0;L[c+40>>2]=0;L[c+44>>2]=0;L[c+32>>2]=0;L[c+36>>2]=0;L[c+24>>2]=0;L[c+28>>2]=0;L[c+16>>2]=0;L[c+20>>2]=0;L[c+8>>2]=0;L[c+12>>2]=0;b=L[i>>2]}c=m+(k<<3)|0;e:{if(M[b+20|0]){ha[L[L[b>>2]+16>>2]](b,c);b=L[c>>2];break e}L[c>>2]=0;L[c+4>>2]=0;b=0}n=b+n|0;k=k+1|0;if((k|0)!=(g|0)){continue}break}}b=L[a+48>>2];if(!((n|0)<=(b|0)|L[a+52>>2]>=(n|0))){f:{if(!n){k=0;break f}L[8513]=L[8513]+1;k=ha[L[6798]](R(n,152),16)|0;b=L[a+48>>2]}g:{if((b|0)<=0){break g}j=b&1;i=0;if((b|0)!=1){m=b&-2;b=0;while(1){c=R(i,152);qa(c+k|0,c+L[a+56>>2]|0,152);c=R(i|1,152);qa(c+k|0,c+L[a+56>>2]|0,152);i=i+2|0;b=b+2|0;if((m|0)!=(b|0)){continue}break}}if(!j){break g}b=R(i,152);qa(b+k|0,b+L[a+56>>2]|0,152)}b=L[a+56>>2];if(!(b?!b|!M[a+60|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+56>>2]=k;J[a+60|0]=1;L[a+52>>2]=n}L[a+48>>2]=n;if((g|0)>0){k=L[a+176>>2];while(1){m=ca<<3;ba=m+k|0;if(L[ba>>2]){G=(ca<<2)+f|0;k=L[G>>2];v=L[k+32>>2];i=L[a+56>>2];w=L[k+28>>2];s=vb(a,w,P[h+12>>2]);l=vb(a,v,P[h+12>>2]);c=L[k+24>>2];b=L[h+20>>2];j=(c|0)>0?c:b;if((j|0)>L[a+184>>2]){L[a+184>>2]=j}i=i+R(ma,152)|0;c=L[a+16>>2];n=0;if(L[ba>>2]>0){while(1){b=pa(i+R(n,152)|0,0,152);L[b+120>>2]=-8388609;L[b+124>>2]=2139095039;L[b+148>>2]=l;L[b+144>>2]=s;L[b+96>>2]=0;L[b+100>>2]=0;L[b+136>>2]=j;n=n+1|0;if((n|0)>2]){continue}break}b=L[h+20>>2]}j=R(s,244)+c|0;L[j+64>>2]=0;L[j+68>>2]=0;L[j+144>>2]=0;L[j+148>>2]=0;L[j+88>>2]=0;L[j+92>>2]=0;L[j+80>>2]=0;L[j+84>>2]=0;L[j+72>>2]=0;L[j+76>>2]=0;L[j+152>>2]=0;L[j+156>>2]=0;L[j+160>>2]=0;L[j+164>>2]=0;L[j+168>>2]=0;L[j+172>>2]=0;c=R(l,244)+c|0;L[c+88>>2]=0;L[c+92>>2]=0;L[c+80>>2]=0;L[c+84>>2]=0;L[c+72>>2]=0;L[c+76>>2]=0;L[c+64>>2]=0;L[c+68>>2]=0;L[c+144>>2]=0;L[c+148>>2]=0;L[c+152>>2]=0;L[c+156>>2]=0;L[c+160>>2]=0;L[c+164>>2]=0;L[c+168>>2]=0;L[c+172>>2]=0;P[p+12>>2]=S(1)/P[h+12>>2];o=P[h+32>>2];L[p+40>>2]=i+112;L[p+36>>2]=38;L[p+32>>2]=i+32;L[p+28>>2]=i+48;L[p+24>>2]=i;L[p+20>>2]=i+16;P[p+16>>2]=o;P[i+116>>2]=P[h+40>>2];o=P[h+4>>2];L[p+60>>2]=b;L[p+52>>2]=i+124;L[p+48>>2]=i+120;L[p+44>>2]=i+116;P[p+64>>2]=o;b=L[G>>2];ha[L[L[b>>2]+20>>2]](b,p+12|0);if(L[ba>>2]>0){r=0;while(1){o=P[L[G>>2]+16>>2];l=i+R(r,152)|0;if(o<=P[l+124>>2]){P[l+124>>2]=o}o=S(-o);if(o>=P[l+120>>2]){P[l+120>>2]=o}L[l+132>>2]=k;b=L[k+28>>2];D=P[b+272>>2];E=P[b+268>>2];x=P[b+548>>2];z=P[b+288>>2];y=P[b+280>>2];A=P[b+284>>2];B=P[b+552>>2];C=P[b+304>>2];t=P[b+296>>2];q=P[b+300>>2];u=P[b+544>>2];o=P[b+264>>2];F=P[l+8>>2];N=P[l>>2];O=P[l+4>>2];L[l+76>>2]=0;P[l+72>>2]=B*S(S(C*F)+S(S(t*N)+S(O*q)));P[l+68>>2]=x*S(S(z*F)+S(S(y*N)+S(O*A)));P[l+64>>2]=u*S(S(D*F)+S(S(o*N)+S(E*O)));b=L[k+32>>2];D=P[b+268>>2];E=P[b+272>>2];x=P[b+548>>2];z=P[b+288>>2];y=P[b+280>>2];A=P[b+284>>2];B=P[b+552>>2];C=P[b+304>>2];t=P[b+296>>2];q=P[b+300>>2];u=P[b+544>>2];o=P[b+264>>2];L[l+92>>2]=0;Q=P[l+40>>2];U=P[l+32>>2];V=P[l+36>>2];P[l+88>>2]=B*S(S(C*Q)+S(S(t*U)+S(q*V)));P[l+84>>2]=x*S(S(z*Q)+S(S(y*U)+S(V*A)));P[l+80>>2]=u*S(S(E*Q)+S(S(o*U)+S(D*V)));na=S(0);o=P[w+344>>2];da=P[l+24>>2];ea=P[l+16>>2];ga=P[l+20>>2];q=S(S(S(S(o*da)*da)+S(S(S(o*ea)*ea)+S(ga*S(o*ga))))+S(S(F*S(S(F*P[w+304>>2])+S(S(N*P[w+296>>2])+S(O*P[w+300>>2]))))+S(S(N*S(S(F*P[w+272>>2])+S(S(N*P[w+264>>2])+S(O*P[w+268>>2]))))+S(O*S(S(F*P[w+288>>2])+S(S(N*P[w+280>>2])+S(O*P[w+284>>2])))))));o=P[v+344>>2];ia=P[l+56>>2];ja=P[l+48>>2];ka=P[l+52>>2];o=S(S(q+S(S(S(o*ia)*ia)+S(S(S(o*ja)*ja)+S(ka*S(o*ka)))))+S(S(Q*S(S(Q*P[v+304>>2])+S(S(U*P[v+296>>2])+S(V*P[v+300>>2]))))+S(S(U*S(S(Q*P[v+272>>2])+S(S(U*P[v+264>>2])+S(V*P[v+268>>2]))))+S(V*S(S(Q*P[v+288>>2])+S(S(U*P[v+280>>2])+S(V*P[v+284>>2])))))));la=S(T(o))>S(1.1920928955078125e-7)?S(S(1)/o):S(0);P[l+108>>2]=la;oa=S(0);ra=S(0);sa=S(0);H=S(0);I=S(0);K=S(0);if(L[j+240>>2]){I=P[j+228>>2];H=P[j+224>>2];ra=P[j+212>>2];sa=P[j+208>>2];oa=P[j+216>>2];K=P[j+232>>2]}W=S(0);X=S(0);Y=S(0);Z=S(0);$=S(0);if(L[c+240>>2]){Z=P[c+228>>2];Y=P[c+224>>2];W=P[c+212>>2];X=P[c+208>>2];na=P[c+216>>2];$=P[c+232>>2]}aa=P[w+320>>2];D=P[w+312>>2];E=P[w+316>>2];x=P[w+336>>2];z=P[w+328>>2];y=P[w+332>>2];A=P[v+320>>2];B=P[v+312>>2];C=P[v+316>>2];t=P[v+336>>2];q=P[v+328>>2];u=P[v+332>>2];o=P[p+64>>2];L[l+100>>2]=0;P[l+112>>2]=S(la*P[l+112>>2])+S(la*S(S(0)-S(o*S(S(S(S(da*S(oa+aa))+S(S(ea*S(sa+D))+S(ga*S(ra+E))))+S(S(F*S(K+x))+S(S(N*S(H+z))+S(O*S(I+y)))))+S(S(S(ia*S(na+A))+S(S(ja*S(X+B))+S(ka*S(W+C))))+S(S(Q*S($+t))+S(S(U*S(Y+q))+S(V*S(Z+u)))))))));r=r+1|0;if((r|0)>2]){continue}break}}k=L[a+176>>2];b=L[m+k>>2]}else{b=0}ma=b+ma|0;ca=ca+1|0;if((ca|0)!=(g|0)){continue}break}}ha[L[L[a>>2]+28>>2]](a,d,e,h);j=L[a+68>>2];l=L[a+28>>2];n=L[a+128>>2];m=L[a+48>>2];if(!((n|0)>=(m|0)|(m|0)<=L[a+132>>2])){h:{if(!m){k=0;break h}L[8513]=L[8513]+1;k=ha[L[6798]](m<<2,16)|0;n=L[a+128>>2]}f=L[a+136>>2];i:{j:{if((n|0)>0){c=0;i=0;if(n>>>0>=4){d=n&-4;r=0;while(1){e=i<<2;L[e+k>>2]=L[e+f>>2];b=e|4;L[b+k>>2]=L[b+f>>2];b=e|8;L[b+k>>2]=L[b+f>>2];b=e|12;L[b+k>>2]=L[b+f>>2];i=i+4|0;r=r+4|0;if((d|0)!=(r|0)){continue}break}}d=n&3;if(d){while(1){b=i<<2;L[b+k>>2]=L[b+f>>2];i=i+1|0;c=c+1|0;if((d|0)!=(c|0)){continue}break}}if(M[a+140|0]){break j}break i}if(!f|!M[a+140|0]){break i}}if(f){L[8514]=L[8514]+1;ha[L[6799]](f)}}L[a+136>>2]=k;L[a+132>>2]=m;J[a+140|0]=1}L[a+128>>2]=m;k:{if(M[h+64|0]&16){n=L[a+108>>2];e=l<<1;if(!((n|0)>=(e|0)|(e|0)<=L[a+112>>2])){l:{if(!l){k=0;break l}L[8513]=L[8513]+1;k=ha[L[6798]](l<<3,16)|0;n=L[a+108>>2]}g=L[a+116>>2];m:{n:{if((n|0)>0){c=0;i=0;if(n>>>0>=4){d=n&-4;r=0;while(1){f=i<<2;L[f+k>>2]=L[f+g>>2];b=f|4;L[b+k>>2]=L[b+g>>2];b=f|8;L[b+k>>2]=L[b+g>>2];b=f|12;L[b+k>>2]=L[b+g>>2];i=i+4|0;r=r+4|0;if((d|0)!=(r|0)){continue}break}}d=n&3;if(d){while(1){b=i<<2;L[b+k>>2]=L[b+g>>2];i=i+1|0;c=c+1|0;if((d|0)!=(c|0)){continue}break}}if(M[a+120|0]){break n}break m}if(!g|!M[a+120|0]){break m}}if(g){L[8514]=L[8514]+1;ha[L[6799]](g)}}L[a+116>>2]=k;L[a+112>>2]=e;J[a+120|0]=1}L[a+108>>2]=e;break k}n=L[a+108>>2];if(!((l|0)<=(n|0)|(l|0)<=L[a+112>>2])){o:{if(!l){k=0;break o}L[8513]=L[8513]+1;k=ha[L[6798]](l<<2,16)|0;n=L[a+108>>2]}f=L[a+116>>2];p:{q:{if((n|0)>0){c=0;i=0;if(n>>>0>=4){d=n&-4;r=0;while(1){e=i<<2;L[e+k>>2]=L[e+f>>2];b=e|4;L[b+k>>2]=L[b+f>>2];b=e|8;L[b+k>>2]=L[b+f>>2];b=e|12;L[b+k>>2]=L[b+f>>2];i=i+4|0;r=r+4|0;if((d|0)!=(r|0)){continue}break}}d=n&3;if(d){while(1){b=i<<2;L[b+k>>2]=L[b+f>>2];i=i+1|0;c=c+1|0;if((d|0)!=(c|0)){continue}break}}if(M[a+120|0]){break q}break p}if(!f|!M[a+120|0]){break p}}if(f){L[8514]=L[8514]+1;ha[L[6799]](f)}}L[a+116>>2]=k;L[a+112>>2]=l;J[a+120|0]=1}L[a+108>>2]=l}n=L[a+148>>2];if(!((j|0)<=(n|0)|(j|0)<=L[a+152>>2])){r:{if(!j){k=0;break r}L[8513]=L[8513]+1;k=ha[L[6798]](j<<2,16)|0;n=L[a+148>>2]}f=L[a+156>>2];s:{t:{if((n|0)>0){c=0;i=0;if(n>>>0>=4){d=n&-4;r=0;while(1){e=i<<2;L[e+k>>2]=L[e+f>>2];b=e|4;L[b+k>>2]=L[b+f>>2];b=e|8;L[b+k>>2]=L[b+f>>2];b=e|12;L[b+k>>2]=L[b+f>>2];i=i+4|0;r=r+4|0;if((d|0)!=(r|0)){continue}break}}d=n&3;if(d){while(1){b=i<<2;L[b+k>>2]=L[b+f>>2];i=i+1|0;c=c+1|0;if((d|0)!=(c|0)){continue}break}}if(M[a+160|0]){break t}break s}if(!f|!M[a+160|0]){break s}}if(f){L[8514]=L[8514]+1;ha[L[6799]](f)}}L[a+156>>2]=k;L[a+152>>2]=j;J[a+160|0]=1}L[a+148>>2]=j;u:{if((m|0)<=0){break u}e=L[a+136>>2];b=0;i=0;if(m>>>0>=8){d=m&-8;n=0;while(1){L[e+(i<<2)>>2]=i;c=i|1;L[e+(c<<2)>>2]=c;c=i|2;L[e+(c<<2)>>2]=c;c=i|3;L[e+(c<<2)>>2]=c;c=i|4;L[e+(c<<2)>>2]=c;c=i|5;L[e+(c<<2)>>2]=c;c=i|6;L[e+(c<<2)>>2]=c;c=i|7;L[e+(c<<2)>>2]=c;i=i+8|0;n=n+8|0;if((d|0)!=(n|0)){continue}break}}c=m&7;if(!c){break u}while(1){L[e+(i<<2)>>2]=i;i=i+1|0;b=b+1|0;if((c|0)!=(b|0)){continue}break}}v:{if((l|0)<=0){break v}e=L[a+116>>2];b=0;i=0;if(l>>>0>=8){d=l&-8;n=0;while(1){L[e+(i<<2)>>2]=i;c=i|1;L[e+(c<<2)>>2]=c;c=i|2;L[e+(c<<2)>>2]=c;c=i|3;L[e+(c<<2)>>2]=c;c=i|4;L[e+(c<<2)>>2]=c;c=i|5;L[e+(c<<2)>>2]=c;c=i|6;L[e+(c<<2)>>2]=c;c=i|7;L[e+(c<<2)>>2]=c;i=i+8|0;n=n+8|0;if((d|0)!=(n|0)){continue}break}}c=l&7;if(!c){break v}while(1){L[e+(i<<2)>>2]=i;i=i+1|0;b=b+1|0;if((c|0)!=(b|0)){continue}break}}w:{if((j|0)<=0){break w}d=L[a+156>>2];b=0;i=0;if(j>>>0>=8){c=j&-8;n=0;while(1){L[d+(i<<2)>>2]=i;a=i|1;L[d+(a<<2)>>2]=a;a=i|2;L[d+(a<<2)>>2]=a;a=i|3;L[d+(a<<2)>>2]=a;a=i|4;L[d+(a<<2)>>2]=a;a=i|5;L[d+(a<<2)>>2]=a;a=i|6;L[d+(a<<2)>>2]=a;a=i|7;L[d+(a<<2)>>2]=a;i=i+8|0;n=n+8|0;if((c|0)!=(n|0)){continue}break}}a=j&7;if(!a){break w}while(1){L[d+(i<<2)>>2]=i;i=i+1|0;b=b+1|0;if((a|0)!=(b|0)){continue}break}}va();fa=p+256|0;return S(S(0))}function ag(a,b,c){var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=S(0),l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=S(0),t=0,u=S(0),v=0,w=S(0),x=0,y=S(0),z=S(0),A=S(0),B=S(0),C=S(0),D=0,E=0;i=fa-144|0;fa=i;a:{if((c|0)<=0){b=L[a+12>>2];if(!(b?!b|!M[a+16|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+12>>2]=0;J[a+16|0]=1;L[a+4>>2]=0;L[a+8>>2]=0;b=L[a+32>>2];if(!(b?!b|!M[a+36|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+32>>2]=0;J[a+36|0]=1;L[a+24>>2]=0;L[a+28>>2]=0;b=L[a+52>>2];if(!(b?!b|!M[a+56|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+52>>2]=0;J[a+56|0]=1;L[a+44>>2]=0;L[a+48>>2]=0;break a}J[i+112|0]=1;L[i+88>>2]=0;L[i+92>>2]=256;L[i+72>>2]=0;L[i+76>>2]=256;L[i+56>>2]=0;L[i+60>>2]=256;L[i+108>>2]=0;L[i+100>>2]=0;L[i+104>>2]=0;L[i+80>>2]=0;L[i+84>>2]=0;L[i+64>>2]=0;L[i+68>>2]=0;L[i+48>>2]=0;L[i+52>>2]=0;f=i+16|0;h=fa-48|0;fa=h;B=S(-1.0000000150474662e30);C=S(1.0000000150474662e30);j=c;b:{if((c|0)>0){c=b;y=S(1.0000000150474662e30);z=S(1.0000000150474662e30);A=S(-1.0000000150474662e30);u=S(-1.0000000150474662e30);while(1){w=P[c+8>>2];B=w>B?w:B;s=P[c+4>>2];A=s>A?s:A;k=P[c>>2];u=k>u?k:u;C=w>2]=0;L[f+28>>2]=0;P[f+24>>2]=S(B+C)*S(.5);P[f+20>>2]=S(A+y)*S(.5);P[f+16>>2]=S(u+z)*S(.5);u=S(u-z);s=S(A-y);c=u(c?s:u)?2:c;L[f+112>>2]=d;c=k>(c?u:s)?!c:2;c=(c|0)==(d|0)?d+(d>>>0>1?-2:1)|0:c;L[f+104>>2]=c;c=c+d|0;L[f+108>>2]=3-c;k=S(k*S(9788566967472434e-20));c=(d|0)==((4-c|0)%3|0);w=c?k:S(-k);P[f+8>>2]=w;k=S(s*S(9788566967472434e-20));s=c?k:S(-k);P[f+4>>2]=s;k=S(u*S(9788566967472434e-20));k=c?k:S(-k);P[f>>2]=k;J[h+44|0]=1;L[h+36>>2]=0;L[h+40>>2]=0;c:{d:{if((j|0)>0){L[8513]=L[8513]+1;L[h+40>>2]=ha[L[6798]](j<<4,16);J[h+44|0]=1;L[h+36>>2]=j;L[h+32>>2]=j;if((j|0)<=0){break c}y=w!=S(0)?S(S(1)/w):w;z=s!=S(0)?S(S(1)/s):s;A=k!=S(0)?S(S(1)/k):k;c=h+8|0;p=c+(L[f+104>>2]<<2)|0;m=c+(L[f+112>>2]<<2)|0;n=c+(L[f+108>>2]<<2)|0;B=P[f+24>>2];C=P[f+20>>2];u=P[f+16>>2];d=L[h+40>>2];g=0;while(1){w=P[b>>2];s=P[b+4>>2];k=P[b+8>>2];L[h+20>>2]=0;P[h+16>>2]=y*S(k-B);P[h+12>>2]=z*S(s-C);P[h+8>>2]=A*S(w-u);c=d+(g<<4)|0;k=P[n>>2];e:{if(S(T(k))>2]=l;k=P[m>>2];f:{if(S(T(k))>2]=l;k=P[p>>2];L[c+12>>2]=g;if(S(T(k))>2]=l;b=b+16|0;g=g+1|0;if((j|0)!=(g|0)){continue}break}break d}L[h+32>>2]=j;break c}if((j|0)<2){break c}Yj(h+28|0,h+8|0,0,j-1|0)}L[f+44>>2]=j;L[f+40>>2]=0;L[f+36>>2]=L[f+32>>2];b=L[f+84>>2];g:{if((j|0)<=(b|0)){break g}if((j|0)>L[f+88>>2]){h:{if(!j){g=0;n=b;break h}L[8513]=L[8513]+1;g=ha[L[6798]](j<<2,16)|0;n=L[f+84>>2]}i:{if((n|0)<=0){break i}m=0;c=0;if(n>>>0>=4){v=n&-4;d=0;while(1){l=c<<2;L[l+g>>2]=L[l+L[f+92>>2]>>2];p=l|4;L[p+g>>2]=L[p+L[f+92>>2]>>2];p=l|8;L[p+g>>2]=L[p+L[f+92>>2]>>2];p=l|12;L[p+g>>2]=L[p+L[f+92>>2]>>2];c=c+4|0;d=d+4|0;if((v|0)!=(d|0)){continue}break}}n=n&3;if(!n){break i}while(1){d=c<<2;L[d+g>>2]=L[d+L[f+92>>2]>>2];c=c+1|0;m=m+1|0;if((n|0)!=(m|0)){continue}break}}c=L[f+92>>2];if(!(c?!c|!M[f+96|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](c)}L[f+92>>2]=g;J[f+96|0]=1;L[f+88>>2]=j}n=j+(b^-1)|0;d=j-b&3;if(d){c=0;while(1){L[L[f+92>>2]+(b<<2)>>2]=0;b=b+1|0;c=c+1|0;if((d|0)!=(c|0)){continue}break}}if(n>>>0<3){break g}while(1){c=b<<2;L[c+L[f+92>>2]>>2]=0;L[(c+L[f+92>>2]|0)+4>>2]=0;L[(c+L[f+92>>2]|0)+8>>2]=0;L[(c+L[f+92>>2]|0)+12>>2]=0;b=b+4|0;if((j|0)!=(b|0)){continue}break}}L[f+84>>2]=j;if((j|0)>0){while(1){d=L[f+40>>2];j:{if(d){break j}b=L[f+36>>2];k:{if(b){L[f+36>>2]=L[b+8>>2];d=L[b>>2];break k}L[8513]=L[8513]+1;b=ha[L[6798]](12,16)|0;c=L[f+44>>2];L[b+8>>2]=0;L[b+4>>2]=c;L[8513]=L[8513]+1;d=ha[L[6798]](R(c,112),16)|0;L[b>>2]=d;L[b+8>>2]=L[f+32>>2];L[f+32>>2]=b}v=L[b+4>>2];if((v|0)<=0){break j}p=0;m=0;c=d;if(v>>>0>=4){n=v&-4;g=0;b=d;r=0;while(1){c=b+448|0;m=g+4|0;L[b+336>>2]=(v|0)>(m|0)?c:0;L[b+224>>2]=(v|0)>(g|3)?b+336|0:0;L[b+112>>2]=(v|0)>(g|2)?b+224|0:0;L[b>>2]=(v|0)>(g|1)?b+112|0:0;g=m;b=c;r=r+4|0;if((n|0)!=(r|0)){continue}break}}b=v&3;if(!b){break j}while(1){n=c;c=c+112|0;m=m+1|0;L[n>>2]=(v|0)>(m|0)?c:0;p=p+1|0;if((b|0)!=(p|0)){continue}break}}L[f+40>>2]=L[d>>2];L[d+16>>2]=0;L[d+8>>2]=0;L[d+12>>2]=0;L[d>>2]=0;L[d+4>>2]=0;L[d+104>>2]=-1;c=L[h+40>>2]+(o<<4)|0;b=L[c+4>>2];L[d+88>>2]=L[c>>2];L[d+92>>2]=b;b=L[c+12>>2];L[d+96>>2]=L[c+8>>2];L[d+100>>2]=b;L[L[f+92>>2]+(o<<2)>>2]=d;o=o+1|0;if((j|0)!=(o|0)){continue}break}}b=L[h+40>>2];if(!(b?!b|!M[h+44|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[h+40>>2]=0;J[h+44|0]=1;L[h+32>>2]=0;L[h+36>>2]=0;L[f+116>>2]=0;L[f+120>>2]=0;L[f+60>>2]=R(j,6);L[f+56>>2]=0;L[f+100>>2]=-3;L[f+52>>2]=L[f+48>>2];L[h+16>>2]=0;L[h+20>>2]=0;L[h+8>>2]=0;L[h+12>>2]=0;bg(f,0,j,h+8|0);L[f+124>>2]=L[h+8>>2];b=L[h+40>>2];if(!(b?!b|!M[h+44|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}fa=h+48|0;if((L[a+4>>2]&L[a+8>>2])<0){b=L[a+12>>2];if(!(b?!b|!M[a+16|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}J[a+16|0]=1;L[a+8>>2]=0;L[a+12>>2]=0}L[a+4>>2]=0;b=L[a+24>>2];l:{if((b|0)>=0){break l}if(L[a+28>>2]<0){c=L[a+32>>2];if(!(c?!c|!M[a+36|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](c)}J[a+36|0]=1;L[a+28>>2]=0;L[a+32>>2]=0}c=b;d=0-b&3;if(d){while(1){n=L[a+32>>2]+R(c,12)|0;L[n>>2]=0;L[n+4>>2]=0;L[n+8>>2]=0;c=c+1|0;e=e+1|0;if((d|0)!=(e|0)){continue}break}}if(b>>>0>4294967292){break l}while(1){d=R(c,12);b=d+L[a+32>>2]|0;L[b>>2]=0;L[b+4>>2]=0;L[b+8>>2]=0;b=d+L[a+32>>2]|0;L[b+20>>2]=0;L[b+12>>2]=0;L[b+16>>2]=0;b=d+L[a+32>>2]|0;L[b+32>>2]=0;L[b+24>>2]=0;L[b+28>>2]=0;b=d+L[a+32>>2]|0;L[b+44>>2]=0;L[b+36>>2]=0;L[b+40>>2]=0;c=c+4|0;if(c){continue}break}}L[a+24>>2]=0;c=L[a+44>>2];if((c|0)<0){b=L[a+52>>2];if(L[a+48>>2]<0){if(!(b?!b|!M[a+56|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}J[a+56|0]=1;L[a+48>>2]=0;L[a+52>>2]=0;b=0}d=b;b=c<<2;pa(d+b|0,0,0-b|0)}L[a+44>>2]=0;b=L[i+140>>2];m:{if(L[b+104>>2]>=0){break m}L[b+104>>2]=0;L[8513]=L[8513]+1;p=ha[L[6798]](4,16)|0;L[p>>2]=b;c=0;n=1;m=1;while(1){v=c;d=fa-16|0;fa=d;n:{o:{p:{q:{h=L[(c<<2)+p>>2];e=h;r:{if(L[e+100>>2]>=0){P[d+(L[i+124>>2]<<2)>>2]=L[e+88>>2];break r}s=ac(e+24|0);c=e+72|0;k=ac(c);b=L[e+100>>2];P[d+(L[i+124>>2]<<2)>>2]=s/k;if((b|0)<0){break q}}P[d+(L[i+128>>2]<<2)>>2]=L[e+92>>2];break p}s=ac(e+40|0);k=ac(c);b=L[e+100>>2];P[d+(L[i+128>>2]<<2)>>2]=s/k;if((b|0)<0){break o}}k=S(L[e+96>>2]);break n}k=S(ac(e+56|0)/ac(e+72|0))}P[d+(L[i+120>>2]<<2)>>2]=k;y=P[i+36>>2];z=P[i+40>>2];A=P[i+32>>2];B=P[i+16>>2];C=P[i+20>>2];u=P[i+24>>2];w=P[d>>2];s=P[d+4>>2];k=P[d+8>>2];L[i+12>>2]=0;P[i+8>>2]=z+S(k*u);P[i+4>>2]=y+S(s*C);P[i>>2]=A+S(w*B);fa=d+16|0;e=L[a+4>>2];s:{if((e|0)!=L[a+8>>2]){break s}q=e?e<<1:1;if((q|0)<=(e|0)){break s}t:{if(!q){d=0;break t}L[8513]=L[8513]+1;d=ha[L[6798]](q<<4,16)|0;e=L[a+4>>2]}u:{if((e|0)<=0){break u}c=0;if((e|0)!=1){l=e&-2;b=0;while(1){r=c<<4;j=r+d|0;f=r+L[a+12>>2]|0;g=L[f+4>>2];L[j>>2]=L[f>>2];L[j+4>>2]=g;g=L[f+12>>2];L[j+8>>2]=L[f+8>>2];L[j+12>>2]=g;g=r|16;j=g+d|0;r=g+L[a+12>>2]|0;g=L[r+4>>2];L[j>>2]=L[r>>2];L[j+4>>2]=g;g=L[r+12>>2];L[j+8>>2]=L[r+8>>2];L[j+12>>2]=g;c=c+2|0;b=b+2|0;if((l|0)!=(b|0)){continue}break}}if(!(e&1)){break u}b=c<<4;e=b+d|0;c=b+L[a+12>>2]|0;b=L[c+4>>2];L[e>>2]=L[c>>2];L[e+4>>2]=b;b=L[c+12>>2];L[e+8>>2]=L[c+8>>2];L[e+12>>2]=b}b=L[a+12>>2];if(!(b?!b|!M[a+16|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+12>>2]=d;J[a+16|0]=1;L[a+8>>2]=q;e=L[a+4>>2]}b=L[i+4>>2];c=L[a+12>>2]+(e<<4)|0;L[c>>2]=L[i>>2];L[c+4>>2]=b;b=L[i+12>>2];L[c+8>>2]=L[i+8>>2];L[c+12>>2]=b;L[a+4>>2]=L[a+4>>2]+1;b=-1;j=-1;f=L[h+8>>2];c=f;if(c){while(1){if(L[c+20>>2]<0){l=L[a+24>>2];e=l;v:{if((e|0)!=L[a+28>>2]){break v}x=e?l<<1:1;if((x|0)<=(e|0)){break v}w:{if(!x){o=0;d=l;break w}L[8513]=L[8513]+1;o=ha[L[6798]](R(x,12),16)|0;d=L[a+24>>2]}x:{if((d|0)<=0){break x}e=0;if((d|0)!=1){r=d&-2;g=0;while(1){h=R(e,12);t=h+L[a+32>>2]|0;q=h+o|0;h=L[t+4>>2];L[q>>2]=L[t>>2];L[q+4>>2]=h;L[q+8>>2]=L[t+8>>2];h=R(e|1,12);t=h+L[a+32>>2]|0;q=h+o|0;h=L[t+4>>2];L[q>>2]=L[t>>2];L[q+4>>2]=h;L[q+8>>2]=L[t+8>>2];e=e+2|0;g=g+2|0;if((r|0)!=(g|0)){continue}break}}if(!(d&1)){break x}d=R(e,12);g=d+L[a+32>>2]|0;e=d+o|0;d=L[g+4>>2];L[e>>2]=L[g>>2];L[e+4>>2]=d;L[e+8>>2]=L[g+8>>2]}d=L[a+32>>2];if(!(d?!d|!M[a+36|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](d)}L[a+32>>2]=o;J[a+36|0]=1;L[a+28>>2]=x;e=L[a+24>>2]}d=L[a+32>>2]+R(e,12)|0;L[d>>2]=0;L[d+4>>2]=0;L[d+8>>2]=0;g=L[a+24>>2]+1|0;L[a+24>>2]=g;y:{if(L[a+28>>2]!=(g|0)){break y}x=g?g<<1:1;if((x|0)<=(g|0)){break y}z:{if(!x){o=0;break z}L[8513]=L[8513]+1;o=ha[L[6798]](R(x,12),16)|0;g=L[a+24>>2]}A:{if((g|0)<=0){break A}r=g&1;e=0;if((g|0)!=1){h=g&-2;g=0;while(1){d=R(e,12);t=d+L[a+32>>2]|0;q=d+o|0;d=L[t+4>>2];L[q>>2]=L[t>>2];L[q+4>>2]=d;L[q+8>>2]=L[t+8>>2];d=R(e|1,12);t=d+L[a+32>>2]|0;q=d+o|0;d=L[t+4>>2];L[q>>2]=L[t>>2];L[q+4>>2]=d;L[q+8>>2]=L[t+8>>2];e=e+2|0;g=g+2|0;if((h|0)!=(g|0)){continue}break}}if(!r){break A}d=R(e,12);g=d+L[a+32>>2]|0;e=d+o|0;d=L[g+4>>2];L[e>>2]=L[g>>2];L[e+4>>2]=d;L[e+8>>2]=L[g+8>>2]}d=L[a+32>>2];if(!(d?!d|!M[a+36|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](d)}L[a+32>>2]=o;J[a+36|0]=1;L[a+28>>2]=x;g=L[a+24>>2]}d=L[a+32>>2]+R(g,12)|0;L[d>>2]=0;L[d+4>>2]=0;L[d+8>>2]=0;L[a+24>>2]=L[a+24>>2]+1;E=L[a+32>>2];L[c+20>>2]=l;r=l+1|0;L[L[c+8>>2]+20>>2]=r;o=E+R(l,12)|0;L[o+16>>2]=-1;L[o+4>>2]=1;x=L[c+12>>2];d=L[x+104>>2];B:{if((d|0)>=0){e=n;n=d;break B}L[x+104>>2]=n;C:{D:{if((m|0)!=(n|0)){break D}g=m?m<<1:1;if((m|0)>=(g|0)){break D}if(g){L[8513]=L[8513]+1;d=ha[L[6798]](g<<2,16)|0}else{d=0}E:{if((m|0)>0){t=m&3;q=0;e=0;if(m>>>0>=4){h=m&-4;m=0;while(1){D=e<<2;L[D+d>>2]=L[p+D>>2];l=D|4;L[l+d>>2]=L[p+l>>2];l=D|8;L[l+d>>2]=L[p+l>>2];l=D|12;L[l+d>>2]=L[p+l>>2];e=e+4|0;m=m+4|0;if((h|0)!=(m|0)){continue}break}}if(!t){break E}while(1){m=e<<2;L[m+d>>2]=L[m+p>>2];e=e+1|0;q=q+1|0;if((t|0)!=(q|0)){continue}break}break E}if(!p){break C}}if(p){L[8514]=L[8514]+1;ha[L[6799]](p)}break C}d=p;g=m}L[(n<<2)+d>>2]=x;e=n+1|0;p=d;m=g}L[o+8>>2]=n;L[(E+R(r,12)|0)+8>>2]=v;n=e}e=L[c+20>>2];d=e;if((b|0)>=0){L[L[a+32>>2]+R(e,12)>>2]=b-e;d=j}b=e;j=d;c=L[c>>2];if((f|0)!=(c|0)){continue}break}L[L[a+32>>2]+R(j,12)>>2]=b-j}c=v+1|0;if((n|0)>(c|0)){continue}break}m=0;while(1){j=L[L[(m<<2)+p>>2]+8>>2];e=j;if(e){while(1){c=L[e+20>>2];if((c|0)>=0){o=L[a+44>>2];F:{if((o|0)!=L[a+48>>2]){break F}l=o?o<<1:1;if((l|0)<=(o|0)){break F}G:{if(!l){d=0;break G}L[8513]=L[8513]+1;d=ha[L[6798]](l<<2,16)|0;o=L[a+44>>2]}f=L[a+52>>2];H:{I:{if((o|0)>0){g=0;c=0;if(o>>>0>=4){n=o&-4;r=0;while(1){h=c<<2;L[h+d>>2]=L[f+h>>2];b=h|4;L[b+d>>2]=L[b+f>>2];b=h|8;L[b+d>>2]=L[b+f>>2];b=h|12;L[b+d>>2]=L[b+f>>2];c=c+4|0;r=r+4|0;if((n|0)!=(r|0)){continue}break}}n=o&3;if(!n){break I}while(1){b=c<<2;L[b+d>>2]=L[b+f>>2];c=c+1|0;g=g+1|0;if((n|0)!=(g|0)){continue}break}break I}if(!f){break H}}if(f?M[a+56|0]:0){L[8514]=L[8514]+1;ha[L[6799]](f)}o=L[a+44>>2]}L[a+52>>2]=d;J[a+56|0]=1;L[a+48>>2]=l;c=L[e+20>>2]}L[L[a+52>>2]+(o<<2)>>2]=c;L[a+44>>2]=L[a+44>>2]+1;c=e;while(1){L[c+20>>2]=-1;c=L[L[c+8>>2]+4>>2];if((e|0)!=(c|0)){continue}break}}e=L[e>>2];if((j|0)!=(e|0)){continue}break}}b=(m|0)==(v|0);m=m+1|0;if(!b){continue}break}if(!p){break m}if(p){L[8514]=L[8514]+1;ha[L[6799]](p)}}a=L[i+108>>2];if(!(a?!a|!M[i+112|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](a)}L[i+108>>2]=0;J[i+112|0]=1;L[i+100>>2]=0;L[i+104>>2]=0;while(1){b=L[i+80>>2];if(b){L[i+80>>2]=L[b+8>>2];a=L[b>>2];if(a){L[8514]=L[8514]+1;ha[L[6799]](a)}if(b){L[8514]=L[8514]+1;ha[L[6799]](b)}continue}break}while(1){b=L[i+64>>2];if(b){L[i+64>>2]=L[b+8>>2];a=L[b>>2];if(a){L[8514]=L[8514]+1;ha[L[6799]](a)}if(b){L[8514]=L[8514]+1;ha[L[6799]](b)}continue}break}while(1){b=L[i+48>>2];if(!b){break a}L[i+48>>2]=L[b+8>>2];a=L[b>>2];if(a){L[8514]=L[8514]+1;ha[L[6799]](a)}if(b){L[8514]=L[8514]+1;ha[L[6799]](b)}continue}}fa=i+144|0}function bg(a,b,c,d){var e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0;v=fa-16|0;fa=v;a:{b:{c:{d:{e:{f:{g=c-b|0;switch(g|0){case 1:break d;case 2:break e;case 0:break f;default:break b}}L[d>>2]=0;L[d+4>>2]=0;L[d+8>>2]=0;L[d+12>>2]=0;break a}c=L[L[a+92>>2]+(b<<2)>>2];b=c+112|0;e=L[c+88>>2];p=L[c+200>>2];l=(e|0)!=(p|0);g=L[c+204>>2];f=L[c+92>>2];g:{if(!(l|(g|0)!=(f|0))){if(L[c+96>>2]==L[c+208>>2]){break c}f=L[c+96>>2]>L[c+208>>2];g=(f?112:0)+c|0;L[g>>2]=g;g=f?b:c;L[g+4>>2]=g;L[d+4>>2]=g;L[d>>2]=g;b=f?c:b;f=g;c=f;break g}L[c+4>>2]=b;L[c>>2]=b;L[c+116>>2]=c;L[c+112>>2]=c;n=(f|0)<(g|0);i=n&(e|0)==(p|0);e=(e|0)<(p|0);p=i|e;L[d+4>>2]=p?b:c;L[d>>2]=p?c:b;g=n|e&(l&(f|0)==(g|0));f=g?b:c;g=g?c:b}L[d+12>>2]=f;L[d+8>>2]=g;a=cg(a,c,b);L[a+4>>2]=a;L[a>>2]=a;L[c+8>>2]=a;a=L[a+8>>2];L[a+4>>2]=a;L[a>>2]=a;L[b+8>>2]=a;break a}c=L[L[a+92>>2]+(b<<2)>>2]}L[c+8>>2]=0;L[c+4>>2]=c;L[c>>2]=c;L[d+12>>2]=c;L[d+8>>2]=c;L[d+4>>2]=c;L[d>>2]=c;break a}f=((g|0)/2|0)+b|0;g=f;h:{if((f|0)>=(c|0)){break h}p=L[a+92>>2];g=L[(p+(f<<2)|0)-4>>2];l=L[g+88>>2];n=L[g+96>>2];k=L[g+92>>2];g=f;while(1){e=L[p+(g<<2)>>2];if((l|0)!=L[e+88>>2]|(k|0)!=L[e+92>>2]|(n|0)!=L[e+96>>2]){break h}g=g+1|0;if((g|0)<(c|0)){continue}break}g=c}bg(a,b,f,d);L[v+8>>2]=0;L[v+12>>2]=0;L[v>>2]=0;L[v+4>>2]=0;bg(a,g,c,v);q=a;c=0;h=fa-128|0;fa=h;i:{if(!L[v+4>>2]){break i}if(!L[d+4>>2]){a=L[v+4>>2];L[d>>2]=L[v>>2];L[d+4>>2]=a;a=L[v+12>>2];L[d+8>>2]=L[v+8>>2];L[d+12>>2]=a;break i}L[q+100>>2]=L[q+100>>2]-1;L[h+124>>2]=0;L[h+120>>2]=0;w=d;a=L[d+12>>2];g=L[v+8>>2];j:{k:{l:{if(L[a+88>>2]!=L[g+88>>2]|L[a+92>>2]!=L[g+92>>2]){break l}b=L[g+4>>2];if((b|0)==(g|0)){L[h+124>>2]=a;b=L[g+8>>2];a=0;if(!b){break k}L[h+120>>2]=L[b+12>>2];a=0;break j}d=L[g>>2];L[b>>2]=d;L[d+4>>2]=b;if(L[v>>2]==(g|0)){a=d;f=L[a+88>>2];e=L[b+88>>2];i=a;m:{if((f|0)<(e|0)){break m}if((f|0)==(e|0)){i=d;if(L[a+92>>2]>2]){break m}}i=b}L[v>>2]=i}if(L[v+4>>2]!=(g|0)){break l}a=L[d+88>>2];g=L[b+88>>2];L[v+4>>2]=(a|0)>(g|0)|(a|0)==(g|0)&L[d+92>>2]>L[b+92>>2]?d:b}l=L[v>>2];n=L[w>>2];k=L[v+4>>2];i=L[w+4>>2];e=L[i+88>>2];b=L[k+88>>2]-e|0;n:{if((b|0)>0){a=k;d=i;while(1){g=a;f=L[a+92>>2];e=b;while(1){o:{b=L[d+92>>2];p=f-b|0;a=L[d+4>>2];if((a|0)==(d|0)){break o}o=L[a+92>>2]-b|0;if((o|0)>0){break o}b=L[a+88>>2];j=L[d+88>>2];if((b|0)!=(j|0)){j=b-j|0;if((j|0)>=0|(R(e,o)|0)>(R(j,p)|0)){break o}}e=L[g+88>>2]-b|0;d=a;continue}break}a=L[g+4>>2];if((g|0)==(a|0)){break n}o=L[a+88>>2];b=o-L[d+88>>2]|0;if((b|0)<=0){break n}f=L[a+92>>2]-f|0;if((f|0)>=0){break n}j=L[g+88>>2];if((j|0)==(o|0)){continue}o=o-j|0;if((o|0)>=0){break n}if((R(f,e)|0)<(R(o,p)|0)){continue}break}break n}if((b|0)<0){g=k;a=i;p:while(1){p=L[g+92>>2];f=L[g>>2];while(1){e=b;d=a;s=L[a+92>>2];o=p-s|0;q:{if((f|0)==(g|0)){break q}b=L[f+92>>2]-p|0;if((b|0)<0){break q}a=L[f+88>>2];j=L[g+88>>2];if((a|0)!=(j|0)){j=a-j|0;if((j|0)>=0|(R(b,e)|0)>(R(j,o)|0)){break q}}b=a-L[d+88>>2]|0;g=f;a=d;continue p}a=L[d>>2];if((d|0)==(a|0)){break n}j=L[a+88>>2];b=L[g+88>>2]-j|0;if((b|0)>=0){break n}s=L[a+92>>2]-s|0;if((s|0)<=0){break n}m=L[d+88>>2];if((m|0)==(j|0)){continue}j=j-m|0;if((j|0)>=0){break n}if((R(e,s)|0)<(R(j,o)|0)){continue}break}break}break n}b=L[i+92>>2];a=i;while(1){r:{d=a;a=L[a+4>>2];if((i|0)==(a|0)|(e|0)!=L[a+88>>2]){break r}g=b;b=L[a+92>>2];if((g|0)>=(b|0)){continue}}break}b=L[k+92>>2];a=k;while(1){g=a;a=L[a>>2];if((k|0)==(a|0)|(e|0)!=L[a+88>>2]){break n}f=b;b=L[a+92>>2];if((f|0)<=(b|0)){continue}break}}o=L[n+88>>2];e=o-L[l+88>>2]|0;s:{if((e|0)>0){b=l;a=n;while(1){f=b;o=L[b+92>>2];p=e;while(1){t:{e=L[a+92>>2];j=o-e|0;b=L[a>>2];if((b|0)==(a|0)){break t}s=L[b+92>>2]-e|0;if((s|0)>0){break t}m=L[a+88>>2];e=L[b+88>>2];if((m|0)!=(e|0)){m=m-e|0;if((m|0)>=0|(R(p,s)|0)>(R(j,m)|0)){break t}}p=e-L[f+88>>2]|0;a=b;continue}break}b=L[f>>2];if((f|0)==(b|0)){break s}s=L[b+88>>2];e=L[a+88>>2]-s|0;if((e|0)<=0){break s}o=L[b+92>>2]-o|0;if((o|0)>=0){break s}m=L[f+88>>2];if((m|0)==(s|0)){continue}s=m-s|0;if((s|0)>=0){break s}if((R(o,p)|0)<(R(j,s)|0)){continue}break}break s}if((e|0)<0){f=l;b=n;u:while(1){j=L[f+92>>2];p=L[f+4>>2];while(1){o=e;a=b;r=L[a+92>>2];s=j-r|0;v:{if((f|0)==(p|0)){break v}e=L[p+92>>2]-j|0;if((e|0)<0){break v}m=L[f+88>>2];b=L[p+88>>2];if((m|0)!=(b|0)){m=m-b|0;if((m|0)>=0|(R(e,o)|0)>(R(m,s)|0)){break v}}e=L[a+88>>2]-b|0;f=p;b=a;continue u}b=L[a+4>>2];if((b|0)==(a|0)){break s}m=L[b+88>>2];e=m-L[f+88>>2]|0;if((e|0)>=0){break s}r=L[b+92>>2]-r|0;if((r|0)<=0){break s}B=L[a+88>>2];if((B|0)==(m|0)){continue}m=B-m|0;if((m|0)>=0){break s}if((R(o,r)|0)<(R(m,s)|0)){continue}break}break}break s}e=L[n+92>>2];b=n;while(1){a=b;b=L[a>>2];if(!((n|0)==(b|0)|(o|0)!=L[b+88>>2])){f=e;e=L[b+92>>2];if((f|0)>=(e|0)){continue}}break}e=L[l+92>>2];b=l;while(1){f=b;b=L[b+4>>2];if((l|0)==(b|0)|(o|0)!=L[b+88>>2]){break s}p=e;e=L[b+92>>2];if((p|0)<=(e|0)){continue}break}}L[a+4>>2]=f;L[f>>2]=a;L[d>>2]=g;L[g+4>>2]=d;if(L[l+88>>2]>2]){L[w>>2]=l}if(L[k+88>>2]>=L[i+88>>2]){L[w+4>>2]=k}L[w+12>>2]=L[v+12>>2];L[h+124>>2]=d;a=1}L[h+120>>2]=g}o=L[h+120>>2];w:{if(a){s=L[h+124>>2];i=L[s+96>>2];r=L[o+96>>2];m=L[s+92>>2];l=L[o+92>>2];d=L[s+8>>2];u=L[s+88>>2];B=L[o+88>>2];L[h+80>>2]=0;a=r-i|0;e=a>>31;b=l-m|0;w=b>>31;p=mI(a,e,b,w);C=ga;f=B-u|0;g=0-f|0;j=g>>31;f=mI(g,j,f,f>>31);k=ga;D=mI(b,w,b,w);n=f-D|0;D=k-(ga+(f>>>0>>0)|0)|0;a=mI(g,j,a,e);k=0-a|0;E=0-(ga+((a|0)!=0)|0)|0;if(d){a=d;while(1){t=L[a+12>>2];x=L[t+92>>2];f=x-m|0;e=f;z=f>>31;y=mI(f,z,g,j);A=ga;H=L[t+88>>2];f=H-u|0;I=f>>31;J=mI(b,w,f,I);x:{if((y|0)!=(0-J|0)|(0-(ga+((J|0)!=0)|0)|0)!=(A|0)){break x}e=mI(p,C,e,z);z=ga;y=mI(k,E,f,I);e=y+e|0;f=ga+z|0;f=e>>>0>>0?f+1|0:f;A=e;z=L[t+96>>2];e=z-i|0;y=mI(n,D,e,e>>31);t=A+y|0;e=ga+f|0;e=t>>>0>>0?e+1|0:e;if(!t&(e|0)<=0|(e|0)<0){break x}y:{if(!c){break y}f=L[c+4>>2];if(L[c>>2]==(a|0)){if((a|0)!=(f|0)){break x}f=L[c+12>>2];e=L[L[a+8>>2]+12>>2];y=L[e+96>>2];t=L[f+96>>2]-y|0;A=L[e+92>>2];z=z-y|0;x=R(t,A-x|0)+R(z,L[f+92>>2]-A|0)|0;x=mI(x,x>>31,b,w);y=ga;e=L[e+88>>2];f=R(z,e-L[f+88>>2]|0)+R(t,H-e|0)|0;t=mI(f,f>>31,g,j);f=t+x|0;e=ga+y|0;e=f>>>0>>0?e+1|0:e;if(!f&(e|0)<=0|(e|0)<0){break y}break x}if((a|0)!=(f|0)){break x}}c=a}a=L[a>>2];if((d|0)!=(a|0)){continue}break}L[h+80>>2]=c}f=L[o+8>>2];d=0;L[h+56>>2]=0;if(f){a=f;while(1){m=L[a+12>>2];u=L[m+92>>2];e=u-l|0;i=e;t=e>>31;x=mI(e,t,g,j);z=ga;y=L[m+88>>2];e=y-B|0;A=e>>31;H=mI(b,w,e,A);z:{if((x|0)!=(0-H|0)|(0-(ga+((H|0)!=0)|0)|0)!=(z|0)){break z}i=mI(p,C,i,t);t=ga;x=mI(k,E,e,A);i=x+i|0;e=ga+t|0;e=i>>>0>>0?e+1|0:e;A=i;t=L[m+96>>2];i=t-r|0;m=mI(n,D,i,i>>31);i=A+m|0;e=ga+e|0;e=i>>>0>>0?e+1|0:e;if(!i&(e|0)<=0|(e|0)<0){break z}A:{if(!d){break A}if(L[d>>2]!=(a|0)){break z}if(L[d+4>>2]!=(a|0)){break A}e=L[d+12>>2];i=L[L[a+8>>2]+12>>2];x=L[i+96>>2];m=L[e+96>>2]-x|0;z=L[i+92>>2];t=t-x|0;u=R(m,z-u|0)+R(t,L[e+92>>2]-z|0)|0;u=mI(u,u>>31,b,w);x=ga;i=L[i+88>>2];e=R(t,i-L[e+88>>2]|0)+R(m,y-i|0)|0;m=mI(e,e>>31,g,j);i=m+u|0;e=ga+x|0;e=i>>>0>>0?e+1|0:e;if(!i&(e|0)<=0|(e|0)<0){break z}}d=a}a=L[a>>2];if((f|0)!=(a|0)){continue}break}L[h+56>>2]=d}B:{if(!(c|d)){break B}_j(q,s,o,h+80|0,h+56|0);a=L[h+80>>2];if(a){s=L[a+12>>2];L[h+124>>2]=s}a=L[h+56>>2];if(!a){break B}o=L[a+12>>2];L[h+120>>2]=o;r=L[o+96>>2];l=L[o+92>>2];B=L[o+88>>2]}m=r+1|0;break w}B=L[o+88>>2]+1|0;l=L[o+92>>2];s=L[h+124>>2];m=L[o+96>>2]}a=s;g=o;n=0;e=0;p=0;k=1;c=0;b=0;w=0;while(1){r=L[g+96>>2];d=L[a+96>>2];f=L[a+92>>2];j=L[g+92>>2];i=L[a+88>>2];u=L[g+88>>2];L[h+116>>2]=-1;j=j-f|0;L[h+108>>2]=j;r=r-d|0;L[h+112>>2]=r;u=u-i|0;L[h+104>>2]=u;E=l-f|0;f=m-d|0;d=R(E,r)-R(f,j)|0;C=d>>31;L[h+80>>2]=d;L[h+84>>2]=C;i=B-i|0;f=R(f,u)-R(i,r)|0;D=f>>31;L[h+88>>2]=f;L[h+92>>2]=D;i=R(i,j)-R(u,E)|0;E=i>>31;L[h+96>>2]=i;L[h+100>>2]=E;x=u>>31;t=mI(f,D,u,x);z=ga;y=j>>31;A=mI(d,C,j,y);L[h+72>>2]=t-A;L[h+76>>2]=z-(ga+(t>>>0>>0)|0);A=C;C=r>>31;d=mI(d,A,r,C);t=ga;u=mI(i,E,u,x);L[h+64>>2]=d-u;L[h+68>>2]=t-(ga+(d>>>0>>0)|0);d=mI(j,y,i,E);i=ga;f=mI(f,D,r,C);L[h+56>>2]=d-f;L[h+60>>2]=i-(ga+(d>>>0>>0)|0);L[h+48>>2]=0;L[h+40>>2]=0;L[h+44>>2]=0;L[h+32>>2]=0;L[h+36>>2]=0;d=h+104|0;f=h+80|0;i=h+56|0;j=Zj(q,0,a,d,f,i,h+32|0);L[h+24>>2]=0;L[h+16>>2]=0;L[h+20>>2]=0;L[h+8>>2]=0;L[h+12>>2]=0;i=Zj(q,1,g,d,f,i,h+8|0);if(!(i|j)){b=cg(q,a,g);L[b+4>>2]=b;L[b>>2]=b;L[a+8>>2]=b;a=L[b+8>>2];L[a+4>>2]=a;L[a>>2]=a;L[g+8>>2]=a;break i}r=j?-1:1;if(!(!j|!i)){r=yc(h+32|0,h+8|0)}C:{D:{E:{if(k&1){break E}if((r|0)>=0){if(L[h+16>>2]|L[h+20>>2]|L[h+24>>2]>=0){break E}k=n;g=e;f=c;d=b;break D}if(L[h+40>>2]|L[h+44>>2]|L[h+48>>2]>=0){break E}L[h+4>>2]=j;f=c;d=b;break C}f=cg(q,a,g);d=f;if(c){L[c+4>>2]=f;d=b}L[f>>2]=c;k=L[f+8>>2];g=k;if(n){L[n>>2]=k;g=e}L[k+4>>2]=n}L[h+4>>2]=j;L[h>>2]=i;c=i;if(!r){_j(q,L[h+124>>2],L[h+120>>2],h+4|0,h);c=L[h>>2]}if(!(!c|(r|0)<0)){F:{G:{if(F){a=L[F>>2];if((i|0)!=(a|0)){while(1){n=L[a+8>>2];b=0;l=0;e=L[a>>2];if((e|0)!=(a|0)){L[e+4>>2]=L[a+4>>2];L[L[a+4>>2]>>2]=e;l=e}L[L[n+12>>2]+8>>2]=l;l=L[n>>2];if((l|0)!=(n|0)){L[l+4>>2]=L[n+4>>2];L[L[n+4>>2]>>2]=l;b=l}L[L[a+12>>2]+8>>2]=b;L[a+16>>2]=0;L[a+8>>2]=0;L[a+12>>2]=0;L[a>>2]=0;L[a+4>>2]=0;L[a>>2]=L[q+56>>2];L[q+56>>2]=a;L[n+16>>2]=0;L[n+8>>2]=0;L[n+12>>2]=0;L[n>>2]=0;L[n+4>>2]=0;L[n>>2]=L[q+56>>2];L[q+56>>2]=n;L[q+116>>2]=L[q+116>>2]-1;a=e;if((i|0)!=(a|0)){continue}break}}if(k){break G}break F}if(!k){p=i;break F}F=L[i+4>>2];p=g}L[F>>2]=g;L[g+4>>2]=F;L[k>>2]=i;L[i+4>>2]=k;c=L[h>>2];g=0}e=g;a=L[h+120>>2];m=L[a+96>>2];l=L[a+92>>2];B=L[a+88>>2];L[h+120>>2]=L[c+12>>2];F=L[c+8>>2];n=0;break C}n=k;e=g}H:{I:{if((r|0)<=0){r=L[h+4>>2];if(r){break I}}a=L[h+124>>2];break H}J:{K:{if(G){a=L[G+4>>2];if((j|0)!=(a|0)){while(1){k=L[a+8>>2];l=L[a+4>>2];b=0;c=0;g=L[a>>2];if((g|0)!=(a|0)){L[g+4>>2]=l;L[L[a+4>>2]>>2]=g;c=g}L[L[k+12>>2]+8>>2]=c;c=L[k>>2];if((c|0)!=(k|0)){L[c+4>>2]=L[k+4>>2];L[L[k+4>>2]>>2]=c;b=c}L[L[a+12>>2]+8>>2]=b;L[a+16>>2]=0;L[a+8>>2]=0;L[a+12>>2]=0;L[a>>2]=0;L[a+4>>2]=0;L[a>>2]=L[q+56>>2];L[q+56>>2]=a;L[k+16>>2]=0;L[k+8>>2]=0;L[k+12>>2]=0;L[k>>2]=0;L[k+4>>2]=0;L[k>>2]=L[q+56>>2];L[q+56>>2]=k;L[q+116>>2]=L[q+116>>2]-1;a=l;if((j|0)!=(a|0)){continue}break}}if(!f){break J}L[d>>2]=G;a=G+4|0;break K}if(!f){w=j;break J}a=L[j>>2];L[d>>2]=a;w=d;a=a+4|0}L[a>>2]=d;L[j>>2]=f;L[f+4>>2]=j;d=0;r=L[h+4>>2]}a=L[h+124>>2];m=L[a+96>>2];l=L[a+92>>2];B=L[a+88>>2];a=L[r+12>>2];L[h+124>>2]=a;G=L[r+8>>2];f=0}g=L[h+120>>2];if((a|0)!=(s|0)|(o|0)!=(g|0)){k=0;c=f;b=d;continue}else{L:{if(!G){L[d>>2]=f;L[f+4>>2]=d;L[L[h+124>>2]+8>>2]=f;break L}a=L[G+4>>2];if((w|0)!=(a|0)){while(1){k=L[a+8>>2];g=L[a+4>>2];b=0;c=L[a>>2];if((c|0)!=(a|0)){L[c+4>>2]=g;L[L[a+4>>2]>>2]=c;b=c}L[L[k+12>>2]+8>>2]=b;l=L[k>>2];M:{if((k|0)==(l|0)){l=0;break M}L[l+4>>2]=L[k+4>>2];L[L[k+4>>2]>>2]=l}L[L[a+12>>2]+8>>2]=l;L[a+16>>2]=0;L[a+8>>2]=0;L[a+12>>2]=0;L[a>>2]=0;L[a+4>>2]=0;L[a>>2]=L[q+56>>2];L[q+56>>2]=a;L[k+16>>2]=0;L[k+8>>2]=0;L[k+12>>2]=0;L[k>>2]=0;L[k+4>>2]=0;L[k>>2]=L[q+56>>2];L[q+56>>2]=k;L[q+116>>2]=L[q+116>>2]-1;a=g;if((w|0)!=(a|0)){continue}break}}if(!f){break L}L[d>>2]=G;L[G+4>>2]=d;L[w>>2]=f;L[f+4>>2]=w}if(!F){L[n>>2]=e;L[e+4>>2]=n;L[L[h+120>>2]+8>>2]=n;break i}a=L[F>>2];if((p|0)!=(a|0)){while(1){c=L[a+8>>2];l=0;b=L[a>>2];if((b|0)!=(a|0)){L[b+4>>2]=L[a+4>>2];L[L[a+4>>2]>>2]=b;l=b}L[L[c+12>>2]+8>>2]=l;l=L[c>>2];N:{if((c|0)==(l|0)){l=0;break N}L[l+4>>2]=L[c+4>>2];L[L[c+4>>2]>>2]=l}L[L[a+12>>2]+8>>2]=l;L[a+16>>2]=0;L[a+8>>2]=0;L[a+12>>2]=0;L[a>>2]=0;L[a+4>>2]=0;L[a>>2]=L[q+56>>2];L[q+56>>2]=a;L[c+16>>2]=0;L[c+8>>2]=0;L[c+12>>2]=0;L[c>>2]=0;L[c+4>>2]=0;L[c>>2]=L[q+56>>2];L[q+56>>2]=c;L[q+116>>2]=L[q+116>>2]-1;a=b;if((p|0)!=(a|0)){continue}break}}if(!n){break i}L[F>>2]=e;L[e+4>>2]=F;L[n>>2]=p;L[p+4>>2]=n}break}}fa=h+128|0}fa=v+16|0}function Xg(a,b,c){var d=0,e=0,f=S(0),g=0,h=0,i=0,j=0,k=0,l=S(0),m=0,n=S(0),o=S(0),p=S(0),q=0,r=S(0),s=S(0),t=S(0),u=S(0),v=0,w=S(0),x=0,y=0,z=0,A=0,B=S(0),C=0,D=S(0),E=0,F=0,G=0,H=0,I=S(0),O=S(0);m=fa-32|0;fa=m;A=L[a+56>>2];a:{if((c-b|0)==1){b:{if(M[a+60|0]){b=L[a+116>>2]+(b<<4)|0;e=L[b+4>>2];c=L[a+136>>2]+(A<<4)|0;L[c>>2]=L[b>>2];L[c+4>>2]=e;break b}b=L[a+76>>2]+(b<<6)|0;e=L[b+4>>2];c=L[a+96>>2]+(A<<6)|0;L[c>>2]=L[b>>2];L[c+4>>2]=e;e=L[b+60>>2];L[c+56>>2]=L[b+56>>2];L[c+60>>2]=e;e=L[b+52>>2];L[c+48>>2]=L[b+48>>2];L[c+52>>2]=e;e=L[b+44>>2];L[c+40>>2]=L[b+40>>2];L[c+44>>2]=e;e=L[b+36>>2];L[c+32>>2]=L[b+32>>2];L[c+36>>2]=e;e=L[b+28>>2];L[c+24>>2]=L[b+24>>2];L[c+28>>2]=e;e=L[b+20>>2];L[c+16>>2]=L[b+16>>2];L[c+20>>2]=e}e=L[b+12>>2];L[c+8>>2]=L[b+8>>2];L[c+12>>2]=e;L[a+56>>2]=L[a+56>>2]+1;break a}k=c;e=b;g=c-e|0;c:{d:{e:{if((c|0)<=(e|0)){D=S(g|0);break e}f:{if(!M[a+60|0]){d=L[a+76>>2];c=b;while(1){h=d+(c<<6)|0;w=S(w+S(S(P[h+16>>2]+P[h>>2])*S(.5)));r=S(r+S(S(P[h+24>>2]+P[h+8>>2])*S(.5)));s=S(s+S(S(P[h+20>>2]+P[h+4>>2])*S(.5)));c=c+1|0;if((k|0)!=(c|0)){continue}break}break f}t=P[a+12>>2];o=P[a+8>>2];p=P[a+44>>2];l=P[a+40>>2];d=L[a+116>>2];n=P[a+4>>2];f=P[a+36>>2];c=b;while(1){h=d+(c<<4)|0;w=S(w+S(S(S(S(S(N[h+6>>1])/f)+n)+S(S(S(N[h>>1])/f)+n))*S(.5)));r=S(r+S(S(S(S(S(N[h+10>>1])/p)+t)+S(S(S(N[h+4>>1])/p)+t))*S(.5)));s=S(s+S(S(S(S(S(N[h+8>>1])/l)+o)+S(S(S(N[h+2>>1])/l)+o))*S(.5)));c=c+1|0;if((k|0)!=(c|0)){continue}break}}D=S(g|0);if((e|0)<(k|0)){break d}}r=S(0);s=S(0);break c}f=S(S(1)/D);I=S(f*r);O=S(f*s);w=S(f*w);s=S(0);if(!M[a+60|0]){c=L[a+76>>2];r=S(0);while(1){d=c+(e<<6)|0;f=S(S(S(P[d+16>>2]+P[d>>2])*S(.5))-w);u=S(u+S(f*f));f=S(S(S(P[d+24>>2]+P[d+8>>2])*S(.5))-I);s=S(s+S(f*f));f=S(S(S(P[d+20>>2]+P[d+4>>2])*S(.5))-O);r=S(r+S(f*f));e=e+1|0;if((k|0)!=(e|0)){continue}break}break c}B=P[a+12>>2];t=P[a+8>>2];o=P[a+44>>2];p=P[a+40>>2];c=L[a+116>>2];l=P[a+4>>2];n=P[a+36>>2];r=S(0);while(1){d=c+(e<<4)|0;f=S(S(S(S(S(S(N[d+6>>1])/n)+l)+S(S(S(N[d>>1])/n)+l))*S(.5))-w);u=S(u+S(f*f));f=S(S(S(S(S(S(N[d+10>>1])/o)+B)+S(S(S(N[d+4>>1])/o)+B))*S(.5))-I);s=S(s+S(f*f));f=S(S(S(S(S(S(N[d+8>>1])/p)+t)+S(S(S(N[d+2>>1])/p)+t))*S(.5))-O);r=S(r+S(f*f));e=e+1|0;if((k|0)!=(e|0)){continue}break}}l=S(S(1)/S(D+S(-1)));n=S(l*u);f=S(l*r);c=n(c?f:n)?2:c;r=S(0);s=S(0);u=S(0);i=fa-96|0;L[i+28>>2]=0;y=k-b|0;d=(b|0)>=(k|0);g:{if(d){break g}if(!M[a+60|0]){e=L[a+76>>2];c=b;while(1){h=e+(c<<6)|0;u=S(S(S(P[h+16>>2]+P[h>>2])*S(.5))+u);r=S(S(S(P[h+24>>2]+P[h+8>>2])*S(.5))+r);s=S(S(S(P[h+20>>2]+P[h+4>>2])*S(.5))+s);c=c+1|0;if((k|0)!=(c|0)){continue}break}break g}t=P[a+12>>2];o=P[a+8>>2];p=P[a+44>>2];l=P[a+40>>2];e=L[a+116>>2];n=P[a+4>>2];f=P[a+36>>2];c=b;while(1){h=e+(c<<4)|0;u=S(S(S(S(S(S(N[h+6>>1])/f)+n)+S(S(S(N[h>>1])/f)+n))*S(.5))+u);r=S(S(S(S(S(S(N[h+10>>1])/p)+t)+S(S(S(N[h+4>>1])/p)+t))*S(.5))+r);s=S(S(S(S(S(S(N[h+8>>1])/l)+o)+S(S(S(N[h+2>>1])/l)+o))*S(.5))+s);c=c+1|0;if((k|0)!=(c|0)){continue}break}}f=S(S(1)/S(y|0));P[i+24>>2]=f*r;P[i+20>>2]=f*s;P[i+16>>2]=f*u;e=b;if(!d){c=g<<2;B=P[c+(i+16|0)>>2];z=c+i|0;c=b;while(1){d=M[a+60|0];h:{if(d){g=L[a+116>>2]+(c<<4)|0;t=P[a+44>>2];o=P[a+12>>2];r=S(S(S(N[g+4>>1])/t)+o);p=P[a+40>>2];l=P[a+8>>2];s=S(S(S(N[g+2>>1])/p)+l);n=P[a+36>>2];f=P[a+4>>2];u=S(S(S(N[g>>1])/n)+f);w=S(S(S(N[g+10>>1])/t)+o);D=S(S(S(N[g+8>>1])/p)+l);f=S(S(S(N[g+6>>1])/n)+f);break h}g=L[a+76>>2]+(c<<6)|0;r=P[g+8>>2];s=P[g+4>>2];u=P[g>>2];w=P[g+24>>2];D=P[g+20>>2];f=P[g+16>>2]}L[i+12>>2]=0;P[i+8>>2]=S(w+r)*S(.5);P[i+4>>2]=S(D+s)*S(.5);P[i>>2]=S(f+u)*S(.5);if(B>2]){i:{if(d){g=L[a+116>>2];q=g+(c<<4)|0;h=q;d=L[h+12>>2];L[i+40>>2]=L[h+8>>2];L[i+44>>2]=d;d=L[h+4>>2];L[i+32>>2]=L[h>>2];L[i+36>>2]=d;d=g;g=e<<4;h=d+g|0;d=L[h+4>>2];L[q>>2]=L[h>>2];L[q+4>>2]=d;d=L[h+12>>2];L[q+8>>2]=L[h+8>>2];L[q+12>>2]=d;d=L[i+36>>2];g=g+L[a+116>>2]|0;L[g>>2]=L[i+32>>2];L[g+4>>2]=d;d=L[i+44>>2];L[g+8>>2]=L[i+40>>2];L[g+12>>2]=d;break i}h=L[a+76>>2];j=h+(c<<6)|0;d=L[j+60>>2];L[i+88>>2]=L[j+56>>2];L[i+92>>2]=d;d=L[j+52>>2];L[i+80>>2]=L[j+48>>2];L[i+84>>2]=d;d=L[j+44>>2];L[i+72>>2]=L[j+40>>2];L[i+76>>2]=d;d=L[j+36>>2];q=i- -64|0;g=q;L[g>>2]=L[j+32>>2];L[g+4>>2]=d;d=L[j+28>>2];L[i+56>>2]=L[j+24>>2];L[i+60>>2]=d;d=L[j+20>>2];L[i+48>>2]=L[j+16>>2];L[i+52>>2]=d;d=L[j+12>>2];L[i+40>>2]=L[j+8>>2];L[i+44>>2]=d;d=L[j+4>>2];L[i+32>>2]=L[j>>2];L[i+36>>2]=d;g=e<<6;h=g+h|0;d=L[h+4>>2];L[j>>2]=L[h>>2];L[j+4>>2]=d;d=L[h+12>>2];L[j+8>>2]=L[h+8>>2];L[j+12>>2]=d;d=L[h+20>>2];L[j+16>>2]=L[h+16>>2];L[j+20>>2]=d;d=L[h+28>>2];L[j+24>>2]=L[h+24>>2];L[j+28>>2]=d;d=L[h+36>>2];L[j+32>>2]=L[h+32>>2];L[j+36>>2]=d;d=L[h+44>>2];L[j+40>>2]=L[h+40>>2];L[j+44>>2]=d;d=L[h+52>>2];L[j+48>>2]=L[h+48>>2];L[j+52>>2]=d;d=L[h+60>>2];L[j+56>>2]=L[h+56>>2];L[j+60>>2]=d;d=L[i+36>>2];g=g+L[a+76>>2]|0;L[g>>2]=L[i+32>>2];L[g+4>>2]=d;d=L[i+44>>2];L[g+8>>2]=L[i+40>>2];L[g+12>>2]=d;d=L[i+52>>2];L[g+16>>2]=L[i+48>>2];L[g+20>>2]=d;d=L[i+60>>2];L[g+24>>2]=L[i+56>>2];L[g+28>>2]=d;d=L[q+4>>2];L[g+32>>2]=L[q>>2];L[g+36>>2]=d;d=L[i+76>>2];L[g+40>>2]=L[i+72>>2];L[g+44>>2]=d;d=L[i+84>>2];L[g+48>>2]=L[i+80>>2];L[g+52>>2]=d;d=L[i+92>>2];L[g+56>>2]=L[i+88>>2];L[g+60>>2]=d}e=e+1|0}c=c+1|0;if((k|0)!=(c|0)){continue}break}}c=(y>>1)+b|0;d=c;c=(y|0)/3|0;j=(b+c|0)>=(e|0)?d:(k+(c^-1)|0)<=(e|0)?d:e;E=L[a+56>>2];j:{if(M[a+60|0]){t=P[a+40>>2];o=P[a+8>>2];p=P[a+24>>2];l=P[a+44>>2];n=P[a+12>>2];f=P[a+28>>2];c=L[a+136>>2]+(E<<4)|0;B=S(S(P[a+20>>2]-P[a+4>>2])*P[a+36>>2]);k:{if(B=S(0)){d=~~B>>>0;break k}d=0}K[c>>1]=d&65534;f=S(S(f-n)*l);l:{if(f=S(0)){d=~~f>>>0;break l}d=0}K[c+4>>1]=d&65534;f=S(S(p-o)*t);m:{if(f=S(0)){d=~~f>>>0;break m}d=0}K[c+2>>1]=d&65534;break j}c=L[a+24>>2];e=L[a+96>>2]+(E<<6)|0;L[e>>2]=L[a+20>>2];L[e+4>>2]=c;c=L[a+32>>2];L[e+8>>2]=L[a+28>>2];L[e+12>>2]=c}c=L[a+56>>2];n:{if(M[a+60|0]){l=P[a+40>>2];o=P[a+8>>2];n=P[a+44>>2];p=P[a+12>>2];c=L[a+136>>2]+(c<<4)|0;f=P[a+4>>2];f=S(S(S(f-f)*P[a+36>>2])+S(1));o:{if(f=S(0)){d=~~f>>>0;break o}d=0}K[c+6>>1]=d|1;f=S(S(S(p-p)*n)+S(1));p:{if(f=S(0)){d=~~f>>>0;break p}d=0}K[c+10>>1]=d|1;f=S(S(S(o-o)*l)+S(1));q:{if(f=S(0)){d=~~f>>>0;break q}d=0}K[c+8>>1]=d|1;break n}e=L[a+96>>2]+(c<<6)|0;c=L[a+8>>2];L[e+16>>2]=L[a+4>>2];L[e+20>>2]=c;c=L[a+16>>2];L[e+24>>2]=L[a+12>>2];L[e+28>>2]=c}if((b|0)<(k|0)){c=b;while(1){x=L[a+56>>2];r:{if(M[a+60|0]){h=L[a+116>>2]+(c<<4)|0;g=N[h+4>>1];d=N[h+2>>1];e=N[h>>1];t=P[a+44>>2];o=P[a+40>>2];p=P[a+36>>2];L[m+28>>2]=0;l=P[a+4>>2];P[m+16>>2]=S(S(e>>>0)/p)+l;n=P[a+8>>2];P[m+20>>2]=S(S(d>>>0)/o)+n;f=P[a+12>>2];P[m+24>>2]=S(S(g>>>0)/t)+f;g=N[h+6>>1];d=N[h+8>>1];e=N[h+10>>1];L[m+12>>2]=0;P[m+8>>2]=f+S(S(e>>>0)/t);P[m+4>>2]=n+S(S(d>>>0)/o);P[m>>2]=l+S(S(g>>>0)/p);break r}d=L[a+76>>2]+(c<<6)|0;e=L[d+12>>2];L[m+24>>2]=L[d+8>>2];L[m+28>>2]=e;e=L[d+4>>2];L[m+16>>2]=L[d>>2];L[m+20>>2]=e;e=L[d+28>>2];L[m+8>>2]=L[d+24>>2];L[m+12>>2]=e;e=L[d+20>>2];L[m>>2]=L[d+16>>2];L[m+4>>2]=e}s:{if(M[a+60|0]){p=P[a+12>>2];l=P[a+44>>2];f=S(S(P[m+24>>2]-p)*l);t:{if(f=S(0)){z=~~f>>>0;break t}z=0}n=P[a+8>>2];f=P[a+40>>2];o=S(S(P[m+20>>2]-n)*f);u:{if(o=S(0)){h=~~o>>>0;break u}h=0}l=S(S(l*S(P[m+8>>2]-p))+S(1));v:{if(l=S(0)){g=~~l>>>0;break v}g=0}f=S(S(f*S(P[m+4>>2]-n))+S(1));w:{if(f=S(0)){d=~~f>>>0;break w}d=0}n=P[a+4>>2];f=P[a+36>>2];l=S(S(P[m+16>>2]-n)*f);x:{if(l=S(0)){e=~~l>>>0;break x}e=0}y=e&65534;i=L[a+136>>2];v=i+(x<<4)|0;q=y>>>0>=N[v>>1];f=S(S(f*S(P[m>>2]-n))+S(1));y:{if(f=S(0)){e=~~f>>>0;break y}e=0}if(!q){K[v>>1]=y}e=e|1;q=i+(x<<4)|0;if(e>>>0>N[q+6>>1]){K[q+6>>1]=e}e=h&65534;if(e>>>0>1]){K[v+2>>1]=e}e=d|1;h=i+(x<<4)|0;if(e>>>0>N[h+8>>1]){K[h+8>>1]=e}e=z&65534;if(e>>>0>1]){K[v+4>>1]=e}e=g|1;d=i+(x<<4)|0;if(e>>>0<=N[d+10>>1]){break s}K[d+10>>1]=e;break s}f=P[m+16>>2];e=L[a+96>>2];d=e+(x<<6)|0;if(f>2]){P[d>>2]=f}f=P[m+20>>2];if(f>2]){P[d+4>>2]=f}f=P[m+24>>2];if(f>2]){P[d+8>>2]=f}f=P[m+28>>2];if(f>2]){P[d+12>>2]=f}f=P[m>>2];e=e+(x<<6)|0;if(f>P[e+16>>2]){P[e+16>>2]=f}f=P[m+4>>2];if(f>P[e+20>>2]){P[e+20>>2]=f}f=P[m+8>>2];if(f>P[e+24>>2]){P[e+24>>2]=f}f=P[m+12>>2];if(!(f>P[e+28>>2])){break s}P[e+28>>2]=f}c=c+1|0;if((k|0)!=(c|0)){continue}break}}F=L[a+56>>2]+1|0;L[a+56>>2]=F;Xg(a,b,j);H=L[a+56>>2];Xg(a,j,k);c=M[a+60|0];x=L[a+56>>2]-A|0;if(!(!c|(x|0)<129)){e=0;q=0;v=L[a+136>>2];A=v+(H<<4)|0;b=L[A+12>>2];y=(b|0)>=0?1:0-b|0;i=v+(F<<4)|0;b=L[i+12>>2];z=(b|0)>=0?1:0-b|0;if(z>>>0<=128){d=L[a+152>>2];c=d;z:{if((c|0)!=L[a+156>>2]){break z}j=c?d<<1:1;if((j|0)<=(c|0)){break z}if(j){L[8513]=L[8513]+1;G=ha[L[6798]](j<<5,16)|0;b=L[a+152>>2]}else{b=d}A:{if((b|0)<=0){break A}if((b|0)!=1){h=b&-2;while(1){k=e<<5;g=k+G|0;C=L[a+160>>2]+k|0;c=L[C+4>>2];L[g>>2]=L[C>>2];L[g+4>>2]=c;c=L[C+28>>2];L[g+24>>2]=L[C+24>>2];L[g+28>>2]=c;c=L[C+20>>2];L[g+16>>2]=L[C+16>>2];L[g+20>>2]=c;c=L[C+12>>2];L[g+8>>2]=L[C+8>>2];L[g+12>>2]=c;c=k|32;g=c+G|0;k=c+L[a+160>>2]|0;c=L[k+4>>2];L[g>>2]=L[k>>2];L[g+4>>2]=c;c=L[k+12>>2];L[g+8>>2]=L[k+8>>2];L[g+12>>2]=c;c=L[k+20>>2];L[g+16>>2]=L[k+16>>2];L[g+20>>2]=c;c=L[k+28>>2];L[g+24>>2]=L[k+24>>2];L[g+28>>2]=c;e=e+2|0;q=q+2|0;if((h|0)!=(q|0)){continue}break}}if(!(b&1)){break A}b=e<<5;c=b+G|0;e=b+L[a+160>>2]|0;b=L[e+4>>2];L[c>>2]=L[e>>2];L[c+4>>2]=b;b=L[e+28>>2];L[c+24>>2]=L[e+24>>2];L[c+28>>2]=b;b=L[e+20>>2];L[c+16>>2]=L[e+16>>2];L[c+20>>2]=b;b=L[e+12>>2];L[c+8>>2]=L[e+8>>2];L[c+12>>2]=b}b=L[a+160>>2];if(!(b?!b|!M[a+164|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+160>>2]=G;J[a+164|0]=1;L[a+156>>2]=j;c=L[a+152>>2]}L[a+152>>2]=c+1;c=L[a+160>>2]+(d<<5)|0;K[c>>1]=N[i>>1];K[c+2>>1]=N[i+2>>1];K[c+4>>1]=N[i+4>>1];b=v+(F<<4)|0;K[c+6>>1]=N[b+6>>1];K[c+8>>1]=N[b+8>>1];b=N[b+10>>1];L[c+16>>2]=z;L[c+12>>2]=F;K[c+10>>1]=b}if((y|0)<=128){d=L[a+152>>2];c=d;B:{if((c|0)!=L[a+156>>2]){break B}j=c?d<<1:1;if((j|0)<=(c|0)){break B}C:{if(!j){b=0;c=d;break C}L[8513]=L[8513]+1;b=ha[L[6798]](j<<5,16)|0;c=L[a+152>>2]}D:{if((c|0)<=0){break D}e=0;if((c|0)!=1){z=c&-2;q=0;while(1){k=e<<5;h=k+b|0;i=k+L[a+160>>2]|0;g=L[i+4>>2];L[h>>2]=L[i>>2];L[h+4>>2]=g;g=L[i+28>>2];L[h+24>>2]=L[i+24>>2];L[h+28>>2]=g;g=L[i+20>>2];L[h+16>>2]=L[i+16>>2];L[h+20>>2]=g;g=L[i+12>>2];L[h+8>>2]=L[i+8>>2];L[h+12>>2]=g;g=k|32;h=g+b|0;k=g+L[a+160>>2]|0;g=L[k+4>>2];L[h>>2]=L[k>>2];L[h+4>>2]=g;g=L[k+12>>2];L[h+8>>2]=L[k+8>>2];L[h+12>>2]=g;g=L[k+20>>2];L[h+16>>2]=L[k+16>>2];L[h+20>>2]=g;g=L[k+28>>2];L[h+24>>2]=L[k+24>>2];L[h+28>>2]=g;e=e+2|0;q=q+2|0;if((z|0)!=(q|0)){continue}break}}if(!(c&1)){break D}c=e<<5;e=c+b|0;g=c+L[a+160>>2]|0;c=L[g+4>>2];L[e>>2]=L[g>>2];L[e+4>>2]=c;c=L[g+28>>2];L[e+24>>2]=L[g+24>>2];L[e+28>>2]=c;c=L[g+20>>2];L[e+16>>2]=L[g+16>>2];L[e+20>>2]=c;c=L[g+12>>2];L[e+8>>2]=L[g+8>>2];L[e+12>>2]=c}c=L[a+160>>2];if(!(c?!c|!M[a+164|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](c)}L[a+160>>2]=b;J[a+164|0]=1;L[a+156>>2]=j;c=L[a+152>>2]}L[a+152>>2]=c+1;c=L[a+160>>2]+(d<<5)|0;K[c>>1]=N[A>>1];K[c+2>>1]=N[A+2>>1];K[c+4>>1]=N[A+4>>1];b=v+(H<<4)|0;K[c+6>>1]=N[b+6>>1];K[c+8>>1]=N[b+8>>1];b=N[b+10>>1];L[c+16>>2]=y;L[c+12>>2]=H;K[c+10>>1]=b}L[a+168>>2]=L[a+152>>2];c=M[a+60|0]}if(c&255){L[(L[a+136>>2]+(E<<4)|0)+12>>2]=0-x;break a}L[(L[a+96>>2]+(E<<6)|0)+32>>2]=x}fa=m+32|0}function vd(a,b,c,d,e,f){var g=0,h=0,i=0,j=0,k=S(0),l=S(0),m=S(0),n=0,o=0,p=S(0),q=S(0),r=S(0),s=S(0),t=S(0),u=S(0),v=S(0),w=S(0),x=S(0),y=S(0),z=0,A=S(0),B=S(0),C=S(0),D=S(0),E=S(0),F=0,G=0,H=S(0),I=S(0),K=S(0),N=S(0),O=S(0),U=S(0),V=0,W=0,X=0,Y=0,Z=0,_=0;i=fa-512|0;fa=i;a:{if((ha[L[L[d>>2]+80>>2]](d)|0)==2){g=(f?36:28)+a|0;j=L[d+152>>2];h=j-1|0;L[g>>2]=h;if(!j){break a}while(1){vd(a,b,c,L[L[d+160>>2]+(h<<2)>>2],e,f);j=L[g>>2];h=j-1|0;L[g>>2]=h;if(j){continue}break}break a}h=(ha[L[L[d>>2]+80>>2]](d)|0)!=1;g=L[e+4>>2];if(!(h|(g|0)!=28)){g=fa-144|0;fa=g;h=L[b+12>>2];j=L[h+12>>2];L[g+88>>2]=L[h+8>>2];L[g+92>>2]=j;j=L[h+4>>2];L[g+80>>2]=L[h>>2];L[g+84>>2]=j;j=L[h+28>>2];L[g+104>>2]=L[h+24>>2];L[g+108>>2]=j;j=L[h+20>>2];L[g+96>>2]=L[h+16>>2];L[g+100>>2]=j;j=L[h+44>>2];L[g+120>>2]=L[h+40>>2];L[g+124>>2]=j;j=L[h+36>>2];L[g+112>>2]=L[h+32>>2];L[g+116>>2]=j;j=L[h+60>>2];L[g+136>>2]=L[h+56>>2];L[g+140>>2]=j;j=L[h+52>>2];L[g+128>>2]=L[h+48>>2];L[g+132>>2]=j;h=L[c+12>>2];p=P[h+52>>2];q=P[h+56>>2];r=P[h+20>>2];s=P[h+24>>2];t=P[h+8>>2];u=P[h>>2];w=P[h+4>>2];x=P[h+48>>2];y=P[h+16>>2];k=P[e+56>>2];l=P[e+48>>2];m=P[e+52>>2];v=S(S(P[h+40>>2]*k)+S(S(P[h+32>>2]*l)+S(P[h+36>>2]*m)));P[g+72>>2]=v;r=S(S(s*k)+S(S(y*l)+S(r*m)));P[g+68>>2]=r;s=S(S(t*k)+S(S(u*l)+S(w*m)));P[g+64>>2]=s;l=S(S(S(q*k)+S(S(x*l)+S(p*m)))+P[e+64>>2]);P[g+76>>2]=l;ha[L[L[d>>2]+8>>2]](d,g+80|0,g+32|0,g+48|0);k=S(ha[L[L[e>>2]+48>>2]](e));m=S(k+P[g+52>>2]);P[g+52>>2]=m;p=S(k+P[g+56>>2]);P[g+56>>2]=p;t=S(P[g+36>>2]-k);P[g+36>>2]=t;q=S(k+P[g+48>>2]);P[g+48>>2]=q;u=S(P[g+32>>2]-k);P[g+32>>2]=u;k=S(P[g+40>>2]-k);P[g+40>>2]=k;k=S(S(p+k)*S(.5));u=S(S(u+q)*S(.5));t=S(S(m+t)*S(.5));w=S(S(v*k)+S(S(s*u)+S(t*r)));k=S(S(S(p-k)*S(T(v)))+S(S(S(q-u)*S(T(s)))+S(S(m-t)*S(T(r)))));if(!(l>S(S(w+k)+S(9.999999974752427e-7))|!(S(l+S(9.999999974752427e-7))>=S(w-k)))){ha[L[L[d>>2]+112>>2]](d);k=S(ha[L[L[d>>2]+48>>2]](d));l=S(ha[L[L[e>>2]+48>>2]](e));h=L[d+184>>2];if(h){s=S(k+l);while(1){h=h-1|0;e=L[d+180>>2]+R(h,L[d+192>>2])|0;k=P[d+156>>2];b:{if(L[d+188>>2]==1){l=S(Q[e>>3]*+k);m=S(Q[e+8>>3]*+P[d+160>>2]);k=S(Q[e+16>>3]*+P[d+164>>2]);break b}l=S(k*P[e>>2]);P[g+16>>2]=l;m=S(P[e+4>>2]*P[d+160>>2]);P[g+20>>2]=m;k=S(P[e+8>>2]*P[d+164>>2])}L[g+28>>2]=0;p=S(S(S(k*P[g+104>>2])+S(S(l*P[g+96>>2])+S(m*P[g+100>>2])))+P[g+132>>2]);P[g+20>>2]=p;v=P[g+68>>2];q=S(S(S(k*P[g+88>>2])+S(S(l*P[g+80>>2])+S(m*P[g+84>>2])))+P[g+128>>2]);P[g+16>>2]=q;r=P[g+64>>2];k=S(S(S(k*P[g+120>>2])+S(S(l*P[g+112>>2])+S(m*P[g+116>>2])))+P[g+136>>2]);P[g+24>>2]=k;l=P[g+72>>2];k=S(S(S(S(k*l)+S(S(q*r)+S(p*v)))-P[g+76>>2])-s);c:{if(!(k>2]=0;P[g+8>>2]=-l;P[g+4>>2]=-v;P[g>>2]=-r;e=L[a+16>>2];ha[L[L[e>>2]+8>>2]](e,L[a+28>>2],L[a+24>>2]);e=L[a+16>>2];ha[L[L[e>>2]+12>>2]](e,L[a+36>>2],L[a+32>>2]);e=L[a+12>>2];if(!e){e=L[a+4>>2];e=ha[L[L[e>>2]+12>>2]](e,L[c+8>>2],L[b+8>>2])|0;L[a+12>>2]=e}j=L[a+16>>2];L[j+4>>2]=e;ha[L[L[j>>2]+16>>2]](j,g,g+16|0,k);break c}e=L[a+16>>2];ha[L[L[e>>2]+8>>2]](e,L[a+28>>2],L[a+24>>2]);e=L[a+16>>2];ha[L[L[e>>2]+12>>2]](e,L[a+36>>2],L[a+32>>2]);e=L[a+12>>2];if(!e){e=L[a+4>>2];e=ha[L[L[e>>2]+12>>2]](e,L[b+8>>2],L[c+8>>2])|0;L[a+12>>2]=e}j=L[a+16>>2];L[j+4>>2]=e;ha[L[L[j>>2]+16>>2]](j,g- -64|0,g+16|0,k)}if(h){continue}break}}ha[L[L[d>>2]+116>>2]](d)}fa=g+144|0;break a}if((g|0)==31){g=fa-96|0;fa=g;n=L[e+16>>2];if(n){h=L[c+12>>2];O=P[h+56>>2];U=P[h+52>>2];k=P[h+40>>2];l=P[h+36>>2];m=P[h+24>>2];v=P[h+20>>2];H=P[h+48>>2];r=P[h+32>>2];s=P[h+16>>2];p=P[h+8>>2];q=P[h+4>>2];t=P[h>>2];o=L[a+16>>2];while(1){n=n-1|0;h=L[e+24>>2]+R(n,80)|0;z=L[h+64>>2];u=P[h+56>>2];w=P[h+48>>2];x=P[h+52>>2];y=P[h+32>>2];A=P[h>>2];B=P[h+16>>2];C=P[h+36>>2];D=P[h+4>>2];E=P[h+20>>2];I=P[h+40>>2];K=P[h+8>>2];N=P[h+24>>2];L[g+92>>2]=0;L[g+76>>2]=0;L[g+60>>2]=0;L[g+44>>2]=0;P[g+72>>2]=S(I*k)+S(S(K*r)+S(l*N));P[g+68>>2]=S(C*k)+S(S(D*r)+S(l*E));P[g+64>>2]=S(y*k)+S(S(A*r)+S(l*B));P[g+56>>2]=S(I*m)+S(S(K*s)+S(v*N));P[g+52>>2]=S(C*m)+S(S(D*s)+S(v*E));P[g+48>>2]=S(y*m)+S(S(A*s)+S(v*B));P[g+40>>2]=S(I*p)+S(S(K*t)+S(q*N));P[g+36>>2]=S(C*p)+S(S(D*t)+S(q*E));P[g+32>>2]=S(y*p)+S(S(A*t)+S(q*B));P[g+88>>2]=O+S(S(u*k)+S(S(w*r)+S(l*x)));P[g+84>>2]=U+S(S(u*m)+S(S(w*s)+S(v*x)));P[g+80>>2]=H+S(S(u*p)+S(S(w*t)+S(q*x)));h=L[c+8>>2];L[g+28>>2]=n;L[g+24>>2]=-1;L[g+16>>2]=h;L[g+12>>2]=z;L[g+8>>2]=c;L[g+20>>2]=g+32;j=L[o+8>>2];if((h|0)==L[j+8>>2]){o=o+8|0}else{j=L[o+12>>2];o=o+12|0}h=g+8|0;L[o>>2]=h;vd(a,b,h,d,z,f);o=L[a+16>>2];L[o+(L[L[o+8>>2]+8>>2]==L[g+16>>2]?8:12)>>2]=j;if(n){continue}break}}fa=g+96|0;break a}if(g-21>>>0<=8){g=fa-128|0;fa=g;J[g+120|0]=f;L[g+116>>2]=d;L[g+104>>2]=a;L[g+100>>2]=17548;L[g+108>>2]=b;L[g+112>>2]=c;P[g+124>>2]=ha[L[L[e>>2]+48>>2]](e);a=L[c+12>>2];u=P[a+52>>2];w=P[a+56>>2];b=L[b+12>>2];x=P[b+52>>2];y=P[b+56>>2];k=P[a+20>>2];l=P[a+36>>2];A=P[b+20>>2];B=P[b+36>>2];C=P[b+24>>2];m=P[a+24>>2];D=P[b+40>>2];v=P[a+40>>2];E=P[b+32>>2];r=P[a+32>>2];I=P[b>>2];s=P[a>>2];K=P[b+16>>2];p=P[a+16>>2];H=P[a+48>>2];N=P[b+48>>2];q=P[a+4>>2];O=P[b+4>>2];U=P[b+8>>2];t=P[a+8>>2];L[g+96>>2]=0;L[g+80>>2]=0;L[g- -64>>2]=0;P[g+76>>2]=S(D*v)+S(S(U*t)+S(m*C));P[g+72>>2]=S(B*v)+S(S(O*t)+S(m*A));P[g+60>>2]=S(D*l)+S(S(U*q)+S(k*C));P[g+56>>2]=S(B*l)+S(S(O*q)+S(k*A));H=S(-H);P[g+92>>2]=S(S(S(t*H)-S(m*u))-S(v*w))+S(S(y*v)+S(S(N*t)+S(m*x)));P[g+88>>2]=S(S(S(q*H)-S(k*u))-S(l*w))+S(S(y*l)+S(S(N*q)+S(k*x)));L[g+48>>2]=0;P[g+36>>2]=S(E*r)+S(S(I*s)+S(p*K));P[g+68>>2]=S(E*v)+S(S(I*t)+S(m*K));P[g+52>>2]=S(E*l)+S(S(I*q)+S(k*K));P[g+44>>2]=S(D*r)+S(S(U*s)+S(p*C));P[g+40>>2]=S(B*r)+S(S(O*s)+S(p*A));P[g+84>>2]=S(S(S(s*H)-S(p*u))-S(r*w))+S(S(y*r)+S(S(N*s)+S(p*x)));a=g+20|0;b=g+4|0;ha[L[L[d>>2]+8>>2]](d,g+36|0,a,b);ha[L[L[e>>2]+64>>2]](e,g+100|0,a,b);fa=g+128|0;break a}g=L[b+12>>2];h=L[g+12>>2];L[i+456>>2]=L[g+8>>2];L[i+460>>2]=h;h=L[g+4>>2];L[i+448>>2]=L[g>>2];L[i+452>>2]=h;h=L[g+28>>2];L[i+472>>2]=L[g+24>>2];L[i+476>>2]=h;h=L[g+20>>2];L[i+464>>2]=L[g+16>>2];L[i+468>>2]=h;h=L[g+44>>2];L[i+488>>2]=L[g+40>>2];L[i+492>>2]=h;h=L[g+36>>2];L[i+480>>2]=L[g+32>>2];L[i+484>>2]=h;h=L[g+60>>2];L[i+504>>2]=L[g+56>>2];L[i+508>>2]=h;h=L[g+52>>2];L[i+496>>2]=L[g+48>>2];L[i+500>>2]=h;g=L[c+12>>2];h=L[g+12>>2];L[i+392>>2]=L[g+8>>2];L[i+396>>2]=h;h=L[g+4>>2];L[i+384>>2]=L[g>>2];L[i+388>>2]=h;h=L[g+28>>2];L[i+408>>2]=L[g+24>>2];L[i+412>>2]=h;h=L[g+20>>2];L[i+400>>2]=L[g+16>>2];L[i+404>>2]=h;h=L[g+44>>2];L[i+424>>2]=L[g+40>>2];L[i+428>>2]=h;h=L[g+36>>2];L[i+416>>2]=L[g+32>>2];L[i+420>>2]=h;h=L[g+60>>2];L[i+440>>2]=L[g+56>>2];L[i+444>>2]=h;h=L[g+52>>2];L[i+432>>2]=L[g+48>>2];L[i+436>>2]=h;L[i+376>>2]=0;J[i+380|0]=1;L[i+368>>2]=0;L[i+372>>2]=0;h=i+448|0;j=i+384|0;o=i+364|0;g=fa-96|0;fa=g;d:{if(L[d+68>>2]){k=P[h+20>>2];l=P[h+36>>2];u=P[h+52>>2];m=P[h+24>>2];w=P[h+56>>2];v=P[h+40>>2];r=P[h+32>>2];s=P[h>>2];p=P[h+16>>2];q=P[h+4>>2];t=P[h+8>>2];x=P[h+48>>2];L[g+60>>2]=0;x=S(-x);y=P[j+56>>2];A=P[j+48>>2];B=P[j+52>>2];P[g+56>>2]=S(S(S(t*x)-S(m*u))-S(v*w))+S(S(v*y)+S(S(t*A)+S(m*B)));P[g+52>>2]=S(S(S(q*x)-S(k*u))-S(l*w))+S(S(l*y)+S(S(q*A)+S(k*B)));P[g+48>>2]=S(S(S(s*x)-S(p*u))-S(r*w))+S(S(r*y)+S(S(s*A)+S(p*B)));u=P[j+20>>2];w=P[j+36>>2];x=P[j+24>>2];y=P[j+40>>2];A=P[j+32>>2];B=P[j>>2];C=P[j+16>>2];D=P[j+4>>2];E=P[j+8>>2];L[g+44>>2]=0;L[g+28>>2]=0;P[g+40>>2]=S(y*v)+S(S(E*t)+S(m*x));P[g+36>>2]=S(w*v)+S(S(D*t)+S(m*u));P[g+24>>2]=S(y*l)+S(S(E*q)+S(k*x));P[g+20>>2]=S(w*l)+S(S(D*q)+S(k*u));L[g+12>>2]=0;P[g+32>>2]=S(A*v)+S(S(B*t)+S(m*C));P[g+16>>2]=S(A*l)+S(S(B*q)+S(k*C));P[g+8>>2]=S(y*r)+S(S(E*s)+S(p*x));P[g+4>>2]=S(w*r)+S(S(D*s)+S(p*u));P[g>>2]=S(A*r)+S(S(B*s)+S(p*C));h=g- -64|0;ha[L[L[e>>2]+8>>2]](e,g,h,g+80|0);Sl(d+68|0,h,o);break d}ha[L[L[e>>2]+8>>2]](e,j,g- -64|0,g+80|0);G=ha[L[L[d>>2]+88>>2]](d)|0;if(!G){break d}Z=g+16|0;while(1){G=G-1|0;ha[L[L[d>>2]+120>>2]](d,G,h,g,Z);e:{if(P[g+80>>2]>2]|P[g+64>>2]>P[g+16>>2]|(P[g+84>>2]>2]|P[g+68>>2]>P[g+20>>2])){break e}if(P[g+88>>2]>2]|P[g+72>>2]>P[g+24>>2]){break e}e=L[o+4>>2];f:{if((e|0)!=L[o+8>>2]){break f}W=e?e<<1:1;if((W|0)<=(e|0)){break f}g:{if(!W){z=0;break g}L[8513]=L[8513]+1;z=ha[L[6798]](W<<2,16)|0;e=L[o+4>>2]}n=L[o+12>>2];h:{i:{if((e|0)>0){X=0;j=0;if(e>>>0>=4){_=e&-4;Y=0;while(1){F=j<<2;L[F+z>>2]=L[n+F>>2];V=F|4;L[V+z>>2]=L[n+V>>2];V=F|8;L[V+z>>2]=L[n+V>>2];F=F|12;L[F+z>>2]=L[n+F>>2];j=j+4|0;Y=Y+4|0;if((_|0)!=(Y|0)){continue}break}}e=e&3;if(!e){break i}while(1){F=j<<2;L[F+z>>2]=L[n+F>>2];j=j+1|0;X=X+1|0;if((e|0)!=(X|0)){continue}break}break i}if(!n){break h}}if(n?M[o+16|0]:0){L[8514]=L[8514]+1;ha[L[6799]](n)}e=L[o+4>>2]}L[o+12>>2]=z;J[o+16|0]=1;L[o+8>>2]=W}L[L[o+12>>2]+(e<<2)>>2]=G;L[o+4>>2]=L[o+4>>2]+1}if(G){continue}break}}fa=g+96|0;if(L[i+368>>2]){ha[L[L[d>>2]+112>>2]](d);g=yb(i+72|0);L[i+128>>2]=0;L[i+132>>2]=0;L[i+76>>2]=1;L[i+136>>2]=0;L[i+140>>2]=0;L[i+144>>2]=0;L[i+148>>2]=0;L[i+152>>2]=0;L[i+156>>2]=0;L[i+160>>2]=0;L[i+164>>2]=0;L[i+168>>2]=0;L[i+172>>2]=0;L[g>>2]=2036;o=Re(i+176|0);L[o>>2]=4548;L[i+268>>2]=4;L[i+352>>2]=17472;L[i+344>>2]=17392;L[i+336>>2]=17320;L[i+68>>2]=d;e=i+344|0;j:{if(ha[L[L[d>>2]+96>>2]](d)|0){break j}h=L[i+68>>2];e=i+352|0;if(ha[L[L[h>>2]+100>>2]](h)|0){break j}e=i+336|0}L[i+360>>2]=e;L[e+4>>2]=i+68;h=ha[L[L[d>>2]+92>>2]](d)|0;e=L[i+368>>2];k:{if(!e){break k}e=e-1|0;if(f){while(1){f=e;e=L[L[i+376>>2]+(e<<2)>>2];L[a+32>>2]=e;j=L[i+360>>2];j=ha[L[L[j>>2]>>2]](j,e)|0;if(h){ha[L[L[d>>2]+132>>2]](i+4|0,d,e)}n=L[a+28>>2];z=L[a+24>>2];G=L[b+12>>2];e=L[b+8>>2];L[i+8>>2]=j;L[i+12>>2]=e;L[i+16>>2]=G;L[i+4>>2]=b;L[i+20>>2]=oI(z,n);L[i+24>>2]=ga;n=L[a+16>>2];j=L[n+8>>2];n=((e|0)==L[j+8>>2]?8:12)+n|0;e=i+4|0;L[n>>2]=e;Ig(a,c,e);L[L[a+16>>2]+8>>2]=j;e=f-1|0;if(f){continue}break k}}if(h){while(1){f=L[L[i+376>>2]+(e<<2)>>2];L[a+24>>2]=f;h=L[i+360>>2];j=ha[L[L[h>>2]>>2]](h,f)|0;h=i+4|0;ha[L[L[d>>2]+132>>2]](h,d,f);n=L[a+28>>2];z=L[a+24>>2];G=L[b+12>>2];f=L[b+8>>2];L[i+8>>2]=j;L[i+12>>2]=f;L[i+16>>2]=G;L[i+4>>2]=b;L[i+20>>2]=oI(z,n);L[i+24>>2]=ga;n=L[a+16>>2];j=L[n+8>>2];L[((f|0)==L[j+8>>2]?8:12)+n>>2]=h;Ig(a,h,c);L[L[a+16>>2]+8>>2]=j;f=e;e=e-1|0;if(f){continue}break k}}while(1){f=L[L[i+376>>2]+(e<<2)>>2];L[a+24>>2]=f;h=L[i+360>>2];h=ha[L[L[h>>2]>>2]](h,f)|0;j=L[a+28>>2];n=L[a+24>>2];z=L[b+12>>2];f=L[b+8>>2];L[i+8>>2]=h;L[i+12>>2]=f;L[i+16>>2]=z;L[i+4>>2]=b;L[i+20>>2]=oI(n,j);L[i+24>>2]=ga;j=L[a+16>>2];h=L[j+8>>2];j=((f|0)==L[h+8>>2]?8:12)+j|0;f=i+4|0;L[j>>2]=f;Ig(a,f,c);L[L[a+16>>2]+8>>2]=h;f=e;e=e-1|0;if(f){continue}break}}ha[L[L[d>>2]+116>>2]](d);Oa(o);Oa(g)}a=L[i+376>>2];if(!a|!M[i+380|0]){break a}if(a){L[8514]=L[8514]+1;ha[L[6799]](a)}}fa=i+512|0}function wg(a,b,c,d,e){var f=S(0),g=S(0),h=S(0),i=S(0),j=S(0),k=S(0),l=0,m=S(0),n=S(0),o=S(0),p=S(0),q=S(0),r=S(0),s=S(0),t=S(0),u=S(0),v=S(0),w=S(0),x=S(0),y=S(0),z=S(0),A=S(0),B=S(0),C=S(0),D=S(0),E=S(0),F=S(0),G=S(0),H=S(0),I=S(0),K=S(0),N=S(0),O=S(0),Q=S(0),R=S(0),U=S(0),V=S(0),W=S(0),X=S(0),Y=S(0),Z=S(0),$=S(0),aa=S(0),ba=S(0),ca=S(0),da=S(0),ea=S(0),ga=S(0),ha=S(0),ia=S(0),ja=S(0),ka=S(0),la=S(0),ma=S(0),na=S(0),oa=0,pa=S(0),qa=S(0),ra=S(0),sa=S(0),ta=S(0),ua=S(0),va=S(0),wa=S(0),xa=S(0),ya=S(0),za=S(0),Aa=S(0),Ba=S(0),Ca=S(0),Da=S(0),Ga=S(0),Ha=S(0),Ia=S(0),Ja=S(0),Ka=S(0),La=S(0);l=fa-80|0;fa=l;J[a+525|0]=0;J[a+526|0]=0;L[a+500>>2]=0;L[a+504>>2]=0;a:{if(!(M[a+527|0]|!M[a+552|0])){Ga=P[c+52>>2];Ha=P[c+56>>2];s=P[a+412>>2];q=P[a+416>>2];Q=P[a+420>>2];Ia=P[b+52>>2];Ja=P[b+56>>2];R=P[a+348>>2];U=P[a+352>>2];y=P[a+356>>2];i=P[c+20>>2];n=P[c+24>>2];o=P[b+20>>2];u=P[b+24>>2];v=P[a+308>>2];D=P[a+324>>2];E=P[a+340>>2];O=P[a+316>>2];G=P[a+332>>2];V=P[a+304>>2];p=P[b+36>>2];W=P[a+320>>2];k=P[b+40>>2];X=P[a+336>>2];Y=P[a+372>>2];Z=P[a+388>>2];$=P[a+404>>2];ia=P[a+368>>2];ja=P[a+384>>2];ka=P[a+400>>2];h=P[a+568>>2];j=P[a+564>>2];g=P[a+560>>2];H=P[c+36>>2];la=P[a+380>>2];I=P[c+40>>2];ma=P[a+396>>2];Ka=P[c+48>>2];K=P[c+8>>2];x=P[c+4>>2];r=P[c>>2];La=P[b+48>>2];t=P[b+8>>2];z=P[b>>2];A=P[b+4>>2];C=P[c+16>>2];m=P[b+16>>2];na=P[a+300>>2];w=P[b+32>>2];f=P[a+556>>2];F=P[c+32>>2];ua=P[a+364>>2];L[l+76>>2]=0;L[l+60>>2]=0;L[l+44>>2]=0;pa=S(S(E*k)+S(S(v*w)+S(D*p)));B=S(S(2)/S(S(h*h)+S(S(j*j)+S(S(f*f)+S(g*g)))));aa=S(f*B);ba=S(f*aa);N=S(g*B);ca=S(g*N);va=S(S(1)-S(ba+ca));qa=S(S($*I)+S(S(Y*F)+S(Z*H)));B=S(j*B);da=S(f*B);ea=S(h*N);wa=S(da+ea);ra=S(S(ma*I)+S(S(ua*F)+S(la*H)));ga=S(g*B);ha=S(h*aa);xa=S(ga-ha);g=S(S(ka*I)+S(S(ia*F)+S(ja*H)));aa=S(S(va*qa)+S(S(wa*ra)+S(xa*g)));sa=S(S(G*k)+S(S(na*w)+S(O*p)));ya=S(da-ea);j=S(j*B);za=S(S(1)-S(ca+j));N=S(f*N);B=S(h*B);Aa=S(N+B);f=S(S(ya*qa)+S(S(za*ra)+S(Aa*g)));h=S(S(X*k)+S(S(V*w)+S(W*p)));Ba=S(ga+ha);Ca=S(N-B);Da=S(S(1)-S(ba+j));j=S(S(Ba*qa)+S(S(Ca*ra)+S(Da*g)));P[l+56>>2]=S(pa*aa)+S(S(sa*f)+S(h*j));B=S(S(E*u)+S(S(v*m)+S(D*o)));N=S(S(G*u)+S(S(na*m)+S(O*o)));ba=S(S(X*u)+S(S(V*m)+S(W*o)));P[l+52>>2]=S(B*aa)+S(S(N*f)+S(ba*j));ca=S(S($*n)+S(S(Y*C)+S(Z*i)));da=S(S(ma*n)+S(S(ua*C)+S(la*i)));ea=S(S(ka*n)+S(S(ia*C)+S(ja*i)));ga=S(S(va*ca)+S(S(wa*da)+S(xa*ea)));ha=S(S(ya*ca)+S(S(za*da)+S(Aa*ea)));ta=S(S(Ba*ca)+S(S(Ca*da)+S(Da*ea)));P[l+40>>2]=S(pa*ga)+S(S(sa*ha)+S(h*ta));P[l+36>>2]=S(B*ga)+S(S(N*ha)+S(ba*ta));v=S(S(E*t)+S(S(v*z)+S(A*D)));D=S(-S(La+S(S(y*t)+S(S(R*z)+S(A*U)))));m=S(Ia+S(S(y*u)+S(S(R*m)+S(o*U))));p=S(Ja+S(S(y*k)+S(S(R*w)+S(p*U))));k=S(S(S(v*D)-S(B*m))-S(pa*p));o=S(S(G*t)+S(S(na*z)+S(O*A)));w=S(S(S(o*D)-S(N*m))-S(sa*p));u=S(S(X*t)+S(S(V*z)+S(A*W)));t=S(S(S(u*D)-S(ba*m))-S(h*p));P[l+72>>2]=S(S(k*aa)+S(S(w*f)+S(t*j)))+S(S(S(qa*S(0))+S(S(ra*S(0))+S(g*S(0))))+S(Ha+S(S(Q*I)+S(S(s*F)+S(H*q)))));P[l+68>>2]=S(S(k*ga)+S(S(w*ha)+S(t*ta)))+S(S(S(ca*S(0))+S(S(da*S(0))+S(ea*S(0))))+S(Ga+S(S(Q*n)+S(S(s*C)+S(i*q)))));L[l+28>>2]=0;P[l+48>>2]=S(v*aa)+S(S(o*f)+S(u*j));P[l+32>>2]=S(v*ga)+S(S(o*ha)+S(u*ta));f=S(S($*K)+S(S(Y*r)+S(x*Z)));g=S(S(ma*K)+S(S(ua*r)+S(la*x)));i=S(S(ka*K)+S(S(ia*r)+S(x*ja)));n=S(S(va*f)+S(S(wa*g)+S(xa*i)));p=S(S(ya*f)+S(S(za*g)+S(Aa*i)));m=h;h=S(S(Ba*f)+S(S(Ca*g)+S(Da*i)));P[l+24>>2]=S(pa*n)+S(S(sa*p)+S(m*h));P[l+20>>2]=S(B*n)+S(S(N*p)+S(ba*h));P[l+16>>2]=S(v*n)+S(S(o*p)+S(u*h));P[l+64>>2]=S(S(k*n)+S(S(w*p)+S(t*h)))+S(S(S(f*S(0))+S(S(g*S(0))+S(i*S(0))))+S(Ka+S(S(Q*K)+S(S(s*r)+S(x*q)))));Ma(l+16|0,l);f=P[l+8>>2];h=P[l>>2];g=P[l+4>>2];i=S(S(f*f)+S(S(h*h)+S(g*g)));if(S(T(i))>2]=0;m=f;f=S(S(1)/S(_(i)));P[a+468>>2]=m*f;P[a+464>>2]=g*f;P[a+460>>2]=h*f;f=P[l+12>>2];f=fS(1)?S(1):f);f=S(f+f);P[a+504>>2]=f;if(S(T(f))>2];h=P[l+8>>2];p=P[l+4>>2];k=P[l+20>>2];j=P[l+12>>2];x=P[l+28>>2];r=P[l+16>>2];t=P[l>>2];Ma(c,oa);Ma(a+364|0,l);g=S(-0);C=S(1);z=P[l+16>>2];A=P[l+4>>2];m=P[l+28>>2];w=P[l+8>>2];F=P[l+12>>2];i=P[l+24>>2];s=P[l+20>>2];q=P[l>>2];o=S(S(S(z*A)+S(S(m*w)+S(F*i)))-S(s*q));H=S(S(S(r*p)+S(S(x*h)+S(j*f)))-S(k*t));u=S(S(S(i*q)+S(S(m*A)+S(F*s)))-S(z*w));I=S(S(S(f*t)+S(S(x*p)+S(j*k)))-S(r*h));n=S(S(S(S(m*F)-S(q*z))-S(s*A))-S(i*w));K=S(S(S(S(x*j)-S(t*r))-S(k*p))-S(f*h));x=S(S(S(k*h)+S(S(x*t)+S(r*j)))-S(f*p));p=S(S(S(s*w)+S(S(m*q)+S(z*F)))-S(i*A));t=S(S(o*H)+S(S(u*I)+S(S(n*K)+S(x*p))));h=S(t*S(0));z=S(S(u*x)+S(S(S(n*H)-S(K*o))-S(p*I)));A=S(S(o*I)+S(S(S(n*x)-S(K*p))-S(u*H)));k=S(A*S(0));f=S(S(h+z)-k);r=S(S(p*H)+S(S(S(n*I)-S(K*u))-S(o*x)));h=S(S(h+k)-r);j=S(z*S(-0));k=S(j+S(S(r*S(-0))-A));j=S(j+S(t+S(r*S(0))));m=S(S(f*A)+S(S(S(t*h)-S(k*z))-S(j*r)));q=m;s=S(m*m);m=S(S(h*r)+S(S(S(t*j)-S(k*A))-S(f*z)));f=S(S(j*z)+S(S(S(t*f)-S(k*r))-S(h*A)));h=S(S(1)/S(_(S(s+S(S(m*m)+S(f*f))))));k=S(q*h);j=S(m*h);f=S(f*h);h=S(S(k*S(0))+S(j+S(f*S(0))));if(!(h>2];y=P[a+456>>2];oa=h>=y;j=P[a+448>>2];b:{if(!(!oa|!(y<=j))){g=FS(1)?S(1):g);s=S(g+g);f=S(0);c:{if(!(s>S(1.1920928955078125e-7))){break c}g=S(S(1)/S(_(S(S(m*m)+S(S(w*w)+S(C*C))))));k=S(m*g);i=S(w*g);g=S(C*g);f=h;if(!(S(T(g))>S(1.1920928955078125e-7))){break c}f=S(S(k*k)/S(g*g));f=S(_(S(S(f+S(1))/S(S(S(1)/S(j*j))+S(f/S(h*h))))))}q=P[a+428>>2];y=S(f*q);if(!(y>2]=y;P[a+528>>2]=!(f>s)|!(qS(1.1920928955078125e-7)){f=S(T(S(g*S(S(j/h)*S(S(-k)/g)))));f=k>2]=0;L[a+540>>2]=0;L[a+472>>2]=0;L[a+544>>2]=0;L[a+548>>2]=0;j=S(S(p*k)+S(S(n*S(-g))-S(o*i)));s=S(S(o*g)+S(S(n*S(-i))-S(u*k)));q=S(S(o*k)+S(S(p*i)+S(u*g)));g=S(S(u*i)+S(S(n*S(-k))-S(p*g)));f=S(S(j*p)+S(S(s*R)+S(S(q*Q)+S(n*g))));P[a+468>>2]=f;h=S(S(s*o)+S(S(g*U)+S(S(q*R)+S(n*j))));P[a+464>>2]=h;g=S(S(g*u)+S(S(j*Q)+S(S(q*U)+S(n*s))));P[a+460>>2]=g;P[a+492>>2]=S(1)/S(S(S(f*S(S(f*P[d+40>>2])+S(S(P[d+8>>2]*g)+S(h*P[d+24>>2]))))+S(S(g*S(S(P[d+32>>2]*f)+S(S(g*P[d>>2])+S(P[d+16>>2]*h))))+S(h*S(S(P[d+36>>2]*f)+S(S(P[d+4>>2]*g)+S(h*P[d+20>>2]))))))+S(S(f*S(S(f*P[e+40>>2])+S(S(P[e+8>>2]*g)+S(h*P[e+24>>2]))))+S(S(g*S(S(P[e+32>>2]*f)+S(S(g*P[e>>2])+S(h*P[e+16>>2]))))+S(h*S(S(P[e+36>>2]*f)+S(S(P[e+4>>2]*g)+S(h*P[e+20>>2])))))));break b}f=P[a+396>>2];g=P[a+364>>2];i=P[a+380>>2];k=S(S(P[c+40>>2]*f)+S(S(P[c+32>>2]*g)+S(i*P[c+36>>2])));v=P[b+40>>2];q=P[a+340>>2];D=P[b+32>>2];E=P[a+308>>2];O=P[b+36>>2];G=P[a+324>>2];ia=S(S(v*q)+S(S(D*E)+S(O*G)));s=S(S(P[c+8>>2]*f)+S(S(P[c>>2]*g)+S(i*P[c+4>>2])));V=P[b+8>>2];W=P[b>>2];X=P[b+4>>2];ja=S(S(V*q)+S(S(W*E)+S(X*G)));Y=P[b+24>>2];Z=P[b+16>>2];B=S(Z*E);E=P[b+20>>2];ka=S(S(Y*q)+S(B+S(E*G)));q=S(S(P[c+24>>2]*f)+S(S(P[c+16>>2]*g)+S(i*P[c+20>>2])));g=S(S(k*ia)+S(S(s*ja)+S(ka*q)));f=P[a+336>>2];i=P[a+304>>2];G=P[a+320>>2];la=S(S(v*f)+S(S(D*i)+S(O*G)));ma=S(S(V*f)+S(S(W*i)+S(X*G)));na=S(S(Y*f)+S(S(Z*i)+S(E*G)));f=S(S(k*la)+S(S(s*ma)+S(na*q)));i=P[a+332>>2];G=P[a+300>>2];$=P[a+316>>2];v=S(S(v*i)+S(S(D*G)+S($*O)));D=S(S(Y*i)+S(S(Z*G)+S($*E)));E=S(S(V*i)+S(S(W*G)+S($*X)));b=h>2]=0;P[a+468>>2]=-S(S(s*D)-S(E*q));P[a+464>>2]=-S(S(k*E)-S(v*s));P[a+460>>2]=-S(S(q*v)-S(D*k));break b}i=S(S(k*v)+S(S(s*E)+S(D*q)));O=S(T(i));d:{if(b){if(O=y)){break d}h=Za(g,i);if(h>j){f=S(0);g=Ea(j);i=Fa(j);break d}f=S(0);if(!(hh){g=S(0);f=Ea(h);break e}g=S(0);if(!(j>2]=0;h=S(S(g*ia)+S(S(i*v)+S(la*f)));j=S(S(g*ja)+S(S(i*E)+S(ma*f)));g=S(S(g*ka)+S(S(i*D)+S(na*f)));f=S(S(1)/S(_(S(S(h*h)+S(S(j*j)+S(g*g))))));i=S(g*f);j=S(j*f);g=S(S(s*i)-S(j*q));h=S(h*f);f=S(S(q*h)-S(i*k));h=S(S(k*j)-S(h*s));i=S(_(S(S(g*g)+S(S(f*f)+S(h*h)))));P[a+504>>2]=i;i=S(S(1)/i);P[a+468>>2]=i*S(-g);P[a+464>>2]=i*S(-h);P[a+460>>2]=i*S(-f)}k=P[a+452>>2];if(k>=S(0)){j=S(S(m*z)+S(S(C*r)+S(S(F*t)+S(A*w))));f=S(S(C*A)+S(S(S(F*z)-S(t*m))-S(w*r)));g=S(S(m*r)+S(S(S(F*A)-S(t*w))-S(C*z)));h=S(S(w*z)+S(S(S(F*r)-S(t*C))-S(m*A)));i=S(S(1)/S(_(S(S(j*j)+S(S(f*f)+S(S(g*g)+S(h*h)))))));f=S(f*i);h=S(h*i);g=S(g*i);j=S(j*i);i=jS(1)?S(1):i);i=S(i+i);if(i>S(3.1415927410125732)){i=j>S(1)?S(-1):S(-j);i=ob(i>S(1)?S(1):i);i=S(i+i);h=S(-h);g=S(-g);f=S(-f)}P[a+512>>2]=i;if(i>S(1.1920928955078125e-7)){j=S(S(1)/S(_(S(S(f*f)+S(S(g*g)+S(h*h))))));f=S(f*j);g=S(g*j);h=S(h*j)}r=P[a+428>>2];j=S(k*r);if(j>2]=t;m=S(1);f:{if(!(i>2]=m;L[a+488>>2]=0;k=S(S(p*f)+S(S(n*S(-h))-S(o*g)));m=S(k*p);j=S(S(o*h)+S(S(n*S(-g))-S(u*f)));r=S(S(o*f)+S(S(p*g)+S(u*h)));p=S(S(u*g)+S(S(n*S(-f))-S(p*h)));i=S(m+S(S(j*R)+S(S(r*Q)+S(n*p))));P[a+484>>2]=i;o=S(S(j*o)+S(S(p*U)+S(S(r*R)+S(n*k))));P[a+480>>2]=o;n=S(S(p*u)+S(S(k*Q)+S(S(r*U)+S(n*j))));P[a+476>>2]=n;P[a+496>>2]=S(1)/S(S(S(i*S(S(i*P[d+40>>2])+S(S(P[d+8>>2]*n)+S(o*P[d+24>>2]))))+S(S(n*S(S(P[d+32>>2]*i)+S(S(n*P[d>>2])+S(P[d+16>>2]*o))))+S(o*S(S(P[d+36>>2]*i)+S(S(P[d+4>>2]*n)+S(o*P[d+20>>2]))))))+S(S(i*S(S(i*P[e+40>>2])+S(S(P[e+8>>2]*n)+S(o*P[e+24>>2]))))+S(S(n*S(S(P[e+32>>2]*i)+S(S(n*P[e>>2])+S(o*P[e+16>>2]))))+S(o*S(S(P[e+36>>2]*i)+S(S(P[e+4>>2]*n)+S(o*P[e+20>>2])))))))}if(!M[a+526|0]){break a}L[a+548>>2]=0;i=S(S(x*f)+S(S(K*S(-h))-S(H*g)));n=S(S(I*g)+S(S(K*S(-f))-S(x*h)));o=S(S(H*f)+S(S(x*g)+S(I*h)));f=S(S(H*h)+S(S(K*S(-g))-S(I*f)));P[a+544>>2]=S(i*x)+S(S(S(K*n)-S(o*H))-S(f*I));P[a+540>>2]=S(f*H)+S(S(S(K*i)-S(o*I))-S(n*x));P[a+536>>2]=S(n*I)+S(S(S(K*f)-S(o*x))-S(i*H));break a}L[a+512>>2]=0}fa=l+80|0}function Al(a){var b=0,c=0,d=0,e=S(0),f=S(0),g=0,h=S(0),i=S(0),j=S(0),k=0,l=S(0),m=S(0),n=S(0),o=S(0),p=S(0),q=S(0),r=S(0),s=0,t=S(0),u=S(0),v=S(0),w=S(0),x=S(0),y=S(0),z=0,A=0,B=0,C=S(0),D=S(0),E=0,F=S(0),G=S(0),H=S(0),I=S(0),K=S(0),N=S(0),O=S(0),Q=S(0),R=S(0),T=S(0),U=S(0),V=0,W=0,X=0,Y=0,Z=S(0),_=S(0),$=0;k=fa-16|0;fa=k;a:{if(!M[a+356|0]){c=M[a+312|0];break a}J[a+356|0]=0;J[a+352|0]=0;L[a+344>>2]=0;L[a+348>>2]=0;L[a+336>>2]=0;L[a+340>>2]=0;d=M[a+332|0]&-16;J[a+332|0]=d;b=a+316|0;b:{c:{switch(L[a>>2]-1|0){case 0:c=L[a+168>>2];L[a+260>>2]=L[a+164>>2];L[a+264>>2]=c;c=L[a+88>>2];L[a+244>>2]=L[a+84>>2];L[a+248>>2]=c;c=L[a+176>>2];L[a+268>>2]=L[a+172>>2];L[a+272>>2]=c;c=L[a+96>>2];L[a+252>>2]=L[a+92>>2];L[a+256>>2]=c;J[a+352|0]=0;L[a+288>>2]=0;P[a+280>>2]=P[a+248>>2]-P[a+264>>2];P[a+276>>2]=P[a+244>>2]-P[a+260>>2];P[a+284>>2]=P[a+252>>2]-P[a+268>>2];L[a+344>>2]=0;L[a+348>>2]=0;L[a+336>>2]=1065353216;L[a+340>>2]=0;c=1;break b;case 1:g=1;j=P[a+8>>2];e=S(P[a+24>>2]-j);i=P[a+12>>2];h=S(P[a+28>>2]-i);m=S(h*S(S(0)-i));l=P[a+4>>2];i=S(P[a+20>>2]-l);j=S(m+S(S(i*S(S(0)-l))+S(S(S(0)-j)*e)));b=j>S(0);c=1;d:{if(!b){break d}f=S(S(h*h)+S(S(i*i)+S(e*e)));if(!(f>j)){f=S(1);c=2;break d}f=S(j/f);c=3}L[a+344>>2]=0;L[a+348>>2]=0;P[a+340>>2]=f;j=S(S(1)-f);P[a+336>>2]=j;J[a+332|0]=d|c;L[a+256>>2]=0;e=P[a+92>>2];l=S(e+S(f*S(P[a+108>>2]-e)));P[a+252>>2]=l;e=P[a+88>>2];n=S(e+S(f*S(P[a+104>>2]-e)));P[a+248>>2]=n;e=P[a+84>>2];o=S(e+S(f*S(P[a+100>>2]-e)));P[a+244>>2]=o;m=P[a+180>>2];q=P[a+184>>2];e=P[a+168>>2];r=P[a+188>>2];h=P[a+172>>2];i=P[a+164>>2];L[a+288>>2]=0;h=S(h+S(f*S(r-h)));P[a+284>>2]=l-h;e=S(e+S(f*S(q-e)));P[a+280>>2]=n-e;i=S(i+S(f*S(m-i)));P[a+276>>2]=o-i;L[a+272>>2]=0;P[a+268>>2]=h;P[a+264>>2]=e;P[a+260>>2]=i;if(!b){L[a>>2]=1;g=0}if(!(c&1)){L[a>>2]=g;c=(g<<4)+a|0;b=L[c+16>>2];L[a+12>>2]=L[c+12>>2];L[a+16>>2]=b;b=L[c+8>>2];L[a+4>>2]=L[c+4>>2];L[a+8>>2]=b;b=L[c+96>>2];L[a+92>>2]=L[c+92>>2];L[a+96>>2]=b;b=L[c+88>>2];L[a+84>>2]=L[c+84>>2];L[a+88>>2]=b;b=L[c+176>>2];L[a+172>>2]=L[c+172>>2];L[a+176>>2]=b;b=L[c+168>>2];L[a+164>>2]=L[c+164>>2];L[a+168>>2]=b}c=j>=S(0)&f>=S(0);break b;case 2:L[k+8>>2]=0;L[k+12>>2]=0;L[k>>2]=0;L[k+4>>2]=0;sd(k,a+4|0,a+20|0,a+36|0,b);L[a+256>>2]=0;f=P[a+336>>2];e=P[a+340>>2];h=P[a+344>>2];i=S(S(S(f*P[a+92>>2])+S(e*P[a+108>>2]))+S(h*P[a+124>>2]));P[a+252>>2]=i;j=S(S(S(f*P[a+88>>2])+S(e*P[a+104>>2]))+S(h*P[a+120>>2]));P[a+248>>2]=j;l=S(S(S(f*P[a+84>>2])+S(e*P[a+100>>2]))+S(h*P[a+116>>2]));P[a+244>>2]=l;n=P[a+180>>2];o=P[a+196>>2];m=P[a+168>>2];q=P[a+184>>2];r=P[a+200>>2];u=P[a+172>>2];v=P[a+188>>2];w=P[a+204>>2];x=P[a+164>>2];L[a+288>>2]=0;p=i;i=S(S(S(f*u)+S(e*v))+S(h*w));P[a+284>>2]=p-i;p=j;j=S(S(S(f*m)+S(e*q))+S(h*r));P[a+280>>2]=p-j;m=l;l=S(S(S(f*x)+S(e*n))+S(h*o));P[a+276>>2]=m-l;L[a+272>>2]=0;P[a+268>>2]=i;P[a+264>>2]=j;P[a+260>>2]=l;e:{f:{g:{h:{i:{b=L[a>>2];j:{if((b|0)>=4){g=M[a+332|0];if(g&8){c=b;break j}c=b-1|0;L[a>>2]=c;b=(c<<4)+a|0;d=L[b+16>>2];L[a+60>>2]=L[b+12>>2];L[a+64>>2]=d;d=L[b+8>>2];L[a+52>>2]=L[b+4>>2];L[a+56>>2]=d;d=L[b+88>>2];L[a+132>>2]=L[b+84>>2];L[a+136>>2]=d;d=L[b+96>>2];L[a+140>>2]=L[b+92>>2];L[a+144>>2]=d;d=L[b+176>>2];L[a+220>>2]=L[b+172>>2];L[a+224>>2]=d;d=L[b+168>>2];L[a+212>>2]=L[b+164>>2];L[a+216>>2]=d;break j}c=3;if((b|0)!=3){break i}g=M[a+332|0]}if(g&4){break h}c=c-1|0;L[a>>2]=c;b=(c<<4)+a|0;d=L[b+16>>2];L[a+44>>2]=L[b+12>>2];L[a+48>>2]=d;d=L[b+8>>2];L[a+36>>2]=L[b+4>>2];L[a+40>>2]=d;d=L[b+96>>2];L[a+124>>2]=L[b+92>>2];L[a+128>>2]=d;d=L[b+88>>2];L[a+116>>2]=L[b+84>>2];L[a+120>>2]=d;d=L[b+176>>2];L[a+204>>2]=L[b+172>>2];L[a+208>>2]=d;d=L[b+168>>2];L[a+196>>2]=L[b+164>>2];L[a+200>>2]=d;break h}c=2;if((b|0)<2){break g}g=M[a+332|0]}if(g&2){break f}c=c-1|0;L[a>>2]=c;b=(c<<4)+a|0;d=L[b+16>>2];L[a+28>>2]=L[b+12>>2];L[a+32>>2]=d;d=L[b+8>>2];L[a+20>>2]=L[b+4>>2];L[a+24>>2]=d;d=L[b+96>>2];L[a+108>>2]=L[b+92>>2];L[a+112>>2]=d;d=L[b+88>>2];L[a+100>>2]=L[b+84>>2];L[a+104>>2]=d;d=L[b+176>>2];L[a+188>>2]=L[b+172>>2];L[a+192>>2]=d;d=L[b+168>>2];L[a+180>>2]=L[b+164>>2];L[a+184>>2]=d;break f}c=1;if((b|0)!=1){break e}g=M[a+332|0]}if(g&1){break e}c=c-1|0;L[a>>2]=c;c=(c<<4)+a|0;b=L[c+16>>2];L[a+12>>2]=L[c+12>>2];L[a+16>>2]=b;b=L[c+8>>2];L[a+4>>2]=L[c+4>>2];L[a+8>>2]=b;b=L[c+96>>2];L[a+92>>2]=L[c+92>>2];L[a+96>>2]=b;b=L[c+88>>2];L[a+84>>2]=L[c+84>>2];L[a+88>>2]=b;b=L[c+176>>2];L[a+172>>2]=L[c+172>>2];L[a+176>>2]=b;b=L[c+168>>2];L[a+164>>2]=L[c+164>>2];L[a+168>>2]=b}c=0;if(!(h>=S(0))|(!(f>=S(0))|!(e>=S(0)))){break b}c=P[a+348>>2]>=S(0);break b;case 3:break c;default:break b}}L[k+8>>2]=0;L[k+12>>2]=0;L[k>>2]=0;L[k+4>>2]=0;g=fa-48|0;fa=g;J[g+24|0]=0;d=L[k+12>>2];L[b+8>>2]=L[k+8>>2];L[b+12>>2]=d;d=L[k+4>>2];L[b>>2]=L[k>>2];L[b+4>>2]=d;s=M[b+16|0];J[b+16|0]=s|15;O=P[k+8>>2];d=a+4|0;f=P[d+8>>2];Q=S(O-f);z=a+36|0;p=P[z+8>>2];e=S(p-f);A=a+52|0;t=P[A>>2];h=P[d>>2];i=S(t-h);B=a+20|0;j=P[B+4>>2];l=P[d+4>>2];n=S(j-l);o=P[B>>2];m=S(o-h);F=P[A+4>>2];q=S(F-l);C=S(S(i*n)-S(m*q));G=P[z>>2];r=S(G-h);u=P[B+8>>2];v=S(u-f);U=P[A+8>>2];w=S(U-f);D=S(S(q*v)-S(n*w));H=P[z+4>>2];x=S(H-l);I=S(S(w*m)-S(v*i));y=S(S(e*C)+S(S(r*D)+S(x*I)));K=S(Q*C);C=P[k>>2];R=S(C-h);N=S(R*D);D=P[k+4>>2];T=S(D-l);V=S(y*y)>2];e=S(h-O);f=S(e*e);i=P[g+8>>2];e=S(i-C);l=S(e*e);j=P[g+12>>2];e=S(j-D);e=S(f+S(l+S(e*e)));f=S(34028234663852886e22);if(!(e>2]=P[g+20>>2];P[b+8>>2]=h;P[b+4>>2]=j;P[b>>2]=i;J[b+16|0]=M[g+24|0]&7|s&-16;f=P[g+36>>2];s=L[g+32>>2];E=L[g+28>>2];L[b+32>>2]=0;P[b+28>>2]=f;L[b+20>>2]=E;L[b+24>>2]=s;f=e}m:{if(!W){break m}sd(k,d,z,A,g+8|0);h=P[g+16>>2];e=S(h-P[k+8>>2]);l=S(e*e);i=P[g+8>>2];e=S(i-P[k>>2]);m=S(e*e);j=P[g+12>>2];e=S(j-P[k+4>>2]);e=S(l+S(m+S(e*e)));if(!(e>2]=P[g+20>>2];P[b+8>>2]=h;P[b+4>>2]=j;P[b>>2]=i;s=M[g+24|0];J[b+16|0]=M[b+16|0]&240|(s&1|s<<1&12);s=L[g+36>>2];E=L[g+32>>2];f=P[g+28>>2];L[b+24>>2]=0;L[b+28>>2]=E;L[b+32>>2]=s;P[b+20>>2]=f;f=e}n:{if(!V){break n}sd(k,d,A,B,g+8|0);h=P[g+16>>2];e=S(h-P[k+8>>2]);l=S(e*e);i=P[g+8>>2];e=S(i-P[k>>2]);m=S(e*e);j=P[g+12>>2];e=S(j-P[k+4>>2]);e=S(l+S(m+S(e*e)));if(!(e>2]=P[g+20>>2];P[b+8>>2]=h;P[b+4>>2]=j;P[b>>2]=i;d=M[g+24|0];J[b+16|0]=M[b+16|0]&240|(d&1|d>>>1&2|d<<2&8);f=P[g+36>>2];h=P[g+28>>2];P[b+32>>2]=P[g+32>>2];L[b+28>>2]=0;P[b+24>>2]=f;P[b+20>>2]=h;f=e}$=1;if(!X){break k}sd(k,B,A,z,g+8|0);j=f;f=P[g+16>>2];e=S(f-P[k+8>>2]);l=S(e*e);e=P[g+8>>2];h=S(e-P[k>>2]);m=S(h*h);h=P[g+12>>2];i=S(h-P[k+4>>2]);if(!(j>S(l+S(m+S(i*i))))){break k}P[b+12>>2]=P[g+20>>2];P[b+8>>2]=f;P[b+4>>2]=h;P[b>>2]=e;d=M[g+24|0];J[b+16|0]=M[b+16|0]&240|(d&4|d<<1&2|d<<2&8);f=P[g+36>>2];e=P[g+28>>2];P[b+32>>2]=P[g+32>>2];P[b+28>>2]=f;P[b+24>>2]=e;L[b+20>>2]=0}fa=g+48|0;if($){L[a+256>>2]=0;e=P[a+336>>2];h=P[a+340>>2];i=P[a+344>>2];f=P[a+348>>2];j=S(S(S(S(e*P[a+92>>2])+S(h*P[a+108>>2]))+S(i*P[a+124>>2]))+S(f*P[a+140>>2]));P[a+252>>2]=j;l=S(S(S(S(e*P[a+88>>2])+S(h*P[a+104>>2]))+S(i*P[a+120>>2]))+S(f*P[a+136>>2]));P[a+248>>2]=l;n=S(S(S(S(e*P[a+84>>2])+S(h*P[a+100>>2]))+S(i*P[a+116>>2]))+S(f*P[a+132>>2]));P[a+244>>2]=n;L[a+288>>2]=0;L[a+272>>2]=0;o=S(S(S(S(e*P[a+164>>2])+S(h*P[a+180>>2]))+S(i*P[a+196>>2]))+S(f*P[a+212>>2]));P[a+260>>2]=o;m=S(S(S(S(e*P[a+168>>2])+S(h*P[a+184>>2]))+S(i*P[a+200>>2]))+S(f*P[a+216>>2]));P[a+264>>2]=m;e=S(S(S(S(e*P[a+172>>2])+S(h*P[a+188>>2]))+S(i*P[a+204>>2]))+S(f*P[a+220>>2]));P[a+268>>2]=e;P[a+276>>2]=n-o;P[a+280>>2]=l-m;P[a+284>>2]=j-e;o:{p:{q:{r:{s:{b=L[a>>2];t:{if((b|0)>=4){g=M[a+332|0];if(g&8){c=b;break t}c=b-1|0;L[a>>2]=c;b=(c<<4)+a|0;d=L[b+16>>2];L[a+60>>2]=L[b+12>>2];L[a+64>>2]=d;d=L[b+8>>2];L[a+52>>2]=L[b+4>>2];L[a+56>>2]=d;d=L[b+96>>2];L[a+140>>2]=L[b+92>>2];L[a+144>>2]=d;d=L[b+88>>2];L[a+132>>2]=L[b+84>>2];L[a+136>>2]=d;d=L[b+176>>2];L[a+220>>2]=L[b+172>>2];L[a+224>>2]=d;d=L[b+168>>2];L[a+212>>2]=L[b+164>>2];L[a+216>>2]=d;break t}c=3;if((b|0)!=3){break s}g=M[a+332|0]}if(g&4){break r}c=c-1|0;L[a>>2]=c;b=(c<<4)+a|0;d=L[b+16>>2];L[a+44>>2]=L[b+12>>2];L[a+48>>2]=d;d=L[b+8>>2];L[a+36>>2]=L[b+4>>2];L[a+40>>2]=d;d=L[b+96>>2];L[a+124>>2]=L[b+92>>2];L[a+128>>2]=d;d=L[b+88>>2];L[a+116>>2]=L[b+84>>2];L[a+120>>2]=d;d=L[b+176>>2];L[a+204>>2]=L[b+172>>2];L[a+208>>2]=d;d=L[b+168>>2];L[a+196>>2]=L[b+164>>2];L[a+200>>2]=d;break r}c=2;if((b|0)<2){break q}g=M[a+332|0]}if(g&2){break p}c=c-1|0;L[a>>2]=c;b=(c<<4)+a|0;d=L[b+16>>2];L[a+28>>2]=L[b+12>>2];L[a+32>>2]=d;d=L[b+8>>2];L[a+20>>2]=L[b+4>>2];L[a+24>>2]=d;d=L[b+96>>2];L[a+108>>2]=L[b+92>>2];L[a+112>>2]=d;d=L[b+88>>2];L[a+100>>2]=L[b+84>>2];L[a+104>>2]=d;d=L[b+176>>2];L[a+188>>2]=L[b+172>>2];L[a+192>>2]=d;d=L[b+168>>2];L[a+180>>2]=L[b+164>>2];L[a+184>>2]=d;break p}c=1;if((b|0)!=1){break o}g=M[a+332|0]}if(g&1){break o}c=c-1|0;L[a>>2]=c;c=(c<<4)+a|0;b=L[c+16>>2];L[a+12>>2]=L[c+12>>2];L[a+16>>2]=b;b=L[c+8>>2];L[a+4>>2]=L[c+4>>2];L[a+8>>2]=b;b=L[c+96>>2];L[a+92>>2]=L[c+92>>2];L[a+96>>2]=b;b=L[c+88>>2];L[a+84>>2]=L[c+84>>2];L[a+88>>2]=b;b=L[c+176>>2];L[a+172>>2]=L[c+172>>2];L[a+176>>2]=b;b=L[c+168>>2];L[a+164>>2]=L[c+164>>2];L[a+168>>2]=b}c=P[a+336>>2]>=S(0)&P[a+340>>2]>=S(0)&P[a+344>>2]>=S(0)&f>=S(0);break b}if(M[a+352|0]){break b}L[a+276>>2]=0;L[a+280>>2]=0;c=1;J[a+312|0]=1;L[a+284>>2]=0;L[a+288>>2]=0;break a}J[a+312|0]=c}fa=k+16|0;return(c&255)!=0}function dm(a){var b=0,c=0,d=0,e=0,f=0,g=0,h=0,i=S(0),j=0,k=0,l=S(0),m=0,n=0,o=S(0),p=0,q=S(0),r=0,s=0,t=S(0),u=0,v=0,w=S(0),x=S(0),y=0,z=S(0),A=S(0),B=0,C=S(0),D=0,E=0,F=0,G=S(0),H=0,I=S(0),Q=S(0),U=S(0),V=S(0),W=S(0),X=S(0),Y=S(0),Z=S(0),$=S(0);g=fa-96|0;fa=g;J[g+52|0]=1;L[g+48>>2]=0;J[g+72|0]=1;L[g+40>>2]=0;L[g+44>>2]=0;L[g+68>>2]=0;J[g+92|0]=1;L[g+60>>2]=0;L[g+64>>2]=0;L[g+88>>2]=0;L[g+80>>2]=0;L[g+84>>2]=0;L[g+28>>2]=0;J[g+32|0]=1;L[g+20>>2]=0;L[g+24>>2]=0;L[a+72>>2]=0;L[a+76>>2]=0;L[a+64>>2]=0;L[a+68>>2]=0;a:{b:{j=L[a+28>>2];if((j|0)>0){while(1){D=R(B,36);E=L[(D+L[a+36>>2]|0)+4>>2];if((E|0)>0){F=0;while(1){b=L[(L[a+36>>2]+D|0)+12>>2];e=L[b+(F<<2)>>2];F=F+1|0;H=(E|0)==(F|0);b=L[b+((H?0:F)<<2)>>2];K[g+14>>1]=b;K[g+12>>1]=e;c=e<<16>>16;d=b<<16>>16;if((c|0)<(d|0)){K[g+14>>1]=e;K[g+12>>1]=b;c=b;d=e}v=d<<16>>16;j=0;n=c<<16>>16;b=n+(d<<16)&L[g+64>>2]-1;c:{if(b>>>0>=O[g+20>>2]){break c}b=L[L[g+28>>2]+(b<<2)>>2];if((b|0)==-1){break c}h=L[g+48>>2];e=L[g+88>>2];while(1){k=b<<2;b=k+e|0;if(!(N[b>>1]==(c&65535)&N[b+2>>1]==(d&65535))){b=L[h+k>>2];if((b|0)!=-1){continue}break c}break}j=k+L[g+68>>2]|0}b=L[a+16>>2];e=b+(v<<4)|0;b=b+(n<<4)|0;i=S(P[e+8>>2]-P[b+8>>2]);G=i;q=S(P[e>>2]-P[b>>2]);o=S(P[e+4>>2]-P[b+4>>2]);i=S(S(1)/S(_(S(S(i*i)+S(S(q*q)+S(o*o))))));w=S(G*i);x=S(o*i);l=S(q*i);c=L[a+48>>2];d:{if((c|0)>0){e=L[a+56>>2];b=0;while(1){d=e+(b<<4)|0;q=P[d+8>>2];i=P[d>>2];o=P[d+4>>2];if(!(+S(T(S(i-l)))>1e-6|+S(T(S(o-x)))>1e-6|+S(T(S(q-w)))>1e-6)|!(+S(T(S(l+i)))>1e-6|+S(T(S(x+o)))>1e-6|+S(T(S(w+q)))>1e-6)){break d}b=b+1|0;if((b|0)!=(c|0)){continue}break}}e:{if(L[a+52>>2]!=(c|0)){break e}r=c?c<<1:1;if((r|0)<=(c|0)){break e}f:{if(!r){d=0;break f}L[8513]=L[8513]+1;d=ha[L[6798]](r<<4,16)|0;c=L[a+48>>2]}g:{if((c|0)<=0){break g}v=c&1;b=0;if((c|0)!=1){n=c&-2;c=0;while(1){k=b<<4;h=k+d|0;p=k+L[a+56>>2]|0;e=L[p+4>>2];L[h>>2]=L[p>>2];L[h+4>>2]=e;e=L[p+12>>2];L[h+8>>2]=L[p+8>>2];L[h+12>>2]=e;e=k|16;h=e+d|0;k=e+L[a+56>>2]|0;e=L[k+4>>2];L[h>>2]=L[k>>2];L[h+4>>2]=e;e=L[k+12>>2];L[h+8>>2]=L[k+8>>2];L[h+12>>2]=e;b=b+2|0;c=c+2|0;if((n|0)!=(c|0)){continue}break}}if(!v){break g}b=b<<4;c=b+d|0;e=b+L[a+56>>2]|0;b=L[e+4>>2];L[c>>2]=L[e>>2];L[c+4>>2]=b;b=L[e+12>>2];L[c+8>>2]=L[e+8>>2];L[c+12>>2]=b}b=L[a+56>>2];if(!(b?!b|!M[a+60|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+56>>2]=d;J[a+60|0]=1;L[a+52>>2]=r;c=L[a+48>>2]}b=L[a+56>>2]+(c<<4)|0;L[b+12>>2]=0;P[b+8>>2]=w;P[b+4>>2]=x;P[b>>2]=l;L[a+48>>2]=L[a+48>>2]+1}h:{if(j){K[j+2>>1]=B;if(H){break h}continue}K[g+8>>1]=B;K[g+10>>1]=65535;i:{j:{d=K[g+12>>1];k=N[g+14>>1];f=g+16|0;e=L[f+48>>2];y=d+(k<<16)&e-1;k:{if(y>>>0>=O[f+4>>2]){break k}b=L[L[f+12>>2]+(y<<2)>>2];if((b|0)==-1){break k}v=L[f+32>>2];n=L[f+72>>2];h=d&65535;while(1){c=b<<2;d=c+n|0;if((h|0)==N[d>>1]&(k|0)==N[d+2>>1]){break j}b=L[c+v>>2];if((b|0)!=-1){continue}break}}v=L[f+44>>2];b=v;l:{if((e|0)!=(b|0)){break l}b=e;p=b?b<<1:1;if((b|0)>=(p|0)){break l}m:{if(!p){m=0;d=e;break m}L[8513]=L[8513]+1;m=ha[L[6798]](p<<2,16)|0;d=L[f+44>>2]}n:{if((d|0)<=0){break n}r=0;b=0;if(d>>>0>=4){n=d&-4;j=0;while(1){k=b<<2;h=k+m|0;c=k+L[f+52>>2]|0;c=N[c>>1]|N[c+2>>1]<<16;K[h>>1]=c;K[h+2>>1]=c>>>16;c=k|4;h=c+m|0;c=c+L[f+52>>2]|0;c=N[c>>1]|N[c+2>>1]<<16;K[h>>1]=c;K[h+2>>1]=c>>>16;c=k|8;h=c+m|0;c=c+L[f+52>>2]|0;c=N[c>>1]|N[c+2>>1]<<16;K[h>>1]=c;K[h+2>>1]=c>>>16;c=k|12;h=c+m|0;c=c+L[f+52>>2]|0;c=N[c>>1]|N[c+2>>1]<<16;K[h>>1]=c;K[h+2>>1]=c>>>16;b=b+4|0;j=j+4|0;if((n|0)!=(j|0)){continue}break}}h=d&3;if(!h){break n}while(1){d=b<<2;c=d+m|0;d=d+L[f+52>>2]|0;d=N[d>>1]|N[d+2>>1]<<16;K[c>>1]=d;K[c+2>>1]=d>>>16;b=b+1|0;r=r+1|0;if((h|0)!=(r|0)){continue}break}}b=L[f+52>>2];if(!(b?!b|!M[f+56|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[f+52>>2]=m;J[f+56|0]=1;L[f+48>>2]=p;b=L[f+44>>2]}d=L[f+52>>2]+(b<<2)|0;b=N[g+8>>1]|N[g+10>>1]<<16;K[d>>1]=b;K[d+2>>1]=b>>>16;L[f+44>>2]=L[f+44>>2]+1;p=L[f- -64>>2];o:{if((p|0)!=L[f+68>>2]){break o}n=p?p<<1:1;if((n|0)<=(p|0)){break o}p:{if(!n){m=0;break p}L[8513]=L[8513]+1;m=ha[L[6798]](n<<2,16)|0;p=L[f+64>>2]}q:{if((p|0)<=0){break q}r=0;b=0;if(p>>>0>=4){h=p&-4;j=0;while(1){k=b<<2;c=k+m|0;d=k+L[f+72>>2]|0;d=N[d>>1]|N[d+2>>1]<<16;K[c>>1]=d;K[c+2>>1]=d>>>16;d=k|4;c=d+m|0;d=d+L[f+72>>2]|0;d=N[d>>1]|N[d+2>>1]<<16;K[c>>1]=d;K[c+2>>1]=d>>>16;d=k|8;c=d+m|0;d=d+L[f+72>>2]|0;d=N[d>>1]|N[d+2>>1]<<16;K[c>>1]=d;K[c+2>>1]=d>>>16;d=k|12;c=d+m|0;d=d+L[f+72>>2]|0;d=N[d>>1]|N[d+2>>1]<<16;K[c>>1]=d;K[c+2>>1]=d>>>16;b=b+4|0;j=j+4|0;if((h|0)!=(j|0)){continue}break}}h=p&3;if(!h){break q}while(1){d=b<<2;c=d+m|0;d=d+L[f+72>>2]|0;d=N[d>>1]|N[d+2>>1]<<16;K[c>>1]=d;K[c+2>>1]=d>>>16;b=b+1|0;r=r+1|0;if((h|0)!=(r|0)){continue}break}}b=L[f+72>>2];if(!(b?!b|!M[f+76|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[f+72>>2]=m;J[f+76|0]=1;L[f+68>>2]=n;p=L[f+64>>2]}d=L[f+72>>2]+(p<<2)|0;b=N[g+12>>1]|N[g+14>>1]<<16;K[d>>1]=b;K[d+2>>1]=b>>>16;L[f+64>>2]=L[f+64>>2]+1;if((e|0)>2]){j=0;m=0;p=0;y=0;d=L[f+4>>2];u=L[f+48>>2];r:{if((d|0)>=(u|0)){break r}s:{if((u|0)<=L[f+8>>2]){j=L[f+12>>2];break s}if(u){L[8513]=L[8513]+1;j=ha[L[6798]](u<<2,16)|0;b=L[f+4>>2]}else{b=d}n=L[f+12>>2];t:{u:{if((b|0)>0){if(b>>>0>=4){c=b&-4;while(1){h=m<<2;L[h+j>>2]=L[h+n>>2];e=h|4;L[e+j>>2]=L[e+n>>2];e=h|8;L[e+j>>2]=L[e+n>>2];e=h|12;L[e+j>>2]=L[e+n>>2];m=m+4|0;p=p+4|0;if((c|0)!=(p|0)){continue}break}}e=b&3;if(!e){break u}while(1){b=m<<2;L[b+j>>2]=L[b+n>>2];m=m+1|0;y=y+1|0;if((e|0)!=(y|0)){continue}break}break u}if(n){break u}break t}if(n?M[f+16|0]:0){L[8514]=L[8514]+1;ha[L[6799]](n)}}L[f+12>>2]=j;J[f+16|0]=1;L[f+8>>2]=u}b=d<<2;k=u<<2;pa(b+j|0,0,k-b|0);L[f+4>>2]=u;e=L[f+24>>2];if((e|0)<(u|0)){v:{if((u|0)<=L[f+28>>2]){j=L[f+32>>2];break v}w:{if(!u){j=0;b=e;break w}L[8513]=L[8513]+1;j=ha[L[6798]](k,16)|0;b=L[f+24>>2]}r=L[f+32>>2];x:{if((b|0)>0){y=0;m=0;if(b>>>0>=4){h=b&-4;p=0;while(1){n=m<<2;L[n+j>>2]=L[n+r>>2];c=n|4;L[c+j>>2]=L[c+r>>2];c=n|8;L[c+j>>2]=L[c+r>>2];c=n|12;L[c+j>>2]=L[c+r>>2];m=m+4|0;p=p+4|0;if((h|0)!=(p|0)){continue}break}}c=b&3;if(!c){break x}while(1){b=m<<2;L[b+j>>2]=L[b+r>>2];m=m+1|0;y=y+1|0;if((c|0)!=(y|0)){continue}break}break x}if(r){break x}L[f+32>>2]=j;L[f+28>>2]=u;J[f+36|0]=1;break v}if(r?M[f+36|0]:0){L[8514]=L[8514]+1;ha[L[6799]](r)}L[f+32>>2]=j;J[f+36|0]=1;L[f+28>>2]=u}b=e<<2;pa(b+j|0,0,k-b|0)}L[f+24>>2]=u;if((u|0)>0){pa(L[f+12>>2],255,k);pa(L[f+32>>2],255,k)}if((d|0)<=0){break r}n=L[f+32>>2];h=L[f+72>>2];c=L[f+12>>2];m=0;while(1){e=m<<2;b=e+h|0;b=c+(((N[b+2>>1]<<16)+K[b>>1]&L[f+48>>2]-1)<<2)|0;L[e+n>>2]=L[b>>2];L[b>>2]=m;m=m+1|0;if((d|0)!=(m|0)){continue}break}}y=K[g+12>>1]+(N[g+14>>1]<<16)&L[f+48>>2]-1}b=L[f+12>>2]+(y<<2)|0;L[L[f+32>>2]+(v<<2)>>2]=L[b>>2];L[b>>2]=v;break i}e=L[f+52>>2]+(b<<2)|0;b=N[g+8>>1]|N[g+10>>1]<<16;K[e>>1]=b;K[e+2>>1]=b>>>16}if(!H){continue}}break}j=L[a+28>>2]}B=B+1|0;if((B|0)<(j|0)){continue}break}B=0;d=(j|0)>0;if(d){break b}}i=P[a+72>>2];z=P[a+68>>2];A=P[a+64>>2];break a}D=L[a+16>>2];h=L[a+36>>2];A=P[a+64>>2];z=P[a+68>>2];i=P[a+72>>2];while(1){b=h+R(B,36)|0;k=L[b+4>>2];if((k|0)>=3){v=L[b+12>>2];E=D+(L[v>>2]<<4)|0;c=k-2|0;b=1;while(1){n=D+(L[v+(b<<2)>>2]<<4)|0;V=P[n+8>>2];e=b+1|0;s=D+(L[v+((e|0)%(k|0)<<2)>>2]<<4)|0;W=P[s+8>>2];I=P[E>>2];X=P[n>>2];Y=S(I-X);Q=P[E+4>>2];Z=P[s+4>>2];t=S(Q-Z);w=P[s>>2];x=S(I-w);l=P[n+4>>2];o=S(Q-l);$=S(S(Y*t)-S(x*o));U=P[E+8>>2];q=S(U-W);G=S(o*q);o=S(U-V);t=S(G-S(t*o));G=i;i=S(S(o*x)-S(q*Y));o=S(S(_(S(S($*$)+S(S(t*t)+S(i*i)))))*S(.5));i=S(G+S(S(S(S(U+V)+W)*S(.3333333432674408))*o));P[a+72>>2]=i;z=S(z+S(S(S(Z+S(Q+l))*S(.3333333432674408))*o));P[a+68>>2]=z;A=S(A+S(S(S(w+S(I+X))*S(.3333333432674408))*o));P[a+64>>2]=A;C=S(C+o);s=(b|0)==(c|0);b=e;if(!s){continue}break}}B=B+1|0;if((B|0)!=(j|0)){continue}break}s=d}L[a+96>>2]=2139095039;o=S(S(1)/C);w=S(o*i);P[a+72>>2]=w;x=S(o*z);P[a+68>>2]=x;l=S(o*A);P[a+64>>2]=l;q=S(34028234663852886e22);o=S(34028234663852886e22);if(s){e=L[a+36>>2];b=0;while(1){s=e+R(b,36)|0;i=S(T(S(P[s+32>>2]+S(S(w*P[s+28>>2])+S(S(l*P[s+20>>2])+S(x*P[s+24>>2]))))));if(i>2]=i;o=i}b=b+1|0;if((j|0)!=(b|0)){continue}break}}s=L[a+8>>2];y:{if((s|0)<=0){t=S(-34028234663852886e22);i=S(34028234663852886e22);z=S(-34028234663852886e22);A=S(-34028234663852886e22);C=S(34028234663852886e22);break y}e=L[a+16>>2];A=S(-34028234663852886e22);b=0;C=S(34028234663852886e22);z=S(-34028234663852886e22);t=S(-34028234663852886e22);i=S(34028234663852886e22);while(1){d=e+(b<<4)|0;l=P[d+8>>2];A=l>A?l:A;i=i>l?l:i;l=P[d+4>>2];z=l>z?l:z;q=l>2];t=l>t?l:t;C=l>2]=0;l=S(A-i);P[a+124>>2]=l;w=S(z-q);P[a+120>>2]=w;x=S(t-C);P[a+116>>2]=x;L[a+112>>2]=0;P[a+108>>2]=i+A;P[a+104>>2]=q+z;P[a+100>>2]=t+C;e=w>x;s=l>(e?w:x)?2:e;e=s<<2;i=P[e+(a+116|0)>>2];l=S(o/S(1.7320507764816284));P[a+84>>2]=l;P[a+88>>2]=l;P[a+80>>2]=l;d=a+80|0;e=d+e|0;i=S(i*S(.5));P[e>>2]=i;q=S(S(i-l)*S(.0009765625));z:{A:{while(1){if(Pg(a)){break A}i=S(i-q);P[e>>2]=i;b=b+1|0;if((b|0)!=1024){continue}break}P[a+84>>2]=l;P[a+88>>2]=l;P[a+80>>2]=l;break z}b=1<>2];b=d+(b<<2)|0;t=P[b>>2];o=S(S(o-l)*S(.0009765625));P[b>>2]=o+t;q=S(o+P[e>>2]);P[e>>2]=q;if(Pg(a)){c=0;while(1){i=q;c=c+1|0;if((c|0)==1024){break z}t=P[b>>2];P[b>>2]=o+t;q=S(o+P[e>>2]);P[e>>2]=q;if(Pg(a)){continue}break}}P[b>>2]=t;P[e>>2]=i}a=L[g+88>>2];if(!(a?!a|!M[g+92|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](a)}L[g+88>>2]=0;J[g+92|0]=1;L[g+80>>2]=0;L[g+84>>2]=0;a=L[g+68>>2];if(!(a?!a|!M[g+72|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](a)}L[g+68>>2]=0;J[g+72|0]=1;L[g+60>>2]=0;L[g+64>>2]=0;a=L[g+48>>2];if(!(a?!a|!M[g+52|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](a)}L[g+48>>2]=0;J[g+52|0]=1;L[g+40>>2]=0;L[g+44>>2]=0;a=L[g+28>>2];if(!(a?!a|!M[g+32|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](a)}fa=g+96|0}function $z(a,b){a=a|0;b=S(b);var c=0,d=0,e=0,f=0,g=S(0),h=0,i=0,j=0,k=S(0),l=S(0),m=S(0),n=0,o=0,p=S(0),q=S(0),r=0,s=S(0),t=S(0),u=S(0),v=0,w=S(0),x=0,y=S(0),z=S(0),A=S(0),B=S(0),C=S(0),D=S(0),E=0,F=S(0),G=S(0),H=S(0),I=S(0),K=S(0);n=fa-96|0;fa=n;c=L[a+136>>2];a:{if(!c){break a}if(!((c|0)<=L[a+8>>2]|(c|0)<=L[a+12>>2])){L[8513]=L[8513]+1;f=ha[L[6798]](c<<4,16)|0;i=L[a+8>>2];b:{if((i|0)<=0){break b}if((i|0)!=1){r=i&-2;while(1){j=d<<4;o=j+f|0;h=j+L[a+16>>2]|0;v=L[h+4>>2];L[o>>2]=L[h>>2];L[o+4>>2]=v;v=L[h+12>>2];L[o+8>>2]=L[h+8>>2];L[o+12>>2]=v;h=j|16;j=h+f|0;h=h+L[a+16>>2]|0;o=L[h+4>>2];L[j>>2]=L[h>>2];L[j+4>>2]=o;o=L[h+12>>2];L[j+8>>2]=L[h+8>>2];L[j+12>>2]=o;d=d+2|0;e=e+2|0;if((r|0)!=(e|0)){continue}break}}if(!(i&1)){break b}e=d<<4;d=e+f|0;e=e+L[a+16>>2]|0;i=L[e+4>>2];L[d>>2]=L[e>>2];L[d+4>>2]=i;i=L[e+12>>2];L[d+8>>2]=L[e+8>>2];L[d+12>>2]=i}d=L[a+16>>2];if(!(d?!d|!M[a+20|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](d)}L[a+16>>2]=f;J[a+20|0]=1;L[a+12>>2]=c}L[a+8>>2]=c;if(!((c|0)<=L[a+28>>2]|(c|0)<=L[a+32>>2])){L[8513]=L[8513]+1;f=ha[L[6798]](c<<4,16)|0;i=L[a+28>>2];c:{if((i|0)<=0){break c}d=0;if((i|0)!=1){r=i&-2;e=0;while(1){j=d<<4;o=j+f|0;h=j+L[a+36>>2]|0;v=L[h+4>>2];L[o>>2]=L[h>>2];L[o+4>>2]=v;v=L[h+12>>2];L[o+8>>2]=L[h+8>>2];L[o+12>>2]=v;h=j|16;j=h+f|0;h=h+L[a+36>>2]|0;o=L[h+4>>2];L[j>>2]=L[h>>2];L[j+4>>2]=o;o=L[h+12>>2];L[j+8>>2]=L[h+8>>2];L[j+12>>2]=o;d=d+2|0;e=e+2|0;if((r|0)!=(e|0)){continue}break}}if(!(i&1)){break c}e=d<<4;d=e+f|0;e=e+L[a+36>>2]|0;i=L[e+4>>2];L[d>>2]=L[e>>2];L[d+4>>2]=i;i=L[e+12>>2];L[d+8>>2]=L[e+8>>2];L[d+12>>2]=i}d=L[a+36>>2];if(!(d?!d|!M[a+40|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](d)}L[a+36>>2]=f;J[a+40|0]=1;L[a+32>>2]=c}L[a+28>>2]=c;v=L[a+48>>2];if((v|0)<(c|0)){d:{if((c|0)<=L[a+52>>2]){j=c<<2;e=L[a+56>>2];break d}L[8513]=L[8513]+1;j=c<<2;e=ha[L[6798]](j,16)|0;f=L[a+56>>2];e:{r=L[a+48>>2];if((r|0)>0){i=0;d=0;if(r>>>0>=4){E=r&-4;h=0;while(1){o=d<<2;P[o+e>>2]=P[f+o>>2];x=o|4;P[x+e>>2]=P[f+x>>2];x=o|8;P[x+e>>2]=P[f+x>>2];o=o|12;P[o+e>>2]=P[f+o>>2];d=d+4|0;h=h+4|0;if((E|0)!=(h|0)){continue}break}}h=r&3;if(!h){break e}while(1){o=d<<2;P[o+e>>2]=P[f+o>>2];d=d+1|0;i=i+1|0;if((h|0)!=(i|0)){continue}break}break e}if(f){break e}L[a+56>>2]=e;L[a+52>>2]=c;J[a+60|0]=1;break d}if(f?M[a+60|0]:0){L[8514]=L[8514]+1;ha[L[6799]](f)}L[a+56>>2]=e;J[a+60|0]=1;L[a+52>>2]=c}d=v<<2;pa(d+e|0,0,j-d|0)}L[a+48>>2]=c;v=L[a+68>>2];if((v|0)<(c|0)){f:{if((c|0)<=L[a+72>>2]){j=c<<2;e=L[a+76>>2];break f}L[8513]=L[8513]+1;j=c<<2;e=ha[L[6798]](j,16)|0;f=L[a+76>>2];g:{r=L[a+68>>2];if((r|0)>0){i=0;d=0;if(r>>>0>=4){E=r&-4;h=0;while(1){o=d<<2;P[o+e>>2]=P[f+o>>2];x=o|4;P[x+e>>2]=P[f+x>>2];x=o|8;P[x+e>>2]=P[f+x>>2];o=o|12;P[o+e>>2]=P[f+o>>2];d=d+4|0;h=h+4|0;if((E|0)!=(h|0)){continue}break}}h=r&3;if(!h){break g}while(1){o=d<<2;P[o+e>>2]=P[f+o>>2];d=d+1|0;i=i+1|0;if((h|0)!=(i|0)){continue}break}break g}if(f){break g}L[a+76>>2]=e;L[a+72>>2]=c;J[a+80|0]=1;break f}if(f?M[a+80|0]:0){L[8514]=L[8514]+1;ha[L[6799]](f)}L[a+76>>2]=e;J[a+80|0]=1;L[a+72>>2]=c}d=v<<2;pa(d+e|0,0,j-d|0)}L[a+68>>2]=c;i=L[a+136>>2];if((i|0)<=0){break a}c=L[a+56>>2];f=L[a+76>>2];e=0;d=0;if(i>>>0>=4){o=i&-4;h=0;while(1){j=d<<2;L[j+f>>2]=0;L[c+j>>2]=0;r=j|4;L[r+f>>2]=0;L[c+r>>2]=0;r=j|8;L[r+f>>2]=0;L[c+r>>2]=0;j=j|12;L[j+f>>2]=0;L[c+j>>2]=0;d=d+4|0;h=h+4|0;if((o|0)!=(h|0)){continue}break}}h=i&3;if(h){while(1){j=d<<2;L[j+f>>2]=0;L[c+j>>2]=0;d=d+1|0;e=e+1|0;if((h|0)!=(e|0)){continue}break}}if((i|0)<=0){break a}h=n+80|0;j=n- -64|0;e=0;while(1){f=L[a+144>>2]+R(e,284)|0;d=L[f+88>>2];if(d){c=L[f+104>>2];L[n+56>>2]=L[f+100>>2];L[n+60>>2]=c;c=L[f+96>>2];L[n+48>>2]=L[f+92>>2];L[n+52>>2]=c;c=L[f+120>>2];L[j+8>>2]=L[f+116>>2];L[j+12>>2]=c;c=L[f+112>>2];L[j>>2]=L[f+108>>2];L[j+4>>2]=c;c=L[f+136>>2];L[h+8>>2]=L[f+132>>2];L[h+12>>2]=c;c=L[f+128>>2];L[h>>2]=L[f+124>>2];L[h+4>>2]=c;c=L[a+120>>2]<<2;g=P[c+(n+48|0)>>2];m=P[c+j>>2];l=P[c+h>>2];i=e<<4;c=i+L[a+36>>2]|0;L[c+12>>2]=0;P[c+8>>2]=l;P[c+4>>2]=m;P[c>>2]=g;c=i+L[a+36>>2]|0;m=P[c+8>>2];l=P[f+8>>2];p=P[c>>2];k=P[f>>2];q=P[c+4>>2];u=P[f+4>>2];g=S(S(m*l)+S(S(p*k)+S(q*u)));m=S(m-S(l*g));l=S(p-S(k*g));p=S(q-S(u*g));g=S(S(1)/S(_(S(S(m*m)+S(S(l*l)+S(p*p))))));m=S(m*g);P[c+8>>2]=m;p=S(p*g);P[c+4>>2]=p;g=S(l*g);P[c>>2]=g;l=P[f+8>>2];k=P[f>>2];q=P[f+4>>2];c=i+L[a+16>>2]|0;L[c+12>>2]=0;P[c+8>>2]=S(k*p)-S(g*q);P[c+4>>2]=S(l*g)-S(m*k);P[c>>2]=S(q*m)-S(p*l);c=i+L[a+16>>2]|0;g=P[c+8>>2];k=g;l=S(g*g);g=P[c>>2];m=P[c+4>>2];l=S(S(1)/S(_(S(l+S(S(g*g)+S(m*m))))));P[c+8>>2]=k*l;P[c+4>>2]=m*l;P[c>>2]=g*l;c=L[a+116>>2];o=f+16|0;r=e<<2;v=r+L[a+76>>2]|0;f=i+L[a+36>>2]|0;t=P[f+8>>2];g=P[f>>2];A=P[f+4>>2];if(S(S(t*t)+S(S(g*g)+S(A*A)))>S(1.100000023841858)){k=S(0)}else{k=P[o+4>>2];m=S(k-P[c+56>>2]);q=P[o>>2];l=S(q-P[c+52>>2]);s=P[o+8>>2];p=S(s-P[c+60>>2]);k=S(k-P[d+56>>2]);q=S(q-P[d+52>>2]);u=P[f+4>>2];y=S(S(g*k)-S(q*u));s=S(s-P[d+60>>2]);w=P[f+8>>2];C=S(S(s*u)-S(k*w));z=S(S(q*w)-S(s*g));F=S(S(P[d+44>>2]*y)+S(S(P[d+12>>2]*C)+S(P[d+28>>2]*z)));B=t;t=P[c+328>>2];D=P[c+332>>2];G=P[d+328>>2];H=P[d+332>>2];I=S(B*S(S(S(S(t*m)-S(l*D))+P[c+320>>2])-S(S(S(G*k)-S(q*H))+P[d+320>>2])));K=S(D*p);D=P[c+336>>2];B=k;k=P[d+336>>2];s=S(S(I+S(S(g*S(S(S(K-S(m*D))+P[c+312>>2])-S(S(S(H*s)-S(B*k))+P[d+312>>2])))+S(A*S(S(S(S(D*l)-S(p*t))+P[c+316>>2])-S(S(S(k*q)-S(s*G))+P[d+316>>2])))))*S(-.20000000298023224));k=S(S(P[d+36>>2]*y)+S(S(P[d+4>>2]*C)+S(P[d+20>>2]*z)));t=S(S(P[d+396>>2]*k)*k);k=S(S(P[d+40>>2]*y)+S(S(P[d+8>>2]*C)+S(P[d+24>>2]*z)));t=S(S(S(F*P[d+404>>2])*F)+S(t+S(k*S(k*P[d+400>>2]))));k=S(S(l*u)-S(g*m));m=S(S(m*w)-S(u*p));g=S(S(p*g)-S(w*l));l=S(S(P[c+44>>2]*k)+S(S(P[c+12>>2]*m)+S(P[c+28>>2]*g)));p=S(S(P[c+404>>2]*l)*l);l=S(S(P[c+36>>2]*k)+S(S(P[c+4>>2]*m)+S(P[c+20>>2]*g)));g=S(S(P[c+40>>2]*k)+S(S(P[c+8>>2]*m)+S(P[c+24>>2]*g)));k=S(s*S(S(1)/S(t+S(P[d+344>>2]+S(P[c+344>>2]+S(p+S(S(S(P[c+396>>2]*l)*l)+S(g*S(g*P[c+400>>2])))))))))}P[v>>2]=k;d=r+L[a+76>>2]|0;P[d>>2]=P[6797]*P[d>>2];i=L[a+136>>2]}e=e+1|0;if((i|0)>(e|0)){continue}break}if((i|0)<=0){break a}e=L[a+144>>2];h=0;d=0;while(1){h:{i:{j:{o=R(d,284);i=o+e|0;c=L[i+88>>2];if(c){g=P[i+252>>2];if(g==S(0)){break j}g=S(g*b);break i}L[L[a+56>>2]+(d<<2)>>2]=0;L[(e+o|0)+280>>2]=1065353216;break h}e=L[a+116>>2];j=L[a+16>>2]+(d<<4)|0;g=P[i+256>>2];f=n+48|0;L[f+4>>2]=c;L[f>>2]=e;r=L[i+20>>2];L[f+8>>2]=L[i+16>>2];L[f+12>>2]=r;r=L[i+28>>2];L[f+16>>2]=L[i+24>>2];L[f+20>>2]=r;r=L[j+4>>2];L[f+24>>2]=L[j>>2];L[f+28>>2]=r;r=L[j+12>>2];L[f+32>>2]=L[j+8>>2];L[f+36>>2]=r;P[f+44>>2]=g==S(0)?S(0):g;A=P[i+16>>2];p=S(A-P[e+52>>2]);g=P[j+4>>2];m=P[j>>2];y=P[i+20>>2];k=S(y-P[e+56>>2]);u=S(S(p*g)-S(m*k));l=P[j+8>>2];C=P[i+24>>2];q=S(C-P[e+60>>2]);s=S(S(k*l)-S(g*q));w=S(S(q*m)-S(l*p));t=S(S(P[e+296>>2]*u)+S(S(P[e+264>>2]*s)+S(w*P[e+280>>2])));z=S(S(P[e+300>>2]*u)+S(S(P[e+268>>2]*s)+S(w*P[e+284>>2])));D=S(l*S(S(t*k)-S(p*z)));B=k;k=S(S(P[e+304>>2]*u)+S(S(P[e+272>>2]*s)+S(w*P[e+288>>2])));z=S(P[e+344>>2]+S(D+S(S(m*S(S(z*q)-S(B*k)))+S(g*S(S(k*p)-S(q*t))))));B=l;p=S(A-P[c+52>>2]);k=S(y-P[c+56>>2]);u=S(S(p*g)-S(m*k));q=S(C-P[c+60>>2]);s=S(S(k*l)-S(g*q));l=S(S(q*m)-S(l*p));w=S(S(P[c+296>>2]*u)+S(S(P[c+264>>2]*s)+S(l*P[c+280>>2])));t=S(S(P[c+300>>2]*u)+S(S(P[c+268>>2]*s)+S(l*P[c+284>>2])));y=m;m=S(S(P[c+304>>2]*u)+S(S(P[c+272>>2]*s)+S(l*P[c+288>>2])));P[f+40>>2]=S(1)/S(z+S(P[c+344>>2]+S(S(B*S(S(w*k)-S(p*t)))+S(S(y*S(S(t*q)-S(k*m)))+S(g*S(S(m*p)-S(q*w)))))));g=P[n+92>>2];m=S(-g);e=L[f>>2];l=P[e+328>>2];p=P[n+60>>2];k=S(p-P[e+56>>2]);q=P[n+56>>2];u=S(q-P[e+52>>2]);s=P[e+332>>2];c=L[n+52>>2];w=P[c+328>>2];p=S(p-P[c+56>>2]);q=S(q-P[c+52>>2]);t=P[c+332>>2];z=S(P[n+80>>2]*S(S(S(S(l*k)-S(u*s))+P[e+320>>2])-S(S(S(w*p)-S(q*t))+P[c+320>>2])));B=s;s=P[n+64>>2];A=S(s-P[e+60>>2]);y=k;k=P[e+336>>2];s=S(s-P[c+60>>2]);C=p;p=P[c+336>>2];l=S(P[n+88>>2]*S(-S(z+S(S(P[n+72>>2]*S(S(S(S(B*A)-S(y*k))+P[e+312>>2])-S(S(S(t*s)-S(C*p))+P[c+312>>2])))+S(S(S(S(S(k*u)-S(A*l))+P[e+316>>2])-S(S(S(p*q)-S(s*w))+P[c+316>>2]))*P[n+76>>2])))));g=g>2]}f=d<<2;j=f+L[a+56>>2]|0;L[j>>2]=0;c=e+o|0;L[c+280>>2]=1065353216;m=P[i+228>>2];l=P[i+276>>2];P[j>>2]=g;g=S(g*S(.5));k=S(g*g);g=P[f+L[a+76>>2]>>2];g=S(k+S(g*g));m=S(m*S(l*b));if(!(g>S(m*m))){break h}P[c+280>>2]=S(m/S(_(g)))*P[c+280>>2];h=1}d=d+1|0;c=L[a+136>>2];if((d|0)<(c|0)){continue}break}d=0;if((c|0)>0&h){f=L[a+56>>2];i=L[a+144>>2];h=L[a+76>>2];while(1){j=d<<2;e=j+h|0;k:{if(P[e>>2]==S(0)){break k}o=i+R(d,284)|0;b=P[o+280>>2];if(!(b>2]=b*P[j>>2];P[e>>2]=P[o+280>>2]*P[e>>2]}d=d+1|0;if((c|0)!=(d|0)){continue}break}}if((c|0)<=0){break a}d=0;while(1){i=R(d,284);e=i+L[a+144>>2]|0;b=P[e+16>>2];c=L[a+116>>2];g=P[c+52>>2];m=P[e+20>>2];l=P[c+56>>2];p=P[e+24>>2];k=P[c+60>>2];L[n+60>>2]=0;P[n+56>>2]=p-k;P[n+52>>2]=m-l;P[n+48>>2]=b-g;h=d<<2;b=P[h+L[a+56>>2]>>2];if(b!=S(0)){f=L[a+16>>2]+(d<<4)|0;g=P[f>>2];m=P[f+4>>2];l=P[f+8>>2];L[n+44>>2]=0;P[n+40>>2]=b*l;P[n+36>>2]=b*m;P[n+32>>2]=g*b;rb(c,n+32|0,n+48|0)}h=h+L[a+76>>2]|0;if(P[h>>2]!=S(0)){c=L[(i+L[a+144>>2]|0)+88>>2];b=P[c+52>>2];g=P[c+56>>2];m=P[c+60>>2];l=P[e+16>>2];p=P[e+20>>2];k=P[e+24>>2];L[n+44>>2]=0;P[n+40>>2]=k-m;P[n+36>>2]=p-g;P[n+32>>2]=l-b;f=L[a+36>>2]+(d<<4)|0;g=P[f>>2];m=P[f+4>>2];l=P[f+8>>2];b=P[h>>2];L[n+28>>2]=0;P[n+24>>2]=b*l;P[n+20>>2]=b*m;P[n+16>>2]=g*b;i=L[a+116>>2];f=i+(L[a+124>>2]<<2)|0;g=P[f+36>>2];m=P[n+56>>2];l=P[f+4>>2];p=P[n+48>>2];k=P[f+20>>2];q=P[n+52>>2];b=S(S(S(g*m)+S(S(l*p)+S(k*q)))*S(S(1)-P[e+244>>2]));P[n+56>>2]=m-S(g*b);P[n+52>>2]=q-S(k*b);P[n+48>>2]=p-S(l*b);rb(i,n+16|0,n+48|0);L[n+12>>2]=0;P[n+8>>2]=-P[n+24>>2];P[n+4>>2]=-P[n+20>>2];P[n>>2]=-P[n+16>>2];rb(c,n,n+32|0)}d=d+1|0;if((d|0)>2]){continue}break}}fa=n+96|0}function _B(a,b,c){a=a|0;b=b|0;c=S(c);var d=0,e=0,f=S(0),g=S(0),h=0,i=S(0),j=0,k=S(0),l=0,m=S(0),n=0,o=0,p=S(0),q=S(0),r=0,s=S(0);h=fa-80|0;fa=h;if(!(!M[a+171|0]&P[a+172>>2]<=S(0))){J[a+168|0]=ha[L[L[a>>2]+48>>2]](a);f=S(P[a+16>>2]-S(P[a+44>>2]*c));P[a+16>>2]=f;a:{if(!(f>S(0))){break a}g=P[a+28>>2];if(!(g>2]=g;f=g}b:{if(!(f>2]));if(!(g>2]=f}P[a+20>>2]=f*c;e=L[a+8>>2];d=L[e+16>>2];L[h+24>>2]=L[e+12>>2];L[h+28>>2]=d;d=L[e+8>>2];L[h+16>>2]=L[e+4>>2];L[h+20>>2]=d;d=L[e+32>>2];L[h+40>>2]=L[e+28>>2];L[h+44>>2]=d;d=L[e+24>>2];L[h+32>>2]=L[e+20>>2];L[h+36>>2]=d;d=L[e+48>>2];L[h+56>>2]=L[e+44>>2];L[h+60>>2]=d;d=L[e+40>>2];L[h+48>>2]=L[e+36>>2];L[h+52>>2]=d;e=fa-240|0;fa=e;if(!M[32528]){L[8121]=0;L[8122]=0;L[8120]=1065353216;L[8123]=0;L[8124]=0;L[8126]=0;L[8127]=0;L[8125]=1065353216;L[8128]=0;L[8129]=0;L[8130]=1065353216;L[8131]=0;J[32528]=1}d=L[a+176>>2]<<4;j=d+32480|0;g=P[j>>2];l=d+32484|0;k=P[l>>2];d=d+32488|0;f=P[d>>2];L[a+124>>2]=0;i=f;f=P[a+20>>2];f=S(P[a+52>>2]+(f>S(0)?f:S(0)));P[a+120>>2]=S(i*f)+P[a+100>>2];P[a+116>>2]=S(k*f)+P[a+96>>2];P[a+112>>2]=P[a+92>>2]+S(g*f);L[e+188>>2]=0;L[e+192>>2]=0;L[e+200>>2]=0;L[e+204>>2]=0;L[e+196>>2]=1065353216;L[e+208>>2]=0;L[e+212>>2]=0;L[e+216>>2]=1065353216;L[e+220>>2]=0;L[e+124>>2]=0;L[e+128>>2]=0;L[e+136>>2]=0;L[e+140>>2]=0;L[e+132>>2]=1065353216;L[e+144>>2]=0;L[e+148>>2]=0;L[e+152>>2]=1065353216;L[e+156>>2]=0;L[e+180>>2]=0;L[e+184>>2]=0;L[e+176>>2]=1065353216;L[e+116>>2]=0;L[e+120>>2]=0;L[e+112>>2]=1065353216;o=L[a+12>>2];f=S(ha[L[L[o>>2]+48>>2]](o));g=P[j>>2];k=P[a+96>>2];i=P[l>>2];m=P[a+100>>2];p=P[d>>2];q=P[a+92>>2];s=P[a+56>>2];L[e+236>>2]=0;f=S(f+s);P[e+232>>2]=m+S(p*f);P[e+228>>2]=k+S(f*i);P[e+224>>2]=q+S(g*f);d=L[a+124>>2];L[e+168>>2]=L[a+120>>2];L[e+172>>2]=d;d=L[a+116>>2];L[e+160>>2]=L[a+112>>2];L[e+164>>2]=d;d=L[a+8>>2];if(!M[32528]){L[8121]=0;L[8122]=0;L[8120]=1065353216;L[8123]=0;L[8124]=0;L[8126]=0;L[8127]=0;L[8125]=1065353216;L[8128]=0;L[8129]=0;L[8130]=1065353216;L[8131]=0;J[32528]=1}j=L[a+176>>2]<<4;f=P[j+32480>>2];g=P[j+32484>>2];k=P[j+32488>>2];L[e+28>>2]=0;L[e+32>>2]=0;L[e+36>>2]=0;L[e+40>>2]=0;L[e+44>>2]=0;L[e+48>>2]=0;L[e+104>>2]=0;L[e+108>>2]=1060439169;P[e+100>>2]=-k;P[e+96>>2]=-g;L[e+84>>2]=0;L[e+12>>2]=1065353216;L[e+20>>2]=0;L[e+24>>2]=0;L[e+8>>2]=19308;P[e+92>>2]=-f;L[e+88>>2]=d;j=L[d+188>>2];K[e+16>>1]=N[j+4>>1];K[e+18>>1]=N[j+6>>1];j=L[a+12>>2];c:{if(M[a+170|0]){Ec(d,j,e+176|0,e+112|0,e+8|0,P[b+56>>2]);break c}Ab(b,j,e+176|0,e+112|0,e+8|0,S(0))}f=P[e+12>>2];d:{if(f>2]<<4;e:{if(!(S(S(P[e+60>>2]*P[d+32488>>2])+S(S(P[e+52>>2]*P[d+32480>>2])+S(P[e+56>>2]*P[d+32484>>2])))>S(0))){break e}P[a+108>>2]=f*P[a+52>>2];if(M[a+180|0]){g=S(S(1)-f);P[a+92>>2]=S(g*P[a+92>>2])+S(f*P[a+112>>2]);P[a+96>>2]=S(g*P[a+96>>2])+S(f*P[a+116>>2]);P[a+100>>2]=S(g*P[a+100>>2])+S(f*P[a+120>>2]);break e}d=L[a+116>>2];L[a+92>>2]=L[a+112>>2];L[a+96>>2]=d;d=L[a+124>>2];L[a+100>>2]=L[a+120>>2];L[a+104>>2]=d}L[a+16>>2]=0;L[a+20>>2]=0;break d}P[a+108>>2]=P[a+52>>2];d=L[a+124>>2];L[a+100>>2]=L[a+120>>2];L[a+104>>2]=d;d=L[a+116>>2];L[a+92>>2]=L[a+112>>2];L[a+96>>2]=d}fa=e+240|0;j=h- -64|0;f:{if(M[a+171|0]){sl(a,b,a+60|0);break f}f=P[a+172>>2];P[a+172>>2]=f-c;g=P[a- -64>>2];k=P[a+68>>2];i=P[a+60>>2];L[h+12>>2]=0;f=c>2]=k*f;P[h+4>>2]=f*g;P[h>>2]=f*i;sl(a,b,h)}d=fa-416|0;fa=d;e=L[a+124>>2];L[d+216>>2]=L[a+120>>2];L[d+220>>2]=e;e=L[a+116>>2];L[d+208>>2]=L[a+112>>2];L[d+212>>2]=e;f=P[a+16>>2];f=S((fS(0))){break g}g=P[a+24>>2];if(!(g>2]<<4;e=l+32488|0;i=P[e>>2];g=P[l+32484>>2];l=l+32480|0;k=S(f+P[a+108>>2]);f=S(P[l>>2]*k);m=S(P[a+112>>2]-f);P[a+112>>2]=m;g=S(k*g);p=S(P[a+116>>2]-g);P[a+116>>2]=p;k=S(k*i);q=S(P[a+120>>2]-k);P[a+120>>2]=q;i=P[a+40>>2];o=L[a+8>>2];L[d+124>>2]=0;L[d+128>>2]=0;L[d+132>>2]=0;L[d+136>>2]=0;L[d+140>>2]=0;L[d+144>>2]=0;L[d+180>>2]=0;L[d+108>>2]=1065353216;L[d+116>>2]=0;L[d+120>>2]=0;L[d+184>>2]=o;L[d+104>>2]=19308;n=L[e+4>>2];L[d+196>>2]=L[e>>2];L[d+200>>2]=n;n=L[l+4>>2];L[d+188>>2]=L[l>>2];L[d+192>>2]=n;P[d+204>>2]=i;n=L[o+188>>2];K[d+112>>1]=N[n+4>>1];K[d+114>>1]=N[n+6>>1];L[d+20>>2]=0;L[d+24>>2]=0;L[d+28>>2]=0;L[d+32>>2]=0;L[d+36>>2]=0;L[d+40>>2]=0;L[d+76>>2]=0;L[d+4>>2]=1065353216;L[d+12>>2]=0;L[d+16>>2]=0;L[d+80>>2]=o;L[d>>2]=19308;r=L[e+4>>2];L[d+92>>2]=L[e>>2];L[d+96>>2]=r;e=L[l+4>>2];L[d+84>>2]=L[l>>2];L[d+88>>2]=e;P[d+100>>2]=i;K[d+8>>1]=N[n+4>>1];e=N[n+6>>1];L[d+364>>2]=0;L[d+368>>2]=0;L[d+376>>2]=0;L[d+380>>2]=0;L[d+372>>2]=1065353216;L[d+384>>2]=0;L[d+388>>2]=0;L[d+392>>2]=1065353216;L[d+396>>2]=0;L[d+300>>2]=0;L[d+304>>2]=0;L[d+312>>2]=0;L[d+316>>2]=0;L[d+308>>2]=1065353216;L[d+320>>2]=0;L[d+324>>2]=0;L[d+328>>2]=1065353216;L[d+332>>2]=0;L[d+236>>2]=0;L[d+240>>2]=0;L[d+244>>2]=1065353216;L[d+356>>2]=0;L[d+360>>2]=0;L[d+352>>2]=1065353216;K[d+10>>1]=e;L[d+292>>2]=0;L[d+296>>2]=0;L[d+288>>2]=1065353216;L[d+224>>2]=1065353216;L[d+228>>2]=0;L[d+232>>2]=0;L[d+256>>2]=0;L[d+260>>2]=0;L[d+248>>2]=0;L[d+252>>2]=0;L[d+264>>2]=1065353216;L[d+268>>2]=0;e=L[a+104>>2];L[d+408>>2]=L[a+100>>2];L[d+412>>2]=e;e=L[a+96>>2];L[d+400>>2]=L[a+92>>2];L[d+404>>2]=e;e=L[a+120>>2];l=L[a+124>>2];n=L[a+112>>2];r=L[a+116>>2];L[d+284>>2]=0;P[d+280>>2]=q-k;P[d+276>>2]=p-g;L[d+344>>2]=e;L[d+348>>2]=l;P[d+272>>2]=m-f;L[d+336>>2]=n;L[d+340>>2]=r;i=P[b+56>>2];e=L[a+12>>2];h:{if(M[a+170|0]){Ec(o,e,d+352|0,d+288|0,d+104|0,i);if(P[d+108>>2]>2],L[a+12>>2],d+352|0,d+224|0,d,P[b+56>>2]);break h}Ab(b,e,d+352|0,d+288|0,d+104|0,i);if(P[d+108>>2]>2],d+352|0,d+224|0,d,P[b+56>>2])}i=P[a+16>>2];i=S((i>2]>2]>2]S(0))){break o}c=P[a+52>>2];if(!(M[a+169|0]?M[a+168|0]:1)|(!(c>i)|!e)){break o}e=L[d+212>>2];L[a+112>>2]=L[d+208>>2];L[a+116>>2]=e;e=L[d+220>>2];L[a+120>>2]=L[d+216>>2];L[a+124>>2]=e;if(!M[32528]){L[8121]=0;L[8122]=0;L[8120]=1065353216;L[8123]=0;L[8124]=0;L[8126]=0;L[8127]=0;L[8125]=1065353216;L[8128]=0;L[8129]=0;L[8130]=1065353216;L[8131]=0;J[32528]=1}e=L[a+176>>2]<<4;i=P[e+32488>>2];m=P[e+32484>>2];c=S(c+P[a+108>>2]);p=S(P[a+112>>2]-S(P[e+32480>>2]*c));P[a+112>>2]=p;m=S(P[a+116>>2]-S(c*m));P[a+116>>2]=m;c=S(P[a+120>>2]-S(c*i));P[a+120>>2]=c;L[d+352>>2]=1065353216;L[d+364>>2]=0;L[d+368>>2]=0;L[d+356>>2]=0;L[d+360>>2]=0;L[d+372>>2]=1065353216;L[d+384>>2]=0;L[d+388>>2]=0;L[d+376>>2]=0;L[d+380>>2]=0;L[d+288>>2]=1065353216;L[d+392>>2]=1065353216;L[d+396>>2]=0;L[d+300>>2]=0;L[d+304>>2]=0;L[d+292>>2]=0;L[d+296>>2]=0;L[d+308>>2]=1065353216;L[d+320>>2]=0;L[d+324>>2]=0;L[d+312>>2]=0;L[d+316>>2]=0;L[d+224>>2]=1065353216;L[d+328>>2]=1065353216;L[d+332>>2]=0;L[d+236>>2]=0;L[d+240>>2]=0;L[d+228>>2]=0;L[d+232>>2]=0;L[d+244>>2]=1065353216;L[d+256>>2]=0;L[d+260>>2]=0;L[d+248>>2]=0;L[d+252>>2]=0;L[d+264>>2]=1065353216;L[d+268>>2]=0;e=L[a+104>>2];L[d+408>>2]=L[a+100>>2];L[d+412>>2]=e;e=L[a+96>>2];L[d+400>>2]=L[a+92>>2];L[d+404>>2]=e;e=L[a+124>>2];L[d+344>>2]=L[a+120>>2];L[d+348>>2]=e;e=L[a+116>>2];L[d+336>>2]=L[a+112>>2];L[d+340>>2]=e;L[d+284>>2]=0;P[d+280>>2]=c-k;P[d+276>>2]=m-g;P[d+272>>2]=p-f;p:{if(M[a+170|0]){Ec(L[a+8>>2],L[a+12>>2],d+352|0,d+288|0,d+104|0,P[b+56>>2]);if(P[d+108>>2]>2],L[a+12>>2],d+352|0,d+224|0,d,P[b+56>>2]);break p}Ab(b,L[a+12>>2],d+352|0,d+288|0,d+104|0,P[b+56>>2]);if(P[d+108>>2]>2],d+352|0,d+224|0,d,P[b+56>>2])}g=P[a+96>>2];c=P[d+108>>2];if(!M[a+182|0]){break m}f=S(g-P[d+168>>2]);break n}c=P[d+108>>2];if(!(c>2];if(!l){break m}f=S(g-P[d+168>>2])}k=P[a+112>>2];i=P[a+92>>2];if(M[a+181|0]){f=S(S(1)-c);P[a+92>>2]=S(f*i)+S(c*k);break l}c=S(f*S(.5));f=S(S(1)-c);P[a+92>>2]=S(f*i)+S(c*k);break l}f=S(S(1)-c);P[a+92>>2]=S(f*P[a+92>>2])+S(c*P[a+112>>2])}P[a+96>>2]=S(f*g)+S(c*P[a+116>>2]);J[a+181|0]=0;J[a+169|0]=0;L[a+16>>2]=0;L[a+20>>2]=0;P[a+100>>2]=S(f*P[a+100>>2])+S(c*P[a+120>>2]);break j}J[a+181|0]=1;q:{if(!l){break q}c=P[a+24>>2];if(!(c>2]);g=S(g+P[a+116>>2]);f=S(f+P[a+112>>2]);if(!M[32528]){L[8121]=0;L[8122]=0;L[8120]=1065353216;L[8123]=0;L[8124]=0;L[8126]=0;L[8127]=0;L[8125]=1065353216;L[8128]=0;L[8129]=0;L[8130]=1065353216;L[8131]=0;J[32528]=1}b=L[a+176>>2]<<4;i=P[b+32480>>2];m=P[b+32484>>2];c=S(c+P[a+108>>2]);P[a+120>>2]=k-S(c*P[b+32488>>2]);P[a+116>>2]=g-S(c*m);P[a+112>>2]=f-S(i*c)}b=L[a+116>>2];L[a+92>>2]=L[a+112>>2];L[a+96>>2]=b;b=L[a+124>>2];L[a+100>>2]=L[a+120>>2];L[a+104>>2]=b}fa=d+416|0;b=L[a+104>>2];L[j+8>>2]=L[a+100>>2];L[j+12>>2]=b;b=L[a+96>>2];L[j>>2]=L[a+92>>2];L[j+4>>2]=b;a=L[a+8>>2];L[a+260>>2]=L[a+260>>2]+1;b=L[h+28>>2];L[a+12>>2]=L[h+24>>2];L[a+16>>2]=b;b=L[h+20>>2];L[a+4>>2]=L[h+16>>2];L[a+8>>2]=b;b=L[h+44>>2];L[a+28>>2]=L[h+40>>2];L[a+32>>2]=b;b=L[h+36>>2];L[a+20>>2]=L[h+32>>2];L[a+24>>2]=b;b=L[h+52>>2];L[a+36>>2]=L[h+48>>2];L[a+40>>2]=b;b=L[h+60>>2];L[a+44>>2]=L[h+56>>2];L[a+48>>2]=b;b=L[j+4>>2];L[a+52>>2]=L[j>>2];L[a+56>>2]=b;b=L[j+12>>2];L[a+60>>2]=L[j+8>>2];L[a+64>>2]=b}fa=h+80|0}function Yf(a){a=a|0;var b=0,c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0;l=fa-16|0;fa=l;a:{b:{c:{d:{e:{f:{g:{h:{i:{if(a>>>0<=244){g=L[8530];h=a>>>0<11?16:a+11&-8;c=h>>>3|0;b=g>>>c|0;if(b&3){c=c+((b^-1)&1)|0;a=c<<3;b=a+34160|0;d=L[a+34168>>2];a=L[d+8>>2];j:{if((b|0)==(a|0)){L[8530]=nI(c)&g;break j}L[a+12>>2]=b;L[b+8>>2]=a}a=d+8|0;b=c<<3;L[d+4>>2]=b|3;b=b+d|0;L[b+4>>2]=L[b+4>>2]|1;break a}k=L[8532];if(k>>>0>=h>>>0){break i}if(b){a=2<>2];a=L[e+8>>2];k:{if((b|0)==(a|0)){g=nI(d)&g;L[8530]=g;break k}L[a+12>>2]=b;L[b+8>>2]=a}L[e+4>>2]=h|3;c=e+h|0;a=d<<3;d=a-h|0;L[c+4>>2]=d|1;L[a+e>>2]=d;if(k){b=(k&-8)+34160|0;f=L[8535];a=1<<(k>>>3);l:{if(!(a&g)){L[8530]=a|g;a=b;break l}a=L[b+8>>2]}L[b+8>>2]=f;L[a+12>>2]=f;L[f+12>>2]=b;L[f+8>>2]=a}a=e+8|0;L[8535]=c;L[8532]=d;break a}j=L[8531];if(!j){break i}c=L[(lI(0-j&j)<<2)+34424>>2];f=(L[c+4>>2]&-8)-h|0;b=c;while(1){m:{a=L[b+16>>2];if(!a){a=L[b+20>>2];if(!a){break m}}b=(L[a+4>>2]&-8)-h|0;d=b>>>0>>0;f=d?b:f;c=d?a:c;b=a;continue}break}i=L[c+24>>2];d=L[c+12>>2];if((d|0)!=(c|0)){a=L[c+8>>2];L[a+12>>2]=d;L[d+8>>2]=a;break b}b=c+20|0;a=L[b>>2];if(!a){a=L[c+16>>2];if(!a){break h}b=c+16|0}while(1){e=b;d=a;b=a+20|0;a=L[b>>2];if(a){continue}b=d+16|0;a=L[d+16>>2];if(a){continue}break}L[e>>2]=0;break b}h=-1;if(a>>>0>4294967231){break i}a=a+11|0;h=a&-8;j=L[8531];if(!j){break i}f=0-h|0;g=0;n:{if(h>>>0<256){break n}g=31;if(h>>>0>16777215){break n}a=U(a>>>8|0);g=((h>>>38-a&1)-(a<<1)|0)+62|0}b=L[(g<<2)+34424>>2];o:{p:{q:{if(!b){a=0;break q}a=0;c=h<<((g|0)!=31?25-(g>>>1|0)|0:0);while(1){r:{e=(L[b+4>>2]&-8)-h|0;if(e>>>0>=f>>>0){break r}d=b;f=e;if(e){break r}f=0;a=b;break p}e=L[b+20>>2];b=L[((c>>>29&4)+b|0)+16>>2];a=e?(e|0)==(b|0)?a:e:a;c=c<<1;if(b){continue}break}}if(!(a|d)){d=0;a=2<>2]}if(!a){break o}}while(1){b=(L[a+4>>2]&-8)-h|0;c=b>>>0>>0;f=c?b:f;d=c?a:d;b=L[a+16>>2];if(b){a=b}else{a=L[a+20>>2]}if(a){continue}break}}if(!d|L[8532]-h>>>0<=f>>>0){break i}g=L[d+24>>2];c=L[d+12>>2];if((d|0)!=(c|0)){a=L[d+8>>2];L[a+12>>2]=c;L[c+8>>2]=a;break c}b=d+20|0;a=L[b>>2];if(!a){a=L[d+16>>2];if(!a){break g}b=d+16|0}while(1){e=b;c=a;b=a+20|0;a=L[b>>2];if(a){continue}b=c+16|0;a=L[c+16>>2];if(a){continue}break}L[e>>2]=0;break c}a=L[8532];if(a>>>0>=h>>>0){d=L[8535];b=a-h|0;s:{if(b>>>0>=16){c=d+h|0;L[c+4>>2]=b|1;L[a+d>>2]=b;L[d+4>>2]=h|3;break s}L[d+4>>2]=a|3;a=a+d|0;L[a+4>>2]=L[a+4>>2]|1;c=0;b=0}L[8532]=b;L[8535]=c;a=d+8|0;break a}i=L[8533];if(i>>>0>h>>>0){b=i-h|0;L[8533]=b;c=L[8536];a=c+h|0;L[8536]=a;L[a+4>>2]=b|1;L[c+4>>2]=h|3;a=c+8|0;break a}a=0;j=h+47|0;if(L[8648]){c=L[8650]}else{L[8651]=-1;L[8652]=-1;L[8649]=4096;L[8650]=4096;L[8648]=l+12&-16^1431655768;L[8653]=0;L[8641]=0;c=4096}e=j+c|0;f=0-c|0;b=e&f;if(b>>>0<=h>>>0){break a}d=L[8640];if(d){c=L[8638];g=c+b|0;if(d>>>0>>0|c>>>0>=g>>>0){break a}}t:{if(!(M[34564]&4)){u:{v:{w:{x:{d=L[8536];if(d){a=34568;while(1){c=L[a>>2];if(c>>>0<=d>>>0&d>>>0>2]>>>0){break x}a=L[a+8>>2];if(a){continue}break}}c=wc(0);if((c|0)==-1){break u}g=b;d=L[8649];a=d-1|0;if(a&c){g=(b-c|0)+(a+c&0-d)|0}if(g>>>0<=h>>>0){break u}d=L[8640];if(d){a=L[8638];f=a+g|0;if(d>>>0>>0|a>>>0>=f>>>0){break u}}a=wc(g);if((c|0)!=(a|0)){break w}break t}g=f&e-i;c=wc(g);if((c|0)==(L[a>>2]+L[a+4>>2]|0)){break v}a=c}if((a|0)==-1){break u}if(h+48>>>0<=g>>>0){c=a;break t}c=L[8650];c=c+(j-g|0)&0-c;if((wc(c)|0)==-1){break u}g=c+g|0;c=a;break t}if((c|0)!=-1){break t}}L[8641]=L[8641]|4}c=wc(b);a=wc(0);if((c|0)==-1|(a|0)==-1|a>>>0<=c>>>0){break d}g=a-c|0;if(g>>>0<=h+40>>>0){break d}}a=L[8638]+g|0;L[8638]=a;if(a>>>0>O[8639]){L[8639]=a}y:{e=L[8536];if(e){a=34568;while(1){d=L[a>>2];b=L[a+4>>2];if((d+b|0)==(c|0)){break y}a=L[a+8>>2];if(a){continue}break}break f}a=L[8534];if(!(a>>>0<=c>>>0?a:0)){L[8534]=c}a=0;L[8643]=g;L[8642]=c;L[8538]=-1;L[8539]=L[8648];L[8645]=0;while(1){d=a<<3;b=d+34160|0;L[d+34168>>2]=b;L[d+34172>>2]=b;a=a+1|0;if((a|0)!=32){continue}break}d=g-40|0;a=c+8&7?-8-c&7:0;b=d-a|0;L[8533]=b;a=a+c|0;L[8536]=a;L[a+4>>2]=b|1;L[(c+d|0)+4>>2]=40;L[8537]=L[8652];break e}if(M[a+12|0]&8|d>>>0>e>>>0|c>>>0<=e>>>0){break f}L[a+4>>2]=b+g;a=e+8&7?-8-e&7:0;c=a+e|0;L[8536]=c;b=L[8533]+g|0;a=b-a|0;L[8533]=a;L[c+4>>2]=a|1;L[(b+e|0)+4>>2]=40;L[8537]=L[8652];break e}d=0;break b}c=0;break c}if(O[8534]>c>>>0){L[8534]=c}b=c+g|0;a=34568;z:{A:{B:{C:{D:{E:{while(1){if((b|0)!=L[a>>2]){a=L[a+8>>2];if(a){continue}break E}break}if(!(M[a+12|0]&8)){break D}}a=34568;while(1){b=L[a>>2];if(b>>>0<=e>>>0){f=b+L[a+4>>2]|0;if(f>>>0>e>>>0){break C}}a=L[a+8>>2];continue}}L[a>>2]=c;L[a+4>>2]=L[a+4>>2]+g;j=(c+8&7?-8-c&7:0)+c|0;L[j+4>>2]=h|3;g=b+(b+8&7?-8-b&7:0)|0;i=h+j|0;a=g-i|0;if((e|0)==(g|0)){L[8536]=i;a=L[8533]+a|0;L[8533]=a;L[i+4>>2]=a|1;break A}if(L[8535]==(g|0)){L[8535]=i;a=L[8532]+a|0;L[8532]=a;L[i+4>>2]=a|1;L[a+i>>2]=a;break A}f=L[g+4>>2];if((f&3)==1){e=f&-8;F:{if(f>>>0<=255){c=L[g+12>>2];b=L[g+8>>2];if((c|0)==(b|0)){L[8530]=L[8530]&nI(f>>>3|0);break F}L[b+12>>2]=c;L[c+8>>2]=b;break F}h=L[g+24>>2];c=L[g+12>>2];G:{if((g|0)!=(c|0)){b=L[g+8>>2];L[b+12>>2]=c;L[c+8>>2]=b;break G}H:{f=g+20|0;b=L[f>>2];if(b){break H}f=g+16|0;b=L[f>>2];if(b){break H}c=0;break G}while(1){d=f;c=b;f=c+20|0;b=L[f>>2];if(b){continue}f=c+16|0;b=L[c+16>>2];if(b){continue}break}L[d>>2]=0}if(!h){break F}d=L[g+28>>2];b=(d<<2)+34424|0;I:{if(L[b>>2]==(g|0)){L[b>>2]=c;if(c){break I}L[8531]=L[8531]&nI(d);break F}L[h+(L[h+16>>2]==(g|0)?16:20)>>2]=c;if(!c){break F}}L[c+24>>2]=h;b=L[g+16>>2];if(b){L[c+16>>2]=b;L[b+24>>2]=c}b=L[g+20>>2];if(!b){break F}L[c+20>>2]=b;L[b+24>>2]=c}g=e+g|0;f=L[g+4>>2];a=a+e|0}L[g+4>>2]=f&-2;L[i+4>>2]=a|1;L[a+i>>2]=a;if(a>>>0<=255){b=(a&-8)+34160|0;c=L[8530];a=1<<(a>>>3);J:{if(!(c&a)){L[8530]=a|c;a=b;break J}a=L[b+8>>2]}L[b+8>>2]=i;L[a+12>>2]=i;L[i+12>>2]=b;L[i+8>>2]=a;break A}f=31;if(a>>>0<=16777215){b=U(a>>>8|0);f=((a>>>38-b&1)-(b<<1)|0)+62|0}L[i+28>>2]=f;L[i+16>>2]=0;L[i+20>>2]=0;b=(f<<2)+34424|0;d=L[8531];c=1<>2]=i;break K}f=a<<((f|0)!=31?25-(f>>>1|0)|0:0);c=L[b>>2];while(1){b=c;if((L[c+4>>2]&-8)==(a|0)){break B}c=f>>>29|0;f=f<<1;d=(c&4)+b|0;c=L[d+16>>2];if(c){continue}break}L[d+16>>2]=i}L[i+24>>2]=b;L[i+12>>2]=i;L[i+8>>2]=i;break A}d=g-40|0;a=c+8&7?-8-c&7:0;b=d-a|0;L[8533]=b;a=a+c|0;L[8536]=a;L[a+4>>2]=b|1;L[(c+d|0)+4>>2]=40;L[8537]=L[8652];a=(f+(f-39&7?39-f&7:0)|0)-47|0;d=a>>>0>>0?e:a;L[d+4>>2]=27;a=L[8645];L[d+16>>2]=L[8644];L[d+20>>2]=a;a=L[8643];L[d+8>>2]=L[8642];L[d+12>>2]=a;L[8644]=d+8;L[8643]=g;L[8642]=c;L[8645]=0;a=d+24|0;while(1){L[a+4>>2]=7;b=a+8|0;a=a+4|0;if(b>>>0>>0){continue}break}if((d|0)==(e|0)){break e}L[d+4>>2]=L[d+4>>2]&-2;f=d-e|0;L[e+4>>2]=f|1;L[d>>2]=f;if(f>>>0<=255){b=(f&-8)+34160|0;c=L[8530];a=1<<(f>>>3);L:{if(!(c&a)){L[8530]=a|c;a=b;break L}a=L[b+8>>2]}L[b+8>>2]=e;L[a+12>>2]=e;L[e+12>>2]=b;L[e+8>>2]=a;break e}a=31;if(f>>>0<=16777215){a=U(f>>>8|0);a=((f>>>38-a&1)-(a<<1)|0)+62|0}L[e+28>>2]=a;L[e+16>>2]=0;L[e+20>>2]=0;b=(a<<2)+34424|0;d=L[8531];c=1<>2]=e;break M}a=f<<((a|0)!=31?25-(a>>>1|0)|0:0);d=L[b>>2];while(1){b=d;if((f|0)==(L[b+4>>2]&-8)){break z}c=a>>>29|0;a=a<<1;c=(c&4)+b|0;d=L[c+16>>2];if(d){continue}break}L[c+16>>2]=e}L[e+24>>2]=b;L[e+12>>2]=e;L[e+8>>2]=e;break e}a=L[b+8>>2];L[a+12>>2]=i;L[b+8>>2]=i;L[i+24>>2]=0;L[i+12>>2]=b;L[i+8>>2]=a}a=j+8|0;break a}a=L[b+8>>2];L[a+12>>2]=e;L[b+8>>2]=e;L[e+24>>2]=0;L[e+12>>2]=b;L[e+8>>2]=a}a=L[8533];if(a>>>0<=h>>>0){break d}b=a-h|0;L[8533]=b;c=L[8536];a=c+h|0;L[8536]=a;L[a+4>>2]=b|1;L[c+4>>2]=h|3;a=c+8|0;break a}L[8527]=48;a=0;break a}N:{if(!g){break N}b=L[d+28>>2];a=(b<<2)+34424|0;O:{if(L[a>>2]==(d|0)){L[a>>2]=c;if(c){break O}j=nI(b)&j;L[8531]=j;break N}L[g+(L[g+16>>2]==(d|0)?16:20)>>2]=c;if(!c){break N}}L[c+24>>2]=g;a=L[d+16>>2];if(a){L[c+16>>2]=a;L[a+24>>2]=c}a=L[d+20>>2];if(!a){break N}L[c+20>>2]=a;L[a+24>>2]=c}P:{if(f>>>0<=15){a=f+h|0;L[d+4>>2]=a|3;a=a+d|0;L[a+4>>2]=L[a+4>>2]|1;break P}L[d+4>>2]=h|3;e=d+h|0;L[e+4>>2]=f|1;L[e+f>>2]=f;if(f>>>0<=255){b=(f&-8)+34160|0;c=L[8530];a=1<<(f>>>3);Q:{if(!(c&a)){L[8530]=a|c;a=b;break Q}a=L[b+8>>2]}L[b+8>>2]=e;L[a+12>>2]=e;L[e+12>>2]=b;L[e+8>>2]=a;break P}a=31;if(f>>>0<=16777215){a=U(f>>>8|0);a=((f>>>38-a&1)-(a<<1)|0)+62|0}L[e+28>>2]=a;L[e+16>>2]=0;L[e+20>>2]=0;b=(a<<2)+34424|0;R:{c=1<>2]=e;break S}a=f<<((a|0)!=31?25-(a>>>1|0)|0:0);h=L[b>>2];while(1){b=h;if((L[b+4>>2]&-8)==(f|0)){break R}c=a>>>29|0;a=a<<1;c=(c&4)+b|0;h=L[c+16>>2];if(h){continue}break}L[c+16>>2]=e}L[e+24>>2]=b;L[e+12>>2]=e;L[e+8>>2]=e;break P}a=L[b+8>>2];L[a+12>>2]=e;L[b+8>>2]=e;L[e+24>>2]=0;L[e+12>>2]=b;L[e+8>>2]=a}a=d+8|0;break a}T:{if(!i){break T}b=L[c+28>>2];a=(b<<2)+34424|0;U:{if(L[a>>2]==(c|0)){L[a>>2]=d;if(d){break U}L[8531]=nI(b)&j;break T}L[i+(L[i+16>>2]==(c|0)?16:20)>>2]=d;if(!d){break T}}L[d+24>>2]=i;a=L[c+16>>2];if(a){L[d+16>>2]=a;L[a+24>>2]=d}a=L[c+20>>2];if(!a){break T}L[d+20>>2]=a;L[a+24>>2]=d}V:{if(f>>>0<=15){a=f+h|0;L[c+4>>2]=a|3;a=a+c|0;L[a+4>>2]=L[a+4>>2]|1;break V}L[c+4>>2]=h|3;d=c+h|0;L[d+4>>2]=f|1;L[d+f>>2]=f;if(k){b=(k&-8)+34160|0;e=L[8535];a=1<<(k>>>3);W:{if(!(a&g)){L[8530]=a|g;a=b;break W}a=L[b+8>>2]}L[b+8>>2]=e;L[a+12>>2]=e;L[e+12>>2]=b;L[e+8>>2]=a}L[8535]=d;L[8532]=f}a=c+8|0}fa=l+16|0;return a|0}function Gz(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=S(0),g=0,h=S(0),i=S(0),j=0,k=S(0),l=S(0),m=0,n=S(0),o=S(0),p=S(0),q=S(0),r=0,s=S(0),t=0,u=0,v=S(0),w=S(0),x=0,y=0,z=S(0),A=0,B=S(0),C=0,D=0,E=S(0),F=0,G=S(0),H=0,I=0,K=0,N=S(0),O=S(0),Q=0,U=S(0),V=S(0),W=S(0),X=S(0);e=fa-176|0;fa=e;r=L[b+36>>2];a:{if(J[r+100|0]&1){break a}U=P[r+88>>2]>S(0)?P[a+16>>2]:P[a+20>>2];d=fa-32|0;fa=d;F=L[a+8>>2];t=L[F+4>>2];j=L[L[a+4>>2]+684>>2];m=L[F+12>>2];l=P[m+20>>2];q=P[m+36>>2];h=P[m+24>>2];k=P[m+52>>2];f=P[m+40>>2];i=P[m+56>>2];s=P[m+32>>2];n=P[m>>2];p=P[m+16>>2];v=P[m+4>>2];o=P[m+8>>2];B=P[m+48>>2];w=P[r+8>>2];z=P[r+12>>2];E=P[r+16>>2];L[d+12>>2]=0;G=f;f=S(E-i);i=S(w-B);w=h;h=S(z-k);P[d+8>>2]=S(G*f)+S(S(o*i)+S(w*h));P[d+4>>2]=S(q*f)+S(S(v*i)+S(h*l));P[d>>2]=S(s*f)+S(S(n*i)+S(h*p));f=S(S(1)/P[j+76>>2]);i=S(S(f*P[d>>2])/S(3));b=i>2])/S(3));c=h>>5&134215680^b<<16);g=b>>>11|0;f=S(S(f*P[d+8>>2])/S(3));u=f>>5&134215680^b<<16);c=b>>>11|0;g=L[j+68>>2];C=t>>>5&134215680;A=b;h=f;f=S(S(1)-f);f:{if(S(T(f))>>5&134215680^b<<16);b=b+(t&65535)+(b>>>11)|0;b=b<<16^C^b;b=(b>>>11|0)+b|0;b=b<<3^b;b=(b>>>5|0)+b|0;b=b<<4^b;b=(b>>>17|0)+b|0;b=b<<25^b;C=(b>>>6|0)+b|0;g=L[j+60>>2];A=c+((C>>>0)%(g>>>0)<<2)|0;b=L[A>>2];L[j+96>>2]=L[j+96>>2]+1;c=L[j+92>>2];h:{if(b){while(1){c=c+1|0;L[j+92>>2]=c;if(!((C|0)!=L[b+272>>2]|(x|0)!=L[b+256>>2]|((y|0)!=L[b+260>>2]|(u|0)!=L[b+264>>2]))&(t|0)==L[b+276>>2]){break h}b=L[b+280>>2];if(b){continue}break}}L[j+92>>2]=c+1;b=L[j+84>>2];L[j+84>>2]=b+1;if((b|0)>=L[j+88>>2]){L[8499]=L[8499]+1;if((g|0)>0){while(1){c=L[j+68>>2]+(D<<2)|0;b=L[c>>2];L[c>>2]=0;if(b){while(1){c=L[b+280>>2];ra(b);b=c;if(c){continue}break}}D=D+1|0;if((g|0)!=(D|0)){continue}break}}L[j+92>>2]=1;L[j+96>>2]=1;L[j+84>>2]=0;L[j+76>>2]=1048576e3;L[j+80>>2]=0}b=sa(284);g=pa(b,0,272);L[g+280>>2]=L[A>>2];L[A>>2]=g;L[g+272>>2]=C;L[g+276>>2]=t;L[g+264>>2]=u;L[g+260>>2]=y;L[g+256>>2]=x;x=0;c=fa-144|0;fa=c;f=P[j+76>>2];i=S(S(S(L[g+256>>2])*S(3))*f);p=S(f*S(S(L[g+264>>2])*S(3)));v=S(f*S(S(L[g+260>>2])*S(3)));while(1){h=S(S(P[j+76>>2]*S(x|0))+p);y=0;while(1){n=P[j+76>>2];L[c+20>>2]=0;P[c+16>>2]=h;l=S(S(n*S(y|0))+v);P[c+12>>2]=l;f=S(0);P[c+8>>2]=S(n*S(0))+i;t=L[g+276>>2];L[c+80>>2]=1065353216;L[c+92>>2]=0;L[c+96>>2]=0;L[c+84>>2]=0;L[c+88>>2]=0;L[c+100>>2]=1065353216;L[c+112>>2]=0;L[c+116>>2]=0;L[c+104>>2]=0;L[c+108>>2]=0;L[c+120>>2]=1065353216;L[c+140>>2]=0;L[c+132>>2]=0;L[c+136>>2]=0;L[c+124>>2]=0;L[c+128>>2]=0;i:{if(L[t+4>>2]>19){n=S(0);break i}n=Je(c+8|0,t,c+80|0,c+24|0);t=L[g+276>>2]}u=(g+(y<<4)|0)+(x<<2)|0;P[u>>2]=n;n=P[j+76>>2];L[c+20>>2]=0;P[c+16>>2]=h;P[c+12>>2]=l;P[c+8>>2]=n+i;L[c+80>>2]=1065353216;L[c+92>>2]=0;L[c+96>>2]=0;L[c+84>>2]=0;L[c+88>>2]=0;L[c+100>>2]=1065353216;L[c+112>>2]=0;L[c+116>>2]=0;L[c+104>>2]=0;L[c+108>>2]=0;L[c+120>>2]=1065353216;L[c+140>>2]=0;L[c+132>>2]=0;L[c+136>>2]=0;L[c+124>>2]=0;L[c+128>>2]=0;if(L[t+4>>2]<=19){f=Je(c+8|0,t,c+80|0,c+24|0);t=L[g+276>>2]}P[u- -64>>2]=f;f=P[j+76>>2];L[c+20>>2]=0;P[c+16>>2]=h;P[c+12>>2]=l;P[c+8>>2]=S(f+f)+i;L[c+80>>2]=1065353216;L[c+92>>2]=0;L[c+96>>2]=0;L[c+84>>2]=0;L[c+88>>2]=0;L[c+100>>2]=1065353216;L[c+112>>2]=0;L[c+116>>2]=0;L[c+104>>2]=0;L[c+108>>2]=0;L[c+120>>2]=1065353216;L[c+140>>2]=0;L[c+132>>2]=0;L[c+136>>2]=0;L[c+124>>2]=0;L[c+128>>2]=0;j:{if(L[t+4>>2]>19){f=S(0);break j}f=Je(c+8|0,t,c+80|0,c+24|0);t=L[g+276>>2]}P[u+128>>2]=f;f=P[j+76>>2];L[c+20>>2]=0;P[c+16>>2]=h;P[c+12>>2]=l;P[c+8>>2]=S(f*S(3))+i;L[c+80>>2]=1065353216;L[c+92>>2]=0;L[c+96>>2]=0;L[c+84>>2]=0;L[c+88>>2]=0;L[c+100>>2]=1065353216;L[c+112>>2]=0;L[c+116>>2]=0;L[c+104>>2]=0;L[c+108>>2]=0;L[c+120>>2]=1065353216;L[c+140>>2]=0;L[c+132>>2]=0;L[c+136>>2]=0;L[c+124>>2]=0;L[c+128>>2]=0;if(L[t+4>>2]<=19){f=Je(c+8|0,t,c+80|0,c+24|0)}else{f=S(0)}P[u+192>>2]=f;y=y+1|0;if((y|0)!=4){continue}break}x=x+1|0;if((x|0)!=4){continue}break}fa=c+144|0}L[b+268>>2]=L[j+80>>2];i=S(S(k-S(I|0))*S(3));k:{if(S(T(i))>2];j=j+u|0;p=P[j+c>>2];v=P[b+j>>2];l=P[c+t>>2];q=P[b+t>>2];k=S(l-q);f=S(f-S(y|0));o=S(S(S(S(p-v)-k)*f)+k);B=P[b+A>>2];j=c;c=g+C|0;k=P[j+c>>2];s=P[b+c>>2];w=S(k-s);i=S(i-S(x|0));o=S(S(S(S(S(S(S(h-B)-w)*f)+w)-o)*i)+o);G=o;V=S(o*o);E=S(h-k);o=S(p-l);N=S(B-s);w=S(v-q);z=S(S(S(N-w)*i)+w);n=S(n-S(D|0));z=S(S(S(S(S(S(E-o)*i)+o)-z)*n)+z);p=S(h-p);h=S(k-l);p=S(S(S(p-h)*f)+h);h=S(s-q);h=S(S(S(S(B-v)-h)*f)+h);h=S(S(S(p-h)*n)+h);p=S(S(1)/S(_(S(V+S(S(z*z)+S(h*h))))));P[d+24>>2]=G*p;P[d+20>>2]=h*p;P[d+16>>2]=z*p;h=S(l+S(o*f));h=S(S(S(S(k+S(E*f))-h)*i)+h);o=S(s+S(N*f));f=S(q+S(w*f));f=S(S(S(o-f)*i)+f);f=S(S(S(S(h-f)*n)+f)-U);b=f>2]=L[F+8>>2];s=P[m+8>>2];n=P[m>>2];p=P[m+4>>2];k=P[m+24>>2];v=P[m+16>>2];o=P[m+20>>2];q=P[m+40>>2];B=P[m+32>>2];w=P[m+36>>2];i=P[d+24>>2];h=P[d+16>>2];l=P[d+20>>2];L[e+88>>2]=0;q=S(S(q*i)+S(S(B*h)+S(l*w)));P[e+84>>2]=q;k=S(S(k*i)+S(S(v*h)+S(l*o)));P[e+80>>2]=k;i=S(S(s*i)+S(S(n*h)+S(p*l)));P[e+76>>2]=i;P[e+92>>2]=-S(S(q*S(P[r+16>>2]-S(f*q)))+S(S(i*S(P[r+8>>2]-S(f*i)))+S(k*S(P[r+12>>2]-S(f*k)))))}fa=d+32|0;if(!b){break a}i=P[r+88>>2];d=L[a+12>>2];n:{if(!d){if(!(S(i+S(0))>S(0))){break a}b=L[L[a+8>>2]+8>>2];break n}b=d;O=P[d+344>>2];if(!(S(i+O)>S(0))){break a}}if(!(J[33988]&1)){L[8485]=0;L[8486]=0;J[33988]=1;L[8495]=0;L[8496]=0;L[8493]=0;L[8494]=0;L[8491]=0;L[8492]=0;L[8489]=0;L[8490]=0;L[8487]=0;L[8488]=0}f=P[b+52>>2];s=P[b+56>>2];h=P[r+12>>2];k=P[b+60>>2];l=P[r+16>>2];q=P[r+8>>2];L[e+68>>2]=0;k=S(l-k);P[e+64>>2]=k;s=S(h-s);P[e+60>>2]=s;n=S(q-f);P[e+56>>2]=n;c=d?d+264|0:33940;o:{if(!d){b=L[a+4>>2];f=P[b+452>>2];p=S(0);break o}p=P[d+328>>2];v=P[d+332>>2];b=L[a+4>>2];f=P[b+452>>2];W=S(S(S(S(p*s)-S(n*v))+P[d+320>>2])*f);o=P[d+336>>2];X=S(S(S(S(o*n)-S(k*p))+P[d+316>>2])*f);p=S(S(S(S(v*k)-S(s*o))+P[d+312>>2])*f)}v=P[b+316>>2];o=P[r+32>>2];B=P[r+28>>2];d=L[a+8>>2];w=P[L[d+8>>2]+224>>2];z=P[r+24>>2];L[e+96>>2]=r;k=P[e+84>>2];s=P[e+80>>2];n=P[e+76>>2];sk(e+8|0,f,i,O,c,e+56|0);c=L[e+20>>2];L[e+108>>2]=L[e+16>>2];L[e+112>>2]=c;c=L[e+28>>2];L[e+116>>2]=L[e+24>>2];L[e+120>>2]=c;c=L[e+36>>2];L[e+124>>2]=L[e+32>>2];L[e+128>>2]=c;c=L[e+44>>2];L[e+132>>2]=L[e+40>>2];L[e+136>>2]=c;c=L[e+52>>2];L[e+140>>2]=L[e+48>>2];L[e+144>>2]=c;c=e- -64|0;j=L[c+4>>2];L[e+156>>2]=L[c>>2];L[e+160>>2]=j;c=L[e+12>>2];L[e+100>>2]=L[e+8>>2];L[e+104>>2]=c;P[e+164>>2]=i*f;c=L[e+60>>2];L[e+148>>2]=L[e+56>>2];L[e+152>>2]=c;l=S(S(l-o)-W);q=S(S(q-z)-p);h=S(S(h-B)-X);f=S(S(l*k)+S(S(n*q)+S(s*h)));i=S(v*w);l=S(l-S(k*f));o=S(l*l);l=S(q-S(n*f));h=S(h-S(s*f));P[e+168>>2]=S(o+S(S(l*l)+S(h*h)))>2]=P[(L[L[d+8>>2]+204>>2]&3?328:324)+b>>2];m=0;j=L[b+812>>2];p:{if((j|0)!=L[b+816>>2]){break p}r=j?j<<1:1;if((r|0)<=(j|0)){break p}if(r){L[8513]=L[8513]+1;Q=ha[L[6798]](R(r,104),16)|0;j=L[b+812>>2]}if((j|0)>0){while(1){c=R(m,104);d=c+Q|0;c=c+L[b+820>>2]|0;g=L[c+4>>2];L[d>>2]=L[c>>2];L[d+4>>2]=g;L[d+24>>2]=L[c+24>>2];g=L[c+20>>2];L[d+16>>2]=L[c+16>>2];L[d+20>>2]=g;g=L[c+12>>2];L[d+8>>2]=L[c+8>>2];L[d+12>>2]=g;g=L[c+40>>2];L[d+36>>2]=L[c+36>>2];L[d+40>>2]=g;g=L[c+32>>2];L[d+28>>2]=L[c+28>>2];L[d+32>>2]=g;g=L[c+56>>2];L[d+52>>2]=L[c+52>>2];L[d+56>>2]=g;g=L[c+48>>2];L[d+44>>2]=L[c+44>>2];L[d+48>>2]=g;g=L[c+64>>2];L[d+60>>2]=L[c+60>>2];L[d+64>>2]=g;g=L[c+72>>2];L[d+68>>2]=L[c+68>>2];L[d+72>>2]=g;g=L[c+80>>2];L[d+76>>2]=L[c+76>>2];L[d+80>>2]=g;g=L[c+88>>2];L[d+84>>2]=L[c+84>>2];L[d+88>>2]=g;g=L[c+96>>2];L[d+92>>2]=L[c+92>>2];L[d+96>>2]=g;L[d+100>>2]=L[c+100>>2];m=m+1|0;if((m|0)!=(j|0)){continue}break}}d=L[b+820>>2];if(!(d?!d|!M[b+824|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](d)}L[b+820>>2]=Q;J[b+824|0]=1;L[b+816>>2]=r;j=L[b+812>>2]}c=L[e+76>>2];d=L[b+820>>2]+R(j,104)|0;L[d>>2]=L[e+72>>2];L[d+4>>2]=c;L[d+24>>2]=L[e+96>>2];c=L[e+92>>2];L[d+16>>2]=L[e+88>>2];L[d+20>>2]=c;c=L[e+84>>2];L[d+8>>2]=L[e+80>>2];L[d+12>>2]=c;c=L[e+112>>2];L[d+36>>2]=L[e+108>>2];L[d+40>>2]=c;c=L[e+104>>2];L[d+28>>2]=L[e+100>>2];L[d+32>>2]=c;c=L[e+128>>2];L[d+52>>2]=L[e+124>>2];L[d+56>>2]=c;c=L[e+120>>2];L[d+44>>2]=L[e+116>>2];L[d+48>>2]=c;c=L[e+144>>2];L[d+68>>2]=L[e+140>>2];L[d+72>>2]=c;c=L[e+136>>2];L[d+60>>2]=L[e+132>>2];L[d+64>>2]=c;c=L[e+152>>2];L[d+76>>2]=L[e+148>>2];L[d+80>>2]=c;c=L[e+160>>2];L[d+84>>2]=L[e+156>>2];L[d+88>>2]=c;c=L[e+168>>2];L[d+92>>2]=L[e+164>>2];L[d+96>>2]=c;L[d+100>>2]=L[e+172>>2];L[b+812>>2]=L[b+812>>2]+1;a=L[a+12>>2];if(!a){break a}ib(a,0)}fa=e+176|0}function sB(a,b){a=a|0;b=b|0;var c=0,d=0,e=S(0),f=0,g=S(0),h=S(0),i=S(0),j=S(0),k=S(0),l=0,m=S(0),n=S(0),o=S(0),p=0,q=S(0),r=S(0),s=S(0),t=S(0),u=0,v=S(0),w=S(0),x=S(0),y=S(0),z=S(0),A=S(0),B=S(0),C=S(0),D=S(0),E=0,F=0,G=S(0),H=S(0),I=S(0),K=0,N=S(0),O=S(0),Q=S(0),T=S(0),U=S(0),V=S(0),W=0,X=S(0),Y=S(0),Z=S(0),$=S(0),aa=S(0),ba=0,ca=0,da=S(0),ea=S(0),fa=S(0),ga=S(0),ha=S(0),ia=S(0),ja=S(0),ka=S(0),la=0,ma=0,na=0;d=L[a+32>>2];ba=d+328|0;c=L[a+28>>2];ca=c+328|0;d=d+4|0;c=c+4|0;if(M[a+739|0]){e=P[L[a+32>>2]+344>>2];V=P[L[a+28>>2]+344>>2];j=S(e+V);j=j>S(0)?S(e/j):S(.5);o=S(S(1)-j);q=P[a+672>>2];r=P[d+40>>2];h=P[a+664>>2];s=P[d+32>>2];k=P[d+36>>2];g=P[a+668>>2];m=P[d+56>>2];ga=S(S(S(q*r)+S(S(h*s)+S(k*g)))+m);B=S(ga-m);I=B;m=P[a+592>>2];i=P[c+40>>2];n=P[a+560>>2];y=P[c+32>>2];v=P[a+576>>2];z=P[c+36>>2];O=S(S(m*i)+S(S(n*y)+S(v*z)));t=P[a+656>>2];H=S(t*r);r=P[a+624>>2];N=S(r*s);s=P[a+640>>2];Q=S(H+S(N+S(s*k)));k=S(S(O*j)+S(Q*o));H=k;T=S(k*k);w=P[c+8>>2];A=P[c>>2];D=P[c+4>>2];U=S(S(m*w)+S(S(n*A)+S(D*v)));x=P[d+8>>2];X=P[d>>2];Y=P[d+4>>2];Z=S(S(t*x)+S(S(r*X)+S(Y*s)));k=S(S(U*j)+S(Z*o));C=P[c+24>>2];G=P[c+16>>2];N=v;v=P[c+20>>2];da=S(S(m*C)+S(S(n*G)+S(N*v)));N=P[d+24>>2];$=P[d+16>>2];m=s;s=P[d+20>>2];ea=S(S(t*N)+S(S(r*$)+S(m*s)));t=S(S(da*j)+S(ea*o));r=S(S(1)/S(_(S(T+S(S(k*k)+S(t*t))))));m=S(H*r);H=S(B*m);n=P[d+48>>2];X=S(n+S(S(q*x)+S(S(h*X)+S(Y*g))));B=S(X-n);n=S(k*r);g=S(S(q*N)+S(S(h*$)+S(s*g)));q=P[d+52>>2];Y=S(g+q);s=S(Y-q);q=S(t*r);h=S(H+S(S(B*n)+S(s*q)));k=S(m*h);N=S(I-k);g=P[a+608>>2];t=P[a+600>>2];r=P[a+604>>2];x=P[c+56>>2];$=S(S(S(g*i)+S(S(t*y)+S(z*r)))+x);x=S($-x);H=P[c+48>>2];ha=S(H+S(S(g*w)+S(S(t*A)+S(D*r))));H=S(ha-H);I=S(S(g*C)+S(S(t*G)+S(v*r)));g=P[c+52>>2];ia=S(I+g);T=S(ia-g);g=S(S(m*x)+S(S(H*n)+S(T*q)));aa=S(m*g);k=S(aa-k);t=S(N-S(o*k));r=S(q*h);ja=S(s-r);fa=S(q*g);I=S(fa-r);r=S(ja-S(o*I));h=S(n*h);ka=S(B-h);g=S(n*g);h=S(g-h);s=S(ka-S(o*h));aa=S(x-aa);k=S(aa+S(j*k));T=S(T-fa);B=S(T+S(j*I));g=S(H-g);x=S(g+S(j*h));d=!(eS(1.1920928955078125e-7)){i=S(S(1)/S(_(h)));h=S(e*i);e=S(V*i);g=S(g*i);break a}h=P[a+588>>2];e=S(h*w);w=P[a+556>>2];g=S(w*A);A=P[a+572>>2];g=S(e+S(g+S(D*A)));e=S(S(h*C)+S(S(w*G)+S(A*v)));h=S(S(h*i)+S(S(w*y)+S(A*z)))}p=L[b+24>>2];f=L[b+12>>2];P[f+8>>2]=S(x*e)-S(g*B);P[f+4>>2]=S(k*g)-S(h*x);P[f>>2]=S(B*h)-S(e*k);c=L[b+20>>2];P[c+8>>2]=-S(S(s*e)-S(g*r));P[c+4>>2]=-S(S(t*g)-S(h*s));P[c>>2]=-S(S(r*h)-S(e*t));y=S(S(m*g)-S(h*n));v=S(S(q*h)-S(e*m));i=S(S(s*y)-S(v*r));z=S(S(n*e)-S(g*q));w=S(S(t*v)-S(z*s));A=S(S(r*z)-S(y*t));D=S(S(x*y)-S(v*B));C=S(S(k*v)-S(z*x));G=S(S(B*z)-S(y*k));F=M[a+716|0];if(!(d|!F)){D=S(j*D);C=S(j*C);G=S(j*G);w=S(o*w);A=S(o*A);i=S(o*i)}l=p<<2;u=l+f|0;P[u+8>>2]=D;P[u+4>>2]=C;P[u>>2]=G;P[c+l>>2]=-A;K=p+1|0;P[c+(K<<2)>>2]=-w;W=p+2|0;P[c+(W<<2)>>2]=-i;i=S(S(s*q)+S(n*S(-r)));s=S(S(t*n)+S(m*S(-s)));t=S(S(r*m)+S(q*S(-t)));r=S(S(x*q)+S(n*S(-B)));x=S(S(k*n)+S(m*S(-x)));k=S(S(B*m)+S(q*S(-k)));if(!d){r=S(j*r);x=S(j*x);k=S(j*k);s=S(o*s);t=S(o*t);i=S(o*i)}j=S(-q);o=S(-n);B=S(-m);la=p<<3;d=f+la|0;P[d+8>>2]=r;P[d+4>>2]=x;P[d>>2]=k;u=p<<1;P[c+(u<<2)>>2]=-t;ma=u|1;P[c+(ma<<2)>>2]=-s;na=u+2|0;P[c+(na<<2)>>2]=-i;b:{if(M[a+736|0]){s=S(-z);t=S(-y);i=S(-v);x=S(-h);k=S(-e);r=S(-g);d=L[b+28>>2];break b}C=P[b+4>>2];G=P[b>>2];d=L[b+8>>2];P[d+8>>2]=h;P[d+4>>2]=e;P[d>>2]=g;E=d+l|0;P[E+8>>2]=z;P[E+4>>2]=y;P[E>>2]=v;d=d+la|0;P[d+8>>2]=m;P[d+4>>2]=q;P[d>>2]=n;d=L[b+16>>2];x=S(-h);P[d+8>>2]=x;k=S(-e);P[d+4>>2]=k;r=S(-g);P[d>>2]=r;E=p<<2;i=S(-v);P[E+d>>2]=i;t=S(-y);P[d+(K<<2)>>2]=t;s=S(-z);P[d+(W<<2)>>2]=s;u=u<<2;P[u+d>>2]=o;P[d+(ma<<2)>>2]=j;P[d+(na<<2)>>2]=B;d=L[b+28>>2];w=S(ga-$);A=S(X-ha);D=S(Y-ia);C=S(G*C);P[d>>2]=S(S(h*w)+S(S(g*A)+S(D*e)))*C;P[d+E>>2]=S(S(z*w)+S(S(v*A)+S(D*y)))*C;P[d+u>>2]=C*S(S(m*w)+S(S(n*A)+S(D*q)))}p=R(p,12);P[p+f>>2]=g;u=p+8|0;P[u+f>>2]=h;E=p+4|0;P[E+f>>2]=e;l=l<<2;P[l+f>>2]=v;K=l|4;P[K+f>>2]=y;W=l|8;P[W+f>>2]=z;P[c+p>>2]=r;P[c+u>>2]=x;P[c+E>>2]=k;P[c+l>>2]=i;P[c+K>>2]=t;P[c+W>>2]=s;i=S(S(U*ea)-S(Z*da));k=S(i*h);h=S(S(da*Q)-S(ea*O));s=S(h*g);g=S(S(O*Z)-S(Q*U));k=S(k+S(s+S(g*e)));e=S(P[b>>2]*P[b+4>>2]);P[d+p>>2]=k*e;P[d+l>>2]=S(S(i*z)+S(S(h*v)+S(g*y)))*e;c:{d:{if(F){u=!M[a+737|0];e=S(P[a+708>>2]*P[a+732>>2]);d=e>S(0)?1:2;break d}if(!M[a+737|0]){break c}u=0;e=S(0);d=0}p=R(L[b+24>>2],5);l=p<<2;P[l+f>>2]=n;E=l+8|0;P[E+f>>2]=m;K=f;f=l+4|0;P[K+f>>2]=q;P[c+E>>2]=B;P[c+f>>2]=j;P[c+l>>2]=o;c=a+688|0;j=we(c);o=xe(c);c=L[b+28>>2];L[l+c>>2]=0;f=L[a+748>>2];h=P[(f&2?a+760|0:b+4|0)>>2];if(!((F|0)!=0&j==o|u)){if(f&4){P[L[b+32>>2]+(p<<2)>>2]=P[a+752>>2]}g=pd(P[a+728>>2],j,o,P[a+680>>2],S(h*P[b>>2]));c=L[b+28>>2];f=p<<2;l=c+f|0;P[l>>2]=S(S(g*P[a+680>>2])*P[a+732>>2])+P[l>>2];P[f+L[b+36>>2]>>2]=-P[a+684>>2];P[f+L[b+40>>2]>>2]=P[a+684>>2]}if(!F){break c}f=p<<2;c=f+c|0;P[c>>2]=S(S(h*P[b>>2])*e)+P[c>>2];if(J[a+748|0]&1){P[f+L[b+32>>2]>>2]=P[a+756>>2]}e:{if(j==o){L[L[b+36>>2]+(p<<2)>>2]=-8388609;e=S(34028234663852886e22);break e}f=L[b+36>>2]+(p<<2)|0;if((d|0)==1){L[f>>2]=0;e=S(34028234663852886e22);break e}L[f>>2]=-8388609;e=S(0)}P[L[b+40>>2]+(p<<2)>>2]=e;j=P[a+704>>2];f:{if(!(j>S(0))){break f}e=S(S(S(P[ca+8>>2]*m)+S(S(P[ca>>2]*n)+S(P[ca+4>>2]*q)))-S(S(P[ba+8>>2]*m)+S(S(P[ba>>2]*n)+S(q*P[ba+4>>2]))));g:{if((d|0)==1){if(!(eP[c>>2]){break g}break f}if(!(e>S(0))){break f}e=S(e*S(-j));if(!(e>2])){break f}}P[c>>2]=e}P[c>>2]=P[a+700>>2]*P[c>>2]}return}h=P[a+656>>2];A=P[d+40>>2];V=S(h*A);g=P[a+624>>2];D=P[d+32>>2];i=P[a+640>>2];C=P[d+36>>2];ga=S(S(g*D)+S(i*C));G=P[d+24>>2];X=S(h*G);O=P[d+16>>2];Q=P[d+20>>2];Y=S(S(g*O)+S(i*Q));y=P[a+592>>2];e=P[c+40>>2];N=S(y*e);v=P[a+560>>2];j=P[c+32>>2];z=P[a+576>>2];o=P[c+36>>2];$=S(S(v*j)+S(z*o));t=P[a+588>>2];H=S(t*e);r=P[a+556>>2];s=P[a+572>>2];ha=S(S(r*j)+S(s*o));k=P[a+584>>2];ia=S(k*e);B=P[a+552>>2];x=P[a+568>>2];T=S(S(B*j)+S(x*o));m=P[c+24>>2];aa=S(y*m);n=P[c+16>>2];q=P[c+20>>2];ja=S(S(v*n)+S(z*q));w=P[a+672>>2];I=S(w*A);A=P[a+664>>2];U=S(A*D);D=P[a+668>>2];C=S(S(I+S(U+S(C*D)))+P[d+56>>2]);G=S(S(S(w*G)+S(S(A*O)+S(Q*D)))+P[d+52>>2]);O=P[a+608>>2];Q=P[a+600>>2];U=P[a+604>>2];Z=P[c+56>>2];da=S(S(S(O*e)+S(S(Q*j)+S(o*U)))+Z);e=P[c+52>>2];ea=S(S(S(O*m)+S(S(Q*n)+S(q*U)))+e);I=g;g=P[d>>2];fa=P[d+4>>2];I=S(S(I*g)+S(fa*i));i=P[d+8>>2];ka=S(h*i);j=P[c>>2];o=P[c+4>>2];v=S(S(v*j)+S(o*z));h=P[c+8>>2];z=S(y*h);g=S(P[d+48>>2]+S(S(w*i)+S(S(A*g)+S(fa*D))));i=P[c+48>>2];y=S(i+S(S(O*h)+S(S(Q*j)+S(o*U))));p=L[b+24>>2];F=M[a+736|0];if(!F){f=L[b+8>>2];L[f>>2]=1065353216;l=(p<<2)+4|0;L[l+f>>2]=1065353216;u=(p<<3)+8|0;L[u+f>>2]=1065353216;f=L[b+16>>2];L[f>>2]=-1082130432;L[f+l>>2]=-1082130432;L[f+u>>2]=-1082130432;Z=P[c+56>>2];i=P[c+48>>2];e=P[c+52>>2]}c=L[b+12>>2];L[c+12>>2]=0;w=S(da-Z);P[c+4>>2]=w;L[c>>2]=0;e=S(ea-e);P[c+8>>2]=-e;l=p<<2;f=l+c|0;L[f+12>>2]=0;i=S(y-i);P[f+8>>2]=i;L[f+4>>2]=0;P[f>>2]=-w;u=p<<3;f=u+c|0;L[f+8>>2]=0;L[f+12>>2]=0;P[f+4>>2]=-i;P[f>>2]=e;e=P[d+48>>2];i=P[d+56>>2];w=P[d+52>>2];f=L[b+20>>2];L[f+12>>2]=0;L[f>>2]=0;w=S(G-w);P[f+8>>2]=w;i=S(C-i);P[f+4>>2]=-i;d=f+l|0;L[d+12>>2]=0;e=S(g-e);P[d+8>>2]=-e;L[d+4>>2]=0;P[d>>2]=i;d=f+u|0;L[d+8>>2]=0;L[d+12>>2]=0;P[d+4>>2]=e;P[d>>2]=-w;e=S(P[b>>2]*P[b+4>>2]);d=L[b+28>>2];if(!F){P[d>>2]=e*S(g-y);P[d+l>>2]=e*S(G-ea);P[d+(p<<3)>>2]=e*S(C-da)}l=R(p,12);g=S(S(k*h)+S(S(B*j)+S(x*o)));P[l+c>>2]=g;u=l+8|0;i=S(ia+T);P[u+c>>2]=i;E=l+4|0;y=S(S(k*m)+S(S(B*n)+S(x*q)));P[E+c>>2]=y;F=p<<4;h=S(S(t*h)+S(S(r*j)+S(o*s)));P[F+c>>2]=h;K=F|4;n=S(S(t*m)+S(S(r*n)+S(s*q)));P[K+c>>2]=n;W=F|8;q=S(H+ha);P[W+c>>2]=q;P[f+l>>2]=-g;P[f+u>>2]=-i;P[f+E>>2]=-y;P[f+F>>2]=-h;P[f+K>>2]=-n;P[f+W>>2]=-q;j=S(z+v);m=S(X+Y);v=S(ka+I);o=S(aa+ja);z=S(S(j*m)-S(v*o));s=S(z*i);i=S(V+ga);k=m;m=S(N+$);t=S(S(o*i)-S(k*m));k=S(t*g);g=S(S(m*v)-S(i*j));P[d+l>>2]=S(s+S(k+S(y*g)))*e;P[d+F>>2]=S(S(z*q)+S(S(t*h)+S(n*g)))*e;F=M[a+716|0];h:{i:{if(F){u=!M[a+737|0];q=S(P[a+708>>2]*P[a+732>>2]);d=q>S(0)?1:2;break i}if(!M[a+737|0]){break h}u=0;q=S(0);d=0}p=R(p,5);l=p<<2;P[l+c>>2]=j;E=l+8|0;P[E+c>>2]=m;K=c;c=l+4|0;P[K+c>>2]=o;P[f+E>>2]=-m;P[c+f>>2]=-o;P[f+l>>2]=-j;c=a+688|0;e=we(c);n=xe(c);c=L[b+28>>2];L[l+c>>2]=0;f=L[a+748>>2];h=P[(f&2?a+760|0:b+4|0)>>2];if(!((F|0)!=0&e==n|u)){if(f&4){P[L[b+32>>2]+(p<<2)>>2]=P[a+752>>2]}g=pd(P[a+728>>2],e,n,P[a+680>>2],S(h*P[b>>2]));c=L[b+28>>2];f=p<<2;l=c+f|0;P[l>>2]=S(S(g*P[a+680>>2])*P[a+732>>2])+P[l>>2];P[f+L[b+36>>2]>>2]=-P[a+684>>2];P[f+L[b+40>>2]>>2]=P[a+684>>2]}if(!F){break h}f=p<<2;c=f+c|0;P[c>>2]=S(S(h*P[b>>2])*q)+P[c>>2];if(J[a+748|0]&1){P[f+L[b+32>>2]>>2]=P[a+756>>2]}j:{if(e==n){L[L[b+36>>2]+(p<<2)>>2]=-8388609;e=S(34028234663852886e22);break j}f=L[b+36>>2]+(p<<2)|0;if((d|0)==1){L[f>>2]=0;e=S(34028234663852886e22);break j}L[f>>2]=-8388609;e=S(0)}P[L[b+40>>2]+(p<<2)>>2]=e;n=P[a+704>>2];k:{if(!(n>S(0))){break k}e=S(S(S(P[ca+8>>2]*m)+S(S(P[ca>>2]*j)+S(o*P[ca+4>>2])))-S(S(P[ba+8>>2]*m)+S(S(P[ba>>2]*j)+S(o*P[ba+4>>2]))));l:{if((d|0)==1){if(!(eP[c>>2]){break l}break k}if(!(e>S(0))){break k}e=S(e*S(-n));if(!(e>2])){break k}}P[c>>2]=e}P[c>>2]=P[a+700>>2]*P[c>>2]}}function nk(a,b,c,d,e){var f=0,g=0,h=S(0),i=S(0),j=S(0),k=S(0),l=S(0),m=S(0),n=S(0),o=S(0),p=0,q=S(0),r=S(0),s=S(0),t=S(0),u=S(0),v=0,w=S(0),x=S(0),y=S(0),z=0,A=S(0),B=S(0),C=0,D=0,E=S(0),F=S(0),G=0,H=S(0),I=S(0),K=S(0),N=S(0),O=S(0),Q=S(0),R=S(0),T=S(0),U=S(0),V=S(0),W=S(0),X=S(0),Y=S(0),Z=S(0),$=S(0),aa=S(0),ba=S(0),ca=S(0),da=S(0),ea=S(0),ga=S(0),ha=S(0),ia=0;p=fa-48|0;fa=p;ia=P[b+52>>2]>2];if(ia){i=P[b+44>>2];q=P[b+36>>2];m=P[b+40>>2];h=S(S(i*i)+S(S(q*q)+S(m*m)));E=P[b+48>>2];G=M[33872];if(!(G&1)){if(!(J[30088]&1)){if(!(J[30140]&1)){L[7524]=0;L[7525]=0;L[7523]=1065353216;J[30140]=1;L[7526]=0;L[7527]=0;L[7529]=0;L[7530]=0;L[7528]=1065353216;L[7531]=0;L[7532]=0;L[7533]=1065353216;L[7534]=0}L[7518]=0;L[7519]=0;J[30088]=1;g=L[7524];L[7506]=L[7523];L[7507]=g;g=L[7528];L[7510]=L[7527];L[7511]=g;g=L[7532];L[7514]=L[7531];L[7515]=g;L[7520]=0;L[7521]=0;g=L[7526];L[7508]=L[7525];L[7509]=g;g=L[7530];L[7512]=L[7529];L[7513]=g;g=L[7534];L[7516]=L[7533];L[7517]=g}J[33872]=1;g=L[7507];L[8452]=L[7506];L[8453]=g;g=L[7511];L[8456]=L[7510];L[8457]=g;g=L[7515];L[8460]=L[7514];L[8461]=g;g=L[7519];L[8464]=L[7518];L[8465]=g;g=L[7509];L[8454]=L[7508];L[8455]=g;g=L[7513];L[8458]=L[7512];L[8459]=g;g=L[7517];L[8462]=L[7516];L[8463]=g;g=L[7521];L[8466]=L[7520];L[8467]=g;G=1}f=L[c+8>>2];g=L[c>>2];z=f?f+4|0:g?g+60|0:33808;j=P[z+48>>2];l=P[b+4>>2];n=P[z+56>>2];k=P[b+12>>2];A=P[z+52>>2];u=P[b+8>>2];if(!(G&1)){G=1;if(!(J[30088]&1)){if(!(J[30140]&1)){L[7524]=0;L[7525]=0;L[7523]=1065353216;J[30140]=1;L[7526]=0;L[7527]=0;L[7529]=0;L[7530]=0;L[7528]=1065353216;L[7531]=0;L[7532]=0;L[7533]=1065353216;L[7534]=0}L[7518]=0;L[7519]=0;J[30088]=1;f=L[7524];L[7506]=L[7523];L[7507]=f;f=L[7528];L[7510]=L[7527];L[7511]=f;f=L[7532];L[7514]=L[7531];L[7515]=f;L[7520]=0;L[7521]=0;f=L[7526];L[7508]=L[7525];L[7509]=f;f=L[7530];L[7512]=L[7529];L[7513]=f;f=L[7534];L[7516]=L[7533];L[7517]=f}J[33872]=1;f=L[7507];L[8452]=L[7506];L[8453]=f;f=L[7511];L[8456]=L[7510];L[8457]=f;f=L[7515];L[8460]=L[7514];L[8461]=f;f=L[7519];L[8464]=L[7518];L[8465]=f;f=L[7509];L[8454]=L[7508];L[8455]=f;f=L[7513];L[8458]=L[7512];L[8459]=f;f=L[7517];L[8462]=L[7516];L[8463]=f;f=L[7521];L[8466]=L[7520];L[8467]=f}j=S(l-j);l=S(k-n);n=S(u-A);k=i;i=S(S(1)/S(_(h)));A=S(k*i);u=S(m*i);w=S(q*i);v=L[d+8>>2];f=L[d>>2];v=v?v+4|0:f?f+60|0:33808;i=S(P[b+20>>2]-P[v+48>>2]);q=S(P[b+28>>2]-P[v+56>>2]);m=S(P[b+24>>2]-P[v+52>>2]);a:{b:{C=L[c+4>>2];if(!C){if(g){break b}k=S(0);h=S(0);break a}h=P[C+328>>2];k=P[C+332>>2];r=S(S(h*n)-S(j*k));o=P[C+336>>2];s=S(S(o*j)-S(l*h));t=S(S(k*l)-S(n*o));k=P[C+312>>2];o=P[C+320>>2];h=P[C+316>>2];break a}h=P[g+332>>2];k=P[g+336>>2];r=S(S(h*n)-S(j*k));o=P[g+340>>2];s=S(S(o*j)-S(l*h));t=S(S(k*l)-S(n*o));k=P[g+316>>2];o=P[g+324>>2];h=P[g+320>>2]}x=S(o+r);y=S(h+s);B=S(k+t);c:{d:{D=L[d+4>>2];if(!D){if(f){break d}s=S(0);o=S(0);h=S(0);k=S(0);t=S(0);r=S(0);break c}h=P[D+328>>2];r=P[D+332>>2];k=S(S(h*m)-S(i*r));s=P[D+336>>2];h=S(S(s*i)-S(q*h));o=S(S(r*q)-S(m*s));s=P[D+316>>2];t=P[D+320>>2];r=P[D+312>>2];break c}h=P[f+332>>2];r=P[f+336>>2];k=S(S(h*m)-S(i*r));s=P[f+340>>2];h=S(S(s*i)-S(q*h));o=S(S(r*q)-S(m*s));s=P[f+320>>2];t=P[f+324>>2];r=P[f+316>>2]}F=P[a+12>>2];Q=P[b+52>>2];b=L[c+4>>2];L[e+4>>2]=L[c>>2];L[e+8>>2]=b;L[e+12>>2]=L[c+8>>2];b=L[d+4>>2];L[e+16>>2]=L[d>>2];L[e+20>>2]=b;L[e+24>>2]=L[d+8>>2];k=S(x-S(t+k));r=S(B-S(r+o));s=S(y-S(s+h));h=S(S(k*A)+S(S(r*w)+S(u*s)));o=S(A*h);if(!(G&1)){if(!(J[30088]&1)){if(!(J[30140]&1)){L[7524]=0;L[7525]=0;L[7523]=1065353216;J[30140]=1;L[7526]=0;L[7527]=0;L[7529]=0;L[7530]=0;L[7528]=1065353216;L[7531]=0;L[7532]=0;L[7533]=1065353216;L[7534]=0}L[7518]=0;L[7519]=0;J[30088]=1;b=L[7524];L[7506]=L[7523];L[7507]=b;b=L[7528];L[7510]=L[7527];L[7511]=b;b=L[7532];L[7514]=L[7531];L[7515]=b;L[7520]=0;L[7521]=0;b=L[7526];L[7508]=L[7525];L[7509]=b;b=L[7530];L[7512]=L[7529];L[7513]=b;b=L[7534];L[7516]=L[7533];L[7517]=b}J[33872]=1;b=L[7507];L[8452]=L[7506];L[8453]=b;b=L[7511];L[8456]=L[7510];L[8457]=b;b=L[7515];L[8460]=L[7514];L[8461]=b;b=L[7519];L[8464]=L[7518];L[8465]=b;b=L[7509];L[8454]=L[7508];L[8455]=b;b=L[7513];L[8458]=L[7512];L[8459]=b;b=L[7517];L[8462]=L[7516];L[8463]=b;b=L[7521];L[8466]=L[7520];L[8467]=b;G=1}t=P[z+36>>2];x=P[z+20>>2];y=P[z+40>>2];B=P[z+24>>2];H=P[z+4>>2];I=P[z+8>>2];K=P[z+32>>2];N=P[z>>2];O=P[z+16>>2];L[e+40>>2]=0;P[e+28>>2]=S(K*l)+S(S(N*j)+S(n*O));P[e+36>>2]=S(y*l)+S(S(I*j)+S(n*B));P[e+32>>2]=S(t*l)+S(S(H*j)+S(n*x));if(!(G&1)){if(!(J[30088]&1)){if(!(J[30140]&1)){L[7524]=0;L[7525]=0;L[7523]=1065353216;J[30140]=1;L[7526]=0;L[7527]=0;L[7529]=0;L[7530]=0;L[7528]=1065353216;L[7531]=0;L[7532]=0;L[7533]=1065353216;L[7534]=0}L[7518]=0;L[7519]=0;J[30088]=1;b=L[7524];L[7506]=L[7523];L[7507]=b;b=L[7528];L[7510]=L[7527];L[7511]=b;b=L[7532];L[7514]=L[7531];L[7515]=b;L[7520]=0;L[7521]=0;b=L[7526];L[7508]=L[7525];L[7509]=b;b=L[7530];L[7512]=L[7529];L[7513]=b;b=L[7534];L[7516]=L[7533];L[7517]=b}J[33872]=1;b=L[7507];L[8452]=L[7506];L[8453]=b;b=L[7511];L[8456]=L[7510];L[8457]=b;b=L[7515];L[8460]=L[7514];L[8461]=b;b=L[7519];L[8464]=L[7518];L[8465]=b;b=L[7509];L[8454]=L[7508];L[8455]=b;b=L[7513];L[8458]=L[7512];L[8459]=b;b=L[7517];L[8462]=L[7516];L[8463]=b;b=L[7521];L[8466]=L[7520];L[8467]=b}t=P[v+36>>2];x=P[v+20>>2];y=P[v+40>>2];B=P[v+24>>2];H=P[v+4>>2];I=P[v+8>>2];K=P[v+32>>2];N=P[v>>2];O=P[v+16>>2];L[e+192>>2]=0;P[e+188>>2]=q;P[e+184>>2]=m;c=e+180|0;P[c>>2]=i;L[e+176>>2]=0;P[e+172>>2]=l;P[e+168>>2]=n;P[e+164>>2]=j;L[e+56>>2]=0;L[e+156>>2]=0;L[e+160>>2]=0;L[e+60>>2]=1065353216;L[e+64>>2]=1065353216;P[e+208>>2]=E;P[e+204>>2]=A;P[e+200>>2]=u;P[e+196>>2]=w;L[e+84>>2]=0;j=S(Q-F);P[e+80>>2]=A*j;P[e+76>>2]=u*j;P[e+72>>2]=w*j;L[e+68>>2]=1065353216;P[e+44>>2]=S(K*q)+S(S(N*i)+S(m*O));P[e+52>>2]=S(y*q)+S(S(I*i)+S(m*B));P[e+48>>2]=S(t*q)+S(S(H*i)+S(m*x));J[e+152|0]=0;j=P[a+16>>2];l=S(k-o);i=S(l*l);l=S(r-S(w*h));r=S(l*l);l=S(s-S(u*h));P[e+212>>2]=S(i+S(r+S(l*l)))>2]}b=M[33936];if(!(b&1)){L[8472]=0;L[8473]=0;J[33936]=1;L[8482]=0;L[8483]=0;L[8480]=0;L[8481]=0;L[8478]=0;L[8479]=0;L[8476]=0;L[8477]=0;L[8474]=0;L[8475]=0;b=1}f:{if(D){a=D+344|0}else{l=S(0);if(!f){break f}a=f+128|0}l=P[a>>2]}if(!(b&1)){L[8472]=0;L[8473]=0;J[33936]=1;L[8482]=0;L[8483]=0;L[8480]=0;L[8481]=0;L[8478]=0;L[8479]=0;L[8476]=0;L[8477]=0;L[8474]=0;L[8475]=0}a=C?C+264|0:g?g+180|0:33888;u=P[a+40>>2];w=P[a+24>>2];o=P[a+36>>2];t=P[a+20>>2];b=D?D+264|0:f?f+180|0:33888;E=P[b+40>>2];x=P[b+24>>2];y=P[b+36>>2];B=P[b+20>>2];n=P[e+168>>2];F=P[a+8>>2];Q=P[a+4>>2];H=P[a+32>>2];i=P[e+164>>2];I=P[a>>2];q=P[e+172>>2];K=P[a+16>>2];m=P[c+4>>2];N=P[b+8>>2];O=P[b+4>>2];T=P[b+32>>2];h=P[c>>2];U=P[b>>2];k=P[c+8>>2];V=P[b+16>>2];L[p+44>>2]=0;L[p+28>>2]=0;L[p+12>>2]=0;W=S(S(H*n)+S(S(I*S(0))-S(K*q)));X=S(S(o*n)+S(S(Q*S(0))-S(t*q)));Y=S(S(u*n)+S(S(F*S(0))-S(w*q)));Z=S(S(T*m)+S(S(U*S(0))-S(V*k)));$=S(S(y*m)+S(S(O*S(0))-S(B*k)));aa=S(S(E*m)+S(S(N*S(0))-S(x*k)));r=S(S(j-S(S(S(W*S(0))+S(q*X))-S(n*Y)))+S(l-S(S(S(Z*S(0))+S(k*$))-S(m*aa))));ba=S(S(S(F*q)+S(w*S(0)))-S(u*i));ca=S(S(S(Q*q)+S(t*S(0)))-S(o*i));da=S(S(S(I*q)+S(K*S(0)))-S(H*i));ea=S(S(S(N*k)+S(x*S(0)))-S(E*h));ga=S(S(S(O*k)+S(B*S(0)))-S(y*h));ha=S(S(S(U*k)+S(V*S(0)))-S(T*h));s=S(S(j-S(S(i*ba)+S(S(ca*S(0))-S(q*da))))+S(l-S(S(h*ea)+S(S(ga*S(0))-S(k*ha)))));A=S(S(S(0)-S(S(Y*S(0))+S(S(n*W)-S(X*i))))+S(S(0)-S(S(aa*S(0))+S(S(m*Z)-S($*h)))));R=S(S(S(0)-S(S(S(da*S(0))+S(q*ca))-S(n*ba)))+S(S(0)-S(S(S(ha*S(0))+S(k*ga))-S(m*ea))));F=S(S(u*S(0))+S(S(i*w)-S(F*n)));o=S(S(o*S(0))+S(S(i*t)-S(Q*n)));t=S(S(H*S(0))+S(S(i*K)-S(I*n)));E=S(S(E*S(0))+S(S(h*x)-S(N*m)));x=S(S(y*S(0))+S(S(h*B)-S(O*m)));y=S(S(T*S(0))+S(S(h*V)-S(U*m)));u=S(S(S(0)-S(S(i*F)+S(S(o*S(0))-S(q*t))))+S(S(0)-S(S(h*E)+S(S(x*S(0))-S(k*y)))));w=S(S(S(0)-S(S(S(t*S(0))+S(q*o))-S(n*F)))+S(S(0)-S(S(S(y*S(0))+S(k*x))-S(m*E))));B=S(S(R*u)-S(w*s));o=S(S(j-S(S(F*S(0))+S(S(n*t)-S(o*i))))+S(l-S(S(E*S(0))+S(S(m*y)-S(x*h)))));n=S(S(S(0)-S(S(ba*S(0))+S(S(n*da)-S(ca*i))))+S(S(0)-S(S(ea*S(0))+S(S(m*ha)-S(ga*h)))));m=S(S(s*o)-S(u*n));l=S(S(S(0)-S(S(i*Y)+S(S(X*S(0))-S(q*W))))+S(S(0)-S(S(h*aa)+S(S($*S(0))-S(k*Z)))));i=S(S(n*w)-S(o*R));j=S(S(1)/S(S(A*B)+S(S(r*m)+S(l*i))));P[p+40>>2]=S(S(r*s)-S(R*l))*j;P[p+36>>2]=S(S(l*w)-S(u*r))*j;P[p+32>>2]=B*j;P[p+24>>2]=S(S(A*R)-S(n*r))*j;P[p+20>>2]=S(S(r*o)-S(w*A))*j;P[p+16>>2]=i*j;P[p+8>>2]=S(S(l*n)-S(s*A))*j;P[p+4>>2]=S(S(A*u)-S(o*l))*j;P[p>>2]=m*j;a=L[p+12>>2];L[e+112>>2]=L[p+8>>2];L[e+116>>2]=a;a=L[p+4>>2];L[e+104>>2]=L[p>>2];L[e+108>>2]=a;a=L[p+20>>2];L[e+120>>2]=L[p+16>>2];L[e+124>>2]=a;a=L[p+28>>2];L[e+128>>2]=L[p+24>>2];L[e+132>>2]=a;a=L[p+36>>2];L[e+136>>2]=L[p+32>>2];L[e+140>>2]=a;a=L[p+44>>2];L[e+144>>2]=L[p+40>>2];L[e+148>>2]=a}fa=p+48|0;return ia}function _j(a,b,c,d,e){var f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,M=0,N=0,O=0,P=0,Q=0,S=0,T=0,U=0,V=0,W=0;k=fa-48|0;fa=k;x=L[e>>2];q=b;S=L[d>>2];if(S){q=L[S+12>>2]}D=L[q+96>>2];l=c;t=L[b+96>>2];E=L[c+96>>2]-t|0;i=L[(S?S:x)+12>>2];s=L[b+92>>2];j=L[i+92>>2]-s|0;K=L[c+92>>2]-s|0;u=L[i+96>>2]-t|0;H=R(E,j)-R(K,u)|0;M=H>>31;r=E>>31;m=mI(H,M,E,r);h=ga;w=L[b+88>>2];i=L[i+88>>2]-w|0;T=L[c+88>>2]-w|0;I=R(i,K)-R(j,T)|0;N=I>>31;o=T;n=o>>31;j=mI(I,N,o,n);b=m-j|0;y=L[q+92>>2];c=y;F=b;z=h-(ga+(j>>>0>m>>>0)|0)|0;g=mI(b,z,c,c>>31);f=ga;c=K;m=c>>31;v=mI(I,N,c,m);h=ga;J=R(o,u)-R(i,E)|0;O=J>>31;i=mI(J,O,E,r);b=v-i|0;q=L[q+88>>2];j=q;G=b;A=h-(ga+(i>>>0>v>>>0)|0)|0;b=mI(b,A,j,j>>31);i=b+g|0;f=ga+f|0;f=b>>>0>i>>>0?f+1|0:f;j=mI(o,n,J,O);o=ga;c=mI(c,m,H,M);B=j-c|0;C=o-(ga+(c>>>0>j>>>0)|0)|0;c=mI(B,C,D,D>>31);b=c+i|0;f=ga+f|0;o=b>>>0>>0?f+1|0:f;c=mI(H,M,w,w>>31);j=ga;h=c;c=mI(I,N,t,t>>31);i=h+c|0;g=ga+j|0;g=c>>>0>i>>>0?g+1|0:g;j=mI(J,O,s,s>>31);c=j+i|0;h=ga+g|0;s=c;t=c>>>0>>0?h+1|0:h;l=x?L[x+12>>2]:l;w=L[l+96>>2];v=L[l+92>>2];u=L[l+88>>2];c=x;a:{if(!S){break a}c=x;if(!L[S+12>>2]){break a}c=L[L[S+8>>2]+4>>2];g=L[c+12>>2];i=L[g+92>>2];m=i>>31;h=mI(i,m,J,O);f=ga;n=h;j=L[g+88>>2];r=j>>31;h=mI(j,r,H,M);n=n+h|0;f=ga+f|0;f=h>>>0>n>>>0?f+1|0:f;l=n;h=L[g+96>>2];P=h>>31;n=mI(h,P,I,N);l=l+n|0;g=ga+f|0;g=l>>>0>>0?g+1|0:g;b:{if(l>>>0>>0&(t|0)>=(g|0)|(g|0)<(t|0)){break b}l=c+12|0;p=L[a+100>>2];while(1){if((p|0)==L[c+20>>2]){break b}m=mI(i,m,F,z);i=ga;j=mI(j,r,G,A);m=j+m|0;f=ga+i|0;f=j>>>0>m>>>0?f+1|0:f;i=mI(h,P,B,C);j=i+m|0;f=ga+f|0;f=i>>>0>j>>>0?f+1|0:f;i=f;if((o|0)>=(f|0)&b>>>0>=j>>>0|(f|0)<(o|0)){break b}L[d>>2]=c;b=L[l>>2];D=L[b+96>>2];y=L[b+92>>2];q=L[b+88>>2];if(b){c=L[L[c+8>>2]+4>>2];l=c+12|0;b=j;o=i;n=L[c+12>>2];j=n;i=L[j+92>>2];m=i>>31;h=mI(i,m,J,O);f=ga;g=h;j=L[j+88>>2];r=j>>31;h=mI(j,r,H,M);Q=g+h|0;g=ga+f|0;g=h>>>0>Q>>>0?g+1|0:g;h=L[n+96>>2];P=h>>31;f=mI(h,P,I,N);n=f+Q|0;g=ga+g|0;g=f>>>0>n>>>0?g+1|0:g;if(n>>>0>>0&(t|0)>=(g|0)|(g|0)<(t|0)){break b}continue}break}b=j;o=i}c=L[e>>2]}j=mI(F,z,v,v>>31);i=ga;h=j;j=mI(G,A,u,u>>31);h=h+j|0;f=ga+i|0;f=h>>>0>>0?f+1|0:f;j=mI(B,C,w,w>>31);i=j+h|0;g=ga+f|0;m=i>>>0>>0?g+1|0:g;c:{if(!c){c=0;break c}if(!L[c+12>>2]){break c}l=L[L[c+8>>2]>>2];n=L[l+12>>2];h=n;j=L[h+92>>2];r=j>>31;f=mI(j,r,J,O);g=ga;p=f;h=L[h+88>>2];P=h>>31;f=mI(h,P,H,M);p=p+f|0;g=ga+g|0;g=f>>>0>p>>>0?g+1|0:g;n=L[n+96>>2];U=n>>31;f=mI(n,U,I,N);p=f+p|0;g=ga+g|0;g=f>>>0>p>>>0?g+1|0:g;if(p>>>0>>0&(t|0)>=(g|0)|(g|0)<(t|0)){break c}V=l+12|0;Q=L[a+100>>2];while(1){f=l;if((Q|0)==L[f+20>>2]){break c}j=mI(j,r,F,z);g=ga;l=j;j=mI(h,P,G,A);l=l+j|0;h=ga+g|0;h=j>>>0>l>>>0?h+1|0:h;n=mI(B,C,n,U);j=n+l|0;g=ga+h|0;g=j>>>0>>0?g+1|0:g;h=g;if((m|0)>=(g|0)&i>>>0>=j>>>0|(g|0)<(m|0)){break c}L[e>>2]=f;c=L[V>>2];w=L[c+96>>2];v=L[c+92>>2];u=L[c+88>>2];if(c){l=L[L[f+8>>2]>>2];V=l+12|0;c=f;i=j;m=h;n=L[l+12>>2];h=n;j=L[h+92>>2];r=j>>31;f=mI(j,r,J,O);g=ga;p=f;h=L[h+88>>2];P=h>>31;f=mI(h,P,H,M);p=p+f|0;g=ga+g|0;g=f>>>0>p>>>0?g+1|0:g;f=p;n=L[n+96>>2];U=n>>31;p=mI(n,U,I,N);W=f+p|0;f=ga+g|0;f=p>>>0>W>>>0?f+1|0:f;if(s>>>0>W>>>0&(t|0)>=(f|0)|(f|0)<(t|0)){break c}continue}break}c=f;i=j;m=h}o=m-((b>>>0>i>>>0)+o|0)|0;d:{b=i-b|0;if(!!b&(o|0)>=0|(o|0)>0){t=L[a+100>>2];while(1){c=L[d>>2];while(1){e:{j=(R(v-y|0,K)+R(u-q|0,T)|0)+R(w-D|0,E)|0;r=j>>31;if(!c|!L[c+12>>2]){break e}s=L[L[c>>2]+8>>2];if((t|0)>=L[s+20>>2]){break e}i=L[s+12>>2];l=L[i+92>>2];a=l-y|0;x=L[i+88>>2];h=x-q|0;n=L[i+96>>2];m=n-D|0;p=(R(a,K)+R(h,T)|0)+R(m,E)|0;a=mI(F,z,a,a>>31);i=ga;f=a;a=mI(G,A,h,h>>31);h=f+a|0;g=ga+i|0;g=a>>>0>h>>>0?g+1|0:g;i=mI(B,C,m,m>>31);a=i+h|0;f=ga+g|0;f=a>>>0>>0?f+1|0:f;f:{if(!(f|a)){if((p|0)<0){break f}break e}if((f|0)>0|(f|0)>=0){break e}L[k+32>>2]=0-a;L[k+36>>2]=0-(((a|0)!=0)+f|0);h=(p|0)>0;L[k+40>>2]=h?-1:p>>>31|0;i=(p|0)<0;L[k+24>>2]=h?p:i?0-p|0:0;a=p>>31;L[k+28>>2]=h?a:i?0-(((p|0)!=0)+a|0)|0:0;g:{if((j|0)>0){L[k+16>>2]=1;m=r;h=-1;a=j;break g}if((j|0)<0){L[k+16>>2]=-1;m=0-(((j|0)!=0)+r|0)|0;h=1;a=0-j|0;break g}L[k+16>>2]=0;m=0;h=0;a=0}L[k>>2]=a;L[k+4>>2]=m;a=b;i=o;h:{if(!!a&(i|0)>=0|(i|0)>0){break h}i=0;a=0;if((o|0)>0|(o|0)>=0){break h}L[k+16>>2]=h;i=0-(((b|0)!=0)+o|0)|0;a=0-b|0}L[k+8>>2]=a;L[k+12>>2]=i;if((yc(k+24|0,k)|0)<0){break e}}c=(c|0)!=(S|0)?s:0;L[d>>2]=c;a=v-l|0;a=mI(F,z,a,a>>31);b=ga;j=a;a=u-x|0;a=mI(G,A,a,a>>31);o=j+a|0;h=ga+b|0;h=a>>>0>o>>>0?h+1|0:h;a=w-n|0;a=mI(B,C,a,a>>31);b=a+o|0;f=ga+h|0;o=a>>>0>b>>>0?f+1|0:f;q=x;y=l;D=n;continue}break}a=L[e>>2];if(!a|!L[a+12>>2]){break d}p=L[L[a+8>>2]>>2];if((t|0)>=L[p+20>>2]){break d}i=L[p+12>>2];s=L[i+92>>2];f=s-v|0;v=f>>31;a=mI(f,v,J,O);c=ga;h=a;l=L[i+88>>2];m=l-u|0;x=m>>31;a=mI(m,x,H,M);u=h+a|0;g=ga+c|0;g=a>>>0>u>>>0?g+1|0:g;h=L[i+96>>2];i=h-w|0;n=i>>31;c=mI(I,N,i,n);if((u|0)!=(0-c|0)|(0-(ga+((c|0)!=0)|0)|0)!=(g|0)){break d}a=s-y|0;a=mI(F,z,a,a>>31);c=ga;g=a;a=l-q|0;a=mI(G,A,a,a>>31);l=g+a|0;g=ga+c|0;g=a>>>0>l>>>0?g+1|0:g;a=h-D|0;a=mI(B,C,a,a>>31);c=a+l|0;h=ga+g|0;h=a>>>0>c>>>0?h+1|0:h;a=h;if(!c&(a|0)<=0|(a|0)<0){break d}l=(R(f,K)+R(m,T)|0)+R(i,E)|0;h=mI(f,v,F,z);f=ga;g=h;h=mI(G,A,m,x);m=g+h|0;g=ga+f|0;g=h>>>0>m>>>0?g+1|0:g;h=mI(B,C,i,n);i=h+m|0;f=ga+g|0;f=h>>>0>i>>>0?f+1|0:f;i:{if(!(f|i)){if((l|0)<0){break i}break d}if((f|0)>0|(f|0)>=0){break d}L[k+32>>2]=0-i;L[k+36>>2]=0-(((i|0)!=0)+f|0);m=(l|0)>0;L[k+40>>2]=m?-1:l>>>31|0;h=(l|0)<0;L[k+24>>2]=m?l:h?0-l|0:0;i=l>>31;L[k+28>>2]=m?i:h?0-(((l|0)!=0)+i|0)|0:0;j:{if((j|0)>0){L[k+16>>2]=1;i=-1;break j}if((j|0)<0){L[k+16>>2]=-1;i=j;j=0-i|0;r=0-(((i|0)!=0)+r|0)|0;i=1;break j}L[k+16>>2]=0;j=0;r=0;i=0}L[k>>2]=j;L[k+4>>2]=r;j=b;h=o;k:{if(!!j&(h|0)>=0|(h|0)>0){break k}h=0;j=0;if((o|0)>0|(o|0)>=0){break k}L[k+16>>2]=i;h=0-(((b|0)!=0)+o|0)|0;j=0-b|0}L[k+8>>2]=j;L[k+12>>2]=h;if((yc(k+24|0,k)|0)<=0){break d}}L[e>>2]=p;b=L[p+12>>2];w=L[b+96>>2];v=L[b+92>>2];u=L[b+88>>2];b=c;o=a;continue}}if((o|0)>0|(o|0)>=0){break d}p=L[a+100>>2];while(1){j=(R(v-y|0,K)+R(u-q|0,T)|0)+R(w-D|0,E)|0;r=j>>31;l:{if(!c|!L[c+12>>2]){break l}s=L[L[c+4>>2]+8>>2];if((p|0)>=L[s+20>>2]){break l}i=L[s+12>>2];m=L[i+92>>2];a=m-v|0;h=L[i+88>>2];g=h-u|0;i=L[i+96>>2];n=i-w|0;l=(R(a,K)+R(g,T)|0)+R(n,E)|0;a=mI(F,z,a,a>>31);f=ga;t=a;a=mI(G,A,g,g>>31);g=t+a|0;f=ga+f|0;f=a>>>0>g>>>0?f+1|0:f;n=mI(B,C,n,n>>31);a=n+g|0;g=ga+f|0;g=a>>>0>>0?g+1|0:g;m:{if(!(g|a)){if((l|0)>0){break m}break l}if((g|0)>0|(g|0)>=0){break l}L[k+32>>2]=0-a;L[k+36>>2]=0-(((a|0)!=0)+g|0);g=(l|0)>0;L[k+40>>2]=g?-1:l>>>31|0;f=(l|0)<0;L[k+24>>2]=g?l:f?0-l|0:0;a=l>>31;L[k+28>>2]=g?a:f?0-(((l|0)!=0)+a|0)|0:0;n:{if((j|0)>0){L[k+16>>2]=1;l=-1;f=r;a=j;break n}if((j|0)<0){L[k+16>>2]=-1;l=1;f=0-(((j|0)!=0)+r|0)|0;a=0-j|0;break n}l=0;L[k+16>>2]=0;f=0;a=0}L[k>>2]=a;L[k+4>>2]=f;a=b;f=o;o:{if(!!a&(f|0)>=0|(f|0)>0){break o}f=0;a=0;if((o|0)>0|(o|0)>=0){break o}L[k+16>>2]=l;f=0-(((b|0)!=0)+o|0)|0;a=0-b|0}L[k+8>>2]=a;L[k+12>>2]=f;if((yc(k+24|0,k)|0)>0){break l}}c=(c|0)!=(x|0)?s:0;L[e>>2]=c;a=m-y|0;a=mI(F,z,a,a>>31);b=ga;j=a;a=h-q|0;a=mI(G,A,a,a>>31);o=j+a|0;f=ga+b|0;f=a>>>0>o>>>0?f+1|0:f;a=i-D|0;a=mI(B,C,a,a>>31);b=a+o|0;g=ga+f|0;o=a>>>0>b>>>0?g+1|0:g;u=h;v=m;w=i;continue}a=L[d>>2];if(!a|!L[a+12>>2]){break d}Q=L[L[a+8>>2]+4>>2];if((p|0)>=L[Q+20>>2]){break d}h=L[Q+12>>2];s=L[h+92>>2];m=s-y|0;y=m>>31;a=mI(m,y,J,O);c=ga;f=a;l=L[h+88>>2];i=l-q|0;g=i>>31;a=mI(i,g,H,M);t=f+a|0;f=ga+c|0;f=a>>>0>t>>>0?f+1|0:f;q=L[h+96>>2];c=q-D|0;n=c>>31;h=mI(I,N,c,n);if((t|0)!=(0-h|0)|(0-(ga+((h|0)!=0)|0)|0)!=(f|0)){break d}a=v-s|0;a=mI(F,z,a,a>>31);h=ga;f=a;a=u-l|0;a=mI(G,A,a,a>>31);f=f+a|0;h=ga+h|0;h=a>>>0>f>>>0?h+1|0:h;a=w-q|0;q=mI(B,C,a,a>>31);a=q+f|0;f=ga+h|0;f=a>>>0>>0?f+1|0:f;if((f|0)>0|(f|0)>=0){break d}q=(R(m,K)+R(i,T)|0)+R(c,E)|0;m=mI(m,y,F,z);h=ga;i=mI(G,A,i,g);m=i+m|0;g=ga+h|0;g=i>>>0>m>>>0?g+1|0:g;i=mI(B,C,c,n);c=i+m|0;g=ga+g|0;g=c>>>0>>0?g+1|0:g;p:{if(!(g|c)){if((q|0)>0){break p}break d}if((g|0)>0|(g|0)>=0){break d}L[k+32>>2]=0-c;L[k+36>>2]=0-(((c|0)!=0)+g|0);h=(q|0)>0;L[k+40>>2]=h?-1:q>>>31|0;i=(q|0)<0;L[k+24>>2]=h?q:i?0-q|0:0;c=q>>31;L[k+28>>2]=h?c:i?0-(((q|0)!=0)+c|0)|0:0;q:{if((j|0)>0){L[k+16>>2]=1;i=-1;break q}if((j|0)<0){L[k+16>>2]=-1;c=j;j=0-j|0;r=0-(((c|0)!=0)+r|0)|0;i=1;break q}L[k+16>>2]=0;j=0;r=0;i=0}L[k>>2]=j;L[k+4>>2]=r;c=b;j=o;r:{if(!!c&(j|0)>=0|(j|0)>0){break r}j=0;c=0;if((o|0)>0|(o|0)>=0){break r}L[k+16>>2]=i;j=0-(((b|0)!=0)+o|0)|0;c=0-b|0}L[k+8>>2]=c;L[k+12>>2]=j;if((yc(k+24|0,k)|0)>=0){break d}}L[d>>2]=Q;b=L[Q+12>>2];D=L[b+96>>2];y=L[b+92>>2];c=L[e>>2];q=L[b+88>>2];b=a;o=f;continue}}fa=k+48|0}function Ac(a,b,c,d,e){var f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=S(0),p=0,q=S(0),r=S(0),s=S(0),t=0,u=0,v=S(0),w=0,x=0;p=fa-32|0;fa=p;f=Cd(a);L[f>>2]=20992;L[f+284>>2]=0;J[f+280|0]=1;L[f+276>>2]=0;J[f+408|0]=1;L[f+268>>2]=0;L[f+272>>2]=0;L[f+404>>2]=0;J[f+428|0]=1;L[f+396>>2]=0;L[f+400>>2]=0;L[f+424>>2]=0;J[f+448|0]=1;L[f+416>>2]=0;L[f+420>>2]=0;L[f+444>>2]=0;J[f+496|0]=1;L[f+436>>2]=0;L[f+440>>2]=0;L[f+492>>2]=0;L[f+484>>2]=0;L[f+488>>2]=0;J[f+516|0]=1;L[f+512>>2]=0;J[f+704|0]=1;L[f+684>>2]=b;L[f+504>>2]=0;L[f+508>>2]=0;L[f+700>>2]=0;L[f+692>>2]=0;L[f+696>>2]=0;J[f+724|0]=1;L[f+720>>2]=0;L[f+712>>2]=0;L[f+716>>2]=0;J[f+744|0]=1;L[f+740>>2]=0;L[f+732>>2]=0;L[f+736>>2]=0;J[f+764|0]=1;L[f+760>>2]=0;L[f+752>>2]=0;L[f+756>>2]=0;J[f+784|0]=1;L[f+780>>2]=0;L[f+772>>2]=0;L[f+776>>2]=0;J[f+804|0]=1;J[f+824|0]=1;L[f+800>>2]=0;L[f+792>>2]=0;L[f+796>>2]=0;J[f+844|0]=1;L[f+820>>2]=0;L[f+812>>2]=0;L[f+816>>2]=0;J[f+864|0]=1;L[f+840>>2]=0;L[f+832>>2]=0;L[f+836>>2]=0;J[f+884|0]=1;L[f+860>>2]=0;L[f+852>>2]=0;L[f+856>>2]=0;L[f+880>>2]=0;L[f+872>>2]=0;L[f+876>>2]=0;w=hc(f+928|0);hc(f+988|0);hc(f+1048|0);L[f+1120>>2]=0;J[f+1124|0]=1;J[f+1144|0]=1;a=f+1112|0;L[a>>2]=0;L[a+4>>2]=0;L[f+1140>>2]=0;J[f+1248|0]=1;a=f+1132|0;L[a>>2]=0;L[a+4>>2]=0;L[f+1244>>2]=0;a=f+1236|0;L[a>>2]=0;L[a+4>>2]=0;L[f+288>>2]=0;L[f+292>>2]=1065353216;L[f+236>>2]=8;K[f+472>>1]=0;L[f+296>>2]=0;L[f+300>>2]=0;L[f+304>>2]=0;L[f+308>>2]=0;L[f+312>>2]=0;L[f+476>>2]=0;L[f+388>>2]=1;L[f+380>>2]=0;L[f+384>>2]=4;L[f+372>>2]=0;L[f+376>>2]=1;L[f+364>>2]=1065353216;L[f+368>>2]=1065353216;L[f+356>>2]=1056964608;L[f+360>>2]=1056964608;L[f+348>>2]=1056964608;L[f+352>>2]=1056964608;L[f+340>>2]=1036831949;L[f+344>>2]=1065353216;L[f+332>>2]=1065353216;L[f+336>>2]=1060320051;L[f+324>>2]=1065353216;L[f+328>>2]=1036831949;L[f+316>>2]=1045220557;L[f+320>>2]=0;L[f+528>>2]=0;L[f+532>>2]=0;L[f+520>>2]=0;L[f+524>>2]=0;L[f+536>>2]=1065353216;L[f+540>>2]=0;L[f+544>>2]=0;L[f+548>>2]=0;L[f+552>>2]=0;L[f+556>>2]=1065353216;L[f+560>>2]=0;L[f+564>>2]=0;L[f+568>>2]=0;L[f+572>>2]=0;L[f+576>>2]=1065353216;L[f+580>>2]=0;L[f+584>>2]=1065353216;L[f+588>>2]=0;L[f+592>>2]=0;L[f+596>>2]=0;L[f+600>>2]=0;L[f+604>>2]=1065353216;L[f+608>>2]=0;L[f+612>>2]=0;L[f+616>>2]=0;L[f+620>>2]=0;J[f+924|0]=1;L[f+888>>2]=0;L[f+624>>2]=1065353216;L[f+628>>2]=0;L[f+680>>2]=0;L[f+916>>2]=0;L[f+920>>2]=0;L[f+908>>2]=0;L[f+912>>2]=0;L[f+900>>2]=0;L[f+904>>2]=0;L[f+892>>2]=0;L[f+896>>2]=0;L[f+8>>2]=0;L[f+12>>2]=0;L[f+4>>2]=1065353216;L[f+16>>2]=0;L[f+20>>2]=0;L[f+28>>2]=0;L[f+32>>2]=0;L[f+24>>2]=1065353216;L[f+36>>2]=0;L[f+40>>2]=0;L[f+48>>2]=0;L[f+52>>2]=0;L[f+44>>2]=1065353216;L[f+56>>2]=0;L[f+60>>2]=0;L[f- -64>>2]=0;b=L[f+404>>2];a=f;if(!(!b|!M[f+408|0])){if(b){L[8514]=L[8514]+1;ha[L[6799]](b)}}L[a+404>>2]=0;J[a+408|0]=1;L[a+396>>2]=0;L[a+400>>2]=0;b=L[a+424>>2];if(!(b?!b|!M[a+428|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+424>>2]=0;J[a+428|0]=1;g=a;L[a+416>>2]=0;L[a+420>>2]=0;a=L[a+444>>2];if(!(a?!a|!M[g+448|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](a)}L[g+444>>2]=0;J[g+448|0]=1;L[g+436>>2]=0;L[g+440>>2]=0;a=L[g+420>>2];m=L[g+416>>2];a:{if((a|0)!=(m|0)){break a}a=m?m<<1:1;if((m|0)>=(a|0)){a=m;break a}if(a){L[8513]=L[8513]+1;i=ha[L[6798]](a<<2,16)|0;m=L[g+416>>2]}h=L[g+424>>2];b:{c:{if((m|0)>0){b=0;if(m>>>0>=4){t=m&-4;while(1){j=k<<2;L[j+i>>2]=L[h+j>>2];n=j|4;L[n+i>>2]=L[h+n>>2];n=j|8;L[n+i>>2]=L[h+n>>2];j=j|12;L[j+i>>2]=L[h+j>>2];k=k+4|0;l=l+4|0;if((t|0)!=(l|0)){continue}break}}l=m&3;if(l){while(1){j=k<<2;L[j+i>>2]=L[h+j>>2];k=k+1|0;b=b+1|0;if((l|0)!=(b|0)){continue}break}}if(M[g+428|0]){break c}break b}if(!h|!M[g+428|0]){break b}}if(h){L[8514]=L[8514]+1;ha[L[6799]](h)}m=L[g+416>>2]}L[g+424>>2]=i;J[g+428|0]=1;L[g+420>>2]=a}h=L[g+424>>2];L[h+(m<<2)>>2]=1;i=m+1|0;L[g+416>>2]=i;d:{if((a|0)!=(i|0)){b=a;k=h;a=i;break d}b=a?a<<1:1;if((b|0)<=(a|0)){b=a;k=h;break d}e:{if(!b){k=0;break e}L[8513]=L[8513]+1;k=ha[L[6798]](b<<2,16)|0;h=L[g+424>>2];a=L[g+416>>2]}f:{g:{if((a|0)>0){m=0;i=0;if(a>>>0>=4){t=a&-4;l=0;while(1){j=i<<2;L[j+k>>2]=L[h+j>>2];n=j|4;L[n+k>>2]=L[h+n>>2];n=j|8;L[n+k>>2]=L[h+n>>2];j=j|12;L[j+k>>2]=L[h+j>>2];i=i+4|0;l=l+4|0;if((t|0)!=(l|0)){continue}break}}l=a&3;if(l){while(1){j=i<<2;L[j+k>>2]=L[h+j>>2];i=i+1|0;m=m+1|0;if((l|0)!=(m|0)){continue}break}}if(M[g+428|0]){break g}break f}if(!h|!M[g+428|0]){break f}}if(h){L[8514]=L[8514]+1;ha[L[6799]](h)}a=L[g+416>>2]}L[g+424>>2]=k;J[g+428|0]=1;L[g+420>>2]=b}L[(a<<2)+k>>2]=2;h=a+1|0;L[g+416>>2]=h;h:{if((b|0)!=(h|0)){a=b;i=k;b=h;break h}a=b?b<<1:1;if((b|0)>=(a|0)){a=b;i=k;break h}i:{if(!a){i=0;break i}L[8513]=L[8513]+1;i=ha[L[6798]](a<<2,16)|0;k=L[g+424>>2];b=L[g+416>>2]}j:{k:{if((b|0)>0){m=0;h=0;if(b>>>0>=4){t=b&-4;l=0;while(1){j=h<<2;L[j+i>>2]=L[k+j>>2];n=j|4;L[n+i>>2]=L[k+n>>2];n=j|8;L[n+i>>2]=L[k+n>>2];j=j|12;L[j+i>>2]=L[k+j>>2];h=h+4|0;l=l+4|0;if((t|0)!=(l|0)){continue}break}}l=b&3;if(l){while(1){j=h<<2;L[j+i>>2]=L[k+j>>2];h=h+1|0;m=m+1|0;if((l|0)!=(m|0)){continue}break}}if(M[g+428|0]){break k}break j}if(!k|!M[g+428|0]){break j}}if(k){L[8514]=L[8514]+1;ha[L[6799]](k)}b=L[g+416>>2]}L[g+424>>2]=i;J[g+428|0]=1;L[g+420>>2]=a}L[(b<<2)+i>>2]=3;b=b+1|0;L[g+416>>2]=b;l:{if((a|0)!=(b|0)){h=i;a=b;break l}j=a?a<<1:1;if((j|0)<=(a|0)){h=i;break l}m:{if(!j){h=0;break m}L[8513]=L[8513]+1;h=ha[L[6798]](j<<2,16)|0;i=L[g+424>>2];a=L[g+416>>2]}n:{o:{if((a|0)>0){b=0;k=0;if(a>>>0>=4){t=a&-4;m=0;while(1){l=k<<2;L[l+h>>2]=L[i+l>>2];n=l|4;L[n+h>>2]=L[i+n>>2];n=l|8;L[n+h>>2]=L[i+n>>2];l=l|12;L[l+h>>2]=L[i+l>>2];k=k+4|0;m=m+4|0;if((t|0)!=(m|0)){continue}break}}m=a&3;if(m){while(1){l=k<<2;L[l+h>>2]=L[i+l>>2];k=k+1|0;b=b+1|0;if((m|0)!=(b|0)){continue}break}}if(M[g+428|0]){break o}break n}if(!i|!M[g+428|0]){break n}}if(i){L[8514]=L[8514]+1;ha[L[6799]](i)}a=L[g+416>>2]}L[g+424>>2]=h;J[g+428|0]=1;L[g+420>>2]=j}L[(a<<2)+h>>2]=0;L[g+416>>2]=a+1;L[8513]=L[8513]+1;a=ha[L[6798]](20,16)|0;L[a+12>>2]=0;L[a+4>>2]=35;L[a+8>>2]=0;L[a>>2]=13384;L[a+16>>2]=f;L[a+4>>2]=32;L[a>>2]=21300;L[f+192>>2]=a;L[a+12>>2]=1048576e3;a=f+1152|0;L[a>>2]=0;L[a+4>>2]=0;L[f+1148>>2]=1065353216;a=f+1160|0;L[a>>2]=0;L[a+4>>2]=0;a=f+1172|0;L[a>>2]=0;L[a+4>>2]=0;L[f+1168>>2]=1065353216;a=f+1180|0;L[a>>2]=0;L[a+4>>2]=0;a=f+1192|0;L[a>>2]=0;L[a+4>>2]=0;L[f+1188>>2]=1065353216;a=f+1200|0;L[a>>2]=0;L[a+4>>2]=0;a=f+1208|0;L[a>>2]=0;L[a+4>>2]=0;a=f+1216|0;L[a>>2]=0;L[a+4>>2]=0;a=f+1224|0;L[a>>2]=0;L[a+4>>2]=1065353216;k=Bk(f);a=k;L[a+12>>2]=1065353216;L[a+16>>2]=1;L[a+4>>2]=1065353216;L[a+8>>2]=1065353216;a=L[f+192>>2];o=S(ha[L[L[a>>2]+48>>2]](a));a=L[f+712>>2];p:{if((c|0)<=(a|0)){break p}if(L[f+716>>2]<(c|0)){if(c){L[8513]=L[8513]+1;u=ha[L[6798]](R(c,104),16)|0;i=L[f+712>>2]}else{i=a}q:{if((i|0)<=0){break q}b=0;if((i|0)!=1){h=i&-2;while(1){g=R(b,104);qa(g+u|0,g+L[f+720>>2]|0,104);g=R(b|1,104);qa(g+u|0,g+L[f+720>>2]|0,104);b=b+2|0;x=x+2|0;if((h|0)!=(x|0)){continue}break}}if(!(i&1)){break q}b=R(b,104);qa(b+u|0,b+L[f+720>>2]|0,104)}b=L[f+720>>2];if(!(b?!b|!M[f+724|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[f+720>>2]=u;J[f+724|0]=1;L[f+716>>2]=c}i=(a^-1)+c|0;h=c-a&3;if(h){b=0;while(1){pa(L[f+720>>2]+R(a,104)|0,0,104);a=a+1|0;b=b+1|0;if((h|0)!=(b|0)){continue}break}}if(i>>>0<3){break p}while(1){b=R(a,104);pa(b+L[f+720>>2]|0,0,104);pa((b+L[f+720>>2]|0)+104|0,0,104);pa((b+L[f+720>>2]|0)+208|0,0,104);pa((b+L[f+720>>2]|0)+312|0,0,104);a=a+4|0;if((c|0)!=(a|0)){continue}break}}L[f+712>>2]=c;if((c|0)>0){b=0;while(1){a=pa(L[f+720>>2]+R(b,104)|0,0,104);r=S(0);s=S(0);v=S(0);q=S(0);u=0;if(d){q=P[d+12>>2];v=P[d+8>>2];r=P[d+4>>2];s=P[d>>2];u=d+16|0}P[a+8>>2]=s;P[a+12>>2]=r;P[a+20>>2]=q;P[a+16>>2]=v;d=L[a+12>>2];L[a+24>>2]=L[a+8>>2];L[a+28>>2]=d;d=L[a+20>>2];L[a+32>>2]=L[a+16>>2];L[a+36>>2]=d;r:{if(!e){q=S(1);e=0;break r}q=P[e>>2];e=e+4|0}P[a+88>>2]=q>S(0)?S(S(1)/q):S(0);L[p+28>>2]=0;P[p+24>>2]=o+v;P[p+20>>2]=o+r;P[p+16>>2]=o+s;L[p+12>>2]=0;P[p+8>>2]=v-o;P[p+4>>2]=r-o;P[p>>2]=s-o;L[a+96>>2]=Bb(w,p,a);L[a+4>>2]=k;d=u;b=b+1|0;if((c|0)!=(b|0)){continue}break}}a=f+892|0;b=L[w>>2];s:{if(b){c=L[f+192>>2];o=S(ha[L[L[c>>2]+48>>2]](c));q=P[b>>2];r=P[b+4>>2];s=P[b+8>>2];L[f+904>>2]=0;P[f+900>>2]=s-o;P[f+896>>2]=r-o;P[f+892>>2]=q-o;q=P[b+20>>2];r=P[b+24>>2];s=P[b+16>>2];L[f+920>>2]=0;P[f+916>>2]=o+r;P[f+912>>2]=o+q;b=f+908|0;P[b>>2]=o+s;c=L[f+188>>2];if(!c){break s}d=L[f+684>>2];e=L[d+32>>2];ha[L[L[e>>2]+16>>2]](e,c,a,b,L[d+36>>2]);break s}L[a>>2]=0;L[a+4>>2]=0;L[a+24>>2]=0;L[a+28>>2]=0;L[a+16>>2]=0;L[a+20>>2]=0;L[a+8>>2]=0;L[a+12>>2]=0}fa=p+32|0;return f}function xA(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0;u=fa-16|0;fa=u;wa(2555);d=L[a+180>>2];j=L[a+212>>2];a:{if((d|0)>=(j|0)){break a}if((j|0)>L[a+184>>2]){if(j){L[8513]=L[8513]+1;g=ha[L[6798]](j<<2,16)|0;c=L[a+180>>2]}else{c=d}b:{if((c|0)<=0){break b}if(c>>>0>=4){i=c&-4;while(1){f=h<<2;L[f+g>>2]=L[f+L[a+188>>2]>>2];m=f|4;L[m+g>>2]=L[m+L[a+188>>2]>>2];m=f|8;L[m+g>>2]=L[m+L[a+188>>2]>>2];f=f|12;L[f+g>>2]=L[f+L[a+188>>2]>>2];h=h+4|0;e=e+4|0;if((i|0)!=(e|0)){continue}break}}c=c&3;if(!c){break b}while(1){e=h<<2;L[e+g>>2]=L[e+L[a+188>>2]>>2];h=h+1|0;r=r+1|0;if((c|0)!=(r|0)){continue}break}}c=L[a+188>>2];if(!(c?!c|!M[a+192|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](c)}L[a+188>>2]=g;J[a+192|0]=1;L[a+184>>2]=j}c=j+(d^-1)|0;e=j-d&3;if(e){h=0;while(1){L[L[a+188>>2]+(d<<2)>>2]=0;d=d+1|0;h=h+1|0;if((e|0)!=(h|0)){continue}break}}if(c>>>0<3){break a}while(1){c=d<<2;L[c+L[a+188>>2]>>2]=0;L[(c+L[a+188>>2]|0)+4>>2]=0;L[(c+L[a+188>>2]|0)+8>>2]=0;L[(c+L[a+188>>2]|0)+12>>2]=0;d=d+4|0;if((j|0)!=(d|0)){continue}break}}L[a+180>>2]=j;if((ha[L[L[a>>2]+104>>2]](a)|0)>0){d=0;while(1){c=d<<2;L[c+L[a+188>>2]>>2]=L[c+L[a+220>>2]>>2];d=d+1|0;if((ha[L[L[a>>2]+104>>2]](a)|0)>(d|0)){continue}break}}d=L[a+180>>2];if((d|0)>=2){Pk(a+176|0,u+15|0,0,d-1|0)}d=ha[L[L[a>>2]+104>>2]](a)|0;d=d?L[a+188>>2]:0;c=L[a+180>>2];g=L[a+196>>2];L[g+20>>2]=ha[L[L[a>>2]+20>>2]](a);L[g+16>>2]=c;L[g+12>>2]=d;L[g+4>>2]=b;c=L[g+32>>2];c:{if((c|0)>=0){break c}if(L[g+36>>2]<0){d=L[g+40>>2];if(!(d?!d|!M[g+44|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](d)}J[g+44|0]=1;L[g+36>>2]=0;L[g+40>>2]=0}e=0;d=c;j=0-c&3;if(j){while(1){L[L[g+40>>2]+(d<<2)>>2]=0;d=d+1|0;e=e+1|0;if((j|0)!=(e|0)){continue}break}}if(c>>>0>4294967292){break c}while(1){c=d<<2;L[c+L[g+40>>2]>>2]=0;L[(c+L[g+40>>2]|0)+4>>2]=0;L[(c+L[g+40>>2]|0)+8>>2]=0;L[(c+L[g+40>>2]|0)+12>>2]=0;d=d+4|0;if(d){continue}break}}L[g+32>>2]=0;c=L[g+52>>2];d:{if((c|0)>=0){break d}if(L[g+56>>2]<0){d=L[g+60>>2];if(!(d?!d|!M[g- -64|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](d)}J[g+64|0]=1;L[g+56>>2]=0;L[g+60>>2]=0}e=0;d=c;j=0-c&3;if(j){while(1){L[L[g+60>>2]+(d<<2)>>2]=0;d=d+1|0;e=e+1|0;if((j|0)!=(e|0)){continue}break}}if(c>>>0>4294967292){break d}while(1){c=d<<2;L[c+L[g+60>>2]>>2]=0;L[(c+L[g+60>>2]|0)+4>>2]=0;L[(c+L[g+60>>2]|0)+8>>2]=0;L[(c+L[g+60>>2]|0)+12>>2]=0;d=d+4|0;if(d){continue}break}}L[g+52>>2]=0;c=L[g+72>>2];e:{if((c|0)>=0){break e}if(L[g+76>>2]<0){d=L[g+80>>2];if(!(d?!d|!M[g+84|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](d)}J[g+84|0]=1;L[g+76>>2]=0;L[g+80>>2]=0}e=0;d=c;j=0-c&3;if(j){while(1){L[L[g+80>>2]+(d<<2)>>2]=0;d=d+1|0;e=e+1|0;if((j|0)!=(e|0)){continue}break}}if(c>>>0>4294967292){break e}while(1){c=d<<2;L[c+L[g+80>>2]>>2]=0;L[(c+L[g+80>>2]|0)+4>>2]=0;L[(c+L[g+80>>2]|0)+8>>2]=0;L[(c+L[g+80>>2]|0)+12>>2]=0;d=d+4|0;if(d){continue}break}}L[g+72>>2]=0;d=L[a+200>>2];c=L[a+24>>2];A=d,B=L[a+8>>2],C=ha[L[L[c>>2]+36>>2]](c)|0,z=L[L[d>>2]+8>>2],ha[z](A|0,B|0,C|0);f=L[a+204>>2];m=L[a+24>>2];t=L[a+196>>2];g=0;r=0;v=fa-16|0;fa=v;j=a;d=0;wa(2450);a=L[f+28>>2];f:{if((a|0)>=0){break f}if(L[f+32>>2]<0){c=L[f+36>>2];if(!(c?!c|!M[f+40|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](c)}J[f+40|0]=1;L[f+32>>2]=0;L[f+36>>2]=0}c=a;e=0-c&3;if(e){while(1){L[L[f+36>>2]+(c<<2)>>2]=0;c=c+1|0;d=d+1|0;if((e|0)!=(d|0)){continue}break}}if(a>>>0>4294967292){break f}while(1){a=c<<2;L[a+L[f+36>>2]>>2]=0;L[(a+L[f+36>>2]|0)+4>>2]=0;L[(a+L[f+36>>2]|0)+8>>2]=0;L[(a+L[f+36>>2]|0)+12>>2]=0;c=c+4|0;if(c){continue}break}}L[f+28>>2]=0;a=0;l=fa-16|0;fa=l;k=f+4|0;h=L[k+4>>2];g:{if((h|0)<=0){break g}i=L[k+12>>2];while(1){d=a;n=i+(a<<3)|0;e=n;c=L[e>>2];if((c|0)!=(a|0)){while(1){d=i+(c<<3)|0;L[e>>2]=L[d>>2];d=L[d>>2];e=i+(d<<3)|0;c=L[e>>2];if((c|0)!=(d|0)){continue}break}}L[n>>2]=d;a=a+1|0;if((h|0)!=(a|0)){continue}break}if((h|0)<2){break g}Zk(k,l+15|0,0,h-1|0)}fa=l+16|0;k=L[f+8>>2];if((k|0)>0){d=0;while(1){a=d;c=a+1|0;h=(c|0)<(k|0)?k:c;e=h-1|0;n=L[f+16>>2];l=L[n+(a<<3)>>2];while(1){h:{c=d;if((e|0)==(c|0)){c=e;d=h;break h}d=c+1|0;if((l|0)==L[n+(d<<3)>>2]){continue}}break}s=(a|0)>(c|0);i:{if(s){break i}i=1;h=(c-a|0)+1|0;o=h&1;p=L[j+16>>2];e=a;if((a|0)!=(c|0)){w=h&-2;h=0;while(1){q=n+(e<<3)|0;y=L[p+(L[q+4>>2]<<2)>>2];if((l|0)==L[y+208>>2]){x=i;i=L[y+216>>2];i=x&((i|0)!=4&(i|0)!=1)}q=L[p+(L[q+12>>2]<<2)>>2];if((l|0)==L[q+208>>2]){x=i;i=L[q+216>>2];i=x&((i|0)!=4&(i|0)!=1)}e=e+2|0;h=h+2|0;if((w|0)!=(h|0)){continue}break}}j:{if(!o){break j}e=L[p+(L[(n+(e<<3)|0)+4>>2]<<2)>>2];if((l|0)!=L[e+208>>2]){break j}e=L[e+216>>2];i=(e|0)!=4&(e|0)!=1&i}if(i){if(s){break i}while(1){e=L[L[j+16>>2]+(L[(L[f+16>>2]+(a<<3)|0)+4>>2]<<2)>>2];if((l|0)==L[e+208>>2]&(L[e+216>>2]&-2)!=4){L[e+216>>2]=2}e=(a|0)==(c|0);a=a+1|0;if(!e){continue}break}break i}while(1){e=a;a=L[L[j+16>>2]+(L[(L[f+16>>2]+(a<<3)|0)+4>>2]<<2)>>2];if(!((l|0)!=L[a+208>>2]|L[a+216>>2]!=2)){if((L[a+216>>2]&-2)!=4){L[a+216>>2]=3}L[a+220>>2]=0}a=e+1|0;if((c|0)!=(e|0)){continue}break}}if((d|0)<(k|0)){continue}break}}p=ha[L[L[m>>2]+36>>2]](m)|0;if((p|0)>0){d=0;while(1){n=ha[L[L[m>>2]+40>>2]](m,d)|0;a=L[n+744>>2];c=L[n+740>>2];k:{if(!(L[c+216>>2]!=2?c:0)&(!a|L[a+216>>2]==2)){break k}e=L[c+204>>2];if(!(!(e&2)|L[c+216>>2]==2|e&4)){ib(a,0)}e=L[a+204>>2];if(!(!(e&2)|L[a+216>>2]==2|e&4)){ib(c,0)}if(!M[f+64|0]){break k}if(!(ha[L[L[m>>2]+28>>2]](m,c,a)|0)){break k}e=L[f+28>>2];l:{if((e|0)!=L[f+32>>2]){break l}k=e?e<<1:1;if((k|0)<=(e|0)){break l}m:{if(!k){a=0;break m}L[8513]=L[8513]+1;a=ha[L[6798]](k<<2,16)|0;e=L[f+28>>2]}n:{if((e|0)<=0){break n}i=0;c=0;if(e>>>0>=4){s=e&-4;h=0;while(1){l=c<<2;L[l+a>>2]=L[l+L[f+36>>2]>>2];o=l|4;L[o+a>>2]=L[o+L[f+36>>2]>>2];o=l|8;L[o+a>>2]=L[o+L[f+36>>2]>>2];l=l|12;L[l+a>>2]=L[l+L[f+36>>2]>>2];c=c+4|0;h=h+4|0;if((s|0)!=(h|0)){continue}break}}h=e&3;if(!h){break n}while(1){l=c<<2;L[l+a>>2]=L[l+L[f+36>>2]>>2];c=c+1|0;i=i+1|0;if((h|0)!=(i|0)){continue}break}}c=L[f+36>>2];if(!(!c|!M[f+40|0])){if(c){L[8514]=L[8514]+1;ha[L[6799]](c)}e=L[f+28>>2]}L[f+36>>2]=a;J[f+40|0]=1;L[f+32>>2]=k}L[L[f+36>>2]+(e<<2)>>2]=n;L[f+28>>2]=e+1}d=d+1|0;if((p|0)!=(d|0)){continue}break}}va();n=L[f+8>>2];wa(2791);o:{if(!M[f+64|0]){a=ha[L[L[m>>2]+44>>2]](m)|0;d=ha[L[L[m>>2]+36>>2]](m)|0;ha[L[L[t>>2]+8>>2]](t,L[j+16>>2],L[j+8>>2],a,d,-1);break o}m=L[f+28>>2];if((m|0)>=2){Xk(f+24|0,v+15|0,0,m-1|0)}if((n|0)<=0){break o}a=1;while(1){l=L[L[f+16>>2]+(r<<3)>>2];i=1;while(1){d=L[f+16>>2]+(r<<3)|0;if((l|0)==L[d>>2]){s=L[L[j+16>>2]+(L[d+4>>2]<<2)>>2];c=L[f+48>>2];p:{if((c|0)!=L[f+52>>2]){break p}p=c?c<<1:1;if((p|0)<=(c|0)){break p}q:{if(!p){e=0;break q}L[8513]=L[8513]+1;e=ha[L[6798]](p<<2,16)|0;c=L[f+48>>2]}r:{if((c|0)<=0){break r}h=0;d=0;if(c>>>0>=4){w=c&-4;o=0;while(1){k=d<<2;L[k+e>>2]=L[k+L[f+56>>2]>>2];q=k|4;L[q+e>>2]=L[q+L[f+56>>2]>>2];q=k|8;L[q+e>>2]=L[q+L[f+56>>2]>>2];k=k|12;L[k+e>>2]=L[k+L[f+56>>2]>>2];d=d+4|0;o=o+4|0;if((w|0)!=(o|0)){continue}break}}k=c&3;if(!k){break r}while(1){o=d<<2;L[o+e>>2]=L[o+L[f+56>>2]>>2];d=d+1|0;h=h+1|0;if((k|0)!=(h|0)){continue}break}}d=L[f+56>>2];if(!(!d|!M[f+60|0])){if(d){L[8514]=L[8514]+1;ha[L[6799]](d)}c=L[f+48>>2]}L[f+56>>2]=e;J[f+60|0]=1;L[f+52>>2]=p}L[L[f+56>>2]+(c<<2)>>2]=s;L[f+48>>2]=c+1;d=L[s+216>>2];i=((d|0)==2|(d|0)==5)&i;r=r+1|0;if((n|0)>(r|0)){continue}}break}h=0;d=0;s:{if((g|0)>=(m|0)){break s}k=L[f+36>>2];e=k+(g<<2)|0;d=L[e>>2];c=L[L[d+740>>2]+208>>2];if((c|0)<0){c=L[L[d+744>>2]+208>>2]}d=0;if((c|0)!=(l|0)){break s}a=g+1|0;c=(a|0)<(m|0)?m:a;h=c-1|0;a=g;while(1){t:{if((a|0)==(h|0)){a=c;break t}a=a+1|0;p=L[k+(a<<2)>>2];d=L[L[p+740>>2]+208>>2];if((d|0)<0){d=L[L[p+744>>2]+208>>2]}if((d|0)==(l|0)){continue}}break}h=a-g|0;d=e}if(!i){ha[L[L[t>>2]+8>>2]](t,L[f+56>>2],L[f+48>>2],d,h,l)}c=L[f+48>>2];u:{if((c|0)>=0){break u}if(L[f+52>>2]<0){d=L[f+56>>2];if(!(d?!d|!M[f+60|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](d)}J[f+60|0]=1;L[f+52>>2]=0;L[f+56>>2]=0}e=0;d=c;i=0-c&3;if(i){while(1){L[L[f+56>>2]+(d<<2)>>2]=0;d=d+1|0;e=e+1|0;if((i|0)!=(e|0)){continue}break}}if(c>>>0>4294967292){break u}while(1){c=d<<2;L[c+L[f+56>>2]>>2]=0;L[(c+L[f+56>>2]|0)+4>>2]=0;L[(c+L[f+56>>2]|0)+8>>2]=0;L[(c+L[f+56>>2]|0)+12>>2]=0;d=d+4|0;if(d){continue}break}}g=h?a:g;L[f+48>>2]=0;if((n|0)>(r|0)){continue}break}}va();fa=v+16|0;Ok(L[j+196>>2]);a=L[j+200>>2];ha[L[L[a>>2]+16>>2]](a,b,L[j+72>>2]);va();fa=u+16|0}function EG(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=S(0),o=S(0),p=S(0),q=S(0),r=0,s=0,t=S(0),u=S(0),v=S(0),w=S(0),x=S(0),y=S(0),z=S(0),A=S(0),B=0,C=S(0),D=0,E=S(0),F=S(0),G=S(0),H=S(0),I=S(0),K=S(0),N=S(0),O=S(0),Q=S(0),U=S(0),V=S(0),W=S(0),X=0,Y=0,Z=0,_=0,$=0,aa=0,ba=S(0),ca=S(0),da=S(0),ea=S(0),ga=S(0),ia=S(0);g=fa-176|0;fa=g;$=L[b+4>>2];aa=L[c+4>>2];if(!(L[$+68>>2]==L[a+40>>2]&L[aa+68>>2]==L[a+44>>2])){h=L[a+8>>2];r=L[h+8>>2];if((r|0)>0){while(1){i=L[(L[h+16>>2]+R(f,12)|0)+8>>2];if(i){ha[L[L[i>>2]>>2]](i)|0;j=L[a+4>>2];ha[L[L[j>>2]+60>>2]](j,i)}f=f+1|0;if((r|0)!=(f|0)){continue}break}h=L[a+8>>2]}Pm(h)}L[g+24>>2]=0;L[g+16>>2]=0;L[g+20>>2]=0;J[g+28|0]=1;i=L[a+8>>2];s=L[i+8>>2];a:{if((s|0)<=0){break a}while(1){h=L[(L[i+16>>2]+R(l,12)|0)+8>>2];if(h){ha[L[L[h>>2]+16>>2]](h,g+12|0);f=0;j=L[g+16>>2];if((j|0)>0){while(1){k=L[L[g+24>>2]+(f<<2)>>2];if(L[k+748>>2]){L[e+4>>2]=k;h=L[k+740>>2];j=L[L[e+8>>2]+8>>2];r=(h|0)==(j|0);m=h;h=L[L[e+12>>2]+8>>2];_a(k,(r?m:h)+4|0,(r?h:j)+4|0);L[e+4>>2]=0;j=L[g+16>>2]}f=f+1|0;if((j|0)>(f|0)){continue}break}}b:{if((j|0)>=0){break b}if(L[g+20>>2]<0){h=L[g+24>>2];if(!(h?!h|!M[g+28|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](h)}J[g+28|0]=1;L[g+20>>2]=0;L[g+24>>2]=0}s=0;f=j;h=0-f&3;if(h){while(1){L[L[g+24>>2]+(f<<2)>>2]=0;f=f+1|0;s=s+1|0;if((h|0)!=(s|0)){continue}break}}if(j>>>0>4294967292){break b}while(1){h=f<<2;L[h+L[g+24>>2]>>2]=0;L[(h+L[g+24>>2]|0)+4>>2]=0;L[(h+L[g+24>>2]|0)+8>>2]=0;L[(h+L[g+24>>2]|0)+12>>2]=0;f=f+4|0;if(f){continue}break}}L[g+16>>2]=0;s=L[i+8>>2]}l=l+1|0;if((s|0)>(l|0)){continue}break}h=L[g+24>>2];if(!h|!M[g+28|0]){break a}if(h){L[8514]=L[8514]+1;ha[L[6799]](h)}}r=L[$+64>>2];j=L[aa+64>>2];f=L[a+4>>2];h=L[a+8>>2];L[g+172>>2]=L[a+32>>2];L[g+168>>2]=h;L[g+164>>2]=e;L[g+160>>2]=d;L[g+156>>2]=f;L[g+144>>2]=0;L[g+140>>2]=9996;L[g+152>>2]=c;L[g+148>>2]=b;h=L[r>>2];c:{if(!h){break c}d=L[j>>2];if(!d){break c}f=L[b+12>>2];w=P[f+8>>2];n=S(-P[f+48>>2]);t=P[f+24>>2];p=P[f+52>>2];x=P[f+40>>2];u=P[f+56>>2];e=L[c+12>>2];v=P[e+56>>2];q=P[e+48>>2];o=P[e+52>>2];ea=S(S(S(S(w*n)-S(t*p))-S(x*u))+S(S(v*x)+S(S(q*w)+S(t*o))));y=P[f+4>>2];C=P[f+20>>2];z=P[f+36>>2];ga=S(S(S(S(y*n)-S(C*p))-S(z*u))+S(S(v*z)+S(S(q*y)+S(C*o))));H=P[e+40>>2];E=P[e+24>>2];I=P[e+8>>2];F=P[e+36>>2];K=P[e+20>>2];G=P[e+4>>2];W=P[f>>2];A=S(W*n);n=P[f+16>>2];A=S(A-S(n*p));p=P[f+32>>2];ia=S(S(A-S(p*u))+S(S(v*p)+S(S(q*W)+S(n*o))));v=P[e+16>>2];q=P[e>>2];o=P[e+32>>2];L[8513]=L[8513]+1;e=ha[L[6798]](1024,16)|0;L[e+4>>2]=d;L[e>>2]=h;da=S(S(H*x)+S(S(I*w)+S(t*E)));Q=S(T(da));A=S(S(F*x)+S(S(G*w)+S(t*K)));U=S(T(A));N=S(S(o*x)+S(S(q*w)+S(t*v)));V=S(T(N));O=S(S(H*z)+S(S(I*y)+S(C*E)));w=S(T(O));t=S(S(F*z)+S(S(G*y)+S(C*K)));x=S(T(t));y=S(S(o*z)+S(S(q*y)+S(C*v)));C=S(T(y));z=S(S(H*p)+S(S(I*W)+S(n*E)));H=S(T(z));E=S(S(F*p)+S(S(G*W)+S(n*K)));I=S(T(E));F=S(S(o*p)+S(S(q*W)+S(n*v)));K=S(T(F));X=124;f=128;l=128;j=1;while(1){d:{e:{f:{r=j-1|0;s=r<<3;d=s+e|0;D=L[d>>2];B=L[d+4>>2];G=P[B+24>>2];n=P[B+8>>2];ba=S(S(S(G-n)*S(.5))+S(0));p=P[B+16>>2];u=P[B>>2];ca=S(S(S(p-u)*S(.5))+S(0));v=P[B+20>>2];o=P[B+4>>2];W=S(S(S(v-o)*S(.5))+S(0));q=S(S(ba*H)+S(S(ca*K)+S(I*W)));n=S(S(G+n)*S(.5));u=S(S(p+u)*S(.5));v=S(S(v+o)*S(.5));o=S(ia+S(S(n*z)+S(S(u*F)+S(E*v))));g:{if(!(P[D>>2]<=S(q+o))|!(P[D+16>>2]>=S(o-q))){break g}q=S(S(ba*w)+S(S(ca*C)+S(x*W)));o=S(ga+S(S(n*O)+S(S(u*y)+S(t*v))));if(!(P[D+4>>2]<=S(q+o))|!(P[D+20>>2]>=S(o-q))){break g}q=S(S(ba*Q)+S(S(ca*V)+S(U*W)));o=S(ea+S(S(n*da)+S(S(u*N)+S(A*v))));if(!(P[D+8>>2]<=S(q+o))|!(P[D+24>>2]>=S(o-q))){break g}h:{if((r|0)<=(X|0)){d=f;h=e;break h}d=f<<1;i:{if((f|0)>=(d|0)){h=e;break i}if((d|0)<=(l|0)){h=e;break i}j:{if(!f){h=0;break j}L[8513]=L[8513]+1;h=ha[L[6798]](f<<4,16)|0;if((f|0)<=0){break j}l=0;X=0;if(f>>>0>=4){Z=f&-4;Y=0;while(1){_=X<<3;m=_+h|0;k=e+_|0;i=L[k+4>>2];L[m>>2]=L[k>>2];L[m+4>>2]=i;i=_|8;m=i+h|0;k=e+i|0;i=L[k+4>>2];L[m>>2]=L[k>>2];L[m+4>>2]=i;i=_|16;m=i+h|0;k=e+i|0;i=L[k+4>>2];L[m>>2]=L[k>>2];L[m+4>>2]=i;i=_|24;m=i+h|0;k=e+i|0;i=L[k+4>>2];L[m>>2]=L[k>>2];L[m+4>>2]=i;X=X+4|0;Y=Y+4|0;if((Z|0)!=(Y|0)){continue}break}}m=f&3;if(!m){break j}while(1){f=X<<3;k=f+h|0;i=e+f|0;f=L[i+4>>2];L[k>>2]=L[i>>2];L[k+4>>2]=f;X=X+1|0;l=l+1|0;if((m|0)!=(l|0)){continue}break}}if(e){L[8514]=L[8514]+1;ha[L[6799]](e)}l=d}X=d-4|0}e=L[B+40>>2];if(L[D+40>>2]){f=L[D+36>>2];if(e){e=h+s|0;L[e+4>>2]=L[B+36>>2];L[e>>2]=f;e=L[D+40>>2];f=(j<<3)+h|0;L[f+4>>2]=L[B+36>>2];L[f>>2]=e;e=L[D+36>>2];L[f+12>>2]=L[B+40>>2];L[f+8>>2]=e;e=L[D+40>>2];L[f+20>>2]=L[B+40>>2];L[f+16>>2]=e;j=j+3|0;break e}e=h+s|0;L[e+4>>2]=B;L[e>>2]=f;f=L[D+40>>2];e=(j<<3)+h|0;L[e+4>>2]=B;L[e>>2]=f;break f}if(e){e=h+s|0;L[e+4>>2]=L[B+36>>2];L[e>>2]=D;e=(j<<3)+h|0;L[e+4>>2]=L[B+40>>2];L[e>>2]=D;break f}ha[L[L[g+140>>2]+8>>2]](g+140|0,D,B);f=d;e=h}j=r;break d}j=j+1|0}f=d;e=h}if(j){continue}break}if(!e){break c}if(e){L[8514]=L[8514]+1;ha[L[6799]](e)}}Y=L[a+8>>2];if(L[Y+8>>2]>0){j=0;while(1){h=R(j,12);d=h+L[Y+16>>2]|0;r=L[d+8>>2];k:{if(!r){break k}f=L[$+24>>2]+R(L[d>>2],80)|0;e=L[f+64>>2];d=L[b+12>>2];v=P[d+52>>2];q=P[d+56>>2];y=P[f+48>>2];C=P[f+52>>2];z=P[f+56>>2];H=P[f+4>>2];E=P[f+20>>2];I=P[f+36>>2];F=P[f+8>>2];K=P[f+24>>2];G=P[f+40>>2];Q=P[d+20>>2];A=P[d+24>>2];n=P[f>>2];U=P[d+36>>2];p=P[f+16>>2];N=P[d+40>>2];u=P[f+32>>2];o=P[d+48>>2];V=P[d+8>>2];O=P[d>>2];w=P[d+4>>2];t=P[d+16>>2];x=P[d+32>>2];f=0;L[g+72>>2]=0;L[g+56>>2]=0;L[g+40>>2]=0;L[g+24>>2]=0;P[g+44>>2]=S(u*N)+S(S(n*x)+S(U*p));P[g+28>>2]=S(u*A)+S(S(n*t)+S(Q*p));P[g+12>>2]=S(u*V)+S(S(n*O)+S(w*p));P[g+52>>2]=S(G*N)+S(S(F*x)+S(U*K));P[g+48>>2]=S(I*N)+S(S(H*x)+S(U*E));P[g+36>>2]=S(G*A)+S(S(F*t)+S(Q*K));P[g+32>>2]=S(I*A)+S(S(H*t)+S(Q*E));P[g+20>>2]=S(G*V)+S(S(F*O)+S(w*K));P[g+16>>2]=S(I*V)+S(S(H*O)+S(w*E));P[g+68>>2]=q+S(S(z*N)+S(S(y*x)+S(U*C)));P[g+64>>2]=v+S(S(z*A)+S(S(y*t)+S(Q*C)));P[g+60>>2]=o+S(S(z*V)+S(S(y*O)+S(w*C)));d=g+12|0;ha[L[L[e>>2]+8>>2]](e,d,g+124|0,g+108|0);i=L[aa+24>>2]+R(L[(h+L[Y+16>>2]|0)+4>>2],80)|0;e=L[i+64>>2];l=L[c+12>>2];v=P[l+52>>2];q=P[l+56>>2];y=P[i+48>>2];C=P[i+52>>2];z=P[i+56>>2];H=P[i+4>>2];E=P[i+20>>2];I=P[i+36>>2];F=P[i+8>>2];K=P[i+24>>2];G=P[i+40>>2];Q=P[l+20>>2];A=P[l+24>>2];n=P[i>>2];U=P[l+36>>2];p=P[i+16>>2];N=P[l+40>>2];u=P[i+32>>2];o=P[l+48>>2];V=P[l+8>>2];O=P[l>>2];w=P[l+4>>2];t=P[l+16>>2];x=P[l+32>>2];L[g+72>>2]=0;L[g+56>>2]=0;L[g+40>>2]=0;L[g+24>>2]=0;P[g+44>>2]=S(u*N)+S(S(n*x)+S(U*p));P[g+28>>2]=S(u*A)+S(S(n*t)+S(Q*p));P[g+12>>2]=S(u*V)+S(S(n*O)+S(w*p));P[g+52>>2]=S(G*N)+S(S(F*x)+S(U*K));P[g+48>>2]=S(I*N)+S(S(H*x)+S(U*E));P[g+36>>2]=S(G*A)+S(S(F*t)+S(Q*K));P[g+32>>2]=S(I*A)+S(S(H*t)+S(Q*E));P[g+20>>2]=S(G*V)+S(S(F*O)+S(w*K));P[g+16>>2]=S(I*V)+S(S(H*O)+S(w*E));P[g+68>>2]=q+S(S(z*N)+S(S(y*x)+S(U*C)));P[g+64>>2]=v+S(S(z*A)+S(S(y*t)+S(Q*C)));P[g+60>>2]=o+S(S(z*V)+S(S(y*O)+S(w*C)));ha[L[L[e>>2]+8>>2]](e,d,g+92|0,g+76|0);d=0;l:{if(P[g+124>>2]>P[g+76>>2]){break l}d=0;if(P[g+108>>2]>2]){break l}d=1}if(!(P[g+128>>2]>P[g+80>>2])&(!(P[g+112>>2]>2])&(P[g+116>>2]>2]|P[g+132>>2]>P[g+84>>2]?f:d))){break k}ha[L[L[r>>2]>>2]](r)|0;d=L[a+4>>2];ha[L[L[d>>2]+60>>2]](d,r);d=h+L[Y+16>>2]|0;i=L[d+4>>2];l=L[d>>2];h=L[a+16>>2];m:{if((h|0)!=L[a+20>>2]){break m}Z=h?h<<1:1;if((Z|0)<=(h|0)){break m}n:{if(!Z){s=0;break n}L[8513]=L[8513]+1;s=ha[L[6798]](R(Z,12),16)|0;h=L[a+16>>2]}o:{if((h|0)<=0){break o}r=h&1;if((h|0)!=1){e=h&-2;h=0;while(1){d=R(f,12);m=d+s|0;k=d+L[a+24>>2]|0;d=L[k+4>>2];L[m>>2]=L[k>>2];L[m+4>>2]=d;L[m+8>>2]=L[k+8>>2];d=R(f|1,12);m=d+s|0;k=d+L[a+24>>2]|0;d=L[k+4>>2];L[m>>2]=L[k>>2];L[m+4>>2]=d;L[m+8>>2]=L[k+8>>2];f=f+2|0;h=h+2|0;if((e|0)!=(h|0)){continue}break}}if(!r){break o}d=R(f,12);h=d+s|0;e=d+L[a+24>>2]|0;d=L[e+4>>2];L[h>>2]=L[e>>2];L[h+4>>2]=d;L[h+8>>2]=L[e+8>>2]}d=L[a+24>>2];if(!(d?!d|!M[a+28|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](d)}L[a+24>>2]=s;J[a+28|0]=1;L[a+20>>2]=Z;h=L[a+16>>2]}d=L[a+24>>2]+R(h,12)|0;L[d+8>>2]=0;L[d+4>>2]=i;L[d>>2]=l;L[a+16>>2]=L[a+16>>2]+1}j=j+1|0;if((j|0)>2]){continue}break}}if(L[a+16>>2]>0){f=0;while(1){c=L[a+8>>2];b=L[a+24>>2]+R(f,12)|0;ha[L[L[c>>2]+8>>2]](c,L[b>>2],L[b+4>>2])|0;f=f+1|0;if((f|0)>2]){continue}break}}b=L[a+24>>2];if(!(b?!b|!M[a+28|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+24>>2]=0;J[a+28|0]=1;L[a+16>>2]=0;L[a+20>>2]=0;fa=g+176|0}function vz(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=S(0),k=S(0),l=S(0),m=0,n=0,o=0,p=S(0),q=0,r=S(0),s=S(0),t=0,u=S(0),v=S(0),w=S(0),x=S(0),y=S(0),z=S(0),A=S(0),B=S(0),C=S(0),D=0,E=0,F=S(0),G=S(0);f=fa-176|0;fa=f;i=L[a+48>>2];e=L[a+52>>2];a:{if(!e){break a}e=L[e+20>>2];if(!e){break a}if(!(ha[L[L[e>>2]+48>>2]](e)&1)){break a}L[f+40>>2]=0;L[f+44>>2]=0;L[f+32>>2]=1065353216;L[f+36>>2]=1065353216;g=L[L[a+52>>2]+20>>2];e=L[a+8>>2];u=P[e+52>>2];p=P[e+12>>2];r=P[e+8>>2];v=P[e+56>>2];w=P[e+28>>2];y=P[e+20>>2];z=P[e+24>>2];A=P[e+60>>2];B=P[e+44>>2];C=P[e+36>>2];s=P[e+40>>2];x=P[e+4>>2];j=P[b+8>>2];k=P[b>>2];l=P[b+4>>2];L[f+152>>2]=0;P[f+148>>2]=A+S(S(j*B)+S(S(k*C)+S(l*s)));P[f+144>>2]=v+S(S(j*w)+S(S(k*y)+S(l*z)));P[f+140>>2]=u+S(S(j*p)+S(S(k*x)+S(l*r)));p=P[e+8>>2];r=P[e+12>>2];j=P[b+20>>2];k=P[b+24>>2];x=P[e+4>>2];l=P[b+16>>2];L[f+20>>2]=0;P[f+16>>2]=A+S(S(k*B)+S(S(l*C)+S(s*j)));P[f+12>>2]=v+S(S(k*w)+S(S(l*y)+S(z*j)));P[f+8>>2]=u+S(S(k*r)+S(S(l*x)+S(j*p)));o=f+140|0;h=f+8|0;n=f+32|0;ha[L[L[g>>2]+8>>2]](g,o,h,n);g=L[L[a+52>>2]+20>>2];u=P[e+52>>2];p=P[e+8>>2];r=P[e+12>>2];v=P[e+56>>2];w=P[e+20>>2];y=P[e+24>>2];z=P[e+28>>2];A=P[e+60>>2];B=P[e+36>>2];C=P[e+40>>2];j=P[b+20>>2];s=P[e+44>>2];k=P[b+24>>2];x=P[e+4>>2];l=P[b+16>>2];L[f+152>>2]=0;P[f+148>>2]=A+S(S(k*s)+S(S(l*B)+S(j*C)));P[f+144>>2]=v+S(S(k*z)+S(S(l*w)+S(j*y)));P[f+140>>2]=u+S(S(k*r)+S(S(l*x)+S(j*p)));p=P[e+8>>2];r=P[e+12>>2];j=P[b+36>>2];k=P[b+40>>2];x=P[e+4>>2];l=P[b+32>>2];L[f+20>>2]=0;P[f+16>>2]=A+S(S(k*s)+S(S(l*B)+S(C*j)));P[f+12>>2]=v+S(S(k*z)+S(S(l*w)+S(y*j)));P[f+8>>2]=u+S(S(k*r)+S(S(l*x)+S(j*p)));ha[L[L[g>>2]+8>>2]](g,o,h,n);g=L[L[a+52>>2]+20>>2];u=P[e+52>>2];p=P[e+8>>2];r=P[e+12>>2];v=P[e+56>>2];w=P[e+20>>2];y=P[e+24>>2];z=P[e+28>>2];A=P[e+60>>2];B=P[e+36>>2];C=P[e+40>>2];j=P[b+36>>2];s=P[e+44>>2];k=P[b+40>>2];x=P[e+4>>2];l=P[b+32>>2];L[f+152>>2]=0;P[f+148>>2]=A+S(S(k*s)+S(S(l*B)+S(j*C)));P[f+144>>2]=v+S(S(k*z)+S(S(l*w)+S(j*y)));P[f+140>>2]=u+S(S(k*r)+S(S(l*x)+S(j*p)));p=P[e+12>>2];r=P[e+8>>2];x=P[e+4>>2];j=P[b+8>>2];k=P[b>>2];l=P[b+4>>2];L[f+20>>2]=0;P[f+16>>2]=A+S(S(j*s)+S(S(k*B)+S(C*l)));P[f+12>>2]=v+S(S(j*z)+S(S(k*w)+S(y*l)));P[f+8>>2]=u+S(S(j*p)+S(S(k*x)+S(l*r)));ha[L[L[g>>2]+8>>2]](g,o,h,n)}e=c<<21|d;L[f+168>>2]=e;L[f+164>>2]=e;b:{c:{g=e+(d<<15^-1)|0;g=R(g>>10^g,9);g=g>>6^g;g=(g<<11^-1)+g|0;g=L[a+108>>2]-1&(g>>16^g);if(g>>>0>=O[a- -64>>2]){break c}g=L[L[a+72>>2]+(g<<2)>>2];if((g|0)==-1){break c}o=L[a+92>>2];h=L[a+132>>2];while(1){n=g<<2;if((e|0)!=L[n+h>>2]){g=L[o+n>>2];if((g|0)!=-1){continue}break c}break}e=L[a+112>>2];if(!e){break c}g=L[(e+(g<<3)|0)+4>>2];b=L[a+8>>2];L[g+8>>2]=L[L[b+192>>2]+8>>2];e=L[a+4>>2];o=L[e+192>>2];L[f+48>>2]=-1;L[f+52>>2]=-1;L[f+44>>2]=e+4;L[f+40>>2]=e;L[f+36>>2]=o;L[f+32>>2]=0;L[f+160>>2]=d;L[f+156>>2]=c;L[f+152>>2]=b+4;L[f+148>>2]=b;L[f+144>>2]=g;L[f+140>>2]=0;c=f+32|0;d=f+140|0;b=ha[L[L[i>>2]+8>>2]](i,c,d,0)|0;ha[L[L[b>>2]+8>>2]](b,c,d,L[a+52>>2],L[a+44>>2]);ha[L[L[b>>2]>>2]](b)|0;ha[L[L[i>>2]+60>>2]](i,b);break b}l=P[b+20>>2];y=P[b+36>>2];z=P[b+24>>2];A=P[b+40>>2];u=P[b+4>>2];B=P[b+32>>2];v=P[b+8>>2];w=P[b>>2];C=P[b+16>>2];L[f+124>>2]=0;L[f+108>>2]=0;L[f+92>>2]=0;L[f+76>>2]=0;L[f+60>>2]=0;k=S(C-w);s=S(y-u);p=S(B-w);r=S(l-u);j=S(S(k*s)-S(p*r));x=j;F=S(j*j);j=S(A-v);G=S(r*j);r=S(z-v);s=S(G-S(s*r));k=S(S(r*p)-S(j*k));p=S(S(1)/S(_(S(F+S(S(s*s)+S(k*k))))));j=S(S(x*p)*S(.05999999865889549));P[f+120>>2]=A-j;k=S(S(k*p)*S(.05999999865889549));P[f+116>>2]=y-k;P[f+104>>2]=z-j;P[f+100>>2]=l-k;P[f+88>>2]=v-j;P[f+84>>2]=u-k;P[f+72>>2]=A+j;P[f+68>>2]=y+k;P[f+56>>2]=z+j;P[f+52>>2]=l+k;L[f+44>>2]=0;l=S(S(s*p)*S(.05999999865889549));P[f+112>>2]=B-l;P[f+96>>2]=C-l;P[f+80>>2]=w-l;P[f+64>>2]=B+l;P[f+48>>2]=C+l;P[f+40>>2]=v+j;P[f+36>>2]=u+k;P[f+32>>2]=w+l;L[8513]=L[8513]+1;e=We(ha[L[6798]](112,16)|0,f+32|0,6);b=L[a+8>>2];L[e+8>>2]=L[L[b+192>>2]+8>>2];g=L[a+4>>2];o=L[g+192>>2];L[f+156>>2]=-1;L[f+160>>2]=-1;L[f+152>>2]=g+4;L[f+148>>2]=g;L[f+144>>2]=o;L[f+140>>2]=0;L[f+28>>2]=d;L[f+24>>2]=c;L[f+20>>2]=b+4;L[f+16>>2]=b;L[f+12>>2]=e;L[f+8>>2]=0;c=f+140|0;d=f+8|0;b=ha[L[L[i>>2]+8>>2]](i,c,d,0)|0;ha[L[L[b>>2]+8>>2]](b,c,d,L[a+52>>2],L[a+44>>2]);ha[L[L[b>>2]>>2]](b)|0;ha[L[L[i>>2]+60>>2]](i,b);L[f+172>>2]=e;d:{e:{f:{g:{h:{i:{e=a+60|0;b=L[e+48>>2];c=L[f+164>>2];a=(c<<15^-1)+c|0;a=R(a>>10^a,9);a=a>>6^a;a=(a<<11^-1)+a|0;o=b-1&(a>>16^a);j:{if(o>>>0>=O[e+4>>2]){break j}a=L[L[e+12>>2]+(o<<2)>>2];if((a|0)==-1){break j}d=L[e+32>>2];i=L[e+72>>2];while(1){g=a<<2;if((c|0)==L[g+i>>2]){break i}a=L[d+g>>2];if((a|0)!=-1){continue}break}}E=L[e+44>>2];a=E;k:{if((b|0)!=(a|0)){break k}a=b;n=a?a<<1:1;if((a|0)>=(n|0)){break k}l:{if(!n){d=0;c=b;break l}L[8513]=L[8513]+1;d=ha[L[6798]](n<<3,16)|0;c=L[e+44>>2]}m:{if((c|0)<=0){break m}i=0;a=0;if(c>>>0>=4){t=c&-4;g=0;while(1){h=a<<3;m=h+d|0;q=h+L[e+52>>2]|0;D=L[q+4>>2];L[m>>2]=L[q>>2];L[m+4>>2]=D;m=h|8;q=m+d|0;m=m+L[e+52>>2]|0;D=L[m+4>>2];L[q>>2]=L[m>>2];L[q+4>>2]=D;m=h|16;q=m+d|0;m=m+L[e+52>>2]|0;D=L[m+4>>2];L[q>>2]=L[m>>2];L[q+4>>2]=D;h=h|24;m=h+d|0;h=h+L[e+52>>2]|0;q=L[h+4>>2];L[m>>2]=L[h>>2];L[m+4>>2]=q;a=a+4|0;g=g+4|0;if((t|0)!=(g|0)){continue}break}}c=c&3;if(!c){break m}while(1){g=a<<3;h=g+d|0;g=g+L[e+52>>2]|0;t=L[g+4>>2];L[h>>2]=L[g>>2];L[h+4>>2]=t;a=a+1|0;i=i+1|0;if((c|0)!=(i|0)){continue}break}}a=L[e+52>>2];if(!(a?!a|!M[e+56|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](a)}L[e+52>>2]=d;J[e+56|0]=1;L[e+48>>2]=n;a=L[e+44>>2]}c=L[f+172>>2];a=L[e+52>>2]+(a<<3)|0;L[a>>2]=L[f+168>>2];L[a+4>>2]=c;L[e+44>>2]=L[e+44>>2]+1;i=L[e- -64>>2];if((i|0)!=L[e+68>>2]){break e}n=i?i<<1:1;if((n|0)<=(i|0)){break e}n:{if(!n){d=0;break n}L[8513]=L[8513]+1;d=ha[L[6798]](n<<2,16)|0;i=L[e+64>>2]}c=L[e+72>>2];if((i|0)<=0){break h}g=0;a=0;if(i>>>0>=4){m=i&-4;t=0;while(1){h=a<<2;L[h+d>>2]=L[c+h>>2];q=h|4;L[q+d>>2]=L[c+q>>2];q=h|8;L[q+d>>2]=L[c+q>>2];h=h|12;L[h+d>>2]=L[c+h>>2];a=a+4|0;t=t+4|0;if((m|0)!=(t|0)){continue}break}}i=i&3;if(!i){break g}while(1){h=a<<2;L[h+d>>2]=L[c+h>>2];a=a+1|0;g=g+1|0;if((i|0)!=(g|0)){continue}break}break g}b=L[f+172>>2];a=L[e+52>>2]+(a<<3)|0;L[a>>2]=L[f+168>>2];L[a+4>>2]=b;break d}if(!c){break f}}if(c?M[e+76|0]:0){L[8514]=L[8514]+1;ha[L[6799]](c)}i=L[e+64>>2]}L[e+72>>2]=d;L[e+68>>2]=n;J[e+76|0]=1}L[L[e+72>>2]+(i<<2)>>2]=L[f+164>>2];L[e+64>>2]=L[e+64>>2]+1;if((b|0)>2]){d=0;i=0;n=0;o=0;b=L[e+4>>2];g=L[e+48>>2];o:{if((b|0)>=(g|0)){break o}p:{if((g|0)<=L[e+8>>2]){d=L[e+12>>2];break p}if(g){L[8513]=L[8513]+1;d=ha[L[6798]](g<<2,16)|0;a=L[e+4>>2]}else{a=b}c=L[e+12>>2];q:{r:{if((a|0)>0){if(a>>>0>=4){t=a&-4;while(1){h=i<<2;L[h+d>>2]=L[c+h>>2];m=h|4;L[m+d>>2]=L[c+m>>2];m=h|8;L[m+d>>2]=L[c+m>>2];h=h|12;L[h+d>>2]=L[c+h>>2];i=i+4|0;n=n+4|0;if((t|0)!=(n|0)){continue}break}}a=a&3;if(!a){break r}while(1){h=i<<2;L[h+d>>2]=L[c+h>>2];i=i+1|0;o=o+1|0;if((a|0)!=(o|0)){continue}break}break r}if(c){break r}break q}if(c?M[e+16|0]:0){L[8514]=L[8514]+1;ha[L[6799]](c)}}L[e+12>>2]=d;J[e+16|0]=1;L[e+8>>2]=g}a=b<<2;t=g<<2;pa(a+d|0,0,t-a|0);L[e+4>>2]=g;c=L[e+24>>2];if((c|0)<(g|0)){s:{if((g|0)<=L[e+28>>2]){d=L[e+32>>2];break s}t:{if(!g){d=0;a=c;break t}L[8513]=L[8513]+1;d=ha[L[6798]](t,16)|0;a=L[e+24>>2]}h=L[e+32>>2];u:{if((a|0)>0){o=0;i=0;if(a>>>0>=4){q=a&-4;n=0;while(1){m=i<<2;L[m+d>>2]=L[h+m>>2];D=m|4;L[D+d>>2]=L[h+D>>2];D=m|8;L[D+d>>2]=L[h+D>>2];m=m|12;L[m+d>>2]=L[h+m>>2];i=i+4|0;n=n+4|0;if((q|0)!=(n|0)){continue}break}}a=a&3;if(!a){break u}while(1){n=i<<2;L[n+d>>2]=L[h+n>>2];i=i+1|0;o=o+1|0;if((a|0)!=(o|0)){continue}break}break u}if(h){break u}L[e+32>>2]=d;L[e+28>>2]=g;J[e+36|0]=1;break s}if(h?M[e+36|0]:0){L[8514]=L[8514]+1;ha[L[6799]](h)}L[e+32>>2]=d;J[e+36|0]=1;L[e+28>>2]=g}a=c<<2;pa(a+d|0,0,t-a|0)}L[e+24>>2]=g;if((g|0)>0){pa(L[e+12>>2],255,t);pa(L[e+32>>2],255,t)}if((b|0)<=0){break o}c=L[e+32>>2];d=L[e+72>>2];g=L[e+12>>2];i=0;while(1){o=i<<2;a=L[o+d>>2];a=(a<<15^-1)+a|0;a=R(a>>10^a,9);a=a>>6^a;a=(a<<11^-1)+a|0;a=g+((L[e+48>>2]-1&(a>>16^a))<<2)|0;L[c+o>>2]=L[a>>2];L[a>>2]=i;i=i+1|0;if((b|0)!=(i|0)){continue}break}}a=L[f+164>>2];a=(a<<15^-1)+a|0;a=R(a>>10^a,9);a=a>>6^a;a=(a<<11^-1)+a|0;o=L[e+48>>2]-1&(a>>16^a)}a=L[e+12>>2]+(o<<2)|0;L[L[e+32>>2]+(E<<2)>>2]=L[a>>2];L[a>>2]=E}}fa=f+176|0}function Cg(a,b,c){var d=S(0),e=0,f=0,g=S(0),h=S(0),i=S(0),j=S(0),k=0,l=0,m=0,n=S(0),o=S(0),p=S(0),q=S(0),r=S(0),s=S(0),t=S(0),u=0,v=0,w=0,x=S(0),y=S(0),z=S(0),A=S(0),B=S(0),C=S(0),D=S(0),E=S(0),F=S(0),G=S(0),H=S(0),I=S(0),J=S(0),K=S(0),M=0,N=S(0),O=S(0),Q=S(0),T=S(0),U=0,V=0,W=0,X=0,Y=S(0),Z=S(0),$=0,aa=0;e=fa-96|0;fa=e;L[a+376>>2]=0;L[a+364>>2]=4;L[a+368>>2]=0;k=a+316|0;L[a+360>>2]=k;L[a+356>>2]=a+284;L[a+352>>2]=a+252;L[a+348>>2]=a+220;f=L[b+4>>2];L[a>>2]=L[b>>2];L[a+4>>2]=f;f=L[b+20>>2];L[a+16>>2]=L[b+16>>2];L[a+20>>2]=f;f=L[b+12>>2];L[a+8>>2]=L[b+8>>2];L[a+12>>2]=f;f=L[b+36>>2];L[a+32>>2]=L[b+32>>2];L[a+36>>2]=f;f=L[b+28>>2];L[a+24>>2]=L[b+24>>2];L[a+28>>2]=f;f=L[b+52>>2];L[a+48>>2]=L[b+48>>2];L[a+52>>2]=f;f=L[b+44>>2];L[a+40>>2]=L[b+40>>2];L[a+44>>2]=f;l=b- -64|0;f=L[l+4>>2];w=a- -64|0;L[w>>2]=L[l>>2];L[w+4>>2]=f;f=L[b+60>>2];L[a+56>>2]=L[b+56>>2];L[a+60>>2]=f;f=L[b+84>>2];L[a+80>>2]=L[b+80>>2];L[a+84>>2]=f;f=L[b+76>>2];L[a+72>>2]=L[b+72>>2];L[a+76>>2]=f;f=L[b+100>>2];L[a+96>>2]=L[b+96>>2];L[a+100>>2]=f;f=L[b+92>>2];L[a+88>>2]=L[b+88>>2];L[a+92>>2]=f;f=L[b+108>>2];L[a+104>>2]=L[b+104>>2];L[a+108>>2]=f;f=L[b+116>>2];L[a+112>>2]=L[b+112>>2];L[a+116>>2]=f;f=L[b+124>>2];b=L[b+120>>2];L[a+144>>2]=0;L[a+180>>2]=0;L[a+120>>2]=b;L[a+124>>2]=f;b=L[c+4>>2];L[a+128>>2]=L[c>>2];L[a+132>>2]=b;b=L[c+12>>2];L[a+136>>2]=L[c+8>>2];L[a+140>>2]=b;L[a+364>>2]=3;L[a+164>>2]=0;L[a+328>>2]=0;L[a+180>>2]=1;L[a+148>>2]=k;h=P[a+136>>2];i=P[a+128>>2];d=P[a+132>>2];g=S(S(h*h)+S(S(i*i)+S(d*d)));b=g>S(0);h=b?S(-h):S(0);i=b?S(-i):S(1);d=b?S(-d):S(0);j=S(S(1)/S(_(S(S(h*h)+S(S(i*i)+S(d*d))))));P[a+324>>2]=h*j;P[a+320>>2]=d*j;P[k>>2]=i*j;Xa(e+16|0,a,k);b=L[e+28>>2];L[a+340>>2]=L[e+24>>2];L[a+344>>2]=b;b=L[e+20>>2];L[a+332>>2]=L[e+16>>2];L[a+336>>2]=b;L[a+164>>2]=1065353216;c=L[a+148>>2];b=L[c+20>>2];L[a+128>>2]=L[c+16>>2];L[a+132>>2]=b;b=L[c+28>>2];L[a+136>>2]=L[c+24>>2];L[a+140>>2]=b;b=L[c+28>>2];L[e+72>>2]=L[c+24>>2];L[e+76>>2]=b;b=L[c+20>>2];L[e+64>>2]=L[c+16>>2];L[e+68>>2]=b;b=L[c+28>>2];L[e+56>>2]=L[c+24>>2];L[e+60>>2]=b;b=L[c+20>>2];L[e+48>>2]=L[c+16>>2];L[e+52>>2]=b;b=L[c+28>>2];L[e+40>>2]=L[c+24>>2];L[e+44>>2]=b;b=L[c+20>>2];L[e+32>>2]=L[c+16>>2];L[e+36>>2]=b;b=L[c+28>>2];L[e+24>>2]=L[c+24>>2];L[e+28>>2]=b;b=L[c+20>>2];L[e+16>>2]=L[c+16>>2];L[e+20>>2]=b;d=P[a+136>>2];n=P[a+132>>2];j=P[a+128>>2];u=L[a+368>>2];W=a+148|0;while(1){a:{b:{o=S(_(S(S(d*d)+S(S(j*j)+S(n*n)))));c:{if(o>2]=1;break c}f=R(u,36);w=f+a|0;c=L[w+180>>2];l=c<<2;L[(l+w|0)+164>>2]=0;b=L[a+364>>2]-1|0;L[a+364>>2]=b;v=f+W|0;f=L[((b<<2)+a|0)+348>>2];L[l+v>>2]=f;L[w+180>>2]=c+1;L[f+12>>2]=0;i=S(S(1)/o);P[f+8>>2]=i*S(-d);P[f+4>>2]=i*S(-n);P[f>>2]=i*S(-j);Xa(e+80|0,a,f);b=L[e+92>>2];L[f+24>>2]=L[e+88>>2];L[f+28>>2]=b;b=L[e+84>>2];L[f+16>>2]=L[e+80>>2];L[f+20>>2]=b;d:{f=L[w+180>>2];l=L[((f<<2)+v|0)-4>>2];j=P[l+24>>2];d=S(j-P[e+24>>2]);s=S(d*d);h=P[l+16>>2];d=S(h-P[e+16>>2]);p=S(d*d);i=P[l+20>>2];d=S(i-P[e+20>>2]);if(S(s+S(p+S(d*d)))>2]);s=S(d*d);d=S(h-P[e+32>>2]);p=S(d*d);d=S(i-P[e+36>>2]);if(S(s+S(p+S(d*d)))>2]);s=S(d*d);d=S(h-P[e+48>>2]);p=S(d*d);d=S(i-P[e+52>>2]);if(S(s+S(p+S(d*d)))>2]);s=S(d*d);d=S(h-P[e+64>>2]);p=S(d*d);d=S(i-P[e+68>>2]);if(S(s+S(p+S(d*d)))>2];X=X+1&3;c=(e+16|0)+(X<<4)|0;L[c+8>>2]=L[l+24>>2];L[c+12>>2]=b;b=L[l+20>>2];L[c>>2]=L[l+16>>2];L[c+4>>2]=b;d=S(S(S(P[a+136>>2]*j)+S(S(P[a+128>>2]*h)+S(P[a+132>>2]*i)))/o);N=d>N?d:N;if(S(S(o*S(-9999999747378752e-20))+S(o-N))<=S(0)){u=L[a+368>>2];c=R(u,36)+a|0;b=L[c+180>>2]-1|0;L[c+180>>2]=b;c=L[(c+(b<<2)|0)+148>>2];b=L[a+364>>2];L[a+364>>2]=b+1;L[((b<<2)+a|0)+348>>2]=c;break c}L[e+12>>2]=0;e:{f:{g:{switch(f-2|0){case 0:c=L[v+4>>2];h=P[c+24>>2];b=L[v>>2];x=P[b+24>>2];n=S(h-x);i=P[c+16>>2];q=P[b+16>>2];o=S(i-q);g=P[c+20>>2];r=P[b+20>>2];j=S(g-r);d=S(S(n*n)+S(S(o*o)+S(j*j)));if(!(d>S(0))){break e}t=S(S(-S(S(x*n)+S(S(q*o)+S(r*j))))/d);if(t>=S(1)){L[e+12>>2]=2;L[e+80>>2]=0;L[e+84>>2]=1065353216;g=S(S(h*h)+S(S(i*i)+S(g*g)));break f}if(t<=S(0)){L[e+12>>2]=1;L[e+80>>2]=1065353216;L[e+84>>2]=0;g=S(S(x*x)+S(S(q*q)+S(r*r)));break f}L[e+12>>2]=3;P[e+84>>2]=t;P[e+80>>2]=S(1)-t;d=S(x+S(n*t));p=S(d*d);d=S(q+S(o*t));g=S(d*d);d=S(r+S(j*t));g=S(p+S(g+S(d*d)));break f;case 1:g=Ke(L[v>>2]+16|0,L[v+4>>2]+16|0,L[v+8>>2]+16|0,e+80|0,e+12|0);break f;case 2:break g;default:break f}}m=fa-32|0;fa=m;d=S(-1);l=L[v+4>>2]+16|0;s=P[l+4>>2];k=L[v+12>>2]+16|0;C=P[k+4>>2];D=S(s-C);f=L[v>>2]+16|0;p=P[f+8>>2];E=P[k+8>>2];F=S(p-E);Y=S(D*S(-F));c=L[v+8>>2]+16|0;i=P[c>>2];G=P[k>>2];z=S(i-G);O=P[f>>2];H=S(O-G);Z=S(H*D);t=P[c+8>>2];A=S(t-E);h=P[l>>2];I=S(h-G);Q=P[f+4>>2];J=S(Q-C);x=S(I*S(-J));T=P[l+8>>2];K=S(T-E);q=S(K*S(-H));g=P[c+4>>2];B=S(g-C);r=S(J*K);n=S(F*I);y=S(S(Y*z)+S(S(Z*A)+S(S(x*A)+S(S(q*B)+S(S(r*z)+S(n*B))))));h:{if(!(y>S(0)|y>2]=0;L[m+16>>2]=0;L[m+20>>2]=0;L[m+12>>2]=0;if(S(y*S(S(E*S(Z+x))+S(S(G*S(r+Y))+S(C*S(n+q)))))>S(0)){d=Ke(f,l,k,m+16|0,m+12|0);b=L[m+12>>2];L[e+12>>2]=b&3|b<<1&8;P[e+80>>2]=P[m+16>>2];g=P[m+20>>2];L[e+88>>2]=0;P[e+84>>2]=g;P[e+92>>2]=P[m+24>>2]}i:{if(!(S(y*S(S(P[k+8>>2]*S(S(I*B)-S(z*D)))+S(S(P[k>>2]*S(S(D*A)-S(B*K)))+S(P[k+4>>2]*S(S(K*z)-S(A*I))))))>S(0))){break i}g=Ke(l,c,k,m+16|0,m+12|0);if(!(d>2]=L[m+12>>2]<<1&14;P[e+84>>2]=P[m+16>>2];d=P[m+20>>2];L[e+80>>2]=0;P[e+88>>2]=d;P[e+92>>2]=P[m+24>>2];d=g}j:{if(!(S(y*S(S(P[k+8>>2]*S(S(z*J)-S(H*B)))+S(S(P[k>>2]*S(S(B*F)-S(J*A)))+S(P[k+4>>2]*S(S(A*H)-S(F*z))))))>S(0))){break j}g=Ke(c,f,k,m+16|0,m+12|0);if(!(d>2];L[e+12>>2]=b>>>1&1|b<<1&8|b<<2&4;P[e+88>>2]=P[m+16>>2];d=P[m+20>>2];L[e+84>>2]=0;P[e+80>>2]=d;P[e+92>>2]=P[m+24>>2];d=g}if(!(d>2]=15;q=P[c>>2];r=P[l+4>>2];n=P[k+8>>2];o=P[c+4>>2];j=P[l+8>>2];h=P[k>>2];i=P[c+8>>2];g=P[l>>2];d=P[k+4>>2];t=S(S(S(S(S(q*r)*n)+S(S(S(S(S(o*j)*h)+S(S(i*g)*d))-S(S(j*q)*d))-S(S(g*o)*n)))-S(S(r*i)*h))/y);P[e+80>>2]=t;q=P[f>>2];r=P[c+4>>2];n=P[k+8>>2];o=P[f+4>>2];j=P[c+8>>2];h=P[k>>2];i=P[f+8>>2];g=P[c>>2];d=P[k+4>>2];x=S(S(S(S(S(q*r)*n)+S(S(S(S(S(o*j)*h)+S(S(i*g)*d))-S(S(j*q)*d))-S(S(g*o)*n)))-S(S(r*i)*h))/y);P[e+84>>2]=x;q=P[l>>2];r=P[f+4>>2];n=P[k+8>>2];o=P[l+4>>2];j=P[f+8>>2];h=P[k>>2];i=P[l+8>>2];g=P[f>>2];d=P[k+4>>2];d=S(S(S(S(S(q*r)*n)+S(S(S(S(S(o*j)*h)+S(S(i*g)*d))-S(S(j*q)*d))-S(S(g*o)*n)))-S(S(r*i)*h))/y);P[e+88>>2]=d;P[e+92>>2]=S(1)-S(S(t+x)+d);d=S(0)}fa=m+32|0;g=d}if(!(g>=S(0))){break e}u=1-u|0;b=R(u,36);U=b+a|0;L[U+180>>2]=0;L[a+136>>2]=0;L[a+140>>2]=0;L[a+128>>2]=0;L[a+132>>2]=0;L[a+368>>2]=u;m=L[w+180>>2];if(!m){d=S(0);V=L[e+12>>2];n=S(0);j=S(0);break b}k=b+W|0;c=L[a+364>>2];d=S(0);M=0;V=L[e+12>>2];n=S(0);j=S(0);b=0;while(1){w=b<<2;l=w+v|0;$=L[l>>2];k:{if(V>>>b&1){f=M<<2;L[f+k>>2]=$;h=P[w+(e+80|0)>>2];M=M+1|0;L[U+180>>2]=M;P[(f+U|0)+164>>2]=h;f=L[l>>2];i=P[f+24>>2];d=P[f+20>>2];j=S(S(h*P[f+16>>2])+P[a+128>>2]);P[a+128>>2]=j;n=S(S(h*d)+P[a+132>>2]);P[a+132>>2]=n;d=S(S(h*i)+P[a+136>>2]);P[a+136>>2]=d;break k}f=c+1|0;L[a+364>>2]=f;L[((c<<2)+a|0)+348>>2]=$;c=f}b=b+1|0;if((m|0)!=(b|0)){continue}break}break b}u=L[a+368>>2];c=R(u,36)+a|0;b=L[c+180>>2]-1|0;L[c+180>>2]=b;c=L[(c+(b<<2)|0)+148>>2];b=L[a+364>>2];L[a+364>>2]=b+1;L[((b<<2)+a|0)+348>>2]=c;break c}u=L[a+368>>2];c=R(u,36)+a|0;b=L[c+180>>2]-1|0;L[c+180>>2]=b;c=L[(c+(b<<2)|0)+148>>2];b=L[a+364>>2];L[a+364>>2]=b+1;L[((b<<2)+a|0)+348>>2]=c}b=L[a+376>>2];break a}aa=aa+1|0;b=aa>>>0>=128?2:(V|0)==15?1:L[a+376>>2];L[a+376>>2]=b;if(!b){continue}}break}L[a+372>>2]=(R(u,36)+a|0)+148;d=S(0);l:{switch(b|0){case 0:d=P[a+136>>2];p=S(d*d);d=P[a+128>>2];g=S(d*d);d=P[a+132>>2];d=S(_(S(p+S(g+S(d*d)))));case 1:P[a+144>>2]=d;break;default:break l}}fa=e+96|0;return b}function sH(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0,g=S(0),h=S(0),i=0,j=S(0),k=0,l=S(0),m=S(0),n=S(0),o=S(0),p=S(0),q=S(0),r=S(0),s=S(0),t=S(0),u=S(0),v=S(0),w=S(0),x=S(0),y=S(0),z=S(0),A=S(0),B=0,C=0,D=S(0),E=S(0),F=0,G=0,H=0,I=0,J=0,K=S(0),M=S(0),N=S(0);e=fa-144|0;fa=e;f=ha[L[L[a>>2]+20>>2]](a)|0;ha[L[L[f>>2]+56>>2]](f,b,S(1));a:{b:{c:{d:{e:{f:{g:{h:{i:{j:{f=L[c+4>>2];switch(f|0){case 31:break j;case 28:break c;case 13:break d;case 11:break e;case 10:break f;case 9:break g;case 8:break h;case 0:break i;default:break b}}f=L[c+16>>2];if((f|0)<=0){break a}while(1){k=f-1|0;i=L[c+24>>2]+R(k,80)|0;B=L[i+64>>2];p=P[i+56>>2];q=P[i+48>>2];w=P[i+52>>2];x=P[i+32>>2];y=P[i>>2];z=P[i+16>>2];A=P[i+36>>2];r=P[i+4>>2];s=P[i+20>>2];t=P[i+40>>2];D=P[i+8>>2];E=P[i+24>>2];K=P[b+48>>2];M=P[b+52>>2];N=P[b+56>>2];g=P[b+8>>2];h=P[b>>2];j=P[b+4>>2];l=P[b+24>>2];m=P[b+16>>2];n=P[b+20>>2];u=P[b+40>>2];v=P[b+32>>2];o=P[b+36>>2];L[e+60>>2]=0;L[e+44>>2]=0;L[e+28>>2]=0;L[e+12>>2]=0;P[e+40>>2]=S(t*u)+S(S(D*v)+S(E*o));P[e+36>>2]=S(A*u)+S(S(r*v)+S(s*o));P[e+32>>2]=S(x*u)+S(S(y*v)+S(z*o));P[e+24>>2]=S(t*l)+S(S(D*m)+S(E*n));P[e+20>>2]=S(A*l)+S(S(r*m)+S(s*n));P[e+16>>2]=S(x*l)+S(S(y*m)+S(z*n));P[e+8>>2]=S(t*g)+S(S(D*h)+S(E*j));P[e+4>>2]=S(A*g)+S(S(r*h)+S(s*j));P[e>>2]=S(x*g)+S(S(y*h)+S(z*j));P[e+56>>2]=N+S(S(p*u)+S(S(q*v)+S(w*o)));P[e+52>>2]=M+S(S(p*l)+S(S(q*m)+S(w*n)));P[e+48>>2]=K+S(S(p*g)+S(S(q*h)+S(w*j)));ha[L[L[a>>2]+28>>2]](a,e,B,d);i=f>>>0>1;f=k;if(i){continue}break}break a}f=L[c+40>>2];L[e+8>>2]=L[c+36>>2];L[e+12>>2]=f;f=L[c+32>>2];L[e>>2]=L[c+28>>2];L[e+4>>2]=f;g=S(ha[L[L[c>>2]+48>>2]](c));h=S(ha[L[L[c>>2]+48>>2]](c));j=S(S(ha[L[L[c>>2]+48>>2]](c))+P[e+8>>2]);P[e+8>>2]=j;g=S(g+P[e>>2]);P[e>>2]=g;h=S(h+P[e+4>>2]);P[e+4>>2]=h;a=ha[L[L[a>>2]+20>>2]](a)|0;L[e+140>>2]=0;P[e+136>>2]=-j;P[e+132>>2]=-h;P[e+128>>2]=-g;ha[L[L[a>>2]+72>>2]](a,e+128|0,e,b,d);break a}g=S(ha[L[L[c>>2]+48>>2]](c));a=ha[L[L[a>>2]+20>>2]](a)|0;ha[L[L[a>>2]+16>>2]](a,g,b,d);break a}f=L[c+92>>2];if((f|0)<=0){break a}while(1){k=f-1|0;i=L[c+100>>2]+(k<<4)|0;g=P[i+8>>2];h=P[i>>2];j=P[i+4>>2];i=ha[L[L[a>>2]+20>>2]](a)|0;x=P[L[c+120>>2]+(k<<2)>>2];y=P[b+48>>2];z=P[b+52>>2];A=P[b+56>>2];l=P[b+8>>2];m=P[b>>2];n=P[b+4>>2];u=P[b+24>>2];v=P[b+16>>2];o=P[b+20>>2];p=P[b+40>>2];q=P[b+32>>2];w=P[b+36>>2];L[e+60>>2]=0;L[e+44>>2]=0;L[e+28>>2]=0;L[e+12>>2]=0;r=S(q*S(0));s=S(w*S(0));P[e+40>>2]=p+S(r+s);t=S(p*S(0));P[e+36>>2]=t+S(r+w);P[e+32>>2]=t+S(q+s);r=S(v*S(0));s=S(o*S(0));P[e+24>>2]=u+S(r+s);t=S(u*S(0));P[e+20>>2]=t+S(r+o);P[e+16>>2]=t+S(v+s);r=S(m*S(0));s=S(n*S(0));P[e+8>>2]=l+S(r+s);t=S(l*S(0));P[e+4>>2]=t+S(r+n);P[e>>2]=t+S(m+s);P[e+56>>2]=A+S(S(g*p)+S(S(h*q)+S(j*w)));P[e+52>>2]=z+S(S(g*u)+S(S(h*v)+S(j*o)));P[e+48>>2]=y+S(S(g*l)+S(S(h*m)+S(j*n)));ha[L[L[i>>2]+16>>2]](i,x,e,d);i=f>>>0>1;f=k;if(i){continue}break}break a}f=L[c+52>>2];c=c+28|0;g=P[(f<<2)+c>>2];h=P[c+((f+2|0)%3<<2)>>2];a=ha[L[L[a>>2]+20>>2]](a)|0;ha[L[L[a>>2]+76>>2]](a,h,g,f,b,d);break a}f=L[c+68>>2];g=P[c+60>>2];h=P[c+56>>2];a=ha[L[L[a>>2]+20>>2]](a)|0;ha[L[L[a>>2]+84>>2]](a,h,g,f,b,d);break a}f=L[c+52>>2];g=S(ha[L[L[c>>2]+92>>2]](c));k=L[c+40>>2];L[e+8>>2]=L[c+36>>2];L[e+12>>2]=k;k=L[c+32>>2];L[e>>2]=L[c+28>>2];L[e+4>>2]=k;h=S(ha[L[L[c>>2]+48>>2]](c));j=S(ha[L[L[c>>2]+48>>2]](c));P[e+8>>2]=S(ha[L[L[c>>2]+48>>2]](c))+P[e+8>>2];P[e>>2]=h+P[e>>2];P[e+4>>2]=j+P[e+4>>2];h=P[(f<<2)+e>>2];a=ha[L[L[a>>2]+20>>2]](a)|0;ha[L[L[a>>2]+80>>2]](a,g,h,f,b,d);break a}g=P[c+64>>2];a=ha[L[L[a>>2]+20>>2]](a)|0;ha[L[L[a>>2]+88>>2]](a,c+48|0,g,b,d);break a}k:{if((f|0)>6){break k}B=L[c+52>>2];if(B){if(L[B+28>>2]<=0){break k}while(1){i=L[B+36>>2];F=R(G,36);f=i+F|0;H=L[f+4>>2];l:{if((H|0)<=0){g=S(0);h=S(0);j=S(0);break l}k=L[(L[f+12>>2]+(H<<2)|0)-4>>2];j=S(0);f=0;h=S(0);g=S(0);while(1){i=L[L[(i+F|0)+12>>2]+(f<<2)>>2];I=i<<4;C=I+L[B+16>>2]|0;t=P[C>>2];D=P[C+4>>2];E=P[C+8>>2];C=ha[L[L[a>>2]+20>>2]](a)|0;J=L[B+16>>2];k=J+(k<<4)|0;l=P[k+8>>2];m=P[k>>2];n=P[k+4>>2];u=P[b+48>>2];v=P[b+8>>2];o=P[b>>2];p=P[b+4>>2];q=P[b+52>>2];w=P[b+24>>2];x=P[b+16>>2];y=P[b+20>>2];z=P[b+56>>2];A=P[b+40>>2];r=P[b+32>>2];s=P[b+36>>2];L[e+12>>2]=0;P[e+8>>2]=z+S(S(l*A)+S(S(m*r)+S(n*s)));P[e+4>>2]=q+S(S(l*w)+S(S(m*x)+S(n*y)));P[e>>2]=u+S(S(l*v)+S(S(m*o)+S(n*p)));k=I+J|0;l=P[k+8>>2];m=P[k>>2];n=P[k+4>>2];L[e+140>>2]=0;P[e+136>>2]=z+S(S(l*A)+S(S(m*r)+S(s*n)));P[e+132>>2]=q+S(S(l*w)+S(S(m*x)+S(y*n)));P[e+128>>2]=u+S(S(l*v)+S(S(m*o)+S(p*n)));ha[L[L[C>>2]+8>>2]](C,e,e+128|0,d);j=S(j+E);h=S(h+D);g=S(g+t);k=i;f=f+1|0;i=L[B+36>>2];if((f|0)>2]){continue}break}}f=ha[L[L[a>>2]+20>>2]](a)|0;if(ha[L[L[f>>2]+48>>2]](f)&16384){L[e+8>>2]=0;L[e+12>>2]=0;L[e>>2]=1065353216;L[e+4>>2]=1065353216;f=L[B+36>>2]+F|0;r=P[f+28>>2];s=P[f+20>>2];t=P[f+24>>2];f=ha[L[L[a>>2]+20>>2]](a)|0;l=P[b+48>>2];m=P[b+8>>2];n=P[b>>2];u=P[b+4>>2];v=P[b+52>>2];o=P[b+24>>2];p=P[b+16>>2];q=P[b+20>>2];w=P[b+56>>2];x=P[b+40>>2];y=P[b+32>>2];z=P[b+36>>2];L[e+140>>2]=0;A=S(S(1)/S(H|0));j=S(A*j);g=S(A*g);h=S(A*h);P[e+136>>2]=w+S(S(x*j)+S(S(y*g)+S(z*h)));P[e+132>>2]=v+S(S(j*o)+S(S(g*p)+S(h*q)));P[e+128>>2]=l+S(S(j*m)+S(S(g*n)+S(h*u)));L[e+124>>2]=0;j=S(j+r);g=S(g+s);h=S(h+t);P[e+120>>2]=w+S(S(x*j)+S(S(y*g)+S(z*h)));P[e+116>>2]=v+S(S(j*o)+S(S(g*p)+S(h*q)));P[e+112>>2]=l+S(S(j*m)+S(S(g*n)+S(h*u)));ha[L[L[f>>2]+8>>2]](f,e+128|0,e+112|0,e)}G=G+1|0;if((G|0)>2]){continue}break}break k}if((ha[L[L[c>>2]+100>>2]](c)|0)<=0){break k}f=0;while(1){ha[L[L[c>>2]+104>>2]](c,f,e,e+128|0);g=P[b+48>>2];h=P[b+8>>2];j=P[b>>2];l=P[b+4>>2];m=P[b+52>>2];n=P[b+24>>2];u=P[b+16>>2];v=P[b+20>>2];o=P[b+56>>2];p=P[b+40>>2];q=P[b+32>>2];w=P[b+36>>2];L[e+124>>2]=0;x=P[e+8>>2];y=P[e>>2];z=P[e+4>>2];P[e+120>>2]=o+S(S(p*x)+S(S(q*y)+S(w*z)));P[e+116>>2]=m+S(S(x*n)+S(S(y*u)+S(z*v)));P[e+112>>2]=g+S(S(x*h)+S(S(y*j)+S(z*l)));L[e+108>>2]=0;r=o;o=P[e+136>>2];s=S(p*o);p=P[e+128>>2];t=S(q*p);q=P[e+132>>2];P[e+104>>2]=r+S(s+S(t+S(w*q)));P[e+100>>2]=m+S(S(o*n)+S(S(p*u)+S(v*q)));P[e+96>>2]=g+S(S(o*h)+S(S(p*j)+S(l*q)));k=ha[L[L[a>>2]+20>>2]](a)|0;ha[L[L[k>>2]+8>>2]](k,e+112|0,e+96|0,d);f=f+1|0;if((ha[L[L[c>>2]+100>>2]](c)|0)>(f|0)){continue}break}}f=L[c+4>>2];if(f-21>>>0<=8){L[e+136>>2]=1566444395;L[e+140>>2]=0;L[e+128>>2]=1566444395;L[e+132>>2]=1566444395;L[e+120>>2]=-581039253;L[e+124>>2]=0;L[e+112>>2]=-581039253;L[e+116>>2]=-581039253;L[e+8>>2]=ha[L[L[a>>2]+20>>2]](a);L[e+4>>2]=8612;L[e>>2]=8588;f=L[d+12>>2];L[e+20>>2]=L[d+8>>2];L[e+24>>2]=f;f=L[d+4>>2];L[e+12>>2]=L[d>>2];L[e+16>>2]=f;f=L[b+12>>2];L[e+36>>2]=L[b+8>>2];L[e+40>>2]=f;f=L[b+4>>2];L[e+28>>2]=L[b>>2];L[e+32>>2]=f;f=L[b+20>>2];L[e+44>>2]=L[b+16>>2];L[e+48>>2]=f;f=L[b+28>>2];L[e+52>>2]=L[b+24>>2];L[e+56>>2]=f;f=L[b+44>>2];L[e+68>>2]=L[b+40>>2];L[e+72>>2]=f;f=L[b+36>>2];L[e+60>>2]=L[b+32>>2];L[e+64>>2]=f;f=L[b+52>>2];L[e+76>>2]=L[b+48>>2];L[e+80>>2]=f;f=L[b+60>>2];L[e+84>>2]=L[b+56>>2];L[e+88>>2]=f;ha[L[L[c>>2]+64>>2]](c,e,e+112|0,e+128|0);f=L[c+4>>2]}if((f|0)!=3){break a}L[e+136>>2]=1566444395;L[e+140>>2]=0;L[e+128>>2]=1566444395;L[e+132>>2]=1566444395;L[e+120>>2]=-581039253;L[e+124>>2]=0;L[e+112>>2]=-581039253;L[e+116>>2]=-581039253;L[e+8>>2]=ha[L[L[a>>2]+20>>2]](a);L[e+4>>2]=8612;L[e>>2]=8588;a=L[d+12>>2];L[e+20>>2]=L[d+8>>2];L[e+24>>2]=a;a=L[d+4>>2];L[e+12>>2]=L[d>>2];L[e+16>>2]=a;a=L[b+12>>2];L[e+36>>2]=L[b+8>>2];L[e+40>>2]=a;a=L[b+4>>2];L[e+28>>2]=L[b>>2];L[e+32>>2]=a;a=L[b+20>>2];L[e+44>>2]=L[b+16>>2];L[e+48>>2]=a;a=L[b+28>>2];L[e+52>>2]=L[b+24>>2];L[e+56>>2]=a;a=L[b+44>>2];L[e+68>>2]=L[b+40>>2];L[e+72>>2]=a;a=L[b+36>>2];L[e+60>>2]=L[b+32>>2];L[e+64>>2]=a;a=L[b+52>>2];L[e+76>>2]=L[b+48>>2];L[e+80>>2]=a;a=L[b+60>>2];L[e+84>>2]=L[b+56>>2];L[e+88>>2]=a;a=L[c+92>>2];ha[L[L[a>>2]+8>>2]](a,e+4|0,e+112|0,e+128|0)}fa=e+144|0}function fm(a,b,c,d,e){var f=0,g=S(0),h=0,i=0,j=0,k=0,l=0,m=S(0),n=S(0),o=S(0),p=0,q=S(0),r=0,s=0,t=S(0),u=S(0),v=S(0),w=S(0),x=S(0),y=S(0),z=S(0);k=fa-48|0;fa=k;J[a+60|0]=c;a:{if(c){g=P[d>>2];m=P[d+4>>2];n=P[d+8>>2];L[a+16>>2]=0;o=S(n+S(-1));P[a+12>>2]=o;m=S(m+S(-1));P[a+8>>2]=m;n=S(g+S(-1));P[a+4>>2]=n;v=P[e>>2];q=P[e+4>>2];g=P[e+8>>2];J[a+60|0]=1;L[a+32>>2]=0;t=S(g+S(1));P[a+28>>2]=t;u=S(q+S(1));P[a+24>>2]=u;q=S(v+S(1));P[a+20>>2]=q;w=S(S(65533)/S(t-o));P[a+44>>2]=w;x=S(S(65533)/S(u-m));P[a+40>>2]=x;y=S(S(65533)/S(q-n));P[a+36>>2]=y;g=S(S(o-o)*w);b:{if(g=S(0)){c=~~g>>>0;break b}c=0}z=S((c&65534)>>>0);g=S(S(m-m)*x);c:{if(g=S(0)){c=~~g>>>0;break c}c=0}v=S(m+S(S((c&65534)>>>0)/x));g=S(S(n-n)*y);d:{if(g=S(0)){c=~~g>>>0;break d}c=0}g=S(S(n+S(S((c&65534)>>>0)/y))+S(-1));if(g>2]=g;n=g}g=S(v+S(-1));if(g>2]=g;m=g}g=S(S(o+S(z/w))+S(-1));if(g>2]=g;o=g}g=S(S(w*S(t-o))+S(1));e:{if(g=S(0)){c=~~g>>>0;break e}c=0}z=S((c|1)>>>0);g=S(S(x*S(u-m))+S(1));f:{if(g=S(0)){c=~~g>>>0;break f}c=0}v=S(m+S(S((c|1)>>>0)/x));g=S(S(y*S(q-n))+S(1));g:{if(g=S(0)){c=~~g>>>0;break g}c=0}g=S(S(n+S(S((c|1)>>>0)/y))+S(1));if(g>q){P[a+20>>2]=g;q=g}g=S(v+S(1));if(g>u){P[a+24>>2]=g;u=g}g=S(S(o+S(z/w))+S(1));if(g>t){P[a+28>>2]=g;t=g}L[a+48>>2]=0;P[a+44>>2]=S(65533)/S(t-o);P[a+40>>2]=S(65533)/S(u-m);P[a+36>>2]=S(65533)/S(q-n);L[k+32>>2]=a;L[k+28>>2]=a+104;L[k+24>>2]=15532;ha[L[L[b>>2]+8>>2]](b,k+24|0,a+4|0,a+20|0);c=L[a+128>>2];r=L[a+108>>2];j=r<<1;h:{if((c|0)>=(j|0)){break h}if((j|0)>L[a+132>>2]){i:{if(!r){d=0;e=c;break i}L[8513]=L[8513]+1;d=ha[L[6798]](r<<5,16)|0;e=L[a+128>>2]}j:{if((e|0)<=0){break j}b=0;if((e|0)!=1){s=e&-2;while(1){i=b<<4;h=i+d|0;p=i+L[a+136>>2]|0;f=L[p+4>>2];L[h>>2]=L[p>>2];L[h+4>>2]=f;f=L[p+12>>2];L[h+8>>2]=L[p+8>>2];L[h+12>>2]=f;f=i|16;h=f+d|0;i=f+L[a+136>>2]|0;f=L[i+4>>2];L[h>>2]=L[i>>2];L[h+4>>2]=f;f=L[i+12>>2];L[h+8>>2]=L[i+8>>2];L[h+12>>2]=f;b=b+2|0;l=l+2|0;if((s|0)!=(l|0)){continue}break}}if(!(e&1)){break j}b=b<<4;e=b+d|0;f=b+L[a+136>>2]|0;b=L[f+4>>2];L[e>>2]=L[f>>2];L[e+4>>2]=b;b=L[f+12>>2];L[e+8>>2]=L[f+8>>2];L[e+12>>2]=b}b=L[a+136>>2];if(!(b?!b|!M[a+140|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+136>>2]=d;J[a+140|0]=1;L[a+132>>2]=j}e=j+(c^-1)|0;d=j-c&3;if(d){b=0;while(1){f=L[a+136>>2]+(c<<4)|0;L[f>>2]=0;L[f+4>>2]=0;L[f+8>>2]=0;L[f+12>>2]=0;c=c+1|0;b=b+1|0;if((d|0)!=(b|0)){continue}break}}if(e>>>0<3){break h}while(1){d=c<<4;b=d+L[a+136>>2]|0;L[b>>2]=0;L[b+4>>2]=0;L[b+8>>2]=0;L[b+12>>2]=0;b=d+L[a+136>>2]|0;L[b+24>>2]=0;L[b+28>>2]=0;L[b+16>>2]=0;L[b+20>>2]=0;b=d+L[a+136>>2]|0;L[b+40>>2]=0;L[b+44>>2]=0;L[b+32>>2]=0;L[b+36>>2]=0;b=d+L[a+136>>2]|0;L[b+56>>2]=0;L[b+60>>2]=0;L[b+48>>2]=0;L[b+52>>2]=0;c=c+4|0;if((j|0)!=(c|0)){continue}break}}L[a+128>>2]=j;break a}L[k+40>>2]=15664;L[k+44>>2]=a- -64;L[k+32>>2]=-581039253;L[k+36>>2]=0;L[k+24>>2]=-581039253;L[k+28>>2]=-581039253;L[k+16>>2]=1566444395;L[k+20>>2]=0;L[k+8>>2]=1566444395;L[k+12>>2]=1566444395;ha[L[L[b>>2]+8>>2]](b,k+40|0,k+24|0,k+8|0);b=L[a+88>>2];r=L[a+68>>2];l=r<<1;k:{if((b|0)>=(l|0)){break k}if((l|0)>L[a+92>>2]){if(r){L[8513]=L[8513]+1;p=ha[L[6798]](r<<7,16)|0;c=L[a+88>>2]}else{c=b}l:{if((c|0)<=0){break l}d=0;if((c|0)!=1){s=c&-2;while(1){i=d<<6;h=i+p|0;j=i+L[a+96>>2]|0;e=L[j+4>>2];L[h>>2]=L[j>>2];L[h+4>>2]=e;e=L[j+60>>2];L[h+56>>2]=L[j+56>>2];L[h+60>>2]=e;e=L[j+52>>2];L[h+48>>2]=L[j+48>>2];L[h+52>>2]=e;e=L[j+44>>2];L[h+40>>2]=L[j+40>>2];L[h+44>>2]=e;e=L[j+36>>2];L[h+32>>2]=L[j+32>>2];L[h+36>>2]=e;e=L[j+28>>2];L[h+24>>2]=L[j+24>>2];L[h+28>>2]=e;e=L[j+20>>2];L[h+16>>2]=L[j+16>>2];L[h+20>>2]=e;e=L[j+12>>2];L[h+8>>2]=L[j+8>>2];L[h+12>>2]=e;e=i|64;h=e+p|0;i=e+L[a+96>>2]|0;e=L[i+4>>2];L[h>>2]=L[i>>2];L[h+4>>2]=e;e=L[i+12>>2];L[h+8>>2]=L[i+8>>2];L[h+12>>2]=e;e=L[i+20>>2];L[h+16>>2]=L[i+16>>2];L[h+20>>2]=e;e=L[i+28>>2];L[h+24>>2]=L[i+24>>2];L[h+28>>2]=e;e=L[i+36>>2];L[h+32>>2]=L[i+32>>2];L[h+36>>2]=e;e=L[i+44>>2];L[h+40>>2]=L[i+40>>2];L[h+44>>2]=e;e=L[i+52>>2];L[h+48>>2]=L[i+48>>2];L[h+52>>2]=e;e=L[i+60>>2];L[h+56>>2]=L[i+56>>2];L[h+60>>2]=e;d=d+2|0;f=f+2|0;if((s|0)!=(f|0)){continue}break}}if(!(c&1)){break l}c=d<<6;d=c+p|0;e=c+L[a+96>>2]|0;c=L[e+4>>2];L[d>>2]=L[e>>2];L[d+4>>2]=c;c=L[e+60>>2];L[d+56>>2]=L[e+56>>2];L[d+60>>2]=c;c=L[e+52>>2];L[d+48>>2]=L[e+48>>2];L[d+52>>2]=c;c=L[e+44>>2];L[d+40>>2]=L[e+40>>2];L[d+44>>2]=c;c=L[e+36>>2];L[d+32>>2]=L[e+32>>2];L[d+36>>2]=c;c=L[e+28>>2];L[d+24>>2]=L[e+24>>2];L[d+28>>2]=c;c=L[e+20>>2];L[d+16>>2]=L[e+16>>2];L[d+20>>2]=c;c=L[e+12>>2];L[d+8>>2]=L[e+8>>2];L[d+12>>2]=c}c=L[a+96>>2];if(!(c?!c|!M[a+100|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](c)}L[a+96>>2]=p;J[a+100|0]=1;L[a+92>>2]=l}d=l+(b^-1)|0;c=l-b&3;if(c){e=0;while(1){f=L[a+96>>2]+(b<<6)|0;L[f>>2]=0;L[f+4>>2]=0;L[f+56>>2]=0;L[f+60>>2]=0;L[f+48>>2]=0;L[f+52>>2]=0;L[f+40>>2]=0;L[f+44>>2]=0;L[f+32>>2]=0;L[f+36>>2]=0;L[f+24>>2]=0;L[f+28>>2]=0;L[f+16>>2]=0;L[f+20>>2]=0;L[f+8>>2]=0;L[f+12>>2]=0;b=b+1|0;e=e+1|0;if((c|0)!=(e|0)){continue}break}}if(d>>>0<3){break k}while(1){d=b<<6;c=d+L[a+96>>2]|0;L[c>>2]=0;L[c+4>>2]=0;L[c+56>>2]=0;L[c+60>>2]=0;L[c+48>>2]=0;L[c+52>>2]=0;L[c+40>>2]=0;L[c+44>>2]=0;L[c+32>>2]=0;L[c+36>>2]=0;L[c+24>>2]=0;L[c+28>>2]=0;L[c+16>>2]=0;L[c+20>>2]=0;L[c+8>>2]=0;L[c+12>>2]=0;c=d+L[a+96>>2]|0;L[c+120>>2]=0;L[c+124>>2]=0;L[c+112>>2]=0;L[c+116>>2]=0;L[c+104>>2]=0;L[c+108>>2]=0;L[c+96>>2]=0;L[c+100>>2]=0;L[c+88>>2]=0;L[c+92>>2]=0;L[c+80>>2]=0;L[c+84>>2]=0;L[c+72>>2]=0;L[c+76>>2]=0;c=c- -64|0;L[c>>2]=0;L[c+4>>2]=0;c=d+L[a+96>>2]|0;L[c+184>>2]=0;L[c+188>>2]=0;L[c+176>>2]=0;L[c+180>>2]=0;L[c+168>>2]=0;L[c+172>>2]=0;L[c+160>>2]=0;L[c+164>>2]=0;L[c+152>>2]=0;L[c+156>>2]=0;L[c+144>>2]=0;L[c+148>>2]=0;L[c+136>>2]=0;L[c+140>>2]=0;L[c+128>>2]=0;L[c+132>>2]=0;c=d+L[a+96>>2]|0;L[c+248>>2]=0;L[c+252>>2]=0;L[c+240>>2]=0;L[c+244>>2]=0;L[c+232>>2]=0;L[c+236>>2]=0;L[c+224>>2]=0;L[c+228>>2]=0;L[c+216>>2]=0;L[c+220>>2]=0;L[c+208>>2]=0;L[c+212>>2]=0;L[c+200>>2]=0;L[c+204>>2]=0;L[c+192>>2]=0;L[c+196>>2]=0;b=b+4|0;if((l|0)!=(b|0)){continue}break}}L[a+88>>2]=l}L[a+56>>2]=0;Xg(a,0,r);if(!(L[a+152>>2]|!M[a+60|0])){if(L[a+156>>2]){b=1}else{L[8513]=L[8513]+1;s=ha[L[6798]](32,16)|0;h=L[a+152>>2];m:{if((h|0)<=0){break m}e=0;if((h|0)!=1){d=h&-2;l=0;while(1){f=e<<5;c=f+s|0;i=f+L[a+160>>2]|0;b=L[i+4>>2];L[c>>2]=L[i>>2];L[c+4>>2]=b;b=L[i+28>>2];L[c+24>>2]=L[i+24>>2];L[c+28>>2]=b;b=L[i+20>>2];L[c+16>>2]=L[i+16>>2];L[c+20>>2]=b;b=L[i+12>>2];L[c+8>>2]=L[i+8>>2];L[c+12>>2]=b;b=f|32;c=b+s|0;f=b+L[a+160>>2]|0;b=L[f+4>>2];L[c>>2]=L[f>>2];L[c+4>>2]=b;b=L[f+12>>2];L[c+8>>2]=L[f+8>>2];L[c+12>>2]=b;b=L[f+20>>2];L[c+16>>2]=L[f+16>>2];L[c+20>>2]=b;b=L[f+28>>2];L[c+24>>2]=L[f+24>>2];L[c+28>>2]=b;e=e+2|0;l=l+2|0;if((d|0)!=(l|0)){continue}break}}if(!(h&1)){break m}b=e<<5;c=b+s|0;d=b+L[a+160>>2]|0;b=L[d+4>>2];L[c>>2]=L[d>>2];L[c+4>>2]=b;b=L[d+28>>2];L[c+24>>2]=L[d+24>>2];L[c+28>>2]=b;b=L[d+20>>2];L[c+16>>2]=L[d+16>>2];L[c+20>>2]=b;b=L[d+12>>2];L[c+8>>2]=L[d+8>>2];L[c+12>>2]=b}b=L[a+160>>2];if(!(b?!b|!M[a+164|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+160>>2]=s;J[a+164|0]=1;L[a+156>>2]=1;b=L[a+152>>2]+1|0}L[a+152>>2]=b;d=L[a+160>>2];c=L[a+136>>2];K[d>>1]=N[c>>1];K[d+2>>1]=N[c+2>>1];K[d+4>>1]=N[c+4>>1];K[d+6>>1]=N[c+6>>1];K[d+8>>1]=N[c+8>>1];b=N[c+10>>1];L[d+12>>2]=0;K[d+10>>1]=b;b=L[c+12>>2];L[d+16>>2]=(b|0)>=0?1:0-b|0}L[a+168>>2]=L[a+152>>2];b=L[a+116>>2];if(!(b?!b|!M[a+120|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+116>>2]=0;J[a+120|0]=1;L[a+108>>2]=0;L[a+112>>2]=0;b=L[a+76>>2];if(!(b?!b|!M[a+80|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+76>>2]=0;J[a+80|0]=1;L[a+68>>2]=0;L[a+72>>2]=0;fa=k+48|0}function uB(a){a=a|0;var b=0,c=S(0),d=0,e=S(0),f=S(0),g=S(0),h=S(0),i=S(0),j=S(0),k=S(0),l=S(0),m=S(0),n=S(0),o=0,p=S(0),q=S(0),r=0,s=S(0),t=S(0),u=S(0),v=S(0),w=S(0),x=S(0),y=S(0),z=S(0),A=S(0),B=S(0),C=S(0),D=S(0),E=S(0),F=S(0),G=S(0),H=S(0),I=S(0),J=S(0),K=S(0),N=S(0),O=S(0),Q=0,U=0,V=0,W=S(0),X=S(0),Y=S(0),Z=0;r=fa-48|0;fa=r;if(M[a+738|0]){L[a+744>>2]=0;L[a+36>>2]=0;if(!M[a+736|0]){e=P[a+672>>2];b=L[a+32>>2];g=P[a+664>>2];h=P[a+668>>2];p=S(S(S(e*P[b+44>>2])+S(S(g*P[b+36>>2])+S(h*P[b+40>>2])))+P[b+60>>2]);f=P[a+608>>2];d=L[a+28>>2];c=P[a+600>>2];j=P[a+604>>2];m=S(S(S(f*P[d+44>>2])+S(S(c*P[d+36>>2])+S(j*P[d+40>>2])))+P[d+60>>2]);i=S(p-m);t=S(S(S(e*P[b+12>>2])+S(S(g*P[b+4>>2])+S(h*P[b+8>>2])))+P[b+52>>2]);u=S(S(S(f*P[d+12>>2])+S(S(c*P[d+4>>2])+S(j*P[d+8>>2])))+P[d+52>>2]);k=S(t-u);C=S(S(S(e*P[b+28>>2])+S(S(g*P[b+20>>2])+S(h*P[b+24>>2])))+P[b+56>>2]);D=S(S(S(f*P[d+28>>2])+S(S(c*P[d+20>>2])+S(j*P[d+24>>2])))+P[d+56>>2]);g=S(C-D);e=S(S(i*i)+S(S(k*k)+S(g*g)));a:{if(e>S(1.1920928955078125e-7)){h=S(S(1)/S(_(e)));e=S(i*h);P[r+8>>2]=e;g=S(g*h);P[r+4>>2]=g;h=S(k*h);P[r>>2]=h;break a}L[r+8>>2]=0;L[r>>2]=1065353216;L[r+4>>2]=0;h=S(1);g=S(0);e=S(0)}L[r+12>>2]=0;b:{if(S(T(e))>S(.7071067690849304)){f=S(S(g*g)+S(e*e));i=S(S(1)/S(_(f)));f=S(f*i);c=S(i*S(-e));j=S(c*h);e=S(g*i);g=S(e*S(-h));i=S(0);break b}c=S(S(h*h)+S(g*g));f=S(S(1)/S(_(c)));j=S(c*f);i=S(f*S(-g));g=S(e*i);c=S(h*f);f=S(c*S(-e));e=S(0)}P[r+40>>2]=j;P[r+36>>2]=g;P[r+20>>2]=c;P[r+32>>2]=f;P[r+24>>2]=e;P[r+16>>2]=i;while(1){E=P[b+344>>2];K=P[d+344>>2];z=P[d+36>>2];A=P[d+4>>2];B=P[d+20>>2];l=P[d+40>>2];v=P[d+8>>2];s=P[d+24>>2];n=P[d+44>>2];q=P[d+12>>2];w=P[d+56>>2];x=P[d+28>>2];y=P[d+60>>2];G=P[d+52>>2];H=P[b+36>>2];I=P[b+4>>2];N=P[b+20>>2];k=P[b+40>>2];O=P[b+8>>2];Y=P[b+24>>2];e=P[b+44>>2];h=P[b+12>>2];g=P[b+56>>2];j=P[b+28>>2];f=P[b+52>>2];c=P[b+60>>2];U=(Q<<4)+r|0;Z=L[U+4>>2];o=R(Q,84)+a|0;V=o+48|0;L[V>>2]=L[U>>2];L[V+4>>2]=Z;V=L[U+12>>2];L[o+56>>2]=L[U+8>>2];L[o+60>>2]=V;L[o+92>>2]=0;L[o+76>>2]=0;F=e;i=S(C-g);e=P[o+48>>2];W=S(t-f);g=P[o+52>>2];f=S(S(i*e)-S(W*g));J=h;X=S(p-c);h=P[o+56>>2];c=S(S(X*g)-S(i*h));i=j;j=S(S(W*h)-S(X*e));i=S(S(F*f)+S(S(J*c)+S(i*j)));P[o+88>>2]=i;k=S(S(k*f)+S(S(O*c)+S(Y*j)));P[o+84>>2]=k;f=S(S(H*f)+S(S(I*c)+S(N*j)));P[o+80>>2]=f;F=n;j=S(u-G);n=S(D-w);c=S(S(g*j)-S(e*n));J=S(n*h);n=S(m-y);g=S(J-S(g*n));e=S(S(n*e)-S(h*j));h=S(S(F*c)+S(S(q*g)+S(x*e)));P[o+72>>2]=h;j=S(S(l*c)+S(S(v*g)+S(s*e)));P[o+68>>2]=j;e=S(S(z*c)+S(S(A*g)+S(B*e)));P[o- -64>>2]=e;g=P[d+404>>2];c=P[d+400>>2];z=P[d+396>>2];L[o+108>>2]=0;z=S(e*z);P[o+96>>2]=z;c=S(j*c);P[o+100>>2]=c;g=S(h*g);P[o+104>>2]=g;A=P[b+404>>2];B=P[b+400>>2];l=P[b+396>>2];L[o+124>>2]=0;l=S(f*l);P[o+112>>2]=l;B=S(k*B);P[o+116>>2]=B;A=S(i*A);P[o+120>>2]=A;P[o+128>>2]=S(E+S(K+S(S(g*h)+S(S(z*e)+S(j*c)))))+S(S(A*i)+S(S(l*f)+S(k*B)));Q=Q+1|0;if((Q|0)!=3){continue}break}}e=P[a+576>>2];g=P[a+560>>2];h=P[a+592>>2];c:{if(S(T(h))>S(.7071067690849304)){f=S(S(e*e)+S(h*h));i=S(S(1)/S(_(f)));c=S(i*S(-h));j=S(g*c);k=S(e*i);p=S(k*S(-g));m=S(0);f=S(f*i);break c}c=S(S(g*g)+S(e*e));f=S(S(1)/S(_(c)));j=S(c*f);m=S(f*S(-e));p=S(h*m);k=S(0);c=S(g*f);f=S(c*S(-h))}b=L[a+32>>2];q=P[b+36>>2];w=P[b+20>>2];n=P[b+40>>2];x=P[b+8>>2];y=P[b+24>>2];s=P[b+44>>2];G=P[b+12>>2];H=P[b+28>>2];d=L[a+28>>2];t=P[d+44>>2];u=P[d+36>>2];C=P[d+40>>2];D=P[d+12>>2];E=P[d+8>>2];K=P[d+28>>2];z=P[d+20>>2];A=P[d+24>>2];I=P[b+4>>2];B=P[d+4>>2];L[a+308>>2]=0;L[a+312>>2]=0;L[a+300>>2]=0;L[a+304>>2]=0;L[a+344>>2]=0;L[a+328>>2]=0;i=S(S(t*k)+S(S(u*m)+S(c*C)));l=S(S(D*k)+S(S(B*m)+S(c*E)));c=S(S(K*k)+S(S(z*m)+S(c*A)));k=S(S(t*i)+S(S(D*l)+S(K*c)));P[a+324>>2]=k;m=S(S(C*i)+S(S(E*l)+S(A*c)));P[a+320>>2]=m;v=S(S(u*i)+S(S(B*l)+S(z*c)));P[a+316>>2]=v;l=S(-l);s=S(S(S(G*l)-S(H*c))-S(s*i));P[a+340>>2]=s;n=S(S(S(x*l)-S(y*c))-S(n*i));P[a+336>>2]=n;c=S(S(S(I*l)-S(w*c))-S(q*i));P[a+332>>2]=c;i=P[d+400>>2];l=P[d+404>>2];q=P[d+396>>2];L[a+360>>2]=0;l=S(k*l);P[a+356>>2]=l;i=S(m*i);P[a+352>>2]=i;q=S(v*q);P[a+348>>2]=q;w=P[b+400>>2];x=P[b+404>>2];y=P[b+396>>2];L[a+376>>2]=0;x=S(s*x);P[a+372>>2]=x;w=S(n*w);P[a+368>>2]=w;y=S(c*y);P[a+364>>2]=y;P[a+380>>2]=S(S(l*k)+S(S(q*v)+S(m*i)))+S(S(x*s)+S(S(y*c)+S(n*w)));v=P[d+36>>2];s=P[d+20>>2];l=P[d+40>>2];n=P[d+8>>2];q=P[d+24>>2];m=P[d+44>>2];w=P[d+12>>2];x=P[d+28>>2];y=P[b+36>>2];G=P[b+20>>2];H=P[b+40>>2];I=P[b+8>>2];N=P[b+24>>2];O=P[b+44>>2];c=P[b+12>>2];Y=P[b+28>>2];W=P[d+4>>2];X=P[b+4>>2];L[a+392>>2]=0;L[a+396>>2]=0;L[a+384>>2]=0;L[a+388>>2]=0;L[a+428>>2]=0;L[a+412>>2]=0;i=S(S(D*j)+S(S(B*f)+S(p*E)));k=S(-i);F=S(c*k);c=S(S(K*j)+S(S(z*f)+S(p*A)));f=S(S(t*j)+S(S(u*f)+S(p*C)));j=S(S(F-S(Y*c))-S(O*f));P[a+424>>2]=j;p=S(S(S(I*k)-S(N*c))-S(H*f));P[a+420>>2]=p;k=S(S(S(X*k)-S(G*c))-S(y*f));P[a+416>>2]=k;m=S(S(m*f)+S(S(w*i)+S(c*x)));P[a+408>>2]=m;l=S(S(l*f)+S(S(n*i)+S(c*q)));P[a+404>>2]=l;f=S(S(v*f)+S(S(W*i)+S(c*s)));P[a+400>>2]=f;c=P[d+400>>2];i=P[d+404>>2];v=P[d+396>>2];L[a+444>>2]=0;i=S(m*i);P[a+440>>2]=i;c=S(l*c);P[a+436>>2]=c;v=S(f*v);P[a+432>>2]=v;s=P[b+400>>2];n=P[b+404>>2];q=P[b+396>>2];L[a+460>>2]=0;n=S(j*n);P[a+456>>2]=n;s=S(p*s);P[a+452>>2]=s;q=S(k*q);P[a+448>>2]=q;P[a+464>>2]=S(S(i*m)+S(S(v*f)+S(l*c)))+S(S(n*j)+S(S(q*k)+S(p*s)));p=P[d+36>>2];m=P[d+20>>2];k=P[d+40>>2];l=P[d+8>>2];v=P[d+24>>2];i=P[d+44>>2];s=P[d+12>>2];n=P[d+28>>2];q=P[b+36>>2];w=P[b+20>>2];x=P[b+40>>2];y=P[b+8>>2];G=P[b+24>>2];H=P[b+44>>2];f=P[b+12>>2];I=P[b+28>>2];N=P[d+4>>2];O=P[b+4>>2];L[a+476>>2]=0;L[a+480>>2]=0;L[a+468>>2]=0;L[a+472>>2]=0;L[a+512>>2]=0;L[a+496>>2]=0;c=S(S(D*h)+S(S(B*g)+S(e*E)));j=S(-c);F=S(f*j);f=S(S(K*h)+S(S(z*g)+S(e*A)));e=S(S(t*h)+S(S(u*g)+S(e*C)));g=S(S(F-S(I*f))-S(H*e));P[a+508>>2]=g;h=S(S(S(y*j)-S(G*f))-S(x*e));P[a+504>>2]=h;j=S(S(S(O*j)-S(w*f))-S(q*e));P[a+500>>2]=j;i=S(S(i*e)+S(S(s*c)+S(f*n)));P[a+492>>2]=i;k=S(S(k*e)+S(S(l*c)+S(f*v)));P[a+488>>2]=k;e=S(S(p*e)+S(S(N*c)+S(f*m)));P[a+484>>2]=e;f=P[d+400>>2];c=P[d+404>>2];p=P[d+396>>2];L[a+528>>2]=0;c=S(i*c);P[a+524>>2]=c;f=S(k*f);P[a+520>>2]=f;p=S(e*p);P[a+516>>2]=p;m=P[b+400>>2];t=P[b+404>>2];u=P[b+396>>2];L[a+724>>2]=0;L[a+544>>2]=0;t=S(g*t);P[a+540>>2]=t;m=S(h*m);P[a+536>>2]=m;u=S(j*u);P[a+532>>2]=u;P[a+548>>2]=S(S(c*i)+S(S(p*e)+S(k*f)))+S(S(t*g)+S(S(u*j)+S(h*m)));e=P[a+652>>2];g=P[a+620>>2];h=P[a+636>>2];i=S(S(P[b+44>>2]*e)+S(S(P[b+36>>2]*g)+S(h*P[b+40>>2])));k=P[d+44>>2];f=P[a+584>>2];p=P[d+36>>2];c=P[a+552>>2];j=P[a+568>>2];m=P[d+40>>2];n=S(i*S(S(k*f)+S(S(p*c)+S(j*m))));t=S(S(P[b+12>>2]*e)+S(S(P[b+4>>2]*g)+S(h*P[b+8>>2])));u=P[d+12>>2];C=P[d+4>>2];D=P[d+8>>2];F=S(t*S(S(u*f)+S(S(C*c)+S(j*D))));E=P[d+28>>2];J=S(E*f);f=P[d+20>>2];l=S(f*c);c=P[d+24>>2];J=S(J+S(l+S(j*c)));j=S(S(P[b+28>>2]*e)+S(S(P[b+20>>2]*g)+S(h*P[b+24>>2])));e=P[a+588>>2];g=P[a+556>>2];h=P[a+572>>2];e=S(Za(S(n+S(F+S(J*j))),S(S(i*S(S(k*e)+S(S(p*g)+S(m*h))))+S(S(t*S(S(u*e)+S(S(C*g)+S(D*h))))+S(S(S(E*e)+S(S(f*g)+S(c*h)))*j))))*P[a+732>>2]);P[a+728>>2]=e;_k(a+688|0,e);d=a;b=L[a+28>>2];h=P[a+592>>2];f=P[a+560>>2];c=P[a+576>>2];e=S(S(P[b+44>>2]*h)+S(S(P[b+36>>2]*f)+S(c*P[b+40>>2])));g=S(S(P[b+12>>2]*h)+S(S(P[b+4>>2]*f)+S(c*P[b+8>>2])));h=S(S(P[b+28>>2]*h)+S(S(P[b+20>>2]*f)+S(c*P[b+24>>2])));a=L[a+32>>2];P[d+720>>2]=S(1)/S(S(S(e*S(S(e*P[b+304>>2])+S(S(P[b+272>>2]*g)+S(h*P[b+288>>2]))))+S(S(g*S(S(P[b+296>>2]*e)+S(S(g*P[b+264>>2])+S(h*P[b+280>>2]))))+S(h*S(S(P[b+300>>2]*e)+S(S(P[b+268>>2]*g)+S(h*P[b+284>>2]))))))+S(S(e*S(S(e*P[a+304>>2])+S(S(P[a+272>>2]*g)+S(h*P[a+288>>2]))))+S(S(g*S(S(P[a+296>>2]*e)+S(S(g*P[a+264>>2])+S(h*P[a+280>>2]))))+S(h*S(S(P[a+300>>2]*e)+S(S(P[a+268>>2]*g)+S(h*P[a+284>>2])))))))}fa=r+48|0}function Mp(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=S(0),v=0,w=0,x=0,y=0,z=S(0),A=S(0);t=fa-16|0;fa=t;L[t+12>>2]=a;L[t+8>>2]=b;L[t+4>>2]=c;m=L[t+12>>2];y=L[t+4>>2];a=0;h=fa-48|0;fa=h;w=L[t+8>>2];if((w|0)>=2){k=L[m+712>>2];b=R(k,k);o=sa(b>>>0>1073741823?-1:b<<2);if((k|0)>0){j=k&-2;d=k&1;while(1){c=R(a,k);i=(c+a<<2)+o|0;b=0;e=0;if((k|0)!=1){while(1){a:{if((a|0)!=(b|0)){L[(R(b,k)+a<<2)+o>>2]=2147483647;L[(b+c<<2)+o>>2]=2147483647;break a}L[i>>2]=0}f=b|1;b:{if((f|0)!=(a|0)){L[(R(f,k)+a<<2)+o>>2]=2147483647;L[(c+f<<2)+o>>2]=2147483647;break b}L[i>>2]=0}b=b+2|0;e=e+2|0;if((j|0)!=(e|0)){continue}break}}c:{if(!d){break c}if((a|0)!=(b|0)){L[(R(b,k)+a<<2)+o>>2]=2147483647;L[(b+c<<2)+o>>2]=2147483647;break c}L[i>>2]=0}a=a+1|0;if((k|0)!=(a|0)){continue}break}}c=L[m+732>>2];if((c|0)>0){a=L[m+720>>2];i=L[m+740>>2];b=0;while(1){f=i+R(b,52)|0;e=(L[f+12>>2]-a|0)/104|0;f=(L[f+8>>2]-a|0)/104|0;L[(R(e,k)+f<<2)+o>>2]=1;L[(e+R(f,k)<<2)+o>>2]=1;b=b+1|0;if((c|0)!=(b|0)){continue}break}}d:{e:{if((w|0)!=2){if((k|0)<=0){break d}while(1){f=R(k,l);c=0;while(1){a=c+1|0;if((a|0)<(k|0)){e=R(c,k);j=(e+l<<2)+o|0;b=a;while(1){i=L[j>>2]+L[(b+f<<2)+o>>2]|0;d=(b+e<<2)+o|0;if(i>>>0>2]){L[(R(b,k)+c<<2)+o>>2]=i;L[d>>2]=i}b=b+1|0;if((k|0)!=(b|0)){continue}break}}c=a;if((a|0)!=(k|0)){continue}break}l=l+1|0;if((l|0)!=(k|0)){continue}break}break e}L[h+40>>2]=0;J[h+44|0]=1;L[h+32>>2]=0;L[h+36>>2]=0;L[h+24>>2]=0;L[h+16>>2]=0;L[h+20>>2]=0;J[h+24|0]=1;L[h+8>>2]=0;L[h+12>>2]=0;L[h+12>>2]=0;j=h+8|0;f=0;i=0;b=L[h+32>>2];a=k;f:{if((b|0)>(a|0)){c=a;while(1){i=L[h+40>>2]+R(c,20)|0;f=L[i+12>>2];if(!(f?!f|!M[i+16|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](f)}L[i+12>>2]=0;J[i+16|0]=1;L[i+4>>2]=0;L[i+8>>2]=0;c=c+1|0;if((c|0)!=(b|0)){continue}break}break f}d=(a|0)<=(b|0);if(d){break f}if((a|0)>L[h+36>>2]){if(a){L[8513]=L[8513]+1;i=ha[L[6798]](R(a,20),16)|0;c=L[h+32>>2]}else{c=b}g:{if((c|0)<=0){break g}while(1){e=R(f,20);Jc(e+i|0,e+L[h+40>>2]|0);f=f+1|0;if((c|0)!=(f|0)){continue}break}l=L[h+32>>2];if((l|0)<=0){break g}f=0;while(1){c=L[h+40>>2]+R(f,20)|0;e=L[c+12>>2];if(!(e?!e|!M[c+16|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](e)}L[c+12>>2]=0;J[c+16|0]=1;L[c+4>>2]=0;L[c+8>>2]=0;f=f+1|0;if((l|0)!=(f|0)){continue}break}}c=L[h+40>>2];if(!(c?!c|!M[h+44|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](c)}L[h+40>>2]=i;J[h+44|0]=1;L[h+36>>2]=a;if(d){break f}}while(1){Jc(L[h+40>>2]+R(b,20)|0,j);b=b+1|0;if((a|0)!=(b|0)){continue}break}}L[h+32>>2]=a;a=L[h+20>>2];if(!(a?!a|!M[h+24|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](a)}if(L[m+732>>2]>0){i=0;while(1){a=L[m+740>>2]+R(i,52)|0;b=L[m+720>>2];g=(L[a+12>>2]-b|0)/104|0;p=L[h+40>>2];s=(L[a+8>>2]-b|0)/104|0;c=p+R(s,20)|0;a=L[c+4>>2];h:{i:{if((a|0)<=0){break i}f=L[c+12>>2];b=0;while(1){if((g|0)!=L[f+(b<<2)>>2]){b=b+1|0;if((b|0)!=(a|0)){continue}break i}break}if((a|0)!=(b|0)){break h}}j:{if(L[c+8>>2]!=(a|0)){break j}q=a?a<<1:1;if((q|0)<=(a|0)){break j}k:{if(!q){j=0;break k}L[8513]=L[8513]+1;j=ha[L[6798]](q<<2,16)|0;a=L[c+4>>2]}f=L[c+12>>2];l:{m:{if((a|0)>0){d=0;b=0;if(a>>>0>=4){p=a&-4;l=0;while(1){e=b<<2;L[e+j>>2]=L[e+f>>2];r=e|4;L[r+j>>2]=L[f+r>>2];r=e|8;L[r+j>>2]=L[f+r>>2];e=e|12;L[e+j>>2]=L[e+f>>2];b=b+4|0;l=l+4|0;if((p|0)!=(l|0)){continue}break}}a=a&3;if(!a){break m}while(1){e=b<<2;L[e+j>>2]=L[e+f>>2];b=b+1|0;d=d+1|0;if((a|0)!=(d|0)){continue}break}break m}if(!f){break l}}if(f?M[c+16|0]:0){L[8514]=L[8514]+1;ha[L[6799]](f)}a=L[c+4>>2]}L[c+12>>2]=j;J[c+16|0]=1;L[c+8>>2]=q;p=L[h+40>>2]}L[L[c+12>>2]+(a<<2)>>2]=g;L[c+4>>2]=L[c+4>>2]+1}f=R(g,20)+p|0;a=L[f+4>>2];n:{o:{if((a|0)<=0){break o}c=L[f+12>>2];b=0;while(1){if((s|0)!=L[c+(b<<2)>>2]){b=b+1|0;if((b|0)!=(a|0)){continue}break o}break}if((a|0)!=(b|0)){break n}}p:{if(L[f+8>>2]!=(a|0)){break p}g=a?a<<1:1;if((g|0)<=(a|0)){break p}q:{if(!g){e=0;break q}L[8513]=L[8513]+1;e=ha[L[6798]](g<<2,16)|0;a=L[f+4>>2]}j=L[f+12>>2];r:{s:{if((a|0)>0){c=0;b=0;if(a>>>0>=4){p=a&-4;d=0;while(1){l=b<<2;L[l+e>>2]=L[j+l>>2];q=l|4;L[q+e>>2]=L[j+q>>2];q=l|8;L[q+e>>2]=L[j+q>>2];l=l|12;L[l+e>>2]=L[j+l>>2];b=b+4|0;d=d+4|0;if((p|0)!=(d|0)){continue}break}}a=a&3;if(!a){break s}while(1){d=b<<2;L[d+e>>2]=L[d+j>>2];b=b+1|0;c=c+1|0;if((a|0)!=(c|0)){continue}break}break s}if(!j){break r}}if(j?M[f+16|0]:0){L[8514]=L[8514]+1;ha[L[6799]](j)}a=L[f+4>>2]}L[f+12>>2]=e;J[f+16|0]=1;L[f+8>>2]=g}L[L[f+12>>2]+(a<<2)>>2]=s;L[f+4>>2]=L[f+4>>2]+1}i=i+1|0;if((i|0)>2]){continue}break}}i=L[h+32>>2];t:{if((i|0)<=0){break t}e=0;a=L[h+40>>2];while(1){f=a+R(e,20)|0;b=L[f+4>>2];if((b|0)>0){q=R(e,k);s=L[f+12>>2];j=0;while(1){d=L[s+(j<<2)>>2];l=a+R(d,20)|0;c=L[l+4>>2];if((c|0)>0){r=(R(d,k)+e<<2)+o|0;x=L[l+12>>2];b=0;while(1){g=L[x+(b<<2)>>2];u:{if((g|0)==(e|0)){break u}p=R(g,k);v=(p+e<<2)+o|0;p=L[(d+p<<2)+o>>2]+L[r>>2]|0;if(O[v>>2]<=p>>>0){break u}L[(g+q<<2)+o>>2]=p;L[v>>2]=p;c=L[l+4>>2]}b=b+1|0;if((c|0)>(b|0)){continue}break}b=L[f+4>>2]}j=j+1|0;if((j|0)<(b|0)){continue}break}}e=e+1|0;if((i|0)!=(e|0)){continue}break}if((i|0)<=0){break t}a=0;while(1){b=L[h+40>>2]+R(a,20)|0;c=L[b+12>>2];if(!(c?!c|!M[b+16|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](c)}L[b+12>>2]=0;J[b+16|0]=1;L[b+4>>2]=0;L[b+8>>2]=0;a=a+1|0;if((i|0)!=(a|0)){continue}break}}a=L[h+40>>2];if(!a|!M[h+44|0]){break e}if(a){L[8514]=L[8514]+1;ha[L[6799]](a)}}if((k|0)<=0){l=0;break d}l=0;a=0;while(1){f=a;a=a+1|0;if((k|0)>(a|0)){x=R(f,k);c=a;while(1){if(L[(c+x<<2)+o>>2]==(w|0)){b=L[m+720>>2];i=y;if(!i){i=L[L[m+880>>2]>>2]}q=b+R(f,104)|0;s=b+R(c,104)|0;b=L[m+732>>2];v:{if((b|0)!=L[m+736>>2]){break v}r=b?b<<1:1;if((r|0)<=(b|0)){break v}w:{if(!r){j=0;break w}L[8513]=L[8513]+1;j=ha[L[6798]](R(r,52),16)|0;b=L[m+732>>2]}x:{if((b|0)<=0){break x}e=0;if((b|0)!=1){v=b&-2;p=0;while(1){d=R(e,52);g=d+j|0;d=d+L[m+740>>2]|0;n=L[d+4>>2];L[g>>2]=L[d>>2];L[g+4>>2]=n;L[g+48>>2]=L[d+48>>2];n=L[d+44>>2];L[g+40>>2]=L[d+40>>2];L[g+44>>2]=n;n=L[d+36>>2];L[g+32>>2]=L[d+32>>2];L[g+36>>2]=n;n=L[d+28>>2];L[g+24>>2]=L[d+24>>2];L[g+28>>2]=n;n=L[d+20>>2];L[g+16>>2]=L[d+16>>2];L[g+20>>2]=n;n=L[d+12>>2];L[g+8>>2]=L[d+8>>2];L[g+12>>2]=n;d=R(e|1,52);g=d+j|0;d=d+L[m+740>>2]|0;n=L[d+4>>2];L[g>>2]=L[d>>2];L[g+4>>2]=n;n=L[d+12>>2];L[g+8>>2]=L[d+8>>2];L[g+12>>2]=n;n=L[d+20>>2];L[g+16>>2]=L[d+16>>2];L[g+20>>2]=n;n=L[d+28>>2];L[g+24>>2]=L[d+24>>2];L[g+28>>2]=n;n=L[d+36>>2];L[g+32>>2]=L[d+32>>2];L[g+36>>2]=n;n=L[d+44>>2];L[g+40>>2]=L[d+40>>2];L[g+44>>2]=n;L[g+48>>2]=L[d+48>>2];e=e+2|0;p=p+2|0;if((v|0)!=(p|0)){continue}break}}if(!(b&1)){break x}e=R(e,52);b=e+j|0;e=e+L[m+740>>2]|0;d=L[e+4>>2];L[b>>2]=L[e>>2];L[b+4>>2]=d;L[b+48>>2]=L[e+48>>2];d=L[e+44>>2];L[b+40>>2]=L[e+40>>2];L[b+44>>2]=d;d=L[e+36>>2];L[b+32>>2]=L[e+32>>2];L[b+36>>2]=d;d=L[e+28>>2];L[b+24>>2]=L[e+24>>2];L[b+28>>2]=d;d=L[e+20>>2];L[b+16>>2]=L[e+16>>2];L[b+20>>2]=d;d=L[e+12>>2];L[b+8>>2]=L[e+8>>2];L[b+12>>2]=d}b=L[m+740>>2];if(!(b?!b|!M[m+744|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[m+740>>2]=j;J[m+744|0]=1;L[m+736>>2]=r;b=L[m+732>>2]}b=L[m+740>>2]+R(b,52)|0;L[b+8>>2]=0;L[b+12>>2]=0;L[b+4>>2]=i;L[b>>2]=0;L[b+16>>2]=0;L[b+20>>2]=0;L[b+24>>2]=0;L[b+28>>2]=0;L[b+32>>2]=0;L[b+36>>2]=0;L[b+40>>2]=0;L[b+44>>2]=0;L[b+48>>2]=0;b=L[m+732>>2];L[m+732>>2]=b+1;i=R(b,52);b=i+L[m+740>>2]|0;L[b+8>>2]=s;L[b+12>>2]=q;u=S(P[s+16>>2]-P[q+16>>2]);z=S(u*u);u=S(P[s+8>>2]-P[q+8>>2]);A=S(u*u);u=S(P[s+12>>2]-P[q+12>>2]);P[b+16>>2]=_(S(z+S(A+S(u*u))));J[m+924|0]=1;b=i+L[m+740>>2]|0;J[b+20|0]=M[b+20|0]|1;l=l+1|0}c=c+1|0;if((k|0)!=(c|0)){continue}break}}if((a|0)!=(k|0)){continue}break}}ra(o)}fa=h+48|0;fa=t+16|0;return l|0}function wb(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=S(0),g=0,h=S(0),i=S(0),j=S(0),k=S(0),l=0,m=0,n=S(0),o=S(0),p=S(0),q=S(0),r=S(0),s=S(0),t=S(0),u=S(0),v=S(0),w=S(0),x=S(0),y=S(0),z=S(0),A=S(0),B=S(0),C=S(0),D=S(0),E=S(0),F=S(0),G=S(0),H=0,I=S(0),J=S(0),K=S(0),N=S(0),O=S(0),Q=S(0),R=S(0),T=S(0),U=S(0),V=S(0),W=S(0),X=S(0),Y=S(0),Z=S(0),$=S(0),aa=S(0),ba=S(0),ca=S(0);e=fa-272|0;fa=e;L[a+56>>2]=0;L[e+264>>2]=0;L[e+268>>2]=0;L[e+256>>2]=0;L[e+260>>2]=0;g=L[b+12>>2];L[e+168>>2]=L[b+8>>2];L[e+172>>2]=g;g=L[b+4>>2];L[e+160>>2]=L[b>>2];L[e+164>>2]=g;g=L[b+28>>2];L[e+184>>2]=L[b+24>>2];L[e+188>>2]=g;g=L[b+20>>2];L[e+176>>2]=L[b+16>>2];L[e+180>>2]=g;g=L[b+44>>2];L[e+200>>2]=L[b+40>>2];L[e+204>>2]=g;g=L[b+36>>2];L[e+192>>2]=L[b+32>>2];L[e+196>>2]=g;g=L[b+60>>2];L[e+216>>2]=L[b+56>>2];L[e+220>>2]=g;g=L[b+52>>2];L[e+208>>2]=L[b+48>>2];L[e+212>>2]=g;g=L[b+76>>2];L[e+104>>2]=L[b+72>>2];L[e+108>>2]=g;g=L[b+68>>2];L[e+96>>2]=L[b+64>>2];L[e+100>>2]=g;g=L[b+92>>2];L[e+120>>2]=L[b+88>>2];L[e+124>>2]=g;g=L[b+84>>2];L[e+112>>2]=L[b+80>>2];L[e+116>>2]=g;g=L[b+108>>2];L[e+136>>2]=L[b+104>>2];L[e+140>>2]=g;g=L[b+100>>2];L[e+128>>2]=L[b+96>>2];L[e+132>>2]=g;g=L[b+124>>2];L[e+152>>2]=L[b+120>>2];L[e+156>>2]=g;g=L[b+116>>2];L[e+144>>2]=L[b+112>>2];L[e+148>>2]=g;f=P[e+212>>2];i=P[e+148>>2];y=S(S(f+i)*S(.5));v=S(f-y);P[e+212>>2]=v;f=P[e+216>>2];h=P[e+152>>2];z=S(S(f+h)*S(.5));w=S(f-z);P[e+216>>2]=w;x=S(i-y);P[e+148>>2]=x;P[e+152>>2]=h-z;f=P[e+208>>2];i=P[e+144>>2];A=S(S(f+i)*S(.5));F=S(f-A);P[e+208>>2]=F;G=S(i-A);P[e+144>>2]=G;l=L[L[a+28>>2]+4>>2]-17>>>0<=1?L[L[a+32>>2]+4>>2]-17>>>0<2:l;f=P[a+44>>2];i=P[a+48>>2];L[7861]=L[7861]+1;L[a+68>>2]=0;L[a+12>>2]=0;L[a+16>>2]=0;L[a+4>>2]=0;L[a+8>>2]=1065353216;L[a+60>>2]=-1;L[a+64>>2]=0;g=M[a+52|0];He(L[a+24>>2]);o=g?S(0):f;p=g?S(0):i;r=S(o+p);g=a+4|0;I=P[e+136>>2];J=P[e+132>>2];K=P[e+120>>2];N=P[e+116>>2];O=P[e+200>>2];Q=P[e+196>>2];R=P[e+184>>2];T=P[e+180>>2];i=S(0xde0b6b000000000);U=P[e+128>>2];V=P[e+112>>2];W=P[e+104>>2];X=P[e+100>>2];Y=P[e+96>>2];Z=P[e+192>>2];$=P[e+176>>2];aa=P[e+168>>2];ba=P[e+164>>2];ca=P[e+160>>2];a:{b:{c:{while(1){n=P[b+32>>2];s=P[b>>2];t=P[b+16>>2];u=P[b+36>>2];B=P[b+4>>2];C=P[b+20>>2];D=P[b+40>>2];f=P[a+12>>2];j=P[b+8>>2];k=P[a+4>>2];E=P[b+24>>2];h=P[a+8>>2];L[e+252>>2]=0;q=j;j=S(-k);P[e+248>>2]=S(S(q*j)-S(E*h))-S(D*f);P[e+244>>2]=S(S(B*j)-S(C*h))-S(u*f);P[e+240>>2]=S(S(s*j)-S(t*h))-S(n*f);j=P[b+96>>2];n=P[b+64>>2];s=P[b+80>>2];t=P[b+100>>2];u=P[b+68>>2];B=P[b+84>>2];C=P[b+104>>2];D=P[b+72>>2];E=P[b+88>>2];L[e+236>>2]=0;P[e+232>>2]=S(C*f)+S(S(D*k)+S(h*E));P[e+228>>2]=S(t*f)+S(S(u*k)+S(h*B));P[e+224>>2]=S(j*f)+S(S(n*k)+S(h*s));Te(e+80|0,L[a+28>>2],e+240|0);Te(e- -64|0,L[a+32>>2],e+224|0);L[e+60>>2]=0;f=P[e+88>>2];h=P[e+80>>2];j=P[e+84>>2];k=S(S(S(f*O)+S(S(h*Z)+S(j*Q)))+w);P[e+56>>2]=k;s=S(S(S(f*R)+S(S(h*$)+S(j*T)))+v);P[e+52>>2]=s;t=S(S(S(f*aa)+S(S(h*ca)+S(j*ba)))+F);P[e+48>>2]=t;L[e+44>>2]=0;f=P[e+72>>2];h=P[e+64>>2];n=P[e+68>>2];j=S(S(S(f*I)+S(S(h*U)+S(n*J)))+P[e+152>>2]);P[e+40>>2]=j;u=S(S(S(f*K)+S(S(h*V)+S(n*N)))+x);P[e+36>>2]=u;f=S(S(S(f*W)+S(S(h*Y)+S(n*X)))+G);P[e+32>>2]=f;if(l){L[e+40>>2]=0;L[e+56>>2]=0;j=S(0);k=S(0)}L[e+28>>2]=0;h=S(k-j);P[e+24>>2]=h;f=S(t-f);P[e+16>>2]=f;k=S(s-u);P[e+20>>2]=k;f=S(S(P[a+12>>2]*h)+S(S(P[a+4>>2]*f)+S(k*P[a+8>>2])));if(!(!(f>S(0))|!(S(f*f)>S(i*P[b+128>>2])))){L[a+68>>2]=10;break c}if(yl(L[a+24>>2],e+16|0)){L[a+68>>2]=1;break c}f=S(i-f);if(f<=S(i*S(9.999999974752427e-7))){L[a+68>>2]=f<=S(0)?2:11;break c}Bl(L[a+24>>2],e+16|0,e+48|0,e+32|0);d:{if(!zl(L[a+24>>2],e)){m=3;break d}f=P[e+8>>2];h=S(f*f);f=P[e>>2];j=S(f*f);f=P[e+4>>2];f=S(h+S(j+S(f*f)));if(f>2];L[g>>2]=L[e>>2];L[g+4>>2]=l;l=L[e+12>>2];L[g+8>>2]=L[e+8>>2];L[g+12>>2]=l;m=6;break d}if(S(i-f)<=S(i*S(1.1920928955078125e-7))){m=12;i=f;break d}m=L[e+4>>2];L[g>>2]=L[e>>2];L[g+4>>2]=m;m=L[e+12>>2];L[g+8>>2]=L[e+8>>2];L[g+12>>2]=m;m=L[a+64>>2];L[a+64>>2]=m+1;if((m|0)>1e3){break b}if(L[L[a+24>>2]>>2]==4){L[a+68>>2]=13;break b}i=f;continue}break}L[a+68>>2]=m}xl(L[a+24>>2],e+240|0,e+224|0);l=L[g+12>>2];L[e+264>>2]=L[g+8>>2];L[e+268>>2]=l;l=L[g+4>>2];L[e+256>>2]=L[g>>2];L[e+260>>2]=l;f=P[a+12>>2];h=P[a+4>>2];k=P[a+8>>2];j=S(S(f*f)+S(S(h*h)+S(k*k)));if(+j<1e-4){L[a+68>>2]=5}if(j>S(14210854715202004e-30)){j=S(S(1)/S(_(j)));P[e+256>>2]=j*P[e+256>>2];P[e+260>>2]=j*P[e+260>>2];P[e+264>>2]=j*P[e+264>>2];n=S(_(i));i=S(o/n);P[e+240>>2]=P[e+240>>2]-S(i*h);P[e+244>>2]=P[e+244>>2]-S(i*k);P[e+248>>2]=P[e+248>>2]-S(i*f);i=S(p/n);P[e+224>>2]=S(i*h)+P[e+224>>2];P[e+228>>2]=S(i*k)+P[e+228>>2];P[e+232>>2]=S(i*f)+P[e+232>>2];l=1;L[a+60>>2]=1;f=S(S(S(1)/j)-r);break a}L[a+60>>2]=2}l=0;f=S(0)}H=1;m=L[a+20>>2];if(!(!L[a+68>>2]|(!L[a+72>>2]|!m))){H=!(+S(r+f)<.01)}e:{f:{g:{if(!m|l&H){break g}L[7860]=L[7860]+1;L[g+8>>2]=0;L[g+12>>2]=0;L[g>>2]=0;L[g+4>>2]=0;if(ha[L[L[m>>2]+8>>2]](m,L[a+24>>2],L[a+28>>2],L[a+32>>2],e+160|0,e+96|0,g,e+80|0,e- -64|0,d)|0){j=S(0);m=9;h=P[e+72>>2];r=P[e+88>>2];o=S(h-r);n=P[e+64>>2];v=P[e+80>>2];i=S(n-v);w=P[e+68>>2];x=P[e+84>>2];p=S(w-x);k=S(S(o*o)+S(S(i*i)+S(p*p)));if(k<=S(14210854715202004e-30)){j=P[a+16>>2];o=P[a+12>>2];i=P[a+4>>2];p=P[a+8>>2];k=S(S(o*o)+S(S(i*i)+S(p*p)))}h:{if(!(k>S(14210854715202004e-30))){break h}m=8;h=S(r-h);q=S(h*h);h=S(v-n);n=S(h*h);h=S(x-w);h=S(-S(_(S(q+S(n+S(h*h))))));if(!(h>2];L[e+248>>2]=L[e+88>>2];L[e+252>>2]=d;d=L[e+76>>2];L[e+232>>2]=L[e+72>>2];L[e+236>>2]=d;d=L[e+84>>2];L[e+240>>2]=L[e+80>>2];L[e+244>>2]=d;d=L[e+68>>2];L[e+224>>2]=L[e+64>>2];L[e+228>>2]=d;P[e+268>>2]=j;f=S(S(1)/S(_(k)));P[e+264>>2]=o*f;P[e+260>>2]=p*f;P[e+256>>2]=i*f;L[a+60>>2]=3;f=h;break f}L[a+60>>2]=m;if(l){break f}break e}h=P[a+12>>2];k=P[a+4>>2];j=P[a+8>>2];if(!(S(S(h*h)+S(S(k*k)+S(j*j)))>S(0))){break g}i=S(P[e+88>>2]-P[e+72>>2]);q=S(i*i);i=S(P[e+80>>2]-P[e+64>>2]);n=S(i*i);i=S(P[e+84>>2]-P[e+68>>2]);i=S(S(_(S(q+S(n+S(i*i)))))-r);if(!(!(i>2];L[e+248>>2]=L[e+88>>2];L[e+252>>2]=d;d=L[e+76>>2];L[e+232>>2]=L[e+72>>2];L[e+236>>2]=d;P[e+248>>2]=P[e+248>>2]-S(o*h);P[e+232>>2]=S(p*h)+P[e+232>>2];d=L[e+68>>2];L[e+224>>2]=L[e+64>>2];L[e+228>>2]=d;d=L[e+84>>2];L[e+240>>2]=L[e+80>>2];L[e+244>>2]=d;P[e+224>>2]=S(p*k)+P[e+224>>2];P[e+228>>2]=S(p*j)+P[e+228>>2];P[e+240>>2]=P[e+240>>2]-S(o*k);P[e+244>>2]=P[e+244>>2]-S(o*j);d=L[g+12>>2];L[e+264>>2]=L[g+8>>2];L[e+268>>2]=d;d=L[g+4>>2];L[e+256>>2]=L[g>>2];L[e+260>>2]=d;h=P[e+264>>2];k=P[e+256>>2];j=P[e+260>>2];f=S(S(1)/S(_(S(S(h*h)+S(S(k*k)+S(j*j))))));P[e+264>>2]=h*f;P[e+260>>2]=j*f;P[e+256>>2]=k*f;L[a+60>>2]=6;f=i;break f}L[a+60>>2]=5;break f}if(!l){break e}}if(!(f>2]>S(f*f))){break e}i:{if(!L[a+76>>2]){break i}b=L[a+28>>2];d=e+80|0;l=e- -64|0;ha[L[L[b>>2]+8>>2]](b,e+160|0,d,l);i=P[e+88>>2];h=P[e+72>>2];k=P[e+80>>2];j=P[e+64>>2];o=P[e+84>>2];p=P[e+68>>2];b=L[a+32>>2];ha[L[L[b>>2]+8>>2]](b,e+96|0,d,l);q=S(S(S(h+i)*S(.5))-S(S(P[e+88>>2]+P[e+72>>2])*S(.5)));i=P[e+264>>2];h=P[e+256>>2];j=S(S(S(S(j+k)*S(.5))-S(S(P[e+80>>2]+P[e+64>>2])*S(.5)))*h);k=P[e+260>>2];if(!(S(S(q*i)+S(j+S(S(S(S(p+o)*S(.5))-S(S(P[e+84>>2]+P[e+68>>2])*S(.5)))*k)))>2]=-i;P[e+260>>2]=-k;P[e+256>>2]=-h}b=L[e+260>>2];L[g>>2]=L[e+256>>2];L[g+4>>2]=b;b=L[e+268>>2];L[g+8>>2]=L[e+264>>2];L[g+12>>2]=b;P[a+56>>2]=f;L[e+92>>2]=0;P[e+88>>2]=z+P[e+232>>2];P[e+84>>2]=y+P[e+228>>2];P[e+80>>2]=A+P[e+224>>2];ha[L[L[c>>2]+16>>2]](c,e+256|0,e+80|0,f)}fa=e+272|0}function wl(a,b,c,d,e,f,g){var h=0,i=0,j=0,k=0,l=0,m=0,n=S(0),o=0,p=0,q=0,r=S(0),s=S(0),t=S(0),u=0,v=S(0),w=0,x=S(0),y=S(0),z=S(0),A=S(0),B=S(0),C=0,D=S(0),E=S(0),F=S(0),G=0,H=0,I=0,K=S(0),N=S(0),O=S(0),Q=S(0),T=S(0),U=0,V=0,W=0,X=S(0),Y=S(0),Z=S(0),_=S(0),$=S(0),aa=S(0),ba=S(0),ca=S(0);m=fa+-64|0;fa=m;L[m+56>>2]=0;L[m+48>>2]=0;L[m+52>>2]=0;J[m+60|0]=1;h=L[d+4>>2];if((h|0)>0){L[8513]=L[8513]+1;L[m+56>>2]=ha[L[6798]](h<<4,16);J[m+60|0]=1;L[m+52>>2]=h}q=L[b+28>>2];a:{if((q|0)<=0){break a}v=P[c+40>>2];x=P[c+36>>2];z=P[c+24>>2];A=P[c+20>>2];I=L[b+36>>2];B=P[a+8>>2];D=P[a+4>>2];F=P[a>>2];K=P[c+32>>2];N=P[c+16>>2];O=P[c+8>>2];Q=P[c+4>>2];y=P[c>>2];n=S(34028234663852886e22);j=-1;while(1){h=I+R(i,36)|0;t=P[h+28>>2];s=P[h+20>>2];r=P[h+24>>2];t=S(S(S(S(v*t)+S(S(K*s)+S(r*x)))*B)+S(S(S(S(O*t)+S(S(y*s)+S(r*Q)))*F)+S(S(S(z*t)+S(S(N*s)+S(r*A)))*D)));h=t>2]+R(j,36)|0;V=L[C+4>>2];b:{if((V|0)<=0){h=d;break b}q=m+44|0;I=0;while(1){h=q;i=I;I=i+1|0;W=(V|0)==(I|0);k=L[b+16>>2];j=L[C+12>>2];q=k+(L[j+((W?0:I)<<2)>>2]<<4)|0;y=P[q+8>>2];E=P[q>>2];T=P[q+4>>2];i=k+(L[j+(i<<2)>>2]<<4)|0;n=P[i+8>>2];t=P[i>>2];s=P[i+4>>2];aa=P[c+56>>2];ba=P[c+48>>2];ca=P[c+52>>2];z=P[c+40>>2];A=P[c+32>>2];B=P[c+36>>2];r=P[C+28>>2];D=P[c+8>>2];v=P[C+20>>2];F=P[c>>2];x=P[C+24>>2];K=P[c+4>>2];N=P[c+24>>2];O=P[c+16>>2];Q=P[c+20>>2];L[m+36>>2]=0;y=S(n-y);E=S(t-E);T=S(s-T);X=S(S(D*y)+S(S(F*E)+S(K*T)));Y=S(S(N*r)+S(S(O*v)+S(Q*x)));Z=S(S(D*r)+S(S(F*v)+S(K*x)));_=S(S(N*y)+S(S(O*E)+S(T*Q)));$=S(S(X*Y)-S(Z*_));P[m+32>>2]=-$;y=S(S(z*y)+S(S(A*E)+S(T*B)));r=S(S(z*r)+S(S(A*v)+S(B*x)));E=S(S(y*Z)-S(r*X));P[m+28>>2]=-E;y=S(-S(S(_*r)-S(Y*y)));P[m+24>>2]=y;G=0;q=d;U=L[d+4>>2];if((U|0)>=2){d=(L[q+12>>2]+(U<<4)|0)-16|0;r=P[d+8>>2];v=P[d>>2];x=P[d+4>>2];D=S(-S(S(S(S(ba+S(S(n*D)+S(S(t*F)+S(s*K))))*y)-S(S(ca+S(S(n*N)+S(S(t*O)+S(s*Q))))*E))-S(S(aa+S(S(n*z)+S(S(t*A)+S(s*B))))*$)));n=S(S(S(P[m+32>>2]*r)+S(S(P[m+24>>2]*v)+S(x*P[m+28>>2])))+D);while(1){d=L[q+12>>2]+(G<<4)|0;t=P[d+8>>2];A=P[d>>2];s=P[d+4>>2];z=S(S(S(P[m+32>>2]*t)+S(S(P[m+24>>2]*A)+S(s*P[m+28>>2])))+D);B=P[d+12>>2];c:{d:{e:{if(n>2];f:{if((d|0)!=L[h+8>>2]){break f}u=d?d<<1:1;if((u|0)<=(d|0)){break f}g:{if(!u){j=0;break g}L[8513]=L[8513]+1;j=ha[L[6798]](u<<4,16)|0;d=L[h+4>>2]}h:{if((d|0)<=0){break h}i=0;if((d|0)!=1){H=d&-2;k=0;while(1){o=i<<4;p=o+j|0;l=o+L[h+12>>2]|0;w=L[l+4>>2];L[p>>2]=L[l>>2];L[p+4>>2]=w;w=L[l+12>>2];L[p+8>>2]=L[l+8>>2];L[p+12>>2]=w;l=o|16;o=l+j|0;l=l+L[h+12>>2]|0;p=L[l+4>>2];L[o>>2]=L[l>>2];L[o+4>>2]=p;p=L[l+12>>2];L[o+8>>2]=L[l+8>>2];L[o+12>>2]=p;i=i+2|0;k=k+2|0;if((H|0)!=(k|0)){continue}break}}if(!(d&1)){break h}d=i<<4;i=d+j|0;d=d+L[h+12>>2]|0;k=L[d+4>>2];L[i>>2]=L[d>>2];L[i+4>>2]=k;k=L[d+12>>2];L[i+8>>2]=L[d+8>>2];L[i+12>>2]=k}d=L[h+12>>2];if(!(d?!d|!M[h+16|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](d)}L[h+12>>2]=j;J[h+16|0]=1;L[h+8>>2]=u;d=L[h+4>>2]}i=L[h+12>>2]+(d<<4)|0;break e}n=S(n/S(n-z));B=S(S(t-r)*n);F=S(S(s-x)*n);v=S(S(S(A-v)*n)+v);d=L[h+4>>2];i:{if((d|0)!=L[h+8>>2]){break i}u=d?d<<1:1;if((u|0)<=(d|0)){break i}j:{if(!u){j=0;break j}L[8513]=L[8513]+1;j=ha[L[6798]](u<<4,16)|0;d=L[h+4>>2]}k:{if((d|0)<=0){break k}i=0;if((d|0)!=1){H=d&-2;k=0;while(1){o=i<<4;p=o+j|0;l=o+L[h+12>>2]|0;w=L[l+4>>2];L[p>>2]=L[l>>2];L[p+4>>2]=w;w=L[l+12>>2];L[p+8>>2]=L[l+8>>2];L[p+12>>2]=w;l=o|16;o=l+j|0;l=l+L[h+12>>2]|0;p=L[l+4>>2];L[o>>2]=L[l>>2];L[o+4>>2]=p;p=L[l+12>>2];L[o+8>>2]=L[l+8>>2];L[o+12>>2]=p;i=i+2|0;k=k+2|0;if((H|0)!=(k|0)){continue}break}}if(!(d&1)){break k}d=i<<4;i=d+j|0;d=d+L[h+12>>2]|0;k=L[d+4>>2];L[i>>2]=L[d>>2];L[i+4>>2]=k;k=L[d+12>>2];L[i+8>>2]=L[d+8>>2];L[i+12>>2]=k}d=L[h+12>>2];if(!(d?!d|!M[h+16|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](d)}L[h+12>>2]=j;J[h+16|0]=1;L[h+8>>2]=u;d=L[h+4>>2]}n=S(B+r);i=L[h+12>>2]+(d<<4)|0;P[i>>2]=v;B=S(0);r=S(F+x);break d}if(!(z>2];l:{if((d|0)!=L[h+8>>2]){break l}u=d?d<<1:1;if((u|0)<=(d|0)){break l}m:{if(!u){j=0;break m}L[8513]=L[8513]+1;j=ha[L[6798]](u<<4,16)|0;d=L[h+4>>2]}n:{if((d|0)<=0){break n}i=0;if((d|0)!=1){H=d&-2;k=0;while(1){o=i<<4;p=o+j|0;l=o+L[h+12>>2]|0;w=L[l+4>>2];L[p>>2]=L[l>>2];L[p+4>>2]=w;w=L[l+12>>2];L[p+8>>2]=L[l+8>>2];L[p+12>>2]=w;l=o|16;o=l+j|0;l=l+L[h+12>>2]|0;p=L[l+4>>2];L[o>>2]=L[l>>2];L[o+4>>2]=p;p=L[l+12>>2];L[o+8>>2]=L[l+8>>2];L[o+12>>2]=p;i=i+2|0;k=k+2|0;if((H|0)!=(k|0)){continue}break}}if(!(d&1)){break n}d=i<<4;i=d+j|0;d=d+L[h+12>>2]|0;k=L[d+4>>2];L[i>>2]=L[d>>2];L[i+4>>2]=k;k=L[d+12>>2];L[i+8>>2]=L[d+8>>2];L[i+12>>2]=k}d=L[h+12>>2];if(!(d?!d|!M[h+16|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](d)}L[h+12>>2]=j;J[h+16|0]=1;L[h+8>>2]=u;d=L[h+4>>2]}d=L[h+12>>2]+(d<<4)|0;L[d+12>>2]=0;P[d+8>>2]=r;P[d+4>>2]=x;P[d>>2]=n;d=L[h+4>>2]+1|0;L[h+4>>2]=d;o:{if(L[h+8>>2]!=(d|0)){break o}u=d?d<<1:1;if((u|0)<=(d|0)){break o}p:{if(!u){j=0;break p}L[8513]=L[8513]+1;j=ha[L[6798]](u<<4,16)|0;d=L[h+4>>2]}q:{if((d|0)<=0){break q}i=0;if((d|0)!=1){H=d&-2;k=0;while(1){o=i<<4;p=o+j|0;l=o+L[h+12>>2]|0;w=L[l+4>>2];L[p>>2]=L[l>>2];L[p+4>>2]=w;w=L[l+12>>2];L[p+8>>2]=L[l+8>>2];L[p+12>>2]=w;l=o|16;o=l+j|0;l=l+L[h+12>>2]|0;p=L[l+4>>2];L[o>>2]=L[l>>2];L[o+4>>2]=p;p=L[l+12>>2];L[o+8>>2]=L[l+8>>2];L[o+12>>2]=p;i=i+2|0;k=k+2|0;if((H|0)!=(k|0)){continue}break}}if(!(d&1)){break q}d=i<<4;i=d+j|0;d=d+L[h+12>>2]|0;k=L[d+4>>2];L[i>>2]=L[d>>2];L[i+4>>2]=k;k=L[d+12>>2];L[i+8>>2]=L[d+8>>2];L[i+12>>2]=k}d=L[h+12>>2];if(!(d?!d|!M[h+16|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](d)}L[h+12>>2]=j;J[h+16|0]=1;L[h+8>>2]=u;d=L[h+4>>2]}i=L[h+12>>2]+(d<<4)|0}P[i>>2]=A;n=t;r=s}P[i+12>>2]=B;P[i+8>>2]=n;P[i+4>>2]=r;L[h+4>>2]=L[h+4>>2]+1}n=z;r=t;x=s;v=A;G=G+1|0;if((U|0)!=(G|0)){continue}break}}d=L[q+4>>2];r:{if((d|0)>=0){break r}if(L[q+8>>2]<0){i=L[q+12>>2];if(!(i?!i|!M[q+16|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](i)}J[q+16|0]=1;L[q+8>>2]=0;L[q+12>>2]=0}j=0;i=d;G=0-d&3;if(G){while(1){u=L[m+12>>2];k=L[q+12>>2]+(i<<4)|0;L[k>>2]=L[m+8>>2];L[k+4>>2]=u;u=L[m+20>>2];L[k+8>>2]=L[m+16>>2];L[k+12>>2]=u;i=i+1|0;j=j+1|0;if((G|0)!=(j|0)){continue}break}}if(d>>>0>4294967292){break r}while(1){k=L[m+12>>2];d=i<<4;j=d+L[q+12>>2]|0;L[j>>2]=L[m+8>>2];L[j+4>>2]=k;k=L[m+20>>2];L[j+8>>2]=L[m+16>>2];L[j+12>>2]=k;k=L[m+20>>2];j=d+L[q+12>>2]|0;L[j+24>>2]=L[m+16>>2];L[j+28>>2]=k;k=L[m+12>>2];L[j+16>>2]=L[m+8>>2];L[j+20>>2]=k;k=L[m+20>>2];j=d+L[q+12>>2]|0;L[j+40>>2]=L[m+16>>2];L[j+44>>2]=k;k=L[m+12>>2];L[j+32>>2]=L[m+8>>2];L[j+36>>2]=k;j=L[m+20>>2];d=d+L[q+12>>2]|0;L[d+56>>2]=L[m+16>>2];L[d+60>>2]=j;j=L[m+12>>2];L[d+48>>2]=L[m+8>>2];L[d+52>>2]=j;i=i+4|0;if(i){continue}break}}L[q+4>>2]=0;d=h;if(!W){continue}break}}j=L[h+4>>2];if((j|0)<=0){break a}n=P[C+28>>2];t=P[C+20>>2];s=P[C+24>>2];r=S(S(P[c+40>>2]*n)+S(S(P[c+32>>2]*t)+S(s*P[c+36>>2])));v=S(S(P[c+8>>2]*n)+S(S(P[c>>2]*t)+S(s*P[c+4>>2])));n=S(S(P[c+24>>2]*n)+S(S(P[c+16>>2]*t)+S(s*P[c+20>>2])));t=S(P[C+32>>2]-S(S(r*P[c+56>>2])+S(S(v*P[c+48>>2])+S(n*P[c+52>>2]))));q=0;while(1){b=L[h+12>>2]+(q<<4)|0;s=S(t+S(S(r*P[b+8>>2])+S(S(v*P[b>>2])+S(n*P[b+4>>2]))));s=e>=s?e:s;if(s<=f){c=L[b+12>>2];L[m+32>>2]=L[b+8>>2];L[m+36>>2]=c;c=L[b+4>>2];L[m+24>>2]=L[b>>2];L[m+28>>2]=c;ha[L[L[g>>2]+16>>2]](g,a,m+24|0,s);j=L[h+4>>2]}q=q+1|0;if((q|0)<(j|0)){continue}break}}a=L[m+56>>2];if(!(a?!a|!M[m+60|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](a)}fa=m- -64|0}function $n(a){a=a|0;var b=S(0),c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=S(0),m=S(0),n=0,o=0,p=S(0),q=S(0),r=S(0),s=0,t=0,u=S(0),v=S(0),w=S(0),x=S(0),y=S(0),z=S(0),A=S(0),B=S(0),C=S(0),D=S(0),E=0,F=0;t=fa-48|0;fa=t;L[t+44>>2]=a;s=L[t+44>>2];ha[L[L[s>>2]+112>>2]](s);c=fa-16|0;fa=c;L[c+12>>2]=s+68;a=fa-16|0;L[a+12>>2]=L[c+12>>2];fa=c+16|0;a:{if(!L[L[a+12>>2]>>2]){h=fa+-64|0;fa=h;J[h+60|0]=1;L[h+52>>2]=0;L[h+56>>2]=0;i=s+68|0;a=L[i+72>>2];j=ha[L[L[a>>2]+12>>2]](a)|0;L[h+32>>2]=0;L[h+36>>2]=0;L[h+24>>2]=0;L[h+28>>2]=0;L[h+16>>2]=0;L[h+20>>2]=0;L[h+8>>2]=0;L[h+12>>2]=0;b:{if((j|0)<=0){L[h+48>>2]=j;break b}L[8513]=L[8513]+1;L[h+56>>2]=ha[L[6798]](R(j,36),16);L[h+52>>2]=j;J[h+60|0]=1;e=j-1|0;if(e){c=j&-2;while(1){d=L[h+56>>2]+R(g,36)|0;a=d;L[a>>2]=0;L[a+4>>2]=0;L[a+8>>2]=0;L[a+12>>2]=0;a=L[h+28>>2];L[d+16>>2]=L[h+24>>2];L[d+20>>2]=a;a=L[h+36>>2];L[d+24>>2]=L[h+32>>2];L[d+28>>2]=a;L[d+32>>2]=0;d=L[h+56>>2]+R(g|1,36)|0;a=d;L[a>>2]=0;L[a+4>>2]=0;L[a+8>>2]=0;L[a+12>>2]=0;a=L[h+28>>2];L[d+16>>2]=L[h+24>>2];L[d+20>>2]=a;a=L[h+36>>2];L[d+24>>2]=L[h+32>>2];L[d+28>>2]=a;L[d+32>>2]=0;g=g+2|0;n=n+2|0;if((c|0)!=(n|0)){continue}break}}if(j&1){c=L[h+56>>2]+R(g,36)|0;L[c>>2]=0;L[c+4>>2]=0;L[c+8>>2]=0;L[c+12>>2]=0;a=L[h+28>>2];L[c+16>>2]=L[h+24>>2];L[c+20>>2]=a;a=L[h+36>>2];L[c+24>>2]=L[h+32>>2];L[c+28>>2]=a;L[c+32>>2]=0}L[h+48>>2]=j;if((j|0)<=0){break b}d=j&1;k=L[h+56>>2];c:{if(!e){a=0;break c}g=j&-2;a=0;n=0;while(1){e=L[i+72>>2];c=k+R(a,36)|0;ha[L[L[e>>2]+16>>2]](e,a,c);L[c+32>>2]=a;j=a|1;e=k+R(j,36)|0;c=L[i+72>>2];ha[L[L[c>>2]+16>>2]](c,j,e);L[e+32>>2]=j;a=a+2|0;n=n+2|0;if((g|0)!=(n|0)){continue}break}}if(!d){break b}e=L[i+72>>2];c=k+R(a,36)|0;ha[L[L[e>>2]+16>>2]](e,a,c);L[c+32>>2]=a}n=0;k=0;F=h+44|0;c=L[F+4>>2];d:{if((c|0)<=0){p=S(-34028234663852886e22);D=S(-34028234663852886e22);q=S(-34028234663852886e22);l=S(34028234663852886e22);m=S(34028234663852886e22);b=S(34028234663852886e22);break d}a=L[F+12>>2];y=S(-34028234663852886e22);m=S(34028234663852886e22);l=S(34028234663852886e22);w=S(34028234663852886e22);p=S(-34028234663852886e22);q=S(-34028234663852886e22);while(1){e=a+R(o,36)|0;b=P[e+16>>2];y=b>y?b:y;b=P[e+8>>2];w=b>2];l=b>2];m=b>2];p=b>p?b:p;b=P[e+20>>2];q=b>q?b:q;o=o+1|0;if((c|0)!=(o|0)){continue}break}D=S(p+S(1));p=S(q+S(1));q=S(y+S(1));l=S(l+S(-1));m=S(m+S(-1));b=S(w+S(-1))}P[i+24>>2]=m;L[i>>2]=0;L[i+68>>2]=0;L[i+52>>2]=0;P[i+48>>2]=D;P[i+44>>2]=p;P[i+40>>2]=q;L[i+36>>2]=0;P[i+32>>2]=b;P[i+28>>2]=l;P[i- -64>>2]=S(65535)/S(D-b);P[i+60>>2]=S(65535)/S(p-l);P[i+56>>2]=S(65535)/S(q-m);a=L[i+8>>2];o=L[F+4>>2];E=o<<1;if((a|0)<(E|0)){if((E|0)>L[i+12>>2]){if(o){L[8513]=L[8513]+1;n=ha[L[6798]](o<<5,16)|0;c=L[i+8>>2]}else{c=a}e:{if((c|0)<=0){break e}o=0;if((c|0)!=1){d=c&-2;while(1){j=o<<4;g=j+n|0;f=j+L[i+16>>2]|0;e=L[f+4>>2];L[g>>2]=L[f>>2];L[g+4>>2]=e;e=L[f+12>>2];L[g+8>>2]=L[f+8>>2];L[g+12>>2]=e;e=j|16;g=e+n|0;j=e+L[i+16>>2]|0;e=L[j+4>>2];L[g>>2]=L[j>>2];L[g+4>>2]=e;e=L[j+12>>2];L[g+8>>2]=L[j+8>>2];L[g+12>>2]=e;o=o+2|0;k=k+2|0;if((d|0)!=(k|0)){continue}break}}if(!(c&1)){break e}c=o<<4;e=c+n|0;g=c+L[i+16>>2]|0;c=L[g+4>>2];L[e>>2]=L[g>>2];L[e+4>>2]=c;c=L[g+12>>2];L[e+8>>2]=L[g+8>>2];L[e+12>>2]=c}c=L[i+16>>2];if(!(c?!c|!M[i+20|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](c)}L[i+16>>2]=n;J[i+20|0]=1;L[i+12>>2]=E}e=E+(a^-1)|0;c=E-a&3;if(c){o=0;while(1){L[(L[i+16>>2]+(a<<4)|0)+12>>2]=0;a=a+1|0;o=o+1|0;if((c|0)!=(o|0)){continue}break}}if(e>>>0>=3){while(1){c=a<<4;L[(c+L[i+16>>2]|0)+12>>2]=0;L[(c+L[i+16>>2]|0)+28>>2]=0;L[(c+L[i+16>>2]|0)+44>>2]=0;L[(c+L[i+16>>2]|0)+60>>2]=0;a=a+4|0;if((E|0)!=(a|0)){continue}break}}o=L[F+4>>2]}L[i+8>>2]=E;Gg(i,F,0,o);a=L[h+56>>2];if(!(a?!a|!M[h+60|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](a)}fa=h- -64|0;break a}j=fa-16|0;fa=j;L[j+12>>2]=s+68;k=fa-32|0;fa=k;f=L[j+12>>2];a=L[f>>2];if(a){n=L[f+16>>2];while(1){e=a;a=a-1|0;d=a<<4;c=d+n|0;g=L[c+12>>2];f:{if((g|0)>=0){c=L[f+72>>2];ha[L[L[c>>2]+16>>2]](c,g,k);p=P[f+56>>2];x=P[f+40>>2];r=P[f+24>>2];q=P[f+60>>2];z=P[f+44>>2];u=P[f+28>>2];l=P[k>>2];m=P[k+4>>2];n=L[f+16>>2];c=d+n|0;A=P[f+48>>2];v=P[f+32>>2];b=P[k+8>>2];b=b>2];b=S(S(S((b>A?A:b)-v)*w)+S(.5));g:{if(b=S(0)){d=~~b>>>0;break g}d=0}K[c+4>>1]=d;b=mz?z:b)-u))+S(.5));h:{if(b=S(0)){d=~~b>>>0;break h}d=0}K[c+2>>1]=d;b=lx?x:b)-r)*p)+S(.5));i:{if(b=S(0)){d=~~b>>>0;break i}d=0}K[c>>1]=d;l=P[k+16>>2];m=P[k+20>>2];b=P[k+24>>2];b=bA?A:b)-v))+S(.5));j:{if(b=S(0)){d=~~b>>>0;break j}d=0}K[c+10>>1]=d;b=mz?z:b)-u))+S(.5));k:{if(b=S(0)){d=~~b>>>0;break k}d=0}K[c+8>>1]=d;b=lx?x:b)-r))+S(.5));if(b=S(0)){K[c+6>>1]=~~b>>>0;break f}K[c+6>>1]=0;break f}B=P[f+24>>2];g=(e<<4)+n|0;u=P[f+56>>2];b=S(B+S(S(N[g+6>>1])/u));y=b>S(-34028234663852886e22)?b:S(-34028234663852886e22);v=P[f+64>>2];C=P[f+32>>2];b=S(S(S(N[g+4>>1])/v)+C);D=b>2];r=P[f+28>>2];b=S(S(S(N[g+2>>1])/x)+r);z=b>1])/u)+B);A=b>1])/v));p=b>S(-34028234663852886e22)?b:S(-34028234663852886e22);b=S(r+S(S(N[g+8>>1])/x));q=b>S(-34028234663852886e22)?b:S(-34028234663852886e22);g=L[g+12>>2];e=e+((g|0)>=0?1:0-g|0)|0;if(e){e=(e<<4)+n|0;b=S(B+S(S(N[e+6>>1])/u));y=b>y?b:y;b=S(S(S(N[e+4>>1])/v)+C);D=b>1])/x)+r);z=b>1])/u)+B);A=b>1])/v));p=b>p?b:p;b=S(r+S(S(N[e+8>>1])/x));q=b>q?b:q}l=P[f+40>>2];m=P[f+44>>2];w=P[f+48>>2];b=pw?w:b)-C))+S(.5));l:{if(b=S(0)){d=~~b>>>0;break l}d=0}K[c+10>>1]=d;b=qm?m:b)-r))+S(.5));m:{if(b=S(0)){d=~~b>>>0;break m}d=0}K[c+8>>1]=d;b=yl?l:b)-B))+S(.5));n:{if(b=S(0)){d=~~b>>>0;break n}d=0}K[c+6>>1]=d;b=Dw?w:b)-C)*v)+S(.5));o:{if(b=S(0)){d=~~b>>>0;break o}d=0}K[c+4>>1]=d;b=r>z?r:z;b=S(S(S((b>m?m:b)-r)*x)+S(.5));p:{if(b=S(0)){d=~~b>>>0;break p}d=0}K[c+2>>1]=d;b=Al?l:b)-B)*u)+S(.5));q:{if(b=S(0)){d=~~b>>>0;break q}d=0}K[c>>1]=d}if(a){continue}break}}fa=k+32|0;fa=j+16|0}ha[L[L[s>>2]+116>>2]](s);j=fa-16|0;fa=j;c=t+12|0;L[j+12>>2]=c;L[j+8>>2]=s+68;a=L[j+8>>2];Od(c);k=fa-16|0;fa=k;L[k+12>>2]=a;L[k+8>>2]=0;L[k+4>>2]=c;c=L[k+8>>2];a=L[k+4>>2];f=fa-48|0;fa=f;L[f+44>>2]=L[k+12>>2];L[f+40>>2]=c;L[f+36>>2]=a;a=L[f+40>>2];c=fa-16|0;d=L[f+44>>2];L[c+12>>2]=d+4;L[c+8>>2]=a;a=L[L[c+12>>2]+12>>2]+(L[c+8>>2]<<4)|0;e=d+24|0;c=d+56|0;Jh(f+20|0,a,e,c);a=L[f+24>>2];g=L[f+36>>2];L[g>>2]=L[f+20>>2];L[g+4>>2]=a;a=L[f+32>>2];L[g+8>>2]=L[f+28>>2];L[g+12>>2]=a;a=L[f+40>>2];g=fa-16|0;L[g+12>>2]=d+4;L[g+8>>2]=a;Jh(f+4|0,(L[L[g+12>>2]+12>>2]+(L[g+8>>2]<<4)|0)+6|0,e,c);a=L[f+8>>2];c=L[f+36>>2];L[c+16>>2]=L[f+4>>2];L[c+20>>2]=a;a=L[f+16>>2];L[c+24>>2]=L[f+12>>2];L[c+28>>2]=a;fa=f+48|0;fa=k+16|0;fa=j+16|0;a=L[t+16>>2];L[s+16>>2]=L[t+12>>2];L[s+20>>2]=a;a=L[t+40>>2];L[s+40>>2]=L[t+36>>2];L[s+44>>2]=a;a=L[t+32>>2];L[s+32>>2]=L[t+28>>2];L[s+36>>2]=a;a=L[t+24>>2];L[s+24>>2]=L[t+20>>2];L[s+28>>2]=a;fa=t+48|0}function YA(a,b){a=a|0;b=b|0;var c=S(0),d=0,e=S(0),f=S(0),g=0,h=S(0),i=0,j=S(0),k=0,l=S(0),m=S(0),n=0,o=S(0),p=S(0),q=S(0),r=S(0),s=0,t=S(0),u=S(0),v=S(0),w=S(0),x=S(0),y=S(0),z=0,A=0,B=S(0),C=0,D=S(0),E=S(0),F=S(0),G=0,H=S(0),I=0,K=0,N=0,O=0,Q=0,U=0,V=0,W=S(0),X=S(0),Y=0,Z=0,$=S(0),aa=S(0),ba=S(0),ca=0,da=0,ea=0,fa=S(0),ga=S(0),ha=S(0),ia=S(0),ja=S(0),ka=S(0);Z=L[a+28>>2];d=Z;D=P[d+344>>2];G=L[a+32>>2];B=P[G+344>>2];h=S(D+B);t=h>S(0)?S(B/h):S(.5);u=S(S(1)-t);v=P[a+920>>2];w=P[a+904>>2];e=P[a+856>>2];j=P[a+840>>2];F=P[a+888>>2];q=P[a+824>>2];s=L[b+24>>2];V=M[a+49|0];a:{if(V){c=S(S(t*e)+S(u*v));r=S(S(t*q)+S(u*F));h=S(S(t*j)+S(u*w));p=S(S(1)/S(_(S(S(c*c)+S(S(r*r)+S(h*h))))));h=S(h*p);r=S(r*p);p=S(c*p);if(S(T(p))>S(.7071067690849304)){c=S(S(h*h)+S(p*p));o=S(S(1)/S(_(c)));l=S(o*S(-p));x=S(r*l);m=S(h*o);y=S(m*S(-r));c=S(c*o);break a}f=S(S(r*r)+S(h*h));c=S(S(1)/S(_(f)));x=S(f*c);f=S(c*S(-h));y=S(p*f);l=S(r*c);c=S(l*S(-p));break a}x=P[a+864>>2];y=P[a+848>>2];m=P[a+860>>2];l=P[a+844>>2];f=P[a+828>>2];r=q;h=j;p=e;c=P[a+832>>2]}ea=M[a+180|0];fa=P[a+880>>2];ga=P[a+944>>2];ha=P[a+876>>2];ia=P[a+940>>2];ja=P[a+872>>2];ka=P[a+936>>2];g=L[b+12>>2];P[g+8>>2]=m;P[g+4>>2]=l;P[g>>2]=f;k=s<<2;P[k+g>>2]=c;n=k+8|0;P[n+g>>2]=x;C=k+4|0;P[C+g>>2]=y;i=L[b+20>>2];H=S(-m);P[i+8>>2]=H;E=S(-l);P[i+4>>2]=E;W=S(-f);P[i>>2]=W;aa=S(-x);P[i+n>>2]=aa;ba=S(-y);P[i+C>>2]=ba;$=S(-c);P[i+k>>2]=$;o=P[a+280>>2];C=L[b+28>>2];n=C;K=L[a+300>>2];if(!(K&128)){o=S(o*P[b+4>>2])}o=S(o*P[b>>2]);X=S(S(q*w)-S(F*j));j=S(S(j*v)-S(w*e));e=S(S(e*F)-S(v*q));P[n>>2]=o*S(S(X*m)+S(S(j*f)+S(e*l)));P[k+C>>2]=o*S(S(X*x)+S(S(j*c)+S(e*y)));if(K&64){k=L[b+32>>2];P[k>>2]=P[a+292>>2];P[k+(s<<2)>>2]=P[a+292>>2]}ca=B>2];j=P[G+56>>2];o=P[d+60>>2];q=P[d+56>>2];v=P[G+52>>2];w=P[d+52>>2];b:{if(V){e=S(P[a+944>>2]-e);l=S(P[a+936>>2]-v);m=S(P[a+940>>2]-j);c=S(S(e*p)+S(S(l*r)+S(h*m)));f=S(p*c);x=S(e-f);o=S(P[a+880>>2]-o);y=S(P[a+872>>2]-w);q=S(P[a+876>>2]-q);e=S(S(o*p)+S(S(y*r)+S(h*q)));B=S(p*e);j=S(P[a+1080>>2]-P[a+1032>>2]);f=S(S(B+S(p*j))-f);v=S(x-S(u*f));X=m;m=S(h*c);E=S(X-m);D=S(h*e);m=S(S(D+S(h*j))-m);w=S(E-S(u*m));c=S(r*c);l=S(l-c);e=S(r*e);c=S(S(e+S(r*j))-c);F=S(l-S(u*c));j=S(o-B);B=S(j+S(t*f));q=S(q-D);D=S(q+S(t*m));f=S(y-e);H=S(f+S(t*c));c=S(S(t*x)+S(u*j));f=S(S(t*l)+S(u*f));e=S(S(t*E)+S(u*q));j=S(S(c*c)+S(S(f*f)+S(e*e)));c:{if(j>S(1.1920928955078125e-7)){m=c;c=S(S(1)/S(_(j)));m=S(m*c);l=S(e*c);f=S(f*c);break c}m=P[a+860>>2];l=P[a+844>>2];f=P[a+828>>2]}A=s<<3;d=A+g|0;P[d+8>>2]=S(H*l)-S(f*D);P[d+4>>2]=S(B*f)-S(m*H);P[d>>2]=S(D*m)-S(l*B);I=k<<2;P[I+i>>2]=-S(S(w*m)-S(l*v));N=(k|1)<<2;P[N+i>>2]=-S(S(v*f)-S(m*F));O=k+2<<2;P[O+i>>2]=-S(S(F*l)-S(f*w));y=S(S(p*f)-S(m*r));c=S(S(h*m)-S(l*p));E=S(S(F*y)-S(c*w));x=S(S(r*l)-S(f*h));e=S(S(v*c)-S(x*F));W=S(S(w*x)-S(y*v));j=S(S(H*y)-S(c*D));q=S(S(B*c)-S(x*H));o=S(S(D*x)-S(y*B));if(M[a+297|0]!=0&ca){j=S(t*j);q=S(t*q);o=S(t*o);E=S(u*E);W=S(u*W);e=S(u*e)}Y=R(s,12);d=Y+g|0;P[d+8>>2]=j;P[d+4>>2]=q;P[d>>2]=o;z=U<<2;da=z+8|0;P[i+da>>2]=-E;Q=z+4|0;P[i+Q>>2]=-e;P[i+z>>2]=-W;n=L[b+8>>2];d=A+n|0;P[d+8>>2]=m;P[d+4>>2]=l;P[d>>2]=f;d=n+Y|0;P[d+8>>2]=x;P[d+4>>2]=y;P[d>>2]=c;d=L[b+16>>2];P[I+d>>2]=-f;P[d+N>>2]=-l;P[d+O>>2]=-m;P[d+da>>2]=-x;P[d+Q>>2]=-y;P[d+z>>2]=-c;j=S(0);q=S(0);o=S(0);break b}z=k<<2;q=S(j-q);o=S(e-o);e=S(S(q*m)-S(l*o));P[z+g>>2]=t*e;I=z|4;j=S(v-w);v=S(S(o*f)-S(m*j));P[I+g>>2]=t*v;N=z+8|0;w=S(S(j*l)-S(f*q));P[N+g>>2]=t*w;P[i+z>>2]=u*e;P[i+I>>2]=u*v;P[i+N>>2]=u*w;A=U<<2;O=A+8|0;e=S(S(j*y)-S(c*q));P[O+g>>2]=t*e;Y=A+4|0;v=S(S(o*c)-S(x*j));P[Y+g>>2]=t*v;w=S(S(q*x)-S(y*o));P[g+A>>2]=t*w;P[i+O>>2]=u*e;P[i+Y>>2]=u*v;P[i+A>>2]=u*w;n=L[b+8>>2];d=n+(s<<3)|0;P[d+8>>2]=m;P[d+4>>2]=l;P[d>>2]=f;d=R(s,12)+n|0;P[d+8>>2]=x;P[d+4>>2]=y;P[d>>2]=c;d=L[b+16>>2];P[z+d>>2]=W;P[d+I>>2]=E;P[d+N>>2]=H;P[d+O>>2]=aa;P[d+Y>>2]=ba;P[d+A>>2]=$;F=S(0);w=S(0);v=S(0);H=S(0);D=S(0);B=S(0)}e=P[a+264>>2];k=k<<2;z=k+C|0;if(!(K&32)){e=S(e*P[b+4>>2])}e=S(e*P[b>>2]);$=m;m=S(ga-fa);X=f;f=S(ka-ja);E=S(ia-ha);P[z>>2]=e*S(S($*m)+S(S(X*f)+S(E*l)));z=U<<2;P[z+C>>2]=e*S(S(x*m)+S(S(c*f)+S(E*y)));if(K&16){Q=k;k=L[b+32>>2];P[Q+k>>2]=P[a+276>>2];P[k+z>>2]=P[a+276>>2]}f=ea?S(1):S(-1);d:{e:{U=M[a+296|0];f:{if(U){c=S(f*P[a+1032>>2]);z=c>S(0)?2:1;k=M[a+1096|0];break f}if(!M[a+1096|0]){break e}z=0;c=S(0);k=1}N=s<<4;P[N+n>>2]=r;s=s<<2;O=s|1;A=O<<2;P[A+n>>2]=h;Q=n;n=s|2;I=n<<2;P[Q+I>>2]=p;P[d+N>>2]=-r;P[d+A>>2]=-h;P[d+I>>2]=-p;Q=i+(n<<2)|0;g:{h:{if(V){if(ca){break g}A=s<<2;P[A+g>>2]=S(D*p)-S(h*B);V=O<<2;P[V+g>>2]=S(B*r)-S(p*H);P[g+(n<<2)>>2]=S(H*h)-S(r*D);P[i+A>>2]=-S(S(w*p)-S(h*v));P[i+V>>2]=-S(S(v*r)-S(p*F));m=S(-S(S(F*h)-S(r*w)));break h}n=s<<2;e=S(S(q*p)-S(h*o));P[n+g>>2]=t*e;o=S(S(o*r)-S(p*j));P[g+A>>2]=t*o;j=S(S(j*h)-S(r*q));P[g+I>>2]=t*j;P[i+n>>2]=u*e;P[i+A>>2]=u*o;m=S(u*j)}P[Q>>2]=m}e=P[a+188>>2];j=P[a+184>>2];i=s<<2;L[i+C>>2]=0;d=L[b+36>>2];L[i+d>>2]=0;n=L[b+40>>2];L[i+n>>2]=0;q=P[(K&512?a+232|0:b+4|0)>>2];if(!(!k|(U|0)!=0&e==j)){if(K&1){P[L[b+32>>2]+(s<<2)>>2]=P[a+212>>2]}o=pd(P[a+1080>>2],P[a+184>>2],P[a+188>>2],P[a+1100>>2],S(q*P[b>>2]));C=L[b+28>>2];k=s<<2;i=C+k|0;P[i>>2]=P[i>>2]-S(S(o*f)*P[a+1100>>2]);d=L[b+36>>2];i=k+d|0;P[i>>2]=P[i>>2]-S(P[a+1104>>2]*P[b>>2]);n=L[b+40>>2];k=k+n|0;P[k>>2]=S(P[a+1104>>2]*P[b>>2])+P[k>>2]}i=5;if(!U){break d}g=s<<2;k=g+C|0;P[k>>2]=S(S(q*P[b>>2])*c)+P[k>>2];if(J[a+301|0]&1){P[g+L[b+32>>2]>>2]=P[a+244>>2]}n=g+n|0;i:{j:{if(e==j){L[(s<<2)+d>>2]=-8388609;break j}g=(s<<2)+d|0;if((z|0)==1){L[g>>2]=-8388609;c=S(0);break i}L[g>>2]=0}c=S(34028234663852886e22)}P[n>>2]=c;c=S(S(1)-P[a+240>>2]);k:{if(!(c>S(0)|c>2]*p)+S(S(P[Z+312>>2]*r)+S(h*P[Z+316>>2])))-S(S(P[G+320>>2]*p)+S(S(P[G+312>>2]*r)+S(h*P[G+316>>2])))));l:{if((z|0)==1){if(!(cP[k>>2]){break l}break k}if(!(c>S(0))){break k}l=S(c*S(-e));if(!(l>2])){break k}}P[k>>2]=l}P[k>>2]=P[a+232>>2]*P[k>>2];break d}i=4}d=M[a+297|0];m:{n:{if(d){s=!M[a+1112|0];l=P[a+1088>>2];k=l>S(0)?1:2;break n}if(!M[a+1112|0]){break m}s=0;l=S(0);k=0}n=L[b+12>>2];i=R(L[b+24>>2],i);g=i<<2;P[n+g>>2]=r;G=g+8|0;P[G+n>>2]=p;K=g+4|0;P[K+n>>2]=h;n=L[b+20>>2];P[n+G>>2]=-p;P[n+K>>2]=-h;P[g+n>>2]=-r;g=L[a+300>>2];q=P[(g&2048?a+248|0:b+4|0)>>2];f=P[a+196>>2];j=P[a+192>>2];if(!((d|0)!=0&f==j|s)){e=f;c=j;if(g&4){P[L[b+32>>2]+(i<<2)>>2]=P[a+228>>2];e=P[a+196>>2];c=P[a+192>>2]}c=pd(P[a+1084>>2],c,e,P[a+1116>>2],S(q*P[b>>2]));C=L[b+28>>2];g=i<<2;P[C+g>>2]=c*P[a+1116>>2];P[g+L[b+36>>2]>>2]=P[b>>2]*S(-P[a+1120>>2]);P[g+L[b+40>>2]>>2]=P[a+1120>>2]*P[b>>2]}if(!d){break m}d=i<<2;g=d+C|0;P[g>>2]=S(S(q*P[b>>2])*l)+P[g>>2];if(M[a+301|0]&4){P[d+L[b+32>>2]>>2]=P[a+260>>2]}o:{if(f==j){L[L[b+36>>2]+(i<<2)>>2]=-8388609;c=S(34028234663852886e22);break o}d=L[b+36>>2]+(i<<2)|0;if((k|0)==1){L[d>>2]=0;c=S(34028234663852886e22);break o}L[d>>2]=-8388609;c=S(0)}P[L[b+40>>2]+(i<<2)>>2]=c;c=S(S(1)-P[a+256>>2]);p:{if(!(c>S(0)|c>2];f=S(S(P[b+336>>2]*p)+S(S(P[b+328>>2]*r)+S(h*P[b+332>>2])));b=L[a+32>>2];h=S(f-S(S(P[b+336>>2]*p)+S(S(P[b+328>>2]*r)+S(h*P[b+332>>2]))));q:{if((k|0)==1){if(!(hP[g>>2]){break q}break p}if(!(h>S(0))){break p}h=S(h*S(-c));if(!(h>2])){break p}}P[g>>2]=h}P[g>>2]=P[a+248>>2]*P[g>>2]}}function bE(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=S(0),f=S(0),g=S(0),h=0,i=S(0),j=S(0),k=S(0),l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;h=fa-48|0;fa=h;e=P[a+40>>2];f=P[a+24>>2];j=S(S(1)/P[a+116>>2]);k=P[a+56>>2];g=S(S(j*P[d+8>>2])+k);g=f>g?f:g;g=e>2])+k);f=f>j?f:j;e=e>2];f=P[a+20>>2];j=S(S(1)/P[a+112>>2]);k=P[a+52>>2];g=S(S(j*P[d+4>>2])+k);g=f>g?f:g;g=e>2])+k);f=f>j?f:j;e=e>2];f=P[a+16>>2];j=S(S(1)/P[a+108>>2]);k=P[a+48>>2];g=S(S(j*P[d>>2])+k);g=f>g?f:g;g=e>2])+k);f=f>j?f:j;e=e>2]-1|0;p=L[a+64>>2]-1|0;g:{h:{switch(L[a+104>>2]){case 0:l=(o|0)<(l|0)?o:l;n=(q|0)>0?q:0;p=(p|0)>(r|0)?r:p;t=(s|0)>0?s:0;break g;case 1:l=(o|0)<(l|0)?o:l;n=(q|0)>0?q:0;p=(d|0)<(p|0)?d:p;t=(c|0)>0?c:0;break g;case 2:break h;default:break g}}l=(l|0)>(r|0)?r:l;n=(s|0)>0?s:0;p=(d|0)<(p|0)?d:p;t=(c|0)>0?c:0}if(!((p|0)<=(t|0)|(n|0)>=(l|0))){while(1){q=n&1;o=n+1|0;j=S(o|0);k=S(n|0);c=t;while(1){i:{j:{d=c;if(!(M[a+100|0]|(c+n&1?0:M[a+101|0])|(q?0:M[a+102|0]))){g=S(ha[L[L[a>>2]+68>>2]](a,d,n));k:{l:{switch(L[a+104>>2]){case 2:f=P[a+80>>2];e=P[a+84>>2];i=P[a+56>>2];L[h+12>>2]=0;e=S(k-S(e*S(.5)));f=S(S(d|0)-S(f*S(.5)));g=S(g-i);break k;case 1:f=P[a+80>>2];i=P[a+84>>2];e=P[a+52>>2];L[h+12>>2]=0;e=S(g-e);f=S(S(d|0)-S(f*S(.5)));g=S(k-S(i*S(.5)));break k;case 0:e=P[a+80>>2];i=P[a+84>>2];f=P[a+48>>2];L[h+12>>2]=0;f=S(g-f);e=S(S(d|0)-S(e*S(.5)));g=S(k-S(i*S(.5)));break k;default:break l}}e=P[h+4>>2];f=P[h>>2];g=P[h+8>>2]}P[h>>2]=f*P[a+108>>2];P[h+4>>2]=e*P[a+112>>2];P[h+8>>2]=g*P[a+116>>2];g=S(ha[L[L[a>>2]+68>>2]](a,d,o));m:{n:{switch(L[a+104>>2]){case 2:f=P[a+80>>2];e=P[a+84>>2];i=P[a+56>>2];L[h+28>>2]=0;e=S(j-S(e*S(.5)));f=S(S(d|0)-S(f*S(.5)));g=S(g-i);break m;case 1:f=P[a+80>>2];i=P[a+84>>2];e=P[a+52>>2];L[h+28>>2]=0;e=S(g-e);f=S(S(d|0)-S(f*S(.5)));g=S(j-S(i*S(.5)));break m;case 0:e=P[a+80>>2];i=P[a+84>>2];f=P[a+48>>2];L[h+28>>2]=0;f=S(g-f);e=S(S(d|0)-S(e*S(.5)));g=S(j-S(i*S(.5)));break m;default:break n}}e=P[h+20>>2];f=P[h+16>>2];g=P[h+24>>2]}P[h+16>>2]=f*P[a+108>>2];P[h+20>>2]=e*P[a+112>>2];P[h+24>>2]=g*P[a+116>>2];c=d+1|0;g=S(ha[L[L[a>>2]+68>>2]](a,c,n));o:{p:{switch(L[a+104>>2]){case 2:f=P[a+80>>2];e=P[a+84>>2];i=P[a+56>>2];L[h+44>>2]=0;e=S(k-S(e*S(.5)));f=S(S(c|0)-S(f*S(.5)));g=S(g-i);break o;case 1:f=P[a+80>>2];i=P[a+84>>2];e=P[a+52>>2];L[h+44>>2]=0;e=S(g-e);f=S(S(c|0)-S(f*S(.5)));g=S(k-S(i*S(.5)));break o;case 0:e=P[a+80>>2];i=P[a+84>>2];f=P[a+48>>2];L[h+44>>2]=0;f=S(g-f);e=S(S(c|0)-S(e*S(.5)));g=S(k-S(i*S(.5)));break o;default:break p}}e=P[h+36>>2];f=P[h+32>>2];g=P[h+40>>2]}P[h+32>>2]=f*P[a+108>>2];P[h+36>>2]=e*P[a+112>>2];P[h+40>>2]=g*P[a+116>>2];ha[L[L[b>>2]+8>>2]](b,h,d,n);g=S(ha[L[L[a>>2]+68>>2]](a,c,n));q:{r:{switch(L[a+104>>2]){case 2:f=P[a+80>>2];e=P[a+84>>2];i=P[a+56>>2];L[h+12>>2]=0;e=S(k-S(e*S(.5)));f=S(S(c|0)-S(f*S(.5)));g=S(g-i);break q;case 1:f=P[a+80>>2];i=P[a+84>>2];e=P[a+52>>2];L[h+12>>2]=0;e=S(g-e);f=S(S(c|0)-S(f*S(.5)));g=S(k-S(i*S(.5)));break q;case 0:e=P[a+80>>2];i=P[a+84>>2];f=P[a+48>>2];L[h+12>>2]=0;f=S(g-f);e=S(S(c|0)-S(e*S(.5)));g=S(k-S(i*S(.5)));break q;default:break r}}e=P[h+4>>2];f=P[h>>2];g=P[h+8>>2]}P[h>>2]=f*P[a+108>>2];P[h+4>>2]=e*P[a+112>>2];P[h+8>>2]=g*P[a+116>>2];g=S(ha[L[L[a>>2]+68>>2]](a,c,o));s:{switch(L[a+104>>2]){case 2:f=P[a+80>>2];e=P[a+84>>2];i=P[a+56>>2];L[h+44>>2]=0;e=S(j-S(e*S(.5)));f=S(S(c|0)-S(f*S(.5)));g=S(g-i);break i;case 1:f=P[a+80>>2];i=P[a+84>>2];e=P[a+52>>2];L[h+44>>2]=0;e=S(g-e);f=S(S(c|0)-S(f*S(.5)));g=S(j-S(i*S(.5)));break i;case 0:break s;default:break j}}e=P[a+80>>2];i=P[a+84>>2];f=P[a+48>>2];L[h+44>>2]=0;f=S(g-f);e=S(S(c|0)-S(e*S(.5)));g=S(j-S(i*S(.5)));break i}g=S(ha[L[L[a>>2]+68>>2]](a,d,n));t:{u:{switch(L[a+104>>2]){case 2:f=P[a+80>>2];e=P[a+84>>2];i=P[a+56>>2];L[h+12>>2]=0;e=S(k-S(e*S(.5)));f=S(S(d|0)-S(f*S(.5)));g=S(g-i);break t;case 1:f=P[a+80>>2];i=P[a+84>>2];e=P[a+52>>2];L[h+12>>2]=0;e=S(g-e);f=S(S(d|0)-S(f*S(.5)));g=S(k-S(i*S(.5)));break t;case 0:e=P[a+80>>2];i=P[a+84>>2];f=P[a+48>>2];L[h+12>>2]=0;f=S(g-f);e=S(S(d|0)-S(e*S(.5)));g=S(k-S(i*S(.5)));break t;default:break u}}e=P[h+4>>2];f=P[h>>2];g=P[h+8>>2]}P[h>>2]=f*P[a+108>>2];P[h+4>>2]=e*P[a+112>>2];P[h+8>>2]=g*P[a+116>>2];c=d+1|0;g=S(ha[L[L[a>>2]+68>>2]](a,c,n));v:{w:{switch(L[a+104>>2]){case 2:f=P[a+80>>2];e=P[a+84>>2];i=P[a+56>>2];L[h+28>>2]=0;e=S(k-S(e*S(.5)));f=S(S(c|0)-S(f*S(.5)));g=S(g-i);break v;case 1:f=P[a+80>>2];i=P[a+84>>2];e=P[a+52>>2];L[h+28>>2]=0;e=S(g-e);f=S(S(c|0)-S(f*S(.5)));g=S(k-S(i*S(.5)));break v;case 0:e=P[a+80>>2];i=P[a+84>>2];f=P[a+48>>2];L[h+28>>2]=0;f=S(g-f);e=S(S(c|0)-S(e*S(.5)));g=S(k-S(i*S(.5)));break v;default:break w}}e=P[h+20>>2];f=P[h+16>>2];g=P[h+24>>2]}P[h+16>>2]=f*P[a+108>>2];P[h+20>>2]=e*P[a+112>>2];P[h+24>>2]=g*P[a+116>>2];g=S(ha[L[L[a>>2]+68>>2]](a,c,o));x:{y:{switch(L[a+104>>2]){case 2:f=P[a+80>>2];e=P[a+84>>2];i=P[a+56>>2];L[h+44>>2]=0;e=S(j-S(e*S(.5)));f=S(S(c|0)-S(f*S(.5)));g=S(g-i);break x;case 1:f=P[a+80>>2];i=P[a+84>>2];e=P[a+52>>2];L[h+44>>2]=0;e=S(g-e);f=S(S(c|0)-S(f*S(.5)));g=S(j-S(i*S(.5)));break x;case 0:e=P[a+80>>2];i=P[a+84>>2];f=P[a+48>>2];L[h+44>>2]=0;f=S(g-f);e=S(S(c|0)-S(e*S(.5)));g=S(j-S(i*S(.5)));break x;default:break y}}e=P[h+36>>2];f=P[h+32>>2];g=P[h+40>>2]}P[h+32>>2]=f*P[a+108>>2];P[h+36>>2]=e*P[a+112>>2];P[h+40>>2]=g*P[a+116>>2];ha[L[L[b>>2]+8>>2]](b,h,d,n);g=S(ha[L[L[a>>2]+68>>2]](a,c,o));z:{A:{switch(L[a+104>>2]){case 2:f=P[a+80>>2];e=P[a+84>>2];i=P[a+56>>2];L[h+28>>2]=0;e=S(j-S(e*S(.5)));f=S(S(c|0)-S(f*S(.5)));g=S(g-i);break z;case 1:f=P[a+80>>2];i=P[a+84>>2];e=P[a+52>>2];L[h+28>>2]=0;e=S(g-e);f=S(S(c|0)-S(f*S(.5)));g=S(j-S(i*S(.5)));break z;case 0:e=P[a+80>>2];i=P[a+84>>2];f=P[a+48>>2];L[h+28>>2]=0;f=S(g-f);e=S(S(c|0)-S(e*S(.5)));g=S(j-S(i*S(.5)));break z;default:break A}}e=P[h+20>>2];f=P[h+16>>2];g=P[h+24>>2]}P[h+16>>2]=f*P[a+108>>2];P[h+20>>2]=e*P[a+112>>2];P[h+24>>2]=g*P[a+116>>2];g=S(ha[L[L[a>>2]+68>>2]](a,d,o));B:{switch(L[a+104>>2]){case 2:f=P[a+80>>2];e=P[a+84>>2];i=P[a+56>>2];L[h+44>>2]=0;e=S(j-S(e*S(.5)));f=S(S(d|0)-S(f*S(.5)));g=S(g-i);break i;case 1:f=P[a+80>>2];i=P[a+84>>2];e=P[a+52>>2];L[h+44>>2]=0;e=S(g-e);f=S(S(d|0)-S(f*S(.5)));g=S(j-S(i*S(.5)));break i;case 0:break B;default:break j}}e=P[a+80>>2];i=P[a+84>>2];f=P[a+48>>2];L[h+44>>2]=0;f=S(g-f);e=S(S(d|0)-S(e*S(.5)));g=S(j-S(i*S(.5)));break i}e=P[h+36>>2];f=P[h+32>>2];g=P[h+40>>2]}P[h+32>>2]=f*P[a+108>>2];P[h+36>>2]=e*P[a+112>>2];P[h+40>>2]=g*P[a+116>>2];ha[L[L[b>>2]+8>>2]](b,h,d,n);if((c|0)!=(p|0)){continue}break}n=o;if((l|0)!=(n|0)){continue}break}}fa=h+48|0}function Ze(a,b,c,d){var e=0,f=0,g=0,h=S(0),i=S(0),j=S(0),k=S(0),l=S(0),m=S(0),n=S(0),o=S(0),p=S(0),q=S(0),r=S(0),s=S(0),t=0,u=0,v=S(0),w=S(0),x=S(0),y=S(0),z=S(0),A=S(0),B=S(0),C=S(0),D=S(0),E=S(0),F=0,G=S(0),H=S(0),I=S(0),K=0,N=S(0),O=S(0),Q=S(0),T=S(0);e=fa-688|0;fa=e;g=e+612|0;L[g+4>>2]=35;L[g+8>>2]=0;L[g>>2]=14328;L[g+44>>2]=1025758986;L[g+12>>2]=1065353216;L[g+16>>2]=1065353216;L[g>>2]=14044;L[g+20>>2]=1065353216;L[g+24>>2]=0;L[g+44>>2]=0;L[g+28>>2]=0;L[g+4>>2]=8;L[g>>2]=16192;f=L[c+12>>2];t=L[c+4>>2];u=L[t+4>>2];a:{if((u|0)<=19){L[e+604>>2]=0;L[e+608>>2]=0;L[e+436>>2]=6864;P[e+600>>2]=P[d+4>>2];J[e+408|0]=0;L[e+384>>2]=953267991;u=e+664|0;L[u+12>>2]=t;L[u+8>>2]=g;K=e+76|0;L[u+4>>2]=K;L[u>>2]=19064;F=e+60|0;L[F+12>>2]=t;L[F+8>>2]=g;L[F+4>>2]=K;L[F>>2]=18416;g=L[d+16>>2]&8?F:u;b:{if(!(ha[L[L[g>>2]+8>>2]](g,a,b,f,f,e+436|0)|0)){break b}h=P[e+576>>2];j=P[e+568>>2];i=P[e+572>>2];k=S(S(h*h)+S(S(j*j)+S(i*i)));if(!(k>S(9999999747378752e-20))){break b}l=P[e+600>>2];if(!(l>2])){break b}m=h;h=S(S(1)/S(_(k)));P[e+576>>2]=m*h;P[e+572>>2]=i*h;P[e+568>>2]=j*h;a=L[c+8>>2];L[e+36>>2]=0;L[e+32>>2]=a;a=L[e+580>>2];L[e+48>>2]=L[e+576>>2];L[e+52>>2]=a;a=L[e+572>>2];L[e+40>>2]=L[e+568>>2];L[e+44>>2]=a;P[e+56>>2]=l;S(ha[L[L[d>>2]+12>>2]](d,e+32|0,1))}break a}g=u-21|0;if(g>>>0<=8){v=P[f+20>>2];i=P[f+36>>2];q=P[f+24>>2];n=P[f+52>>2];k=P[f+56>>2];l=P[f+40>>2];r=P[f+32>>2];o=P[f+16>>2];m=P[f>>2];p=P[f+4>>2];s=P[f+48>>2];x=P[f+8>>2];j=P[a+52>>2];w=P[a+56>>2];h=P[a+48>>2];L[e+448>>2]=0;n=S(-n);B=S(q*n);y=S(S(B-S(x*s))-S(l*k));C=S(w*l);D=S(q*j);P[e+444>>2]=y+S(C+S(S(h*x)+D));E=S(v*n);z=S(S(E-S(p*s))-S(i*k));G=S(w*i);H=S(v*j);P[e+440>>2]=z+S(G+S(S(h*p)+H));I=S(o*n);N=S(S(I-S(m*s))-S(r*k));O=S(w*r);Q=S(o*j);P[e+436>>2]=N+S(O+S(S(h*m)+Q));w=P[b+52>>2];n=P[b+56>>2];j=P[b+48>>2];L[e+44>>2]=0;A=y;y=S(n*l);T=S(j*x);x=S(q*w);P[e+40>>2]=A+S(y+S(T+x));A=z;z=S(n*i);q=S(j*p);p=S(v*w);P[e+36>>2]=A+S(z+S(q+p));n=S(n*r);A=S(j*m);m=S(o*w);P[e+32>>2]=N+S(n+S(A+m));c:{switch(g|0){case 0:b=L[c+8>>2];g=e+436|0;u=e+32|0;a=xg(e+76|0,g,u,L[d+16>>2]);L[a+52>>2]=t;L[a+48>>2]=b;L[a+44>>2]=d;L[a>>2]=6932;c=L[f+12>>2];b=a- -64|0;L[b>>2]=L[f+8>>2];L[b+4>>2]=c;b=L[f+4>>2];L[a+56>>2]=L[f>>2];L[a+60>>2]=b;b=L[f+28>>2];L[a+80>>2]=L[f+24>>2];L[a+84>>2]=b;b=L[f+20>>2];L[a+72>>2]=L[f+16>>2];L[a+76>>2]=b;b=L[f+44>>2];L[a+96>>2]=L[f+40>>2];L[a+100>>2]=b;b=L[f+36>>2];L[a+88>>2]=L[f+32>>2];L[a+92>>2]=b;b=L[f+60>>2];L[a+112>>2]=L[f+56>>2];L[a+116>>2]=b;b=L[f+52>>2];L[a+104>>2]=L[f+48>>2];L[a+108>>2]=b;P[a+40>>2]=P[d+4>>2];b=fa-16|0;fa=b;c=L[t+48>>2];L[b+12>>2]=a;L[b+8>>2]=c;L[b+4>>2]=12388;c=L[t+52>>2];d=b+4|0;a=fa-32|0;fa=a;L[a+24>>2]=0;L[a+28>>2]=0;L[a+16>>2]=0;L[a+20>>2]=0;L[a+8>>2]=0;L[a+12>>2]=0;L[a>>2]=0;L[a+4>>2]=0;d:{if(M[c+60|0]){Em(c,d,g,u,a+16|0,a,L[c+56>>2]);break d}Fm(c,d,g,u,a+16|0,a)}fa=a+32|0;fa=b+16|0;break a;case 4:b=L[c+8>>2];c=e+436|0;g=e+32|0;a=xg(e+76|0,c,g,L[d+16>>2]);L[a+52>>2]=t;L[a+48>>2]=b;L[a+44>>2]=d;L[a>>2]=6932;u=L[f+12>>2];b=a- -64|0;L[b>>2]=L[f+8>>2];L[b+4>>2]=u;b=L[f+4>>2];L[a+56>>2]=L[f>>2];L[a+60>>2]=b;b=L[f+28>>2];L[a+80>>2]=L[f+24>>2];L[a+84>>2]=b;b=L[f+20>>2];L[a+72>>2]=L[f+16>>2];L[a+76>>2]=b;b=L[f+44>>2];L[a+96>>2]=L[f+40>>2];L[a+100>>2]=b;b=L[f+36>>2];L[a+88>>2]=L[f+32>>2];L[a+92>>2]=b;b=L[f+60>>2];L[a+112>>2]=L[f+56>>2];L[a+116>>2]=b;b=L[f+52>>2];L[a+104>>2]=L[f+48>>2];L[a+108>>2]=b;P[a+40>>2]=P[d+4>>2];ha[L[L[t>>2]+144>>2]](t,a,c,g);break a;default:break c}}v=P[f>>2];q=P[f+4>>2];k=S(-k);A=S(l*k);l=P[f+8>>2];s=S(-s);o=S(A+S(S(l*s)+B));P[e+672>>2]=S(C+S(S(h*l)+D))+o;L[e+676>>2]=0;i=S(S(i*k)+S(S(q*s)+E));P[e+668>>2]=S(G+S(S(h*q)+H))+i;A=S(O+S(S(h*v)+Q));h=S(S(r*k)+S(S(v*s)+I));P[e+664>>2]=A+h;L[e+72>>2]=0;P[e+68>>2]=S(y+S(S(j*l)+x))+o;P[e+64>>2]=S(z+S(S(j*q)+p))+i;P[e+60>>2]=S(n+S(S(j*v)+m))+h;b=L[c+8>>2];a=xg(e+76|0,e+664|0,e+60|0,L[d+16>>2]);L[a+52>>2]=t;L[a+48>>2]=b;L[a+44>>2]=d;L[a>>2]=7116;c=L[f+12>>2];b=a- -64|0;L[b>>2]=L[f+8>>2];L[b+4>>2]=c;b=L[f+4>>2];L[a+56>>2]=L[f>>2];L[a+60>>2]=b;b=L[f+28>>2];L[a+80>>2]=L[f+24>>2];L[a+84>>2]=b;b=L[f+20>>2];L[a+72>>2]=L[f+16>>2];L[a+76>>2]=b;b=L[f+44>>2];L[a+96>>2]=L[f+40>>2];L[a+100>>2]=b;b=L[f+36>>2];L[a+88>>2]=L[f+32>>2];L[a+92>>2]=b;b=L[f+60>>2];L[a+112>>2]=L[f+56>>2];L[a+116>>2]=b;b=L[f+52>>2];L[a+104>>2]=L[f+48>>2];L[a+108>>2]=b;P[a+40>>2]=P[d+4>>2];b=L[e+676>>2];L[e+24>>2]=L[e+672>>2];L[e+28>>2]=b;b=L[e+668>>2];L[e+16>>2]=L[e+664>>2];L[e+20>>2]=b;h=P[e+60>>2];if(h>2]){P[e+16>>2]=h}j=P[e+64>>2];if(j>2]){P[e+20>>2]=j}i=P[e+68>>2];if(i>2]){P[e+24>>2]=i}k=P[e+72>>2];if(k>2]){P[e+28>>2]=k}b=L[e+676>>2];L[e+8>>2]=L[e+672>>2];L[e+12>>2]=b;b=L[e+668>>2];L[e>>2]=L[e+664>>2];L[e+4>>2]=b;if(h>P[e>>2]){P[e>>2]=h}if(j>P[e+4>>2]){P[e+4>>2]=j}if(i>P[e+8>>2]){P[e+8>>2]=i}if(k>P[e+12>>2]){P[e+12>>2]=k}ha[L[L[t>>2]+64>>2]](t,a,e+16|0,e);break a}if((u|0)!=31){break a}g=L[t+64>>2];c=L[c+8>>2];L[e+56>>2]=d;L[e+52>>2]=b;L[e+48>>2]=a;L[e+44>>2]=f;L[e+40>>2]=t;L[e+36>>2]=c;L[e+32>>2]=7304;if(g){h=P[f+20>>2];j=P[f+36>>2];i=P[f+24>>2];k=P[f+52>>2];p=P[a+52>>2];l=P[f+40>>2];r=P[f+56>>2];o=P[a+56>>2];x=P[f>>2];s=P[f+16>>2];v=P[f+32>>2];w=P[f+4>>2];m=P[f+8>>2];q=P[f+48>>2];n=P[a+48>>2];L[e+88>>2]=0;o=S(o-r);y=m;m=S(n-q);p=S(p-k);P[e+84>>2]=S(l*o)+S(S(y*m)+S(i*p));P[e+80>>2]=S(j*o)+S(S(w*m)+S(p*h));P[e+76>>2]=S(v*o)+S(S(x*m)+S(p*s));o=P[b+52>>2];m=P[b+56>>2];p=P[f>>2];x=P[f+4>>2];w=P[f+8>>2];n=P[b+48>>2];L[e+448>>2]=0;y=l;l=S(m-r);r=S(n-q);m=i;i=S(o-k);P[e+444>>2]=S(y*l)+S(S(w*r)+S(m*i));P[e+440>>2]=S(j*l)+S(S(x*r)+S(h*i));P[e+436>>2]=S(v*l)+S(S(p*r)+S(s*i));qn(L[g>>2],e+76|0,e+436|0,e+32|0);break a}b=L[t+16>>2];if((b|0)<=0){break a}c=0;while(1){a=L[L[e+40>>2]+24>>2]+R(c,80)|0;d=L[a+64>>2];o=P[a+56>>2];m=P[a+48>>2];p=P[a+52>>2];x=P[a+32>>2];w=P[a>>2];n=P[a+16>>2];B=P[a+36>>2];y=P[a+4>>2];C=P[a+20>>2];D=P[a+40>>2];E=P[a+8>>2];z=P[a+24>>2];a=L[e+44>>2];G=P[a+52>>2];H=P[a+56>>2];h=P[a+24>>2];j=P[a+20>>2];i=P[a+40>>2];k=P[a+36>>2];I=P[a+48>>2];l=P[a+8>>2];r=P[a>>2];s=P[a+4>>2];v=P[a+16>>2];q=P[a+32>>2];L[e+136>>2]=0;L[e+120>>2]=0;L[e+104>>2]=0;L[e+88>>2]=0;P[e+116>>2]=S(D*i)+S(S(E*q)+S(z*k));P[e+112>>2]=S(B*i)+S(S(y*q)+S(C*k));P[e+108>>2]=S(x*i)+S(S(w*q)+S(n*k));P[e+100>>2]=S(D*h)+S(S(E*v)+S(z*j));P[e+96>>2]=S(B*h)+S(S(y*v)+S(C*j));P[e+92>>2]=S(x*h)+S(S(w*v)+S(n*j));P[e+84>>2]=S(D*l)+S(S(E*r)+S(s*z));P[e+80>>2]=S(B*l)+S(S(y*r)+S(s*C));P[e+76>>2]=S(x*l)+S(S(w*r)+S(n*s));P[e+132>>2]=H+S(S(o*i)+S(S(m*q)+S(k*p)));P[e+128>>2]=G+S(S(o*h)+S(S(m*v)+S(j*p)));P[e+124>>2]=I+S(S(o*l)+S(S(m*r)+S(s*p)));L[e+684>>2]=c;L[e+680>>2]=-1;L[e+672>>2]=L[e+36>>2];L[e+668>>2]=d;L[e+664>>2]=0;L[e+676>>2]=e+76;L[e+448>>2]=-65535;L[e+452>>2]=0;L[e+440>>2]=1065353216;L[e+444>>2]=0;L[e+460>>2]=c;L[e+436>>2]=7480;a=L[e+56>>2];L[e+456>>2]=a;P[e+440>>2]=P[a+4>>2];L[e+452>>2]=L[a+16>>2];Ze(L[e+48>>2],L[e+52>>2],e+664|0,e+436|0);c=c+1|0;if((b|0)!=(c|0)){continue}break}}fa=e+688|0}function MF(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;P[a+20>>2]=Q[b+32>>3];P[a+24>>2]=Q[b+40>>3];P[a+28>>2]=Q[b+48>>3];P[a+32>>2]=Q[b+56>>3];P[a+4>>2]=Q[b>>3];P[a+8>>2]=Q[b+8>>3];P[a+12>>2]=Q[b+16>>3];P[a+16>>2]=Q[b+24>>3];P[a+36>>2]=Q[b+64>>3];P[a+40>>2]=Q[b+72>>3];P[a+44>>2]=Q[b+80>>3];P[a+48>>2]=Q[b+88>>3];L[a+56>>2]=L[b+96>>2];J[a+60|0]=L[b+100>>2]!=0;f=L[a+88>>2];k=L[b+104>>2];a:{if((f|0)>=(k|0)){break a}if((k|0)>L[a+92>>2]){if(k){L[8513]=L[8513]+1;j=ha[L[6798]](k<<6,16)|0;c=L[a+88>>2]}else{c=f}b:{if((c|0)<=0){break b}if((c|0)!=1){m=c&-2;while(1){h=l<<6;g=h+j|0;i=h+L[a+96>>2]|0;e=L[i+4>>2];L[g>>2]=L[i>>2];L[g+4>>2]=e;e=L[i+60>>2];L[g+56>>2]=L[i+56>>2];L[g+60>>2]=e;e=L[i+52>>2];L[g+48>>2]=L[i+48>>2];L[g+52>>2]=e;e=L[i+44>>2];L[g+40>>2]=L[i+40>>2];L[g+44>>2]=e;e=L[i+36>>2];L[g+32>>2]=L[i+32>>2];L[g+36>>2]=e;e=L[i+28>>2];L[g+24>>2]=L[i+24>>2];L[g+28>>2]=e;e=L[i+20>>2];L[g+16>>2]=L[i+16>>2];L[g+20>>2]=e;e=L[i+12>>2];L[g+8>>2]=L[i+8>>2];L[g+12>>2]=e;e=h|64;g=e+j|0;h=e+L[a+96>>2]|0;e=L[h+4>>2];L[g>>2]=L[h>>2];L[g+4>>2]=e;e=L[h+12>>2];L[g+8>>2]=L[h+8>>2];L[g+12>>2]=e;e=L[h+20>>2];L[g+16>>2]=L[h+16>>2];L[g+20>>2]=e;e=L[h+28>>2];L[g+24>>2]=L[h+24>>2];L[g+28>>2]=e;e=L[h+36>>2];L[g+32>>2]=L[h+32>>2];L[g+36>>2]=e;e=L[h+44>>2];L[g+40>>2]=L[h+40>>2];L[g+44>>2]=e;e=L[h+52>>2];L[g+48>>2]=L[h+48>>2];L[g+52>>2]=e;e=L[h+60>>2];L[g+56>>2]=L[h+56>>2];L[g+60>>2]=e;l=l+2|0;d=d+2|0;if((m|0)!=(d|0)){continue}break}}if(!(c&1)){break b}c=l<<6;d=c+j|0;e=c+L[a+96>>2]|0;c=L[e+4>>2];L[d>>2]=L[e>>2];L[d+4>>2]=c;c=L[e+60>>2];L[d+56>>2]=L[e+56>>2];L[d+60>>2]=c;c=L[e+52>>2];L[d+48>>2]=L[e+48>>2];L[d+52>>2]=c;c=L[e+44>>2];L[d+40>>2]=L[e+40>>2];L[d+44>>2]=c;c=L[e+36>>2];L[d+32>>2]=L[e+32>>2];L[d+36>>2]=c;c=L[e+28>>2];L[d+24>>2]=L[e+24>>2];L[d+28>>2]=c;c=L[e+20>>2];L[d+16>>2]=L[e+16>>2];L[d+20>>2]=c;c=L[e+12>>2];L[d+8>>2]=L[e+8>>2];L[d+12>>2]=c}c=L[a+96>>2];if(!(c?!c|!M[a+100|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](c)}L[a+96>>2]=j;J[a+100|0]=1;L[a+92>>2]=k}d=k+(f^-1)|0;c=k-f&3;if(c){j=0;while(1){e=L[a+96>>2]+(f<<6)|0;L[e>>2]=0;L[e+4>>2]=0;L[e+56>>2]=0;L[e+60>>2]=0;L[e+48>>2]=0;L[e+52>>2]=0;L[e+40>>2]=0;L[e+44>>2]=0;L[e+32>>2]=0;L[e+36>>2]=0;L[e+24>>2]=0;L[e+28>>2]=0;L[e+16>>2]=0;L[e+20>>2]=0;L[e+8>>2]=0;L[e+12>>2]=0;f=f+1|0;j=j+1|0;if((c|0)!=(j|0)){continue}break}}if(d>>>0<3){break a}while(1){d=f<<6;c=d+L[a+96>>2]|0;L[c>>2]=0;L[c+4>>2]=0;L[c+56>>2]=0;L[c+60>>2]=0;L[c+48>>2]=0;L[c+52>>2]=0;L[c+40>>2]=0;L[c+44>>2]=0;L[c+32>>2]=0;L[c+36>>2]=0;L[c+24>>2]=0;L[c+28>>2]=0;L[c+16>>2]=0;L[c+20>>2]=0;L[c+8>>2]=0;L[c+12>>2]=0;c=d+L[a+96>>2]|0;L[c+120>>2]=0;L[c+124>>2]=0;L[c+112>>2]=0;L[c+116>>2]=0;L[c+104>>2]=0;L[c+108>>2]=0;L[c+96>>2]=0;L[c+100>>2]=0;L[c+88>>2]=0;L[c+92>>2]=0;L[c+80>>2]=0;L[c+84>>2]=0;L[c+72>>2]=0;L[c+76>>2]=0;c=c- -64|0;L[c>>2]=0;L[c+4>>2]=0;c=d+L[a+96>>2]|0;L[c+184>>2]=0;L[c+188>>2]=0;L[c+176>>2]=0;L[c+180>>2]=0;L[c+168>>2]=0;L[c+172>>2]=0;L[c+160>>2]=0;L[c+164>>2]=0;L[c+152>>2]=0;L[c+156>>2]=0;L[c+144>>2]=0;L[c+148>>2]=0;L[c+136>>2]=0;L[c+140>>2]=0;L[c+128>>2]=0;L[c+132>>2]=0;c=d+L[a+96>>2]|0;L[c+248>>2]=0;L[c+252>>2]=0;L[c+240>>2]=0;L[c+244>>2]=0;L[c+232>>2]=0;L[c+236>>2]=0;L[c+224>>2]=0;L[c+228>>2]=0;L[c+216>>2]=0;L[c+220>>2]=0;L[c+208>>2]=0;L[c+212>>2]=0;L[c+200>>2]=0;L[c+204>>2]=0;L[c+192>>2]=0;L[c+196>>2]=0;f=f+4|0;if((k|0)!=(f|0)){continue}break}}L[a+88>>2]=k;if((k|0)>0){c=L[a+96>>2];d=L[b+112>>2];j=0;while(1){f=c+(j<<6)|0;P[f+16>>2]=Q[d+32>>3];P[f+20>>2]=Q[d+40>>3];P[f+24>>2]=Q[d+48>>3];P[f+28>>2]=Q[d+56>>3];P[f>>2]=Q[d>>3];P[f+4>>2]=Q[d+8>>3];P[f+8>>2]=Q[d+16>>3];P[f+12>>2]=Q[d+24>>3];L[f+32>>2]=L[d+64>>2];L[f+36>>2]=L[d+68>>2];L[f+40>>2]=L[d+72>>2];d=d+80|0;j=j+1|0;if((k|0)!=(j|0)){continue}break}}d=L[a+128>>2];n=L[b+108>>2];c:{if((d|0)>=(n|0)){break c}if((n|0)>L[a+132>>2]){d:{if(!n){l=0;c=d;break d}L[8513]=L[8513]+1;l=ha[L[6798]](n<<4,16)|0;c=L[a+128>>2]}e:{if((c|0)<=0){break e}f=0;if((c|0)!=1){m=c&-2;i=0;while(1){h=f<<4;g=h+l|0;k=h+L[a+136>>2]|0;e=L[k+4>>2];L[g>>2]=L[k>>2];L[g+4>>2]=e;e=L[k+12>>2];L[g+8>>2]=L[k+8>>2];L[g+12>>2]=e;e=h|16;g=e+l|0;h=e+L[a+136>>2]|0;e=L[h+4>>2];L[g>>2]=L[h>>2];L[g+4>>2]=e;e=L[h+12>>2];L[g+8>>2]=L[h+8>>2];L[g+12>>2]=e;f=f+2|0;i=i+2|0;if((m|0)!=(i|0)){continue}break}}if(!(c&1)){break e}c=f<<4;f=c+l|0;e=c+L[a+136>>2]|0;c=L[e+4>>2];L[f>>2]=L[e>>2];L[f+4>>2]=c;c=L[e+12>>2];L[f+8>>2]=L[e+8>>2];L[f+12>>2]=c}c=L[a+136>>2];if(!(c?!c|!M[a+140|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](c)}L[a+136>>2]=l;J[a+140|0]=1;L[a+132>>2]=n}e=n+(d^-1)|0;c=n-d&3;if(c){f=0;while(1){g=L[a+136>>2]+(d<<4)|0;L[g>>2]=0;L[g+4>>2]=0;L[g+8>>2]=0;L[g+12>>2]=0;d=d+1|0;f=f+1|0;if((c|0)!=(f|0)){continue}break}}if(e>>>0<3){break c}while(1){f=d<<4;c=f+L[a+136>>2]|0;L[c>>2]=0;L[c+4>>2]=0;L[c+8>>2]=0;L[c+12>>2]=0;c=f+L[a+136>>2]|0;L[c+24>>2]=0;L[c+28>>2]=0;L[c+16>>2]=0;L[c+20>>2]=0;c=f+L[a+136>>2]|0;L[c+40>>2]=0;L[c+44>>2]=0;L[c+32>>2]=0;L[c+36>>2]=0;c=f+L[a+136>>2]|0;L[c+56>>2]=0;L[c+60>>2]=0;L[c+48>>2]=0;L[c+52>>2]=0;d=d+4|0;if((n|0)!=(d|0)){continue}break}}L[a+128>>2]=n;if((n|0)>0){c=L[a+136>>2];d=L[b+116>>2];j=0;while(1){f=c+(j<<4)|0;L[f+12>>2]=L[d+12>>2];K[f+6>>1]=N[d+6>>1];K[f+8>>1]=N[d+8>>1];K[f+10>>1]=N[d+10>>1];K[f>>1]=N[d>>1];K[f+2>>1]=N[d+2>>1];K[f+4>>1]=N[d+4>>1];d=d+16|0;j=j+1|0;if((n|0)!=(j|0)){continue}break}}L[a+144>>2]=L[b+120>>2];d=L[a+152>>2];h=L[b+124>>2];if(!((d|0)>=(h|0)|(h|0)<=L[a+156>>2])){f:{if(!h){i=0;break f}L[8513]=L[8513]+1;i=ha[L[6798]](h<<5,16)|0;d=L[a+152>>2]}g:{if((d|0)<=0){break g}l=0;if((d|0)!=1){e=d&-2;j=0;while(1){g=l<<5;f=g+i|0;m=g+L[a+160>>2]|0;c=L[m+4>>2];L[f>>2]=L[m>>2];L[f+4>>2]=c;c=L[m+28>>2];L[f+24>>2]=L[m+24>>2];L[f+28>>2]=c;c=L[m+20>>2];L[f+16>>2]=L[m+16>>2];L[f+20>>2]=c;c=L[m+12>>2];L[f+8>>2]=L[m+8>>2];L[f+12>>2]=c;c=g|32;f=c+i|0;g=c+L[a+160>>2]|0;c=L[g+4>>2];L[f>>2]=L[g>>2];L[f+4>>2]=c;c=L[g+12>>2];L[f+8>>2]=L[g+8>>2];L[f+12>>2]=c;c=L[g+20>>2];L[f+16>>2]=L[g+16>>2];L[f+20>>2]=c;c=L[g+28>>2];L[f+24>>2]=L[g+24>>2];L[f+28>>2]=c;l=l+2|0;j=j+2|0;if((e|0)!=(j|0)){continue}break}}if(!(d&1)){break g}c=l<<5;f=c+i|0;d=c+L[a+160>>2]|0;c=L[d+4>>2];L[f>>2]=L[d>>2];L[f+4>>2]=c;c=L[d+28>>2];L[f+24>>2]=L[d+24>>2];L[f+28>>2]=c;c=L[d+20>>2];L[f+16>>2]=L[d+16>>2];L[f+20>>2]=c;c=L[d+12>>2];L[f+8>>2]=L[d+8>>2];L[f+12>>2]=c}c=L[a+160>>2];if(!(c?!c|!M[a+164|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](c)}L[a+160>>2]=i;J[a+164|0]=1;L[a+156>>2]=h}L[a+152>>2]=h;if((h|0)>0){c=L[a+160>>2];d=L[b+128>>2];a=0;while(1){b=c+(a<<5)|0;K[b+6>>1]=N[d+14>>1];K[b+8>>1]=N[d+16>>1];K[b+10>>1]=N[d+18>>1];K[b>>1]=N[d+8>>1];K[b+2>>1]=N[d+10>>1];K[b+4>>1]=N[d+12>>1];L[b+12>>2]=L[d>>2];L[b+16>>2]=L[d+4>>2];d=d+20|0;a=a+1|0;if((h|0)!=(a|0)){continue}break}}}function NF(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;P[a+20>>2]=P[b+16>>2];P[a+24>>2]=P[b+20>>2];P[a+28>>2]=P[b+24>>2];P[a+32>>2]=P[b+28>>2];P[a+4>>2]=P[b>>2];P[a+8>>2]=P[b+4>>2];P[a+12>>2]=P[b+8>>2];P[a+16>>2]=P[b+12>>2];P[a+36>>2]=P[b+32>>2];P[a+40>>2]=P[b+36>>2];P[a+44>>2]=P[b+40>>2];P[a+48>>2]=P[b+44>>2];L[a+56>>2]=L[b+48>>2];J[a+60|0]=L[b+52>>2]!=0;f=L[a+88>>2];k=L[b+56>>2];a:{if((f|0)>=(k|0)){break a}if((k|0)>L[a+92>>2]){if(k){L[8513]=L[8513]+1;j=ha[L[6798]](k<<6,16)|0;c=L[a+88>>2]}else{c=f}b:{if((c|0)<=0){break b}if((c|0)!=1){m=c&-2;while(1){h=l<<6;g=h+j|0;i=h+L[a+96>>2]|0;e=L[i+4>>2];L[g>>2]=L[i>>2];L[g+4>>2]=e;e=L[i+60>>2];L[g+56>>2]=L[i+56>>2];L[g+60>>2]=e;e=L[i+52>>2];L[g+48>>2]=L[i+48>>2];L[g+52>>2]=e;e=L[i+44>>2];L[g+40>>2]=L[i+40>>2];L[g+44>>2]=e;e=L[i+36>>2];L[g+32>>2]=L[i+32>>2];L[g+36>>2]=e;e=L[i+28>>2];L[g+24>>2]=L[i+24>>2];L[g+28>>2]=e;e=L[i+20>>2];L[g+16>>2]=L[i+16>>2];L[g+20>>2]=e;e=L[i+12>>2];L[g+8>>2]=L[i+8>>2];L[g+12>>2]=e;e=h|64;g=e+j|0;h=e+L[a+96>>2]|0;e=L[h+4>>2];L[g>>2]=L[h>>2];L[g+4>>2]=e;e=L[h+12>>2];L[g+8>>2]=L[h+8>>2];L[g+12>>2]=e;e=L[h+20>>2];L[g+16>>2]=L[h+16>>2];L[g+20>>2]=e;e=L[h+28>>2];L[g+24>>2]=L[h+24>>2];L[g+28>>2]=e;e=L[h+36>>2];L[g+32>>2]=L[h+32>>2];L[g+36>>2]=e;e=L[h+44>>2];L[g+40>>2]=L[h+40>>2];L[g+44>>2]=e;e=L[h+52>>2];L[g+48>>2]=L[h+48>>2];L[g+52>>2]=e;e=L[h+60>>2];L[g+56>>2]=L[h+56>>2];L[g+60>>2]=e;l=l+2|0;d=d+2|0;if((m|0)!=(d|0)){continue}break}}if(!(c&1)){break b}c=l<<6;d=c+j|0;e=c+L[a+96>>2]|0;c=L[e+4>>2];L[d>>2]=L[e>>2];L[d+4>>2]=c;c=L[e+60>>2];L[d+56>>2]=L[e+56>>2];L[d+60>>2]=c;c=L[e+52>>2];L[d+48>>2]=L[e+48>>2];L[d+52>>2]=c;c=L[e+44>>2];L[d+40>>2]=L[e+40>>2];L[d+44>>2]=c;c=L[e+36>>2];L[d+32>>2]=L[e+32>>2];L[d+36>>2]=c;c=L[e+28>>2];L[d+24>>2]=L[e+24>>2];L[d+28>>2]=c;c=L[e+20>>2];L[d+16>>2]=L[e+16>>2];L[d+20>>2]=c;c=L[e+12>>2];L[d+8>>2]=L[e+8>>2];L[d+12>>2]=c}c=L[a+96>>2];if(!(c?!c|!M[a+100|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](c)}L[a+96>>2]=j;J[a+100|0]=1;L[a+92>>2]=k}d=k+(f^-1)|0;c=k-f&3;if(c){j=0;while(1){e=L[a+96>>2]+(f<<6)|0;L[e>>2]=0;L[e+4>>2]=0;L[e+56>>2]=0;L[e+60>>2]=0;L[e+48>>2]=0;L[e+52>>2]=0;L[e+40>>2]=0;L[e+44>>2]=0;L[e+32>>2]=0;L[e+36>>2]=0;L[e+24>>2]=0;L[e+28>>2]=0;L[e+16>>2]=0;L[e+20>>2]=0;L[e+8>>2]=0;L[e+12>>2]=0;f=f+1|0;j=j+1|0;if((c|0)!=(j|0)){continue}break}}if(d>>>0<3){break a}while(1){d=f<<6;c=d+L[a+96>>2]|0;L[c>>2]=0;L[c+4>>2]=0;L[c+56>>2]=0;L[c+60>>2]=0;L[c+48>>2]=0;L[c+52>>2]=0;L[c+40>>2]=0;L[c+44>>2]=0;L[c+32>>2]=0;L[c+36>>2]=0;L[c+24>>2]=0;L[c+28>>2]=0;L[c+16>>2]=0;L[c+20>>2]=0;L[c+8>>2]=0;L[c+12>>2]=0;c=d+L[a+96>>2]|0;L[c+120>>2]=0;L[c+124>>2]=0;L[c+112>>2]=0;L[c+116>>2]=0;L[c+104>>2]=0;L[c+108>>2]=0;L[c+96>>2]=0;L[c+100>>2]=0;L[c+88>>2]=0;L[c+92>>2]=0;L[c+80>>2]=0;L[c+84>>2]=0;L[c+72>>2]=0;L[c+76>>2]=0;c=c- -64|0;L[c>>2]=0;L[c+4>>2]=0;c=d+L[a+96>>2]|0;L[c+184>>2]=0;L[c+188>>2]=0;L[c+176>>2]=0;L[c+180>>2]=0;L[c+168>>2]=0;L[c+172>>2]=0;L[c+160>>2]=0;L[c+164>>2]=0;L[c+152>>2]=0;L[c+156>>2]=0;L[c+144>>2]=0;L[c+148>>2]=0;L[c+136>>2]=0;L[c+140>>2]=0;L[c+128>>2]=0;L[c+132>>2]=0;c=d+L[a+96>>2]|0;L[c+248>>2]=0;L[c+252>>2]=0;L[c+240>>2]=0;L[c+244>>2]=0;L[c+232>>2]=0;L[c+236>>2]=0;L[c+224>>2]=0;L[c+228>>2]=0;L[c+216>>2]=0;L[c+220>>2]=0;L[c+208>>2]=0;L[c+212>>2]=0;L[c+200>>2]=0;L[c+204>>2]=0;L[c+192>>2]=0;L[c+196>>2]=0;f=f+4|0;if((k|0)!=(f|0)){continue}break}}L[a+88>>2]=k;if((k|0)>0){c=L[a+96>>2];d=L[b+64>>2];j=0;while(1){f=c+(j<<6)|0;P[f+16>>2]=P[d+16>>2];P[f+20>>2]=P[d+20>>2];P[f+24>>2]=P[d+24>>2];P[f+28>>2]=P[d+28>>2];P[f>>2]=P[d>>2];P[f+4>>2]=P[d+4>>2];P[f+8>>2]=P[d+8>>2];P[f+12>>2]=P[d+12>>2];L[f+32>>2]=L[d+32>>2];L[f+36>>2]=L[d+36>>2];L[f+40>>2]=L[d+40>>2];d=d+48|0;j=j+1|0;if((k|0)!=(j|0)){continue}break}}d=L[a+128>>2];n=L[b+60>>2];c:{if((d|0)>=(n|0)){break c}if((n|0)>L[a+132>>2]){d:{if(!n){l=0;c=d;break d}L[8513]=L[8513]+1;l=ha[L[6798]](n<<4,16)|0;c=L[a+128>>2]}e:{if((c|0)<=0){break e}f=0;if((c|0)!=1){m=c&-2;i=0;while(1){h=f<<4;g=h+l|0;k=h+L[a+136>>2]|0;e=L[k+4>>2];L[g>>2]=L[k>>2];L[g+4>>2]=e;e=L[k+12>>2];L[g+8>>2]=L[k+8>>2];L[g+12>>2]=e;e=h|16;g=e+l|0;h=e+L[a+136>>2]|0;e=L[h+4>>2];L[g>>2]=L[h>>2];L[g+4>>2]=e;e=L[h+12>>2];L[g+8>>2]=L[h+8>>2];L[g+12>>2]=e;f=f+2|0;i=i+2|0;if((m|0)!=(i|0)){continue}break}}if(!(c&1)){break e}c=f<<4;f=c+l|0;e=c+L[a+136>>2]|0;c=L[e+4>>2];L[f>>2]=L[e>>2];L[f+4>>2]=c;c=L[e+12>>2];L[f+8>>2]=L[e+8>>2];L[f+12>>2]=c}c=L[a+136>>2];if(!(c?!c|!M[a+140|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](c)}L[a+136>>2]=l;J[a+140|0]=1;L[a+132>>2]=n}e=n+(d^-1)|0;c=n-d&3;if(c){f=0;while(1){g=L[a+136>>2]+(d<<4)|0;L[g>>2]=0;L[g+4>>2]=0;L[g+8>>2]=0;L[g+12>>2]=0;d=d+1|0;f=f+1|0;if((c|0)!=(f|0)){continue}break}}if(e>>>0<3){break c}while(1){f=d<<4;c=f+L[a+136>>2]|0;L[c>>2]=0;L[c+4>>2]=0;L[c+8>>2]=0;L[c+12>>2]=0;c=f+L[a+136>>2]|0;L[c+24>>2]=0;L[c+28>>2]=0;L[c+16>>2]=0;L[c+20>>2]=0;c=f+L[a+136>>2]|0;L[c+40>>2]=0;L[c+44>>2]=0;L[c+32>>2]=0;L[c+36>>2]=0;c=f+L[a+136>>2]|0;L[c+56>>2]=0;L[c+60>>2]=0;L[c+48>>2]=0;L[c+52>>2]=0;d=d+4|0;if((n|0)!=(d|0)){continue}break}}L[a+128>>2]=n;if((n|0)>0){c=L[a+136>>2];d=L[b+68>>2];j=0;while(1){f=c+(j<<4)|0;L[f+12>>2]=L[d+12>>2];K[f+6>>1]=N[d+6>>1];K[f+8>>1]=N[d+8>>1];K[f+10>>1]=N[d+10>>1];K[f>>1]=N[d>>1];K[f+2>>1]=N[d+2>>1];K[f+4>>1]=N[d+4>>1];d=d+16|0;j=j+1|0;if((n|0)!=(j|0)){continue}break}}L[a+144>>2]=L[b+76>>2];d=L[a+152>>2];h=L[b+80>>2];if(!((d|0)>=(h|0)|(h|0)<=L[a+156>>2])){f:{if(!h){i=0;break f}L[8513]=L[8513]+1;i=ha[L[6798]](h<<5,16)|0;d=L[a+152>>2]}g:{if((d|0)<=0){break g}l=0;if((d|0)!=1){e=d&-2;j=0;while(1){g=l<<5;f=g+i|0;m=g+L[a+160>>2]|0;c=L[m+4>>2];L[f>>2]=L[m>>2];L[f+4>>2]=c;c=L[m+28>>2];L[f+24>>2]=L[m+24>>2];L[f+28>>2]=c;c=L[m+20>>2];L[f+16>>2]=L[m+16>>2];L[f+20>>2]=c;c=L[m+12>>2];L[f+8>>2]=L[m+8>>2];L[f+12>>2]=c;c=g|32;f=c+i|0;g=c+L[a+160>>2]|0;c=L[g+4>>2];L[f>>2]=L[g>>2];L[f+4>>2]=c;c=L[g+12>>2];L[f+8>>2]=L[g+8>>2];L[f+12>>2]=c;c=L[g+20>>2];L[f+16>>2]=L[g+16>>2];L[f+20>>2]=c;c=L[g+28>>2];L[f+24>>2]=L[g+24>>2];L[f+28>>2]=c;l=l+2|0;j=j+2|0;if((e|0)!=(j|0)){continue}break}}if(!(d&1)){break g}c=l<<5;f=c+i|0;d=c+L[a+160>>2]|0;c=L[d+4>>2];L[f>>2]=L[d>>2];L[f+4>>2]=c;c=L[d+28>>2];L[f+24>>2]=L[d+24>>2];L[f+28>>2]=c;c=L[d+20>>2];L[f+16>>2]=L[d+16>>2];L[f+20>>2]=c;c=L[d+12>>2];L[f+8>>2]=L[d+8>>2];L[f+12>>2]=c}c=L[a+160>>2];if(!(c?!c|!M[a+164|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](c)}L[a+160>>2]=i;J[a+164|0]=1;L[a+156>>2]=h}L[a+152>>2]=h;if((h|0)>0){c=L[a+160>>2];d=L[b+72>>2];a=0;while(1){b=c+(a<<5)|0;K[b+6>>1]=N[d+14>>1];K[b+8>>1]=N[d+16>>1];K[b+10>>1]=N[d+18>>1];K[b>>1]=N[d+8>>1];K[b+2>>1]=N[d+10>>1];K[b+4>>1]=N[d+12>>1];L[b+12>>2]=L[d>>2];L[b+16>>2]=L[d+4>>2];d=d+20|0;a=a+1|0;if((h|0)!=(a|0)){continue}break}}}function yG(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=0,g=S(0),h=S(0),i=S(0),j=S(0),k=0,l=S(0),m=0,n=S(0),o=0,p=S(0),q=S(0),r=S(0),s=S(0),t=S(0),u=S(0),v=S(0),w=S(0),x=S(0),y=S(0),z=S(0),A=S(0),B=S(0),C=S(0),D=S(0),E=S(0),F=S(0),G=S(0),H=S(0),I=S(0),J=S(0),K=S(0),N=S(0),O=S(0),Q=S(0),R=S(0),U=S(0),V=S(0),W=S(0),X=S(0),Y=S(0),Z=S(0),$=S(0),aa=S(0),ba=S(0),ca=S(0),da=S(0),ea=S(0),ga=S(0),ia=S(0),ja=0,ka=0,la=S(0),ma=S(0),na=0,oa=S(0);d=fa-48|0;fa=d;a:{if(!L[a+12>>2]){break a}m=M[a+16|0];k=m?c:b;f=L[k+12>>2];y=P[f+56>>2];z=P[f+52>>2];A=P[f+48>>2];o=m?b:c;m=L[o+12>>2];B=P[m+56>>2];ea=P[m+48>>2];C=P[m+52>>2];k=L[k+4>>2];w=P[f+32>>2];D=P[f+16>>2];E=P[f>>2];F=P[f+36>>2];n=P[f+20>>2];s=P[f+4>>2];h=P[m+40>>2];j=P[m+24>>2];g=P[m+8>>2];i=P[m+32>>2];p=P[m+16>>2];r=P[m>>2];t=P[m+36>>2];l=P[f+40>>2];u=P[m+20>>2];H=P[f+24>>2];x=P[m+4>>2];I=P[f+8>>2];m=L[o+4>>2];J=P[m+56>>2];v=P[m+48>>2];K=P[m+52>>2];L[d+28>>2]=0;W=S(S(i*l)+S(S(r*I)+S(H*p)));v=S(-v);X=S(S(t*l)+S(S(x*I)+S(H*u)));l=S(S(h*l)+S(S(g*I)+S(H*j)));P[d+24>>2]=S(S(W*v)-S(K*X))-S(J*l);H=S(S(i*F)+S(S(r*s)+S(n*p)));I=S(S(t*F)+S(S(x*s)+S(n*u)));Y=S(S(h*F)+S(S(g*s)+S(n*j)));P[d+20>>2]=S(S(H*v)-S(K*I))-S(J*Y);Z=S(S(i*w)+S(S(r*E)+S(D*p)));q=K;K=S(S(t*w)+S(S(x*E)+S(D*u)));ga=J;J=S(S(h*w)+S(S(g*E)+S(D*j)));P[d+16>>2]=S(S(Z*v)-S(q*K))-S(ga*J);ha[L[L[k>>2]+64>>2]](d+32|0,k,d+16|0);f=L[o+12>>2];v=P[f+48>>2];R=P[f+32>>2];U=P[f+16>>2];q=P[f+8>>2];O=P[f+4>>2];N=P[f>>2];Q=P[f+56>>2];G=P[f+52>>2];V=P[f+40>>2];$=P[f+36>>2];ia=P[f+24>>2];aa=P[f+20>>2];ba=P[m+64>>2];F=P[m+56>>2];n=P[m+48>>2];s=P[m+52>>2];w=P[d+40>>2];D=P[d+32>>2];E=P[d+36>>2];f=L[a+12>>2];ca=P[f+752>>2];L[e+4>>2]=f;da=S(S(y*h)+S(S(A*g)+S(z*j)));ga=g;g=S(-ea);l=S(S(da+S(S(S(ga*g)-S(j*C))-S(h*B)))+S(S(w*l)+S(S(D*J)+S(Y*E))));p=S(S(S(S(y*i)+S(S(A*r)+S(z*p)))+S(S(S(r*g)-S(p*C))-S(i*B)))+S(S(w*W)+S(S(D*Z)+S(H*E))));r=S(S(S(S(y*t)+S(S(A*x)+S(z*u)))+S(S(S(x*g)-S(u*C))-S(t*B)))+S(S(w*X)+S(S(D*K)+S(I*E))));h=S(S(S(F*l)+S(S(n*p)+S(s*r)))-ba);if(h>2];t=P[f+24>>2];u=P[f+20>>2];x=P[f+40>>2];y=P[f+36>>2];z=P[f+16>>2];A=P[f+32>>2];j=P[m+56>>2];B=P[f+8>>2];g=P[m+48>>2];C=P[f>>2];i=P[m+52>>2];w=P[f+4>>2];L[d+28>>2]=0;P[d+16>>2]=S(B*j)+S(S(C*g)+S(w*i));P[d+24>>2]=S(x*j)+S(S(A*g)+S(i*y));P[d+20>>2]=S(t*j)+S(S(z*g)+S(i*u));L[d+12>>2]=0;j=S(l-S(F*h));g=S(p-S(n*h));i=S(r-S(s*h));P[d+8>>2]=S(S(j*V)+S(S(g*R)+S(i*$)))+Q;P[d+4>>2]=S(S(j*ia)+S(S(g*U)+S(i*aa)))+G;P[d>>2]=S(S(j*q)+S(S(g*N)+S(O*i)))+v;ha[L[L[e>>2]+16>>2]](e,d+16|0,d,h)}b:{if(L[k+4>>2]>6|L[L[e+4>>2]+748>>2]>=L[a+24>>2]){break b}j=P[m+56>>2];c:{if(S(T(j))>S(.7071067690849304)){h=P[m+52>>2];g=S(S(1)/S(_(S(S(h*h)+S(j*j)))));h=S(h*g);j=S(g*S(-j));g=S(0);break c}h=P[m+48>>2];g=P[m+52>>2];i=S(S(1)/S(_(S(S(h*h)+S(g*g)))));j=S(h*i);h=S(0);g=S(i*S(-g))}i=S(ha[L[L[k>>2]+16>>2]](k));i=S(P[6794]/i);i=S((i>S(.39269909262657166)?S(.39269909262657166):i)*S(.5));p=Ea(i);f=L[a+20>>2];H=Fa(i);if((f|0)<=0){break b}q=h;h=S(p/S(_(S(S(h*h)+S(S(g*g)+S(j*j))))));I=S(q*h);J=S(j*h);K=S(g*h);while(1){j=P[m+52>>2];i=P[m+48>>2];h=P[m+56>>2];g=S(S(S(S(6.2831854820251465)/S(f|0))*S(na|0))*S(.5));p=S(Ea(g)/S(_(S(S(h*h)+S(S(i*i)+S(j*j))))));h=S(h*p);j=S(j*p);g=Fa(g);i=S(i*p);p=S(S(h*I)+S(S(j*J)+S(S(g*H)+S(K*i))));r=S(S(h*J)+S(S(S(g*K)-S(H*i))-S(j*I)));t=S(S(i*I)+S(S(S(g*J)-S(H*j))-S(h*K)));u=S(S(j*K)+S(S(S(g*I)-S(H*h))-S(i*J)));P[d+28>>2]=S(S(S(p*g)-S(i*r))-S(t*j))-S(u*h);P[d+24>>2]=S(S(r*j)+S(S(p*h)+S(g*u)))-S(t*i);P[d+20>>2]=S(S(u*i)+S(S(p*j)+S(g*t)))-S(r*h);P[d+16>>2]=S(S(t*h)+S(S(p*i)+S(g*r)))-S(u*j);f=fa-48|0;fa=f;o=M[a+16|0];ja=o?c:b;k=L[ja+12>>2];ea=P[k+56>>2];W=P[k+52>>2];X=P[k+48>>2];ka=o?b:c;o=L[ka+12>>2];Y=P[o+56>>2];$=P[o+48>>2];Z=P[o+52>>2];ja=L[ja+4>>2];h=P[o+40>>2];j=P[o+8>>2];g=P[o+24>>2];i=P[o+32>>2];p=P[o>>2];r=P[o+16>>2];t=P[o+36>>2];y=P[k+40>>2];z=P[k+32>>2];A=P[k+36>>2];u=P[o+4>>2];B=P[k+8>>2];C=P[k>>2];w=P[k+4>>2];x=P[o+20>>2];D=P[k+24>>2];E=P[k+16>>2];F=P[k+20>>2];s=P[d+28>>2];v=P[d+24>>2];n=P[d+16>>2];l=P[d+20>>2];o=L[ka+4>>2];R=P[o+56>>2];ia=P[o+48>>2];U=P[o+52>>2];L[f+28>>2]=0;q=S(S(2)/S(S(s*s)+S(S(v*v)+S(S(n*n)+S(l*l)))));G=S(n*q);aa=S(n*G);O=S(l*q);ba=S(l*O);N=S(S(1)-S(aa+ba));q=S(v*q);ca=S(n*q);da=S(s*O);Q=S(ca+da);la=S(l*q);ma=S(s*G);l=S(la-ma);G=S(S(y*N)+S(S(z*Q)+S(A*l)));V=S(S(N*B)+S(S(Q*C)+S(w*l)));l=S(S(N*D)+S(S(Q*E)+S(F*l)));N=S(-ia);P[f+24>>2]=S(S(S(S(i*G)+S(S(p*V)+S(r*l)))*N)-S(U*S(S(t*G)+S(S(u*V)+S(x*l)))))-S(R*S(S(h*G)+S(S(j*V)+S(g*l))));l=S(la+ma);O=S(n*O);Q=S(s*q);n=S(O-Q);G=S(v*q);s=S(S(1)-S(aa+G));v=S(S(y*l)+S(S(z*n)+S(A*s)));q=S(S(l*B)+S(S(n*C)+S(w*s)));n=S(S(l*D)+S(S(n*E)+S(F*s)));P[f+20>>2]=S(S(S(S(i*v)+S(S(p*q)+S(r*n)))*N)-S(U*S(S(t*v)+S(S(u*q)+S(x*n)))))-S(R*S(S(h*v)+S(S(j*q)+S(g*n))));n=S(ca-da);s=S(S(1)-S(ba+G));l=S(O+Q);v=S(S(y*n)+S(S(z*s)+S(A*l)));q=S(S(n*B)+S(S(s*C)+S(w*l)));n=S(S(n*D)+S(S(s*E)+S(F*l)));P[f+16>>2]=S(S(S(S(i*v)+S(S(p*q)+S(r*n)))*N)-S(U*S(S(t*v)+S(S(u*q)+S(x*n)))))-S(R*S(S(h*v)+S(S(j*q)+S(g*n))));ha[L[L[ja>>2]+64>>2]](f+32|0,ja,f+16|0);k=L[ka+12>>2];O=P[k+48>>2];N=P[k+32>>2];Q=P[k+16>>2];G=P[k+8>>2];V=P[k+4>>2];ia=P[k>>2];aa=P[k+56>>2];ba=P[k+52>>2];ca=P[k+40>>2];da=P[k+36>>2];la=P[k+24>>2];ma=P[k+20>>2];oa=P[o+64>>2];v=P[o+56>>2];R=P[o+48>>2];U=P[o+52>>2];n=P[f+40>>2];s=P[f+32>>2];l=P[f+36>>2];k=L[a+12>>2];q=P[k+752>>2];L[e+4>>2]=k;ga=q;q=S(-$);$=S(S(S(S(ea*h)+S(S(X*j)+S(W*g)))+S(S(S(j*q)-S(g*Z))-S(h*Y)))+S(S(n*S(S(y*h)+S(S(B*j)+S(D*g))))+S(S(s*S(S(z*h)+S(S(C*j)+S(E*g))))+S(l*S(S(A*h)+S(S(w*j)+S(F*g)))))));p=S(S(S(S(ea*i)+S(S(X*p)+S(W*r)))+S(S(S(p*q)-S(r*Z))-S(i*Y)))+S(S(n*S(S(y*i)+S(S(B*p)+S(D*r))))+S(S(s*S(S(z*i)+S(S(C*p)+S(E*r))))+S(l*S(S(A*i)+S(S(w*p)+S(F*r)))))));r=S(S(S(S(ea*t)+S(S(X*u)+S(W*x)))+S(S(S(u*q)-S(x*Z))-S(t*Y)))+S(S(n*S(S(y*t)+S(S(B*u)+S(D*x))))+S(S(s*S(S(z*t)+S(S(C*u)+S(E*x))))+S(l*S(S(A*t)+S(S(w*u)+S(F*x)))))));h=S(S(S(v*$)+S(S(R*p)+S(U*r)))-oa);if(ga>h){k=L[ka+12>>2];t=P[k+24>>2];u=P[k+20>>2];x=P[k+40>>2];y=P[k+36>>2];z=P[k+16>>2];A=P[k+32>>2];j=P[o+56>>2];B=P[k+8>>2];g=P[o+48>>2];C=P[k>>2];i=P[o+52>>2];w=P[k+4>>2];L[f+28>>2]=0;P[f+16>>2]=S(B*j)+S(S(C*g)+S(w*i));P[f+24>>2]=S(x*j)+S(S(A*g)+S(i*y));P[f+20>>2]=S(t*j)+S(S(z*g)+S(i*u));L[f+12>>2]=0;j=S($-S(v*h));g=S(p-S(R*h));i=S(r-S(U*h));P[f+8>>2]=S(S(j*ca)+S(S(g*N)+S(i*da)))+aa;P[f+4>>2]=S(S(j*la)+S(S(g*Q)+S(i*ma)))+ba;P[f>>2]=S(S(j*G)+S(S(g*ia)+S(V*i)))+O;ha[L[L[e>>2]+16>>2]](e,f+16|0,f,h)}fa=f+48|0;f=L[a+20>>2];na=na+1|0;if((f|0)>(na|0)){continue}break}}if(!M[a+8|0]|!L[L[a+12>>2]+748>>2]){break a}a=L[e+4>>2];if(!L[a+748>>2]){break a}c=L[a+740>>2];f=L[L[e+8>>2]+8>>2];b=(c|0)==(f|0);k=a;a=L[L[e+12>>2]+8>>2];_a(k,(b?c:a)+4|0,(b?a:f)+4|0)}fa=d+48|0}function Bg(a,b,c,d,e,f,g){var h=S(0),i=0,j=S(0),k=0,l=S(0),m=S(0),n=S(0),o=S(0),p=0,q=S(0),r=S(0),s=0,t=S(0),u=0,v=S(0),w=0,x=0,y=0,z=0,A=S(0),B=0,C=S(0),D=S(0),E=S(0),F=S(0),G=S(0),H=S(0),I=S(0),K=S(0);k=fa-9824|0;fa=k;i=a;a=k+9696|0;Dg(i,b,c,d,f,a,g);c=k+9452|0;L[c>>2]=0;L[c+4>>2]=0;L[k+9444>>2]=0;L[k+9448>>2]=0;L[k+9680>>2]=0;L[k+9684>>2]=0;L[k+9692>>2]=2;g=0;L[k+9460>>2]=0;h=P[e>>2];j=P[e+4>>2];l=P[e+8>>2];L[k+32>>2]=0;P[k+28>>2]=-l;P[k+24>>2]=-j;P[k+20>>2]=-h;a:{b:{c:{switch(Cg(k+9316|0,a,k+20|0)-1|0){case 0:L[k+68>>2]=0;L[k+72>>2]=0;L[k+76>>2]=0;L[k+9296>>2]=0;L[k+20>>2]=9;L[k+9300>>2]=0;L[k+9304>>2]=0;L[k+60>>2]=0;L[k+64>>2]=0;d=0;while(1){c=R(127-d|0,56);a=c+(k+20|0)|0;L[a+2156>>2]=g;L[a+2152>>2]=0;a=a+2108|0;if(g){L[g+44>>2]=a}L[k+9308>>2]=a;i=k+2128|0;g=i+R(126-d|0,56)|0;L[g+44>>2]=0;L[g+48>>2]=a;L[(c+i|0)+44>>2]=g;L[k+9308>>2]=g;d=d+2|0;if((d|0)!=128){continue}break};L[k+9312>>2]=128;h=P[e>>2];j=P[e+4>>2];l=P[e+8>>2];g=0;L[k+16>>2]=0;P[k+12>>2]=-l;P[k+8>>2]=-j;P[k+4>>2]=-h;e=k+20|0;s=fa-32|0;fa=s;d:{e:{B=k+9316|0;i=L[B+372>>2];if(O[i+32>>2]<2){break e}if(!cb(B)){break e}a=L[e+9280>>2];if(a){d=L[e+9292>>2];c=L[e+9284>>2];while(1){p=L[a+48>>2];if(p){L[p+44>>2]=L[a+44>>2]}p=L[a+44>>2];if(p){L[p+48>>2]=L[a+48>>2]}if(L[e+9280>>2]==(a|0)){L[e+9280>>2]=L[a+48>>2]}L[a+44>>2]=0;L[a+48>>2]=L[e+9288>>2];p=L[e+9288>>2];if(p){L[p+44>>2]=a}c=c-1|0;L[e+9288>>2]=a;d=d+1|0;a=L[e+9280>>2];if(a){continue}break}L[e+9292>>2]=d;L[e+9284>>2]=c}L[e+9276>>2]=0;L[e>>2]=0;d=L[i>>2];c=L[i+12>>2];h=P[c+16>>2];n=S(P[d+16>>2]-h);a=L[i+4>>2];j=P[c+20>>2];m=S(P[a+20>>2]-j);p=L[i+8>>2];l=P[c+24>>2];o=S(P[p+24>>2]-l);q=S(P[d+20>>2]-j);r=S(P[a+24>>2]-l);t=S(P[p+16>>2]-h);l=S(P[d+24>>2]-l);h=S(P[a+16>>2]-h);j=S(P[p+20>>2]-j);f:{if(!(S(S(S(S(n*m)*o)+S(S(S(S(S(q*r)*t)+S(S(l*h)*j))-S(S(r*n)*j))-S(S(h*q)*o)))-S(S(m*l)*t))>2]=d;L[i>>2]=a;L[i+16>>2]=oI(L[i+16>>2],L[i+20>>2]);L[i+20>>2]=ga;c=d}c=ud(e,a,c,p,1);p=ud(e,L[i+4>>2],L[i>>2],L[i+12>>2],1);u=ud(e,L[i+8>>2],L[i+4>>2],L[i+12>>2],1);w=ud(e,L[i>>2],L[i+8>>2],L[i+12>>2],1);if(L[e+9284>>2]!=4){break e}d=L[e+9280>>2];a=L[d+48>>2];if(a){h=P[d+16>>2];h=S(h*h);while(1){j=P[a+16>>2];j=S(j*j);i=j>2];if(a){continue}break}}x=L[d+28>>2];y=L[d+24>>2];z=L[d+20>>2];h=P[d+16>>2];r=P[d+12>>2];n=P[d+8>>2];j=P[d+4>>2];l=P[d>>2];L[c+32>>2]=p;J[c+52|0]=0;L[p+32>>2]=c;J[p+52|0]=0;L[c+36>>2]=u;J[c+53|0]=0;L[u+32>>2]=c;J[u+52|0]=1;L[c+40>>2]=w;J[c+54|0]=0;L[w+32>>2]=c;J[w+52|0]=2;L[p+36>>2]=w;J[p+53|0]=2;L[w+40>>2]=p;J[w+54|0]=1;L[p+40>>2]=u;J[p+54|0]=1;L[u+36>>2]=p;J[u+53|0]=2;J[u+54|0]=1;L[u+40>>2]=w;L[w+36>>2]=u;J[w+53|0]=2;L[e>>2]=0;c=0;while(1){g:{h:{i=L[e+9276>>2];if(i>>>0<=63){a=0;L[s+12>>2]=0;L[s+4>>2]=0;L[s+8>>2]=0;L[e+9276>>2]=i+1;c=c+1|0;J[d+55|0]=c;m=P[d+8>>2];o=P[d>>2];q=P[d+4>>2];i=e+(i<<5)|0;L[i+72>>2]=0;v=m;m=S(S(1)/S(_(S(S(m*m)+S(S(o*o)+S(q*q))))));P[i+68>>2]=v*m;P[i- -64>>2]=q*m;p=i+60|0;P[p>>2]=o*m;Xa(s+16|0,B,p);u=L[s+28>>2];L[i+84>>2]=L[s+24>>2];L[i+88>>2]=u;u=L[s+20>>2];L[i+76>>2]=L[s+16>>2];L[i+80>>2]=u;if(!(S(S(S(P[d+8>>2]*P[i+84>>2])+S(S(P[d>>2]*P[i+76>>2])+S(P[d+4>>2]*P[i+80>>2])))-P[d+16>>2])>S(9999999747378752e-20))){L[e>>2]=7;break g}while(1){i=Ag(e,c,p,L[((a<<2)+d|0)+32>>2],M[(a+d|0)+52|0],s+4|0);if(!i){break h}u=a>>>0<2;a=a+1|0;if(u){continue}break}break h}L[e>>2]=6;break g}if(!(i&O[s+12>>2]>2)){L[e>>2]=4;break g}a=L[s+4>>2];i=L[s+8>>2];L[a+36>>2]=i;J[a+53|0]=2;L[i+40>>2]=a;J[i+54|0]=1;a=L[d+48>>2];if(a){L[a+44>>2]=L[d+44>>2]}a=L[d+44>>2];if(a){L[a+48>>2]=L[d+48>>2]}if(L[e+9280>>2]==(d|0)){L[e+9280>>2]=L[d+48>>2]}L[e+9284>>2]=L[e+9284>>2]-1;L[d+44>>2]=0;L[d+48>>2]=L[e+9288>>2];a=L[e+9288>>2];if(a){L[a+44>>2]=d}L[e+9288>>2]=d;L[e+9292>>2]=L[e+9292>>2]+1;d=L[e+9280>>2];a=L[d+48>>2];if(a){h=P[d+16>>2];h=S(h*h);while(1){j=P[a+16>>2];j=S(j*j);i=j>2];if(a){continue}break}}x=L[d+28>>2];y=L[d+24>>2];z=L[d+20>>2];h=P[d+16>>2];r=P[d+12>>2];n=P[d+8>>2];j=P[d+4>>2];l=P[d>>2];if((c|0)!=255){continue}}break}P[e+56>>2]=h;P[e+40>>2]=l;L[e+4>>2]=z;P[e+52>>2]=r;P[e+48>>2]=n;P[e+44>>2]=j;L[e+36>>2]=3;L[e+12>>2]=x;L[e+8>>2]=y;l=S(l*h);m=S(P[y+16>>2]-l);j=S(j*h);o=S(P[x+20>>2]-j);q=S(P[x+16>>2]-l);r=S(P[y+20>>2]-j);t=S(S(m*o)-S(q*r));h=S(n*h);n=S(P[x+24>>2]-h);v=o;o=S(P[y+24>>2]-h);r=S(S(r*n)-S(v*o));n=S(S(o*q)-S(n*m));n=S(_(S(S(t*t)+S(S(r*r)+S(n*n)))));P[e+20>>2]=n;m=S(P[x+16>>2]-l);o=S(P[z+20>>2]-j);q=S(P[z+16>>2]-l);r=S(P[x+20>>2]-j);t=S(S(m*o)-S(q*r));A=S(t*t);v=r;r=S(P[z+24>>2]-h);t=o;o=S(P[x+24>>2]-h);t=S(S(v*r)-S(t*o));m=S(S(o*q)-S(r*m));m=S(_(S(A+S(S(t*t)+S(m*m)))));P[e+24>>2]=m;o=S(P[z+16>>2]-l);q=S(P[y+20>>2]-j);l=S(P[y+16>>2]-l);j=S(P[z+20>>2]-j);r=S(S(o*q)-S(l*j));v=j;j=S(P[y+24>>2]-h);h=S(P[z+24>>2]-h);q=S(S(v*j)-S(q*h));h=S(S(h*l)-S(j*o));j=S(_(S(S(r*r)+S(S(q*q)+S(h*h)))));h=S(j+S(n+m));P[e+28>>2]=j/h;P[e+24>>2]=m/h;P[e+20>>2]=n/h;a=L[e>>2];break d}a=8;L[e>>2]=8;h=S(0);l=S(1);j=S(0);n=P[k+12>>2];m=P[k+4>>2];o=P[k+8>>2];q=S(_(S(S(n*n)+S(S(m*m)+S(o*o)))));if(q>S(0)){l=S(S(1)/q);j=S(l*S(-n));h=S(l*S(-o));l=S(l*S(-m))}L[e+52>>2]=0;L[e+56>>2]=0;P[e+48>>2]=j;P[e+44>>2]=h;P[e+40>>2]=l;L[e+36>>2]=1;c=L[i>>2];L[e+20>>2]=1065353216;L[e+4>>2]=c}fa=s+32|0;if((a|0)==9){break b}i:{if(!L[k+56>>2]){h=S(0);j=S(0);l=S(0);break i}c=k+24|0;l=S(0);j=S(0);h=S(0);while(1){a=L[k+9816>>2];d=k+4|0;e=L[k+9820>>2];i=L[k+9696>>2]+(e>>1)|0;s=g<<2;p=L[s+c>>2];if(e&1){a=L[a+L[i>>2]>>2]}ha[a|0](d,i,p);n=P[(k+s|0)+40>>2];l=S(l+S(n*P[k+12>>2]));j=S(j+S(n*P[k+8>>2]));h=S(h+S(P[k+4>>2]*n));g=g+1|0;if(g>>>0>2]){continue}break}}g=1;L[f>>2]=1;n=P[b+52>>2];m=P[b+24>>2];o=P[b+20>>2];q=P[b+56>>2];r=P[b+40>>2];t=P[b+36>>2];v=P[b+48>>2];A=P[b+8>>2];C=P[b>>2];D=P[b+4>>2];E=P[b+16>>2];F=P[b+32>>2];L[f+16>>2]=0;P[f+12>>2]=q+S(S(l*r)+S(S(h*F)+S(j*t)));P[f+8>>2]=n+S(S(l*m)+S(S(h*E)+S(j*o)));P[f+4>>2]=v+S(S(l*A)+S(S(h*C)+S(j*D)));r=P[b+52>>2];t=P[b+20>>2];v=P[b+24>>2];A=P[b+56>>2];C=P[b+36>>2];D=P[b+40>>2];E=P[b+48>>2];F=P[b+8>>2];G=P[b>>2];H=P[b+4>>2];I=P[b+16>>2];K=P[b+32>>2];m=P[k- -64>>2];o=P[k+68>>2];q=P[k+60>>2];n=P[k+76>>2];L[f+48>>2]=0;L[f+32>>2]=0;P[f+52>>2]=-n;P[f+44>>2]=-o;P[f+40>>2]=-m;P[f+36>>2]=-q;l=S(l-S(n*o));h=S(h-S(q*n));j=S(j-S(n*m));P[f+28>>2]=A+S(S(D*l)+S(S(K*h)+S(C*j)));P[f+24>>2]=r+S(S(l*v)+S(S(h*I)+S(j*t)));P[f+20>>2]=E+S(S(l*F)+S(S(h*G)+S(j*H)));break a;case 1:break c;default:break a}}L[f>>2]=2;break a}L[f>>2]=3}fa=k+9824|0;return g}function kh(a,b,c,d,e,f){var g=0,h=0,i=0,j=S(0),k=S(0),l=S(0),m=S(0),n=S(0),o=S(0),p=S(0),q=S(0),r=S(0),s=S(0),t=S(0),u=S(0),v=S(0),w=S(0),x=0,y=S(0),z=S(0),A=S(0),B=S(0),C=S(0),D=S(0),E=S(0),F=S(0),G=S(0),H=S(0),I=0,K=0,N=S(0),O=S(0),Q=S(0);g=fa-640|0;fa=g;h=L[d+12>>2];x=L[d+4>>2];i=L[x+4>>2];a:{if((i|0)<=19){P[g+636>>2]=f;L[g+632>>2]=0;L[g+464>>2]=6864;P[g+628>>2]=P[e+4>>2];J[g+436|0]=0;L[g+412>>2]=953267991;L[g+20>>2]=18492;i=g+80|0;L[i+20>>2]=0;L[i+16>>2]=x;L[i+12>>2]=a;L[i+8>>2]=g+20;L[i+4>>2]=g+104;L[i>>2]=18268;b:{if(!(ha[L[L[i>>2]+8>>2]](i,b,c,h,h,g+464|0)|0)){break b}f=P[g+604>>2];j=P[g+596>>2];k=P[g+600>>2];l=S(S(f*f)+S(S(j*j)+S(k*k)));if(!(l>S(9999999747378752e-20))){break b}m=P[g+628>>2];if(!(m>2])){break b}n=f;f=S(S(1)/S(_(l)));P[g+604>>2]=n*f;P[g+600>>2]=k*f;P[g+596>>2]=j*f;a=L[d+8>>2];L[g+40>>2]=0;L[g+36>>2]=a;a=L[g+608>>2];L[g+52>>2]=L[g+604>>2];L[g+56>>2]=a;a=L[g+596>>2];b=L[g+600>>2];c=L[g+624>>2];L[g+68>>2]=L[g+620>>2];L[g+72>>2]=c;L[g+44>>2]=a;L[g+48>>2]=b;a=L[g+616>>2];L[g+60>>2]=L[g+612>>2];L[g+64>>2]=a;P[g+76>>2]=m;S(ha[L[L[e>>2]+12>>2]](e,g+36|0,1))}break a}K=i-21|0;if(K>>>0<=8){c:{switch(K|0){case 0:j=P[h+20>>2];k=P[h+36>>2];p=P[h+52>>2];l=P[h+24>>2];q=P[h+56>>2];m=P[h+40>>2];n=P[h+32>>2];v=P[h>>2];w=P[h+16>>2];r=P[h+4>>2];o=P[h+8>>2];s=P[h+48>>2];t=P[b+52>>2];y=P[b+56>>2];u=P[b+48>>2];L[g+48>>2]=0;s=S(-s);z=S(S(S(o*s)-S(l*p))-S(m*q));P[g+44>>2]=z+S(S(y*m)+S(S(u*o)+S(l*t)));A=S(S(S(r*s)-S(j*p))-S(k*q));P[g+40>>2]=A+S(S(y*k)+S(S(u*r)+S(j*t)));s=S(S(S(v*s)-S(w*p))-S(n*q));P[g+36>>2]=s+S(S(y*n)+S(S(u*v)+S(w*t)));p=P[c+52>>2];q=P[c+56>>2];t=P[c+48>>2];L[g+92>>2]=0;P[g+88>>2]=z+S(S(q*m)+S(S(t*o)+S(l*p)));P[g+84>>2]=A+S(S(q*k)+S(S(t*r)+S(j*p)));P[g+80>>2]=s+S(S(q*n)+S(S(t*v)+S(w*p)));p=P[c+20>>2];q=P[c+36>>2];t=P[c+24>>2];y=P[c+40>>2];u=P[c+32>>2];s=P[c>>2];z=P[c+16>>2];A=P[c+4>>2];B=P[c+8>>2];L[g+508>>2]=0;L[g+512>>2]=0;L[g+492>>2]=0;L[g+516>>2]=0;L[g+520>>2]=0;L[g+524>>2]=0;P[g+504>>2]=S(y*m)+S(S(B*o)+S(l*t));P[g+500>>2]=S(q*m)+S(S(A*o)+S(l*p));P[g+488>>2]=S(y*k)+S(S(B*r)+S(j*t));P[g+484>>2]=S(q*k)+S(S(A*r)+S(j*p));L[g+476>>2]=0;P[g+496>>2]=S(u*m)+S(S(s*o)+S(l*z));P[g+480>>2]=S(u*k)+S(S(s*r)+S(j*z));P[g+472>>2]=S(y*n)+S(S(B*v)+S(w*t));P[g+468>>2]=S(q*n)+S(S(A*v)+S(w*p));P[g+464>>2]=S(u*n)+S(S(s*v)+S(w*z));d=L[d+8>>2];b=El(g+104|0,a,b,c,h,S(ha[L[L[x>>2]+48>>2]](x)));L[b+220>>2]=x;L[b+216>>2]=d;L[b+212>>2]=e;L[b>>2]=7652;j=P[e+4>>2];P[b+208>>2]=f;P[b+200>>2]=j;c=g+20|0;d=g+4|0;ha[L[L[a>>2]+8>>2]](a,g+464|0,c,d);a=fa-16|0;fa=a;e=L[x+48>>2];L[a+12>>2]=b;L[a+8>>2]=e;L[a+4>>2]=12556;e=a+4|0;h=g+36|0;i=g+80|0;b=L[x+52>>2];d:{if(M[b+60|0]){Em(b,e,h,i,c,d,L[b+56>>2]);break d}Fm(b,e,h,i,c,d)}fa=a+16|0;break a;case 7:P[g+276>>2]=f;L[g+272>>2]=0;L[g+104>>2]=6864;P[g+268>>2]=P[e+4>>2];i=g+36|0;L[i+20>>2]=x;L[i+16>>2]=0;L[i+12>>2]=a;L[i+4>>2]=0;L[i+8>>2]=0;L[i>>2]=18268;e:{if(!(ha[L[L[i>>2]+8>>2]](i,b,c,h,h,g+104|0)|0)){break e}f=P[g+244>>2];j=P[g+236>>2];k=P[g+240>>2];l=S(S(f*f)+S(S(j*j)+S(k*k)));if(!(l>S(9999999747378752e-20))){break e}m=P[g+268>>2];if(!(m>2])){break e}n=f;f=S(S(1)/S(_(l)));P[g+244>>2]=n*f;P[g+240>>2]=k*f;P[g+236>>2]=j*f;a=L[d+8>>2];L[g+468>>2]=0;L[g+464>>2]=a;a=L[g+248>>2];L[g+480>>2]=L[g+244>>2];L[g+484>>2]=a;a=L[g+236>>2];b=L[g+240>>2];c=L[g+264>>2];L[g+496>>2]=L[g+260>>2];L[g+500>>2]=c;L[g+472>>2]=a;L[g+476>>2]=b;a=L[g+256>>2];L[g+488>>2]=L[g+252>>2];L[g+492>>2]=a;P[g+504>>2]=m;S(ha[L[L[e>>2]+12>>2]](e,g+464|0,1))}break a;default:break c}}t=P[b+52>>2];y=P[b+56>>2];m=P[h+52>>2];u=P[h+56>>2];s=P[c+52>>2];z=P[c+56>>2];l=P[h+20>>2];n=P[h+36>>2];v=P[h+24>>2];w=P[h+40>>2];A=P[b+48>>2];Q=P[h+48>>2];B=P[c+48>>2];k=P[h+32>>2];r=P[h>>2];o=P[h+16>>2];p=P[h+4>>2];q=P[h+8>>2];j=P[c+20>>2];C=P[c+36>>2];D=P[c+24>>2];E=P[c+40>>2];F=P[c+32>>2];G=P[c>>2];H=P[c+16>>2];N=P[c+4>>2];O=P[c+8>>2];L[g+508>>2]=0;L[g+512>>2]=0;L[g+492>>2]=0;L[g+516>>2]=0;L[g+520>>2]=0;L[g+524>>2]=0;P[g+504>>2]=S(E*w)+S(S(O*q)+S(v*D));P[g+500>>2]=S(C*w)+S(S(N*q)+S(v*j));P[g+488>>2]=S(E*n)+S(S(O*p)+S(l*D));P[g+484>>2]=S(C*n)+S(S(N*p)+S(l*j));L[g+476>>2]=0;P[g+496>>2]=S(F*w)+S(S(G*q)+S(v*H));P[g+480>>2]=S(F*n)+S(S(G*p)+S(l*H));P[g+472>>2]=S(E*k)+S(S(O*r)+S(o*D));P[g+468>>2]=S(C*k)+S(S(N*r)+S(o*j));P[g+464>>2]=S(F*k)+S(S(G*r)+S(o*H));d=L[d+8>>2];b=El(g+104|0,a,b,c,h,S(ha[L[L[x>>2]+48>>2]](x)));L[b+220>>2]=x;L[b+216>>2]=d;L[b+212>>2]=e;L[b>>2]=7864;j=P[e+4>>2];P[b+208>>2]=f;P[b+200>>2]=j;ha[L[L[a>>2]+8>>2]](a,g+464|0,g+36|0,g+80|0);L[g+32>>2]=0;f=S(-Q);C=S(S(S(q*f)-S(v*m))-S(w*u));D=S(S(S(p*f)-S(l*m))-S(n*u));j=S(D+S(S(z*n)+S(S(B*p)+S(l*s))));f=S(S(S(r*f)-S(o*m))-S(k*u));u=S(f+S(S(y*k)+S(S(A*r)+S(o*t))));m=u;k=S(f+S(S(z*k)+S(S(B*r)+S(o*s))));if(k>2]=k;m=k}o=S(D+S(S(y*n)+S(S(A*p)+S(l*t))));n=o;if(j>2]=j;n=j}r=S(C+S(S(y*w)+S(S(A*q)+S(v*t))));f=r;l=S(C+S(S(z*w)+S(S(B*q)+S(v*s))));if(l>2]=l;f=l}L[g+16>>2]=0;P[g+20>>2]=P[g+36>>2]+m;P[g+24>>2]=P[g+40>>2]+n;P[g+28>>2]=P[g+44>>2]+f;P[g+4>>2]=P[g+80>>2]+(k>u?k:u);P[g+8>>2]=P[g+84>>2]+(j>o?j:o);P[g+12>>2]=P[g+88>>2]+(l>r?l:r);ha[L[L[x>>2]+64>>2]](x,b,g+20|0,g+4|0);break a}if((i|0)!=31){break a}wa(3236);if(L[x+16>>2]>0){while(1){i=L[x+24>>2]+R(I,80)|0;K=L[i+64>>2];p=P[i+56>>2];q=P[i+48>>2];t=P[i+52>>2];y=P[i+32>>2];u=P[i>>2];s=P[i+16>>2];z=P[i+36>>2];A=P[i+4>>2];B=P[i+20>>2];C=P[i+40>>2];D=P[i+8>>2];E=P[i+24>>2];F=P[h+48>>2];G=P[h+52>>2];H=P[h+56>>2];j=P[h+8>>2];k=P[h>>2];l=P[h+4>>2];m=P[h+24>>2];n=P[h+16>>2];v=P[h+20>>2];w=P[h+40>>2];r=P[h+32>>2];o=P[h+36>>2];L[g+164>>2]=0;L[g+148>>2]=0;L[g+132>>2]=0;L[g+116>>2]=0;P[g+144>>2]=S(C*w)+S(S(D*r)+S(E*o));P[g+140>>2]=S(z*w)+S(S(A*r)+S(B*o));P[g+136>>2]=S(y*w)+S(S(u*r)+S(s*o));P[g+128>>2]=S(C*m)+S(S(D*n)+S(E*v));P[g+124>>2]=S(z*m)+S(S(A*n)+S(B*v));P[g+120>>2]=S(y*m)+S(S(u*n)+S(s*v));P[g+112>>2]=S(C*j)+S(S(D*k)+S(E*l));P[g+108>>2]=S(z*j)+S(S(A*k)+S(B*l));P[g+104>>2]=S(y*j)+S(S(u*k)+S(s*l));P[g+160>>2]=H+S(S(p*w)+S(S(q*r)+S(t*o)));P[g+156>>2]=G+S(S(p*m)+S(S(q*n)+S(t*v)));P[g+152>>2]=F+S(S(p*j)+S(S(q*k)+S(t*l)));L[g+52>>2]=I;L[g+36>>2]=8080;L[g+44>>2]=-65535;L[g+48>>2]=e;P[g+40>>2]=P[e+4>>2];i=L[d+8>>2];L[g+484>>2]=I;L[g+480>>2]=-1;L[g+472>>2]=i;L[g+468>>2]=K;L[g+464>>2]=d;L[g+476>>2]=g+104;kh(a,b,c,g+464|0,g+36|0,f);I=I+1|0;if((I|0)>2]){continue}break}}va()}fa=g+640|0}function dB(a,b,c,d,e,f,g,h,i,j){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;i=i|0;j=j|0;var k=S(0),l=S(0),m=0,n=0,o=0,p=0,q=0,r=0;a:{if(!(J[i+64|0]&1)){break a}p=L[a+68>>2];n=L[a+28>>2];m=L[a+48>>2];if((m|0)>0){e=R(L[a+192>>2],1664525)+1013904223|0;b:{if((m|0)==1){break b}d=L[a+136>>2];c=L[d+4>>2];e=R(e,1664525)+1013904223|0;f=e^e>>>16;f=f>>>8^f;f=f>>>4^f;f=f>>>2^f;f=d+(((f>>>1^f)&1)<<2)|0;L[d+4>>2]=L[f>>2];L[f>>2]=c;if((m|0)==2){break b}c=L[d+8>>2];e=R(e,1664525)+1013904223|0;f=e^e>>>16;f=f>>>8^f;f=f>>>4^f;f=d+(((f>>>2^f)>>>0)%3<<2)|0;L[d+8>>2]=L[f>>2];L[f>>2]=c;if((m|0)==3){break b}c=4;f=L[d+12>>2];e=R(e,1664525)+1013904223|0;j=e^e>>>16;j=j>>>8^j;j=j>>>4^j;j=d+(((j>>>2^j)&3)<<2)|0;L[d+12>>2]=L[j>>2];L[j>>2]=f;if((m|0)==4){break b}while(1){f=c;c=f+1|0;j=d+(f<<2)|0;r=L[j>>2];q=j;e=R(e,1664525)+1013904223|0;j=e;c:{if(f>>>0>65535){break c}o=e>>>16^e;j=o;if(f>>>0>255){break c}o=o^o>>>8;j=o;if(f>>>0>15){break c}j=o^o>>>4}f=((j>>>0)%(c>>>0)<<2)+d|0;L[q>>2]=L[f>>2];L[f>>2]=r;if((c|0)!=(m|0)){continue}break}}L[a+192>>2]=e}if(L[i+20>>2]<=(b|0)){break a}if((n|0)>0){e=R(L[a+192>>2],1664525)+1013904223|0;d:{if((n|0)==1){break d}d=L[a+116>>2];c=L[d+4>>2];e=R(e,1664525)+1013904223|0;f=e^e>>>16;f=f>>>8^f;f=f>>>4^f;f=f>>>2^f;f=d+(((f>>>1^f)&1)<<2)|0;L[d+4>>2]=L[f>>2];L[f>>2]=c;if((n|0)==2){break d}c=L[d+8>>2];e=R(e,1664525)+1013904223|0;f=e^e>>>16;f=f>>>8^f;f=f>>>4^f;f=d+(((f>>>2^f)>>>0)%3<<2)|0;L[d+8>>2]=L[f>>2];L[f>>2]=c;if((n|0)==3){break d}c=4;f=L[d+12>>2];e=R(e,1664525)+1013904223|0;j=e^e>>>16;j=j>>>8^j;j=j>>>4^j;j=d+(((j>>>2^j)&3)<<2)|0;L[d+12>>2]=L[j>>2];L[j>>2]=f;if((n|0)==4){break d}while(1){f=c;c=f+1|0;j=d+(f<<2)|0;o=L[j>>2];q=j;e=R(e,1664525)+1013904223|0;j=e;e:{if(f>>>0>65535){break e}m=e>>>16^e;j=m;if(f>>>0>255){break e}m=m^m>>>8;j=m;if(f>>>0>15){break e}j=m^m>>>4}f=((j>>>0)%(c>>>0)<<2)+d|0;L[q>>2]=L[f>>2];L[f>>2]=o;if((c|0)!=(n|0)){continue}break}}L[a+192>>2]=e}if((p|0)<=0){break a}e=R(L[a+192>>2],1664525)+1013904223|0;f:{if((p|0)==1){break f}d=L[a+156>>2];c=L[d+4>>2];e=R(e,1664525)+1013904223|0;f=e^e>>>16;f=f>>>8^f;f=f>>>4^f;f=f>>>2^f;f=d+(((f>>>1^f)&1)<<2)|0;L[d+4>>2]=L[f>>2];L[f>>2]=c;if((p|0)==2){break f}c=L[d+8>>2];e=R(e,1664525)+1013904223|0;f=e^e>>>16;f=f>>>8^f;f=f>>>4^f;f=d+(((f>>>2^f)>>>0)%3<<2)|0;L[d+8>>2]=L[f>>2];L[f>>2]=c;if((p|0)==3){break f}c=4;f=L[d+12>>2];e=R(e,1664525)+1013904223|0;j=e^e>>>16;j=j>>>8^j;j=j>>>4^j;j=d+(((j>>>2^j)&3)<<2)|0;L[d+12>>2]=L[j>>2];L[j>>2]=f;if((p|0)==4){break f}while(1){f=c;c=f+1|0;j=d+(f<<2)|0;m=L[j>>2];o=j;e=R(e,1664525)+1013904223|0;j=e;g:{if(f>>>0>65535){break g}n=e>>>16^e;j=n;if(f>>>0>255){break g}n=n^n>>>8;j=n;if(f>>>0>15){break g}j=n^n>>>4}f=((j>>>0)%(c>>>0)<<2)+d|0;L[o>>2]=L[f>>2];L[f>>2]=m;if((c|0)!=(p|0)){continue}break}}L[a+192>>2]=e}e=L[a+48>>2];h:{i:{if(J[i+65|0]&1){if((e|0)>0){c=0;while(1){d=L[a+56>>2]+R(L[L[a+136>>2]+(c<<2)>>2],152)|0;if(L[d+136>>2]>(b|0)){e=L[a+16>>2];Qb(e+R(L[d+144>>2],244)|0,e+R(L[d+148>>2],244)|0,d);e=L[a+48>>2]}c=c+1|0;if((e|0)>(c|0)){continue}break}}if(L[i+20>>2]<=(b|0)){break h}if((h|0)>0){e=0;while(1){b=(e<<2)+g|0;c=L[b>>2];if(M[c+20|0]){c=vb(a,L[c+28>>2],P[i+12>>2]);d=vb(a,L[L[b>>2]+32>>2],P[i+12>>2]);b=L[b>>2];f=R(c,244);c=L[a+16>>2];ha[L[L[b>>2]+24>>2]](b,f+c|0,c+R(d,244)|0,P[i+12>>2])}e=e+1|0;if((h|0)!=(e|0)){continue}break}}d=L[a+28>>2];b=L[i+64>>2];if(!(b&512)){break i}if((d|0)<=0){break h}e=b&16?2:1;c=0;while(1){f=L[a+16>>2];b=L[a+36>>2]+R(L[L[a+116>>2]+(c<<2)>>2],152)|0;tg(f+R(L[b+144>>2],244)|0,f+R(L[b+148>>2],244)|0,b);k=P[b+100>>2];f=k>S(0);j:{if(!f){break j}g=R(c,e)<<2;b=L[a+76>>2]+R(L[g+L[a+156>>2]>>2],152)|0;l=P[b+104>>2];P[b+124>>2]=k*l;P[b+120>>2]=k*S(-l);h=L[a+16>>2];Qb(h+R(L[b+144>>2],244)|0,h+R(L[b+148>>2],244)|0,b);if(!f|!(L[i+64>>2]&16)){break j}b=L[a+76>>2]+R(L[(g+L[a+156>>2]|0)+4>>2],152)|0;l=P[b+104>>2];P[b+124>>2]=k*l;P[b+120>>2]=k*S(-l);f=L[a+16>>2];Qb(f+R(L[b+144>>2],244)|0,f+R(L[b+148>>2],244)|0,b)}c=c+1|0;if((d|0)!=(c|0)){continue}break}break h}if((e|0)>0){c=0;while(1){d=L[a+56>>2]+R(L[L[a+136>>2]+(c<<2)>>2],152)|0;if(L[d+136>>2]>(b|0)){e=L[a+16>>2];Qb(e+R(L[d+144>>2],244)|0,e+R(L[d+148>>2],244)|0,d);e=L[a+48>>2]}c=c+1|0;if((e|0)>(c|0)){continue}break}}if(L[i+20>>2]<=(b|0)){break h}if((h|0)>0){e=0;while(1){b=(e<<2)+g|0;c=L[b>>2];if(M[c+20|0]){c=vb(a,L[c+28>>2],P[i+12>>2]);d=vb(a,L[L[b>>2]+32>>2],P[i+12>>2]);b=L[b>>2];f=R(c,244);c=L[a+16>>2];ha[L[L[b>>2]+24>>2]](b,f+c|0,c+R(d,244)|0,P[i+12>>2])}e=e+1|0;if((h|0)!=(e|0)){continue}break}}c=L[a+28>>2];if((c|0)>0){e=0;while(1){d=L[a+16>>2];b=L[a+36>>2]+R(L[L[a+116>>2]+(e<<2)>>2],152)|0;tg(d+R(L[b+144>>2],244)|0,d+R(L[b+148>>2],244)|0,b);e=e+1|0;if((c|0)!=(e|0)){continue}break}}d=L[a+68>>2];if((d|0)>0){c=0;while(1){b=L[a+76>>2]+R(L[L[a+156>>2]+(c<<2)>>2],152)|0;k=P[(L[a+36>>2]+R(L[b+140>>2],152)|0)+100>>2];if(k>S(0)){l=P[b+104>>2];P[b+124>>2]=k*l;P[b+120>>2]=k*S(-l);e=L[a+16>>2];Qb(e+R(L[b+144>>2],244)|0,e+R(L[b+148>>2],244)|0,b)}c=c+1|0;if((d|0)!=(c|0)){continue}break}}d=L[a+88>>2];if((d|0)<=0){break h}c=0;while(1){b=L[a+96>>2]+R(c,152)|0;k=P[(L[a+36>>2]+R(L[b+140>>2],152)|0)+100>>2];if(k>S(0)){l=k;k=P[b+104>>2];l=S(l*k);k=k>2]=k;P[b+120>>2]=-k;e=L[a+16>>2];Qb(e+R(L[b+144>>2],244)|0,e+R(L[b+148>>2],244)|0,b)}c=c+1|0;if((d|0)!=(c|0)){continue}break}break h}if((d|0)>0){e=0;while(1){c=L[a+16>>2];b=L[a+36>>2]+R(L[L[a+116>>2]+(e<<2)>>2],152)|0;tg(c+R(L[b+144>>2],244)|0,c+R(L[b+148>>2],244)|0,b);e=e+1|0;if((d|0)!=(e|0)){continue}break}}d=L[a+68>>2];if((d|0)>0){c=0;while(1){b=L[a+76>>2]+R(L[L[a+156>>2]+(c<<2)>>2],152)|0;k=P[(L[a+36>>2]+R(L[b+140>>2],152)|0)+100>>2];if(k>S(0)){l=P[b+104>>2];P[b+124>>2]=k*l;P[b+120>>2]=k*S(-l);e=L[a+16>>2];Qb(e+R(L[b+144>>2],244)|0,e+R(L[b+148>>2],244)|0,b)}c=c+1|0;if((d|0)!=(c|0)){continue}break}}d=L[a+88>>2];if((d|0)<=0){break h}c=0;while(1){b=L[a+96>>2]+R(c,152)|0;k=P[(L[a+36>>2]+R(L[b+140>>2],152)|0)+100>>2];if(k>S(0)){l=k;k=P[b+104>>2];l=S(l*k);k=k>2]=k;P[b+120>>2]=-k;e=L[a+16>>2];Qb(e+R(L[b+144>>2],244)|0,e+R(L[b+148>>2],244)|0,b)}c=c+1|0;if((d|0)!=(c|0)){continue}break}}return S(S(0))}function vb(a,b,c){var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=S(0),l=0,m=S(0),n=S(0),o=0,p=S(0),q=S(0),r=S(0),s=S(0),t=S(0),u=S(0);g=fa-256|0;fa=g;h=L[b+212>>2];a:{if((h|0)>=0){break a}b:{h=L[b+236>>2];if(!(h&2)){break b}h=h<<30>>31&b;if(P[h+344>>2]==S(0)&!(M[h+204|0]&2)){break b}h=L[a+8>>2];pa(g+12|0,0,244);d=h;e=d;c:{if(L[a+12>>2]!=(d|0)){break c}l=d?d<<1:1;e=h;if((l|0)<=(d|0)){break c}if(l){L[8513]=L[8513]+1;i=ha[L[6798]](R(l,244),16)|0;d=L[a+8>>2]}else{d=h}if((d|0)>0){while(1){e=R(o,244);f=e+i|0;e=e+L[a+16>>2]|0;j=L[e+4>>2];L[f>>2]=L[e>>2];L[f+4>>2]=j;j=L[e+12>>2];L[f+8>>2]=L[e+8>>2];L[f+12>>2]=j;j=L[e+28>>2];L[f+24>>2]=L[e+24>>2];L[f+28>>2]=j;j=L[e+20>>2];L[f+16>>2]=L[e+16>>2];L[f+20>>2]=j;j=L[e+44>>2];L[f+40>>2]=L[e+40>>2];L[f+44>>2]=j;j=L[e+36>>2];L[f+32>>2]=L[e+32>>2];L[f+36>>2]=j;j=L[e+52>>2];L[f+48>>2]=L[e+48>>2];L[f+52>>2]=j;j=L[e+60>>2];L[f+56>>2]=L[e+56>>2];L[f+60>>2]=j;qa(f- -64|0,e- -64|0,180);o=o+1|0;if((d|0)!=(o|0)){continue}break}}d=L[a+16>>2];if(!(d?!d|!M[a+20|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](d)}L[a+16>>2]=i;J[a+20|0]=1;L[a+12>>2]=l;e=L[a+8>>2]}L[a+8>>2]=e+1;e=R(h,244);d=e+L[a+16>>2]|0;L[d>>2]=0;L[d+4>>2]=0;L[d+8>>2]=0;L[d+12>>2]=0;f=L[g+40>>2];L[d+24>>2]=L[g+36>>2];L[d+28>>2]=f;f=L[g+32>>2];L[d+16>>2]=L[g+28>>2];L[d+20>>2]=f;f=L[g+48>>2];L[d+32>>2]=L[g+44>>2];L[d+36>>2]=f;f=L[g+56>>2];L[d+40>>2]=L[g+52>>2];L[d+44>>2]=f;f=L[g+64>>2];L[d+48>>2]=L[g+60>>2];L[d+52>>2]=f;f=L[g+72>>2];L[d+56>>2]=L[g+68>>2];L[d+60>>2]=f;qa(d- -64|0,g+76|0,180);d=e+L[a+16>>2]|0;a=b?L[b+236>>2]<<30>>31&b:0;L[d+64>>2]=0;L[d+68>>2]=0;L[d+144>>2]=0;L[d+148>>2]=0;L[d+88>>2]=0;L[d+92>>2]=0;L[d+80>>2]=0;L[d+84>>2]=0;L[d+72>>2]=0;L[d+76>>2]=0;L[d+152>>2]=0;L[d+156>>2]=0;L[d+160>>2]=0;L[d+164>>2]=0;L[d+168>>2]=0;L[d+172>>2]=0;d:{if(a){e=L[a+8>>2];L[d>>2]=L[a+4>>2];L[d+4>>2]=e;e=L[a+16>>2];L[d+8>>2]=L[a+12>>2];L[d+12>>2]=e;e=L[a+32>>2];L[d+24>>2]=L[a+28>>2];L[d+28>>2]=e;e=L[a+24>>2];L[d+16>>2]=L[a+20>>2];L[d+20>>2]=e;e=L[a+48>>2];L[d+40>>2]=L[a+44>>2];L[d+44>>2]=e;e=L[a+40>>2];L[d+32>>2]=L[a+36>>2];L[d+36>>2]=e;e=L[a+64>>2];L[d+56>>2]=L[a+60>>2];L[d+60>>2]=e;e=L[a+56>>2];L[d+48>>2]=L[a+52>>2];L[d+52>>2]=e;m=P[a+352>>2];n=P[a+356>>2];p=P[a+348>>2];k=P[a+344>>2];L[d+240>>2]=a;L[d+140>>2]=0;P[d+136>>2]=k*n;P[d+132>>2]=k*m;P[d+128>>2]=k*p;e=L[a+556>>2];L[d+104>>2]=L[a+552>>2];L[d+108>>2]=e;e=L[a+548>>2];L[d+96>>2]=L[a+544>>2];L[d+100>>2]=e;e=L[a+360>>2];L[d+120>>2]=L[a+356>>2];L[d+124>>2]=e;e=L[a+352>>2];L[d+112>>2]=L[a+348>>2];L[d+116>>2]=e;e=L[a+324>>2];L[d+184>>2]=L[a+320>>2];L[d+188>>2]=e;e=L[a+316>>2];L[d+176>>2]=L[a+312>>2];L[d+180>>2]=e;e=L[a+340>>2];L[d+200>>2]=L[a+336>>2];L[d+204>>2]=e;e=L[a+332>>2];L[d+192>>2]=L[a+328>>2];L[d+196>>2]=e;m=P[a+416>>2];n=P[a+420>>2];p=P[a+412>>2];k=P[a+344>>2];L[d+220>>2]=0;P[d+216>>2]=S(k*n)*c;P[d+212>>2]=S(k*m)*c;P[d+208>>2]=S(k*p)*c;p=P[a+272>>2];q=P[a+288>>2];r=P[a+304>>2];s=P[a+280>>2];t=P[a+296>>2];u=P[a+264>>2];k=P[a+436>>2];m=P[a+428>>2];n=P[a+432>>2];P[d+228>>2]=S(S(P[a+300>>2]*k)+S(S(P[a+268>>2]*m)+S(n*P[a+284>>2])))*c;P[d+224>>2]=S(S(t*k)+S(S(u*m)+S(s*n)))*c;c=S(S(S(r*k)+S(S(p*m)+S(n*q)))*c);break d}L[d+4>>2]=0;L[d+8>>2]=0;L[d>>2]=1065353216;L[d+240>>2]=0;L[d+128>>2]=0;L[d+132>>2]=0;L[d+112>>2]=1065353216;L[d+116>>2]=1065353216;L[d+96>>2]=1065353216;L[d+100>>2]=1065353216;L[d+176>>2]=0;L[d+180>>2]=0;L[d+12>>2]=0;L[d+16>>2]=0;L[d+24>>2]=0;L[d+28>>2]=0;L[d+20>>2]=1065353216;L[d+32>>2]=0;L[d+36>>2]=0;L[d+44>>2]=0;L[d+48>>2]=0;L[d+40>>2]=1065353216;L[d+52>>2]=0;L[d+56>>2]=0;L[d+60>>2]=0;L[d+136>>2]=0;L[d+140>>2]=0;L[d+120>>2]=1065353216;L[d+124>>2]=0;L[d+104>>2]=1065353216;L[d+108>>2]=0;L[d+224>>2]=0;L[d+228>>2]=0;L[d+216>>2]=0;L[d+220>>2]=0;L[d+208>>2]=0;L[d+212>>2]=0;L[d+200>>2]=0;L[d+204>>2]=0;L[d+192>>2]=0;L[d+196>>2]=0;L[d+184>>2]=0;L[d+188>>2]=0;c=S(0)}L[d+236>>2]=0;P[d+232>>2]=c;L[b+212>>2]=h;break a}h=L[a+188>>2];if((h|0)>=0){break a}b=L[a+8>>2];L[a+188>>2]=b;pa(g+12|0,0,244);d=b;e:{if((b|0)!=L[a+12>>2]){break e}l=b?b<<1:1;d=b;if((l|0)<=(b|0)){break e}if(l){L[8513]=L[8513]+1;o=ha[L[6798]](R(l,244),16)|0;d=L[a+8>>2]}else{d=b}if((d|0)>0){h=0;while(1){e=R(h,244);f=e+o|0;e=e+L[a+16>>2]|0;i=L[e+4>>2];L[f>>2]=L[e>>2];L[f+4>>2]=i;i=L[e+12>>2];L[f+8>>2]=L[e+8>>2];L[f+12>>2]=i;i=L[e+28>>2];L[f+24>>2]=L[e+24>>2];L[f+28>>2]=i;i=L[e+20>>2];L[f+16>>2]=L[e+16>>2];L[f+20>>2]=i;i=L[e+44>>2];L[f+40>>2]=L[e+40>>2];L[f+44>>2]=i;i=L[e+36>>2];L[f+32>>2]=L[e+32>>2];L[f+36>>2]=i;i=L[e+52>>2];L[f+48>>2]=L[e+48>>2];L[f+52>>2]=i;i=L[e+60>>2];L[f+56>>2]=L[e+56>>2];L[f+60>>2]=i;qa(f- -64|0,e- -64|0,180);h=h+1|0;if((d|0)!=(h|0)){continue}break}}h=L[a+16>>2];if(!(h?!h|!M[a+20|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](h)}L[a+16>>2]=o;J[a+20|0]=1;L[a+12>>2]=l;d=L[a+8>>2]}L[a+8>>2]=d+1;h=R(b,244);b=h+L[a+16>>2]|0;L[b>>2]=0;L[b+4>>2]=0;L[b+8>>2]=0;L[b+12>>2]=0;d=L[g+40>>2];L[b+24>>2]=L[g+36>>2];L[b+28>>2]=d;d=L[g+32>>2];L[b+16>>2]=L[g+28>>2];L[b+20>>2]=d;d=L[g+48>>2];L[b+32>>2]=L[g+44>>2];L[b+36>>2]=d;d=L[g+56>>2];L[b+40>>2]=L[g+52>>2];L[b+44>>2]=d;d=L[g+64>>2];L[b+48>>2]=L[g+60>>2];L[b+52>>2]=d;d=L[g+72>>2];L[b+56>>2]=L[g+68>>2];L[b+60>>2]=d;qa(b- -64|0,g+76|0,180);b=h+L[a+16>>2]|0;L[b+64>>2]=0;L[b+68>>2]=0;L[b+144>>2]=0;L[b+148>>2]=0;L[b+4>>2]=0;L[b+8>>2]=0;L[b>>2]=1065353216;L[b+88>>2]=0;L[b+92>>2]=0;L[b+80>>2]=0;L[b+84>>2]=0;L[b+72>>2]=0;L[b+76>>2]=0;L[b+152>>2]=0;L[b+156>>2]=0;L[b+160>>2]=0;L[b+164>>2]=0;L[b+168>>2]=0;L[b+172>>2]=0;L[b+12>>2]=0;L[b+16>>2]=0;L[b+24>>2]=0;L[b+28>>2]=0;L[b+20>>2]=1065353216;L[b+32>>2]=0;L[b+36>>2]=0;L[b+44>>2]=0;L[b+48>>2]=0;L[b+40>>2]=1065353216;L[b+52>>2]=0;L[b+56>>2]=0;L[b+60>>2]=0;L[b+136>>2]=0;L[b+140>>2]=0;L[b+240>>2]=0;L[b+128>>2]=0;L[b+132>>2]=0;L[b+120>>2]=1065353216;L[b+124>>2]=0;L[b+112>>2]=1065353216;L[b+116>>2]=1065353216;L[b+104>>2]=1065353216;L[b+108>>2]=0;L[b+96>>2]=1065353216;L[b+100>>2]=1065353216;L[b+232>>2]=0;L[b+236>>2]=0;L[b+224>>2]=0;L[b+228>>2]=0;L[b+216>>2]=0;L[b+220>>2]=0;L[b+208>>2]=0;L[b+212>>2]=0;L[b+200>>2]=0;L[b+204>>2]=0;L[b+192>>2]=0;L[b+196>>2]=0;L[b+184>>2]=0;L[b+188>>2]=0;L[b+176>>2]=0;L[b+180>>2]=0;h=L[a+188>>2]}fa=g+256|0;return h}function wk(a){var b=0,c=0,d=0,e=S(0),f=S(0),g=0,h=S(0),i=S(0),j=S(0),k=S(0),l=S(0),m=S(0),n=S(0),o=S(0),p=S(0),q=S(0),r=0,s=S(0),t=S(0),u=0,v=S(0),w=S(0),x=S(0),y=0,z=S(0),A=S(0),B=0,C=S(0),D=S(0),E=0,F=0,G=0,H=0,I=0,K=0,N=S(0),O=S(0),Q=S(0),R=S(0),T=S(0),U=0,V=S(0),W=0,X=0;c=fa-192|0;fa=c;wa(2663);d=L[a+1112>>2];if((d|0)>0){H=a+1048|0;U=L[5822];V=P[5821];while(1){b=L[L[a+1120>>2]+(F<<2)>>2];E=L[b+24>>2];if(E){L[c+188>>2]=0;L[c+180>>2]=0;L[c+184>>2]=0;L[c+172>>2]=0;L[c+176>>2]=0;L[c+164>>2]=0;L[c+168>>2]=0;L[c+156>>2]=0;L[c+160>>2]=0;L[c+148>>2]=0;L[c+152>>2]=0;L[c+184>>2]=966609233;L[c+164>>2]=961656599;L[c+144>>2]=953267991;r=L[b+24>>2];I=(r|0)<=0;a:{if(I){e=S(0);h=S(0);f=S(0);break a}W=r&1;g=L[b+32>>2];y=L[b+12>>2];b:{if((r|0)==1){f=S(0);d=0;h=S(0);e=S(0);break b}X=r&-2;f=S(0);d=0;h=S(0);e=S(0);B=0;while(1){u=d<<2;G=L[u+g>>2];i=P[y+u>>2];K=u|4;u=L[g+K>>2];j=P[y+K>>2];e=S(S(e+S(P[G+8>>2]*i))+S(P[u+8>>2]*j));f=S(S(f+S(i*P[G+16>>2]))+S(j*P[u+16>>2]));h=S(S(h+S(i*P[G+12>>2]))+S(j*P[u+12>>2]));d=d+2|0;B=B+2|0;if((X|0)!=(B|0)){continue}break}}if(!W){break a}u=g;g=d<<2;d=L[u+g>>2];i=P[g+y>>2];e=S(e+S(P[d+8>>2]*i));f=S(f+S(i*P[d+16>>2]));h=S(h+S(i*P[d+12>>2]))}L[b+240>>2]=0;k=f;f=P[b+128>>2];p=S(k*f);P[b+236>>2]=p;v=S(h*f);P[b+232>>2]=v;x=S(e*f);P[b+228>>2]=x;if(!I){B=L[b+52>>2];u=L[b+32>>2];l=S(9999999747378752e-20);d=0;e=S(.00019999999494757503);h=S(0);f=S(.00029999998514540493);i=P[c+168>>2];j=P[c+152>>2];k=P[c+148>>2];m=P[c+160>>2];n=S(0);while(1){y=L[u+(d<<2)>>2];z=P[y+16>>2];w=P[y+12>>2];g=B+(d<<4)|0;q=P[g>>2];s=P[g+4>>2];o=S(P[y+8>>2]-x);j=S(S(o*P[g+8>>2])+j);P[c+152>>2]=j;k=S(S(o*s)+k);P[c+148>>2]=k;l=S(S(o*q)+l);P[c+144>>2]=l;q=P[g>>2];s=P[g+4>>2];o=S(w-v);i=S(S(o*P[g+8>>2])+i);P[c+168>>2]=i;e=S(S(o*s)+e);P[c+164>>2]=e;m=S(S(o*q)+m);P[c+160>>2]=m;w=P[g>>2];q=P[g+4>>2];o=S(z-p);f=S(S(o*P[g+8>>2])+f);P[c+184>>2]=f;h=S(S(o*q)+h);P[c+180>>2]=h;n=S(S(o*w)+n);P[c+176>>2]=n;d=d+1|0;if((r|0)!=(d|0)){continue}break}}if(!M[33884]){L[8470]=U;P[8469]=V;J[33884]=1}Wj(c+144|0,c+96|0,c+48|0);d=L[b+240>>2];L[b+116>>2]=L[b+236>>2];L[b+120>>2]=d;d=L[b+232>>2];L[b+108>>2]=L[b+228>>2];L[b+112>>2]=d;d=L[c+108>>2];L[b+68>>2]=L[c+104>>2];L[b+72>>2]=d;d=L[c+100>>2];L[b+60>>2]=L[c+96>>2];L[b+64>>2]=d;d=L[c+124>>2];L[b+84>>2]=L[c+120>>2];L[b+88>>2]=d;d=L[c+116>>2];L[b+76>>2]=L[c+112>>2];L[b+80>>2]=d;d=L[c+132>>2];L[b+92>>2]=L[c+128>>2];L[b+96>>2]=d;d=L[c+140>>2];L[b+100>>2]=L[c+136>>2];L[b+104>>2]=d;h=P[b+68>>2];f=P[b- -64>>2];e=P[b+84>>2];i=P[b+76>>2];j=P[b+80>>2];o=P[b+172>>2];p=P[b+140>>2];v=P[b+156>>2];x=P[b+148>>2];z=P[b+164>>2];k=P[b+100>>2];w=P[b+168>>2];m=P[b+92>>2];q=P[b+136>>2];n=P[b+96>>2];s=P[b+152>>2];l=P[b+60>>2];C=P[b+132>>2];L[b+316>>2]=0;L[b+320>>2]=0;L[b+224>>2]=0;L[b+208>>2]=0;L[b+192>>2]=0;L[b+324>>2]=0;L[b+328>>2]=0;L[b+332>>2]=0;L[b+336>>2]=0;L[b+340>>2]=0;L[b+344>>2]=0;t=S(S(o*k)+S(S(p*m)+S(v*n)));A=S(S(z*k)+S(S(C*m)+S(x*n)));D=S(S(w*k)+S(S(q*m)+S(s*n)));N=S(S(k*t)+S(S(m*A)+S(n*D)));P[b+220>>2]=N;O=S(S(e*t)+S(S(i*A)+S(j*D)));P[b+216>>2]=O;Q=S(S(h*t)+S(S(l*A)+S(f*D)));P[b+212>>2]=Q;t=S(S(o*e)+S(S(p*i)+S(v*j)));A=S(S(z*e)+S(S(C*i)+S(x*j)));D=S(S(w*e)+S(S(q*i)+S(s*j)));R=S(S(k*t)+S(S(m*A)+S(n*D)));P[b+204>>2]=R;T=S(S(e*t)+S(S(i*A)+S(j*D)));P[b+200>>2]=T;t=S(S(h*t)+S(S(l*A)+S(f*D)));P[b+196>>2]=t;A=k;k=S(S(o*h)+S(S(p*l)+S(f*v)));o=m;m=S(S(z*h)+S(S(C*l)+S(x*f)));p=n;n=S(S(w*h)+S(S(q*l)+S(f*s)));o=S(S(A*k)+S(S(o*m)+S(p*n)));P[b+188>>2]=o;p=S(S(e*k)+S(S(i*m)+S(n*j)));P[b+184>>2]=p;v=S(S(h*k)+S(S(l*m)+S(f*n)));P[b+180>>2]=v;c:{if((E|0)<=0){h=S(0);f=S(0);i=S(0);j=S(0);k=S(0);m=S(0);break c}r=L[b+32>>2];x=P[b+236>>2];z=P[b+232>>2];w=P[b+228>>2];y=L[b+12>>2];d=0;h=S(0);f=S(0);i=S(0);j=S(0);k=S(0);m=S(0);while(1){B=d<<2;g=L[B+r>>2];q=P[g+44>>2];l=P[g+48>>2];e=P[y+B>>2];n=S(P[g+40>>2]*e);m=S(n+m);P[b+316>>2]=m;l=S(e*l);j=S(l+j);P[b+324>>2]=j;e=S(e*q);k=S(e+k);P[b+320>>2]=k;q=P[g+16>>2];s=S(P[g+8>>2]-w);C=S(P[g+12>>2]-z);h=S(S(S(s*e)-S(n*C))+h);P[b+340>>2]=h;q=S(q-x);f=S(S(S(q*n)-S(l*s))+f);P[b+336>>2]=f;i=S(i+S(S(C*l)-S(e*q)));P[b+332>>2]=i;d=d+1|0;if((E|0)!=(d|0)){continue}break}}L[b+328>>2]=0;L[b+344>>2]=0;e=P[b+128>>2];n=S(e*j);j=S(S(1)-P[b+356>>2]);P[b+324>>2]=n*j;P[b+320>>2]=S(e*k)*j;P[b+316>>2]=S(m*e)*j;e=S(S(1)-P[b+360>>2]);P[b+340>>2]=e*S(S(N*h)+S(S(Q*i)+S(f*O)));P[b+336>>2]=S(S(R*h)+S(S(t*i)+S(f*T)))*e;P[b+332>>2]=S(S(o*h)+S(S(v*i)+S(p*f)))*e;pa(b+244|0,0,72);if(!(!(P[b+364>>2]>S(0))|L[b+24>>2]<=0)){d=0;while(1){g=L[L[b+32>>2]+(d<<2)>>2];j=P[g+8>>2];k=P[g+12>>2];m=P[g+16>>2];r=L[b+52>>2]+(d<<4)|0;h=P[r+8>>2];f=P[r>>2];e=P[r+4>>2];n=P[b+108>>2];l=P[b+68>>2];o=P[b+60>>2];p=P[b+64>>2];v=P[b+112>>2];x=P[b+84>>2];z=P[b+76>>2];w=P[b+80>>2];i=P[b+364>>2];q=P[b+116>>2];s=P[b+100>>2];C=P[b+92>>2];t=P[b+96>>2];L[g+20>>2]=0;P[g+16>>2]=m+S(i*S(S(q+S(S(h*s)+S(S(f*C)+S(e*t))))-m));P[g+12>>2]=k+S(i*S(S(v+S(S(h*x)+S(S(f*z)+S(e*w))))-k));P[g+8>>2]=j+S(i*S(S(n+S(S(h*l)+S(S(f*o)+S(e*p))))-j));d=d+1|0;if((d|0)>2]){continue}break}}d:{if(!M[b+377|0]){break d}d=1;r=L[b+32>>2];g=L[r>>2];h=P[g+8>>2];f=h;i=P[g+12>>2];j=i;k=P[g+16>>2];m=k;n=P[g+20>>2];e=n;if((E|0)>1){while(1){g=L[r+(d<<2)>>2];l=P[g+8>>2];h=hl?l:f;l=P[g+20>>2];n=l>n?l:n;o=P[g+16>>2];k=k>2];i=il?l:e;m=m>o?o:m;j=j>p?p:j;d=d+1|0;if((E|0)!=(d|0)){continue}break}}P[c+44>>2]=n;P[c+40>>2]=k;P[c+36>>2]=i;P[c+32>>2]=h;P[c+28>>2]=e;P[c+24>>2]=m;P[c+20>>2]=j;P[c+16>>2]=f;d=L[b+348>>2];if(d){f=P[b+316>>2];e=P[b+320>>2];i=P[b+324>>2];h=P[a+452>>2];L[c+12>>2]=0;P[c+8>>2]=S(h*i)*S(3);P[c+4>>2]=S(h*e)*S(3);P[c>>2]=S(f*h)*S(3);Dd(H,d,c+16|0,c,P[a+464>>2]);break d}L[b+348>>2]=Bb(H,c+16|0,b)}d=L[a+1112>>2]}F=F+1|0;if((F|0)<(d|0)){continue}break}}va();fa=c+192|0}function cb(a){var b=0,c=0,d=0,e=S(0),f=0,g=0,h=S(0),i=S(0),j=S(0),k=S(0),l=0,m=S(0),n=S(0),o=S(0),p=S(0),q=S(0),r=S(0),s=0;d=fa-32|0;fa=d;a:{b:{c:{d:{e:{f:{b=L[a+372>>2];switch(L[b+32>>2]-1|0){case 3:break c;case 2:break d;case 1:break e;case 0:break f;default:break b}}b=L[a+364>>2];c=L[a+372>>2];g=L[c+32>>2];f=(g<<2)+c|0;L[f+16>>2]=0;b=b-1|0;L[a+364>>2]=b;b=L[((b<<2)+a|0)+348>>2];L[f>>2]=b;L[c+32>>2]=g+1;L[b+8>>2]=0;L[b+12>>2]=0;L[b>>2]=1065353216;L[b+4>>2]=0;Xa(d+16|0,a,b);c=L[d+28>>2];L[b+24>>2]=L[d+24>>2];L[b+28>>2]=c;c=L[d+20>>2];L[b+16>>2]=L[d+16>>2];L[b+20>>2]=c;c=1;if(cb(a)){break a}b=L[a+372>>2];c=L[b+32>>2]-1|0;L[b+32>>2]=c;b=L[b+(c<<2)>>2];L[((L[a+364>>2]<<2)+a|0)+348>>2]=b;c=L[a+372>>2];g=L[c+32>>2];f=(g<<2)+c|0;L[f>>2]=b;L[f+16>>2]=0;L[c+32>>2]=g+1;L[b+8>>2]=-2147483648;L[b+12>>2]=0;L[b>>2]=-1082130432;L[b+4>>2]=-2147483648;Xa(d+16|0,a,b);c=L[d+28>>2];L[b+24>>2]=L[d+24>>2];L[b+28>>2]=c;c=L[d+20>>2];L[b+16>>2]=L[d+16>>2];L[b+20>>2]=c;c=1;if(cb(a)){break a}b=L[a+372>>2];c=L[b+32>>2]-1|0;L[b+32>>2]=c;c=L[b+(c<<2)>>2];b=L[a+364>>2];L[a+364>>2]=b+1;g=(b<<2)+a|0;L[g+348>>2]=c;c=L[a+372>>2];f=L[c+32>>2];l=(f<<2)+c|0;L[l+16>>2]=0;L[a+364>>2]=b;b=L[g+348>>2];L[l>>2]=b;L[c+32>>2]=f+1;L[b+8>>2]=0;L[b+12>>2]=0;L[b>>2]=0;L[b+4>>2]=1065353216;Xa(d+16|0,a,b);c=L[d+28>>2];L[b+24>>2]=L[d+24>>2];L[b+28>>2]=c;c=L[d+20>>2];L[b+16>>2]=L[d+16>>2];L[b+20>>2]=c;c=1;if(cb(a)){break a}b=L[a+372>>2];c=L[b+32>>2]-1|0;L[b+32>>2]=c;b=L[b+(c<<2)>>2];L[((L[a+364>>2]<<2)+a|0)+348>>2]=b;c=L[a+372>>2];g=L[c+32>>2];f=(g<<2)+c|0;L[f>>2]=b;L[f+16>>2]=0;L[c+32>>2]=g+1;L[b+8>>2]=-2147483648;L[b+12>>2]=0;L[b>>2]=-2147483648;L[b+4>>2]=-1082130432;Xa(d+16|0,a,b);c=L[d+28>>2];L[b+24>>2]=L[d+24>>2];L[b+28>>2]=c;c=L[d+20>>2];L[b+16>>2]=L[d+16>>2];L[b+20>>2]=c;c=1;if(cb(a)){break a}b=L[a+372>>2];c=L[b+32>>2]-1|0;L[b+32>>2]=c;c=L[b+(c<<2)>>2];b=L[a+364>>2];L[a+364>>2]=b+1;g=(b<<2)+a|0;L[g+348>>2]=c;c=L[a+372>>2];f=L[c+32>>2];l=(f<<2)+c|0;L[l+16>>2]=0;L[a+364>>2]=b;b=L[g+348>>2];L[l>>2]=b;L[c+32>>2]=f+1;L[b+8>>2]=1065353216;L[b+12>>2]=0;L[b>>2]=0;L[b+4>>2]=0;Xa(d+16|0,a,b);c=L[d+28>>2];L[b+24>>2]=L[d+24>>2];L[b+28>>2]=c;c=L[d+20>>2];L[b+16>>2]=L[d+16>>2];L[b+20>>2]=c;c=1;if(cb(a)){break a}b=L[a+372>>2];c=L[b+32>>2]-1|0;L[b+32>>2]=c;b=L[b+(c<<2)>>2];L[((L[a+364>>2]<<2)+a|0)+348>>2]=b;c=L[a+372>>2];g=L[c+32>>2];f=(g<<2)+c|0;L[f>>2]=b;L[f+16>>2]=0;L[c+32>>2]=g+1;L[b+8>>2]=-1082130432;L[b+12>>2]=0;L[b>>2]=-2147483648;L[b+4>>2]=-2147483648;Xa(d+16|0,a,b);c=L[d+28>>2];L[b+24>>2]=L[d+24>>2];L[b+28>>2]=c;c=L[d+20>>2];L[b+16>>2]=L[d+16>>2];L[b+20>>2]=c;c=1;if(cb(a)){break a}b=L[a+372>>2];c=L[b+32>>2]-1|0;L[b+32>>2]=c;b=L[b+(c<<2)>>2];c=L[a+364>>2];L[a+364>>2]=c+1;L[((c<<2)+a|0)+348>>2]=b;break b}c=L[b+4>>2];b=L[b>>2];k=S(P[c+20>>2]-P[b+20>>2]);m=S(-k);n=S(P[c+24>>2]-P[b+24>>2]);p=S(-n);o=S(P[c+16>>2]-P[b+16>>2]);r=S(-o);while(1){g:{L[d+8>>2]=0;L[d+12>>2]=0;L[d>>2]=0;L[d+4>>2]=0;L[d+(g<<2)>>2]=1065353216;e=P[d+4>>2];j=P[d>>2];h=S(S(o*e)+S(j*m));q=P[d+8>>2];i=S(S(k*q)+S(e*p));j=S(S(n*j)+S(q*r));e=S(S(h*h)+S(S(i*i)+S(j*j)));if(e>S(0)){c=L[a+372>>2];f=L[c+32>>2];b=(f<<2)+c|0;L[b+16>>2]=0;l=L[a+364>>2]-1|0;L[a+364>>2]=l;s=b;b=L[((l<<2)+a|0)+348>>2];L[s>>2]=b;L[c+32>>2]=f+1;L[b+12>>2]=0;e=S(S(1)/S(_(e)));P[b+8>>2]=h*e;P[b+4>>2]=j*e;P[b>>2]=i*e;Xa(d+16|0,a,b);c=L[d+28>>2];L[b+24>>2]=L[d+24>>2];L[b+28>>2]=c;c=L[d+20>>2];L[b+16>>2]=L[d+16>>2];L[b+20>>2]=c;if(cb(a)){break g}b=L[a+372>>2];c=L[b+32>>2]-1|0;L[b+32>>2]=c;b=L[b+(c<<2)>>2];L[((L[a+364>>2]<<2)+a|0)+348>>2]=b;c=L[a+372>>2];f=L[c+32>>2];l=(f<<2)+c|0;L[l>>2]=b;L[l+16>>2]=0;L[c+32>>2]=f+1;L[b+12>>2]=0;P[b+8>>2]=e*S(-h);P[b+4>>2]=e*S(-j);P[b>>2]=e*S(-i);Xa(d+16|0,a,b);c=L[d+28>>2];L[b+24>>2]=L[d+24>>2];L[b+28>>2]=c;c=L[d+20>>2];L[b+16>>2]=L[d+16>>2];L[b+20>>2]=c;if(cb(a)){break g}b=L[a+372>>2];c=L[b+32>>2]-1|0;L[b+32>>2]=c;b=L[b+(c<<2)>>2];c=L[a+364>>2];L[a+364>>2]=c+1;L[((c<<2)+a|0)+348>>2]=b}g=g+1|0;if((g|0)!=3){continue}break b}break}c=1;break a}c=L[b+4>>2];g=L[b>>2];e=P[g+16>>2];j=S(P[c+16>>2]-e);f=L[b+8>>2];h=P[g+20>>2];i=S(P[f+20>>2]-h);e=S(P[f+16>>2]-e);k=S(P[c+20>>2]-h);h=S(S(j*i)-S(e*k));n=k;k=P[g+24>>2];m=S(P[f+24>>2]-k);k=S(P[c+24>>2]-k);i=S(S(n*m)-S(i*k));j=S(S(k*e)-S(m*j));e=S(S(h*h)+S(S(i*i)+S(j*j)));if(!(e>S(0))){break b}L[b+28>>2]=0;c=L[a+364>>2]-1|0;L[a+364>>2]=c;c=L[((c<<2)+a|0)+348>>2];L[b+32>>2]=4;L[b+12>>2]=c;L[c+12>>2]=0;e=S(S(1)/S(_(e)));P[c+8>>2]=h*e;P[c+4>>2]=j*e;P[c>>2]=i*e;Xa(d+16|0,a,c);b=L[d+28>>2];L[c+24>>2]=L[d+24>>2];L[c+28>>2]=b;b=L[d+20>>2];L[c+16>>2]=L[d+16>>2];L[c+20>>2]=b;c=1;if(cb(a)){break a}b=L[a+372>>2];c=L[b+32>>2]-1|0;L[b+32>>2]=c;b=L[b+(c<<2)>>2];L[((L[a+364>>2]<<2)+a|0)+348>>2]=b;c=L[a+372>>2];g=L[c+32>>2];f=(g<<2)+c|0;L[f>>2]=b;L[f+16>>2]=0;L[c+32>>2]=g+1;L[b+12>>2]=0;P[b+8>>2]=e*S(-h);P[b+4>>2]=e*S(-j);P[b>>2]=e*S(-i);Xa(d+16|0,a,b);c=L[d+28>>2];L[b+24>>2]=L[d+24>>2];L[b+28>>2]=c;c=L[d+20>>2];L[b+16>>2]=L[d+16>>2];L[b+20>>2]=c;c=1;if(cb(a)){break a}b=L[a+372>>2];c=L[b+32>>2]-1|0;L[b+32>>2]=c;b=L[b+(c<<2)>>2];c=L[a+364>>2];L[a+364>>2]=c+1;L[((c<<2)+a|0)+348>>2]=b;break b}a=L[b>>2];g=L[b+12>>2];e=P[g+16>>2];j=S(P[a+16>>2]-e);f=L[b+4>>2];h=P[g+20>>2];k=S(P[f+20>>2]-h);b=L[b+8>>2];i=P[g+24>>2];m=S(P[b+24>>2]-i);n=S(P[a+20>>2]-h);p=S(P[f+24>>2]-i);o=S(P[b+16>>2]-e);i=S(P[a+24>>2]-i);e=S(P[f+16>>2]-e);h=S(P[b+20>>2]-h);e=S(S(S(S(j*k)*m)+S(S(S(S(S(n*p)*o)+S(S(i*e)*h))-S(S(p*j)*h))-S(S(e*n)*m)))-S(S(k*i)*o));c=1;if(e>S(0)|e>2]=a;L[f+792>>2]=b;L[f+788>>2]=c;L[f+784>>2]=d;L[f+780>>2]=e;a=L[f+796>>2];c=L[f+784>>2];b=fa-16|0;L[b+12>>2]=L[f+792>>2];d=L[b+12>>2];L[b+12>>2]=L[f+792>>2];e=L[b+12>>2];L[b+12>>2]=L[f+792>>2];g=f+748|0;la(g,d,e+4|0,L[b+12>>2]+8|0);b=f+764|0;xa(b,c,g);c=L[f+784>>2];d=fa-16|0;L[d+12>>2]=L[f+788>>2];d=L[d+12>>2];e=fa-16|0;L[e+12>>2]=L[f+792>>2];e=L[e+12>>2];g=fa-16|0;L[g+12>>2]=L[f+792>>2];h=f+716|0;la(h,d,e+4|0,L[g+12>>2]+8|0);d=f+732|0;xa(d,c,h);ha[L[L[a>>2]+8>>2]](a,b,d,L[f+780>>2]);b=L[f+784>>2];c=fa-16|0;L[c+12>>2]=L[f+788>>2];c=L[c+12>>2];d=fa-16|0;L[d+12>>2]=L[f+792>>2];d=L[d+12>>2];e=fa-16|0;L[e+12>>2]=L[f+792>>2];g=f+684|0;la(g,c,d+4|0,L[e+12>>2]+8|0);c=f+700|0;xa(c,b,g);b=L[f+784>>2];d=fa-16|0;L[d+12>>2]=L[f+788>>2];d=L[d+12>>2];e=fa-16|0;L[e+12>>2]=L[f+788>>2];e=L[e+12>>2];g=fa-16|0;L[g+12>>2]=L[f+792>>2];h=f+652|0;la(h,d,e+4|0,L[g+12>>2]+8|0);d=f+668|0;xa(d,b,h);ha[L[L[a>>2]+8>>2]](a,c,d,L[f+780>>2]);b=L[f+784>>2];c=fa-16|0;L[c+12>>2]=L[f+788>>2];c=L[c+12>>2];d=fa-16|0;L[d+12>>2]=L[f+788>>2];d=L[d+12>>2];e=fa-16|0;L[e+12>>2]=L[f+792>>2];g=f+620|0;la(g,c,d+4|0,L[e+12>>2]+8|0);c=f+636|0;xa(c,b,g);b=L[f+784>>2];d=fa-16|0;L[d+12>>2]=L[f+792>>2];d=L[d+12>>2];e=fa-16|0;L[e+12>>2]=L[f+788>>2];e=L[e+12>>2];g=fa-16|0;L[g+12>>2]=L[f+792>>2];h=f+588|0;la(h,d,e+4|0,L[g+12>>2]+8|0);d=f+604|0;xa(d,b,h);ha[L[L[a>>2]+8>>2]](a,c,d,L[f+780>>2]);b=L[f+784>>2];c=fa-16|0;L[c+12>>2]=L[f+792>>2];c=L[c+12>>2];d=fa-16|0;L[d+12>>2]=L[f+788>>2];d=L[d+12>>2];e=fa-16|0;L[e+12>>2]=L[f+792>>2];g=f+556|0;la(g,c,d+4|0,L[e+12>>2]+8|0);c=f+572|0;xa(c,b,g);b=L[f+784>>2];d=fa-16|0;L[d+12>>2]=L[f+792>>2];d=L[d+12>>2];e=fa-16|0;L[e+12>>2]=L[f+792>>2];e=L[e+12>>2];g=fa-16|0;L[g+12>>2]=L[f+792>>2];h=f+524|0;la(h,d,e+4|0,L[g+12>>2]+8|0);d=f+540|0;xa(d,b,h);ha[L[L[a>>2]+8>>2]](a,c,d,L[f+780>>2]);b=L[f+784>>2];c=fa-16|0;L[c+12>>2]=L[f+792>>2];c=L[c+12>>2];d=fa-16|0;L[d+12>>2]=L[f+792>>2];d=L[d+12>>2];e=fa-16|0;L[e+12>>2]=L[f+792>>2];g=f+492|0;la(g,c,d+4|0,L[e+12>>2]+8|0);c=f+508|0;xa(c,b,g);b=L[f+784>>2];d=fa-16|0;L[d+12>>2]=L[f+792>>2];d=L[d+12>>2];e=fa-16|0;L[e+12>>2]=L[f+792>>2];e=L[e+12>>2];g=fa-16|0;L[g+12>>2]=L[f+788>>2];h=f+460|0;la(h,d,e+4|0,L[g+12>>2]+8|0);d=f+476|0;xa(d,b,h);ha[L[L[a>>2]+8>>2]](a,c,d,L[f+780>>2]);b=L[f+784>>2];c=fa-16|0;L[c+12>>2]=L[f+788>>2];c=L[c+12>>2];d=fa-16|0;L[d+12>>2]=L[f+792>>2];d=L[d+12>>2];e=fa-16|0;L[e+12>>2]=L[f+792>>2];g=f+428|0;la(g,c,d+4|0,L[e+12>>2]+8|0);c=f+444|0;xa(c,b,g);b=L[f+784>>2];d=fa-16|0;L[d+12>>2]=L[f+788>>2];d=L[d+12>>2];e=fa-16|0;L[e+12>>2]=L[f+792>>2];e=L[e+12>>2];g=fa-16|0;L[g+12>>2]=L[f+788>>2];h=f+396|0;la(h,d,e+4|0,L[g+12>>2]+8|0);d=f+412|0;xa(d,b,h);ha[L[L[a>>2]+8>>2]](a,c,d,L[f+780>>2]);b=L[f+784>>2];c=fa-16|0;L[c+12>>2]=L[f+788>>2];c=L[c+12>>2];d=fa-16|0;L[d+12>>2]=L[f+788>>2];d=L[d+12>>2];e=fa-16|0;L[e+12>>2]=L[f+792>>2];g=f+364|0;la(g,c,d+4|0,L[e+12>>2]+8|0);c=f+380|0;xa(c,b,g);b=L[f+784>>2];d=fa-16|0;L[d+12>>2]=L[f+788>>2];d=L[d+12>>2];e=fa-16|0;L[e+12>>2]=L[f+788>>2];e=L[e+12>>2];g=fa-16|0;L[g+12>>2]=L[f+788>>2];h=f+332|0;la(h,d,e+4|0,L[g+12>>2]+8|0);d=f+348|0;xa(d,b,h);ha[L[L[a>>2]+8>>2]](a,c,d,L[f+780>>2]);b=L[f+784>>2];c=fa-16|0;L[c+12>>2]=L[f+792>>2];c=L[c+12>>2];d=fa-16|0;L[d+12>>2]=L[f+788>>2];d=L[d+12>>2];e=fa-16|0;L[e+12>>2]=L[f+792>>2];g=f+300|0;la(g,c,d+4|0,L[e+12>>2]+8|0);c=f+316|0;xa(c,b,g);b=L[f+784>>2];d=fa-16|0;L[d+12>>2]=L[f+792>>2];d=L[d+12>>2];e=fa-16|0;L[e+12>>2]=L[f+788>>2];e=L[e+12>>2];g=fa-16|0;L[g+12>>2]=L[f+788>>2];h=f+268|0;la(h,d,e+4|0,L[g+12>>2]+8|0);d=f+284|0;xa(d,b,h);ha[L[L[a>>2]+8>>2]](a,c,d,L[f+780>>2]);b=L[f+784>>2];c=fa-16|0;L[c+12>>2]=L[f+792>>2];c=L[c+12>>2];d=fa-16|0;L[d+12>>2]=L[f+792>>2];d=L[d+12>>2];e=fa-16|0;L[e+12>>2]=L[f+788>>2];g=f+236|0;la(g,c,d+4|0,L[e+12>>2]+8|0);c=f+252|0;xa(c,b,g);b=L[f+784>>2];d=fa-16|0;L[d+12>>2]=L[f+788>>2];d=L[d+12>>2];e=fa-16|0;L[e+12>>2]=L[f+792>>2];e=L[e+12>>2];g=fa-16|0;L[g+12>>2]=L[f+788>>2];h=f+204|0;la(h,d,e+4|0,L[g+12>>2]+8|0);d=f+220|0;xa(d,b,h);ha[L[L[a>>2]+8>>2]](a,c,d,L[f+780>>2]);b=L[f+784>>2];c=fa-16|0;L[c+12>>2]=L[f+788>>2];c=L[c+12>>2];d=fa-16|0;L[d+12>>2]=L[f+792>>2];d=L[d+12>>2];e=fa-16|0;L[e+12>>2]=L[f+788>>2];g=f+172|0;la(g,c,d+4|0,L[e+12>>2]+8|0);c=f+188|0;xa(c,b,g);b=L[f+784>>2];d=fa-16|0;L[d+12>>2]=L[f+788>>2];d=L[d+12>>2];e=fa-16|0;L[e+12>>2]=L[f+788>>2];e=L[e+12>>2];g=fa-16|0;L[g+12>>2]=L[f+788>>2];h=f+140|0;la(h,d,e+4|0,L[g+12>>2]+8|0);d=f+156|0;xa(d,b,h);ha[L[L[a>>2]+8>>2]](a,c,d,L[f+780>>2]);b=L[f+784>>2];c=fa-16|0;L[c+12>>2]=L[f+788>>2];c=L[c+12>>2];d=fa-16|0;L[d+12>>2]=L[f+788>>2];d=L[d+12>>2];e=fa-16|0;L[e+12>>2]=L[f+788>>2];g=f+108|0;la(g,c,d+4|0,L[e+12>>2]+8|0);c=f+124|0;xa(c,b,g);b=L[f+784>>2];d=fa-16|0;L[d+12>>2]=L[f+792>>2];d=L[d+12>>2];e=fa-16|0;L[e+12>>2]=L[f+788>>2];e=L[e+12>>2];g=fa-16|0;L[g+12>>2]=L[f+788>>2];h=f+76|0;la(h,d,e+4|0,L[g+12>>2]+8|0);d=f+92|0;xa(d,b,h);ha[L[L[a>>2]+8>>2]](a,c,d,L[f+780>>2]);b=L[f+784>>2];c=fa-16|0;L[c+12>>2]=L[f+792>>2];c=L[c+12>>2];d=fa-16|0;L[d+12>>2]=L[f+788>>2];d=L[d+12>>2];e=fa-16|0;L[e+12>>2]=L[f+788>>2];g=f+44|0;la(g,c,d+4|0,L[e+12>>2]+8|0);c=f+60|0;xa(c,b,g);b=L[f+784>>2];d=fa-16|0;L[d+12>>2]=L[f+792>>2];d=L[d+12>>2];e=fa-16|0;L[e+12>>2]=L[f+792>>2];e=L[e+12>>2];g=fa-16|0;L[g+12>>2]=L[f+788>>2];h=f+12|0;la(h,d,e+4|0,L[g+12>>2]+8|0);d=f+28|0;xa(d,b,h);ha[L[L[a>>2]+8>>2]](a,c,d,L[f+780>>2]);fa=f+800|0}function qd(a,b,c){var d=S(0),e=S(0),f=S(0),g=S(0),h=S(0),i=S(0),j=S(0),k=S(0),l=S(0),m=S(0),n=S(0),o=S(0),p=S(0),q=S(0),r=S(0),s=S(0),t=S(0),u=S(0),v=S(0),w=S(0),y=S(0),z=S(0),A=S(0),B=S(0),C=S(0),D=S(0),F=S(0),G=S(0),H=0,I=0,K=0,N=0,O=0,Q=0,R=0,U=0,V=0,W=0,X=0,Y=0,Z=0;f=P[b+52>>2];e=P[b+56>>2];p=P[a+96>>2];s=P[a+100>>2];t=P[a+104>>2];q=P[b+20>>2];r=P[b+24>>2];k=P[a- -64>>2];o=P[a+80>>2];u=P[a+52>>2];l=P[a+68>>2];v=P[a+84>>2];h=P[a+56>>2];w=P[b+36>>2];i=P[a+72>>2];y=P[b+40>>2];m=P[a+88>>2];d=P[b+48>>2];g=P[b+8>>2];z=P[b>>2];A=P[b+4>>2];B=P[b+16>>2];n=P[a+48>>2];j=P[b+32>>2];L[a+1124>>2]=0;L[a+1108>>2]=0;L[a+1092>>2]=0;L[a+1076>>2]=0;K=a+1104|0;P[K>>2]=S(m*y)+S(S(h*j)+S(i*w));N=a+1100|0;P[N>>2]=S(v*y)+S(S(u*j)+S(l*w));O=a+1096|0;P[O>>2]=S(o*y)+S(S(n*j)+S(k*w));Q=a+1088|0;P[Q>>2]=S(m*r)+S(S(h*B)+S(i*q));R=a+1084|0;P[R>>2]=S(v*r)+S(S(u*B)+S(l*q));U=a+1080|0;P[U>>2]=S(o*r)+S(S(n*B)+S(k*q));V=a+1072|0;P[V>>2]=S(m*g)+S(S(h*z)+S(A*i));W=a+1068|0;P[W>>2]=S(v*g)+S(S(u*z)+S(A*l));P[a+1064>>2]=S(o*g)+S(S(n*z)+S(k*A));X=a+1120|0;P[X>>2]=e+S(S(t*y)+S(S(p*j)+S(w*s)));Y=a+1116|0;P[Y>>2]=f+S(S(t*r)+S(S(p*B)+S(q*s)));Z=a+1112|0;P[Z>>2]=d+S(S(t*g)+S(S(p*z)+S(A*s)));f=P[c+52>>2];e=P[c+56>>2];p=P[a+160>>2];s=P[a+164>>2];t=P[a+168>>2];q=P[c+20>>2];r=P[c+24>>2];k=P[a+128>>2];o=P[a+144>>2];u=P[a+116>>2];l=P[a+132>>2];v=P[a+148>>2];h=P[a+120>>2];i=P[a+136>>2];w=P[c+36>>2];m=P[a+152>>2];y=P[c+40>>2];d=P[c+48>>2];g=P[c+8>>2];z=P[c>>2];A=P[c+4>>2];B=P[c+16>>2];n=P[a+112>>2];j=P[c+32>>2];L[a+1188>>2]=0;L[a+1172>>2]=0;L[a+1156>>2]=0;L[a+1140>>2]=0;P[a+1168>>2]=S(m*y)+S(S(h*j)+S(i*w));P[a+1164>>2]=S(v*y)+S(S(u*j)+S(l*w));P[a+1160>>2]=S(o*y)+S(S(n*j)+S(k*w));P[a+1152>>2]=S(m*r)+S(S(h*B)+S(i*q));P[a+1148>>2]=S(v*r)+S(S(u*B)+S(l*q));P[a+1144>>2]=S(o*r)+S(S(n*B)+S(k*q));P[a+1136>>2]=S(m*g)+S(S(h*z)+S(A*i));P[a+1132>>2]=S(v*g)+S(S(u*z)+S(A*l));P[a+1128>>2]=S(o*g)+S(S(n*z)+S(k*A));H=a+1184|0;P[H>>2]=e+S(S(t*y)+S(S(p*j)+S(w*s)));c=a+1180|0;P[c>>2]=f+S(S(t*r)+S(S(p*B)+S(q*s)));b=a+1176|0;P[b>>2]=d+S(S(t*g)+S(S(p*z)+S(A*s)));L[a+1268>>2]=0;s=P[V>>2];o=P[U>>2];u=P[N>>2];l=P[O>>2];v=P[R>>2];f=S(S(o*u)-S(l*v));t=P[a+1064>>2];h=P[K>>2];i=P[Q>>2];e=S(S(v*h)-S(u*i));k=P[W>>2];d=S(S(i*l)-S(h*o));j=S(S(1)/S(S(s*f)+S(S(t*e)+S(k*d))));m=S(P[H>>2]-P[X>>2]);n=S(P[b>>2]-P[Z>>2]);g=S(S(f*j)*n);f=S(P[c>>2]-P[Y>>2]);p=S(S(S(S(S(t*v)-S(o*k))*j)*m)+S(g+S(f*S(S(S(k*l)-S(u*t))*j))));P[a+1264>>2]=p;l=S(S(S(S(S(s*o)-S(i*t))*j)*m)+S(S(S(d*j)*n)+S(f*S(S(S(t*h)-S(l*s))*j))));P[a+1260>>2]=l;f=S(S(S(S(S(k*i)-S(v*s))*j)*m)+S(S(S(e*j)*n)+S(f*S(S(S(s*u)-S(h*k))*j))));P[a+1256>>2]=f;P[a+840>>2]=f;e=P[a+680>>2];d=P[a+696>>2];a:{if(!(e>d)){if(e>f){L[a+856>>2]=2;d=S(f-e);break a}if(d>2]=1;d=S(f-d);break a}}L[a+856>>2]=0;d=S(0)}P[a+824>>2]=d;P[a+844>>2]=l;e=P[a+684>>2];d=P[a+700>>2];b:{if(!(e>d)){c:{if(!(e>l)){if(!(d>2]=1;d=S(l-d);break b}L[a+860>>2]=2;d=S(l-e);break b}}L[a+860>>2]=0;d=S(0)}P[a+848>>2]=p;P[a+828>>2]=d;e=P[a+688>>2];d=P[a+704>>2];d:{if(!(e>d)){e:{if(!(e>p)){if(!(d>2]=1;d=S(p-d);break d}L[a+864>>2]=2;d=S(p-e);break d}}L[a+864>>2]=0;d=S(0)}P[a+832>>2]=d;C=P[a+1072>>2];g=P[a+1080>>2];z=P[a+1100>>2];A=P[a+1096>>2];k=P[a+1084>>2];o=S(S(g*z)-S(A*k));w=P[a+1064>>2];F=P[a+1104>>2];G=P[a+1088>>2];e=S(S(k*F)-S(z*G));y=P[a+1068>>2];d=S(S(G*A)-S(F*g));D=S(S(1)/S(S(C*o)+S(S(w*e)+S(y*d))));B=P[a+1164>>2];u=S(S(S(C*g)-S(G*w))*D);j=P[a+1132>>2];l=S(d*D);v=S(S(S(w*F)-S(A*C))*D);p=P[a+1148>>2];s=S(S(B*u)+S(S(j*l)+S(v*p)));h=S(S(S(y*G)-S(k*C))*D);i=S(e*D);m=S(S(S(C*z)-S(F*y))*D);t=S(S(B*h)+S(S(j*i)+S(m*p)));n=S(-C);f=S(-G);q=P[a+1160>>2];k=S(S(S(w*k)-S(g*y))*D);r=P[a+1128>>2];e=S(o*D);g=P[a+1144>>2];d=S(S(S(y*A)-S(z*w))*D);o=S(S(q*k)+S(S(r*e)+S(g*d)));f:{g:{if(oS(-1)){P[a+1192>>2]=Za(S(-S(S(B*k)+S(S(j*e)+S(d*p)))),S(S(P[a+1168>>2]*k)+S(S(P[a+1136>>2]*e)+S(d*P[a+1152>>2]))));c=a+1196|0;d=oS(1)?S(1):d;b=(E(e),x(2));H=b&2147483647;h:{if(H>>>0>=1065353216){d=S(+e*1.5707963267948966+752316384526264e-51);if((H|0)==1065353216){break h}d=S(S(0)/S(e-e));break h}i:{if(H>>>0<=1056964607){if(H-8388608>>>0<956301312){break i}d=S(e*e);d=S(S(e*S(S(S(S(d*S(S(d*S(-.008656363002955914))+S(-.04274342209100723)))+S(.16666586697101593))*d)/S(S(d*S(-.7066296339035034))+S(1))))+e);break h}d=S(S(S(1)-S(T(e)))*S(.5));I=_(+d);I=I+I*+S(S(S(S(d*S(S(d*S(-.008656363002955914))+S(-.04274342209100723)))+S(.16666586697101593))*d)/S(S(d*S(-.7066296339035034))+S(1)));d=S(1.5707963267948966-(I+I));e=(b|0)<0?S(-d):d}d=e}P[c>>2]=d;d=Za(S(-S(S(q*u)+S(S(r*l)+S(g*v)))),S(S(q*h)+S(S(r*i)+S(g*m))));break f}L[a+1196>>2]=-1077342245;P[a+1192>>2]=-Za(t,s);break g}L[a+1196>>2]=1070141403;P[a+1192>>2]=Za(t,s)}d=S(0)}L[a+1236>>2]=0;P[a+1200>>2]=d;L[a+1252>>2]=0;L[a+1220>>2]=0;h=S(S(C*g)+S(r*f));i=S(S(G*q)-S(g*F));m=S(S(F*r)+S(q*n));d=S(S(1)/S(_(S(S(h*h)+S(S(i*i)+S(m*m))))));P[a+1232>>2]=h*d;P[a+1228>>2]=m*d;P[a+1224>>2]=i*d;f=S(S(r*m)-S(i*g));e=S(S(g*h)-S(m*q));d=S(S(q*i)-S(h*r));n=S(S(1)/S(_(S(S(f*f)+S(S(e*e)+S(d*d))))));P[a+1248>>2]=f*n;P[a+1244>>2]=d*n;P[a+1240>>2]=e*n;f=S(S(i*G)-S(C*m));e=S(S(m*F)-S(G*h));d=S(S(h*C)-S(F*i));n=S(S(1)/S(_(S(S(f*f)+S(S(e*e)+S(d*d))))));P[a+1216>>2]=f*n;P[a+1212>>2]=d*n;P[a+1208>>2]=e*n;if(M[a+1301|0]){d=P[L[a+28>>2]+344>>2];e=P[L[a+32>>2]+344>>2];J[a+1280|0]=dS(0)?S(e/d):S(.5);P[a+1272>>2]=d;P[a+1276>>2]=S(1)-d}}function iC(a,b,c,d,e,f,g,h,i,j){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;i=i|0;j=j|0;var k=S(0),l=S(0),m=S(0),n=S(0),o=0,p=S(0),q=0,r=S(0),s=S(0),t=S(0),u=0,v=0,w=0,x=S(0),y=S(0),z=S(0),A=S(0),B=S(0),C=0,D=S(0),E=0,F=0;a=fa-4240|0;fa=a;F=L[c+4>>2]-17>>>0<=1?L[d+4>>2]-17>>>0<2:F;while(1){Ie();q=w<<4;k=P[q+31464>>2];n=P[q+31456>>2];l=P[q+31460>>2];r=P[e+32>>2];s=P[e>>2];t=P[e+16>>2];p=P[e+36>>2];x=P[e+4>>2];y=P[e+20>>2];z=P[e+40>>2];m=P[e+8>>2];A=P[e+24>>2];u=q+(a+1264|0)|0;L[u+12>>2]=0;B=m;m=S(-n);P[u+8>>2]=S(S(B*m)-S(A*l))-S(z*k);P[u+4>>2]=S(S(x*m)-S(y*l))-S(p*k);P[u>>2]=S(S(s*m)-S(t*l))-S(r*k);m=P[f+32>>2];r=P[f>>2];s=P[f+16>>2];t=P[f+36>>2];p=P[f+4>>2];x=P[f+20>>2];y=P[f+40>>2];z=P[f+8>>2];A=P[f+24>>2];q=q+(a+272|0)|0;L[q+12>>2]=0;P[q+8>>2]=S(y*k)+S(S(z*n)+S(l*A));P[q+4>>2]=S(t*k)+S(S(p*n)+S(l*x));P[q>>2]=S(m*k)+S(S(r*n)+S(l*s));w=w+1|0;if((w|0)!=42){continue}break}q=42;E=ha[L[L[c>>2]+84>>2]](c)|0;if((E|0)>0){u=a+3256|0;w=0;while(1){ha[L[L[c>>2]+88>>2]](c,w,a+3248|0);m=P[e+8>>2];r=P[e>>2];s=P[e+4>>2];t=P[e+24>>2];p=P[e+16>>2];x=P[e+20>>2];k=P[u>>2];l=P[a+3248>>2];n=P[a+3252>>2];P[u>>2]=S(P[e+40>>2]*k)+S(S(P[e+32>>2]*l)+S(n*P[e+36>>2]));L[a+3260>>2]=0;P[a+3252>>2]=S(t*k)+S(S(p*l)+S(n*x));P[a+3248>>2]=S(m*k)+S(S(r*l)+S(s*n));Ie();C=L[u+4>>2];o=q<<4;v=o+31464|0;L[v>>2]=L[u>>2];L[v+4>>2]=C;C=L[a+3252>>2];v=o+31456|0;L[v>>2]=L[a+3248>>2];L[v+4>>2]=C;r=P[e+40>>2];s=P[e+8>>2];t=P[e+24>>2];p=P[e+36>>2];x=P[e+4>>2];y=P[e+20>>2];l=P[e+32>>2];k=P[e>>2];z=P[e+16>>2];v=o+(a+1264|0)|0;L[v+12>>2]=0;n=P[a+3248>>2];m=S(-n);D=S(k*m);k=P[a+3252>>2];B=l;l=P[u>>2];P[v>>2]=S(D-S(z*k))-S(B*l);P[v+4>>2]=S(S(x*m)-S(y*k))-S(p*l);P[v+8>>2]=S(S(s*m)-S(t*k))-S(r*l);m=P[f+32>>2];r=P[f>>2];s=P[f+16>>2];t=P[f+36>>2];p=P[f+4>>2];x=P[f+20>>2];y=P[f+40>>2];z=P[f+8>>2];A=P[f+24>>2];o=o+(a+272|0)|0;L[o+12>>2]=0;P[o+8>>2]=S(y*l)+S(S(z*n)+S(k*A));P[o+4>>2]=S(t*l)+S(S(p*n)+S(k*x));P[o>>2]=S(m*l)+S(S(r*n)+S(k*s));q=q+1|0;w=w+1|0;if((E|0)!=(w|0)){continue}break}}E=ha[L[L[d>>2]+84>>2]](d)|0;if((E|0)>0){u=a+3256|0;w=0;while(1){ha[L[L[d>>2]+88>>2]](d,w,a+3248|0);m=P[f+8>>2];r=P[f>>2];s=P[f+4>>2];t=P[f+24>>2];p=P[f+16>>2];x=P[f+20>>2];k=P[u>>2];l=P[a+3248>>2];n=P[a+3252>>2];P[u>>2]=S(P[f+40>>2]*k)+S(S(P[f+32>>2]*l)+S(n*P[f+36>>2]));L[a+3260>>2]=0;P[a+3252>>2]=S(t*k)+S(S(p*l)+S(n*x));P[a+3248>>2]=S(m*k)+S(S(r*l)+S(s*n));Ie();C=L[u+4>>2];o=q<<4;v=o+31464|0;L[v>>2]=L[u>>2];L[v+4>>2]=C;C=L[a+3252>>2];v=o+31456|0;L[v>>2]=L[a+3248>>2];L[v+4>>2]=C;r=P[e+40>>2];s=P[e+8>>2];t=P[e+24>>2];p=P[e+36>>2];x=P[e+4>>2];y=P[e+20>>2];l=P[e+32>>2];k=P[e>>2];z=P[e+16>>2];v=o+(a+1264|0)|0;L[v+12>>2]=0;n=P[a+3248>>2];m=S(-n);D=S(k*m);k=P[a+3252>>2];B=l;l=P[u>>2];P[v>>2]=S(D-S(z*k))-S(B*l);P[v+4>>2]=S(S(x*m)-S(y*k))-S(p*l);P[v+8>>2]=S(S(s*m)-S(t*k))-S(r*l);m=P[f+32>>2];r=P[f>>2];s=P[f+16>>2];t=P[f+36>>2];p=P[f+4>>2];x=P[f+20>>2];y=P[f+40>>2];z=P[f+8>>2];A=P[f+24>>2];o=o+(a+272|0)|0;L[o+12>>2]=0;P[o+8>>2]=S(y*l)+S(S(z*n)+S(k*A));P[o+4>>2]=S(t*l)+S(S(p*n)+S(k*x));P[o>>2]=S(m*l)+S(S(r*n)+S(k*s));q=q+1|0;w=w+1|0;if((E|0)!=(w|0)){continue}break}}ha[L[L[c>>2]+76>>2]](c,a+1264|0,a+3248|0,q);ha[L[L[d>>2]+76>>2]](d,a+272|0,a+2256|0,q);a:{if((q|0)<=0){m=S(0xde0b6b000000000);k=S(0);l=S(0);n=S(0);x=S(0);break a}w=0;m=S(0xde0b6b000000000);x=S(0);n=S(0);l=S(0);k=S(0);while(1){Ie();u=w<<4;r=F?S(0):P[u+31464>>2];s=P[u+31456>>2];t=P[u+31460>>2];b:{if(!(+S(S(r*r)+S(S(s*s)+S(t*t)))>.01)){break b}o=u+(a+2256|0)|0;p=P[o+8>>2];y=P[o>>2];z=P[o+4>>2];o=u+(a+3248|0)|0;A=P[o+8>>2];D=P[o>>2];B=P[o+4>>2];p=S(S(r*(F?S(0):S(S(S(S(p*P[f+40>>2])+S(S(y*P[f+32>>2])+S(z*P[f+36>>2])))+P[f+56>>2])-S(S(S(A*P[e+40>>2])+S(S(D*P[e+32>>2])+S(B*P[e+36>>2])))+P[e+56>>2]))))+S(S(s*S(S(S(S(p*P[f+8>>2])+S(S(y*P[f>>2])+S(z*P[f+4>>2])))+P[f+48>>2])-S(S(S(A*P[e+8>>2])+S(S(D*P[e>>2])+S(B*P[e+4>>2])))+P[e+48>>2])))+S(t*S(S(S(S(p*P[f+24>>2])+S(S(y*P[f+16>>2])+S(z*P[f+20>>2])))+P[f+52>>2])-S(S(S(A*P[e+24>>2])+S(S(D*P[e+16>>2])+S(B*P[e+20>>2])))+P[e+52>>2])))));if(!(p>2];k=s;l=t;n=r;m=p}w=w+1|0;if((w|0)!=(q|0)){continue}break}}Dc(c);Dc(d);q=0;if(!(m>2];p=P[e+56>>2];y=P[e+48>>2];d=L[e+12>>2];c=a- -64|0;L[c>>2]=L[e+8>>2];L[c+4>>2]=d;c=L[e+4>>2];L[a+56>>2]=L[e>>2];L[a+60>>2]=c;c=L[e+28>>2];L[a+80>>2]=L[e+24>>2];L[a+84>>2]=c;c=L[e+20>>2];L[a+72>>2]=L[e+16>>2];L[a+76>>2]=c;c=L[e+40>>2];d=L[e+44>>2];w=L[e+32>>2];e=L[e+36>>2];L[a+116>>2]=0;L[a+96>>2]=c;L[a+100>>2]=d;m=S(m+S(S(r+s)+S(.5)));P[a+112>>2]=p+S(n*m);P[a+108>>2]=t+S(l*m);L[a+88>>2]=w;L[a+92>>2]=e;P[a+104>>2]=y+S(k*m);c=L[f+12>>2];L[a+128>>2]=L[f+8>>2];L[a+132>>2]=c;c=L[f+4>>2];L[a+120>>2]=L[f>>2];L[a+124>>2]=c;c=L[f+28>>2];L[a+144>>2]=L[f+24>>2];L[a+148>>2]=c;c=L[f+20>>2];L[a+136>>2]=L[f+16>>2];L[a+140>>2]=c;c=L[f+44>>2];L[a+160>>2]=L[f+40>>2];L[a+164>>2]=c;c=L[f+36>>2];L[a+152>>2]=L[f+32>>2];L[a+156>>2]=c;c=L[f+60>>2];L[a+176>>2]=L[f+56>>2];L[a+180>>2]=c;c=L[f+52>>2];L[a+168>>2]=L[f+48>>2];L[a+172>>2]=c;L[a+184>>2]=1566444395;J[a+52|0]=0;L[a+12>>2]=18720;L[b+16>>2]=0;P[b+12>>2]=-n;P[b+8>>2]=-l;P[b+4>>2]=-k;wb(b,a+56|0,a+12|0,j,0);b=M[a+52|0];if(b){r=P[a+36>>2];s=P[a+40>>2];t=P[a+32>>2];p=P[a+48>>2];L[h+12>>2]=0;m=S(m-p);P[h+8>>2]=s-S(n*m);P[h+4>>2]=r-S(l*m);P[h>>2]=t-S(k*m);c=L[a+44>>2];L[i+8>>2]=L[a+40>>2];L[i+12>>2]=c;c=L[a+36>>2];L[i>>2]=L[a+32>>2];L[i+4>>2]=c;P[g+12>>2]=x;P[g+8>>2]=n;P[g+4>>2]=l;P[g>>2]=k}q=(b|0)!=0}fa=a+4240|0;return q|0}function Dm(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0;L[a+168>>2]=L[a+152>>2];Jm(b);c=L[a+56>>2];a:{if(d){L[b+56>>2]=c<<24|(c&65280)<<8|(c>>>8&65280|c>>>24);J[b+4|0]=M[a+7|0];J[b+5|0]=M[a+6|0];J[b+6|0]=M[a+5|0];J[b+7|0]=M[a+4|0];J[b+8|0]=M[a+11|0];J[b+9|0]=M[a+10|0];J[b+10|0]=M[a+9|0];J[b+11|0]=M[a+8|0];J[b+12|0]=M[a+15|0];J[b+13|0]=M[a+14|0];J[b+14|0]=M[a+13|0];J[b+15|0]=M[a+12|0];J[b+16|0]=M[a+19|0];J[b+17|0]=M[a+18|0];J[b+18|0]=M[a+17|0];J[b+19|0]=M[a+16|0];J[b+20|0]=M[a+23|0];J[b+21|0]=M[a+22|0];J[b+22|0]=M[a+21|0];J[b+23|0]=M[a+20|0];J[b+24|0]=M[a+27|0];J[b+25|0]=M[a+26|0];J[b+26|0]=M[a+25|0];J[b+27|0]=M[a+24|0];J[b+28|0]=M[a+31|0];J[b+29|0]=M[a+30|0];J[b+30|0]=M[a+29|0];J[b+31|0]=M[a+28|0];J[b+32|0]=M[a+35|0];J[b+33|0]=M[a+34|0];J[b+34|0]=M[a+33|0];J[b+35|0]=M[a+32|0];J[b+36|0]=M[a+39|0];J[b+37|0]=M[a+38|0];J[b+38|0]=M[a+37|0];J[b+39|0]=M[a+36|0];J[b+40|0]=M[a+43|0];J[b+41|0]=M[a+42|0];J[b+42|0]=M[a+41|0];J[b+43|0]=M[a+40|0];J[b+44|0]=M[a+47|0];J[b+45|0]=M[a+46|0];J[b+46|0]=M[a+45|0];J[b+47|0]=M[a+44|0];J[b+48|0]=M[a+51|0];J[b+49|0]=M[a+50|0];J[b+50|0]=M[a+49|0];J[b+51|0]=M[a+48|0];c=L[a+168>>2];g=c<<24|(c&65280)<<8|(c>>>8&65280|c>>>24);c=L[a+144>>2];c=c<<24|(c&65280)<<8|(c>>>8&65280|c>>>24);break a}L[b+56>>2]=c;c=L[a+16>>2];L[b+12>>2]=L[a+12>>2];L[b+16>>2]=c;c=L[a+8>>2];L[b+4>>2]=L[a+4>>2];L[b+8>>2]=c;c=L[a+32>>2];L[b+28>>2]=L[a+28>>2];L[b+32>>2]=c;c=L[a+24>>2];L[b+20>>2]=L[a+20>>2];L[b+24>>2]=c;c=L[a+48>>2];L[b+44>>2]=L[a+44>>2];L[b+48>>2]=c;c=L[a+40>>2];L[b+36>>2]=L[a+36>>2];L[b+40>>2]=c;g=L[a+168>>2];c=L[a+144>>2]}L[b+168>>2]=g;L[b+144>>2]=c;J[b+60|0]=M[a+60|0];i=b+172|0;j=L[a+56>>2];b:{if(M[a+60|0]){c=L[b+136>>2];if(!(c?!c|!M[b+140|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](c)}L[b+136>>2]=i;J[b+140|0]=0;c:{if(!d){if((j|0)<=0){break c}h=L[a+136>>2];g=0;while(1){c=g<<4;f=c+i|0;c=c+h|0;K[f>>1]=N[c>>1];K[f+2>>1]=N[c+2>>1];K[f+4>>1]=N[c+4>>1];K[f+6>>1]=N[c+6>>1];K[f+8>>1]=N[c+8>>1];K[f+10>>1]=N[c+10>>1];L[f+12>>2]=L[c+12>>2];g=g+1|0;if((j|0)!=(g|0)){continue}break}break c}if((j|0)<=0){break c}h=L[a+136>>2];g=0;while(1){c=g<<4;e=c+i|0;f=c+h|0;c=N[f>>1];K[e>>1]=c<<8|c>>>8;c=N[f+2>>1];K[e+2>>1]=c<<8|c>>>8;c=N[f+4>>1];K[e+4>>1]=c<<8|c>>>8;c=N[f+6>>1];K[e+6>>1]=c<<8|c>>>8;c=N[f+8>>1];K[e+8>>1]=c<<8|c>>>8;c=N[f+10>>1];K[e+10>>1]=c<<8|c>>>8;c=L[f+12>>2];L[e+12>>2]=c<<24|(c&65280)<<8|(c>>>8&65280|c>>>24);g=g+1|0;if((j|0)!=(g|0)){continue}break}}h=b+128|0;g=j<<4;break b}c=L[b+96>>2];if(!(c?!c|!M[b+100|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](c)}L[b+96>>2]=i;J[b+100|0]=0;L[b+92>>2]=j;h=b+88|0;L[h>>2]=j;d:{if(!d){c=i;if((j|0)<=0){break d}l=L[a+96>>2];g=0;while(1){k=g<<6;e=k+c|0;f=k+l|0;c=L[f+4>>2];L[e>>2]=L[f>>2];L[e+4>>2]=c;c=L[f+12>>2];L[e+8>>2]=L[f+8>>2];L[e+12>>2]=c;f=k+L[a+96>>2]|0;c=L[f+20>>2];e=k+L[b+96>>2]|0;L[e+16>>2]=L[f+16>>2];L[e+20>>2]=c;c=L[f+28>>2];L[e+24>>2]=L[f+24>>2];L[e+28>>2]=c;c=L[b+96>>2];e=k+c|0;l=L[a+96>>2];f=k+l|0;L[e+32>>2]=L[f+32>>2];L[e+36>>2]=L[f+36>>2];L[e+40>>2]=L[f+40>>2];g=g+1|0;if((j|0)!=(g|0)){continue}break}break d}c=i;if((j|0)<=0){break d}k=L[a+96>>2];while(1){f=l<<6;e=f+c|0;c=f+k|0;J[e|0]=M[c+3|0];J[e+1|0]=M[c+2|0];J[e+2|0]=M[c+1|0];J[e+3|0]=M[c|0];J[e+4|0]=M[c+7|0];J[e+5|0]=M[c+6|0];J[e+6|0]=M[c+5|0];J[e+7|0]=M[c+4|0];J[e+8|0]=M[c+11|0];J[e+9|0]=M[c+10|0];J[e+10|0]=M[c+9|0];J[e+11|0]=M[c+8|0];J[e+12|0]=M[c+15|0];J[e+13|0]=M[c+14|0];J[e+14|0]=M[c+13|0];J[e+15|0]=M[c+12|0];e=f+L[b+96>>2]|0;c=f+L[a+96>>2]|0;J[e+16|0]=M[c+19|0];J[e+17|0]=M[c+18|0];J[e+18|0]=M[c+17|0];J[e+19|0]=M[c+16|0];J[e+20|0]=M[c+23|0];J[e+21|0]=M[c+22|0];J[e+22|0]=M[c+21|0];J[e+23|0]=M[c+20|0];J[e+24|0]=M[c+27|0];J[e+25|0]=M[c+26|0];J[e+26|0]=M[c+25|0];J[e+27|0]=M[c+24|0];J[e+28|0]=M[c+31|0];J[e+29|0]=M[c+30|0];J[e+30|0]=M[c+29|0];J[e+31|0]=M[c+28|0];c=L[b+96>>2];e=f+c|0;k=L[a+96>>2];f=f+k|0;g=L[f+32>>2];L[e+32>>2]=g<<24|(g&65280)<<8|(g>>>8&65280|g>>>24);g=L[f+36>>2];L[e+36>>2]=g<<24|(g&65280)<<8|(g>>>8&65280|g>>>24);f=L[f+40>>2];L[e+40>>2]=f<<24|(f&65280)<<8|(f>>>8&65280|f>>>24);l=l+1|0;if((j|0)!=(l|0)){continue}break}}g=j<<6;if(!M[b+100|0]){break b}if(c){L[8514]=L[8514]+1;ha[L[6799]](c)}}L[h>>2]=0;L[h+4>>2]=0;J[h+5|0]=0;J[h+6|0]=0;J[h+7|0]=0;J[h+8|0]=0;J[h+9|0]=0;J[h+10|0]=0;J[h+11|0]=0;J[h+12|0]=0;h=g+i|0;i=L[a+168>>2];c=L[b+160>>2];if(!(c?!c|!M[b+164|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](c)}L[b+160>>2]=h;J[b+164|0]=0;L[b+156>>2]=i;L[b+152>>2]=i;i=L[a+168>>2];e:{if(!d){if((i|0)<=0){break e}i=L[a+160>>2];d=0;while(1){c=d<<5;f=c+h|0;c=c+i|0;K[f>>1]=N[c>>1];K[f+2>>1]=N[c+2>>1];K[f+4>>1]=N[c+4>>1];K[f+6>>1]=N[c+6>>1];K[f+8>>1]=N[c+8>>1];K[f+10>>1]=N[c+10>>1];L[f+12>>2]=L[c+12>>2];c=L[c+16>>2];L[f+28>>2]=0;L[f+20>>2]=0;L[f+24>>2]=0;L[f+16>>2]=c;d=d+1|0;if((d|0)>2]){continue}break}break e}if((i|0)<=0){break e}c=L[a+160>>2];d=0;while(1){a=d<<5;e=a+h|0;f=a+c|0;a=N[f>>1];K[e>>1]=a<<8|a>>>8;a=N[f+2>>1];K[e+2>>1]=a<<8|a>>>8;a=N[f+4>>1];K[e+4>>1]=a<<8|a>>>8;a=N[f+6>>1];K[e+6>>1]=a<<8|a>>>8;a=N[f+8>>1];K[e+8>>1]=a<<8|a>>>8;a=N[f+10>>1];K[e+10>>1]=a<<8|a>>>8;a=L[f+12>>2];L[e+12>>2]=a<<24|(a&65280)<<8|(a>>>8&65280|a>>>24);a=L[f+16>>2];L[e+16>>2]=a<<24|(a&65280)<<8|(a>>>8&65280|a>>>24);d=d+1|0;if((i|0)!=(d|0)){continue}break}}if(h?M[b+164|0]:0){L[8514]=L[8514]+1;ha[L[6799]](h)}L[b>>2]=0;J[b+157|0]=0;J[b+158|0]=0;J[b+159|0]=0;J[b+160|0]=0;J[b+161|0]=0;J[b+162|0]=0;J[b+163|0]=0;J[b+164|0]=0;L[b+152>>2]=0;L[b+156>>2]=0;return 1}function Tk(a,b){a=a|0;b=S(b);var c=0,d=0,e=0,f=0,g=S(0),h=0,i=S(0),j=0,k=0,l=S(0),m=S(0),n=S(0),o=S(0),p=0,q=S(0),r=0,s=0,t=0,u=0,v=0,w=S(0),x=0,y=S(0),z=S(0),A=S(0),B=S(0),C=S(0),D=S(0),E=S(0),F=S(0),G=S(0),H=0,I=S(0),O=S(0);wa(3084);d=L[a+84>>2];if(d){ha[d|0](a,b)}ha[L[L[a>>2]+140>>2]](a,b);L[a+32>>2]=0;P[a+28>>2]=b;L[a+48>>2]=ha[L[L[a>>2]+20>>2]](a);c=fa-464|0;fa=c;wa(2572);wa(2833);if(L[a+308>>2]>0){while(1){d=L[a+24>>2];ha[L[L[d>>2]+16>>2]](d,L[L[a+316>>2]+(k<<2)>>2]);k=k+1|0;if((k|0)>2]){continue}break}}d=L[a+316>>2];if(!(d?!d|!M[a+320|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](d)}L[a+316>>2]=0;J[a+320|0]=1;L[a+308>>2]=0;L[a+312>>2]=0;va();if(L[a+232>>2]>0){s=c- -64|0;k=0;while(1){e=L[L[a+240>>2]+(k<<2)>>2];L[e+244>>2]=1065353216;a:{b:{switch(L[e+216>>2]-2|0){case 0:case 3:break a;default:break b}}if(M[e+204|0]&3){break a}ue(e,b,c+400|0);if(!M[a+44|0]){break a}g=P[e+252>>2];g=S(g*g);if(g==S(0)){break a}i=S(P[c+456>>2]-P[e+60>>2]);l=S(i*i);i=S(P[c+448>>2]-P[e+52>>2]);q=S(i*i);i=S(P[c+452>>2]-P[e+56>>2]);if(!(g>2]+4>>2]<=19){L[8289]=L[8289]+1;d=L[a+68>>2];d=ha[L[L[d>>2]+36>>2]](d)|0;h=L[a+24>>2];L[c+308>>2]=1065353216;L[c+312>>2]=-65535;f=L[e+64>>2];L[c+324>>2]=L[e+60>>2];L[c+328>>2]=f;f=L[e+56>>2];L[c+316>>2]=L[e+52>>2];L[c+320>>2]=f;f=L[c+460>>2];L[c+340>>2]=L[c+456>>2];L[c+344>>2]=f;f=L[c+452>>2];L[c+332>>2]=L[c+448>>2];L[c+336>>2]=f;L[c+396>>2]=h;L[c+392>>2]=d;L[c+388>>2]=0;L[c+304>>2]=20724;L[c+380>>2]=0;L[c+384>>2]=e;g=P[e+248>>2];h=c+252|0;d=h;L[d+4>>2]=35;L[d+8>>2]=0;L[d>>2]=14328;L[d+44>>2]=1025758986;L[d+12>>2]=1065353216;L[d+16>>2]=1065353216;L[d>>2]=14044;L[d+20>>2]=1065353216;L[d+24>>2]=0;L[d>>2]=16192;P[c+296>>2]=g;P[c+280>>2]=g;L[c+256>>2]=8;P[c+388>>2]=P[a+56>>2];d=L[e+188>>2];K[c+312>>1]=N[d+4>>1];K[c+314>>1]=N[d+6>>1];d=L[c+412>>2];L[c+192>>2]=L[c+408>>2];L[c+196>>2]=d;d=L[c+404>>2];L[c+184>>2]=L[c+400>>2];L[c+188>>2]=d;d=L[c+428>>2];L[c+208>>2]=L[c+424>>2];L[c+212>>2]=d;d=L[c+420>>2];L[c+200>>2]=L[c+416>>2];L[c+204>>2]=d;d=L[c+444>>2];L[c+224>>2]=L[c+440>>2];L[c+228>>2]=d;d=L[c+436>>2];L[c+216>>2]=L[c+432>>2];L[c+220>>2]=d;d=L[c+460>>2];L[c+240>>2]=L[c+456>>2];L[c+244>>2]=d;d=L[c+452>>2];L[c+232>>2]=L[c+448>>2];L[c+236>>2]=d;d=e+4|0;f=L[d+12>>2];L[c+192>>2]=L[d+8>>2];L[c+196>>2]=f;f=L[d+4>>2];L[c+184>>2]=L[d>>2];L[c+188>>2]=f;f=L[e+32>>2];L[c+208>>2]=L[e+28>>2];L[c+212>>2]=f;f=L[e+24>>2];L[c+200>>2]=L[e+20>>2];L[c+204>>2]=f;f=L[e+48>>2];L[c+224>>2]=L[e+44>>2];L[c+228>>2]=f;f=L[e+40>>2];L[c+216>>2]=L[e+36>>2];L[c+220>>2]=f;Ab(a,h,d,c+184|0,c+304|0,S(0));g=P[c+308>>2];if(g>2]-P[e+52>>2]));n=S(g*S(P[c+452>>2]-P[e+56>>2]));o=S(g*S(P[c+456>>2]-P[e+60>>2]));G=S(S(S(m*S(-P[c+348>>2]))-S(n*P[c+352>>2]))-S(o*P[c+356>>2]));d=L[a+24>>2];u=ha[L[L[d>>2]+12>>2]](d,e,L[c+380>>2])|0;d=L[a+308>>2];c:{if((d|0)!=L[a+312>>2]){break c}t=d?d<<1:1;if((t|0)<=(d|0)){break c}d:{if(!t){h=0;break d}L[8513]=L[8513]+1;h=ha[L[6798]](t<<2,16)|0;d=L[a+308>>2]}e:{if((d|0)<=0){break e}v=0;f=0;if(d>>>0>=4){H=d&-4;p=0;while(1){j=f<<2;L[j+h>>2]=L[j+L[a+316>>2]>>2];r=j|4;L[r+h>>2]=L[r+L[a+316>>2]>>2];r=j|8;L[r+h>>2]=L[r+L[a+316>>2]>>2];j=j|12;L[j+h>>2]=L[j+L[a+316>>2]>>2];f=f+4|0;p=p+4|0;if((H|0)!=(p|0)){continue}break}}j=d&3;if(!j){break e}while(1){p=f<<2;L[p+h>>2]=L[p+L[a+316>>2]>>2];f=f+1|0;v=v+1|0;if((j|0)!=(v|0)){continue}break}}f=L[a+316>>2];if(!(!f|!M[a+320|0])){if(f){L[8514]=L[8514]+1;ha[L[6799]](f)}d=L[a+308>>2]}L[a+316>>2]=h;J[a+320|0]=1;L[a+312>>2]=t}L[L[a+316>>2]+(d<<2)>>2]=u;L[a+308>>2]=d+1;d=L[c+380>>2];y=P[d+20>>2];z=P[d+36>>2];A=P[d+40>>2];B=P[d+8>>2];C=P[d+24>>2];g=P[d+60>>2];I=P[d+52>>2];i=P[d+56>>2];D=P[d+44>>2];l=P[d+12>>2];E=P[d+28>>2];F=P[d+4>>2];q=P[e+60>>2];w=P[e+52>>2];O=P[e+56>>2];L[c+8>>2]=0;L[c+12>>2]=0;L[c>>2]=0;L[c+4>>2]=0;L[c+28>>2]=0;o=S(o+q);m=S(m+w);n=S(n+O);w=S(S(D*o)+S(S(l*m)+S(E*n)));q=l;l=S(-I);P[c+24>>2]=w+S(S(S(q*l)-S(E*i))-S(D*g));P[c+20>>2]=S(S(o*A)+S(S(m*B)+S(n*C)))+S(S(S(B*l)-S(C*i))-S(A*g));P[c+16>>2]=S(S(o*z)+S(S(m*F)+S(n*y)))+S(S(S(F*l)-S(y*i))-S(z*g));d=L[c+360>>2];L[s+8>>2]=L[c+356>>2];L[s+12>>2]=d;d=L[c+352>>2];L[s>>2]=L[c+348>>2];L[s+4>>2]=d;J[c+116|0]=0;L[c+112>>2]=0;L[c+92>>2]=0;L[c+84>>2]=0;L[c+88>>2]=0;P[c+80>>2]=G;L[c+144>>2]=0;L[c+148>>2]=0;L[c+136>>2]=0;L[c+140>>2]=0;L[c+128>>2]=0;L[c+132>>2]=0;L[c+120>>2]=0;L[c+124>>2]=0;d=R(Fl(u,c),184)+u|0;L[d+96>>2]=0;g=S(P[e+224>>2]*P[L[c+380>>2]+224>>2]);g=g>2]=g>S(10)?S(10):g;h=L[e+56>>2];L[d+52>>2]=L[e+52>>2];L[d+56>>2]=h;h=L[e+64>>2];L[d+60>>2]=L[e+60>>2];L[d+64>>2]=h;L[d+48>>2]=0;P[d+44>>2]=o;P[d+40>>2]=n;P[d+36>>2]=m}}va()}k=k+1|0;if((k|0)>2]){continue}break}}va();fa=c+464|0;ha[L[L[a>>2]+44>>2]](a);ha[L[L[a>>2]+148>>2]](a);P[a+104>>2]=b;ha[L[L[a>>2]+152>>2]](a,a+92|0);ha[L[L[a>>2]+144>>2]](a,b);wa(2678);if(L[a+280>>2]>0){while(1){d=L[L[a+288>>2]+(x<<2)>>2];ha[L[L[d>>2]+8>>2]](d,a,b);x=x+1|0;if((x|0)>2]){continue}break}}va();ha[L[L[a>>2]+156>>2]](a,b);d=L[a+80>>2];if(d){ha[d|0](a,b)}va()}function cq(a,b,c){a=a|0;b=b|0;c=S(c);var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=S(0),p=S(0),q=S(0);m=fa-16|0;fa=m;L[m+12>>2]=a;L[m+8>>2]=b;P[m+4>>2]=c;a=L[m+8>>2];o=P[m+4>>2];b=0;l=fa-32|0;fa=l;d=L[m+12>>2];if(L[d+716>>2]==L[d+712>>2]){h=L[d+720>>2];g=L[d+712>>2];a:{if((g|0)<=0){break a}if((g|0)!=1){i=g&-2;while(1){k=L[(L[d+720>>2]+R(e,104)|0)+96>>2];if(k){L[k+36>>2]=e}k=e|1;n=L[(L[d+720>>2]+R(k,104)|0)+96>>2];if(n){L[n+36>>2]=k}e=e+2|0;f=f+2|0;if((i|0)!=(f|0)){continue}break}}if(!(g&1)){break a}f=L[(L[d+720>>2]+R(e,104)|0)+96>>2];if(!f){break a}L[f+36>>2]=e}g=g?h:0;f=L[d+732>>2];if((f|0)>0){e=0;while(1){h=R(e,52);i=h+L[d+740>>2]|0;L[i+8>>2]=(L[i+8>>2]-g|0)/104;h=h+L[d+740>>2]|0;L[h+12>>2]=(L[h+12>>2]-g|0)/104;e=e+1|0;if((f|0)!=(e|0)){continue}break}}h=L[d+752>>2];if((h|0)>0){f=0;while(1){e=R(f,44);i=e+L[d+760>>2]|0;L[i+8>>2]=(L[i+8>>2]-g|0)/104;i=e+L[d+760>>2]|0;L[i+12>>2]=(L[i+12>>2]-g|0)/104;i=e+L[d+760>>2]|0;L[i+16>>2]=(L[i+16>>2]-g|0)/104;e=L[(e+L[d+760>>2]|0)+40>>2];if(e){L[e+36>>2]=f}f=f+1|0;if((h|0)!=(f|0)){continue}break}}f=L[d+792>>2];b:{if((f|0)<=0){break b}h=L[d+800>>2];e=0;if((f|0)!=1){k=f&-2;i=0;while(1){n=h+R(e,96)|0;L[n>>2]=(L[n>>2]-g|0)/104;n=h+R(e|1,96)|0;L[n>>2]=(L[n>>2]-g|0)/104;e=e+2|0;i=i+2|0;if((k|0)!=(i|0)){continue}break}}if(!(f&1)){break b}e=h+R(e,96)|0;L[e>>2]=(L[e>>2]-g|0)/104}k=L[d+692>>2];if((k|0)>0){f=L[d+700>>2];h=0;while(1){e=0;i=R(h,60);if(L[(i+f|0)+24>>2]>0){while(1){f=(f+i|0)+(e<<2)|0;L[f+28>>2]=(L[f+28>>2]-g|0)/104;e=e+1|0;f=L[d+700>>2];if((e|0)>2]){continue}break}}h=h+1|0;if((k|0)!=(h|0)){continue}break}}g=L[d+712>>2]<<1|1;if((g|0)>L[d+716>>2]){L[8513]=L[8513]+1;e=ha[L[6798]](R(g,104),16)|0;f=L[d+712>>2];c:{if((f|0)<=0){break c}if((f|0)!=1){h=f&-2;while(1){i=R(j,104);qa(i+e|0,i+L[d+720>>2]|0,104);i=R(j|1,104);qa(i+e|0,i+L[d+720>>2]|0,104);j=j+2|0;b=b+2|0;if((h|0)!=(b|0)){continue}break}}if(!(f&1)){break c}b=R(j,104);qa(b+e|0,b+L[d+720>>2]|0,104)}b=L[d+720>>2];if(!(b?!b|!M[d+724|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[d+720>>2]=e;J[d+724|0]=1;L[d+716>>2]=g}b=0;f=0;j=L[d+720>>2];e=L[d+712>>2];d:{if((e|0)<=0){break d}if((e|0)!=1){g=e&-2;while(1){h=L[d+720>>2]+R(b,104)|0;i=L[h+96>>2];if(i){L[i+36>>2]=h}h=L[d+720>>2]+R(b|1,104)|0;i=L[h+96>>2];if(i){L[i+36>>2]=h}b=b+2|0;f=f+2|0;if((g|0)!=(f|0)){continue}break}}if(!(e&1)){break d}b=L[d+720>>2]+R(b,104)|0;f=L[b+96>>2];if(!f){break d}L[f+36>>2]=b}e=e?j:0;j=L[d+732>>2];e:{if((j|0)<=0){break e}b=0;if((j|0)!=1){g=j&-2;f=0;while(1){h=R(b,52);i=h+L[d+740>>2]|0;L[i+8>>2]=e+R(L[i+8>>2],104);h=h+L[d+740>>2]|0;L[h+12>>2]=e+R(L[h+12>>2],104);h=R(b|1,52);i=h+L[d+740>>2]|0;L[i+8>>2]=e+R(L[i+8>>2],104);h=h+L[d+740>>2]|0;L[h+12>>2]=e+R(L[h+12>>2],104);b=b+2|0;f=f+2|0;if((g|0)!=(f|0)){continue}break}}if(!(j&1)){break e}b=R(b,52);f=b+L[d+740>>2]|0;L[f+8>>2]=e+R(L[f+8>>2],104);b=b+L[d+740>>2]|0;L[b+12>>2]=e+R(L[b+12>>2],104)}j=L[d+752>>2];if((j|0)>0){b=0;while(1){f=R(b,44);g=f+L[d+760>>2]|0;L[g+8>>2]=e+R(L[g+8>>2],104);g=f+L[d+760>>2]|0;L[g+12>>2]=e+R(L[g+12>>2],104);g=f+L[d+760>>2]|0;L[g+16>>2]=e+R(L[g+16>>2],104);f=f+L[d+760>>2]|0;g=L[f+40>>2];if(g){L[g+36>>2]=f}b=b+1|0;if((j|0)!=(b|0)){continue}break}}g=L[d+792>>2];f:{if((g|0)<=0){break f}f=L[d+800>>2];h=0;b=0;if(g>>>0>=4){i=g&-4;j=0;while(1){k=f+R(b,96)|0;L[k>>2]=e+R(L[k>>2],104);k=f+R(b|1,96)|0;L[k>>2]=e+R(L[k>>2],104);k=f+R(b|2,96)|0;L[k>>2]=e+R(L[k>>2],104);k=f+R(b|3,96)|0;L[k>>2]=e+R(L[k>>2],104);b=b+4|0;j=j+4|0;if((i|0)!=(j|0)){continue}break}}j=g&3;if(!j){break f}while(1){g=f+R(b,96)|0;L[g>>2]=e+R(L[g>>2],104);b=b+1|0;h=h+1|0;if((j|0)!=(h|0)){continue}break}}h=L[d+692>>2];if((h|0)>0){b=L[d+700>>2];j=0;while(1){f=0;g=R(j,60);if(L[(g+b|0)+24>>2]>0){while(1){b=(b+g|0)+(f<<2)|0;L[b+28>>2]=e+R(L[b+28>>2],104);f=f+1|0;b=L[d+700>>2];if((f|0)>2]){continue}break}}j=j+1|0;if((h|0)!=(j|0)){continue}break}}}b=L[d+192>>2];c=S(ha[L[L[b>>2]+48>>2]](b));b=L[d+712>>2];g:{if((b|0)!=L[d+716>>2]){break g}f=b?b<<1:1;if((f|0)<=(b|0)){break g}h:{if(!f){e=0;break h}L[8513]=L[8513]+1;e=ha[L[6798]](R(f,104),16)|0;b=L[d+712>>2]}i:{if((b|0)<=0){break i}g=b&1;j=0;if((b|0)!=1){h=b&-2;b=0;while(1){i=R(j,104);qa(i+e|0,i+L[d+720>>2]|0,104);i=R(j|1,104);qa(i+e|0,i+L[d+720>>2]|0,104);j=j+2|0;b=b+2|0;if((h|0)!=(b|0)){continue}break}}if(!g){break i}b=R(j,104);qa(b+e|0,b+L[d+720>>2]|0,104)}b=L[d+720>>2];if(!(b?!b|!M[d+724|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[d+720>>2]=e;J[d+724|0]=1;L[d+716>>2]=f;b=L[d+712>>2]}pa(L[d+720>>2]+R(b,104)|0,0,104);b=L[d+712>>2];L[d+712>>2]=b+1;b=pa(L[d+720>>2]+R(b,104)|0,0,104);e=L[a+12>>2];L[b+16>>2]=L[a+8>>2];L[b+20>>2]=e;e=L[a+4>>2];L[b+8>>2]=L[a>>2];L[b+12>>2]=e;e=L[a>>2];f=L[a+4>>2];j=L[a+12>>2];L[b+32>>2]=L[a+8>>2];L[b+36>>2]=j;L[b+24>>2]=e;L[b+28>>2]=f;P[b+88>>2]=o>S(0)?S(S(1)/o):S(0);L[b+4>>2]=L[L[d+880>>2]>>2];o=P[b+8>>2];p=P[b+12>>2];q=P[b+16>>2];L[l+28>>2]=0;P[l+24>>2]=c+q;P[l+20>>2]=c+p;L[l+12>>2]=0;P[l+16>>2]=c+o;P[l+8>>2]=q-c;P[l+4>>2]=p-c;P[l>>2]=o-c;L[b+96>>2]=Bb(d+928|0,l,b);fa=l+32|0;fa=m+16|0}function aB(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=S(0),g=0,h=S(0),i=0,j=S(0),k=S(0),l=0,m=S(0),n=S(0),o=0,p=0;c=L[d+64>>2];a:{if(!(c&4)){break a}b=L[a+28>>2];if((b|0)<=0){break a}l=L[a+76>>2];i=L[a+36>>2];if(c&16){c=0;while(1){e=i+R(c,152)|0;g=L[e+132>>2];P[g+120>>2]=P[e+100>>2];e=l+R(L[e+140>>2],152)|0;P[g+124>>2]=P[e+100>>2];P[g+128>>2]=P[e+252>>2];c=c+1|0;if((b|0)!=(c|0)){continue}break}break a}c=0;if((b|0)!=1){p=b&-2;while(1){g=i+R(c,152)|0;o=L[g+132>>2];P[o+120>>2]=P[g+100>>2];P[o+124>>2]=P[(l+R(L[g+140>>2],152)|0)+100>>2];g=i+R(c|1,152)|0;o=L[g+132>>2];P[o+120>>2]=P[g+100>>2];P[o+124>>2]=P[(l+R(L[g+140>>2],152)|0)+100>>2];c=c+2|0;e=e+2|0;if((p|0)!=(e|0)){continue}break}}if(!(b&1)){break a}b=i+R(c,152)|0;c=L[b+132>>2];P[c+120>>2]=P[b+100>>2];P[c+124>>2]=P[(l+R(L[b+140>>2],152)|0)+100>>2]}p=L[a+48>>2];if((p|0)>0){o=L[a+56>>2];l=0;while(1){c=o+R(l,152)|0;e=L[c+132>>2];b=L[e+44>>2];if(b){i=L[e+28>>2];j=P[i+356>>2];k=P[c+24>>2];m=P[i+352>>2];n=P[c+20>>2];f=P[c+100>>2];h=S(S(1)/P[d+12>>2]);P[b>>2]=P[b>>2]+S(S(S(P[c+16>>2]*f)*P[i+348>>2])*h);P[b+4>>2]=S(S(m*S(f*n))*h)+P[b+4>>2];P[b+8>>2]=S(S(j*S(f*k))*h)+P[b+8>>2];g=L[e+32>>2];j=P[g+356>>2];k=P[c+56>>2];m=P[g+352>>2];n=P[c+52>>2];f=P[c+100>>2];h=S(S(1)/P[d+12>>2]);P[b+32>>2]=P[b+32>>2]+S(S(S(P[c+48>>2]*f)*P[g+348>>2])*h);P[b+36>>2]=S(S(m*S(f*n))*h)+P[b+36>>2];P[b+40>>2]=S(S(j*S(f*k))*h)+P[b+40>>2];j=P[i+552>>2];k=P[c+8>>2];m=P[i+548>>2];n=P[c+4>>2];f=P[c+100>>2];h=S(S(1)/P[d+12>>2]);P[b+16>>2]=P[b+16>>2]+S(S(S(P[c>>2]*P[i+544>>2])*f)*h);P[b+20>>2]=S(S(f*S(n*m))*h)+P[b+20>>2];P[b+24>>2]=S(S(f*S(k*j))*h)+P[b+24>>2];j=P[g+552>>2];k=P[c+40>>2];m=P[g+548>>2];n=P[c+36>>2];f=P[c+100>>2];h=S(S(1)/P[d+12>>2]);P[b+48>>2]=P[b+48>>2]+S(S(S(P[c+32>>2]*P[g+544>>2])*f)*h);P[b+52>>2]=S(S(f*S(n*m))*h)+P[b+52>>2];P[b+56>>2]=S(S(f*S(k*j))*h)+P[b+56>>2]}f=P[c+100>>2];P[e+36>>2]=f;if(P[e+16>>2]<=S(T(f))){J[e+20|0]=0}l=l+1|0;if((p|0)!=(l|0)){continue}break}}l=L[a+8>>2];if((l|0)>0){e=L[a+16>>2];g=0;while(1){i=R(g,244);b=i+e|0;c=L[b+240>>2];if(c){b:{if(L[d+44>>2]){m=P[d+12>>2];f=P[d+52>>2];c=fa-80|0;fa=c;c:{if(!L[b+240>>2]){break c}P[b+176>>2]=P[b+64>>2]+P[b+176>>2];P[b+192>>2]=P[b+80>>2]+P[b+192>>2];P[b+180>>2]=P[b+68>>2]+P[b+180>>2];P[b+184>>2]=P[b+72>>2]+P[b+184>>2];P[b+196>>2]=P[b+84>>2]+P[b+196>>2];P[b+200>>2]=P[b+88>>2]+P[b+200>>2];k=P[b+160>>2];d:{if(!(!(P[b+144>>2]!=S(0)|P[b+148>>2]!=S(0))&P[b+152>>2]==S(0))){h=P[b+168>>2];j=P[b+164>>2];break d}h=P[b+168>>2];j=P[b+164>>2];if(k!=S(0)|j!=S(0)){break d}if(h==S(0)){break c}}L[c+12>>2]=0;P[c+8>>2]=h*f;P[c+4>>2]=j*f;P[c>>2]=k*f;Rb(b,b+144|0,c,m,c+16|0);e=L[c+28>>2];L[b+8>>2]=L[c+24>>2];L[b+12>>2]=e;e=L[c+20>>2];L[b>>2]=L[c+16>>2];L[b+4>>2]=e;e=L[c+44>>2];L[b+24>>2]=L[c+40>>2];L[b+28>>2]=e;e=L[c+36>>2];L[b+16>>2]=L[c+32>>2];L[b+20>>2]=e;e=L[c+52>>2];L[b+32>>2]=L[c+48>>2];L[b+36>>2]=e;e=L[c+60>>2];L[b+40>>2]=L[c+56>>2];L[b+44>>2]=e;e=L[c+68>>2];L[b+48>>2]=L[c+64>>2];L[b+52>>2]=e;e=L[c+76>>2];L[b+56>>2]=L[c+72>>2];L[b+60>>2]=e}fa=c+80|0;e=L[a+16>>2];b=i+e|0;f=P[b+176>>2];c=L[b+240>>2];break b}f=S(P[b+64>>2]+P[b+176>>2]);P[b+176>>2]=f;P[b+192>>2]=P[b+80>>2]+P[b+192>>2];P[b+180>>2]=P[b+68>>2]+P[b+180>>2];P[b+184>>2]=P[b+72>>2]+P[b+184>>2];P[b+196>>2]=P[b+84>>2]+P[b+196>>2];P[b+200>>2]=P[b+88>>2]+P[b+200>>2]}b=e+i|0;h=P[b+212>>2];j=P[b+180>>2];k=P[b+216>>2];m=P[b+184>>2];n=P[b+208>>2];L[c+324>>2]=0;P[c+312>>2]=f+n;L[c+260>>2]=L[c+260>>2]+1;P[c+320>>2]=m+k;P[c+316>>2]=j+h;b=i+L[a+16>>2]|0;f=P[b+228>>2];h=P[b+196>>2];j=P[b+232>>2];k=P[b+200>>2];m=P[b+224>>2];n=P[b+192>>2];b=L[b+240>>2];L[b+340>>2]=0;P[b+328>>2]=n+m;P[b+336>>2]=k+j;P[b+332>>2]=h+f;L[b+260>>2]=L[b+260>>2]+1;if(L[d+44>>2]){c=i+L[a+16>>2]|0;b=L[c+240>>2];L[b+260>>2]=L[b+260>>2]+1;e=L[c+12>>2];L[b+12>>2]=L[c+8>>2];L[b+16>>2]=e;e=L[c+4>>2];L[b+4>>2]=L[c>>2];L[b+8>>2]=e;e=L[c+28>>2];L[b+28>>2]=L[c+24>>2];L[b+32>>2]=e;e=L[c+20>>2];L[b+20>>2]=L[c+16>>2];L[b+24>>2]=e;e=L[c+36>>2];L[b+36>>2]=L[c+32>>2];L[b+40>>2]=e;e=L[c+44>>2];L[b+44>>2]=L[c+40>>2];L[b+48>>2]=e;e=L[c+60>>2];L[b+60>>2]=L[c+56>>2];L[b+64>>2]=e;e=L[c+52>>2];L[b+52>>2]=L[c+48>>2];L[b+56>>2]=e}e=L[a+16>>2];L[L[(i+e|0)+240>>2]+212>>2]=-1;l=L[a+8>>2]}g=g+1|0;if((l|0)>(g|0)){continue}break}}if((L[a+28>>2]&L[a+32>>2])<0){b=L[a+36>>2];if(!(b?!b|!M[a+40|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}J[a+40|0]=1;L[a+32>>2]=0;L[a+36>>2]=0}L[a+28>>2]=0;if((L[a+48>>2]&L[a+52>>2])<0){b=L[a+56>>2];if(!(b?!b|!M[a+60|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}J[a+60|0]=1;L[a+52>>2]=0;L[a+56>>2]=0}L[a+48>>2]=0;if((L[a+68>>2]&L[a+72>>2])<0){b=L[a+76>>2];if(!(b?!b|!M[a+80|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}J[a+80|0]=1;L[a+72>>2]=0;L[a+76>>2]=0}L[a+68>>2]=0;if((L[a+88>>2]&L[a+92>>2])<0){b=L[a+96>>2];if(!(b?!b|!M[a+100|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}J[a+100|0]=1;L[a+92>>2]=0;L[a+96>>2]=0}L[a+88>>2]=0;if((L[a+8>>2]&L[a+12>>2])<0){b=L[a+16>>2];if(!(b?!b|!M[a+20|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}J[a+20|0]=1;L[a+12>>2]=0;L[a+16>>2]=0}L[a+8>>2]=0;return S(S(0))}function yz(a,b,c){a=a|0;b=b|0;c=c|0;var d=S(0),e=0,f=S(0),g=S(0),h=S(0),i=S(0),j=0,k=0,l=S(0),m=S(0),n=S(0),o=S(0),p=S(0),q=S(0),r=S(0),s=S(0),t=S(0),u=S(0),v=S(0),w=S(0),x=S(0),y=0,z=S(0),A=S(0),B=S(0),C=S(0),D=S(0),E=S(0),F=S(0),G=S(0),H=S(0),I=S(0),K=S(0),N=0,O=S(0),Q=S(0),T=0,U=0,V=S(0),W=S(0),X=S(0),Y=S(0),Z=S(0),$=S(0),aa=S(0),ba=S(0),ca=S(0),da=0,ea=S(0),fa=0;N=L[c+36>>2];c=L[N+12>>2];V=P[c+8>>2];y=L[b+36>>2];E=P[y+8>>2];F=S(V-E);b=L[N+8>>2];W=P[b+8>>2];m=S(W-E);p=S(F-m);e=L[N+16>>2];X=P[e+12>>2];G=P[y+12>>2];u=S(X-G);Y=P[b+12>>2];l=S(Y-G);i=S(u-l);Z=P[e+8>>2];v=S(Z-E);d=S(v-m);$=P[c+12>>2];H=S($-G);n=S(H-l);w=S(S(p*i)-S(d*n));aa=P[e+16>>2];I=P[y+16>>2];x=S(aa-I);ba=P[b+16>>2];o=S(ba-I);f=S(x-o);ca=P[c+16>>2];K=S(ca-I);B=S(K-o);C=S(S(n*f)-S(i*B));D=S(S(B*d)-S(f*p));d=S(S(w*w)+S(S(C*C)+S(D*D)));a:{if(!(d>S(1.1920928955078125e-7))){i=S(34028234663852886e22);break a}i=S(34028234663852886e22);d=S(S(1)/S(_(d)));z=S(w*d);f=S(C*d);A=S(D*d);h=S(S(o*z)+S(S(m*f)+S(l*A)));g=S(h*h);if(!(gS(0))){break c}O=S(u-f);Q=S(v-d);ea=S(S(S(s*O)-S(Q*i))*w);t=i;i=S(x-h);if(!(S(ea+S(S(S(S(t*i)-S(O*r))*C)+S(D*S(S(r*Q)-S(i*s)))))>S(0))){break c}if(S(S(S(S(Q*A)-S(q*O))*w)+S(S(S(S(O*z)-S(A*i))*C)+S(D*S(S(i*q)-S(z*Q)))))>S(0)){break b}}d=S(S(B*B)+S(S(p*p)+S(n*n)));i=S(34028234663852886e22);d:{if(!(d>S(1.1920928955078125e-7))){break d}q=S(S(-S(S(o*B)+S(S(m*p)+S(l*n))))/d);r=qS(1)?S(1):q;q=S(o+S(B*r));s=S(m+S(p*r));r=S(l+S(n*r));d=S(S(q*q)+S(S(s*s)+S(r*r)));i=S(34028234663852886e22);if(!(dS(1.1920928955078125e-7))){break e}t=d;d=S(S(-S(S(K*d)+S(S(F*f)+S(H*h))))/g);g=dS(1)?S(1):d;d=S(K+S(t*g));f=S(F+S(f*g));h=S(H+S(h*g));g=S(S(d*d)+S(S(f*f)+S(h*h)));if(!(gS(1.1920928955078125e-7))){break a}t=d;d=S(S(-S(S(x*d)+S(S(v*f)+S(u*g))))/h);m=dS(1)?S(1):d;h=S(x+S(t*m));d=S(v+S(f*m));f=S(u+S(g*m));g=S(S(h*h)+S(S(d*d)+S(f*f)));if(!(g>2]);g=S(d*d);d=S(E-P[y+24>>2]);f=S(d*d);d=S(G-P[y+28>>2]);d=S(_(S(g+S(f+S(d*d)))));u=S(S(d+d)+P[a+12>>2]);f:{if(!(S(u*u)>i)){break f}o=S(E+s);d=S(W-o);p=S(G+r);f=S($-p);h=S(V-o);g=S(Y-p);v=S(S(d*f)-S(h*g));n=S(I+q);m=S(ca-n);l=S(ba-n);w=S(S(g*m)-S(f*l));o=S(Z-o);p=S(X-p);x=S(S(o*g)-S(d*p));t=g;g=S(aa-n);n=S(S(p*l)-S(t*g));t=S(n*n);n=S(S(g*d)-S(l*o));n=S(_(S(S(x*x)+S(t+S(n*n)))));d=S(S(l*h)-S(m*d));l=S(_(S(S(v*v)+S(S(w*w)+S(d*d)))));d=S(S(h*p)-S(o*f));t=S(d*d);d=S(S(f*g)-S(p*m));f=S(d*d);d=S(S(m*o)-S(g*h));f=S(_(S(t+S(f+S(d*d)))));d=S(S(1)/S(n+S(l+f)));h=P[y+88>>2];g=P[e+88>>2];m=S(l*d);l=P[b+88>>2];f=S(f*d);o=S(n*d);d=P[c+88>>2];g=l<=S(0)?S(0):d<=S(0)?S(0):g<=S(0)?S(0):S(S(g*m)+S(S(l*f)+S(o*d)));d=S(h+g);if(!(d>S(0))){break f}b=L[a+4>>2];l=P[b+316>>2];a=L[a+8>>2];p=P[a+316>>2];l=l>p?l:p;h=S(S(h/d)*P[b+332>>2]);d=S(S(g/d)*P[a+332>>2]);i=S(S(-1)/S(_(i)));q=S(i*q);r=S(i*r);i=S(s*i);c=L[b+832>>2];g:{if((c|0)!=L[b+836>>2]){break g}T=c?c<<1:1;if((T|0)<=(c|0)){break g}if(T){L[8513]=L[8513]+1;U=ha[L[6798]](R(T,56),16)|0;c=L[b+832>>2]}h:{if((c|0)<=0){break h}a=0;if((c|0)!=1){fa=c&-2;while(1){e=R(a,56);j=e+U|0;e=e+L[b+840>>2]|0;k=L[e+4>>2];L[j>>2]=L[e>>2];L[j+4>>2]=k;k=L[e+52>>2];L[j+48>>2]=L[e+48>>2];L[j+52>>2]=k;k=L[e+44>>2];L[j+40>>2]=L[e+40>>2];L[j+44>>2]=k;k=L[e+36>>2];L[j+32>>2]=L[e+32>>2];L[j+36>>2]=k;k=L[e+28>>2];L[j+24>>2]=L[e+24>>2];L[j+28>>2]=k;k=L[e+20>>2];L[j+16>>2]=L[e+16>>2];L[j+20>>2]=k;k=L[e+12>>2];L[j+8>>2]=L[e+8>>2];L[j+12>>2]=k;e=R(a|1,56);j=e+U|0;e=e+L[b+840>>2]|0;k=L[e+4>>2];L[j>>2]=L[e>>2];L[j+4>>2]=k;k=L[e+12>>2];L[j+8>>2]=L[e+8>>2];L[j+12>>2]=k;k=L[e+20>>2];L[j+16>>2]=L[e+16>>2];L[j+20>>2]=k;k=L[e+28>>2];L[j+24>>2]=L[e+24>>2];L[j+28>>2]=k;k=L[e+36>>2];L[j+32>>2]=L[e+32>>2];L[j+36>>2]=k;k=L[e+44>>2];L[j+40>>2]=L[e+40>>2];L[j+44>>2]=k;k=L[e+52>>2];L[j+48>>2]=L[e+48>>2];L[j+52>>2]=k;a=a+2|0;da=da+2|0;if((da|0)!=(fa|0)){continue}break}}if(!(c&1)){break h}a=R(a,56);c=a+U|0;a=a+L[b+840>>2]|0;e=L[a+4>>2];L[c>>2]=L[a>>2];L[c+4>>2]=e;e=L[a+52>>2];L[c+48>>2]=L[a+48>>2];L[c+52>>2]=e;e=L[a+44>>2];L[c+40>>2]=L[a+40>>2];L[c+44>>2]=e;e=L[a+36>>2];L[c+32>>2]=L[a+32>>2];L[c+36>>2]=e;e=L[a+28>>2];L[c+24>>2]=L[a+24>>2];L[c+28>>2]=e;e=L[a+20>>2];L[c+16>>2]=L[a+16>>2];L[c+20>>2]=e;e=L[a+12>>2];L[c+8>>2]=L[a+8>>2];L[c+12>>2]=e}a=L[b+840>>2];if(!(a?!a|!M[b+844|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](a)}L[b+840>>2]=U;J[b+844|0]=1;L[b+836>>2]=T;c=L[b+832>>2]}a=L[b+840>>2]+R(c,56)|0;P[a+52>>2]=d;P[a+48>>2]=h;P[a+44>>2]=l;P[a+40>>2]=u;L[a+36>>2]=0;P[a+32>>2]=q;P[a+28>>2]=r;P[a+24>>2]=i;P[a+8>>2]=f;L[a+4>>2]=N;L[a>>2]=y;L[a+20>>2]=0;P[a+16>>2]=m;P[a+12>>2]=o;L[b+832>>2]=L[b+832>>2]+1}}function Mm(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=S(0),g=S(0),h=S(0),i=S(0),j=S(0),k=S(0),l=S(0),m=0,n=S(0),o=S(0),p=S(0),q=0,r=S(0),s=S(0),t=S(0),u=S(0),v=S(0),w=S(0),x=S(0),y=S(0),z=S(0),A=S(0),B=0,C=S(0),D=S(0),E=S(0),F=S(0),G=S(0),H=S(0),I=S(0),J=S(0),K=0,M=0;d=fa-144|0;fa=d;L[d+108>>2]=0;f=P[b+80>>2];l=P[b+96>>2];y=P[b+120>>2];o=P[b+56>>2];E=P[b+112>>2];v=P[b+116>>2];G=P[b+52>>2];i=P[b+68>>2];j=P[b+84>>2];p=P[b+100>>2];h=P[b+20>>2];t=P[b+36>>2];s=P[b+72>>2];n=P[b+88>>2];u=P[b+24>>2];g=P[b+104>>2];C=P[b+40>>2];k=P[b+64>>2];D=P[b+32>>2];w=P[b>>2];z=P[b+16>>2];H=P[b+48>>2];r=P[b+4>>2];A=P[b+8>>2];L[d+104>>2]=0;L[d+88>>2]=0;L[d+72>>2]=0;P[d+84>>2]=S(g*C)+S(S(s*A)+S(u*n));P[d+80>>2]=S(g*t)+S(S(s*r)+S(h*n));P[d+68>>2]=S(p*C)+S(S(i*A)+S(u*j));P[d- -64>>2]=S(p*t)+S(S(i*r)+S(h*j));y=S(o-y);o=S(H-E);E=S(G-v);P[d+100>>2]=S(g*y)+S(S(s*o)+S(n*E));P[d+96>>2]=S(p*y)+S(S(i*o)+S(E*j));L[d+56>>2]=0;P[d+76>>2]=S(g*D)+S(S(s*w)+S(z*n));P[d+60>>2]=S(p*D)+S(S(i*w)+S(z*j));P[d+52>>2]=S(l*C)+S(S(k*A)+S(f*u));P[d+48>>2]=S(l*t)+S(S(k*r)+S(f*h));P[d+44>>2]=S(l*D)+S(S(k*w)+S(f*z));P[d+92>>2]=S(l*y)+S(S(k*o)+S(E*f));t=S(0);u=S(0);C=S(0);q=fa-32|0;fa=q;m=L[a+4>>2];D=S(P[m+28>>2]*P[m+12>>2]);j=S(D+P[a+12>>2]);l=P[d+100>>2];m=L[a+8>>2];f=P[m- -64>>2];v=S(l-f);i=P[m+56>>2];s=S(P[m+72>>2]-i);n=P[m+60>>2];g=S(P[m+92>>2]-n);k=S(P[m+88>>2]-i);h=S(P[m+76>>2]-n);p=S(S(s*g)-S(k*h));r=p;x=S(p*p);p=S(P[m+96>>2]-f);o=g;g=S(P[m+80>>2]-f);f=S(S(h*p)-S(o*g));g=S(S(g*k)-S(p*s));k=S(S(1)/S(_(S(x+S(S(f*f)+S(g*g))))));p=S(r*k);w=P[d+92>>2];s=S(f*k);f=S(S(w-i)*s);i=P[d+96>>2];h=S(i-n);n=S(g*k);f=S(S(v*p)+S(f+S(h*n)));if(f>2];L[q+24>>2]=L[d+100>>2];L[q+28>>2]=B;B=L[d+96>>2];L[q+16>>2]=L[d+92>>2];L[q+20>>2]=B;L[q+12>>2]=0;P[q+8>>2]=p;P[q+4>>2]=n;P[q>>2]=s;z=P[m+96>>2];r=P[m+80>>2];A=S(z-r);y=P[m+88>>2];o=P[m+72>>2];F=S(y-o);g=P[q+4>>2];k=P[q>>2];E=P[m+92>>2];v=P[m+76>>2];h=S(E-v);G=P[q+24>>2];I=S(S(S(F*g)-S(k*h))*S(G-r));x=h;h=P[q+8>>2];H=P[q+16>>2];J=P[q+20>>2];A=S(I+S(S(S(S(x*h)-S(g*A))*S(H-o))+S(S(J-v)*S(S(A*k)-S(h*F)))));x=r;r=P[m+64>>2];F=S(x-r);x=o;o=P[m+56>>2];I=S(x-o);x=v;v=P[m+60>>2];x=S(x-v);F=S(S(S(S(I*g)-S(k*x))*S(G-r))+S(S(S(S(x*h)-S(g*F))*S(H-o))+S(S(J-v)*S(S(F*k)-S(h*I)))));o=S(o-y);v=S(v-E);G=S(S(S(o*g)-S(k*v))*S(G-z));x=g;g=S(r-z);g=S(G+S(S(S(S(v*h)-S(x*g))*S(H-y))+S(S(J-E)*S(S(g*k)-S(h*o)))));b:{if(!(!(g>S(0))|!(F>S(0)))){B=1;if(A>S(0)){break b}}B=F<=S(0)&A<=S(0)&g<=S(0)}c:{if(B){t=S(l-S(f*p));u=S(i-S(f*n));C=S(w-S(f*s));z=S(j*j);break c}if((ha[L[L[m>>2]+100>>2]](m)|0)<=0){break a}z=S(j*j);m=0;while(1){B=L[a+8>>2];ha[L[L[B>>2]+104>>2]](B,m,q+16|0,q);j=S(0);w=P[q+24>>2];g=S(P[q+8>>2]-w);f=S(P[d+100>>2]-w);r=P[q+16>>2];k=S(P[q>>2]-r);i=S(P[d+92>>2]-r);A=P[q+20>>2];l=S(P[d+96>>2]-A);h=S(P[q+4>>2]-A);y=S(S(g*f)+S(S(k*i)+S(l*h)));d:{if(!(y>S(0))){break d}j=S(S(g*g)+S(S(k*k)+S(h*h)));if(j>y){j=S(y/j);f=S(f-S(g*j));l=S(l-S(h*j));i=S(i-S(k*j));break d}f=S(f-g);l=S(l-h);i=S(i-k);j=S(1)}if(S(S(f*f)+S(S(i*i)+S(l*l)))>2];m=m+1|0;if((ha[L[L[B>>2]+100>>2]](B)|0)>(m|0)){continue}break}if(!K){break a}l=P[d+100>>2];i=P[d+96>>2];w=P[d+92>>2]}f=S(l-t);l=S(w-C);i=S(i-u);j=S(S(f*f)+S(S(l*l)+S(i*i)));if(!(jS(1.1920928955078125e-7)){L[d+124>>2]=0;g=f;j=S(_(j));f=S(S(1)/j);P[d+120>>2]=g*f;P[d+116>>2]=i*f;P[d+112>>2]=l*f;D=S(D-j);break e}L[d+124>>2]=0;P[d+120>>2]=p;P[d+116>>2]=n;P[d+112>>2]=s}L[d+140>>2]=0;P[d+136>>2]=t;P[d+132>>2]=u;P[d+128>>2]=C;P[d+108>>2]=-D;M=1}fa=q+32|0;f:{if(!M){break f}if(e){j=P[b+72>>2];p=P[b+64>>2];s=P[b+68>>2];n=P[b+88>>2];g=P[b+80>>2];k=P[b+84>>2];h=P[b+104>>2];t=P[b+96>>2];u=P[b+100>>2];f=P[d+120>>2];l=P[d+112>>2];i=P[d+116>>2];L[d+40>>2]=0;C=S(S(h*f)+S(S(t*l)+S(i*u)));P[d+36>>2]=-C;D=S(S(n*f)+S(S(g*l)+S(i*k)));P[d+32>>2]=-D;w=S(S(j*f)+S(S(p*l)+S(s*i)));P[d+28>>2]=-w;z=P[b+112>>2];r=P[b+116>>2];f=P[b+120>>2];L[d+24>>2]=0;l=P[d+136>>2];o=S(h*l);i=P[d+128>>2];h=P[d+132>>2];o=S(f+S(o+S(S(t*i)+S(u*h))));f=P[d+108>>2];P[d+20>>2]=o+S(C*f);P[d+16>>2]=S(r+S(S(l*n)+S(S(i*g)+S(k*h))))+S(D*f);P[d+12>>2]=S(z+S(S(l*j)+S(S(i*p)+S(s*h))))+S(w*f);ha[L[L[c>>2]+16>>2]](c,d+28|0,d+12|0,f);break f}f=P[b+72>>2];l=P[b+64>>2];i=P[b+68>>2];j=P[b+88>>2];p=P[b+80>>2];s=P[b+84>>2];n=P[b+104>>2];g=P[b+96>>2];k=P[b+100>>2];L[d+40>>2]=0;h=P[d+120>>2];t=P[d+112>>2];u=P[d+116>>2];P[d+36>>2]=S(n*h)+S(S(g*t)+S(k*u));P[d+32>>2]=S(j*h)+S(S(p*t)+S(u*s));P[d+28>>2]=S(f*h)+S(S(l*t)+S(i*u));h=P[b+112>>2];t=P[b+116>>2];u=P[b+120>>2];L[d+24>>2]=0;r=n;n=P[d+136>>2];o=g;g=P[d+128>>2];v=k;k=P[d+132>>2];P[d+20>>2]=u+S(S(r*n)+S(S(o*g)+S(v*k)));P[d+16>>2]=t+S(S(n*j)+S(S(g*p)+S(s*k)));P[d+12>>2]=h+S(S(n*f)+S(S(g*l)+S(i*k)));ha[L[L[c>>2]+16>>2]](c,d+28|0,d+12|0,P[d+108>>2])}fa=d+144|0}function Gg(a,b,c,d){var e=S(0),f=0,g=S(0),h=0,i=S(0),j=0,k=S(0),l=S(0),m=S(0),n=0,o=S(0),p=S(0),q=S(0),r=S(0),s=0,t=0,u=0,v=S(0),w=S(0),x=0,y=0,z=0,A=S(0),B=S(0),C=S(0),D=0,E=0,F=0,G=0;x=L[a>>2];L[a>>2]=x+1;a:{if((d-c|0)==1){q=P[a+48>>2];g=P[a+32>>2];c=L[b+12>>2]+R(c,36)|0;e=P[c+8>>2];e=e>2];e=S(S(S((e>q?q:e)-g)*o)+S(.5));b:{if(e=S(0)){d=~~e>>>0;break b}d=0}m=P[a+40>>2];i=P[c>>2];r=P[a+60>>2];l=P[a+44>>2];e=P[a+28>>2];p=P[c+4>>2];v=P[a+56>>2];k=P[a+24>>2];a=L[a+16>>2];b=a+(x<<4)|0;K[b+4>>1]=d;p=e>p?e:p;p=S(S(r*S((l=S(0)){d=~~p>>>0;break c}d=0}K[b+2>>1]=d;i=k>i?k:i;i=S(S(S((i>m?m:i)-k)*v)+S(.5));d:{if(i=S(0)){d=~~i>>>0;break d}d=0}K[b>>1]=d;i=P[c+16>>2];p=P[c+20>>2];w=o;o=P[c+24>>2];o=g>o?g:o;g=S(S(w*S((q=S(0)){d=~~g>>>0;break e}d=0}K[b+10>>1]=d;g=e>p?e:p;e=S(S(r*S((g>l?l:g)-e))+S(.5));f:{if(e=S(0)){d=~~e>>>0;break f}d=0}K[b+8>>1]=d;e=k>i?k:i;e=S(S(v*S((e>m?m:e)-k))+S(.5));g:{if(e=S(0)){d=~~e>>>0;break g}d=0}K[b+6>>1]=d;b=L[c+32>>2];break a}u=b;b=c;h=d-b|0;h:{i:{j:{if((b|0)>=(d|0)){m=S(h|0);break j}n=L[u+12>>2];f=b;while(1){j=n+R(f,36)|0;l=S(l+S(S(P[j+16>>2]+P[j>>2])*S(.5)));e=S(e+S(S(P[j+24>>2]+P[j+8>>2])*S(.5)));k=S(k+S(S(P[j+20>>2]+P[j+4>>2])*S(.5)));f=f+1|0;if((f|0)!=(d|0)){continue}break}m=S(h|0);if((b|0)<(d|0)){break i}}e=S(0);k=S(0);break h}g=S(S(1)/m);q=S(g*e);i=S(g*k);l=S(g*l);j=L[u+12>>2];k=S(0);e=S(0);g=S(0);while(1){o=g;f=j+R(b,36)|0;g=S(S(S(P[f+16>>2]+P[f>>2])*S(.5))-l);g=S(o+S(g*g));o=k;k=S(S(S(P[f+24>>2]+P[f+8>>2])*S(.5))-q);k=S(o+S(k*k));o=e;e=S(S(S(P[f+20>>2]+P[f+4>>2])*S(.5))-i);e=S(o+S(e*e));b=b+1|0;if((d|0)!=(b|0)){continue}break}}m=S(S(1)/S(m+S(-1)));g=S(m*g);e=S(m*e);b=g(b?e:g)?2:b;e=S(0);k=S(0);g=S(0);j=fa+-64|0;L[j+28>>2]=0;n=(c|0)>=(d|0);if(!n){y=L[u+12>>2];b=c;while(1){f=y+R(b,36)|0;e=S(S(S(P[f+16>>2]+P[f>>2])*S(.5))+e);k=S(S(S(P[f+24>>2]+P[f+8>>2])*S(.5))+k);g=S(S(S(P[f+20>>2]+P[f+4>>2])*S(.5))+g);b=b+1|0;if((d|0)!=(b|0)){continue}break}}y=d-c|0;m=S(S(1)/S(y|0));P[j+24>>2]=m*k;P[j+20>>2]=m*g;P[j+16>>2]=m*e;f=c;if(!n){b=h<<2;e=P[b+(j+16|0)>>2];D=b+j|0;b=c;while(1){n=L[u+12>>2];h=n+R(b,36)|0;k=P[h+4>>2];g=P[h+20>>2];m=P[h+8>>2];l=P[h+24>>2];q=P[h>>2];i=P[h+16>>2];L[j+12>>2]=0;P[j>>2]=S(i+q)*S(.5);P[j+8>>2]=S(l+m)*S(.5);P[j+4>>2]=S(g+k)*S(.5);if(e>2]){s=L[h+12>>2];L[j+40>>2]=L[h+8>>2];L[j+44>>2]=s;s=L[h+4>>2];L[j+32>>2]=L[h>>2];L[j+36>>2]=s;s=L[h+28>>2];L[j+56>>2]=L[h+24>>2];L[j+60>>2]=s;s=L[h+20>>2];L[j+48>>2]=L[h+16>>2];L[j+52>>2]=s;s=L[h+32>>2];z=R(f,36);n=n+z|0;t=L[n+4>>2];L[h>>2]=L[n>>2];L[h+4>>2]=t;t=L[n+12>>2];L[h+8>>2]=L[n+8>>2];L[h+12>>2]=t;t=L[n+20>>2];L[h+16>>2]=L[n+16>>2];L[h+20>>2]=t;t=L[n+28>>2];L[h+24>>2]=L[n+24>>2];L[h+28>>2]=t;L[h+32>>2]=L[n+32>>2];n=L[j+36>>2];h=L[u+12>>2]+z|0;L[h>>2]=L[j+32>>2];L[h+4>>2]=n;n=L[j+56>>2];z=L[j+60>>2];t=L[j+48>>2];E=L[j+52>>2];F=L[j+44>>2];G=L[j+40>>2];L[h+32>>2]=s;L[h+8>>2]=G;L[h+12>>2]=F;L[h+16>>2]=t;L[h+20>>2]=E;L[h+24>>2]=n;L[h+28>>2]=z;f=f+1|0}b=b+1|0;if((d|0)!=(b|0)){continue}break}}b=(y>>1)+c|0;h=b;b=(y|0)/3|0;j=(b+c|0)>=(f|0)?h:((b^-1)+d|0)<=(f|0)?h:f;k:{if((c|0)>=(d|0)){e=S(34028234663852886e22);k=S(-34028234663852886e22);g=S(-34028234663852886e22);l=S(-34028234663852886e22);m=S(34028234663852886e22);q=S(34028234663852886e22);break k}h=L[u+12>>2];l=S(-34028234663852886e22);q=S(34028234663852886e22);b=c;m=S(34028234663852886e22);e=S(34028234663852886e22);g=S(-34028234663852886e22);k=S(-34028234663852886e22);while(1){f=h+R(b,36)|0;i=P[f+16>>2];l=i>l?i:l;i=P[f+8>>2];e=e>i?i:e;i=P[f+4>>2];m=i>2];q=i>2];g=g>2];k=k>2];v=P[a+44>>2];i=P[a+28>>2];B=P[a- -64>>2];o=P[a+48>>2];r=P[a+32>>2];b=L[a+16>>2]+(x<<4)|0;C=P[a+56>>2];w=P[a+40>>2];p=P[a+24>>2];l=lw?w:l)-p))+S(.5));l:{if(l=S(0)){f=~~l>>>0;break l}f=0}K[b+6>>1]=f;l=p>q?p:q;l=S(S(S((l>w?w:l)-p)*C)+S(.5));m:{if(l=S(0)){f=~~l>>>0;break m}f=0}K[b>>1]=f;g=go?o:g)-r))+S(.5));n:{if(g=S(0)){f=~~g>>>0;break n}f=0}K[b+10>>1]=f;k=kv?v:k)-i))+S(.5));o:{if(k=S(0)){f=~~k>>>0;break o}f=0}K[b+8>>1]=f;e=eo?o:e)-r)*B)+S(.5));p:{if(e=S(0)){f=~~e>>>0;break p}f=0}K[b+4>>1]=f;e=i>m?i:m;e=S(S(S((e>v?v:e)-i)*A)+S(.5));q:{if(e=S(0)){f=~~e>>>0;break q}f=0}K[b+2>>1]=f;Gg(a,u,c,j);Gg(a,u,j,d);b=x-L[a>>2]|0;a=L[a+16>>2]}L[((x<<4)+a|0)+12>>2]=b}function Yy(a,b){a=a|0;b=S(b);var c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=S(0),m=0,n=S(0),o=S(0),p=S(0),q=S(0),r=S(0),s=0,t=S(0),u=S(0);j=L[a+24>>2];if((j|0)>0){while(1){a:{b:{e=L[L[a+32>>2]+(s<<2)>>2];switch(L[e+216>>2]-2|0){case 0:case 3:break a;default:break b}}d=0;j=fa+-64|0;fa=j;tk(e,0);h=L[e+732>>2];if((h|0)>0){while(1){f=L[e+740>>2]+R(d,52)|0;i=L[f+8>>2];r=P[i+28>>2];g=L[f+12>>2];n=P[g+28>>2];q=P[i+32>>2];o=P[g+32>>2];l=P[i+24>>2];b=P[g+24>>2];L[f+48>>2]=0;p=S(b-l);P[f+36>>2]=p;l=S(o-q);P[f+44>>2]=l;b=S(n-r);P[f+40>>2]=b;P[f+32>>2]=S(1)/S(P[f+24>>2]*S(S(l*l)+S(S(p*p)+S(b*b))));d=d+1|0;if((h|0)!=(d|0)){continue}break}}i=L[e+792>>2];if((i|0)>0){k=0;while(1){c=L[e+800>>2]+R(k,96)|0;f=L[c+20>>2];r=P[f+12>>2];n=P[f+8>>2];q=P[f+4>>2];o=P[f+28>>2];l=P[f+20>>2];b=P[f+24>>2];t=P[c+12>>2];u=P[c+4>>2];p=P[c+8>>2];P[j+56>>2]=S(P[f+44>>2]*t)+S(S(P[f+36>>2]*u)+S(p*P[f+40>>2]));L[j+60>>2]=0;P[j+52>>2]=S(o*t)+S(S(l*u)+S(p*b));P[j+48>>2]=S(r*t)+S(S(q*u)+S(n*p));g=L[c>>2];sk(j,P[e+452>>2],P[g+88>>2],P[f+344>>2],f+264|0,j+48|0);h=L[j+12>>2];L[c+36>>2]=L[j+8>>2];L[c+40>>2]=h;h=L[j+4>>2];L[c+28>>2]=L[j>>2];L[c+32>>2]=h;h=L[j+28>>2];L[c+52>>2]=L[j+24>>2];L[c+56>>2]=h;h=L[j+20>>2];L[c+44>>2]=L[j+16>>2];L[c+48>>2]=h;h=L[j+44>>2];L[c+68>>2]=L[j+40>>2];L[c+72>>2]=h;h=L[j+36>>2];L[c+60>>2]=L[j+32>>2];L[c+64>>2]=h;h=L[j+60>>2];L[c+84>>2]=L[j+56>>2];L[c+88>>2]=h;h=L[j+52>>2];L[c+76>>2]=L[j+48>>2];L[c+80>>2]=h;P[c+92>>2]=P[e+452>>2]*P[g+88>>2];ib(f,0);k=k+1|0;if((i|0)!=(k|0)){continue}break}}m=L[e+372>>2];c:{if((m|0)<=0){break c}d=L[e+396>>2];if((d|0)>0){k=0;while(1){c=0;if((d|0)>0){while(1){if(L[L[e+404>>2]+(c<<2)>>2]){D()}else{qk(e,S(1))}c=c+1|0;d=L[e+396>>2];if((c|0)<(d|0)){continue}break}m=L[e+372>>2]}k=k+1|0;if((m|0)>(k|0)){continue}break}}h=L[e+712>>2];if((h|0)<=0){break c}d=0;while(1){b=P[e+452>>2];g=L[e+720>>2]+R(d,104)|0;L[g+20>>2]=0;P[g+8>>2]=S(b*P[g+40>>2])+P[g+24>>2];P[g+16>>2]=S(b*P[g+48>>2])+P[g+32>>2];P[g+12>>2]=S(b*P[g+44>>2])+P[g+28>>2];d=d+1|0;if((h|0)!=(d|0)){continue}break}}c=L[e+376>>2];d:{if((c|0)<=0){break d}d=L[e+416>>2];k=0;while(1){if((d|0)>0){b=S(S(k|0)/S(c|0));c=0;while(1){ha[L[(L[L[e+424>>2]+(c<<2)>>2]<<2)+21936>>2]](e,S(1),b);c=c+1|0;d=L[e+416>>2];if((c|0)<(d|0)){continue}break}c=L[e+376>>2]}k=k+1|0;if((k|0)<(c|0)){continue}break}h=L[e+712>>2];if((h|0)<=0){break d}b=S(P[e+456>>2]*S(S(1)-P[e+296>>2]));d=0;while(1){g=L[e+720>>2]+R(d,104)|0;L[g+52>>2]=0;L[g+56>>2]=0;L[g+60>>2]=0;L[g+64>>2]=0;L[g+68>>2]=0;P[g+40>>2]=b*S(P[g+8>>2]-P[g+24>>2]);P[g+48>>2]=b*S(P[g+16>>2]-P[g+32>>2]);P[g+44>>2]=b*S(P[g+12>>2]-P[g+28>>2]);d=d+1|0;if((h|0)!=(d|0)){continue}break}}m=L[e+380>>2];e:{if((m|0)<=0){break e}l=P[e+456>>2];b=P[e+292>>2];i=L[e+712>>2];f:{if((i|0)>0){c=0;if((i|0)!=1){g=i&-2;k=0;while(1){f=L[e+720>>2]+R(c,104)|0;h=L[f+12>>2];L[f+24>>2]=L[f+8>>2];L[f+28>>2]=h;h=L[f+20>>2];L[f+32>>2]=L[f+16>>2];L[f+36>>2]=h;f=L[e+720>>2]+R(c|1,104)|0;h=L[f+12>>2];L[f+24>>2]=L[f+8>>2];L[f+28>>2]=h;h=L[f+20>>2];L[f+32>>2]=L[f+16>>2];L[f+36>>2]=h;c=c+2|0;k=k+2|0;if((g|0)!=(k|0)){continue}break}}if(i&1){i=L[e+720>>2]+R(c,104)|0;g=L[i+12>>2];h=L[i+8>>2];L[i+24>>2]=h;L[i+28>>2]=g;h=L[i+20>>2];L[i+32>>2]=L[i+16>>2];L[i+36>>2]=h}m=L[e+380>>2];if((m|0)<=0){break f}}k=0;d=L[e+436>>2];if((d|0)<=0){break f}while(1){c=0;if((d|0)>0){while(1){ha[L[(L[L[e+444>>2]+(c<<2)>>2]<<2)+21936>>2]](e,S(1),S(0));c=c+1|0;d=L[e+436>>2];if((c|0)<(d|0)){continue}break}m=L[e+380>>2]}k=k+1|0;if((m|0)>(k|0)){continue}break}}g=L[e+712>>2];if((g|0)<=0){break e}b=S(b*l);h=L[e+720>>2];d=0;while(1){i=h+R(d,104)|0;P[i+40>>2]=S(b*S(P[i+8>>2]-P[i+24>>2]))+P[i+40>>2];P[i+44>>2]=S(b*S(P[i+12>>2]-P[i+28>>2]))+P[i+44>>2];P[i+48>>2]=S(b*S(P[i+16>>2]-P[i+32>>2]))+P[i+48>>2];d=d+1|0;if((g|0)!=(d|0)){continue}break}}k=0;f=L[e+1112>>2];if((f|0)>0){i=L[e+1120>>2];while(1){d=L[i+(k<<2)>>2];g:{if(!(P[d+352>>2]>S(0))){break g}g=L[d+24>>2];if((g|0)<=0){break g}h=L[d+32>>2];m=0;while(1){c=L[h+(m<<2)>>2];h:{if(!(P[c+88>>2]>S(0))){break h}n=P[d+332>>2];q=S(P[c+28>>2]-P[d+232>>2]);o=S(P[c+24>>2]-P[d+228>>2]);b=P[d+336>>2];r=S(S(S(n*q)-S(o*b))+P[d+324>>2]);l=S(P[c+32>>2]-P[d+236>>2]);p=S(b*l);b=P[d+340>>2];q=S(P[d+316>>2]+S(p-S(q*b)));l=S(P[d+320>>2]+S(S(b*o)-S(l*n)));b=P[c+48>>2];n=P[c+40>>2];o=P[c+44>>2];if(!(S(S(r*r)+S(S(q*q)+S(l*l)))<=S(S(b*b)+S(S(n*n)+S(o*o))))){break h}p=b;r=S(r-b);b=P[d+352>>2];P[c+48>>2]=p+S(r*b);P[c+44>>2]=o+S(b*S(l-o));P[c+40>>2]=n+S(b*S(q-n))}m=m+1|0;if((g|0)!=(m|0)){continue}break}}k=k+1|0;if((f|0)!=(k|0)){continue}break}}tk(e,1);fa=j- -64|0;j=L[a+24>>2]}s=s+1|0;if((s|0)<(j|0)){continue}break}}}function To(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0,g=0;e=fa-400|0;fa=e;L[e+396>>2]=a;L[e+392>>2]=b;L[e+388>>2]=c;L[e+384>>2]=d;a=L[e+396>>2];b=fa-16|0;L[b+12>>2]=L[e+392>>2];c=L[b+12>>2];L[b+12>>2]=L[e+392>>2];d=L[b+12>>2];L[b+12>>2]=L[e+392>>2];f=e+368|0;la(f,c,d+4|0,L[b+12>>2]+8|0);b=fa-16|0;L[b+12>>2]=L[e+388>>2];b=L[b+12>>2];c=fa-16|0;L[c+12>>2]=L[e+392>>2];c=L[c+12>>2];d=fa-16|0;L[d+12>>2]=L[e+392>>2];g=e+352|0;la(g,b,c+4|0,L[d+12>>2]+8|0);ha[L[L[a>>2]+8>>2]](a,f,g,L[e+384>>2]);b=fa-16|0;L[b+12>>2]=L[e+388>>2];b=L[b+12>>2];c=fa-16|0;L[c+12>>2]=L[e+392>>2];c=L[c+12>>2];d=fa-16|0;L[d+12>>2]=L[e+392>>2];f=e+336|0;la(f,b,c+4|0,L[d+12>>2]+8|0);b=fa-16|0;L[b+12>>2]=L[e+388>>2];b=L[b+12>>2];c=fa-16|0;L[c+12>>2]=L[e+388>>2];c=L[c+12>>2];d=fa-16|0;L[d+12>>2]=L[e+392>>2];g=e+320|0;la(g,b,c+4|0,L[d+12>>2]+8|0);ha[L[L[a>>2]+8>>2]](a,f,g,L[e+384>>2]);b=fa-16|0;L[b+12>>2]=L[e+388>>2];b=L[b+12>>2];c=fa-16|0;L[c+12>>2]=L[e+388>>2];c=L[c+12>>2];d=fa-16|0;L[d+12>>2]=L[e+392>>2];f=e+304|0;la(f,b,c+4|0,L[d+12>>2]+8|0);b=fa-16|0;L[b+12>>2]=L[e+392>>2];b=L[b+12>>2];c=fa-16|0;L[c+12>>2]=L[e+388>>2];c=L[c+12>>2];d=fa-16|0;L[d+12>>2]=L[e+392>>2];g=e+288|0;la(g,b,c+4|0,L[d+12>>2]+8|0);ha[L[L[a>>2]+8>>2]](a,f,g,L[e+384>>2]);b=fa-16|0;L[b+12>>2]=L[e+392>>2];b=L[b+12>>2];c=fa-16|0;L[c+12>>2]=L[e+388>>2];c=L[c+12>>2];d=fa-16|0;L[d+12>>2]=L[e+392>>2];f=e+272|0;la(f,b,c+4|0,L[d+12>>2]+8|0);b=fa-16|0;L[b+12>>2]=L[e+392>>2];b=L[b+12>>2];c=fa-16|0;L[c+12>>2]=L[e+392>>2];c=L[c+12>>2];d=fa-16|0;L[d+12>>2]=L[e+392>>2];g=e+256|0;la(g,b,c+4|0,L[d+12>>2]+8|0);ha[L[L[a>>2]+8>>2]](a,f,g,L[e+384>>2]);b=fa-16|0;L[b+12>>2]=L[e+392>>2];b=L[b+12>>2];c=fa-16|0;L[c+12>>2]=L[e+392>>2];c=L[c+12>>2];d=fa-16|0;L[d+12>>2]=L[e+392>>2];f=e+240|0;la(f,b,c+4|0,L[d+12>>2]+8|0);b=fa-16|0;L[b+12>>2]=L[e+392>>2];b=L[b+12>>2];c=fa-16|0;L[c+12>>2]=L[e+392>>2];c=L[c+12>>2];d=fa-16|0;L[d+12>>2]=L[e+388>>2];g=e+224|0;la(g,b,c+4|0,L[d+12>>2]+8|0);ha[L[L[a>>2]+8>>2]](a,f,g,L[e+384>>2]);b=fa-16|0;L[b+12>>2]=L[e+388>>2];b=L[b+12>>2];c=fa-16|0;L[c+12>>2]=L[e+392>>2];c=L[c+12>>2];d=fa-16|0;L[d+12>>2]=L[e+392>>2];f=e+208|0;la(f,b,c+4|0,L[d+12>>2]+8|0);b=fa-16|0;L[b+12>>2]=L[e+388>>2];b=L[b+12>>2];c=fa-16|0;L[c+12>>2]=L[e+392>>2];c=L[c+12>>2];d=fa-16|0;L[d+12>>2]=L[e+388>>2];g=e+192|0;la(g,b,c+4|0,L[d+12>>2]+8|0);ha[L[L[a>>2]+8>>2]](a,f,g,L[e+384>>2]);b=fa-16|0;L[b+12>>2]=L[e+388>>2];b=L[b+12>>2];c=fa-16|0;L[c+12>>2]=L[e+388>>2];c=L[c+12>>2];d=fa-16|0;L[d+12>>2]=L[e+392>>2];f=e+176|0;la(f,b,c+4|0,L[d+12>>2]+8|0);b=fa-16|0;L[b+12>>2]=L[e+388>>2];b=L[b+12>>2];c=fa-16|0;L[c+12>>2]=L[e+388>>2];c=L[c+12>>2];d=fa-16|0;L[d+12>>2]=L[e+388>>2];g=e+160|0;la(g,b,c+4|0,L[d+12>>2]+8|0);ha[L[L[a>>2]+8>>2]](a,f,g,L[e+384>>2]);b=fa-16|0;L[b+12>>2]=L[e+392>>2];b=L[b+12>>2];c=fa-16|0;L[c+12>>2]=L[e+388>>2];c=L[c+12>>2];d=fa-16|0;L[d+12>>2]=L[e+392>>2];f=e+144|0;la(f,b,c+4|0,L[d+12>>2]+8|0);b=fa-16|0;L[b+12>>2]=L[e+392>>2];b=L[b+12>>2];c=fa-16|0;L[c+12>>2]=L[e+388>>2];c=L[c+12>>2];d=fa-16|0;L[d+12>>2]=L[e+388>>2];g=e+128|0;la(g,b,c+4|0,L[d+12>>2]+8|0);ha[L[L[a>>2]+8>>2]](a,f,g,L[e+384>>2]);b=fa-16|0;L[b+12>>2]=L[e+392>>2];b=L[b+12>>2];c=fa-16|0;L[c+12>>2]=L[e+392>>2];c=L[c+12>>2];d=fa-16|0;L[d+12>>2]=L[e+388>>2];f=e+112|0;la(f,b,c+4|0,L[d+12>>2]+8|0);b=fa-16|0;L[b+12>>2]=L[e+388>>2];b=L[b+12>>2];c=fa-16|0;L[c+12>>2]=L[e+392>>2];c=L[c+12>>2];d=fa-16|0;L[d+12>>2]=L[e+388>>2];g=e+96|0;la(g,b,c+4|0,L[d+12>>2]+8|0);ha[L[L[a>>2]+8>>2]](a,f,g,L[e+384>>2]);b=fa-16|0;L[b+12>>2]=L[e+388>>2];b=L[b+12>>2];c=fa-16|0;L[c+12>>2]=L[e+392>>2];c=L[c+12>>2];d=fa-16|0;L[d+12>>2]=L[e+388>>2];f=e+80|0;la(f,b,c+4|0,L[d+12>>2]+8|0);b=fa-16|0;L[b+12>>2]=L[e+388>>2];b=L[b+12>>2];c=fa-16|0;L[c+12>>2]=L[e+388>>2];c=L[c+12>>2];d=fa-16|0;L[d+12>>2]=L[e+388>>2];g=e- -64|0;la(g,b,c+4|0,L[d+12>>2]+8|0);ha[L[L[a>>2]+8>>2]](a,f,g,L[e+384>>2]);b=fa-16|0;L[b+12>>2]=L[e+388>>2];b=L[b+12>>2];c=fa-16|0;L[c+12>>2]=L[e+388>>2];c=L[c+12>>2];d=fa-16|0;L[d+12>>2]=L[e+388>>2];f=e+48|0;la(f,b,c+4|0,L[d+12>>2]+8|0);b=fa-16|0;L[b+12>>2]=L[e+392>>2];b=L[b+12>>2];c=fa-16|0;L[c+12>>2]=L[e+388>>2];c=L[c+12>>2];d=fa-16|0;L[d+12>>2]=L[e+388>>2];g=e+32|0;la(g,b,c+4|0,L[d+12>>2]+8|0);ha[L[L[a>>2]+8>>2]](a,f,g,L[e+384>>2]);b=fa-16|0;L[b+12>>2]=L[e+392>>2];b=L[b+12>>2];c=fa-16|0;L[c+12>>2]=L[e+388>>2];c=L[c+12>>2];d=fa-16|0;L[d+12>>2]=L[e+388>>2];f=e+16|0;la(f,b,c+4|0,L[d+12>>2]+8|0);b=fa-16|0;L[b+12>>2]=L[e+392>>2];b=L[b+12>>2];c=fa-16|0;L[c+12>>2]=L[e+392>>2];c=L[c+12>>2];d=fa-16|0;L[d+12>>2]=L[e+388>>2];la(e,b,c+4|0,L[d+12>>2]+8|0);ha[L[L[a>>2]+8>>2]](a,f,e,L[e+384>>2]);fa=e+400|0}function Fl(a,b){var c=S(0),d=S(0),e=S(0),f=S(0),g=S(0),h=S(0),i=S(0),j=S(0),k=0,l=S(0),m=S(0),n=S(0),o=S(0),p=S(0),q=S(0),r=S(0),s=S(0),t=S(0),u=S(0),v=S(0),w=S(0),x=0,y=S(0),z=S(0),A=0,B=S(0),C=S(0),D=S(0),E=S(0),F=S(0),G=S(0),H=S(0),I=S(0),J=S(0),K=S(0),N=S(0),O=S(0),Q=S(0),U=S(0),V=S(0),W=S(0),X=S(0),Y=S(0),Z=S(0),_=S(0),$=S(0),aa=S(0),ba=S(0),ca=S(0),da=S(0),ea=0;k=L[a+748>>2];a:{if((k|0)==4){c=P[a+84>>2];e=P[b+80>>2];k=c>2];c=k?c:e;k=f>2];c=k?f:c;x=e>2]<(x?e:c);A=k?3:A;b:{c:{d:{e:{if(M[27180]){if(!A){n=P[a+564>>2];i=P[a+380>>2];h=S(n-i);q=P[a+560>>2];l=P[a+376>>2];d=S(q-l);v=P[a+556>>2];w=P[a+372>>2];m=S(v-w);e=P[b+8>>2];f=P[b+4>>2];j=P[b>>2];break e}j=P[b>>2];s=P[a+188>>2];c=S(j-s);q=P[a+560>>2];l=P[a+376>>2];d=S(q-l);v=P[a+556>>2];w=P[a+372>>2];m=S(v-w);f=P[b+4>>2];t=P[a+192>>2];e=S(f-t);h=S(S(c*d)-S(m*e));o=S(h*h);n=P[a+564>>2];i=P[a+380>>2];h=S(n-i);p=S(e*h);e=P[b+8>>2];u=P[a+196>>2];g=S(e-u);p=S(p-S(d*g));c=S(S(g*m)-S(h*c));da=S(o+S(S(p*p)+S(c*c)));if((A|0)!=1){break e}j=S(j-P[a+4>>2]);g=S(-j);f=S(f-P[a+8>>2]);p=S(-f);e=S(e-P[a+12>>2]);r=S(-e);m=S(0);break d}f:{g:{h:{i:{if(!A){j=P[a+380>>2];h=P[a+564>>2];m=S(j-h);f=P[a+376>>2];d=P[a+560>>2];y=S(f-d);e=P[a+372>>2];l=P[a+556>>2];B=S(e-l);u=P[b+4>>2];H=S(u-d);W=S(-H);t=P[b>>2];z=S(t-l);X=S(-z);s=P[b+8>>2];I=S(s-h);Y=S(-I);E=S(t-e);D=S(-E);F=S(s-j);V=S(-F);G=S(u-f);c=S(-G);break i}t=P[b>>2];g=P[a+188>>2];J=S(t-g);f=P[a+376>>2];d=P[a+560>>2];y=S(f-d);e=P[a+372>>2];l=P[a+556>>2];B=S(e-l);u=P[b+4>>2];p=P[a+192>>2];K=S(u-p);c=S(S(J*y)-S(B*K));i=S(c*c);j=P[a+380>>2];h=P[a+564>>2];m=S(j-h);s=P[b+8>>2];r=P[a+196>>2];N=S(s-r);c=S(S(K*m)-S(y*N));n=S(c*c);c=S(S(N*B)-S(m*J));n=S(i+S(n+S(c*c)));E=S(t-e);C=S(p-d);c=S(g-l);G=S(u-f);i=S(S(E*C)-S(c*G));q=S(i*i);D=S(r-h);F=S(s-j);i=S(S(G*D)-S(C*F));o=S(i*i);i=S(S(F*c)-S(D*E));i=S(q+S(o+S(i*i)));n=i>2];v=S(t-n);i=P[a+8>>2];w=S(u-i);g=S(S(v*y)-S(B*w));o=S(g*g);q=P[a+12>>2];O=S(s-q);g=S(S(w*m)-S(y*O));m=S(S(O*B)-S(m*v));m=S(o+S(S(g*g)+S(m*m)));o=S(i-d);Q=S(n-l);g=S(S(E*o)+S(Q*c));p=S(g*g);U=S(q-h);g=S(S(G*U)+S(o*V));r=S(g*g);g=S(S(F*Q)+S(U*D));g=S(p+S(r+S(g*g)));m=g>2];K=S(u-p);_=S(-K);g=P[a+188>>2];J=S(t-g);$=S(-J);r=P[a+196>>2];N=S(s-r);aa=S(-N);ba=S(-w);ca=S(-O);if(!(!x|k)){l=S(q-r);o=S(i-p);z=S(n-g);d=S(0);break f}D=S(r-h);C=S(p-d);c=S(g-l);break g}_=S(-K);$=S(-J);aa=S(-N);n=P[a+4>>2];Q=S(n-l);q=P[a+12>>2];U=S(q-h);i=P[a+8>>2];o=S(i-d);v=S(t-n);Z=S(-v);w=S(u-i);ba=S(-w);O=S(s-q);ca=S(-O);m=S(0)}d=S(S(v*C)+S(c*ba));h=S(d*d);d=S(S(w*D)+S(C*ca));c=S(S(O*c)+S(D*Z));c=S(h+S(S(d*d)+S(c*c)));d=S(S(J*o)+S(Q*_));h=S(d*d);d=S(S(K*U)+S(o*aa));l=S(d*d);d=S(S(N*Q)+S(U*$));d=S(h+S(l+S(d*d)));c=c>d?c:d;o=S(i-p);h=S(z*o);z=S(n-g);d=S(h+S(z*W));h=S(d*d);l=S(q-r);d=S(S(H*l)+S(o*Y));y=S(d*d);d=S(S(I*z)+S(l*X));d=S(h+S(y+S(d*d)));d=c>d?c:d;c=S(0);if(k){break b}C=S(q-j);y=S(i-f);B=S(n-e);G=S(u-f);c=S(-G);E=S(t-e);D=S(-E);F=S(s-j);V=S(-F)}f=S(p-f);e=S(g-e);h=S(S(v*f)+S(e*ba));j=S(r-j);f=S(S(w*j)+S(f*ca));e=S(S(O*e)+S(j*Z));e=S(S(h*h)+S(S(f*f)+S(e*e)));f=S(S(J*y)+S(B*_));h=S(f*f);f=S(S(K*C)+S(y*aa));g=S(f*f);f=S(S(N*B)+S(C*$));f=S(h+S(g+S(f*f)));e=e>f?e:f;c=S(S(E*o)+S(z*c));f=S(c*c);c=S(S(G*l)+S(o*V));h=S(c*c);c=S(S(F*z)+S(l*D));c=S(f+S(h+S(c*c)));c=c>2]);f=S(f-P[a+8>>2]);c=S(S(j*d)-S(m*f));g=S(c*c);e=S(e-P[a+12>>2]);c=S(S(f*h)-S(d*e));d=S(c*c);c=S(S(e*m)-S(h*j));m=S(g+S(d+S(c*c)));u=P[a+196>>2];t=P[a+192>>2];s=P[a+188>>2];g=S(-j);p=S(-f);r=S(-e);if(k){break d}d=S(0);if(x){break c}}c=S(q-t);d=S(v-s);h=S(S(j*c)+S(d*p));q=S(h*h);h=S(n-u);c=S(S(f*h)+S(c*r));n=S(c*c);c=S(S(e*d)+S(h*g));d=S(q+S(n+S(c*c)));c=S(0);if(k){break b}}c=S(l-t);h=S(j*c);j=S(w-s);l=S(h+S(j*p));h=f;f=S(i-u);c=S(S(h*f)+S(c*r));h=S(c*c);c=S(S(e*j)+S(f*g));c=S(S(l*l)+S(h+S(c*c)))}e=S(T(da));k=e>S(-0xde0b6b000000000);x=k?0:-1;f=S(T(m));e=k?e:S(-0xde0b6b000000000);k=f>e;x=k?1:x;j=S(T(d));e=k?f:e;k=j>e;k=S(T(c))>(k?j:e)?3:k?2:x;A=R(k,184)+a|0;x=L[A+116>>2];if(!x){break a}ea=L[8113];if(!ea){break a}ha[ea|0](x)|0;L[A+116>>2]=0;break a}L[a+748>>2]=k+1}x=a;a=(k|0)>0?k:0;qa((x+R(a,184)|0)+4|0,b,184);return a}function KG(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=S(0),j=S(0),k=S(0),l=S(0),m=S(0),n=S(0),o=S(0),p=S(0),q=S(0),r=0,s=S(0),t=S(0),u=S(0),v=S(0),w=S(0),x=S(0),y=S(0),z=S(0),A=S(0),B=S(0),C=S(0),D=S(0),E=S(0),F=0,G=0,H=S(0),I=S(0),K=0,N=0,O=0;f=fa-176|0;fa=f;g=M[a+28|0];F=g?b:c;K=g?c:b;N=L[K+4>>2];if(L[N+68>>2]!=L[a+40>>2]){r=L[a+12>>2];if((r|0)>0){g=0;while(1){G=g<<2;h=L[G+L[a+20>>2]>>2];if(h){ha[L[L[h>>2]>>2]](h)|0;h=L[a+4>>2];ha[L[L[h>>2]+60>>2]](h,L[L[a+20>>2]+G>>2])}g=g+1|0;if((r|0)!=(g|0)){continue}break}}cn(a,b,c)}h=L[N+64>>2];b=L[a+20>>2];c=L[a+4>>2];L[f+172>>2]=L[a+32>>2];L[f+168>>2]=b;L[f+164>>2]=e;L[f+160>>2]=d;L[f+156>>2]=c;L[f+152>>2]=F;L[f+148>>2]=K;L[f+144>>2]=9840;L[f+60>>2]=0;L[f+52>>2]=0;L[f+56>>2]=0;J[f+64|0]=1;c=L[a+12>>2];a:{if((c|0)<=0){break a}b=0;while(1){d=L[L[a+20>>2]+(b<<2)>>2];if(d){ha[L[L[d>>2]+16>>2]](d,f+48|0);g=0;d=L[f+52>>2];if((d|0)>0){while(1){c=L[L[f+60>>2]+(g<<2)>>2];if(L[c+748>>2]){L[e+4>>2]=c;r=L[c+740>>2];G=L[L[e+8>>2]+8>>2];d=(r|0)==(G|0);O=c;c=L[L[e+12>>2]+8>>2];_a(O,(d?r:c)+4|0,(d?c:G)+4|0);L[e+4>>2]=0;d=L[f+52>>2]}g=g+1|0;if((g|0)<(d|0)){continue}break}}b:{if((d|0)>=0){break b}if(L[f+56>>2]<0){c=L[f+60>>2];if(!(c?!c|!M[f+64|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](c)}J[f+64|0]=1;L[f+56>>2]=0;L[f+60>>2]=0}c=0;g=d;r=0-g&3;if(r){while(1){L[L[f+60>>2]+(g<<2)>>2]=0;g=g+1|0;c=c+1|0;if((r|0)!=(c|0)){continue}break}}if(d>>>0>4294967292){break b}while(1){c=g<<2;L[c+L[f+60>>2]>>2]=0;L[(c+L[f+60>>2]|0)+4>>2]=0;L[(c+L[f+60>>2]|0)+8>>2]=0;L[(c+L[f+60>>2]|0)+12>>2]=0;g=g+4|0;if(g){continue}break}}L[f+52>>2]=0;c=L[a+12>>2]}b=b+1|0;if((c|0)>(b|0)){continue}break}b=L[f+60>>2];if(!b|!M[f+64|0]){break a}if(b){L[8514]=L[8514]+1;ha[L[6799]](b)}}c:{d:{if(h){b=L[K+12>>2];s=P[b+52>>2];t=P[b+56>>2];c=L[F+12>>2];u=P[c+52>>2];v=P[c+56>>2];i=P[b+20>>2];j=P[b+36>>2];w=P[c+20>>2];x=P[c+36>>2];y=P[c+24>>2];k=P[b+24>>2];z=P[c+40>>2];l=P[b+40>>2];A=P[c+32>>2];m=P[b+32>>2];B=P[c>>2];n=P[b>>2];C=P[c+16>>2];o=P[b+16>>2];D=P[b+48>>2];E=P[c+48>>2];p=P[b+4>>2];H=P[c+4>>2];I=P[c+8>>2];q=P[b+8>>2];L[f+108>>2]=0;L[f+92>>2]=0;L[f+76>>2]=0;P[f+88>>2]=S(z*l)+S(S(I*q)+S(k*y));P[f+84>>2]=S(x*l)+S(S(H*q)+S(k*w));P[f+72>>2]=S(z*j)+S(S(I*p)+S(i*y));P[f+68>>2]=S(x*j)+S(S(H*p)+S(i*w));D=S(-D);P[f+104>>2]=S(S(S(q*D)-S(k*s))-S(l*t))+S(S(v*l)+S(S(E*q)+S(k*u)));P[f+100>>2]=S(S(S(p*D)-S(i*s))-S(j*t))+S(S(v*j)+S(S(E*p)+S(i*u)));L[f+60>>2]=0;P[f+48>>2]=S(A*m)+S(S(B*n)+S(o*C));P[f+80>>2]=S(A*l)+S(S(B*q)+S(k*C));P[f+64>>2]=S(A*j)+S(S(B*p)+S(i*C));P[f+56>>2]=S(z*m)+S(S(I*n)+S(o*y));P[f+52>>2]=S(x*m)+S(S(H*n)+S(o*w));P[f+96>>2]=S(S(S(n*D)-S(o*s))-S(m*t))+S(S(v*m)+S(S(E*n)+S(o*u)));b=L[F+4>>2];ha[L[L[b>>2]+8>>2]](b,f+48|0,f+128|0,f+112|0);b=L[f+140>>2];L[f+24>>2]=L[f+136>>2];L[f+28>>2]=b;b=L[f+124>>2];L[f+40>>2]=L[f+120>>2];L[f+44>>2]=b;b=L[f+116>>2];L[f+32>>2]=L[f+112>>2];L[f+36>>2]=b;b=L[f+132>>2];L[f+16>>2]=L[f+128>>2];L[f+20>>2]=b;Vb(h,L[h>>2],f+16|0,f+144|0);break d}g=0;b=L[a+12>>2];if((b|0)<=0){break c}while(1){an(f+144|0,L[(L[N+24>>2]+R(g,80)|0)+64>>2],g);g=g+1|0;if((b|0)!=(g|0)){continue}break}}h=L[a+12>>2];if((h|0)<=0){break c}e=0;while(1){d=e<<2;e:{if(!L[d+L[a+20>>2]>>2]){break e}b=L[N+24>>2]+R(e,80)|0;g=L[b+64>>2];c=L[K+12>>2];H=P[c+52>>2];I=P[c+56>>2];s=P[b+48>>2];t=P[b+52>>2];u=P[b+56>>2];v=P[b+4>>2];w=P[b+20>>2];x=P[b+36>>2];y=P[b+8>>2];z=P[b+24>>2];A=P[b+40>>2];i=P[c+20>>2];j=P[c+24>>2];B=P[b>>2];C=P[b+16>>2];k=P[c+36>>2];E=P[b+32>>2];l=P[c+40>>2];D=P[c+48>>2];m=P[c+8>>2];n=P[c>>2];o=P[c+4>>2];p=P[c+16>>2];q=P[c+32>>2];c=0;L[f+108>>2]=0;L[f+92>>2]=0;L[f+76>>2]=0;L[f+60>>2]=0;P[f+80>>2]=S(E*l)+S(S(B*q)+S(k*C));P[f+64>>2]=S(E*j)+S(S(B*p)+S(i*C));P[f+48>>2]=S(E*m)+S(S(B*n)+S(o*C));P[f+88>>2]=S(A*l)+S(S(y*q)+S(k*z));P[f+84>>2]=S(x*l)+S(S(v*q)+S(k*w));P[f+72>>2]=S(A*j)+S(S(y*p)+S(i*z));P[f+68>>2]=S(x*j)+S(S(v*p)+S(i*w));P[f+56>>2]=S(A*m)+S(S(y*n)+S(o*z));P[f+52>>2]=S(x*m)+S(S(v*n)+S(o*w));P[f+104>>2]=I+S(S(u*l)+S(S(s*q)+S(k*t)));P[f+100>>2]=H+S(S(u*j)+S(S(s*p)+S(i*t)));P[f+96>>2]=D+S(S(u*m)+S(S(s*n)+S(o*t)));ha[L[L[g>>2]+8>>2]](g,f+48|0,f+16|0,f+128|0);b=L[F+4>>2];ha[L[L[b>>2]+8>>2]](b,L[F+12>>2],f+112|0,f);b=0;f:{if(P[f+16>>2]>P[f>>2]){break f}b=0;if(P[f+128>>2]>2]){break f}b=1}if(!(P[f+20>>2]>P[f+4>>2])&(!(P[f+132>>2]>2])&(P[f+136>>2]>2]|P[f+24>>2]>P[f+8>>2]?c:b))){break e}b=L[d+L[a+20>>2]>>2];ha[L[L[b>>2]>>2]](b)|0;b=L[a+4>>2];ha[L[L[b>>2]+60>>2]](b,L[d+L[a+20>>2]>>2]);L[d+L[a+20>>2]>>2]=0}e=e+1|0;if((h|0)!=(e|0)){continue}break}}fa=f+176|0}function Cl(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;var g=0,h=S(0),i=S(0),j=S(0),k=S(0),l=S(0),m=S(0),n=S(0),o=S(0),p=S(0),q=S(0),r=0,s=S(0),t=S(0),u=S(0),v=S(0),w=S(0),x=S(0),y=S(0),z=S(0),A=S(0),B=S(0),C=S(0),D=S(0),E=0,F=S(0),G=S(0),H=S(0),I=S(0),J=S(0),K=S(0),M=S(0),N=S(0),O=S(0),Q=S(0),R=S(0),T=S(0),U=S(0),V=S(0),W=S(0),X=S(0),Y=S(0),Z=S(0),$=S(0),aa=S(0),ba=S(0),ca=S(0),da=0,ea=S(0),ga=0;g=fa-96|0;fa=g;He(L[a+4>>2]);V=P[d+40>>2];W=P[d+36>>2];X=P[d+24>>2];Y=P[d+20>>2];G=P[b+20>>2];H=P[b+36>>2];I=P[b+24>>2];y=P[b+52>>2];m=P[c+52>>2];z=P[d+52>>2];l=P[e+52>>2];J=P[b+40>>2];A=P[b+56>>2];h=P[c+56>>2];B=P[d+56>>2];i=P[e+56>>2];Z=P[d+32>>2];$=P[d+16>>2];aa=P[d+8>>2];ba=P[d+4>>2];ca=P[d>>2];K=P[b>>2];M=P[b+16>>2];N=P[b+32>>2];O=P[b+4>>2];Q=P[b+8>>2];C=P[b+48>>2];j=P[c+48>>2];D=P[d+48>>2];p=P[e+48>>2];r=L[a+8>>2];L[g+60>>2]=0;x=S(S(j-C)-S(p-D));j=S(-x);t=S(S(m-y)-S(l-z));u=S(S(h-A)-S(i-B));P[g+56>>2]=S(S(Q*j)-S(I*t))-S(J*u);P[g+52>>2]=S(S(O*j)-S(G*t))-S(H*u);P[g+48>>2]=S(S(K*j)-S(M*t))-S(N*u);ha[L[L[r>>2]+64>>2]](g+80|0,r,g+48|0);h=P[b+52>>2];i=P[b+24>>2];p=P[b+20>>2];j=P[b+56>>2];m=P[b+40>>2];l=P[b+36>>2];k=P[b+16>>2];n=P[b+48>>2];s=P[b+8>>2];o=P[b>>2];q=P[b+4>>2];v=P[b+32>>2];L[g+76>>2]=0;R=j;j=P[g+88>>2];w=S(m*j);m=P[g+80>>2];T=l;l=P[g+84>>2];v=S(R+S(w+S(S(v*m)+S(T*l))));P[g+72>>2]=v;n=S(n+S(S(j*s)+S(S(m*o)+S(l*q))));P[g+64>>2]=n;h=S(h+S(S(j*i)+S(S(m*k)+S(l*p))));P[g+68>>2]=h;r=L[a+12>>2];j=P[d+20>>2];m=P[d+36>>2];l=P[d+24>>2];i=P[d+40>>2];p=P[d>>2];k=P[d+16>>2];s=P[d+32>>2];o=P[d+4>>2];q=P[d+8>>2];L[g+28>>2]=0;P[g+24>>2]=S(i*u)+S(S(q*x)+S(t*l));P[g+20>>2]=S(m*u)+S(S(o*x)+S(t*j));P[g+16>>2]=S(s*u)+S(S(p*x)+S(t*k));ha[L[L[r>>2]+64>>2]](g+32|0,r,g+16|0);p=P[d+56>>2];k=P[d+40>>2];s=P[d+36>>2];j=P[d+52>>2];m=P[d+24>>2];l=P[d+20>>2];o=P[d+32>>2];i=P[d+48>>2];q=P[d+8>>2];w=P[d>>2];U=P[d+4>>2];F=P[d+16>>2];L[g+60>>2]=0;L[g+92>>2]=0;R=j;j=P[g+40>>2];ea=S(m*j);m=P[g+32>>2];T=l;l=P[g+36>>2];F=S(R+S(ea+S(S(F*m)+S(T*l))));P[g+52>>2]=F;h=S(h-F);P[g+84>>2]=h;i=S(i+S(S(j*q)+S(S(m*w)+S(l*U))));P[g+48>>2]=i;i=S(n-i);P[g+80>>2]=i;j=S(p+S(S(j*k)+S(S(m*o)+S(l*s))));P[g+56>>2]=j;k=S(v-j);P[g+88>>2]=k;s=S(0);j=S(0);m=S(0);l=S(0);p=S(0);n=S(0);a:{b:{if(!(S(S(k*k)+S(S(i*i)+S(h*h)))>S(9999999747378752e-20))){break b}r=32;while(1){if(!r){break b}E=L[a+8>>2];L[g+12>>2]=0;h=S(-P[g+80>>2]);i=P[g+84>>2];k=P[g+88>>2];P[g+8>>2]=S(S(Q*h)-S(I*i))-S(J*k);P[g+4>>2]=S(S(O*h)-S(G*i))-S(H*k);P[g>>2]=S(S(K*h)-S(M*i))-S(N*k);da=g+16|0;ha[L[L[E>>2]+64>>2]](da,E,g);L[g+76>>2]=0;h=P[g+24>>2];i=P[g+16>>2];k=P[g+20>>2];P[g+72>>2]=A+S(S(h*J)+S(S(i*N)+S(H*k)));P[g+68>>2]=y+S(S(h*I)+S(S(i*M)+S(G*k)));P[g+64>>2]=C+S(S(h*Q)+S(S(i*K)+S(O*k)));E=L[a+12>>2];L[g+12>>2]=0;h=P[g+88>>2];i=P[g+80>>2];k=P[g+84>>2];P[g+8>>2]=S(V*h)+S(S(aa*i)+S(X*k));P[g+4>>2]=S(W*h)+S(S(ba*i)+S(Y*k));P[g>>2]=S(Z*h)+S(S(ca*i)+S($*k));ha[L[L[E>>2]+64>>2]](da,E,g);L[g+60>>2]=0;L[g+44>>2]=0;k=P[g+24>>2];o=P[g+16>>2];q=P[g+20>>2];h=S(z+S(S(k*X)+S(S(o*$)+S(Y*q))));P[g+52>>2]=h;v=S(P[g+68>>2]-h);P[g+36>>2]=v;h=P[g+84>>2];i=S(D+S(S(k*aa)+S(S(o*ca)+S(ba*q))));P[g+48>>2]=i;w=S(P[g+64>>2]-i);P[g+32>>2]=w;i=P[g+80>>2];k=S(B+S(S(k*V)+S(S(o*Z)+S(W*q))));P[g+56>>2]=k;o=S(P[g+72>>2]-k);P[g+40>>2]=o;if(n>S(1)){break a}k=P[g+88>>2];o=S(S(k*o)+S(S(i*w)+S(h*v)));if(o>S(0)){j=S(S(k*u)+S(S(i*x)+S(t*h)));if(j>=S(-14210854715202004e-30)){break a}m=P[b+48>>2];l=P[c+48>>2];p=P[b+52>>2];y=P[c+52>>2];A=P[b+56>>2];C=P[c+56>>2];D=P[d+48>>2];q=P[e+48>>2];z=P[d+52>>2];w=P[e+52>>2];B=P[d+56>>2];U=P[e+56>>2];L[g+44>>2]=0;P[g+36>>2]=v;n=S(n-S(o/j));j=S(S(1)-n);B=S(S(B*j)+S(n*U));z=S(S(j*z)+S(n*w));D=S(S(j*D)+S(n*q));A=S(S(j*A)+S(n*C));y=S(S(j*p)+S(n*y));C=S(S(j*m)+S(n*l));p=P[g+92>>2];m=h;l=k;j=i}if(!yl(L[a+4>>2],g+32|0)){Bl(L[a+4>>2],g+32|0,g- -64|0,g+48|0)}if(!zl(L[a+4>>2],g+80|0)){break b}r=r-1|0;h=P[g+88>>2];i=S(h*h);h=P[g+80>>2];k=S(h*h);h=P[g+84>>2];if(S(i+S(k+S(h*h)))>S(9999999747378752e-20)){continue}break}}P[f+164>>2]=n;n=S(0);i=S(0);h=S(0);k=S(S(l*l)+S(S(j*j)+S(m*m)));if(k>=S(14210854715202004e-30)){h=l;l=S(S(1)/S(_(k)));i=S(h*l);n=S(m*l);s=S(j*l);h=p}P[f+132>>2]=s;P[f+144>>2]=h;P[f+140>>2]=i;P[f+136>>2]=n;if(S(-P[f+172>>2])<=S(S(i*u)+S(S(s*x)+S(t*n)))){break a}xl(L[a+4>>2],g+16|0,g);a=L[g+12>>2];L[f+156>>2]=L[g+8>>2];L[f+160>>2]=a;a=L[g+4>>2];L[f+148>>2]=L[g>>2];L[f+152>>2]=a;ga=1}fa=g+96|0;return ga|0}function Wj(a,b,c){var d=S(0),e=S(0),f=S(0),g=S(0),h=S(0),i=S(0),j=S(0),k=S(0),l=S(0),m=S(0),n=S(0),o=S(0),p=S(0),q=S(0),r=S(0),s=S(0),t=S(0),u=S(0),v=S(0),w=0,x=S(0),y=S(0),z=S(0),A=S(0),B=S(0),C=S(0),D=S(0),E=S(0),F=S(0),G=S(0),H=S(0),I=0;w=L[a+4>>2];L[b>>2]=L[a>>2];L[b+4>>2]=w;w=L[a+12>>2];L[b+8>>2]=L[a+8>>2];L[b+12>>2]=w;w=L[a+28>>2];L[b+24>>2]=L[a+24>>2];L[b+28>>2]=w;w=L[a+20>>2];L[b+16>>2]=L[a+16>>2];L[b+20>>2]=w;w=L[a+36>>2];L[b+32>>2]=L[a+32>>2];L[b+36>>2]=w;w=L[a+44>>2];L[b+40>>2]=L[a+40>>2];L[b+44>>2]=w;e=P[a+8>>2];f=P[a+20>>2];l=P[a+40>>2];g=P[a+24>>2];i=P[a+36>>2];j=P[a+4>>2];m=P[a+32>>2];n=P[a+16>>2];h=P[a>>2];L[c+44>>2]=0;L[c+28>>2]=0;L[c+12>>2]=0;p=S(S(n*i)-S(m*f));k=S(S(f*l)-S(i*g));o=S(S(g*m)-S(l*n));d=S(S(1)/S(S(e*p)+S(S(h*k)+S(j*o))));q=S(S(S(e*i)-S(l*j))*d);P[c+4>>2]=q;r=S(S(S(j*g)-S(f*e))*d);P[c+8>>2]=r;o=S(o*d);P[c+16>>2]=o;s=S(S(S(h*l)-S(m*e))*d);P[c+20>>2]=s;t=S(S(S(e*n)-S(g*h))*d);P[c+24>>2]=t;p=S(p*d);P[c+32>>2]=p;u=S(S(S(j*m)-S(i*h))*d);P[c+36>>2]=u;v=S(S(S(h*f)-S(n*j))*d);P[c+40>>2]=v;k=S(k*d);P[c>>2]=k;a:{b:{if(!L[8470]){break b}while(1){d=S(T(k));e=S(T(o));j=S(T(p));h=S(S(d+e)+j);f=S(T(q));l=S(T(s));g=S(T(u));i=S(S(f+l)+g);h=h>i?h:i;i=S(T(r));m=S(T(t));n=S(T(v));y=S(S(i+m)+n);d=S(S(d+f)+i);e=S(S(e+l)+m);d=d>e?d:e;e=S(S(j+g)+n);e=S((h>y?h:y)*(d>e?d:e));if(e>2];f=S(T(y));j=P[b+16>>2];g=S(T(j));h=P[b+32>>2];n=S(T(h));d=S(S(f+g)+n);z=P[b+4>>2];B=S(T(z));m=P[b+20>>2];C=S(T(m));l=P[b+36>>2];D=S(T(l));i=S(S(B+C)+D);E=d>i?d:i;A=P[b+8>>2];F=S(T(A));i=P[b+24>>2];G=S(T(i));d=P[b+40>>2];H=S(T(d));x=S(S(F+G)+H);E=E>x?E:x;f=S(S(f+B)+F);g=S(S(g+C)+G);f=f>g?f:g;g=S(S(n+D)+H);f=S(E*(f>g?f:g));if(f>2]=0;L[b+28>>2]=0;L[b+12>>2]=0;x=d;e=Zf(S(e/f),S(.25));d=S(e+S(-2));e=S(S(1)/e);B=S(S(S(x*d)+S(v*e))*S(.5));f=S(x+B);P[b+40>>2]=f;C=S(S(S(l*d)+S(t*e))*S(.5));l=S(l+C);P[b+36>>2]=l;D=S(S(S(h*d)+S(e*r))*S(.5));g=S(h+D);P[b+32>>2]=g;F=S(S(S(i*d)+S(u*e))*S(.5));i=S(i+F);P[b+24>>2]=i;G=S(S(S(m*d)+S(s*e))*S(.5));m=S(m+G);P[b+20>>2]=m;H=S(S(S(j*d)+S(e*q))*S(.5));n=S(j+H);P[b+16>>2]=n;x=A;A=S(S(S(p*e)+S(d*A))*S(.5));j=S(x+A);P[b+8>>2]=j;x=z;z=S(S(S(o*e)+S(d*z))*S(.5));h=S(x+z);P[b+4>>2]=h;x=y;y=S(S(S(y*d)+S(k*e))*S(.5));e=S(x+y);P[b>>2]=e;L[c+44>>2]=0;L[c+28>>2]=0;L[c+12>>2]=0;q=S(S(n*l)-S(g*m));k=S(S(m*f)-S(l*i));r=S(S(i*g)-S(f*n));d=S(S(1)/S(S(j*q)+S(S(e*k)+S(r*h))));v=S(S(S(e*m)-S(n*h))*d);P[c+40>>2]=v;u=S(S(S(h*g)-S(l*e))*d);P[c+36>>2]=u;p=S(q*d);P[c+32>>2]=p;t=S(S(S(j*n)-S(i*e))*d);P[c+24>>2]=t;s=S(S(S(e*f)-S(g*j))*d);P[c+20>>2]=s;o=S(r*d);P[c+16>>2]=o;r=S(S(S(h*i)-S(m*j))*d);P[c+8>>2]=r;q=S(S(S(j*l)-S(f*h))*d);P[c+4>>2]=q;k=S(k*d);P[c>>2]=k;d=S(S(S(T(y))+S(T(H)))+S(T(D)));e=S(S(T(C))+S(S(T(G))+S(T(z))));d=d>e?d:e;e=S(S(T(B))+S(S(T(F))+S(T(A))));if(S(E*P[8469])>=(d>e?d:e)){break a}I=I+1|0;if(I>>>0>2];e=P[b+20>>2];j=P[b+40>>2];h=P[b+24>>2];f=P[a+36>>2];l=P[a+20>>2];g=P[a+4>>2];i=P[b+4>>2];m=P[a+40>>2];n=P[a+24>>2];q=P[a+8>>2];r=P[b+8>>2];o=P[a+32>>2];s=P[b+32>>2];t=P[a>>2];p=P[b>>2];u=P[a+16>>2];v=P[b+16>>2];L[c+44>>2]=0;L[c+28>>2]=0;L[c+12>>2]=0;k=S(S(o*s)+S(S(t*p)+S(v*u)));P[c>>2]=S(k+k)*S(.5);k=S(S(m*j)+S(S(q*r)+S(h*n)));P[c+40>>2]=S(k+k)*S(.5);k=S(S(S(S(f*j)+S(S(g*r)+S(h*l)))+S(S(m*d)+S(S(q*i)+S(e*n))))*S(.5));P[c+36>>2]=k;j=S(S(S(S(o*j)+S(S(t*r)+S(h*u)))+S(S(m*s)+S(S(q*p)+S(v*n))))*S(.5));P[c+32>>2]=j;P[c+24>>2]=k;h=S(S(f*d)+S(S(g*i)+S(e*l)));P[c+20>>2]=S(h+h)*S(.5);d=S(S(S(S(o*d)+S(S(t*i)+S(e*u)))+S(S(f*s)+S(S(g*p)+S(v*l))))*S(.5));P[c+16>>2]=d;P[c+8>>2]=j;P[c+4>>2]=d;return}d=P[a+32>>2];e=P[a>>2];j=P[a+16>>2];h=P[b+32>>2];f=P[b>>2];l=P[b+16>>2];g=P[a+36>>2];i=P[a+4>>2];m=P[a+20>>2];n=P[b+36>>2];q=P[b+4>>2];r=P[b+20>>2];o=P[a+40>>2];s=P[b+40>>2];t=P[a+8>>2];p=P[b+8>>2];u=P[a+24>>2];v=P[b+24>>2];L[c+44>>2]=0;L[c+28>>2]=0;L[c+12>>2]=0;k=S(S(o*s)+S(S(t*p)+S(v*u)));P[c+40>>2]=S(k+k)*S(.5);k=S(S(S(S(g*s)+S(S(i*p)+S(v*m)))+S(S(o*n)+S(S(t*q)+S(r*u))))*S(.5));P[c+36>>2]=k;o=S(S(S(S(d*s)+S(S(e*p)+S(v*j)))+S(S(o*h)+S(S(t*f)+S(l*u))))*S(.5));P[c+32>>2]=o;P[c+24>>2]=k;s=S(S(g*n)+S(S(i*q)+S(r*m)));P[c+20>>2]=S(s+s)*S(.5);g=S(S(S(S(d*n)+S(S(e*q)+S(r*j)))+S(S(g*h)+S(S(i*f)+S(l*m))))*S(.5));P[c+16>>2]=g;P[c+8>>2]=o;P[c+4>>2]=g;d=S(S(d*h)+S(S(e*f)+S(l*j)));P[c>>2]=S(d+d)*S(.5)}function sg(a,b,c){var d=S(0),e=S(0),f=S(0),g=S(0),h=S(0),i=S(0),j=S(0),k=S(0),l=S(0),m=S(0),n=S(0),o=S(0),p=S(0),q=S(0),r=S(0),s=S(0),t=S(0),u=S(0),v=S(0),w=S(0),x=S(0),y=S(0),z=S(0),A=S(0),B=0,C=0;B=M[a+180|0];C=M[a+48|0];a:{if(C?B:1){x=P[b+52>>2];z=P[b+56>>2];j=P[a+100>>2];k=P[a+104>>2];l=P[a+108>>2];d=P[b+20>>2];g=P[b+24>>2];y=P[a+68>>2];p=P[a+84>>2];q=P[a+56>>2];r=P[a+72>>2];s=P[a+88>>2];t=P[a+60>>2];h=P[b+36>>2];u=P[a+76>>2];m=P[b+40>>2];v=P[a+92>>2];A=P[b+48>>2];n=P[b+8>>2];o=P[b>>2];e=P[b+4>>2];f=P[b+16>>2];w=P[a+52>>2];i=P[b+32>>2];L[a+884>>2]=0;L[a+868>>2]=0;L[a+852>>2]=0;L[a+836>>2]=0;P[a+864>>2]=S(v*m)+S(S(t*i)+S(u*h));P[a+860>>2]=S(s*m)+S(S(q*i)+S(r*h));P[a+856>>2]=S(p*m)+S(S(w*i)+S(y*h));P[a+848>>2]=S(v*g)+S(S(t*f)+S(u*d));P[a+844>>2]=S(s*g)+S(S(q*f)+S(r*d));P[a+840>>2]=S(p*g)+S(S(w*f)+S(y*d));P[a+832>>2]=S(v*n)+S(S(t*o)+S(e*u));P[a+828>>2]=S(s*n)+S(S(q*o)+S(e*r));P[a+824>>2]=S(p*n)+S(S(w*o)+S(y*e));P[a+880>>2]=z+S(S(l*m)+S(S(j*i)+S(h*k)));P[a+876>>2]=x+S(S(l*g)+S(S(j*f)+S(d*k)));P[a+872>>2]=A+S(S(l*n)+S(S(j*o)+S(e*k)));j=P[a+172>>2];d=P[c+40>>2];k=P[a+164>>2];g=P[c+32>>2];h=P[c+36>>2];l=P[a+168>>2];y=S(S(j*d)+S(S(k*g)+S(h*l)));e=P[c+24>>2];f=P[c+16>>2];i=P[c+20>>2];m=S(S(j*e)+S(S(k*f)+S(i*l)));p=P[a+156>>2];q=P[a+124>>2];r=P[a+140>>2];n=S(S(p*d)+S(S(q*g)+S(r*h)));s=P[a+152>>2];t=P[a+120>>2];u=P[a+136>>2];o=S(S(s*d)+S(S(t*g)+S(u*h)));v=P[a+148>>2];w=P[a+116>>2];x=P[a+132>>2];z=S(S(v*d)+S(S(w*g)+S(x*h)));g=S(S(p*e)+S(S(q*f)+S(r*i)));h=S(S(s*e)+S(S(t*f)+S(u*i)));i=S(S(v*e)+S(S(w*f)+S(x*i)));d=P[c+8>>2];e=P[c>>2];f=P[c+4>>2];j=S(S(j*d)+S(S(k*e)+S(f*l)));k=S(S(p*d)+S(S(q*e)+S(f*r)));l=S(S(s*d)+S(S(t*e)+S(f*u)));d=S(S(v*d)+S(S(w*e)+S(x*f)));break a}x=P[c+52>>2];z=P[c+56>>2];j=P[a+164>>2];k=P[a+168>>2];l=P[a+172>>2];d=P[c+20>>2];g=P[c+24>>2];y=P[a+132>>2];p=P[a+148>>2];q=P[a+120>>2];r=P[a+136>>2];s=P[a+152>>2];t=P[a+124>>2];h=P[c+36>>2];u=P[a+140>>2];m=P[c+40>>2];v=P[a+156>>2];A=P[c+48>>2];n=P[c+8>>2];o=P[c>>2];e=P[c+4>>2];f=P[c+16>>2];w=P[a+116>>2];i=P[c+32>>2];L[a+884>>2]=0;L[a+868>>2]=0;L[a+852>>2]=0;L[a+836>>2]=0;P[a+864>>2]=S(v*m)+S(S(t*i)+S(u*h));P[a+860>>2]=S(s*m)+S(S(q*i)+S(r*h));P[a+856>>2]=S(p*m)+S(S(w*i)+S(y*h));P[a+848>>2]=S(v*g)+S(S(t*f)+S(u*d));P[a+844>>2]=S(s*g)+S(S(q*f)+S(r*d));P[a+840>>2]=S(p*g)+S(S(w*f)+S(y*d));P[a+832>>2]=S(v*n)+S(S(t*o)+S(e*u));P[a+828>>2]=S(s*n)+S(S(q*o)+S(e*r));P[a+824>>2]=S(p*n)+S(S(w*o)+S(y*e));P[a+880>>2]=z+S(S(l*m)+S(S(j*i)+S(h*k)));P[a+876>>2]=x+S(S(l*g)+S(S(j*f)+S(d*k)));P[a+872>>2]=A+S(S(l*n)+S(S(j*o)+S(e*k)));j=P[a+108>>2];d=P[b+40>>2];k=P[a+100>>2];g=P[b+32>>2];h=P[b+36>>2];l=P[a+104>>2];y=S(S(j*d)+S(S(k*g)+S(h*l)));e=P[b+24>>2];f=P[b+16>>2];i=P[b+20>>2];m=S(S(j*e)+S(S(k*f)+S(i*l)));p=P[a+92>>2];q=P[a+60>>2];r=P[a+76>>2];n=S(S(p*d)+S(S(q*g)+S(r*h)));s=P[a+88>>2];t=P[a+56>>2];u=P[a+72>>2];o=S(S(s*d)+S(S(t*g)+S(u*h)));v=P[a+84>>2];w=P[a+52>>2];x=P[a+68>>2];z=S(S(v*d)+S(S(w*g)+S(x*h)));g=S(S(p*e)+S(S(q*f)+S(r*i)));h=S(S(s*e)+S(S(t*f)+S(u*i)));i=S(S(v*e)+S(S(w*f)+S(x*i)));d=P[b+8>>2];e=P[b>>2];f=P[b+4>>2];j=S(S(j*d)+S(S(k*e)+S(f*l)));k=S(S(p*d)+S(S(q*e)+S(f*r)));l=S(S(s*d)+S(S(t*e)+S(f*u)));c=b;d=S(S(v*d)+S(S(w*e)+S(x*f)))}e=P[c+56>>2];f=P[c+52>>2];P[a+936>>2]=P[c+48>>2]+j;L[a+932>>2]=0;P[a+928>>2]=n;P[a+924>>2]=o;P[a+920>>2]=z;L[a+916>>2]=0;P[a+912>>2]=g;P[a+908>>2]=h;P[a+904>>2]=i;L[a+900>>2]=0;P[a+896>>2]=k;P[a+892>>2]=l;P[a+888>>2]=d;L[a+948>>2]=0;P[a+940>>2]=m+f;P[a+944>>2]=y+e;b=L[a+876>>2];L[a+968>>2]=L[a+872>>2];L[a+972>>2]=b;b=L[a+884>>2];L[a+976>>2]=L[a+880>>2];L[a+980>>2]=b;b=L[a+948>>2];L[a+992>>2]=L[a+944>>2];L[a+996>>2]=b;b=L[a+940>>2];L[a+984>>2]=L[a+936>>2];L[a+988>>2]=b;e=P[a+840>>2];f=P[a+856>>2];i=P[a+824>>2];L[a+964>>2]=0;P[a+960>>2]=f;P[a+956>>2]=e;P[a+952>>2]=i;b:{if(B|C){n=P[a+972>>2];g=S(P[a+988>>2]-n);o=P[a+968>>2];h=S(P[a+984>>2]-o);m=P[a+976>>2];d=S(P[a+992>>2]-m);break b}n=P[a+972>>2];g=S(n-P[a+988>>2]);o=P[a+968>>2];h=S(o-P[a+984>>2]);m=P[a+976>>2];d=S(m-P[a+992>>2])}P[a+1016>>2]=h;L[a+1028>>2]=0;P[a+1024>>2]=d;P[a+1020>>2]=g;L[a+1012>>2]=0;j=S(S(f*d)+S(S(i*h)+S(e*g)));P[a+1032>>2]=j;P[a+1008>>2]=S(f*j)+m;P[a+1004>>2]=n+S(e*j);P[a+1e3>>2]=o+S(i*j);P[a+1036>>2]=S(d*P[a+860>>2])+S(S(h*P[a+828>>2])+S(P[a+844>>2]*g));P[a+1040>>2]=S(d*P[a+864>>2])+S(S(h*P[a+832>>2])+S(P[a+848>>2]*g))}function Vn(a,b,c){a=a|0;b=b|0;c=c|0;var d=S(0),e=S(0),f=0,g=0,h=0;f=fa-96|0;fa=f;L[f+92>>2]=a;L[f+88>>2]=b;L[f+84>>2]=c;a=L[f+92>>2];b=f+12|0;ej(b);ha[L[L[a>>2]+20>>2]](a,L[f+88>>2],b);d=P[f+76>>2];a=fa-32|0;fa=a;L[a+28>>2]=L[f+84>>2];L[a+24>>2]=b;L[a+20>>2]=b+16;L[a+16>>2]=b+32;P[a+12>>2]=d;c=L[a+28>>2];b=fa-16|0;L[b+12>>2]=L[a+24>>2];e=P[L[b+12>>2]>>2];L[b+12>>2]=L[a+20>>2];d=P[L[b+12>>2]>>2];L[b+12>>2]=L[a+16>>2];a:{if(P[L[b+12>>2]>>2]>2]=L[a+16>>2];d=P[L[b+12>>2]>>2];break a}b=fa-16|0;L[b+12>>2]=L[a+20>>2];d=P[L[b+12>>2]>>2]}b:{if(e>d){b=fa-16|0;L[b+12>>2]=L[a+20>>2];d=P[L[b+12>>2]>>2];L[b+12>>2]=L[a+16>>2];c:{if(P[L[b+12>>2]>>2]>2]=L[a+16>>2];d=P[L[b+12>>2]>>2];break c}b=fa-16|0;L[b+12>>2]=L[a+20>>2];d=P[L[b+12>>2]>>2]}break b}b=fa-16|0;L[b+12>>2]=L[a+24>>2];d=P[L[b+12>>2]>>2]}b=fa-16|0;L[b+12>>2]=c;P[L[b+12>>2]>>2]=d;L[b+12>>2]=L[a+24>>2];e=P[L[b+12>>2]+4>>2];L[b+12>>2]=L[a+20>>2];d=P[L[b+12>>2]+4>>2];L[b+12>>2]=L[a+16>>2];d:{if(P[L[b+12>>2]+4>>2]>2]=L[a+16>>2];d=P[L[b+12>>2]+4>>2];break d}b=fa-16|0;L[b+12>>2]=L[a+20>>2];d=P[L[b+12>>2]+4>>2]}e:{if(e>d){b=fa-16|0;L[b+12>>2]=L[a+20>>2];d=P[L[b+12>>2]+4>>2];L[b+12>>2]=L[a+16>>2];f:{if(P[L[b+12>>2]+4>>2]>2]=L[a+16>>2];d=P[L[b+12>>2]+4>>2];break f}b=fa-16|0;L[b+12>>2]=L[a+20>>2];d=P[L[b+12>>2]+4>>2]}break e}b=fa-16|0;L[b+12>>2]=L[a+24>>2];d=P[L[b+12>>2]+4>>2]}b=fa-16|0;L[b+12>>2]=c;P[L[b+12>>2]+4>>2]=d;L[b+12>>2]=L[a+24>>2];e=P[L[b+12>>2]+8>>2];L[b+12>>2]=L[a+20>>2];d=P[L[b+12>>2]+8>>2];L[b+12>>2]=L[a+16>>2];g:{if(P[L[b+12>>2]+8>>2]>2]=L[a+16>>2];d=P[L[b+12>>2]+8>>2];break g}b=fa-16|0;L[b+12>>2]=L[a+20>>2];d=P[L[b+12>>2]+8>>2]}h:{if(e>d){b=fa-16|0;L[b+12>>2]=L[a+20>>2];d=P[L[b+12>>2]+8>>2];L[b+12>>2]=L[a+16>>2];i:{if(P[L[b+12>>2]+8>>2]>2]=L[a+16>>2];d=P[L[b+12>>2]+8>>2];break i}b=fa-16|0;L[b+12>>2]=L[a+20>>2];d=P[L[b+12>>2]+8>>2]}break h}b=fa-16|0;L[b+12>>2]=L[a+24>>2];d=P[L[b+12>>2]+8>>2]}b=fa-16|0;L[b+12>>2]=c;P[L[b+12>>2]+8>>2]=d;L[b+12>>2]=L[a+24>>2];e=P[L[b+12>>2]>>2];L[b+12>>2]=L[a+20>>2];d=P[L[b+12>>2]>>2];L[b+12>>2]=L[a+16>>2];j:{if(P[L[b+12>>2]>>2]>d){b=fa-16|0;L[b+12>>2]=L[a+16>>2];d=P[L[b+12>>2]>>2];break j}b=fa-16|0;L[b+12>>2]=L[a+20>>2];d=P[L[b+12>>2]>>2]}k:{if(e>2]=L[a+20>>2];d=P[L[b+12>>2]>>2];L[b+12>>2]=L[a+16>>2];l:{if(P[L[b+12>>2]>>2]>d){b=fa-16|0;L[b+12>>2]=L[a+16>>2];d=P[L[b+12>>2]>>2];break l}b=fa-16|0;L[b+12>>2]=L[a+20>>2];d=P[L[b+12>>2]>>2]}break k}b=fa-16|0;L[b+12>>2]=L[a+24>>2];d=P[L[b+12>>2]>>2]}b=fa-16|0;L[b+12>>2]=c+16;P[L[b+12>>2]>>2]=d;L[b+12>>2]=L[a+24>>2];e=P[L[b+12>>2]+4>>2];L[b+12>>2]=L[a+20>>2];d=P[L[b+12>>2]+4>>2];L[b+12>>2]=L[a+16>>2];m:{if(P[L[b+12>>2]+4>>2]>d){b=fa-16|0;L[b+12>>2]=L[a+16>>2];d=P[L[b+12>>2]+4>>2];break m}b=fa-16|0;L[b+12>>2]=L[a+20>>2];d=P[L[b+12>>2]+4>>2]}n:{if(e>2]=L[a+20>>2];d=P[L[b+12>>2]+4>>2];L[b+12>>2]=L[a+16>>2];o:{if(P[L[b+12>>2]+4>>2]>d){b=fa-16|0;L[b+12>>2]=L[a+16>>2];d=P[L[b+12>>2]+4>>2];break o}b=fa-16|0;L[b+12>>2]=L[a+20>>2];d=P[L[b+12>>2]+4>>2]}break n}b=fa-16|0;L[b+12>>2]=L[a+24>>2];d=P[L[b+12>>2]+4>>2]}b=fa-16|0;L[b+12>>2]=c+16;P[L[b+12>>2]+4>>2]=d;L[b+12>>2]=L[a+24>>2];e=P[L[b+12>>2]+8>>2];L[b+12>>2]=L[a+20>>2];d=P[L[b+12>>2]+8>>2];L[b+12>>2]=L[a+16>>2];p:{if(P[L[b+12>>2]+8>>2]>d){b=fa-16|0;L[b+12>>2]=L[a+16>>2];d=P[L[b+12>>2]+8>>2];break p}b=fa-16|0;L[b+12>>2]=L[a+20>>2];d=P[L[b+12>>2]+8>>2]}q:{if(e>2]=L[a+20>>2];d=P[L[b+12>>2]+8>>2];L[b+12>>2]=L[a+16>>2];r:{if(P[L[b+12>>2]+8>>2]>d){b=fa-16|0;L[b+12>>2]=L[a+16>>2];d=P[L[b+12>>2]+8>>2];break r}b=fa-16|0;L[b+12>>2]=L[a+20>>2];d=P[L[b+12>>2]+8>>2]}break q}b=fa-16|0;L[b+12>>2]=L[a+24>>2];d=P[L[b+12>>2]+8>>2]}b=fa-16|0;h=c+16|0;L[b+12>>2]=h;P[L[b+12>>2]+8>>2]=d;d=P[a+12>>2];L[b+12>>2]=c;g=L[b+12>>2];P[g>>2]=P[g>>2]-d;d=P[a+12>>2];L[b+12>>2]=c;g=L[b+12>>2];P[g+4>>2]=P[g+4>>2]-d;d=P[a+12>>2];L[b+12>>2]=c;c=L[b+12>>2];P[c+8>>2]=P[c+8>>2]-d;d=P[a+12>>2];L[b+12>>2]=h;c=L[b+12>>2];P[c>>2]=P[c>>2]+d;d=P[a+12>>2];L[b+12>>2]=h;c=L[b+12>>2];P[c+4>>2]=P[c+4>>2]+d;d=P[a+12>>2];L[b+12>>2]=h;b=L[b+12>>2];P[b+8>>2]=P[b+8>>2]+d;fa=a+32|0;fa=f+96|0}function vA(a,b){a=a|0;b=S(b);var c=0,d=0,e=0,f=0,g=S(0),h=0,i=0,j=S(0),k=S(0),l=S(0),m=S(0),n=S(0),o=S(0),p=S(0),q=S(0),r=S(0),s=S(0),t=S(0),u=0,v=S(0),w=S(0),x=S(0),y=S(0),z=S(0),A=S(0),B=S(0),C=S(0),D=S(0),E=S(0),F=S(0);c=fa-288|0;fa=c;wa(2726);if(L[a+232>>2]>0){while(1){d=L[L[a+240>>2]+(i<<2)>>2];L[d+244>>2]=1065353216;a:{b:{switch(L[d+216>>2]-2|0){case 0:case 3:break a;default:break b}}if(M[d+204|0]&3){break a}ue(d,b,c+224|0);c:{d:{if(!M[a+44|0]){break d}g=P[d+252>>2];g=S(g*g);if(g==S(0)){break d}j=S(P[c+280>>2]-P[d+60>>2]);l=S(j*j);j=S(P[c+272>>2]-P[d+52>>2]);k=S(j*j);j=S(P[c+276>>2]-P[d+56>>2]);if(!(g>2]+4>>2]<=19){L[8289]=L[8289]+1;e=L[a+68>>2];e=ha[L[L[e>>2]+36>>2]](e)|0;f=L[a+24>>2];L[c+132>>2]=1065353216;L[c+136>>2]=-65535;h=L[d+64>>2];L[c+148>>2]=L[d+60>>2];L[c+152>>2]=h;h=L[d+56>>2];L[c+140>>2]=L[d+52>>2];L[c+144>>2]=h;h=L[c+284>>2];L[c+164>>2]=L[c+280>>2];L[c+168>>2]=h;h=L[c+276>>2];L[c+156>>2]=L[c+272>>2];L[c+160>>2]=h;L[c+220>>2]=f;L[c+216>>2]=e;L[c+212>>2]=0;L[c+128>>2]=20724;L[c+204>>2]=0;L[c+208>>2]=d;g=P[d+248>>2];e=c+76|0;L[e+4>>2]=35;L[e+8>>2]=0;L[e>>2]=14328;L[e+44>>2]=1025758986;L[e+12>>2]=1065353216;L[e+16>>2]=1065353216;L[e>>2]=14044;L[e+20>>2]=1065353216;L[e+24>>2]=0;L[e>>2]=16192;P[c+120>>2]=g;P[c+104>>2]=g;L[c+80>>2]=8;P[c+212>>2]=P[a+56>>2];f=L[d+188>>2];K[c+136>>1]=N[f+4>>1];K[c+138>>1]=N[f+6>>1];f=L[c+236>>2];L[c+16>>2]=L[c+232>>2];L[c+20>>2]=f;f=L[c+228>>2];L[c+8>>2]=L[c+224>>2];L[c+12>>2]=f;f=L[c+252>>2];L[c+32>>2]=L[c+248>>2];L[c+36>>2]=f;f=L[c+244>>2];L[c+24>>2]=L[c+240>>2];L[c+28>>2]=f;f=L[c+268>>2];L[c+48>>2]=L[c+264>>2];L[c+52>>2]=f;f=L[c+260>>2];L[c+40>>2]=L[c+256>>2];L[c+44>>2]=f;f=L[c+284>>2];L[c+64>>2]=L[c+280>>2];L[c+68>>2]=f;f=L[c+276>>2];L[c+56>>2]=L[c+272>>2];L[c+60>>2]=f;f=d+4|0;h=L[f+12>>2];L[c+16>>2]=L[f+8>>2];L[c+20>>2]=h;h=L[f+4>>2];L[c+8>>2]=L[f>>2];L[c+12>>2]=h;h=L[d+32>>2];L[c+32>>2]=L[d+28>>2];L[c+36>>2]=h;h=L[d+24>>2];L[c+24>>2]=L[d+20>>2];L[c+28>>2]=h;h=L[d+48>>2];L[c+48>>2]=L[d+44>>2];L[c+52>>2]=h;h=L[d+40>>2];L[c+40>>2]=L[d+36>>2];L[c+44>>2]=h;Ab(a,e,f,c+8|0,c+128|0,S(0));g=P[c+132>>2];if(g>2]=g;e=c+224|0;ue(d,S(g*b),e);L[d+244>>2]=0;Hk(d,e);va()}i=i+1|0;if((i|0)>2]){continue}break}}if(M[a+275|0]){wa(2922);i=L[a+308>>2];if((i|0)>0){while(1){f=L[L[a+316>>2]+(u<<2)>>2];if(L[f+748>>2]>0){d=L[f+744>>2];d=L[d+236>>2]<<30>>31&d;e=L[f+740>>2];e=L[e+236>>2]<<30>>31&e;h=0;while(1){b=S(P[e+228>>2]*P[d+228>>2]);e:{if(!(b>S(0))){break e}i=f+R(h,184)|0;g=P[i+124>>2];if(g==S(0)){break e}r=P[i+44>>2];y=P[d+60>>2];s=P[i+40>>2];z=P[d+56>>2];t=P[i+36>>2];A=P[d+52>>2];j=S(b*S(g*S(-P[i+76>>2])));k=S(b*S(g*S(-P[i+72>>2])));g=S(b*S(g*S(-P[i+68>>2])));b=P[e+344>>2];if(b!=S(0)){n=P[i+56>>2];o=P[i+60>>2];p=P[i+52>>2];q=S(g*P[e+348>>2]);P[e+312>>2]=S(b*q)+P[e+312>>2];m=S(k*P[e+352>>2]);P[e+316>>2]=S(b*m)+P[e+316>>2];l=b;b=S(j*P[e+356>>2]);P[e+320>>2]=S(l*b)+P[e+320>>2];l=P[e+552>>2];v=P[e+304>>2];w=P[e+296>>2];B=P[e+300>>2];C=P[e+548>>2];D=P[e+288>>2];E=P[e+280>>2];F=P[e+284>>2];p=S(p-P[e+52>>2]);x=S(n-P[e+56>>2]);n=S(S(p*m)-S(q*x));o=S(o-P[e+60>>2]);m=S(S(x*b)-S(m*o));b=S(S(o*q)-S(b*p));P[e+328>>2]=S(S(S(P[e+272>>2]*n)+S(S(P[e+264>>2]*m)+S(b*P[e+268>>2])))*P[e+544>>2])+P[e+328>>2];P[e+332>>2]=S(C*S(S(D*n)+S(S(E*m)+S(b*F))))+P[e+332>>2];P[e+336>>2]=S(l*S(S(v*n)+S(S(w*m)+S(b*B))))+P[e+336>>2]}b=P[d+344>>2];if(b==S(0)){break e}g=S(P[d+348>>2]*S(-g));P[d+312>>2]=S(b*g)+P[d+312>>2];k=S(P[d+352>>2]*S(-k));P[d+316>>2]=S(b*k)+P[d+316>>2];l=b;b=S(P[d+356>>2]*S(-j));P[d+320>>2]=S(l*b)+P[d+320>>2];q=P[d+552>>2];m=P[d+304>>2];n=P[d+296>>2];o=P[d+300>>2];p=P[d+548>>2];l=P[d+288>>2];v=P[d+280>>2];w=P[d+284>>2];t=S(t-A);s=S(s-z);j=S(S(t*k)-S(g*s));r=S(r-y);k=S(S(s*b)-S(k*r));b=S(S(r*g)-S(b*t));P[d+328>>2]=S(S(S(P[d+272>>2]*j)+S(S(P[d+264>>2]*k)+S(b*P[d+268>>2])))*P[d+544>>2])+P[d+328>>2];P[d+332>>2]=S(p*S(S(l*j)+S(S(v*k)+S(b*w))))+P[d+332>>2];P[d+336>>2]=S(q*S(S(m*j)+S(S(n*k)+S(b*o))))+P[d+336>>2]}h=h+1|0;if((h|0)>2]){continue}break}i=L[a+308>>2]}u=u+1|0;if((u|0)<(i|0)){continue}break}}va()}va();fa=c+288|0}function gj(a,b,c,d,e){var f=0,g=S(0);f=fa-32|0;fa=f;L[f+24>>2]=a;L[f+20>>2]=b;L[f+16>>2]=c;L[f+12>>2]=d;P[f+8>>2]=e;a=L[f+24>>2];L[f+28>>2]=a;b=fa-16|0;L[b+12>>2]=a;L[b+12>>2]=a+16;L[b+12>>2]=L[f+20>>2];g=P[L[b+12>>2]>>2];L[b+12>>2]=L[f+16>>2];e=P[L[b+12>>2]>>2];L[b+12>>2]=L[f+12>>2];a:{if(P[L[b+12>>2]>>2]>2]=L[f+12>>2];e=P[L[b+12>>2]>>2];break a}b=fa-16|0;L[b+12>>2]=L[f+16>>2];e=P[L[b+12>>2]>>2]}b:{if(g>e){b=fa-16|0;L[b+12>>2]=L[f+16>>2];e=P[L[b+12>>2]>>2];L[b+12>>2]=L[f+12>>2];c:{if(P[L[b+12>>2]>>2]>2]=L[f+12>>2];e=P[L[b+12>>2]>>2];break c}b=fa-16|0;L[b+12>>2]=L[f+16>>2];e=P[L[b+12>>2]>>2]}break b}b=fa-16|0;L[b+12>>2]=L[f+20>>2];e=P[L[b+12>>2]>>2]}b=fa-16|0;L[b+12>>2]=a;P[L[b+12>>2]>>2]=e;L[b+12>>2]=L[f+20>>2];g=P[L[b+12>>2]+4>>2];L[b+12>>2]=L[f+16>>2];e=P[L[b+12>>2]+4>>2];L[b+12>>2]=L[f+12>>2];d:{if(P[L[b+12>>2]+4>>2]>2]=L[f+12>>2];e=P[L[b+12>>2]+4>>2];break d}b=fa-16|0;L[b+12>>2]=L[f+16>>2];e=P[L[b+12>>2]+4>>2]}e:{if(g>e){b=fa-16|0;L[b+12>>2]=L[f+16>>2];e=P[L[b+12>>2]+4>>2];L[b+12>>2]=L[f+12>>2];f:{if(P[L[b+12>>2]+4>>2]>2]=L[f+12>>2];e=P[L[b+12>>2]+4>>2];break f}b=fa-16|0;L[b+12>>2]=L[f+16>>2];e=P[L[b+12>>2]+4>>2]}break e}b=fa-16|0;L[b+12>>2]=L[f+20>>2];e=P[L[b+12>>2]+4>>2]}b=fa-16|0;L[b+12>>2]=a;P[L[b+12>>2]+4>>2]=e;L[b+12>>2]=L[f+20>>2];g=P[L[b+12>>2]+8>>2];L[b+12>>2]=L[f+16>>2];e=P[L[b+12>>2]+8>>2];L[b+12>>2]=L[f+12>>2];g:{if(P[L[b+12>>2]+8>>2]>2]=L[f+12>>2];e=P[L[b+12>>2]+8>>2];break g}b=fa-16|0;L[b+12>>2]=L[f+16>>2];e=P[L[b+12>>2]+8>>2]}h:{if(g>e){b=fa-16|0;L[b+12>>2]=L[f+16>>2];e=P[L[b+12>>2]+8>>2];L[b+12>>2]=L[f+12>>2];i:{if(P[L[b+12>>2]+8>>2]>2]=L[f+12>>2];e=P[L[b+12>>2]+8>>2];break i}b=fa-16|0;L[b+12>>2]=L[f+16>>2];e=P[L[b+12>>2]+8>>2]}break h}b=fa-16|0;L[b+12>>2]=L[f+20>>2];e=P[L[b+12>>2]+8>>2]}b=fa-16|0;L[b+12>>2]=a;P[L[b+12>>2]+8>>2]=e;L[b+12>>2]=L[f+20>>2];g=P[L[b+12>>2]>>2];L[b+12>>2]=L[f+16>>2];e=P[L[b+12>>2]>>2];L[b+12>>2]=L[f+12>>2];j:{if(P[L[b+12>>2]>>2]>e){b=fa-16|0;L[b+12>>2]=L[f+12>>2];e=P[L[b+12>>2]>>2];break j}b=fa-16|0;L[b+12>>2]=L[f+16>>2];e=P[L[b+12>>2]>>2]}k:{if(g>2]=L[f+16>>2];e=P[L[b+12>>2]>>2];L[b+12>>2]=L[f+12>>2];l:{if(P[L[b+12>>2]>>2]>e){b=fa-16|0;L[b+12>>2]=L[f+12>>2];e=P[L[b+12>>2]>>2];break l}b=fa-16|0;L[b+12>>2]=L[f+16>>2];e=P[L[b+12>>2]>>2]}break k}b=fa-16|0;L[b+12>>2]=L[f+20>>2];e=P[L[b+12>>2]>>2]}b=fa-16|0;L[b+12>>2]=a+16;P[L[b+12>>2]>>2]=e;L[b+12>>2]=L[f+20>>2];g=P[L[b+12>>2]+4>>2];L[b+12>>2]=L[f+16>>2];e=P[L[b+12>>2]+4>>2];L[b+12>>2]=L[f+12>>2];m:{if(P[L[b+12>>2]+4>>2]>e){b=fa-16|0;L[b+12>>2]=L[f+12>>2];e=P[L[b+12>>2]+4>>2];break m}b=fa-16|0;L[b+12>>2]=L[f+16>>2];e=P[L[b+12>>2]+4>>2]}n:{if(g>2]=L[f+16>>2];e=P[L[b+12>>2]+4>>2];L[b+12>>2]=L[f+12>>2];o:{if(P[L[b+12>>2]+4>>2]>e){b=fa-16|0;L[b+12>>2]=L[f+12>>2];e=P[L[b+12>>2]+4>>2];break o}b=fa-16|0;L[b+12>>2]=L[f+16>>2];e=P[L[b+12>>2]+4>>2]}break n}b=fa-16|0;L[b+12>>2]=L[f+20>>2];e=P[L[b+12>>2]+4>>2]}b=fa-16|0;L[b+12>>2]=a+16;P[L[b+12>>2]+4>>2]=e;L[b+12>>2]=L[f+20>>2];g=P[L[b+12>>2]+8>>2];L[b+12>>2]=L[f+16>>2];e=P[L[b+12>>2]+8>>2];L[b+12>>2]=L[f+12>>2];p:{if(P[L[b+12>>2]+8>>2]>e){b=fa-16|0;L[b+12>>2]=L[f+12>>2];e=P[L[b+12>>2]+8>>2];break p}b=fa-16|0;L[b+12>>2]=L[f+16>>2];e=P[L[b+12>>2]+8>>2]}q:{if(g>2]=L[f+16>>2];e=P[L[b+12>>2]+8>>2];L[b+12>>2]=L[f+12>>2];r:{if(P[L[b+12>>2]+8>>2]>e){b=fa-16|0;L[b+12>>2]=L[f+12>>2];e=P[L[b+12>>2]+8>>2];break r}b=fa-16|0;L[b+12>>2]=L[f+16>>2];e=P[L[b+12>>2]+8>>2]}break q}b=fa-16|0;L[b+12>>2]=L[f+20>>2];e=P[L[b+12>>2]+8>>2]}b=fa-16|0;c=a+16|0;L[b+12>>2]=c;P[L[b+12>>2]+8>>2]=e;e=P[f+8>>2];L[b+12>>2]=a;d=L[b+12>>2];P[d>>2]=P[d>>2]-e;e=P[f+8>>2];L[b+12>>2]=a;d=L[b+12>>2];P[d+4>>2]=P[d+4>>2]-e;e=P[f+8>>2];L[b+12>>2]=a;a=L[b+12>>2];P[a+8>>2]=P[a+8>>2]-e;e=P[f+8>>2];L[b+12>>2]=c;a=L[b+12>>2];P[a>>2]=P[a>>2]+e;e=P[f+8>>2];L[b+12>>2]=c;a=L[b+12>>2];P[a+4>>2]=P[a+4>>2]+e;e=P[f+8>>2];L[b+12>>2]=c;a=L[b+12>>2];P[a+8>>2]=P[a+8>>2]+e;fa=f+32|0}function xb(a,b,c,d,e,f,g){var h=0,i=0,j=S(0),k=S(0),l=0,m=S(0),n=S(0),o=S(0),p=S(0),q=S(0),r=0,s=0,t=0,u=S(0),v=S(0),w=S(0),x=S(0),y=S(0),z=S(0),A=S(0),B=S(0),C=S(0),D=S(0),E=S(0),F=S(0),G=0,H=S(0),I=S(0),K=S(0),O=S(0),Q=S(0),R=S(0),U=S(0),V=S(0),W=S(0);i=fa+-64|0;fa=i;r=e<<4;h=r+L[a+16>>2]|0;s=N[h>>1];l=N[h+2>>1];t=N[h+4>>1];m=P[a+28>>2];n=P[a+60>>2];o=P[a+32>>2];p=P[a- -64>>2];k=P[a+24>>2];j=P[a+56>>2];L[i+44>>2]=0;P[i+40>>2]=o+S(S(t>>>0)/p);P[i+36>>2]=m+S(S(l>>>0)/n);P[i+32>>2]=k+S(S(s>>>0)/j);s=N[h+6>>1];l=N[h+8>>1];h=N[h+10>>1];L[i+60>>2]=0;P[i+56>>2]=o+S(S(h>>>0)/p);P[i+52>>2]=m+S(S(l>>>0)/n);P[i+48>>2]=k+S(S(s>>>0)/j);s=f<<4;h=s+L[b+16>>2]|0;l=N[h>>1];t=N[h+2>>1];G=N[h+4>>1];m=P[b+28>>2];n=P[b+60>>2];o=P[b+32>>2];p=P[b- -64>>2];k=P[b+24>>2];j=P[b+56>>2];L[i+12>>2]=0;P[i+8>>2]=o+S(S(G>>>0)/p);P[i+4>>2]=m+S(S(t>>>0)/n);P[i>>2]=k+S(S(l>>>0)/j);l=N[h+6>>1];t=N[h+8>>1];h=N[h+10>>1];L[i+28>>2]=0;P[i+24>>2]=o+S(S(h>>>0)/p);P[i+20>>2]=m+S(S(t>>>0)/n);P[i+16>>2]=k+S(S(l>>>0)/j);h=0;H=P[d+24>>2];m=P[i+24>>2];j=S(S(m+P[i+8>>2])*S(.5));I=P[d+16>>2];n=P[i+16>>2];q=S(S(n+P[i>>2])*S(.5));o=P[i+20>>2];u=S(S(o+P[i+4>>2])*S(.5));K=P[d+20>>2];p=P[i+48>>2];k=S(S(p+P[i+32>>2])*S(.5));v=S(S(P[d>>2]+S(S(H*j)+S(S(I*q)+S(u*K))))-k);y=P[d+72>>2];m=S(m-j);z=P[d+64>>2];n=S(n-q);A=P[d+68>>2];o=S(o-u);p=S(p-k);a:{if(S(T(v))>S(S(S(y*m)+S(S(z*n)+S(A*o)))+p)){break a}O=P[d+40>>2];Q=P[d+32>>2];R=P[d+36>>2];k=P[i+52>>2];w=S(S(k+P[i+36>>2])*S(.5));x=S(S(P[d+4>>2]+S(S(O*j)+S(S(Q*q)+S(u*R))))-w);B=P[d+88>>2];C=P[d+80>>2];D=P[d+84>>2];k=S(k-w);if(S(T(x))>S(S(S(B*m)+S(S(C*n)+S(D*o)))+k)){break a}U=P[d+56>>2];V=P[d+48>>2];W=P[d+52>>2];q=S(P[d+8>>2]+S(S(U*j)+S(S(V*q)+S(u*W))));j=P[i+56>>2];F=S(S(j+P[i+40>>2])*S(.5));q=S(q-F);u=P[d+104>>2];w=P[d+96>>2];E=P[d+100>>2];j=S(j-F);if(S(T(q))>S(S(S(u*m)+S(S(w*n)+S(E*o)))+j)|S(T(S(S(q*V)+S(S(v*I)+S(x*Q)))))>S(S(S(j*w)+S(S(p*z)+S(k*C)))+n)|S(T(S(S(q*W)+S(S(v*K)+S(x*R)))))>S(S(S(j*E)+S(S(p*A)+S(k*D)))+o)){break a}l=S(T(S(S(q*U)+S(S(v*H)+S(x*O)))))>S(S(S(j*u)+S(S(p*y)+S(k*B)))+m);h=!l;if(!g|l){break a}b:{if(S(T(S(S(q*Q)-S(V*x))))>S(S(m*A)+S(S(o*y)+S(S(k*w)+S(j*C))))){break b}F=S(-x);if(S(T(S(S(q*R)+S(W*F))))>S(S(m*z)+S(S(n*y)+S(S(k*E)+S(j*D))))|S(T(S(S(q*O)+S(U*F))))>S(S(o*z)+S(S(n*A)+S(S(k*u)+S(j*B))))|S(T(S(S(v*V)-S(I*q))))>S(S(m*D)+S(S(o*B)+S(S(p*w)+S(j*z))))){break b}q=S(-q);if(S(T(S(S(v*W)+S(K*q))))>S(S(m*C)+S(S(n*B)+S(S(p*E)+S(j*A))))|S(T(S(S(v*U)+S(H*q))))>S(S(o*C)+S(S(n*D)+S(S(p*u)+S(j*y))))|S(T(S(S(x*I)-S(Q*v))))>S(S(m*E)+S(S(o*u)+S(S(p*C)+S(k*z))))){break b}j=S(-v);if(S(T(S(S(x*K)+S(R*j))))>S(S(m*w)+S(S(n*u)+S(S(p*D)+S(k*A))))){break b}h=1;if(!(S(T(S(S(x*H)+S(O*j))))>S(S(o*w)+S(S(n*E)+S(S(p*B)+S(k*y)))))){break a}}h=0}c:{if(!h){break c}h=L[(s+L[b+16>>2]|0)+12>>2];s=L[(r+L[a+16>>2]|0)+12>>2];if((s|0)>=0){if((h|0)>=0){f=L[c+4>>2];d:{if((f|0)!=L[c+8>>2]){break d}e=f?f<<1:1;if((e|0)<=(f|0)){break d}e:{if(!e){d=0;break e}L[8513]=L[8513]+1;d=ha[L[6798]](e<<3,16)|0;f=L[c+4>>2]}b=L[c+12>>2];f:{g:{if((f|0)>0){a=0;if((f|0)!=1){l=f&-2;g=0;while(1){r=a<<3;t=r+d|0;G=b+r|0;L[t>>2]=L[G>>2];L[t+4>>2]=L[G+4>>2];r=r|8;t=r+d|0;r=b+r|0;L[t>>2]=L[r>>2];L[t+4>>2]=L[r+4>>2];a=a+2|0;g=g+2|0;if((l|0)!=(g|0)){continue}break}}if(f&1){a=a<<3;g=a+d|0;a=a+b|0;L[g>>2]=L[a>>2];L[g+4>>2]=L[a+4>>2]}if(M[c+16|0]){break g}break f}if(!b|!M[c+16|0]){break f}}if(b){L[8514]=L[8514]+1;ha[L[6799]](b)}f=L[c+4>>2]}L[c+12>>2]=d;J[c+16|0]=1;L[c+8>>2]=e}a=L[c+12>>2]+(f<<3)|0;L[a+4>>2]=h;L[a>>2]=s;L[c+4>>2]=f+1;break c}g=f+1|0;xb(a,b,c,d,e,g,0);l=a;a=L[(L[b+16>>2]+(g<<4)|0)+12>>2];xb(l,b,c,d,e,(a|0)<0?g-a|0:f+2|0,0);break c}g=e+1|0;if((h|0)>=0){xb(a,b,c,d,g,f,0);l=a;a=L[(L[a+16>>2]+(g<<4)|0)+12>>2];xb(l,b,c,d,(a|0)<0?g-a|0:e+2|0,f,0);break c}h=f+1|0;xb(a,b,c,d,g,h,0);r=h<<4;s=L[(r+L[b+16>>2]|0)+12>>2];f=f+2|0;xb(a,b,c,d,g,(s|0)<0?h-s|0:f,0);s=g<<4;l=L[(s+L[a+16>>2]|0)+12>>2];e=e+2|0;xb(a,b,c,d,(l|0)<0?g-l|0:e,h,0);l=a;a=L[(s+L[a+16>>2]|0)+12>>2];e=(a|0)<0?g-a|0:e;a=L[(r+L[b+16>>2]|0)+12>>2];xb(l,b,c,d,e,(a|0)<0?h-a|0:f,0)}fa=i- -64|0}function Ec(a,b,c,d,e,f){var g=0,h=S(0),i=0,j=S(0),k=S(0),l=S(0),m=S(0),n=S(0),o=S(0),p=S(0),q=S(0),r=0,s=S(0),t=0,u=0,v=S(0),w=0,x=S(0),y=S(0),z=S(0),A=S(0),B=S(0),C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,M=0,N=0;g=fa-272|0;fa=g;i=L[c+12>>2];L[g+216>>2]=L[c+8>>2];L[g+220>>2]=i;i=L[c+4>>2];L[g+208>>2]=L[c>>2];L[g+212>>2]=i;i=L[c+28>>2];L[g+232>>2]=L[c+24>>2];L[g+236>>2]=i;i=L[c+20>>2];L[g+224>>2]=L[c+16>>2];L[g+228>>2]=i;i=L[c+44>>2];L[g+248>>2]=L[c+40>>2];L[g+252>>2]=i;i=L[c+36>>2];L[g+240>>2]=L[c+32>>2];L[g+244>>2]=i;i=L[c+60>>2];L[g+264>>2]=L[c+56>>2];L[g+268>>2]=i;i=L[c+52>>2];L[g+256>>2]=L[c+48>>2];L[g+260>>2]=i;i=L[d+12>>2];L[g+152>>2]=L[d+8>>2];L[g+156>>2]=i;i=L[d+4>>2];L[g+144>>2]=L[d>>2];L[g+148>>2]=i;i=L[d+28>>2];L[g+168>>2]=L[d+24>>2];L[g+172>>2]=i;i=L[d+20>>2];L[g+160>>2]=L[d+16>>2];L[g+164>>2]=i;i=L[d+44>>2];L[g+184>>2]=L[d+40>>2];L[g+188>>2]=i;i=L[d+36>>2];L[g+176>>2]=L[d+32>>2];L[g+180>>2]=i;i=L[d+60>>2];L[g+200>>2]=L[d+56>>2];L[g+204>>2]=i;i=L[d+52>>2];L[g+192>>2]=L[d+48>>2];L[g+196>>2]=i;L[g+108>>2]=0;P[g+104>>2]=P[g+200>>2]-P[g+264>>2];P[g+100>>2]=P[g+196>>2]-P[g+260>>2];P[g+96>>2]=P[g+192>>2]-P[g+256>>2];t=g+208|0;u=g+16|0;i=g+128|0;ec(t,g+144|0,u,i);L[g+92>>2]=0;k=P[g+128>>2];P[g+88>>2]=k*P[g+24>>2];P[g+84>>2]=k*P[g+20>>2];P[g+80>>2]=k*P[g+16>>2];L[g+72>>2]=0;L[g+76>>2]=0;L[g+64>>2]=0;L[g+68>>2]=0;Ma(t,i);L[g+60>>2]=0;L[g+44>>2]=0;h=P[g+140>>2];l=P[g+136>>2];k=P[g+128>>2];j=P[g+132>>2];m=S(S(2)/S(S(h*h)+S(S(l*l)+S(S(k*k)+S(j*j)))));n=S(l*m);o=S(j*n);p=S(k*m);q=S(h*p);P[g+52>>2]=o+q;P[g+40>>2]=o-q;o=S(k*p);v=j;j=S(j*m);m=S(v*j);P[g+56>>2]=S(1)-S(o+m);l=S(l*n);P[g+36>>2]=S(1)-S(o+l);L[g+28>>2]=0;o=S(k*n);p=S(h*j);P[g+48>>2]=o-p;k=S(k*j);h=S(h*n);P[g+32>>2]=k+h;P[g+24>>2]=o+p;P[g+20>>2]=k-h;P[g+16>>2]=S(1)-S(m+l);xm(b,u,g+96|0,g+80|0,i,g+112|0);if(L[a+268>>2]>0){t=d+48|0;u=c+48|0;c=0;while(1){i=L[L[a+276>>2]+(c<<2)>>2];a:{if(!(ha[L[L[e>>2]+8>>2]](e,L[i+188>>2])|0)){break a}w=L[i+192>>2];C=i+4|0;d=g+16|0;r=g+96|0;ha[L[L[w>>2]+8>>2]](w,C,d,r);L[g+28>>2]=0;L[g+108>>2]=0;P[g+24>>2]=P[g+24>>2]+P[g+136>>2];P[g+20>>2]=P[g+20>>2]+P[g+132>>2];P[g+16>>2]=P[g+16>>2]+P[g+128>>2];P[g+96>>2]=P[g+96>>2]+P[g+112>>2];P[g+100>>2]=P[g+100>>2]+P[g+116>>2];P[g+104>>2]=P[g+104>>2]+P[g+120>>2];L[g+12>>2]=1065353216;w=0;h=P[r>>2];j=P[d>>2];l=S(S(h+j)*S(.5));k=S(P[t>>2]-l);h=S(S(h-j)*S(.5));D=k>h;j=P[r+4>>2];m=P[d+4>>2];p=S(S(j+m)*S(.5));n=S(P[t+4>>2]-p);o=S(P[u>>2]-l);E=h>2];m=P[d+8>>2];q=S(S(l+m)*S(.5));s=S(P[t+8>>2]-q);x=S(S(l-m)*S(.5));A=S(-x);d=sx)<<5;I=o>2]-p);J=z>p;K=j>2]-q);M=A>q;N=I|E<<3|J<<1|K<<4|M<<2|(q>x)<<5;b:{if(r&N){break b}B=S(k-o);k=P[g+12>>2];c:{d:{if(I){m=S(0);l=S(S(S(-o)-h)/B);if(!(l>=S(0))){break d}m=S(1);break c}m=S(0);if(!F){break d}h=S(S(S(-o)-h)/B);if(!(h=h)){break h}n=S(0);l=S(1);m=S(0);break g}l=S(0);if(!d){break h}j=S(S(S(-q)-x)/s);if(!(j=h)){break l}n=S(-1);l=S(0);m=S(0);break k}if(!H){break l}j=S(S(S(-z)-p)/v);if(!(j>>0>=32){h=S(S(S(-A)-q)/s);if(!(j<=h)){break n}n=S(0);l=S(-1);m=S(0);break m}if(r>>>0<32){break n}h=S(S(S(-A)-q)/s);if(!(h>2]=h;L[g+92>>2]=0;P[g+88>>2]=l;P[g+84>>2]=n;P[g+80>>2]=m;w=1}if(!w){break a}r=L[i+192>>2];d=fa-32|0;fa=d;L[d+24>>2]=-1;L[d+28>>2]=-1;L[d+20>>2]=C;L[d+16>>2]=i;L[d+12>>2]=r;L[d+8>>2]=0;kh(b,g+208|0,g+144|0,d+8|0,e,f);fa=d+32|0}c=c+1|0;if((c|0)>2]){continue}break}}fa=g+272|0}function SB(a,b){a=a|0;b=b|0;var c=0,d=0,e=S(0),f=0,g=0,h=0,i=S(0),j=0,k=S(0),l=S(0),m=0,n=S(0),o=0,p=S(0),q=S(0),r=S(0),s=0,t=S(0),u=S(0),v=S(0),w=0,x=S(0),y=0,z=S(0),A=S(0),B=S(0),C=0,D=S(0),E=S(0);a:{g=L[a+28>>2];c=g+4|0;f=L[a+32>>2];d=f+4|0;wg(a,c,d,g+264|0,f+264|0);g=L[b+8>>2];L[g>>2]=1065353216;w=L[b+24>>2];j=w<<2;h=j+4|0;L[h+g>>2]=1065353216;m=w<<3;o=m+8|0;L[o+g>>2]=1065353216;n=P[c+20>>2];t=P[c+24>>2];e=P[a+348>>2];k=P[c+36>>2];l=P[a+352>>2];p=P[c+40>>2];i=P[a+356>>2];q=P[c+8>>2];x=P[c>>2];r=P[c+4>>2];u=P[c+16>>2];v=P[c+32>>2];g=L[b+12>>2];L[g+12>>2]=0;L[g>>2]=0;k=S(S(p*i)+S(S(v*e)+S(l*k)));P[g+4>>2]=k;n=S(S(t*i)+S(S(u*e)+S(l*n)));P[g+8>>2]=-n;f=g+j|0;L[f+12>>2]=0;l=S(S(q*i)+S(S(x*e)+S(r*l)));P[f+8>>2]=l;L[f+4>>2]=0;P[f>>2]=-k;f=g+m|0;L[f+8>>2]=0;L[f+12>>2]=0;P[f+4>>2]=-l;P[f>>2]=n;f=L[b+16>>2];L[f>>2]=-1082130432;L[f+h>>2]=-1082130432;L[f+o>>2]=-1082130432;q=P[d+36>>2];x=P[d+40>>2];e=P[a+412>>2];p=P[d+20>>2];i=P[a+416>>2];r=P[d+24>>2];t=P[a+420>>2];u=P[d+8>>2];v=P[d>>2];z=P[d+4>>2];A=P[d+32>>2];B=P[d+16>>2];f=L[b+20>>2];L[f+12>>2]=0;L[f>>2]=0;p=S(S(r*t)+S(S(B*e)+S(i*p)));P[f+8>>2]=p;q=S(S(x*t)+S(S(A*e)+S(i*q)));P[f+4>>2]=-q;h=f+j|0;L[h+12>>2]=0;i=S(S(u*t)+S(S(v*e)+S(z*i)));P[h+8>>2]=-i;L[h+4>>2]=0;P[h>>2]=q;h=f+m|0;L[h+8>>2]=0;L[h+12>>2]=0;P[h+4>>2]=i;P[h>>2]=-p;C=L[a+592>>2];e=S(P[(C&2?a+600|0:b+4|0)>>2]*P[b>>2]);h=L[b+40>>2];o=L[b+36>>2];s=L[b+28>>2];b:{if(!(C&1)){P[s>>2]=e*S(S(S(i+P[d+48>>2])-l)-P[c+48>>2]);L[o>>2]=-8388609;L[h>>2]=2139095039;P[j+s>>2]=e*S(S(S(p+P[d+52>>2])-n)-P[c+52>>2]);L[j+o>>2]=-8388609;L[h+j>>2]=2139095039;P[m+s>>2]=e*S(S(S(q+P[d+56>>2])-k)-P[c+56>>2]);L[m+o>>2]=-8388609;L[h+m>>2]=2139095039;break b}y=L[b+32>>2];P[s>>2]=e*S(S(S(i+P[d+48>>2])-l)-P[c+48>>2]);L[o>>2]=-8388609;L[h>>2]=2139095039;P[y>>2]=P[a+596>>2];P[j+s>>2]=e*S(S(S(p+P[d+52>>2])-n)-P[c+52>>2]);L[j+o>>2]=-8388609;L[h+j>>2]=2139095039;P[j+y>>2]=P[a+596>>2];P[m+s>>2]=e*S(S(S(q+P[d+56>>2])-k)-P[c+56>>2]);L[m+o>>2]=-8388609;L[h+m>>2]=2139095039;P[m+y>>2]=P[a+596>>2]}d=R(w,3);c:{if(!M[a+526|0]){break c}e=P[a+456>>2];if(!(!(e>P[a+444>>2])|!(e>P[a+448>>2]))){e=P[a+340>>2];l=P[a+308>>2];i=P[a+324>>2];k=P[c+8>>2];n=P[c>>2];t=P[c+4>>2];p=P[c+24>>2];q=P[c+16>>2];x=P[c+20>>2];d=d<<2;h=d+8|0;r=P[a+336>>2];B=P[c+40>>2];u=P[a+304>>2];D=P[c+32>>2];v=P[a+320>>2];E=P[c+36>>2];z=S(S(r*B)+S(S(u*D)+S(v*E)));P[h+g>>2]=z;j=d+4|0;A=S(S(r*p)+S(S(u*q)+S(v*x)));P[j+g>>2]=A;r=S(S(r*k)+S(S(u*n)+S(t*v)));P[d+g>>2]=r;c=w<<4;k=S(S(e*k)+S(S(l*n)+S(t*i)));P[c+g>>2]=k;m=c|4;n=S(S(e*p)+S(S(l*q)+S(i*x)));P[m+g>>2]=n;y=c|8;e=S(S(e*B)+S(S(l*D)+S(i*E)));P[y+g>>2]=e;P[f+h>>2]=-z;P[f+j>>2]=-A;P[d+f>>2]=-r;P[c+f>>2]=-k;P[f+m>>2]=-n;P[f+y>>2]=-e;l=S(P[b>>2]*P[a+436>>2]);P[d+s>>2]=l*S(S(P[a+468>>2]*z)+S(S(P[a+460>>2]*r)+S(A*P[a+464>>2])));P[c+s>>2]=l*S(S(P[a+468>>2]*e)+S(S(P[a+460>>2]*k)+S(n*P[a+464>>2])));L[d+o>>2]=-8388609;h=L[b+40>>2];L[d+h>>2]=2139095039;L[c+o>>2]=-8388609;L[c+h>>2]=2139095039;d=R(w,5);break c}l=P[a+464>>2];i=P[a+468>>2];d=d<<2;e=P[a+436>>2];k=S(e*S(e*P[a+460>>2]));P[d+g>>2]=k;c=d+8|0;i=S(e*S(e*i));P[c+g>>2]=i;j=d+4|0;e=S(e*S(e*l));P[j+g>>2]=e;P[c+f>>2]=-i;P[f+j>>2]=-e;P[d+f>>2]=-k;P[d+s>>2]=S(P[b>>2]*P[a+432>>2])*P[a+504>>2];if(C&4){P[d+L[b+32>>2]>>2]=P[a+604>>2]}L[d+o>>2]=0;L[d+h>>2]=2139095039;d=w<<2}if(M[a+525|0]){l=P[a+480>>2];i=P[a+484>>2];c=d<<2;e=P[a+436>>2];k=S(e*S(e*P[a+476>>2]));P[c+g>>2]=k;j=c+8|0;i=S(e*S(e*i));P[j+g>>2]=i;m=g;g=c+4|0;e=S(e*S(e*l));P[m+g>>2]=e;P[f+j>>2]=-i;P[f+g>>2]=-e;P[c+f>>2]=-k;P[c+L[b+28>>2]>>2]=S(P[b>>2]*P[a+432>>2])*P[a+508>>2];if(C&4){P[c+L[b+32>>2]>>2]=P[a+604>>2]}if(P[a+452>>2]>S(0)){c=d<<2;d=c+h|0;b=c+L[b+36>>2]|0;if(P[a+508>>2]>S(0)){L[b>>2]=0;L[d>>2]=2139095039;break a}L[b>>2]=-8388609;L[d>>2]=0;break a}a=d<<2;L[a+L[b+36>>2]>>2]=-8388609;L[a+h>>2]=2139095039}}}function Te(a,b,c){a=a|0;b=b|0;c=c|0;var d=S(0),e=0,f=S(0),g=S(0),h=0,i=S(0),j=S(0),k=0,l=S(0),m=0,n=S(0),o=S(0),p=0,q=S(0),r=S(0),s=0,t=S(0),u=0,v=0,w=S(0),x=S(0),y=S(0),z=S(0),A=S(0),B=S(0),C=S(0);e=fa-48|0;fa=e;a:{b:{switch(L[b+4>>2]){case 8:L[a>>2]=0;L[a+4>>2]=0;L[a+8>>2]=0;L[a+12>>2]=0;break a;case 0:d=P[b+32>>2];f=P[b+36>>2];i=P[c+4>>2];j=P[c+8>>2];g=P[b+28>>2];o=P[c>>2];L[a+12>>2]=0;P[a>>2]=o>=S(0)?g:S(-g);P[a+8>>2]=j>=S(0)?f:S(-f);P[a+4>>2]=i>=S(0)?d:S(-d);break a;case 1:d=P[c+8>>2];f=P[c>>2];g=P[c+4>>2];i=S(S(d*P[b- -64>>2])+S(S(f*P[b+56>>2])+S(g*P[b+60>>2])));j=S(S(d*P[b+80>>2])+S(S(f*P[b+72>>2])+S(g*P[b+76>>2])));c=i>2])+S(S(f*P[b+88>>2])+S(g*P[b+92>>2])))>(c?j:i)?2:c)<<4)|0;c=L[b>>2];m=L[b+4>>2];d=P[b+8>>2];L[a+12>>2]=0;P[a+8>>2]=d;L[a>>2]=c;L[a+4>>2]=m;break a;case 13:h=L[b+40>>2];L[e+40>>2]=L[b+36>>2];L[e+44>>2]=h;h=L[b+32>>2];L[e+32>>2]=L[b+28>>2];L[e+36>>2]=h;P[e+16>>2]=P[c>>2];P[e+20>>2]=P[c+4>>2];d=P[c+8>>2];L[e+28>>2]=0;P[e+24>>2]=d;c=1;h=2;c:{d:{e:{b=L[b+52>>2];switch(b-1|0){case 0:break d;case 1:break e;default:break c}}h=1}c=0;m=b}k=b<<2;b=e+32|0;d=P[k+b>>2];k=b;b=c<<2;f=P[(k|b)>>2];k=b;b=e+16|0;g=P[k+b>>2];i=P[b+(h<<2)>>2];j=S(_(S(S(g*g)+S(i*i))));f:{if(j!=S(0)){f=S(f/j);P[(c<<2)+e>>2]=g*f;b=m<<2;P[b+e>>2]=P[b+(e+16|0)>>2]>2]=f;b=m<<2;P[b+e>>2]=P[b+(e+16|0)>>2]>2]=r;b=L[e+4>>2];c=L[e>>2];d=P[e+8>>2];L[a+12>>2]=0;P[a+8>>2]=d;L[a>>2]=c;L[a+4>>2]=b;break a;case 10:h=b+28|0;m=L[b+52>>2];k=m<<2;w=P[h+k>>2];o=P[h+((m+2|0)%3<<2)>>2];n=S(1);d=P[c+8>>2];f=P[c>>2];g=P[c+4>>2];i=S(S(d*d)+S(S(f*f)+S(g*g)));if(!(i>2]=0;L[e+44>>2]=0;L[e+32>>2]=0;L[e+36>>2]=0;P[k+(e+32|0)>>2]=w;d=S(-0xde0b6b000000000);f=S(0);g=S(0);x=S(o*t);l=P[b+44>>2];y=S(t*l);i=S(S(x+P[e+40>>2])-y);z=S(o*n);A=S(n*l);j=S(S(z+P[e+32>>2])-A);B=S(o*r);C=S(r*l);o=S(S(B+P[e+36>>2])-C);l=S(S(t*i)+S(S(n*j)+S(r*o)));if(l>S(-0xde0b6b000000000)){f=o;g=i;q=j;d=l}L[e+40>>2]=0;L[e+44>>2]=0;L[e+32>>2]=0;L[e+36>>2]=0;P[(e+32|0)+(m<<2)>>2]=-w;i=P[e+40>>2];j=P[e+32>>2];o=P[e+36>>2];L[a+12>>2]=0;l=d;d=S(S(x+i)-y);i=S(S(z+j)-A);j=S(S(B+o)-C);b=l>2]=b?d:g;P[a+4>>2]=b?j:f;P[a>>2]=b?i:q;break a;case 5:i=P[b+12>>2];j=P[b+20>>2];o=P[b+16>>2];m=L[b+92>>2];b=L[b+96>>2];g:{if((b|0)<=0){h=-1;break g}d=S(P[c>>2]*i);f=S(P[c+8>>2]*j);g=S(P[c+4>>2]*o);u=b&1;h:{if((b|0)==1){b=0;h=-1;n=S(-34028234663852886e22);break h}v=b&-2;b=0;h=-1;n=S(-34028234663852886e22);c=0;while(1){k=m+(b<<4)|0;l=S(S(P[k+8>>2]*f)+S(S(P[k>>2]*d)+S(g*P[k+4>>2])));k=l>n;s=b|1;p=m+(s<<4)|0;q=S(S(P[p+8>>2]*f)+S(S(P[p>>2]*d)+S(g*P[p+4>>2])));l=k?l:n;p=q>l;n=p?q:l;h=p?s:k?b:h;b=b+2|0;c=c+2|0;if((v|0)!=(c|0)){continue}break}}if(!u){break g}c=b;b=m+(b<<4)|0;h=S(S(P[b+8>>2]*f)+S(S(P[b>>2]*d)+S(g*P[b+4>>2])))>n?c:h}b=m+(h<<4)|0;d=P[b>>2];f=P[b+4>>2];g=P[b+8>>2];L[a+12>>2]=0;P[a+8>>2]=j*g;P[a+4>>2]=o*f;P[a>>2]=i*d;break a;case 4:i=P[b+12>>2];j=P[b+20>>2];o=P[b+16>>2];m=L[b+104>>2];b=L[b+96>>2];i:{if((b|0)<=0){h=-1;break i}d=S(P[c>>2]*i);f=S(P[c+8>>2]*j);g=S(P[c+4>>2]*o);u=b&1;j:{if((b|0)==1){b=0;h=-1;n=S(-34028234663852886e22);break j}v=b&-2;b=0;h=-1;n=S(-34028234663852886e22);c=0;while(1){k=m+(b<<4)|0;l=S(S(P[k+8>>2]*f)+S(S(P[k>>2]*d)+S(g*P[k+4>>2])));k=l>n;s=b|1;p=m+(s<<4)|0;q=S(S(P[p+8>>2]*f)+S(S(P[p>>2]*d)+S(g*P[p+4>>2])));l=k?l:n;p=q>l;n=p?q:l;h=p?s:k?b:h;b=b+2|0;c=c+2|0;if((v|0)!=(c|0)){continue}break}}if(!u){break i}c=b;b=m+(b<<4)|0;h=S(S(P[b+8>>2]*f)+S(S(P[b>>2]*d)+S(g*P[b+4>>2])))>n?c:h}b=m+(h<<4)|0;d=P[b>>2];f=P[b+4>>2];g=P[b+8>>2];L[a+12>>2]=0;P[a+8>>2]=j*g;P[a+4>>2]=o*f;P[a>>2]=i*d;break a;default:break b}}ha[L[L[b>>2]+68>>2]](a,b,c)}fa=e+48|0}function Pe(a,b,c){var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=S(0),l=0,m=0,n=S(0),o=S(0),p=S(0),q=S(0),r=S(0),s=S(0);a:{b:{if(M[a+165|0]){d=L[a+88>>2];if(!(!c|(d|0)<=0)){e=L[a+96>>2];n=P[a+168>>2];o=P[b+8>>2];p=P[b+4>>2];q=P[b>>2];c=0;while(1){f=e+(c<<4)|0;k=S(P[f+8>>2]-o);r=S(k*k);k=S(P[f>>2]-q);s=S(k*k);k=S(P[f+4>>2]-p);if(n>=S(r+S(s+S(k*k)))){break b}c=c+1|0;if((d|0)!=(c|0)){continue}break}}c=L[a+32>>2];L[c+12>>2]=L[c+12>>2]+1;c:{if(L[a+92>>2]!=(d|0)){break c}h=d?d<<1:1;if((h|0)<=(d|0)){break c}if(h){L[8513]=L[8513]+1;g=ha[L[6798]](h<<4,16)|0;d=L[a+88>>2]}d:{if((d|0)<=0){break d}i=d&1;c=0;if((d|0)!=1){l=d&-2;d=0;while(1){j=c<<4;f=j+g|0;m=j+L[a+96>>2]|0;e=L[m+4>>2];L[f>>2]=L[m>>2];L[f+4>>2]=e;e=L[m+12>>2];L[f+8>>2]=L[m+8>>2];L[f+12>>2]=e;e=j|16;f=e+g|0;j=e+L[a+96>>2]|0;e=L[j+4>>2];L[f>>2]=L[j>>2];L[f+4>>2]=e;e=L[j+12>>2];L[f+8>>2]=L[j+8>>2];L[f+12>>2]=e;c=c+2|0;d=d+2|0;if((l|0)!=(d|0)){continue}break}}if(!i){break d}c=c<<4;f=c+g|0;e=c+L[a+96>>2]|0;c=L[e+4>>2];L[f>>2]=L[e>>2];L[f+4>>2]=c;c=L[e+12>>2];L[f+8>>2]=L[e+8>>2];L[f+12>>2]=c}c=L[a+96>>2];if(!(c?!c|!M[a+100|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](c)}L[a+96>>2]=g;J[a+100|0]=1;L[a+92>>2]=h;d=L[a+88>>2]}c=L[b+4>>2];e=L[a+96>>2]+(d<<4)|0;L[e>>2]=L[b>>2];L[e+4>>2]=c;c=L[b+12>>2];L[e+8>>2]=L[b+8>>2];L[e+12>>2]=c;b=L[a+88>>2];L[a+88>>2]=b+1;L[L[a+32>>2]+16>>2]=L[a+96>>2];return b}d=L[a+108>>2];if(!(!c|(d|0)<=0)){e=L[a+116>>2];n=P[a+168>>2];o=P[b+8>>2];p=P[b+4>>2];q=P[b>>2];c=0;while(1){f=e+(c<<2)|0;k=S(P[f+8>>2]-o);r=S(k*k);k=S(P[f>>2]-q);s=S(k*k);k=S(P[f+4>>2]-p);if(n>=S(r+S(s+S(k*k)))){break a}c=c+3|0;if((d|0)>(c|0)){continue}break}}e=L[a+112>>2];e:{if((e|0)!=(d|0)){break e}e=d?d<<1:1;if((e|0)<=(d|0)){e=d;break e}if(e){L[8513]=L[8513]+1;h=ha[L[6798]](e<<2,16)|0;d=L[a+108>>2]}i=L[a+116>>2];f:{g:{if((d|0)>0){c=0;if(d>>>0>=4){g=d&-4;while(1){l=c<<2;P[l+h>>2]=P[i+l>>2];f=l|4;P[f+h>>2]=P[f+i>>2];f=l|8;P[f+h>>2]=P[f+i>>2];f=l|12;P[f+h>>2]=P[f+i>>2];c=c+4|0;j=j+4|0;if((g|0)!=(j|0)){continue}break}}g=d&3;if(g){while(1){f=c<<2;P[f+h>>2]=P[f+i>>2];c=c+1|0;m=m+1|0;if((g|0)!=(m|0)){continue}break}}if(M[a+120|0]){break g}break f}if(!i|!M[a+120|0]){break f}}if(i){L[8514]=L[8514]+1;ha[L[6799]](i)}d=L[a+108>>2]}L[a+116>>2]=h;L[a+112>>2]=e;J[a+120|0]=1}g=L[a+116>>2];P[g+(d<<2)>>2]=P[b>>2];d=d+1|0;L[a+108>>2]=d;h:{if((d|0)!=(e|0)){f=e;c=g;e=d;break h}f=e?e<<1:1;if((e|0)>=(f|0)){f=e;c=g;break h}i:{if(!f){c=0;break i}L[8513]=L[8513]+1;c=ha[L[6798]](f<<2,16)|0;g=L[a+116>>2];e=L[a+108>>2]}j:{k:{if((e|0)>0){m=0;h=0;if(e>>>0>=4){l=e&-4;j=0;while(1){i=h<<2;P[i+c>>2]=P[g+i>>2];d=i|4;P[d+c>>2]=P[d+g>>2];d=i|8;P[d+c>>2]=P[d+g>>2];d=i|12;P[d+c>>2]=P[d+g>>2];h=h+4|0;j=j+4|0;if((l|0)!=(j|0)){continue}break}}l=e&3;if(l){while(1){d=h<<2;P[d+c>>2]=P[d+g>>2];h=h+1|0;m=m+1|0;if((l|0)!=(m|0)){continue}break}}if(M[a+120|0]){break k}break j}if(!g|!M[a+120|0]){break j}}if(g){L[8514]=L[8514]+1;ha[L[6799]](g)}e=L[a+108>>2]}L[a+116>>2]=c;L[a+112>>2]=f;J[a+120|0]=1}P[(e<<2)+c>>2]=P[b+4>>2];e=e+1|0;L[a+108>>2]=e;l:{if((e|0)!=(f|0)){d=c;f=e;break l}i=f?f<<1:1;if((i|0)<=(f|0)){d=c;break l}m:{if(!i){d=0;break m}L[8513]=L[8513]+1;d=ha[L[6798]](i<<2,16)|0;c=L[a+116>>2];f=L[a+108>>2]}n:{o:{if((f|0)>0){e=0;h=0;if(f>>>0>=4){l=f&-4;m=0;while(1){j=h<<2;P[j+d>>2]=P[c+j>>2];g=j|4;P[g+d>>2]=P[c+g>>2];g=j|8;P[g+d>>2]=P[c+g>>2];g=j|12;P[g+d>>2]=P[c+g>>2];h=h+4|0;m=m+4|0;if((l|0)!=(m|0)){continue}break}}l=f&3;if(l){while(1){g=h<<2;P[g+d>>2]=P[c+g>>2];h=h+1|0;e=e+1|0;if((l|0)!=(e|0)){continue}break}}if(M[a+120|0]){break o}break n}if(!c|!M[a+120|0]){break n}}if(c){L[8514]=L[8514]+1;ha[L[6799]](c)}f=L[a+108>>2]}L[a+116>>2]=d;L[a+112>>2]=i;J[a+120|0]=1}P[(f<<2)+d>>2]=P[b+8>>2];b=f+1|0;L[a+108>>2]=b;a=L[a+32>>2];L[a+16>>2]=d;L[a+12>>2]=L[a+12>>2]+1;c=((b|0)/3|0)-1|0}return c}return(c>>>0)/3|0}function oD(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0,g=0,h=0,i=S(0),j=S(0),k=S(0),l=S(0),m=S(0),n=S(0),o=0,p=0,q=0,r=0,s=0;c=fa-80|0;fa=c;s=ha[L[L[a>>2]+28>>2]](a)|0;if((s|0)>0){i=P[a+12>>2];j=P[a+8>>2];k=P[a+4>>2];while(1){ha[L[L[a>>2]+16>>2]](a,c+76|0,c+52|0,c- -64|0,c+56|0,c+72|0,c+68|0,c+48|0,c+60|0,r);a:{b:{switch(L[c+64>>2]){case 0:c:{switch(L[c+60>>2]-2|0){case 0:d=0;if(L[c+48>>2]<=0){break a}while(1){g=L[c+76>>2];h=L[c+56>>2];e=L[c+72>>2]+R(L[c+68>>2],d)|0;f=g+R(h,L[e>>2])|0;l=P[f>>2];m=P[f+4>>2];n=P[f+8>>2];L[c+12>>2]=0;P[c+8>>2]=i*n;P[c+4>>2]=j*m;P[c>>2]=k*l;f=g+R(h,L[e+4>>2])|0;l=P[f>>2];m=P[f+4>>2];n=P[f+8>>2];L[c+28>>2]=0;P[c+24>>2]=i*n;P[c+20>>2]=j*m;P[c+16>>2]=k*l;e=g+R(h,L[e+8>>2])|0;l=P[e>>2];m=P[e+4>>2];n=P[e+8>>2];L[c+44>>2]=0;P[c+40>>2]=i*n;P[c+36>>2]=j*m;P[c+32>>2]=k*l;ha[L[L[b>>2]+8>>2]](b,c,r,d);d=d+1|0;if((d|0)>2]){continue}break};break a;case 1:d=0;if(L[c+48>>2]<=0){break a}while(1){g=L[c+76>>2];h=L[c+56>>2];e=L[c+72>>2]+R(L[c+68>>2],d)|0;f=g+R(h,N[e>>1])|0;l=P[f>>2];m=P[f+4>>2];n=P[f+8>>2];L[c+12>>2]=0;P[c+8>>2]=i*n;P[c+4>>2]=j*m;P[c>>2]=k*l;f=g+R(h,N[e+2>>1])|0;l=P[f>>2];m=P[f+4>>2];n=P[f+8>>2];L[c+28>>2]=0;P[c+24>>2]=i*n;P[c+20>>2]=j*m;P[c+16>>2]=k*l;e=g+R(h,N[e+4>>1])|0;l=P[e>>2];m=P[e+4>>2];n=P[e+8>>2];L[c+44>>2]=0;P[c+40>>2]=i*n;P[c+36>>2]=j*m;P[c+32>>2]=k*l;ha[L[L[b>>2]+8>>2]](b,c,r,d);d=d+1|0;if((d|0)>2]){continue}break};break a;case 3:break c;default:break a}}d=0;if(L[c+48>>2]<=0){break a}while(1){g=L[c+76>>2];h=L[c+56>>2];e=L[c+72>>2]+R(L[c+68>>2],d)|0;f=g+R(h,M[e|0])|0;l=P[f>>2];m=P[f+4>>2];n=P[f+8>>2];L[c+12>>2]=0;P[c+8>>2]=i*n;P[c+4>>2]=j*m;P[c>>2]=k*l;f=g+R(h,M[e+1|0])|0;l=P[f>>2];m=P[f+4>>2];n=P[f+8>>2];L[c+28>>2]=0;P[c+24>>2]=i*n;P[c+20>>2]=j*m;P[c+16>>2]=k*l;e=g+R(h,M[e+2|0])|0;l=P[e>>2];m=P[e+4>>2];n=P[e+8>>2];L[c+44>>2]=0;P[c+40>>2]=i*n;P[c+36>>2]=j*m;P[c+32>>2]=k*l;ha[L[L[b>>2]+8>>2]](b,c,r,d);d=d+1|0;if((d|0)>2]){continue}break};break a;case 1:break b;default:break a}}d:{switch(L[c+60>>2]-2|0){case 0:d=0;if(L[c+48>>2]<=0){break a}while(1){g=L[c+76>>2];h=L[c+56>>2];e=L[c+72>>2]+R(L[c+68>>2],d)|0;f=g+R(h,L[e>>2])|0;o=Q[f>>3];p=Q[f+8>>3];q=Q[f+16>>3];L[c+12>>2]=0;P[c+8>>2]=i*S(q);P[c+4>>2]=j*S(p);P[c>>2]=k*S(o);f=g+R(h,L[e+4>>2])|0;o=Q[f>>3];p=Q[f+8>>3];q=Q[f+16>>3];L[c+28>>2]=0;P[c+24>>2]=i*S(q);P[c+20>>2]=j*S(p);P[c+16>>2]=k*S(o);e=g+R(h,L[e+8>>2])|0;o=Q[e>>3];p=Q[e+8>>3];q=Q[e+16>>3];L[c+44>>2]=0;P[c+40>>2]=i*S(q);P[c+36>>2]=j*S(p);P[c+32>>2]=k*S(o);ha[L[L[b>>2]+8>>2]](b,c,r,d);d=d+1|0;if((d|0)>2]){continue}break};break a;case 1:d=0;if(L[c+48>>2]<=0){break a}while(1){g=L[c+76>>2];h=L[c+56>>2];e=L[c+72>>2]+R(L[c+68>>2],d)|0;f=g+R(h,N[e>>1])|0;o=Q[f>>3];p=Q[f+8>>3];q=Q[f+16>>3];L[c+12>>2]=0;P[c+8>>2]=i*S(q);P[c+4>>2]=j*S(p);P[c>>2]=k*S(o);f=g+R(h,N[e+2>>1])|0;o=Q[f>>3];p=Q[f+8>>3];q=Q[f+16>>3];L[c+28>>2]=0;P[c+24>>2]=i*S(q);P[c+20>>2]=j*S(p);P[c+16>>2]=k*S(o);e=g+R(h,N[e+4>>1])|0;o=Q[e>>3];p=Q[e+8>>3];q=Q[e+16>>3];L[c+44>>2]=0;P[c+40>>2]=i*S(q);P[c+36>>2]=j*S(p);P[c+32>>2]=k*S(o);ha[L[L[b>>2]+8>>2]](b,c,r,d);d=d+1|0;if((d|0)>2]){continue}break};break a;case 3:break d;default:break a}}d=0;if(L[c+48>>2]<=0){break a}while(1){g=L[c+76>>2];h=L[c+56>>2];e=L[c+72>>2]+R(L[c+68>>2],d)|0;f=g+R(h,M[e|0])|0;o=Q[f>>3];p=Q[f+8>>3];q=Q[f+16>>3];L[c+12>>2]=0;P[c+8>>2]=i*S(q);P[c+4>>2]=j*S(p);P[c>>2]=k*S(o);f=g+R(h,M[e+1|0])|0;o=Q[f>>3];p=Q[f+8>>3];q=Q[f+16>>3];L[c+28>>2]=0;P[c+24>>2]=i*S(q);P[c+20>>2]=j*S(p);P[c+16>>2]=k*S(o);e=g+R(h,M[e+2|0])|0;o=Q[e>>3];p=Q[e+8>>3];q=Q[e+16>>3];L[c+44>>2]=0;P[c+40>>2]=i*S(q);P[c+36>>2]=j*S(p);P[c+32>>2]=k*S(o);ha[L[L[b>>2]+8>>2]](b,c,r,d);d=d+1|0;if((d|0)>2]){continue}break}}ha[L[L[a>>2]+24>>2]](a,r);r=r+1|0;if((s|0)!=(r|0)){continue}break}}fa=c+80|0}function Uo(a,b,c,d,e,f,g,h,i,j,k,l){a=a|0;b=b|0;c=c|0;d=d|0;e=S(e);f=S(f);g=S(g);h=S(h);i=S(i);j=j|0;k=S(k);l=l|0;var m=0;m=fa-2704|0;fa=m;L[m+2700>>2]=a;L[m+2696>>2]=b;L[m+2692>>2]=c;L[m+2688>>2]=d;P[m+2684>>2]=e;P[m+2680>>2]=f;P[m+2676>>2]=g;P[m+2672>>2]=h;P[m+2668>>2]=i;L[m+2664>>2]=j;P[m+2660>>2]=k;J[m+2659|0]=l;b=L[m+2700>>2];a=m+1472|0;c=a+1184|0;while(1){L[(fa-16|0)+12>>2]=a;a=a+16|0;if((c|0)!=(a|0)){continue}break}a=m+288|0;c=a+1184|0;while(1){L[(fa-16|0)+12>>2]=a;a=a+16|0;if((c|0)!=(a|0)){continue}break}L[m+284>>2]=m+1472;L[m+280>>2]=m+288;a=L[m+2696>>2];c=m+244|0;d=m+2684|0;Ga(c,L[m+2692>>2],d);ta(m+260|0,a,c);a=L[m+2696>>2];c=m+212|0;Ga(c,L[m+2692>>2],d);La(m+228|0,a,c);L[(fa-16|0)+12>>2]=m+192;P[m+188>>2]=P[m+2660>>2]*S(.01745329238474369);L[m+184>>2]=L[m+2692>>2];L[m+180>>2]=L[m+2688>>2];Ub(m+164|0,L[m+184>>2],L[m+180>>2]);J[m+163|0]=0;J[m+162|0]=0;if(P[m+2680>>2]<=S(-1.5707963705062866)){P[m+2680>>2]=P[m+188>>2]+S(-1.5707963705062866);J[m+163|0]=1}if(P[m+2676>>2]>=S(1.5707963705062866)){P[m+2676>>2]=S(1.5707963705062866)-P[m+188>>2];J[m+162|0]=1}if(P[m+2680>>2]>P[m+2676>>2]){P[m+2680>>2]=P[m+188>>2]+S(-1.5707963705062866);P[m+2676>>2]=S(1.5707963705062866)-P[m+188>>2];J[m+162|0]=1;J[m+163|0]=1}e=S(S(P[m+2676>>2]-P[m+2680>>2])/P[m+188>>2]);a:{if(S(T(e))>2]=a+1;if(L[m+156>>2]<2){L[m+156>>2]=2}P[m+152>>2]=S(P[m+2676>>2]-P[m+2680>>2])/S(L[m+156>>2]-1|0);J[m+151|0]=0;b:{if(P[m+2672>>2]>P[m+2668>>2]){P[m+2672>>2]=P[m+188>>2]+S(-3.1415927410125732);P[m+2668>>2]=3.1415927410125732;J[m+151|0]=1;break b}c:{if(S(P[m+2668>>2]-P[m+2672>>2])>=S(6.2831854820251465)){J[m+151|0]=1;break c}J[m+151|0]=0}}e=S(S(P[m+2668>>2]-P[m+2672>>2])/P[m+188>>2]);d:{if(S(T(e))>2]=a+1;if(L[m+144>>2]<2){L[m+144>>2]=2}P[m+140>>2]=S(P[m+2668>>2]-P[m+2672>>2])/S(L[m+144>>2]-1|0);L[m+136>>2]=0;while(1){if(L[m+136>>2]>2]){P[m+132>>2]=S(S(L[m+136>>2])*P[m+152>>2])+P[m+2680>>2];P[m+128>>2]=P[m+2684>>2]*Qa(P[m+132>>2]);P[m+124>>2]=P[m+2684>>2]*Ra(P[m+132>>2]);L[m+120>>2]=0;while(1){if(L[m+120>>2]>2]){P[m+116>>2]=S(S(L[m+120>>2])*P[m+140>>2])+P[m+2672>>2];P[m+112>>2]=Qa(P[m+116>>2]);P[m+108>>2]=Ra(P[m+116>>2]);a=L[m+2696>>2];P[m+40>>2]=P[m+124>>2]*P[m+108>>2];c=m+44|0;Xb(c,m+40|0,L[m+180>>2]);d=m+60|0;ta(d,a,c);P[m+20>>2]=P[m+124>>2]*P[m+112>>2];a=m+24|0;Xb(a,m+20|0,m+164|0);c=m+76|0;ta(c,d,a);a=m+4|0;Xb(a,m+128|0,L[m+184>>2]);ta(m+92|0,c,a);c=L[m+96>>2];a=L[m+280>>2]+(L[m+120>>2]<<4)|0;L[a>>2]=L[m+92>>2];L[a+4>>2]=c;c=L[m+104>>2];L[a+8>>2]=L[m+100>>2];L[a+12>>2]=c;e:{if(L[m+136>>2]){a=L[m+120>>2]<<4;ha[L[L[b>>2]+8>>2]](b,a+L[m+284>>2]|0,a+L[m+280>>2]|0,L[m+2664>>2]);break e}if(J[m+162|0]&1){ha[L[L[b>>2]+8>>2]](b,m+228|0,L[m+280>>2]+(L[m+120>>2]<<4)|0,L[m+2664>>2])}}f:{if(L[m+120>>2]){c=L[m+280>>2];a=L[m+120>>2];ha[L[L[b>>2]+8>>2]](b,c+(a-1<<4)|0,c+(a<<4)|0,L[m+2664>>2]);break f}a=L[m+280>>2]+(L[m+120>>2]<<4)|0;c=L[a+12>>2];L[m+200>>2]=L[a+8>>2];L[m+204>>2]=c;c=L[a+4>>2];L[m+192>>2]=L[a>>2];L[m+196>>2]=c}if(!(!(J[m+163|0]&1)|L[m+136>>2]!=(L[m+156>>2]-1|0))){ha[L[L[b>>2]+8>>2]](b,m+260|0,L[m+280>>2]+(L[m+120>>2]<<4)|0,L[m+2664>>2])}if(J[m+2659|0]&1){g:{if(J[m+151|0]&1){if(L[m+120>>2]==(L[m+144>>2]-1|0)){ha[L[L[b>>2]+8>>2]](b,m+192|0,L[m+280>>2]+(L[m+120>>2]<<4)|0,L[m+2664>>2])}break g}if(!((L[m+136>>2]!=(L[m+156>>2]-1|0)?L[m+136>>2]:0)|(L[m+120>>2]!=(L[m+144>>2]-1|0)?L[m+120>>2]:0))){ha[L[L[b>>2]+8>>2]](b,L[m+2696>>2],L[m+280>>2]+(L[m+120>>2]<<4)|0,L[m+2664>>2])}}}L[m+120>>2]=L[m+120>>2]+1;continue}break}L[m+276>>2]=L[m+284>>2];L[m+284>>2]=L[m+280>>2];L[m+280>>2]=L[m+276>>2];L[m+136>>2]=L[m+136>>2]+1;continue}break}fa=m+2704|0}function jh(a,b){var c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0;d=fa-96|0;fa=d;l=L[a+8>>2];if((l|0)>0){while(1){e=L[L[a+16>>2]+(c<<2)>>2];if(L[e+236>>2]==1){ha[L[L[e>>2]+24>>2]](e,b);l=L[a+8>>2]}c=c+1|0;if((l|0)>(c|0)){continue}break}}J[d+52|0]=1;L[d+48>>2]=0;J[d+72|0]=1;L[d+40>>2]=0;L[d+44>>2]=0;L[d+68>>2]=0;J[d+92|0]=1;L[d+60>>2]=0;L[d+64>>2]=0;L[d+88>>2]=0;L[d+80>>2]=0;L[d+84>>2]=0;L[d+28>>2]=0;J[d+32|0]=1;L[d+20>>2]=0;L[d+24>>2]=0;a:{if((l|0)<=0){break a}while(1){e=L[L[L[a+16>>2]+(r<<2)>>2]+192>>2];L[d+12>>2]=e;c=e+(e<<15^-1)|0;c=R(c>>10^c,9);c=c>>6^c;c=(c<<11^-1)+c|0;c=L[d+64>>2]-1&(c>>16^c);b:{c:{if(c>>>0>=O[d+20>>2]){break c}c=L[L[d+28>>2]+(c<<2)>>2];if((c|0)==-1){break c}f=L[d+48>>2];h=L[d+88>>2];while(1){if((e|0)!=L[h+(c<<3)>>2]){c=L[f+(c<<2)>>2];if((c|0)!=-1){continue}break c}break}if(L[d+68>>2]){break b}}L[d+4>>2]=e;j=0;d:{e:{e=d+16|0;l=L[e+48>>2];c=L[d+4>>2];f=(c<<15^-1)+c|0;f=R(f>>10^f,9);f=f>>6^f;f=(f<<11^-1)+f|0;q=l-1&(f>>16^f);f:{if(q>>>0>=O[e+4>>2]){break f}f=L[L[e+12>>2]+(q<<2)>>2];if((f|0)==-1){break f}h=L[e+32>>2];n=L[e+72>>2];while(1){if((c|0)==L[n+(f<<3)>>2]){break e}f=L[h+(f<<2)>>2];if((f|0)!=-1){continue}break}}s=L[e+44>>2];c=s;g:{if((l|0)!=(c|0)){break g}c=l;i=c?c<<1:1;if((c|0)>=(i|0)){break g}h:{if(!i){h=0;c=l;break h}L[8513]=L[8513]+1;h=ha[L[6798]](i<<2,16)|0;c=L[e+44>>2]}i:{if((c|0)<=0){break i}n=0;f=0;if(c>>>0>=4){o=c&-4;while(1){k=f<<2;L[k+h>>2]=L[k+L[e+52>>2]>>2];g=k|4;L[g+h>>2]=L[g+L[e+52>>2]>>2];g=k|8;L[g+h>>2]=L[g+L[e+52>>2]>>2];k=k|12;L[k+h>>2]=L[k+L[e+52>>2]>>2];f=f+4|0;j=j+4|0;if((o|0)!=(j|0)){continue}break}}j=c&3;if(!j){break i}while(1){k=f<<2;L[k+h>>2]=L[k+L[e+52>>2]>>2];f=f+1|0;n=n+1|0;if((j|0)!=(n|0)){continue}break}}f=L[e+52>>2];if(!(!f|!M[e+56|0])){if(f){L[8514]=L[8514]+1;ha[L[6799]](f)}c=L[e+44>>2]}L[e+52>>2]=h;J[e+56|0]=1;L[e+48>>2]=i}L[L[e+52>>2]+(c<<2)>>2]=L[d+12>>2];L[e+44>>2]=c+1;c=L[e- -64>>2];j:{if((c|0)!=L[e+68>>2]){break j}k=c?c<<1:1;if((k|0)<=(c|0)){break j}k:{if(!k){h=0;break k}L[8513]=L[8513]+1;h=ha[L[6798]](k<<3,16)|0;c=L[e+64>>2]}l:{if((c|0)<=0){break l}n=0;f=0;if(c>>>0>=4){o=c&-4;j=0;while(1){i=f<<3;g=i+h|0;m=i+L[e+72>>2]|0;p=L[m+4>>2];L[g>>2]=L[m>>2];L[g+4>>2]=p;g=i|8;m=g+h|0;g=g+L[e+72>>2]|0;p=L[g+4>>2];L[m>>2]=L[g>>2];L[m+4>>2]=p;g=i|16;m=g+h|0;g=g+L[e+72>>2]|0;p=L[g+4>>2];L[m>>2]=L[g>>2];L[m+4>>2]=p;i=i|24;g=i+h|0;i=i+L[e+72>>2]|0;m=L[i+4>>2];L[g>>2]=L[i>>2];L[g+4>>2]=m;f=f+4|0;j=j+4|0;if((o|0)!=(j|0)){continue}break}}c=c&3;if(!c){break l}while(1){j=f<<3;i=j+h|0;j=j+L[e+72>>2]|0;o=L[j+4>>2];L[i>>2]=L[j>>2];L[i+4>>2]=o;f=f+1|0;n=n+1|0;if((c|0)!=(n|0)){continue}break}}c=L[e+72>>2];if(!(c?!c|!M[e+76|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](c)}L[e+72>>2]=h;J[e+76|0]=1;L[e+68>>2]=k;c=L[e+64>>2]}f=L[d+8>>2];c=L[e+72>>2]+(c<<3)|0;L[c>>2]=L[d+4>>2];L[c+4>>2]=f;L[e+64>>2]=L[e+64>>2]+1;if((l|0)>2]){nn(e);c=L[d+4>>2];c=(c<<15^-1)+c|0;c=R(c>>10^c,9);c=c>>6^c;c=(c<<11^-1)+c|0;q=L[e+48>>2]-1&(c>>16^c)}c=L[e+12>>2]+(q<<2)|0;L[L[e+32>>2]+(s<<2)>>2]=L[c>>2];L[c>>2]=s;break d}L[L[e+52>>2]+(f<<2)>>2]=L[d+12>>2]}c=L[d+12>>2];ha[L[L[c>>2]+60>>2]](c,b);l=L[a+8>>2]}r=r+1|0;if((r|0)<(l|0)){continue}break}a=L[d+88>>2];if(!a|!M[d+92|0]){break a}if(a){L[8514]=L[8514]+1;ha[L[6799]](a)}}L[d+88>>2]=0;J[d+92|0]=1;L[d+80>>2]=0;L[d+84>>2]=0;a=L[d+68>>2];if(!(a?!a|!M[d+72|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](a)}L[d+68>>2]=0;J[d+72|0]=1;L[d+60>>2]=0;L[d+64>>2]=0;a=L[d+48>>2];if(!(a?!a|!M[d+52|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](a)}L[d+48>>2]=0;J[d+52|0]=1;L[d+40>>2]=0;L[d+44>>2]=0;a=L[d+28>>2];if(!(a?!a|!M[d+32|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](a)}fa=d+96|0}function Sj(a,b){var c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,y=0,A=0;o=fa-16|0;fa=o;s=(E(a),x(2));e=s&2147483647;a:{if(e>>>0<=1305022426){j=+a;d=j*.6366197723675814+6755399441055744+-6755399441055744;r=j+d*-1.5707963109016418+d*-1.5893254773528196e-8;Q[b>>3]=r;c=r<-.7853981852531433;if(T(d)<2147483648){e=~~d}else{e=-2147483648}if(c){d=d+-1;Q[b>>3]=j+d*-1.5707963109016418+d*-1.5893254773528196e-8;e=e-1|0;break a}if(!(r>.7853981852531433)){break a}d=d+1;Q[b>>3]=j+d*-1.5707963109016418+d*-1.5893254773528196e-8;e=e+1|0;break a}if(e>>>0>=2139095040){Q[b>>3]=S(a-a);e=0;break a}c=e;e=(e>>>23|0)-150|0;Q[o+8>>3]=(z(2,c-(e<<23)|0),F());t=o+8|0;g=fa-560|0;fa=g;c=(e-3|0)/24|0;p=(c|0)>0?c:0;i=e+R(p,-24)|0;l=L[5840];if((l|0)>=0){e=l+1|0;c=p;while(1){Q[(g+320|0)+(f<<3)>>3]=(c|0)<0?0:+L[(c<<2)+23376>>2];c=c+1|0;f=f+1|0;if((e|0)!=(f|0)){continue}break}}k=i-24|0;e=0;f=(l|0)>0?l:0;while(1){c=0;d=0;while(1){d=Q[(c<<3)+t>>3]*Q[(g+320|0)+(e-c<<3)>>3]+d;c=c+1|0;if((c|0)!=1){continue}break}Q[(e<<3)+g>>3]=d;c=(e|0)==(f|0);e=e+1|0;if(!c){continue}break}y=47-i|0;u=48-i|0;A=i-25|0;e=l;b:{while(1){d=Q[(e<<3)+g>>3];c=0;f=e;n=(e|0)<=0;if(!n){while(1){m=(g+480|0)+(c<<2)|0;j=d*5.960464477539063e-8;c:{if(T(j)<2147483648){h=~~j;break c}h=-2147483648}j=+(h|0);d=j*-16777216+d;d:{if(T(d)<2147483648){h=~~d;break d}h=-2147483648}L[m>>2]=h;f=f-1|0;d=Q[(f<<3)+g>>3]+j;c=c+1|0;if((e|0)!=(c|0)){continue}break}}d=me(d,k);d=d+X(d*.125)*-8;e:{if(T(d)<2147483648){m=~~d;break e}m=-2147483648}d=d-+(m|0);f:{g:{h:{v=(k|0)<=0;i:{if(!v){f=(e<<2)+g|0;h=L[f+476>>2];c=h>>u;q=f;f=h-(c<>2]=f;m=c+m|0;h=f>>y;break i}if(k){break h}h=L[((e<<2)+g|0)+476>>2]>>23}if((h|0)<=0){break f}break g}h=2;if(d>=.5){break g}h=0;break f}c=0;f=0;if(!n){while(1){q=(g+480|0)+(c<<2)|0;n=L[q>>2];w=16777215;j:{k:{if(f){break k}w=16777216;if(n){break k}f=0;break j}L[q>>2]=w-n;f=1}c=c+1|0;if((e|0)!=(c|0)){continue}break}}l:{if(v){break l}c=8388607;m:{switch(A|0){case 1:c=4194303;break;case 0:break m;default:break l}}n=(e<<2)+g|0;L[n+476>>2]=L[n+476>>2]&c}m=m+1|0;if((h|0)!=2){break f}d=1-d;h=2;if(!f){break f}d=d-me(1,k)}if(d==0){f=0;n:{c=e;if((l|0)>=(e|0)){break n}while(1){c=c-1|0;f=L[(g+480|0)+(c<<2)>>2]|f;if((c|0)>(l|0)){continue}break}if(!f){break n}i=k;while(1){i=i-24|0;e=e-1|0;if(!L[(g+480|0)+(e<<2)>>2]){continue}break}break b}c=1;while(1){f=c;c=c+1|0;if(!L[(g+480|0)+(l-f<<2)>>2]){continue}break}f=e+f|0;while(1){e=e+1|0;Q[(g+320|0)+(e<<3)>>3]=L[(e+p<<2)+23376>>2];c=0;d=0;while(1){d=Q[(c<<3)+t>>3]*Q[(g+320|0)+(e-c<<3)>>3]+d;c=c+1|0;if((c|0)!=1){continue}break}Q[(e<<3)+g>>3]=d;if((e|0)<(f|0)){continue}break}e=f;continue}break}d=me(d,24-i|0);o:{if(d>=16777216){k=(g+480|0)+(e<<2)|0;j=d*5.960464477539063e-8;p:{if(T(j)<2147483648){c=~~j;break p}c=-2147483648}d=+(c|0)*-16777216+d;q:{if(T(d)<2147483648){f=~~d;break q}f=-2147483648}L[k>>2]=f;e=e+1|0;break o}if(T(d)<2147483648){c=~~d}else{c=-2147483648}i=k}L[(g+480|0)+(e<<2)>>2]=c}d=me(1,i);r:{if((e|0)<0){break r}c=e;while(1){f=c;Q[(c<<3)+g>>3]=d*+L[(g+480|0)+(c<<2)>>2];c=c-1|0;d=d*5.960464477539063e-8;if(f){continue}break}if((e|0)<0){break r}f=e;while(1){d=0;c=0;i=e-f|0;k=(i|0)>(l|0)?l:i;if((k|0)>=0){while(1){d=Q[(c<<3)+26144>>3]*Q[(c+f<<3)+g>>3]+d;p=(c|0)!=(k|0);c=c+1|0;if(p){continue}break}}Q[(g+160|0)+(i<<3)>>3]=d;c=(f|0)>0;f=f-1|0;if(c){continue}break}}d=0;if((e|0)>=0){while(1){c=e;e=e-1|0;d=d+Q[(g+160|0)+(c<<3)>>3];if(c){continue}break}}Q[o>>3]=h?-d:d;fa=g+560|0;e=m&7;d=Q[o>>3];if((s|0)<0){Q[b>>3]=-d;e=0-e|0;break a}Q[b>>3]=d}fa=o+16|0;return e}function cz(a,b){a=a|0;b=b|0;var c=S(0),d=0,e=S(0),f=0,g=0,h=S(0),i=S(0),j=0,k=S(0),l=S(0),m=S(0),n=S(0),o=S(0),p=S(0),q=S(0),r=S(0),s=S(0),t=S(0),u=0,v=0,w=0,x=0,y=0,z=0,A=S(0),B=0,C=0,D=S(0),E=S(0),F=S(0),G=S(0),H=S(0),I=S(0),J=0,K=S(0);f=L[a+216>>2];D=P[f+4>>2];a:{if(D==S(0)){break a}g=L[b>>2];if(!(ha[L[L[f>>2]+8>>2]](f,L[g+188>>2])|0)){break a}v=a+68|0;w=a+132|0;f=g+4|0;y=L[a+216>>2];a=fa+-64|0;fa=a;d=L[g+192>>2];b:{if(L[d+4>>2]==32){if(!g|L[g+236>>2]!=8){break b}f=v+48|0;d=w+48|0;if(!(L[g+988>>2]|!L[g+752>>2])){vk(g)}L[a+60>>2]=1065353216;L[a+48>>2]=g;L[a+52>>2]=0;L[a+56>>2]=-1;b=fa-80|0;fa=b;c=P[f>>2];l=P[d>>2];e=P[f+4>>2];h=P[d+4>>2];i=P[f+8>>2];k=P[d+8>>2];L[b+76>>2]=0;P[b+72>>2]=k-i;P[b+68>>2]=h-e;P[b+64>>2]=l-c;c:{if(!L[g+988>>2]){u=L[g+752>>2];if((u|0)<=0){break c}while(1){d=L[g+760>>2]+R(j,44)|0;c=uk(f,b- -64|0,L[d+8>>2]+8|0,L[d+12>>2]+8|0,L[d+16>>2]+8|0,P[a+60>>2]);if(c>S(0)){L[a+52>>2]=3;L[a+56>>2]=j;P[a+60>>2]=c;x=x+1|0}j=j+1|0;if((u|0)!=(j|0)){continue}break}break c}c=P[a+60>>2];L[b>>2]=21032;j=L[f+4>>2];L[b+4>>2]=L[f>>2];L[b+8>>2]=j;j=L[f+12>>2];L[b+12>>2]=L[f+8>>2];L[b+16>>2]=j;l=P[d+8>>2];e=P[f+8>>2];h=P[d>>2];i=P[f>>2];k=P[d+4>>2];m=P[f+4>>2];L[b+48>>2]=0;P[b+44>>2]=l-e;P[b+40>>2]=k-m;P[b+36>>2]=h-i;j=L[d+4>>2];L[b+20>>2]=L[d>>2];L[b+24>>2]=j;j=L[d+12>>2];L[b+28>>2]=L[d+8>>2];L[b+32>>2]=j;L[b+56>>2]=0;L[b+60>>2]=0;P[b+52>>2]=c;qn(L[g+988>>2],f,d,b);d=L[b+56>>2];if(!d){break c}P[a+60>>2]=P[b+52>>2];L[a+52>>2]=3;L[a+56>>2]=(d-L[g+760>>2]|0)/44;x=1}if(L[g+772>>2]>0){J=L[g+780>>2];E=P[b+72>>2];F=P[b+68>>2];G=P[b+64>>2];while(1){j=0;while(1){d=(J+R(z,104)|0)+8|0;u=R(j,12);B=L[d+(L[u+21076>>2]<<2)>>2];t=P[B+8>>2];C=L[(L[u+21072>>2]<<2)+d>>2];i=P[C+8>>2];c=S(t-i);d=L[(L[u+21080>>2]<<2)+d>>2];H=P[d+12>>2];k=P[C+12>>2];e=S(H-k);A=P[d+8>>2];h=S(A-i);o=P[B+12>>2];m=S(o-k);l=S(S(c*e)-S(h*m));p=m;I=P[d+16>>2];m=P[C+16>>2];q=S(I-m);r=P[B+16>>2];n=S(r-m);e=S(S(p*q)-S(e*n));h=S(S(n*h)-S(q*c));c=S(S(E*l)+S(S(G*e)+S(F*h)));d:{if(S(T(c))>2];n=P[f>>2];p=P[f+4>>2];c=S(S(-S(S(S(q*l)+S(S(n*e)+S(h*p)))-S(S(m*l)+S(S(i*e)+S(k*h)))))/c);if(!(c>S(11920928955078125e-22))|!(P[a+60>>2]>c)){break d}s=S(n+S(G*c));i=S(i-s);n=S(p+S(F*c));o=S(o-n);t=S(t-s);k=S(k-n);p=r;r=S(q+S(E*c));q=S(p-r);m=S(m-r);if(!(S(S(l*S(S(i*o)-S(t*k)))+S(S(e*S(S(k*q)-S(o*m)))+S(h*S(S(m*t)-S(q*i)))))>S(-11920928955078125e-22))){break d}n=S(H-n);s=S(A-s);A=S(l*S(S(t*n)-S(s*o)));p=o;o=S(I-r);if(!(c>S(0))|(!(S(A+S(S(e*S(S(p*o)-S(n*q)))+S(h*S(S(q*s)-S(o*t)))))>S(-11920928955078125e-22))|!(S(S(l*S(S(s*k)-S(i*n)))+S(S(e*S(S(n*m)-S(k*o)))+S(h*S(S(o*i)-S(m*s)))))>S(-11920928955078125e-22)))){break d}x=x+1|0;L[a+52>>2]=4;L[a+56>>2]=z;P[a+60>>2]=c}j=j+1|0;if((j|0)!=4){continue}break}z=z+1|0;if((z|0)>2]){continue}break}}fa=b+80|0;if(!x){break b}k=P[a+60>>2];if(!(k<=P[y+4>>2])){break b}L[a+40>>2]=0;b=L[a+56>>2];L[a+44>>2]=b;c=S(P[w+52>>2]-P[v+52>>2]);l=S(P[w+48>>2]-P[v+48>>2]);e=S(P[w+56>>2]-P[v+56>>2]);e:{if(L[a+52>>2]!=3){i=S(S(1)/S(_(S(S(e*e)+S(S(l*l)+S(c*c))))));h=S(i*S(-e));c=S(i*S(-c));e=S(i*S(-l));break e}b=L[g+760>>2]+R(b,44)|0;h=P[b+28>>2];r=S(h*e);e=P[b+20>>2];p=c;c=P[b+24>>2];if(!(S(r+S(S(e*l)+S(p*c)))>S(0))){K=P[b+32>>2];break e}h=S(-h);c=S(-c);e=S(-e)}P[a+32>>2]=K;P[a+28>>2]=h;P[a+24>>2]=c;P[a+36>>2]=k;P[a+20>>2]=e;L[a+12>>2]=g;L[a+16>>2]=a+40;S(ha[L[L[y>>2]+12>>2]](y,a+12|0,1));break b}b=fa-32|0;fa=b;L[b+24>>2]=-1;L[b+28>>2]=-1;L[b+20>>2]=f;L[b+16>>2]=g;L[b+12>>2]=d;L[b+8>>2]=0;Ze(v,w,b+8|0,y);fa=b+32|0}fa=a- -64|0}return D!=S(0)|0}function mA(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;a:{b:{c:{if((f|0)>=0){i=L[a+16>>2];if((i|0)>0){break c}break b}f=L[a+8>>2];S(ha[L[L[f>>2]+12>>2]](f,b,c,d,e,L[a+12>>2],L[a+16>>2],L[a+4>>2],L[a+20>>2],L[a+24>>2]));return}m=L[a+12>>2];while(1){q=m+(g<<2)|0;j=L[q>>2];h=L[L[j+28>>2]+208>>2];if((h|0)<0){h=L[L[j+32>>2]+208>>2]}if((f|0)==(h|0)){break b}g=g+1|0;if((i|0)!=(g|0)){continue}break}q=0;break a}if((g|0)>=(i|0)){break a}h=i-g|0;k=h&1;j=L[a+12>>2];if((i|0)!=(g+1|0)){i=h&-2;m=0;while(1){l=j+(g<<2)|0;n=L[l>>2];h=L[L[n+28>>2]+208>>2];if((h|0)<0){h=L[L[n+32>>2]+208>>2]}g=g+2|0;o=((f|0)==(h|0))+o|0;l=L[l+4>>2];h=L[L[l+28>>2]+208>>2];if((h|0)<0){h=L[L[l+32>>2]+208>>2]}o=((f|0)==(h|0))+o|0;m=m+2|0;if((i|0)!=(m|0)){continue}break}}if(!k){break a}h=L[j+(g<<2)>>2];g=L[L[h+28>>2]+208>>2];if((g|0)<0){g=L[L[h+32>>2]+208>>2]}o=((f|0)==(g|0))+o|0}f=L[a+4>>2];if(L[f+72>>2]>=2){if((c|0)>0){g=L[a+36>>2];h=L[a+32>>2];j=0;while(1){n=(j<<2)+b|0;d:{if((g|0)!=(h|0)){break d}i=g?g<<1:1;if((i|0)<=(g|0)){h=g;break d}e:{if(!i){f=0;break e}L[8513]=L[8513]+1;f=ha[L[6798]](i<<2,16)|0;g=L[a+32>>2]}h=g;f:{if((g|0)<=0){break f}m=0;g=0;if(h>>>0>=4){r=h&-4;k=0;while(1){l=g<<2;L[l+f>>2]=L[l+L[a+40>>2]>>2];p=l|4;L[p+f>>2]=L[p+L[a+40>>2]>>2];p=l|8;L[p+f>>2]=L[p+L[a+40>>2]>>2];l=l|12;L[l+f>>2]=L[l+L[a+40>>2]>>2];g=g+4|0;k=k+4|0;if((r|0)!=(k|0)){continue}break}}k=h&3;if(!k){break f}while(1){l=g<<2;L[l+f>>2]=L[l+L[a+40>>2]>>2];g=g+1|0;m=m+1|0;if((k|0)!=(m|0)){continue}break}}g=L[a+40>>2];if(!(!g|!M[a+44|0])){if(g){L[8514]=L[8514]+1;ha[L[6799]](g)}h=L[a+32>>2]}L[a+40>>2]=f;J[a+44|0]=1;L[a+36>>2]=i;g=i}L[L[a+40>>2]+(h<<2)>>2]=L[n>>2];h=h+1|0;L[a+32>>2]=h;j=j+1|0;if((j|0)!=(c|0)){continue}break}}if((e|0)>0){g=L[a+56>>2];h=L[a+52>>2];j=0;while(1){i=(j<<2)+d|0;g:{if((g|0)!=(h|0)){break g}b=g?g<<1:1;if((b|0)<=(g|0)){h=g;break g}h:{if(!b){f=0;break h}L[8513]=L[8513]+1;f=ha[L[6798]](b<<2,16)|0;g=L[a+52>>2]}h=g;i:{if((g|0)<=0){break i}m=0;g=0;if(h>>>0>=4){l=h&-4;k=0;while(1){c=g<<2;L[c+f>>2]=L[c+L[a+60>>2]>>2];n=c|4;L[n+f>>2]=L[n+L[a+60>>2]>>2];n=c|8;L[n+f>>2]=L[n+L[a+60>>2]>>2];c=c|12;L[c+f>>2]=L[c+L[a+60>>2]>>2];g=g+4|0;k=k+4|0;if((l|0)!=(k|0)){continue}break}}c=h&3;if(!c){break i}while(1){k=g<<2;L[k+f>>2]=L[k+L[a+60>>2]>>2];g=g+1|0;m=m+1|0;if((c|0)!=(m|0)){continue}break}}c=L[a+60>>2];if(!(!c|!M[a+64|0])){if(c){L[8514]=L[8514]+1;ha[L[6799]](c)}h=L[a+52>>2]}L[a+60>>2]=f;J[a+64|0]=1;L[a+56>>2]=b;g=b}L[L[a+60>>2]+(h<<2)>>2]=L[i>>2];h=h+1|0;L[a+52>>2]=h;j=j+1|0;if((j|0)!=(e|0)){continue}break}}j:{if(!o){h=L[a+72>>2];break j}g=L[a+76>>2];h=L[a+72>>2];j=0;while(1){d=(j<<2)+q|0;k:{if((g|0)!=(h|0)){break k}b=g?g<<1:1;if((b|0)<=(g|0)){h=g;break k}l:{if(!b){f=0;break l}L[8513]=L[8513]+1;f=ha[L[6798]](b<<2,16)|0;g=L[a+72>>2]}h=g;m:{if((g|0)<=0){break m}m=0;g=0;if(h>>>0>=4){e=h&-4;k=0;while(1){c=g<<2;L[c+f>>2]=L[c+L[a+80>>2]>>2];i=c|4;L[i+f>>2]=L[i+L[a+80>>2]>>2];i=c|8;L[i+f>>2]=L[i+L[a+80>>2]>>2];c=c|12;L[c+f>>2]=L[c+L[a+80>>2]>>2];g=g+4|0;k=k+4|0;if((e|0)!=(k|0)){continue}break}}c=h&3;if(!c){break m}while(1){e=g<<2;L[e+f>>2]=L[e+L[a+80>>2]>>2];g=g+1|0;m=m+1|0;if((c|0)!=(m|0)){continue}break}}c=L[a+80>>2];if(!(!c|!M[a+84|0])){if(c){L[8514]=L[8514]+1;ha[L[6799]](c)}h=L[a+72>>2]}L[a+80>>2]=f;J[a+84|0]=1;L[a+76>>2]=b;g=b}L[L[a+80>>2]+(h<<2)>>2]=L[d>>2];h=h+1|0;L[a+72>>2]=h;j=j+1|0;if((o|0)!=(j|0)){continue}break}}if(L[L[a+4>>2]+72>>2]<(L[a+52>>2]+h|0)){Ok(a)}return}g=L[a+8>>2];S(ha[L[L[g>>2]+12>>2]](g,b,c,d,e,q,o,f,L[a+20>>2],L[a+24>>2]))}function hI(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=S(0);f=fa-32|0;fa=f;h=a+4|0;Hc(h,((R(L[a+152>>2],L[a+16>>2])|0)/100|0)+1|0);if(L[a+164>>2]){c=((R(L[a+148>>2],L[a+76>>2])|0)/100|0)+1|0;Hc(a- -64|0,c);c=L[a+164>>2]-c|0;L[a+164>>2]=(c|0)>0?c:0}c=(L[a+144>>2]+1|0)%2|0;L[a+144>>2]=c;c=L[((c<<2)+a|0)+124>>2];if(c){g=a- -64|0;while(1){d=L[c+52>>2];e=d?d+56|0:((L[c+60>>2]<<2)+a|0)+124|0;d=L[c+56>>2];L[e>>2]=d;e=L[c+56>>2];if(e){L[e+52>>2]=L[c+52>>2]}L[c+52>>2]=0;L[c+56>>2]=L[a+132>>2];e=L[a+132>>2];if(e){L[e+52>>2]=c}L[a+132>>2]=c;fc(h,L[c+48>>2]);e=L[c+28>>2];L[f+8>>2]=L[c+24>>2];L[f+12>>2]=e;e=L[c+20>>2];L[f>>2]=L[c+16>>2];L[f+4>>2]=e;e=L[c+44>>2];L[f+24>>2]=L[c+40>>2];L[f+28>>2]=e;e=L[c+36>>2];L[f+16>>2]=L[c+32>>2];L[f+20>>2]=e;e=Bb(g,f,c);L[c+60>>2]=2;L[c+48>>2]=e;c=d;if(c){continue}break}J[a+194|0]=1;L[a+164>>2]=L[a+76>>2]}L[f>>2]=5824;L[f+4>>2]=a;a:{if(!M[a+193|0]){break a}_e(h,L[a+4>>2],L[a- -64>>2],f);if(!M[a+193|0]){break a}c=L[h>>2];_e(h,c,c,f)}b:{if(!M[a+194|0]){break b}c=L[a+136>>2];e=ha[L[L[c>>2]+28>>2]](c)|0;c=L[e+4>>2];if((c|0)<=0){break b}c:{d=L[a+160>>2];h=(R(L[a+156>>2],c)|0)/100|0;d=(d|0)>(h|0)?d:h;g=(c|0)<(d|0)?c:d;if((g|0)>0){c=0;while(1){h=L[e+12>>2]+((L[a+184>>2]+c|0)%L[e+4>>2]<<4)|0;i=L[h>>2];d=L[i+48>>2];j=L[h+4>>2];h=L[j+48>>2];d:{e:{if(!(P[d>>2]<=P[h+16>>2])|!(P[d+16>>2]>=P[h>>2])|(!(P[d+4>>2]<=P[h+20>>2])|!(P[d+20>>2]>=P[h+4>>2]))){break e}if(!(P[d+8>>2]<=P[h+24>>2])){break e}if(P[d+24>>2]>=P[h+8>>2]){break d}}d=L[a+136>>2];ha[L[L[d>>2]+12>>2]](d,i,j,b)|0;c=c-1|0;g=g-1|0}c=c+1|0;if((g|0)>(c|0)){continue}break}c=L[e+4>>2];if((c|0)<=0){break c}}L[a+184>>2]=(L[a+184>>2]+g|0)%(c|0);break b}L[a+184>>2]=0}J[a+194|0]=0;L[a+160>>2]=1;L[a+180>>2]=L[a+180>>2]+1;c=L[a+172>>2];d=L[a+168>>2];if(d){m=S(S(c>>>0)/S(d>>>0))}else{m=S(0)}P[a+176>>2]=m;L[a+172>>2]=c>>>1;L[a+168>>2]=d>>>1;fa=f+32|0;d=0;c=0;j=0;l=fa-16|0;fa=l;f=L[a+136>>2];if(ha[L[L[f>>2]+56>>2]](f)|0){h=a;a=L[a+136>>2];g=ha[L[L[a>>2]+28>>2]](a)|0;a=L[g+4>>2];if((a|0)>=2){jc(g,l+15|0,0,a-1|0);a=L[g+4>>2]}if((a|0)>0){while(1){i=L[g+12>>2]+(j<<4)|0;f=L[i+4>>2];e=d;d=L[i>>2];f:{g:{if((e|0)==(d|0)&(c|0)==(f|0)){break g}c=L[d+48>>2];e=L[f+48>>2];if(!(P[c>>2]<=P[e+16>>2])|!(P[c+16>>2]>=P[e>>2])|(!(P[c+4>>2]<=P[e+20>>2])|!(P[c+20>>2]>=P[e+4>>2]))){break g}if(!(P[c+8>>2]<=P[e+24>>2])){break g}if(P[c+24>>2]>=P[e+8>>2]){break f}}a=L[h+136>>2];ha[L[L[a>>2]+32>>2]](a,i,b);L[i>>2]=0;L[i+4>>2]=0;k=k+1|0;a=L[g+4>>2]}c=f;j=j+1|0;if((j|0)<(a|0)){continue}break}if((a|0)>=2){jc(g,l+14|0,0,a-1|0);a=L[g+4>>2]}b=a-k|0;h:{if((k|0)>=0){break h}if((b|0)>L[g+8>>2]){d=0;i:{if((a|0)==(k|0)){break i}L[8513]=L[8513]+1;d=ha[L[6798]](b<<4,16)|0;e=L[g+4>>2];if((e|0)<=0){break i}c=0;while(1){h=c<<4;f=h+d|0;h=h+L[g+12>>2]|0;L[f>>2]=L[h>>2];L[f+4>>2]=L[h+4>>2];L[f+8>>2]=L[h+8>>2];L[f+12>>2]=L[h+12>>2];c=c+1|0;if((e|0)!=(c|0)){continue}break}}c=L[g+12>>2];if(!(c?!c|!M[g+16|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](c)}L[g+12>>2]=d;J[g+16|0]=1;L[g+8>>2]=b}c=0;f=0-k&3;if(f){while(1){d=L[g+12>>2]+(a<<4)|0;L[d>>2]=0;L[d+4>>2]=0;L[d+8>>2]=0;L[d+12>>2]=0;a=a+1|0;c=c+1|0;if((f|0)!=(c|0)){continue}break}}if(k>>>0>4294967292){break h}while(1){c=a<<4;d=c+L[g+12>>2]|0;L[d>>2]=0;L[d+4>>2]=0;L[d+8>>2]=0;L[d+12>>2]=0;d=c+L[g+12>>2]|0;L[d+24>>2]=0;L[d+28>>2]=0;L[d+16>>2]=0;L[d+20>>2]=0;d=c+L[g+12>>2]|0;L[d+40>>2]=0;L[d+44>>2]=0;L[d+32>>2]=0;L[d+36>>2]=0;c=c+L[g+12>>2]|0;L[c+56>>2]=0;L[c+60>>2]=0;L[c+48>>2]=0;L[c+52>>2]=0;a=a+4|0;if((b|0)!=(a|0)){continue}break}}a=b}L[g+4>>2]=a}fa=l+16|0}function Bc(a,b,c,d,e,f,g,h,i,j,k){var l=0,m=S(0),n=S(0),o=S(0),p=S(0),q=0,r=S(0),s=S(0),t=S(0),u=0,v=S(0),w=S(0),x=S(0),y=S(0),z=S(0),A=S(0),B=S(0),C=S(0),D=S(0),E=0,F=S(0),G=S(0),H=S(0),I=S(0),K=0,N=0,O=S(0),Q=S(0),T=S(0),U=S(0),V=S(0),W=0,X=S(0),Y=S(0),Z=S(0),_=0;q=L[a+68>>2];u=q;a:{if((q|0)!=L[a+72>>2]){break a}K=q?q<<1:1;if((q|0)>=(K|0)){break a}if(K){L[8513]=L[8513]+1;N=ha[L[6798]](R(K,152),16)|0;l=L[a+68>>2]}else{l=q}b:{if((l|0)<=0){break b}u=0;if((l|0)!=1){_=l&-2;while(1){E=R(u,152);qa(E+N|0,E+L[a+76>>2]|0,152);E=R(u|1,152);qa(E+N|0,E+L[a+76>>2]|0,152);u=u+2|0;W=W+2|0;if((W|0)!=(_|0)){continue}break}}if(!(l&1)){break b}l=R(u,152);qa(l+N|0,l+L[a+76>>2]|0,152)}l=L[a+76>>2];if(!(l?!l|!M[a+80|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](l)}L[a+76>>2]=N;J[a+80|0]=1;L[a+72>>2]=K;u=L[a+68>>2]}L[a+68>>2]=u+1;l=L[a+76>>2]+R(q,152)|0;L[l+140>>2]=e;q=L[a+16>>2];a=L[(q+R(d,244)|0)+240>>2];e=L[(q+R(c,244)|0)+240>>2];L[l+148>>2]=d;L[l+144>>2]=c;O=P[f+84>>2];L[l+132>>2]=0;P[l+104>>2]=O;L[l+96>>2]=0;L[l+100>>2]=0;c:{if(e){f=L[b+4>>2];L[l+16>>2]=L[b>>2];L[l+20>>2]=f;f=L[b+12>>2];L[l+24>>2]=L[b+8>>2];L[l+28>>2]=f;p=P[g+8>>2];m=P[g>>2];n=P[g+4>>2];L[l+12>>2]=0;Q=P[l+20>>2];T=P[l+16>>2];F=S(S(m*Q)-S(n*T));P[l+8>>2]=F;U=P[l+24>>2];G=S(S(p*T)-S(m*U));P[l+4>>2]=G;H=S(S(n*U)-S(Q*p));P[l>>2]=H;p=P[e+272>>2];m=P[e+268>>2];n=P[e+548>>2];o=P[e+288>>2];v=P[e+280>>2];z=P[e+284>>2];r=P[e+552>>2];t=P[e+304>>2];A=P[e+296>>2];B=P[e+300>>2];C=P[e+544>>2];y=P[e+264>>2];L[l+76>>2]=0;r=S(r*S(S(t*F)+S(S(A*H)+S(G*B))));P[l+72>>2]=r;o=S(n*S(S(o*F)+S(S(v*H)+S(G*z))));P[l+68>>2]=o;v=S(C*S(S(p*F)+S(S(y*H)+S(G*m))));P[l+64>>2]=v;break c}L[l+64>>2]=0;L[l+68>>2]=0;L[l>>2]=0;L[l+4>>2]=0;L[l+72>>2]=0;L[l+76>>2]=0;L[l+8>>2]=0;L[l+12>>2]=0;L[l+16>>2]=0;L[l+20>>2]=0;L[l+24>>2]=0;L[l+28>>2]=0}d:{if(a){p=P[b>>2];m=P[b+4>>2];n=P[b+8>>2];L[l+60>>2]=0;X=S(-n);P[l+56>>2]=X;Y=S(-m);P[l+52>>2]=Y;Z=S(-p);P[l+48>>2]=Z;s=P[h+8>>2];w=P[h+4>>2];x=P[h>>2];L[l+44>>2]=0;I=S(S(p*w)-S(x*m));P[l+40>>2]=I;x=S(S(n*x)-S(s*p));P[l+36>>2]=x;w=S(S(m*s)-S(w*n));P[l+32>>2]=w;p=P[a+272>>2];n=P[a+268>>2];m=P[a+548>>2];z=P[a+288>>2];t=P[a+280>>2];A=P[a+284>>2];s=P[a+552>>2];B=P[a+304>>2];C=P[a+296>>2];y=P[a+300>>2];V=P[a+544>>2];D=P[a+264>>2];L[l+92>>2]=0;s=S(s*S(S(B*I)+S(S(C*w)+S(x*y))));P[l+88>>2]=s;m=S(m*S(S(z*I)+S(S(t*w)+S(x*A))));P[l+84>>2]=m;n=S(V*S(S(p*I)+S(S(D*w)+S(x*n))));P[l+80>>2]=n;break d}L[l+80>>2]=0;L[l+84>>2]=0;L[l+32>>2]=0;L[l+36>>2]=0;L[l+88>>2]=0;L[l+92>>2]=0;L[l+40>>2]=0;L[l+44>>2]=0;L[l+48>>2]=0;L[l+52>>2]=0;L[l+56>>2]=0;L[l+60>>2]=0;m=S(0);n=S(0)}z=S(0);V=i;if(e){i=P[g+4>>2];t=P[g>>2];y=S(P[b+8>>2]*S(S(v*i)-S(t*o)));D=o;o=P[g+8>>2];D=S(P[e+344>>2]+S(y+S(S(P[b>>2]*S(S(D*o)-S(i*r)))+S(S(S(r*t)-S(o*v))*P[b+4>>2]))))}else{D=S(0)}if(a){r=P[h>>2];o=P[h+4>>2];y=S(P[b+8>>2]*S(S(m*r)-S(n*o)));i=m;m=P[h+8>>2];i=S(P[a+344>>2]+S(y+S(S(P[b>>2]*S(S(s*o)-S(i*m)))+S(S(S(n*m)-S(s*r))*P[b+4>>2]))))}else{i=S(0)}C=S(V/S(D+i));P[l+108>>2]=C;i=S(0);r=S(0);o=S(0);v=S(0);s=S(0);m=S(0);if(e){b=q+R(c,244)|0;o=S(P[b+176>>2]+P[b+208>>2]);m=P[b+192>>2];v=P[b+200>>2];r=S(P[b+180>>2]+P[b+212>>2]);s=P[b+196>>2];i=S(P[b+184>>2]+P[b+216>>2])}n=S(0);p=S(0);t=S(0);A=S(0);B=S(0);if(a){a=q+R(d,244)|0;z=S(P[a+176>>2]+P[a+208>>2]);n=S(P[a+180>>2]+P[a+212>>2]);t=P[a+200>>2];A=P[a+196>>2];B=P[a+192>>2];p=S(P[a+184>>2]+P[a+216>>2])}P[l+124>>2]=O;P[l+116>>2]=k;P[l+120>>2]=-O;P[l+112>>2]=C*S(j-S(S(S(S(U*i)+S(S(T*o)+S(r*Q)))+S(S(F*v)+S(S(H*m)+S(s*G))))+S(S(S(X*p)+S(S(Z*z)+S(n*Y)))+S(S(I*t)+S(S(w*B)+S(A*x))))))}function IB(a,b){a=a|0;b=b|0;var c=S(0),d=S(0),e=S(0),f=0,g=S(0),h=0,i=S(0),j=0,k=S(0),l=0,m=S(0),n=S(0),o=0,p=S(0),q=0,r=S(0),s=S(0),t=S(0),u=0,v=S(0),w=0,x=S(0),y=S(0),z=S(0),A=S(0),B=S(0),C=S(0),D=0,E=S(0),F=S(0),G=S(0),H=S(0),I=S(0),J=0,K=0;f=fa-96|0;fa=f;h=L[a+32>>2];l=L[a+28>>2];q=L[b+8>>2];L[q>>2]=1065353216;u=L[b+24>>2];o=u+1<<2;L[o+q>>2]=1065353216;J=u<<1;K=J+2<<2;L[q+K>>2]=1065353216;s=P[l+8>>2];m=P[l+12>>2];n=P[l+20>>2];p=P[l+24>>2];k=P[l+28>>2];i=P[l+36>>2];d=P[l+40>>2];c=P[a+52>>2];r=P[l+44>>2];e=P[a+56>>2];v=P[l+4>>2];g=P[a+48>>2];q=L[b+12>>2];L[q+12>>2]=0;L[q>>2]=0;i=S(S(r*e)+S(S(i*g)+S(c*d)));P[q+4>>2]=i;n=S(S(k*e)+S(S(n*g)+S(c*p)));P[q+8>>2]=-n;w=u<<2;j=w+q|0;L[j+12>>2]=0;m=S(S(m*e)+S(S(v*g)+S(s*c)));P[j+8>>2]=m;L[j+4>>2]=0;P[j>>2]=-i;D=u<<3;j=q+D|0;L[j+8>>2]=0;L[j+12>>2]=0;P[j+4>>2]=-m;P[j>>2]=n;j=L[b+16>>2];if(j){L[j>>2]=-1082130432;L[j+o>>2]=-1082130432;L[j+K>>2]=-1082130432}s=P[h+8>>2];d=P[h+12>>2];k=P[h+36>>2];r=P[h+40>>2];v=P[h+44>>2];p=P[h+20>>2];z=P[h+24>>2];c=P[a+68>>2];A=P[h+28>>2];e=P[a+72>>2];B=P[h+4>>2];g=P[a+64>>2];j=L[b+20>>2];L[j+12>>2]=0;L[j>>2]=0;p=S(S(A*e)+S(S(p*g)+S(c*z)));P[j+8>>2]=p;k=S(S(v*e)+S(S(k*g)+S(c*r)));P[j+4>>2]=-k;o=j+w|0;L[o+12>>2]=0;c=S(S(d*e)+S(S(B*g)+S(s*c)));P[o+8>>2]=-c;L[o+4>>2]=0;P[o>>2]=k;o=j+(J<<2)|0;L[o+8>>2]=0;L[o+12>>2]=0;P[o+4>>2]=c;P[o>>2]=-p;e=P[l+60>>2];g=P[h+60>>2];d=P[l+56>>2];r=P[h+56>>2];o=L[b+28>>2];s=S(P[b>>2]*P[b+4>>2]);P[o>>2]=s*S(S(S(c+P[h+52>>2])-m)-P[l+52>>2]);P[o+w>>2]=s*S(S(S(p+r)-n)-d);P[o+D>>2]=s*S(S(S(k+g)-i)-e);o=R(u,12);L[o+q>>2]=1065353216;w=u<<4|4;L[w+q>>2]=1065353216;D=q;q=R(u,20)+8|0;L[D+q>>2]=1065353216;L[j+o>>2]=-1082130432;L[j+w>>2]=-1082130432;L[j+q>>2]=-1082130432;e=P[h+12>>2];n=P[h+24>>2];m=P[h+40>>2];g=P[h+8>>2];p=P[h+36>>2];k=P[h+28>>2];d=P[h+20>>2];r=P[h+44>>2];v=P[l+12>>2];z=P[l+4>>2];A=P[l+8>>2];B=P[l+28>>2];E=P[l+20>>2];F=P[l+24>>2];G=P[l+44>>2];H=P[l+36>>2];I=P[l+40>>2];i=P[h+4>>2];L[f+72>>2]=0;L[f+56>>2]=0;x=S(S(d*m)-S(p*n));y=S(S(n*r)-S(m*k));t=S(S(k*p)-S(r*d));c=S(S(1)/S(S(e*x)+S(S(i*y)+S(g*t))));C=S(S(S(i*n)-S(d*g))*c);n=S(S(S(g*k)-S(n*e))*c);k=S(S(S(e*d)-S(k*i))*c);P[f+68>>2]=S(G*C)+S(S(H*n)+S(I*k));d=S(S(S(g*p)-S(m*i))*c);g=S(S(S(e*m)-S(r*g))*c);e=S(S(S(i*r)-S(p*e))*c);P[f- -64>>2]=S(G*d)+S(S(H*g)+S(I*e));P[f+52>>2]=S(C*B)+S(S(n*E)+S(k*F));P[f+48>>2]=S(d*B)+S(S(g*E)+S(e*F));L[f+40>>2]=0;i=S(x*c);m=S(y*c);c=S(t*c);P[f+60>>2]=S(G*i)+S(S(H*m)+S(I*c));P[f+44>>2]=S(i*B)+S(S(m*E)+S(c*F));P[f+36>>2]=S(C*v)+S(S(n*z)+S(A*k));P[f+32>>2]=S(d*v)+S(S(g*z)+S(A*e));P[f+28>>2]=S(i*v)+S(S(m*z)+S(A*c));h=f+12|0;Ma(f+28|0,h);n=P[a+92>>2];c=P[h+12>>2];e=S(n-c);x=S(e*e);m=P[a+88>>2];e=P[h+8>>2];g=S(m-e);y=S(g*g);p=P[a+80>>2];g=P[h>>2];i=S(p-g);t=S(i*i);k=P[a+84>>2];i=P[h+4>>2];d=S(k-i);C=S(x+S(y+S(t+S(d*d))));d=S(n+c);x=S(d*d);d=S(m+e);y=S(d*d);d=S(p+g);t=S(d*d);d=S(k+i);if(!(CS(1)?S(1):d);P[f+76>>2]=d+d;L[f+92>>2]=0;d=S(S(i*p)+S(S(S(n*e)-S(c*m))-S(g*k)));r=S(S(e*k)+S(S(S(n*g)-S(c*p))-S(i*m)));c=S(S(g*m)+S(S(S(n*i)-S(c*k))-S(e*p)));e=S(S(d*d)+S(S(r*r)+S(c*c)));a:{if(e>2]=1065353216;L[f+84>>2]=0;P[f+88>>2]=0;break a}t=c;c=S(S(1)/S(_(e)));P[f+84>>2]=t*c;P[f+80>>2]=r*c;P[f+88>>2]=d*c}c=S(-P[f+76>>2]);P[f+84>>2]=P[f+84>>2]*c;P[f+88>>2]=P[f+88>>2]*c;a=L[b+24>>2];b=L[b+28>>2];P[R(a,12)+b>>2]=s*S(P[f+80>>2]*c);P[b+(a<<4)>>2]=s*P[f+84>>2];P[b+R(a,20)>>2]=s*P[f+88>>2];fa=f+96|0}function zz(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=S(0),m=S(0),n=0,o=0,p=S(0),q=S(0),r=S(0),s=S(0);d=fa-448|0;fa=d;f=L[c+36>>2];i=L[b+36>>2];b=L[a+24>>2];a:{if(M[L[b+1140>>2]+(L[i+380>>2]+R(L[f+380>>2],L[b+1112>>2])|0)|0]?(b|0)!=L[a+28>>2]|!L[b+1132>>2]:1){c=d+392|0;L[c+4>>2]=35;L[c+8>>2]=0;L[c>>2]=14328;L[c+44>>2]=1025758986;L[c+12>>2]=1065353216;L[c+16>>2]=1065353216;L[c>>2]=14044;L[c+20>>2]=1065353216;L[c+24>>2]=0;L[c+52>>2]=i;L[c>>2]=21628;L[c+44>>2]=0;b=d+336|0;L[b+4>>2]=35;L[b+8>>2]=0;L[b>>2]=14328;L[b+44>>2]=1025758986;L[b+12>>2]=1065353216;L[b+16>>2]=1065353216;L[b>>2]=14044;L[b+20>>2]=1065353216;L[b+24>>2]=0;L[b+52>>2]=f;L[b>>2]=21628;L[b+44>>2]=0;g=J[30088]&1;b:{c:{d:{if(!g){if(!(J[30140]&1)){break d}break c}if(g){break b}if(J[30140]&1){break c}}L[7524]=0;L[7525]=0;L[7523]=1065353216;J[30140]=1;L[7526]=0;L[7527]=0;L[7529]=0;L[7530]=0;L[7528]=1065353216;L[7531]=0;L[7532]=0;L[7533]=1065353216;L[7534]=0}L[7518]=0;L[7519]=0;J[30088]=1;g=L[7524];L[7506]=L[7523];L[7507]=g;g=L[7528];L[7510]=L[7527];L[7511]=g;g=L[7532];L[7514]=L[7531];L[7515]=g;L[7520]=0;L[7521]=0;g=L[7526];L[7508]=L[7525];L[7509]=g;g=L[7530];L[7512]=L[7529];L[7513]=g;g=L[7534];L[7516]=L[7533];L[7517]=g}p=P[f+232>>2];q=P[i+232>>2];r=P[f+236>>2];s=P[i+236>>2];l=P[f+228>>2];m=P[i+228>>2];L[d+76>>2]=0;P[d+64>>2]=m-l;P[d+72>>2]=s-r;P[d+68>>2]=q-p;e:{if(!Gl(c,b,30024,d- -64|0,d+280|0)){break e}L[d+84>>2]=0;L[d+88>>2]=0;L[d+76>>2]=0;L[d+80>>2]=0;L[d+32>>2]=0;L[d+16>>2]=0;L[d+56>>2]=0;L[d+60>>2]=0;L[d+52>>2]=i;L[d+44>>2]=0;L[d+48>>2]=0;L[d+40>>2]=f;L[d+68>>2]=0;L[d+72>>2]=0;J[d+216|0]=0;L[d+64>>2]=21160;b=L[d+56>>2];L[d+24>>2]=L[d+52>>2];L[d+28>>2]=b;b=L[d+44>>2];L[d+8>>2]=L[d+40>>2];L[d+12>>2]=b;if(!nk(a,d+280|0,d+24|0,d+8|0,d- -64|0)){break e}L[8513]=L[8513]+1;e=ha[L[6798]](216,16)|0;b=pa(e+4|0,0,212);L[e>>2]=21160;qa(b,d+68|0,100);b=L[d+180>>2];L[e+112>>2]=L[d+176>>2];L[e+116>>2]=b;b=L[d+172>>2];L[e+104>>2]=L[d+168>>2];L[e+108>>2]=b;b=L[d+196>>2];L[e+128>>2]=L[d+192>>2];L[e+132>>2]=b;b=L[d+188>>2];L[e+120>>2]=L[d+184>>2];L[e+124>>2]=b;b=L[d+204>>2];L[e+136>>2]=L[d+200>>2];L[e+140>>2]=b;b=L[d+212>>2];L[e+144>>2]=L[d+208>>2];L[e+148>>2]=b;J[e+152|0]=M[d+216|0];L[e+212>>2]=L[d+276>>2];b=L[d+272>>2];L[e+204>>2]=L[d+268>>2];L[e+208>>2]=b;b=L[d+264>>2];L[e+196>>2]=L[d+260>>2];L[e+200>>2]=b;b=L[d+256>>2];L[e+188>>2]=L[d+252>>2];L[e+192>>2]=b;b=L[d+248>>2];L[e+180>>2]=L[d+244>>2];L[e+184>>2]=b;b=L[d+240>>2];L[e+172>>2]=L[d+236>>2];L[e+176>>2]=b;b=L[d+232>>2];L[e+164>>2]=L[d+228>>2];L[e+168>>2]=b;b=L[d+224>>2];L[e+156>>2]=L[d+220>>2];L[e+160>>2]=b;h=L[a+24>>2];f=L[h+852>>2];f:{if((f|0)!=L[h+856>>2]){break f}g=f?f<<1:1;if((g|0)<=(f|0)){break f}if(g){L[8513]=L[8513]+1;j=ha[L[6798]](g<<2,16)|0;f=L[h+852>>2]}g:{if((f|0)<=0){break g}if(f>>>0>=4){c=f&-4;while(1){i=k<<2;L[i+j>>2]=L[i+L[h+860>>2]>>2];b=i|4;L[b+j>>2]=L[b+L[h+860>>2]>>2];b=i|8;L[b+j>>2]=L[b+L[h+860>>2]>>2];b=i|12;L[b+j>>2]=L[b+L[h+860>>2]>>2];k=k+4|0;n=n+4|0;if((c|0)!=(n|0)){continue}break}}c=f&3;if(!c){break g}while(1){b=k<<2;L[b+j>>2]=L[b+L[h+860>>2]>>2];k=k+1|0;o=o+1|0;if((c|0)!=(o|0)){continue}break}}b=L[h+860>>2];if(!(!b|!M[h+864|0])){if(b){L[8514]=L[8514]+1;ha[L[6799]](b)}f=L[h+852>>2]}L[h+860>>2]=j;J[h+864|0]=1;L[h+856>>2]=g}L[L[h+860>>2]+(f<<2)>>2]=e;L[h+852>>2]=f+1;b=L[a+24>>2];l=P[b+348>>2];a=L[a+28>>2];m=P[a+348>>2];P[e+64>>2]=P[e+64>>2]*(l>m?l:m);P[e+68>>2]=P[e+68>>2]*S(S(P[b+360>>2]+P[a+360>>2])*S(.5))}break a}L[8498]=L[8498]+1}fa=d+448|0}function Jl(a,b,c,d){var e=0,f=0,g=S(0),h=S(0),i=S(0),j=S(0),k=S(0),l=S(0),m=S(0),n=S(0),o=S(0),p=S(0),q=S(0),r=S(0),s=S(0),t=S(0),u=S(0),v=S(0),w=S(0),x=S(0),y=S(0),z=S(0),A=S(0),B=0,C=S(0),D=0,E=S(0),F=S(0),G=S(0),H=S(0),I=S(0),K=S(0),M=0,N=S(0),O=S(0),Q=S(0),R=S(0),T=S(0),U=S(0),V=S(0),W=S(0),X=S(0),Y=S(0),Z=S(0),_=0,$=0,aa=S(0),ba=S(0),ca=S(0),da=S(0),ea=S(0),ga=S(0);e=fa-240|0;fa=e;a:{if(L[a+16>>2]){He(L[a+4>>2]);f=L[a+12>>2];D=L[f+4>>2];M=L[a+16>>2];_=L[M+4>>2];h=S(ha[L[L[f>>2]+48>>2]](f));B=L[a+16>>2];j=S(ha[L[L[B>>2]+48>>2]](B));B=L[a+4>>2];$=L[a+8>>2];a=e+160|0;L[a+72>>2]=1;L[a+76>>2]=1;L[a+60>>2]=-1;J[a+52|0]=0;P[a+48>>2]=j;P[a+44>>2]=h;L[a+40>>2]=_;L[a+36>>2]=D;L[a+32>>2]=M;L[a+28>>2]=f;L[a+24>>2]=B;L[a+20>>2]=$;L[a+4>>2]=0;L[a+8>>2]=1065353216;L[a+12>>2]=0;L[a+16>>2]=0;L[a>>2]=18600;L[e+152>>2]=1566444395;f=L[b+12>>2];L[e+32>>2]=L[b+8>>2];L[e+36>>2]=f;f=L[b+4>>2];L[e+24>>2]=L[b>>2];L[e+28>>2]=f;f=L[b+28>>2];L[e+48>>2]=L[b+24>>2];L[e+52>>2]=f;f=L[b+20>>2];L[e+40>>2]=L[b+16>>2];L[e+44>>2]=f;D=L[b+44>>2];f=e- -64|0;L[f>>2]=L[b+40>>2];L[f+4>>2]=D;f=L[b+36>>2];L[e+56>>2]=L[b+32>>2];L[e+60>>2]=f;f=L[b+60>>2];L[e+80>>2]=L[b+56>>2];L[e+84>>2]=f;f=L[b+52>>2];L[e+72>>2]=L[b+48>>2];L[e+76>>2]=f;b=L[c+12>>2];L[e+96>>2]=L[c+8>>2];L[e+100>>2]=b;b=L[c+4>>2];L[e+88>>2]=L[c>>2];L[e+92>>2]=b;b=L[c+20>>2];L[e+104>>2]=L[c+16>>2];L[e+108>>2]=b;b=L[c+28>>2];L[e+112>>2]=L[c+24>>2];L[e+116>>2]=b;b=L[c+44>>2];L[e+128>>2]=L[c+40>>2];L[e+132>>2]=b;b=L[c+36>>2];L[e+120>>2]=L[c+32>>2];L[e+124>>2]=b;b=L[c+52>>2];L[e+136>>2]=L[c+48>>2];L[e+140>>2]=b;b=L[c+60>>2];L[e+144>>2]=L[c+56>>2];L[e+148>>2]=b;wb(a,e+24|0,d,0,0);break a}E=P[b+52>>2];F=P[b+56>>2];G=P[c+52>>2];H=P[c+56>>2];k=P[b+20>>2];l=P[b+36>>2];h=P[c+20>>2];j=P[c+36>>2];g=P[c+24>>2];m=P[b+24>>2];i=P[c+40>>2];p=P[b+40>>2];I=P[b+48>>2];aa=P[c+48>>2];f=L[a+12>>2];q=P[b+32>>2];r=P[b+16>>2];s=P[b>>2];t=P[b+4>>2];x=P[c+32>>2];y=P[c+16>>2];z=P[c>>2];A=P[c+4>>2];n=P[c+8>>2];u=P[b+8>>2];a=L[a+20>>2];v=P[a+52>>2];w=P[a+56>>2];o=P[a+48>>2];L[e+172>>2]=0;N=S(S(p*x)+S(S(u*z)+S(m*y)));o=S(-o);O=S(S(p*j)+S(S(u*A)+S(m*h)));C=S(S(p*i)+S(S(u*n)+S(m*g)));P[e+168>>2]=S(S(N*o)-S(v*O))-S(w*C);Q=S(S(l*x)+S(S(t*z)+S(k*y)));R=S(S(l*j)+S(S(t*A)+S(k*h)));T=S(S(l*i)+S(S(t*n)+S(k*g)));P[e+164>>2]=S(S(Q*o)-S(v*R))-S(w*T);U=S(S(q*x)+S(S(s*z)+S(r*y)));V=S(S(q*j)+S(S(s*A)+S(r*h)));W=S(S(q*i)+S(S(s*n)+S(r*g)));P[e+160>>2]=S(S(U*o)-S(v*V))-S(w*W);b=e+160|0;ha[L[L[f>>2]+64>>2]](e+24|0,f,b);k=P[a+52>>2];l=P[a+56>>2];ba=P[a+64>>2];m=P[a+48>>2];p=P[e+24>>2];q=P[e+28>>2];r=P[e+32>>2];ca=P[c+52>>2];s=P[c+24>>2];t=P[c+20>>2];da=P[c+56>>2];u=P[c+40>>2];v=P[c+36>>2];ea=P[c+48>>2];w=P[c+8>>2];o=P[c>>2];X=P[c+4>>2];Y=P[c+16>>2];Z=P[c+32>>2];L[e+172>>2]=0;ga=S(S(F*i)+S(S(I*n)+S(E*g)));K=n;n=S(-aa);g=S(S(ga+S(S(S(K*n)-S(g*G))-S(i*H)))+S(S(r*C)+S(S(p*W)+S(T*q))));K=g;C=S(l*g);g=S(S(S(S(F*x)+S(S(I*z)+S(E*y)))+S(S(S(z*n)-S(y*G))-S(x*H)))+S(S(r*N)+S(S(p*U)+S(Q*q))));i=S(S(S(S(F*j)+S(S(I*A)+S(E*h)))+S(S(S(A*n)-S(h*G))-S(j*H)))+S(S(r*O)+S(S(p*V)+S(R*q))));h=S(S(C+S(S(m*g)+S(k*i)))-ba);j=S(K-S(l*h));g=S(g-S(m*h));i=S(i-S(k*h));P[e+168>>2]=da+S(S(u*j)+S(S(Z*g)+S(v*i)));P[e+164>>2]=ca+S(S(j*s)+S(S(g*Y)+S(i*t)));P[e+160>>2]=ea+S(S(j*w)+S(S(g*o)+S(i*X)));L[e+20>>2]=0;P[e+16>>2]=S(u*l)+S(S(Z*m)+S(k*v));P[e+12>>2]=S(s*l)+S(S(Y*m)+S(k*t));P[e+8>>2]=S(w*l)+S(S(o*m)+S(k*X));ha[L[L[d>>2]+16>>2]](d,e+8|0,b,h)}fa=e+240|0}function Kk(a,b){var c=0,d=S(0),e=S(0),f=S(0),g=S(0),h=S(0),i=S(0),j=S(0),k=S(0),l=S(0),m=S(0),n=S(0),o=S(0),p=S(0),q=S(0),r=S(0),s=S(0),t=0;L[a+312>>2]=0;L[a+316>>2]=0;L[a+236>>2]=2;L[a+544>>2]=1065353216;L[a+548>>2]=1065353216;L[a+348>>2]=1065353216;L[a+352>>2]=1065353216;L[a+412>>2]=0;L[a+416>>2]=0;L[a+320>>2]=0;L[a+324>>2]=0;L[a+328>>2]=0;L[a+332>>2]=0;L[a+336>>2]=0;L[a+340>>2]=0;L[a+552>>2]=1065353216;L[a+556>>2]=0;L[a+360>>2]=0;L[a+364>>2]=0;L[a+356>>2]=1065353216;L[a+368>>2]=0;L[a+372>>2]=0;L[a+376>>2]=0;L[a+380>>2]=0;L[a+384>>2]=0;L[a+388>>2]=0;L[a+392>>2]=0;L[a+420>>2]=0;L[a+424>>2]=0;L[a+428>>2]=0;L[a+432>>2]=0;L[a+436>>2]=0;L[a+440>>2]=0;g=P[b+92>>2];d=P[b+96>>2];P[a+448>>2]=dS(1)?S(1):d;P[a+444>>2]=gS(1)?S(1):g;P[a+472>>2]=P[b+112>>2];P[a+476>>2]=P[b+116>>2];c=L[b+4>>2];L[a+608>>2]=0;L[a+612>>2]=0;L[a+480>>2]=c;J[a+452|0]=M[b+120|0];P[a+456>>2]=P[b+124>>2];P[a+460>>2]=P[b+128>>2];P[a+464>>2]=P[b+132>>2];P[a+468>>2]=P[b+136>>2];a:{if(c){ha[L[L[c>>2]+8>>2]](c,a+4|0);break a}c=L[b+12>>2];L[a+4>>2]=L[b+8>>2];L[a+8>>2]=c;c=L[b+20>>2];L[a+12>>2]=L[b+16>>2];L[a+16>>2]=c;c=L[b+36>>2];L[a+28>>2]=L[b+32>>2];L[a+32>>2]=c;c=L[b+28>>2];L[a+20>>2]=L[b+24>>2];L[a+24>>2]=c;c=L[b+44>>2];L[a+36>>2]=L[b+40>>2];L[a+40>>2]=c;c=L[b+52>>2];L[a+44>>2]=L[b+48>>2];L[a+48>>2]=c;c=b- -64|0;t=L[c+4>>2];L[a+60>>2]=L[c>>2];L[a+64>>2]=t;c=L[b+60>>2];L[a+52>>2]=L[b+56>>2];L[a+56>>2]=c}L[a+132>>2]=0;L[a+136>>2]=0;c=L[a+8>>2];L[a+68>>2]=L[a+4>>2];L[a+72>>2]=c;L[a+156>>2]=0;L[a+160>>2]=0;L[a+148>>2]=0;L[a+152>>2]=0;L[a+140>>2]=0;L[a+144>>2]=0;c=L[a+24>>2];L[a+84>>2]=L[a+20>>2];L[a+88>>2]=c;c=L[a+16>>2];L[a+76>>2]=L[a+12>>2];L[a+80>>2]=c;c=L[a+32>>2];L[a+92>>2]=L[a+28>>2];L[a+96>>2]=c;c=L[a+40>>2];L[a+100>>2]=L[a+36>>2];L[a+104>>2]=c;c=L[a+48>>2];L[a+108>>2]=L[a+44>>2];L[a+112>>2]=c;c=L[a+56>>2];L[a+116>>2]=L[a+52>>2];L[a+120>>2]=c;c=L[a+64>>2];L[a+124>>2]=L[a+60>>2];L[a+128>>2]=c;P[a+224>>2]=P[b+100>>2];P[a+232>>2]=P[b+104>>2];P[a+228>>2]=P[b+108>>2];ha[L[L[a>>2]+12>>2]](a,L[b+72>>2]);c=L[8291];L[8291]=c+1;L[a+508>>2]=c;g=S(0);c=L[a+204>>2];d=P[b>>2];if(d==S(0)){c=c|1}else{g=S(S(1)/d);c=c&-2}P[a+344>>2]=g;L[a+204>>2]=c;L[a+376>>2]=0;P[a+364>>2]=d*P[a+380>>2];P[a+372>>2]=d*P[a+388>>2];P[a+368>>2]=d*P[a+384>>2];e=P[b+84>>2];f=P[b+80>>2];d=P[b+76>>2];L[a+504>>2]=0;L[a+308>>2]=0;L[a+292>>2]=0;L[a+276>>2]=0;L[a+408>>2]=0;d=d!=S(0)?S(S(1)/d):S(0);P[a+396>>2]=d;f=f!=S(0)?S(S(1)/f):S(0);P[a+400>>2]=f;e=e!=S(0)?S(S(1)/e):S(0);P[a+404>>2]=e;m=P[a+12>>2];h=S(e*m);n=P[a+4>>2];i=S(d*n);o=P[a+8>>2];j=S(f*o);P[a+264>>2]=S(m*h)+S(S(n*i)+S(o*j));p=P[a+28>>2];q=P[a+20>>2];r=P[a+24>>2];P[a+268>>2]=S(p*h)+S(S(q*i)+S(j*r));s=P[a+44>>2];k=S(s*h);h=P[a+36>>2];l=S(h*i);i=P[a+40>>2];P[a+272>>2]=k+S(l+S(j*i));j=S(e*p);k=S(d*q);l=S(f*r);P[a+280>>2]=S(m*j)+S(S(n*k)+S(o*l));P[a+284>>2]=S(p*j)+S(S(q*k)+S(r*l));P[a+288>>2]=S(s*j)+S(S(h*k)+S(l*i));e=S(e*s);d=S(d*h);f=S(f*i);P[a+296>>2]=S(m*e)+S(S(n*d)+S(o*f));P[a+300>>2]=S(p*e)+S(S(q*d)+S(r*f));P[a+304>>2]=S(s*e)+S(S(h*d)+S(i*f));d=P[a+348>>2];f=P[a+352>>2];e=P[a+356>>2];L[a+536>>2]=0;L[a+540>>2]=0;L[a+528>>2]=0;L[a+532>>2]=0;L[a+520>>2]=0;L[a+524>>2]=0;L[a+512>>2]=0;L[a+516>>2]=0;P[a+568>>2]=g*e;P[a+564>>2]=g*f;P[a+560>>2]=g*d;L[a+604>>2]=0;L[a+596>>2]=0;L[a+600>>2]=0;L[a+588>>2]=0;L[a+592>>2]=0;L[a+580>>2]=0;L[a+584>>2]=0;L[a+572>>2]=0;L[a+576>>2]=0}function CG(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=S(0),f=S(0),g=S(0),h=S(0),i=S(0),j=S(0),k=S(0),l=S(0),m=S(0),n=0,o=0,p=S(0),q=S(0),r=S(0),s=S(0),t=S(0),u=S(0),v=S(0),w=S(0),x=S(0),y=S(0),z=S(0),A=S(0),B=0,C=0,D=0,E=S(0),F=S(0),G=S(0),H=0,I=0;d=fa-240|0;fa=d;L[a+4>>2]=L[a+4>>2]+1;B=L[c+36>>2];D=R(B,80);H=L[a+12>>2];I=L[H+4>>2];n=L[(D+L[I+24>>2]|0)+64>>2];c=L[a+8>>2];C=L[b+36>>2];b=L[L[c+4>>2]+24>>2]+R(C,80)|0;o=L[b+64>>2];c=L[c+12>>2];E=P[c+52>>2];F=P[c+56>>2];e=P[c+24>>2];f=P[c+20>>2];g=P[c+40>>2];h=P[c+36>>2];G=P[c+48>>2];i=P[c+8>>2];j=P[c>>2];k=P[c+4>>2];l=P[c+16>>2];m=P[c+32>>2];p=P[b+32>>2];q=P[b>>2];r=P[b+16>>2];s=P[b+56>>2];t=P[b+48>>2];u=P[b+52>>2];v=P[b+36>>2];w=P[b+4>>2];x=P[b+20>>2];y=P[b+40>>2];z=P[b+8>>2];A=P[b+24>>2];b=0;L[d+236>>2]=0;L[d+220>>2]=0;L[d+204>>2]=0;P[d+216>>2]=S(y*g)+S(S(z*m)+S(h*A));P[d+212>>2]=S(v*g)+S(S(w*m)+S(h*x));P[d+200>>2]=S(y*e)+S(S(z*l)+S(f*A));P[d+196>>2]=S(v*e)+S(S(w*l)+S(f*x));P[d+232>>2]=F+S(S(s*g)+S(S(t*m)+S(h*u)));P[d+228>>2]=E+S(S(s*e)+S(S(t*l)+S(f*u)));L[d+188>>2]=0;P[d+208>>2]=S(p*g)+S(S(q*m)+S(h*r));P[d+192>>2]=S(p*e)+S(S(q*l)+S(f*r));P[d+184>>2]=S(y*i)+S(S(z*j)+S(k*A));P[d+180>>2]=S(v*i)+S(S(w*j)+S(k*x));P[d+176>>2]=S(p*i)+S(S(q*j)+S(k*r));P[d+224>>2]=G+S(S(s*i)+S(S(t*j)+S(k*u)));c=L[H+12>>2];E=P[c+52>>2];F=P[c+56>>2];e=P[c+24>>2];f=P[c+20>>2];g=P[c+40>>2];h=P[c+36>>2];G=P[c+48>>2];i=P[c+8>>2];j=P[c>>2];k=P[c+4>>2];l=P[c+16>>2];m=P[c+32>>2];c=L[I+24>>2]+D|0;p=P[c+32>>2];q=P[c>>2];r=P[c+16>>2];s=P[c+56>>2];t=P[c+48>>2];u=P[c+52>>2];v=P[c+36>>2];w=P[c+4>>2];x=P[c+20>>2];y=P[c+40>>2];z=P[c+8>>2];A=P[c+24>>2];L[d+172>>2]=0;L[d+156>>2]=0;L[d+140>>2]=0;P[d+152>>2]=S(y*g)+S(S(z*m)+S(h*A));P[d+148>>2]=S(v*g)+S(S(w*m)+S(h*x));P[d+136>>2]=S(y*e)+S(S(z*l)+S(f*A));P[d+132>>2]=S(v*e)+S(S(w*l)+S(f*x));P[d+168>>2]=F+S(S(s*g)+S(S(t*m)+S(h*u)));P[d+164>>2]=E+S(S(s*e)+S(S(t*l)+S(f*u)));L[d+124>>2]=0;P[d+144>>2]=S(p*g)+S(S(q*m)+S(h*r));P[d+128>>2]=S(p*e)+S(S(q*l)+S(f*r));P[d+120>>2]=S(y*i)+S(S(z*j)+S(k*A));P[d+116>>2]=S(v*i)+S(S(w*j)+S(k*x));P[d+112>>2]=S(p*i)+S(S(q*j)+S(k*r));P[d+160>>2]=G+S(S(s*i)+S(S(t*j)+S(k*u)));ha[L[L[o>>2]+8>>2]](o,d+176|0,d+96|0,d+80|0);ha[L[L[n>>2]+8>>2]](n,d+112|0,d- -64|0,d+48|0);c=L[7543];a:{if(c){if(!(ha[c|0](o,n)|0)){break a}}b=P[d+80>>2]>2]|P[d+96>>2]>P[d+48>>2]?b:1;c=0;if((P[d+88>>2]>2]|P[d+104>>2]>P[d+56>>2]?c:b)^1|P[d+84>>2]>2]|P[d+100>>2]>P[d+52>>2]){break a}b=L[a+8>>2];c=L[b+8>>2];L[d+44>>2]=C;L[d+40>>2]=-1;L[d+32>>2]=c;L[d+28>>2]=o;L[d+24>>2]=b;L[d+36>>2]=d+176;b=L[a+12>>2];c=L[b+8>>2];L[d+20>>2]=B;L[d+16>>2]=-1;L[d+8>>2]=c;L[d+4>>2]=n;L[d>>2]=b;L[d+12>>2]=d+112;b=L[a+28>>2];L[7546]=L[7546]+1;c=B<<16|C;c=(c<<15^-1)+c|0;c=R(c>>10^c,9);c=c>>6^c;c=(c<<11^-1)+c|0;c=L[b+12>>2]-1&(c>>16^c);b:{c:{if((c|0)>=L[b+32>>2]){break c}c=L[L[b+40>>2]+(c<<2)>>2];if((c|0)==-1){break c}n=L[b+60>>2];o=L[b+16>>2];while(1){b=o+R(c,12)|0;if(L[b>>2]==(C|0)&L[b+4>>2]==(B|0)){break b}c=L[n+(c<<2)>>2];if((c|0)!=-1){continue}break}}b=0}d:{if(b){b=L[b+8>>2];break d}b=L[a+16>>2];b=ha[L[L[b>>2]+8>>2]](b,d+24|0,d,L[a+32>>2])|0;c=L[a+28>>2];L[(ha[L[L[c>>2]+12>>2]](c,C,B)|0)+8>>2]=b}c=L[a+24>>2];n=L[c+8>>2];o=L[c+12>>2];L[c+12>>2]=d;D=d+24|0;L[c+8>>2]=D;ha[L[L[c>>2]+8>>2]](c,-1,C);c=L[a+24>>2];ha[L[L[c>>2]+12>>2]](c,-1,B);ha[L[L[b>>2]+8>>2]](b,D,d,L[a+20>>2],L[a+24>>2]);a=L[a+24>>2];L[a+8>>2]=n;L[a+12>>2]=o}fa=d+240|0}function Iw(a,b){a=a|0;b=S(b);var c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;m=fa-16|0;fa=m;L[m+12>>2]=a;P[m+8>>2]=b;a=0;c=fa-1120|0;fa=c;j=42;f=L[m+12>>2];e=L[f+44>>2];e=ha[L[L[e>>2]+84>>2]](e)|0;if((e|0)>0){while(1){d=L[f+44>>2];ha[L[L[d>>2]+88>>2]](d,a,c+128|0);am();h=L[c+140>>2];d=j<<4;g=d+30440|0;L[g>>2]=L[c+136>>2];L[g+4>>2]=h;g=L[c+132>>2];d=d+30432|0;L[d>>2]=L[c+128>>2];L[d+4>>2]=g;j=j+1|0;a=a+1|0;if((e|0)!=(a|0)){continue}break}}a=0;while(1){e=L[f+44>>2];am();d=a<<4;ha[L[L[e>>2]+64>>2]](c+4|0,e,d+30432|0);e=d+(c+128|0)|0;d=L[c+16>>2];L[e+8>>2]=L[c+12>>2];L[e+12>>2]=d;d=L[c+8>>2];L[e>>2]=L[c+4>>2];L[e+4>>2]=d;a=a+1|0;if((j|0)!=(a|0)){continue}break}L[c+120>>2]=4096;L[c+124>>2]=4096;L[c+112>>2]=16;L[c+116>>2]=981668463;L[c+104>>2]=j;L[c+100>>2]=1;L[c+108>>2]=c+128;J[c+96|0]=1;L[c+92>>2]=0;L[c+84>>2]=0;L[c+88>>2]=0;L[c+72>>2]=0;J[c+76|0]=1;L[c+64>>2]=0;L[c+68>>2]=0;L[c+24>>2]=0;J[c+28|0]=1;J[c+56|0]=1;L[c+16>>2]=0;L[c+20>>2]=0;L[c+52>>2]=0;L[c+44>>2]=0;L[c+48>>2]=0;L[c+32>>2]=0;L[c+36>>2]=0;L[c+8>>2]=0;J[c+4|0]=1;p=ak(c+60|0,c+100|0,c+4|0);if((p|0)!=1){e=L[c+8>>2];a=e;h=L[f+4>>2];if((a|0)>(h|0)){if((e|0)>L[f+8>>2]){a:{if(!e){j=0;break a}L[8513]=L[8513]+1;j=ha[L[6798]](e<<4,16)|0;h=L[f+4>>2]}b:{if((h|0)<=0){break b}a=0;if((h|0)!=1){k=h&-2;while(1){g=a<<4;i=g+j|0;d=g+L[f+12>>2]|0;n=L[d+4>>2];L[i>>2]=L[d>>2];L[i+4>>2]=n;n=L[d+12>>2];L[i+8>>2]=L[d+8>>2];L[i+12>>2]=n;d=g|16;g=d+j|0;d=d+L[f+12>>2]|0;i=L[d+4>>2];L[g>>2]=L[d>>2];L[g+4>>2]=i;i=L[d+12>>2];L[g+8>>2]=L[d+8>>2];L[g+12>>2]=i;a=a+2|0;l=l+2|0;if((k|0)!=(l|0)){continue}break}}if(!(h&1)){break b}a=a<<4;d=a+j|0;a=a+L[f+12>>2]|0;g=L[a+4>>2];L[d>>2]=L[a>>2];L[d+4>>2]=g;g=L[a+12>>2];L[d+8>>2]=L[a+8>>2];L[d+12>>2]=g}a=L[f+12>>2];if(!(a?!a|!M[f+16|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](a)}L[f+12>>2]=j;J[f+16|0]=1;L[f+8>>2]=e}a=L[c+8>>2]}L[f+4>>2]=e;if((a|0)>0){a=0;while(1){e=a<<4;d=e+L[f+12>>2]|0;e=e+L[c+24>>2]|0;g=L[e+4>>2];L[d>>2]=L[e>>2];L[d+4>>2]=g;g=L[e+12>>2];L[d+8>>2]=L[e+8>>2];L[d+12>>2]=g;a=a+1|0;if((a|0)>2]){continue}break}}e=L[c+36>>2];L[f+40>>2]=e;a=e;d=L[f+24>>2];if((a|0)>(d|0)){c:{if((e|0)<=L[f+28>>2]){h=L[f+32>>2];break c}d:{if(!e){h=0;a=d;break d}L[8513]=L[8513]+1;h=ha[L[6798]](e<<2,16)|0;a=L[f+24>>2]}i=L[f+32>>2];e:{g=a;if((a|0)>0){j=0;a=0;if(g>>>0>=4){n=g&-4;l=0;while(1){k=a<<2;L[k+h>>2]=L[i+k>>2];o=k|4;L[o+h>>2]=L[i+o>>2];o=k|8;L[o+h>>2]=L[i+o>>2];k=k|12;L[k+h>>2]=L[i+k>>2];a=a+4|0;l=l+4|0;if((n|0)!=(l|0)){continue}break}}g=g&3;if(!g){break e}while(1){l=a<<2;L[l+h>>2]=L[i+l>>2];a=a+1|0;j=j+1|0;if((g|0)!=(j|0)){continue}break}break e}if(i){break e}L[f+32>>2]=h;L[f+28>>2]=e;J[f+36|0]=1;break c}if(i?M[f+36|0]:0){L[8514]=L[8514]+1;ha[L[6799]](i)}L[f+32>>2]=h;J[f+36|0]=1;L[f+28>>2]=e}pa((d<<2)+h|0,0,e-d<<2);a=L[f+40>>2]}L[f+24>>2]=e;if((a|0)>0){e=L[f+32>>2];a=0;d=L[c+52>>2];while(1){g=a<<2;L[g+e>>2]=L[d+g>>2];a=a+1|0;if((a|0)>2]){continue}break}}$j(c+4|0)}a=L[c+52>>2];if(!(a?!a|!M[c+56|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](a)}L[c+52>>2]=0;J[c+56|0]=1;L[c+44>>2]=0;L[c+48>>2]=0;a=L[c+24>>2];if(!(a?!a|!M[c+28|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](a)}a=L[c+92>>2];if(!(a?!a|!M[c+96|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](a)}L[c+92>>2]=0;J[c+96|0]=1;L[c+84>>2]=0;L[c+88>>2]=0;a=L[c+72>>2];if(!(a?!a|!M[c+76|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](a)}fa=c+1120|0;fa=m+16|0;return(p|0)!=1|0}function dG(a,b,c,d){a=a|0;b=b|0;c=c|0;d=S(d);var e=0,f=0,g=0,h=S(0),i=S(0),j=S(0),k=S(0),l=S(0),m=S(0),n=0,o=S(0),p=0,q=S(0),r=S(0),s=S(0),t=S(0),u=S(0),v=S(0),w=S(0),x=S(0),y=S(0),z=S(0),A=S(0),B=S(0),C=S(0),D=S(0),E=S(0),F=0;e=fa-192|0;fa=e;a:{if(P[L[a+4>>2]+752>>2]>2];k=S(S(P[b+8>>2]*d)+o);r=P[c+4>>2];m=S(S(P[b+4>>2]*d)+r);s=P[c>>2];l=S(S(P[b>>2]*d)+s);g=L[L[a+8>>2]+8>>2];n=L[a+4>>2];f=L[n+740>>2];p=(g|0)==(f|0);b:{if(!p){f=L[L[a+12>>2]+8>>2];h=S(k-P[f+60>>2]);i=S(l-P[f+52>>2]);j=S(m-P[f+56>>2]);t=S(S(P[f+44>>2]*h)+S(S(P[f+12>>2]*i)+S(j*P[f+28>>2])));u=S(S(P[f+40>>2]*h)+S(S(P[f+8>>2]*i)+S(j*P[f+24>>2])));h=S(S(P[f+36>>2]*h)+S(S(P[f+4>>2]*i)+S(j*P[f+20>>2])));break b}h=S(k-P[f+60>>2]);i=S(l-P[f+52>>2]);j=S(m-P[f+56>>2]);t=S(S(P[f+44>>2]*h)+S(S(P[f+12>>2]*i)+S(j*P[f+28>>2])));u=S(S(P[f+40>>2]*h)+S(S(P[f+8>>2]*i)+S(j*P[f+24>>2])));g=L[L[a+12>>2]+8>>2];h=S(S(P[f+36>>2]*h)+S(S(P[f+4>>2]*i)+S(j*P[f+20>>2])))}v=P[g+20>>2];w=P[g+36>>2];x=P[g+40>>2];y=P[g+8>>2];z=P[g+24>>2];i=P[g+44>>2];j=P[g+60>>2];A=P[g+12>>2];B=P[g+52>>2];C=P[g+28>>2];D=P[g+56>>2];E=P[g+4>>2];L[e+36>>2]=0;q=i;i=S(o-j);j=S(s-B);o=S(r-D);P[e+32>>2]=S(q*i)+S(S(A*j)+S(C*o));P[e+28>>2]=S(x*i)+S(S(y*j)+S(o*z));L[e+20>>2]=0;P[e+16>>2]=t;P[e+12>>2]=u;P[e+8>>2]=h;P[e+24>>2]=S(w*i)+S(S(E*j)+S(o*v));g=L[b+12>>2];L[e+80>>2]=L[b+8>>2];L[e+84>>2]=g;g=L[b>>2];b=L[b+4>>2];L[e+136>>2]=0;L[e+140>>2]=0;L[e+144>>2]=0;L[e+148>>2]=0;L[e+152>>2]=0;L[e+156>>2]=0;P[e+60>>2]=m;P[e- -64>>2]=k;L[e+68>>2]=0;L[e+72>>2]=g;L[e+76>>2]=b;L[e+128>>2]=0;L[e+132>>2]=0;J[e+124|0]=0;L[e+120>>2]=0;L[e+100>>2]=0;L[e+92>>2]=0;L[e+96>>2]=0;P[e+88>>2]=d;P[e+56>>2]=l;b=L[c+12>>2];L[e+48>>2]=L[c+8>>2];L[e+52>>2]=b;b=L[c+4>>2];L[e+40>>2]=L[c>>2];L[e+44>>2]=b;f=L[n+748>>2];c:{if((f|0)<=0){b=-1;break c}d=P[e+16>>2];m=P[e+12>>2];l=P[e+8>>2];k=P[n+752>>2];k=S(k*k);c=0;b=-1;while(1){g=n+R(c,184)|0;h=S(P[g+12>>2]-d);i=S(h*h);h=S(P[g+4>>2]-l);q=S(h*h);h=S(P[g+8>>2]-m);h=S(i+S(q+S(h*h)));g=h>2]+8>>2];c=L[L[a+12>>2]+8>>2];d=S(P[b+224>>2]*P[c+224>>2]);d=d>2]=d>S(10)?S(10):d;P[e+100>>2]=P[b+228>>2]*P[c+228>>2];d=S(P[b+232>>2]*P[c+232>>2]);d=d>2]=d>S(10)?S(10):d;d=P[e+80>>2];d:{if(S(T(d))>S(.7071067690849304)){l=P[e+76>>2];k=S(S(l*l)+S(d*d));m=S(S(1)/S(_(k)));h=S(k*m);i=S(m*S(-d));j=P[e+72>>2];k=S(i*j);d=S(l*m);l=S(d*S(-j));j=S(0);break d}h=P[e+72>>2];l=P[e+76>>2];k=S(S(h*h)+S(l*l));m=S(S(1)/S(_(k)));k=S(k*m);j=S(m*S(-l));l=S(d*j);i=S(h*m);h=S(i*S(-d));d=S(0)}P[e+184>>2]=k;P[e+180>>2]=l;P[e+164>>2]=i;P[e+176>>2]=h;P[e+168>>2]=d;P[e+160>>2]=j;e:{if(!p){c=a+28|0;f=a+20|0;n=a+16|0;b=a+24|0;break e}c=a+24|0;f=a+16|0;n=a+20|0;b=a+28|0}f=L[f>>2];n=L[n>>2];c=L[c>>2];L[e+116>>2]=L[b>>2];L[e+112>>2]=c;L[e+108>>2]=n;L[e+104>>2]=f;b=L[a+4>>2];f:{if((g|0)>=0){b=b+R(g,184)|0;c=L[b+116>>2];f=L[b+124>>2];n=L[b+128>>2];d=P[b+132>>2];F=L[b+152>>2];qa(b+4|0,e+8|0,184);L[b+152>>2]=F;P[b+132>>2]=d;L[b+124>>2]=f;L[b+128>>2]=n;L[b+116>>2]=c;break f}g=Fl(b,e+8|0)}f=L[7547];if(!f){break a}c=L[a+8>>2];b=L[a+12>>2];if(!(M[L[c+8>>2]+204|0]&8|M[L[b+8>>2]+204|0]&8)){break a}ha[f|0]((L[a+4>>2]+R(g,184)|0)+4|0,p?c:b,L[e+104>>2],L[e+112>>2],p?b:c,L[e+108>>2],L[e+116>>2])|0}fa=e+192|0}function Je(a,b,c,d){var e=0,f=S(0),g=S(0),h=S(0),i=0,j=0,k=S(0),l=S(0),m=S(0),n=0,o=S(0),p=S(0),q=S(0),r=S(0),s=0,t=S(0),u=S(0),v=S(0),w=S(0),x=S(0),y=S(0),z=S(0),A=S(0),B=0,C=0,D=S(0),E=S(0),F=0;e=fa-656|0;fa=e;j=e+444|0;L[j+4>>2]=35;L[j+8>>2]=0;L[j>>2]=14328;L[j+44>>2]=1025758986;L[j+12>>2]=1065353216;L[j+16>>2]=1065353216;L[j>>2]=14044;L[j+20>>2]=1065353216;L[j+24>>2]=0;P[j+44>>2]=0;P[j+28>>2]=0;L[j+4>>2]=8;L[j>>2]=16192;L[e+392>>2]=0;L[e+396>>2]=0;L[e+404>>2]=0;L[e+408>>2]=0;L[e+400>>2]=1065353216;L[e+412>>2]=0;L[e+416>>2]=0;L[e+420>>2]=1065353216;L[e+424>>2]=0;L[e+384>>2]=0;L[e+388>>2]=0;L[e+380>>2]=1065353216;n=L[a+12>>2];L[e+436>>2]=L[a+8>>2];L[e+440>>2]=n;n=L[a+4>>2];L[e+428>>2]=L[a>>2];L[e+432>>2]=n;a=e+496|0;Dg(b,c,j,e+380|0,d,a,0);L[e+136>>2]=0;L[e+140>>2]=0;L[e+128>>2]=0;L[e+132>>2]=0;L[e+364>>2]=0;L[e+368>>2]=0;L[e+376>>2]=2;L[e+144>>2]=0;L[e+648>>2]=1065353216;L[e+652>>2]=0;L[e+640>>2]=1065353216;L[e+644>>2]=1065353216;o=S(34028234663852886e22);a:{b:{c:{switch(Cg(e,a,e+640|0)|0){case 0:i=L[e+372>>2];if(!L[i+32>>2]){o=S(0);break b}a=0;o=S(0);while(1){B=a<<2;i=B+i|0;k=P[i+16>>2];n=L[e+616>>2];F=e+640|0;C=L[e+620>>2];s=L[e+496>>2]+(C>>1)|0;i=L[i>>2];if(C&1){n=L[n+L[s>>2]>>2]}ha[n|0](F,s,i);n=L[e+620>>2];s=L[e+500>>2]+(n>>1)|0;g=S(k*P[e+648>>2]);h=S(k*P[e+644>>2]);f=S(k*P[e+640>>2]);i=L[L[e+372>>2]+B>>2];p=S(-P[i+8>>2]);l=S(-P[i+4>>2]);m=S(-P[i>>2]);i=L[e+616>>2];i=n&1?L[L[s>>2]+i>>2]:i;t=S(t+g);u=S(u+h);q=S(q+f);L[e+636>>2]=0;P[e+632>>2]=S(P[e+544>>2]*p)+S(S(P[e+536>>2]*m)+S(P[e+540>>2]*l));P[e+628>>2]=S(P[e+528>>2]*p)+S(S(P[e+520>>2]*m)+S(P[e+524>>2]*l));P[e+624>>2]=S(P[e+512>>2]*p)+S(S(P[e+504>>2]*m)+S(P[e+508>>2]*l));ha[i|0](e+640|0,s,e+624|0);g=P[e+648>>2];h=P[e+640>>2];f=P[e+644>>2];v=S(v+S(k*S(S(S(g*P[e+592>>2])+S(S(h*P[e+584>>2])+S(f*P[e+588>>2])))+P[e+608>>2])));w=S(w+S(k*S(S(S(g*P[e+576>>2])+S(S(h*P[e+568>>2])+S(f*P[e+572>>2])))+P[e+604>>2])));o=S(o+S(k*S(S(S(g*P[e+560>>2])+S(S(h*P[e+552>>2])+S(f*P[e+556>>2])))+P[e+600>>2])));a=a+1|0;i=L[e+372>>2];if(a>>>0>2]){continue}break};break b;case 1:break c;default:break a}}if(!Bg(b,c,j,e+380|0,e+128|0,d,1)){break a}f=S(P[d+12>>2]-P[d+28>>2]);m=S(P[d+4>>2]-P[d+20>>2]);g=S(P[d+8>>2]-P[d+24>>2]);h=S(_(S(S(f*f)+S(S(m*m)+S(g*g)))));if(h>=S(1.1920928955078125e-7)){L[d+48>>2]=0;k=f;f=S(S(1)/h);P[d+44>>2]=k*f;P[d+40>>2]=g*f;P[d+36>>2]=m*f}o=S(-h);break a}x=P[c+52>>2];y=P[c+24>>2];z=P[c+20>>2];A=P[c+56>>2];r=P[c+40>>2];k=P[c+36>>2];p=P[c+16>>2];l=P[c+32>>2];m=P[c+48>>2];g=P[c+8>>2];h=P[c>>2];f=P[c+4>>2];L[d+16>>2]=0;D=S(m+S(S(t*g)+S(S(q*h)+S(u*f))));P[d+4>>2]=D;E=S(A+S(S(t*r)+S(S(q*l)+S(u*k))));P[d+12>>2]=E;q=S(x+S(S(t*y)+S(S(q*p)+S(u*z))));P[d+8>>2]=q;x=P[c+52>>2];y=P[c+24>>2];z=P[c+20>>2];A=P[c+56>>2];r=P[c+40>>2];g=P[c+36>>2];k=P[c+48>>2];p=P[c+8>>2];l=P[c>>2];m=P[c+4>>2];h=P[c+16>>2];f=P[c+32>>2];L[d+32>>2]=0;g=S(A+S(S(v*r)+S(S(o*f)+S(w*g))));P[d+28>>2]=g;h=S(x+S(S(v*y)+S(S(o*h)+S(w*z))));P[d+24>>2]=h;f=S(k+S(S(v*p)+S(S(o*l)+S(w*m))));P[d+20>>2]=f;p=Dc(b);l=Dc(j);L[d+48>>2]=0;g=S(g-E);k=S(f-D);f=S(h-q);m=S(_(S(S(g*g)+S(S(k*k)+S(f*f)))));r=S(S(1)/m);g=S(g*r);P[d+44>>2]=g;h=S(f*r);P[d+40>>2]=h;f=S(k*r);P[d+36>>2]=f;l=S(p+l);P[d+4>>2]=S(l*f)+P[d+4>>2];P[d+8>>2]=S(l*h)+P[d+8>>2];P[d+12>>2]=S(l*g)+P[d+12>>2];o=S(m-l)}fa=e+656|0;return o}function nD(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;e=fa-32|0;fa=e;d=ha[L[L[a>>2]+28>>2]](a)|0;L[b>>2]=0;L[b+20>>2]=d;if(d){q=ha[L[L[c>>2]+16>>2]](c,32,d)|0;l=L[q+8>>2];L[b>>2]=ha[L[L[c>>2]+28>>2]](c,l);r=ha[L[L[a>>2]+28>>2]](a)|0;if((r|0)>0){while(1){ha[L[L[a>>2]+16>>2]](a,e+28|0,e+4|0,e+16|0,e+8|0,e+24|0,e+20|0,e,e+12|0,p);d=L[e>>2];L[l+24>>2]=d;f=L[e+4>>2];L[l>>2]=0;L[l+4>>2]=0;L[l+28>>2]=f;L[l+8>>2]=0;L[l+12>>2]=0;L[l+16>>2]=0;L[l+20>>2]=0;a:{b:{switch(L[e+12>>2]-2|0){case 0:if(!d){break a}f=ha[L[L[c>>2]+16>>2]](c,4,R(d,3))|0;k=L[f+8>>2];L[l+8>>2]=ha[L[L[c>>2]+28>>2]](c,k);if(L[e>>2]>0){d=0;m=L[e+24>>2];while(1){i=k+R(d,12)|0;j=m+R(L[e+20>>2],d)|0;L[i>>2]=L[j>>2];L[i+4>>2]=L[j+4>>2];L[i+8>>2]=L[j+8>>2];d=d+1|0;if((d|0)>2]){continue}break}}ha[L[L[c>>2]+20>>2]](c,f,3271,1497453121,L[f+8>>2]);break a;case 1:if(!d){break a}n=ha[L[L[c>>2]+16>>2]](c,8,d)|0;i=L[n+8>>2];L[l+12>>2]=ha[L[L[c>>2]+28>>2]](c,i);j=L[e>>2];c:{if((j|0)<=0){break c}d=0;k=L[e+20>>2];m=L[e+24>>2];if((j|0)!=1){o=j&-2;f=0;while(1){h=i+(d<<3)|0;g=m+R(d,k)|0;K[h>>1]=N[g>>1];K[h+2>>1]=N[g+2>>1];K[h+4>>1]=N[g+4>>1];g=d|1;h=i+(g<<3)|0;g=m+R(g,k)|0;K[h>>1]=N[g>>1];K[h+2>>1]=N[g+2>>1];K[h+4>>1]=N[g+4>>1];d=d+2|0;f=f+2|0;if((o|0)!=(f|0)){continue}break}}if(!(j&1)){break c}f=i+(d<<3)|0;d=m+R(d,k)|0;K[f>>1]=N[d>>1];K[f+2>>1]=N[d+2>>1];K[f+4>>1]=N[d+4>>1]}ha[L[L[c>>2]+20>>2]](c,n,3432,1497453121,L[n+8>>2]);break a;case 3:break b;default:break a}}if(!d){break a}f=ha[L[L[c>>2]+16>>2]](c,4,d)|0;k=L[f+8>>2];L[l+16>>2]=ha[L[L[c>>2]+28>>2]](c,k);d=0;if(L[e>>2]>0){while(1){i=k+(d<<2)|0;j=L[e+24>>2]+R(L[e+20>>2],d)|0;J[i|0]=M[j|0];J[i+1|0]=M[j+1|0];J[i+2|0]=M[j+2|0];d=d+1|0;if((d|0)>2]){continue}break}}ha[L[L[c>>2]+20>>2]](c,f,3459,1497453121,L[f+8>>2])}d:{e:{switch(L[e+16>>2]){case 0:d=L[e+4>>2];if(!d){break d}n=ha[L[L[c>>2]+16>>2]](c,16,d)|0;i=L[n+8>>2];L[l>>2]=ha[L[L[c>>2]+28>>2]](c,i);j=L[e+4>>2];f:{if((j|0)<=0){break f}d=0;k=L[e+8>>2];m=L[e+28>>2];if((j|0)!=1){o=j&-2;f=0;while(1){h=i+(d<<4)|0;g=m+R(d,k)|0;P[h>>2]=P[g>>2];P[h+4>>2]=P[g+4>>2];P[h+8>>2]=P[g+8>>2];g=d|1;h=i+(g<<4)|0;g=m+R(g,k)|0;P[h>>2]=P[g>>2];P[h+4>>2]=P[g+4>>2];P[h+8>>2]=P[g+8>>2];d=d+2|0;f=f+2|0;if((o|0)!=(f|0)){continue}break}}if(!(j&1)){break f}f=i+(d<<4)|0;d=m+R(d,k)|0;P[f>>2]=P[d>>2];P[f+4>>2]=P[d+4>>2];P[f+8>>2]=P[d+8>>2]}ha[L[L[c>>2]+20>>2]](c,n,3686,1497453121,L[n+8>>2]);break d;case 1:break e;default:break d}}d=L[e+4>>2];if(!d){break d}n=ha[L[L[c>>2]+16>>2]](c,32,d)|0;i=L[n+8>>2];L[l+4>>2]=ha[L[L[c>>2]+28>>2]](c,i);j=L[e+4>>2];g:{if((j|0)<=0){break g}d=0;k=L[e+8>>2];m=L[e+28>>2];if((j|0)!=1){o=j&-2;f=0;while(1){h=i+(d<<5)|0;g=m+R(d,k)|0;Q[h>>3]=Q[g>>3];Q[h+8>>3]=Q[g+8>>3];Q[h+16>>3]=Q[g+16>>3];g=d|1;h=i+(g<<5)|0;g=m+R(g,k)|0;Q[h>>3]=Q[g>>3];Q[h+8>>3]=Q[g+8>>3];Q[h+16>>3]=Q[g+16>>3];d=d+2|0;f=f+2|0;if((o|0)!=(f|0)){continue}break}}if(!(j&1)){break g}f=i+(d<<5)|0;d=m+R(d,k)|0;Q[f>>3]=Q[d>>3];Q[f+8>>3]=Q[d+8>>3];Q[f+16>>3]=Q[d+16>>3]}ha[L[L[c>>2]+20>>2]](c,n,4058,1497453121,L[n+8>>2])}ha[L[L[a>>2]+24>>2]](a,p);l=l+32|0;p=p+1|0;if((r|0)!=(p|0)){continue}break}}ha[L[L[c>>2]+20>>2]](c,q,3286,1497453121,L[q+8>>2])}P[b+4>>2]=P[a+4>>2];P[b+8>>2]=P[a+8>>2];P[b+12>>2]=P[a+12>>2];P[b+16>>2]=P[a+16>>2];fa=e+32|0;return 4141}function Po(a,b,c,d,e,f){a=a|0;b=S(b);c=S(c);d=d|0;e=e|0;f=f|0;var g=0,h=0,i=0,j=0,k=0;g=fa-736|0;fa=g;L[g+732>>2]=a;P[g+728>>2]=b;P[g+724>>2]=c;L[g+720>>2]=d;L[g+716>>2]=e;L[g+712>>2]=f;a=L[g+732>>2];L[g+708>>2]=30;d=fa-16|0;L[d+12>>2]=L[g+716>>2];d=L[d+12>>2]+48|0;e=L[d+12>>2];L[g+696>>2]=L[d+8>>2];L[g+700>>2]=e;e=L[d+4>>2];L[g+688>>2]=L[d>>2];L[g+692>>2]=e;P[g+668>>2]=0;P[g+664>>2]=0;P[g+660>>2]=0;d=g+672|0;la(d,g+668|0,g+664|0,g+660|0);P[g+656>>2]=P[g+724>>2]*S(.5);b=P[g+656>>2];e=fa-16|0;L[e+12>>2]=d;P[L[e+12>>2]+(L[g+720>>2]<<2)>>2]=b;P[g+636>>2]=0;P[g+632>>2]=0;P[g+628>>2]=0;d=g+640|0;la(d,g+636|0,g+632|0,g+628|0);b=P[g+728>>2];e=fa-16|0;L[e+12>>2]=d;P[L[e+12>>2]+((L[g+720>>2]+1|0)%3<<2)>>2]=b;P[g+608>>2]=0;P[g+604>>2]=0;P[g+600>>2]=0;d=g+612|0;la(d,g+608|0,g+604|0,g+600|0);b=P[g+728>>2];e=fa-16|0;L[e+12>>2]=d;P[L[e+12>>2]+((L[g+720>>2]+2|0)%3<<2)>>2]=b;P[g+580>>2]=0;P[g+576>>2]=0;P[g+572>>2]=0;d=g+584|0;la(d,g+580|0,g+576|0,g+572|0);b=S(-P[g+656>>2]);e=fa-16|0;L[e+12>>2]=d;P[L[e+12>>2]+(L[g+720>>2]<<2)>>2]=b;L[g+568>>2]=0;while(1){if(L[g+568>>2]<360){b=S(Qa(S(S(L[g+568>>2])*S(.01745329238474369)))*P[g+728>>2]);e=fa-16|0;d=g+584|0;L[e+12>>2]=d;P[L[e+12>>2]+((L[g+720>>2]+1|0)%3<<2)>>2]=b;b=S(Ra(S(S(L[g+568>>2])*S(.01745329238474369)))*P[g+728>>2]);e=fa-16|0;L[e+12>>2]=d;P[L[e+12>>2]+((L[g+720>>2]+2|0)%3<<2)>>2]=b;e=fa-16|0;L[e+12>>2]=L[g+716>>2];f=g+536|0;ua(f,L[e+12>>2],g+672|0);e=g+552|0;h=g+688|0;ta(e,h,f);f=fa-16|0;L[f+12>>2]=L[g+716>>2];i=g+504|0;ua(i,L[f+12>>2],d);d=g+520|0;ta(d,h,i);ha[L[L[a>>2]+8>>2]](a,e,d,L[g+712>>2]);L[g+568>>2]=L[g+708>>2]+L[g+568>>2];continue}break}d=fa-16|0;L[d+12>>2]=L[g+716>>2];f=g+472|0;e=L[d+12>>2];d=g+672|0;ua(f,e,d);h=g+488|0;e=g+688|0;ta(h,e,f);f=fa-16|0;L[f+12>>2]=L[g+716>>2];f=L[f+12>>2];i=g+408|0;Zb(i,d);k=g+424|0;j=i;i=g+640|0;ta(k,j,i);j=g+440|0;ua(j,f,k);f=g+456|0;ta(f,e,j);ha[L[L[a>>2]+8>>2]](a,h,f,L[g+712>>2]);f=fa-16|0;L[f+12>>2]=L[g+716>>2];h=g+376|0;ua(h,L[f+12>>2],d);f=g+392|0;ta(f,e,h);h=fa-16|0;L[h+12>>2]=L[g+716>>2];h=L[h+12>>2];k=g+312|0;Zb(k,d);j=g+328|0;La(j,k,i);i=g+344|0;ua(i,h,j);h=g+360|0;ta(h,e,i);ha[L[L[a>>2]+8>>2]](a,f,h,L[g+712>>2]);f=fa-16|0;L[f+12>>2]=L[g+716>>2];h=g+280|0;ua(h,L[f+12>>2],d);f=g+296|0;ta(f,e,h);h=fa-16|0;L[h+12>>2]=L[g+716>>2];h=L[h+12>>2];i=g+216|0;Zb(i,d);k=g+232|0;j=i;i=g+612|0;ta(k,j,i);j=g+248|0;ua(j,h,k);h=g+264|0;ta(h,e,j);ha[L[L[a>>2]+8>>2]](a,f,h,L[g+712>>2]);f=fa-16|0;L[f+12>>2]=L[g+716>>2];h=g+184|0;ua(h,L[f+12>>2],d);f=g+200|0;ta(f,e,h);h=fa-16|0;L[h+12>>2]=L[g+716>>2];h=L[h+12>>2];k=g+120|0;Zb(k,d);j=g+136|0;La(j,k,i);i=g+152|0;ua(i,h,j);h=g+168|0;ta(h,e,i);ha[L[L[a>>2]+8>>2]](a,f,h,L[g+712>>2]);P[g+100>>2]=0;P[g+96>>2]=0;P[g+92>>2]=0;f=g+104|0;la(f,g+100|0,g+96|0,g+92|0);h=fa-16|0;L[h+12>>2]=f;P[L[h+12>>2]+(L[g+720>>2]<<2)>>2]=1;P[g+72>>2]=0;P[g+68>>2]=0;P[g+64>>2]=0;h=g+76|0;la(h,g+72|0,g+68|0,g- -64|0);i=fa-16|0;L[i+12>>2]=h;P[L[i+12>>2]+((L[g+720>>2]+1|0)%3<<2)>>2]=1;i=fa-16|0;L[i+12>>2]=L[g+716>>2];k=g+32|0;ua(k,L[i+12>>2],d);d=g+48|0;La(d,e,k);e=fa-16|0;L[e+12>>2]=L[g+716>>2];i=g+16|0;ua(i,L[e+12>>2],f);e=fa-16|0;L[e+12>>2]=L[g+716>>2];ua(g,L[e+12>>2],h);b=P[g+728>>2];ha[L[L[a>>2]+60>>2]](a,d,i,g,b,b,S(0),S(6.2831854820251465),L[g+712>>2],0,S(10));fa=g+736|0} -function Sz(a,b,c){a=a|0;b=S(b);c=S(c);var d=0,e=0,f=S(0),g=S(0),h=S(0),i=S(0),j=S(0),k=S(0),l=0,m=0,n=0,o=S(0),p=S(0),q=0,r=S(0),s=S(0),t=S(0),u=0;d=fa-80|0;fa=d;l=a+4|0;n=a+16|0;a:{b:{e=L[a+8>>2];if(!e){e=L[l>>2];if(e){break b}b=S(0);break a}b=P[e+332>>2];h=P[a+172>>2];f=P[a+168>>2];g=P[e+336>>2];i=S(S(b*h)-S(f*g));j=P[e+328>>2];k=P[a+164>>2];f=S(S(j*f)-S(k*b));g=S(S(g*k)-S(h*j));h=P[e+316>>2];j=P[e+312>>2];b=P[e+320>>2];break a}b=P[e+336>>2];h=P[a+172>>2];f=P[a+168>>2];g=P[e+340>>2];i=S(S(b*h)-S(f*g));j=P[e+332>>2];k=P[a+164>>2];f=S(S(j*f)-S(k*b));g=S(S(g*k)-S(h*j));h=P[e+320>>2];j=P[e+316>>2];b=P[e+324>>2]}r=S(b+f);s=S(h+g);t=S(j+i);c:{d:{e=L[a+20>>2];if(!e){e=L[n>>2];if(e){break d}h=S(0);j=S(0);i=S(0);g=S(0);f=S(0);b=S(0);break c}b=P[e+332>>2];h=P[a+188>>2];f=P[a+184>>2];g=P[e+336>>2];i=S(S(b*h)-S(f*g));j=P[e+328>>2];k=P[a+180>>2];f=S(S(j*f)-S(k*b));g=S(S(g*k)-S(h*j));h=P[e+316>>2];j=P[e+312>>2];b=P[e+320>>2];break c}b=P[e+336>>2];h=P[a+188>>2];f=P[a+184>>2];g=P[e+340>>2];i=S(S(b*h)-S(f*g));j=P[e+332>>2];k=P[a+180>>2];f=S(S(j*f)-S(k*b));g=S(S(g*k)-S(h*j));h=P[e+320>>2];j=P[e+316>>2];b=P[e+324>>2]}k=P[a+200>>2];o=P[a+204>>2];p=P[a+196>>2];e=d- -64|0;L[e>>2]=0;L[e+4>>2]=0;L[d+56>>2]=0;L[d+60>>2]=0;J[d+72|0]=1;e=L[a+84>>2];L[d+48>>2]=L[a+80>>2];L[d+52>>2]=e;e=L[a+76>>2];L[d+40>>2]=L[a+72>>2];L[d+44>>2]=e;b=S(r-S(b+f));j=S(t-S(j+i));h=S(s-S(h+g));i=S(S(o*b)+S(S(p*j)+S(k*h)));e:{if(!(i>2];h=P[d+44>>2];i=P[d+40>>2];break e}f=S(o*i);g=f;b=S(b-f);f=P[a+212>>2];b=S(S(g+S(b*f))+P[d+48>>2]);g=S(k*i);h=S(S(g+S(S(h-g)*f))+P[d+44>>2]);i=S(p*i);i=S(P[d+40>>2]+S(i+S(S(j-i)*f)))}e=a+164|0;q=a+180|0;j=P[a+112>>2];k=P[a+108>>2];g=P[a+128>>2];o=P[a+120>>2];p=P[a+124>>2];f=P[a+144>>2];r=P[a+136>>2];s=P[a+140>>2];t=P[a+104>>2];L[d+52>>2]=0;f=S(S(S(f*b)+S(S(r*i)+S(h*s)))*c);P[d+48>>2]=f;g=S(S(S(g*b)+S(S(o*i)+S(h*p)))*c);P[d+44>>2]=g;b=S(S(S(j*b)+S(S(t*i)+S(k*h)))*c);P[d+40>>2]=b;m=L[a+16>>2];a=L[a+4>>2];f:{if((m|0)==(a|0)){if(b!=b|g!=g|(f!=f|P[a+368>>2]>S(_(S(S(f*f)+S(S(b*b)+S(g*g))))))){break f}c=P[a+372>>2];a=L[d+72>>2];L[d+32>>2]=a;L[d+28>>2]=0;L[d+12>>2]=0;i=S(c*S(-0));P[d+24>>2]=i;P[d+20>>2]=i;P[d+16>>2]=i;P[d+8>>2]=c*S(-f);P[d+4>>2]=c*S(-g);P[d>>2]=c*S(-b);if(a&1){qe(l,d,e);a=M[d+32|0]}if(a&2){zc(l,d+16|0,e)}b=P[L[l>>2]+372>>2];a=L[d+52>>2];L[d+8>>2]=L[d+48>>2];L[d+12>>2]=a;a=L[d+60>>2];l=d+16|0;L[l>>2]=L[d+56>>2];L[l+4>>2]=a;L[d+32>>2]=L[d+72>>2];a=d- -64|0;e=L[a+4>>2];L[d+24>>2]=L[a>>2];L[d+28>>2]=e;P[d+8>>2]=b*P[d+8>>2];P[l>>2]=b*P[l>>2];a=L[d+44>>2];L[d>>2]=L[d+40>>2];L[d+4>>2]=a;P[d>>2]=b*P[d>>2];P[d+4>>2]=b*P[d+4>>2];P[d+20>>2]=b*P[d+20>>2];P[d+24>>2]=b*P[d+24>>2];a=M[d+32|0];if(a&1){qe(n,d,q);a=M[d+32|0]}if(!(a&2)){break f}zc(n,l,q);break f}a=L[d+52>>2];L[d+8>>2]=L[d+48>>2];L[d+12>>2]=a;a=L[d+60>>2];m=d+16|0;L[m>>2]=L[d+56>>2];L[m+4>>2]=a;a=d- -64|0;u=L[a+4>>2];L[d+24>>2]=L[a>>2];L[d+28>>2]=u;L[d+32>>2]=L[d+72>>2];P[d+8>>2]=-P[d+8>>2];P[m>>2]=-P[m>>2];a=L[d+44>>2];L[d>>2]=L[d+40>>2];L[d+4>>2]=a;P[d>>2]=-P[d>>2];P[d+4>>2]=-P[d+4>>2];L[d+12>>2]=0;b=P[d+20>>2];c=P[d+24>>2];L[d+28>>2]=0;P[d+24>>2]=-c;P[d+20>>2]=-b;a=M[d+32|0];if(a&1){qe(l,d,e);a=M[d+32|0]}if(a&2){zc(l,m,e)}qe(n,d+40|0,q);if(!(M[d+72|0]&2)){break f}zc(n,d+56|0,q)}fa=d+80|0}function bx(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=S(0),l=0,m=0,n=0,o=0,p=0;j=fa-16|0;fa=j;L[j+12>>2]=a;L[j+8>>2]=b;L[j+4>>2]=c;c=oa(128);o=L[j+12>>2];p=L[j+8>>2];h=L[j+4>>2];b=0;L[c+4>>2]=35;L[c+8>>2]=0;L[c>>2]=14328;L[c+44>>2]=1025758986;L[c+12>>2]=1065353216;L[c+16>>2]=1065353216;J[c+84|0]=0;L[c+68>>2]=-1082130432;L[c+72>>2]=-1082130432;L[c+52>>2]=1065353216;L[c+56>>2]=1065353216;L[c>>2]=14144;L[c+20>>2]=1065353216;L[c+24>>2]=0;L[c+76>>2]=-1082130432;L[c+80>>2]=0;L[c+60>>2]=1065353216;L[c+64>>2]=0;L[c>>2]=15324;L[c+4>>2]=9;J[c+104|0]=1;L[c+100>>2]=0;J[c+124|0]=1;L[c+92>>2]=0;L[c+96>>2]=0;L[c+120>>2]=0;L[c+112>>2]=0;L[c+116>>2]=0;if((h|0)>0){L[8513]=L[8513]+1;a=ha[L[6798]](h<<4,16)|0;d=L[c+92>>2];a:{if((d|0)<=0){break a}if((d|0)!=1){l=d&-2;while(1){e=b<<4;i=e+a|0;f=e+L[c+100>>2]|0;m=L[f+4>>2];L[i>>2]=L[f>>2];L[i+4>>2]=m;m=L[f+12>>2];L[i+8>>2]=L[f+8>>2];L[i+12>>2]=m;f=e|16;e=f+a|0;f=f+L[c+100>>2]|0;i=L[f+4>>2];L[e>>2]=L[f>>2];L[e+4>>2]=i;i=L[f+12>>2];L[e+8>>2]=L[f+8>>2];L[e+12>>2]=i;b=b+2|0;g=g+2|0;if((l|0)!=(g|0)){continue}break}}if(!(d&1)){break a}b=b<<4;d=b+a|0;b=b+L[c+100>>2]|0;g=L[b+4>>2];L[d>>2]=L[b>>2];L[d+4>>2]=g;g=L[b+12>>2];L[d+8>>2]=L[b+8>>2];L[d+12>>2]=g}b=L[c+100>>2];if(!(b?!b|!M[c+104|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[c+100>>2]=a;J[c+104|0]=1;L[c+96>>2]=h;d=L[c+112>>2]}L[c+92>>2]=h;if((d|0)<(h|0)){b:{if((h|0)<=L[c+116>>2]){g=L[c+120>>2];break b}c:{if(!h){g=0;a=d;break c}L[8513]=L[8513]+1;g=ha[L[6798]](h<<2,16)|0;a=L[c+112>>2]}f=L[c+120>>2];d:{e:{if((a|0)>0){i=0;b=0;if(a>>>0>=4){m=a&-4;l=0;while(1){e=b<<2;P[e+g>>2]=P[e+f>>2];n=e|4;P[n+g>>2]=P[f+n>>2];n=e|8;P[n+g>>2]=P[f+n>>2];e=e|12;P[e+g>>2]=P[e+f>>2];b=b+4|0;l=l+4|0;if((m|0)!=(l|0)){continue}break}}a=a&3;if(!a){break e}while(1){e=b<<2;P[e+g>>2]=P[e+f>>2];b=b+1|0;i=i+1|0;if((a|0)!=(i|0)){continue}break}break e}if(f){break e}break d}if(f?M[c+124|0]:0){L[8514]=L[8514]+1;ha[L[6799]](f)}}L[c+120>>2]=g;J[c+124|0]=1;L[c+116>>2]=h}pa((d<<2)+g|0,0,h-d<<2)}L[c+112>>2]=h;f:{if((h|0)<=0){break f}b=0;if((h|0)!=1){f=h&-2;g=0;while(1){a=b<<4;d=a+L[c+100>>2]|0;a=a+o|0;e=L[a+4>>2];L[d>>2]=L[a>>2];L[d+4>>2]=e;e=L[a+12>>2];L[d+8>>2]=L[a+8>>2];L[d+12>>2]=e;a=b<<2;P[a+L[c+120>>2]>>2]=P[a+p>>2];e=b|1;a=e<<4;d=a+L[c+100>>2]|0;a=a+o|0;i=L[a+4>>2];L[d>>2]=L[a>>2];L[d+4>>2]=i;i=L[a+12>>2];L[d+8>>2]=L[a+8>>2];L[d+12>>2]=i;a=e<<2;P[a+L[c+120>>2]>>2]=P[a+p>>2];b=b+2|0;g=g+2|0;if((f|0)!=(g|0)){continue}break}}if(!(h&1)){break f}a=b<<4;d=a+L[c+100>>2]|0;a=a+o|0;h=L[a+4>>2];L[d>>2]=L[a>>2];L[d+4>>2]=h;h=L[a+12>>2];L[d+8>>2]=L[a+8>>2];L[d+12>>2]=h;a=b<<2;P[a+L[c+120>>2]>>2]=P[a+p>>2]}a=fa-96|0;fa=a;J[c+84|0]=1;if(!M[30304]){L[7553]=0;L[7554]=0;L[7552]=1065353216;L[7555]=0;L[7556]=0;L[7558]=0;L[7559]=0;L[7557]=1065353216;L[7560]=0;L[7561]=0;L[7565]=0;L[7566]=0;L[7564]=-1082130432;L[7562]=1065353216;L[7563]=0;L[7567]=0;L[7568]=0;L[7570]=0;L[7571]=0;L[7569]=-1082130432;L[7572]=0;L[7573]=0;L[7574]=-1082130432;L[7575]=0;J[30304]=1}a=pa(a,0,96);ha[L[L[c>>2]+76>>2]](c,30208,a,6);k=P[c+44>>2];P[c+68>>2]=P[a>>2]+k;P[c+52>>2]=P[a+48>>2]-k;P[c+72>>2]=k+P[a+20>>2];P[c+56>>2]=P[a+68>>2]-k;P[c+76>>2]=k+P[a+40>>2];P[c+60>>2]=P[a+88>>2]-k;fa=a+96|0;fa=j+16|0;return c|0}function hr(a,b,c,d,e,f,g,h){a=a|0;b=b|0;c=c|0;d=d|0;e=S(e);f=S(f);g=g|0;h=h|0;var i=0,j=0,k=0,l=S(0),m=0,n=S(0),o=S(0),p=0,q=S(0),r=S(0),s=S(0),t=S(0),u=S(0),v=S(0),w=S(0),x=S(0),y=S(0),z=S(0);j=fa-32|0;fa=j;L[j+28>>2]=a;L[j+24>>2]=b;L[j+20>>2]=c;L[j+16>>2]=d;P[j+12>>2]=e;P[j+8>>2]=f;L[j+4>>2]=g;J[j+3|0]=h;k=L[j+28>>2];c=L[j+24>>2];b=L[j+20>>2];a=L[j+16>>2];n=P[j+12>>2];o=P[j+8>>2];h=J[j+3|0]&1;i=fa-288|0;fa=i;m=L[j+4>>2];l=P[m+16>>2];f=P[m+20>>2];e=P[m+12>>2];g=L[m+4>>2];d=L[m>>2];P[i+228>>2]=P[m+8>>2];L[i+220>>2]=d;L[i+224>>2]=g;P[i+216>>2]=o;P[i+212>>2]=e;P[i+208>>2]=n;d=L[c+12>>2];L[i+168>>2]=L[c+8>>2];L[i+172>>2]=d;d=L[c+4>>2];L[i+160>>2]=L[c>>2];L[i+164>>2]=d;c=L[b+12>>2];L[i+184>>2]=L[b+8>>2];L[i+188>>2]=c;c=L[b+4>>2];L[i+176>>2]=L[b>>2];L[i+180>>2]=c;b=L[a+12>>2];L[i+200>>2]=L[a+8>>2];L[i+204>>2]=b;b=L[a+4>>2];L[i+192>>2]=L[a>>2];L[i+196>>2]=b;J[i+264|0]=h;P[i+252>>2]=f;L[i+248>>2]=1036831949;L[i+240>>2]=0;L[i+244>>2]=0;P[i+232>>2]=l;L[i+256>>2]=0;L[i+260>>2]=0;L[i+236>>2]=0;b=i+4|0;m=0;g=L[k+136>>2];a:{if((g|0)!=L[k+140>>2]){break a}h=g?g<<1:1;if((h|0)<=(g|0)){break a}if(h){L[8513]=L[8513]+1;m=ha[L[6798]](R(h,284),16)|0;g=L[k+136>>2]}if((g|0)>0){while(1){c=R(p,284);a=c+L[k+144>>2]|0;d=qa(c+m|0,a,92);c=L[a+104>>2];L[d+100>>2]=L[a+100>>2];L[d+104>>2]=c;c=L[a+96>>2];L[d+92>>2]=L[a+92>>2];L[d+96>>2]=c;c=L[a+120>>2];L[d+116>>2]=L[a+116>>2];L[d+120>>2]=c;c=L[a+112>>2];L[d+108>>2]=L[a+108>>2];L[d+112>>2]=c;c=L[a+136>>2];L[d+132>>2]=L[a+132>>2];L[d+136>>2]=c;c=L[a+128>>2];L[d+124>>2]=L[a+124>>2];L[d+128>>2]=c;c=L[a+144>>2];L[d+140>>2]=L[a+140>>2];L[d+144>>2]=c;c=L[a+152>>2];L[d+148>>2]=L[a+148>>2];L[d+152>>2]=c;qa(d+156|0,a+156|0,128);p=p+1|0;if((p|0)!=(g|0)){continue}break}}a=L[k+144>>2];if(!(a?!a|!M[k+148|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](a)}L[k+144>>2]=m;J[k+148|0]=1;L[k+140>>2]=h;g=L[k+136>>2]}c=qa(L[k+144>>2]+R(g,284)|0,b,92);a=L[b+104>>2];L[c+100>>2]=L[b+100>>2];L[c+104>>2]=a;a=L[b+96>>2];L[c+92>>2]=L[b+92>>2];L[c+96>>2]=a;a=L[b+120>>2];L[c+116>>2]=L[b+116>>2];L[c+120>>2]=a;a=L[b+112>>2];L[c+108>>2]=L[b+108>>2];L[c+112>>2]=a;a=L[b+128>>2];L[c+124>>2]=L[b+124>>2];L[c+128>>2]=a;a=L[b+136>>2];L[c+132>>2]=L[b+132>>2];L[c+136>>2]=a;a=L[b+152>>2];L[c+148>>2]=L[b+148>>2];L[c+152>>2]=a;a=L[b+144>>2];L[c+140>>2]=L[b+140>>2];L[c+144>>2]=a;qa(c+156|0,b+156|0,128);L[k+136>>2]=L[k+136>>2]+1;b=(L[k+144>>2]+R(L[k+136>>2],284)|0)-284|0;J[b+84|0]=0;a=L[k+116>>2];l=P[a+52>>2];q=P[a+12>>2];r=P[a+8>>2];f=P[a+56>>2];s=P[a+28>>2];t=P[a+20>>2];u=P[a+24>>2];e=P[a+60>>2];v=P[a+44>>2];w=P[a+36>>2];x=P[a+40>>2];y=P[a+4>>2];L[b+48>>2]=0;z=e;n=P[b+164>>2];o=P[b+156>>2];e=P[b+160>>2];P[b+44>>2]=z+S(S(v*n)+S(S(w*o)+S(x*e)));P[b+40>>2]=f+S(S(n*s)+S(S(o*t)+S(u*e)));P[b+36>>2]=l+S(S(n*q)+S(S(o*y)+S(r*e)));L[b- -64>>2]=0;l=P[b+180>>2];f=P[b+172>>2];e=P[b+176>>2];P[b+60>>2]=S(v*l)+S(S(w*f)+S(x*e));P[b+56>>2]=S(s*l)+S(S(t*f)+S(u*e));P[b+52>>2]=S(q*l)+S(S(y*f)+S(r*e));l=P[b+196>>2];f=P[b+188>>2];e=P[b+192>>2];L[b+80>>2]=0;P[b+76>>2]=S(v*l)+S(S(w*f)+S(x*e));P[b+72>>2]=S(s*l)+S(S(t*f)+S(u*e));P[b+68>>2]=S(q*l)+S(S(y*f)+S(r*e));mg(k,L[k+136>>2]-1|0,0);fa=i+288|0;fa=j+32|0;return b|0}function Pn(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0;f=L[a+108>>2];if(f){ha[L[L[f>>2]+12>>2]](f,L[b+60>>2],c)}k=N[b+12>>1];b=a;i=L[a+60>>2];a=L[a+92>>2];if(!(ha[L[L[a>>2]+56>>2]](a)|0)){a=L[b+92>>2];ha[L[L[a>>2]+16>>2]](a,i+(k<<6)|0,c)}g=N[b+56>>1];f=L[b+60>>2];K[f+54>>1]=N[f+54>>1]-2;K[f+56>>1]=N[f+56>>1]-2;K[f+58>>1]=N[f+58>>1]-2;c=L[b+68>>2];j=i+(k<<6)|0;h=N[j+54>>1]<<2;a=c+h|0;e=N[b+6>>1];K[a>>1]=e;d=N[a+6>>1];if(d){h=f+(N[(c+h|0)+2>>1]<<6)|0;while(1){l=e&65535;f=a+4|0;e=N[f>>1];if(l>>>0>=e>>>0){d=(L[b+60>>2]+(d<<6)|0)+(e&1?54:48)|0;K[d>>1]=N[d>>1]-1;K[h+54>>1]=N[h+54>>1]+1;d=N[a+4>>1]|N[a+6>>1]<<16;e=N[a>>1]|N[a+2>>1]<<16;K[a+4>>1]=e;K[a+6>>1]=e>>>16;K[a>>1]=d;K[a+2>>1]=d>>>16;d=a;a=f;d=N[d+10>>1];if(d){continue}}break}e=N[b+6>>1];a=L[b+68>>2]}else{a=c}h=N[j+48>>1];d=h<<2;K[d+c>>1]=e;f=a;a=d+a|0;d=N[a+6>>1];if(d){h=L[b+60>>2]+(N[(f+(h<<2)|0)+2>>1]<<6)|0;e=N[a>>1];while(1){j=e&65535;f=a+4|0;e=N[f>>1];if(j>>>0>=e>>>0){d=(L[b+60>>2]+(d<<6)|0)+(e&1?54:48)|0;K[d>>1]=N[d>>1]-1;K[h+48>>1]=N[h+48>>1]+1;d=N[a+4>>1]|N[a+6>>1]<<16;e=N[a>>1]|N[a+2>>1]<<16;K[a+4>>1]=e;K[a+6>>1]=e>>>16;K[a>>1]=d;K[a+2>>1]=d>>>16;d=a;a=f;d=N[d+10>>1];if(d){continue}}break}e=N[b+6>>1]}h=(g<<1)-1|0;a=c+(h<<2)|0;K[a>>1]=e;K[a+2>>1]=0;c=L[b+72>>2];j=i+(k<<6)|0;f=N[j+56>>1]<<2;a=c+f|0;K[a>>1]=e;d=N[a+6>>1];if(d){g=L[b+60>>2]+(N[(c+f|0)+2>>1]<<6)|0;while(1){l=e&65535;f=a+4|0;e=N[f>>1];if(l>>>0>=e>>>0){d=(L[b+60>>2]+(d<<6)|0)+(e&1?54:48)|0;K[d+2>>1]=N[d+2>>1]-1;K[g+56>>1]=N[g+56>>1]+1;d=N[a+4>>1]|N[a+6>>1]<<16;e=N[a>>1]|N[a+2>>1]<<16;K[a+4>>1]=e;K[a+6>>1]=e>>>16;K[a>>1]=d;K[a+2>>1]=d>>>16;d=a;a=f;d=N[d+10>>1];if(d){continue}}break}e=N[b+6>>1];a=L[b+72>>2]}else{a=c}g=N[j+50>>1];d=g<<2;K[d+c>>1]=e;f=a;a=d+a|0;d=N[a+6>>1];if(d){g=L[b+60>>2]+(N[(f+(g<<2)|0)+2>>1]<<6)|0;e=N[a>>1];while(1){j=e&65535;f=a+4|0;e=N[f>>1];if(j>>>0>=e>>>0){d=(L[b+60>>2]+(d<<6)|0)+(e&1?54:48)|0;K[d+2>>1]=N[d+2>>1]-1;K[g+50>>1]=N[g+50>>1]+1;d=N[a+4>>1]|N[a+6>>1]<<16;e=N[a>>1]|N[a+2>>1]<<16;K[a+4>>1]=e;K[a+6>>1]=e>>>16;K[a>>1]=d;K[a+2>>1]=d>>>16;d=a;a=f;d=N[d+10>>1];if(d){continue}}break}e=N[b+6>>1]}a=c+(h<<2)|0;K[a>>1]=e;K[a+2>>1]=0;c=L[b+76>>2];g=i+(k<<6)|0;f=N[g+58>>1]<<2;a=c+f|0;K[a>>1]=e;d=N[a+6>>1];if(d){i=L[b+60>>2]+(N[(c+f|0)+2>>1]<<6)|0;while(1){j=e&65535;f=a+4|0;e=N[f>>1];if(j>>>0>=e>>>0){d=(L[b+60>>2]+(d<<6)|0)+(e&1?54:48)|0;K[d+4>>1]=N[d+4>>1]-1;K[i+58>>1]=N[i+58>>1]+1;d=N[a+4>>1]|N[a+6>>1]<<16;e=N[a>>1]|N[a+2>>1]<<16;K[a+4>>1]=e;K[a+6>>1]=e>>>16;K[a>>1]=d;K[a+2>>1]=d>>>16;d=a;a=f;d=N[d+10>>1];if(d){continue}}break}e=N[b+6>>1];a=L[b+76>>2]}else{a=c}i=N[g+52>>1];d=i<<2;K[d+c>>1]=e;f=a;a=d+a|0;d=N[a+6>>1];if(d){i=L[b+60>>2]+(N[(f+(i<<2)|0)+2>>1]<<6)|0;e=N[a>>1];while(1){g=e&65535;f=a+4|0;e=N[f>>1];if(g>>>0>=e>>>0){d=(L[b+60>>2]+(d<<6)|0)+(e&1?54:48)|0;K[d+4>>1]=N[d+4>>1]-1;K[i+52>>1]=N[i+52>>1]+1;d=N[a+4>>1]|N[a+6>>1]<<16;e=N[a>>1]|N[a+2>>1]<<16;K[a+4>>1]=e;K[a+6>>1]=e>>>16;K[a>>1]=d;K[a+2>>1]=d>>>16;d=a;a=f;d=N[d+10>>1];if(d){continue}}break}e=N[b+6>>1]}a=c+(h<<2)|0;K[a>>1]=e;K[a+2>>1]=0;K[(L[b+60>>2]+(k<<6)|0)+48>>1]=N[b+64>>1];K[b+64>>1]=k;K[b+56>>1]=N[b+56>>1]-1}function Fz(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=S(0);d=fa-384|0;fa=d;g=L[b+36>>2];b=d+328|0;L[b+4>>2]=35;L[b+8>>2]=0;L[b>>2]=14328;L[b+44>>2]=1025758986;L[b+12>>2]=1065353216;L[b+16>>2]=1065353216;L[b>>2]=14044;L[b+20>>2]=1065353216;L[b+24>>2]=0;L[b+52>>2]=g;L[b>>2]=21628;L[b+44>>2]=0;c=L[a+28>>2];l=L[c+4>>2];a:{if(M[g+376|0]?M[L[c+8>>2]+204|0]&3:0){break a}if(!(J[30088]&1)){if(!(J[30140]&1)){L[7524]=0;L[7525]=0;L[7523]=1065353216;J[30140]=1;L[7526]=0;L[7527]=0;L[7529]=0;L[7530]=0;L[7528]=1065353216;L[7531]=0;L[7532]=0;L[7533]=1065353216;L[7534]=0}L[7518]=0;L[7519]=0;J[30088]=1;c=L[7532];L[7514]=L[7531];L[7515]=c;c=L[7524];L[7506]=L[7523];L[7507]=c;c=L[7528];L[7510]=L[7527];L[7511]=c;L[7520]=0;L[7521]=0;c=L[7534];L[7516]=L[7533];L[7517]=c;c=L[7526];L[7508]=L[7525];L[7509]=c;c=L[7530];L[7512]=L[7529];L[7513]=c;c=L[a+28>>2]}c=L[c+12>>2];L[d+64>>2]=0;L[d+68>>2]=0;L[d+56>>2]=1065353216;L[d+60>>2]=0;if(!Gl(b,l,c,d+56|0,d+272|0)){break a}L[d+76>>2]=0;L[d+80>>2]=0;L[d+68>>2]=0;L[d+72>>2]=0;L[d+60>>2]=0;L[d+64>>2]=0;J[d+208|0]=0;L[d+48>>2]=0;L[d+52>>2]=0;L[d+44>>2]=g;L[d+56>>2]=21160;c=L[L[a+28>>2]+8>>2];L[d+40>>2]=c;L[d+32>>2]=0;b=L[c+236>>2];L[d+24>>2]=0;L[d+8>>2]=c;L[d+36>>2]=c&b<<30>>31;b=L[d+48>>2];L[d+16>>2]=L[d+44>>2];L[d+20>>2]=b;b=L[d+36>>2];L[d>>2]=L[d+32>>2];L[d+4>>2]=b;if(!nk(a,d+272|0,d+16|0,d,d+56|0)){break a}L[8513]=L[8513]+1;b=ha[L[6798]](216,16)|0;c=pa(b+4|0,0,212);L[b>>2]=21160;qa(c,d+60|0,100);c=L[d+172>>2];L[b+112>>2]=L[d+168>>2];L[b+116>>2]=c;c=L[d+164>>2];L[b+104>>2]=L[d+160>>2];L[b+108>>2]=c;c=L[d+188>>2];L[b+128>>2]=L[d+184>>2];L[b+132>>2]=c;c=L[d+180>>2];L[b+120>>2]=L[d+176>>2];L[b+124>>2]=c;c=L[d+196>>2];L[b+136>>2]=L[d+192>>2];L[b+140>>2]=c;c=L[d+204>>2];L[b+144>>2]=L[d+200>>2];L[b+148>>2]=c;J[b+152|0]=M[d+208|0];L[b+212>>2]=L[d+268>>2];c=L[d+264>>2];L[b+204>>2]=L[d+260>>2];L[b+208>>2]=c;c=L[d+256>>2];L[b+196>>2]=L[d+252>>2];L[b+200>>2]=c;c=L[d+248>>2];L[b+188>>2]=L[d+244>>2];L[b+192>>2]=c;c=L[d+240>>2];L[b+180>>2]=L[d+236>>2];L[b+184>>2]=c;c=L[d+232>>2];L[b+172>>2]=L[d+228>>2];L[b+176>>2]=c;c=L[d+224>>2];L[b+164>>2]=L[d+220>>2];L[b+168>>2]=c;c=L[d+216>>2];L[b+156>>2]=L[d+212>>2];L[b+160>>2]=c;e=L[a+24>>2];f=L[e+852>>2];b:{if((f|0)!=L[e+856>>2]){break b}g=f?f<<1:1;if((g|0)<=(f|0)){break b}if(g){L[8513]=L[8513]+1;h=ha[L[6798]](g<<2,16)|0;f=L[e+852>>2]}c:{if((f|0)<=0){break c}if(f>>>0>=4){l=f&-4;while(1){j=i<<2;L[j+h>>2]=L[j+L[e+860>>2]>>2];c=j|4;L[c+h>>2]=L[c+L[e+860>>2]>>2];c=j|8;L[c+h>>2]=L[c+L[e+860>>2]>>2];c=j|12;L[c+h>>2]=L[c+L[e+860>>2]>>2];i=i+4|0;k=k+4|0;if((l|0)!=(k|0)){continue}break}}k=f&3;if(!k){break c}while(1){c=i<<2;L[c+h>>2]=L[c+L[e+860>>2]>>2];i=i+1|0;m=m+1|0;if((k|0)!=(m|0)){continue}break}}c=L[e+860>>2];if(!(!c|!M[e+864|0])){if(c){L[8514]=L[8514]+1;ha[L[6799]](c)}f=L[e+852>>2]}L[e+860>>2]=h;J[e+864|0]=1;L[e+856>>2]=g}L[L[e+860>>2]+(f<<2)>>2]=b;L[e+852>>2]=f+1;n=P[b+64>>2];c=L[a+24>>2];d:{if(M[L[L[a+28>>2]+8>>2]+204|0]&3){P[b+64>>2]=P[c+344>>2]*n;a=c+356|0;break d}P[b+64>>2]=P[c+340>>2]*n;a=c+352|0}P[b+68>>2]=P[a>>2]*P[b+68>>2]}fa=d+384|0}function Ab(a,b,c,d,e,f){var g=0,h=0,i=S(0),j=0,k=S(0),l=S(0),m=S(0),n=S(0),o=S(0),p=S(0),q=S(0),r=0,s=0,t=S(0),u=0;g=fa-400|0;fa=g;wa(2434);h=L[c+12>>2];L[g+344>>2]=L[c+8>>2];L[g+348>>2]=h;h=L[c+4>>2];L[g+336>>2]=L[c>>2];L[g+340>>2]=h;h=L[c+28>>2];L[g+360>>2]=L[c+24>>2];L[g+364>>2]=h;h=L[c+20>>2];L[g+352>>2]=L[c+16>>2];L[g+356>>2]=h;h=L[c+44>>2];L[g+376>>2]=L[c+40>>2];L[g+380>>2]=h;h=L[c+36>>2];L[g+368>>2]=L[c+32>>2];L[g+372>>2]=h;h=L[c+60>>2];L[g+392>>2]=L[c+56>>2];L[g+396>>2]=h;h=L[c+52>>2];L[g+384>>2]=L[c+48>>2];L[g+388>>2]=h;h=L[d+12>>2];L[g+280>>2]=L[d+8>>2];L[g+284>>2]=h;h=L[d+4>>2];L[g+272>>2]=L[d>>2];L[g+276>>2]=h;h=L[d+28>>2];L[g+296>>2]=L[d+24>>2];L[g+300>>2]=h;h=L[d+20>>2];L[g+288>>2]=L[d+16>>2];L[g+292>>2]=h;h=L[d+44>>2];L[g+312>>2]=L[d+40>>2];L[g+316>>2]=h;h=L[d+36>>2];L[g+304>>2]=L[d+32>>2];L[g+308>>2]=h;h=L[d+60>>2];L[g+328>>2]=L[d+56>>2];L[g+332>>2]=h;h=L[d+52>>2];L[g+320>>2]=L[d+48>>2];L[g+324>>2]=h;r=g+336|0;s=g+12|0;h=g+256|0;ec(r,g+272|0,s,h);L[g+236>>2]=0;i=P[g+256>>2];P[g+232>>2]=i*P[g+20>>2];P[g+228>>2]=i*P[g+16>>2];P[g+224>>2]=i*P[g+12>>2];L[g+216>>2]=0;L[g+220>>2]=0;L[g+208>>2]=0;L[g+212>>2]=0;L[g+68>>2]=0;L[g+72>>2]=0;L[g+60>>2]=0;L[g+64>>2]=0;Ma(r,h);L[g+56>>2]=0;L[g+40>>2]=0;k=P[g+268>>2];m=P[g+264>>2];i=P[g+256>>2];l=P[g+260>>2];o=S(S(2)/S(S(k*k)+S(S(m*m)+S(S(i*i)+S(l*l)))));q=S(m*o);n=S(l*q);p=S(i*o);t=S(k*p);P[g+48>>2]=n+t;P[g+36>>2]=n-t;n=S(i*p);p=l;l=S(l*o);o=S(p*l);P[g+52>>2]=S(1)-S(n+o);m=S(m*q);P[g+32>>2]=S(1)-S(n+m);L[g+24>>2]=0;n=S(i*q);p=S(k*l);P[g+44>>2]=n-p;i=S(i*l);k=S(k*q);P[g+28>>2]=i+k;P[g+20>>2]=n+p;P[g+16>>2]=i-k;P[g+12>>2]=S(1)-S(o+m);r=g+240|0;xm(b,s,g+208|0,g+224|0,h,r);L[g+12>>2]=8404;j=L[c+12>>2];L[g+56>>2]=L[c+8>>2];L[g+60>>2]=j;j=L[c+4>>2];L[g+48>>2]=L[c>>2];L[g+52>>2]=j;j=L[c+28>>2];L[g+72>>2]=L[c+24>>2];L[g+76>>2]=j;u=L[c+20>>2];j=g- -64|0;L[j>>2]=L[c+16>>2];L[j+4>>2]=u;j=L[c+44>>2];L[g+88>>2]=L[c+40>>2];L[g+92>>2]=j;j=L[c+36>>2];L[g+80>>2]=L[c+32>>2];L[g+84>>2]=j;j=L[c+60>>2];L[g+104>>2]=L[c+56>>2];L[g+108>>2]=j;j=L[c+52>>2];L[g+96>>2]=L[c+48>>2];L[g+100>>2]=j;c=L[d+12>>2];L[g+120>>2]=L[d+8>>2];L[g+124>>2]=c;c=L[d+4>>2];L[g+112>>2]=L[d>>2];L[g+116>>2]=c;c=L[d+28>>2];L[g+136>>2]=L[d+24>>2];L[g+140>>2]=c;c=L[d+20>>2];L[g+128>>2]=L[d+16>>2];L[g+132>>2]=c;c=L[d+36>>2];L[g+144>>2]=L[d+32>>2];L[g+148>>2]=c;c=L[d+44>>2];L[g+152>>2]=L[d+40>>2];L[g+156>>2]=c;c=L[d+60>>2];L[g+168>>2]=L[d+56>>2];L[g+172>>2]=c;c=L[d+52>>2];L[g+160>>2]=L[d+48>>2];L[g+164>>2]=c;L[g+196>>2]=e;P[g+200>>2]=f;L[g+204>>2]=b;L[g+192>>2]=a;f=S(P[g+168>>2]-P[g+104>>2]);i=S(P[g+160>>2]-P[g+96>>2]);k=S(P[g+164>>2]-P[g+100>>2]);l=S(S(1)/S(_(S(S(f*f)+S(S(i*i)+S(k*k))))));m=S(f*l);q=m==S(0)?S(0xde0b6b000000000):S(S(1)/m);P[g+24>>2]=q;o=S(k*l);n=o==S(0)?S(0xde0b6b000000000):S(S(1)/o);P[g+20>>2]=n;L[g+40>>2]=q>2]=n>2]=p+S(S(f*i)+S(k*o));f=f==S(0)?S(0xde0b6b000000000):S(S(1)/f);P[g+16>>2]=f;L[g+32>>2]=f>2];ha[L[L[a>>2]+24>>2]](a,g+384|0,g+320|0,s,h,r);va();fa=g+400|0}function RB(a){a=a|0;var b=S(0),c=S(0),d=0,e=0,f=S(0),g=S(0),h=0,i=S(0),j=S(0),k=0,l=S(0),m=S(0),n=S(0),o=S(0),p=S(0),q=S(0),r=S(0),s=0,t=0,u=0,v=S(0),w=S(0),x=S(0),y=S(0),z=S(0),A=S(0),B=S(0),C=S(0),D=S(0),E=S(0),F=S(0),G=S(0),H=S(0),I=S(0),J=S(0),K=S(0),N=S(0),O=S(0),Q=S(0),U=S(0),V=S(0),W=S(0),X=S(0),Y=S(0),Z=0;k=fa-48|0;fa=k;if(M[a+527|0]){L[a+36>>2]=0;L[a+576>>2]=0;L[a+580>>2]=0;L[a+516>>2]=0;L[a+520>>2]=0;L[a+584>>2]=0;L[a+588>>2]=0;if(!M[a+524|0]){c=P[a+420>>2];d=L[a+32>>2];b=P[a+412>>2];g=P[a+416>>2];x=S(S(S(c*P[d+44>>2])+S(S(b*P[d+36>>2])+S(g*P[d+40>>2])))+P[d+60>>2]);i=P[a+356>>2];e=L[a+28>>2];f=P[a+348>>2];j=P[a+352>>2];y=S(S(S(i*P[e+44>>2])+S(S(f*P[e+36>>2])+S(j*P[e+40>>2])))+P[e+60>>2]);l=S(x-y);z=S(S(S(c*P[d+12>>2])+S(S(b*P[d+4>>2])+S(g*P[d+8>>2])))+P[d+52>>2]);A=S(S(S(i*P[e+12>>2])+S(S(f*P[e+4>>2])+S(j*P[e+8>>2])))+P[e+52>>2]);m=S(z-A);B=S(S(S(c*P[d+28>>2])+S(S(b*P[d+20>>2])+S(g*P[d+24>>2])))+P[d+56>>2]);C=S(S(S(i*P[e+28>>2])+S(S(f*P[e+20>>2])+S(j*P[e+24>>2])))+P[e+56>>2]);b=S(B-C);c=S(S(l*l)+S(S(m*m)+S(b*b)));a:{if(c>S(1.1920928955078125e-7)){g=S(S(1)/S(_(c)));c=S(l*g);P[k+8>>2]=c;b=S(b*g);P[k+4>>2]=b;g=S(m*g);P[k>>2]=g;break a}L[k+8>>2]=0;L[k>>2]=1065353216;L[k+4>>2]=0;g=S(1);b=S(0);c=S(0)}L[k+12>>2]=0;b:{if(S(T(c))>S(.7071067690849304)){f=S(S(b*b)+S(c*c));i=S(S(1)/S(_(f)));f=S(f*i);j=S(i*S(-c));l=S(j*g);c=S(b*i);b=S(c*S(-g));m=S(0);break b}f=S(S(g*g)+S(b*b));i=S(S(1)/S(_(f)));l=S(f*i);m=S(i*S(-b));b=S(c*m);j=S(g*i);f=S(j*S(-c));c=S(0)}P[k+40>>2]=l;P[k+36>>2]=b;P[k+20>>2]=j;P[k+32>>2]=f;P[k+24>>2]=c;P[k+16>>2]=m;while(1){F=P[d+344>>2];G=P[e+344>>2];o=P[e+36>>2];p=P[e+4>>2];q=P[e+20>>2];r=P[e+40>>2];H=P[e+8>>2];I=P[e+24>>2];n=P[e+44>>2];J=P[e+12>>2];K=P[e+56>>2];N=P[e+28>>2];O=P[e+60>>2];Q=P[e+52>>2];U=P[d+36>>2];V=P[d+4>>2];W=P[d+20>>2];m=P[d+40>>2];X=P[d+8>>2];Y=P[d+24>>2];c=P[d+44>>2];g=P[d+12>>2];b=P[d+56>>2];j=P[d+28>>2];i=P[d+52>>2];f=P[d+60>>2];t=(s<<4)+k|0;Z=L[t+4>>2];h=R(s,84)+a|0;u=h+48|0;L[u>>2]=L[t>>2];L[u+4>>2]=Z;u=L[t+12>>2];L[h+56>>2]=L[t+8>>2];L[h+60>>2]=u;L[h+92>>2]=0;L[h+76>>2]=0;v=c;l=S(B-b);c=P[h+48>>2];D=S(z-i);b=P[h+52>>2];i=S(S(l*c)-S(D*b));w=g;E=S(x-f);g=P[h+56>>2];f=S(S(E*b)-S(l*g));l=j;j=S(S(D*g)-S(E*c));l=S(S(v*i)+S(S(w*f)+S(l*j)));P[h+88>>2]=l;m=S(S(m*i)+S(S(X*f)+S(Y*j)));P[h+84>>2]=m;i=S(S(U*i)+S(S(V*f)+S(W*j)));P[h+80>>2]=i;v=n;j=S(A-Q);n=S(C-K);f=S(S(b*j)-S(c*n));w=S(n*g);n=S(y-O);b=S(w-S(b*n));c=S(S(n*c)-S(g*j));g=S(S(v*f)+S(S(J*b)+S(N*c)));P[h+72>>2]=g;j=S(S(r*f)+S(S(H*b)+S(I*c)));P[h+68>>2]=j;c=S(S(o*f)+S(S(p*b)+S(q*c)));P[h- -64>>2]=c;b=P[e+404>>2];f=P[e+400>>2];o=P[e+396>>2];L[h+108>>2]=0;o=S(c*o);P[h+96>>2]=o;f=S(j*f);P[h+100>>2]=f;b=S(g*b);P[h+104>>2]=b;p=P[d+404>>2];q=P[d+400>>2];r=P[d+396>>2];L[h+124>>2]=0;r=S(i*r);P[h+112>>2]=r;q=S(m*q);P[h+116>>2]=q;p=S(l*p);P[h+120>>2]=p;P[h+128>>2]=S(F+S(G+S(S(b*g)+S(S(o*c)+S(j*f)))))+S(S(p*l)+S(S(r*i)+S(m*q)));s=s+1|0;if((s|0)!=3){continue}break}}e=a;d=L[a+28>>2];a=L[a+32>>2];wg(e,d+4|0,a+4|0,d+264|0,a+264|0)}fa=k+48|0}function Ak(a){a=a|0;var b=0,c=0;L[a>>2]=20992;b=L[a+192>>2];if(b){ha[L[L[b>>2]+4>>2]](b)}if(L[a+1112>>2]>0){while(1){kg(a,0);if(L[a+1112>>2]>0){continue}break}}if(L[a+872>>2]>0){b=0;while(1){c=L[L[a+880>>2]+(b<<2)>>2];if(c){L[8514]=L[8514]+1;ha[L[6799]](c)}b=b+1|0;if((b|0)>2]){continue}break}}if(L[a+852>>2]>0){b=0;while(1){c=L[L[a+860>>2]+(b<<2)>>2];if(c){L[8514]=L[8514]+1;ha[L[6799]](c)}b=b+1|0;if((b|0)>2]){continue}break}}b=L[a+1244>>2];if(!(b?!b|!M[a+1248|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+1244>>2]=0;J[a+1248|0]=1;b=a+1236|0;L[b>>2]=0;L[b+4>>2]=0;b=L[a+1140>>2];if(!(b?!b|!M[a+1144|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+1140>>2]=0;J[a+1144|0]=1;b=a+1132|0;L[b>>2]=0;L[b+4>>2]=0;b=L[a+1120>>2];if(!(b?!b|!M[a+1124|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+1120>>2]=0;J[a+1124|0]=1;L[a+1112>>2]=0;L[a+1116>>2]=0;gc(a+1048|0);gc(a+988|0);gc(a+928|0);b=L[a+880>>2];if(!(b?!b|!M[a+884|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+880>>2]=0;J[a+884|0]=1;L[a+872>>2]=0;L[a+876>>2]=0;b=L[a+860>>2];if(!(b?!b|!M[a+864|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+860>>2]=0;J[a+864|0]=1;L[a+852>>2]=0;L[a+856>>2]=0;b=L[a+840>>2];if(!(b?!b|!M[a+844|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+840>>2]=0;J[a+844|0]=1;L[a+832>>2]=0;L[a+836>>2]=0;b=L[a+820>>2];if(!(b?!b|!M[a+824|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+820>>2]=0;J[a+824|0]=1;L[a+812>>2]=0;L[a+816>>2]=0;b=L[a+800>>2];if(!(b?!b|!M[a+804|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+800>>2]=0;J[a+804|0]=1;L[a+792>>2]=0;L[a+796>>2]=0;b=L[a+780>>2];if(!(b?!b|!M[a+784|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+780>>2]=0;J[a+784|0]=1;L[a+772>>2]=0;L[a+776>>2]=0;b=L[a+760>>2];if(!(b?!b|!M[a+764|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+760>>2]=0;J[a+764|0]=1;L[a+752>>2]=0;L[a+756>>2]=0;b=L[a+740>>2];if(!(b?!b|!M[a+744|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+740>>2]=0;J[a+744|0]=1;L[a+732>>2]=0;L[a+736>>2]=0;b=L[a+720>>2];if(!(b?!b|!M[a+724|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+720>>2]=0;J[a+724|0]=1;L[a+712>>2]=0;L[a+716>>2]=0;b=L[a+700>>2];if(!(b?!b|!M[a+704|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+700>>2]=0;J[a+704|0]=1;L[a+692>>2]=0;L[a+696>>2]=0;b=L[a+512>>2];if(!(b?!b|!M[a+516|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+512>>2]=0;J[a+516|0]=1;L[a+504>>2]=0;L[a+508>>2]=0;b=L[a+492>>2];if(!(b?!b|!M[a+496|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+492>>2]=0;J[a+496|0]=1;L[a+484>>2]=0;L[a+488>>2]=0;b=L[a+444>>2];if(!(b?!b|!M[a+448|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+444>>2]=0;J[a+448|0]=1;L[a+436>>2]=0;L[a+440>>2]=0;b=L[a+424>>2];if(!(b?!b|!M[a+428|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+424>>2]=0;J[a+428|0]=1;L[a+416>>2]=0;L[a+420>>2]=0;b=L[a+404>>2];if(!(b?!b|!M[a+408|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+404>>2]=0;J[a+408|0]=1;L[a+396>>2]=0;L[a+400>>2]=0;b=L[a+276>>2];if(!(b?!b|!M[a+280|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+276>>2]=0;J[a+280|0]=1;L[a+268>>2]=0;L[a+272>>2]=0;L[a>>2]=6712;return a|0}function Ce(a,b,c,d,e,f,g,h,i,j,k,l,m){var n=S(0),o=S(0),p=S(0),q=S(0),r=S(0),s=S(0),t=0,u=S(0),v=S(0),w=0,x=S(0),y=S(0),z=0,A=0,B=S(0),C=S(0),D=S(0),E=S(0),F=0,G=0,H=0,I=0,J=S(0),K=S(0),N=S(0),O=S(0),Q=S(0),T=S(0),U=0;z=L[i+24>>2];G=M[b+44|0];F=L[b+56>>2];a:{if(!(G|F)){break a}t=L[(l?20:16)+i>>2];w=L[(l?12:8)+i>>2];j=R(j,z);A=j<<2;P[w+A>>2]=P[k>>2];z=j+1|0;H=z<<2;P[H+w>>2]=P[k+4>>2];U=w;w=j+2|0;I=w<<2;P[U+I>>2]=P[k+8>>2];P[t+A>>2]=-P[k>>2];P[t+H>>2]=-P[k+4>>2];P[t+I>>2]=-P[k+8>>2];if(!l){r=P[a+1184>>2];s=P[a+1180>>2];u=P[a+1176>>2];n=P[k+4>>2];b:{if(M[a+1301|0]){B=S(P[a+1120>>2]-P[c+56>>2]);p=P[k+8>>2];v=S(P[a+1112>>2]-P[c+48>>2]);q=P[k>>2];C=S(P[a+1116>>2]-P[c+52>>2]);o=S(S(B*p)+S(S(v*q)+S(n*C)));D=S(q*o);x=S(P[b+52>>2]-P[b+48>>2]);J=S(r-P[d+56>>2]);K=S(u-P[d+48>>2]);N=S(s-P[d+52>>2]);u=S(S(J*p)+S(S(q*K)+S(N*n)));O=S(q*u);y=S(S(D+S(q*x))-O);s=S(n*o);Q=S(n*u);E=S(S(s+S(n*x))-Q);r=P[a+1272>>2];D=S(S(v-D)+S(r*y));C=S(S(C-s)+S(r*E));s=S(S(D*n)-S(q*C));o=S(p*o);T=S(p*u);v=S(S(o+S(p*x))-T);o=S(S(B-o)+S(r*v));u=S(S(o*q)-S(p*D));x=S(S(C*p)-S(n*o));o=P[a+1276>>2];B=S(S(K-O)-S(o*y));E=S(S(N-Q)-S(o*E));y=S(S(B*n)-S(q*E));v=S(S(J-T)-S(o*v));q=S(S(v*q)-S(p*B));n=S(S(E*p)-S(n*v));if(!(!M[a+1280|0]|m)){y=S(o*y);q=S(o*q);s=S(r*s);u=S(r*u);x=S(r*x);n=S(o*n)}c=j<<2;a=c+L[i+12>>2]|0;P[a+8>>2]=s;P[a+4>>2]=u;P[a>>2]=x;t=L[i+20>>2];P[c+t>>2]=-n;P[(z<<2)+t>>2]=-q;n=S(-y);break b}p=P[k>>2];q=P[c+48>>2];m=L[i+12>>2];A=j<<2;o=S(s-P[c+52>>2]);s=P[k+8>>2];r=S(r-P[c+56>>2]);P[m+A>>2]=S(o*s)-S(n*r);c=z<<2;q=S(u-q);P[c+m>>2]=S(r*p)-S(s*q);P[m+(w<<2)>>2]=S(q*n)-S(p*o);n=P[k>>2];p=P[d+48>>2];q=P[a+1176>>2];t=L[i+20>>2];r=S(P[a+1180>>2]-P[d+52>>2]);o=P[k+8>>2];s=P[k+4>>2];u=S(P[a+1184>>2]-P[d+56>>2]);P[A+t>>2]=-S(S(r*o)-S(s*u));p=S(q-p);P[c+t>>2]=-S(S(u*n)-S(o*p));n=S(-S(S(p*s)-S(n*r)))}P[(w<<2)+t>>2]=n}c:{d:{if(F){n=P[b+4>>2];p=P[b>>2];a=L[i+28>>2];L[a+(j<<2)>>2]=0;if(!(!G|n==p)){P[L[i+32>>2]+(j<<2)>>2]=P[b+28>>2]}n=S(P[i>>2]*P[b+32>>2]);if(l){break d}c=a+(j<<2)|0;P[c>>2]=S(n*P[b+48>>2])+P[c>>2];break c}a=j<<2;L[a+L[i+28>>2]>>2]=0;t=1;if(!G){break a}P[a+L[i+32>>2]>>2]=P[b+28>>2];n=P[b+8>>2];n=pd(P[b+52>>2],P[b>>2],P[b+4>>2],l?n:S(-n),S(P[i>>2]*P[b+32>>2]));c=a+L[i+28>>2]|0;P[c>>2]=S(n*P[b+8>>2])+P[c>>2];P[a+L[i+36>>2]>>2]=-P[b+12>>2];P[a+L[i+40>>2]>>2]=P[b+12>>2];return 1}c=a+(j<<2)|0;P[c>>2]=P[c>>2]-S(n*P[b+48>>2])}c=j<<2;P[c+L[i+32>>2]>>2]=P[b+36>>2];if(P[b>>2]==P[b+4>>2]){L[c+L[i+36>>2]>>2]=-8388609;L[c+L[i+40>>2]>>2]=2139095039;return 1}t=1;d=(F|0)==1;P[c+L[i+36>>2]>>2]=d?S(0):S(-34028234663852886e22);P[c+L[i+40>>2]>>2]=d?S(34028234663852886e22):S(0);p=P[b+40>>2];if(!(p>S(0))){break a}b=l?g:e;n=P[k+8>>2];q=P[k>>2];r=P[k+4>>2];o=S(S(P[b+8>>2]*n)+S(S(P[b>>2]*q)+S(P[b+4>>2]*r)));b=l?h:f;n=S(o-S(S(P[b+8>>2]*n)+S(S(P[b>>2]*q)+S(r*P[b+4>>2]))));if((F|0)==1){if(!(nP[a>>2])){break a}P[a>>2]=n;return 1}if(!(n>S(0))){break a}n=S(n*S(-p));a=a+(j<<2)|0;if(!(n>2])){break a}P[a>>2]=n}return t}function ll(a,b,c,d){var e=0,f=S(0),g=S(0),h=S(0),i=S(0),j=S(0),k=S(0),l=S(0),m=S(0),n=S(0),o=S(0),p=S(0),q=S(0),r=S(0),s=S(0),t=S(0),u=S(0),v=S(0),w=S(0),x=S(0),y=S(0),z=S(0),A=0,B=0,C=S(0),D=S(0),E=S(0);a=ub(a,6,al(),b);L[a>>2]=19568;e=L[c+12>>2];L[a+120>>2]=L[c+8>>2];L[a+124>>2]=e;e=L[c+4>>2];L[a+112>>2]=L[c>>2];L[a+116>>2]=e;e=L[c+28>>2];L[a+136>>2]=L[c+24>>2];L[a+140>>2]=e;e=L[c+20>>2];L[a+128>>2]=L[c+16>>2];L[a+132>>2]=e;e=L[c+44>>2];L[a+152>>2]=L[c+40>>2];L[a+156>>2]=e;e=L[c+36>>2];L[a+144>>2]=L[c+32>>2];L[a+148>>2]=e;e=L[c+56>>2];A=L[c+60>>2];B=L[c+48>>2];c=L[c+52>>2];L[a+784>>2]=0;L[a+776>>2]=0;L[a+780>>2]=0;L[a+768>>2]=0;L[a+772>>2]=0;L[a+764>>2]=1045220557;L[a+756>>2]=1045220557;L[a+760>>2]=1045220557;L[a+740>>2]=0;L[a+744>>2]=0;L[a+748>>2]=0;L[a+752>>2]=0;L[a+720>>2]=0;L[a+724>>2]=0;L[a+712>>2]=0;L[a+716>>2]=0;L[a+704>>2]=0;L[a+708>>2]=0;L[a+696>>2]=0;L[a+700>>2]=0;L[a+688>>2]=0;L[a+692>>2]=0;L[a+680>>2]=0;L[a+684>>2]=0;L[a+168>>2]=e;L[a+172>>2]=A;L[a+160>>2]=B;L[a+164>>2]=c;L[a+728>>2]=1060320051;L[a+732>>2]=1065353216;L[a+736>>2]=1056964608;J[a+790|0]=0;K[a+788>>1]=0;L[a+792>>2]=0;L[a+796>>2]=0;L[a+800>>2]=0;L[a+808>>2]=0;L[a+812>>2]=0;L[a+816>>2]=0;L[a+876>>2]=0;L[a+880>>2]=1036831949;L[a+884>>2]=1133903872;L[a+868>>2]=1065353216;L[a+872>>2]=-1082130432;L[a+896>>2]=0;L[a+900>>2]=1045220557;L[a+904>>2]=0;L[a+908>>2]=0;L[a+924>>2]=0;L[a+928>>2]=0;L[a+888>>2]=1065353216;L[a+892>>2]=1056964608;L[a+916>>2]=0;L[a+992>>2]=0;J[a+912|0]=0;L[a+940>>2]=0;L[a+944>>2]=1036831949;L[a+948>>2]=1133903872;L[a+968>>2]=0;L[a+972>>2]=0;L[a+960>>2]=0;L[a+964>>2]=1045220557;L[a+932>>2]=1065353216;L[a+936>>2]=-1082130432;L[a+952>>2]=1065353216;L[a+956>>2]=1056964608;L[a+988>>2]=0;L[a+980>>2]=0;J[a+976|0]=0;L[a+1004>>2]=0;L[a+1008>>2]=1036831949;L[a+1012>>2]=1133903872;c=a+1032|0;L[c>>2]=0;L[c+4>>2]=0;c=a+1024|0;L[c>>2]=0;L[c+4>>2]=1045220557;L[a+996>>2]=1065353216;L[a+1e3>>2]=-1082130432;L[a+1016>>2]=1065353216;L[a+1020>>2]=1056964608;c=a+1052|0;L[c>>2]=0;L[c+4>>2]=0;L[a+1044>>2]=0;J[a+1040|0]=0;J[a+1301|0]=1;J[a+1308|0]=0;L[a+1304>>2]=0;J[a+1300|0]=d;o=P[a+168>>2];p=P[a+160>>2];q=P[a+164>>2];r=P[a+144>>2];s=P[a+112>>2];t=P[a+128>>2];u=P[a+148>>2];v=P[a+116>>2];w=P[a+132>>2];x=P[a+152>>2];y=P[a+120>>2];z=P[a+136>>2];C=P[b+52>>2];D=P[b+56>>2];E=P[b+60>>2];f=P[b+12>>2];g=P[b+8>>2];h=P[b+28>>2];i=P[b+20>>2];j=P[b+24>>2];k=P[b+44>>2];l=P[b+36>>2];m=P[b+40>>2];n=P[b+4>>2];L[a+108>>2]=0;L[a+92>>2]=0;L[a+76>>2]=0;L[a+60>>2]=0;P[a+88>>2]=S(x*k)+S(S(y*l)+S(z*m));P[a+84>>2]=S(u*k)+S(S(v*l)+S(w*m));P[a+80>>2]=S(r*k)+S(S(s*l)+S(t*m));P[a+72>>2]=S(x*h)+S(S(y*i)+S(z*j));P[a+68>>2]=S(u*h)+S(S(v*i)+S(w*j));P[a- -64>>2]=S(r*h)+S(S(s*i)+S(t*j));P[a+56>>2]=S(x*f)+S(S(y*n)+S(g*z));P[a+52>>2]=S(u*f)+S(S(v*n)+S(g*w));P[a+48>>2]=S(r*f)+S(S(s*n)+S(t*g));P[a+104>>2]=E+S(S(o*k)+S(S(p*l)+S(m*q)));P[a+100>>2]=D+S(S(o*h)+S(S(p*i)+S(j*q)));P[a+96>>2]=C+S(S(o*f)+S(S(p*n)+S(g*q)));qd(a,L[a+28>>2]+4|0,L[a+32>>2]+4|0);return a}function JF(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0,g=0,h=S(0),i=S(0),j=S(0),k=S(0),l=S(0),m=0,n=0,o=0,p=0,q=0,r=S(0),s=0,t=S(0),u=S(0),v=S(0),w=S(0),x=S(0),y=S(0),z=0,A=0,B=0;q=fa+-64|0;fa=q;g=L[a+48>>2];L[q+12>>2]=b;L[q+8>>2]=g;L[q+4>>2]=12704;p=q+4|0;g=fa-16|0;fa=g;f=L[a+52>>2];a:{if(M[f+60|0]){w=P[f+40>>2];t=P[f+24>>2];h=P[f+8>>2];x=P[f+36>>2];u=P[f+20>>2];r=P[f+4>>2];k=P[c>>2];l=P[c+4>>2];v=P[f+28>>2];j=P[f+12>>2];i=P[c+8>>2];i=j>i?j:i;y=P[f+44>>2];i=S(S((i>v?v:i)-j)*y);b:{if(i=S(0)){a=~~i>>>0;break b}a=0}n=a&65534;K[g+14>>1]=n;l=h>l?h:l;l=S(w*S((l>t?t:l)-h));c:{if(l=S(0)){a=~~l>>>0;break c}a=0}o=a&65534;K[g+12>>1]=o;k=ku?u:k)-r)*x);d:{if(k=S(0)){a=~~k>>>0;break d}a=0}s=a&65534;K[g+10>>1]=s;k=P[d>>2];l=P[d+4>>2];i=P[d+8>>2];i=j>i?j:i;j=S(S(y*S((i>v?v:i)-j))+S(1));e:{if(j=S(0)){a=~~j>>>0;break e}a=0}z=a|1;K[g+8>>1]=z;j=h>l?h:l;h=S(S(w*S((j>t?t:j)-h))+S(1));f:{if(h=S(0)){a=~~h>>>0;break f}a=0}A=a|1;K[g+6>>1]=A;h=ku?u:h)-r))+S(1));g:{if(h=S(0)){a=~~h>>>0;break g}a=0}B=a|1;K[g+4>>1]=B;h:{switch(L[f+144>>2]){case 0:a=L[f+56>>2];if((a|0)>0){e=L[f+136>>2];b=0;while(1){m=m+1|0;i:{j:{c=L[e+12>>2];f=(c|0)<0;d=s>>>0<=N[e+6>>1]&N[e>>1]<=B>>>0&n>>>0<=N[e+10>>1]&z>>>0>=N[e+4>>1]&o>>>0<=N[e+8>>1]&N[e+2>>1]<=A>>>0;k:{if(!(f|!d)){ha[L[L[p>>2]+8>>2]](p,c>>>21|0,c&2097151);break k}if(f&(d^-1)){break j}}e=e+16|0;b=b+1|0;break i}e=e-(c<<4)|0;b=b-c|0}if((a|0)>(b|0)){continue}break}}if(L[7548]>=(m|0)){break a}L[7548]=m;break a;case 1:if(L[f+152>>2]>0){while(1){a=L[f+160>>2]+(e<<5)|0;l:{if(N[g+10>>1]>N[a+6>>1]|N[g+4>>1]>1]|(N[g+8>>1]>1]|N[g+14>>1]>N[a+10>>1])){break l}if(N[g+6>>1]>1]|N[g+12>>1]>N[a+8>>1]){break l}b=L[a+16>>2];m:{if((b|0)<=0){a=0;break m}c=L[a+12>>2];n=b+c|0;b=L[f+136>>2]+(c<<4)|0;a=0;while(1){n:{o:{d=L[b+12>>2];o=(d|0)<0;m=N[g+10>>1]<=N[b+6>>1]&N[g+4>>1]>=N[b>>1]&N[g+14>>1]<=N[b+10>>1]&N[g+8>>1]>=N[b+4>>1]&N[g+12>>1]<=N[b+8>>1]&N[g+6>>1]>=N[b+2>>1];p:{if(!(o|!m)){ha[L[L[p>>2]+8>>2]](p,d>>>21|0,d&2097151);break p}if(o&(m^-1)){break o}}c=c+1|0;b=b+16|0;break n}c=c-d|0;b=b-(d<<4)|0}a=a+1|0;if((c|0)<(n|0)){continue}break}}if(L[7548]>=(a|0)){break l}L[7548]=a}e=e+1|0;if((e|0)>2]){continue}break}}break a;case 2:break h;default:break a}}Gm(f,L[f+136>>2],p,g+10|0,g+4|0);break a}o=L[f+56>>2];if((o|0)>0){e=L[f+96>>2];while(1){b=0;q:{if(P[c>>2]>P[e+16>>2]){break q}b=0;if(P[d>>2]>2]){break q}b=1}a=0;a=P[d+8>>2]>2]|P[c+8>>2]>P[e+24>>2]?a:b;r:{s:{t:{if(P[d+4>>2]>2]|P[c+4>>2]>P[e+20>>2]){b=L[e+32>>2];s=(b|0)==-1;a=0;break t}b=L[e+32>>2];s=(b|0)==-1;if(!(s&a)){break t}ha[L[L[p>>2]+8>>2]](p,L[e+36>>2],L[e+40>>2]);o=L[f+56>>2];break s}if(a|s){break s}n=b+n|0;e=(b<<6)+e|0;break r}n=n+1|0;e=e- -64|0}m=m+1|0;if((n|0)<(o|0)){continue}break}}if(L[7548]>=(m|0)){break a}L[7548]=m}fa=g+16|0;fa=q- -64|0}function ze(a,b,c,d,e,f){var g=0,h=S(0),i=S(0),j=0,k=S(0),l=S(0),m=S(0),n=S(0),o=S(0),p=S(0),q=S(0),r=0,s=0,t=0,u=0,v=S(0),w=S(0),x=S(0),y=0,z=S(0),A=0,B=S(0),C=S(0),D=S(0),E=S(0),F=S(0),G=S(0),H=S(0);j=L[a+88>>2];r=j;a:{if((j|0)!=L[a+92>>2]){break a}t=j?j<<1:1;if((j|0)>=(t|0)){break a}if(t){L[8513]=L[8513]+1;u=ha[L[6798]](R(t,152),16)|0;g=L[a+88>>2]}else{g=j}b:{if((g|0)<=0){break b}r=0;if((g|0)!=1){A=g&-2;while(1){s=R(r,152);qa(s+u|0,s+L[a+96>>2]|0,152);s=R(r|1,152);qa(s+u|0,s+L[a+96>>2]|0,152);r=r+2|0;y=y+2|0;if((y|0)!=(A|0)){continue}break}}if(!(g&1)){break b}g=R(r,152);qa(g+u|0,g+L[a+96>>2]|0,152)}g=L[a+96>>2];if(!(g?!g|!M[a+100|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](g)}L[a+96>>2]=u;J[a+100|0]=1;L[a+92>>2]=t;r=L[a+88>>2]}L[a+88>>2]=r+1;g=L[a+96>>2]+R(j,152)|0;L[g+140>>2]=e;L[g+16>>2]=0;L[g+20>>2]=0;L[g+48>>2]=-2147483648;L[g+52>>2]=-2147483648;L[g+24>>2]=0;L[g+28>>2]=0;L[g+56>>2]=-2147483648;L[g+60>>2]=0;j=L[a+16>>2];a=L[(j+R(d,244)|0)+240>>2];e=L[(j+R(c,244)|0)+240>>2];L[g+148>>2]=d;L[g+144>>2]=c;x=P[f+88>>2];L[g+132>>2]=0;P[g+104>>2]=x;L[g+96>>2]=0;L[g+100>>2]=0;h=P[b>>2];i=P[b+4>>2];k=P[b+8>>2];L[g+12>>2]=0;n=S(-k);P[g+8>>2]=n;o=S(-i);P[g+4>>2]=o;p=S(-h);P[g>>2]=p;h=S(0);if(e){h=S(S(S(P[e+304>>2]*n)+S(S(P[e+296>>2]*p)+S(P[e+300>>2]*o)))*P[e+552>>2]);l=S(S(S(P[e+288>>2]*n)+S(S(P[e+280>>2]*p)+S(P[e+284>>2]*o)))*P[e+548>>2]);i=S(S(S(P[e+272>>2]*n)+S(S(P[e+264>>2]*p)+S(P[e+268>>2]*o)))*P[e+544>>2])}else{i=S(0)}P[g+64>>2]=i;L[g+76>>2]=0;P[g+72>>2]=h;P[g+68>>2]=l;h=P[b>>2];i=P[b+4>>2];k=P[b+8>>2];P[g+44>>2]=P[b+12>>2];P[g+40>>2]=k;P[g+36>>2]=i;P[g+32>>2]=h;if(a){m=S(S(S(P[a+304>>2]*k)+S(S(P[a+296>>2]*h)+S(i*P[a+300>>2])))*P[a+552>>2]);q=S(S(S(P[a+288>>2]*k)+S(S(P[a+280>>2]*h)+S(i*P[a+284>>2])))*P[a+548>>2]);l=S(S(S(P[a+272>>2]*k)+S(S(P[a+264>>2]*h)+S(i*P[a+268>>2])))*P[a+544>>2])}else{l=S(0)}P[g+80>>2]=l;L[g+92>>2]=0;P[g+88>>2]=m;P[g+84>>2]=q;q=S(0);m=S(0);if(e){q=S(S(P[e+272>>2]*n)+S(S(P[e+264>>2]*p)+S(P[e+268>>2]*o)));m=S(S(P[e+288>>2]*n)+S(S(P[e+280>>2]*p)+S(P[e+284>>2]*o)));l=S(S(P[e+304>>2]*n)+S(S(P[e+296>>2]*p)+S(P[e+300>>2]*o)))}else{l=S(0)}q=S(S(S(l*n)+S(S(q*p)+S(m*o)))+S(0));if(a){v=S(S(P[a+288>>2]*k)+S(S(P[a+280>>2]*h)+S(i*P[a+284>>2])));w=S(S(P[a+272>>2]*k)+S(S(P[a+264>>2]*h)+S(P[a+268>>2]*i)));m=S(S(P[a+304>>2]*k)+S(S(P[a+296>>2]*h)+S(i*P[a+300>>2])))}else{m=S(0)}z=S(S(1)/S(q+S(S(m*k)+S(S(w*h)+S(v*i)))));P[g+108>>2]=z;w=S(0);q=S(0);m=S(0);v=S(0);if(e){b=j+R(c,244)|0;w=S(P[b+176>>2]+P[b+208>>2]);B=P[b+200>>2];v=P[b+196>>2];q=S(S(P[b+180>>2]+P[b+212>>2])*S(0));C=P[b+192>>2];m=S(P[b+184>>2]+P[b+216>>2])}l=S(-0);if(a){a=j+R(d,244)|0;D=S(P[a+176>>2]+P[a+208>>2]);E=S(P[a+184>>2]+P[a+216>>2]);F=P[a+192>>2];G=P[a+200>>2];H=P[a+196>>2];l=S(S(P[a+180>>2]+P[a+212>>2])*S(-0))}P[g+124>>2]=x;P[g+116>>2]=0;P[g+120>>2]=-x;P[g+112>>2]=z*S(S(0)-S(S(S(S(m*S(0))+S(S(w*S(0))+q))+S(S(n*B)+S(S(p*C)+S(v*o))))+S(S(S(E*S(-0))+S(S(D*S(-0))+l))+S(S(k*G)+S(S(h*F)+S(i*H))))))}function Ll(a,b,c){var d=S(0),e=S(0),f=S(0),g=0,h=S(0),i=0,j=0,k=S(0),l=S(0),m=S(0),n=S(0),o=0,p=S(0),q=S(0),r=S(0),s=0,t=0;g=fa-528|0;fa=g;k=P[a+20>>2];d=S(k-P[a+4>>2]);e=P[a+56>>2];h=P[a+52>>2];m=P[a+24>>2];l=S(m-P[a+8>>2]);f=S(S(d*e)-S(h*l));q=f;n=P[a+16>>2];p=S(n-P[a>>2]);r=S(p*h);h=P[a+48>>2];d=S(r-S(h*d));r=S(f*f);f=S(S(l*h)-S(e*p));e=S(S(1)/S(_(S(S(d*d)+S(r+S(f*f))))));h=S(q*e);P[g+256>>2]=h;f=S(f*e);P[g+260>>2]=f;d=S(d*e);P[g+264>>2]=d;P[g+268>>2]=S(m*d)+S(S(n*h)+S(k*f));o=g+272|0;d=P[g+264>>2];e=P[g+256>>2];k=P[g+260>>2];h=P[g+268>>2];f=S(S(S(P[b+8>>2]*d)+S(S(P[b>>2]*e)+S(P[b+4>>2]*k)))-h);i=f>S(1.1920928955078125e-7);if(!i){j=L[b+4>>2];L[o>>2]=L[b>>2];L[o+4>>2]=j;j=L[b+12>>2];L[o+8>>2]=L[b+8>>2];L[o+12>>2]=j;h=P[g+268>>2];d=P[g+264>>2];k=P[g+260>>2];e=P[g+256>>2];j=1}m=P[b+24>>2];l=P[b+16>>2];n=P[b+20>>2];d=S(S(S(m*d)+S(S(l*e)+S(n*k)))-h);if((i|0)!=(d>S(1.1920928955078125e-7)|0)){h=P[b>>2];p=P[b+4>>2];q=P[b+8>>2];i=o+(j<<4)|0;L[i+12>>2]=0;e=S(S(-f)/S(d-f));k=S(S(1)-e);P[i+8>>2]=S(m*e)+S(q*k);P[i+4>>2]=S(n*e)+S(k*p);P[i>>2]=S(l*e)+S(k*h);j=j+1|0}t=d>S(1.1920928955078125e-7);if(!t){s=L[b+20>>2];i=o+(j<<4)|0;L[i>>2]=L[b+16>>2];L[i+4>>2]=s;s=L[b+28>>2];L[i+8>>2]=L[b+24>>2];L[i+12>>2]=s;j=j+1|0}h=P[b+40>>2];m=P[b+32>>2];l=P[b+36>>2];e=S(S(S(h*P[g+264>>2])+S(S(m*P[g+256>>2])+S(l*P[g+260>>2])))-P[g+268>>2]);if((t|0)!=(e>S(1.1920928955078125e-7)|0)){n=P[b+16>>2];p=P[b+20>>2];q=P[b+24>>2];i=o+(j<<4)|0;L[i+12>>2]=0;d=S(S(-d)/S(e-d));k=S(S(1)-d);P[i+8>>2]=S(h*d)+S(q*k);P[i+4>>2]=S(l*d)+S(k*p);P[i>>2]=S(m*d)+S(k*n);j=j+1|0}t=e>S(1.1920928955078125e-7);if(!t){s=L[b+36>>2];i=o+(j<<4)|0;L[i>>2]=L[b+32>>2];L[i+4>>2]=s;s=L[b+44>>2];L[i+8>>2]=L[b+40>>2];L[i+12>>2]=s;j=j+1|0}if((t|0)!=(f>S(1.1920928955078125e-7)|0)){k=P[b+32>>2];h=P[b>>2];m=P[b+36>>2];l=P[b+4>>2];d=P[b+40>>2];n=P[b+8>>2];i=o+(j<<4)|0;L[i+12>>2]=0;q=d;d=S(S(-e)/S(f-e));e=S(S(1)-d);P[i+8>>2]=S(q*e)+S(d*n);P[i+4>>2]=S(e*m)+S(d*l);P[i>>2]=S(e*k)+S(d*h);j=j+1|0}if(f>S(1.1920928955078125e-7)){b=j}else{i=L[b+4>>2];o=o+(j<<4)|0;L[o>>2]=L[b>>2];L[o+4>>2]=i;i=L[b+12>>2];L[o+8>>2]=L[b+8>>2];L[o+12>>2]=i;b=j+1|0}j=0;a:{if(!b){break a}k=P[a+40>>2];e=S(k-P[a+24>>2]);d=P[a+48>>2];h=P[a+56>>2];m=P[a+32>>2];l=S(m-P[a+16>>2]);f=S(S(e*d)-S(h*l));q=f;r=l;l=P[a+52>>2];n=P[a+36>>2];p=S(n-P[a+20>>2]);d=S(S(r*l)-S(d*p));e=S(S(p*h)-S(l*e));f=S(S(1)/S(_(S(S(d*d)+S(S(e*e)+S(f*f))))));h=S(q*f);P[g+260>>2]=h;e=S(e*f);P[g+256>>2]=e;f=S(d*f);P[g+264>>2]=f;P[g+268>>2]=S(k*f)+S(S(m*e)+S(n*h));b=Kl(g+256|0,g+272|0,b,g);j=0;if(!b){break a}k=P[a+8>>2];e=S(k-P[a+40>>2]);d=P[a+48>>2];h=P[a+56>>2];m=P[a>>2];l=S(m-P[a+32>>2]);f=S(S(e*d)-S(h*l));q=f;r=l;l=P[a+52>>2];n=P[a+4>>2];p=S(n-P[a+36>>2]);d=S(S(r*l)-S(d*p));e=S(S(p*h)-S(l*e));f=S(S(1)/S(_(S(S(d*d)+S(S(e*e)+S(f*f))))));h=S(q*f);P[g+260>>2]=h;e=S(e*f);P[g+256>>2]=e;f=S(d*f);P[g+264>>2]=f;P[g+268>>2]=S(k*f)+S(S(m*e)+S(n*h));j=Kl(g+256|0,g,b,c)}fa=g+528|0;return j}function Bn(a,b,c,d,e,f,g,h,i){var j=0,k=0,l=S(0),m=0,n=0,o=0,p=0,q=S(0),r=0,s=0,t=0,u=S(0),v=S(0),w=0,x=0,y=0,z=0,A=S(0),B=S(0),C=S(0);o=fa-32|0;fa=o;if(b){j=L[a+44>>2];a:{if((j|0)>127){break a}if(L[a+48>>2]<=127){L[8513]=L[8513]+1;r=ha[L[6798]](512,16)|0;w=L[a+44>>2];b:{if((w|0)<=0){break b}if(w>>>0>=4){z=w&-4;while(1){s=k<<2;L[s+r>>2]=L[s+L[a+52>>2]>>2];p=s|4;L[p+r>>2]=L[p+L[a+52>>2]>>2];p=s|8;L[p+r>>2]=L[p+L[a+52>>2]>>2];p=s|12;L[p+r>>2]=L[p+L[a+52>>2]>>2];k=k+4|0;m=m+4|0;if((z|0)!=(m|0)){continue}break}}p=w&3;if(!p){break b}while(1){m=k<<2;L[m+r>>2]=L[m+L[a+52>>2]>>2];k=k+1|0;n=n+1|0;if((p|0)!=(n|0)){continue}break}}k=L[a+52>>2];if(!(k?!k|!M[a+56|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](k)}L[a+52>>2]=r;J[a+56|0]=1;L[a+48>>2]=128}k=j;m=0-j&3;if(m){while(1){L[L[a+52>>2]+(k<<2)>>2]=0;k=k+1|0;x=x+1|0;if((m|0)!=(x|0)){continue}break}}if(j-125>>>0<3){break a}while(1){j=k<<2;L[j+L[a+52>>2]>>2]=0;L[(j+L[a+52>>2]|0)+4>>2]=0;L[(j+L[a+52>>2]|0)+8>>2]=0;L[(j+L[a+52>>2]|0)+12>>2]=0;k=k+4|0;if((k|0)!=128){continue}break}}L[a+44>>2]=128;L[L[a+52>>2]>>2]=b;n=126;x=1;while(1){k=L[a+52>>2];b=x-1|0;p=b<<2;t=L[k+p>>2];u=P[t>>2];v=P[t+4>>2];q=P[h>>2];l=P[h+4>>2];P[o+8>>2]=P[t+8>>2]-P[h+8>>2];P[o+4>>2]=v-l;P[o>>2]=u-q;u=P[t+16>>2];v=P[t+20>>2];q=P[g>>2];l=P[g+4>>2];P[o+24>>2]=P[t+24>>2]-P[g+8>>2];P[o+20>>2]=v-l;P[o+16>>2]=u-q;m=L[e>>2];u=P[c>>2];v=P[d>>2];A=S(S(P[(m<<4)+o>>2]-u)*v);q=P[d+4>>2];j=L[e+4>>2];l=P[c+4>>2];B=S(q*S(P[((1-j<<4)+o|0)+4>>2]-l));c:{if(A>B){break c}l=S(S(P[((j<<4)+o|0)+4>>2]-l)*q);C=S(v*S(P[(1-m<<4)+o>>2]-u));if(l>C){break c}u=l>A?l:A;q=P[d+8>>2];j=L[e+8>>2];l=P[c+8>>2];v=S(q*S(P[((1-j<<4)+o|0)+8>>2]-l));if(u>v){break c}q=S(S(P[((j<<4)+o|0)+8>>2]-l)*q);l=Bl|!((q>u?q:u)v?v:l)>S(0))){break c}if(L[t+40>>2]){if((b|0)>(n|0)){b=L[a+44>>2];y=b<<1;if((b|0)<(y|0)){if((y|0)>L[a+48>>2]){d:{if(!b){k=0;break d}L[8513]=L[8513]+1;k=ha[L[6798]](b<<3,16)|0;s=L[a+44>>2];if((s|0)<=0){break d}w=0;n=0;if(s>>>0>=4){m=s&-4;z=0;while(1){r=n<<2;L[r+k>>2]=L[r+L[a+52>>2]>>2];j=r|4;L[j+k>>2]=L[j+L[a+52>>2]>>2];j=r|8;L[j+k>>2]=L[j+L[a+52>>2]>>2];j=r|12;L[j+k>>2]=L[j+L[a+52>>2]>>2];n=n+4|0;z=z+4|0;if((m|0)!=(z|0)){continue}break}}m=s&3;if(!m){break d}while(1){j=n<<2;L[j+k>>2]=L[j+L[a+52>>2]>>2];n=n+1|0;w=w+1|0;if((m|0)!=(w|0)){continue}break}}j=L[a+52>>2];if(!(j?!j|!M[a+56|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](j)}L[a+52>>2]=k;J[a+56|0]=1;L[a+48>>2]=y}k=b-1|0;n=0;j=b&3;if(j){while(1){L[L[a+52>>2]+(b<<2)>>2]=0;b=b+1|0;n=n+1|0;if((j|0)!=(n|0)){continue}break}}if(k>>>0>=3){while(1){j=b<<2;L[j+L[a+52>>2]>>2]=0;L[(j+L[a+52>>2]|0)+4>>2]=0;L[(j+L[a+52>>2]|0)+8>>2]=0;L[(j+L[a+52>>2]|0)+12>>2]=0;b=b+4|0;if((y|0)!=(b|0)){continue}break}}k=L[a+52>>2]}L[a+44>>2]=y;n=y-2|0}L[k+p>>2]=L[t+36>>2];L[L[a+52>>2]+(x<<2)>>2]=L[t+40>>2];b=x+1|0;break c}ha[L[L[i>>2]+12>>2]](i,t)}x=b;if(b){continue}break}}fa=o+32|0}function RA(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;c=L[b+8>>2];a:{if((c|0)<=0){break a}d=L[b+16>>2];if((c|0)!=1){g=c&-2;while(1){i=e<<2;h=L[i+d>>2];if(!(M[h+204|0]&3)){L[h+208>>2]=f;f=f+1|0}L[h+244>>2]=1065353216;L[h+212>>2]=-1;h=L[d+(i|4)>>2];if(!(M[h+204|0]&3)){L[h+208>>2]=f;f=f+1|0}L[h+244>>2]=1065353216;L[h+212>>2]=-1;e=e+2|0;k=k+2|0;if((g|0)!=(k|0)){continue}break}}if(!(c&1)){break a}c=L[d+(e<<2)>>2];if(!(M[c+204|0]&3)){L[c+208>>2]=f;f=f+1|0}L[c+244>>2]=1065353216;L[c+212>>2]=-1}d=0;h=0;i=0;k=0;c=L[a+8>>2];b:{if((f|0)<=(c|0)){break b}if(L[a+12>>2]<(f|0)){if(f){L[8513]=L[8513]+1;h=ha[L[6798]](f<<3,16)|0;e=L[a+8>>2]}else{e=c}c:{if((e|0)<=0){break c}if(e>>>0>=4){n=e&-4;while(1){g=d<<3;j=g+h|0;l=g+L[a+16>>2]|0;m=L[l+4>>2];L[j>>2]=L[l>>2];L[j+4>>2]=m;j=g|8;l=j+h|0;j=j+L[a+16>>2]|0;m=L[j+4>>2];L[l>>2]=L[j>>2];L[l+4>>2]=m;j=g|16;l=j+h|0;j=j+L[a+16>>2]|0;m=L[j+4>>2];L[l>>2]=L[j>>2];L[l+4>>2]=m;g=g|24;j=g+h|0;g=g+L[a+16>>2]|0;l=L[g+4>>2];L[j>>2]=L[g>>2];L[j+4>>2]=l;d=d+4|0;i=i+4|0;if((n|0)!=(i|0)){continue}break}}e=e&3;if(!e){break c}while(1){g=d<<3;i=g+h|0;g=g+L[a+16>>2]|0;n=L[g+4>>2];L[i>>2]=L[g>>2];L[i+4>>2]=n;d=d+1|0;k=k+1|0;if((e|0)!=(k|0)){continue}break}}e=L[a+16>>2];if(!(e?!e|!M[a+20|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](e)}L[a+16>>2]=h;J[a+20|0]=1;L[a+12>>2]=f}e=(c^-1)+f|0;h=f-c&3;if(h){d=0;while(1){k=L[a+16>>2]+(c<<3)|0;L[k>>2]=0;L[k+4>>2]=0;c=c+1|0;d=d+1|0;if((h|0)!=(d|0)){continue}break}}if(e>>>0<3){break b}while(1){e=c<<3;d=e+L[a+16>>2]|0;L[d>>2]=0;L[d+4>>2]=0;d=e+L[a+16>>2]|0;L[d+8>>2]=0;L[d+12>>2]=0;d=e+L[a+16>>2]|0;L[d+16>>2]=0;L[d+20>>2]=0;e=e+L[a+16>>2]|0;L[e+24>>2]=0;L[e+28>>2]=0;c=c+4|0;if((f|0)!=(c|0)){continue}break}}L[a+8>>2]=f;d:{if((f|0)<=0){break d}e=L[a+16>>2];d=0;c=0;if(f>>>0>=4){k=f&-4;h=0;while(1){g=e+(c<<3)|0;L[g+4>>2]=1;L[g>>2]=c;g=c|1;i=e+(g<<3)|0;L[i+4>>2]=1;L[i>>2]=g;g=c|2;i=e+(g<<3)|0;L[i+4>>2]=1;L[i>>2]=g;g=c|3;i=e+(g<<3)|0;L[i+4>>2]=1;L[i>>2]=g;c=c+4|0;h=h+4|0;if((k|0)!=(h|0)){continue}break}}f=f&3;if(!f){break d}while(1){h=e+(c<<3)|0;L[h+4>>2]=1;L[h>>2]=c;c=c+1|0;d=d+1|0;if((f|0)!=(d|0)){continue}break}}e=0;b=L[b+68>>2];b=ha[L[L[b>>2]+36>>2]](b)|0;h=ha[L[L[b>>2]+36>>2]](b)|0;e:{if(!h){break e}k=ha[L[L[b>>2]+20>>2]](b)|0;if((h|0)<=0){break e}a=L[a+16>>2];while(1){b=k+(e<<4)|0;c=L[L[b>>2]>>2];f:{if(!c|M[c+204|0]&7){break f}b=L[L[b+4>>2]>>2];if(!b|M[b+204|0]&7){break f}b=L[b+208>>2];c=L[c+208>>2];f=a+(c<<3)|0;d=L[f>>2];if((c|0)!=(d|0)){while(1){c=a+(d<<3)|0;L[f>>2]=L[c>>2];c=L[c>>2];f=a+(c<<3)|0;d=L[f>>2];if((c|0)!=(d|0)){continue}break}}f=a+(b<<3)|0;d=L[f>>2];if((d|0)!=(b|0)){while(1){b=a+(d<<3)|0;L[f>>2]=L[b>>2];b=L[b>>2];f=a+(b<<3)|0;d=L[f>>2];if((b|0)!=(d|0)){continue}break}}if((b|0)==(c|0)){break f}c=a+(c<<3)|0;L[c>>2]=b;b=a+(b<<3)|0;L[b+4>>2]=L[b+4>>2]+L[c+4>>2]}e=e+1|0;if((h|0)!=(e|0)){continue}break}}}function Jz(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=S(0),f=S(0),g=S(0),h=S(0),i=S(0),j=S(0),k=S(0),l=S(0),m=S(0),n=S(0),o=S(0),p=S(0),q=S(0),r=S(0),s=S(0),t=S(0),u=S(0),v=S(0),w=S(0),x=S(0),y=S(0),z=S(0),A=S(0),B=S(0),C=S(0),D=S(0),E=S(0),F=S(0),G=S(0),H=S(0);a=L[a+16>>2];e=P[a+908>>2];i=P[a+912>>2];q=P[a+916>>2];j=P[b+56>>2];t=P[b+36>>2];z=P[b+40>>2];f=P[b+32>>2];k=P[b+48>>2];A=P[b+8>>2];u=P[b+4>>2];l=P[b>>2];n=P[a+900>>2];B=P[b+24>>2];g=S(n*B);r=P[a+892>>2];o=P[b+16>>2];C=S(r*o);p=P[a+896>>2];v=P[b+20>>2];w=S(p*v);D=S(C+w);m=P[b+52>>2];P[d+4>>2]=S(g+D)+m;h=S(n*A);E=S(r*l);x=S(p*u);F=S(E+x);P[d>>2]=k+S(h+F);L[d+12>>2]=0;n=S(n*z);r=S(r*f);p=S(p*t);G=S(r+p);P[d+8>>2]=j+S(n+G);a=L[d+4>>2];L[c>>2]=L[d>>2];L[c+4>>2]=a;a=L[d+12>>2];L[c+8>>2]=L[d+8>>2];L[c+12>>2]=a;y=S(e*f);p=S(y+p);H=S(n+p);o=S(e*o);w=S(o+w);f=S(m+S(g+w));s=S(e*l);x=S(s+x);e=S(k+S(h+x));if(e>2]){P[c>>2]=e}if(f>2]){P[c+4>>2]=f}l=S(H+j);if(l>2]){P[c+8>>2]=l}if(P[c+12>>2]>S(0)){L[c+12>>2]=0}if(e>P[d>>2]){P[d>>2]=e}if(f>P[d+4>>2]){P[d+4>>2]=f}if(l>P[d+8>>2]){P[d+8>>2]=l}if(P[d+12>>2]>2]=0}l=S(i*u);u=S(s+l);f=S(S(h+u)+k);if(f>2]){P[c>>2]=f}s=o;o=S(i*v);v=S(s+o);e=S(S(g+v)+m);if(e>2]){P[c+4>>2]=e}t=S(i*t);y=S(y+t);i=S(S(n+y)+j);if(i>2]){P[c+8>>2]=i}if(P[c+12>>2]>S(0)){L[c+12>>2]=0}if(f>P[d>>2]){P[d>>2]=f}if(e>P[d+4>>2]){P[d+4>>2]=e}if(i>P[d+8>>2]){P[d+8>>2]=i}if(P[d+12>>2]>2]=0}l=S(E+l);f=S(S(h+l)+k);if(f>2]){P[c>>2]=f}o=S(C+o);e=S(S(g+o)+m);if(e>2]){P[c+4>>2]=e}s=n;n=S(r+t);i=S(S(s+n)+j);if(i>2]){P[c+8>>2]=i}if(P[c+12>>2]>S(0)){L[c+12>>2]=0}if(f>P[d>>2]){P[d>>2]=f}if(e>P[d+4>>2]){P[d+4>>2]=e}if(i>P[d+8>>2]){P[d+8>>2]=i}if(P[d+12>>2]>2]=0}f=S(q*A);e=S(S(f+F)+k);if(e>2]){P[c>>2]=e}i=S(q*B);g=S(S(i+D)+m);if(g>2]){P[c+4>>2]=g}q=S(q*z);h=S(S(q+G)+j);if(h>2]){P[c+8>>2]=h}if(P[c+12>>2]>S(0)){L[c+12>>2]=0}if(e>P[d>>2]){P[d>>2]=e}if(g>P[d+4>>2]){P[d+4>>2]=g}if(h>P[d+8>>2]){P[d+8>>2]=h}if(P[d+12>>2]>2]=0}e=S(S(f+x)+k);if(e>2]){P[c>>2]=e}g=S(S(i+w)+m);if(g>2]){P[c+4>>2]=g}h=S(S(q+p)+j);if(h>2]){P[c+8>>2]=h}if(P[c+12>>2]>S(0)){L[c+12>>2]=0}if(e>P[d>>2]){P[d>>2]=e}if(g>P[d+4>>2]){P[d+4>>2]=g}if(h>P[d+8>>2]){P[d+8>>2]=h}if(P[d+12>>2]>2]=0}e=S(S(f+u)+k);if(e>2]){P[c>>2]=e}g=S(S(i+v)+m);if(g>2]){P[c+4>>2]=g}h=S(S(q+y)+j);if(h>2]){P[c+8>>2]=h}if(P[c+12>>2]>S(0)){L[c+12>>2]=0}if(e>P[d>>2]){P[d>>2]=e}if(g>P[d+4>>2]){P[d+4>>2]=g}if(h>P[d+8>>2]){P[d+8>>2]=h}if(P[d+12>>2]>2]=0}k=S(S(f+l)+k);if(k>2]){P[c>>2]=k}m=S(S(i+o)+m);if(m>2]){P[c+4>>2]=m}j=S(S(q+n)+j);if(j>2]){P[c+8>>2]=j}if(P[c+12>>2]>S(0)){L[c+12>>2]=0}if(k>P[d>>2]){P[d>>2]=k}if(m>P[d+4>>2]){P[d+4>>2]=m}if(j>P[d+8>>2]){P[d+8>>2]=j}if(P[d+12>>2]>2]=0}}function am(){if(!M[31424]){L[7774]=1062847606;L[7775]=0;L[7772]=1042701022;L[7773]=1056964440;L[7770]=1062847606;L[7771]=0;L[7768]=-1093024784;L[7769]=1050556081;L[7766]=1062847606;L[7767]=0;L[7764]=-1093024784;L[7765]=-1096927567;L[7762]=1062847606;L[7763]=0;L[7760]=1042701022;L[7761]=-1090519208;L[7758]=1062847572;L[7759]=0;L[7756]=1057396286;L[7757]=0;L[7754]=1057396386;L[7755]=0;L[7752]=1060121912;L[7753]=1056964507;L[7750]=1057396420;L[7751]=0;L[7748]=-1098475836;L[7749]=1062148969;L[7746]=1057396386;L[7747]=0;L[7744]=-1084636143;L[7745]=0;L[7742]=1057396420;L[7743]=0;L[7740]=-1098475836;L[7741]=-1085334679;L[7738]=1057396386;L[7739]=0;L[7736]=1060121912;L[7737]=-1090519141;L[7734]=-2147483648;L[7735]=0;L[7732]=1058437413;L[7733]=1062149053;L[7730]=-2147483648;L[7731]=0;L[7728]=-2147483648;L[7729]=1065353216;L[7726]=-2147483648;L[7727]=0;L[7724]=-1089046235;L[7725]=1062149053;L[7722]=-2147483648;L[7723]=0;L[7720]=-1082951543;L[7721]=1050556148;L[7718]=-2147483648;L[7719]=0;L[7716]=-1082951543;L[7717]=-1096927500;L[7714]=0;L[7715]=0;L[7712]=-1089046235;L[7713]=-1085334595;L[7710]=0;L[7711]=0;L[7708]=0;L[7709]=-1082130432;L[7706]=0;L[7707]=0;L[7704]=1058437413;L[7705]=-1085334595;L[7702]=0;L[7703]=0;L[7700]=1064532105;L[7701]=-1096927500;L[7698]=0;L[7699]=0;L[7696]=1064532105;L[7697]=1050556148;L[7694]=-1090087228;L[7695]=0;L[7692]=1049007812;L[7693]=1062148969;L[7690]=-1090087262;L[7691]=0;L[7688]=-1087361736;L[7689]=1056964507;L[7686]=-1084636042;L[7687]=0;L[7684]=-1104782626;L[7685]=1056964440;L[7682]=-1090087262;L[7683]=0;L[7680]=-1087361736;L[7681]=-1090519141;L[7678]=-1084636076;L[7679]=0;L[7676]=-1090087362;L[7677]=-2147483648;L[7674]=-1090087262;L[7675]=0;L[7672]=1062847505;L[7673]=-2147483648;L[7670]=-1084636042;L[7671]=0;L[7668]=1054458864;L[7669]=1050556081;L[7666]=-1090087228;L[7667]=0;L[7664]=1049007812;L[7665]=-1085334679;L[7662]=-1084636042;L[7663]=0;L[7660]=-1104782626;L[7661]=-1090519208;L[7658]=-1084636042;L[7659]=0;L[7656]=1054458864;L[7657]=-1096927567;L[7654]=1065353216;L[7655]=0;L[7652]=-2147483648;L[7653]=0;L[7650]=1055193471;L[7651]=0;L[7648]=1063581978;L[7649]=0;L[7646]=1055193572;L[7647]=0;L[7644]=1049461434;L[7645]=1062847522;L[7642]=1055193572;L[7643]=0;L[7640]=-1086767520;L[7641]=1057396202;L[7638]=1055193572;L[7639]=0;L[7636]=-1086767520;L[7637]=-1090087446;L[7634]=1055193605;L[7635]=0;L[7632]=1049461434;L[7633]=-1084636126;L[7630]=-1092290076;L[7631]=0;L[7628]=1060716128;L[7629]=1057396202;L[7626]=-1092290043;L[7627]=0;L[7624]=-1098022214;L[7625]=1062847522;L[7622]=-1092290177;L[7623]=0;L[7620]=-1083901670;L[7621]=-2147483648;L[7618]=-1092290076;L[7619]=0;L[7616]=-1098022214;L[7617]=-1084636126;L[7614]=-1092290076;L[7615]=0;L[7612]=1060716128;L[7613]=-1090087446;L[7610]=-1082130432;L[7611]=0;L[7608]=0;L[7609]=-2147483648;J[31424]=1}}function Ie(){if(!M[32448]){L[8030]=1062847606;L[8031]=0;L[8028]=1042701022;L[8029]=1056964440;L[8026]=1062847606;L[8027]=0;L[8024]=-1093024784;L[8025]=1050556081;L[8022]=1062847606;L[8023]=0;L[8020]=-1093024784;L[8021]=-1096927567;L[8018]=1062847606;L[8019]=0;L[8016]=1042701022;L[8017]=-1090519208;L[8014]=1062847572;L[8015]=0;L[8012]=1057396286;L[8013]=0;L[8010]=1057396386;L[8011]=0;L[8008]=1060121912;L[8009]=1056964507;L[8006]=1057396420;L[8007]=0;L[8004]=-1098475836;L[8005]=1062148969;L[8002]=1057396386;L[8003]=0;L[8e3]=-1084636143;L[8001]=0;L[7998]=1057396420;L[7999]=0;L[7996]=-1098475836;L[7997]=-1085334679;L[7994]=1057396386;L[7995]=0;L[7992]=1060121912;L[7993]=-1090519141;L[7990]=-2147483648;L[7991]=0;L[7988]=1058437413;L[7989]=1062149053;L[7986]=-2147483648;L[7987]=0;L[7984]=-2147483648;L[7985]=1065353216;L[7982]=-2147483648;L[7983]=0;L[7980]=-1089046235;L[7981]=1062149053;L[7978]=-2147483648;L[7979]=0;L[7976]=-1082951543;L[7977]=1050556148;L[7974]=-2147483648;L[7975]=0;L[7972]=-1082951543;L[7973]=-1096927500;L[7970]=0;L[7971]=0;L[7968]=-1089046235;L[7969]=-1085334595;L[7966]=0;L[7967]=0;L[7964]=0;L[7965]=-1082130432;L[7962]=0;L[7963]=0;L[7960]=1058437413;L[7961]=-1085334595;L[7958]=0;L[7959]=0;L[7956]=1064532105;L[7957]=-1096927500;L[7954]=0;L[7955]=0;L[7952]=1064532105;L[7953]=1050556148;L[7950]=-1090087228;L[7951]=0;L[7948]=1049007812;L[7949]=1062148969;L[7946]=-1090087262;L[7947]=0;L[7944]=-1087361736;L[7945]=1056964507;L[7942]=-1084636042;L[7943]=0;L[7940]=-1104782626;L[7941]=1056964440;L[7938]=-1090087262;L[7939]=0;L[7936]=-1087361736;L[7937]=-1090519141;L[7934]=-1084636076;L[7935]=0;L[7932]=-1090087362;L[7933]=-2147483648;L[7930]=-1090087262;L[7931]=0;L[7928]=1062847505;L[7929]=-2147483648;L[7926]=-1084636042;L[7927]=0;L[7924]=1054458864;L[7925]=1050556081;L[7922]=-1090087228;L[7923]=0;L[7920]=1049007812;L[7921]=-1085334679;L[7918]=-1084636042;L[7919]=0;L[7916]=-1104782626;L[7917]=-1090519208;L[7914]=-1084636042;L[7915]=0;L[7912]=1054458864;L[7913]=-1096927567;L[7910]=1065353216;L[7911]=0;L[7908]=-2147483648;L[7909]=0;L[7906]=1055193471;L[7907]=0;L[7904]=1063581978;L[7905]=0;L[7902]=1055193572;L[7903]=0;L[7900]=1049461434;L[7901]=1062847522;L[7898]=1055193572;L[7899]=0;L[7896]=-1086767520;L[7897]=1057396202;L[7894]=1055193572;L[7895]=0;L[7892]=-1086767520;L[7893]=-1090087446;L[7890]=1055193605;L[7891]=0;L[7888]=1049461434;L[7889]=-1084636126;L[7886]=-1092290076;L[7887]=0;L[7884]=1060716128;L[7885]=1057396202;L[7882]=-1092290043;L[7883]=0;L[7880]=-1098022214;L[7881]=1062847522;L[7878]=-1092290177;L[7879]=0;L[7876]=-1083901670;L[7877]=-2147483648;L[7874]=-1092290076;L[7875]=0;L[7872]=-1098022214;L[7873]=-1084636126;L[7870]=-1092290076;L[7871]=0;L[7868]=1060716128;L[7869]=-1090087446;L[7866]=-1082130432;L[7867]=0;L[7864]=0;L[7865]=-2147483648;J[32448]=1}}function jg(a,b){var c=0,d=S(0),e=0,f=S(0),g=S(0),h=S(0),i=0,j=0,k=0,l=S(0),m=S(0),n=S(0),o=S(0),p=S(0),q=S(0),r=S(0),s=S(0),t=S(0),u=S(0),v=S(0),w=S(0),x=S(0),y=0,z=0,A=0,B=S(0),C=S(0);i=fa-32|0;fa=i;c=L[a+192>>2];d=S(ha[L[L[c>>2]+48>>2]](c));j=L[a+712>>2];if((j|0)>0){k=a+928|0;while(1){l=P[b+48>>2];m=P[b+8>>2];n=P[b+4>>2];o=P[b>>2];p=P[b+52>>2];q=P[b+24>>2];r=P[b+20>>2];s=P[b+16>>2];f=P[b+56>>2];h=P[b+40>>2];g=P[b+36>>2];t=P[b+32>>2];c=L[a+720>>2]+R(e,104)|0;L[c+20>>2]=0;w=f;f=P[c+16>>2];u=S(h*f);h=P[c+8>>2];v=g;g=P[c+12>>2];t=S(w+S(u+S(S(t*h)+S(v*g))));P[c+16>>2]=t;p=S(p+S(S(f*q)+S(S(h*s)+S(g*r))));P[c+12>>2]=p;l=S(l+S(S(f*m)+S(S(h*o)+S(g*n))));P[c+8>>2]=l;m=P[b+48>>2];n=P[b+8>>2];o=P[b>>2];q=P[b+4>>2];r=P[b+52>>2];s=P[b+24>>2];v=P[b+16>>2];u=P[b+20>>2];f=P[b+56>>2];h=P[b+40>>2];g=P[b+32>>2];x=P[b+36>>2];L[c+36>>2]=0;w=f;f=P[c+32>>2];B=S(h*f);h=P[c+24>>2];C=S(g*h);g=P[c+28>>2];P[c+32>>2]=w+S(B+S(C+S(x*g)));P[c+28>>2]=r+S(S(f*s)+S(S(h*v)+S(g*u)));P[c+24>>2]=m+S(S(f*n)+S(S(h*o)+S(g*q)));f=P[c+80>>2];h=P[c+72>>2];g=P[c+76>>2];m=P[b+8>>2];n=P[b>>2];o=P[b+4>>2];q=P[b+24>>2];r=P[b+16>>2];s=P[b+20>>2];v=P[b+40>>2];u=P[b+32>>2];x=P[b+36>>2];L[c+84>>2]=0;P[c+80>>2]=S(v*f)+S(S(u*h)+S(g*x));P[c+76>>2]=S(q*f)+S(S(r*h)+S(g*s));P[c+72>>2]=S(m*f)+S(S(n*h)+S(o*g));L[i+28>>2]=0;P[i+24>>2]=d+t;P[i+20>>2]=d+p;P[i+16>>2]=d+l;L[i+12>>2]=0;P[i+8>>2]=t-d;P[i+4>>2]=p-d;P[i>>2]=l-d;Gc(k,L[c+96>>2],i);e=e+1|0;if((j|0)!=(e|0)){continue}break}}ig(a);c=L[a+928>>2];a:{if(c){e=L[a+192>>2];d=S(ha[L[L[e>>2]+48>>2]](e));f=P[c>>2];h=P[c+4>>2];g=P[c+8>>2];L[a+904>>2]=0;P[a+900>>2]=g-d;P[a+896>>2]=h-d;P[a+892>>2]=f-d;f=P[c+20>>2];h=P[c+24>>2];g=P[c+16>>2];L[a+920>>2]=0;P[a+916>>2]=d+h;P[a+912>>2]=d+f;c=a+908|0;P[c>>2]=d+g;e=L[a+188>>2];if(!e){break a}j=L[a+684>>2];k=L[j+32>>2];ha[L[L[k>>2]+16>>2]](k,e,a+892|0,c,L[j+36>>2]);break a}L[a+892>>2]=0;L[a+896>>2]=0;L[a+916>>2]=0;L[a+920>>2]=0;L[a+908>>2]=0;L[a+912>>2]=0;L[a+900>>2]=0;L[a+904>>2]=0}k=L[a+732>>2];if((k|0)>0){A=L[a+740>>2];e=0;c=0;while(1){j=R(c,52)+A|0;y=L[j+8>>2];z=L[j+12>>2];d=S(P[y+16>>2]-P[z+16>>2]);f=S(d*d);d=S(P[y+8>>2]-P[z+8>>2]);g=S(d*d);d=S(P[y+12>>2]-P[z+12>>2]);d=S(_(S(f+S(g+S(d*d)))));P[j+16>>2]=d;P[j+28>>2]=d*d;c=c+1|0;if((k|0)!=(c|0)){continue}break}while(1){c=R(e,52)+A|0;P[c+24>>2]=S(P[L[c+8>>2]+88>>2]+P[L[c+12>>2]+88>>2])/P[L[c+4>>2]+4>>2];e=e+1|0;if((k|0)!=(e|0)){continue}break}}hg(a);e=L[b+12>>2];c=a+1156|0;L[c>>2]=L[b+8>>2];L[c+4>>2]=e;c=L[b+4>>2];L[a+1148>>2]=L[b>>2];L[a+1152>>2]=c;e=L[b+28>>2];c=a+1172|0;L[c>>2]=L[b+24>>2];L[c+4>>2]=e;e=L[b+20>>2];c=a+1164|0;L[c>>2]=L[b+16>>2];L[c+4>>2]=e;e=L[b+36>>2];c=a+1180|0;L[c>>2]=L[b+32>>2];L[c+4>>2]=e;e=L[b+44>>2];c=a+1188|0;L[c>>2]=L[b+40>>2];L[c+4>>2]=e;e=L[b+60>>2];c=a+1204|0;L[c>>2]=L[b+56>>2];L[c+4>>2]=e;c=L[b+52>>2];a=a+1196|0;L[a>>2]=L[b+48>>2];L[a+4>>2]=c;fa=i+32|0}function Ke(a,b,c,d,e){var f=S(0),g=S(0),h=S(0),i=S(0),j=S(0),k=S(0),l=S(0),m=S(0),n=S(0),o=S(0),p=S(0),q=S(0),r=S(0),s=0,t=S(0),u=S(0),v=S(0),w=S(0),x=S(0),y=S(0),z=S(0),A=S(0),B=S(0),C=S(0),D=0,E=S(0);f=S(-1);l=P[a>>2];i=P[b>>2];g=S(l-i);k=P[b+4>>2];u=P[c+4>>2];z=S(k-u);v=P[c>>2];A=S(i-v);q=P[a+4>>2];j=S(q-k);m=S(S(g*z)-S(A*j));h=P[b+8>>2];w=P[c+8>>2];B=S(h-w);r=P[a+8>>2];o=S(r-h);x=S(S(j*B)-S(z*o));y=S(S(o*A)-S(B*g));E=S(S(m*m)+S(S(x*x)+S(y*y)));a:{if(!(E>S(0))){break a}b:{if(!(S(S(r*S(S(g*y)+S(x*S(-j))))+S(S(l*S(S(j*m)+S(y*S(-o))))+S(q*S(S(o*x)+S(m*S(-g))))))>S(0))){j=S(-1);g=S(0);break b}j=S(-1);o=S(h-r);n=S(i-l);p=S(k-q);f=S(S(o*o)+S(S(n*n)+S(p*p)));c:{if(!(f>S(0))){g=S(0);s=0;break c}g=S(1);f=S(S(-S(S(r*o)+S(S(l*n)+S(q*p))))/f);if(f>=S(1)){j=S(S(h*h)+S(S(i*i)+S(k*k)));D=2;s=2;break c}g=S(0);if(f<=S(0)){j=S(S(r*r)+S(S(l*l)+S(q*q)));t=S(1);s=1;break c}g=S(r+S(o*f));j=S(g*g);g=S(l+S(n*f));i=S(g*g);g=S(q+S(p*f));j=S(j+S(i+S(g*g)));t=S(S(1)-f);D=2;g=f;s=3}L[e>>2]=s&1|D;L[d+8>>2]=0;P[d+4>>2]=g;P[d>>2]=t;h=P[b+8>>2];k=P[b+4>>2];i=P[b>>2]}r=S(w-r);q=S(u-q);o=S(v-l);d:{if(!(S(S(h*S(S(A*y)-S(x*z)))+S(S(i*S(S(z*m)-S(y*B)))+S(k*S(S(B*x)-S(m*A)))))>S(0))){f=j;break d}D=j>2];l=S(u-h);v=P[c>>2];n=S(v-i);w=P[c+4>>2];p=S(w-k);C=S(S(l*l)+S(S(n*n)+S(p*p)));f=S(-1);e:{if(!(C>S(0))){break e}g=S(1);f=S(S(-S(S(h*l)+S(S(i*n)+S(k*p))))/C);if(f>=S(1)){t=S(0);s=2;f=S(S(u*u)+S(S(v*v)+S(w*w)));break e}g=S(0);if(f<=S(0)){t=S(1);s=1;f=S(S(h*h)+S(S(i*i)+S(k*k)));break e}t=S(S(1)-f);s=3;g=f;h=S(h+S(l*f));i=S(i+S(n*f));f=S(k+S(p*f));f=S(S(h*h)+S(S(i*i)+S(f*f)))}if(!(D|j>f)){f=j;break d}L[e>>2]=s<<1;P[d+8>>2]=g;P[d+4>>2]=t;L[d>>2]=0}k=P[c+8>>2];h=P[c>>2];l=P[c+4>>2];f:{if(!(S(S(k*S(S(o*y)-S(x*q)))+S(S(h*S(S(q*m)-S(y*r)))+S(l*S(S(r*x)-S(m*o)))))>S(0))){break f}i=S(-1);v=P[a+8>>2];n=S(v-k);w=P[a>>2];p=S(w-h);C=P[a+4>>2];u=S(C-l);j=S(S(n*n)+S(S(p*p)+S(u*u)));g:{if(!(j>S(0))){break g}g=S(1);j=S(S(-S(S(k*n)+S(S(h*p)+S(l*u))))/j);if(j>=S(1)){i=S(S(v*v)+S(S(w*w)+S(C*C)));t=S(0);s=2;break g}g=S(0);if(j<=S(0)){i=S(S(k*k)+S(S(h*h)+S(l*l)));t=S(1);s=1;break g}g=S(k+S(n*j));i=S(g*g);g=S(h+S(p*j));h=S(g*g);g=S(l+S(u*j));i=S(i+S(h+S(g*g)));t=S(S(1)-j);s=3;g=j}if(!(fi)){break f}L[e>>2]=s<<2&4|s>>>1;L[d+4>>2]=0;P[d>>2]=g;P[d+8>>2]=t;f=i}if(!(f>2];g=P[a>>2];j=P[a+4>>2];L[e>>2]=7;j=S(S(S(f*m)+S(S(g*x)+S(y*j)))/E);f=S(y*j);i=S(P[b+4>>2]-f);g=S(x*j);k=S(P[b>>2]-g);h=S(S(A*i)+S(k*S(-z)));l=S(h*h);j=S(m*j);h=S(P[b+8>>2]-j);i=S(S(z*h)+S(i*S(-B)));m=S(i*i);i=S(S(B*k)+S(h*S(-A)));h=S(_(S(l+S(m+S(i*i)))));i=S(_(E));k=S(h/i);P[d>>2]=k;h=S(P[c+4>>2]-f);t=S(P[c>>2]-g);m=S(S(o*h)+S(t*S(-q)));l=S(m*m);m=S(P[c+8>>2]-j);h=S(S(q*m)+S(h*S(-r)));n=S(h*h);h=S(S(r*t)+S(m*S(-o)));i=S(S(_(S(l+S(n+S(h*h)))))/i);P[d+4>>2]=i;P[d+8>>2]=S(1)-S(k+i);f=S(S(j*j)+S(S(g*g)+S(f*f)))}return f}function Ro(a,b,c,d,e,f){a=a|0;b=S(b);c=S(c);d=d|0;e=e|0;f=f|0;var g=0,h=0,i=0;g=fa-480|0;fa=g;L[g+476>>2]=a;P[g+472>>2]=b;P[g+468>>2]=c;L[g+464>>2]=d;L[g+460>>2]=e;L[g+456>>2]=f;a=L[g+476>>2];L[g+452>>2]=30;P[g+432>>2]=0;P[g+428>>2]=0;P[g+424>>2]=0;e=g+436|0;la(e,g+432|0,g+428|0,g+424|0);b=S(-P[g+468>>2]);d=fa-16|0;L[d+12>>2]=e;P[L[d+12>>2]+(L[g+464>>2]<<2)>>2]=b;P[g+404>>2]=0;P[g+400>>2]=0;P[g+396>>2]=0;f=g+408|0;la(f,g+404|0,g+400|0,g+396|0);b=P[g+468>>2];d=fa-16|0;L[d+12>>2]=f;P[L[d+12>>2]+(L[g+464>>2]<<2)>>2]=b;d=g+332|0;Yb(d,L[g+460>>2]);xa(g+316|0,L[g+460>>2],e);e=fa-16|0;L[e+12>>2]=d;h=L[g+320>>2];e=L[e+12>>2]+48|0;L[e>>2]=L[g+316>>2];L[e+4>>2]=h;h=L[g+328>>2];L[e+8>>2]=L[g+324>>2];L[e+12>>2]=h;e=fa-16|0;L[e+12>>2]=d;e=L[e+12>>2]+48|0;h=L[e+12>>2];L[g+304>>2]=L[e+8>>2];L[g+308>>2]=h;h=L[e+4>>2];L[g+296>>2]=L[e>>2];L[g+300>>2]=h;e=fa-16|0;L[e+12>>2]=d;h=g+280|0;nc(h,L[e+12>>2],(L[g+464>>2]+1|0)%3|0);e=fa-16|0;L[e+12>>2]=d;d=g+248|0;nc(d,L[e+12>>2],L[g+464>>2]);e=g+264|0;Zb(e,d);P[g+244>>2]=-1.5707963705062866;P[g+240>>2]=1.5707963705062866;P[g+236>>2]=-1.5707963705062866;P[g+232>>2]=1.5707963705062866;ha[L[L[a>>2]+64>>2]](a,g+296|0,h,e,P[g+472>>2],P[g+244>>2],P[g+240>>2],P[g+236>>2],P[g+232>>2],L[g+456>>2],S(L[g+452>>2]),0);d=g+168|0;Yb(d,L[g+460>>2]);xa(g+152|0,L[g+460>>2],f);e=fa-16|0;L[e+12>>2]=d;f=L[g+156>>2];e=L[e+12>>2]+48|0;L[e>>2]=L[g+152>>2];L[e+4>>2]=f;f=L[g+164>>2];L[e+8>>2]=L[g+160>>2];L[e+12>>2]=f;e=fa-16|0;L[e+12>>2]=d;e=L[e+12>>2]+48|0;f=L[e+12>>2];L[g+144>>2]=L[e+8>>2];L[g+148>>2]=f;f=L[e+4>>2];L[g+136>>2]=L[e>>2];L[g+140>>2]=f;e=fa-16|0;L[e+12>>2]=d;f=g+120|0;nc(f,L[e+12>>2],(L[g+464>>2]+1|0)%3|0);e=fa-16|0;L[e+12>>2]=d;d=g+104|0;nc(d,L[e+12>>2],L[g+464>>2]);P[g+100>>2]=-1.5707963705062866;P[g+96>>2]=1.5707963705062866;P[g+92>>2]=-1.5707963705062866;P[g+88>>2]=1.5707963705062866;ha[L[L[a>>2]+64>>2]](a,g+136|0,f,d,P[g+472>>2],P[g+100>>2],P[g+96>>2],P[g+92>>2],P[g+88>>2],L[g+456>>2],S(L[g+452>>2]),0);d=fa-16|0;L[d+12>>2]=L[g+460>>2];d=L[d+12>>2]+48|0;e=L[d+12>>2];L[g+80>>2]=L[d+8>>2];L[g+84>>2]=e;e=L[d+4>>2];L[g+72>>2]=L[d>>2];L[g+76>>2]=e;L[g+68>>2]=0;while(1){if(L[g+68>>2]<360){b=S(Qa(S(S(L[g+68>>2])*S(.01745329238474369)))*P[g+472>>2]);d=fa-16|0;e=g+436|0;L[d+12>>2]=e;P[L[d+12>>2]+((L[g+464>>2]+1|0)%3<<2)>>2]=b;f=g+408|0;L[d+12>>2]=f;P[L[d+12>>2]+((L[g+464>>2]+1|0)%3<<2)>>2]=b;b=S(Ra(S(S(L[g+68>>2])*S(.01745329238474369)))*P[g+472>>2]);d=fa-16|0;L[d+12>>2]=e;P[L[d+12>>2]+((L[g+464>>2]+2|0)%3<<2)>>2]=b;d=fa-16|0;L[d+12>>2]=f;P[L[d+12>>2]+((L[g+464>>2]+2|0)%3<<2)>>2]=b;d=fa-16|0;L[d+12>>2]=L[g+460>>2];h=g+36|0;ua(h,L[d+12>>2],e);d=g+52|0;e=g+72|0;ta(d,e,h);h=fa-16|0;L[h+12>>2]=L[g+460>>2];i=g+4|0;ua(i,L[h+12>>2],f);f=g+20|0;ta(f,e,i);ha[L[L[a>>2]+8>>2]](a,d,f,L[g+456>>2]);L[g+68>>2]=L[g+452>>2]+L[g+68>>2];continue}break}fa=g+480|0}function ra(a){var b=0,c=0,d=0,e=0,f=0,g=0,h=0;a:{if(!a){break a}d=a-8|0;b=L[a-4>>2];a=b&-8;f=d+a|0;b:{if(b&1){break b}if(!(b&3)){break a}b=L[d>>2];d=d-b|0;if(d>>>0>>0<=255){b=b>>>3|0;e=L[d+12>>2];c=L[d+8>>2];if((e|0)==(c|0)){L[8530]=L[8530]&nI(b);break b}L[c+12>>2]=e;L[e+8>>2]=c;break b}h=L[d+24>>2];b=L[d+12>>2];c:{if((d|0)!=(b|0)){c=L[d+8>>2];L[c+12>>2]=b;L[b+8>>2]=c;break c}d:{e=d+20|0;c=L[e>>2];if(c){break d}e=d+16|0;c=L[e>>2];if(c){break d}b=0;break c}while(1){g=e;b=c;e=b+20|0;c=L[e>>2];if(c){continue}e=b+16|0;c=L[b+16>>2];if(c){continue}break}L[g>>2]=0}if(!h){break b}e=L[d+28>>2];c=(e<<2)+34424|0;e:{if(L[c>>2]==(d|0)){L[c>>2]=b;if(b){break e}L[8531]=L[8531]&nI(e);break b}L[h+(L[h+16>>2]==(d|0)?16:20)>>2]=b;if(!b){break b}}L[b+24>>2]=h;c=L[d+16>>2];if(c){L[b+16>>2]=c;L[c+24>>2]=b}c=L[d+20>>2];if(!c){break b}L[b+20>>2]=c;L[c+24>>2]=b;break b}b=L[f+4>>2];if((b&3)!=3){break b}L[8532]=a;L[f+4>>2]=b&-2;L[d+4>>2]=a|1;L[a+d>>2]=a;return}if(d>>>0>=f>>>0){break a}b=L[f+4>>2];if(!(b&1)){break a}f:{if(!(b&2)){if(L[8536]==(f|0)){L[8536]=d;a=L[8533]+a|0;L[8533]=a;L[d+4>>2]=a|1;if(L[8535]!=(d|0)){break a}L[8532]=0;L[8535]=0;return}if(L[8535]==(f|0)){L[8535]=d;a=L[8532]+a|0;L[8532]=a;L[d+4>>2]=a|1;L[a+d>>2]=a;return}a=(b&-8)+a|0;g:{if(b>>>0<=255){b=b>>>3|0;e=L[f+12>>2];c=L[f+8>>2];if((e|0)==(c|0)){L[8530]=L[8530]&nI(b);break g}L[c+12>>2]=e;L[e+8>>2]=c;break g}h=L[f+24>>2];b=L[f+12>>2];h:{if((f|0)!=(b|0)){c=L[f+8>>2];L[c+12>>2]=b;L[b+8>>2]=c;break h}i:{e=f+20|0;c=L[e>>2];if(c){break i}e=f+16|0;c=L[e>>2];if(c){break i}b=0;break h}while(1){g=e;b=c;e=b+20|0;c=L[e>>2];if(c){continue}e=b+16|0;c=L[b+16>>2];if(c){continue}break}L[g>>2]=0}if(!h){break g}e=L[f+28>>2];c=(e<<2)+34424|0;j:{if(L[c>>2]==(f|0)){L[c>>2]=b;if(b){break j}L[8531]=L[8531]&nI(e);break g}L[h+(L[h+16>>2]==(f|0)?16:20)>>2]=b;if(!b){break g}}L[b+24>>2]=h;c=L[f+16>>2];if(c){L[b+16>>2]=c;L[c+24>>2]=b}c=L[f+20>>2];if(!c){break g}L[b+20>>2]=c;L[c+24>>2]=b}L[d+4>>2]=a|1;L[a+d>>2]=a;if(L[8535]!=(d|0)){break f}L[8532]=a;return}L[f+4>>2]=b&-2;L[d+4>>2]=a|1;L[a+d>>2]=a}if(a>>>0<=255){b=(a&-8)+34160|0;c=L[8530];a=1<<(a>>>3);k:{if(!(c&a)){L[8530]=a|c;a=b;break k}a=L[b+8>>2]}L[b+8>>2]=d;L[a+12>>2]=d;L[d+12>>2]=b;L[d+8>>2]=a;return}e=31;if(a>>>0<=16777215){b=U(a>>>8|0);e=((a>>>38-b&1)-(b<<1)|0)+62|0}L[d+28>>2]=e;L[d+16>>2]=0;L[d+20>>2]=0;g=(e<<2)+34424|0;l:{m:{c=L[8531];b=1<>2]=d;L[d+24>>2]=g;break n}e=a<<((e|0)!=31?25-(e>>>1|0)|0:0);b=L[g>>2];while(1){c=b;if((L[b+4>>2]&-8)==(a|0)){break m}b=e>>>29|0;e=e<<1;g=c+(b&4)|0;b=L[g+16>>2];if(b){continue}break}L[g+16>>2]=d;L[d+24>>2]=c}L[d+12>>2]=d;L[d+8>>2]=d;break l}a=L[c+8>>2];L[a+12>>2]=d;L[c+8>>2]=d;L[d+24>>2]=0;L[d+12>>2]=c;L[d+8>>2]=a}a=L[8538]-1|0;L[8538]=a?a:-1}}function tz(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=S(0),g=S(0),h=S(0),i=S(0),j=S(0),k=S(0),l=S(0),m=S(0),n=S(0),o=S(0),p=S(0),q=S(0),r=S(0),s=S(0),t=S(0),u=S(0),v=S(0),w=S(0),x=S(0),y=S(0),z=S(0),A=S(0),B=S(0),C=S(0),D=S(0),E=S(0),F=S(0),G=S(0),H=S(0),I=S(0),J=S(0),K=S(0),N=S(0),O=S(0),Q=S(0),R=S(0),T=S(0),U=S(0),V=S(0),W=S(0),X=S(0),Y=S(0),Z=S(0),_=S(0),$=S(0),aa=S(0),ba=S(0),ca=S(0),da=S(0),ea=S(0),ga=S(0),ia=S(0),ja=S(0),ka=S(0),la=S(0);d=fa-240|0;fa=d;U=S(1);e=M[a+8|0];a=e?c:b;k=P[a+60>>2];g=S(P[a+124>>2]-k);f=S(g*g);i=P[a+116>>2];u=P[a+52>>2];g=S(i-u);j=S(g*g);w=P[a+56>>2];g=S(P[a+120>>2]-w);f=S(f+S(j+S(g*g)));g=P[a+252>>2];a:{if(f>2];if(L[c+4>>2]-21>>>0>8){break a}h=P[b+12>>2];v=S(-P[b+52>>2]);f=P[b+28>>2];j=P[b+56>>2];l=P[b+44>>2];m=P[b+60>>2];V=S(S(S(h*v)-S(f*j))-S(l*m));n=P[a+124>>2];x=P[a+120>>2];X=S(S(n*l)+S(S(i*h)+S(f*x)));o=P[b+8>>2];p=P[b+24>>2];q=P[b+40>>2];W=S(S(S(o*v)-S(p*j))-S(q*m));g=S(W+S(S(n*q)+S(S(i*o)+S(p*x))));r=P[b+36>>2];y=P[a+92>>2];Y=S(f*y);z=P[a+76>>2];Z=S(z*h);A=P[a+108>>2];B=P[a+88>>2];_=S(f*B);C=P[a+72>>2];$=S(C*h);D=P[a+104>>2];E=P[a+84>>2];aa=S(f*E);F=P[a+68>>2];ba=S(F*h);G=P[a+100>>2];s=P[b+4>>2];ca=S(z*s);t=P[b+20>>2];da=S(t*y);H=P[a+28>>2];ea=S(f*H);I=P[a+12>>2];ga=S(I*h);J=P[a+44>>2];K=P[a+24>>2];ia=S(f*K);N=P[a+8>>2];ja=S(N*h);O=P[a+40>>2];Q=P[a+20>>2];ka=S(f*Q);R=P[a+4>>2];la=S(R*h);T=P[a+36>>2];L[d+236>>2]=0;j=S(S(S(s*v)-S(t*j))-S(r*m));m=S(j+S(S(k*r)+S(S(u*s)+S(t*w))));v=m;i=S(j+S(S(n*r)+S(S(i*s)+S(t*x))));if(i>2]=i;v=i}n=S(W+S(S(k*q)+S(S(u*o)+S(p*w))));j=n;if(g>2]=g;j=g}k=S(V+S(S(k*l)+S(S(u*h)+S(f*w))));f=k;h=S(V+X);if(f>h){P[d+232>>2]=h;f=h}L[d+220>>2]=0;u=f;f=P[a+248>>2];P[d+232>>2]=u-f;P[d+228>>2]=j-f;P[d+224>>2]=v-f;P[d+216>>2]=f+(h>k?h:k);P[d+212>>2]=f+(g>n?g:n);P[d+208>>2]=f+(i>m?i:m);L[d+132>>2]=0;P[d+128>>2]=h;P[d+124>>2]=g;P[d+120>>2]=i;L[d+116>>2]=0;P[d+112>>2]=S(A*l)+S(Z+Y);P[d+108>>2]=S(D*l)+S($+_);P[d+104>>2]=S(G*l)+S(ba+aa);L[d+100>>2]=0;P[d+96>>2]=S(A*q)+S(S(z*o)+S(p*y));P[d+92>>2]=S(D*q)+S(S(C*o)+S(p*B));P[d+88>>2]=S(G*q)+S(S(F*o)+S(p*E));L[d+84>>2]=0;P[d+80>>2]=S(A*r)+S(ca+da);P[d+76>>2]=S(D*r)+S(S(C*s)+S(t*B));L[d+68>>2]=0;P[d- -64>>2]=k;P[d+60>>2]=n;P[d+56>>2]=m;L[d+52>>2]=0;P[d+48>>2]=S(J*l)+S(ga+ea);P[d+44>>2]=S(O*l)+S(ja+ia);P[d+40>>2]=S(T*l)+S(la+ka);L[d+36>>2]=0;P[d+32>>2]=S(J*q)+S(S(I*o)+S(p*H));P[d+28>>2]=S(O*q)+S(S(N*o)+S(p*K));P[d+24>>2]=S(T*q)+S(S(R*o)+S(p*Q));L[d+20>>2]=0;P[d+16>>2]=S(J*r)+S(S(I*s)+S(t*H));P[d+12>>2]=S(O*r)+S(S(N*s)+S(t*K));P[d+200>>2]=f;P[d+72>>2]=S(G*r)+S(S(F*s)+S(t*E));P[d+8>>2]=S(T*r)+S(S(R*s)+S(t*Q));L[d+4>>2]=22104;P[d+204>>2]=P[a+244>>2];ha[L[L[c>>2]+64>>2]](c,d+4|0,d+224|0,d+208|0);g=P[d+204>>2];if(!(g>2])){break a}P[a+244>>2]=g;U=g}fa=d+240|0;return S(U)}function Qn(a,b,c,d,e,f,g,h,i){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;i=i|0;var j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;t=h;q=fa-16|0;fa=q;Kd(a,q+10|0,b,0);Kd(a,q+4|0,c,1);k=L[a+60>>2];h=a;r=N[a+64>>1];p=k+(r<<6)|0;K[a+64>>1]=N[p+48>>1];j=N[a+56>>1]+1|0;K[a+56>>1]=j;L[p+8>>2]=i;K[p+6>>1]=g;K[p+4>>1]=f;L[p>>2]=e;L[p+12>>2]=r;K[k+54>>1]=N[k+54>>1]+2;i=L[a+68>>2];k=j<<1;l=k&65534;j=l<<2;n=j|4;m=i+n|0;o=i;l=l-1|0;i=l<<2;o=o+i|0;o=N[o>>1]|N[o+2>>1]<<16;K[m>>1]=o;K[m+2>>1]=o>>>16;m=N[q+10>>1];o=L[a+68>>2];s=o+i|0;K[s+2>>1]=r;K[s>>1]=m;m=N[q+4>>1];o=j+o|0;K[o+2>>1]=r;K[o>>1]=m;K[p+54>>1]=k;K[p+48>>1]=l;m=L[a+60>>2];K[m+56>>1]=N[m+56>>1]+2;m=L[a+72>>2];o=m+n|0;m=i+m|0;m=N[m>>1]|N[m+2>>1]<<16;K[o>>1]=m;K[o+2>>1]=m>>>16;m=N[q+12>>1];o=L[a+72>>2];s=o+i|0;K[s+2>>1]=r;K[s>>1]=m;m=N[q+6>>1];o=j+o|0;K[o+2>>1]=r;K[o>>1]=m;K[p+56>>1]=k;K[p+50>>1]=l;m=L[a+60>>2];K[m+58>>1]=N[m+58>>1]+2;o=n;n=L[a+76>>2];m=o+n|0;n=i+n|0;n=N[n>>1]|N[n+2>>1]<<16;K[m>>1]=n;K[m+2>>1]=n>>>16;n=N[q+14>>1];o=i;i=L[a+76>>2];m=o+i|0;K[m+2>>1]=r;K[m>>1]=n;n=N[q+8>>1];i=i+j|0;K[i+2>>1]=r;K[i>>1]=n;K[p+58>>1]=k;K[p+52>>1]=l;i=L[a+68>>2];l=N[p+48>>1]<<2;a=i+l|0;k=a-4|0;j=N[k>>1];if(j>>>0>N[a>>1]){l=L[h+60>>2]+(N[(i+l|0)+2>>1]<<6)|0;while(1){i=a-4|0;j=(L[h+60>>2]+(N[i+2>>1]<<6)|0)+(j&1?54:48)|0;K[j>>1]=N[j>>1]+1;K[l+48>>1]=N[l+48>>1]-1;j=N[a>>1]|N[a+2>>1]<<16;n=N[k>>1]|N[k+2>>1]<<16;K[a>>1]=n;K[a+2>>1]=n>>>16;K[k>>1]=j;K[k+2>>1]=j>>>16;k=k-4|0;j=N[k>>1];a=i;if(j>>>0>N[a>>1]){continue}break}i=L[h+68>>2]}l=N[p+54>>1];a=(l<<2)+i|0;k=a-4|0;j=N[k>>1];if(j>>>0>N[a>>1]){l=L[h+60>>2]+(N[((l<<2)+i|0)+2>>1]<<6)|0;while(1){i=a-4|0;j=(L[h+60>>2]+(N[i+2>>1]<<6)|0)+(j&1?54:48)|0;K[j>>1]=N[j>>1]+1;K[l+54>>1]=N[l+54>>1]-1;j=N[a>>1]|N[a+2>>1]<<16;n=N[k>>1]|N[k+2>>1]<<16;K[a>>1]=n;K[a+2>>1]=n>>>16;K[k>>1]=j;K[k+2>>1]=j>>>16;k=k-4|0;j=N[k>>1];a=i;if(j>>>0>N[a>>1]){continue}break}}i=L[h+72>>2];l=N[p+50>>1]<<2;a=i+l|0;k=a-4|0;j=N[k>>1];if(j>>>0>N[a>>1]){l=L[h+60>>2]+(N[(i+l|0)+2>>1]<<6)|0;while(1){i=a-4|0;j=(L[h+60>>2]+(N[i+2>>1]<<6)|0)+(j&1?54:48)|0;K[j+2>>1]=N[j+2>>1]+1;K[l+50>>1]=N[l+50>>1]-1;j=N[a>>1]|N[a+2>>1]<<16;n=N[k>>1]|N[k+2>>1]<<16;K[a>>1]=n;K[a+2>>1]=n>>>16;K[k>>1]=j;K[k+2>>1]=j>>>16;k=k-4|0;j=N[k>>1];a=i;if(j>>>0>N[a>>1]){continue}break}i=L[h+72>>2]}l=N[p+56>>1];a=(l<<2)+i|0;k=a-4|0;j=N[k>>1];if(j>>>0>N[a>>1]){l=L[h+60>>2]+(N[((l<<2)+i|0)+2>>1]<<6)|0;while(1){i=a-4|0;j=(L[h+60>>2]+(N[i+2>>1]<<6)|0)+(j&1?54:48)|0;K[j+2>>1]=N[j+2>>1]+1;K[l+56>>1]=N[l+56>>1]-1;j=N[a>>1]|N[a+2>>1]<<16;n=N[k>>1]|N[k+2>>1]<<16;K[a>>1]=n;K[a+2>>1]=n>>>16;K[k>>1]=j;K[k+2>>1]=j>>>16;k=k-4|0;j=N[k>>1];a=i;if(j>>>0>N[a>>1]){continue}break}}Jd(h,2,N[p+52>>1]);Id(h,2,N[p+58>>1],t);fa=q+16|0;a=L[h+60>>2];h=L[h+108>>2];if(h){L[(a+(r<<6)|0)+60>>2]=ha[L[L[h>>2]+8>>2]](h,b,c,d,e,f,g,t,0)}return a+(r<<6)|0}function MG(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=S(0),g=S(0),h=S(0),i=S(0),j=S(0),k=S(0),l=S(0),m=S(0),n=S(0),o=S(0),p=S(0),q=S(0),r=S(0),s=S(0),t=S(0),u=S(0),v=S(0),w=S(0),x=S(0),y=S(0),z=S(0),A=S(0),B=S(0),C=S(0),D=S(0),E=S(0),F=S(0),G=S(0),H=S(0),I=S(0),J=S(0),K=S(0),N=S(0),O=S(0),Q=S(0),R=S(0),T=S(0),U=S(0),V=S(0),W=S(0),X=S(0),Y=S(0),Z=S(0),_=S(0),$=S(0),aa=S(0),ba=S(0),ca=S(0),da=S(0),ea=S(0),ga=S(0),ia=S(0),ja=S(0),ka=S(0),la=S(0);d=fa-240|0;fa=d;U=S(1);e=M[a+8|0];a=e?c:b;k=P[a+60>>2];g=S(P[a+124>>2]-k);f=S(g*g);i=P[a+116>>2];u=P[a+52>>2];g=S(i-u);j=S(g*g);w=P[a+56>>2];g=S(P[a+120>>2]-w);f=S(f+S(j+S(g*g)));g=P[a+252>>2];a:{if(f>2];if(L[c+4>>2]-21>>>0>8){break a}h=P[b+12>>2];v=S(-P[b+52>>2]);f=P[b+28>>2];j=P[b+56>>2];l=P[b+44>>2];m=P[b+60>>2];V=S(S(S(h*v)-S(f*j))-S(l*m));n=P[a+124>>2];x=P[a+120>>2];X=S(S(n*l)+S(S(i*h)+S(f*x)));o=P[b+8>>2];p=P[b+24>>2];q=P[b+40>>2];W=S(S(S(o*v)-S(p*j))-S(q*m));g=S(W+S(S(n*q)+S(S(i*o)+S(p*x))));r=P[b+36>>2];y=P[a+92>>2];Y=S(f*y);z=P[a+76>>2];Z=S(z*h);A=P[a+108>>2];B=P[a+88>>2];_=S(f*B);C=P[a+72>>2];$=S(C*h);D=P[a+104>>2];E=P[a+84>>2];aa=S(f*E);F=P[a+68>>2];ba=S(F*h);G=P[a+100>>2];s=P[b+4>>2];ca=S(z*s);t=P[b+20>>2];da=S(t*y);H=P[a+28>>2];ea=S(f*H);I=P[a+12>>2];ga=S(I*h);J=P[a+44>>2];K=P[a+24>>2];ia=S(f*K);N=P[a+8>>2];ja=S(N*h);O=P[a+40>>2];Q=P[a+20>>2];ka=S(f*Q);R=P[a+4>>2];la=S(R*h);T=P[a+36>>2];L[d+236>>2]=0;j=S(S(S(s*v)-S(t*j))-S(r*m));m=S(j+S(S(k*r)+S(S(u*s)+S(t*w))));v=m;i=S(j+S(S(n*r)+S(S(i*s)+S(t*x))));if(i>2]=i;v=i}n=S(W+S(S(k*q)+S(S(u*o)+S(p*w))));j=n;if(g>2]=g;j=g}k=S(V+S(S(k*l)+S(S(u*h)+S(f*w))));f=k;h=S(V+X);if(f>h){P[d+232>>2]=h;f=h}L[d+220>>2]=0;u=f;f=P[a+248>>2];P[d+232>>2]=u-f;P[d+228>>2]=j-f;P[d+224>>2]=v-f;P[d+216>>2]=f+(h>k?h:k);P[d+212>>2]=f+(g>n?g:n);P[d+208>>2]=f+(i>m?i:m);L[d+132>>2]=0;P[d+128>>2]=h;P[d+124>>2]=g;P[d+120>>2]=i;L[d+116>>2]=0;P[d+112>>2]=S(A*l)+S(Z+Y);P[d+108>>2]=S(D*l)+S($+_);P[d+104>>2]=S(G*l)+S(ba+aa);L[d+100>>2]=0;P[d+96>>2]=S(A*q)+S(S(z*o)+S(p*y));P[d+92>>2]=S(D*q)+S(S(C*o)+S(p*B));P[d+88>>2]=S(G*q)+S(S(F*o)+S(p*E));L[d+84>>2]=0;P[d+80>>2]=S(A*r)+S(ca+da);P[d+76>>2]=S(D*r)+S(S(C*s)+S(t*B));L[d+68>>2]=0;P[d- -64>>2]=k;P[d+60>>2]=n;P[d+56>>2]=m;L[d+52>>2]=0;P[d+48>>2]=S(J*l)+S(ga+ea);P[d+44>>2]=S(O*l)+S(ja+ia);P[d+40>>2]=S(T*l)+S(la+ka);L[d+36>>2]=0;P[d+32>>2]=S(J*q)+S(S(I*o)+S(p*H));P[d+28>>2]=S(O*q)+S(S(N*o)+S(p*K));P[d+24>>2]=S(T*q)+S(S(R*o)+S(p*Q));L[d+20>>2]=0;P[d+16>>2]=S(J*r)+S(S(I*s)+S(t*H));P[d+12>>2]=S(O*r)+S(S(N*s)+S(t*K));P[d+200>>2]=f;P[d+72>>2]=S(G*r)+S(S(F*s)+S(t*E));P[d+8>>2]=S(T*r)+S(S(R*s)+S(t*Q));L[d+4>>2]=9576;P[d+204>>2]=P[a+244>>2];ha[L[L[c>>2]+64>>2]](c,d+4|0,d+224|0,d+208|0);g=P[d+204>>2];if(!(g>2])){break a}P[a+244>>2]=g;U=g}fa=d+240|0;return S(U)}function _e(a,b,c,d){var e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;if(!(!b|!c)){if(!(L[a+24>>2]>127|L[a+28>>2]>127)){L[8513]=L[8513]+1;l=ha[L[6798]](1024,16)|0;g=L[a+24>>2];a:{if((g|0)<=0){break a}if(g>>>0>=4){p=g&-4;while(1){f=n<<3;i=f+l|0;h=f+L[a+32>>2]|0;m=L[h+4>>2];L[i>>2]=L[h>>2];L[i+4>>2]=m;i=f|8;h=i+l|0;i=i+L[a+32>>2]|0;m=L[i+4>>2];L[h>>2]=L[i>>2];L[h+4>>2]=m;i=f|16;h=i+l|0;i=i+L[a+32>>2]|0;m=L[i+4>>2];L[h>>2]=L[i>>2];L[h+4>>2]=m;f=f|24;i=f+l|0;f=f+L[a+32>>2]|0;h=L[f+4>>2];L[i>>2]=L[f>>2];L[i+4>>2]=h;n=n+4|0;e=e+4|0;if((p|0)!=(e|0)){continue}break}}e=g&3;if(!e){break a}while(1){f=n<<3;g=f+l|0;f=f+L[a+32>>2]|0;p=L[f+4>>2];L[g>>2]=L[f>>2];L[g+4>>2]=p;n=n+1|0;j=j+1|0;if((e|0)!=(j|0)){continue}break}}e=L[a+32>>2];if(!(e?!e|!M[a+36|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](e)}L[a+32>>2]=l;J[a+36|0]=1;L[a+28>>2]=128}L[a+24>>2]=128;e=L[a+32>>2];L[e+4>>2]=c;L[e>>2]=b;b=124;e=1;while(1){j=L[a+32>>2];l=e;e=e-1|0;i=e<<3;c=j+i|0;g=L[c+4>>2];f=L[c>>2];if((b|0)<(e|0)){b=L[a+24>>2];p=b<<1;if(!((p|0)<=L[a+28>>2]|(b|0)>=(p|0))){b:{if(!b){j=0;break b}L[8513]=L[8513]+1;j=ha[L[6798]](b<<4,16)|0;m=L[a+24>>2];if((m|0)<=0){break b}b=0;n=0;if(m>>>0>=4){r=m&-4;c=0;while(1){h=n<<3;k=h+j|0;o=h+L[a+32>>2]|0;q=L[o+4>>2];L[k>>2]=L[o>>2];L[k+4>>2]=q;k=h|8;o=k+j|0;k=k+L[a+32>>2]|0;q=L[k+4>>2];L[o>>2]=L[k>>2];L[o+4>>2]=q;k=h|16;o=k+j|0;k=k+L[a+32>>2]|0;q=L[k+4>>2];L[o>>2]=L[k>>2];L[o+4>>2]=q;h=h|24;k=h+j|0;h=h+L[a+32>>2]|0;o=L[h+4>>2];L[k>>2]=L[h>>2];L[k+4>>2]=o;n=n+4|0;c=c+4|0;if((r|0)!=(c|0)){continue}break}}c=m&3;if(!c){break b}while(1){h=n<<3;m=h+j|0;h=h+L[a+32>>2]|0;r=L[h+4>>2];L[m>>2]=L[h>>2];L[m+4>>2]=r;n=n+1|0;b=b+1|0;if((c|0)!=(b|0)){continue}break}}b=L[a+32>>2];if(!(b?!b|!M[a+36|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+32>>2]=j;J[a+36|0]=1;L[a+28>>2]=p}L[a+24>>2]=p;b=p-4|0}c:{if((f|0)==(g|0)){if(!L[f+40>>2]){break c}c=j+i|0;e=L[f+36>>2];L[c+4>>2]=e;L[c>>2]=e;c=l<<3;e=c+L[a+32>>2]|0;g=L[f+40>>2];L[e+4>>2]=g;L[e>>2]=g;e=L[f+40>>2];c=c+L[a+32>>2]|0;L[c+8>>2]=L[f+36>>2];L[c+12>>2]=e;e=l+2|0;break c}if(!(P[f>>2]<=P[g+16>>2])|!(P[f+16>>2]>=P[g>>2])|(!(P[f+4>>2]<=P[g+20>>2])|!(P[f+20>>2]>=P[g+4>>2]))){break c}if(!(P[f+8>>2]<=P[g+24>>2])|!(P[f+24>>2]>=P[g+8>>2])){break c}c=L[g+40>>2];if(L[f+40>>2]){e=L[f+36>>2];if(c){c=j+i|0;L[c+4>>2]=L[g+36>>2];L[c>>2]=e;e=L[f+40>>2];c=l<<3;j=c+L[a+32>>2]|0;L[j+4>>2]=L[g+36>>2];L[j>>2]=e;e=L[f+36>>2];j=c+L[a+32>>2]|0;L[j+12>>2]=L[g+40>>2];L[j+8>>2]=e;e=L[f+40>>2];c=c+L[a+32>>2]|0;L[c+20>>2]=L[g+40>>2];L[c+16>>2]=e;e=l+3|0;break c}c=j+i|0;L[c+4>>2]=g;L[c>>2]=e;c=L[f+40>>2];e=L[a+32>>2]+(l<<3)|0;L[e+4>>2]=g;L[e>>2]=c;e=l+1|0;break c}if(c){c=j+i|0;L[c+4>>2]=L[g+36>>2];L[c>>2]=f;c=L[a+32>>2]+(l<<3)|0;L[c+4>>2]=L[g+40>>2];L[c>>2]=f;e=l+1|0;break c}ha[L[L[d>>2]+8>>2]](d,f,g)}if(e){continue}break}}}function gh(a,b){var c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0;L[a>>2]=10328;L[8513]=L[8513]+1;c=ha[L[6798]](360,16)|0;L[c+308>>2]=953267991;J[c+332|0]=M[c+332|0]&240;L[a+24>>2]=c;c=L[b+20>>2];L[8513]=L[8513]+1;e=ha[L[6798]](4,16)|0;L[e>>2]=(c?18484:18644)+8;L[a+28>>2]=e;L[8513]=L[8513]+1;c=ha[L[6798]](24,16)|0;e=L[a+24>>2];f=L[a+28>>2];L[c+16>>2]=0;L[c+20>>2]=3;J[c+4|0]=0;L[c+12>>2]=e;L[c+8>>2]=f;L[c>>2]=8816;L[a+32>>2]=c;L[8513]=L[8513]+1;c=ha[L[6798]](8,16)|0;L[c>>2]=10444;J[c+4|0]=0;L[a+36>>2]=c;L[8513]=L[8513]+1;c=ha[L[6798]](8,16)|0;L[c>>2]=10568;J[c+4|0]=0;L[a+40>>2]=c;L[8513]=L[8513]+1;c=ha[L[6798]](8,16)|0;L[c>>2]=10660;J[c+4|0]=0;L[a+44>>2]=c;L[8513]=L[8513]+1;c=ha[L[6798]](8,16)|0;L[c>>2]=10740;J[c+4|0]=0;L[a+48>>2]=c;L[8513]=L[8513]+1;c=ha[L[6798]](8,16)|0;L[c>>2]=10828;J[c+4|0]=0;L[a+52>>2]=c;L[8513]=L[8513]+1;c=ha[L[6798]](8,16)|0;L[c>>2]=10912;J[c+4|0]=0;L[a+56>>2]=c;L[8513]=L[8513]+1;c=ha[L[6798]](8,16)|0;L[c>>2]=10980;J[c+4|0]=0;L[a+60>>2]=c;L[8513]=L[8513]+1;c=ha[L[6798]](8,16)|0;L[c>>2]=11064;J[c+4|0]=0;L[a+76>>2]=c;L[8513]=L[8513]+1;c=ha[L[6798]](8,16)|0;L[c>>2]=11064;L[a+80>>2]=c;J[c+4|0]=1;L[8513]=L[8513]+1;c=ha[L[6798]](8,16)|0;L[c>>2]=11148;J[c+4|0]=0;L[a+72>>2]=c;L[8513]=L[8513]+1;c=ha[L[6798]](16,16)|0;L[c+8>>2]=1;L[c+12>>2]=0;L[c>>2]=11224;J[c+4|0]=0;L[a+88>>2]=c;L[8513]=L[8513]+1;c=ha[L[6798]](16,16)|0;L[c+8>>2]=1;L[c+12>>2]=0;L[c>>2]=11224;L[a+84>>2]=c;J[c+4|0]=1;i=L[b+16>>2];g=L[b>>2];a:{if(g){J[a+12|0]=0;break a}J[a+12|0]=1;L[8513]=L[8513]+1;g=ha[L[6798]](20,16)|0;c=L[b+8>>2];L[g+4>>2]=c;L[g>>2]=772;L[8513]=L[8513]+1;c=ha[L[6798]](R(c,772),16)|0;L[g+12>>2]=c;L[g+16>>2]=c;j=L[g+4>>2];L[g+8>>2]=j;e=j-1|0;b:{if(!e){break b}f=L[g>>2];k=e&7;if(k){while(1){d=c;c=c+f|0;L[d>>2]=c;e=e-1|0;h=h+1|0;if((k|0)!=(h|0)){continue}break}}if(j-2>>>0<7){break b}while(1){d=c;c=c+f|0;L[d>>2]=c;d=c;c=c+f|0;L[d>>2]=c;d=c;c=c+f|0;L[d>>2]=c;d=c;c=c+f|0;L[d>>2]=c;d=c;c=c+f|0;L[d>>2]=c;d=c;c=c+f|0;L[d>>2]=c;d=c;c=c+f|0;L[d>>2]=c;d=c;c=c+f|0;L[d>>2]=c;e=e-8|0;if(e){continue}break}}L[c>>2]=0}L[a+8>>2]=g;c=L[b+4>>2];if(c){J[a+20|0]=0;L[a+16>>2]=c;return a}J[a+20|0]=1;L[8513]=L[8513]+1;f=ha[L[6798]](20,16)|0;b=L[b+12>>2];L[f+4>>2]=b;c=(i|0)<=36?36:i;c=c>>>0<=80?80:c;L[f>>2]=c;L[8513]=L[8513]+1;c=ha[L[6798]](R(b,c),16)|0;L[f+12>>2]=c;L[f+16>>2]=c;g=L[f+4>>2];L[f+8>>2]=g;e=g-1|0;c:{if(!e){break c}b=L[f>>2];i=e&7;if(i){h=0;while(1){d=c;c=b+c|0;L[d>>2]=c;e=e-1|0;h=h+1|0;if((i|0)!=(h|0)){continue}break}}if(g-2>>>0<7){break c}while(1){d=c;c=b+c|0;L[d>>2]=c;d=c;c=b+c|0;L[d>>2]=c;d=c;c=b+c|0;L[d>>2]=c;d=c;c=b+c|0;L[d>>2]=c;d=c;c=b+c|0;L[d>>2]=c;d=c;c=b+c|0;L[d>>2]=c;d=c;c=b+c|0;L[d>>2]=c;d=c;c=b+c|0;L[d>>2]=c;e=e-8|0;if(e){continue}break}}L[c>>2]=0;L[a+16>>2]=f;return a}function Em(a,b,c,d,e,f,g){var h=S(0),i=S(0),j=0,k=0,l=S(0),m=S(0),n=S(0),o=S(0),p=S(0),q=S(0),r=S(0),s=0,t=S(0),u=0,v=S(0),w=S(0),x=S(0),y=S(0),z=S(0),A=S(0),B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,M=0,O=0,Q=0,R=0,T=0,U=0;k=fa-32|0;fa=k;x=P[c+4>>2];y=P[d+4>>2];z=P[c>>2];A=P[d>>2];n=P[a+28>>2];p=P[a+12>>2];v=P[d+8>>2];w=P[c+8>>2];h=S((v>2]);h=h>2];h=S(S((h>n?n:h)-p)*l);a:{if(h=S(0)){C=~~h>>>0;break a}C=0}o=P[a+24>>2];q=P[a+8>>2];h=S((x>y?y:x)+P[e+4>>2]);h=h>2];h=S(S((h>o?o:h)-q)*t);b:{if(h=S(0)){B=~~h>>>0;break b}B=0}m=P[a+20>>2];r=P[a+4>>2];h=S((z>A?A:z)+P[e>>2]);h=h>2];h=S(S((h>m?m:h)-r)*i);c:{if(h=S(0)){u=~~h>>>0;break c}u=0}h=S((v>w?v:w)+P[f+8>>2]);h=hn?n:h)-p)*l)+S(1));d:{if(h=S(0)){s=~~h>>>0;break d}s=0}h=S((x>2]);h=ho?o:h)-q)*t)+S(1));e:{if(h=S(0)){j=~~h>>>0;break e}j=0}h=S((z>2]);h=hm?m:h)-r)*i)+S(1));f:{if(h=S(0)){d=~~h>>>0;break f}d=0}if((g|0)>0){i=S(v-w);m=S(A-z);t=S(y-x);h=S(S(1)/S(_(S(S(i*i)+S(S(m*m)+S(t*t))))));l=S(i*h);n=S(l*i);i=S(m*h);h=S(t*h);t=S(n+S(S(i*m)+S(t*h)));G=C&65534;H=B&65534;I=u&65534;J=s|1;K=j|1;M=d|1;d=L[a+136>>2];p=l==S(0)?S(0xde0b6b000000000):S(S(1)/l);s=p>2];u=0;g:{h:{i:{j:{if(N[d+6>>1]>>0){break j}B=N[d>>1];if(M>>>0>>0|N[d+10>>1]>>0){break j}s=N[d+4>>1];if(N[d+8>>1]>>0|s>>>0>J>>>0){break j}j=N[d+2>>1];if(j>>>0>K>>>0){break j}v=P[a+4>>2];w=P[a+36>>2];n=P[a+8>>2];o=P[a+40>>2];m=P[a+12>>2];l=P[a+44>>2];L[k+12>>2]=0;i=S(m+S(S(s>>>0)/l));P[k+8>>2]=i;h=S(n+S(S(j>>>0)/o));P[k+4>>2]=h;u=N[d+10>>1];s=N[d+8>>1];j=N[d+6>>1];L[k+28>>2]=0;P[k>>2]=S(v+S(S(B>>>0)/w))-P[f>>2];P[k+4>>2]=h-P[f+4>>2];P[k+8>>2]=i-P[f+8>>2];P[k+16>>2]=S(v+S(S(j>>>0)/w))-P[e>>2];P[k+20>>2]=S(n+S(S(s>>>0)/o))-P[e+4>>2];P[k+24>>2]=S(m+S(S(u>>>0)/l))-P[e+8>>2];k:{i=P[c>>2];l=S(r*S(P[U>>2]-i));h=P[c+4>>2];n=S(q*S(P[T>>2]-h));if(l>n){break k}h=S(q*S(P[Q>>2]-h));o=S(r*S(P[C>>2]-i));if(h>o){break k}m=h>l?h:l;h=P[c+8>>2];l=S(p*S(P[R>>2]-h));if(m>l){break k}i=S(p*S(P[O>>2]-h));h=nh){break k}u=t>(i>m?i:m)&(h>l?l:h)>S(0);if(!u|(F|0)<0){break j}j=L[d+12>>2];ha[L[L[b>>2]+8>>2]](b,j>>21,j&2097151);break i}u=0}if((F|0)>=0){break i}if(!u){break h}}D=D+1|0;d=d+16|0;break g}j=L[d+12>>2];D=D-j|0;d=d-(j<<4)|0}E=E+1|0;if((g|0)>(D|0)){continue}break}}if(L[7548]<(E|0)){L[7548]=E}fa=k+32|0}function Ln(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0;l=fa-16|0;fa=l;c=L[a+92>>2];if(ha[L[L[c>>2]+56>>2]](c)|0){c=L[a+92>>2];e=ha[L[L[c>>2]+28>>2]](c)|0;d=L[e+4>>2];if((d|0)>=2){jc(e,l+15|0,0,d-1|0);d=L[e+4>>2]}i=L[a+104>>2];g=d-i|0;a:{if((i|0)>=0){break a}if(L[e+8>>2]<(g|0)){if(g){L[8513]=L[8513]+1;h=ha[L[6798]](g<<4,16)|0;c=L[e+4>>2]}else{c=d}if((c|0)>0){while(1){k=f<<4;j=k+h|0;k=k+L[e+12>>2]|0;L[j>>2]=L[k>>2];L[j+4>>2]=L[k+4>>2];L[j+8>>2]=L[k+8>>2];L[j+12>>2]=L[k+12>>2];f=f+1|0;if((c|0)!=(f|0)){continue}break}}c=L[e+12>>2];if(!(c?!c|!M[e+16|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](c)}L[e+12>>2]=h;J[e+16|0]=1;L[e+8>>2]=g}f=0;h=0-i&3;if(h){while(1){c=L[e+12>>2]+(d<<4)|0;L[c>>2]=0;L[c+4>>2]=0;L[c+8>>2]=0;L[c+12>>2]=0;d=d+1|0;f=f+1|0;if((h|0)!=(f|0)){continue}break}}if(i>>>0>4294967292){break a}while(1){c=d<<4;f=c+L[e+12>>2]|0;L[f>>2]=0;L[f+4>>2]=0;L[f+8>>2]=0;L[f+12>>2]=0;f=c+L[e+12>>2]|0;L[f+24>>2]=0;L[f+28>>2]=0;L[f+16>>2]=0;L[f+20>>2]=0;f=c+L[e+12>>2]|0;L[f+40>>2]=0;L[f+44>>2]=0;L[f+32>>2]=0;L[f+36>>2]=0;c=c+L[e+12>>2]|0;L[c+56>>2]=0;L[c+60>>2]=0;L[c+48>>2]=0;L[c+52>>2]=0;d=d+4|0;if((g|0)!=(d|0)){continue}break}}L[e+4>>2]=g;L[a+104>>2]=0;if((g|0)>0){i=0;j=0;h=0;f=0;while(1){d=L[e+12>>2]+(j<<4)|0;c=L[d+4>>2];k=h;h=L[d>>2];b:{c:{if((k|0)==(h|0)&(c|0)==(f|0)|N[h+54>>1]>1]|(N[c+54>>1]>1]|N[h+56>>1]>1])){break c}if(N[c+56>>1]>1]|N[h+58>>1]>1]){break c}if(N[c+58>>1]>=N[h+52>>1]){break b}}g=L[a+92>>2];ha[L[L[g>>2]+32>>2]](g,d,b);L[d>>2]=0;L[d+4>>2]=0;i=L[a+104>>2]+1|0;L[a+104>>2]=i;L[7536]=L[7536]-1;g=L[e+4>>2]}f=c;j=j+1|0;if((j|0)<(g|0)){continue}break}if((g|0)>=2){jc(e,l+14|0,0,g-1|0);i=L[a+104>>2];g=L[e+4>>2]}b=g-i|0;d:{if((i|0)>=0){break d}if((b|0)>L[e+8>>2]){h=0;e:{if((g|0)==(i|0)){break e}L[8513]=L[8513]+1;h=ha[L[6798]](b<<4,16)|0;j=L[e+4>>2];if((j|0)<=0){break e}f=0;while(1){d=f<<4;c=d+h|0;d=d+L[e+12>>2]|0;L[c>>2]=L[d>>2];L[c+4>>2]=L[d+4>>2];L[c+8>>2]=L[d+8>>2];L[c+12>>2]=L[d+12>>2];f=f+1|0;if((j|0)!=(f|0)){continue}break}}c=L[e+12>>2];if(!(c?!c|!M[e+16|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](c)}L[e+12>>2]=h;J[e+16|0]=1;L[e+8>>2]=b}d=0;f=0-i&3;if(f){while(1){c=L[e+12>>2]+(g<<4)|0;L[c>>2]=0;L[c+4>>2]=0;L[c+8>>2]=0;L[c+12>>2]=0;g=g+1|0;d=d+1|0;if((f|0)!=(d|0)){continue}break}}if(i>>>0>4294967292){break d}while(1){c=g<<4;d=c+L[e+12>>2]|0;L[d>>2]=0;L[d+4>>2]=0;L[d+8>>2]=0;L[d+12>>2]=0;d=c+L[e+12>>2]|0;L[d+24>>2]=0;L[d+28>>2]=0;L[d+16>>2]=0;L[d+20>>2]=0;d=c+L[e+12>>2]|0;L[d+40>>2]=0;L[d+44>>2]=0;L[d+32>>2]=0;L[d+36>>2]=0;c=c+L[e+12>>2]|0;L[c+56>>2]=0;L[c+60>>2]=0;L[c+48>>2]=0;L[c+52>>2]=0;g=g+4|0;if((b|0)!=(g|0)){continue}break}}}else{b=g}L[e+4>>2]=b;L[a+104>>2]=0}fa=l+16|0}function sl(a,b,c){var d=0,e=S(0),f=S(0),g=S(0),h=S(0),i=S(0),j=S(0),k=S(0),l=S(0),m=S(0),n=S(0),o=S(0),p=S(0),q=0,r=S(0),s=S(0),t=S(0);d=fa-240|0;fa=d;h=P[c>>2];f=P[c+4>>2];e=P[c+8>>2];L[a+124>>2]=0;P[a+120>>2]=e+P[a+100>>2];P[a+116>>2]=f+P[a+96>>2];P[a+112>>2]=h+P[a+92>>2];L[d+188>>2]=0;L[d+192>>2]=0;L[d+200>>2]=0;L[d+204>>2]=0;L[d+196>>2]=1065353216;L[d+208>>2]=0;L[d+212>>2]=0;L[d+216>>2]=1065353216;L[d+220>>2]=0;L[d+124>>2]=0;L[d+128>>2]=0;L[d+136>>2]=0;L[d+140>>2]=0;L[d+132>>2]=1065353216;L[d+144>>2]=0;L[d+148>>2]=0;L[d+152>>2]=1065353216;L[d+156>>2]=0;L[d+180>>2]=0;L[d+184>>2]=0;L[d+176>>2]=1065353216;L[d+116>>2]=0;L[d+120>>2]=0;L[d+112>>2]=1065353216;q=10;r=S(1);while(1){a:{if(!q){break a}c=L[a+96>>2];L[d+224>>2]=L[a+92>>2];L[d+228>>2]=c;c=L[a+104>>2];L[d+232>>2]=L[a+100>>2];L[d+236>>2]=c;c=L[a+124>>2];L[d+168>>2]=L[a+120>>2];L[d+172>>2]=c;c=L[a+116>>2];L[d+160>>2]=L[a+112>>2];L[d+164>>2]=c;k=P[a+92>>2];l=P[a+112>>2];m=P[a+96>>2];h=P[a+116>>2];f=P[a+100>>2];e=P[a+120>>2];c=L[a+8>>2];L[d+84>>2]=0;L[d+12>>2]=1065353216;L[d+44>>2]=0;L[d+48>>2]=0;L[d+36>>2]=0;L[d+40>>2]=0;L[d+28>>2]=0;L[d+32>>2]=0;L[d+20>>2]=0;L[d+24>>2]=0;L[d+104>>2]=0;L[d+108>>2]=0;P[d+100>>2]=f-e;P[d+96>>2]=m-h;P[d+92>>2]=k-l;L[d+88>>2]=c;L[d+8>>2]=19308;c=L[c+188>>2];K[d+16>>1]=N[c+4>>1];K[d+18>>1]=N[c+6>>1];c=L[a+12>>2];e=S(ha[L[L[c>>2]+48>>2]](c));c=L[a+12>>2];ha[L[L[c>>2]+44>>2]](c,S(e+P[a+56>>2]));b:{if(M[a+170|0]){Ec(L[a+8>>2],L[a+12>>2],d+176|0,d+112|0,d+8|0,P[b+56>>2]);break b}Ab(b,L[a+12>>2],d+176|0,d+112|0,d+8|0,P[b+56>>2])}c=L[a+12>>2];ha[L[L[c>>2]+44>>2]](c,e);t=P[d+12>>2];c:{if(t>2];i=S(P[a+120>>2]-k);l=P[a+92>>2];g=S(P[a+112>>2]-l);m=P[a+96>>2];f=S(P[a+116>>2]-m);e=S(S(i*i)+S(S(g*g)+S(f*f)));j=S(_(e));if(j>S(1.1920928955078125e-7)){n=P[d+60>>2];o=P[d+52>>2];p=P[d+56>>2];c=L[a+96>>2];L[a+112>>2]=L[a+92>>2];L[a+116>>2]=c;c=L[a+104>>2];L[a+120>>2]=L[a+100>>2];L[a+124>>2]=c;e=f;f=S(S(1)/j);e=S(e*f);s=e;h=S(i*f);f=S(g*f);e=S(S(n*h)+S(S(o*f)+S(e*p)));g=S(e+e);e=S(s-S(p*g));s=e;i=S(h-S(n*g));g=S(f-S(o*g));e=S(S(1)/S(_(S(S(i*i)+S(S(g*g)+S(e*e))))));h=S(s*e);f=S(i*e);e=S(g*e);g=S(S(n*f)+S(S(o*e)+S(p*h)));h=S(P[a+116>>2]+S(j*S(h-S(p*g))));P[a+116>>2]=h;f=S(P[a+120>>2]+S(j*S(f-S(n*g))));P[a+120>>2]=f;e=S(P[a+112>>2]+S(j*S(e-S(o*g))));P[a+112>>2]=e;i=S(f-k);g=S(e-l);f=S(h-m);e=S(S(i*i)+S(S(g*g)+S(f*f)))}if(!(e>S(1.1920928955078125e-7))){break a}e=S(S(1)/S(_(e)));if(!(S(S(S(i*e)*P[a+84>>2])+S(S(S(g*e)*P[a+76>>2])+S(S(f*e)*P[a+80>>2])))<=S(0))){break c}break a}c=L[a+116>>2];L[a+92>>2]=L[a+112>>2];L[a+96>>2]=c;c=L[a+124>>2];L[a+100>>2]=L[a+120>>2];L[a+104>>2]=c}q=q-1|0;r=S(r-t);if(r>S(.009999999776482582)){continue}}break}fa=d+240|0}function Il(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;var g=0,h=S(0),i=S(0),j=S(0),k=S(0),l=S(0),m=S(0),n=0,o=S(0),p=S(0),q=0,r=S(0),s=S(0),t=0,u=S(0),v=S(0),w=S(0),x=S(0);g=fa-304|0;fa=g;h=P[b+52>>2];k=P[c+52>>2];l=P[b+56>>2];i=P[c+56>>2];m=P[b+48>>2];j=P[c+48>>2];L[g+300>>2]=0;p=S(i-l);P[g+296>>2]=p;o=S(k-h);P[g+292>>2]=o;u=S(j-m);P[g+288>>2]=u;t=c;c=g+116|0;n=g+52|0;ec(b,t,c,n);L[g+284>>2]=0;h=P[g+52>>2];k=S(h*P[g+124>>2]);P[g+280>>2]=k;l=S(h*P[g+120>>2]);P[g+276>>2]=l;h=S(h*P[g+116>>2]);P[g+272>>2]=h;i=P[d+52>>2];m=P[e+52>>2];j=P[d+56>>2];r=P[e+56>>2];s=P[d+48>>2];x=P[e+48>>2];L[g+268>>2]=0;v=S(r-j);P[g+264>>2]=v;w=S(m-i);P[g+260>>2]=w;s=S(x-s);P[g+256>>2]=s;ec(d,e,c,n);L[g+252>>2]=0;i=P[g+52>>2];m=S(i*P[g+124>>2]);P[g+248>>2]=m;j=S(i*P[g+120>>2]);P[g+244>>2]=j;i=S(i*P[g+116>>2]);P[g+240>>2]=i;c=L[a+12>>2];k=S(S(_(S(S(k*k)+S(S(h*h)+S(l*l)))))*S(ha[L[L[c>>2]+16>>2]](c)));c=L[a+16>>2];if(c){h=S(ha[L[L[c>>2]+16>>2]](c))}else{h=S(0)}r=S(k+S(h*S(_(S(S(m*m)+S(S(i*i)+S(j*j)))))));l=S(v-p);i=S(s-u);m=S(w-o);a:{if(S(r+S(_(S(S(l*l)+S(S(i*i)+S(m*m))))))==S(0)){break a}J[g+220|0]=0;L[g+216>>2]=1566444395;L[g+180>>2]=18332;Jl(a,b,d,g+180|0);c=L[g+212>>2];L[g+232>>2]=L[g+208>>2];L[g+236>>2]=c;c=L[g+204>>2];L[g+224>>2]=L[g+200>>2];L[g+228>>2]=c;if(!M[g+220|0]){break a}k=P[g+192>>2];j=P[g+184>>2];p=P[g+188>>2];if(S(r+S(S(l*k)+S(S(i*j)+S(m*p))))<=S(1.1920928955078125e-7)){break a}b:{o=S(P[g+216>>2]+P[f+172>>2]);c:{if(!(o>S(.0010000000474974513))){h=S(0);l=P[g+196>>2];break c}e=g+28|0;t=g+164|0;c=0;h=S(0);while(1){q=L[f+168>>2];if(q){L[g+124>>2]=1065353216;L[g+128>>2]=0;L[g+116>>2]=1065353216;L[g+120>>2]=1065353216;ha[L[L[q>>2]+20>>2]](q,g+224|0,S(.20000000298023224),g+116|0)}q=0;j=S(r+S(S(l*k)+S(S(i*j)+S(m*p))));if(j<=S(1.1920928955078125e-7)){break a}k=h;h=S(h+S(o/j));if(k>=h|h>S(1)|h>2];if(n){L[g+16>>2]=0;L[g+20>>2]=0;L[g+8>>2]=1065353216;L[g+12>>2]=0;ha[L[L[n>>2]+20>>2]](n,t,S(.20000000298023224),g+8|0)}ha[L[L[f>>2]>>2]](f,h);J[g+48|0]=0;L[g+44>>2]=1566444395;L[g+8>>2]=18332;Jl(a,g+116|0,g+52|0,g+8|0);if(!M[g+48|0]){break b}o=P[f+172>>2];n=L[e+12>>2];L[g+232>>2]=L[e+8>>2];L[g+236>>2]=n;n=L[e+4>>2];L[g+224>>2]=L[e>>2];L[g+228>>2]=n;if((c|0)==64){ha[L[L[f>>2]+8>>2]](f,-2,65);break a}c=c+1|0;j=P[g+12>>2];p=P[g+16>>2];k=P[g+20>>2];o=S(P[g+44>>2]+o);if(o>S(.0010000000474974513)){continue}break}l=P[g+24>>2]}P[f+132>>2]=j;P[f+164>>2]=h;P[f+144>>2]=l;P[f+140>>2]=k;P[f+136>>2]=p;a=L[g+228>>2];L[f+148>>2]=L[g+224>>2];L[f+152>>2]=a;a=L[g+236>>2];L[f+156>>2]=L[g+232>>2];L[f+160>>2]=a;q=1;break a}ha[L[L[f>>2]+8>>2]](f,-1,c)}fa=g+304|0;return q|0}function Eg(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,i=S(0),j=S(0),k=S(0),l=S(0),m=S(0),n=S(0),o=S(0),p=S(0),q=S(0),r=0,s=0,t=S(0),u=S(0),v=S(0);g=fa-272|0;fa=g;He(L[a+4>>2]);j=P[b+52>>2];i=P[c+52>>2];n=P[d+52>>2];k=P[e+52>>2];l=P[b+56>>2];m=P[c+56>>2];o=P[d+56>>2];p=P[e+56>>2];q=P[b+48>>2];t=P[c+48>>2];u=P[d+48>>2];v=P[e+48>>2];J[g+252|0]=0;L[g+248>>2]=1566444395;L[g+212>>2]=18332;r=yg(g+132|0,L[a+8>>2],L[a+12>>2],L[a+4>>2],0);L[g+128>>2]=1566444395;a=L[b+12>>2];L[g+8>>2]=L[b+8>>2];L[g+12>>2]=a;a=L[b+4>>2];L[g>>2]=L[b>>2];L[g+4>>2]=a;a=L[b+28>>2];L[g+24>>2]=L[b+24>>2];L[g+28>>2]=a;a=L[b+20>>2];L[g+16>>2]=L[b+16>>2];L[g+20>>2]=a;a=L[b+44>>2];L[g+40>>2]=L[b+40>>2];L[g+44>>2]=a;a=L[b+36>>2];L[g+32>>2]=L[b+32>>2];L[g+36>>2]=a;a=L[b+60>>2];L[g+56>>2]=L[b+56>>2];L[g+60>>2]=a;a=L[b+52>>2];L[g+48>>2]=L[b+48>>2];L[g+52>>2]=a;a=L[d+12>>2];L[g+72>>2]=L[d+8>>2];L[g+76>>2]=a;a=L[d+4>>2];L[g+64>>2]=L[d>>2];L[g+68>>2]=a;a=L[d+20>>2];L[g+80>>2]=L[d+16>>2];L[g+84>>2]=a;a=L[d+28>>2];L[g+88>>2]=L[d+24>>2];L[g+92>>2]=a;a=L[d+44>>2];L[g+104>>2]=L[d+40>>2];L[g+108>>2]=a;a=L[d+36>>2];L[g+96>>2]=L[d+32>>2];L[g+100>>2]=a;a=L[d+52>>2];L[g+112>>2]=L[d+48>>2];L[g+116>>2]=a;a=L[d+60>>2];L[g+120>>2]=L[d+56>>2];L[g+124>>2]=a;wb(r,g,g+212|0,0,0);a=L[g+244>>2];L[g+264>>2]=L[g+240>>2];L[g+268>>2]=a;a=L[g+236>>2];L[g+256>>2]=L[g+232>>2];L[g+260>>2]=a;h=0;a:{if(!M[g+252|0]){break a}o=S(S(m-l)-S(p-o));p=S(S(i-j)-S(k-n));q=S(S(t-q)-S(v-u));k=P[g+224>>2];l=P[g+220>>2];m=P[g+216>>2];i=P[g+248>>2];b:{c:{if(!(i>S(.0010000000474974513))){j=S(0);i=P[g+228>>2];break c}s=g+232|0;a=0;n=S(0);while(1){h=0;if((a|0)==32){break a}j=S(n-S(i/S(S(o*k)+S(S(q*m)+S(p*l)))));h=0;if(n>=j){break a}h=0;if(j>S(1)){break a}h=0;if(j>2]>>2]](f,j);i=S(S(1)-j);P[g+48>>2]=S(i*P[b+48>>2])+S(j*P[c+48>>2]);P[g+52>>2]=S(i*P[b+52>>2])+S(j*P[c+52>>2]);P[g+56>>2]=S(i*P[b+56>>2])+S(j*P[c+56>>2]);P[g+112>>2]=S(i*P[d+48>>2])+S(j*P[e+48>>2]);P[g+116>>2]=S(i*P[d+52>>2])+S(j*P[e+52>>2]);P[g+120>>2]=S(i*P[d+56>>2])+S(j*P[e+56>>2]);wb(r,g,g+212|0,0,0);h=0;if(!M[g+252|0]){break a}i=P[g+248>>2];if(i>2]=j;i=P[g+228>>2];k=P[g+224>>2];l=P[g+220>>2];m=P[g+216>>2];break b}a=a+1|0;h=L[g+244>>2];L[g+264>>2]=L[g+240>>2];L[g+268>>2]=h;h=L[g+236>>2];L[g+256>>2]=L[g+232>>2];L[g+260>>2]=h;k=P[g+224>>2];l=P[g+220>>2];m=P[g+216>>2];n=j;if(i>S(.0010000000474974513)){continue}break}i=P[g+228>>2]}h=0;if(S(-P[f+172>>2])<=S(S(k*o)+S(S(m*q)+S(p*l)))){break a}P[f+164>>2]=j;s=g+256|0}P[f+132>>2]=m;P[f+144>>2]=i;P[f+140>>2]=k;P[f+136>>2]=l;a=s;b=L[a+4>>2];L[f+148>>2]=L[a>>2];L[f+152>>2]=b;b=L[a+12>>2];L[f+156>>2]=L[a+8>>2];L[f+160>>2]=b;h=1}fa=g+272|0;return h|0}function lp(a,b,c,d,e,f,g,h,i,j,k){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;i=i|0;j=j|0;k=k|0;var l=0,m=S(0),n=S(0),o=S(0),p=S(0),q=S(0),r=0,s=0,t=0,u=S(0),v=S(0),w=S(0),x=0,y=0,z=0,A=S(0),B=0;l=fa-48|0;fa=l;L[l+44>>2]=a;L[l+40>>2]=b;L[l+36>>2]=c;L[l+32>>2]=d;L[l+28>>2]=e;L[l+24>>2]=f;L[l+20>>2]=g;L[l+16>>2]=h;L[l+12>>2]=i;J[l+11|0]=j;L[l+4>>2]=k;t=L[l+40>>2];h=L[l+36>>2];i=L[l+32>>2];j=L[l+28>>2];k=L[l+24>>2];b=L[l+12>>2];z=J[l+11|0]&1;x=L[l+4>>2];e=0;d=L[l+20>>2];f=L[l+16>>2];a:{if((d|0)<2|(f|0)<2){break a}u=S(d-1|0);v=S(f-1|0);L[8513]=L[8513]+1;c=R(d,f);g=ha[L[6798]](c>>>0>268435455?-1:c<<4,16)|0;r=sa(c>>>0>1073741823?-1:c<<2);while(1){p=P[h+8>>2];m=S(S(e|0)/v);p=S(S(S(P[j+8>>2]-p)*m)+p);q=P[i+8>>2];q=S(S(S(S(P[k+8>>2]-q)*m)+q)-p);n=P[i+4>>2];o=S(S(S(P[k+4>>2]-n)*m)+n);n=P[h+4>>2];n=S(S(S(P[j+4>>2]-n)*m)+n);A=S(o-n);o=P[i>>2];w=S(S(S(P[k>>2]-o)*m)+o);o=P[h>>2];o=S(S(S(P[j>>2]-o)*m)+o);w=S(w-o);B=R(d,e);a=0;while(1){y=a+B|0;s=g+(y<<4)|0;L[s+12>>2]=0;m=S(S(a|0)/u);P[s+8>>2]=S(q*m)+p;P[s+4>>2]=S(A*m)+n;P[s>>2]=S(w*m)+o;L[r+(y<<2)>>2]=1065353216;a=a+1|0;if((d|0)!=(a|0)){continue}break}e=e+1|0;if((f|0)!=(e|0)){continue}break}L[8513]=L[8513]+1;e=Ac(ha[L[6798]](1252,16)|0,t,c,g,r);if(b&1){P[L[e+720>>2]+88>>2]=0;J[e+924|0]=1}if(b&2){P[(L[e+720>>2]+R(d-1|0,104)|0)+88>>2]=0;J[e+924|0]=1}if(b&4){P[(L[e+720>>2]+R(R(d,f-1|0),104)|0)+88>>2]=0;J[e+924|0]=1}if(b&8){P[(L[e+720>>2]+R((d+R(d,f-1|0)|0)-1|0,104)|0)+88>>2]=0;J[e+924|0]=1}if(b&16){P[(L[e+720>>2]+R(d-1>>>1|0,104)|0)+88>>2]=0;J[e+924|0]=1}if(b&32){P[(L[e+720>>2]+R(R(d,f-1>>>1|0),104)|0)+88>>2]=0;J[e+924|0]=1}if(b&64){P[(L[e+720>>2]+R((d+R(d,f-1>>>1|0)|0)-1|0,104)|0)+88>>2]=0;J[e+924|0]=1}if(b&128){P[(L[e+720>>2]+R(R(d,f-1|0)+(d-1>>>1|0)|0,104)|0)+88>>2]=0;J[e+924|0]=1}if(b&256){P[(L[e+720>>2]+R(R(d,f-1>>>1|0)+(d-1>>>1|0)|0,104)|0)+88>>2]=0;J[e+924|0]=1}if(g){L[8514]=L[8514]+1;ha[L[6799]](g)}ra(r);if((d|0)<=0){break a}r=f-1|0;u=S(S(1)/S(r|0));v=S(S(1)/S(d-1|0));a=0;j=0;while(1){i=R(a,d);b=0;c=a+1|0;b:{if((c|0)<(f|0)){s=R(c,d);m=S(u*S(r-a|0));p=S(u*S(r+(a^-1)|0));a=0;while(1){g=a+s|0;h=a+i|0;b=a+1|0;c:{if((b|0)<(d|0)){t=b+i|0;Ha(e,h,t,0,0);Ha(e,h,g,0,0);k=b+s|0;pb(e,h,g,k,0);d:{if(x){g=(j<<2)+x|0;q=S(v*S(a|0));P[g>>2]=q;P[g+20>>2]=p;n=S(v*S(b|0));P[g+16>>2]=n;P[g+12>>2]=p;P[g+8>>2]=q;P[g+4>>2]=m;pb(e,k,t,h,0);P[g+44>>2]=m;P[g+40>>2]=q;P[g+36>>2]=m;P[g+32>>2]=n;P[g+28>>2]=p;P[g+24>>2]=n;break d}pb(e,k,t,h,0)}if(z){Ha(e,h,k,0,0)}j=j+12|0;break c}Ha(e,h,g,0,0)}a=b;if((d|0)!=(b|0)){continue}break}break b}while(1){a=b+1|0;if((a|0)<(d|0)){Ha(e,b+i|0,a+i|0,0,0)}b=a;if((b|0)!=(d|0)){continue}break}}a=c;if((f|0)!=(a|0)){continue}break}}fa=l+48|0;return e|0}function Ha(a,b,c,d,e){var f=0,g=0,h=0,i=0,j=0,k=S(0),l=0,m=0,n=0,o=0,p=S(0),q=S(0);f=R(c,104);c=L[a+720>>2];i=f+c|0;j=c+R(b,104)|0;a:{b:{if(!e){break b}c=L[a+732>>2];if((c|0)<=0){break b}e=L[a+740>>2];f=L[e+12>>2];h=L[e+8>>2];if((h|0)==(j|0)&(f|0)==(i|0)){break a}b=0;if((h|0)==(i|0)&(f|0)==(j|0)){break a}while(1){c:{b=b+1|0;if((c|0)==(b|0)){break c}h=e+R(b,52)|0;f=L[h+12>>2];h=L[h+8>>2];if((h|0)==(j|0)&(f|0)==(i|0)){break c}if((h|0)!=(i|0)|(f|0)!=(j|0)){continue}}break}if((b|0)<(c|0)){break a}}h=0;b=fa-48|0;fa=b;L[b+40>>2]=0;L[b+32>>2]=0;L[b+36>>2]=0;L[b+24>>2]=0;L[b+28>>2]=0;L[b+16>>2]=0;L[b+20>>2]=0;L[b+8>>2]=0;L[b+12>>2]=0;L[b>>2]=0;L[b+4>>2]=0;d=d?d:L[L[a+880>>2]>>2];c=L[a+732>>2];d:{if((c|0)!=L[a+736>>2]){break d}l=c?c<<1:1;if((l|0)<=(c|0)){break d}if(l){L[8513]=L[8513]+1;h=ha[L[6798]](R(l,52),16)|0;c=L[a+732>>2]}e:{if((c|0)<=0){break e}if((c|0)!=1){o=c&-2;while(1){e=R(m,52);f=e+h|0;e=e+L[a+740>>2]|0;g=L[e+4>>2];L[f>>2]=L[e>>2];L[f+4>>2]=g;L[f+48>>2]=L[e+48>>2];g=L[e+44>>2];L[f+40>>2]=L[e+40>>2];L[f+44>>2]=g;g=L[e+36>>2];L[f+32>>2]=L[e+32>>2];L[f+36>>2]=g;g=L[e+28>>2];L[f+24>>2]=L[e+24>>2];L[f+28>>2]=g;g=L[e+20>>2];L[f+16>>2]=L[e+16>>2];L[f+20>>2]=g;g=L[e+12>>2];L[f+8>>2]=L[e+8>>2];L[f+12>>2]=g;e=R(m|1,52);f=e+h|0;e=e+L[a+740>>2]|0;g=L[e+4>>2];L[f>>2]=L[e>>2];L[f+4>>2]=g;g=L[e+12>>2];L[f+8>>2]=L[e+8>>2];L[f+12>>2]=g;g=L[e+20>>2];L[f+16>>2]=L[e+16>>2];L[f+20>>2]=g;g=L[e+28>>2];L[f+24>>2]=L[e+24>>2];L[f+28>>2]=g;g=L[e+36>>2];L[f+32>>2]=L[e+32>>2];L[f+36>>2]=g;g=L[e+44>>2];L[f+40>>2]=L[e+40>>2];L[f+44>>2]=g;L[f+48>>2]=L[e+48>>2];m=m+2|0;n=n+2|0;if((o|0)!=(n|0)){continue}break}}if(!(c&1)){break e}c=R(m,52);e=c+h|0;c=c+L[a+740>>2]|0;f=L[c+4>>2];L[e>>2]=L[c>>2];L[e+4>>2]=f;L[e+48>>2]=L[c+48>>2];f=L[c+44>>2];L[e+40>>2]=L[c+40>>2];L[e+44>>2]=f;f=L[c+36>>2];L[e+32>>2]=L[c+32>>2];L[e+36>>2]=f;f=L[c+28>>2];L[e+24>>2]=L[c+24>>2];L[e+28>>2]=f;f=L[c+20>>2];L[e+16>>2]=L[c+16>>2];L[e+20>>2]=f;f=L[c+12>>2];L[e+8>>2]=L[c+8>>2];L[e+12>>2]=f}c=L[a+740>>2];if(!(c?!c|!M[a+744|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](c)}L[a+740>>2]=h;J[a+744|0]=1;L[a+736>>2]=l;c=L[a+732>>2]}c=L[a+740>>2]+R(c,52)|0;L[c+4>>2]=d;L[c>>2]=0;d=L[b+4>>2];L[c+8>>2]=L[b>>2];L[c+12>>2]=d;d=L[b+12>>2];L[c+16>>2]=L[b+8>>2];L[c+20>>2]=d;d=L[b+20>>2];L[c+24>>2]=L[b+16>>2];L[c+28>>2]=d;d=L[b+28>>2];L[c+32>>2]=L[b+24>>2];L[c+36>>2]=d;d=L[b+36>>2];L[c+40>>2]=L[b+32>>2];L[c+44>>2]=d;L[c+48>>2]=L[b+40>>2];L[a+732>>2]=L[a+732>>2]+1;fa=b+48|0;b=(L[a+740>>2]+R(L[a+732>>2],52)|0)-52|0;L[b+8>>2]=j;L[b+12>>2]=i;k=S(P[j+16>>2]-P[i+16>>2]);p=S(k*k);k=S(P[j+8>>2]-P[i+8>>2]);q=S(k*k);k=S(P[j+12>>2]-P[i+12>>2]);P[b+16>>2]=_(S(p+S(q+S(k*k))));J[a+924|0]=1}}function dg(a,b,c){var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;j=b+12|0;k=c+12|0;n=L[a+12>>2];while(1){a=l;l=a+1|0;f=L[(((l|0)!=3?l:0)<<2)+b>>2];d=L[c+4>>2];a:{b:{g=L[((a?a-1|0:2)<<2)+b>>2];h=L[c>>2];if((g|0)==(h|0)){a=2;e=0;if((d|0)==(f|0)){break b}}c:{if(!((f|0)!=(h|0)|(d|0)!=(g|0))){d=0;a=2;break c}e=L[c+8>>2];if(!((d|0)!=(g|0)|(e|0)!=(f|0))){e=1;a=-1;break b}if(!((d|0)!=(f|0)|(e|0)!=(g|0))){d=1;a=-1;break c}if(!((e|0)!=(g|0)|(f|0)!=(h|0))){e=2;a=-1;break b}a=27208;if((f|0)!=(e|0)|(g|0)!=(h|0)){break a}d=2;a=-1}a=(a+d<<2)+k|0;break a}a=(a+e<<2)+k|0}m=L[a>>2];d:{e:{e=L[b>>2];d=L[b+4>>2];if(!((e|0)!=(f|0)|(d|0)!=(g|0))){d=0;a=2;break e}f:{if(!((e|0)!=(g|0)|(d|0)!=(f|0))){d=0;a=2;break f}a=L[b+8>>2];if(!((d|0)!=(f|0)|(a|0)!=(g|0))){d=1;a=-1;break e}if(!((d|0)!=(g|0)|(a|0)!=(f|0))){d=1;a=-1;break f}if(!((a|0)!=(f|0)|(e|0)!=(g|0))){d=2;a=-1;break e}d=27208;if((a|0)!=(g|0)|(f|0)!=(e|0)){break d}d=2;a=-1}d=(a+d<<2)+j|0;break d}d=(a+d<<2)+j|0}e=2;d=L[(L[d>>2]<<2)+n>>2];h=L[d+4>>2];g:{h:{i=L[d>>2];if((i|0)==(g|0)){a=0;if((f|0)==(h|0)){break h}}a=0;i:{if(!((f|0)!=(i|0)|(g|0)!=(h|0))){break i}e=L[d+8>>2];if(!((g|0)!=(h|0)|(e|0)!=(f|0))){a=1;e=-1;break h}if(!((f|0)!=(h|0)|(e|0)!=(g|0))){e=-1;a=1;break i}if(!((e|0)!=(g|0)|(f|0)!=(i|0))){a=2;e=-1;break h}a=27208;if((f|0)!=(e|0)|(g|0)!=(i|0)){break g}e=-1;a=2}a=((a+e<<2)+d|0)+12|0;break g}a=(d+(a+e<<2)|0)+12|0}L[a>>2]=m;j:{k:{e=L[b>>2];a=L[b+4>>2];if(!((e|0)!=(f|0)|(a|0)!=(g|0))){d=0;a=2;break k}l:{if(!((e|0)!=(g|0)|(a|0)!=(f|0))){d=0;a=2;break l}d=L[b+8>>2];if(!((a|0)!=(f|0)|(d|0)!=(g|0))){d=1;a=-1;break k}if(!((a|0)!=(g|0)|(d|0)!=(f|0))){d=1;a=-1;break l}if(!((d|0)!=(f|0)|(e|0)!=(g|0))){d=2;a=-1;break k}a=27208;if((d|0)!=(g|0)|(f|0)!=(e|0)){break j}d=2;a=-1}a=(a+d<<2)+j|0;break j}a=(a+d<<2)+j|0}m=L[a>>2];m:{n:{e=L[c>>2];d=L[c+4>>2];if(!((e|0)!=(g|0)|(d|0)!=(f|0))){d=0;a=2;break n}o:{if(!((f|0)!=(e|0)|(d|0)!=(g|0))){d=0;a=2;break o}a=L[c+8>>2];if(!((d|0)!=(g|0)|(a|0)!=(f|0))){d=1;a=-1;break n}if(!((d|0)!=(f|0)|(a|0)!=(g|0))){d=1;a=-1;break o}if(!((a|0)!=(g|0)|(f|0)!=(e|0))){d=2;a=-1;break n}d=27208;if((a|0)!=(f|0)|(e|0)!=(g|0)){break m}d=2;a=-1}d=(a+d<<2)+k|0;break m}d=(a+d<<2)+k|0}e=2;d=L[(L[d>>2]<<2)+n>>2];h=L[d+4>>2];p:{q:{i=L[d>>2];if((i|0)==(f|0)){a=0;if((g|0)==(h|0)){break q}}r:{if(!((g|0)!=(i|0)|(f|0)!=(h|0))){f=0;a=2;break r}e=L[d+8>>2];if(!((f|0)!=(h|0)|(e|0)!=(g|0))){a=1;e=-1;break q}if(!((g|0)!=(h|0)|(f|0)!=(e|0))){f=1;a=-1;break r}if(!((f|0)!=(e|0)|(g|0)!=(i|0))){a=2;e=-1;break q}a=27208;if((e|0)!=(g|0)|(f|0)!=(i|0)){break p}f=2;a=-1}a=((a+f<<2)+d|0)+12|0;break p}a=(d+(a+e<<2)|0)+12|0}L[a>>2]=m;if((l|0)!=3){continue}break}}function OD(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=S(0),g=S(0),h=0,i=0,j=0,k=S(0),l=S(0),m=S(0),n=S(0),o=S(0),p=S(0),q=S(0),r=S(0),s=S(0),t=S(0),u=S(0),v=0,w=0,x=0,y=0,z=0;g=P[b+44>>2];m=P[b+40>>2];n=P[b+36>>2];k=P[b+28>>2];o=P[b+24>>2];p=P[b+20>>2];q=P[b+32>>2];r=P[b+16>>2];l=P[b+12>>2];s=P[b+8>>2];t=P[b+4>>2];u=P[b>>2];i=L[a+4>>2];b=L[i+4>>2];a:{if((b|0)!=L[i+8>>2]){break a}v=b?b<<1:1;if((v|0)<=(b|0)){break a}if(v){L[8513]=L[8513]+1;w=ha[L[6798]](v<<6,16)|0;b=L[i+4>>2]}b:{if((b|0)<=0){break b}if((b|0)!=1){z=b&-2;while(1){h=x<<6;e=h+w|0;a=L[i+12>>2]+h|0;j=L[a+4>>2];L[e>>2]=L[a>>2];L[e+4>>2]=j;j=L[a+60>>2];L[e+56>>2]=L[a+56>>2];L[e+60>>2]=j;j=L[a+52>>2];L[e+48>>2]=L[a+48>>2];L[e+52>>2]=j;j=L[a+44>>2];L[e+40>>2]=L[a+40>>2];L[e+44>>2]=j;j=L[a+36>>2];L[e+32>>2]=L[a+32>>2];L[e+36>>2]=j;j=L[a+28>>2];L[e+24>>2]=L[a+24>>2];L[e+28>>2]=j;j=L[a+20>>2];L[e+16>>2]=L[a+16>>2];L[e+20>>2]=j;j=L[a+12>>2];L[e+8>>2]=L[a+8>>2];L[e+12>>2]=j;a=h|64;e=a+w|0;a=a+L[i+12>>2]|0;h=L[a+4>>2];L[e>>2]=L[a>>2];L[e+4>>2]=h;h=L[a+12>>2];L[e+8>>2]=L[a+8>>2];L[e+12>>2]=h;h=L[a+20>>2];L[e+16>>2]=L[a+16>>2];L[e+20>>2]=h;h=L[a+28>>2];L[e+24>>2]=L[a+24>>2];L[e+28>>2]=h;h=L[a+36>>2];L[e+32>>2]=L[a+32>>2];L[e+36>>2]=h;h=L[a+44>>2];L[e+40>>2]=L[a+40>>2];L[e+44>>2]=h;h=L[a+52>>2];L[e+48>>2]=L[a+48>>2];L[e+52>>2]=h;h=L[a+60>>2];L[e+56>>2]=L[a+56>>2];L[e+60>>2]=h;x=x+2|0;y=y+2|0;if((y|0)!=(z|0)){continue}break}}if(!(b&1)){break b}a=x<<6;b=a+w|0;a=a+L[i+12>>2]|0;e=L[a+4>>2];L[b>>2]=L[a>>2];L[b+4>>2]=e;e=L[a+60>>2];L[b+56>>2]=L[a+56>>2];L[b+60>>2]=e;e=L[a+52>>2];L[b+48>>2]=L[a+48>>2];L[b+52>>2]=e;e=L[a+44>>2];L[b+40>>2]=L[a+40>>2];L[b+44>>2]=e;e=L[a+36>>2];L[b+32>>2]=L[a+32>>2];L[b+36>>2]=e;e=L[a+28>>2];L[b+24>>2]=L[a+24>>2];L[b+28>>2]=e;e=L[a+20>>2];L[b+16>>2]=L[a+16>>2];L[b+20>>2]=e;e=L[a+12>>2];L[b+8>>2]=L[a+8>>2];L[b+12>>2]=e}a=L[i+12>>2];if(!(a?!a|!M[i+16|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](a)}L[i+12>>2]=w;J[i+16|0]=1;L[i+8>>2]=v;b=L[i+4>>2]}a=L[i+12>>2]+(b<<6)|0;L[a+40>>2]=d;L[a+36>>2]=c;L[a+32>>2]=-1;f=l>S(0)?l:S(0);f=f>2]=g>f?g:f;f=s>S(-0xde0b6b000000000)?s:S(-0xde0b6b000000000);f=f>2]=fS(-0xde0b6b000000000)?t:S(-0xde0b6b000000000);f=f>2]=fS(-0xde0b6b000000000)?u:S(-0xde0b6b000000000);f=f>2]=f>2]=go?o:g;P[a+8>>2]=g>m?m:g;g=tp?p:g;P[a+4>>2]=g>n?n:g;g=ur?r:g;P[a>>2]=g>q?q:g;L[i+4>>2]=L[i+4>>2]+1}function Cw(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,f=0,g=S(0),h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=S(0);i=fa-16|0;fa=i;L[i+12>>2]=a;L[i+8>>2]=b;L[i+4>>2]=c;a=L[i+8>>2];j=L[i+4>>2];b=fa-128|0;fa=b;c=L[i+12>>2];L[c+68>>2]=L[c+68>>2]+1;d=L[a+12>>2];L[b+72>>2]=L[a+8>>2];L[b+76>>2]=d;d=L[a+4>>2];L[b+64>>2]=L[a>>2];L[b+68>>2]=d;d=L[a+28>>2];L[b+88>>2]=L[a+24>>2];L[b+92>>2]=d;d=L[a+20>>2];L[b+80>>2]=L[a+16>>2];L[b+84>>2]=d;d=L[a+44>>2];L[b+104>>2]=L[a+40>>2];L[b+108>>2]=d;d=L[a+36>>2];L[b+96>>2]=L[a+32>>2];L[b+100>>2]=d;d=L[a+60>>2];L[b+120>>2]=L[a+56>>2];L[b+124>>2]=d;d=L[a+52>>2];L[b+112>>2]=L[a+48>>2];L[b+116>>2]=d;n=L[j+4>>2];o=S(ha[L[L[j>>2]+48>>2]](j));ha[L[L[j>>2]+8>>2]](j,a,b+48|0,b+32|0);g=P[b+48>>2];if(g>2]){P[c+32>>2]=g}g=P[b+32>>2];if(g>P[c+48>>2]){P[c+48>>2]=g}g=P[b+52>>2];if(g>2]){P[c+36>>2]=g}g=P[b+36>>2];if(g>P[c+52>>2]){P[c+52>>2]=g}g=P[b+56>>2];if(g>2]){P[c+40>>2]=g}g=P[b+40>>2];if(g>P[c+56>>2]){P[c+56>>2]=g}a=L[c+64>>2];if(a){d=L[b+60>>2];L[b+8>>2]=L[b+56>>2];L[b+12>>2]=d;d=L[b+44>>2];L[b+24>>2]=L[b+40>>2];L[b+28>>2]=d;d=L[b+36>>2];L[b+16>>2]=L[b+32>>2];L[b+20>>2]=d;d=L[b+52>>2];L[b>>2]=L[b+48>>2];L[b+4>>2]=d;a=Bb(a,b,L[c+16>>2])}else{a=0}h=L[c+16>>2];a:{if((h|0)!=L[c+20>>2]){break a}k=h?h<<1:1;if((k|0)<=(h|0)){break a}if(k){L[8513]=L[8513]+1;m=ha[L[6798]](R(k,80),16)|0;h=L[c+16>>2]}if((h|0)>0){while(1){d=R(l,80);e=d+m|0;d=d+L[c+24>>2]|0;f=L[d+4>>2];L[e>>2]=L[d>>2];L[e+4>>2]=f;f=L[d+12>>2];L[e+8>>2]=L[d+8>>2];L[e+12>>2]=f;f=L[d+28>>2];L[e+24>>2]=L[d+24>>2];L[e+28>>2]=f;f=L[d+20>>2];L[e+16>>2]=L[d+16>>2];L[e+20>>2]=f;f=L[d+44>>2];L[e+40>>2]=L[d+40>>2];L[e+44>>2]=f;f=L[d+36>>2];L[e+32>>2]=L[d+32>>2];L[e+36>>2]=f;f=L[d+60>>2];L[e+56>>2]=L[d+56>>2];L[e+60>>2]=f;f=L[d+52>>2];L[e+48>>2]=L[d+48>>2];L[e+52>>2]=f;f=L[d+68>>2];L[e+64>>2]=L[d+64>>2];L[e+68>>2]=f;f=L[d+76>>2];L[e+72>>2]=L[d+72>>2];L[e+76>>2]=f;l=l+1|0;if((l|0)!=(h|0)){continue}break}}d=L[c+24>>2];if(!(d?!d|!M[c+28|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](d)}L[c+24>>2]=m;J[c+28|0]=1;L[c+20>>2]=k;h=L[c+16>>2]}e=L[b+68>>2];d=L[c+24>>2]+R(h,80)|0;L[d>>2]=L[b+64>>2];L[d+4>>2]=e;e=L[b+76>>2];L[d+8>>2]=L[b+72>>2];L[d+12>>2]=e;e=L[b+92>>2];L[d+24>>2]=L[b+88>>2];L[d+28>>2]=e;e=L[b+84>>2];L[d+16>>2]=L[b+80>>2];L[d+20>>2]=e;e=L[b+100>>2];L[d+32>>2]=L[b+96>>2];L[d+36>>2]=e;e=L[b+108>>2];L[d+40>>2]=L[b+104>>2];L[d+44>>2]=e;e=L[b+116>>2];L[d+48>>2]=L[b+112>>2];L[d+52>>2]=e;e=L[b+124>>2];L[d+56>>2]=L[b+120>>2];L[d+60>>2]=e;L[d+64>>2]=j;L[d+68>>2]=n;P[d+72>>2]=o;L[d+76>>2]=a;L[c+16>>2]=L[c+16>>2]+1;fa=b+128|0;fa=i+16|0}function Oo(a,b,c,d,e){a=a|0;b=b|0;c=S(c);d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=S(0),k=S(0),l=0;f=fa-272|0;fa=f;L[f+268>>2]=a;L[f+264>>2]=b;P[f+260>>2]=c;L[f+256>>2]=d;L[f+252>>2]=e;d=L[f+268>>2];e=f+236|0;Ga(e,L[f+264>>2],f+260|0);a=fa-16|0;g=f+220|0;L[a+12>>2]=g;i=f+204|0;L[a+12>>2]=i;a=fa-32|0;fa=a;L[a+28>>2]=L[f+264>>2];L[a+24>>2]=g;L[a+20>>2]=i;b=fa-16|0;L[b+12>>2]=L[a+28>>2];h=fa-16|0;P[h+12>>2]=P[L[b+12>>2]+8>>2];a:{if(S(T(P[h+12>>2]))>S(.7071067690849304)){b=fa-16|0;L[b+12>>2]=L[a+28>>2];c=P[L[b+12>>2]+4>>2];L[b+12>>2]=L[a+28>>2];j=P[L[b+12>>2]+4>>2];L[b+12>>2]=L[a+28>>2];k=P[L[b+12>>2]+8>>2];L[b+12>>2]=L[a+28>>2];P[a+16>>2]=S(c*j)+S(k*P[L[b+12>>2]+8>>2]);P[b+12>>2]=P[a+16>>2];P[a+12>>2]=S(1)/S(_(P[b+12>>2]));L[b+12>>2]=L[a+24>>2];P[L[b+12>>2]>>2]=0;L[b+12>>2]=L[a+28>>2];c=S(S(-P[L[b+12>>2]+8>>2])*P[a+12>>2]);L[b+12>>2]=L[a+24>>2];P[L[b+12>>2]+4>>2]=c;L[b+12>>2]=L[a+28>>2];c=S(P[L[b+12>>2]+4>>2]*P[a+12>>2]);L[b+12>>2]=L[a+24>>2];P[L[b+12>>2]+8>>2]=c;c=S(P[a+16>>2]*P[a+12>>2]);L[b+12>>2]=L[a+20>>2];P[L[b+12>>2]>>2]=c;L[b+12>>2]=L[a+28>>2];c=P[L[b+12>>2]>>2];L[b+12>>2]=L[a+24>>2];c=S(S(-c)*P[L[b+12>>2]+8>>2]);L[b+12>>2]=L[a+20>>2];P[L[b+12>>2]+4>>2]=c;L[b+12>>2]=L[a+28>>2];c=P[L[b+12>>2]>>2];L[b+12>>2]=L[a+24>>2];c=S(c*P[L[b+12>>2]+4>>2]);break a}b=fa-16|0;L[b+12>>2]=L[a+28>>2];c=P[L[b+12>>2]>>2];L[b+12>>2]=L[a+28>>2];j=P[L[b+12>>2]>>2];L[b+12>>2]=L[a+28>>2];k=P[L[b+12>>2]+4>>2];L[b+12>>2]=L[a+28>>2];P[a+8>>2]=S(c*j)+S(k*P[L[b+12>>2]+4>>2]);P[b+12>>2]=P[a+8>>2];P[a+4>>2]=S(1)/S(_(P[b+12>>2]));L[b+12>>2]=L[a+28>>2];c=S(S(-P[L[b+12>>2]+4>>2])*P[a+4>>2]);L[b+12>>2]=L[a+24>>2];P[L[b+12>>2]>>2]=c;L[b+12>>2]=L[a+28>>2];c=S(P[L[b+12>>2]>>2]*P[a+4>>2]);L[b+12>>2]=L[a+24>>2];P[L[b+12>>2]+4>>2]=c;L[b+12>>2]=L[a+24>>2];P[L[b+12>>2]+8>>2]=0;L[b+12>>2]=L[a+28>>2];c=P[L[b+12>>2]+8>>2];L[b+12>>2]=L[a+24>>2];c=S(S(-c)*P[L[b+12>>2]+4>>2]);L[b+12>>2]=L[a+20>>2];P[L[b+12>>2]>>2]=c;L[b+12>>2]=L[a+28>>2];c=P[L[b+12>>2]+8>>2];L[b+12>>2]=L[a+24>>2];c=S(c*P[L[b+12>>2]>>2]);L[b+12>>2]=L[a+20>>2];P[L[b+12>>2]+4>>2]=c;c=S(P[a+8>>2]*P[a+4>>2])}b=fa-16|0;L[b+12>>2]=L[a+20>>2];P[L[b+12>>2]+8>>2]=c;fa=a+32|0;P[f+200>>2]=100;b=f+168|0;a=f+200|0;Ga(b,g,a);h=f+184|0;ta(h,e,b);b=f+136|0;Ga(b,g,a);g=f+152|0;La(g,e,b);b=f+104|0;Ga(b,i,a);l=f+120|0;ta(l,e,b);b=f+72|0;Ga(b,i,a);a=f+88|0;La(a,e,b);b=f+56|0;xa(b,L[f+256>>2],h);e=f+40|0;xa(e,L[f+256>>2],g);ha[L[L[d>>2]+8>>2]](d,b,e,L[f+252>>2]);b=f+24|0;xa(b,L[f+256>>2],l);e=f+8|0;xa(e,L[f+256>>2],a);ha[L[L[d>>2]+8>>2]](d,b,e,L[f+252>>2]);fa=f+272|0}function bk(a,b,c){var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;i=L[b>>2];j=L[a+4>>2];k=L[b+4>>2];f=L[b+8>>2];n=bc(a,c,k,f);e=2;d=L[b+12>>2];o=j+2|0;L[n+20>>2]=o;p=j+1|0;L[n+16>>2]=p;L[n+12>>2]=d;d=L[L[a+12>>2]+(L[b+12>>2]<<2)>>2];l=L[d+4>>2];a:{b:{g=L[d>>2];if((g|0)==(k|0)&(f|0)==(l|0)){break b}e=2;c:{if(!((f|0)!=(g|0)|(k|0)!=(l|0))){break c}e=L[d+8>>2];if(!((k|0)!=(l|0)|(e|0)!=(f|0))){h=1;e=-1;break b}if(!((f|0)!=(l|0)|(e|0)!=(k|0))){h=1;e=-1;break c}if(!((e|0)!=(k|0)|(f|0)!=(g|0))){h=2;e=-1;break b}h=27208;if((f|0)!=(e|0)|(k|0)!=(g|0)){break a}h=2;e=-1}h=((e+h<<2)+d|0)+12|0;break a}h=(d+(e+h<<2)|0)+12|0}L[h>>2]=j;l=bc(a,c,f,i);d=L[b+16>>2];L[l+20>>2]=j;L[l+16>>2]=o;L[l+12>>2]=d;e=2;d=L[L[a+12>>2]+(L[b+16>>2]<<2)>>2];h=L[d+4>>2];d:{e:{m=L[d>>2];if((m|0)==(f|0)&(i|0)==(h|0)){break e}f:{if(!((i|0)!=(m|0)|(f|0)!=(h|0))){f=2;e=0;break f}g=L[d+8>>2];if(!((f|0)!=(h|0)|(g|0)!=(i|0))){q=1;e=-1;break e}if(!((i|0)!=(h|0)|(f|0)!=(g|0))){f=-1;e=1;break f}if(!((f|0)!=(g|0)|(i|0)!=(m|0))){q=2;e=-1;break e}e=27208;if((i|0)!=(g|0)|(f|0)!=(m|0)){break d}f=-1;e=2}e=(d+(e+f<<2)|0)+12|0;break d}e=(d+(e+q<<2)|0)+12|0}L[e>>2]=p;f=bc(a,c,i,k);d=L[b+20>>2];L[f+20>>2]=p;L[f+16>>2]=j;L[f+12>>2]=d;e=2;j=L[a+12>>2];d=L[j+(L[b+20>>2]<<2)>>2];g=L[d+4>>2];g:{h:{m=L[d>>2];if((m|0)==(i|0)){h=0;if((k|0)==(g|0)){break h}}i:{if(!((k|0)!=(m|0)|(i|0)!=(g|0))){i=0;e=2;break i}e=L[d+8>>2];if(!((i|0)!=(g|0)|(e|0)!=(k|0))){h=1;e=-1;break h}if(!((k|0)!=(g|0)|(e|0)!=(i|0))){i=1;e=-1;break i}if(!((e|0)!=(i|0)|(k|0)!=(m|0))){h=2;e=-1;break h}g=27208;if((e|0)!=(k|0)|(i|0)!=(m|0)){break g}i=2;e=-1}g=((e+i<<2)+d|0)+12|0;break g}g=(d+(e+h<<2)|0)+12|0}L[g>>2]=o;d=L[(L[n+12>>2]<<2)+j>>2];if(!(!(L[d>>2]==(c|0)|L[d+4>>2]==(c|0))&L[d+8>>2]!=(c|0))){dg(a,n,d);L[L[a+12>>2]+(L[n+24>>2]<<2)>>2]=0;if(n){L[8514]=L[8514]+1;ha[L[6799]](n)}L[L[a+12>>2]+(L[d+24>>2]<<2)>>2]=0;if(d){L[8514]=L[8514]+1;ha[L[6799]](d)}j=L[a+12>>2]}d=L[(L[l+12>>2]<<2)+j>>2];if(!(!(L[d>>2]==(c|0)|L[d+4>>2]==(c|0))&L[d+8>>2]!=(c|0))){dg(a,l,d);L[L[a+12>>2]+(L[l+24>>2]<<2)>>2]=0;if(l){L[8514]=L[8514]+1;ha[L[6799]](l)}L[L[a+12>>2]+(L[d+24>>2]<<2)>>2]=0;if(d){L[8514]=L[8514]+1;ha[L[6799]](d)}j=L[a+12>>2]}d=L[(L[f+12>>2]<<2)+j>>2];if(!(!(L[d>>2]==(c|0)|L[d+4>>2]==(c|0))&L[d+8>>2]!=(c|0))){dg(a,f,d);L[L[a+12>>2]+(L[f+24>>2]<<2)>>2]=0;if(f){L[8514]=L[8514]+1;ha[L[6799]](f)}L[L[a+12>>2]+(L[d+24>>2]<<2)>>2]=0;if(d){L[8514]=L[8514]+1;ha[L[6799]](d)}j=L[a+12>>2]}L[(L[b+24>>2]<<2)+j>>2]=0;if(b){L[8514]=L[8514]+1;ha[L[6799]](b)}}function NC(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0,g=S(0),h=S(0),i=0,j=0,k=S(0),l=S(0),m=S(0),n=S(0),o=0,p=S(0),q=0,r=0,s=0,t=0,u=S(0),v=S(0),w=0,x=0,y=0,z=S(0),A=S(0),B=S(0),C=0;e=fa-112|0;fa=e;ha[L[L[a>>2]+112>>2]](a);L[e+104>>2]=0;J[e+108|0]=1;L[e+96>>2]=0;L[e+100>>2]=0;k=P[c+8>>2];l=P[d+8>>2];m=P[c>>2];h=P[d>>2];n=P[c+4>>2];p=P[d+4>>2];L[e+88>>2]=0;l=S(l-k);m=S(h-m);h=S(p-n);k=S(S(1)/S(_(S(S(l*l)+S(S(m*m)+S(h*h))))));P[e+84>>2]=l*k;P[e+80>>2]=h*k;P[e+76>>2]=m*k;t=L[a+68>>2];if((t|0)>0){while(1){o=q<<4;f=o+L[a+84>>2]|0;d=N[f+4>>1];m=P[a+132>>2];h=P[a+100>>2];j=N[f+10>>1];i=N[f+2>>1];l=P[a+128>>2];n=P[a+96>>2];r=N[f+8>>1];k=P[a+92>>2];g=P[a+124>>2];p=S(k+S(S(N[f+6>>1])/g));a:{b:{c:{d:{g=S(S(S(S(S(N[f>>1])/g)+k)+p)*S(.5));k=S(P[c>>2]-g);p=S(p-g);e:{if(S(T(k))>p&S(k*P[e+76>>2])>=S(0)){break e}g=S(S(S(i>>>0)/l)+n);n=S(n+S(S(r>>>0)/l));g=S(S(g+n)*S(.5));l=S(P[c+4>>2]-g);n=S(n-g);if(S(T(l))>n&S(l*P[e+80>>2])>=S(0)){break e}g=S(S(S(d>>>0)/m)+h);h=S(h+S(S(j>>>0)/m));g=S(S(g+h)*S(.5));m=S(P[c+8>>2]-g);g=S(h-g);h=P[e+84>>2];if(S(T(m))>g&S(m*h)>=S(0)){break e}u=P[e+80>>2];z=S(T(u));A=S(T(h));if(S(T(S(S(u*m)-S(l*h))))>S(S(n*A)+S(g*z))){break e}v=P[e+76>>2];B=S(T(v));if(!(S(T(S(S(h*k)-S(m*v))))>S(S(p*A)+S(g*B)))){break d}}j=L[f+12>>2]>=0;d=0;break c}i=S(T(S(S(v*l)-S(k*u))))>S(S(p*z)+S(n*B));d=!i;w=L[f+12>>2];j=(w|0)>=0;if((w|0)<0|i){break c}f=L[e+96>>2];f:{if((f|0)!=L[e+100>>2]){break f}r=f?f<<1:1;if((r|0)<=(f|0)){break f}g:{if(!r){d=0;break g}L[8513]=L[8513]+1;d=ha[L[6798]](r<<2,16)|0;f=L[e+96>>2]}o=L[e+104>>2];h:{i:{if((f|0)>0){x=0;j=0;if(f>>>0>=4){C=f&-4;y=0;while(1){i=j<<2;L[i+d>>2]=L[i+o>>2];s=i|4;L[s+d>>2]=L[o+s>>2];s=i|8;L[s+d>>2]=L[o+s>>2];i=i|12;L[i+d>>2]=L[i+o>>2];j=j+4|0;y=y+4|0;if((C|0)!=(y|0)){continue}break}}f=f&3;if(!f){break i}while(1){i=j<<2;L[i+d>>2]=L[i+o>>2];j=j+1|0;x=x+1|0;if((f|0)!=(x|0)){continue}break}break i}if(!o){break h}}if(o?M[e+108|0]:0){L[8514]=L[8514]+1;ha[L[6799]](o)}f=L[e+96>>2]}L[e+104>>2]=d;J[e+108|0]=1;L[e+100>>2]=r}L[L[e+104>>2]+(f<<2)>>2]=w;L[e+96>>2]=L[e+96>>2]+1;break b}if(d|j){break b}q=q-L[(o+L[a+84>>2]|0)+12>>2]|0;break a}q=q+1|0}if((t|0)>(q|0)){continue}break}}c=L[e+96>>2];if(c){d=L[a+172>>2];L[e+68>>2]=1008981770;while(1){c=c-1|0;q=c<<2;f=L[q+L[e+104>>2]>>2];j=ha[L[L[a>>2]+84>>2]](a)|0;t=f;f=e+4|0;ha[L[L[j>>2]+20>>2]](j,t,f);ha[L[L[b>>2]+8>>2]](b,f,d,L[q+L[e+104>>2]>>2]);if(c){continue}break}}ha[L[L[a>>2]+116>>2]](a);a=L[e+104>>2];if(!(a?!a|!M[e+108|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](a)}fa=e+112|0}function Qo(a,b,c,d,e,f){a=a|0;b=S(b);c=S(c);d=d|0;e=e|0;f=f|0;var g=0,h=0,i=0,j=0,k=0,l=0;g=fa-384|0;fa=g;L[g+380>>2]=a;P[g+376>>2]=b;P[g+372>>2]=c;L[g+368>>2]=d;L[g+364>>2]=e;L[g+360>>2]=f;a=L[g+380>>2];d=fa-16|0;L[d+12>>2]=L[g+364>>2];d=L[d+12>>2]+48|0;e=L[d+12>>2];L[g+352>>2]=L[d+8>>2];L[g+356>>2]=e;e=L[d+4>>2];L[g+344>>2]=L[d>>2];L[g+348>>2]=e;P[g+324>>2]=0;P[g+320>>2]=0;P[g+316>>2]=0;d=g+328|0;la(d,g+324|0,g+320|0,g+316|0);b=P[g+372>>2];e=fa-16|0;L[e+12>>2]=d;P[L[e+12>>2]+(L[g+368>>2]<<2)>>2]=b;L[g+312>>2]=30;P[g+292>>2]=0;P[g+288>>2]=0;P[g+284>>2]=0;d=g+296|0;la(d,g+292|0,g+288|0,g+284|0);b=S(-P[g+372>>2]);e=fa-16|0;L[e+12>>2]=d;P[L[e+12>>2]+(L[g+368>>2]<<2)>>2]=b;P[g+264>>2]=0;P[g+260>>2]=0;P[g+256>>2]=0;d=g+268|0;la(d,g+264|0,g+260|0,g+256|0);b=P[g+372>>2];e=fa-16|0;L[e+12>>2]=d;P[L[e+12>>2]+(L[g+368>>2]<<2)>>2]=b;L[g+252>>2]=0;while(1){if(L[g+252>>2]<360){b=S(Qa(S(S(L[g+252>>2])*S(.01745329238474369)))*P[g+376>>2]);d=fa-16|0;e=g+296|0;L[d+12>>2]=e;P[L[d+12>>2]+((L[g+368>>2]+1|0)%3<<2)>>2]=b;f=g+268|0;L[d+12>>2]=f;P[L[d+12>>2]+((L[g+368>>2]+1|0)%3<<2)>>2]=b;b=S(Ra(S(S(L[g+252>>2])*S(.01745329238474369)))*P[g+376>>2]);d=fa-16|0;L[d+12>>2]=e;P[L[d+12>>2]+((L[g+368>>2]+2|0)%3<<2)>>2]=b;d=fa-16|0;L[d+12>>2]=f;P[L[d+12>>2]+((L[g+368>>2]+2|0)%3<<2)>>2]=b;d=fa-16|0;L[d+12>>2]=L[g+364>>2];h=g+220|0;ua(h,L[d+12>>2],e);d=g+236|0;e=g+344|0;ta(d,e,h);h=fa-16|0;L[h+12>>2]=L[g+364>>2];i=g+188|0;ua(i,L[h+12>>2],f);f=g+204|0;ta(f,e,i);ha[L[L[a>>2]+8>>2]](a,d,f,L[g+360>>2]);L[g+252>>2]=L[g+312>>2]+L[g+252>>2];continue}break}P[g+168>>2]=0;P[g+164>>2]=0;P[g+160>>2]=0;d=g+172|0;la(d,g+168|0,g+164|0,g+160|0);e=fa-16|0;L[e+12>>2]=d;P[L[e+12>>2]+(L[g+368>>2]<<2)>>2]=1;P[g+140>>2]=0;P[g+136>>2]=0;P[g+132>>2]=0;e=g+144|0;la(e,g+140|0,g+136|0,g+132|0);f=fa-16|0;L[f+12>>2]=e;P[L[f+12>>2]+((L[g+368>>2]+1|0)%3<<2)>>2]=1;f=fa-16|0;L[f+12>>2]=L[g+364>>2];h=g+100|0;i=L[f+12>>2];f=g+328|0;ua(h,i,f);i=g+116|0;j=g+344|0;La(i,j,h);h=fa-16|0;L[h+12>>2]=L[g+364>>2];k=g+84|0;ua(k,L[h+12>>2],d);h=fa-16|0;L[h+12>>2]=L[g+364>>2];l=g+68|0;ua(l,L[h+12>>2],e);b=P[g+376>>2];ha[L[L[a>>2]+60>>2]](a,i,k,l,b,b,S(0),S(6.2831854820251465),L[g+360>>2],0,S(10));h=fa-16|0;L[h+12>>2]=L[g+364>>2];i=g+36|0;ua(i,L[h+12>>2],f);f=g+52|0;ta(f,j,i);h=fa-16|0;L[h+12>>2]=L[g+364>>2];i=g+20|0;ua(i,L[h+12>>2],d);d=fa-16|0;L[d+12>>2]=L[g+364>>2];h=g+4|0;ua(h,L[d+12>>2],e);ha[L[L[a>>2]+60>>2]](a,f,i,h,P[g+376>>2],P[g+376>>2],S(0),S(6.2831854820251465),L[g+360>>2],0,S(10));fa=g+384|0}function PD(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=S(0),f=S(0),g=S(0),h=0,i=0,j=S(0),k=0,l=0,m=0,n=S(0),o=S(0),p=S(0),q=S(0),r=S(0),s=S(0),t=0,u=0,v=S(0),w=S(0),x=S(0),y=S(0),z=S(0),A=S(0),B=0,C=0;f=P[b+40>>2];g=P[b+36>>2];e=P[b+24>>2];o=P[b+20>>2];i=L[a+8>>2];v=P[i+44>>2];w=P[i+40>>2];x=P[i+12>>2];y=P[i+8>>2];p=P[b+32>>2];q=P[b+16>>2];n=P[b+8>>2];r=P[b+4>>2];s=P[b>>2];z=P[i+36>>2];A=P[i+4>>2];b=L[a+4>>2];a=L[b+4>>2];a:{if((a|0)!=L[b+8>>2]){break a}t=a?a<<1:1;if((t|0)<=(a|0)){break a}b:{if(!t){i=0;break b}L[8513]=L[8513]+1;i=ha[L[6798]](t<<4,16)|0;a=L[b+4>>2]}c:{if((a|0)<=0){break c}if((a|0)!=1){C=a&-2;while(1){l=k<<4;m=l+i|0;h=l+L[b+12>>2]|0;u=L[h+4>>2];L[m>>2]=L[h>>2];L[m+4>>2]=u;u=L[h+12>>2];L[m+8>>2]=L[h+8>>2];L[m+12>>2]=u;h=l|16;l=h+i|0;h=h+L[b+12>>2]|0;m=L[h+4>>2];L[l>>2]=L[h>>2];L[l+4>>2]=m;m=L[h+12>>2];L[l+8>>2]=L[h+8>>2];L[l+12>>2]=m;k=k+2|0;B=B+2|0;if((B|0)!=(C|0)){continue}break}}if(!(a&1)){break c}a=k<<4;k=a+i|0;a=a+L[b+12>>2]|0;h=L[a+4>>2];L[k>>2]=L[a>>2];L[k+4>>2]=h;h=L[a+12>>2];L[k+8>>2]=L[a+8>>2];L[k+12>>2]=h}a=L[b+12>>2];if(!(a?!a|!M[b+16|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](a)}L[b+12>>2]=i;J[b+16|0]=1;L[b+8>>2]=t;a=L[b+4>>2]}a=L[b+12>>2]+(a<<4)|0;L[a+12>>2]=c<<21|d;j=n>S(-0xde0b6b000000000)?n:S(-0xde0b6b000000000);j=e>j?e:j;j=f>j?f:j;n=n=S(0)){d=~~f>>>0;break d}d=0}K[a+4>>1]=d&65534;f=r>S(-0xde0b6b000000000)?r:S(-0xde0b6b000000000);f=fo?o:e;g=e>g?g:e;d=S(f-g)=S(0)){h=~~g>>>0;break e}h=0}K[a+2>>1]=h&65534;g=s>S(-0xde0b6b000000000)?s:S(-0xde0b6b000000000);g=gq?q:e;e=e>p?p:e;i=S(g-e)=S(0)){h=~~e>>>0;break f}h=0}K[a>>1]=h&65534;e=S(S(S((c?S(j+S(.0010000000474974513)):j)-x)*v)+S(1));g:{if(e=S(0)){c=~~e>>>0;break g}c=0}K[a+10>>1]=c|1;f=S(S(S((d?S(f+S(.0010000000474974513)):f)-y)*w)+S(1));h:{if(f=S(0)){c=~~f>>>0;break h}c=0}K[a+8>>1]=c|1;f=S(S(S((i?S(g+S(.0010000000474974513)):g)-A)*z)+S(1));i:{if(f=S(0)){c=~~f>>>0;break i}c=0}K[a+6>>1]=c|1;L[b+4>>2]=L[b+4>>2]+1}function BF(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,f=0,g=S(0),h=S(0),i=S(0),j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=S(0),r=S(0),s=S(0);l=fa-32|0;fa=l;d=L[a+4>>2];ha[L[L[d>>2]+16>>2]](d,l+28|0,l+24|0,l+20|0,l+16|0,l+12|0,l+8|0,l+4|0,l,b);e=L[a+4>>2];j=L[l+12>>2]+R(L[l+8>>2],c)|0;m=L[l+16>>2];d=L[l+28>>2];f=L[l>>2];a:{if(!L[l+20>>2]){b:{c:{switch(f-2|0){case 0:k=L[j+8>>2];break b;case 1:k=N[j+4>>1];break b;default:break c}}k=M[j+2|0]}k=R(k,m)+d|0;g=P[k>>2];h=P[k+4>>2];i=P[k+8>>2];q=P[e+4>>2];r=P[e+8>>2];s=P[e+12>>2];L[a+56>>2]=0;P[a+52>>2]=i*s;P[a+48>>2]=h*r;P[a+44>>2]=g*q;d:{e:{switch(f-2|0){case 0:k=L[j+4>>2];break d;case 1:k=N[j+2>>1];break d;default:break e}}k=M[j+1|0]}k=R(k,m)+d|0;g=P[k>>2];h=P[k+4>>2];i=P[k+8>>2];q=P[e+4>>2];r=P[e+8>>2];s=P[e+12>>2];L[a+40>>2]=0;P[a+36>>2]=i*s;P[a+32>>2]=h*r;P[a+28>>2]=g*q;f:{g:{switch(f-2|0){case 0:f=L[j>>2];break f;case 1:f=N[j>>1];break f;default:break g}}f=M[j|0]}d=R(f,m)+d|0;k=d+8|0;g=S(P[d+4>>2]*P[e+8>>2]);i=S(P[d>>2]*P[e+4>>2]);h=P[e+12>>2];break a}k=e+12|0;h:{switch(f-2|0){case 0:f=R(L[j+8>>2],m)+d|0;n=Q[f>>3];o=Q[f+8>>3];p=Q[f+16>>3];g=P[e+4>>2];h=P[e+8>>2];i=P[e+12>>2];L[a+56>>2]=0;P[a+52>>2]=i*S(p);P[a+48>>2]=h*S(o);P[a+44>>2]=g*S(n);f=R(L[j+4>>2],m)+d|0;n=Q[f>>3];o=Q[f+8>>3];p=Q[f+16>>3];g=P[e+4>>2];h=P[e+8>>2];i=P[e+12>>2];L[a+40>>2]=0;P[a+36>>2]=i*S(p);P[a+32>>2]=h*S(o);P[a+28>>2]=g*S(n);d=R(L[j>>2],m)+d|0;g=S(P[e+8>>2]*S(Q[d+8>>3]));i=S(P[e+4>>2]*S(Q[d>>3]));h=S(Q[d+16>>3]);break a;case 1:f=R(N[j+4>>1],m)+d|0;n=Q[f>>3];o=Q[f+8>>3];p=Q[f+16>>3];g=P[e+4>>2];h=P[e+8>>2];i=P[e+12>>2];L[a+56>>2]=0;P[a+52>>2]=i*S(p);P[a+48>>2]=h*S(o);P[a+44>>2]=g*S(n);f=R(N[j+2>>1],m)+d|0;n=Q[f>>3];o=Q[f+8>>3];p=Q[f+16>>3];g=P[e+4>>2];h=P[e+8>>2];i=P[e+12>>2];L[a+40>>2]=0;P[a+36>>2]=i*S(p);P[a+32>>2]=h*S(o);P[a+28>>2]=g*S(n);d=R(N[j>>1],m)+d|0;g=S(P[e+8>>2]*S(Q[d+8>>3]));i=S(P[e+4>>2]*S(Q[d>>3]));h=S(Q[d+16>>3]);break a;default:break h}}f=R(M[j+2|0],m)+d|0;n=Q[f>>3];o=Q[f+8>>3];p=Q[f+16>>3];g=P[e+4>>2];h=P[e+8>>2];i=P[e+12>>2];L[a+56>>2]=0;P[a+52>>2]=i*S(p);P[a+48>>2]=h*S(o);P[a+44>>2]=g*S(n);f=R(M[j+1|0],m)+d|0;n=Q[f>>3];o=Q[f+8>>3];p=Q[f+16>>3];g=P[e+4>>2];h=P[e+8>>2];i=P[e+12>>2];L[a+40>>2]=0;P[a+36>>2]=i*S(p);P[a+32>>2]=h*S(o);P[a+28>>2]=g*S(n);d=R(M[j|0],m)+d|0;g=S(P[e+8>>2]*S(Q[d+8>>3]));i=S(P[e+4>>2]*S(Q[d>>3]));h=S(Q[d+16>>3])}q=P[k>>2];L[a+24>>2]=0;P[a+16>>2]=g;P[a+12>>2]=i;P[a+20>>2]=q*h;d=L[a+8>>2];ha[L[L[d>>2]+8>>2]](d,a+12|0,b,c);a=L[a+4>>2];ha[L[L[a>>2]+24>>2]](a,b);fa=l+32|0}function Ld(a,b,c,d,e,f){var g=0,h=0,i=0,j=S(0);L[a+104>>2]=0;L[a+108>>2]=0;J[a+100|0]=0;L[a+96>>2]=0;L[a+92>>2]=e;K[a+6>>1]=65535;K[a+4>>1]=65534;L[a>>2]=5520;if(!e){L[8513]=L[8513]+1;e=qh(ha[L[6798]](76,16)|0);J[a+100|0]=1;L[a+92>>2]=e}if(!f){L[8513]=L[8513]+1;e=ha[L[6798]](24,16)|0;L[e+4>>2]=0;L[e+8>>2]=0;L[e+20>>2]=0;L[e>>2]=5584;L[e+12>>2]=0;L[e+16>>2]=0;L[e+8>>2]=0;J[e+20|0]=1;L[a+112>>2]=e;L[8513]=L[8513]+1;e=th(ha[L[6798]](196,16)|0,L[a+112>>2]);L[a+108>>2]=e;J[e+193|0]=1}e=L[b+4>>2];L[a+8>>2]=L[b>>2];L[a+12>>2]=e;e=L[b+12>>2];L[a+16>>2]=L[b+8>>2];L[a+20>>2]=e;b=L[c+12>>2];L[a+32>>2]=L[c+8>>2];L[a+36>>2]=b;b=L[c+4>>2];L[a+24>>2]=L[c>>2];L[a+28>>2]=b;e=0;L[a+52>>2]=0;j=S(N[a+6>>1]);P[a+48>>2]=j/S(P[a+32>>2]-P[a+16>>2]);P[a+44>>2]=j/S(P[a+28>>2]-P[a+12>>2]);P[a+40>>2]=j/S(P[a+24>>2]-P[a+8>>2]);L[8513]=L[8513]+1;f=d+1|0;d=f&65535;i=d<<6;c=ha[L[6798]](i,16)|0;a:{if(!d){K[a+58>>1]=f;L[a+60>>2]=c;K[a+64>>1]=1;K[a+56>>1]=0;break a}b=c;g=d&7;if(g){while(1){L[b+8>>2]=0;L[b>>2]=0;b=b- -64|0;e=e+1|0;if((g|0)!=(e|0)){continue}break}}if((d-1&67108863)>>>0>=7){e=c+i|0;while(1){L[b+448>>2]=0;L[b+384>>2]=0;L[b+320>>2]=0;L[b+256>>2]=0;L[b+192>>2]=0;L[b+128>>2]=0;L[b+64>>2]=0;L[b+8>>2]=0;L[b>>2]=0;L[b+456>>2]=0;L[b+392>>2]=0;L[b+328>>2]=0;L[b+264>>2]=0;L[b+200>>2]=0;L[b+136>>2]=0;L[b+72>>2]=0;b=b+512|0;if((e|0)!=(b|0)){continue}break}}K[a+58>>1]=f;L[a+60>>2]=c;b=1;K[a+64>>1]=1;K[a+56>>1]=0;if((f&65535)>>>0<2){break a}e=d-1|0;f=e&7;if(d-2>>>0>=7){i=e&-8;e=0;while(1){g=b+1|0;K[(c+(b<<6)|0)+48>>1]=g;h=c+(g<<6)|0;g=b+2|0;K[h+48>>1]=g;h=c+(g<<6)|0;g=b+3|0;K[h+48>>1]=g;h=c+(g<<6)|0;g=b+4|0;K[h+48>>1]=g;h=c+(g<<6)|0;g=b+5|0;K[h+48>>1]=g;h=c+(g<<6)|0;g=b+6|0;K[h+48>>1]=g;h=c+(g<<6)|0;g=b+7|0;K[h+48>>1]=g;b=b+8|0;K[(c+(g<<6)|0)+48>>1]=b;e=e+8|0;if((i|0)!=(e|0)){continue}break}}if(!f){break a}e=0;while(1){g=c+(b<<6)|0;b=b+1|0;K[g+48>>1]=b;e=e+1|0;if((f|0)!=(e|0)){continue}break}}K[(c+(d<<6)|0)-16>>1]=0;L[8513]=L[8513]+1;b=d<<3;c=ha[L[6798]](b,16)|0;L[a+68>>2]=c;L[a+80>>2]=c;L[8513]=L[8513]+1;c=ha[L[6798]](b,16)|0;L[a+72>>2]=c;L[a+84>>2]=c;L[8513]=L[8513]+1;b=ha[L[6798]](b,16)|0;L[a+76>>2]=b;L[a+88>>2]=b;b=L[a+60>>2];K[b+54>>1]=1;K[b+48>>1]=0;L[b>>2]=0;c=L[a+68>>2];K[c>>1]=0;K[c+2>>1]=0;d=N[a+6>>1];K[c+6>>1]=0;K[c+4>>1]=d;K[b+56>>1]=1;K[b+50>>1]=0;c=L[a+72>>2];K[c>>1]=0;K[c+2>>1]=0;d=N[a+6>>1];K[c+6>>1]=0;K[c+4>>1]=d;K[b+58>>1]=1;K[b+52>>1]=0;b=L[a+76>>2];K[b>>1]=0;K[b+2>>1]=0;c=N[a+6>>1];K[b+6>>1]=0;K[b+4>>1]=c;L[a>>2]=5356}function bt(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,f=S(0),g=S(0),h=S(0),i=S(0),j=S(0),k=S(0),l=S(0),m=S(0),n=S(0),o=S(0),p=S(0),q=S(0),r=S(0),s=S(0),t=S(0),u=S(0),v=S(0),w=S(0),x=S(0),y=S(0),z=S(0),A=0,B=0,C=0,D=0,E=S(0),F=S(0),G=S(0);e=fa-16|0;fa=e;L[e+12>>2]=a;L[e+8>>2]=b;J[e+7|0]=c;A=oa(1128);c=L[e+12>>2];a=L[e+8>>2];B=M[e+7|0];b=ub(A,7,al(),c);J[b+48|0]=0;L[b>>2]=20084;d=L[a+12>>2];L[b+124>>2]=L[a+8>>2];L[b+128>>2]=d;d=L[a+4>>2];L[b+116>>2]=L[a>>2];L[b+120>>2]=d;d=L[a+28>>2];L[b+140>>2]=L[a+24>>2];L[b+144>>2]=d;d=L[a+20>>2];L[b+132>>2]=L[a+16>>2];L[b+136>>2]=d;d=L[a+36>>2];L[b+148>>2]=L[a+32>>2];L[b+152>>2]=d;d=L[a+44>>2];L[b+156>>2]=L[a+40>>2];L[b+160>>2]=d;d=L[a+56>>2];C=L[a+60>>2];D=L[a+52>>2];a=L[a+48>>2];J[b+180|0]=B&1;L[b+164>>2]=a;L[b+168>>2]=D;L[b+172>>2]=d;L[b+176>>2]=C;o=P[b+172>>2];p=P[b+164>>2];q=P[b+168>>2];r=P[b+148>>2];s=P[b+116>>2];t=P[b+132>>2];u=P[b+152>>2];v=P[b+120>>2];w=P[b+136>>2];x=P[b+156>>2];y=P[b+124>>2];z=P[b+140>>2];E=P[c+52>>2];F=P[c+56>>2];G=P[c+60>>2];f=P[c+12>>2];g=P[c+8>>2];h=P[c+28>>2];i=P[c+20>>2];j=P[c+24>>2];k=P[c+44>>2];l=P[c+36>>2];m=P[c+40>>2];n=P[c+4>>2];L[b+288>>2]=1065353216;L[b+292>>2]=0;L[b+280>>2]=1065353216;L[b+284>>2]=1060320051;L[b+272>>2]=1065353216;L[b+276>>2]=0;L[b+264>>2]=1065353216;L[b+268>>2]=1060320051;L[b+224>>2]=0;L[b+228>>2]=0;L[b+216>>2]=1065353216;L[b+220>>2]=1060320051;L[b+208>>2]=0;L[b+212>>2]=0;L[b+200>>2]=1065353216;L[b+204>>2]=1060320051;L[b+192>>2]=0;L[b+196>>2]=0;L[b+184>>2]=1065353216;L[b+188>>2]=-1082130432;L[b+112>>2]=0;L[b+96>>2]=0;L[b+80>>2]=0;L[b- -64>>2]=0;P[b+92>>2]=S(x*k)+S(S(y*l)+S(z*m));P[b+88>>2]=S(u*k)+S(S(v*l)+S(w*m));P[b+84>>2]=S(r*k)+S(S(s*l)+S(t*m));P[b+76>>2]=S(x*h)+S(S(y*i)+S(z*j));P[b+72>>2]=S(u*h)+S(S(v*i)+S(w*j));P[b+68>>2]=S(r*h)+S(S(s*i)+S(t*j));P[b+60>>2]=S(x*f)+S(S(y*n)+S(g*z));P[b+56>>2]=S(u*f)+S(S(v*n)+S(g*w));P[b+52>>2]=S(r*f)+S(S(s*n)+S(t*g));P[b+108>>2]=G+S(S(o*k)+S(S(p*l)+S(m*q)));P[b+104>>2]=F+S(S(o*h)+S(S(p*i)+S(j*q)));P[b+100>>2]=E+S(S(o*f)+S(S(p*n)+S(g*q)));L[b+1124>>2]=0;L[b+1116>>2]=0;L[b+1120>>2]=0;J[b+1096|0]=0;L[b+256>>2]=1065353216;L[b+260>>2]=0;L[b+248>>2]=1065353216;L[b+252>>2]=1060320051;L[b+240>>2]=1065353216;L[b+244>>2]=0;L[b+232>>2]=1065353216;L[b+236>>2]=1060320051;L[b+1100>>2]=0;L[b+1104>>2]=0;L[b+300>>2]=0;a=b+1105|0;J[a|0]=0;J[a+1|0]=0;J[a+2|0]=0;J[a+3|0]=0;J[a+4|0]=0;J[a+5|0]=0;J[a+6|0]=0;J[a+7|0]=0;J[b+49|0]=1;sg(b,L[b+28>>2]+4|0,L[b+32>>2]+4|0);fa=e+16|0;return A|0}function FB(a){a=a|0;var b=0,c=0,d=0,e=S(0),f=S(0),g=S(0),h=0,i=S(0),j=S(0),k=S(0),l=S(0),m=0,n=S(0),o=S(0),p=S(0),q=S(0),r=S(0),s=S(0),t=S(0),u=S(0),v=S(0),w=S(0),x=S(0),y=S(0),z=S(0),A=S(0);c=fa-48|0;fa=c;if(M[a+1308|0]){L[a+1056>>2]=0;L[a+992>>2]=0;L[a+928>>2]=0;L[a+712>>2]=0;L[a+716>>2]=0;L[a+720>>2]=0;L[a+724>>2]=0;qd(a,L[a+28>>2]+4|0,L[a+32>>2]+4|0);ha[L[L[a>>2]+44>>2]](a);b=a+1292|0;d=L[b+4>>2];L[c+40>>2]=L[b>>2];L[c+44>>2]=d;d=L[a+1288>>2];L[c+32>>2]=L[a+1284>>2];L[c+36>>2]=d;d=L[b+4>>2];L[c+24>>2]=L[b>>2];L[c+28>>2]=d;b=L[a+1288>>2];L[c+16>>2]=L[a+1284>>2];L[c+20>>2]=b;if(P[a+696>>2]>=P[a+680>>2]){b=M[a+1300|0];g=P[(b?a+1064|0:a+1128|0)>>2];f=P[(b?a+1080|0:a+1144|0)>>2];e=P[(b?a+1096|0:a+1160|0)>>2];L[c+12>>2]=0;P[c+8>>2]=e;P[c+4>>2]=f;P[c>>2]=g;ug(a,a+176|0,c,c+32|0,c+16|0)}if(P[a+700>>2]>=P[a+684>>2]){b=M[a+1300|0];g=P[(b?a+1068|0:a+1132|0)>>2];f=P[(b?a+1084|0:a+1148|0)>>2];e=P[(b?a+1100|0:a+1164|0)>>2];L[c+12>>2]=0;P[c+8>>2]=e;P[c+4>>2]=f;P[c>>2]=g;ug(a,a+260|0,c,c+32|0,c+16|0)}if(P[a+704>>2]>=P[a+688>>2]){b=M[a+1300|0];g=P[(b?a+1072|0:a+1136|0)>>2];f=P[(b?a+1088|0:a+1152|0)>>2];e=P[(b?a+1104|0:a+1168|0)>>2];L[c+12>>2]=0;P[c+8>>2]=e;P[c+4>>2]=f;P[c>>2]=g;ug(a,a+344|0,c,c+32|0,c+16|0)}while(1){if(De(a,m)){b=(m<<4)+a|0;d=b+1216|0;h=L[d+4>>2];L[c+8>>2]=L[d>>2];L[c+12>>2]=h;b=b+1208|0;d=L[b+4>>2];L[c>>2]=L[b>>2];L[c+4>>2]=d;d=L[a+32>>2];i=P[d+36>>2];j=P[d+20>>2];n=P[d+40>>2];k=P[d+8>>2];l=P[d+24>>2];o=P[d+44>>2];s=P[d+12>>2];t=P[d+28>>2];h=L[a+28>>2];p=P[h+36>>2];u=P[h+20>>2];q=P[h+40>>2];v=P[h+8>>2];w=P[h+24>>2];r=P[h+44>>2];x=P[h+12>>2];y=P[h+28>>2];z=P[d+4>>2];A=P[h+4>>2];b=R(m,84)+a|0;L[b+436>>2]=0;L[b+440>>2]=0;L[b+428>>2]=0;L[b+432>>2]=0;g=P[c+8>>2];e=P[c>>2];f=P[c+4>>2];L[b+472>>2]=0;L[b+456>>2]=0;r=S(S(r*g)+S(S(x*e)+S(y*f)));P[b+452>>2]=r;q=S(S(q*g)+S(S(v*e)+S(w*f)));P[b+448>>2]=q;p=S(S(p*g)+S(S(A*e)+S(u*f)));P[b+444>>2]=p;e=S(-e);o=S(S(S(s*e)-S(t*f))-S(o*g));P[b+468>>2]=o;n=S(S(S(k*e)-S(l*f))-S(n*g));P[b+464>>2]=n;g=S(S(S(z*e)-S(j*f))-S(i*g));P[b+460>>2]=g;f=P[h+400>>2];e=P[h+404>>2];i=P[h+396>>2];L[b+488>>2]=0;e=S(r*e);P[b+484>>2]=e;f=S(q*f);P[b+480>>2]=f;i=S(p*i);P[b+476>>2]=i;j=P[d+400>>2];k=P[d+404>>2];l=P[d+396>>2];L[b+504>>2]=0;k=S(o*k);P[b+500>>2]=k;j=S(n*j);P[b+496>>2]=j;l=S(g*l);P[b+492>>2]=l;P[b+508>>2]=S(S(e*r)+S(S(i*p)+S(q*f)))+S(S(k*o)+S(S(l*g)+S(n*j)))}m=m+1|0;if((m|0)!=3){continue}break}}fa=c+48|0}function SG(a,b,c,d){a=a|0;b=b|0;c=c|0;d=S(d);var e=S(0),f=S(0),g=S(0),h=S(0),i=S(0),j=S(0),k=S(0),l=S(0),m=S(0),n=0,o=S(0),p=S(0),q=S(0),r=S(0),s=S(0),t=S(0),u=S(0),v=S(0),w=S(0),x=S(0),y=S(0),z=S(0),A=S(0),B=S(0),C=S(0),D=S(0),E=S(0),F=S(0),G=S(0),H=S(0),I=S(0),J=S(0);n=fa-16|0;fa=n;k=P[b+8>>2];f=P[c+8>>2];q=S(S(k*d)+f);C=P[b+4>>2];B=P[c+4>>2];D=S(S(C*d)+B);E=P[b>>2];e=S(E*d);d=P[c>>2];F=S(e+d);a:{if(M[a+228|0]){r=P[a+44>>2];i=S(-P[a+84>>2]);s=P[a+60>>2];h=P[a+88>>2];t=P[a+76>>2];g=P[a+92>>2];y=S(S(S(r*i)-S(s*h))-S(t*g));e=P[a+204>>2];u=P[a+36>>2];v=P[a+52>>2];w=P[a+68>>2];z=S(S(S(u*i)-S(v*h))-S(w*g));l=P[a+196>>2];x=P[a+40>>2];j=S(x*i);i=P[a+56>>2];j=S(j-S(i*h));h=P[a+72>>2];j=S(j-S(h*g));g=P[a+200>>2];e=S(S(S(S(y*e)+S(S(z*l)+S(j*g)))+P[a+220>>2])+S(S(q*S(S(t*e)+S(S(w*l)+S(h*g))))+S(S(F*S(S(r*e)+S(S(u*l)+S(x*g))))+S(D*S(S(s*e)+S(S(v*l)+S(i*g)))))));g=e;l=k;o=S(S(e-f)*k);f=P[a+172>>2];e=P[a+164>>2];k=P[a+168>>2];e=S(S(S(q*S(S(t*f)+S(S(w*e)+S(h*k))))+S(S(F*S(S(r*f)+S(S(u*e)+S(x*k))))+S(D*S(S(s*f)+S(S(v*e)+S(i*k))))))+S(S(S(y*f)+S(S(z*e)+S(k*j)))+P[a+212>>2]));p=S(S(e-d)*E);k=q;d=P[a+188>>2];f=P[a+180>>2];q=P[a+184>>2];f=S(S(S(k*S(S(t*d)+S(S(w*f)+S(h*q))))+S(S(F*S(S(r*d)+S(S(u*f)+S(x*q))))+S(D*S(S(s*d)+S(S(v*f)+S(i*q))))))+S(S(S(y*d)+S(S(z*f)+S(j*q)))+P[a+216>>2]));d=S(o+S(p+S(C*S(f-B))));P[n+8>>2]=g+S(l*d);P[n+4>>2]=f+S(C*d);P[n>>2]=e+S(E*d);break a}I=P[a+220>>2];r=P[a+204>>2];s=P[a+196>>2];t=P[a+200>>2];J=P[a+212>>2];e=P[a+168>>2];u=P[a+172>>2];v=P[a+164>>2];w=P[a+108>>2];o=S(-P[a+148>>2]);l=P[a+124>>2];p=P[a+152>>2];x=P[a+140>>2];A=P[a+156>>2];i=S(S(S(w*o)-S(l*p))-S(x*A));h=P[a+100>>2];g=P[a+116>>2];y=P[a+132>>2];z=S(S(S(h*o)-S(g*p))-S(y*A));j=P[a+104>>2];m=S(j*o);o=P[a+120>>2];m=S(m-S(o*p));p=P[a+136>>2];A=S(m-S(p*A));m=P[a+188>>2];G=P[a+180>>2];H=P[a+184>>2];m=S(S(S(f*S(S(x*m)+S(S(y*G)+S(p*H))))+S(S(d*S(S(w*m)+S(S(h*G)+S(j*H))))+S(B*S(S(l*m)+S(S(g*G)+S(o*H))))))+S(S(S(i*m)+S(S(z*G)+S(A*H)))+P[a+216>>2]));P[n+4>>2]=m;e=S(S(S(f*S(S(x*u)+S(S(y*v)+S(p*e))))+S(S(d*S(S(w*u)+S(S(h*v)+S(j*e))))+S(B*S(S(l*u)+S(S(g*v)+S(o*e))))))+S(J+S(S(i*u)+S(S(z*v)+S(e*A)))));P[n>>2]=e;d=S(S(I+S(S(i*r)+S(S(z*s)+S(A*t))))+S(S(f*S(S(x*r)+S(S(y*s)+S(p*t))))+S(S(d*S(S(w*r)+S(S(h*s)+S(j*t))))+S(B*S(S(l*r)+S(S(g*s)+S(o*t)))))));P[n+8>>2]=d;d=S(S(S(q-d)*k)+S(S(S(F-e)*E)+S(C*S(D-m))))}L[n+12>>2]=0;a=L[a+32>>2];ha[L[L[a>>2]+16>>2]](a,b,n,d);fa=n+16|0}function ol(a,b){var c=S(0),d=S(0),e=S(0),f=S(0),g=S(0),h=S(0),i=S(0),j=S(0),k=S(0),l=S(0),m=S(0),n=S(0),o=S(0),p=S(0),q=0,r=S(0),s=S(0);q=L[b+4>>2];L[a+556>>2]=L[b>>2];L[a+560>>2]=q;q=L[b+12>>2];L[a+564>>2]=L[b+8>>2];L[a+568>>2]=q;k=S(-0);l=S(1);f=P[a+568>>2];d=S(f*S(0));g=P[a+564>>2];h=P[a+556>>2];e=S(h*S(0));j=S(S(d+g)-e);e=S(d+e);d=P[a+560>>2];i=S(e-d);e=S(g*S(-0));p=S(e+S(S(d*S(-0))-h));e=S(e+S(f+S(d*S(0))));m=S(S(j*h)+S(S(S(f*i)-S(p*g))-S(e*d)));n=S(S(i*d)+S(S(S(f*e)-S(p*h))-S(j*g)));j=S(S(e*g)+S(S(S(f*j)-S(p*d))-S(i*h)));i=S(S(m*S(0))+S(n+S(j*S(0))));if(!(i>2];a:{if(!(f>=S(.05000000074505806))){break a}c=P[a+448>>2];if(!(c>=S(.05000000074505806))){break a}d=oS(1)?S(1):d);d=S(d+d);b:{if(!(d>S(1.1920928955078125e-7))){break b}e=S(S(1)/S(_(S(S(i*i)+S(S(k*k)+S(l*l))))));m=S(i*e);n=S(k*e);e=S(l*e);if(!(S(T(e))>S(1.1920928955078125e-7))){break b}s=S(S(m*m)/S(e*e));f=S(_(S(S(s+S(1))/S(S(S(1)/S(c*c))+S(s/S(f*f))))))}if(!(S(T(d))>S(1.1920928955078125e-7))){break a}c:{if(d>f){d=f;break c}c=S(-f);if(!(c>d)){break c}d=c}c=S(d*S(.5));d=S(Ea(c)/S(_(S(S(m*m)+S(S(n*n)+S(e*e))))));i=S(m*d);l=S(e*d);k=S(n*d);o=Fa(c)}f=S(j*g);d=S(p*g);m=S(h*g);n=S(r*g);j=P[a+452>>2];d:{if(!(j>=S(.05000000074505806))){break d}g=n;h=m;e=d;c=fS(1)?S(1):c);c=S(c+c);if(c>S(3.1415927410125732)){e=S(-d);h=S(-m);g=S(-n);c=f>S(1)?S(-1):S(-f);c=ob(c>S(1)?S(1):c);c=S(c+c)}if(c>S(1.1920928955078125e-7)){p=S(S(1)/S(_(S(S(e*e)+S(S(g*g)+S(h*h))))));e=S(e*p);h=S(h*p);g=S(g*p)}if(!(S(T(c))>S(1.1920928955078125e-7))){break d}e:{if(c>j){c=j;break e}d=S(-j);if(!(d>c)){break e}c=d}f=S(c*S(.5));c=S(Ea(f)/S(_(S(S(e*e)+S(S(g*g)+S(h*h))))));d=S(e*c);m=S(h*c);n=S(g*c);f=Fa(f)}P[a+568>>2]=S(S(S(o*f)-S(n*k))-S(l*m))-S(i*d);P[a+564>>2]=S(S(k*m)+S(S(o*d)+S(i*f)))-S(l*n);P[a+560>>2]=S(S(i*n)+S(S(o*m)+S(l*f)))-S(k*d);P[a+556>>2]=S(S(l*d)+S(S(o*n)+S(k*f)))-S(i*m)}function on(a){a=a|0;var b=0,c=0,d=S(0),e=0,f=S(0),g=0,h=S(0),i=S(0),j=S(0),k=S(0),l=0,m=0,n=0,o=0;b=fa-80|0;fa=b;a:{if(!(ha[L[L[a>>2]+20>>2]](a)|0)){break a}c=ha[L[L[a>>2]+20>>2]](a)|0;if(!(ha[L[L[c>>2]+48>>2]](c)&8)){break a}c=L[a+24>>2];l=ha[L[L[c>>2]+36>>2]](c)|0;L[b+72>>2]=0;L[b+76>>2]=0;L[b+64>>2]=1065353216;L[b+68>>2]=1065353216;c=0;if((l|0)<=0){break a}while(1){g=0;e=L[a+24>>2];m=ha[L[L[e>>2]+40>>2]](e,c)|0;n=L[m+748>>2];if((n|0)>0){while(1){o=ha[L[L[a>>2]+20>>2]](a)|0;e=R(g,184)+m|0;ha[L[L[o>>2]+32>>2]](o,e+36|0,e+68|0,P[e+84>>2],L[e+152>>2],b- -64|0);g=g+1|0;if((n|0)!=(g|0)){continue}break}}c=c+1|0;if((l|0)!=(c|0)){continue}break}}b:{if(!(ha[L[L[a>>2]+20>>2]](a)|0)){break b}c=ha[L[L[a>>2]+20>>2]](a)|0;if(!(ha[L[L[c>>2]+48>>2]](c)&3)|L[a+8>>2]<=0){break b}g=0;while(1){c=L[L[a+16>>2]+(g<<2)>>2];c:{if(M[c+204|0]&32){break c}d:{if(!(ha[L[L[a>>2]+20>>2]](a)|0)){break d}e=ha[L[L[a>>2]+20>>2]](a)|0;if(!(ha[L[L[e>>2]+48>>2]](e)&1)){break d}e:{f:{g:{h:{switch(L[c+216>>2]-1|0){case 0:L[b+64>>2]=1065353216;break f;case 1:L[b+64>>2]=0;break g;case 2:L[b+64>>2]=0;break f;case 4:L[b+64>>2]=1065353216;break g;default:break h}}L[b+64>>2]=1065353216;f=S(0);d=S(0);break e}f=S(1);d=S(0);break e}f=S(1);d=S(1)}L[b+76>>2]=0;P[b+72>>2]=d;P[b+68>>2]=f;ha[L[L[a>>2]+28>>2]](a,c+4|0,L[c+192>>2],b- -64|0)}e=L[a+72>>2];if(!e){break c}if(!(ha[L[L[e>>2]+48>>2]](e)&2)){break c}L[b+40>>2]=0;L[b+44>>2]=0;L[b+32>>2]=1065353216;L[b+36>>2]=0;e=L[c+192>>2];ha[L[L[e>>2]+8>>2]](e,c+4|0,b- -64|0,b+48|0);d=P[6794];P[b+64>>2]=P[b+64>>2]-d;P[b+68>>2]=P[b+68>>2]-d;P[b+72>>2]=P[b+72>>2]-d;P[b+48>>2]=d+P[b+48>>2];P[b+52>>2]=d+P[b+52>>2];P[b+56>>2]=d+P[b+56>>2];i:{if(M[c+204|0]&3|(!M[a+44|0]|L[c+236>>2]!=2)){break i}e=L[c+192>>2];ha[L[L[e>>2]+8>>2]](e,c+68|0,b+16|0,b);f=S(P[b+16>>2]-d);P[b+16>>2]=f;h=S(P[b+20>>2]-d);P[b+20>>2]=h;i=S(P[b+24>>2]-d);P[b+24>>2]=i;j=S(d+P[b>>2]);P[b>>2]=j;k=S(d+P[b+4>>2]);P[b+4>>2]=k;d=S(d+P[b+8>>2]);P[b+8>>2]=d;if(f>2]){P[b+64>>2]=f}if(P[b+68>>2]>h){P[b+68>>2]=h}if(P[b+72>>2]>i){P[b+72>>2]=i}f=P[b+28>>2];if(f>2]){P[b+76>>2]=f}if(P[b+48>>2]>2]=j}if(P[b+52>>2]>2]=k}if(d>P[b+56>>2]){P[b+56>>2]=d}d=P[b+12>>2];if(!(d>P[b+60>>2])){break i}P[b+60>>2]=d}c=L[a+72>>2];ha[L[L[c>>2]+52>>2]](c,b- -64|0,b+48|0,b+32|0)}g=g+1|0;if((g|0)>2]){continue}break}}fa=b+80|0}function ml(a,b,c,d,e,f){a=ub(a,6,b,c);L[a>>2]=19568;b=L[d+12>>2];L[a+56>>2]=L[d+8>>2];L[a+60>>2]=b;b=L[d+4>>2];L[a+48>>2]=L[d>>2];L[a+52>>2]=b;b=L[d+28>>2];L[a+72>>2]=L[d+24>>2];L[a+76>>2]=b;c=L[d+20>>2];b=a- -64|0;L[b>>2]=L[d+16>>2];L[b+4>>2]=c;b=L[d+44>>2];L[a+88>>2]=L[d+40>>2];L[a+92>>2]=b;b=L[d+36>>2];L[a+80>>2]=L[d+32>>2];L[a+84>>2]=b;b=L[d+60>>2];L[a+104>>2]=L[d+56>>2];L[a+108>>2]=b;b=L[d+52>>2];L[a+96>>2]=L[d+48>>2];L[a+100>>2]=b;b=L[e+12>>2];L[a+120>>2]=L[e+8>>2];L[a+124>>2]=b;b=L[e+4>>2];L[a+112>>2]=L[e>>2];L[a+116>>2]=b;b=L[e+20>>2];L[a+128>>2]=L[e+16>>2];L[a+132>>2]=b;b=L[e+28>>2];L[a+136>>2]=L[e+24>>2];L[a+140>>2]=b;b=L[e+36>>2];L[a+144>>2]=L[e+32>>2];L[a+148>>2]=b;b=L[e+44>>2];L[a+152>>2]=L[e+40>>2];L[a+156>>2]=b;b=L[e+52>>2];L[a+160>>2]=L[e+48>>2];L[a+164>>2]=b;b=L[e+60>>2];L[a+168>>2]=L[e+56>>2];L[a+172>>2]=b;L[a+680>>2]=0;L[a+684>>2]=0;L[a+688>>2]=0;L[a+692>>2]=0;L[a+696>>2]=0;L[a+700>>2]=0;L[a+704>>2]=0;L[a+708>>2]=0;L[a+712>>2]=0;L[a+716>>2]=0;L[a+720>>2]=0;L[a+724>>2]=0;L[a+740>>2]=0;L[a+744>>2]=0;L[a+748>>2]=0;L[a+752>>2]=0;L[a+764>>2]=1045220557;L[a+756>>2]=1045220557;L[a+760>>2]=1045220557;L[a+784>>2]=0;L[a+776>>2]=0;L[a+780>>2]=0;L[a+768>>2]=0;L[a+772>>2]=0;L[a+736>>2]=1056964608;L[a+728>>2]=1060320051;L[a+732>>2]=1065353216;J[a+790|0]=0;K[a+788>>1]=0;L[a+800>>2]=0;L[a+792>>2]=0;L[a+796>>2]=0;L[a+816>>2]=0;L[a+808>>2]=0;L[a+812>>2]=0;L[a+928>>2]=0;L[a+884>>2]=1133903872;L[a+876>>2]=0;L[a+880>>2]=1036831949;L[a+904>>2]=0;L[a+908>>2]=0;L[a+896>>2]=0;L[a+900>>2]=1045220557;L[a+868>>2]=1065353216;L[a+872>>2]=-1082130432;L[a+924>>2]=0;L[a+888>>2]=1065353216;L[a+892>>2]=1056964608;L[a+916>>2]=0;L[a+992>>2]=0;J[a+912|0]=0;L[a+948>>2]=1133903872;L[a+940>>2]=0;L[a+944>>2]=1036831949;L[a+968>>2]=0;L[a+972>>2]=0;L[a+960>>2]=0;L[a+964>>2]=1045220557;L[a+932>>2]=1065353216;L[a+936>>2]=-1082130432;L[a+988>>2]=0;L[a+952>>2]=1065353216;L[a+956>>2]=1056964608;L[a+980>>2]=0;L[a+1056>>2]=0;J[a+976|0]=0;L[a+1012>>2]=1133903872;L[a+1004>>2]=0;L[a+1008>>2]=1036831949;b=a+1032|0;L[b>>2]=0;L[b+4>>2]=0;b=a+1024|0;L[b>>2]=0;L[b+4>>2]=1045220557;L[a+996>>2]=1065353216;L[a+1e3>>2]=-1082130432;L[a+1052>>2]=0;L[a+1016>>2]=1065353216;L[a+1020>>2]=1056964608;L[a+1044>>2]=0;J[a+1308|0]=0;L[a+1304>>2]=0;J[a+1301|0]=1;J[a+1300|0]=f;J[a+1040|0]=0;qd(a,L[a+28>>2]+4|0,L[a+32>>2]+4|0);return a}function pb(a,b,c,d,e){var f=0,g=0,h=0,i=0,j=0,k=S(0),l=S(0),m=S(0),n=S(0),o=0,p=0,q=0,r=0,s=S(0),t=0,u=S(0),v=S(0);if(!((b|0)==(d|0)|(b|0)==(c|0)|(c|0)==(d|0))){i=fa-48|0;fa=i;L[i+40>>2]=0;L[i+32>>2]=0;L[i+36>>2]=0;L[i+24>>2]=0;L[i+28>>2]=0;L[i+16>>2]=0;L[i+20>>2]=0;L[i+8>>2]=0;L[i+12>>2]=0;e=e?e:L[L[a+880>>2]>>2];f=L[a+752>>2];a:{if((f|0)!=L[a+756>>2]){break a}o=f?f<<1:1;if((o|0)<=(f|0)){break a}if(o){L[8513]=L[8513]+1;p=ha[L[6798]](R(o,44),16)|0;f=L[a+752>>2]}b:{if((f|0)<=0){break b}if((f|0)!=1){t=f&-2;while(1){g=R(q,44);h=g+p|0;g=g+L[a+760>>2]|0;j=L[g+4>>2];L[h>>2]=L[g>>2];L[h+4>>2]=j;L[h+40>>2]=L[g+40>>2];j=L[g+36>>2];L[h+32>>2]=L[g+32>>2];L[h+36>>2]=j;j=L[g+28>>2];L[h+24>>2]=L[g+24>>2];L[h+28>>2]=j;j=L[g+20>>2];L[h+16>>2]=L[g+16>>2];L[h+20>>2]=j;j=L[g+12>>2];L[h+8>>2]=L[g+8>>2];L[h+12>>2]=j;g=R(q|1,44);h=g+p|0;g=g+L[a+760>>2]|0;j=L[g+4>>2];L[h>>2]=L[g>>2];L[h+4>>2]=j;j=L[g+12>>2];L[h+8>>2]=L[g+8>>2];L[h+12>>2]=j;j=L[g+20>>2];L[h+16>>2]=L[g+16>>2];L[h+20>>2]=j;j=L[g+28>>2];L[h+24>>2]=L[g+24>>2];L[h+28>>2]=j;j=L[g+36>>2];L[h+32>>2]=L[g+32>>2];L[h+36>>2]=j;L[h+40>>2]=L[g+40>>2];q=q+2|0;r=r+2|0;if((t|0)!=(r|0)){continue}break}}if(!(f&1)){break b}f=R(q,44);g=f+p|0;f=f+L[a+760>>2]|0;h=L[f+4>>2];L[g>>2]=L[f>>2];L[g+4>>2]=h;L[g+40>>2]=L[f+40>>2];h=L[f+36>>2];L[g+32>>2]=L[f+32>>2];L[g+36>>2]=h;h=L[f+28>>2];L[g+24>>2]=L[f+24>>2];L[g+28>>2]=h;h=L[f+20>>2];L[g+16>>2]=L[f+16>>2];L[g+20>>2]=h;h=L[f+12>>2];L[g+8>>2]=L[f+8>>2];L[g+12>>2]=h}f=L[a+760>>2];if(!(f?!f|!M[a+764|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](f)}L[a+760>>2]=p;J[a+764|0]=1;L[a+756>>2]=o;f=L[a+752>>2]}f=L[a+760>>2]+R(f,44)|0;L[f+4>>2]=e;L[f>>2]=0;e=L[i+12>>2];L[f+8>>2]=L[i+8>>2];L[f+12>>2]=e;e=L[i+20>>2];L[f+16>>2]=L[i+16>>2];L[f+20>>2]=e;e=L[i+28>>2];L[f+24>>2]=L[i+24>>2];L[f+28>>2]=e;e=L[i+36>>2];L[f+32>>2]=L[i+32>>2];L[f+36>>2]=e;L[f+40>>2]=L[i+40>>2];L[a+752>>2]=L[a+752>>2]+1;fa=i+48|0;e=(L[a+760>>2]+R(L[a+752>>2],44)|0)-44|0;b=L[a+720>>2]+R(b,104)|0;L[e+8>>2]=b;c=L[a+720>>2]+R(c,104)|0;L[e+12>>2]=c;d=L[a+720>>2]+R(d,104)|0;L[e+16>>2]=d;l=P[b+8>>2];s=S(P[c+8>>2]-l);k=P[b+12>>2];m=S(P[d+12>>2]-k);l=S(P[d+8>>2]-l);k=S(P[c+12>>2]-k);n=S(S(s*m)-S(l*k));u=S(n*n);v=k;k=P[b+16>>2];n=S(P[d+16>>2]-k);k=S(P[c+16>>2]-k);m=S(S(v*n)-S(m*k));l=S(S(k*l)-S(n*s));P[e+36>>2]=_(S(u+S(S(m*m)+S(l*l))));J[a+924|0]=1}}function Ck(a,b){var c=0,d=0,e=S(0),f=S(0),g=S(0),h=S(0),i=S(0),j=S(0),k=S(0),l=S(0),m=S(0),n=S(0),o=S(0),p=S(0),q=S(0),r=S(0),s=S(0);d=fa+-64|0;fa=d;J[b+84|0]=0;c=L[a+116>>2];r=P[c+52>>2];g=P[c+8>>2];e=P[c+12>>2];s=P[c+56>>2];i=P[c+20>>2];h=P[c+24>>2];k=P[c+28>>2];f=P[c+60>>2];m=P[c+36>>2];n=P[c+40>>2];o=P[c+44>>2];p=P[c+4>>2];L[b+48>>2]=0;q=f;f=P[b+164>>2];j=P[b+156>>2];l=P[b+160>>2];P[b+44>>2]=q+S(S(o*f)+S(S(m*j)+S(n*l)));P[b+40>>2]=s+S(S(f*k)+S(S(j*i)+S(h*l)));P[b+36>>2]=r+S(S(f*e)+S(S(j*p)+S(g*l)));L[b- -64>>2]=0;f=P[b+180>>2];j=P[b+172>>2];l=P[b+176>>2];P[b+60>>2]=S(o*f)+S(S(m*j)+S(n*l));P[b+56>>2]=S(k*f)+S(S(i*j)+S(h*l));P[b+52>>2]=S(e*f)+S(S(p*j)+S(g*l));f=P[b+192>>2];j=P[b+196>>2];l=P[b+188>>2];L[b+80>>2]=0;P[b+76>>2]=S(o*j)+S(S(m*l)+S(n*f));P[b+72>>2]=S(k*j)+S(S(i*l)+S(h*f));P[b+68>>2]=S(e*j)+S(S(p*l)+S(g*f));g=P[b+204>>2];L[b+28>>2]=0;g=S(g+P[b+212>>2]);P[b+24>>2]=S(g*P[b+60>>2])+P[b+44>>2];P[b+20>>2]=S(g*P[b+56>>2])+P[b+40>>2];P[b+16>>2]=S(P[b+52>>2]*g)+P[b+36>>2];L[d+44>>2]=-1082130432;c=L[a+100>>2];c=ha[L[L[c>>2]+8>>2]](c,b+36|0,b+16|0,d+12|0)|0;L[b+88>>2]=0;a:{if(c){e=P[d+44>>2];c=L[d+32>>2];L[b>>2]=L[d+28>>2];L[b+4>>2]=c;c=L[d+40>>2];L[b+8>>2]=L[d+36>>2];L[b+12>>2]=c;J[b+84|0]=1;g=S(g*e);if(!M[33784]){L[d+56>>2]=0;L[d+60>>2]=0;L[d+48>>2]=0;L[d+52>>2]=0;ng(33168,d+48|0);J[33784]=1}L[d+56>>2]=0;L[d+60>>2]=0;L[d+48>>2]=0;L[d+52>>2]=0;ve(33168,S(0),d+48|0);L[b+88>>2]=33168;P[b+32>>2]=g-P[b+212>>2];i=P[b+204>>2];h=S(P[b+208>>2]*S(.009999999776482582));e=S(i-h);k=P[b+32>>2];c=e>k;e=c?e:k;i=S(i+h);if(c|e>i){P[b+32>>2]=e>i?i:e}c=L[d+16>>2];L[b+16>>2]=L[d+12>>2];L[b+20>>2]=c;c=L[d+24>>2];L[b+24>>2]=L[d+20>>2];L[b+28>>2]=c;h=P[b+8>>2];k=P[b>>2];m=P[b+4>>2];e=S(S(h*P[b+60>>2])+S(S(k*P[b+52>>2])+S(m*P[b+56>>2])));if(e>=S(-.10000000149011612)){L[b+272>>2]=0;e=S(10);break a}a=L[a+116>>2];i=P[a+328>>2];e=S(S(-1)/e);f=h;h=S(P[b+20>>2]-P[a+56>>2]);n=S(P[b+16>>2]-P[a+52>>2]);o=P[a+332>>2];j=S(f*S(P[a+320>>2]+S(S(i*h)-S(n*o))));f=k;k=S(P[b+24>>2]-P[a+60>>2]);q=h;h=P[a+336>>2];P[b+272>>2]=e*S(j+S(S(f*S(P[a+312>>2]+S(S(o*k)-S(q*h))))+S(m*S(S(S(h*n)-S(k*i))+P[a+316>>2]))));break a}g=P[b+204>>2];L[b+272>>2]=0;P[b+32>>2]=g;L[b+12>>2]=0;P[b+8>>2]=-P[b+60>>2];P[b+4>>2]=-P[b+56>>2];P[b>>2]=-P[b+52>>2];g=S(-1);e=S(1)}P[b+268>>2]=e;fa=d- -64|0;return g}function zm(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,f=0,g=0,h=S(0),i=S(0),j=S(0),k=0,l=0,m=S(0),n=0,o=0,p=S(0),q=S(0),r=0;d=fa-80|0;fa=d;e=L[a+4>>2];ha[L[L[e>>2]+16>>2]](e,d+28|0,d+24|0,d+20|0,d+16|0,d+12|0,d+8|0,d+4|0,d,b);g=L[d+12>>2]+R(L[d+8>>2],c)|0;e=L[a+4>>2];k=L[d+16>>2];l=L[d+28>>2];f=L[d>>2];a:{if(!L[d+20>>2]){if((f|0)!=3){f=R(L[g+8>>2],k)+l|0;h=P[f>>2];i=P[f+4>>2];j=P[f+8>>2];m=P[e+4>>2];p=P[e+8>>2];q=P[e+12>>2];L[d+76>>2]=0;P[d+72>>2]=j*q;P[d+68>>2]=i*p;P[d+64>>2]=h*m;f=R(L[g+4>>2],k)+l|0;h=P[f>>2];i=P[f+4>>2];j=P[f+8>>2];m=P[e+4>>2];p=P[e+8>>2];q=P[e+12>>2];L[d+60>>2]=0;P[d+56>>2]=j*q;P[d+52>>2]=i*p;P[d+48>>2]=h*m;g=R(L[g>>2],k)+l|0;h=P[g+4>>2];i=P[g+8>>2];j=P[e+8>>2];m=P[e+12>>2];P[d+32>>2]=P[g>>2]*P[e+4>>2];i=S(i*m);h=S(h*j);break a}f=R(N[g+4>>1],k)+l|0;h=P[f>>2];i=P[f+4>>2];j=P[f+8>>2];m=P[e+4>>2];p=P[e+8>>2];q=P[e+12>>2];L[d+76>>2]=0;P[d+72>>2]=j*q;P[d+68>>2]=i*p;P[d+64>>2]=h*m;f=R(N[g+2>>1],k)+l|0;h=P[f>>2];i=P[f+4>>2];j=P[f+8>>2];m=P[e+4>>2];p=P[e+8>>2];q=P[e+12>>2];L[d+60>>2]=0;P[d+56>>2]=j*q;P[d+52>>2]=i*p;P[d+48>>2]=h*m;g=R(N[g>>1],k)+l|0;h=P[g+4>>2];i=P[g+8>>2];j=P[e+8>>2];m=P[e+12>>2];P[d+32>>2]=P[g>>2]*P[e+4>>2];i=S(i*m);h=S(h*j);break a}if((f|0)!=3){f=R(L[g+8>>2],k)+l|0;n=Q[f>>3];o=Q[f+8>>3];r=Q[f+16>>3];h=P[e+4>>2];i=P[e+8>>2];j=P[e+12>>2];L[d+76>>2]=0;P[d+72>>2]=j*S(r);P[d+68>>2]=i*S(o);P[d+64>>2]=h*S(n);f=R(L[g+4>>2],k)+l|0;n=Q[f>>3];o=Q[f+8>>3];r=Q[f+16>>3];h=P[e+4>>2];i=P[e+8>>2];j=P[e+12>>2];L[d+60>>2]=0;P[d+56>>2]=j*S(r);P[d+52>>2]=i*S(o);P[d+48>>2]=h*S(n);g=R(L[g>>2],k)+l|0;n=Q[g+8>>3];o=Q[g+16>>3];h=P[e+8>>2];i=P[e+12>>2];P[d+32>>2]=P[e+4>>2]*S(Q[g>>3]);i=S(i*S(o));h=S(h*S(n));break a}f=R(N[g+4>>1],k)+l|0;n=Q[f>>3];o=Q[f+8>>3];r=Q[f+16>>3];h=P[e+4>>2];i=P[e+8>>2];j=P[e+12>>2];L[d+76>>2]=0;P[d+72>>2]=j*S(r);P[d+68>>2]=i*S(o);P[d+64>>2]=h*S(n);f=R(N[g+2>>1],k)+l|0;n=Q[f>>3];o=Q[f+8>>3];r=Q[f+16>>3];h=P[e+4>>2];i=P[e+8>>2];j=P[e+12>>2];L[d+60>>2]=0;P[d+56>>2]=j*S(r);P[d+52>>2]=i*S(o);P[d+48>>2]=h*S(n);g=R(N[g>>1],k)+l|0;n=Q[g+8>>3];o=Q[g+16>>3];h=P[e+8>>2];i=P[e+12>>2];P[d+32>>2]=P[e+4>>2]*S(Q[g>>3]);i=S(i*S(o));h=S(h*S(n))}L[d+44>>2]=0;P[d+40>>2]=i;P[d+36>>2]=h;e=L[a+8>>2];ha[L[L[e>>2]+8>>2]](e,d+32|0,b,c);a=L[a+4>>2];ha[L[L[a>>2]+24>>2]](a,b);fa=d+80|0}function rd(a,b){var c=0,d=0,e=0,f=0,g=0,h=S(0),i=S(0),j=0,k=S(0),l=S(0),m=S(0),n=0,o=S(0),p=S(0),q=S(0),r=0,s=0,t=0,u=0;e=fa-96|0;fa=e;c=L[a+12>>2];d=e+80|0;g=e- -64|0;ha[L[L[c>>2]+8>>2]](c,L[a+8>>2]+4|0,d,g);c=L[b+68>>2];ha[L[L[c>>2]+16>>2]](c,L[L[a+8>>2]+188>>2],d,g,L[b+24>>2]);c=L[b+24>>2];ha[L[L[c>>2]+32>>2]](c,L[L[a+8>>2]+284>>2],b+28|0,c);b=L[a+8>>2];c=L[b+56>>2];L[a+92>>2]=L[b+52>>2];L[a+96>>2]=c;c=L[b+64>>2];L[a+100>>2]=L[b+60>>2];L[a+104>>2]=c;b=L[b+284>>2];a:{if((ha[L[L[b>>2]+36>>2]](b)|0)<=0){g=0;break a}s=a+128|0;g=0;while(1){c=L[a+132>>2];b:{if((c|0)>=0){break b}if(L[a+136>>2]<0){b=L[a+140>>2];if(!(b?!b|!M[a+144|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}J[a+144|0]=1;L[a+136>>2]=0;L[a+140>>2]=0}d=0;b=c;f=0-b&3;if(f){while(1){L[L[a+140>>2]+(b<<2)>>2]=0;b=b+1|0;d=d+1|0;if((f|0)!=(d|0)){continue}break}}if(c>>>0>4294967292){break b}while(1){c=b<<2;L[c+L[a+140>>2]>>2]=0;L[(c+L[a+140>>2]|0)+4>>2]=0;L[(c+L[a+140>>2]|0)+8>>2]=0;L[(c+L[a+140>>2]|0)+12>>2]=0;b=b+4|0;if(b){continue}break}}L[a+132>>2]=0;b=L[L[a+8>>2]+284>>2];b=L[(ha[L[L[b>>2]+28>>2]](b)|0)+12>>2]+(j<<4)|0;c=L[L[b+4>>2]>>2];d=L[L[b>>2]>>2];c:{if((M[d+204|0]&4?d:0)|(M[c+204|0]&4?c:0)){break c}b=L[b+8>>2];if(b){ha[L[L[b>>2]+16>>2]](b,s)}r=L[a+132>>2];if((r|0)<=0){break c}k=P[a+100>>2];l=P[a+96>>2];t=L[a+8>>2];u=L[a+140>>2];m=P[a+92>>2];c=0;while(1){f=L[(c<<2)+u>>2];n=L[f+748>>2];if((n|0)>0){h=L[f+740>>2]==(t|0)?S(-1):S(1);d=0;while(1){b=f+R(d,184)|0;i=P[b+84>>2];if(i>2];p=P[b+72>>2];q=P[b+76>>2];L[a+164>>2]=0;P[a+160>>2]=h*q;P[a+156>>2]=h*p;P[a+152>>2]=h*o;n=L[f+748>>2];o=i}p=P[b+68>>2];q=P[b+72>>2];k=S(S(S(i*S(h*P[b+76>>2]))*S(.20000000298023224))+k);P[a+100>>2]=k;l=S(S(S(i*S(h*q))*S(.20000000298023224))+l);P[a+96>>2]=l;m=S(S(S(i*S(h*p))*S(.20000000298023224))+m);P[a+92>>2]=m;g=1}d=d+1|0;if((n|0)>(d|0)){continue}break}}c=c+1|0;if((r|0)!=(c|0)){continue}break}}b=L[L[a+8>>2]+284>>2];j=j+1|0;if((ha[L[L[b>>2]+36>>2]](b)|0)>(j|0)){continue}break}}b=L[a+8>>2];c=L[a+104>>2];L[e+56>>2]=L[a+100>>2];L[e+60>>2]=c;c=L[a+96>>2];L[e+48>>2]=L[a+92>>2];L[e+52>>2]=c;L[b+260>>2]=L[b+260>>2]+1;a=L[e+60>>2];L[b+60>>2]=L[e+56>>2];L[b+64>>2]=a;a=L[e+52>>2];L[b+52>>2]=L[e+48>>2];L[b+56>>2]=a;fa=e+96|0;return g}function se(a,b,c){var d=S(0),e=S(0),f=S(0),g=S(0),h=S(0),i=S(0),j=S(0),k=S(0),l=S(0),m=S(0),n=S(0),o=S(0),p=S(0),q=S(0),r=0,s=S(0),t=S(0),u=0,v=S(0),w=S(0),x=S(0),y=S(0),z=S(0),A=S(0),B=S(0);n=P[a+452>>2];w=P[a+304>>2];q=P[a+300>>2];a:{if(!(w>S(0)|q>S(0))){break a}u=L[a+720>>2];v=P[(u+R(c,104)|0)+88>>2];if(!(v>S(0))|L[a+288>>2]>3){break a}r=R(c,104)+u|0;p=P[r+48>>2];e=S(p-P[b+8>>2]);s=P[r+40>>2];f=S(s-P[b>>2]);t=P[r+44>>2];j=S(t-P[b+4>>2]);o=S(S(e*e)+S(S(f*f)+S(j*j)));if(!(o>S(1.1920928955078125e-7))){break a}x=P[L[a+684>>2]>>2];A=S(_(o));g=S(S(1)/A);d=S(e*g);h=S(j*g);g=S(f*g);i=P[r+72>>2];k=P[r+80>>2];m=P[r+76>>2];b:{switch(L[a+288>>2]){case 2:e=S(S(k*e)+S(S(i*f)+S(j*m)))>2]*S(.5));i=S(e*S(f*o));f=S(i*S(-d));j=S(i*S(-h));i=S(i*S(-g));c:{if(!(e>S(0))){k=S(0);m=S(0);break c}k=S(0);m=S(0);if(!(e=h)|!(d>S(0)))){d=S(S(S(_(h))/S(_(d)))*S(.800000011920929));f=S(f*d);i=S(i*d);j=S(j*d)}a=R(c,104)+u|0;P[a+56>>2]=B+S(i+P[a+56>>2]);b=a- -64|0;P[b>>2]=m+S(f+P[b>>2]);P[a+60>>2]=k+S(j+P[a+60>>2]);return;case 0:case 1:case 3:break b;default:break a}}l=e;e=S(S(k*e)+S(S(i*f)+S(j*m)))S(0))){break a}e=S(n*v);l=d;a=R(c,104)+u|0;d=S(x*S(S(o*S(f*P[a+92>>2]))*S(-.5)));f=S(q*d);j=S(w*d);d=S(S(l*f)+S(S(k*j)+S(0)));n=S(e*d);l=S(n*n);g=S(S(g*f)+S(S(i*j)+S(0)));n=S(e*g);h=S(S(h*f)+S(S(m*j)+S(0)));f=S(e*h);if(S(l+S(S(n*n)+S(f*f)))>S(S(p*p)+S(S(s*s)+S(t*t)))){e=S(S(1)/e);l=g;g=S(S(1)/S(_(S(S(d*d)+S(S(g*g)+S(h*h))))));f=S(l*g);l=p;p=S(d*g);h=S(h*g);d=S(S(l*p)+S(S(s*f)+S(t*h)));P[a+56>>2]=P[a+56>>2]-S(e*S(f*d));P[a+60>>2]=P[a+60>>2]-S(e*S(h*d));a=a- -64|0;P[a>>2]=P[a>>2]-S(e*S(p*d));return}P[a+56>>2]=g+P[a+56>>2];P[a+60>>2]=h+P[a+60>>2];a=a- -64|0;P[a>>2]=d+P[a>>2]}}function Hl(a,b,c,d,e,f){var g=0,h=S(0),i=S(0),j=S(0),k=S(0),l=0,m=S(0),n=S(0),o=S(0),p=S(0),q=S(0),r=S(0),s=S(0),t=S(0),u=S(0),v=S(0),w=S(0),x=S(0),y=S(0),z=S(0),A=0,B=0,C=0,D=S(0),E=S(0);g=fa-544|0;fa=g;l=a;a=g+384|0;Dg(l,b,c,d,f,a,0);L[g+140>>2]=0;L[g+144>>2]=0;L[g+132>>2]=0;L[g+136>>2]=0;L[g+368>>2]=0;L[g+372>>2]=0;L[g+380>>2]=2;L[g+148>>2]=0;a:{b:{e=Cg(g+4|0,a,e);if(!e){c=L[g+376>>2];if(!L[c+32>>2]){break b}d=0;while(1){a=c;c=d<<2;l=a+c|0;h=P[l+16>>2];a=L[g+504>>2];C=g+528|0;A=L[g+508>>2];B=L[g+384>>2]+(A>>1)|0;l=L[l>>2];if(A&1){a=L[a+L[B>>2]>>2]}ha[a|0](C,B,l);l=L[g+508>>2];a=L[g+388>>2]+(l>>1)|0;p=S(h*P[g+536>>2]);q=S(h*P[g+532>>2]);r=S(h*P[g+528>>2]);c=L[L[g+376>>2]+c>>2];i=S(-P[c+8>>2]);j=S(-P[c+4>>2]);k=S(-P[c>>2]);c=L[g+504>>2];c=l&1?L[L[a>>2]+c>>2]:c;m=S(m+p);n=S(n+q);o=S(o+r);L[g+524>>2]=0;P[g+520>>2]=S(P[g+432>>2]*i)+S(S(P[g+424>>2]*k)+S(P[g+428>>2]*j));P[g+516>>2]=S(P[g+416>>2]*i)+S(S(P[g+408>>2]*k)+S(P[g+412>>2]*j));P[g+512>>2]=S(P[g+400>>2]*i)+S(S(P[g+392>>2]*k)+S(P[g+396>>2]*j));ha[c|0](g+528|0,a,g+512|0);i=P[g+536>>2];j=P[g+528>>2];k=P[g+532>>2];s=S(s+S(h*S(S(S(i*P[g+480>>2])+S(S(j*P[g+472>>2])+S(k*P[g+476>>2])))+P[g+496>>2])));t=S(t+S(h*S(S(S(i*P[g+464>>2])+S(S(j*P[g+456>>2])+S(k*P[g+460>>2])))+P[g+492>>2])));u=S(u+S(h*S(S(S(i*P[g+448>>2])+S(S(j*P[g+440>>2])+S(k*P[g+444>>2])))+P[g+488>>2])));d=d+1|0;c=L[g+376>>2];if(d>>>0>2]){continue}break}break b}L[f>>2]=(e|0)==1?1:2;break a}h=P[b+52>>2];i=P[b+24>>2];j=P[b+20>>2];k=P[b+56>>2];p=P[b+40>>2];q=P[b+36>>2];r=P[b+16>>2];v=P[b+32>>2];w=P[b+48>>2];x=P[b+8>>2];y=P[b>>2];z=P[b+4>>2];L[f+16>>2]=0;P[f+4>>2]=w+S(S(m*x)+S(S(o*y)+S(n*z)));P[f+12>>2]=k+S(S(m*p)+S(S(o*v)+S(n*q)));P[f+8>>2]=h+S(S(m*i)+S(S(o*r)+S(n*j)));i=P[b+52>>2];j=P[b+24>>2];k=P[b+20>>2];p=P[b+56>>2];q=P[b+40>>2];r=P[b+36>>2];v=P[b+48>>2];w=P[b+8>>2];x=P[b>>2];y=P[b+4>>2];z=P[b+16>>2];D=P[b+32>>2];h=S(m-s);m=S(o-u);n=S(n-t);o=S(_(S(S(h*h)+S(S(m*m)+S(n*n)))));P[f+52>>2]=o;L[f+48>>2]=0;L[f+32>>2]=0;E=h;h=o>S(9999999747378752e-20)?S(S(1)/o):S(1);P[f+44>>2]=E*h;P[f+40>>2]=n*h;P[f+36>>2]=m*h;P[f+28>>2]=p+S(S(s*q)+S(S(u*D)+S(t*r)));P[f+24>>2]=i+S(S(s*j)+S(S(u*z)+S(t*k)));P[f+20>>2]=v+S(S(s*w)+S(S(u*x)+S(t*y)))}fa=g+544|0;return!e}function iz(a,b){a=a|0;b=S(b);var c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;d=L[a+452>>2];l=a+324|0;ha[L[L[d>>2]+16>>2]](d,l,0);d=L[a+452>>2];ha[L[L[d>>2]+12>>2]](d)|0;Tk(a,b);wa(2534);if(L[a+328>>2]){d=0;j=L[l+4>>2];a:{if((j|0)<=0){break a}c=L[l+12>>2];if(j>>>0>=4){k=j&-4;while(1){h=e<<2;i=L[L[h+c>>2]+384>>2];f=(f|0)>(i|0)?f:i;i=L[L[c+(h|4)>>2]+384>>2];f=(f|0)>(i|0)?f:i;i=L[L[c+(h|8)>>2]+384>>2];f=(f|0)>(i|0)?f:i;h=L[L[c+(h|12)>>2]+384>>2];f=(f|0)>(h|0)?f:h;e=e+4|0;g=g+4|0;if((k|0)!=(g|0)){continue}break}}g=j&3;if(g){while(1){h=L[L[c+(e<<2)>>2]+384>>2];f=(f|0)>(h|0)?f:h;e=e+1|0;d=d+1|0;if((g|0)!=(d|0)){continue}break}}if((j|0)<=0){break a}d=0;while(1){e=L[L[l+12>>2]+(d<<2)>>2];if(L[e+852>>2]>0){c=0;while(1){g=L[L[e+860>>2]+(c<<2)>>2];ha[L[L[g>>2]+8>>2]](g,P[e+452>>2],f);c=c+1|0;if((c|0)>2]){continue}break}}d=d+1|0;if((j|0)!=(d|0)){continue}break}if((f|0)>0){if((j|0)<=0){break a}g=0;while(1){d=0;while(1){e=L[L[l+12>>2]+(d<<2)>>2];h=L[e+852>>2];b:{if((h|0)<=0){break b}c=0;if((h|0)!=1){i=h&-2;k=0;while(1){m=c<<2;n=L[m+L[e+860>>2]>>2];ha[L[L[n>>2]+12>>2]](n,P[e+452>>2],S(1));m=L[L[e+860>>2]+(m|4)>>2];ha[L[L[m>>2]+12>>2]](m,P[e+452>>2],S(1));c=c+2|0;k=k+2|0;if((i|0)!=(k|0)){continue}break}}if(!(h&1)){break b}c=L[L[e+860>>2]+(c<<2)>>2];ha[L[L[c>>2]+12>>2]](c,P[e+452>>2],S(1))}d=d+1|0;if((j|0)!=(d|0)){continue}break}g=g+1|0;if((g|0)!=(f|0)){continue}break}}if((j|0)<=0){break a}f=0;while(1){g=L[L[l+12>>2]+(f<<2)>>2];if(L[g+852>>2]>0){d=0;while(1){e=d<<2;c=L[e+L[g+860>>2]>>2];ha[L[L[c>>2]+16>>2]](c,P[g+452>>2]);c=L[e+L[g+860>>2]>>2];c:{if(!M[c+152|0]){c=L[g+852>>2];break c}if(c){L[8514]=L[8514]+1;ha[L[6799]](c)}d=d-1|0;c=L[g+852>>2];if((c|0)<=0){break c}h=L[g+860>>2];k=L[h+e>>2];e=0;while(1){i=h+(e<<2)|0;if((k|0)!=L[i>>2]){e=e+1|0;if((e|0)!=(c|0)){continue}break c}break}if((c|0)<=(e|0)){break c}c=c-1|0;e=c<<2;L[i>>2]=L[e+h>>2];L[e+L[g+860>>2]>>2]=k;L[g+852>>2]=c}d=d+1|0;if((d|0)<(c|0)){continue}break}}f=f+1|0;if((j|0)!=(f|0)){continue}break}}}d=L[a+452>>2];ha[L[L[d>>2]+28>>2]](d,S(P[d+12>>2]*b));va();if(L[a+328>>2]>0){d=0;while(1){c=L[L[a+336>>2]+(d<<2)>>2];ok(c,c);d=d+1|0;if((d|0)>2]){continue}break}}a=L[a+452>>2];ha[L[L[a>>2]+32>>2]](a)}function Nb(a,b,c,d){var e=0,f=S(0),g=S(0),h=S(0),i=S(0),j=0,k=S(0),l=S(0),m=S(0),n=S(0),o=0,p=S(0),q=0,r=0,s=S(0),t=S(0),u=S(0),v=S(0),w=S(0),x=0,y=0,z=0,A=0,B=S(0);p=P[c+4>>2];s=P[c+8>>2];i=S(s*S(0));k=S(p-i);l=P[c>>2];f=S(p*S(-0));g=S(S(l*S(0))+f);m=S(i-l);u=S(_(S(S(g*g)+S(S(k*k)+S(m*m)))));n=S(S(1)/u);f=S(f+l);h=S(S(p*S(0))-s);t=S(i+S(l*S(-0)));v=S(_(S(S(f*f)+S(S(h*h)+S(t*t)))));i=S(S(1)/v);e=u>v;k=e?S(k*n):S(h*i);m=e?S(m*n):S(t*i);t=S(S(k*p)-S(l*m));n=e?S(g*n):S(f*i);u=S(S(n*l)-S(s*k));v=S(S(m*s)-S(p*n));x=L[d+12>>2];y=(b|0)<=0;a:{while(1){j=-1;if(!y){i=P[c+8>>2];g=P[c+4>>2];f=P[c>>2];e=0;while(1){b:{if(!L[(e<<2)+x>>2]){break b}if((j|0)!=-1){d=(e<<4)+a|0;h=S(S(P[d+8>>2]*i)+S(S(P[d>>2]*f)+S(g*P[d+4>>2])));d=(j<<4)+a|0;if(!(h>S(S(P[d+8>>2]*i)+S(S(P[d>>2]*f)+S(g*P[d+4>>2]))))){break b}}j=e}e=e+1|0;if((e|0)!=(b|0)){continue}break}}q=-1;e=0;z=(j<<2)+x|0;if(L[z>>2]==3){break a}c:{while(1){o=q;A=e;i=S(e|0);f=S(i*S(.01745329238474369));g=Fa(f);f=Ea(f);q=-1;if(!y){h=S(s+S(S(S(n*f)+S(t*g))*S(.02500000037252903)));w=S(p+S(S(S(m*f)+S(u*g))*S(.02500000037252903)));g=S(l+S(S(S(k*f)+S(v*g))*S(.02500000037252903)));e=0;while(1){d:{if(!L[(e<<2)+x>>2]){break d}if((q|0)!=-1){d=(e<<4)+a|0;f=S(S(P[d+8>>2]*h)+S(S(P[d>>2]*g)+S(w*P[d+4>>2])));d=(q<<4)+a|0;if(!(f>S(S(P[d+8>>2]*h)+S(S(P[d>>2]*g)+S(w*P[d+4>>2]))))){break d}}q=e}e=e+1|0;if((e|0)!=(b|0)){continue}break}}if((j|0)==(o|0)&(j|0)==(q|0)){break c}e:{if((o|0)==-1|(o|0)==(q|0)){break e}g=S(i+S(-40));if(!(i>=g)){break e}while(1){h=S(g*S(.01745329238474369));f=Fa(h);h=Ea(h);f:{g:{if(!y){w=S(s+S(S(S(n*h)+S(t*f))*S(.02500000037252903)));B=S(p+S(S(S(m*h)+S(u*f))*S(.02500000037252903)));f=S(l+S(S(S(k*h)+S(v*f))*S(.02500000037252903)));d=-1;e=0;while(1){h:{if(!L[(e<<2)+x>>2]){break h}if((d|0)!=-1){r=(e<<4)+a|0;h=S(S(P[r+8>>2]*w)+S(S(P[r>>2]*f)+S(B*P[r+4>>2])));r=(d<<4)+a|0;if(!(h>S(S(P[r+8>>2]*w)+S(S(P[r>>2]*f)+S(B*P[r+4>>2]))))){break h}}d=e}e=e+1|0;if((e|0)!=(b|0)){continue}break}if((j|0)==(o|0)){break g}o=d;break f}d=j&o;o=-1;if((d|0)==-1){break c}break f}o=d;if((d|0)==(j|0)){break c}}g=S(g+S(5));if(i>=g){continue}break}}e=A+45|0;if(A>>>0<316){continue}break}L[z>>2]=0;continue}break}L[z>>2]=3}return j}function Zj(a,b,c,d,e,f,g){var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0;k=fa-48|0;fa=k;h=L[c+8>>2];if(h){p=h;while(1){if(L[p+20>>2]>L[a+100>>2]){j=L[p+12>>2];i=L[j+92>>2];l=L[j+96>>2];h=L[c+88>>2];m=L[j+88>>2];o=L[c+92>>2];j=L[c+96>>2];L[k+44>>2]=-1;j=l-j|0;L[k+40>>2]=j;i=i-o|0;L[k+36>>2]=i;l=m-h|0;L[k+32>>2]=l;m=i;q=i>>31;i=mI(i,q,L[e+8>>2],L[e+12>>2]);h=ga;o=l;r=l>>31;l=mI(l,r,L[e>>2],L[e+4>>2]);i=l+i|0;h=ga+h|0;h=i>>>0>>0?h+1|0:h;s=j>>31;t=mI(j,s,L[e+16>>2],L[e+20>>2]);l=t+i|0;i=ga+h|0;i=l>>>0>>0?i+1|0:i;h=mI(L[f+8>>2],L[f+12>>2],m,q);q=ga;o=mI(L[f>>2],L[f+4>>2],o,r);m=o+h|0;h=ga+q|0;h=m>>>0>>0?h+1|0:h;u=m;m=mI(L[f+16>>2],L[f+20>>2],j,s);j=u+m|0;h=ga+h|0;h=j>>>0>>0?h+1|0:h;m=h;a:{if(!!j&(h|0)>=0|(h|0)>0){L[k+24>>2]=1;o=0;h=-1;break a}if((m|0)<0){L[k+24>>2]=-1;h=j;j=0-j|0;m=0-(((h|0)!=0)+m|0)|0;o=0;h=1;break a}L[k+24>>2]=0;j=0;m=0;o=1;h=0}L[k+8>>2]=j;L[k+12>>2]=m;b:{c:{d:{m=k;if(!l&(i|0)<=0|(i|0)<0){if((i|0)>0|(i|0)>=0){break d}L[k+24>>2]=h;i=0-(((l|0)!=0)+i|0)|0;l=0-l|0}L[m+16>>2]=l;L[k+20>>2]=i;break c}L[k+16>>2]=0;L[k+20>>2]=0;if(o){break b}}if(!n){n=L[k+12>>2];L[g>>2]=L[k+8>>2];L[g+4>>2]=n;L[g+16>>2]=L[k+24>>2];n=L[k+20>>2];L[g+8>>2]=L[k+16>>2];L[g+12>>2]=n;n=p;break b}j=yc(k+8|0,g);if((j|0)<0){n=L[k+12>>2];L[g>>2]=L[k+8>>2];L[g+4>>2]=n;L[g+16>>2]=L[k+24>>2];n=L[k+20>>2];L[g+8>>2]=L[k+16>>2];L[g+12>>2]=n;n=p;break b}if(j){break b}x=n;i=L[n+4>>2];e:{f:{if(L[n>>2]==(p|0)){h=2;if((i|0)!=(p|0)){break f}j=L[p+12>>2];i=L[L[p+8>>2]+12>>2];h=L[i+96>>2];m=L[j+96>>2]-h|0;l=L[n+12>>2];o=L[i+92>>2];q=L[l+92>>2]-o|0;o=L[j+92>>2]-o|0;h=L[l+96>>2]-h|0;r=R(m,q)-R(o,h)|0;n=r;u=r>>31;r=L[d+8>>2];s=L[k+36>>2];t=L[d+4>>2];w=L[k+40>>2];v=R(r,s)-R(t,w)|0;v=mI(n,u,v,v>>31);n=ga;i=L[i+88>>2];l=L[l+88>>2]-i|0;u=R(l,o);o=L[j+88>>2]-i|0;j=u-R(o,q)|0;u=j;y=j>>31;q=L[k+32>>2];i=s;s=L[d>>2];j=R(q,t)-R(i,s)|0;t=mI(u,y,j,j>>31);i=t+v|0;j=ga+n|0;j=i>>>0>>0?j+1|0:j;n=i;i=R(h,o)-R(l,m)|0;h=i;m=i>>31;i=R(s,w)-R(q,r)|0;l=mI(h,m,i,i>>31);i=n+l|0;j=ga+j|0;j=i>>>0>>0?j+1|0:j;h=!!i&(j|0)>=0|(j|0)>0?2:1;break e}h=(i|0)==(p|0)}}n=(h|0)!=2^b?p:x}h=L[c+8>>2]}p=L[p>>2];if((p|0)!=(h|0)){continue}break}}fa=k+48|0;return n}function hl(a,b,c,d,e,f,g,h){var i=S(0),j=S(0),k=S(0),l=S(0),m=S(0),n=S(0),o=S(0),p=S(0),q=S(0),r=S(0),s=S(0),t=S(0),u=S(0);a=ub(a,4,b,c);L[a+688>>2]=0;L[a+692>>2]=-1082130432;L[a>>2]=19768;L[a+748>>2]=0;J[a+740|0]=h;L[a+736>>2]=16777216;L[a+708>>2]=0;L[a+712>>2]=0;L[a+704>>2]=1065353216;L[a+696>>2]=1063675494;L[a+700>>2]=1050253722;J[a+716|0]=0;c=L[d+12>>2];L[a+608>>2]=L[d+8>>2];L[a+612>>2]=c;c=L[d+4>>2];L[a+600>>2]=L[d>>2];L[a+604>>2]=c;i=P[f+8>>2];j=P[b+36>>2];m=P[f>>2];n=P[b+4>>2];q=P[b+20>>2];o=P[f+4>>2];k=S(S(i*j)+S(S(m*n)+S(q*o)));a:{if(k>=S(.9999998807907104)){j=P[b+40>>2];k=P[b+24>>2];l=P[b+8>>2];p=S(-P[b+44>>2]);n=S(-P[b+28>>2]);m=S(-P[b+12>>2]);break a}if(k<=S(-.9999998807907104)){j=P[b+40>>2];k=P[b+24>>2];l=P[b+8>>2];p=P[b+44>>2];n=P[b+28>>2];m=P[b+12>>2];break a}l=S(S(o*j)-S(q*i));k=S(S(i*n)-S(j*m));p=S(S(l*o)-S(m*k));j=S(S(m*q)-S(n*o));n=S(S(j*m)-S(i*l));m=S(S(k*i)-S(o*j))}P[a+552>>2]=m;P[a+556>>2]=l;i=P[f>>2];P[a+572>>2]=k;P[a+568>>2]=n;L[a+564>>2]=0;P[a+560>>2]=i;i=P[f+4>>2];P[a+588>>2]=j;P[a+584>>2]=p;L[a+580>>2]=0;P[a+576>>2]=i;i=P[f+8>>2];L[a+596>>2]=0;P[a+592>>2]=i;l=P[f+8>>2];o=P[g+8>>2];k=P[f>>2];q=P[g>>2];i=P[f+4>>2];t=P[g+4>>2];j=S(S(l*o)+S(S(k*q)+S(i*t)));b:{if(jS(.7071067690849304)){j=i;i=S(S(1)/S(_(S(S(i*i)+S(l*l)))));j=S(j*i);k=S(i*S(-l));l=S(0);i=S(0);break b}j=S(S(1)/S(_(S(S(k*k)+S(i*i)))));k=S(k*j);l=S(j*S(-i));j=S(0);i=S(0);break b}j=S(j+S(1));s=S(_(S(j+j)));r=S(S(1)/s);j=S(S(S(k*t)-S(q*i))*r);k=S(S(S(l*q)-S(o*k))*r);l=S(S(S(i*o)-S(t*l))*r);i=S(s*S(.5))}b=L[e+4>>2];L[a+664>>2]=L[e>>2];L[a+668>>2]=b;b=L[e+12>>2];L[a+672>>2]=L[e+8>>2];L[a+676>>2]=b;r=S(S(S(i*p)+S(n*l))-S(k*m));s=S(S(S(i*m)+S(p*k))-S(j*n));u=S(S(S(S(-l)*m)-S(n*k))-S(j*p));m=S(S(S(i*n)+S(m*j))-S(l*p));p=S(S(r*k)+S(S(S(i*s)-S(u*l))-S(m*j)));P[a+616>>2]=p;n=S(S(m*l)+S(S(S(i*r)-S(u*j))-S(s*k)));i=S(S(s*j)+S(S(S(i*m)-S(u*k))-S(r*l)));P[a+620>>2]=S(t*n)-S(i*o);m=P[g>>2];P[a+636>>2]=S(o*p)-S(n*q);P[a+632>>2]=i;L[a+628>>2]=0;P[a+624>>2]=m;m=P[g+4>>2];P[a+652>>2]=S(q*i)-S(p*t);P[a+648>>2]=n;L[a+644>>2]=0;P[a+640>>2]=m;i=P[g+8>>2];P[a+732>>2]=h?S(-1):S(1);L[a+660>>2]=0;P[a+656>>2]=i}function aA(a,b){a=a|0;b=S(b);var c=0,d=S(0),e=0,f=S(0),g=S(0),h=0,i=0,j=S(0),k=S(0),l=S(0),m=S(0),n=0,o=S(0),p=S(0),q=0,r=S(0),s=S(0),t=0,u=S(0);h=fa-32|0;fa=h;e=L[a+136>>2];if((e|0)>0){while(1){mg(a,c,0);c=c+1|0;e=L[a+136>>2];if((c|0)<(e|0)){continue}break}}c=L[a+116>>2];d=P[c+320>>2];f=S(d*d);d=P[c+312>>2];g=S(d*d);d=P[c+316>>2];d=S(S(_(S(f+S(g+S(d*d)))))*S(3.5999999046325684));P[a+112>>2]=d;i=c+(L[a+128>>2]<<2)|0;if(S(S(P[i+36>>2]*P[c+320>>2])+S(S(P[i+4>>2]*P[c+312>>2])+S(P[i+20>>2]*P[c+316>>2])))>2]=-d}a:{if((e|0)<=0){break a}c=0;while(1){Ck(a,L[a+144>>2]+R(c,284)|0);c=c+1|0;e=L[a+136>>2];if((c|0)<(e|0)){continue}break}if((e|0)<=0){break a}g=S(S(1)/P[L[a+116>>2]+344>>2]);e=0;while(1){d=S(0);c=L[a+144>>2]+R(e,284)|0;if(M[c+84|0]){d=P[c+272>>2];d=S(g*S(S(S(P[c+216>>2]*S(P[c+204>>2]-P[c+32>>2]))*P[c+268>>2])-S(P[c+(d>2]*d)));d=d>2]=d;e=e+1|0;c=L[a+136>>2];if((e|0)<(c|0)){continue}break}if((c|0)<=0){break a}c=0;while(1){e=L[a+144>>2]+R(c,284)|0;d=P[e+248>>2];g=P[e+276>>2];j=P[e>>2];f=P[e+4>>2];k=P[e+8>>2];L[h+28>>2]=0;d=d>2]=S(k*d)*b;P[h+20>>2]=S(d*f)*b;P[h+16>>2]=S(j*d)*b;d=P[e+16>>2];i=L[a+116>>2];g=P[i+52>>2];j=P[e+20>>2];f=P[i+56>>2];k=P[e+24>>2];l=P[i+60>>2];L[h+12>>2]=0;P[h+8>>2]=k-l;P[h+4>>2]=j-f;P[h>>2]=d-g;rb(i,h+16|0,h);c=c+1|0;if((c|0)>2]){continue}break}}ha[L[L[a>>2]+20>>2]](a,b);n=L[a+136>>2];if((n|0)>0){c=L[a+116>>2];i=c+(L[a+128>>2]<<2)|0;t=L[a+144>>2];e=0;while(1){a=R(e,284)+t|0;b:{if(M[a+84|0]){d=P[a+236>>2];j=P[i+36>>2];f=P[a+8>>2];k=P[i+4>>2];l=P[a>>2];o=P[i+20>>2];p=P[a+4>>2];g=S(S(j*f)+S(S(k*l)+S(o*p)));q=a+236|0;m=S(j-S(f*g));j=P[c+328>>2];f=S(P[a+40>>2]-P[c+56>>2]);r=S(P[a+36>>2]-P[c+52>>2]);s=P[c+332>>2];m=S(m*S(P[c+320>>2]+S(S(j*f)-S(r*s))));u=S(k-S(l*g));k=S(P[a+44>>2]-P[c+60>>2]);l=f;f=P[c+336>>2];g=S(S(S(m+S(S(u*S(S(S(s*k)-S(l*f))+P[c+312>>2]))+S(S(P[c+316>>2]+S(S(f*r)-S(k*j)))*S(o-S(p*g)))))*b)/P[a+212>>2]);f=g;break b}g=P[a+236>>2];q=a+236|0;d=P[a+240>>2];f=d}j=f;P[q>>2]=d+g;P[a+240>>2]=j*S(.9900000095367432);e=e+1|0;if((n|0)!=(e|0)){continue}break}}fa=h+32|0}function Up(a,b,c){a=a|0;b=S(b);c=c|0;var d=0,e=0,f=0,g=S(0),h=0,i=0,j=0,k=S(0),l=S(0),m=0,n=S(0),o=S(0),p=S(0),q=S(0);i=fa-16|0;fa=i;L[i+12>>2]=a;P[i+8>>2]=b;J[i+7|0]=c;o=P[i+8>>2];j=L[i+12>>2];c=L[j+712>>2];a:{b:{if(!(J[i+7|0]&1)){break b}c:{if((c|0)<=0){break c}d=L[j+720>>2];a=0;if(c>>>0>=8){f=c&-8;while(1){L[(d+R(a,104)|0)+88>>2]=0;L[(d+R(a|1,104)|0)+88>>2]=0;L[(d+R(a|2,104)|0)+88>>2]=0;L[(d+R(a|3,104)|0)+88>>2]=0;L[(d+R(a|4,104)|0)+88>>2]=0;L[(d+R(a|5,104)|0)+88>>2]=0;L[(d+R(a|6,104)|0)+88>>2]=0;L[(d+R(a|7,104)|0)+88>>2]=0;a=a+8|0;h=h+8|0;if((f|0)!=(h|0)){continue}break}}h=c&7;if(!h){break c}while(1){L[(d+R(a,104)|0)+88>>2]=0;a=a+1|0;e=e+1|0;if((h|0)!=(e|0)){continue}break}}f=L[j+752>>2];if((f|0)>0){m=L[j+760>>2];h=0;while(1){d=m+R(h,44)|0;a=L[d+8>>2];e=L[d+12>>2];b=P[a+8>>2];n=S(P[e+8>>2]-b);d=L[d+16>>2];g=P[a+12>>2];k=S(P[d+12>>2]-g);b=S(P[d+8>>2]-b);g=S(P[e+12>>2]-g);l=S(S(n*k)-S(b*g));p=S(l*l);q=g;g=P[a+16>>2];l=S(P[d+16>>2]-g);g=S(P[e+16>>2]-g);k=S(S(q*l)-S(k*g));b=S(S(g*b)-S(l*n));b=S(_(S(p+S(S(k*k)+S(b*b)))));P[a+88>>2]=b+P[a+88>>2];P[e+88>>2]=b+P[e+88>>2];P[d+88>>2]=b+P[d+88>>2];h=h+1|0;if((f|0)!=(h|0)){continue}break}}if((c|0)<=0){break a}d=L[j+720>>2];a=0;if((c|0)!=1){h=c&-2;e=0;while(1){f=d+R(a,104)|0;P[f+88>>2]=S(1)/P[f+88>>2];f=d+R(a|1,104)|0;P[f+88>>2]=S(1)/P[f+88>>2];a=a+2|0;e=e+2|0;if((h|0)!=(e|0)){continue}break}}if(!(c&1)){break b}a=d+R(a,104)|0;P[a+88>>2]=S(1)/P[a+88>>2]}if((c|0)<=0){break a}h=c&1;d=L[j+720>>2];f=c-1|0;d:{if(!f){b=S(0);a=0;break d}m=c&-2;a=0;b=S(0);e=0;while(1){g=b;b=P[(d+R(a,104)|0)+88>>2];g=S(g+(b>S(0)?S(S(1)/b):S(0)));b=P[(d+R(a|1,104)|0)+88>>2];b=S(g+(b>S(0)?S(S(1)/b):S(0)));a=a+2|0;e=e+2|0;if((m|0)!=(e|0)){continue}break}}if(h){g=b;b=P[(d+R(a,104)|0)+88>>2];b=S(g+(b>S(0)?S(S(1)/b):S(0)))}if((c|0)<=0){break a}h=c&1;b=S(S(S(1)/b)*o);d=L[j+720>>2];e:{if(!f){a=0;break e}c=c&-2;a=0;e=0;while(1){f=d+R(a,104)|0;P[f+88>>2]=P[f+88>>2]/b;f=d+R(a|1,104)|0;P[f+88>>2]=P[f+88>>2]/b;a=a+2|0;e=e+2|0;if((c|0)!=(e|0)){continue}break}}if(!h){break a}a=d+R(a,104)|0;P[a+88>>2]=P[a+88>>2]/b}J[j+924|0]=1;fa=i+16|0}function yk(a){var b=0,c=0,d=0,e=0,f=0,g=0,h=0;d=fa+-64|0;h=243703;g=L[a+732>>2];if((g|0)>0){while(1){c=L[a+740>>2];b=c+R(f,52)|0;L[d+56>>2]=L[b+48>>2];e=L[b+44>>2];L[d+48>>2]=L[b+40>>2];L[d+52>>2]=e;e=L[b+36>>2];L[d+40>>2]=L[b+32>>2];L[d+44>>2]=e;e=L[b+28>>2];L[d+32>>2]=L[b+24>>2];L[d+36>>2]=e;e=L[b+20>>2];L[d+24>>2]=L[b+16>>2];L[d+28>>2]=e;e=L[b+12>>2];L[d+16>>2]=L[b+8>>2];L[d+20>>2]=e;e=L[b+4>>2];L[d+8>>2]=L[b>>2];L[d+12>>2]=e;h=R(h,1664525)+1013904223|0;c=c+R((h>>>0)%(g>>>0)|0,52)|0;e=L[c+4>>2];L[b>>2]=L[c>>2];L[b+4>>2]=e;L[b+48>>2]=L[c+48>>2];e=L[c+44>>2];L[b+40>>2]=L[c+40>>2];L[b+44>>2]=e;e=L[c+36>>2];L[b+32>>2]=L[c+32>>2];L[b+36>>2]=e;e=L[c+28>>2];L[b+24>>2]=L[c+24>>2];L[b+28>>2]=e;e=L[c+20>>2];L[b+16>>2]=L[c+16>>2];L[b+20>>2]=e;e=L[c+12>>2];L[b+8>>2]=L[c+8>>2];L[b+12>>2]=e;L[c+48>>2]=L[d+56>>2];b=L[d+52>>2];L[c+40>>2]=L[d+48>>2];L[c+44>>2]=b;b=L[d+44>>2];L[c+32>>2]=L[d+40>>2];L[c+36>>2]=b;b=L[d+36>>2];L[c+24>>2]=L[d+32>>2];L[c+28>>2]=b;b=L[d+28>>2];L[c+16>>2]=L[d+24>>2];L[c+20>>2]=b;b=L[d+20>>2];L[c+8>>2]=L[d+16>>2];L[c+12>>2]=b;b=L[d+12>>2];L[c>>2]=L[d+8>>2];L[c+4>>2]=b;f=f+1|0;if((g|0)!=(f|0)){continue}break}}g=L[a+752>>2];if((g|0)>0){f=0;while(1){c=L[a+760>>2];b=c+R(f,44)|0;L[d+48>>2]=L[b+40>>2];e=L[b+36>>2];L[d+40>>2]=L[b+32>>2];L[d+44>>2]=e;e=L[b+28>>2];L[d+32>>2]=L[b+24>>2];L[d+36>>2]=e;e=L[b+20>>2];L[d+24>>2]=L[b+16>>2];L[d+28>>2]=e;e=L[b+12>>2];L[d+16>>2]=L[b+8>>2];L[d+20>>2]=e;e=L[b+4>>2];L[d+8>>2]=L[b>>2];L[d+12>>2]=e;h=R(h,1664525)+1013904223|0;c=c+R((h>>>0)%(g>>>0)|0,44)|0;e=L[c+4>>2];L[b>>2]=L[c>>2];L[b+4>>2]=e;L[b+40>>2]=L[c+40>>2];e=L[c+36>>2];L[b+32>>2]=L[c+32>>2];L[b+36>>2]=e;e=L[c+28>>2];L[b+24>>2]=L[c+24>>2];L[b+28>>2]=e;e=L[c+20>>2];L[b+16>>2]=L[c+16>>2];L[b+20>>2]=e;e=L[c+12>>2];L[b+8>>2]=L[c+8>>2];L[b+12>>2]=e;L[c+40>>2]=L[d+48>>2];b=L[d+44>>2];L[c+32>>2]=L[d+40>>2];L[c+36>>2]=b;b=L[d+36>>2];L[c+24>>2]=L[d+32>>2];L[c+28>>2]=b;b=L[d+28>>2];L[c+16>>2]=L[d+24>>2];L[c+20>>2]=b;b=L[d+20>>2];L[c+8>>2]=L[d+16>>2];L[c+12>>2]=b;b=L[d+12>>2];L[c>>2]=L[d+8>>2];L[c+4>>2]=b;f=f+1|0;if((g|0)!=(f|0)){continue}break}}}function Gk(a,b){var c=0,d=S(0),e=S(0),f=S(0),g=S(0),h=S(0),i=S(0),j=S(0),k=S(0),l=S(0),m=S(0),n=S(0),o=S(0),p=0,q=0,r=S(0),s=S(0),t=S(0);a:{if(M[a+204|0]&2){c=L[a+8>>2];L[a+68>>2]=L[a+4>>2];L[a+72>>2]=c;c=L[a+16>>2];L[a+76>>2]=L[a+12>>2];L[a+80>>2]=c;c=L[a+24>>2];L[a+84>>2]=L[a+20>>2];L[a+88>>2]=c;c=L[a+32>>2];L[a+92>>2]=L[a+28>>2];L[a+96>>2]=c;c=L[a+40>>2];L[a+100>>2]=L[a+36>>2];L[a+104>>2]=c;c=L[a+48>>2];L[a+108>>2]=L[a+44>>2];L[a+112>>2]=c;c=a+52|0;break a}c=L[b+4>>2];L[a+68>>2]=L[b>>2];L[a+72>>2]=c;c=L[b+12>>2];L[a+76>>2]=L[b+8>>2];L[a+80>>2]=c;c=L[b+20>>2];L[a+84>>2]=L[b+16>>2];L[a+88>>2]=c;c=L[b+28>>2];L[a+92>>2]=L[b+24>>2];L[a+96>>2]=c;c=L[b+36>>2];L[a+100>>2]=L[b+32>>2];L[a+104>>2]=c;c=L[b+44>>2];L[a+108>>2]=L[b+40>>2];L[a+112>>2]=c;c=b+48|0}p=L[c+4>>2];L[a+116>>2]=L[c>>2];L[a+120>>2]=p;p=L[c+8>>2];c=L[c+12>>2];q=L[a+340>>2];L[a+156>>2]=L[a+336>>2];L[a+160>>2]=q;q=L[a+332>>2];L[a+148>>2]=L[a+328>>2];L[a+152>>2]=q;L[a+124>>2]=p;L[a+128>>2]=c;c=L[a+316>>2];L[a+132>>2]=L[a+312>>2];L[a+136>>2]=c;c=L[a+324>>2];L[a+140>>2]=L[a+320>>2];L[a+144>>2]=c;c=L[b+12>>2];L[a+12>>2]=L[b+8>>2];L[a+16>>2]=c;c=L[b+4>>2];L[a+4>>2]=L[b>>2];L[a+8>>2]=c;c=L[b+28>>2];L[a+28>>2]=L[b+24>>2];L[a+32>>2]=c;c=L[b+20>>2];L[a+20>>2]=L[b+16>>2];L[a+24>>2]=c;c=L[b+44>>2];L[a+44>>2]=L[b+40>>2];L[a+48>>2]=c;c=L[b+36>>2];L[a+36>>2]=L[b+32>>2];L[a+40>>2]=c;c=L[b+60>>2];L[a+60>>2]=L[b+56>>2];L[a+64>>2]=c;c=L[b+52>>2];L[a+52>>2]=L[b+48>>2];L[a+56>>2]=c;j=P[a+8>>2];k=P[a+12>>2];l=P[a+28>>2];m=P[a+20>>2];n=P[a+24>>2];g=P[a+44>>2];r=P[a+404>>2];h=P[a+36>>2];i=P[a+40>>2];s=P[a+400>>2];o=P[a+4>>2];t=P[a+396>>2];L[a+308>>2]=0;L[a+292>>2]=0;L[a+276>>2]=0;d=S(r*g);e=S(t*h);f=S(s*i);P[a+304>>2]=S(g*d)+S(S(h*e)+S(i*f));P[a+300>>2]=S(l*d)+S(S(m*e)+S(n*f));P[a+296>>2]=S(k*d)+S(S(o*e)+S(j*f));d=S(r*l);e=S(t*m);f=S(s*n);P[a+288>>2]=S(g*d)+S(S(h*e)+S(i*f));P[a+284>>2]=S(l*d)+S(S(m*e)+S(n*f));P[a+280>>2]=S(k*d)+S(S(o*e)+S(j*f));d=g;g=S(k*r);e=h;h=S(o*t);f=i;i=S(j*s);P[a+272>>2]=S(d*g)+S(S(e*h)+S(f*i));P[a+268>>2]=S(l*g)+S(S(m*h)+S(i*n));P[a+264>>2]=S(k*g)+S(S(o*h)+S(j*i))}function mg(a,b,c){var d=S(0),e=S(0),f=S(0),g=S(0),h=S(0),i=S(0),j=S(0),k=S(0),l=S(0),m=S(0),n=S(0),o=S(0),p=S(0),q=S(0),r=S(0),s=S(0),t=S(0),u=S(0),v=S(0),w=S(0),x=S(0),y=S(0),z=S(0),A=S(0),B=S(0),C=S(0),D=S(0),E=S(0),F=S(0),G=S(0),H=S(0),I=S(0),J=S(0),K=S(0),M=S(0),N=S(0),O=S(0),Q=S(0),T=0;T=a;a=L[a+144>>2]+R(b,284)|0;lg(T,a,c);L[a+136>>2]=0;L[a+120>>2]=0;L[a+104>>2]=0;r=P[a+56>>2];y=P[a+52>>2];j=P[a+60>>2];n=S(P[a+232>>2]*S(.5));d=Ea(n);e=Fa(n);n=P[a+72>>2];t=P[a+76>>2];u=P[a+68>>2];i=S(P[a+236>>2]*S(-.5));g=S(Ea(i)/S(_(S(S(t*t)+S(S(u*u)+S(n*n))))));f=S(u*g);i=Fa(i);h=S(t*g);s=S(n*g);p=S(S(2)/S(S(i*i)+S(S(h*h)+S(S(f*f)+S(s*s)))));l=S(h*p);m=S(f*l);v=S(s*p);q=S(i*v);D=S(m-q);C=S(-y);d=S(d/S(_(S(S(j*j)+S(S(y*y)+S(r*r))))));g=S(C*d);w=S(d*S(-j));d=S(d*S(-r));o=S(S(2)/S(S(e*e)+S(S(w*w)+S(S(g*g)+S(d*d)))));k=S(g*o);F=S(g*k);z=S(d*o);G=S(d*z);x=S(S(1)-S(F+G));A=S(s*v);B=S(h*l);E=S(S(1)-S(A+B));h=S(w*o);H=S(g*h);I=S(e*z);o=S(H-I);J=S(d*h);K=S(e*k);k=S(J+K);M=S(f*v);N=S(i*l);v=S(M+N);d=S(S(D*x)+S(S(E*o)+S(k*v)));O=S(s*l);p=S(f*p);Q=S(i*p);i=S(O+Q);s=S(M-N);f=S(f*p);p=S(S(1)-S(f+B));l=S(S(i*x)+S(S(s*o)+S(k*p)));A=S(S(1)-S(f+A));f=S(A*x);x=S(m+q);m=S(x*o);o=S(O-Q);k=S(f+S(m+S(k*o)));P[a+132>>2]=S(S(C*d)-S(r*l))-S(j*k);m=S(S(r*u)-S(y*n));q=S(S(j*n)-S(r*t));B=S(S(y*t)-S(j*u));f=S(S(1)/S(_(S(S(m*m)+S(S(q*q)+S(B*B))))));m=S(m*f);q=S(q*f);f=S(B*f);P[a+128>>2]=S(m*k)+S(S(q*d)+S(f*l));P[a+124>>2]=S(t*k)+S(S(u*d)+S(n*l));d=S(J-K);z=S(g*z);k=S(e*h);e=S(z+k);w=S(w*h);g=S(S(1)-S(F+w));h=S(S(D*d)+S(S(E*e)+S(v*g)));l=S(S(i*d)+S(S(s*e)+S(g*p)));e=S(S(A*d)+S(S(x*e)+S(o*g)));P[a+116>>2]=S(S(C*h)-S(r*l))-S(j*e);P[a+112>>2]=S(m*e)+S(S(q*h)+S(f*l));P[a+108>>2]=S(t*e)+S(S(u*h)+S(n*l));e=S(H+I);g=S(S(1)-S(G+w));d=S(z-k);h=S(S(D*e)+S(S(E*g)+S(d*v)));i=S(S(i*e)+S(S(s*g)+S(d*p)));e=S(S(A*e)+S(S(x*g)+S(d*o)));P[a+100>>2]=S(S(C*h)-S(r*i))-S(j*e);P[a+96>>2]=S(m*e)+S(S(q*h)+S(f*i));P[a+92>>2]=S(t*e)+S(S(u*h)+S(n*i));L[a+152>>2]=0;d=j;j=P[a+32>>2];P[a+148>>2]=S(d*j)+P[a+44>>2];P[a+144>>2]=S(r*j)+P[a+40>>2];P[a+140>>2]=P[a+36>>2]+S(y*j)}function _a(a,b,c){var d=0,e=0,f=S(0),g=S(0),h=S(0),i=S(0),j=0,k=S(0),l=S(0),m=0,n=S(0),o=S(0),p=S(0),q=S(0),r=S(0),s=S(0),t=S(0),u=S(0),v=S(0),w=S(0),x=S(0),y=S(0);a:{d=L[a+748>>2];if((d|0)<=0){break a}while(1){n=P[b+48>>2];q=P[b+8>>2];r=P[b>>2];s=P[b+4>>2];o=P[b+52>>2];t=P[b+24>>2];i=P[b+16>>2];u=P[b+20>>2];f=P[b+56>>2];h=P[b+40>>2];g=P[b+32>>2];p=P[b+36>>2];j=d-1|0;e=R(j,184)+a|0;L[e- -64>>2]=0;l=f;f=P[e+12>>2];k=S(h*f);h=P[e+4>>2];v=S(g*h);g=P[e+8>>2];p=S(l+S(k+S(v+S(p*g))));P[e+60>>2]=p;o=S(o+S(S(f*t)+S(S(h*i)+S(g*u))));P[e+56>>2]=o;n=S(n+S(S(f*q)+S(S(h*r)+S(g*s))));P[e+52>>2]=n;q=P[c+56>>2];r=P[c+40>>2];s=P[c+32>>2];t=P[c+36>>2];i=P[c+52>>2];u=P[c+24>>2];v=P[c+16>>2];w=P[c+20>>2];f=P[c+48>>2];h=P[c+8>>2];g=P[c>>2];k=P[c+4>>2];L[e+48>>2]=0;l=f;f=P[e+28>>2];x=S(h*f);h=P[e+20>>2];y=S(g*h);g=P[e+24>>2];k=S(l+S(x+S(y+S(k*g))));P[e+36>>2]=k;i=S(i+S(S(f*u)+S(S(h*v)+S(g*w))));P[e+40>>2]=i;f=S(q+S(S(f*r)+S(S(h*s)+S(g*t))));P[e+44>>2]=f;P[e+84>>2]=S(S(p-f)*P[e+76>>2])+S(S(S(n-k)*P[e+68>>2])+S(S(o-i)*P[e+72>>2]));L[e+152>>2]=L[e+152>>2]+1;e=d>>>0>1;d=j;if(e){continue}break}b=L[a+748>>2];if((b|0)<=0){break a}while(1){c=b;b=c-1|0;d=R(b,184)+a|0;j=d+4|0;f=P[d+84>>2];h=P[a+752>>2];b:{if(!(f<=h)){e=L[d+116>>2];c:{if(!e){break c}m=L[8113];if(!m){break c}ha[m|0](e)|0;L[d+116>>2]=0}e=L[a+748>>2];d=e-1|0;if((c|0)!=(e|0)){d=R(d,184)+a|0;qa(j,d+4|0,184);L[d+124>>2]=0;L[d+116>>2]=0;L[d+152>>2]=0;L[d+128>>2]=0;L[d+132>>2]=0;J[d+120|0]=0;d=L[a+748>>2]-1|0}L[a+748>>2]=d;break b}g=S(P[d+44>>2]-S(P[d+60>>2]-S(f*P[d+76>>2])));l=S(g*g);g=S(P[d+36>>2]-S(P[d+52>>2]-S(P[d+68>>2]*f)));f=S(P[d+40>>2]-S(P[d+56>>2]-S(f*P[d+72>>2])));if(S(l+S(S(g*g)+S(f*f)))>S(h*h)){e=L[d+116>>2];d:{if(!e){break d}m=L[8113];if(!m){break d}ha[m|0](e)|0;L[d+116>>2]=0}e=L[a+748>>2];d=e-1|0;if((c|0)!=(e|0)){d=R(d,184)+a|0;qa(j,d+4|0,184);L[d+124>>2]=0;L[d+116>>2]=0;L[d+152>>2]=0;L[d+128>>2]=0;L[d+132>>2]=0;J[d+120|0]=0;d=L[a+748>>2]-1|0}L[a+748>>2]=d;break b}d=L[8114];if(!d){break b}ha[d|0](j,L[a+740>>2],L[a+744>>2])|0}if(c>>>0>1){continue}break}}}function xB(a,b,c){a=a|0;b=b|0;c=c|0;var d=S(0),e=S(0),f=S(0),g=S(0),h=0,i=S(0),j=S(0),k=S(0),l=S(0),m=S(0),n=S(0),o=S(0),p=S(0),q=S(0),r=S(0),s=S(0),t=S(0),u=S(0),v=S(0),w=S(0),x=S(0),y=S(0);h=L[a+28>>2];p=P[h+20>>2];q=P[h+36>>2];r=P[h+40>>2];s=P[h+8>>2];t=P[h+24>>2];d=P[h+60>>2];i=P[h+44>>2];j=P[h+12>>2];f=P[h+52>>2];k=P[h+56>>2];l=P[h+28>>2];m=P[c+8>>2];n=P[c>>2];o=P[c+4>>2];e=P[b+8>>2];g=P[b>>2];u=P[b+4>>2];v=P[h+4>>2];L[a+108>>2]=0;L[a+92>>2]=0;L[a+76>>2]=0;L[a+60>>2]=0;f=S(-f);P[a+104>>2]=S(S(i*S(0))+S(S(j*S(0))+S(l*S(0))))+S(S(S(j*f)-S(l*k))-S(i*d));P[a+100>>2]=S(S(r*S(0))+S(S(s*S(0))+S(t*S(0))))+S(S(S(s*f)-S(t*k))-S(r*d));P[a+96>>2]=S(S(q*S(0))+S(S(v*S(0))+S(p*S(0))))+S(S(S(v*f)-S(p*k))-S(q*d));f=e;e=S(S(1)/S(_(S(S(e*e)+S(S(g*g)+S(u*u))))));d=S(f*e);k=S(g*e);e=S(u*e);P[a+88>>2]=S(i*d)+S(S(j*k)+S(l*e));g=S(S(1)/S(_(S(S(m*m)+S(S(n*n)+S(o*o))))));m=S(m*g);n=S(n*g);o=S(o*g);P[a+84>>2]=S(i*m)+S(S(j*n)+S(l*o));P[a+72>>2]=S(d*r)+S(S(k*s)+S(e*t));P[a+68>>2]=S(m*r)+S(S(n*s)+S(o*t));P[a+56>>2]=S(d*q)+S(S(k*v)+S(e*p));P[a+52>>2]=S(m*q)+S(S(n*v)+S(p*o));f=i;i=S(S(n*e)-S(k*o));g=j;j=S(S(o*d)-S(e*m));u=l;l=S(S(m*k)-S(d*n));P[a+80>>2]=S(f*i)+S(S(g*j)+S(u*l));P[a- -64>>2]=S(i*r)+S(S(j*s)+S(t*l));P[a+48>>2]=S(i*q)+S(S(j*v)+S(p*l));b=L[a+32>>2];w=P[b+60>>2];y=P[b+52>>2];x=P[b+56>>2];p=P[b+20>>2];q=P[b+36>>2];r=P[b+40>>2];s=P[b+8>>2];t=P[b+24>>2];v=P[b+44>>2];g=P[b+12>>2];u=P[b+28>>2];f=P[b+4>>2];L[a+172>>2]=0;L[a+156>>2]=0;L[a+140>>2]=0;L[a+124>>2]=0;P[a+152>>2]=S(d*v)+S(S(k*g)+S(e*u));P[a+148>>2]=S(m*v)+S(S(n*g)+S(o*u));P[a+144>>2]=S(i*v)+S(S(j*g)+S(l*u));P[a+136>>2]=S(d*r)+S(S(k*s)+S(e*t));P[a+132>>2]=S(m*r)+S(S(n*s)+S(o*t));P[a+128>>2]=S(i*r)+S(S(j*s)+S(l*t));P[a+120>>2]=S(d*q)+S(S(k*f)+S(e*p));P[a+116>>2]=S(m*q)+S(S(n*f)+S(o*p));P[a+112>>2]=S(i*q)+S(S(j*f)+S(l*p));d=S(-y);P[a+168>>2]=S(S(v*S(0))+S(S(g*S(0))+S(u*S(0))))+S(S(S(g*d)-S(u*x))-S(v*w));P[a+164>>2]=S(S(r*S(0))+S(S(s*S(0))+S(t*S(0))))+S(S(S(s*d)-S(t*x))-S(r*w));P[a+160>>2]=S(S(q*S(0))+S(S(f*S(0))+S(p*S(0))))+S(S(S(f*d)-S(p*x))-S(q*w));vg(a)}function sd(a,b,c,d,e){var f=S(0),g=S(0),h=S(0),i=S(0),j=S(0),k=0,l=S(0),m=S(0),n=S(0),o=S(0),p=S(0),q=S(0),r=S(0),s=S(0),t=S(0),u=S(0),v=S(0),w=S(0),x=S(0),y=S(0),z=S(0),A=S(0),B=S(0),C=S(0),D=S(0);k=M[e+16|0]&-16;J[e+16|0]=k;B=P[d+8>>2];m=P[b+8>>2];r=S(B-m);l=P[a+8>>2];f=S(l-m);C=P[d>>2];n=P[b>>2];s=S(C-n);i=P[a>>2];g=S(i-n);D=P[d+4>>2];o=P[b+4>>2];t=S(D-o);p=P[a+4>>2];h=S(p-o);j=S(S(r*f)+S(S(s*g)+S(t*h)));x=P[c+8>>2];u=S(x-m);y=P[c>>2];v=S(y-n);z=P[c+4>>2];w=S(z-o);g=S(S(u*f)+S(S(v*g)+S(w*h)));a:{if(!(!(g<=S(0))|!(j<=S(0)))){a=L[b+4>>2];L[e>>2]=L[b>>2];L[e+4>>2]=a;a=L[b+12>>2];L[e+8>>2]=L[b+8>>2];L[e+12>>2]=a;J[e+16|0]=k|1;g=S(0);f=S(0);h=S(1);break a}f=S(l-x);h=S(i-y);q=S(p-z);A=S(S(r*f)+S(S(s*h)+S(t*q)));h=S(S(u*f)+S(S(v*h)+S(w*q)));if(!(!(h>=S(0))|!(h>=A))){a=L[c+4>>2];L[e>>2]=L[c>>2];L[e+4>>2]=a;a=L[c+12>>2];L[e+8>>2]=L[c+8>>2];L[e+12>>2]=a;J[e+16|0]=k|2;g=S(1);f=S(0);h=S(0);break a}q=S(S(g*A)-S(j*h));b:{if(!(h<=S(0))|!(g>=S(0))){break b}f=S(0);if(!(q<=S(0))){break b}L[e+12>>2]=0;J[e+16|0]=k|3;g=S(g/S(g-h));P[e+8>>2]=m+S(u*g);P[e+4>>2]=o+S(w*g);P[e>>2]=n+S(v*g);h=S(S(1)-g);break a}f=S(l-B);i=S(i-C);p=S(p-D);l=S(S(u*f)+S(S(v*i)+S(w*p)));f=S(S(r*f)+S(S(s*i)+S(t*p)));if(!(!(f>=S(0))|!(f>=l))){a=L[d+4>>2];L[e>>2]=L[d>>2];L[e+4>>2]=a;a=L[d+12>>2];L[e+8>>2]=L[d+8>>2];L[e+12>>2]=a;J[e+16|0]=k|4;f=S(1);g=S(0);h=S(0);break a}i=S(S(l*j)-S(f*g));c:{if(!(f<=S(0))|!(j>=S(0))){break c}g=S(0);if(!(i<=S(0))){break c}L[e+12>>2]=0;J[e+16|0]=k|5;f=S(j/S(j-f));P[e+8>>2]=m+S(r*f);P[e+4>>2]=o+S(t*f);P[e>>2]=n+S(s*f);h=S(S(1)-f);break a}d:{j=S(S(h*f)-S(A*l));if(!(j<=S(0))){break d}g=S(A-h);if(!(g>=S(0))){break d}f=S(l-f);if(!(f>=S(0))){break d}L[e+12>>2]=0;J[e+16|0]=k|6;f=S(g/S(g+f));P[e+8>>2]=x+S(S(B-x)*f);P[e+4>>2]=z+S(S(D-z)*f);P[e>>2]=y+S(S(C-y)*f);g=S(S(1)-f);h=S(0);break a}L[e+12>>2]=0;J[e+16|0]=k|7;g=S(S(1)/S(q+S(j+i)));f=S(q*g);g=S(i*g);P[e+8>>2]=S(r*f)+S(m+S(u*g));P[e+4>>2]=S(t*f)+S(o+S(w*g));P[e>>2]=S(s*f)+S(n+S(v*g));h=S(S(S(1)-g)-f)}P[e+20>>2]=h;L[e+32>>2]=0;P[e+28>>2]=f;P[e+24>>2]=g}function nB(a){a=a|0;var b=0,c=S(0),d=0,e=0,f=S(0),g=S(0),h=S(0),i=S(0),j=S(0),k=S(0),l=S(0),m=0,n=S(0),o=S(0),p=S(0),q=S(0),r=S(0),s=0,t=0,u=S(0),v=0,w=S(0),x=S(0),y=S(0),z=S(0),A=S(0),B=S(0),C=S(0),D=S(0),E=S(0),F=S(0),G=S(0),H=S(0),I=S(0),J=S(0),K=S(0),M=S(0),N=S(0),O=S(0),Q=S(0),T=S(0),U=S(0),V=0;L[a+36>>2]=0;m=fa-16|0;b=m+8|0;L[b>>2]=0;L[b+4>>2]=0;L[m>>2]=0;L[m+4>>2]=0;d=L[a+32>>2];e=L[a+28>>2];while(1){v=(s<<2)+m|0;L[v>>2]=1065353216;T=P[d+344>>2];U=P[e+344>>2];l=P[e+56>>2];n=P[e+20>>2];w=P[e+24>>2];x=P[e+28>>2];y=P[e+60>>2];z=P[e+44>>2];A=P[e+36>>2];B=P[e+40>>2];r=P[e+52>>2];j=P[a+308>>2];C=P[e+12>>2];f=P[a+300>>2];D=P[e+4>>2];o=P[a+304>>2];E=P[e+8>>2];g=P[d+56>>2];F=P[d+20>>2];p=P[d+24>>2];q=P[d+28>>2];h=P[d+52>>2];G=P[d+12>>2];H=P[d+4>>2];I=P[d+8>>2];J=P[d+60>>2];i=P[a+324>>2];K=P[d+44>>2];k=P[a+316>>2];M=P[d+36>>2];c=P[a+320>>2];N=P[d+40>>2];V=L[m+4>>2];b=R(s,84)+a|0;t=b+48|0;L[t>>2]=L[m>>2];L[t+4>>2]=V;t=L[m+12>>2];L[b+56>>2]=L[m+8>>2];L[b+60>>2]=t;L[b+92>>2]=0;L[b+76>>2]=0;O=S(S(g+S(S(i*q)+S(S(k*F)+S(p*c))))-g);g=P[b+48>>2];Q=S(S(h+S(S(i*G)+S(S(k*H)+S(I*c))))-h);h=P[b+52>>2];u=S(S(O*g)-S(Q*h));c=S(S(J+S(S(i*K)+S(S(k*M)+S(N*c))))-J);i=P[b+56>>2];k=S(S(c*h)-S(O*i));c=S(S(Q*i)-S(c*g));q=S(S(K*u)+S(S(G*k)+S(q*c)));P[b+88>>2]=q;p=S(S(N*u)+S(S(I*k)+S(p*c)));P[b+84>>2]=p;k=S(S(M*u)+S(S(H*k)+S(F*c)));P[b+80>>2]=k;r=S(S(r+S(S(j*C)+S(S(f*D)+S(E*o))))-r);l=S(S(l+S(S(j*x)+S(S(f*n)+S(w*o))))-l);c=S(S(h*r)-S(g*l));f=S(S(y+S(S(j*z)+S(S(f*A)+S(B*o))))-y);j=S(S(l*i)-S(h*f));f=S(S(f*g)-S(i*r));o=S(S(z*c)+S(S(C*j)+S(x*f)));P[b+72>>2]=o;i=S(S(B*c)+S(S(E*j)+S(w*f)));P[b+68>>2]=i;j=S(S(A*c)+S(S(D*j)+S(n*f)));P[b- -64>>2]=j;f=P[e+404>>2];c=P[e+400>>2];g=P[e+396>>2];L[b+108>>2]=0;g=S(j*g);P[b+96>>2]=g;c=S(i*c);P[b+100>>2]=c;f=S(o*f);P[b+104>>2]=f;h=P[d+404>>2];l=P[d+400>>2];n=P[d+396>>2];L[b+124>>2]=0;n=S(k*n);P[b+112>>2]=n;l=S(p*l);P[b+116>>2]=l;h=S(q*h);P[b+120>>2]=h;P[b+128>>2]=S(T+S(U+S(S(f*o)+S(S(g*j)+S(i*c)))))+S(S(h*q)+S(S(n*k)+S(p*l)));L[v>>2]=0;s=s+1|0;if((s|0)!=3){continue}break}}function mp(a,b,c,d,e,f,g,h,i,j){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;i=i|0;j=j|0;var k=0,l=S(0),m=S(0),n=0,o=0,p=S(0),q=S(0),r=S(0),s=0,t=S(0),u=0,v=0,w=0,x=S(0),y=S(0),z=S(0),A=0;k=fa-48|0;fa=k;L[k+44>>2]=a;L[k+40>>2]=b;L[k+36>>2]=c;L[k+32>>2]=d;L[k+28>>2]=e;L[k+24>>2]=f;L[k+20>>2]=g;L[k+16>>2]=h;L[k+12>>2]=i;J[k+11|0]=j;w=L[k+40>>2];i=L[k+36>>2];j=L[k+32>>2];n=L[k+28>>2];o=L[k+24>>2];b=L[k+12>>2];u=J[k+11|0]&1;e=0;c=0;f=L[k+20>>2];g=L[k+16>>2];a:{if((f|0)<2|(g|0)<2){break a}x=S(f-1|0);y=S(g-1|0);L[8513]=L[8513]+1;d=R(f,g);h=ha[L[6798]](d>>>0>268435455?-1:d<<4,16)|0;s=sa(d>>>0>1073741823?-1:d<<2);while(1){q=P[i+8>>2];l=S(S(c|0)/y);q=S(S(S(P[n+8>>2]-q)*l)+q);r=P[j+8>>2];r=S(S(S(S(P[o+8>>2]-r)*l)+r)-q);p=P[j+4>>2];m=S(S(S(P[o+4>>2]-p)*l)+p);p=P[i+4>>2];p=S(S(S(P[n+4>>2]-p)*l)+p);z=S(m-p);m=P[j>>2];t=S(S(S(P[o>>2]-m)*l)+m);m=P[i>>2];m=S(S(S(P[n>>2]-m)*l)+m);t=S(t-m);A=R(c,f);a=0;while(1){v=a+A|0;e=h+(v<<4)|0;L[e+12>>2]=0;l=S(S(a|0)/x);P[e+8>>2]=S(r*l)+q;P[e+4>>2]=S(z*l)+p;P[e>>2]=S(t*l)+m;L[s+(v<<2)>>2]=1065353216;a=a+1|0;if((f|0)!=(a|0)){continue}break}c=c+1|0;if((g|0)!=(c|0)){continue}break}L[8513]=L[8513]+1;e=Ac(ha[L[6798]](1252,16)|0,w,d,h,s);if(b&1){P[L[e+720>>2]+88>>2]=0;J[e+924|0]=1}if(b&2){P[(L[e+720>>2]+R(f-1|0,104)|0)+88>>2]=0;J[e+924|0]=1}if(b&4){P[(L[e+720>>2]+R(R(f,g-1|0),104)|0)+88>>2]=0;J[e+924|0]=1}if(b&8){P[(L[e+720>>2]+R((f+R(f,g-1|0)|0)-1|0,104)|0)+88>>2]=0;J[e+924|0]=1}if(h){L[8514]=L[8514]+1;ha[L[6799]](h)}ra(s);if((f|0)<=0){break a}b=0;while(1){i=R(b,f);a=0;d=b+1|0;b:{if((d|0)<(g|0)){j=R(d,f);while(1){c=a;h=a+i|0;a=a+1|0;c:{if((f|0)>(a|0)){n=a+i|0;Ha(e,h,n,0,0);o=c+j|0;Ha(e,h,o,0,0);if(b+c&1){c=a+j|0;pb(e,h,n,c,0);pb(e,h,c,o,0);if(!u){break c}Ha(e,h,c,0,0);break c}pb(e,o,h,n,0);pb(e,o,n,a+j|0,0);if(!u){break c}Ha(e,n,o,0,0);break c}Ha(e,h,c+j|0,0,0)}if((a|0)!=(f|0)){continue}break}break b}while(1){b=a+1|0;if((b|0)<(f|0)){Ha(e,a+i|0,b+i|0,0,0)}a=b;if((f|0)!=(a|0)){continue}break}}b=d;if((g|0)!=(b|0)){continue}break}}fa=k+48|0;return e|0}function LF(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,f=0,g=0,h=0,i=0;P[b+16>>2]=P[a+20>>2];P[b+20>>2]=P[a+24>>2];P[b+24>>2]=P[a+28>>2];P[b+28>>2]=P[a+32>>2];P[b>>2]=P[a+4>>2];P[b+4>>2]=P[a+8>>2];P[b+8>>2]=P[a+12>>2];P[b+12>>2]=P[a+16>>2];P[b+32>>2]=P[a+36>>2];P[b+36>>2]=P[a+40>>2];P[b+40>>2]=P[a+44>>2];P[b+44>>2]=P[a+48>>2];L[b+48>>2]=L[a+56>>2];L[b+52>>2]=M[a+60|0];d=L[a+88>>2];L[b+56>>2]=d;a:{if(!d){L[b+64>>2]=0;break a}d=ha[L[L[c>>2]+28>>2]](c,L[a+96>>2])|0;L[b+64>>2]=d;if(!d){break a}h=L[a+88>>2];i=ha[L[L[c>>2]+16>>2]](c,48,h)|0;b:{if((h|0)<=0){g=L[a+96>>2];break b}g=L[a+96>>2];d=L[i+8>>2];while(1){e=(f<<6)+g|0;P[d+16>>2]=P[e+16>>2];P[d+20>>2]=P[e+20>>2];P[d+24>>2]=P[e+24>>2];P[d+28>>2]=P[e+28>>2];P[d>>2]=P[e>>2];P[d+4>>2]=P[e+4>>2];P[d+8>>2]=P[e+8>>2];P[d+12>>2]=P[e+12>>2];L[d+32>>2]=L[e+32>>2];L[d+36>>2]=L[e+36>>2];L[d+40>>2]=L[e+40>>2];d=d+48|0;f=f+1|0;if((h|0)!=(f|0)){continue}break}}ha[L[L[c>>2]+20>>2]](c,i,4118,1497453121,g)}d=L[a+128>>2];L[b+60>>2]=d;c:{if(!d){L[b+68>>2]=0;break c}d=ha[L[L[c>>2]+28>>2]](c,L[a+136>>2])|0;L[b+68>>2]=d;if(!d){break c}f=0;h=L[a+128>>2];i=ha[L[L[c>>2]+16>>2]](c,16,h)|0;d:{if((h|0)<=0){g=L[a+136>>2];break d}g=L[a+136>>2];d=L[i+8>>2];while(1){e=(f<<4)+g|0;L[d+12>>2]=L[e+12>>2];K[d+6>>1]=N[e+6>>1];K[d+8>>1]=N[e+8>>1];K[d+10>>1]=N[e+10>>1];K[d>>1]=N[e>>1];K[d+2>>1]=N[e+2>>1];K[d+4>>1]=N[e+4>>1];d=d+16|0;f=f+1|0;if((h|0)!=(f|0)){continue}break}}ha[L[L[c>>2]+20>>2]](c,i,4095,1497453121,g)}L[b+76>>2]=L[a+144>>2];d=L[a+152>>2];L[b+80>>2]=d;if(!d){L[b+72>>2]=0;return 3637}d=b;b=ha[L[L[c>>2]+28>>2]](c,L[a+160>>2])|0;L[d+72>>2]=b;if(b){f=0;e=L[a+152>>2];g=ha[L[L[c>>2]+16>>2]](c,20,e)|0;e:{if((e|0)<=0){a=L[a+160>>2];break e}a=L[a+160>>2];d=L[g+8>>2];while(1){b=(f<<5)+a|0;K[d+14>>1]=N[b+6>>1];K[d+16>>1]=N[b+8>>1];K[d+18>>1]=N[b+10>>1];K[d+8>>1]=N[b>>1];K[d+10>>1]=N[b+2>>1];K[d+12>>1]=N[b+4>>1];L[d>>2]=L[b+12>>2];L[d+4>>2]=L[b+16>>2];d=d+20|0;f=f+1|0;if((e|0)!=(f|0)){continue}break}}ha[L[L[c>>2]+20>>2]](c,g,3745,1497453121,a)}return 3637}function an(a,b,c){var d=0,e=0,f=0,g=0,h=S(0),i=S(0),j=S(0),k=S(0),l=S(0),m=S(0),n=S(0),o=S(0),p=S(0),q=S(0),r=S(0),s=S(0),t=S(0),u=S(0),v=S(0),w=S(0),x=S(0),y=S(0),z=S(0),A=S(0),B=S(0),C=0,D=S(0),E=S(0),F=S(0);e=fa-160|0;fa=e;f=L[a+4>>2];d=L[f+12>>2];D=P[d+52>>2];E=P[d+56>>2];h=P[d+24>>2];i=P[d+20>>2];j=P[d+40>>2];k=P[d+36>>2];F=P[d+48>>2];l=P[d+8>>2];m=P[d>>2];n=P[d+4>>2];o=P[d+16>>2];p=P[d+32>>2];d=L[L[f+4>>2]+24>>2]+R(c,80)|0;q=P[d+32>>2];r=P[d>>2];s=P[d+16>>2];t=P[d+56>>2];u=P[d+52>>2];v=P[d+48>>2];w=P[d+36>>2];x=P[d+20>>2];y=P[d+4>>2];z=P[d+40>>2];A=P[d+24>>2];B=P[d+8>>2];f=0;L[e+156>>2]=0;L[e+140>>2]=0;L[e+124>>2]=0;P[e+136>>2]=S(z*j)+S(S(B*p)+S(k*A));P[e+132>>2]=S(w*j)+S(S(y*p)+S(k*x));P[e+120>>2]=S(z*h)+S(S(B*o)+S(i*A));P[e+116>>2]=S(w*h)+S(S(y*o)+S(i*x));P[e+152>>2]=E+S(S(t*j)+S(S(v*p)+S(k*u)));P[e+148>>2]=D+S(S(t*h)+S(S(v*o)+S(i*u)));L[e+108>>2]=0;P[e+128>>2]=S(q*j)+S(S(r*p)+S(k*s));P[e+112>>2]=S(q*h)+S(S(r*o)+S(i*s));P[e+96>>2]=S(q*l)+S(S(r*m)+S(n*s));P[e+104>>2]=S(z*l)+S(S(B*m)+S(n*A));P[e+100>>2]=S(w*l)+S(S(y*m)+S(n*x));P[e+144>>2]=F+S(S(t*l)+S(S(v*m)+S(n*u)));ha[L[L[b>>2]+8>>2]](b,e+96|0,e+80|0,e- -64|0);d=L[a+8>>2];g=L[d+4>>2];ha[L[L[g>>2]+8>>2]](g,L[d+12>>2],e+48|0,e+32|0);d=L[7542];a:{if(d){if(!(ha[d|0](L[L[a+8>>2]+4>>2],b)|0)){break a}}f=P[e+64>>2]>2]|P[e+80>>2]>P[e+32>>2]?f:1;d=0;if((P[e+72>>2]>2]|P[e+88>>2]>P[e+40>>2]?d:f)^1|P[e+68>>2]>2]|P[e+84>>2]>P[e+36>>2]){break a}d=L[a+4>>2];f=L[d+8>>2];L[e+24>>2]=-1;L[e+16>>2]=f;L[e+12>>2]=b;L[e+8>>2]=d;L[e+28>>2]=c;b=2;L[e+20>>2]=e+96;if(!L[L[a+24>>2]+(c<<2)>>2]){d=L[a+12>>2];d=ha[L[L[d>>2]+8>>2]](d,e+8|0,L[a+8>>2],L[a+28>>2])|0;L[L[a+24>>2]+(c<<2)>>2]=d;d=L[a+4>>2]}g=L[a+20>>2];f=L[g+8>>2];b:{if(L[f+8>>2]==L[d+8>>2]){C=g+8|0;break b}f=L[g+12>>2];b=3;C=g+12|0}d=e+8|0;L[C>>2]=d;ha[L[L[g>>2]+(b<<2)>>2]](g,-1,c);b=L[L[a+24>>2]+(c<<2)>>2];ha[L[L[b>>2]+8>>2]](b,d,L[a+8>>2],L[a+16>>2],L[a+20>>2]);b=L[a+20>>2];L[(L[L[b+8>>2]+8>>2]==L[L[a+4>>2]+8>>2]?8:12)+b>>2]=f}fa=e+160|0}function lv(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;a=L[c+8>>2];if(!M[31436]){J[31436]=1;L[7857]=17608;J[31432]=0}L[(a+3600|0)+72>>2]=31428;L[(a+3604|0)+72>>2]=31428;L[(a+3608|0)+72>>2]=31428;L[(a+3612|0)+72>>2]=31428;L[(a+3616|0)+72>>2]=31428;L[(a+3620|0)+72>>2]=31428;L[(a+3624|0)+72>>2]=31428;L[(a+3628|0)+72>>2]=31428;L[(a+3632|0)+72>>2]=31428;L[(a+3636|0)+72>>2]=31428;L[(a+3640|0)+72>>2]=31428;L[(a+3644|0)+72>>2]=31428;L[(a+3648|0)+72>>2]=31428;L[(a+3652|0)+72>>2]=31428;L[(a+3656|0)+72>>2]=31428;L[(a+3660|0)+72>>2]=31428;L[(a+3664|0)+72>>2]=31428;L[(a+3668|0)+72>>2]=31428;L[(a+3672|0)+72>>2]=31428;L[(a+3676|0)+72>>2]=31428;L[(a+3680|0)+72>>2]=31428;L[(a+3684|0)+72>>2]=31428;L[(a+3688|0)+72>>2]=31428;L[(a+3692|0)+72>>2]=31428;L[(a+3696|0)+72>>2]=31428;b=a+3700|0;L[b+72>>2]=31428;L[(a+3704|0)+72>>2]=31428;L[(a+3708|0)+72>>2]=31428;L[(a+3712|0)+72>>2]=31428;L[(a+3716|0)+72>>2]=31428;L[(a+3720|0)+72>>2]=31428;L[(a+3724|0)+72>>2]=31428;L[(a+3728|0)+72>>2]=31428;L[(a+3732|0)+72>>2]=31428;L[(a+3736|0)+72>>2]=31428;L[(a+3740|0)+72>>2]=31428;L[a+172>>2]=31428;L[a+316>>2]=31428;L[a+460>>2]=31428;L[a+604>>2]=31428;L[a+748>>2]=31428;L[a+892>>2]=31428;L[(a+964|0)+72>>2]=31428;L[(a+1108|0)+72>>2]=31428;L[(a+1252|0)+72>>2]=31428;L[(a+1396|0)+72>>2]=31428;L[(a+1540|0)+72>>2]=31428;L[(a+1684|0)+72>>2]=31428;L[(a+1828|0)+72>>2]=31428;L[(a+1972|0)+72>>2]=31428;L[(a+2116|0)+72>>2]=31428;L[(a+2260|0)+72>>2]=31428;L[(a+2404|0)+72>>2]=31428;L[(a+2548|0)+72>>2]=31428;L[(a+2692|0)+72>>2]=31428;L[(a+2836|0)+72>>2]=31428;L[(a+2980|0)+72>>2]=31428;L[(a+3124|0)+72>>2]=31428;L[(a+3268|0)+72>>2]=31428;L[(a+3412|0)+72>>2]=31428;L[(a+3556|0)+72>>2]=31428;L[b+72>>2]=31428;L[(a+3844|0)+72>>2]=31428;L[(a+3988|0)+72>>2]=31428;L[(a+4132|0)+72>>2]=31428;L[(a+4276|0)+72>>2]=31428;L[(a+4420|0)+72>>2]=31428;L[(a+4564|0)+72>>2]=31428;L[(a+4708|0)+72>>2]=31428;L[(a+4852|0)+72>>2]=31428;L[(a+4996|0)+72>>2]=31428;L[(a+5140|0)+72>>2]=31428;fa=c+16|0}function jF(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0,g=0,h=0,i=S(0),j=S(0),k=S(0),l=S(0),m=S(0),n=S(0);c=fa-144|0;fa=c;if(L[a+16>>2]>0){f=c- -64|0;while(1){g=R(h,80);d=g+L[a+24>>2]|0;e=L[d+12>>2];L[c+24>>2]=L[d+8>>2];L[c+28>>2]=e;e=L[d+4>>2];L[c+16>>2]=L[d>>2];L[c+20>>2]=e;e=L[d+28>>2];L[c+40>>2]=L[d+24>>2];L[c+44>>2]=e;e=L[d+20>>2];L[c+32>>2]=L[d+16>>2];L[c+36>>2]=e;e=L[d+44>>2];L[c+56>>2]=L[d+40>>2];L[c+60>>2]=e;e=L[d+36>>2];L[c+48>>2]=L[d+32>>2];L[c+52>>2]=e;e=L[d+60>>2];L[f+8>>2]=L[d+56>>2];L[f+12>>2]=e;e=L[d+52>>2];L[f>>2]=L[d+48>>2];L[f+4>>2]=e;d=L[d+64>>2];d=ha[L[L[d>>2]+28>>2]](d)|0;e=L[d+12>>2];L[c+8>>2]=L[d+8>>2];L[c+12>>2]=e;e=L[d+4>>2];L[c>>2]=L[d>>2];L[c+4>>2]=e;i=P[a+80>>2];j=P[b+4>>2];k=P[a+76>>2];l=P[b>>2];P[c+8>>2]=S(P[c+8>>2]*P[b+8>>2])/P[a+84>>2];L[c+12>>2]=0;P[c>>2]=S(l*P[c>>2])/k;P[c+4>>2]=S(j*P[c+4>>2])/i;d=L[(L[a+24>>2]+g|0)+64>>2];ha[L[L[d>>2]+24>>2]](d,c);i=P[a+76>>2];j=P[b>>2];k=P[a+80>>2];l=P[b+4>>2];m=P[a+84>>2];n=P[b+8>>2];L[c+76>>2]=0;P[c+72>>2]=S(n*P[c+72>>2])/m;P[c+68>>2]=S(l*P[c+68>>2])/k;P[c+64>>2]=S(j*P[c+64>>2])/i;e=L[c+20>>2];d=L[a+24>>2]+g|0;L[d>>2]=L[c+16>>2];L[d+4>>2]=e;e=L[c+28>>2];L[d+8>>2]=L[c+24>>2];L[d+12>>2]=e;e=L[c+44>>2];L[d+24>>2]=L[c+40>>2];L[d+28>>2]=e;e=L[c+36>>2];L[d+16>>2]=L[c+32>>2];L[d+20>>2]=e;e=L[c+60>>2];L[d+40>>2]=L[c+56>>2];L[d+44>>2]=e;e=L[c+52>>2];L[d+32>>2]=L[c+48>>2];L[d+36>>2]=e;e=L[f+12>>2];L[d+56>>2]=L[f+8>>2];L[d+60>>2]=e;e=L[f+4>>2];L[d+48>>2]=L[f>>2];L[d+52>>2]=e;if(L[a+64>>2]){d=L[(L[a+24>>2]+g|0)+64>>2];ha[L[L[d>>2]+8>>2]](d,c+16|0,c+128|0,c+112|0);d=L[c+140>>2];L[c+88>>2]=L[c+136>>2];L[c+92>>2]=d;d=L[c+132>>2];L[c+80>>2]=L[c+128>>2];L[c+84>>2]=d;d=L[c+124>>2];L[c+104>>2]=L[c+120>>2];L[c+108>>2]=d;d=L[c+116>>2];L[c+96>>2]=L[c+112>>2];L[c+100>>2]=d;Gc(L[a+64>>2],L[(L[a+24>>2]+g|0)+76>>2],c+80|0)}h=h+1|0;if((h|0)>2]){continue}break}}d=L[b+4>>2];L[a+76>>2]=L[b>>2];L[a+80>>2]=d;d=L[b+12>>2];L[a+84>>2]=L[b+8>>2];L[a+88>>2]=d;ha[L[L[a>>2]+68>>2]](a);fa=c+144|0}function cH(a,b,c,d){a=a|0;b=b|0;c=c|0;d=S(d);var e=0,f=0,g=0,h=0,i=S(0),j=S(0),k=S(0),l=0,m=S(0),n=S(0),o=S(0),p=S(0),q=S(0),r=S(0),s=0,t=S(0),u=S(0),v=S(0),w=S(0),x=S(0),y=S(0),z=S(0),A=S(0),B=S(0),C=S(0),D=S(0),E=S(0),F=S(0);e=fa-192|0;fa=e;m=P[c+8>>2];n=S(S(P[b+8>>2]*d)+m);q=P[c+4>>2];o=S(S(P[b+4>>2]*d)+q);r=P[c>>2];p=S(S(P[b>>2]*d)+r);l=L[a+8>>2];f=L[l+8>>2];g=L[L[a+4>>2]+740>>2];s=(f|0)==(g|0);a:{if(!s){g=L[a+12>>2];h=L[g+8>>2];k=S(n-P[h+60>>2]);i=S(p-P[h+52>>2]);j=S(o-P[h+56>>2]);t=S(S(P[h+44>>2]*k)+S(S(P[h+12>>2]*i)+S(j*P[h+28>>2])));u=S(S(P[h+40>>2]*k)+S(S(P[h+8>>2]*i)+S(j*P[h+24>>2])));k=S(S(P[h+36>>2]*k)+S(S(P[h+4>>2]*i)+S(j*P[h+20>>2])));break a}k=S(n-P[g+60>>2]);i=S(p-P[g+52>>2]);j=S(o-P[g+56>>2]);t=S(S(P[g+44>>2]*k)+S(S(P[g+12>>2]*i)+S(j*P[g+28>>2])));u=S(S(P[g+40>>2]*k)+S(S(P[g+8>>2]*i)+S(j*P[g+24>>2])));k=S(S(P[g+36>>2]*k)+S(S(P[g+4>>2]*i)+S(j*P[g+20>>2])));g=L[a+12>>2];f=L[g+8>>2]}v=P[f+20>>2];w=P[f+36>>2];x=P[f+40>>2];y=P[f+8>>2];z=P[f+24>>2];i=P[f+44>>2];j=P[f+60>>2];A=P[f+12>>2];B=P[f+52>>2];C=P[f+28>>2];D=P[f+56>>2];E=P[f+4>>2];L[e+36>>2]=0;F=i;i=S(m-j);j=S(r-B);m=S(q-D);P[e+32>>2]=S(F*i)+S(S(A*j)+S(C*m));P[e+28>>2]=S(x*i)+S(S(y*j)+S(m*z));L[e+20>>2]=0;P[e+16>>2]=t;P[e+12>>2]=u;P[e+8>>2]=k;P[e+24>>2]=S(w*i)+S(S(E*j)+S(m*v));f=L[b+12>>2];L[e+80>>2]=L[b+8>>2];L[e+84>>2]=f;f=L[b>>2];b=L[b+4>>2];L[e+136>>2]=0;L[e+140>>2]=0;L[e+144>>2]=0;L[e+148>>2]=0;L[e+152>>2]=0;L[e+156>>2]=0;P[e+60>>2]=o;P[e- -64>>2]=n;L[e+68>>2]=0;L[e+72>>2]=f;L[e+76>>2]=b;L[e+128>>2]=0;L[e+132>>2]=0;J[e+124|0]=0;L[e+120>>2]=0;L[e+100>>2]=0;L[e+92>>2]=0;L[e+96>>2]=0;P[e+88>>2]=d;P[e+56>>2]=p;b=L[c+12>>2];L[e+48>>2]=L[c+8>>2];L[e+52>>2]=b;b=L[c+4>>2];L[e+40>>2]=L[c>>2];L[e+44>>2]=b;b:{if(!s){h=a+16|0;f=a+20|0;b=l;l=a+28|0;c=a+24|0;break b}h=a+20|0;f=a+16|0;b=g;g=l;l=a+24|0;c=a+28|0}f=L[f>>2];h=L[h>>2];l=L[l>>2];c=L[c>>2];L[e+116>>2]=c;L[e+112>>2]=l;L[e+108>>2]=h;L[e+104>>2]=f;a=L[a+32>>2];S(ha[L[L[a>>2]+12>>2]](a,e+8|0,g,f,l,b,h,c));fa=e+192|0}function Sl(a,b,c){var d=S(0),e=0,f=S(0),g=0,h=0,i=0,j=0,k=S(0),l=0,m=S(0),n=S(0),o=S(0),p=0,q=S(0),r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0;k=P[a- -64>>2];q=P[a+48>>2];m=P[a+32>>2];d=P[b+24>>2];d=dq?q:d)-m))+S(.5));a:{if(d=S(0)){w=~~d>>>0;break a}w=0}o=P[a+60>>2];f=P[a+44>>2];n=P[a+28>>2];d=P[b+20>>2];d=df?f:d)-n))+S(.5));b:{if(d=S(0)){x=~~d>>>0;break b}x=0}d=P[b+8>>2];d=dq?q:d)-m)*k)+S(.5));c:{if(d=S(0)){s=~~d>>>0;break c}s=0}d=P[b+4>>2];d=df?f:d)-n)*o)+S(.5));d:{if(d=S(0)){y=~~d>>>0;break d}y=0}o=P[a+56>>2];k=P[a+40>>2];f=P[a+24>>2];d=P[b+16>>2];d=dk?k:d)-f))+S(.5));e:{if(d=S(0)){z=~~d>>>0;break e}z=0}d=P[b>>2];d=dk?k:d)-f)*o)+S(.5));f:{if(d=S(0)){A=~~d>>>0;break f}A=0}B=L[a>>2];if((B|0)>0){b=0;while(1){g:{h:{i:{j:{l=b<<4;e=l+L[a+16>>2]|0;if(!(N[e>>1]>z>>>0|N[e+6>>1]>>0|(N[e+8>>1]>>0|N[e+2>>1]>x>>>0))){if(N[e+4>>1]<=w>>>0){break j}}h=L[e+12>>2]>=0;i=0;break i}t=L[e+12>>2];h=(t|0)>=0;e=N[e+10>>1];i=e>>>0>=s>>>0;if((t|0)<0|e>>>0>>0){break i}g=L[c+4>>2];k:{if((g|0)!=L[c+8>>2]){break k}r=g?g<<1:1;if((r|0)<=(g|0)){break k}l:{if(!r){h=0;break l}L[8513]=L[8513]+1;h=ha[L[6798]](r<<2,16)|0;g=L[c+4>>2]}j=L[c+12>>2];m:{n:{if((g|0)>0){u=0;i=0;if(g>>>0>=4){l=g&-4;v=0;while(1){p=i<<2;L[p+h>>2]=L[j+p>>2];e=p|4;L[e+h>>2]=L[e+j>>2];e=p|8;L[e+h>>2]=L[e+j>>2];e=p|12;L[e+h>>2]=L[e+j>>2];i=i+4|0;v=v+4|0;if((l|0)!=(v|0)){continue}break}}l=g&3;if(!l){break n}while(1){e=i<<2;L[e+h>>2]=L[e+j>>2];i=i+1|0;u=u+1|0;if((l|0)!=(u|0)){continue}break}break n}if(!j){break m}}if(j?M[c+16|0]:0){L[8514]=L[8514]+1;ha[L[6799]](j)}g=L[c+4>>2]}L[c+12>>2]=h;J[c+16|0]=1;L[c+8>>2]=r}L[L[c+12>>2]+(g<<2)>>2]=t;L[c+4>>2]=L[c+4>>2]+1;break h}if(h|i){break h}b=b-L[(l+L[a+16>>2]|0)+12>>2]|0;break g}b=b+1|0}if((B|0)>(b|0)){continue}break}}}function qn(a,b,c,d){var e=0,f=0,g=S(0),h=S(0),i=S(0),j=0,k=S(0),l=S(0),m=0,n=0,o=S(0),p=0,q=0,r=S(0),s=S(0),t=0,u=0,v=0,w=0,x=S(0),y=0,z=0,A=0,B=0,C=0,D=0,E=0;f=fa-32|0;fa=f;if(a){g=P[b+8>>2];h=P[c+8>>2];o=P[b>>2];k=P[c>>2];l=P[b+4>>2];i=P[c+4>>2];L[8513]=L[8513]+1;c=ha[L[6798]](512,16)|0;pa(c+4|0,0,508);L[c>>2]=a;g=S(h-g);h=S(k-o);o=S(i-l);k=S(S(1)/S(_(S(S(g*g)+S(S(h*h)+S(o*o))))));l=S(g*k);i=S(l*g);g=S(h*k);r=S(g*h);h=S(o*k);x=S(i+S(r+S(o*h)));o=l==S(0)?S(0xde0b6b000000000):S(S(1)/l);a=o>2];m=L[n+4>>2];L[f>>2]=L[n>>2];L[f+4>>2]=m;m=L[n+12>>2];L[f+8>>2]=L[n+8>>2];L[f+12>>2]=m;m=L[n+28>>2];L[f+24>>2]=L[n+24>>2];L[f+28>>2]=m;m=L[n+20>>2];L[f+16>>2]=L[n+16>>2];L[f+20>>2]=m;r=P[b>>2];k=S(g*S(P[C>>2]-r));i=P[b+4>>2];l=S(h*S(P[B>>2]-i));a:{b:{if(k>l){break b}i=S(h*S(P[z>>2]-i));r=S(g*S(P[D>>2]-r));if(i>r){break b}k=k>2];i=S(o*S(P[A>>2]-s));if(k>i){break b}s=S(o*S(P[y>>2]-s));l=ll|!((ki?i:l)>S(0))){break b}if(L[n+40>>2]){c:{if((e|0)<=(q|0)){e=c;break c}m=p<<1;d:{if((m|0)<=(p|0)){e=c;break d}e:{if((m|0)<=(j|0)){e=c;break e}f:{if(!p){e=0;break f}L[8513]=L[8513]+1;e=ha[L[6798]](p<<3,16)|0;if((p|0)<=0){break f}v=0;q=0;if(p>>>0>=4){E=p&-4;t=0;while(1){j=q<<2;L[j+e>>2]=L[c+j>>2];u=j|4;L[u+e>>2]=L[c+u>>2];u=j|8;L[u+e>>2]=L[c+u>>2];j=j|12;L[j+e>>2]=L[c+j>>2];q=q+4|0;t=t+4|0;if((E|0)!=(t|0)){continue}break}}j=p&3;if(!j){break f}while(1){t=q<<2;L[t+e>>2]=L[c+t>>2];q=q+1|0;v=v+1|0;if((j|0)!=(v|0)){continue}break}}if(c){L[8514]=L[8514]+1;ha[L[6799]](c)}j=m}c=p<<2;pa(c+e|0,0,c)}q=m-2|0;c=e;p=m}L[e+w>>2]=L[n+36>>2];L[(a<<2)+e>>2]=L[n+40>>2];a=a+1|0;break a}ha[L[L[d>>2]+12>>2]](d,n)}a=e}if(a){continue}break}if(c){L[8514]=L[8514]+1;ha[L[6799]](c)}}fa=f+32|0}function Dp(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0;g=fa-16|0;fa=g;L[g+12>>2]=a;L[g+8>>2]=b;a=L[g+8>>2];h=fa-16|0;fa=h;L[h+12>>2]=L[g+12>>2]+748;L[h+8>>2]=a;a=L[h+8>>2];b=fa+-64|0;fa=b;L[b+60>>2]=L[h+12>>2];L[b+56>>2]=a;k=L[b+60>>2];a=fa-16|0;L[a+12>>2]=L[b+56>>2];L[b+52>>2]=L[L[a+12>>2]+4>>2];d=L[b+52>>2];L[b+48>>2]=0;L[b+40>>2]=0;L[b+44>>2]=0;L[b+32>>2]=0;L[b+36>>2]=0;L[b+24>>2]=0;L[b+28>>2]=0;L[b+16>>2]=0;L[b+20>>2]=0;L[b+8>>2]=0;L[b+12>>2]=0;fa=a;e=b+8|0;L[a+12>>2]=e;c=L[a+12>>2];Bh(c);L[(fa-16|0)+12>>2]=c+20;fa=a+16|0;a=fa-32|0;fa=a;L[a+28>>2]=k;L[a+24>>2]=d;L[a+20>>2]=e;d=fa-16|0;i=L[a+28>>2];L[d+12>>2]=i;L[a+16>>2]=L[L[d+12>>2]+4>>2];a:{if(L[a+24>>2]>2]){L[a+12>>2]=L[a+24>>2];while(1){if(L[a+12>>2]>2]){L[a+12>>2]=L[a+12>>2]+1;continue}break}break a}d=L[a+24>>2];e=fa-16|0;L[e+12>>2]=i;if(L[L[e+12>>2]+4>>2]<(d|0)){e=L[a+24>>2];d=fa-16|0;fa=d;L[d+12>>2]=i;L[d+8>>2]=e;c=fa-16|0;e=L[d+12>>2];L[c+12>>2]=e;if(L[L[c+12>>2]+8>>2]>2]){f=L[d+8>>2];c=fa-16|0;fa=c;L[c+8>>2]=e;L[c+4>>2]=f;j=L[c+8>>2];b:{if(L[c+4>>2]){l=L[c+4>>2];f=fa-16|0;fa=f;L[f+12>>2]=j;L[f+8>>2]=l;L[f+4>>2]=0;j=R(L[f+8>>2],44);L[8513]=L[8513]+1;j=ha[L[6798]](j,16)|0;fa=f+16|0;L[c+12>>2]=j;break b}L[c+12>>2]=0}fa=c+16|0;L[d+4>>2]=L[c+12>>2];c=fa-16|0;L[c+12>>2]=e;Ah(e,L[L[c+12>>2]+4>>2],L[d+4>>2]);c=fa-16|0;L[c+12>>2]=e;Db(e,L[L[c+12>>2]+4>>2]);jb(e);J[e+16|0]=1;L[e+12>>2]=L[d+4>>2];L[e+8>>2]=L[d+8>>2]}fa=d+16|0}L[a+8>>2]=L[a+16>>2];while(1){if(L[a+8>>2]>2]){e=L[a+20>>2];c=L[e+4>>2];d=L[i+12>>2]+R(L[a+8>>2],44)|0;L[d>>2]=L[e>>2];L[d+4>>2]=c;L[d+40>>2]=L[e+40>>2];c=L[e+36>>2];L[d+32>>2]=L[e+32>>2];L[d+36>>2]=c;c=L[e+28>>2];L[d+24>>2]=L[e+24>>2];L[d+28>>2]=c;c=L[e+20>>2];L[d+16>>2]=L[e+16>>2];L[d+20>>2]=c;c=L[e+12>>2];L[d+8>>2]=L[e+8>>2];L[d+12>>2]=c;L[a+8>>2]=L[a+8>>2]+1;continue}break}}L[i+4>>2]=L[a+24>>2];fa=a+32|0;Ah(L[b+56>>2],L[b+52>>2],L[k+12>>2]);fa=b- -64|0;fa=h+16|0;fa=g+16|0}function nF(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;f=fa-80|0;fa=f;L[a+68>>2]=L[a+68>>2]+1;d=L[a+16>>2];if((d|0)>0){g=f- -64|0;h=f+48|0;i=f+32|0;j=f+16|0;l=d;while(1){k=L[a+24>>2];m=l-1|0;n=R(m,80);c=k+n|0;if(L[c+64>>2]==(b|0)){L[a+68>>2]=L[a+68>>2]+1;e=L[a+64>>2];if(e){fc(e,L[c+76>>2]);k=L[a+24>>2];d=L[a+16>>2]}c=k+n|0;e=c+8|0;o=L[e+4>>2];L[f+8>>2]=L[e>>2];L[f+12>>2]=o;e=L[c+4>>2];L[f>>2]=L[c>>2];L[f+4>>2]=e;e=L[c+28>>2];L[j+8>>2]=L[c+24>>2];L[j+12>>2]=e;e=L[c+20>>2];L[j>>2]=L[c+16>>2];L[j+4>>2]=e;e=L[c+44>>2];L[i+8>>2]=L[c+40>>2];L[i+12>>2]=e;e=L[c+36>>2];L[i>>2]=L[c+32>>2];L[i+4>>2]=e;e=L[c+60>>2];L[h+8>>2]=L[c+56>>2];L[h+12>>2]=e;e=L[c+52>>2];L[h>>2]=L[c+48>>2];L[h+4>>2]=e;e=L[c+76>>2];L[g+8>>2]=L[c+72>>2];L[g+12>>2]=e;e=L[c+68>>2];L[g>>2]=L[c+64>>2];L[g+4>>2]=e;e=k;k=R(d,80)-80|0;d=e+k|0;e=L[d+4>>2];L[c>>2]=L[d>>2];L[c+4>>2]=e;e=L[d+12>>2];L[c+8>>2]=L[d+8>>2];L[c+12>>2]=e;e=L[d+20>>2];L[c+16>>2]=L[d+16>>2];L[c+20>>2]=e;e=L[d+28>>2];L[c+24>>2]=L[d+24>>2];L[c+28>>2]=e;e=L[d+36>>2];L[c+32>>2]=L[d+32>>2];L[c+36>>2]=e;e=L[d+44>>2];L[c+40>>2]=L[d+40>>2];L[c+44>>2]=e;e=L[d+60>>2];L[c+56>>2]=L[d+56>>2];L[c+60>>2]=e;e=L[d+52>>2];L[c+48>>2]=L[d+48>>2];L[c+52>>2]=e;e=L[d+68>>2];L[c+64>>2]=L[d+64>>2];L[c+68>>2]=e;e=L[d+76>>2];L[c+72>>2]=L[d+72>>2];L[c+76>>2]=e;d=L[f+4>>2];c=k+L[a+24>>2]|0;L[c>>2]=L[f>>2];L[c+4>>2]=d;d=L[f+12>>2];L[c+8>>2]=L[f+8>>2];L[c+12>>2]=d;d=L[j+4>>2];L[c+16>>2]=L[j>>2];L[c+20>>2]=d;d=L[j+12>>2];L[c+24>>2]=L[j+8>>2];L[c+28>>2]=d;d=L[i+12>>2];L[c+40>>2]=L[i+8>>2];L[c+44>>2]=d;d=L[i+4>>2];L[c+32>>2]=L[i>>2];L[c+36>>2]=d;d=L[h+4>>2];L[c+48>>2]=L[h>>2];L[c+52>>2]=d;d=L[h+12>>2];L[c+56>>2]=L[h+8>>2];L[c+60>>2]=d;d=L[g+4>>2];L[c+64>>2]=L[g>>2];L[c+68>>2]=d;d=L[g+12>>2];L[c+72>>2]=L[g+8>>2];L[c+76>>2]=d;if(L[a+64>>2]){L[L[(L[a+24>>2]+n|0)+76>>2]+36>>2]=m}d=L[a+16>>2]-1|0;L[a+16>>2]=d}c=l>>>0>1;l=m;if(c){continue}break}}ha[L[L[a>>2]+68>>2]](a);fa=f+80|0}function PE(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=S(0),k=S(0),l=0,m=S(0),n=S(0),o=0,p=S(0),q=S(0),r=0,s=S(0),t=S(0),u=S(0),v=0,w=0,x=0;a:{if((d|0)<=0){break a}if(d>>>0>=8){e=d&-8;while(1){f=g<<4;L[(f+c|0)+12>>2]=-581039253;L[((f|16)+c|0)+12>>2]=-581039253;L[((f|32)+c|0)+12>>2]=-581039253;L[((f|48)+c|0)+12>>2]=-581039253;L[((f|64)+c|0)+12>>2]=-581039253;L[((f|80)+c|0)+12>>2]=-581039253;L[((f|96)+c|0)+12>>2]=-581039253;L[((f|112)+c|0)+12>>2]=-581039253;g=g+8|0;i=i+8|0;if((e|0)!=(i|0)){continue}break}}e=d&7;if(e){while(1){L[((g<<4)+c|0)+12>>2]=-581039253;g=g+1|0;h=h+1|0;if((e|0)!=(h|0)){continue}break}}if((d|0)<=0){break a}i=0;if(L[a+96>>2]>0){while(1){o=i<<4;h=L[a+96>>2];b:{if((h|0)>0){e=b+o|0;s=P[a+20>>2];p=S(P[e+8>>2]*s);t=P[a+16>>2];q=S(P[e+4>>2]*t);u=P[a+12>>2];m=S(P[e>>2]*u);w=h&1;e=L[a+104>>2];c:{if((h|0)==1){g=0;h=-1;k=S(-34028234663852886e22);break c}x=h&-2;g=0;h=-1;k=S(-34028234663852886e22);r=0;while(1){f=e+(g<<4)|0;j=S(S(P[f+8>>2]*p)+S(S(P[f>>2]*m)+S(q*P[f+4>>2])));v=j>k;f=g|1;l=e+(f<<4)|0;n=S(S(P[l+8>>2]*p)+S(S(P[l>>2]*m)+S(q*P[l+4>>2])));j=v?j:k;l=n>j;k=l?n:j;h=l?f:v?g:h;g=g+2|0;r=r+2|0;if((x|0)!=(r|0)){continue}break}}if(w){f=e+(g<<4)|0;j=S(S(P[f+8>>2]*p)+S(S(P[f>>2]*m)+S(q*P[f+4>>2])));f=j>k;k=f?j:k;h=f?g:h}e=(h<<4)+e|0;m=P[e>>2];n=P[e+4>>2];j=P[e+8>>2];e=c+o|0;P[e+12>>2]=k;P[e+8>>2]=j*s;P[e+4>>2]=n*t;P[e>>2]=u*m;break b}L[(c+o|0)+12>>2]=-581039253}i=i+1|0;if((i|0)!=(d|0)){continue}break a}}h=0;g=0;if(d>>>0>=8){a=d&-8;while(1){b=g<<4;L[(b+c|0)+12>>2]=-581039253;L[((b|16)+c|0)+12>>2]=-581039253;L[((b|32)+c|0)+12>>2]=-581039253;L[((b|48)+c|0)+12>>2]=-581039253;L[((b|64)+c|0)+12>>2]=-581039253;L[((b|80)+c|0)+12>>2]=-581039253;L[((b|96)+c|0)+12>>2]=-581039253;L[((b|112)+c|0)+12>>2]=-581039253;g=g+8|0;i=i+8|0;if((a|0)!=(i|0)){continue}break}}a=d&7;if(!a){break a}while(1){L[((g<<4)+c|0)+12>>2]=-581039253;g=g+1|0;h=h+1|0;if((a|0)!=(h|0)){continue}break}}}function _p(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=S(e);var f=0,g=0,h=0,i=0,j=0,k=S(0),l=0,m=0,n=0,o=S(0),p=S(0),q=S(0),r=S(0),s=0,t=S(0),u=S(0),v=S(0),w=S(0),x=S(0),y=S(0),z=S(0),A=S(0),B=S(0),C=0,D=0,E=S(0);f=fa-32|0;fa=f;L[f+28>>2]=a;L[f+24>>2]=b;L[f+20>>2]=c;J[f+19|0]=d;P[f+12>>2]=e;c=J[f+19|0]&1;E=P[f+12>>2];h=fa-16|0;fa=h;a=L[f+28>>2];s=L[f+24>>2];b=L[a+720>>2]+R(s,104)|0;e=P[b+16>>2];o=P[b+12>>2];p=P[b+8>>2];b=L[f+20>>2];t=P[b+20>>2];u=P[b+36>>2];v=P[b+40>>2];w=P[b+8>>2];x=P[b+24>>2];q=P[b+60>>2];y=P[b+44>>2];z=P[b+12>>2];k=P[b+52>>2];r=P[b+56>>2];A=P[b+28>>2];B=P[b+4>>2];L[h+12>>2]=0;k=S(-k);P[h+8>>2]=S(S(S(z*k)-S(A*r))-S(y*q))+S(S(e*y)+S(S(p*z)+S(A*o)));P[h+4>>2]=S(S(S(w*k)-S(x*r))-S(v*q))+S(S(e*v)+S(S(p*w)+S(x*o)));P[h>>2]=S(S(S(B*k)-S(t*r))-S(u*q))+S(S(e*u)+S(S(p*B)+S(t*o)));i=fa-96|0;fa=i;a:{if(!c){break a}c=L[a+268>>2];b:{if((c|0)<=0){break b}j=L[a+276>>2];d=0;while(1){if((b|0)!=L[j+(d<<2)>>2]){d=d+1|0;if((d|0)!=(c|0)){continue}break b}break}if((c|0)!=(d|0)){break a}}c:{if(L[a+272>>2]!=(c|0)){break c}m=c?c<<1:1;if((m|0)<=(c|0)){break c}d:{if(!m){j=0;break d}L[8513]=L[8513]+1;j=ha[L[6798]](m<<2,16)|0;c=L[a+268>>2]}e:{if((c|0)<=0){break e}d=0;if(c>>>0>=4){n=c&-4;while(1){g=d<<2;L[g+j>>2]=L[g+L[a+276>>2]>>2];l=g|4;L[l+j>>2]=L[l+L[a+276>>2]>>2];l=g|8;L[l+j>>2]=L[l+L[a+276>>2]>>2];g=g|12;L[g+j>>2]=L[g+L[a+276>>2]>>2];d=d+4|0;C=C+4|0;if((n|0)!=(C|0)){continue}break}}g=c&3;if(!g){break e}while(1){n=d<<2;L[n+j>>2]=L[n+L[a+276>>2]>>2];d=d+1|0;D=D+1|0;if((g|0)!=(D|0)){continue}break}}d=L[a+276>>2];if(!(!d|!M[a+280|0])){if(d){L[8514]=L[8514]+1;ha[L[6799]](d)}c=L[a+268>>2]}L[a+276>>2]=j;J[a+280|0]=1;L[a+272>>2]=m}L[L[a+276>>2]+(c<<2)>>2]=b;L[a+268>>2]=c+1}c=L[a+720>>2];L[i+20>>2]=b;b=c+R(s,104)|0;L[i>>2]=b;c=L[h+12>>2];L[i+12>>2]=L[h+8>>2];L[i+16>>2]=c;c=L[h+4>>2];L[i+4>>2]=L[h>>2];L[i+8>>2]=c;J[b+100|0]=M[b+100|0]|1;P[i+24>>2]=E;ki(a+788|0,i);fa=i+96|0;fa=h+16|0;fa=f+32|0}function Fm(a,b,c,d,e,f){var g=0,h=0,i=S(0),j=S(0),k=S(0),l=S(0),m=S(0),n=S(0),o=S(0),p=S(0),q=0,r=S(0),s=S(0),t=0,u=S(0),v=S(0),w=S(0),x=0,y=0,z=S(0),A=S(0),B=S(0),C=0,D=0,E=0,F=0,G=0,H=0;g=fa-32|0;fa=g;if(L[a+56>>2]>0){n=P[d+8>>2];o=P[c+8>>2];j=S(n-o);p=P[d>>2];l=P[c>>2];k=S(p-l);m=P[d+4>>2];i=P[c+4>>2];r=S(m-i);s=S(S(1)/S(_(S(S(j*j)+S(S(k*k)+S(r*r))))));u=S(j*s);v=S(u*j);j=S(k*s);w=S(j*k);k=S(r*s);r=S(v+S(w+S(r*k)));s=S((n>o?n:o)+P[f+8>>2]);v=S((i>2]);w=S((l>2]);z=S((n>2]);A=S((i>m?m:i)+P[e+4>>2]);B=S((l>p?p:l)+P[e>>2]);d=L[a+96>>2];n=u==S(0)?S(0xde0b6b000000000):S(S(1)/u);h=n>2];L[g>>2]=L[d>>2];L[g+4>>2]=h;h=L[d+12>>2];L[g+8>>2]=L[d+8>>2];L[g+12>>2]=h;h=L[d+28>>2];L[g+24>>2]=L[d+24>>2];L[g+28>>2]=h;h=L[d+20>>2];L[g+16>>2]=L[d+16>>2];L[g+20>>2]=h;P[g>>2]=P[g>>2]-P[f>>2];P[g+4>>2]=P[g+4>>2]-P[f+4>>2];P[g+8>>2]=P[g+8>>2]-P[f+8>>2];P[g+16>>2]=P[g+16>>2]-P[e>>2];P[g+20>>2]=P[g+20>>2]-P[e+4>>2];P[g+24>>2]=P[g+24>>2]-P[e+8>>2];h=0;a:{if(P[d+16>>2]>2]>w){break a}h=1}q=0;b:{c:{d:{e:{f:{if((P[d+24>>2]>2]?q:h)^1|P[d+4>>2]>v|P[d+20>>2]>2];l=S(p*S(P[G>>2]-j));i=P[c+4>>2];m=S(o*S(P[F>>2]-i));if(l>m){break f}i=S(o*S(P[D>>2]-i));j=S(p*S(P[H>>2]-j));if(i>j){break f}l=i>l?i:l;k=P[c+8>>2];i=S(n*S(P[E>>2]-k));if(l>i){break f}k=S(n*S(P[C>>2]-k));m=j>m?m:j;if(k>m){break f}y=L[d+32>>2];q=(y|0)==-1;h=r>(k>l?k:l)&(iS(0);if(!h|(y|0)!=-1){break e}ha[L[L[b>>2]+8>>2]](b,L[d+36>>2],L[d+40>>2]);break d}q=L[d+32>>2]==-1;h=0}if(h){break d}if(!q){break c}}t=t+1|0;d=d- -64|0;break b}h=L[d+32>>2];t=h+t|0;d=(h<<6)+d|0}x=x+1|0;if(L[a+56>>2]>(t|0)){continue}break}}if(L[7548]<(x|0)){L[7548]=x}fa=g+32|0}function Ma(a,b){var c=0,d=S(0),e=0,f=S(0),g=0;c=fa+-64|0;fa=c;L[c+60>>2]=a;L[c+56>>2]=b;a=fa-16|0;b=L[c+60>>2];L[a+12>>2]=b;d=P[L[a+12>>2]>>2];L[a+12>>2]=b+16;f=P[L[a+12>>2]+4>>2];L[a+12>>2]=b+32;P[c+52>>2]=S(d+f)+P[L[a+12>>2]+8>>2];a:{if(P[c+52>>2]>S(0)){a=fa-16|0;P[a+12>>2]=P[c+52>>2]+S(1);P[c+28>>2]=_(P[a+12>>2]);P[c+44>>2]=P[c+28>>2]*S(.5);P[c+28>>2]=S(.5)/P[c+28>>2];e=b+32|0;L[a+12>>2]=e;d=P[L[a+12>>2]+4>>2];g=b+16|0;L[a+12>>2]=g;P[c+32>>2]=S(d-P[L[a+12>>2]+8>>2])*P[c+28>>2];L[a+12>>2]=b;d=P[L[a+12>>2]+8>>2];L[a+12>>2]=e;P[c+36>>2]=S(d-P[L[a+12>>2]>>2])*P[c+28>>2];L[a+12>>2]=g;d=P[L[a+12>>2]>>2];L[a+12>>2]=b;P[c+40>>2]=S(d-P[L[a+12>>2]+4>>2])*P[c+28>>2];break a}a=fa-16|0;L[a+12>>2]=b;d=P[L[a+12>>2]>>2];L[a+12>>2]=b+16;b:{if(P[L[a+12>>2]+4>>2]>d){a=fa-16|0;L[a+12>>2]=b+16;d=P[L[a+12>>2]+4>>2];L[a+12>>2]=b+32;a=P[L[a+12>>2]+8>>2]>d?2:1;break b}a=fa-16|0;L[a+12>>2]=b;d=P[L[a+12>>2]>>2];L[a+12>>2]=b+32;a=P[L[a+12>>2]+8>>2]>d?2:0}L[c+24>>2]=a;L[c+20>>2]=(L[c+24>>2]+1|0)%3;L[c+16>>2]=(L[c+24>>2]+2|0)%3;a=fa-16|0;L[a+12>>2]=b+(L[c+24>>2]<<4);d=P[L[a+12>>2]+(L[c+24>>2]<<2)>>2];L[a+12>>2]=b+(L[c+20>>2]<<4);f=P[L[a+12>>2]+(L[c+20>>2]<<2)>>2];L[a+12>>2]=b+(L[c+16>>2]<<4);P[a+12>>2]=S(S(d-f)-P[L[a+12>>2]+(L[c+16>>2]<<2)>>2])+S(1);P[c+12>>2]=_(P[a+12>>2]);e=c+32|0;P[e+(L[c+24>>2]<<2)>>2]=P[c+12>>2]*S(.5);P[c+12>>2]=S(.5)/P[c+12>>2];L[a+12>>2]=b+(L[c+16>>2]<<4);d=P[L[a+12>>2]+(L[c+20>>2]<<2)>>2];L[a+12>>2]=b+(L[c+20>>2]<<4);P[c+44>>2]=S(d-P[L[a+12>>2]+(L[c+16>>2]<<2)>>2])*P[c+12>>2];L[a+12>>2]=b+(L[c+20>>2]<<4);d=P[L[a+12>>2]+(L[c+24>>2]<<2)>>2];L[a+12>>2]=b+(L[c+24>>2]<<4);P[e+(L[c+20>>2]<<2)>>2]=S(d+P[L[a+12>>2]+(L[c+20>>2]<<2)>>2])*P[c+12>>2];L[a+12>>2]=b+(L[c+16>>2]<<4);d=P[L[a+12>>2]+(L[c+24>>2]<<2)>>2];L[a+12>>2]=b+(L[c+24>>2]<<4);P[e+(L[c+16>>2]<<2)>>2]=S(d+P[L[a+12>>2]+(L[c+16>>2]<<2)>>2])*P[c+12>>2]}a=c+32|0;vc(L[c+56>>2],a,a+4|0,a+8|0,a+12|0);fa=c- -64|0}function gg(a,b,c){var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;a:{if(!a|!b){break a}L[8513]=L[8513]+1;d=ha[L[6798]](1024,16)|0;L[d+4>>2]=b;L[d>>2]=a;n=124;i=128;j=128;l=1;while(1){m=l;l=m-1|0;o=l<<3;a=o+d|0;f=L[a+4>>2];e=L[a>>2];if((l|0)>(n|0)){p=i<<1;b:{if((p|0)<=(i|0)){b=d;break b}if((j|0)>=(p|0)){b=d;break b}c:{if(!i){b=0;break c}L[8513]=L[8513]+1;b=ha[L[6798]](i<<4,16)|0;if((i|0)<=0){break c}n=0;a=0;if(i>>>0>=4){r=i&-4;j=0;while(1){h=a<<3;g=h+b|0;k=d+h|0;q=L[k+4>>2];L[g>>2]=L[k>>2];L[g+4>>2]=q;g=h|8;k=g+b|0;g=d+g|0;q=L[g+4>>2];L[k>>2]=L[g>>2];L[k+4>>2]=q;g=h|16;k=g+b|0;g=d+g|0;q=L[g+4>>2];L[k>>2]=L[g>>2];L[k+4>>2]=q;h=h|24;g=h+b|0;h=d+h|0;k=L[h+4>>2];L[g>>2]=L[h>>2];L[g+4>>2]=k;a=a+4|0;j=j+4|0;if((r|0)!=(j|0)){continue}break}}i=i&3;if(!i){break c}while(1){j=a<<3;h=j+b|0;j=d+j|0;r=L[j+4>>2];L[h>>2]=L[j>>2];L[h+4>>2]=r;a=a+1|0;n=n+1|0;if((i|0)!=(n|0)){continue}break}}if(d){L[8514]=L[8514]+1;ha[L[6799]](d)}j=p}n=p-4|0;i=p;d=b}d:{if((e|0)==(f|0)){if(!L[e+40>>2]){break d}a=d+o|0;b=L[e+36>>2];L[a+4>>2]=b;L[a>>2]=b;a=(m<<3)+d|0;b=L[e+40>>2];L[a+4>>2]=b;L[a>>2]=b;b=L[e+40>>2];L[a+8>>2]=L[e+36>>2];L[a+12>>2]=b;l=m+2|0;break d}if(!(P[e>>2]<=P[f+16>>2])|!(P[e+16>>2]>=P[f>>2])|(!(P[e+4>>2]<=P[f+20>>2])|!(P[e+20>>2]>=P[f+4>>2]))){break d}if(!(P[e+8>>2]<=P[f+24>>2])|!(P[e+24>>2]>=P[f+8>>2])){break d}a=L[f+40>>2];if(L[e+40>>2]){b=L[e+36>>2];if(a){a=d+o|0;L[a+4>>2]=L[f+36>>2];L[a>>2]=b;b=L[e+40>>2];a=(m<<3)+d|0;L[a+4>>2]=L[f+36>>2];L[a>>2]=b;b=L[e+36>>2];L[a+12>>2]=L[f+40>>2];L[a+8>>2]=b;b=L[e+40>>2];L[a+20>>2]=L[f+40>>2];L[a+16>>2]=b;l=m+3|0;break d}a=d+o|0;L[a+4>>2]=f;L[a>>2]=b;a=L[e+40>>2];b=(m<<3)+d|0;L[b+4>>2]=f;L[b>>2]=a;l=m+1|0;break d}if(a){a=d+o|0;L[a+4>>2]=L[f+36>>2];L[a>>2]=e;a=(m<<3)+d|0;L[a+4>>2]=L[f+40>>2];L[a>>2]=e;l=m+1|0;break d}ha[L[L[c>>2]+8>>2]](c,e,f)}if(l){continue}break}if(!d){break a}if(d){L[8514]=L[8514]+1;ha[L[6799]](d)}}}function Xo(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0,g=S(0),h=0;e=fa-256|0;fa=e;L[e+252>>2]=a;L[e+248>>2]=b;L[e+244>>2]=c;L[e+240>>2]=d;d=L[e+252>>2];a=e+208|0;La(a,L[e+244>>2],L[e+248>>2]);P[e+204>>2]=.5;Ga(e+224|0,a,e+204|0);a=e+172|0;ta(a,L[e+244>>2],L[e+248>>2]);P[e+168>>2]=.5;Ga(e+188|0,a,e+168|0);P[e+140>>2]=1;P[e+136>>2]=1;P[e+132>>2]=1;la(e+144|0,e+140|0,e+136|0,e+132|0);a=fa-16|0;L[a+12>>2]=e+112;L[a+12>>2]=e+96;L[e+164>>2]=0;while(1){if(L[e+164>>2]<4){L[e+160>>2]=0;while(1){if(L[e+160>>2]<3){a=fa-16|0;b=e+144|0;L[a+12>>2]=b;g=P[L[a+12>>2]>>2];c=e+224|0;L[a+12>>2]=c;P[e+76>>2]=g*P[L[a+12>>2]>>2];L[a+12>>2]=b;g=P[L[a+12>>2]+4>>2];L[a+12>>2]=c;P[e+72>>2]=g*P[L[a+12>>2]+4>>2];L[a+12>>2]=b;g=P[L[a+12>>2]+8>>2];L[a+12>>2]=c;P[e+68>>2]=g*P[L[a+12>>2]+8>>2];la(e+80|0,e+76|0,e+72|0,e+68|0);a=L[e+92>>2];L[e+120>>2]=L[e+88>>2];L[e+124>>2]=a;a=L[e+84>>2];L[e+112>>2]=L[e+80>>2];L[e+116>>2]=a;a=e+112|0;h=e+188|0;hb(a,h);L[e+64>>2]=L[e+160>>2]%3;f=fa-16|0;L[f+12>>2]=b;f=L[f+12>>2]+(L[e+64>>2]<<2)|0;P[f>>2]=S(-0)-P[f>>2];f=fa-16|0;L[f+12>>2]=b;g=P[L[f+12>>2]>>2];f=fa-16|0;L[f+12>>2]=c;P[e+44>>2]=g*P[L[f+12>>2]>>2];f=fa-16|0;L[f+12>>2]=b;g=P[L[f+12>>2]+4>>2];f=fa-16|0;L[f+12>>2]=c;P[e+40>>2]=g*P[L[f+12>>2]+4>>2];f=fa-16|0;L[f+12>>2]=b;g=P[L[f+12>>2]+8>>2];b=fa-16|0;L[b+12>>2]=c;P[e+36>>2]=g*P[L[b+12>>2]+8>>2];la(e+48|0,e+44|0,e+40|0,e+36|0);b=L[e+60>>2];L[e+104>>2]=L[e+56>>2];L[e+108>>2]=b;b=L[e+52>>2];L[e+96>>2]=L[e+48>>2];L[e+100>>2]=b;b=e+96|0;hb(b,h);ha[L[L[d>>2]+8>>2]](d,a,b,L[e+240>>2]);L[e+160>>2]=L[e+160>>2]+1;continue}break}P[e+16>>2]=-1;P[e+12>>2]=-1;P[e+8>>2]=-1;la(e+20|0,e+16|0,e+12|0,e+8|0);a=L[e+32>>2];L[e+152>>2]=L[e+28>>2];L[e+156>>2]=a;a=L[e+24>>2];L[e+144>>2]=L[e+20>>2];L[e+148>>2]=a;if(L[e+164>>2]<3){a=fa-16|0;L[a+12>>2]=e+144;a=L[a+12>>2]+(L[e+164>>2]<<2)|0;P[a>>2]=S(-0)-P[a>>2]}L[e+164>>2]=L[e+164>>2]+1;continue}break}fa=e+256|0}function PH(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,f=0,g=0,h=0,i=S(0),j=S(0),k=0,l=0,m=0,n=0,o=S(0);g=fa-16|0;fa=g;L[7540]=L[7540]+1;if(L[a+4>>2]&2){d=L[b+192>>2];i=S(ha[L[L[d>>2]+20>>2]](d,P[6794]));P[g+12>>2]=i;d=L[c+192>>2];j=S(ha[L[L[d>>2]+20>>2]](d,P[6794]));P[g+8>>2]=j;d=i>2];i=P[c+184>>2];j=P[b+184>>2];e=L[a+68>>2];f=L[e+8>>2];a:{b:{if(f){d=L[e+12>>2];h=L[d>>2];L[e+8>>2]=f-1;L[e+12>>2]=h;break b}d=0;if(M[a+4|0]&4){break a}L[8513]=L[8513]+1;d=ha[L[6798]](772,16)|0}L[d>>2]=1025;L[d+124>>2]=0;L[d+128>>2]=0;J[d+120|0]=0;L[d+116>>2]=0;L[d+132>>2]=0;L[d+136>>2]=0;L[d+140>>2]=0;L[d+144>>2]=0;L[d+148>>2]=0;L[d+152>>2]=0;L[d+308>>2]=0;L[d+312>>2]=0;J[d+304|0]=0;L[d+300>>2]=0;L[d+316>>2]=0;L[d+320>>2]=0;L[d+324>>2]=0;L[d+328>>2]=0;L[d+332>>2]=0;L[d+336>>2]=0;L[d+492>>2]=0;L[d+496>>2]=0;J[d+488|0]=0;L[d+484>>2]=0;L[d+500>>2]=0;L[d+504>>2]=0;L[d+508>>2]=0;L[d+512>>2]=0;L[d+516>>2]=0;L[d+520>>2]=0;J[d+672|0]=0;L[d+668>>2]=0;L[d+676>>2]=0;L[d+680>>2]=0;L[d+684>>2]=0;L[d+688>>2]=0;L[d+692>>2]=0;L[d+696>>2]=0;L[d+700>>2]=0;L[d+704>>2]=0;L[d+740>>2]=b;L[d+744>>2]=c;L[d+748>>2]=0;P[d+752>>2]=o;P[d+756>>2]=i>j?j:i;e=L[a+12>>2];L[d+768>>2]=e;c:{if(L[a+16>>2]!=(e|0)){break c}h=e?e<<1:1;if((h|0)<=(e|0)){break c}d:{if(!h){b=0;break d}L[8513]=L[8513]+1;b=ha[L[6798]](h<<2,16)|0;e=L[a+12>>2]}e:{if((e|0)<=0){break e}c=0;if(e>>>0>=4){l=e&-4;while(1){f=c<<2;L[f+b>>2]=L[f+L[a+20>>2]>>2];k=f|4;L[k+b>>2]=L[k+L[a+20>>2]>>2];k=f|8;L[k+b>>2]=L[k+L[a+20>>2]>>2];f=f|12;L[f+b>>2]=L[f+L[a+20>>2]>>2];c=c+4|0;m=m+4|0;if((l|0)!=(m|0)){continue}break}}f=e&3;if(!f){break e}while(1){l=c<<2;L[l+b>>2]=L[l+L[a+20>>2]>>2];c=c+1|0;n=n+1|0;if((f|0)!=(n|0)){continue}break}}c=L[a+20>>2];if(!(!c|!M[a+24|0])){if(c){L[8514]=L[8514]+1;ha[L[6799]](c)}e=L[a+12>>2]}L[a+20>>2]=b;J[a+24|0]=1;L[a+16>>2]=h}L[L[a+20>>2]+(e<<2)>>2]=d;L[a+12>>2]=e+1}fa=g+16|0;return d|0}function tk(a,b){var c=0,d=S(0),e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=S(0),n=S(0),o=S(0),p=0,q=S(0),r=S(0),s=S(0),t=0,u=0,v=S(0),w=S(0),x=0,y=0,z=0,A=S(0),B=0,C=S(0),D=S(0),E=S(0),F=0,G=S(0);wa(2649);j=L[a+712>>2];a:{if((j|0)<=0){break a}L[8513]=L[8513]+1;c=j<<4;i=ha[L[6798]](c,16)|0;pa(i,0,c);c=L[a+712>>2];if((c|0)<=0){break a}L[8513]=L[8513]+1;c=c<<2;g=ha[L[6798]](c,16)|0;pa(g,0,c)}k=L[a+1112>>2];b:{if(b){if((k|0)<=0){break b}h=L[a+1120>>2];while(1){c=L[h+(e<<2)>>2];f=L[c+312>>2];if(f){d=S(S(1)/S(f|0));P[c+276>>2]=d*P[c+276>>2];P[c+280>>2]=d*P[c+280>>2];P[c+284>>2]=d*P[c+284>>2];P[c+292>>2]=d*P[c+292>>2];P[c+296>>2]=d*P[c+296>>2];P[c+300>>2]=d*P[c+300>>2]}e=e+1|0;if((k|0)!=(e|0)){continue}break}}if((k|0)<=0){break b}x=L[a+720>>2];y=L[a+1120>>2];h=0;z=b?312:308;while(1){c=L[(h<<2)+y>>2];c:{if(L[c+z>>2]<=0){break c}p=L[c+24>>2];if((p|0)<=0){break c}d=P[a+452>>2];e=b?c+276|0:c+244|0;n=S(d*P[e+8>>2]);o=S(d*P[e+4>>2]);A=S(P[c+(b?276:244)>>2]*d);B=L[c+32>>2];e=b?c+292|0:c+260|0;q=S(d*P[e+4>>2]);C=S(-q);r=S(d*P[c+(b?292:260)>>2]);D=S(-r);s=S(d*P[e+8>>2]);E=S(-s);F=L[c+12>>2];f=0;while(1){t=f<<2;l=L[t+B>>2];m=P[l+8>>2];G=P[c+228>>2];u=(l-x|0)/104|0;e=(u<<4)+i|0;d=P[F+t>>2];v=S(P[l+16>>2]-P[c+236>>2]);w=S(P[l+12>>2]-P[c+232>>2]);P[e>>2]=P[e>>2]+S(d*S(A+S(S(q*v)+S(w*E))));m=S(m-G);P[e+4>>2]=P[e+4>>2]+S(d*S(o+S(S(s*m)+S(v*D))));P[e+8>>2]=S(d*S(n+S(S(r*w)+S(m*C))))+P[e+8>>2];e=(u<<2)+g|0;P[e>>2]=d+P[e>>2];f=f+1|0;if((p|0)!=(f|0)){continue}break}}h=h+1|0;if((k|0)!=(h|0)){continue}break}}d:{e:{if((j|0)>0){e=L[a+720>>2];a=0;while(1){d=P[(a<<2)+g>>2];if(d>S(0)){c=(a<<4)+i|0;n=P[c+8>>2];o=P[c+4>>2];b=e+R(a,104)|0;d=S(S(1)/d);P[b+8>>2]=S(d*P[c>>2])+P[b+8>>2];P[b+12>>2]=S(d*o)+P[b+12>>2];P[b+16>>2]=S(d*n)+P[b+16>>2]}a=a+1|0;if((j|0)!=(a|0)){continue}break}break e}if(!g){break d}}if(g){L[8514]=L[8514]+1;ha[L[6799]](g)}}if(i){L[8514]=L[8514]+1;ha[L[6799]](i)}va()}function at(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=0,g=0;f=fa-32|0;fa=f;L[f+28>>2]=a;L[f+24>>2]=b;L[f+20>>2]=c;L[f+16>>2]=d;J[f+15|0]=e;g=oa(1128);b=L[f+20>>2];a=L[f+16>>2];e=J[f+15|0]&1;c=ub(g,7,L[f+28>>2],L[f+24>>2]);J[c+48|0]=0;L[c>>2]=20084;d=L[b+12>>2];L[c+60>>2]=L[b+8>>2];L[c+64>>2]=d;d=L[b+4>>2];L[c+52>>2]=L[b>>2];L[c+56>>2]=d;d=L[b+28>>2];L[c+76>>2]=L[b+24>>2];L[c+80>>2]=d;d=L[b+20>>2];L[c+68>>2]=L[b+16>>2];L[c+72>>2]=d;d=L[b+44>>2];L[c+92>>2]=L[b+40>>2];L[c+96>>2]=d;d=L[b+36>>2];L[c+84>>2]=L[b+32>>2];L[c+88>>2]=d;d=L[b+60>>2];L[c+108>>2]=L[b+56>>2];L[c+112>>2]=d;d=L[b+52>>2];L[c+100>>2]=L[b+48>>2];L[c+104>>2]=d;b=L[a+12>>2];L[c+124>>2]=L[a+8>>2];L[c+128>>2]=b;b=L[a+4>>2];L[c+116>>2]=L[a>>2];L[c+120>>2]=b;b=L[a+28>>2];L[c+140>>2]=L[a+24>>2];L[c+144>>2]=b;b=L[a+20>>2];L[c+132>>2]=L[a+16>>2];L[c+136>>2]=b;b=L[a+44>>2];L[c+156>>2]=L[a+40>>2];L[c+160>>2]=b;b=L[a+36>>2];L[c+148>>2]=L[a+32>>2];L[c+152>>2]=b;b=L[a+60>>2];L[c+172>>2]=L[a+56>>2];L[c+176>>2]=b;b=L[a+52>>2];L[c+164>>2]=L[a+48>>2];L[c+168>>2]=b;L[c+288>>2]=1065353216;L[c+292>>2]=0;L[c+280>>2]=1065353216;L[c+284>>2]=1060320051;L[c+272>>2]=1065353216;L[c+276>>2]=0;L[c+264>>2]=1065353216;L[c+268>>2]=1060320051;L[c+224>>2]=0;L[c+228>>2]=0;L[c+216>>2]=1065353216;L[c+220>>2]=1060320051;L[c+208>>2]=0;L[c+212>>2]=0;L[c+200>>2]=1065353216;L[c+204>>2]=1060320051;L[c+192>>2]=0;L[c+196>>2]=0;L[c+184>>2]=1065353216;L[c+188>>2]=-1082130432;J[c+180|0]=e;L[c+1124>>2]=0;L[c+1116>>2]=0;L[c+1120>>2]=0;J[c+1096|0]=0;L[c+256>>2]=1065353216;L[c+260>>2]=0;L[c+248>>2]=1065353216;L[c+252>>2]=1060320051;L[c+240>>2]=1065353216;L[c+244>>2]=0;L[c+232>>2]=1065353216;L[c+236>>2]=1060320051;L[c+300>>2]=0;a=c+1105|0;J[a|0]=0;J[a+1|0]=0;J[a+2|0]=0;J[a+3|0]=0;J[a+4|0]=0;J[a+5|0]=0;J[a+6|0]=0;J[a+7|0]=0;L[c+1100>>2]=0;L[c+1104>>2]=0;J[c+49|0]=1;sg(c,L[c+28>>2]+4|0,L[c+32>>2]+4|0);fa=f+32|0;return g|0}function Wk(a,b,c,d){J[a+76|0]=1;L[a+72>>2]=0;L[a+68>>2]=c;L[a+28>>2]=0;L[a+32>>2]=0;L[a+24>>2]=b;J[a+20|0]=1;L[a>>2]=6776;L[a+16>>2]=0;L[a- -64>>2]=0;J[a+60|0]=0;L[a+56>>2]=1025758986;J[a+54|0]=1;K[a+52>>1]=256;L[a+48>>2]=0;J[a+44|0]=1;L[a+36>>2]=1;L[a+40>>2]=1065353216;L[a+8>>2]=0;L[a+12>>2]=0;L[a+92>>2]=1058642330;L[a+96>>2]=1065353216;L[a+88>>2]=0;L[a+80>>2]=0;L[a+84>>2]=0;L[a>>2]=20352;L[a+200>>2]=d;L[a+196>>2]=0;L[a+100>>2]=1050253722;L[a+104>>2]=1015580809;L[a+124>>2]=1045220557;L[a+128>>2]=1061997773;L[a+108>>2]=0;L[a+112>>2]=10;L[a+168>>2]=1120403456;L[a+172>>2]=1900671690;L[a+164>>2]=128;L[a+156>>2]=260;L[a+160>>2]=2;L[a+148>>2]=0;L[a+152>>2]=1062836634;L[a+140>>2]=-1121724662;L[a+144>>2]=1036831949;L[a+132>>2]=0;L[a+136>>2]=1;L[a+116>>2]=1101004800;L[a+120>>2]=1065353216;J[a+192|0]=1;L[a+188>>2]=0;L[a+180>>2]=0;L[a+184>>2]=0;J[a+224|0]=1;L[a+212>>2]=0;L[a+216>>2]=0;L[a+220>>2]=0;J[a+244|0]=1;K[a+274>>1]=0;L[a+240>>2]=0;L[a+248>>2]=0;L[a+252>>2]=-1054867456;L[a+232>>2]=0;L[a+236>>2]=0;L[a+256>>2]=0;L[a+260>>2]=0;L[a+264>>2]=0;L[a+268>>2]=0;J[a+292|0]=1;L[a+296>>2]=0;L[a+288>>2]=0;L[a+280>>2]=0;L[a+284>>2]=0;J[a+320|0]=1;J[a+300|0]=1;L[a+316>>2]=0;L[a+308>>2]=0;L[a+312>>2]=0;if(d){c=0}else{L[8513]=L[8513]+1;L[a+200>>2]=dl(ha[L[6798]](196,16)|0);c=1}J[a+273|0]=c;L[8513]=L[8513]+1;c=ha[L[6798]](68,16)|0;L[c>>2]=20292;L[c+16>>2]=0;J[c+20|0]=1;L[c+8>>2]=0;L[c+12>>2]=0;L[c+36>>2]=0;J[c+40|0]=1;J[c+60|0]=1;L[c+28>>2]=0;L[c+32>>2]=0;L[c+56>>2]=0;J[c+64|0]=1;L[c+48>>2]=0;L[c+52>>2]=0;J[a+272|0]=1;L[a+204>>2]=c;L[8513]=L[8513]+1;c=ha[L[6798]](88,16)|0;d=L[a+200>>2];J[c+44|0]=1;L[c+24>>2]=b;L[c+20>>2]=0;L[c+12>>2]=0;L[c+16>>2]=0;L[c+8>>2]=d;L[c+4>>2]=0;L[c>>2]=20608;L[c+40>>2]=0;J[c- -64|0]=1;L[c+32>>2]=0;L[c+36>>2]=0;L[c+60>>2]=0;J[c+84|0]=1;L[c+52>>2]=0;L[c+56>>2]=0;L[c+80>>2]=0;L[c+72>>2]=0;L[c+76>>2]=0;L[a+196>>2]=c;return a}function NG(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=0,g=0,h=S(0),i=0,j=S(0),k=S(0),l=S(0),m=S(0),n=S(0),o=S(0),p=S(0),q=S(0),r=S(0),s=S(0),t=0,u=S(0),v=S(0),w=S(0),x=S(0),y=S(0),z=S(0),A=S(0),B=S(0),C=S(0),D=S(0),E=S(0),F=S(0),G=S(0),H=S(0);a:{f=M[a+8|0];t=f?b:c;g=L[t+4>>2];if(L[g+4>>2]-21>>>0>8){break a}i=f?c:b;if(L[L[i+4>>2]+4>>2]>19){break a}h=S(ha[L[L[g>>2]+48>>2]](g));L[e+4>>2]=L[a+76>>2];c=fa+-64|0;fa=c;b=a+12|0;P[b+56>>2]=h;L[b+52>>2]=d;L[b+8>>2]=t;L[b+4>>2]=i;L[b+44>>2]=e;d=L[t+12>>2];u=P[d+52>>2];v=P[d+56>>2];f=L[i+12>>2];w=P[f+52>>2];x=P[f+56>>2];j=P[d+20>>2];k=P[d+36>>2];y=P[f+20>>2];z=P[f+36>>2];A=P[f+24>>2];l=P[d+24>>2];B=P[f+40>>2];m=P[d+40>>2];C=P[f+32>>2];n=P[d+32>>2];D=P[f>>2];o=P[d>>2];E=P[f+16>>2];p=P[d+16>>2];q=P[d+48>>2];F=P[f+48>>2];r=P[d+4>>2];G=P[f+4>>2];H=P[f+8>>2];s=P[d+8>>2];L[c+60>>2]=0;L[c+44>>2]=0;L[c+28>>2]=0;P[c+40>>2]=S(B*m)+S(S(H*s)+S(l*A));P[c+36>>2]=S(z*m)+S(S(G*s)+S(l*y));P[c+24>>2]=S(B*k)+S(S(H*r)+S(j*A));P[c+20>>2]=S(z*k)+S(S(G*r)+S(j*y));q=S(-q);P[c+56>>2]=S(S(S(s*q)-S(l*u))-S(m*v))+S(S(x*m)+S(S(F*s)+S(l*w)));P[c+52>>2]=S(S(S(r*q)-S(j*u))-S(k*v))+S(S(x*k)+S(S(F*r)+S(j*w)));L[c+12>>2]=0;P[c>>2]=S(C*n)+S(S(D*o)+S(p*E));P[c+32>>2]=S(C*m)+S(S(D*s)+S(l*E));P[c+16>>2]=S(C*k)+S(S(D*r)+S(j*E));P[c+8>>2]=S(B*n)+S(S(H*o)+S(p*A));P[c+4>>2]=S(z*n)+S(S(G*o)+S(p*y));P[c+48>>2]=S(S(S(o*q)-S(p*u))-S(n*v))+S(S(x*n)+S(S(F*o)+S(p*w)));d=L[i+4>>2];ha[L[L[d>>2]+8>>2]](d,c,b+12|0,b+28|0);P[b+28>>2]=P[b+28>>2]+h;P[b+32>>2]=P[b+32>>2]+h;P[b+36>>2]=P[b+36>>2]+h;P[b+12>>2]=P[b+12>>2]-h;P[b+16>>2]=P[b+16>>2]-h;P[b+20>>2]=P[b+20>>2]-h;fa=c- -64|0;c=L[i+8>>2];d=L[a+76>>2];L[d+744>>2]=L[t+8>>2];L[d+740>>2]=c;ha[L[L[g>>2]+64>>2]](g,b,a+24|0,a+40|0);b=L[e+4>>2];if(L[b+748>>2]){d=L[b+740>>2];f=L[L[e+8>>2]+8>>2];c=(d|0)==(f|0);g=b;b=L[L[e+12>>2]+8>>2];_a(g,(c?d:b)+4|0,(c?b:f)+4|0)}L[a+16>>2]=0;L[a+20>>2]=0}}function Bw(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0,g=0,h=0,i=0;f=fa-16|0;fa=f;L[f+12>>2]=a;L[f+8>>2]=b;h=L[f+8>>2];a=fa-80|0;fa=a;e=L[f+12>>2];L[e+68>>2]=L[e+68>>2]+1;b=L[e+64>>2];if(b){fc(b,L[(L[e+24>>2]+R(h,80)|0)+76>>2])}c=L[e+16>>2];g=L[e+24>>2];i=R(h,80);b=g+i|0;d=L[b+12>>2];L[a+8>>2]=L[b+8>>2];L[a+12>>2]=d;d=L[b+4>>2];L[a>>2]=L[b>>2];L[a+4>>2]=d;d=L[b+28>>2];L[a+24>>2]=L[b+24>>2];L[a+28>>2]=d;d=L[b+20>>2];L[a+16>>2]=L[b+16>>2];L[a+20>>2]=d;d=L[b+44>>2];L[a+40>>2]=L[b+40>>2];L[a+44>>2]=d;d=L[b+36>>2];L[a+32>>2]=L[b+32>>2];L[a+36>>2]=d;d=L[b+60>>2];L[a+56>>2]=L[b+56>>2];L[a+60>>2]=d;d=L[b+52>>2];L[a+48>>2]=L[b+48>>2];L[a+52>>2]=d;d=L[b+76>>2];L[a+72>>2]=L[b+72>>2];L[a+76>>2]=d;d=L[b+68>>2];L[a+64>>2]=L[b+64>>2];L[a+68>>2]=d;d=g;g=R(c,80)-80|0;c=d+g|0;d=L[c+4>>2];L[b>>2]=L[c>>2];L[b+4>>2]=d;d=L[c+12>>2];L[b+8>>2]=L[c+8>>2];L[b+12>>2]=d;d=L[c+20>>2];L[b+16>>2]=L[c+16>>2];L[b+20>>2]=d;d=L[c+28>>2];L[b+24>>2]=L[c+24>>2];L[b+28>>2]=d;d=L[c+44>>2];L[b+40>>2]=L[c+40>>2];L[b+44>>2]=d;d=L[c+36>>2];L[b+32>>2]=L[c+32>>2];L[b+36>>2]=d;d=L[c+52>>2];L[b+48>>2]=L[c+48>>2];L[b+52>>2]=d;d=L[c+60>>2];L[b+56>>2]=L[c+56>>2];L[b+60>>2]=d;d=L[c+76>>2];L[b+72>>2]=L[c+72>>2];L[b+76>>2]=d;d=L[c+68>>2];L[b+64>>2]=L[c+64>>2];L[b+68>>2]=d;c=L[a+4>>2];b=g+L[e+24>>2]|0;L[b>>2]=L[a>>2];L[b+4>>2]=c;c=L[a+12>>2];L[b+8>>2]=L[a+8>>2];L[b+12>>2]=c;c=L[a+20>>2];L[b+16>>2]=L[a+16>>2];L[b+20>>2]=c;c=L[a+28>>2];L[b+24>>2]=L[a+24>>2];L[b+28>>2]=c;c=L[a+36>>2];L[b+32>>2]=L[a+32>>2];L[b+36>>2]=c;c=L[a+44>>2];L[b+40>>2]=L[a+40>>2];L[b+44>>2]=c;c=L[a+52>>2];L[b+48>>2]=L[a+48>>2];L[b+52>>2]=c;c=L[a+60>>2];L[b+56>>2]=L[a+56>>2];L[b+60>>2]=c;c=L[a+68>>2];L[b+64>>2]=L[a+64>>2];L[b+68>>2]=c;c=L[a+76>>2];L[b+72>>2]=L[a+72>>2];L[b+76>>2]=c;if(L[e+64>>2]){L[L[(i+L[e+24>>2]|0)+76>>2]+36>>2]=h}L[e+16>>2]=L[e+16>>2]-1;fa=a+80|0;fa=f+16|0}function yn(a){var b=0,c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;a:{l=L[a+36>>2];b=L[a+12>>2];if((l|0)>=(b|0)){break a}b:{if((b|0)<=L[a+40>>2]){d=L[a+44>>2];break b}if(b){L[8513]=L[8513]+1;d=ha[L[6798]](b<<2,16)|0;c=L[a+36>>2]}else{c=l}g=L[a+44>>2];c:{if((c|0)>0){if(c>>>0>=4){j=c&-4;while(1){e=f<<2;L[e+d>>2]=L[e+g>>2];h=e|4;L[h+d>>2]=L[g+h>>2];h=e|8;L[h+d>>2]=L[g+h>>2];e=e|12;L[e+d>>2]=L[e+g>>2];f=f+4|0;i=i+4|0;if((j|0)!=(i|0)){continue}break}}c=c&3;if(!c){break c}while(1){e=f<<2;L[e+d>>2]=L[e+g>>2];f=f+1|0;k=k+1|0;if((c|0)!=(k|0)){continue}break}break c}if(g){break c}L[a+44>>2]=d;L[a+40>>2]=b;J[a+48|0]=1;break b}if(g?M[a+48|0]:0){L[8514]=L[8514]+1;ha[L[6799]](g)}L[a+44>>2]=d;J[a+48|0]=1;L[a+40>>2]=b}c=l<<2;j=b<<2;pa(c+d|0,0,j-c|0);L[a+36>>2]=b;g=L[a+56>>2];if((g|0)<(b|0)){d:{if((b|0)<=L[a+60>>2]){d=L[a- -64>>2];break d}e:{if(!b){d=0;c=g;break e}L[8513]=L[8513]+1;d=ha[L[6798]](j,16)|0;c=L[a+56>>2]}e=L[a- -64>>2];f:{if((c|0)>0){k=0;f=0;if(c>>>0>=4){n=c&-4;i=0;while(1){h=f<<2;L[h+d>>2]=L[e+h>>2];m=h|4;L[m+d>>2]=L[e+m>>2];m=h|8;L[m+d>>2]=L[e+m>>2];h=h|12;L[h+d>>2]=L[e+h>>2];f=f+4|0;i=i+4|0;if((n|0)!=(i|0)){continue}break}}c=c&3;if(!c){break f}while(1){i=f<<2;L[i+d>>2]=L[e+i>>2];f=f+1|0;k=k+1|0;if((c|0)!=(k|0)){continue}break}break f}if(e){break f}L[a+64>>2]=d;L[a+60>>2]=b;J[a+68|0]=1;break d}if(e?M[a+68|0]:0){L[8514]=L[8514]+1;ha[L[6799]](e)}L[a+64>>2]=d;J[a+68|0]=1;L[a+60>>2]=b}c=g<<2;pa(c+d|0,0,j-c|0)}L[a+56>>2]=b;if((b|0)>0){pa(L[a+44>>2],255,j);pa(L[a- -64>>2],255,j)}if((l|0)<=0){break a}c=L[a- -64>>2];g=L[a+16>>2];d=L[a+44>>2];f=0;while(1){b=g+(f<<4)|0;b=L[L[b+4>>2]+12>>2]<<16|L[L[b>>2]+12>>2];b=(b<<15^-1)+b|0;b=R(b>>10^b,9);b=b>>6^b;b=(b<<11^-1)+b|0;b=d+((L[a+12>>2]-1&(b>>16^b))<<2)|0;L[c+(f<<2)>>2]=L[b>>2];L[b>>2]=f;f=f+1|0;if((l|0)!=(f|0)){continue}break}}}function KD(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0,g=0,h=S(0),i=0,j=0,k=0,l=0,m=S(0),n=0,o=0,p=0,q=0,r=S(0),s=S(0),t=S(0),u=0,v=S(0),w=0;i=fa-2048|0;fa=i;a:{if((d|0)<=0){break a}if(d>>>0>=8){l=d&-8;while(1){e=f<<4;L[(e+c|0)+12>>2]=-581039253;L[((e|16)+c|0)+12>>2]=-581039253;L[((e|32)+c|0)+12>>2]=-581039253;L[((e|48)+c|0)+12>>2]=-581039253;L[((e|64)+c|0)+12>>2]=-581039253;L[((e|80)+c|0)+12>>2]=-581039253;L[((e|96)+c|0)+12>>2]=-581039253;L[((e|112)+c|0)+12>>2]=-581039253;f=f+8|0;j=j+8|0;if((l|0)!=(j|0)){continue}break}}e=d&7;if(e){while(1){L[((f<<4)+c|0)+12>>2]=-581039253;f=f+1|0;g=g+1|0;if((e|0)!=(g|0)){continue}break}}if((d|0)<=0){break a}while(1){if((ha[L[L[a>>2]+96>>2]](a)|0)>0){e=p<<4;q=e+b|0;l=c+e|0;n=0;while(1){g=128;b:{c:{if(((ha[L[L[a>>2]+96>>2]](a)|0)-n|0)>127){break c}g=(ha[L[L[a>>2]+96>>2]](a)|0)-n|0;if((g|0)>0){break c}h=S(-34028234663852886e22);g=-1;break b}e=0;j=(g|0)==1;if(!j){k=g&-2;f=0;while(1){ha[L[L[a>>2]+108>>2]](a,e,(e<<4)+i|0);o=e|1;ha[L[L[a>>2]+108>>2]](a,o,(o<<4)+i|0);e=e+2|0;f=f+2|0;if((k|0)!=(f|0)){continue}break}}o=g&1;if(o){ha[L[L[a>>2]+108>>2]](a,e,(e<<4)+i|0)}m=P[q+8>>2];r=P[q+4>>2];s=P[q>>2];d:{if(j){e=0;g=-1;h=S(-34028234663852886e22);break d}w=g&-2;e=0;g=-1;h=S(-34028234663852886e22);j=0;while(1){f=(e<<4)+i|0;t=S(S(P[f+8>>2]*m)+S(S(P[f>>2]*s)+S(r*P[f+4>>2])));f=t>h;u=e|1;k=(u<<4)+i|0;v=S(S(P[k+8>>2]*m)+S(S(P[k>>2]*s)+S(r*P[k+4>>2])));h=f?t:h;k=v>h;h=k?v:h;g=k?u:f?e:g;e=e+2|0;j=j+2|0;if((w|0)!=(j|0)){continue}break}}if(!o){break b}f=(e<<4)+i|0;m=S(S(P[f+8>>2]*m)+S(S(P[f>>2]*s)+S(r*P[f+4>>2])));f=m>h;h=f?m:h;g=f?e:g}if(P[l+12>>2]>2]=L[e+8>>2];g=L[e+4>>2];L[l>>2]=L[e>>2];L[l+4>>2]=g;P[l+12>>2]=h}n=n+128|0;if((ha[L[L[a>>2]+96>>2]](a)|0)>(n|0)){continue}break}}p=p+1|0;if((p|0)!=(d|0)){continue}break}}fa=i+2048|0}function lB(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=S(0),g=S(0),h=0,i=S(0),j=S(0),k=S(0),l=0,m=S(0),n=S(0),o=S(0),p=0,q=0,r=S(0),s=S(0),t=S(0),u=S(0),v=0,w=0,x=S(0),y=S(0),z=S(0);e=L[a+28>>2];d=L[a+32>>2];c=L[b+8>>2];L[c>>2]=1065353216;p=L[b+24>>2];l=p<<2;v=l+4|0;L[c+v>>2]=1065353216;q=p<<3;w=q+8|0;L[c+w>>2]=1065353216;m=P[e+24>>2];n=P[e+28>>2];o=P[e+40>>2];g=P[a+304>>2];j=P[e+44>>2];f=P[a+308>>2];k=P[e+12>>2];r=P[e+4>>2];s=P[e+8>>2];t=P[e+20>>2];u=P[e+36>>2];i=P[a+300>>2];c=L[b+12>>2];L[c+12>>2]=0;L[c>>2]=0;o=S(S(j*f)+S(S(u*i)+S(g*o)));P[c+4>>2]=o;m=S(S(n*f)+S(S(t*i)+S(g*m)));P[c+8>>2]=-m;h=c+l|0;L[h+12>>2]=0;n=S(S(k*f)+S(S(r*i)+S(s*g)));P[h+8>>2]=n;L[h+4>>2]=0;P[h>>2]=-o;c=c+q|0;L[c+8>>2]=0;L[c+12>>2]=0;P[c+4>>2]=-n;P[c>>2]=m;c=L[b+16>>2];L[c>>2]=-1082130432;L[c+v>>2]=-1082130432;L[c+w>>2]=-1082130432;k=P[d+40>>2];r=P[d+44>>2];j=P[d+24>>2];g=P[a+320>>2];s=P[d+28>>2];f=P[a+324>>2];t=P[d+12>>2];u=P[d+4>>2];x=P[d+8>>2];y=P[d+36>>2];z=P[d+20>>2];i=P[a+316>>2];c=L[b+20>>2];L[c+12>>2]=0;L[c>>2]=0;j=S(S(s*f)+S(S(z*i)+S(g*j)));P[c+8>>2]=j;k=S(S(r*f)+S(S(y*i)+S(g*k)));P[c+4>>2]=-k;h=c+l|0;L[h+12>>2]=0;g=S(S(t*f)+S(S(u*i)+S(x*g)));P[h+8>>2]=-g;L[h+4>>2]=0;P[h>>2]=k;c=c+q|0;L[c+8>>2]=0;L[c+12>>2]=0;P[c+4>>2]=g;P[c>>2]=-j;c=L[b+28>>2];h=L[a+332>>2];f=S(P[(h&1?a+336|0:b+4|0)>>2]*P[b>>2]);P[c>>2]=f*S(S(S(g+P[d+52>>2])-n)-P[e+52>>2]);P[c+l>>2]=f*S(S(S(j+P[d+56>>2])-m)-P[e+56>>2]);P[c+q>>2]=f*S(S(S(k+P[d+60>>2])-o)-P[e+60>>2]);e=p<<1;if(h&2){d=L[b+32>>2];P[d>>2]=P[a+340>>2];P[d+l>>2]=P[a+340>>2];P[d+(e<<2)>>2]=P[a+340>>2]}f=P[a+356>>2];a:{if(!(f>S(0))){break a}i=S(-f);P[L[b+36>>2]>>2]=i;P[L[b+40>>2]>>2]=f;g=P[a+356>>2];if(g>S(0)){d=p<<2;P[d+L[b+36>>2]>>2]=i;P[d+L[b+40>>2]>>2]=f;g=P[a+356>>2]}if(!(g>S(0))){break a}e=e<<2;P[e+L[b+36>>2]>>2]=i;P[e+L[b+40>>2]>>2]=f}P[b+52>>2]=P[a+352>>2]}function QC(a,b,c){a=a|0;b=S(b);c=c|0;var d=S(0),e=0,f=S(0),g=S(0),h=S(0),i=S(0),j=S(0),k=0,l=S(0),m=0,n=S(0),o=S(0),p=S(0);k=fa-16|0;fa=k;ha[L[L[a>>2]+112>>2]](a);L[c+8>>2]=0;L[c+12>>2]=0;L[c>>2]=0;L[c+4>>2]=0;m=ha[L[L[a>>2]+88>>2]](a)|0;if(m){p=S(b/S(m|0));while(1){m=m-1|0;e=L[L[a+184>>2]+(m<<2)>>2];ha[L[L[e>>2]+32>>2]](e,p,k);a:{if(ha[L[L[a>>2]+92>>2]](a)|0){e=L[a+164>>2]+(m<<6)|0;b=P[e+8>>2];f=P[k+8>>2];j=S(b*S(b*f));b=P[e>>2];g=P[k>>2];d=S(b*S(b*g));b=P[e+4>>2];i=P[k+4>>2];d=S(j+S(d+S(b*S(b*i))));b=P[e+52>>2];l=S(b*b);b=P[e+56>>2];j=S(b*b);b=S(d*S(l+j));h=P[e+40>>2];d=S(h*S(f*h));h=P[e+32>>2];n=S(h*S(g*h));h=P[e+36>>2];d=S(d+S(n+S(h*S(i*h))));h=P[e+48>>2];h=S(h*h);l=S(d*S(h+l));d=P[e+24>>2];d=S(d*S(f*d));f=P[e+16>>2];g=S(f*S(g*f));f=P[e+20>>2];f=S(S(d+S(g+S(f*S(i*f))))*S(h+j));break a}b:{if(J[30088]&1){l=P[7519];f=P[7518];b=P[7520];break b}if(!(J[30140]&1)){L[7524]=0;L[7525]=0;L[7523]=1065353216;J[30140]=1;L[7526]=0;L[7527]=0;L[7529]=0;L[7530]=0;L[7528]=1065353216;L[7531]=0;L[7532]=0;L[7533]=1065353216;L[7534]=0}L[7518]=0;L[7519]=0;J[30088]=1;e=L[7524];L[7506]=L[7523];L[7507]=e;e=L[7528];L[7510]=L[7527];L[7511]=e;e=L[7532];L[7514]=L[7531];L[7515]=e;L[7520]=0;L[7521]=0;e=L[7526];L[7508]=L[7525];L[7509]=e;e=L[7530];L[7512]=L[7529];L[7513]=e;e=L[7534];L[7516]=L[7533];L[7517]=e;l=S(0);f=S(0);b=S(0)}g=P[7516];d=g;g=P[k+8>>2];i=P[7514];n=i;i=P[k>>2];j=P[7515];o=j;j=P[k+4>>2];f=S(f*f);h=S(l*l);l=S(S(S(d*S(d*g))+S(S(n*S(n*i))+S(o*S(o*j))))*S(f+h));d=P[7512];n=S(d*S(g*d));d=P[7510];o=S(d*S(i*d));d=P[7511];b=S(b*b);f=S(S(n+S(o+S(d*S(j*d))))*S(f+b));d=P[7508];d=S(d*S(d*g));g=P[7506];i=S(g*S(g*i));g=P[7507];b=S(S(d+S(i+S(g*S(g*j))))*S(h+b))}L[c+12>>2]=0;P[c+8>>2]=l+P[c+8>>2];P[c+4>>2]=P[c+4>>2]+f;P[c>>2]=P[c>>2]+b;if(m){continue}break}}ha[L[L[a>>2]+116>>2]](a);fa=k+16|0}function dh(a){var b=0,c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;a:{l=L[a+32>>2];b=L[a+12>>2];if((l|0)>=(b|0)){break a}b:{if((b|0)<=L[a+36>>2]){d=L[a+40>>2];break b}if(b){L[8513]=L[8513]+1;d=ha[L[6798]](b<<2,16)|0;c=L[a+32>>2]}else{c=l}g=L[a+40>>2];c:{if((c|0)>0){if(c>>>0>=4){j=c&-4;while(1){e=f<<2;L[e+d>>2]=L[e+g>>2];h=e|4;L[h+d>>2]=L[g+h>>2];h=e|8;L[h+d>>2]=L[g+h>>2];e=e|12;L[e+d>>2]=L[e+g>>2];f=f+4|0;i=i+4|0;if((j|0)!=(i|0)){continue}break}}c=c&3;if(!c){break c}while(1){e=f<<2;L[e+d>>2]=L[e+g>>2];f=f+1|0;k=k+1|0;if((c|0)!=(k|0)){continue}break}break c}if(g){break c}L[a+40>>2]=d;L[a+36>>2]=b;J[a+44|0]=1;break b}if(g?M[a+44|0]:0){L[8514]=L[8514]+1;ha[L[6799]](g)}L[a+40>>2]=d;J[a+44|0]=1;L[a+36>>2]=b}c=l<<2;j=b<<2;pa(c+d|0,0,j-c|0);L[a+32>>2]=b;g=L[a+52>>2];if((g|0)<(b|0)){d:{if((b|0)<=L[a+56>>2]){d=L[a+60>>2];break d}e:{if(!b){d=0;c=g;break e}L[8513]=L[8513]+1;d=ha[L[6798]](j,16)|0;c=L[a+52>>2]}e=L[a+60>>2];f:{if((c|0)>0){k=0;f=0;if(c>>>0>=4){n=c&-4;i=0;while(1){h=f<<2;L[h+d>>2]=L[e+h>>2];m=h|4;L[m+d>>2]=L[e+m>>2];m=h|8;L[m+d>>2]=L[e+m>>2];h=h|12;L[h+d>>2]=L[e+h>>2];f=f+4|0;i=i+4|0;if((n|0)!=(i|0)){continue}break}}c=c&3;if(!c){break f}while(1){i=f<<2;L[i+d>>2]=L[e+i>>2];f=f+1|0;k=k+1|0;if((c|0)!=(k|0)){continue}break}break f}if(e){break f}L[a+60>>2]=d;L[a+56>>2]=b;J[a- -64|0]=1;break d}if(e?M[a- -64|0]:0){L[8514]=L[8514]+1;ha[L[6799]](e)}L[a+60>>2]=d;J[a+64|0]=1;L[a+56>>2]=b}c=g<<2;pa(c+d|0,0,j-c|0)}L[a+52>>2]=b;if((b|0)>0){pa(L[a+40>>2],255,j);pa(L[a+60>>2],255,j)}if((l|0)<=0){break a}c=L[a+60>>2];g=L[a+16>>2];d=L[a+40>>2];f=0;while(1){b=g+R(f,12)|0;b=L[b+4>>2]<<16|L[b>>2];b=(b<<15^-1)+b|0;b=R(b>>10^b,9);b=b>>6^b;b=(b<<11^-1)+b|0;b=d+((L[a+12>>2]-1&(b>>16^b))<<2)|0;L[c+(f<<2)>>2]=L[b>>2];L[b>>2]=f;f=f+1|0;if((l|0)!=(f|0)){continue}break}}}function Dg(a,b,c,d,e,f,g){var h=S(0),i=S(0),j=S(0),k=S(0),l=S(0),m=S(0),n=S(0),o=S(0),p=S(0),q=S(0),r=S(0),s=S(0),t=S(0),u=S(0),v=S(0),w=S(0),x=S(0),y=S(0),z=S(0),A=S(0),B=S(0),C=S(0),D=S(0),E=S(0);L[e>>2]=0;L[e+4>>2]=0;L[e+32>>2]=0;L[e+24>>2]=0;L[e+28>>2]=0;L[e+16>>2]=0;L[e+20>>2]=0;L[e+8>>2]=0;L[e+12>>2]=0;L[f+4>>2]=c;L[f>>2]=a;l=P[d+20>>2];m=P[d+36>>2];h=P[b+20>>2];i=P[b+36>>2];n=P[d+24>>2];o=P[b+24>>2];p=P[d+40>>2];q=P[b+40>>2];j=P[d+32>>2];r=P[d>>2];s=P[d+16>>2];t=P[d+4>>2];u=P[b+32>>2];v=P[b>>2];w=P[b+16>>2];x=P[b+4>>2];y=P[d+8>>2];k=P[b+8>>2];L[f+52>>2]=0;L[f+36>>2]=0;L[f+20>>2]=0;P[f+48>>2]=S(p*q)+S(S(y*k)+S(o*n));P[f+44>>2]=S(p*i)+S(S(y*x)+S(h*n));P[f+40>>2]=S(p*u)+S(S(y*v)+S(w*n));P[f+32>>2]=S(m*q)+S(S(t*k)+S(o*l));P[f+28>>2]=S(m*i)+S(S(t*x)+S(h*l));P[f+24>>2]=S(m*u)+S(S(t*v)+S(w*l));P[f+16>>2]=S(j*q)+S(S(r*k)+S(s*o));P[f+12>>2]=S(j*i)+S(S(r*x)+S(s*h));P[f+8>>2]=S(j*u)+S(S(r*v)+S(s*w));B=P[b+52>>2];C=P[d+52>>2];D=P[b+56>>2];z=P[d+56>>2];l=P[b+20>>2];m=P[b+36>>2];r=P[d+20>>2];s=P[d+36>>2];h=P[b+24>>2];t=P[d+24>>2];i=P[b+40>>2];u=P[d+40>>2];E=P[b+48>>2];A=P[d+48>>2];n=P[b+32>>2];o=P[b>>2];p=P[b+16>>2];q=P[b+4>>2];v=P[d+32>>2];w=P[d>>2];x=P[d+16>>2];y=P[d+4>>2];j=P[b+8>>2];k=P[d+8>>2];L[f+124>>2]=0;L[f+120>>2]=g?770:771;L[f+116>>2]=0;L[f+100>>2]=0;L[f+84>>2]=0;L[f+68>>2]=0;P[f+96>>2]=S(i*u)+S(S(j*k)+S(t*h));P[f+92>>2]=S(i*s)+S(S(j*y)+S(r*h));P[f+88>>2]=S(i*v)+S(S(j*w)+S(x*h));P[f+80>>2]=S(m*u)+S(S(q*k)+S(t*l));P[f+76>>2]=S(m*s)+S(S(q*y)+S(r*l));P[f+72>>2]=S(m*v)+S(S(q*w)+S(x*l));P[f- -64>>2]=S(n*u)+S(S(o*k)+S(p*t));P[f+60>>2]=S(n*s)+S(S(o*y)+S(p*r));P[f+56>>2]=S(n*v)+S(S(o*w)+S(p*x));k=i;i=S(z-D);z=j;j=S(A-E);A=h;h=S(C-B);P[f+112>>2]=S(k*i)+S(S(z*j)+S(A*h));P[f+108>>2]=S(m*i)+S(S(q*j)+S(h*l));P[f+104>>2]=S(n*i)+S(S(o*j)+S(h*p))}function Kg(a,b,c){var d=0,e=0,f=0,g=0,h=0,i=0,j=0;L[a+4>>2]=1065353216;L[a+8>>2]=1065353216;L[a+48>>2]=0;J[a+36|0]=1;L[a+12>>2]=1065353216;L[a+16>>2]=0;L[a+32>>2]=0;L[a+24>>2]=0;L[a+28>>2]=0;J[a+100|0]=1;L[a>>2]=16836;L[a+96>>2]=0;J[a+120|0]=1;L[a+88>>2]=0;L[a+92>>2]=0;L[a+116>>2]=0;J[a+140|0]=1;L[a+108>>2]=0;L[a+112>>2]=0;L[a+136>>2]=0;J[a+160|0]=1;L[a+128>>2]=0;L[a+132>>2]=0;L[a+168>>2]=0;J[a+164|0]=b;L[a+148>>2]=0;L[a+152>>2]=0;L[a+156>>2]=0;J[a+165|0]=c;L[8513]=L[8513]+1;f=ha[L[6798]](32,16)|0;h=L[a+24>>2];a:{if((h|0)<=0){break a}if((h|0)!=1){j=h&-2;while(1){e=d<<5;c=f+e|0;b=L[a+32>>2]+e|0;g=L[b+4>>2];L[c>>2]=L[b>>2];L[c+4>>2]=g;g=L[b+28>>2];L[c+24>>2]=L[b+24>>2];L[c+28>>2]=g;g=L[b+20>>2];L[c+16>>2]=L[b+16>>2];L[c+20>>2]=g;g=L[b+12>>2];L[c+8>>2]=L[b+8>>2];L[c+12>>2]=g;b=e|32;c=b+f|0;b=b+L[a+32>>2]|0;e=L[b+4>>2];L[c>>2]=L[b>>2];L[c+4>>2]=e;e=L[b+12>>2];L[c+8>>2]=L[b+8>>2];L[c+12>>2]=e;e=L[b+20>>2];L[c+16>>2]=L[b+16>>2];L[c+20>>2]=e;e=L[b+28>>2];L[c+24>>2]=L[b+24>>2];L[c+28>>2]=e;d=d+2|0;i=i+2|0;if((i|0)!=(j|0)){continue}break}}if(!(h&1)){break a}b=d<<5;c=b+f|0;b=b+L[a+32>>2]|0;d=L[b+4>>2];L[c>>2]=L[b>>2];L[c+4>>2]=d;d=L[b+28>>2];L[c+24>>2]=L[b+24>>2];L[c+28>>2]=d;d=L[b+20>>2];L[c+16>>2]=L[b+16>>2];L[c+20>>2]=d;d=L[b+12>>2];L[c+8>>2]=L[b+8>>2];L[c+12>>2]=d}b=L[a+32>>2];if(!(b?!b|!M[a+36|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+32>>2]=f;J[a+36|0]=1;L[a+28>>2]=1;b=f+(L[a+24>>2]<<5)|0;L[b+24>>2]=2;L[b+28>>2]=0;L[b+16>>2]=0;L[b+20>>2]=16;L[b+8>>2]=12;L[b+12>>2]=0;L[b>>2]=0;L[b+4>>2]=0;L[a+24>>2]=L[a+24>>2]+1;c=M[a+164|0];f=L[(c?a+128|0:a+148|0)>>2];b=L[a+32>>2];L[b+24>>2]=c?2:3;L[b+4>>2]=0;d=12;L[b+8>>2]=c?12:6;L[b>>2]=(f|0)/3;b:{if(M[a+165|0]){d=16;a=L[a+88>>2];break b}a=L[a+108>>2]/3|0}L[b+20>>2]=d;L[b+16>>2]=0;L[b+12>>2]=a}function GE(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=S(0),g=S(0),h=S(0),i=S(0),j=S(0),k=S(0),l=S(0),m=S(0),n=S(0),o=S(0),p=S(0),q=S(0),r=0,s=0,t=0,u=S(0),v=S(0),w=S(0),x=S(0),y=0;e=fa-80|0;fa=e;x=S(ha[L[L[a>>2]+48>>2]](a));while(1){L[e+72>>2]=0;L[e+76>>2]=0;L[e+64>>2]=0;L[e+68>>2]=0;s=t<<2;y=s+(e- -64|0)|0;L[y>>2]=1065353216;i=P[b+32>>2];j=P[b>>2];k=P[b+16>>2];l=P[b+36>>2];m=P[b+4>>2];n=P[b+20>>2];f=P[b+40>>2];g=P[b+8>>2];h=P[b+24>>2];L[e+44>>2]=0;o=f;f=P[e+72>>2];p=g;g=P[e+64>>2];q=h;h=P[e+68>>2];P[e+40>>2]=S(o*f)+S(S(p*g)+S(q*h));P[e+36>>2]=S(l*f)+S(S(m*g)+S(h*n));P[e+32>>2]=S(i*f)+S(S(j*g)+S(k*h));r=e+32|0;ha[L[L[a>>2]+64>>2]](e+48|0,a,r);i=P[b+48>>2];j=P[b+8>>2];k=P[b>>2];l=P[b+4>>2];m=P[b+52>>2];n=P[b+24>>2];p=P[b+16>>2];q=P[b+20>>2];f=P[b+56>>2];g=P[b+40>>2];h=P[b+32>>2];u=P[b+36>>2];L[e+44>>2]=0;o=f;f=P[e+56>>2];v=S(g*f);g=P[e+48>>2];w=S(h*g);h=P[e+52>>2];P[e+40>>2]=o+S(v+S(w+S(u*h)));P[e+36>>2]=m+S(S(f*n)+S(S(g*p)+S(h*q)));P[e+32>>2]=i+S(S(f*j)+S(S(g*k)+S(h*l)));r=s+r|0;P[d+s>>2]=x+P[r>>2];L[y>>2]=-1082130432;i=P[b+32>>2];j=P[b>>2];k=P[b+16>>2];l=P[b+36>>2];m=P[b+4>>2];n=P[b+20>>2];f=P[b+40>>2];g=P[b+8>>2];h=P[b+24>>2];L[e+12>>2]=0;o=f;f=P[e+72>>2];p=g;g=P[e+64>>2];q=h;h=P[e+68>>2];P[e+8>>2]=S(o*f)+S(S(p*g)+S(q*h));P[e+4>>2]=S(l*f)+S(S(m*g)+S(h*n));P[e>>2]=S(i*f)+S(S(j*g)+S(k*h));ha[L[L[a>>2]+64>>2]](e+16|0,a,e);i=P[b+48>>2];j=P[b+8>>2];k=P[b>>2];l=P[b+4>>2];m=P[b+52>>2];n=P[b+24>>2];p=P[b+16>>2];q=P[b+20>>2];f=P[b+56>>2];g=P[b+40>>2];h=P[b+32>>2];u=P[b+36>>2];L[e+44>>2]=0;o=f;f=P[e+24>>2];v=S(g*f);g=P[e+16>>2];w=S(h*g);h=P[e+20>>2];P[e+40>>2]=o+S(v+S(w+S(u*h)));P[e+36>>2]=m+S(S(f*n)+S(S(g*p)+S(h*q)));P[e+32>>2]=i+S(S(f*j)+S(S(g*k)+S(h*l)));P[c+s>>2]=P[r>>2]-x;t=t+1|0;if((t|0)!=3){continue}break}fa=e+80|0}function vB(a,b,c){a=a|0;b=b|0;c=c|0;cc(a,b,c);P[b+52>>2]=P[a+48>>2];P[b+56>>2]=P[a+52>>2];P[b+60>>2]=P[a+56>>2];P[b- -64>>2]=P[a+60>>2];P[b+68>>2]=P[a- -64>>2];P[b+72>>2]=P[a+68>>2];P[b+76>>2]=P[a+72>>2];P[b+80>>2]=P[a+76>>2];P[b+84>>2]=P[a+80>>2];P[b+88>>2]=P[a+84>>2];P[b+92>>2]=P[a+88>>2];P[b+96>>2]=P[a+92>>2];P[b+100>>2]=P[a+96>>2];P[b+104>>2]=P[a+100>>2];P[b+108>>2]=P[a+104>>2];P[b+112>>2]=P[a+108>>2];P[b+116>>2]=P[a+112>>2];P[b+120>>2]=P[a+116>>2];P[b+124>>2]=P[a+120>>2];P[b+128>>2]=P[a+124>>2];P[b+132>>2]=P[a+128>>2];P[b+136>>2]=P[a+132>>2];P[b+140>>2]=P[a+136>>2];P[b+144>>2]=P[a+140>>2];P[b+148>>2]=P[a+144>>2];P[b+152>>2]=P[a+148>>2];P[b+156>>2]=P[a+152>>2];P[b+160>>2]=P[a+156>>2];P[b+164>>2]=P[a+160>>2];P[b+168>>2]=P[a+164>>2];P[b+172>>2]=P[a+168>>2];P[b+176>>2]=P[a+172>>2];P[b+228>>2]=P[a+868>>2];P[b+212>>2]=P[a+872>>2];P[b+196>>2]=P[a+680>>2];P[b+180>>2]=P[a+696>>2];P[b+232>>2]=P[a+932>>2];P[b+216>>2]=P[a+936>>2];P[b+200>>2]=P[a+684>>2];P[b+184>>2]=P[a+700>>2];P[b+236>>2]=P[a+996>>2];P[b+220>>2]=P[a+1e3>>2];P[b+204>>2]=P[a+688>>2];P[b+188>>2]=P[a+704>>2];L[b+244>>2]=M[a+1300|0];L[b+248>>2]=M[a+1301|0];P[b+276>>2]=P[a+1316>>2];P[b+324>>2]=P[a+1364>>2];L[b+252>>2]=M[a+1309|0];P[b+300>>2]=P[a+1340>>2];P[b+280>>2]=P[a+1320>>2];P[b+328>>2]=P[a+1368>>2];L[b+256>>2]=M[a+1310|0];P[b+304>>2]=P[a+1344>>2];P[b+284>>2]=P[a+1324>>2];P[b+332>>2]=P[a+1372>>2];L[b+260>>2]=M[a+1311|0];P[b+308>>2]=P[a+1348>>2];P[b+288>>2]=P[a+1328>>2];P[b+336>>2]=P[a+1376>>2];L[b+264>>2]=M[a+1312|0];P[b+312>>2]=P[a+1352>>2];P[b+292>>2]=P[a+1332>>2];P[b+340>>2]=P[a+1380>>2];L[b+268>>2]=M[a+1313|0];P[b+316>>2]=P[a+1356>>2];P[b+296>>2]=P[a+1336>>2];P[b+344>>2]=P[a+1384>>2];L[b+272>>2]=M[a+1314|0];P[b+320>>2]=P[a+1360>>2];return 3370}function Ed(a,b,c){var d=0,e=S(0),f=S(0),g=S(0),h=0;if(!L[a>>2]){L[a>>2]=c;L[c+32>>2]=0;return}d=L[b+40>>2];if(d){f=S(P[c>>2]+P[c+16>>2]);e=S(P[c+8>>2]+P[c+24>>2]);g=S(P[c+4>>2]+P[c+20>>2]);while(1){h=b+36|0;b=L[b+36>>2];b=L[h+(!(S(S(S(T(S(f-S(P[b>>2]+P[b+16>>2]))))+S(T(S(g-S(P[b+4>>2]+P[b+20>>2])))))+S(T(S(e-S(P[b+8>>2]+P[b+24>>2])))))>2]+P[d+16>>2]))))+S(T(S(g-S(P[d+4>>2]+P[d+20>>2])))))+S(T(S(e-S(P[d+8>>2]+P[d+24>>2]))))))<<2)>>2];d=L[b+40>>2];if(d){continue}break}}h=L[b+32>>2];d=L[a+4>>2];a:{if(d){L[a+4>>2]=0;break a}L[8513]=L[8513]+1;d=ha[L[6798]](44,16)|0;L[d>>2]=0;L[d+4>>2]=0;L[d+40>>2]=0;L[d+32>>2]=0;L[d+36>>2]=0;L[d+24>>2]=0;L[d+28>>2]=0;L[d+16>>2]=0;L[d+20>>2]=0;L[d+8>>2]=0;L[d+12>>2]=0}L[d+36>>2]=0;L[d+40>>2]=0;L[d+32>>2]=h;f=P[c>>2];e=P[b>>2];P[d>>2]=e>f?f:e;f=P[c+16>>2];e=P[b+16>>2];P[d+16>>2]=e>2];e=P[b+4>>2];P[d+4>>2]=e>f?f:e;f=P[c+20>>2];e=P[b+20>>2];P[d+20>>2]=e>2];e=P[b+8>>2];P[d+8>>2]=e>f?f:e;f=P[c+24>>2];e=P[b+24>>2];P[d+24>>2]=e>2]+40>>2]==(b|0))<<2)+h|0)+36>>2]=d;L[d+36>>2]=b;L[b+32>>2]=d;L[d+40>>2]=c;L[c+32>>2]=d;f=P[d>>2];while(1){a=d;d=h;c:{if(!(P[d>>2]<=f)|!(P[d+4>>2]<=P[a+4>>2])|(!(P[d+8>>2]<=P[a+8>>2])|!(P[d+16>>2]>=P[a+16>>2]))){break c}if(!(P[d+20>>2]>=P[a+20>>2])){break c}if(P[d+24>>2]>=P[a+24>>2]){break b}}a=L[d+36>>2];f=P[a>>2];b=L[d+40>>2];e=P[b>>2];f=e>f?f:e;P[d>>2]=f;e=P[a+16>>2];g=P[b+16>>2];P[d+16>>2]=e>g?e:g;e=P[a+4>>2];g=P[b+4>>2];P[d+4>>2]=e>2];g=P[b+20>>2];P[d+20>>2]=e>g?e:g;e=P[a+8>>2];g=P[b+8>>2];P[d+8>>2]=e>2];g=P[b+24>>2];P[d+24>>2]=e>g?e:g;h=L[d+32>>2];if(h){continue}break}break b}L[d+36>>2]=b;L[b+32>>2]=d;L[d+40>>2]=c;L[c+32>>2]=d;L[a>>2]=d}}function cg(a,b,c){var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;g=L[a+56>>2];a:{if(g){break a}d=L[a+52>>2];b:{if(d){L[a+52>>2]=L[d+8>>2];g=L[d>>2];break b}L[8513]=L[8513]+1;d=ha[L[6798]](12,16)|0;e=L[a+60>>2];L[d+8>>2]=0;L[d+4>>2]=e;L[8513]=L[8513]+1;g=ha[L[6798]](R(e,24),16)|0;L[d>>2]=g;L[d+8>>2]=L[a+48>>2];L[a+48>>2]=d}h=L[d+4>>2];if((h|0)<=0){break a}e=g;if(h>>>0>=4){m=h&-4;d=g;while(1){e=d+96|0;j=i+4|0;L[d+72>>2]=(h|0)>(j|0)?e:0;L[d+48>>2]=(h|0)>(i|3)?d+72|0:0;L[d+24>>2]=(h|0)>(i|2)?d+48|0:0;L[d>>2]=(h|0)>(i|1)?d+24|0:0;i=j;d=e;f=f+4|0;if((m|0)!=(f|0)){continue}break}}d=h&3;if(!d){break a}while(1){f=e;e=e+24|0;j=j+1|0;L[f>>2]=(h|0)>(j|0)?e:0;l=l+1|0;if((d|0)!=(l|0)){continue}break}}L[a+56>>2]=L[g>>2];L[g+16>>2]=0;L[g+20>>2]=0;L[g+8>>2]=0;L[g+12>>2]=0;L[g>>2]=0;L[g+4>>2]=0;f=L[a+56>>2];c:{if(f){break c}d=L[a+52>>2];d:{if(d){L[a+52>>2]=L[d+8>>2];f=L[d>>2];break d}L[8513]=L[8513]+1;d=ha[L[6798]](12,16)|0;e=L[a+60>>2];L[d+8>>2]=0;L[d+4>>2]=e;L[8513]=L[8513]+1;f=ha[L[6798]](R(e,24),16)|0;L[d>>2]=f;L[d+8>>2]=L[a+48>>2];L[a+48>>2]=d}k=L[d+4>>2];if((k|0)<=0){break c}l=0;j=0;e=f;if(k>>>0>=4){m=k&-4;i=0;d=f;h=0;while(1){e=d+96|0;j=i+4|0;L[d+72>>2]=(k|0)>(j|0)?e:0;L[d+48>>2]=(i|3)<(k|0)?d+72|0:0;L[d+24>>2]=(i|2)<(k|0)?d+48|0:0;L[d>>2]=(i|1)<(k|0)?d+24|0:0;i=j;d=e;h=h+4|0;if((m|0)!=(h|0)){continue}break}}d=k&3;if(!d){break c}while(1){i=e;e=e+24|0;j=j+1|0;L[i>>2]=(k|0)>(j|0)?e:0;l=l+1|0;if((d|0)!=(l|0)){continue}break}}L[a+56>>2]=L[f>>2];L[f+16>>2]=0;L[f+20>>2]=0;L[f+8>>2]=0;L[f+12>>2]=0;L[f>>2]=0;L[f+4>>2]=0;L[g+8>>2]=f;L[f+8>>2]=g;e=L[a+100>>2];L[g+20>>2]=e;L[f+20>>2]=e;L[g+12>>2]=c;L[f+12>>2]=b;L[g+16>>2]=0;L[f+16>>2]=0;c=L[a+116>>2];b=c+1|0;L[a+116>>2]=b;if((c|0)>=L[a+120>>2]){L[a+120>>2]=b}return g}function nn(a){var b=0,c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;a:{l=L[a+4>>2];b=L[a+48>>2];if((l|0)>=(b|0)){break a}b:{if((b|0)<=L[a+8>>2]){d=L[a+12>>2];break b}if(b){L[8513]=L[8513]+1;d=ha[L[6798]](b<<2,16)|0;c=L[a+4>>2]}else{c=l}g=L[a+12>>2];c:{d:{if((c|0)>0){if(c>>>0>=4){j=c&-4;while(1){e=f<<2;L[e+d>>2]=L[e+g>>2];h=e|4;L[h+d>>2]=L[g+h>>2];h=e|8;L[h+d>>2]=L[g+h>>2];e=e|12;L[e+d>>2]=L[e+g>>2];f=f+4|0;i=i+4|0;if((j|0)!=(i|0)){continue}break}}c=c&3;if(!c){break d}while(1){e=f<<2;L[e+d>>2]=L[e+g>>2];f=f+1|0;k=k+1|0;if((c|0)!=(k|0)){continue}break}break d}if(g){break d}break c}if(g?M[a+16|0]:0){L[8514]=L[8514]+1;ha[L[6799]](g)}}L[a+12>>2]=d;J[a+16|0]=1;L[a+8>>2]=b}c=l<<2;j=b<<2;pa(c+d|0,0,j-c|0);L[a+4>>2]=b;g=L[a+24>>2];if((g|0)<(b|0)){e:{if((b|0)<=L[a+28>>2]){d=L[a+32>>2];break e}f:{if(!b){d=0;c=g;break f}L[8513]=L[8513]+1;d=ha[L[6798]](j,16)|0;c=L[a+24>>2]}e=L[a+32>>2];g:{if((c|0)>0){k=0;f=0;if(c>>>0>=4){n=c&-4;i=0;while(1){h=f<<2;L[h+d>>2]=L[e+h>>2];m=h|4;L[m+d>>2]=L[e+m>>2];m=h|8;L[m+d>>2]=L[e+m>>2];h=h|12;L[h+d>>2]=L[e+h>>2];f=f+4|0;i=i+4|0;if((n|0)!=(i|0)){continue}break}}c=c&3;if(!c){break g}while(1){i=f<<2;L[i+d>>2]=L[e+i>>2];f=f+1|0;k=k+1|0;if((c|0)!=(k|0)){continue}break}break g}if(e){break g}L[a+32>>2]=d;L[a+28>>2]=b;J[a+36|0]=1;break e}if(e?M[a+36|0]:0){L[8514]=L[8514]+1;ha[L[6799]](e)}L[a+32>>2]=d;J[a+36|0]=1;L[a+28>>2]=b}c=g<<2;pa(c+d|0,0,j-c|0)}L[a+24>>2]=b;if((b|0)>0){pa(L[a+12>>2],255,j);pa(L[a+32>>2],255,j)}if((l|0)<=0){break a}c=L[a+32>>2];g=L[a+72>>2];d=L[a+12>>2];f=0;while(1){b=L[g+(f<<3)>>2];b=(b<<15^-1)+b|0;b=R(b>>10^b,9);b=b>>6^b;b=(b<<11^-1)+b|0;b=d+((L[a+48>>2]-1&(b>>16^b))<<2)|0;L[c+(f<<2)>>2]=L[b>>2];L[b>>2]=f;f=f+1|0;if((l|0)!=(f|0)){continue}break}}}function hg(a){var b=0,c=0,d=0,e=0,f=S(0),g=0,h=0,i=S(0),j=S(0),k=0,l=0,m=S(0),n=S(0),o=S(0),p=S(0);h=L[a+752>>2];if((h|0)>0){l=L[a+760>>2];while(1){b=l+R(g,44)|0;e=L[b+12>>2];c=L[b+8>>2];f=P[c+8>>2];m=S(P[e+8>>2]-f);d=L[b+16>>2];i=P[c+12>>2];j=S(P[d+12>>2]-i);n=S(P[d+8>>2]-f);i=S(P[e+12>>2]-i);f=S(S(m*j)-S(n*i));o=S(f*f);p=i;f=P[c+16>>2];i=S(P[d+16>>2]-f);f=S(P[e+16>>2]-f);j=S(S(p*i)-S(j*f));f=S(S(f*n)-S(i*m));P[b+36>>2]=_(S(o+S(S(j*j)+S(f*f))));g=g+1|0;if((h|0)!=(g|0)){continue}break}}e=L[a+712>>2];a:{if((e|0)<=0){g=0;break a}b=0;L[8513]=L[8513]+1;e=e<<2;g=ha[L[6798]](e,16)|0;pa(g,0,e);e=L[a+712>>2];if((e|0)<=0){break a}c=L[a+720>>2];if(e>>>0>=8){h=e&-8;d=0;while(1){L[(c+R(b,104)|0)+92>>2]=0;L[(c+R(b|1,104)|0)+92>>2]=0;L[(c+R(b|2,104)|0)+92>>2]=0;L[(c+R(b|3,104)|0)+92>>2]=0;L[(c+R(b|4,104)|0)+92>>2]=0;L[(c+R(b|5,104)|0)+92>>2]=0;L[(c+R(b|6,104)|0)+92>>2]=0;L[(c+R(b|7,104)|0)+92>>2]=0;b=b+8|0;d=d+8|0;if((h|0)!=(d|0)){continue}break}}h=e&7;if(!h){break a}d=0;while(1){L[(c+R(b,104)|0)+92>>2]=0;b=b+1|0;d=d+1|0;if((h|0)!=(d|0)){continue}break}}h=L[a+752>>2];if((h|0)>0){b=L[a+720>>2];l=L[a+760>>2];e=0;while(1){c=R(e,44)+l|0;f=P[c+36>>2];d=L[c+8>>2];k=((d-b|0)/104<<2)+g|0;L[k>>2]=L[k>>2]+1;f=S(T(f));P[d+92>>2]=P[d+92>>2]+f;d=L[c+12>>2];k=((d-b|0)/104<<2)+g|0;L[k>>2]=L[k>>2]+1;P[d+92>>2]=P[d+92>>2]+f;c=L[c+16>>2];d=((c-b|0)/104<<2)+g|0;L[d>>2]=L[d>>2]+1;P[c+92>>2]=P[c+92>>2]+f;e=e+1|0;if((h|0)!=(e|0)){continue}break}e=L[a+712>>2]}b:{c:{if((e|0)>0){a=L[a+720>>2];b=0;while(1){c=L[(b<<2)+g>>2];d:{if((c|0)>0){d=a+R(b,104)|0;P[d+92>>2]=P[d+92>>2]/S(c|0);break d}L[(a+R(b,104)|0)+92>>2]=0}b=b+1|0;if((e|0)!=(b|0)){continue}break}break c}if(!g){break b}}if(g){L[8514]=L[8514]+1;ha[L[6799]](g)}}}function bH(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=S(0),f=S(0),g=S(0),h=S(0),i=S(0),j=S(0),k=S(0),l=S(0),m=S(0),n=S(0),o=S(0),p=S(0),q=S(0),r=S(0),s=S(0),t=0,u=S(0),v=S(0),w=S(0),x=S(0),y=S(0),z=S(0),A=0,B=0;c=fa-96|0;fa=c;e=P[a+76>>2];i=P[a+36>>2];f=P[a+32>>2];j=P[a+80>>2];n=P[a+52>>2];o=P[a+44>>2];p=P[a+48>>2];k=P[a+84>>2];q=P[a+68>>2];w=P[a+60>>2];x=P[a- -64>>2];y=P[a+28>>2];l=P[b+8>>2];g=P[b>>2];h=P[b+4>>2];L[c+92>>2]=0;u=S(k+S(S(l*q)+S(S(g*w)+S(h*x))));P[c+88>>2]=u;v=S(j+S(S(l*n)+S(S(g*o)+S(h*p))));P[c+84>>2]=v;l=S(e+S(S(l*i)+S(S(g*y)+S(h*f))));P[c+80>>2]=l;g=P[b+20>>2];h=P[b+24>>2];m=P[b+16>>2];L[c+76>>2]=0;z=S(k+S(S(h*q)+S(S(m*w)+S(x*g))));P[c+72>>2]=z;r=S(j+S(S(h*n)+S(S(m*o)+S(p*g))));P[c+68>>2]=r;s=S(e+S(S(h*i)+S(S(m*y)+S(f*g))));P[c+64>>2]=s;g=P[b+36>>2];h=P[b+40>>2];m=P[b+32>>2];L[c+60>>2]=0;k=S(k+S(S(h*q)+S(S(m*w)+S(x*g))));P[c+56>>2]=k;j=S(j+S(S(h*n)+S(S(m*o)+S(p*g))));P[c+52>>2]=j;e=S(e+S(S(h*i)+S(S(m*y)+S(f*g))));P[c+48>>2]=e;L[c+44>>2]=0;n=S(S(S(u+z)+k)*S(.3333333432674408));P[c+40>>2]=n;o=S(S(S(v+r)+j)*S(.3333333432674408));P[c+36>>2]=o;p=S(S(S(l+s)+e)*S(.3333333432674408));P[c+32>>2]=p;b=L[a+8>>2];if(ha[L[L[b>>2]+48>>2]](b)&16384){L[c+24>>2]=0;L[c+28>>2]=0;L[c+16>>2]=1065353216;L[c+20>>2]=1065353216;b=L[a+8>>2];L[c+12>>2]=0;i=S(s-l);f=S(j-v);j=S(e-l);q=S(r-v);e=S(S(i*f)-S(j*q));s=e;r=S(e*e);k=S(k-u);e=f;f=S(z-u);e=S(S(q*k)-S(e*f));i=S(S(f*j)-S(k*i));f=S(S(1)/S(_(S(r+S(S(e*e)+S(i*i))))));P[c+8>>2]=S(s*f)+n;P[c+4>>2]=S(i*f)+o;P[c>>2]=p+S(e*f);ha[L[L[b>>2]+8>>2]](b,c+32|0,c,c+16|0)}d=L[a+8>>2];A=c+80|0;t=c- -64|0;b=a+12|0;ha[L[L[d>>2]+8>>2]](d,A,t,b);d=L[a+8>>2];B=t;t=c+48|0;ha[L[L[d>>2]+8>>2]](d,B,t,b);a=L[a+8>>2];ha[L[L[a>>2]+8>>2]](a,t,A,b);fa=c+96|0}function iI(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=0,g=S(0),h=0,i=S(0),j=S(0),k=S(0),l=S(0),m=S(0),n=S(0),o=S(0),p=S(0),q=S(0);e=fa-48|0;fa=e;f=L[c+12>>2];L[e+24>>2]=L[c+8>>2];L[e+28>>2]=f;f=L[c+4>>2];L[e+16>>2]=L[c>>2];L[e+20>>2]=f;f=L[d+12>>2];L[e+40>>2]=L[d+8>>2];L[e+44>>2]=f;f=L[d+4>>2];L[e+32>>2]=L[d>>2];L[e+36>>2]=f;a:{if(L[b+60>>2]==2){fc(a- -64|0,L[b+48>>2]);L[b+48>>2]=Bb(a+4|0,e+16|0,b);h=1;break a}h=1;L[a+168>>2]=L[a+168>>2]+1;b:{f=L[b+48>>2];if(!(P[f>>2]<=P[e+32>>2])|!(P[f+16>>2]>=P[e+16>>2])|(!(P[f+4>>2]<=P[e+36>>2])|!(P[f+20>>2]>=P[e+20>>2]))){break b}if(!(P[f+8>>2]<=P[e+40>>2])|!(P[f+24>>2]>=P[e+24>>2])){break b}k=P[b+20>>2];l=P[b+24>>2];n=P[c>>2];o=P[c+4>>2];p=P[c+8>>2];m=P[b+16>>2];i=P[b+36>>2];j=P[b+40>>2];q=P[b+32>>2];g=P[a+140>>2];L[e+12>>2]=0;j=S(g*S(S(j-l)*S(.5)));P[e+8>>2]=j;i=S(g*S(S(i-k)*S(.5)));P[e+4>>2]=i;g=S(g*S(S(q-m)*S(.5)));P[e>>2]=g;if(S(n-m)>2]=-g}if(S(o-k)>2]=-i}if(S(p-l)>2]=-j}h=Dd(a+4|0,f,e+16|0,e,S(.05000000074505806));if(!h){break a}L[a+172>>2]=L[a+172>>2]+1;break a}Gc(a+4|0,f,e+16|0);L[a+172>>2]=L[a+172>>2]+1}f=L[b+52>>2];L[(f?f+56|0:((L[b+60>>2]<<2)+a|0)+124|0)>>2]=L[b+56>>2];f=L[b+56>>2];if(f){L[f+52>>2]=L[b+52>>2]}f=L[c+4>>2];L[b+16>>2]=L[c>>2];L[b+20>>2]=f;f=L[c+12>>2];L[b+24>>2]=L[c+8>>2];L[b+28>>2]=f;c=L[d+4>>2];L[b+32>>2]=L[d>>2];L[b+36>>2]=c;c=L[d+12>>2];L[b+40>>2]=L[d+8>>2];L[b+44>>2]=c;c=L[a+144>>2];L[b+60>>2]=c;L[b+52>>2]=0;c=(c<<2)+a|0;L[b+56>>2]=L[c+124>>2];d=L[c+124>>2];if(d){L[d+52>>2]=b}L[c+124>>2]=b;c:{if(!h){break c}J[a+194|0]=1;if(M[a+193|0]){break c}L[e>>2]=5824;L[e+4>>2]=a;c=a- -64|0;_e(c,L[c>>2],L[b+48>>2],e);_e(a+4|0,L[a+4>>2],L[b+48>>2],e)}fa=e+48|0}function sk(a,b,c,d,e,f){var g=S(0),h=S(0),i=S(0),j=S(0),k=S(0),l=S(0),m=S(0),n=S(0),o=S(0),p=S(0),q=S(0),r=S(0),s=S(0),t=S(0),u=S(0),v=S(0),w=S(0),x=S(0),y=S(0),z=S(0),A=S(0),B=S(0);l=P[e+40>>2];m=P[e+24>>2];j=P[e+36>>2];k=P[e+20>>2];g=P[f+4>>2];o=P[e+8>>2];r=P[e+4>>2];s=P[e+32>>2];h=P[f>>2];t=P[e>>2];i=P[f+8>>2];v=P[e+16>>2];L[a+44>>2]=0;L[a+28>>2]=0;L[a+12>>2]=0;w=S(S(s*g)+S(S(t*S(0))-S(v*i)));x=S(S(j*g)+S(S(r*S(0))-S(k*i)));y=S(S(l*g)+S(S(o*S(0))-S(m*i)));n=S(S(d-S(S(S(w*S(0))+S(i*x))-S(g*y)))+c);z=S(S(S(o*i)+S(m*S(0)))-S(l*h));A=S(S(S(r*i)+S(k*S(0)))-S(j*h));B=S(S(S(t*i)+S(v*S(0)))-S(s*h));q=S(S(d-S(S(h*z)+S(S(A*S(0))-S(i*B))))+c);p=S(S(S(0)-S(S(y*S(0))+S(S(g*w)-S(x*h))))+S(0));u=S(S(S(0)-S(S(S(B*S(0))+S(i*A))-S(g*z)))+S(0));o=S(S(l*S(0))+S(S(h*m)-S(o*g)));j=S(S(j*S(0))+S(S(h*k)-S(r*g)));k=S(S(s*S(0))+S(S(h*v)-S(t*g)));l=S(S(S(0)-S(S(h*o)+S(S(j*S(0))-S(i*k))))+S(0));m=S(S(S(0)-S(S(S(k*S(0))+S(i*j))-S(g*o)))+S(0));r=S(S(u*l)-S(m*q));j=S(S(d-S(S(o*S(0))+S(S(g*k)-S(j*h))))+c);g=S(S(S(0)-S(S(z*S(0))+S(S(g*B)-S(A*h))))+S(0));k=S(S(q*j)-S(l*g));d=S(S(S(0)-S(S(h*y)+S(S(x*S(0))-S(i*w))))+S(0));h=S(S(g*m)-S(j*u));c=S(S(1)/S(S(p*r)+S(S(n*k)+S(d*h))));i=S(S(S(n*q)-S(u*d))*c);b=S(S(1)/b);q=S(S(S(d*g)-S(q*p))*c);o=S(q*S(0));g=S(S(S(p*u)-S(g*n))*c);s=S(g*S(0));P[a+40>>2]=S(i*b)+S(o+s);t=S(S(S(d*m)-S(l*n))*c);d=S(S(S(p*l)-S(j*d))*c);l=S(d*S(0));n=S(S(S(n*j)-S(m*p))*c);p=S(n*S(0));P[a+36>>2]=S(t*b)+S(l+p);m=S(r*c);j=S(k*c);k=S(j*S(0));c=S(h*c);h=S(c*S(0));P[a+32>>2]=S(m*b)+S(k+h);i=S(i*S(0));P[a+24>>2]=i+S(o+S(b*g));g=S(t*S(0));P[a+20>>2]=g+S(l+S(b*n));n=S(m*S(0));P[a+16>>2]=n+S(k+S(b*c));P[a+8>>2]=i+S(S(q*b)+s);P[a+4>>2]=g+S(S(d*b)+p);P[a>>2]=n+S(S(j*b)+h)}function WG(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=S(0),g=S(0),h=S(0),i=0,j=0,k=0,l=0,m=S(0),n=0;a=fa-608|0;fa=a;g=S(P[b+124>>2]-P[b+60>>2]);h=S(g*g);g=S(P[b+116>>2]-P[b+52>>2]);f=S(g*g);g=S(P[b+120>>2]-P[b+56>>2]);f=S(h+S(f+S(g*g)));g=P[b+252>>2];a:{b:{if(f>2]-P[c+60>>2]);m=S(f*f);f=S(P[c+116>>2]-P[c+52>>2]);h=S(f*f);f=S(P[c+120>>2]-P[c+56>>2]);h=S(m+S(h+S(f*f)));f=P[c+252>>2];if(h>2];g=P[c+248>>2];d=a+556|0;L[d+4>>2]=35;L[d+8>>2]=0;L[d>>2]=14328;L[d+44>>2]=1025758986;L[d+12>>2]=1065353216;L[d+16>>2]=1065353216;L[d>>2]=14044;L[d+20>>2]=1065353216;L[d+24>>2]=0;P[d+44>>2]=g;P[d+28>>2]=g;L[d+4>>2]=8;L[d>>2]=16192;L[a+552>>2]=0;L[a+544>>2]=1566444395;L[a+548>>2]=0;L[a+380>>2]=6864;J[a+352|0]=0;L[a+328>>2]=953267991;e=a+4|0;L[e+12>>2]=d;L[e+8>>2]=i;L[e+4>>2]=a+20;L[e>>2]=18416;i=b+4|0;j=b+68|0;k=c+4|0;l=c+68|0;g=S(1);c:{if(!Eg(e,i,j,k,l,a+380|0)){break c}f=P[a+544>>2];if(f>2]){P[b+244>>2]=f}if(f>2]){P[c+244>>2]=f}g=S(1);if(!(f>2];f=P[b+248>>2];d=a+556|0;L[d+4>>2]=35;L[d+8>>2]=0;L[d>>2]=14328;L[d+44>>2]=1025758986;L[d+12>>2]=1065353216;L[d+16>>2]=1065353216;L[d>>2]=14044;L[d+20>>2]=1065353216;L[d+24>>2]=0;P[d+44>>2]=f;P[d+28>>2]=f;L[d+4>>2]=8;L[d>>2]=16192;L[a+552>>2]=0;L[a+544>>2]=1566444395;L[a+548>>2]=0;L[a+380>>2]=6864;J[a+352|0]=0;L[a+328>>2]=953267991;e=a+4|0;L[e+12>>2]=n;L[e+8>>2]=d;L[e+4>>2]=a+20;L[e>>2]=18416;d:{if(!Eg(e,i,j,k,l,a+380|0)){break d}f=P[a+544>>2];if(f>2]){P[b+244>>2]=f}if(f>2]){P[c+244>>2]=f}if(!(f>2]=a;L[g+8>>2]=b;a=L[g+8>>2];h=fa-16|0;fa=h;L[h+12>>2]=L[g+12>>2]+708;L[h+8>>2]=a;a=L[h+8>>2];b=fa-128|0;fa=b;L[b+124>>2]=L[h+12>>2];L[b+120>>2]=a;k=L[b+124>>2];a=fa-16|0;L[a+12>>2]=L[b+120>>2];L[b+116>>2]=L[L[a+12>>2]+4>>2];c=L[b+116>>2];e=b+12|0;pa(e,0,104);d=fa-16|0;fa=d;L[d+12>>2]=e;a=L[d+12>>2];Bh(a);L[(fa-16|0)+12>>2]=a+8;L[(fa-16|0)+12>>2]=a+24;L[(fa-16|0)+12>>2]=a+40;L[(fa-16|0)+12>>2]=a+56;L[(fa-16|0)+12>>2]=a+72;fa=d+16|0;a=fa-32|0;fa=a;L[a+28>>2]=k;L[a+24>>2]=c;L[a+20>>2]=e;d=fa-16|0;i=L[a+28>>2];L[d+12>>2]=i;L[a+16>>2]=L[L[d+12>>2]+4>>2];a:{if(L[a+24>>2]>2]){L[a+12>>2]=L[a+24>>2];while(1){if(L[a+12>>2]>2]){L[a+12>>2]=L[a+12>>2]+1;continue}break}break a}d=L[a+24>>2];e=fa-16|0;L[e+12>>2]=i;if(L[L[e+12>>2]+4>>2]<(d|0)){e=L[a+24>>2];d=fa-16|0;fa=d;L[d+12>>2]=i;L[d+8>>2]=e;c=fa-16|0;e=L[d+12>>2];L[c+12>>2]=e;if(L[L[c+12>>2]+8>>2]>2]){f=L[d+8>>2];c=fa-16|0;fa=c;L[c+8>>2]=e;L[c+4>>2]=f;j=L[c+8>>2];b:{if(L[c+4>>2]){l=L[c+4>>2];f=fa-16|0;fa=f;L[f+12>>2]=j;L[f+8>>2]=l;L[f+4>>2]=0;j=R(L[f+8>>2],104);L[8513]=L[8513]+1;j=ha[L[6798]](j,16)|0;fa=f+16|0;L[c+12>>2]=j;break b}L[c+12>>2]=0}fa=c+16|0;L[d+4>>2]=L[c+12>>2];c=fa-16|0;L[c+12>>2]=e;Ch(e,L[L[c+12>>2]+4>>2],L[d+4>>2]);c=fa-16|0;L[c+12>>2]=e;Db(e,L[L[c+12>>2]+4>>2]);jb(e);J[e+16|0]=1;L[e+12>>2]=L[d+4>>2];L[e+8>>2]=L[d+8>>2]}fa=d+16|0}L[a+8>>2]=L[a+16>>2];while(1){if(L[a+8>>2]>2]){qa(L[i+12>>2]+R(L[a+8>>2],104)|0,L[a+20>>2],104);L[a+8>>2]=L[a+8>>2]+1;continue}break}}L[i+4>>2]=L[a+24>>2];fa=a+32|0;Ch(L[b+120>>2],L[b+116>>2],L[k+12>>2]);fa=b+128|0;fa=h+16|0;fa=g+16|0}function ZA(a,b){a=a|0;b=b|0;var c=S(0),d=S(0),e=S(0),f=S(0),g=S(0);a:{b:{if(M[a+48|0]){L[b>>2]=0;a=0;break b}L[b>>2]=4;L[b+4>>2]=2;sg(a,L[a+28>>2]+4|0,L[a+32>>2]+4|0);J[a+297|0]=0;L[a+1088>>2]=0;e=P[a+192>>2];f=P[a+196>>2];c:{if(!(e<=f)){break c}c=P[a+924>>2];d=P[a+892>>2];g=P[a+908>>2];d=Za(S(S(c*P[a+864>>2])+S(S(d*P[a+832>>2])+S(P[a+848>>2]*g))),S(S(c*P[a+860>>2])+S(S(d*P[a+828>>2])+S(P[a+844>>2]*g))));d:{if(e>=f){break d}if(dS(3.1415927410125732))){break e}c=S(c+S(-6.2831854820251465))}g=S(T(c));c=Na(S(f-d),S(6.2831854820251465));f:{if(cS(3.1415927410125732))){break f}c=S(c+S(-6.2831854820251465))}d=gf)){break d}c=Na(S(d-f),S(6.2831854820251465));g:{if(cS(3.1415927410125732))){break g}c=S(c+S(-6.2831854820251465))}g=S(T(c));c=Na(S(d-e),S(6.2831854820251465));h:{if(cS(3.1415927410125732))){break h}c=S(c+S(-6.2831854820251465))}d=g>S(T(c))?S(d+S(-6.2831854820251465)):d}P[a+1084>>2]=d;if(!(d>2]=d-e}J[a+296|0]=0;c=P[a+1032>>2];P[a+1080>>2]=c;i:{j:{k:{e=P[a+188>>2];f=P[a+184>>2];if(e>=f){if(c>e){break k}e=f;if(c>2]=0;if(M[a+1096|0]){break j}break i}J[a+296|0]=1;P[a+1032>>2]=c-e}L[b>>2]=L[b>>2]+1;L[b+4>>2]=L[b+4>>2]-1}if(!(M[a+297|0]|M[a+1112|0])){break a}L[b>>2]=L[b>>2]+1;a=L[b+4>>2]-1|0}L[b+4>>2]=a}}function ig(a){var b=0,c=0,d=0,e=0,f=S(0),g=S(0),h=S(0),i=S(0),j=S(0),k=0,l=0,m=S(0),n=S(0),o=S(0),p=S(0);c=L[a+712>>2];a:{if((c|0)<=0){break a}if(c>>>0>=4){k=c&-4;while(1){b=L[a+720>>2]+R(d,104)|0;L[b+72>>2]=0;L[b+76>>2]=0;L[b+80>>2]=0;L[b+84>>2]=0;b=L[a+720>>2]+R(d|1,104)|0;L[b+72>>2]=0;L[b+76>>2]=0;L[b+80>>2]=0;L[b+84>>2]=0;b=L[a+720>>2]+R(d|2,104)|0;L[b+72>>2]=0;L[b+76>>2]=0;L[b+80>>2]=0;L[b+84>>2]=0;b=L[a+720>>2]+R(d|3,104)|0;L[b+72>>2]=0;L[b+76>>2]=0;L[b+80>>2]=0;L[b+84>>2]=0;d=d+4|0;l=l+4|0;if((k|0)!=(l|0)){continue}break}}b=c&3;if(!b){break a}while(1){c=L[a+720>>2]+R(d,104)|0;L[c+72>>2]=0;L[c+76>>2]=0;L[c+80>>2]=0;L[c+84>>2]=0;d=d+1|0;e=e+1|0;if((b|0)!=(e|0)){continue}break}}l=L[a+752>>2];if((l|0)>0){k=0;while(1){b=L[a+760>>2]+R(k,44)|0;d=L[b+12>>2];h=P[d+12>>2];e=L[b+8>>2];f=P[e+12>>2];c=L[b+16>>2];j=P[c+12>>2];p=P[d+16>>2];n=P[c+8>>2];i=P[e+16>>2];o=P[c+16>>2];g=P[e+8>>2];m=P[d+8>>2];L[b+32>>2]=0;m=S(m-g);j=S(j-f);g=S(n-g);h=S(h-f);f=S(S(m*j)-S(g*h));n=h;h=S(o-i);o=j;j=S(p-i);i=S(S(n*h)-S(o*j));g=S(S(j*g)-S(h*m));h=S(S(1)/S(_(S(S(f*f)+S(S(i*i)+S(g*g))))));P[b+28>>2]=f*h;P[b+24>>2]=g*h;P[b+20>>2]=i*h;P[e+80>>2]=f+P[e+80>>2];P[e+76>>2]=g+P[e+76>>2];P[e+72>>2]=i+P[e+72>>2];P[d+72>>2]=i+P[d+72>>2];P[d+76>>2]=g+P[d+76>>2];P[d+80>>2]=f+P[d+80>>2];P[c+72>>2]=i+P[c+72>>2];P[c+76>>2]=g+P[c+76>>2];P[c+80>>2]=f+P[c+80>>2];k=k+1|0;if((l|0)!=(k|0)){continue}break}}d=L[a+712>>2];if((d|0)>0){c=L[a+720>>2];e=0;while(1){a=c+R(e,104)|0;f=P[a+80>>2];i=P[a+72>>2];g=P[a+76>>2];h=S(_(S(S(f*f)+S(S(i*i)+S(g*g)))));if(h>S(1.1920928955078125e-7)){j=f;f=S(S(1)/h);P[a+80>>2]=j*f;P[a+76>>2]=g*f;P[a+72>>2]=i*f}e=e+1|0;if((d|0)!=(e|0)){continue}break}}}function ct(a,b,c){a=a|0;b=S(b);c=S(c);var d=S(0),e=0,f=0,g=0,h=0,i=S(0),j=S(0),k=S(0),l=S(0),m=S(0),n=S(0),o=S(0),p=S(0),q=S(0),r=S(0),s=S(0),t=S(0),u=S(0),v=S(0),w=S(0),x=S(0),y=S(0);g=fa-16|0;fa=g;L[g+12>>2]=a;P[g+8>>2]=b;P[g+4>>2]=c;a=L[g+12>>2];v=P[g+4>>2];h=fa-16|0;fa=h;P[h+12>>2]=P[g+8>>2];c=P[a+692>>2];a:{if(!(c>S(0))){break a}d=P[a+688>>2];b=Na(S(P[h+12>>2]-d),S(6.2831854820251465));b:{if(bS(3.1415927410125732))){break b}b=S(b+S(-6.2831854820251465))}if(!(S(-c)>b)&b<=c){break a}c:{if(b>S(0)){b=Na(S(c+d),S(6.2831854820251465));if(bS(3.1415927410125732))){break c}b=S(b+S(-6.2831854820251465));break c}b=Na(S(d-c),S(6.2831854820251465));if(bS(3.1415927410125732))){break c}b=S(b+S(-6.2831854820251465))}P[h+12>>2]=b}e=L[a+32>>2];b=P[a+652>>2];c=P[a+620>>2];d=P[a+636>>2];m=S(S(P[e+44>>2]*b)+S(S(P[e+36>>2]*c)+S(d*P[e+40>>2])));f=L[a+28>>2];n=P[f+44>>2];i=P[a+584>>2];o=P[f+36>>2];j=P[a+552>>2];k=P[a+568>>2];p=P[f+40>>2];w=S(m*S(S(n*i)+S(S(o*j)+S(k*p))));q=S(S(P[e+12>>2]*b)+S(S(P[e+4>>2]*c)+S(d*P[e+8>>2])));r=P[f+12>>2];s=P[f+4>>2];t=P[f+8>>2];x=S(q*S(S(r*i)+S(S(s*j)+S(k*t))));u=P[f+28>>2];l=S(u*i);i=P[f+20>>2];y=S(i*j);j=P[f+24>>2];l=S(l+S(y+S(k*j)));k=S(S(P[e+28>>2]*b)+S(S(P[e+20>>2]*c)+S(d*P[e+24>>2])));b=P[a+588>>2];c=P[a+556>>2];d=P[a+572>>2];P[a+680>>2]=S(P[h+12>>2]-S(Za(S(w+S(x+S(l*k))),S(S(m*S(S(n*b)+S(S(o*c)+S(p*d))))+S(S(q*S(S(r*b)+S(S(s*c)+S(t*d))))+S(S(S(u*b)+S(S(i*c)+S(j*d)))*k))))*P[a+732>>2]))/v;fa=h+16|0;fa=g+16|0}function Vy(a,b,c){a=a|0;b=b|0;c=c|0;var d=S(0),e=0,f=S(0),g=S(0),h=S(0),i=0,j=0,k=S(0);a=fa-160|0;fa=a;a:{b:{switch((L[b+388>>2]&15)-1|0){case 0:L[a>>2]=21416;e=L[c+12>>2];f=P[e+56>>2];g=P[e+52>>2];i=L[c+8>>2];j=L[i+236>>2];h=P[e+48>>2];e=L[b+192>>2];d=S(ha[L[L[e>>2]+48>>2]](e));e=L[c+4>>2];ha[L[L[e>>2]+8>>2]](e,L[c+12>>2],a+144|0,a+128|0);e=L[a+156>>2];L[a+104>>2]=L[a+152>>2];L[a+108>>2]=e;e=L[a+132>>2];L[a+112>>2]=L[a+128>>2];L[a+116>>2]=e;e=L[a+140>>2];L[a+120>>2]=L[a+136>>2];L[a+124>>2]=e;P[a+104>>2]=P[a+104>>2]-d;P[a+112>>2]=d+P[a+112>>2];e=L[a+148>>2];L[a+96>>2]=L[a+144>>2];L[a+100>>2]=e;P[a+96>>2]=P[a+96>>2]-d;P[a+100>>2]=P[a+100>>2]-d;P[a+116>>2]=d+P[a+116>>2];P[a+120>>2]=d+P[a+120>>2];P[a+20>>2]=d;k=d;d=S(f-f);f=S(d*d);d=S(h-h);h=S(d*d);d=S(g-g);P[a+16>>2]=k+S(_(S(f+S(h+S(d*d)))));L[a+12>>2]=j<<30>>31&i;L[a+8>>2]=c;L[a+4>>2]=b;Vb(b+928|0,L[b+928>>2],a+96|0,a);break a;case 1:break b;default:break a}}L[a+20>>2]=0;L[a+4>>2]=1065353216;L[a>>2]=21500;L[a+24>>2]=b;L[a+28>>2]=c;P[a+8>>2]=P[b+456>>2];e=L[c+4>>2];d=S(ha[L[L[e>>2]+48>>2]](e));e=L[b+192>>2];d=S(d+S(ha[L[L[e>>2]+48>>2]](e)));P[a+12>>2]=d;f=P[b+316>>2];g=P[L[c+8>>2]+224>>2];P[a+16>>2]=f>2];ha[L[L[e>>2]+8>>2]](e,L[c+12>>2],a+144|0,a+128|0);c=L[a+156>>2];L[a+104>>2]=L[a+152>>2];L[a+108>>2]=c;c=L[a+132>>2];L[a+112>>2]=L[a+128>>2];L[a+116>>2]=c;c=L[a+140>>2];L[a+120>>2]=L[a+136>>2];L[a+124>>2]=c;P[a+104>>2]=P[a+104>>2]-d;P[a+112>>2]=d+P[a+112>>2];P[a+116>>2]=d+P[a+116>>2];c=L[a+148>>2];L[a+96>>2]=L[a+144>>2];L[a+100>>2]=c;P[a+96>>2]=P[a+96>>2]-d;P[a+100>>2]=P[a+100>>2]-d;P[a+120>>2]=d+P[a+120>>2];Vb(b+1048|0,L[b+1048>>2],a+96|0,a)}fa=a+160|0}function JG(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=0,g=S(0),h=S(0),i=S(0),j=S(0),k=S(0),l=S(0),m=S(0),n=S(0),o=S(0),p=S(0),q=S(0),r=0,s=S(0),t=S(0),u=S(0),v=S(0),w=S(0),x=S(0),y=S(0),z=S(0),A=S(0),B=S(0),C=S(0),D=0,E=S(0),F=S(0),G=S(0),H=0,I=S(0),J=S(0),K=S(0),N=S(0),O=0;D=L[a+12>>2];if((D|0)<=0){return S(S(1))}f=M[a+28|0];H=f?b:c;b=f?c:b;I=P[b- -64>>2];E=P[b+60>>2];F=P[b+56>>2];G=P[b+52>>2];J=P[b+48>>2];h=P[b+44>>2];i=P[b+40>>2];j=P[b+36>>2];K=P[b+32>>2];k=P[b+28>>2];l=P[b+24>>2];m=P[b+20>>2];N=P[b+16>>2];n=P[b+12>>2];o=P[b+8>>2];r=L[b+260>>2];p=P[b+4>>2];O=L[b+192>>2];q=S(1);f=0;while(1){c=L[O+24>>2]+R(f,80)|0;g=P[c+56>>2];s=P[c+52>>2];t=P[c+48>>2];u=P[c+36>>2];v=P[c+20>>2];w=P[c+4>>2];x=P[c+40>>2];y=P[c+24>>2];z=P[c+8>>2];A=P[c+32>>2];B=P[c>>2];C=P[c+16>>2];L[b+64>>2]=0;L[b+48>>2]=0;L[b+32>>2]=0;L[b+16>>2]=0;L[b+260>>2]=r+1;P[b+36>>2]=S(A*h)+S(S(B*j)+S(i*C));P[b+20>>2]=S(A*k)+S(S(B*m)+S(l*C));P[b+4>>2]=S(A*n)+S(S(B*p)+S(o*C));P[b+44>>2]=S(x*h)+S(S(z*j)+S(i*y));P[b+40>>2]=S(u*h)+S(S(w*j)+S(i*v));P[b+28>>2]=S(x*k)+S(S(z*m)+S(l*y));P[b+24>>2]=S(u*k)+S(S(w*m)+S(l*v));P[b+12>>2]=S(x*n)+S(S(z*p)+S(o*y));P[b+8>>2]=S(u*n)+S(S(w*p)+S(o*v));P[b+60>>2]=E+S(S(g*h)+S(S(t*j)+S(i*s)));P[b+56>>2]=F+S(S(g*k)+S(S(t*m)+S(l*s)));P[b+52>>2]=G+S(S(g*n)+S(S(t*p)+S(o*s)));c=L[L[a+20>>2]+(f<<2)>>2];g=S(ha[L[L[c>>2]+12>>2]](c,b,H,d,e));P[b+64>>2]=I;P[b+60>>2]=E;P[b+56>>2]=F;P[b+52>>2]=G;P[b+48>>2]=J;P[b+44>>2]=h;P[b+40>>2]=i;P[b+36>>2]=j;P[b+32>>2]=K;P[b+28>>2]=k;P[b+24>>2]=l;P[b+20>>2]=m;P[b+16>>2]=N;P[b+12>>2]=n;P[b+8>>2]=o;P[b+4>>2]=p;r=L[b+260>>2]+1|0;L[b+260>>2]=r;q=g>2]=P[a+4>>2];P[b+20>>2]=P[a+8>>2];P[b+24>>2]=P[a+12>>2];P[b+28>>2]=P[a+16>>2];P[b+32>>2]=P[a+20>>2];P[b+36>>2]=P[a+24>>2];P[b+40>>2]=P[a+28>>2];P[b+44>>2]=P[a+32>>2];P[b+48>>2]=P[a+36>>2];P[b+52>>2]=P[a+40>>2];P[b+56>>2]=P[a+44>>2];P[b+60>>2]=P[a+48>>2];P[b- -64>>2]=P[a+52>>2];P[b+68>>2]=P[a+56>>2];P[b+72>>2]=P[a+60>>2];P[b+76>>2]=P[a- -64>>2];P[b+80>>2]=P[a+68>>2];P[b+84>>2]=P[a+72>>2];P[b+88>>2]=P[a+76>>2];P[b+92>>2]=P[a+80>>2];P[b+96>>2]=P[a+84>>2];P[b+100>>2]=P[a+88>>2];P[b+104>>2]=P[a+92>>2];P[b+108>>2]=P[a+96>>2];P[b+112>>2]=P[a+100>>2];P[b+116>>2]=P[a+104>>2];P[b+120>>2]=P[a+108>>2];P[b+124>>2]=P[a+112>>2];P[b+128>>2]=P[a+116>>2];P[b+132>>2]=P[a+120>>2];P[b+136>>2]=P[a+124>>2];P[b+140>>2]=P[a+128>>2];P[b+144>>2]=P[a+132>>2];P[b+148>>2]=P[a+136>>2];P[b+152>>2]=P[a+140>>2];P[b+156>>2]=P[a+144>>2];P[b+160>>2]=P[a+148>>2];P[b+164>>2]=P[a+152>>2];P[b+168>>2]=P[a+156>>2];P[b+172>>2]=P[a+160>>2];P[b+176>>2]=P[a+164>>2];P[b+180>>2]=P[a+168>>2];P[b+184>>2]=P[a+172>>2];P[b+188>>2]=P[a+176>>2];L[b+224>>2]=L[a+180>>2];f=P[a+184>>2];L[b>>2]=0;P[b+192>>2]=f;d=ha[L[L[c>>2]+28>>2]](c,L[a+192>>2])|0;L[b+8>>2]=0;L[b+4>>2]=d;L[b+228>>2]=L[a+204>>2];L[b+232>>2]=L[a+208>>2];L[b+236>>2]=L[a+212>>2];L[b+240>>2]=L[a+216>>2];P[b+196>>2]=P[a+220>>2];P[b+200>>2]=P[a+224>>2];P[b+204>>2]=P[a+232>>2];P[b+208>>2]=P[a+228>>2];L[b+244>>2]=L[a+236>>2];d=ha[L[L[c>>2]+40>>2]](c,a)|0;e=ha[L[L[c>>2]+28>>2]](c,d)|0;L[b+12>>2]=e;if(e){ha[L[L[c>>2]+48>>2]](c,d)}P[b+212>>2]=P[a+244>>2];P[b+216>>2]=P[a+248>>2];P[b+220>>2]=P[a+252>>2];L[b+248>>2]=L[a+256>>2];return 3610}function Pp(a,b){a=a|0;b=b|0;var c=S(0),d=0,e=0,f=0,g=0,h=S(0),i=S(0),j=S(0),k=0,l=0,m=0,n=0;k=fa-16|0;fa=k;L[k+12>>2]=a;L[k+8>>2]=b;d=L[k+8>>2];e=fa-32|0;fa=e;a=L[k+12>>2];b=L[a+192>>2];c=S(ha[L[L[b>>2]+48>>2]](b));g=L[a+712>>2];if((g|0)>0){l=a+928|0;while(1){b=L[a+720>>2]+R(f,104)|0;h=S(P[d>>2]*P[b+8>>2]);P[b+8>>2]=h;i=S(P[d+4>>2]*P[b+12>>2]);P[b+12>>2]=i;j=S(P[d+8>>2]*P[b+16>>2]);P[b+16>>2]=j;P[b+24>>2]=P[d>>2]*P[b+24>>2];P[b+28>>2]=P[d+4>>2]*P[b+28>>2];P[b+32>>2]=P[d+8>>2]*P[b+32>>2];L[e+28>>2]=0;P[e+24>>2]=c+j;P[e+20>>2]=c+i;P[e+16>>2]=c+h;L[e+12>>2]=0;P[e+8>>2]=j-c;P[e+4>>2]=i-c;P[e>>2]=h-c;Gc(l,L[b+96>>2],e);f=f+1|0;if((g|0)!=(f|0)){continue}break}}ig(a);b=L[a+928>>2];a:{if(b){d=L[a+192>>2];c=S(ha[L[L[d>>2]+48>>2]](d));h=P[b>>2];i=P[b+4>>2];j=P[b+8>>2];L[a+904>>2]=0;P[a+900>>2]=j-c;P[a+896>>2]=i-c;P[a+892>>2]=h-c;h=P[b+20>>2];i=P[b+24>>2];j=P[b+16>>2];L[a+920>>2]=0;P[a+916>>2]=c+i;P[a+912>>2]=c+h;b=a+908|0;P[b>>2]=c+j;d=L[a+188>>2];if(!d){break a}f=L[a+684>>2];g=L[f+32>>2];ha[L[L[g>>2]+16>>2]](g,d,a+892|0,b,L[f+36>>2]);break a}L[a+892>>2]=0;L[a+896>>2]=0;L[a+916>>2]=0;L[a+920>>2]=0;L[a+908>>2]=0;L[a+912>>2]=0;L[a+900>>2]=0;L[a+904>>2]=0}g=L[a+732>>2];if((g|0)>0){l=L[a+740>>2];b=0;f=0;while(1){d=l+R(f,52)|0;m=L[d+8>>2];n=L[d+12>>2];c=S(P[m+16>>2]-P[n+16>>2]);h=S(c*c);c=S(P[m+8>>2]-P[n+8>>2]);i=S(c*c);c=S(P[m+12>>2]-P[n+12>>2]);c=S(_(S(h+S(i+S(c*c)))));P[d+16>>2]=c;P[d+28>>2]=c*c;f=f+1|0;if((g|0)!=(f|0)){continue}break}while(1){d=l+R(b,52)|0;P[d+24>>2]=S(P[L[d+8>>2]+88>>2]+P[L[d+12>>2]+88>>2])/P[L[d+4>>2]+4>>2];b=b+1|0;if((g|0)!=(b|0)){continue}break}}hg(a);fa=e+32|0;fa=k+16|0}function ug(a,b,c,d,e){var f=0,g=S(0),h=S(0),i=S(0),j=S(0),k=S(0),l=S(0),m=S(0),n=S(0),o=S(0),p=S(0),q=S(0),r=S(0),s=S(0),t=S(0),u=S(0),v=S(0),w=S(0),x=S(0),y=S(0),z=S(0),A=S(0),B=S(0),C=S(0),D=S(0),E=S(0),F=S(0),G=S(0),H=S(0),I=S(0),J=S(0),K=S(0),M=S(0),N=S(0),O=S(0);f=L[a+28>>2];o=P[f+36>>2];p=P[f+20>>2];q=P[f+40>>2];r=P[f+8>>2];x=P[f+24>>2];n=P[f+44>>2];y=P[f+12>>2];z=P[f+56>>2];A=P[f+28>>2];B=P[f+60>>2];C=P[f+52>>2];a=L[a+32>>2];D=P[a+36>>2];E=P[a+20>>2];s=P[a+40>>2];F=P[a+8>>2];G=P[a+24>>2];h=P[a+44>>2];k=P[a+12>>2];g=P[a+56>>2];j=P[a+28>>2];i=P[a+60>>2];m=P[a+52>>2];H=P[a+344>>2];I=P[f+344>>2];J=P[f+4>>2];K=P[d+4>>2];M=P[d+8>>2];N=P[d>>2];O=P[a+4>>2];l=P[e+4>>2];t=P[e+8>>2];u=P[e>>2];d=L[c+12>>2];L[b+8>>2]=L[c+8>>2];L[b+12>>2]=d;d=L[c+4>>2];L[b>>2]=L[c>>2];L[b+4>>2]=d;L[b+44>>2]=0;L[b+28>>2]=0;v=h;l=S(l-g);h=P[b>>2];u=S(u-m);g=P[b+4>>2];m=S(S(l*h)-S(u*g));w=k;t=S(t-i);k=P[b+8>>2];i=S(S(t*g)-S(l*k));l=j;j=S(S(u*k)-S(t*h));l=S(S(v*m)+S(S(w*i)+S(l*j)));P[b+40>>2]=l;s=S(S(s*m)+S(S(F*i)+S(G*j)));P[b+36>>2]=s;m=S(S(D*m)+S(S(O*i)+S(E*j)));P[b+32>>2]=m;v=n;j=S(N-C);n=S(K-z);i=S(S(g*j)-S(h*n));w=S(n*k);n=S(M-B);g=S(w-S(g*n));h=S(S(n*h)-S(k*j));k=S(S(v*i)+S(S(y*g)+S(A*h)));P[b+24>>2]=k;j=S(S(q*i)+S(S(r*g)+S(x*h)));P[b+20>>2]=j;h=S(S(o*i)+S(S(J*g)+S(p*h)));P[b+16>>2]=h;g=P[f+404>>2];i=P[f+400>>2];o=P[f+396>>2];L[b+60>>2]=0;o=S(h*o);P[b+48>>2]=o;i=S(j*i);P[b+52>>2]=i;g=S(k*g);P[b+56>>2]=g;p=P[a+404>>2];q=P[a+400>>2];r=P[a+396>>2];L[b+76>>2]=0;r=S(m*r);P[b+64>>2]=r;q=S(s*q);P[b+68>>2]=q;p=S(l*p);P[b+72>>2]=p;P[b+80>>2]=S(H+S(I+S(S(g*k)+S(S(o*h)+S(j*i)))))+S(S(p*l)+S(S(r*m)+S(s*q)))}function Ok(a){var b=0,c=0,d=0,e=0,f=0,g=0,h=0;b=L[a+8>>2];c=L[a+32>>2];f=c?L[a+40>>2]:0;d=c;c=L[a+52>>2];g=c?L[a+60>>2]:0;h=c;c=L[a+72>>2];S(ha[L[L[b>>2]+12>>2]](b,f,d,g,h,c?L[a+80>>2]:0,c,L[a+4>>2],L[a+20>>2],L[a+24>>2]));c=L[a+32>>2];a:{if((c|0)>=0){break a}if(L[a+36>>2]<0){b=L[a+40>>2];if(!(b?!b|!M[a+44|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}J[a+44|0]=1;L[a+36>>2]=0;L[a+40>>2]=0}b=c;d=0-b&3;if(d){while(1){L[L[a+40>>2]+(b<<2)>>2]=0;b=b+1|0;e=e+1|0;if((d|0)!=(e|0)){continue}break}}if(c>>>0>4294967292){break a}while(1){c=b<<2;L[c+L[a+40>>2]>>2]=0;L[(c+L[a+40>>2]|0)+4>>2]=0;L[(c+L[a+40>>2]|0)+8>>2]=0;L[(c+L[a+40>>2]|0)+12>>2]=0;b=b+4|0;if(b){continue}break}}L[a+32>>2]=0;c=L[a+52>>2];b:{if((c|0)>=0){break b}if(L[a+56>>2]<0){b=L[a+60>>2];if(!(b?!b|!M[a- -64|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}J[a+64|0]=1;L[a+56>>2]=0;L[a+60>>2]=0}e=0;b=c;d=0-b&3;if(d){while(1){L[L[a+60>>2]+(b<<2)>>2]=0;b=b+1|0;e=e+1|0;if((d|0)!=(e|0)){continue}break}}if(c>>>0>4294967292){break b}while(1){c=b<<2;L[c+L[a+60>>2]>>2]=0;L[(c+L[a+60>>2]|0)+4>>2]=0;L[(c+L[a+60>>2]|0)+8>>2]=0;L[(c+L[a+60>>2]|0)+12>>2]=0;b=b+4|0;if(b){continue}break}}L[a+52>>2]=0;c=L[a+72>>2];c:{if((c|0)>=0){break c}if(L[a+76>>2]<0){b=L[a+80>>2];if(!(b?!b|!M[a+84|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}J[a+84|0]=1;L[a+76>>2]=0;L[a+80>>2]=0}e=0;b=c;d=0-b&3;if(d){while(1){L[L[a+80>>2]+(b<<2)>>2]=0;b=b+1|0;e=e+1|0;if((d|0)!=(e|0)){continue}break}}if(c>>>0>4294967292){break c}while(1){c=b<<2;L[c+L[a+80>>2]>>2]=0;L[(c+L[a+80>>2]|0)+4>>2]=0;L[(c+L[a+80>>2]|0)+8>>2]=0;L[(c+L[a+80>>2]|0)+12>>2]=0;b=b+4|0;if(b){continue}break}}L[a+72>>2]=0}function fh(a){a=a|0;var b=0;L[a>>2]=10328;if(M[a+20|0]){b=L[L[a+16>>2]+16>>2];if(b){L[8514]=L[8514]+1;ha[L[6799]](b)}b=L[a+16>>2];if(b){L[8514]=L[8514]+1;ha[L[6799]](b)}}if(M[a+12|0]){b=L[L[a+8>>2]+16>>2];if(b){L[8514]=L[8514]+1;ha[L[6799]](b)}b=L[a+8>>2];if(b){L[8514]=L[8514]+1;ha[L[6799]](b)}}b=L[a+32>>2];ha[L[L[b>>2]>>2]](b)|0;b=L[a+32>>2];if(b){L[8514]=L[8514]+1;ha[L[6799]](b)}b=L[a+36>>2];ha[L[L[b>>2]>>2]](b)|0;b=L[a+36>>2];if(b){L[8514]=L[8514]+1;ha[L[6799]](b)}b=L[a+40>>2];ha[L[L[b>>2]>>2]](b)|0;b=L[a+40>>2];if(b){L[8514]=L[8514]+1;ha[L[6799]](b)}b=L[a+44>>2];ha[L[L[b>>2]>>2]](b)|0;b=L[a+44>>2];if(b){L[8514]=L[8514]+1;ha[L[6799]](b)}b=L[a+48>>2];ha[L[L[b>>2]>>2]](b)|0;b=L[a+48>>2];if(b){L[8514]=L[8514]+1;ha[L[6799]](b)}b=L[a+52>>2];ha[L[L[b>>2]>>2]](b)|0;b=L[a+52>>2];if(b){L[8514]=L[8514]+1;ha[L[6799]](b)}b=L[a+56>>2];ha[L[L[b>>2]>>2]](b)|0;b=L[a+56>>2];if(b){L[8514]=L[8514]+1;ha[L[6799]](b)}b=L[a+60>>2];ha[L[L[b>>2]>>2]](b)|0;b=L[a+60>>2];if(b){L[8514]=L[8514]+1;ha[L[6799]](b)}b=L[a+76>>2];ha[L[L[b>>2]>>2]](b)|0;b=L[a+76>>2];if(b){L[8514]=L[8514]+1;ha[L[6799]](b)}b=L[a+80>>2];ha[L[L[b>>2]>>2]](b)|0;b=L[a+80>>2];if(b){L[8514]=L[8514]+1;ha[L[6799]](b)}b=L[a+72>>2];ha[L[L[b>>2]>>2]](b)|0;b=L[a+72>>2];if(b){L[8514]=L[8514]+1;ha[L[6799]](b)}b=L[a+88>>2];ha[L[L[b>>2]>>2]](b)|0;b=L[a+88>>2];if(b){L[8514]=L[8514]+1;ha[L[6799]](b)}b=L[a+84>>2];ha[L[L[b>>2]>>2]](b)|0;b=L[a+84>>2];if(b){L[8514]=L[8514]+1;ha[L[6799]](b)}b=L[a+24>>2];if(b){L[8514]=L[8514]+1;ha[L[6799]](b)}b=L[a+28>>2];ha[L[L[b>>2]>>2]](b)|0;b=L[a+28>>2];if(b){L[8514]=L[8514]+1;ha[L[6799]](b)}return a|0}function Vb(a,b,c,d){var e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=S(0),o=S(0),p=S(0),q=S(0),r=S(0),s=S(0),t=0;if(b){n=P[c+24>>2];o=P[c+20>>2];p=P[c+16>>2];q=P[c+8>>2];r=P[c+4>>2];s=P[c>>2];L[8513]=L[8513]+1;a=ha[L[6798]](256,16)|0;L[a>>2]=b;f=64;c=1;while(1){a:{b:{c:{b=c-1|0;k=b<<2;i=L[k+a>>2];d:{if(!(P[i>>2]<=p)|!(P[i+16>>2]>=s)|(!(P[i+4>>2]<=o)|!(P[i+20>>2]>=r))){break d}if(!(P[i+8>>2]<=n)|!(P[i+24>>2]>=q)){break d}if(L[i+40>>2]){if((b|0)!=(f|0)){break c}g=f?f<<1:1;if((g|0)<(c|0)){break c}if(g){L[8513]=L[8513]+1;b=ha[L[6798]](g<<2,16)|0}else{b=0}e:{if(!f){break e}l=0;e=0;if(f>>>0>=4){t=f&-4;h=0;while(1){j=e<<2;L[j+b>>2]=L[a+j>>2];m=j|4;L[m+b>>2]=L[a+m>>2];m=j|8;L[m+b>>2]=L[a+m>>2];j=j|12;L[j+b>>2]=L[a+j>>2];e=e+4|0;h=h+4|0;if((t|0)!=(h|0)){continue}break}}f=f&3;if(!f){break e}while(1){h=e<<2;L[h+b>>2]=L[a+h>>2];e=e+1|0;l=l+1|0;if((f|0)!=(l|0)){continue}break}}if(a){L[8514]=L[8514]+1;ha[L[6799]](a)}break b}ha[L[L[d>>2]+12>>2]](d,i)}break a}g=f;b=a}L[b+k>>2]=L[i+36>>2];f:{if((c|0)!=(g|0)){f=g;a=b;break f}f=c?c<<1:1;if((f|0)<=(c|0)){f=c;a=b;break f}if(f){L[8513]=L[8513]+1;a=ha[L[6798]](f<<2,16)|0}else{a=0}g:{if((c|0)<=0){break g}l=0;g=0;if(c>>>0>=4){j=c&-4;h=0;while(1){e=g<<2;L[e+a>>2]=L[b+e>>2];k=e|4;L[k+a>>2]=L[b+k>>2];k=e|8;L[k+a>>2]=L[b+k>>2];e=e|12;L[e+a>>2]=L[b+e>>2];g=g+4|0;h=h+4|0;if((j|0)!=(h|0)){continue}break}}e=c&3;if(!e){break g}while(1){h=g<<2;L[h+a>>2]=L[b+h>>2];g=g+1|0;l=l+1|0;if((e|0)!=(l|0)){continue}break}}if(b){L[8514]=L[8514]+1;ha[L[6799]](b)}}L[(c<<2)+a>>2]=L[i+40>>2];b=c+1|0}c=b;if((c|0)>0){continue}break}if(a){L[8514]=L[8514]+1;ha[L[6799]](a)}}}function fz(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0,g=S(0),h=S(0),i=S(0),j=S(0),k=S(0),l=S(0),m=0;e=fa-256|0;fa=e;wa(2415);L[e+36>>2]=23020;f=L[b+12>>2];L[e+80>>2]=L[b+8>>2];L[e+84>>2]=f;f=L[b+4>>2];L[e+72>>2]=L[b>>2];L[e+76>>2]=f;f=L[c+12>>2];L[e+96>>2]=L[c+8>>2];L[e+100>>2]=f;f=L[c>>2];m=L[c+4>>2];L[e+108>>2]=0;L[e+112>>2]=0;L[e+116>>2]=0;L[e+120>>2]=0;L[e+128>>2]=0;L[e+132>>2]=0;L[e+124>>2]=1065353216;L[e+136>>2]=0;L[e+140>>2]=0;L[e+144>>2]=1065353216;L[e+148>>2]=0;L[e+88>>2]=f;L[e+92>>2]=m;L[e+252>>2]=d;L[e+104>>2]=1065353216;L[e+248>>2]=a;d=L[b+4>>2];L[e+152>>2]=L[b>>2];L[e+156>>2]=d;d=L[b+12>>2];L[e+160>>2]=L[b+8>>2];L[e+164>>2]=d;L[e+172>>2]=0;L[e+176>>2]=0;L[e+180>>2]=0;L[e+184>>2]=0;L[e+188>>2]=1065353216;L[e+192>>2]=0;L[e+196>>2]=0;L[e+200>>2]=0;L[e+204>>2]=0;L[e+208>>2]=1065353216;L[e+212>>2]=0;L[e+168>>2]=1065353216;d=L[c+12>>2];L[e+224>>2]=L[c+8>>2];L[e+228>>2]=d;d=L[c+4>>2];L[e+216>>2]=L[c>>2];L[e+220>>2]=d;g=S(P[c+8>>2]-P[b+8>>2]);j=S(P[c>>2]-P[b>>2]);h=S(P[c+4>>2]-P[b+4>>2]);i=S(S(1)/S(_(S(S(g*g)+S(S(j*j)+S(h*h))))));g=S(g*i);k=g==S(0)?S(1.0000000150474662e30):S(S(1)/g);P[e+48>>2]=k;h=S(h*i);l=h==S(0)?S(1.0000000150474662e30):S(S(1)/h);P[e+44>>2]=l;L[e- -64>>2]=k>2]=l>2]=j;L[e+56>>2]=j>2]=S(g*S(P[e+96>>2]-P[e+80>>2]))+S(S(i*S(P[e+88>>2]-P[e+72>>2]))+S(h*S(P[e+92>>2]-P[e+76>>2])));a=L[a+68>>2];L[e+24>>2]=0;L[e+28>>2]=0;L[e+16>>2]=0;L[e+20>>2]=0;L[e+8>>2]=0;L[e+12>>2]=0;L[e>>2]=0;L[e+4>>2]=0;ha[L[L[a>>2]+24>>2]](a,b,c,e+36|0,e+16|0,e);va();fa=e+256|0}function YD(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0,g=S(0),h=0,i=0,j=0,k=S(0),l=0,m=0,n=0,o=S(0),p=S(0),q=0,r=0,s=S(0),t=S(0),u=0,v=0,w=0,x=0,y=0,z=S(0),A=S(0),B=S(0),C=S(0),D=0,E=S(0),F=S(0),G=S(0),H=S(0),I=S(0),J=S(0),K=0;l=fa-2048|0;fa=l;a:{if((d|0)<=0){break a}n=L[a+92>>2];if((n|0)<=0){break a}while(1){if((n|0)>0){m=w<<4;i=m+b|0;u=c+m|0;q=L[a+100>>2];x=L[a+120>>2];B=S(-0xde0b6b000000000);v=0;m=n;while(1){g=S(-34028234663852886e22);r=-1;j=(n|0)<=(v|0);b:{if(j){break b}e=(m|0)>=128?128:m;y=(e|0)<=1?1:e;k=P[i+8>>2];o=P[i+4>>2];p=P[i>>2];f=0;while(1){E=P[q>>2];F=P[a+12>>2];G=P[q+4>>2];H=P[a+16>>2];I=P[q+8>>2];z=P[x>>2];J=P[a+20>>2];A=S(ha[L[L[a>>2]+48>>2]](a));s=P[i>>2];t=P[i+4>>2];C=P[i+8>>2];h=(f<<4)+l|0;L[h+12>>2]=0;P[h+8>>2]=S(I+S(z*S(k*J)))-S(A*C);P[h+4>>2]=S(G+S(z*S(o*H)))-S(A*t);P[h>>2]=S(E+S(z*S(p*F)))-S(A*s);x=x+4|0;q=q+16|0;k=C;o=t;p=s;f=f+1|0;if((y|0)!=(f|0)){continue}break}if(j){break b}y=e&1;k=P[i+8>>2];o=P[i+4>>2];p=P[i>>2];c:{if((e|0)==1){e=0;break c}K=e&-2;e=0;f=0;while(1){h=(e<<4)+l|0;s=S(S(P[h+8>>2]*k)+S(S(P[h>>2]*p)+S(o*P[h+4>>2])));h=s>g;D=e|1;j=(D<<4)+l|0;t=S(S(P[j+8>>2]*k)+S(S(P[j>>2]*p)+S(o*P[j+4>>2])));g=h?s:g;j=t>g;g=j?t:g;r=j?D:h?e:r;e=e+2|0;f=f+2|0;if((K|0)!=(f|0)){continue}break}}if(!y){break b}f=(e<<4)+l|0;k=S(S(P[f+8>>2]*k)+S(S(P[f>>2]*p)+S(o*P[f+4>>2])));f=k>g;g=f?k:g;r=f?e:r}if(g>B){e=(r<<4)+l|0;f=L[e+12>>2];L[u+8>>2]=L[e+8>>2];L[u+12>>2]=f;f=L[e+4>>2];L[u>>2]=L[e>>2];L[u+4>>2]=f;B=g}m=m-128|0;v=v+128|0;if((v|0)<(n|0)){continue}break}}w=w+1|0;if((w|0)==(d|0)){break a}n=L[a+92>>2];continue}}fa=l+2048|0}function tH(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0,g=S(0),h=S(0),i=S(0),j=S(0),k=S(0),l=S(0),m=0;e=fa-256|0;fa=e;L[e+36>>2]=8276;f=L[b+12>>2];L[e+80>>2]=L[b+8>>2];L[e+84>>2]=f;f=L[b+4>>2];L[e+72>>2]=L[b>>2];L[e+76>>2]=f;f=L[c+12>>2];L[e+96>>2]=L[c+8>>2];L[e+100>>2]=f;f=L[c>>2];m=L[c+4>>2];L[e+108>>2]=0;L[e+112>>2]=0;L[e+116>>2]=0;L[e+120>>2]=0;L[e+128>>2]=0;L[e+132>>2]=0;L[e+124>>2]=1065353216;L[e+136>>2]=0;L[e+140>>2]=0;L[e+144>>2]=1065353216;L[e+148>>2]=0;L[e+88>>2]=f;L[e+92>>2]=m;L[e+252>>2]=d;L[e+104>>2]=1065353216;L[e+248>>2]=a;d=L[b+4>>2];L[e+152>>2]=L[b>>2];L[e+156>>2]=d;d=L[b+12>>2];L[e+160>>2]=L[b+8>>2];L[e+164>>2]=d;L[e+172>>2]=0;L[e+176>>2]=0;L[e+180>>2]=0;L[e+184>>2]=0;L[e+188>>2]=1065353216;L[e+192>>2]=0;L[e+196>>2]=0;L[e+200>>2]=0;L[e+204>>2]=0;L[e+208>>2]=1065353216;L[e+212>>2]=0;L[e+168>>2]=1065353216;d=L[c+12>>2];L[e+224>>2]=L[c+8>>2];L[e+228>>2]=d;d=L[c+4>>2];L[e+216>>2]=L[c>>2];L[e+220>>2]=d;g=S(P[c+8>>2]-P[b+8>>2]);j=S(P[c>>2]-P[b>>2]);h=S(P[c+4>>2]-P[b+4>>2]);i=S(S(1)/S(_(S(S(g*g)+S(S(j*j)+S(h*h))))));g=S(g*i);k=g==S(0)?S(0xde0b6b000000000):S(S(1)/g);P[e+48>>2]=k;h=S(h*i);l=h==S(0)?S(0xde0b6b000000000):S(S(1)/h);P[e+44>>2]=l;L[e- -64>>2]=k>2]=l>2]=j;L[e+56>>2]=j>2]=S(g*S(P[e+96>>2]-P[e+80>>2]))+S(S(i*S(P[e+88>>2]-P[e+72>>2]))+S(h*S(P[e+92>>2]-P[e+76>>2])));a=L[a+68>>2];L[e+24>>2]=0;L[e+28>>2]=0;L[e+16>>2]=0;L[e+20>>2]=0;L[e+8>>2]=0;L[e+12>>2]=0;L[e>>2]=0;L[e+4>>2]=0;ha[L[L[a>>2]+24>>2]](a,b,c,e+36|0,e+16|0,e);fa=e+256|0}function uz(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=S(0),g=S(0),h=S(0),i=0,j=S(0),k=S(0),l=S(0),m=S(0),n=S(0),o=S(0),p=S(0),q=S(0),r=S(0),s=0,t=S(0),u=S(0),v=S(0),w=S(0),x=S(0),y=S(0),z=S(0),A=S(0),B=S(0),C=S(0),D=S(0),E=S(0),F=S(0),G=S(0);c=M[a+8|0]?b:c;if(L[L[c+4>>2]+4>>2]-21>>>0<=8){s=L[L[c+8>>2]+192>>2];k=S(ha[L[L[s>>2]+48>>2]](s));i=fa-32|0;fa=i;b=a+12|0;L[b+52>>2]=d;L[b+44>>2]=e;P[b+56>>2]=k+S(.05999999865889549);d=L[b+4>>2];ha[L[L[d>>2]+28>>2]](d,i+16|0,i);c=L[c+12>>2];k=P[c+20>>2];m=P[c+36>>2];n=P[c+24>>2];j=P[c+40>>2];v=P[c+56>>2];w=P[c+52>>2];t=P[c+4>>2];o=P[c+8>>2];l=P[b+56>>2];h=P[c+32>>2];f=P[c>>2];r=P[c+48>>2];g=P[c+16>>2];p=P[i+24>>2];q=P[i+8>>2];u=P[i+16>>2];A=P[i>>2];B=P[i+20>>2];C=P[i+4>>2];L[b+40>>2]=0;L[b+24>>2]=0;x=S(S(q+p)*S(.5));y=S(S(A+u)*S(.5));z=S(S(C+B)*S(.5));r=S(-r);D=S(S(S(h*x)+S(S(f*y)+S(g*z)))+S(S(S(f*r)-S(g*w))-S(h*v)));p=S(l+S(S(q-p)*S(.5)));E=S(f*S(0));F=S(g*S(0));G=S(p*S(T(S(h+S(E+F)))));q=S(l+S(S(A-u)*S(.5)));h=S(h*S(0));f=S(q*S(T(S(h+S(f+F)))));g=S(T(S(h+S(E+g))));h=S(l+S(S(C-B)*S(.5)));f=S(G+S(f+S(g*h)));P[b+28>>2]=D+f;P[b+12>>2]=D-f;f=S(S(S(x*j)+S(S(y*o)+S(z*n)))+S(S(S(o*r)-S(n*w))-S(j*v)));g=S(o*S(0));l=S(n*S(0));u=S(p*S(T(S(j+S(g+l)))));j=S(j*S(0));n=S(u+S(S(q*S(T(S(j+S(o+l)))))+S(S(T(S(j+S(g+n))))*h)));P[b+36>>2]=f+n;j=S(S(S(x*m)+S(S(y*t)+S(z*k)))+S(S(S(t*r)-S(k*w))-S(m*v)));o=S(t*S(0));g=S(k*S(0));l=S(p*S(T(S(m+S(o+g)))));m=S(m*S(0));k=S(l+S(S(q*S(T(S(m+S(t+g)))))+S(S(T(S(m+S(o+k))))*h)));P[b+32>>2]=j+k;P[b+20>>2]=f-n;P[b+16>>2]=j-k;fa=i+32|0;ha[L[L[s>>2]+64>>2]](s,b,a+24|0,a+40|0)}}function De(a,b){var c=S(0),d=S(0),e=0,f=0,g=S(0),h=S(0),i=S(0);d=P[((b<<2)+a|0)+1192>>2];f=(b<<6)+a|0;g=P[f+868>>2];h=P[f+872>>2];a:{if(g>=h){break a}if(dS(3.1415927410125732))){break b}c=S(c+S(-6.2831854820251465))}i=S(T(c));c=Na(S(h-d),S(6.2831854820251465));c:{if(cS(3.1415927410125732))){break c}c=S(c+S(-6.2831854820251465))}d=ih)){break a}c=Na(S(d-h),S(6.2831854820251465));d:{if(cS(3.1415927410125732))){break d}c=S(c+S(-6.2831854820251465))}i=S(T(c));c=Na(S(d-g),S(6.2831854820251465));e:{if(cS(3.1415927410125732))){break e}c=S(c+S(-6.2831854820251465))}d=i>S(T(c))?S(d+S(-6.2831854820251465)):d}P[f+920>>2]=d;f:{if(g>h){f=0;L[((b<<6)+a|0)+924>>2]=0;break f}if(d>2]=c;f=1;L[e+924>>2]=1;if(c>S(3.1415927410125732)){P[e+916>>2]=c+S(-6.2831854820251465);break f}if(!(c>2]=c+S(6.2831854820251465);break f}e=(b<<6)+a|0;if(d>h){L[e+924>>2]=2;c=S(d-h);P[e+916>>2]=c;if(c>S(3.1415927410125732)){P[e+916>>2]=c+S(-6.2831854820251465);f=1;break f}f=1;if(!(c>2]=c+S(6.2831854820251465);break f}f=0;L[e+924>>2]=0}return M[((b<<6)+a|0)+912|0]!=0|f}function Oz(a,b,c){a=a|0;b=S(b);c=S(c);var d=0,e=0,f=S(0),g=0,h=0,i=S(0),j=0,k=S(0),l=S(0),m=S(0),n=S(0),o=S(0),p=0,q=S(0),r=S(0),s=S(0),t=0,u=S(0),v=S(0),w=S(0),x=S(0);t=L[a+832>>2];if((t|0)>0){a=L[a+840>>2];while(1){u=S(0);v=S(0);w=S(0);d=a+R(p,56)|0;j=L[d>>2];q=P[j+16>>2];f=P[d+8>>2];e=L[d+4>>2];g=L[e+8>>2];i=P[d+12>>2];h=L[e+12>>2];b=P[d+16>>2];e=L[e+16>>2];k=S(S(S(f*P[g+16>>2])+S(i*P[h+16>>2]))+S(b*P[e+16>>2]));l=S(S(q-P[j+32>>2])-S(k-S(S(S(f*P[g+32>>2])+S(i*P[h+32>>2]))+S(b*P[e+32>>2]))));n=P[d+32>>2];r=P[j+8>>2];m=S(S(S(P[g+8>>2]*f)+S(P[h+8>>2]*i))+S(P[e+8>>2]*b));x=S(S(r-P[j+24>>2])-S(m-S(S(S(f*P[g+24>>2])+S(i*P[h+24>>2]))+S(b*P[e+24>>2]))));o=P[d+24>>2];s=P[j+12>>2];c=S(S(S(f*P[g+12>>2])+S(i*P[h+12>>2]))+S(b*P[e+12>>2]));b=S(S(s-P[j+28>>2])-S(c-S(S(S(f*P[g+28>>2])+S(i*P[h+28>>2]))+S(b*P[e+28>>2]))));f=P[d+28>>2];i=S(S(l*n)+S(S(x*o)+S(b*f)));if(i>2]-S(S(S(n*q)+S(S(o*r)+S(s*f)))-S(S(n*k)+S(S(o*m)+S(c*f)))));w=S(S(n*c)+S(0));u=S(S(o*c)+S(0));v=S(S(f*c)+S(0))}m=P[d+48>>2];c=P[d+44>>2];k=S(w-S(S(l-S(n*i))*c));P[j+16>>2]=q+S(m*k);l=S(v-S(c*S(b-S(f*i))));P[j+12>>2]=s+S(m*l);c=S(u-S(c*S(x-S(o*i))));P[j+8>>2]=r+S(m*c);b=S(P[d+52>>2]*P[d+8>>2]);P[g+8>>2]=P[g+8>>2]-S(c*b);P[g+12>>2]=P[g+12>>2]-S(l*b);P[g+16>>2]=P[g+16>>2]-S(k*b);b=S(P[d+52>>2]*P[d+12>>2]);P[h+8>>2]=P[h+8>>2]-S(c*b);P[h+12>>2]=P[h+12>>2]-S(l*b);P[h+16>>2]=P[h+16>>2]-S(k*b);b=S(P[d+52>>2]*P[d+16>>2]);P[e+8>>2]=P[e+8>>2]-S(c*b);P[e+12>>2]=P[e+12>>2]-S(l*b);P[e+16>>2]=P[e+16>>2]-S(k*b);p=p+1|0;if((t|0)!=(p|0)){continue}break}}}function Pg(a){var b=0,c=0,d=S(0),e=0,f=S(0),g=S(0),h=S(0),i=S(0),j=S(0),k=S(0),l=0;e=L[a+28>>2];if((e|0)<=0){return 1}f=P[a+84>>2];g=P[a+68>>2];i=S(f+g);h=P[a+88>>2];d=P[a+72>>2];j=S(h+d);h=S(d-h);f=S(g-f);d=P[a+80>>2];k=P[a+64>>2];g=S(d+k);d=S(k-d);a=L[a+36>>2];a:{b:{while(1){b=a+R(c,36)|0;if(S(P[b+32>>2]+S(S(j*P[b+28>>2])+S(S(g*P[b+20>>2])+S(i*P[b+24>>2]))))>S(0)){break b}c=c+1|0;if((e|0)!=(c|0)){continue}break}c=0;while(1){b=a+R(c,36)|0;if(S(P[b+32>>2]+S(S(h*P[b+28>>2])+S(S(g*P[b+20>>2])+S(i*P[b+24>>2]))))>S(0)){break a}c=c+1|0;if((e|0)!=(c|0)){continue}break}c=0;while(1){b=a+R(c,36)|0;if(S(P[b+32>>2]+S(S(j*P[b+28>>2])+S(S(g*P[b+20>>2])+S(f*P[b+24>>2]))))>S(0)){break a}c=c+1|0;if((e|0)!=(c|0)){continue}break}c=0;while(1){b=a+R(c,36)|0;if(S(P[b+32>>2]+S(S(h*P[b+28>>2])+S(S(g*P[b+20>>2])+S(f*P[b+24>>2]))))>S(0)){break a}c=c+1|0;if((e|0)!=(c|0)){continue}break}c=0;while(1){b=a+R(c,36)|0;if(S(P[b+32>>2]+S(S(j*P[b+28>>2])+S(S(d*P[b+20>>2])+S(i*P[b+24>>2]))))>S(0)){break a}c=c+1|0;if((e|0)!=(c|0)){continue}break}c=0;while(1){b=a+R(c,36)|0;if(S(P[b+32>>2]+S(S(h*P[b+28>>2])+S(S(d*P[b+20>>2])+S(i*P[b+24>>2]))))>S(0)){break a}c=c+1|0;if((e|0)!=(c|0)){continue}break}c=0;while(1){b=a+R(c,36)|0;if(S(P[b+32>>2]+S(S(j*P[b+28>>2])+S(S(d*P[b+20>>2])+S(f*P[b+24>>2]))))>S(0)){break a}c=c+1|0;if((e|0)!=(c|0)){continue}break}c=0;while(1){c:{b=a+R(c,36)|0;b=S(P[b+32>>2]+S(S(h*P[b+28>>2])+S(S(d*P[b+20>>2])+S(f*P[b+24>>2]))))>S(0);l=!b;if(b){break c}c=c+1|0;if((e|0)!=(c|0)){continue}}break}return l}return 0}return 0}function fl(a,b,c,d){var e=S(0),f=S(0),g=S(0),h=S(0),i=S(0),j=S(0),k=S(0),l=S(0),m=S(0),n=S(0),o=S(0),p=S(0),q=S(0),r=S(0),s=S(0);a=rg(a,4,b);L[a>>2]=19768;b=L[c+12>>2];L[a+560>>2]=L[c+8>>2];L[a+564>>2]=b;b=L[c+4>>2];L[a+552>>2]=L[c>>2];L[a+556>>2]=b;b=L[c+28>>2];L[a+576>>2]=L[c+24>>2];L[a+580>>2]=b;b=L[c+20>>2];L[a+568>>2]=L[c+16>>2];L[a+572>>2]=b;b=L[c+44>>2];L[a+592>>2]=L[c+40>>2];L[a+596>>2]=b;b=L[c+36>>2];L[a+584>>2]=L[c+32>>2];L[a+588>>2]=b;b=L[c+60>>2];L[a+608>>2]=L[c+56>>2];L[a+612>>2]=b;b=L[c+52>>2];L[a+600>>2]=L[c+48>>2];L[a+604>>2]=b;b=L[c+12>>2];L[a+624>>2]=L[c+8>>2];L[a+628>>2]=b;b=L[c+4>>2];L[a+616>>2]=L[c>>2];L[a+620>>2]=b;b=L[c+20>>2];L[a+632>>2]=L[c+16>>2];L[a+636>>2]=b;b=L[c+28>>2];L[a+640>>2]=L[c+24>>2];L[a+644>>2]=b;b=L[c+36>>2];L[a+648>>2]=L[c+32>>2];L[a+652>>2]=b;b=L[c+44>>2];L[a+656>>2]=L[c+40>>2];L[a+660>>2]=b;b=L[c+52>>2];L[a+664>>2]=L[c+48>>2];L[a+668>>2]=b;b=L[c+60>>2];L[a+672>>2]=L[c+56>>2];L[a+676>>2]=b;L[a+688>>2]=0;L[a+692>>2]=-1082130432;L[a+696>>2]=1063675494;L[a+700>>2]=1050253722;L[a+704>>2]=1065353216;L[a+708>>2]=0;L[a+712>>2]=0;J[a+716|0]=0;J[a+740|0]=d;L[a+748>>2]=0;L[a+736>>2]=16777216;b=L[a+28>>2];h=P[b+52>>2];i=P[b+12>>2];j=P[b+8>>2];k=P[b+4>>2];l=P[b+56>>2];m=P[b+28>>2];n=P[b+20>>2];o=P[b+24>>2];p=P[b+60>>2];e=P[a+608>>2];q=P[b+44>>2];f=P[a+600>>2];r=P[b+36>>2];g=P[a+604>>2];s=P[b+40>>2];P[a+732>>2]=d?S(-1):S(1);L[a+676>>2]=0;P[a+672>>2]=p+S(S(e*q)+S(S(f*r)+S(g*s)));P[a+668>>2]=l+S(S(e*m)+S(S(f*n)+S(g*o)));P[a+664>>2]=h+S(S(e*i)+S(S(f*k)+S(g*j)))}function Pz(a,b,c){a=a|0;b=S(b);c=S(c);var d=0,e=S(0),f=S(0),g=0,h=S(0),i=S(0),j=S(0),k=0,l=S(0),m=0,n=S(0),o=0,p=S(0),q=S(0),r=S(0),s=0,t=S(0),u=S(0),v=S(0),w=S(0),x=S(0),y=S(0),z=S(0),A=S(0),B=S(0),C=S(0),D=S(0),E=S(0),F=S(0),G=S(0);m=fa-16|0;fa=m;c=P[a+452>>2];d=L[a+192>>2];r=S(ha[L[L[d>>2]+48>>2]](d));s=L[a+812>>2];if((s|0)>0){while(1){d=L[a+820>>2]+R(o,104)|0;g=L[d>>2];k=L[g+236>>2]<<30>>31&g;a:{if(!k){j=S(0);e=S(0);f=S(0);break a}e=P[k+332>>2];f=P[d+84>>2];h=P[d+80>>2];l=P[k+336>>2];j=S(c*S(S(S(e*f)-S(h*l))+P[k+312>>2]));n=P[k+328>>2];i=S(n*h);h=P[d+76>>2];e=S(c*S(S(i-S(h*e))+P[k+320>>2]));f=S(c*S(S(S(l*h)-S(f*n))+P[k+316>>2]))}g=L[d+24>>2];n=P[g+16>>2];i=S(S(n-P[g+32>>2])-e);e=P[d+12>>2];t=P[g+8>>2];p=S(S(t-P[g+24>>2])-j);j=P[d+4>>2];u=P[g+12>>2];q=S(S(u-P[g+28>>2])-f);f=P[d+8>>2];h=S(S(i*e)+S(S(p*j)+S(q*f)));b:{if(!(h<=S(1.1920928955078125e-7))){break b}v=P[d+20>>2];w=P[d+36>>2];x=P[d+28>>2];y=P[d+32>>2];z=P[d+52>>2];A=P[d+44>>2];B=P[d+48>>2];C=P[d+68>>2];D=P[d+60>>2];E=P[d- -64>>2];l=P[d+96>>2];F=P[d+100>>2];L[m+12>>2]=0;G=S(i-S(l*S(i-S(e*h))));i=S(v+S(S(n*e)+S(S(t*j)+S(u*f))));i=S(F*(i>2]=h;l=S(S(z*e)+S(S(A*j)+S(f*B)));P[m+4>>2]=l;e=S(S(w*e)+S(S(x*j)+S(f*y)));P[m>>2]=e;f=e;e=P[d+92>>2];P[g+8>>2]=P[g+8>>2]-S(f*e);P[g+12>>2]=P[g+12>>2]-S(l*e);P[g+16>>2]=n-S(h*e);if(!k){break b}rb(k,m,d+76|0)}o=o+1|0;if((s|0)!=(o|0)){continue}break}}fa=m+16|0}function $p(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;var g=0,h=S(0),i=0,j=0,k=S(0),l=S(0),m=S(0),n=S(0),o=S(0),p=S(0),q=S(0),r=0,s=0,t=0,u=0,v=0,w=0,x=S(0);g=fa-32|0;fa=g;L[g+28>>2]=a;L[g+24>>2]=b;L[g+20>>2]=c;L[g+16>>2]=d;L[g+12>>2]=e;L[g+8>>2]=f;r=L[g+24>>2];s=L[g+20>>2];t=L[g+16>>2];u=L[g+12>>2];a=L[g+28>>2];e=L[g+8>>2];c=0;d=0;f=fa-96|0;fa=f;pa(f,0,96);e=e?e:L[L[a+880>>2]>>2];b=L[a+772>>2];a:{if((b|0)!=L[a+776>>2]){break a}j=b?b<<1:1;if((j|0)<=(b|0)){break a}if(j){L[8513]=L[8513]+1;c=ha[L[6798]](R(j,104),16)|0;b=L[a+772>>2]}b:{if((b|0)<=0){break b}v=b&1;if((b|0)!=1){w=b&-2;b=0;while(1){i=R(d,104);qa(i+c|0,i+L[a+780>>2]|0,104);i=R(d|1,104);qa(i+c|0,i+L[a+780>>2]|0,104);d=d+2|0;b=b+2|0;if((w|0)!=(b|0)){continue}break}}if(!v){break b}b=R(d,104);qa(b+c|0,b+L[a+780>>2]|0,104)}b=L[a+780>>2];if(!(b?!b|!M[a+784|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+780>>2]=c;J[a+784|0]=1;L[a+776>>2]=j;b=L[a+772>>2]}b=L[a+780>>2]+R(b,104)|0;L[b+4>>2]=e;L[b>>2]=0;qa(b+8|0,f,96);L[a+772>>2]=L[a+772>>2]+1;fa=f+96|0;b=(L[a+780>>2]+R(L[a+772>>2],104)|0)-104|0;c=L[a+720>>2]+R(r,104)|0;L[b+8>>2]=c;d=L[a+720>>2]+R(s,104)|0;L[b+12>>2]=d;e=L[a+720>>2]+R(t,104)|0;L[b+16>>2]=e;f=L[a+720>>2]+R(u,104)|0;L[b+20>>2]=f;h=P[c+16>>2];m=S(P[f+16>>2]-h);k=P[c+8>>2];n=S(P[e+8>>2]-k);l=P[c+12>>2];o=S(P[f+12>>2]-l);p=S(P[f+8>>2]-k);q=S(P[e+12>>2]-l);x=S(S(P[d+16>>2]-h)*S(S(n*o)-S(p*q)));h=S(P[e+16>>2]-h);P[b+24>>2]=x+S(S(S(P[d+8>>2]-k)*S(S(q*m)-S(o*h)))+S(S(P[d+12>>2]-l)*S(S(h*p)-S(m*n))));J[a+924|0]=1;fa=g+32|0}function jp(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=S(0);g=fa-32|0;fa=g;L[g+28>>2]=a;L[g+24>>2]=b;L[g+20>>2]=c;L[g+16>>2]=d;L[g+12>>2]=e;J[g+11|0]=f;j=L[g+24>>2];m=L[g+20>>2];e=L[g+16>>2];q=J[g+11|0]&1;b=0;c=0;f=0;h=L[g+12>>2];o=R(h,3);a=1;if((h|0)>0){a=(o|0)<=1?1:o;k=a&3;if(a-1>>>0>=3){i=a&2147483644;a=0;while(1){d=c<<2;l=L[(d|12)+e>>2];n=L[(d|8)+e>>2];p=L[(d|4)+e>>2];d=L[d+e>>2];b=(b|0)<(d|0)?d:b;b=(b|0)<(p|0)?p:b;b=(b|0)<(n|0)?n:b;b=(b|0)<(l|0)?l:b;c=c+4|0;a=a+4|0;if((i|0)!=(a|0)){continue}break}}if(k){while(1){a=L[(c<<2)+e>>2];b=(a|0)>(b|0)?a:b;c=c+1|0;f=f+1|0;if((k|0)!=(f|0)){continue}break}}a=b+1|0}L[8513]=L[8513]+1;b=R(a,a);d=pa(ha[L[6798]](b,16)|0,0,b);b=R(a,3);i=(((b|0)<=3?3:b)-1>>>0)/3|0;L[8513]=L[8513]+1;k=ha[L[6798]](a<<4,16)|0;c=0;b=0;while(1){f=m+(c<<2)|0;l=L[f>>2];n=L[f+4>>2];r=P[f+8>>2];f=k+(b<<4)|0;L[f+12>>2]=0;P[f+8>>2]=r;L[f>>2]=l;L[f+4>>2]=n;c=c+3|0;f=(b|0)!=(i|0);b=b+1|0;if(f){continue}break}m=0;L[8513]=L[8513]+1;b=Ac(ha[L[6798]](1252,16)|0,j,a,k,0);if((h|0)>0){while(1){f=(m<<2)+e|0;c=L[f+4>>2];h=L[f>>2];j=R(h,a);f=L[f+8>>2];i=d+(j+f|0)|0;if(!M[i|0]){J[i|0]=1;J[d+(h+R(a,f)|0)|0]=1;Ha(b,f,h,0,0)}i=R(a,c);l=d+(i+h|0)|0;if(!M[l|0]){J[l|0]=1;J[d+(c+j|0)|0]=1;Ha(b,h,c,0,0)}j=d+(c+R(a,f)|0)|0;if(!M[j|0]){J[j|0]=1;J[d+(f+i|0)|0]=1;Ha(b,c,f,0,0)}pb(b,h,c,f,0);m=m+3|0;if((o|0)>(m|0)){continue}break}}if(q){yk(b)}if(k){L[8514]=L[8514]+1;ha[L[6799]](k)}if(d){L[8514]=L[8514]+1;ha[L[6799]](d)}fa=g+32|0;return b|0}function WH(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0;c=fa-32|0;fa=c;L[c+24>>2]=0;L[c+16>>2]=0;L[c+20>>2]=0;J[c+28|0]=1;a:{if(L[a+8>>2]<=0){break a}while(1){e=L[a+16>>2]+(j<<4)|0;b:{if(L[c+20>>2]!=(d|0)){break b}f=d?d<<1:1;if((f|0)<=(d|0)){break b}h=0;i=0;if(f){L[8513]=L[8513]+1;i=ha[L[6798]](f<<4,16)|0}if((d|0)>0){while(1){g=h<<4;k=g+i|0;g=g+L[c+24>>2]|0;L[k>>2]=L[g>>2];L[k+4>>2]=L[g+4>>2];L[k+8>>2]=L[g+8>>2];L[k+12>>2]=L[g+12>>2];h=h+1|0;if((h|0)!=(d|0)){continue}break}}d=L[c+24>>2];if(!(d?!d|!M[c+28|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](d)}L[c+24>>2]=i;J[c+28|0]=1;L[c+20>>2]=f;d=L[c+16>>2]}d=L[c+24>>2]+(d<<4)|0;L[d>>2]=L[e>>2];L[d+4>>2]=L[e+4>>2];L[d+8>>2]=L[e+8>>2];L[d+12>>2]=L[e+12>>2];f=L[c+16>>2];d=f+1|0;L[c+16>>2]=d;j=j+1|0;if((j|0)>2]){continue}break}e=0;if((f|0)<0){break a}i=f+1|0;k=i&1;h=L[c+24>>2];if(f){i=i&-2;f=0;while(1){g=e<<4;j=g+h|0;ha[L[L[a>>2]+12>>2]](a,L[j>>2],L[j+4>>2],b)|0;g=h+(g|16)|0;ha[L[L[a>>2]+12>>2]](a,L[g>>2],L[g+4>>2],b)|0;e=e+2|0;f=f+2|0;if((i|0)!=(f|0)){continue}break}}if(!k){break a}e=h+(e<<4)|0;ha[L[L[a>>2]+12>>2]](a,L[e>>2],L[e+4>>2],b)|0}if(L[a+56>>2]>0){b=L[a- -64>>2];e=0;while(1){L[b+(e<<2)>>2]=-1;e=e+1|0;if((e|0)>2]){continue}break}d=L[c+16>>2]}if((d|0)>=2){jc(c+12|0,c+11|0,0,d-1|0);d=L[c+16>>2]}if((d|0)>0){e=0;while(1){b=L[c+24>>2]+(e<<4)|0;ha[L[L[a>>2]+8>>2]](a,L[b>>2],L[b+4>>2])|0;e=e+1|0;if((e|0)>2]){continue}break}}a=L[c+24>>2];if(!(a?!a|!M[c+28|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](a)}fa=c+32|0}function gC(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=S(0),f=S(0),g=S(0),h=S(0),i=0,j=S(0),k=S(0),l=S(0),m=S(0),n=S(0),o=S(0),p=S(0),q=S(0),r=S(0),s=S(0),t=S(0),u=S(0),v=S(0),w=S(0),x=S(0),y=S(0),z=S(0);i=fa-32|0;fa=i;h=P[b+20>>2];r=P[b+36>>2];s=P[b+24>>2];x=P[b+40>>2];j=P[b+4>>2];t=P[b+32>>2];o=P[b+8>>2];p=P[b>>2];u=P[b+16>>2];L[i+28>>2]=0;g=S(u-p);k=S(r-j);e=S(t-p);l=S(h-j);f=S(S(g*k)-S(e*l));m=l;l=S(x-o);n=S(s-o);k=S(S(m*l)-S(k*n));g=S(S(n*e)-S(l*g));e=S(S(o*f)+S(S(p*k)+S(j*g)));v=P[a+12>>2];m=P[a+4>>2];q=P[a+8>>2];l=S(S(S(f*v)+S(S(k*m)+S(g*q)))-e);w=P[a+28>>2];y=P[a+20>>2];z=P[a+24>>2];e=S(S(S(f*w)+S(S(k*y)+S(g*z)))-e);a:{if(S(l*e)>=S(0)){break a}b=L[a+36>>2];if(b&1&l<=S(0)){break a}e=S(l/S(l-e));if(!(e>2])){break a}n=S(S(1)-e);m=S(S(n*m)+S(y*e));p=S(p-m);q=S(S(n*q)+S(z*e));h=S(h-q);u=S(u-m);j=S(j-q);n=S(S(n*v)+S(w*e));s=S(s-n);o=S(o-n);w=S(S(f*f)+S(S(k*k)+S(g*g)));v=S(w*S(-9999999747378752e-20));if(!(S(S(S(S(p*h)-S(u*j))*f)+S(S(S(S(j*s)-S(h*o))*k)+S(g*S(S(o*u)-S(s*p)))))>=v)){break a}r=S(r-q);t=S(t-m);q=S(S(S(u*r)-S(t*h))*f);m=h;h=S(x-n);if(!(v<=S(q+S(S(S(S(m*h)-S(r*s))*k)+S(g*S(S(s*t)-S(h*u))))))|!(v<=S(S(S(S(t*j)-S(p*r))*f)+S(S(S(S(r*o)-S(j*h))*k)+S(g*S(S(h*p)-S(o*t))))))){break a}h=f;f=S(S(1)/S(_(w)));j=S(h*f);P[i+24>>2]=j;g=S(g*f);P[i+20>>2]=g;f=S(k*f);P[i+16>>2]=f;if(!(!(l<=S(0))|b&2)){L[i+12>>2]=0;P[i+8>>2]=-j;P[i+4>>2]=-g;P[i>>2]=-f;P[a+40>>2]=ha[L[L[a>>2]+12>>2]](a,i,e,c,d);break a}P[a+40>>2]=ha[L[L[a>>2]+12>>2]](a,i+16|0,e,c,d)}fa=i+32|0}function ZD(a,b,c){a=a|0;b=b|0;c=c|0;var d=S(0),e=0,f=0,g=S(0),h=0,i=S(0),j=0,k=S(0),l=0,m=0,n=S(0),o=S(0),p=S(0),q=0,r=0,s=0,t=0,u=0,v=S(0),w=S(0),x=S(0),y=S(0),z=S(0),A=S(0),B=0,C=0;m=fa-2048|0;fa=m;L[a>>2]=0;L[a+4>>2]=0;L[a+8>>2]=0;L[a+12>>2]=0;d=P[c+8>>2];i=P[c>>2];n=P[c+4>>2];g=S(S(d*d)+S(S(i*i)+S(n*n)));if(g>2];if((q|0)>0){c=L[b+100>>2];t=L[b+120>>2];n=S(-0xde0b6b000000000);r=q;while(1){d=S(-34028234663852886e22);j=-1;a:{if((q|0)<=(s|0)){break a}e=(r|0)>=128?128:r;l=(e|0)<=1?1:e;f=0;while(1){v=P[c>>2];w=P[b+12>>2];x=P[c+4>>2];y=P[b+16>>2];z=P[c+8>>2];g=P[t>>2];A=P[b+20>>2];k=S(ha[L[L[b>>2]+48>>2]](b));h=(f<<4)+m|0;L[h+12>>2]=0;P[h+8>>2]=S(z+S(g*S(o*A)))-S(o*k);P[h+4>>2]=S(x+S(g*S(p*y)))-S(p*k);P[h>>2]=S(v+S(g*S(i*w)))-S(i*k);t=t+4|0;c=c+16|0;f=f+1|0;if((l|0)!=(f|0)){continue}break}if((q|0)<=(s|0)){break a}B=e&1;b:{if((e|0)==1){e=0;break b}C=e&-2;e=0;f=0;while(1){h=(e<<4)+m|0;g=S(S(P[h+8>>2]*o)+S(S(P[h>>2]*i)+S(p*P[h+4>>2])));h=g>d;u=e|1;l=(u<<4)+m|0;k=S(S(P[l+8>>2]*o)+S(S(P[l>>2]*i)+S(p*P[l+4>>2])));d=h?g:d;l=k>d;d=l?k:d;j=l?u:h?e:j;e=e+2|0;f=f+2|0;if((C|0)!=(f|0)){continue}break}}if(!B){break a}f=(e<<4)+m|0;g=S(S(P[f+8>>2]*o)+S(S(P[f>>2]*i)+S(p*P[f+4>>2])));f=g>d;d=f?g:d;j=f?e:j}if(d>n){e=(j<<4)+m|0;j=L[e+12>>2];L[a+8>>2]=L[e+8>>2];L[a+12>>2]=j;j=L[e+4>>2];L[a>>2]=L[e>>2];L[a+4>>2]=j;n=d}r=r-128|0;s=s+128|0;if((s|0)<(q|0)){continue}break}}fa=m+2048|0}function sD(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;a:{b:{c:{switch(L[a+92>>2]-2|0){case 0:b=L[a+100>>2];L[c>>2]=L[a+96>>2];L[c+4>>2]=b;b=L[a+108>>2];L[c+8>>2]=L[a+104>>2];L[c+12>>2]=b;a=a+112|0;break b;case 1:d:{switch(b|0){case 0:b=L[a+100>>2];L[c>>2]=L[a+96>>2];L[c+4>>2]=b;b=L[a+108>>2];L[c+8>>2]=L[a+104>>2];L[c+12>>2]=b;a=a+112|0;break b;case 1:b=L[a+124>>2];L[c+8>>2]=L[a+120>>2];L[c+12>>2]=b;b=L[a+116>>2];L[c>>2]=L[a+112>>2];L[c+4>>2]=b;a=a+128|0;break b;case 2:break d;default:break a}}b=L[a+140>>2];L[c+8>>2]=L[a+136>>2];L[c+12>>2]=b;b=L[a+132>>2];L[c>>2]=L[a+128>>2];L[c+4>>2]=b;a=a+96|0;break b;case 2:break c;default:break a}}e:{switch(b|0){case 0:b=L[a+100>>2];L[c>>2]=L[a+96>>2];L[c+4>>2]=b;b=L[a+108>>2];L[c+8>>2]=L[a+104>>2];L[c+12>>2]=b;a=a+112|0;break b;case 1:b=L[a+124>>2];L[c+8>>2]=L[a+120>>2];L[c+12>>2]=b;b=L[a+116>>2];L[c>>2]=L[a+112>>2];L[c+4>>2]=b;a=a+128|0;break b;case 2:b=L[a+140>>2];L[c+8>>2]=L[a+136>>2];L[c+12>>2]=b;b=L[a+132>>2];L[c>>2]=L[a+128>>2];L[c+4>>2]=b;a=a+96|0;break b;case 3:b=L[a+100>>2];L[c>>2]=L[a+96>>2];L[c+4>>2]=b;b=L[a+108>>2];L[c+8>>2]=L[a+104>>2];L[c+12>>2]=b;a=a+144|0;break b;case 4:b=L[a+124>>2];L[c+8>>2]=L[a+120>>2];L[c+12>>2]=b;b=L[a+116>>2];L[c>>2]=L[a+112>>2];L[c+4>>2]=b;a=a+144|0;break b;case 5:break e;default:break a}}b=L[a+140>>2];L[c+8>>2]=L[a+136>>2];L[c+12>>2]=b;b=L[a+132>>2];L[c>>2]=L[a+128>>2];L[c+4>>2]=b;a=a+144|0}b=L[a+4>>2];L[d>>2]=L[a>>2];L[d+4>>2]=b;b=L[a+12>>2];L[d+8>>2]=L[a+8>>2];L[d+12>>2]=b}}function OG(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0,g=S(0),h=S(0),i=0,j=S(0),k=0,l=S(0),m=0,n=0,o=0;i=fa-128|0;fa=i;g=P[b>>2];h=P[b+16>>2];l=g>2];a:{if(P[a+28>>2]<(j>l?l:j)){break a}e=g>h;if(P[(j<(e?g:h)?!e<<4:32)+b>>2]>2]){break a}g=P[b+8>>2];e=b+24|0;h=P[e>>2];l=g>2];if(P[a+36>>2]<(j>l?l:j)){break a}k=e;e=g>h;if(P[(j<(e?g:h)?e?b+8|0:k:f)>>2]>2]){break a}g=P[b+4>>2];e=b+20|0;h=P[e>>2];l=g>2];if(P[a+32>>2]<(j>l?l:j)){break a}k=e;e=g>h;if(L[L[L[a+4>>2]+4>>2]+4>>2]>19|P[(j<(e?g:h)?e?b+4|0:k:f)>>2]>2]){break a}m=L[a+48>>2];e=yb(i+24|0);L[e+4>>2]=1;L[e>>2]=2236;k=L[b+12>>2];f=e- -64|0;L[f>>2]=L[b+8>>2];L[f+4>>2]=k;f=L[b+4>>2];L[e+56>>2]=L[b>>2];L[e+60>>2]=f;f=L[b+28>>2];L[e+80>>2]=L[b+24>>2];L[e+84>>2]=f;f=L[b+20>>2];L[e+72>>2]=L[b+16>>2];L[e+76>>2]=f;f=L[b+44>>2];L[e+96>>2]=L[b+40>>2];L[e+100>>2]=f;f=L[b+36>>2];L[e+88>>2]=L[b+32>>2];L[e+92>>2]=f;P[e+44>>2]=P[a+56>>2];b=L[a+8>>2];f=L[b+8>>2];k=L[b+12>>2];L[i+4>>2]=e;L[i+20>>2]=d;L[i+16>>2]=c;L[i+8>>2]=f;L[i+12>>2]=k;L[i>>2]=b;b=ha[L[L[m>>2]+8>>2]](m,L[a+4>>2],i,L[a+64>>2])|0;f=L[a+44>>2];k=L[f+8>>2];b:{if(L[k+8>>2]==L[L[a+8>>2]+8>>2]){n=f+8|0;o=2;break b}k=L[f+12>>2];n=f+12|0;o=3}L[n>>2]=i;ha[L[L[f>>2]+(o<<2)>>2]](f,c,d);ha[L[L[b>>2]+8>>2]](b,L[a+4>>2],i,L[a+52>>2],L[a+44>>2]);c=L[a+44>>2];L[(L[L[c+8>>2]+8>>2]==L[L[a+8>>2]+8>>2]?8:12)+c>>2]=k;ha[L[L[b>>2]>>2]](b)|0;ha[L[L[m>>2]+60>>2]](m,b);Oa(e)}fa=i+128|0}function Zf(a,b){var c=0,d=0,e=0,f=0,g=0,h=S(0),i=0,j=0;e=(E(b),x(2));f=(e<<1)+16777216>>>0<16777217;a:{b:{c:{c=(E(a),x(2));d:{if(c-2139095040>>>0>=2164260864){if(f){break d}break b}if(!f){break c}}h=S(1);if((c|0)==1065353216){break a}g=e<<1;if(!g){break a}c=c<<1;if(!(g>>>0<4278190081&c>>>0<=4278190080)){return S(a+b)}if((c|0)==2130706432){break a}return c>>>0>2130706431^(e|0)>=0?S(0):S(b*b)}if((c<<1)+16777216>>>0<16777217){h=S(a*a);if((c|0)<0){h=(Qj(e)|0)==1?S(-h):h}if((e|0)>=0){break a}c=fa-16|0;P[c+12>>2]=S(1)/h;return P[c+12>>2]}if((c|0)<0){e=Qj(e);if(!e){a=S(a-a);return S(a/a)}g=((e|0)==1)<<16;c=c&2147483647}if(c>>>0>8388607){break b}c=((E(S(a*S(8388608))),x(2))&2147483647)-192937984|0}e=c-1060306944|0;f=e>>>15&240;d=+(z(2,c-(e&-8388608)|0),F())*Q[f+26536>>3]+-1;i=d*d;d=((Q[3349]*d+Q[3350])*(i*i)+((Q[3351]*d+Q[3352])*i+(Q[3353]*d+(Q[f+26544>>3]+ +(e>>23)))))*+b;C(+d);c=x(1)|0;x(0)|0;e:{c=c&2147450880;if((c|0)==1079967744|c>>>0<1079967744){break e}if(d>127.99999995700433){c=fa-16|0;P[c+12>>2]=g?S(-15845632502852868e13):S(15845632502852868e13);return S(P[c+12>>2]*S(15845632502852868e13))}if(!(d<=-150)){break e}c=fa-16|0;P[c+12>>2]=g?S(-2524354896707238e-44):S(2524354896707238e-44);return S(P[c+12>>2]*S(2524354896707238e-44))}i=Q[3308];j=i+d;d=d-(j-i);d=(Q[3309]*d+Q[3310])*(d*d)+(Q[3311]*d+1);C(+j);x(1)|0;f=x(0)|0;c=g+f|0;g=((f&31)<<3)+26208|0;f=L[g>>2];e=f;c=L[g+4>>2]+(c<<15)|0;z(0,e|0);z(1,(e>>>0>>0?c+1|0:c)|0);h=S(d*+B())}return h}function YH(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0;L[7537]=L[7537]+1;e=L[b+12>>2]>L[c+12>>2];h=e?b:c;f=L[h+12>>2];i=e?c:b;g=L[i+12>>2];b=f<<16|g;b=(b<<15^-1)+b|0;b=R(b>>10^b,9);b=b>>6^b;b=(b<<11^-1)+b|0;j=L[a+12>>2]-1&(b>>16^b);c=L[L[a+44>>2]+(j<<2)>>2];a:{if((c|0)==-1){break a}k=L[a- -64>>2];e=L[a+16>>2];while(1){b=e+(c<<4)|0;if(!((g|0)==L[L[b>>2]+12>>2]&(f|0)==L[L[b+4>>2]+12>>2])){c=L[(c<<2)+k>>2];if((c|0)!=-1){continue}break a}break}ha[L[L[a>>2]+32>>2]](a,b,d);l=L[(e+(c<<4)|0)+12>>2];b:{c:{f=L[a+44>>2]+(j<<2)|0;c=L[f>>2];e=b-L[a+16>>2]>>4;if((c|0)==(e|0)){break c}g=L[a+64>>2];while(1){b=c;c=L[g+(b<<2)>>2];if((e|0)!=(c|0)){continue}break}if((b|0)==-1){break c}c=b<<2;b=L[a+64>>2];L[c+b>>2]=L[b+(e<<2)>>2];break b}L[f>>2]=L[L[a+64>>2]+(e<<2)>>2]}f=L[a+8>>2]-1|0;b=L[a+72>>2];if(b){ha[L[L[b>>2]+12>>2]](b,i,h,d)|0}if((e|0)!=(f|0)){d:{e:{h=L[a+16>>2];d=h+(f<<4)|0;b=L[L[d+4>>2]+12>>2]<<16|L[L[d>>2]+12>>2];b=(b<<15^-1)+b|0;b=R(b>>10^b,9);b=b>>6^b;b=(b<<11^-1)+b|0;i=L[a+12>>2]-1&(b>>16^b);g=L[a+44>>2]+(i<<2)|0;c=L[g>>2];if((f|0)==(c|0)){break e}j=L[a+64>>2];while(1){b=c;c=L[j+(b<<2)>>2];if((f|0)!=(c|0)){continue}break}if((b|0)==-1){break e}c=b<<2;b=L[a+64>>2];L[c+b>>2]=L[b+(f<<2)>>2];break d}L[g>>2]=L[L[a+64>>2]+(f<<2)>>2]}c=L[d+4>>2];b=h+(e<<4)|0;L[b>>2]=L[d>>2];L[b+4>>2]=c;c=L[d+12>>2];L[b+8>>2]=L[d+8>>2];L[b+12>>2]=c;b=L[a+44>>2]+(i<<2)|0;L[L[a+64>>2]+(e<<2)>>2]=L[b>>2];L[b>>2]=e}L[a+8>>2]=L[a+8>>2]-1}return l|0}function Vo(a,b,c,d,e,f,g,h,i,j,k){a=a|0;b=b|0;c=c|0;d=d|0;e=S(e);f=S(f);g=S(g);h=S(h);i=i|0;j=j|0;k=S(k);var l=0;l=fa-288|0;fa=l;L[l+284>>2]=a;L[l+280>>2]=b;L[l+276>>2]=c;L[l+272>>2]=d;P[l+268>>2]=e;P[l+264>>2]=f;P[l+260>>2]=g;P[l+256>>2]=h;L[l+252>>2]=i;J[l+251|0]=j;P[l+244>>2]=k;a=L[l+284>>2];L[l+240>>2]=L[l+272>>2];Ub(l+224|0,L[l+276>>2],L[l+272>>2]);P[l+220>>2]=P[l+244>>2]*S(.01745329238474369);e=S(S(P[l+256>>2]-P[l+260>>2])/P[l+220>>2]);a:{if(S(T(e))>2]=b;if(!L[l+216>>2]){L[l+216>>2]=1}b=L[l+280>>2];c=l+152|0;Xb(c,l+268|0,L[l+240>>2]);P[l+148>>2]=Ra(P[l+260>>2]);d=l+168|0;Ga(d,c,l+148|0);c=l+184|0;ta(c,b,d);b=l+116|0;Xb(b,l+264|0,l+224|0);P[l+112>>2]=Qa(P[l+260>>2]);d=l+132|0;Ga(d,b,l+112|0);ta(l+200|0,c,d);if(J[l+251|0]&1){ha[L[L[a>>2]+8>>2]](a,L[l+280>>2],l+200|0,L[l+252>>2])}L[l+108>>2]=1;while(1){if(L[l+108>>2]<=L[l+216>>2]){e=P[l+260>>2];P[l+104>>2]=e+S(S(S(P[l+256>>2]-e)*S(L[l+108>>2]))/S(L[l+216>>2]));b=L[l+280>>2];c=l+40|0;Xb(c,l+268|0,L[l+240>>2]);P[l+36>>2]=Ra(P[l+104>>2]);d=l+56|0;Ga(d,c,l+36|0);c=l+72|0;ta(c,b,d);b=l+4|0;Xb(b,l+264|0,l+224|0);P[l>>2]=Qa(P[l+104>>2]);d=l+20|0;Ga(d,b,l);b=l+88|0;ta(b,c,d);ha[L[L[a>>2]+8>>2]](a,l+200|0,b,L[l+252>>2]);b=L[l+100>>2];L[l+208>>2]=L[l+96>>2];L[l+212>>2]=b;b=L[l+92>>2];L[l+200>>2]=L[l+88>>2];L[l+204>>2]=b;L[l+108>>2]=L[l+108>>2]+1;continue}break}if(J[l+251|0]&1){ha[L[L[a>>2]+8>>2]](a,L[l+280>>2],l+200|0,L[l+252>>2])}fa=l+288|0}function ec(a,b,c,d){var e=S(0),f=S(0),g=0,h=S(0),i=S(0),j=S(0),k=S(0),l=S(0),m=S(0),n=S(0),o=S(0),p=S(0),q=S(0),r=S(0),s=S(0),t=S(0),u=S(0),v=S(0),w=S(0),x=S(0),y=S(0),z=S(0),A=S(0),B=S(0);g=fa+-64|0;fa=g;p=P[b+24>>2];q=P[b+20>>2];r=P[b+40>>2];s=P[b+36>>2];j=P[a+40>>2];k=P[a+20>>2];n=P[a+36>>2];l=P[a+24>>2];t=P[b+8>>2];u=P[b>>2];v=P[b+4>>2];w=P[b+16>>2];x=P[b+32>>2];f=P[a+8>>2];h=P[a+4>>2];o=P[a+32>>2];m=P[a+16>>2];i=P[a>>2];L[g+60>>2]=0;L[g+44>>2]=0;z=S(S(m*n)-S(o*k));A=S(S(k*j)-S(n*l));B=S(S(l*o)-S(j*m));e=S(S(1)/S(S(f*z)+S(S(i*A)+S(h*B))));y=S(S(S(i*k)-S(m*h))*e);k=S(S(S(h*l)-S(k*f))*e);l=S(S(S(f*m)-S(l*i))*e);P[g+56>>2]=S(r*y)+S(S(x*k)+S(s*l));m=S(S(S(h*o)-S(n*i))*e);h=S(S(S(f*n)-S(j*h))*e);f=S(S(S(i*j)-S(o*f))*e);P[g+52>>2]=S(r*m)+S(S(x*h)+S(s*f));P[g+40>>2]=S(y*p)+S(S(k*w)+S(l*q));P[g+36>>2]=S(m*p)+S(S(h*w)+S(f*q));L[g+28>>2]=0;i=S(z*e);j=S(A*e);e=S(B*e);P[g+48>>2]=S(r*i)+S(S(x*j)+S(s*e));P[g+32>>2]=S(i*p)+S(S(j*w)+S(e*q));P[g+24>>2]=S(y*t)+S(S(k*u)+S(v*l));P[g+20>>2]=S(m*t)+S(S(h*u)+S(v*f));P[g+16>>2]=S(i*t)+S(S(j*u)+S(v*e));Ma(g+16|0,g);f=P[g+12>>2];h=P[g+8>>2];i=P[g>>2];j=P[g+4>>2];e=S(S(1)/S(_(S(S(f*f)+S(S(h*h)+S(S(i*i)+S(j*j)))))));f=S(f*e);f=fS(1)?S(1):f);P[d>>2]=f+f;L[c+12>>2]=0;f=S(h*e);h=S(i*e);e=S(j*e);i=S(S(f*f)+S(S(h*h)+S(e*e)));a:{if(i>2]=1065353216;L[c+4>>2]=0;e=S(0);break a}j=e;e=S(S(1)/S(_(i)));P[c+4>>2]=j*e;P[c>>2]=h*e;e=S(f*e)}P[c+8>>2]=e;fa=g- -64|0}function hA(a,b,c){a=a|0;b=b|0;c=c|0;oh(a,b,c);P[b+256>>2]=P[a+264>>2];P[b+260>>2]=P[a+268>>2];P[b+264>>2]=P[a+272>>2];P[b+268>>2]=P[a+276>>2];P[b+272>>2]=P[a+280>>2];P[b+276>>2]=P[a+284>>2];P[b+280>>2]=P[a+288>>2];P[b+284>>2]=P[a+292>>2];P[b+288>>2]=P[a+296>>2];P[b+292>>2]=P[a+300>>2];P[b+296>>2]=P[a+304>>2];P[b+300>>2]=P[a+308>>2];P[b+304>>2]=P[a+312>>2];P[b+308>>2]=P[a+316>>2];P[b+312>>2]=P[a+320>>2];P[b+316>>2]=P[a+324>>2];P[b+320>>2]=P[a+328>>2];P[b+324>>2]=P[a+332>>2];P[b+328>>2]=P[a+336>>2];P[b+332>>2]=P[a+340>>2];P[b+448>>2]=P[a+344>>2];P[b+336>>2]=P[a+544>>2];P[b+340>>2]=P[a+548>>2];P[b+344>>2]=P[a+552>>2];P[b+348>>2]=P[a+556>>2];P[b+352>>2]=P[a+348>>2];P[b+356>>2]=P[a+352>>2];P[b+360>>2]=P[a+356>>2];P[b+364>>2]=P[a+360>>2];P[b+368>>2]=P[a+364>>2];P[b+372>>2]=P[a+368>>2];P[b+376>>2]=P[a+372>>2];P[b+380>>2]=P[a+376>>2];P[b+384>>2]=P[a+380>>2];P[b+388>>2]=P[a+384>>2];P[b+392>>2]=P[a+388>>2];P[b+396>>2]=P[a+392>>2];P[b+400>>2]=P[a+396>>2];P[b+404>>2]=P[a+400>>2];P[b+408>>2]=P[a+404>>2];P[b+412>>2]=P[a+408>>2];P[b+416>>2]=P[a+412>>2];P[b+420>>2]=P[a+416>>2];P[b+424>>2]=P[a+420>>2];P[b+428>>2]=P[a+424>>2];P[b+432>>2]=P[a+428>>2];P[b+436>>2]=P[a+432>>2];P[b+440>>2]=P[a+436>>2];P[b+444>>2]=P[a+440>>2];P[b+452>>2]=P[a+444>>2];P[b+456>>2]=P[a+448>>2];L[b+484>>2]=M[a+452|0];P[b+460>>2]=P[a+456>>2];P[b+464>>2]=P[a+460>>2];P[b+468>>2]=P[a+464>>2];P[b+472>>2]=P[a+468>>2];P[b+476>>2]=P[a+472>>2];P[b+480>>2]=P[a+476>>2];return 3502}function wA(a){a=a|0;var b=0,c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0;wa(2806);b=L[a+204>>2];ha[L[L[b>>2]+8>>2]](b,a,L[a+24>>2]);h=L[a+308>>2];if((h|0)>0){i=L[a+316>>2];j=L[a+204>>2];while(1){b=L[i+(g<<2)>>2];c=L[b+740>>2];a:{if(!c){break a}b=L[b+744>>2];if(!b|L[c+204>>2]&3|M[b+204|0]&3){break a}b=L[b+208>>2];d=L[j+16>>2];e=L[c+208>>2];f=d+(e<<3)|0;c=L[f>>2];if((c|0)!=(e|0)){while(1){c=d+(c<<3)|0;L[f>>2]=L[c>>2];e=L[c>>2];f=d+(e<<3)|0;c=L[f>>2];if((c|0)!=(e|0)){continue}break}}f=d+(b<<3)|0;c=L[f>>2];if((c|0)!=(b|0)){while(1){b=d+(c<<3)|0;L[f>>2]=L[b>>2];b=L[b>>2];f=d+(b<<3)|0;c=L[f>>2];if((b|0)!=(c|0)){continue}break}}if((b|0)==(e|0)){break a}c=d+(e<<3)|0;L[c>>2]=b;b=d+(b<<3)|0;L[b+4>>2]=L[b+4>>2]+L[c+4>>2]}g=g+1|0;if((h|0)!=(g|0)){continue}break}}h=L[a+212>>2];if((h|0)>0){i=L[a+220>>2];j=L[a+204>>2];f=0;while(1){b=L[i+(f<<2)>>2];b:{if(!M[b+20|0]){break b}c=L[b+28>>2];if(M[c+204|0]&3){break b}b=L[b+32>>2];if(M[b+204|0]&3){break b}b=L[b+208>>2];d=L[j+16>>2];e=L[c+208>>2];c=d+(e<<3)|0;g=L[c>>2];if((g|0)!=(e|0)){while(1){e=c;c=d+(g<<3)|0;L[e>>2]=L[c>>2];e=L[c>>2];c=d+(e<<3)|0;g=L[c>>2];if((g|0)!=(e|0)){continue}break}}c=d+(b<<3)|0;g=L[c>>2];if((g|0)!=(b|0)){while(1){b=d+(g<<3)|0;L[c>>2]=L[b>>2];b=L[b>>2];c=d+(b<<3)|0;g=L[c>>2];if((b|0)!=(g|0)){continue}break}}if((b|0)==(e|0)){break b}c=d+(e<<3)|0;L[c>>2]=b;b=d+(b<<3)|0;L[b+4>>2]=L[b+4>>2]+L[c+4>>2]}f=f+1|0;if((h|0)!=(f|0)){continue}break}}b=L[a+204>>2];ha[L[L[b>>2]+12>>2]](b,a);va()}function ud(a,b,c,d,e){var f=0,g=0,h=S(0),i=S(0),j=S(0),k=S(0),l=S(0),m=S(0),n=S(0),o=S(0),p=0,q=S(0);f=L[a+9288>>2];if(f){g=L[f+48>>2];if(g){L[g+44>>2]=L[f+44>>2]}g=L[f+44>>2];if(g){L[g+48>>2]=L[f+48>>2]}if(L[a+9288>>2]==(f|0)){L[a+9288>>2]=L[f+48>>2]}g=a+9292|0;L[g>>2]=L[g>>2]-1;L[f+44>>2]=0;L[f+48>>2]=L[a+9280>>2];g=L[a+9280>>2];if(g){L[g+44>>2]=f}L[a+9280>>2]=f;g=a+9284|0;L[g>>2]=L[g>>2]+1;L[f+28>>2]=d;L[f+24>>2]=c;L[f+20>>2]=b;J[f+55|0]=0;k=P[c+24>>2];q=P[d+24>>2];h=P[b+24>>2];l=P[d+20>>2];j=P[b+20>>2];m=P[c+20>>2];n=P[c+16>>2];o=P[d+16>>2];i=P[b+16>>2];L[f+12>>2]=0;n=S(n-i);l=S(l-j);i=S(o-i);m=S(m-j);j=S(S(n*l)-S(i*m));P[f+8>>2]=j;k=S(k-h);o=S(k*i);i=S(q-h);h=S(o-S(i*n));P[f+4>>2]=h;i=S(S(m*i)-S(l*k));P[f>>2]=i;p=2;a:{h=S(_(S(S(j*j)+S(S(i*i)+S(h*h)))));if(!(h>S(9999999747378752e-20))){break a}g=f+16|0;b:{if(zg(f,b,c,g)){break b}if(zg(f,c,d,g)){break b}if(zg(f,d,b,g)){break b}P[f+16>>2]=S(S(P[b+24>>2]*P[f+8>>2])+S(S(P[b+16>>2]*P[f>>2])+S(P[b+20>>2]*P[f+4>>2])))/h}h=S(S(1)/h);P[f>>2]=h*P[f>>2];P[f+4>>2]=h*P[f+4>>2];P[f+8>>2]=h*P[f+8>>2];if(e){return f}p=3;if(!(P[g>>2]>=S(-9999999747378752e-21))){break a}return f}L[a>>2]=p;b=L[f+48>>2];if(b){L[b+44>>2]=L[f+44>>2]}b=L[f+44>>2];if(b){L[b+48>>2]=L[f+48>>2]}if(L[a+9280>>2]==(f|0)){L[a+9280>>2]=L[f+48>>2]}L[a+9284>>2]=L[a+9284>>2]-1;L[f+44>>2]=0;L[f+48>>2]=L[a+9288>>2];b=L[a+9288>>2];if(b){L[b+44>>2]=f}L[a+9288>>2]=f;L[a+9292>>2]=L[a+9292>>2]+1;return 0}L[a>>2]=5;return 0}function Qe(a,b){var c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;a:{b:{c:{d:{e:{if(M[a+164|0]){m=a+128|0;c=L[m>>2];if((c|0)!=L[a+132>>2]){break b}i=c?c<<1:1;if((i|0)<=(c|0)){break b}if(i){L[8513]=L[8513]+1;h=ha[L[6798]](i<<2,16)|0;c=L[a+128>>2]}d=L[a+136>>2];if((c|0)<=0){break e}if(c>>>0>=4){k=c&-4;while(1){f=e<<2;L[f+h>>2]=L[d+f>>2];j=f|4;L[j+h>>2]=L[d+j>>2];j=f|8;L[j+h>>2]=L[d+j>>2];f=f|12;L[f+h>>2]=L[d+f>>2];e=e+4|0;l=l+4|0;if((k|0)!=(l|0)){continue}break}}c=c&3;if(!c){break d}while(1){f=e<<2;L[f+h>>2]=L[d+f>>2];e=e+1|0;g=g+1|0;if((c|0)!=(g|0)){continue}break}break d}m=a+148|0;g=L[m>>2];f:{if((g|0)!=L[a+152>>2]){break f}f=g?g<<1:1;if((f|0)<=(g|0)){break f}if(f){L[8513]=L[8513]+1;h=ha[L[6798]](f<<1,16)|0;g=L[a+148>>2]}c=L[a+156>>2];g:{h:{if((g|0)>0){if(g>>>0>=4){i=g&-4;while(1){d=e<<1;K[d+h>>1]=N[c+d>>1];k=d|2;K[k+h>>1]=N[c+k>>1];k=d|4;K[k+h>>1]=N[c+k>>1];d=d|6;K[d+h>>1]=N[c+d>>1];e=e+4|0;j=j+4|0;if((i|0)!=(j|0)){continue}break}}d=g&3;if(d){while(1){i=e<<1;K[i+h>>1]=N[c+i>>1];e=e+1|0;l=l+1|0;if((d|0)!=(l|0)){continue}break}}if(M[a+160|0]){break h}break g}if(!c|!M[a+160|0]){break g}}if(c){L[8514]=L[8514]+1;ha[L[6799]](c)}g=L[a+148>>2]}L[a+156>>2]=h;L[a+152>>2]=f;J[a+160|0]=1}e=L[a+156>>2];K[e+(g<<1)>>1]=b;break a}if(!d){break c}}if(d?M[a+140|0]:0){L[8514]=L[8514]+1;ha[L[6799]](d)}c=L[a+128>>2]}L[a+136>>2]=h;L[a+132>>2]=i;J[a+140|0]=1}e=L[a+136>>2];L[e+(c<<2)>>2]=b;g=L[a+128>>2]}L[m>>2]=g+1;L[L[a+32>>2]+4>>2]=e}function DE(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=0,g=S(0),h=S(0),i=S(0),j=S(0),k=S(0),l=S(0),m=S(0),n=S(0),o=S(0),p=S(0),q=S(0),r=S(0),s=0,t=S(0),u=S(0),v=S(0),w=S(0),x=S(0),y=S(0),z=S(0),A=S(0),B=S(0),C=S(0),D=S(0),E=S(0),F=S(0),G=S(0),H=S(0),I=S(0),J=S(0),K=S(0);f=fa-48|0;fa=f;j=P[b+36>>2];k=P[b+20>>2];l=P[b+40>>2];m=P[b+24>>2];n=P[b+4>>2];o=P[b+8>>2];g=P[c+8>>2];p=P[b+32>>2];h=P[c>>2];q=P[b>>2];i=P[c+4>>2];r=P[b+16>>2];L[f+44>>2]=0;P[f+32>>2]=S(p*g)+S(S(q*h)+S(r*i));P[f+40>>2]=S(l*g)+S(S(o*h)+S(i*m));P[f+36>>2]=S(j*g)+S(S(n*h)+S(i*k));s=f+16|0;ha[L[L[a>>2]+64>>2]](s,a,f+32|0);m=P[b+56>>2];n=P[b+40>>2];o=P[b+36>>2];p=P[b+52>>2];q=P[b+24>>2];r=P[b+20>>2];t=P[b+32>>2];u=P[b+48>>2];v=P[b+8>>2];w=P[b>>2];x=P[b+4>>2];y=P[b+16>>2];g=P[f+24>>2];h=P[f+16>>2];i=P[f+20>>2];L[f+12>>2]=0;P[f+8>>2]=-P[f+40>>2];P[f+4>>2]=-P[f+36>>2];P[f>>2]=-P[f+32>>2];ha[L[L[a>>2]+64>>2]](s,a,f);z=P[b+56>>2];A=P[b+40>>2];B=P[b+36>>2];C=P[b+52>>2];D=P[b+24>>2];E=P[b+20>>2];F=P[b+32>>2];G=P[b+48>>2];H=P[b+8>>2];I=P[b>>2];J=P[b+4>>2];K=P[b+16>>2];j=P[f+24>>2];k=P[f+16>>2];l=P[f+20>>2];P[d>>2]=S(S(m+S(S(g*n)+S(S(h*t)+S(i*o))))*P[c+8>>2])+S(S(S(u+S(S(g*v)+S(S(h*w)+S(i*x))))*P[c>>2])+S(S(p+S(S(g*q)+S(S(h*y)+S(i*r))))*P[c+4>>2]));g=S(S(S(z+S(S(j*A)+S(S(k*F)+S(l*B))))*P[c+8>>2])+S(S(S(G+S(S(j*H)+S(S(k*I)+S(l*J))))*P[c>>2])+S(S(C+S(S(j*D)+S(S(k*K)+S(l*E))))*P[c+4>>2])));P[e>>2]=g;h=P[d>>2];if(h>g){P[d>>2]=g;P[e>>2]=h}fa=f+48|0}function Wv(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0;g=fa-16|0;fa=g;L[g+12>>2]=a;L[g+8>>2]=b;L[g+4>>2]=c;a=L[g+8>>2];b=L[g+4>>2];h=fa-16|0;fa=h;L[h+12>>2]=L[g+12>>2];L[h+8>>2]=a;L[h+4>>2]=b;a=L[h+8>>2];i=fa-16|0;fa=i;j=L[h+12>>2];L[i+12>>2]=j+152;L[i+8>>2]=a;a=fa-16|0;f=L[i+12>>2];L[a+12>>2]=f;L[i+4>>2]=L[L[a+12>>2]+4>>2];a=L[i+4>>2];b=fa-16|0;L[b+12>>2]=f;if(L[L[b+12>>2]+8>>2]==(a|0)){a=fa-16|0;L[a+12>>2]=f;b=L[L[a+12>>2]+4>>2];L[a+12>>2]=f;L[a+8>>2]=b;if(L[a+8>>2]){a=L[a+8>>2]<<1}else{a=1}b=fa-16|0;fa=b;L[b+12>>2]=f;L[b+8>>2]=a;a=fa-16|0;c=L[b+12>>2];L[a+12>>2]=c;if(L[L[a+12>>2]+8>>2]>2]){d=L[b+8>>2];a=fa-16|0;fa=a;L[a+8>>2]=c;L[a+4>>2]=d;e=L[a+8>>2];a:{if(L[a+4>>2]){k=L[a+4>>2];d=fa-16|0;fa=d;L[d+12>>2]=e;L[d+8>>2]=k;L[d+4>>2]=0;e=L[d+8>>2]<<6;L[8513]=L[8513]+1;e=ha[L[6798]](e,16)|0;fa=d+16|0;L[a+12>>2]=e;break a}L[a+12>>2]=0}fa=a+16|0;L[b+4>>2]=L[a+12>>2];a=fa;d=a-16|0;L[d+12>>2]=c;d=L[L[d+12>>2]+4>>2];e=L[b+4>>2];a=a-32|0;fa=a;L[a+28>>2]=c;L[a+24>>2]=0;L[a+20>>2]=d;L[a+16>>2]=e;d=L[a+28>>2];L[a+12>>2]=L[a+24>>2];while(1){if(L[a+12>>2]>2]){e=L[a+12>>2]<<6;Yb(e+L[a+16>>2]|0,e+L[d+12>>2]|0);L[a+12>>2]=L[a+12>>2]+1;continue}break}fa=a+32|0;a=fa-16|0;L[a+12>>2]=c;Db(c,L[L[a+12>>2]+4>>2]);jb(c);J[c+16|0]=1;L[c+12>>2]=L[b+4>>2];L[c+8>>2]=L[b+8>>2]}fa=b+16|0}Yb(L[f+12>>2]+(L[f+4>>2]<<6)|0,L[i+8>>2]);L[f+4>>2]=L[f+4>>2]+1;fa=i+16|0;Hf(j+172|0,h+4|0);fa=h+16|0;fa=g+16|0}function Nk(a,b){a=a|0;b=S(b);var c=0,d=S(0),e=S(0),f=S(0),g=S(0),h=S(0),i=S(0),j=S(0),k=S(0),l=0,m=0,n=S(0);wa(2960);l=L[a+232>>2];if((l|0)>0){while(1){c=L[L[a+240>>2]+(m<<2)>>2];if(!(M[c+204|0]&3)){d=P[c+312>>2];k=P[c+444>>2];e=Zf(S(S(1)-k),b);d=S(d*e);P[c+312>>2]=d;h=S(e*P[c+316>>2]);P[c+316>>2]=h;e=S(e*P[c+320>>2]);P[c+320>>2]=e;g=P[c+328>>2];n=P[c+448>>2];f=Zf(S(S(1)-n),b);g=S(g*f);P[c+328>>2]=g;i=S(f*P[c+332>>2]);P[c+332>>2]=i;f=S(f*P[c+336>>2]);P[c+336>>2]=f;a:{if(!M[c+452|0]){break a}if(!(!(P[c+464>>2]>S(S(f*f)+S(S(g*g)+S(i*i))))|!(P[c+460>>2]>S(S(e*e)+S(S(d*d)+S(h*h)))))){j=P[c+456>>2];f=S(f*j);P[c+336>>2]=f;i=S(i*j);P[c+332>>2]=i;g=S(g*j);P[c+328>>2]=g;e=S(e*j);P[c+320>>2]=e;h=S(h*j);P[c+316>>2]=h;d=S(d*j);P[c+312>>2]=d}j=S(_(S(S(e*e)+S(S(d*d)+S(h*h)))));b:{if(!(jS(.004999999888241291)){k=e;e=S(S(1)/j);P[c+320>>2]=k-S(S(k*e)*S(.004999999888241291));P[c+316>>2]=h-S(S(h*e)*S(.004999999888241291));P[c+312>>2]=d-S(S(d*e)*S(.004999999888241291));break b}L[c+312>>2]=0;L[c+316>>2]=0;L[c+320>>2]=0;L[c+324>>2]=0}d=S(_(S(S(f*f)+S(S(g*g)+S(i*i)))));if(!(dS(.004999999888241291)){d=S(S(1)/d);P[c+336>>2]=f-S(S(f*d)*S(.004999999888241291));P[c+332>>2]=i-S(S(i*d)*S(.004999999888241291));P[c+328>>2]=g-S(S(g*d)*S(.004999999888241291));break a}L[c+328>>2]=0;L[c+332>>2]=0;L[c+336>>2]=0;L[c+340>>2]=0}ue(c,b,c+68|0);l=L[a+232>>2]}m=m+1|0;if((m|0)<(l|0)){continue}break}}va()}function rn(a,b){var c=0,d=S(0),e=S(0),f=S(0),g=S(0),h=S(0),i=S(0),j=S(0),k=0;c=fa+-64|0;fa=c;k=L[b+192>>2];ha[L[L[k>>2]+8>>2]](k,b+4|0,c+48|0,c+32|0);d=P[6794];g=S(P[c+48>>2]-d);P[c+48>>2]=g;h=S(P[c+52>>2]-d);P[c+52>>2]=h;f=S(P[c+56>>2]-d);P[c+56>>2]=f;e=S(d+P[c+32>>2]);P[c+32>>2]=e;i=S(d+P[c+36>>2]);P[c+36>>2]=i;j=S(d+P[c+40>>2]);P[c+40>>2]=j;a:{if(M[b+204|0]&3|(!M[a+44|0]|L[b+236>>2]!=2)){break a}k=L[b+192>>2];ha[L[L[k>>2]+8>>2]](k,b+68|0,c+16|0,c);h=S(P[c+16>>2]-d);P[c+16>>2]=h;f=S(P[c+20>>2]-d);P[c+20>>2]=f;e=S(P[c+24>>2]-d);P[c+24>>2]=e;i=S(d+P[c>>2]);P[c>>2]=i;j=S(d+P[c+4>>2]);P[c+4>>2]=j;d=S(d+P[c+8>>2]);P[c+8>>2]=d;g=P[c+48>>2];if(h>2]=h;g=h}h=P[c+52>>2];if(f>2]=f;h=f}f=P[c+56>>2];if(e>2]=e;f=e}e=P[c+28>>2];if(e>2]){P[c+60>>2]=e}e=P[c+32>>2];if(i>e){P[c+32>>2]=i;e=i}i=P[c+36>>2];if(j>i){P[c+36>>2]=j;i=j}j=P[c+40>>2];if(d>j){P[c+40>>2]=d;j=d}d=P[c+12>>2];if(!(d>P[c+44>>2])){break a}P[c+44>>2]=d}k=L[a+68>>2];b:{c:{if(!(J[b+204|0]&1)){f=S(j-f);g=S(e-g);e=S(g*g);g=S(i-h);if(!(S(S(f*f)+S(e+S(g*g)))>2]+16>>2]](k,L[b+188>>2],c+48|0,c+32|0,L[a+24>>2]);break b}if((L[b+216>>2]&-2)!=4){L[b+216>>2]=5}if(M[30164]){break b}b=L[a+72>>2];if(!b){break b}J[30164]=1;ha[L[L[b>>2]+36>>2]](b,3020);b=L[a+72>>2];ha[L[L[b>>2]+36>>2]](b,4395);b=L[a+72>>2];ha[L[L[b>>2]+36>>2]](b,4472);a=L[a+72>>2];ha[L[L[a>>2]+36>>2]](a,4463)}fa=c- -64|0}function LD(a,b,c){a=a|0;b=b|0;c=c|0;var d=S(0),e=0,f=0,g=0,h=0,i=S(0),j=S(0),k=0,l=S(0),m=S(0),n=0,o=0,p=S(0),q=0,r=S(0),s=0;g=fa-2048|0;fa=g;L[a>>2]=0;L[a+4>>2]=0;L[a+8>>2]=0;L[a+12>>2]=0;d=P[c+8>>2];i=P[c>>2];l=P[c+4>>2];j=S(S(d*d)+S(S(i*i)+S(l*l)));if(j>2]+96>>2]](b)|0)>0){l=S(-0xde0b6b000000000);while(1){e=128;a:{b:{if(((ha[L[L[b>>2]+96>>2]](b)|0)-o|0)>127){break b}e=(ha[L[L[b>>2]+96>>2]](b)|0)-o|0;if((e|0)>0){break b}d=S(-34028234663852886e22);f=-1;break a}c=0;h=(e|0)==1;if(!h){k=e&-2;f=0;while(1){ha[L[L[b>>2]+108>>2]](b,c,(c<<4)+g|0);n=c|1;ha[L[L[b>>2]+108>>2]](b,n,(n<<4)+g|0);c=c+2|0;f=f+2|0;if((k|0)!=(f|0)){continue}break}}n=e&1;if(n){ha[L[L[b>>2]+108>>2]](b,c,(c<<4)+g|0)}c:{if(h){c=0;f=-1;d=S(-34028234663852886e22);break c}s=e&-2;c=0;f=-1;d=S(-34028234663852886e22);e=0;while(1){h=(c<<4)+g|0;j=S(S(P[h+8>>2]*m)+S(S(P[h>>2]*i)+S(p*P[h+4>>2])));h=j>d;q=c|1;k=(q<<4)+g|0;r=S(S(P[k+8>>2]*m)+S(S(P[k>>2]*i)+S(p*P[k+4>>2])));d=h?j:d;k=r>d;d=k?r:d;f=k?q:h?c:f;c=c+2|0;e=e+2|0;if((s|0)!=(e|0)){continue}break}}if(!n){break a}e=(c<<4)+g|0;j=S(S(P[e+8>>2]*m)+S(S(P[e>>2]*i)+S(p*P[e+4>>2])));e=j>d;d=e?j:d;f=e?c:f}if(d>l){c=(f<<4)+g|0;e=L[c+12>>2];L[a+8>>2]=L[c+8>>2];L[a+12>>2]=e;e=L[c+4>>2];L[a>>2]=L[c>>2];L[a+4>>2]=e;l=d}o=o+128|0;if((ha[L[L[b>>2]+96>>2]](b)|0)>(o|0)){continue}break}}fa=g+2048|0} -function cm(a,b,c,d){var e=S(0),f=0,g=0,h=0,i=0,j=0,k=S(0),l=S(0),m=S(0),n=S(0),o=S(0),p=S(0),q=S(0),r=0,s=0,t=0,u=S(0),v=S(0),w=S(0);i=fa-32|0;fa=i;while(1){r=c;h=L[a+12>>2]+R((c+d|0)/2|0,24)|0;s=L[h+20>>2];m=P[h+16>>2];u=P[h+8>>2];v=P[h+4>>2];w=P[h>>2];h=d;while(1){n=P[b+8>>2];k=S(u-n);e=S(k*k);o=P[b>>2];k=S(w-o);l=S(k*k);p=P[b+4>>2];k=S(v-p);k=S(e+S(l+S(k*k)));j=L[a+12>>2];while(1){a:{f=R(c,24)+j|0;e=P[f+16>>2];b:{if(e!=m){if(e>2]-n);l=S(e*e);e=S(P[f>>2]-o);q=S(e*e);e=S(P[f+4>>2]-p);e=S(l+S(q+S(e*e)));if(((e!=k?e>2]<(s|0))|0)!=1){break a}}c=c+1|0;continue}break}while(1){c:{t=R(h,24);g=t+j|0;e=P[g+16>>2];d:{if(e!=m){if(e>m){break d}break c}e=S(P[g+8>>2]-n);l=S(e*e);e=S(P[g>>2]-o);q=S(e*e);e=S(P[g+4>>2]-p);e=S(l+S(q+S(e*e)));if(((e!=k?e>k:L[g+20>>2]>(s|0))|0)!=1){break c}}h=h-1|0;continue}break}if((c|0)<=(h|0)){j=L[f+20>>2];L[i+24>>2]=L[f+16>>2];L[i+28>>2]=j;j=L[f+12>>2];L[i+16>>2]=L[f+8>>2];L[i+20>>2]=j;j=L[f+4>>2];L[i+8>>2]=L[f>>2];L[i+12>>2]=j;j=L[g+4>>2];L[f>>2]=L[g>>2];L[f+4>>2]=j;j=L[g+12>>2];L[f+8>>2]=L[g+8>>2];L[f+12>>2]=j;j=L[g+20>>2];L[f+16>>2]=L[g+16>>2];L[f+20>>2]=j;g=L[i+12>>2];f=L[a+12>>2]+t|0;L[f>>2]=L[i+8>>2];L[f+4>>2]=g;g=L[i+28>>2];L[f+16>>2]=L[i+24>>2];L[f+20>>2]=g;g=L[i+20>>2];L[f+8>>2]=L[i+16>>2];L[f+12>>2]=g;h=h-1|0;c=c+1|0}if((c|0)<=(h|0)){continue}break}if((h|0)>(r|0)){cm(a,b,r,h)}if((c|0)<(d|0)){continue}break}fa=i+32|0}function bl(a,b,c){var d=S(0),e=S(0),f=S(0),g=S(0),h=S(0),i=S(0),j=S(0),k=0;a:{d=P[c+128>>2];if(d==S(0)){break a}L[8133]=L[8133]+1;h=d;d=P[c+96>>2];g=P[c+24>>2];i=P[c+16>>2];j=P[c+20>>2];e=P[c+108>>2];e=S(S(S(h-S(d*P[c+116>>2]))-S(S(S(S(g*P[a+152>>2])+S(S(i*P[a+144>>2])+S(j*P[a+148>>2])))+S(S(P[c+8>>2]*P[a+168>>2])+S(S(P[c>>2]*P[a+160>>2])+S(P[c+4>>2]*P[a+164>>2]))))*e))-S(S(S(S(P[c+56>>2]*P[b+152>>2])+S(S(P[c+48>>2]*P[b+144>>2])+S(P[c+52>>2]*P[b+148>>2])))+S(S(P[c+40>>2]*P[b+168>>2])+S(S(P[c+32>>2]*P[b+160>>2])+S(P[c+36>>2]*P[b+164>>2]))))*e));h=S(d+e);f=P[c+120>>2];k=h>2]=k?f:h;d=k?S(f-d):e;if(L[a+240>>2]){P[a+144>>2]=S(P[a+112>>2]*S(d*S(i*P[a+128>>2])))+P[a+144>>2];P[a+148>>2]=S(S(d*S(j*P[a+132>>2]))*P[a+116>>2])+P[a+148>>2];P[a+152>>2]=S(S(d*S(g*P[a+136>>2]))*P[a+120>>2])+P[a+152>>2];e=P[c+72>>2];f=P[c+68>>2];P[a+160>>2]=S(S(d*P[a+96>>2])*P[c+64>>2])+P[a+160>>2];g=P[a+104>>2];P[a+164>>2]=S(f*S(d*P[a+100>>2]))+P[a+164>>2];P[a+168>>2]=S(e*S(d*g))+P[a+168>>2]}if(!L[b+240>>2]){break a}e=P[c+56>>2];f=P[c+52>>2];P[b+144>>2]=S(P[b+112>>2]*S(d*S(P[c+48>>2]*P[b+128>>2])))+P[b+144>>2];P[b+148>>2]=S(S(d*S(f*P[b+132>>2]))*P[b+116>>2])+P[b+148>>2];P[b+152>>2]=S(S(d*S(e*P[b+136>>2]))*P[b+120>>2])+P[b+152>>2];e=P[c+88>>2];f=P[c+84>>2];P[b+160>>2]=S(S(d*P[b+96>>2])*P[c+80>>2])+P[b+160>>2];g=P[b+104>>2];P[b+164>>2]=S(f*S(d*P[b+100>>2]))+P[b+164>>2];P[b+168>>2]=S(e*S(d*g))+P[b+168>>2]}}function cn(a,b,c){var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;h=fa-32|0;fa=h;e=L[a+12>>2];n=M[a+28|0];l=n?c:b;m=L[l+4>>2];f=L[m+16>>2];a:{if((e|0)>=(f|0)){break a}if(L[a+16>>2]<(f|0)){if(f){L[8513]=L[8513]+1;i=ha[L[6798]](f<<2,16)|0;d=L[a+12>>2]}else{d=e}b:{if((d|0)<=0){break b}if(d>>>0>=4){q=d&-4;while(1){g=j<<2;L[g+i>>2]=L[g+L[a+20>>2]>>2];k=g|4;L[k+i>>2]=L[k+L[a+20>>2]>>2];k=g|8;L[k+i>>2]=L[k+L[a+20>>2]>>2];g=g|12;L[g+i>>2]=L[g+L[a+20>>2]>>2];j=j+4|0;o=o+4|0;if((o|0)!=(q|0)){continue}break}}d=d&3;if(!d){break b}while(1){g=j<<2;L[g+i>>2]=L[g+L[a+20>>2]>>2];j=j+1|0;p=p+1|0;if((d|0)!=(p|0)){continue}break}}d=L[a+20>>2];if(!(d?!d|!M[a+24|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](d)}L[a+20>>2]=i;J[a+24|0]=1;L[a+16>>2]=f}d=(e^-1)+f|0;i=f-e&3;if(i){j=0;while(1){L[L[a+20>>2]+(e<<2)>>2]=0;e=e+1|0;j=j+1|0;if((i|0)!=(j|0)){continue}break}}if(d>>>0<3){break a}while(1){d=e<<2;L[d+L[a+20>>2]>>2]=0;L[(d+L[a+20>>2]|0)+4>>2]=0;L[(d+L[a+20>>2]|0)+8>>2]=0;L[(d+L[a+20>>2]|0)+12>>2]=0;e=e+4|0;if((f|0)!=(e|0)){continue}break}}L[a+12>>2]=f;if((f|0)>0){b=n?b:c;e=0;while(1){c:{if(L[m+64>>2]){L[L[a+20>>2]+(e<<2)>>2]=0;break c}c=L[l+12>>2];d=L[l+8>>2];L[h+12>>2]=L[(L[m+24>>2]+R(e,80)|0)+64>>2];L[h+28>>2]=e;L[h+24>>2]=-1;L[h+16>>2]=d;L[h+20>>2]=c;L[h+8>>2]=l;c=L[a+4>>2];c=ha[L[L[c>>2]+8>>2]](c,h+8|0,b,L[a+32>>2])|0;L[L[a+20>>2]+(e<<2)>>2]=c}e=e+1|0;if((f|0)!=(e|0)){continue}break}}fa=h+32|0}function VH(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;L[7538]=L[7538]+1;d=L[a+24>>2];a:{b:{if(d){if(ha[L[L[d>>2]+8>>2]](d,b,c)|0){break b}break a}if(!(N[c+6>>1]&N[b+4>>1])|!(N[b+6>>1]&N[c+4>>1])){break a}}e=L[b+12>>2]>L[c+12>>2];j=e?b:c;g=L[j+12>>2];k=e?c:b;h=L[k+12>>2];b=g<<16|h;b=(b<<15^-1)+b|0;b=R(b>>10^b,9);b=b>>6^b;b=(b<<11^-1)+b|0;m=b>>16^b;c=a;b=L[c+12>>2];l=m&b-1;a=L[L[c+44>>2]+(l<<2)>>2];c:{if((a|0)!=-1){i=L[c- -64>>2];d=L[c+16>>2];while(1){f=a<<4;e=f+d|0;if((h|0)==L[L[e>>2]+12>>2]&(g|0)==L[L[(d+f|0)+4>>2]+12>>2]){break c}a=L[i+(a<<2)>>2];if((a|0)!=-1){continue}break}}h=L[c+8>>2];e=h;a=b;d:{if((e|0)!=(b|0)){break d}e=b;d=b?b<<1:1;if((d|0)<=(b|0)){break d}e:{if(!d){e=0;a=b;break e}L[8513]=L[8513]+1;e=ha[L[6798]](d<<4,16)|0;a=L[c+8>>2]}g=a;if((g|0)>0){a=0;while(1){f=a<<4;i=f+e|0;f=f+L[c+16>>2]|0;L[i>>2]=L[f>>2];L[i+4>>2]=L[f+4>>2];L[i+8>>2]=L[f+8>>2];L[i+12>>2]=L[f+12>>2];a=a+1|0;if((g|0)!=(a|0)){continue}break}}a=L[c+16>>2];if(!(a?!a|!M[c+20|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](a)}L[c+16>>2]=e;J[c+20|0]=1;L[c+12>>2]=d;e=L[c+8>>2];a=d}L[c+8>>2]=e+1;g=L[c+16>>2];e=g+(h<<4)|0;d=L[c+72>>2];if(d){ha[L[L[d>>2]+8>>2]](d,k,j)|0;a=L[c+12>>2]}if((a|0)>(b|0)){yn(c);l=L[c+12>>2]-1&m}b=L[k+12>>2]>2];L[e>>2]=b?k:j;a=g+(h<<4)|0;L[a+8>>2]=0;L[a+12>>2]=0;L[a+4>>2]=b?j:k;a=L[c+44>>2]+(l<<2)|0;L[L[c- -64>>2]+(h<<2)>>2]=L[a>>2];L[a>>2]=h}}return e|0}function _y(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0;c=b;e=L[b+4>>2];b=L[a+24>>2];a:{if((e|0)<=(b|0)){break a}if((e|0)>L[a+28>>2]){if(e){L[8513]=L[8513]+1;f=ha[L[6798]](e<<2,16)|0;d=L[a+24>>2]}else{d=b}b:{if((d|0)<=0){break b}if(d>>>0>=4){i=d&-4;while(1){h=g<<2;L[h+f>>2]=L[h+L[a+32>>2]>>2];j=h|4;L[j+f>>2]=L[j+L[a+32>>2]>>2];j=h|8;L[j+f>>2]=L[j+L[a+32>>2]>>2];h=h|12;L[h+f>>2]=L[h+L[a+32>>2]>>2];g=g+4|0;k=k+4|0;if((i|0)!=(k|0)){continue}break}}d=d&3;if(!d){break b}while(1){h=g<<2;L[h+f>>2]=L[h+L[a+32>>2]>>2];g=g+1|0;l=l+1|0;if((d|0)!=(l|0)){continue}break}}d=L[a+32>>2];if(!(d?!d|!M[a+36|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](d)}L[a+32>>2]=f;J[a+36|0]=1;L[a+28>>2]=e}d=e+(b^-1)|0;f=e-b&3;if(f){g=0;while(1){L[L[a+32>>2]+(b<<2)>>2]=0;b=b+1|0;g=g+1|0;if((f|0)!=(g|0)){continue}break}}if(d>>>0<3){break a}while(1){d=b<<2;L[d+L[a+32>>2]>>2]=0;L[(d+L[a+32>>2]|0)+4>>2]=0;L[(d+L[a+32>>2]|0)+8>>2]=0;L[(d+L[a+32>>2]|0)+12>>2]=0;b=b+4|0;if((e|0)!=(b|0)){continue}break}}L[a+24>>2]=e;c:{if((e|0)<=0){break c}b=L[a+32>>2];f=0;a=0;if(e>>>0>=4){h=e&-4;g=0;while(1){d=a<<2;L[d+b>>2]=L[d+L[c+12>>2]>>2];i=d|4;L[i+b>>2]=L[i+L[c+12>>2]>>2];i=d|8;L[i+b>>2]=L[i+L[c+12>>2]>>2];d=d|12;L[d+b>>2]=L[d+L[c+12>>2]>>2];a=a+4|0;g=g+4|0;if((h|0)!=(g|0)){continue}break}}d=e&3;if(!d){break c}while(1){e=a<<2;L[e+b>>2]=L[e+L[c+12>>2]>>2];a=a+1|0;f=f+1|0;if((d|0)!=(f|0)){continue}break}}}function oH(a,b){a=a|0;b=b|0;var c=0,d=S(0),e=S(0),f=S(0),g=S(0),h=S(0),i=S(0),j=S(0),k=S(0),l=S(0),m=0,n=S(0),o=S(0),p=S(0),q=S(0),r=S(0),s=S(0),t=S(0),u=S(0),v=S(0),w=S(0),x=S(0),y=S(0),z=0,A=S(0),B=S(0),C=S(0);c=fa-128|0;fa=c;m=L[b+36>>2];b=L[L[a+8>>2]+24>>2]+R(m,80)|0;z=L[b+64>>2];n=P[b+32>>2];o=P[b>>2];p=P[b+16>>2];q=P[b+56>>2];r=P[b+52>>2];s=P[b+48>>2];t=P[b+36>>2];u=P[b+20>>2];v=P[b+4>>2];w=P[b+40>>2];x=P[b+24>>2];y=P[b+8>>2];b=L[a+12>>2];A=P[b+52>>2];B=P[b+56>>2];d=P[b+24>>2];e=P[b+20>>2];f=P[b+40>>2];g=P[b+36>>2];C=P[b+48>>2];h=P[b+8>>2];i=P[b>>2];j=P[b+4>>2];k=P[b+16>>2];l=P[b+32>>2];L[c+124>>2]=0;L[c+108>>2]=0;L[c+92>>2]=0;P[c+104>>2]=S(w*f)+S(S(y*l)+S(x*g));P[c+100>>2]=S(t*f)+S(S(v*l)+S(u*g));P[c+88>>2]=S(w*d)+S(S(y*k)+S(x*e));P[c+84>>2]=S(t*d)+S(S(v*k)+S(u*e));P[c+120>>2]=B+S(S(q*f)+S(S(s*l)+S(g*r)));P[c+116>>2]=A+S(S(q*d)+S(S(s*k)+S(e*r)));L[c+76>>2]=0;P[c+72>>2]=S(w*h)+S(S(y*i)+S(j*x));P[c+68>>2]=S(t*h)+S(S(v*i)+S(j*u));P[c+64>>2]=S(n*h)+S(S(o*i)+S(p*j));P[c+112>>2]=C+S(S(q*h)+S(S(s*i)+S(j*r)));P[c+96>>2]=S(n*f)+S(S(o*l)+S(p*g));P[c+80>>2]=S(n*d)+S(S(o*k)+S(p*e));b=L[a+4>>2];L[c+60>>2]=m;L[c+56>>2]=-1;L[c+48>>2]=b;L[c+44>>2]=z;L[c+40>>2]=0;L[c+52>>2]=c- -64;b=L[a+24>>2];L[c+36>>2]=m;L[c+32>>2]=b;L[c+12>>2]=7480;L[c+20>>2]=0;L[c+24>>2]=-65535;P[c+16>>2]=P[b+4>>2];L[c+28>>2]=L[b+16>>2];Ze(L[a+16>>2],L[a+20>>2],c+40|0,c+12|0);fa=c+128|0}function iw(a,b,c,d,e,f,g,h,i){a=a|0;b=b|0;c=c|0;d=S(d);e=S(e);f=S(f);g=g|0;h=h|0;i=i|0;var j=0,k=S(0),l=S(0),m=S(0),n=S(0),o=0;j=fa-48|0;fa=j;L[j+44>>2]=a;L[j+40>>2]=b;L[j+36>>2]=c;P[j+32>>2]=d;P[j+28>>2]=e;P[j+24>>2]=f;L[j+20>>2]=g;L[j+16>>2]=h;J[j+15|0]=i;a=oa(124);b=L[j+44>>2];c=L[j+40>>2];h=L[j+36>>2];d=P[j+32>>2];k=P[j+28>>2];e=P[j+24>>2];g=L[j+20>>2];i=L[j+16>>2];o=M[j+15|0];L[a+12>>2]=0;L[a+4>>2]=35;L[a+8>>2]=0;L[a>>2]=13384;L[a>>2]=15204;L[a+108>>2]=1065353216;L[a+112>>2]=1065353216;L[a+104>>2]=g;J[a+101|0]=0;J[a+102|0]=0;J[a+100|0]=o&1;L[a+96>>2]=i;L[a+92>>2]=h;P[a+88>>2]=d;P[a+76>>2]=e;P[a+72>>2]=k;L[a+68>>2]=c;L[a+64>>2]=b;L[a+4>>2]=24;L[a+116>>2]=1065353216;L[a+120>>2]=0;d=S(c-1|0);P[a+84>>2]=d;l=S(b-1|0);P[a+80>>2]=l;a:{b:{c:{switch(g|0){default:f=P[a+40>>2];m=P[a+24>>2];d=P[a+36>>2];n=P[a+20>>2];e=P[a+32>>2];k=P[a+16>>2];break a;case 0:P[a+32>>2]=e;P[a+16>>2]=k;L[a+44>>2]=0;P[a+40>>2]=d;P[a+36>>2]=l;L[a+28>>2]=0;L[a+20>>2]=0;L[a+24>>2]=0;f=d;d=l;break a;case 1:P[a+32>>2]=l;L[a+16>>2]=0;L[a+44>>2]=0;P[a+40>>2]=d;P[a+36>>2]=e;L[a+24>>2]=0;L[a+28>>2]=0;P[a+20>>2]=k;f=d;d=e;n=k;k=S(0);break b;case 2:break c}}P[a+32>>2]=l;L[a+16>>2]=0;L[a+20>>2]=0;L[a+44>>2]=0;P[a+40>>2]=e;P[a+36>>2]=d;L[a+28>>2]=0;P[a+24>>2]=k;f=e}m=k;e=l;k=S(0)}L[a+60>>2]=0;P[a+56>>2]=S(m+f)*S(.5);P[a+52>>2]=S(n+d)*S(.5);P[a+48>>2]=S(k+e)*S(.5);fa=j+48|0;return a|0}function Qb(a,b,c){var d=S(0),e=S(0),f=S(0),g=S(0),h=S(0),i=S(0),j=S(0);g=P[c+100>>2];h=P[c+24>>2];i=P[c+16>>2];j=P[c+20>>2];e=P[c+108>>2];d=S(S(S(P[c+112>>2]-S(g*P[c+116>>2]))-S(S(S(S(h*P[a+72>>2])+S(S(i*P[a+64>>2])+S(j*P[a+68>>2])))+S(S(P[c+8>>2]*P[a+88>>2])+S(S(P[c>>2]*P[a+80>>2])+S(P[c+4>>2]*P[a+84>>2]))))*e))-S(S(S(S(P[c+56>>2]*P[b+72>>2])+S(S(P[c+48>>2]*P[b+64>>2])+S(P[c+52>>2]*P[b+68>>2])))+S(S(P[c+40>>2]*P[b+88>>2])+S(S(P[c+32>>2]*P[b+80>>2])+S(P[c+36>>2]*P[b+84>>2]))))*e));e=S(g+d);f=P[c+120>>2];a:{if(e>2];if(!(f>2]=e;if(L[a+240>>2]){P[a+64>>2]=S(P[a+112>>2]*S(d*S(i*P[a+128>>2])))+P[a+64>>2];P[a+68>>2]=S(S(d*S(j*P[a+132>>2]))*P[a+116>>2])+P[a+68>>2];P[a+72>>2]=S(S(d*S(h*P[a+136>>2]))*P[a+120>>2])+P[a+72>>2];e=P[c+72>>2];f=P[c+68>>2];P[a+80>>2]=S(S(d*P[a+96>>2])*P[c+64>>2])+P[a+80>>2];g=P[a+104>>2];P[a+84>>2]=S(f*S(d*P[a+100>>2]))+P[a+84>>2];P[a+88>>2]=S(e*S(d*g))+P[a+88>>2]}if(L[b+240>>2]){e=P[c+56>>2];f=P[c+52>>2];P[b+64>>2]=S(P[b+112>>2]*S(d*S(P[c+48>>2]*P[b+128>>2])))+P[b+64>>2];P[b+68>>2]=S(S(d*S(f*P[b+132>>2]))*P[b+116>>2])+P[b+68>>2];P[b+72>>2]=S(S(d*S(e*P[b+136>>2]))*P[b+120>>2])+P[b+72>>2];e=P[c+88>>2];f=P[c+84>>2];P[b+80>>2]=S(S(d*P[b+96>>2])*P[c+80>>2])+P[b+80>>2];g=P[b+104>>2];P[b+84>>2]=S(f*S(d*P[b+100>>2]))+P[b+84>>2];P[b+88>>2]=S(e*S(d*g))+P[b+88>>2]}}function Bm(a,b,c,d){var e=0,f=0,g=0;e=fa-48|0;fa=e;L[a+12>>2]=0;L[a+4>>2]=35;L[a+8>>2]=0;L[a>>2]=13384;L[a+48>>2]=b;L[a>>2]=16936;L[a+4>>2]=21;a:{if(ha[L[L[b>>2]+40>>2]](b)|0){ha[L[L[b>>2]+48>>2]](b,a+16|0,a+32|0);break a}L[e+44>>2]=0;L[e+36>>2]=0;L[e+40>>2]=0;L[e+32>>2]=1065353216;g=e+16|0;b=e+32|0;ha[L[L[a>>2]+68>>2]](g,a,b);P[a+32>>2]=P[e+16>>2]+P[a+12>>2];L[e+32>>2]=-1082130432;ha[L[L[a>>2]+68>>2]](e,a,b);f=L[e+12>>2];L[e+24>>2]=L[e+8>>2];L[e+28>>2]=f;f=L[e+4>>2];L[e+16>>2]=L[e>>2];L[e+20>>2]=f;P[a+16>>2]=P[e+16>>2]-P[a+12>>2];L[e+40>>2]=0;L[e+44>>2]=0;L[e+32>>2]=0;L[e+36>>2]=0;L[e+36>>2]=1065353216;ha[L[L[a>>2]+68>>2]](g,a,b);P[a+36>>2]=P[e+20>>2]+P[a+12>>2];L[e+36>>2]=-1082130432;ha[L[L[a>>2]+68>>2]](e,a,b);f=L[e+12>>2];L[e+24>>2]=L[e+8>>2];L[e+28>>2]=f;f=L[e+4>>2];L[e+16>>2]=L[e>>2];L[e+20>>2]=f;P[a+20>>2]=P[e+20>>2]-P[a+12>>2];L[e+40>>2]=0;L[e+44>>2]=0;L[e+40>>2]=1065353216;L[e+32>>2]=0;L[e+36>>2]=0;ha[L[L[a>>2]+68>>2]](g,a,b);P[a+40>>2]=P[e+24>>2]+P[a+12>>2];L[e+40>>2]=-1082130432;ha[L[L[a>>2]+68>>2]](e,a,b);b=L[e+12>>2];L[e+24>>2]=L[e+8>>2];L[e+28>>2]=b;b=L[e+4>>2];L[e+16>>2]=L[e>>2];L[e+20>>2]=b;P[a+24>>2]=P[e+24>>2]-P[a+12>>2]}fa=e+48|0;J[a+61|0]=0;J[a+60|0]=c;L[a+52>>2]=0;L[a+56>>2]=0;L[a>>2]=12256;L[a+4>>2]=21;if(d){L[8513]=L[8513]+1;b=gm(ha[L[6798]](172,16)|0);L[a+52>>2]=b;fm(b,L[a+48>>2],M[a+60|0],a+16|0,a+32|0);J[a+61|0]=1}}function Ob(a,b,c,d,e,f,g){var h=0,i=S(0),j=S(0),k=S(0),l=S(0),m=S(0),n=0,o=0,p=S(0),q=S(0),r=S(0);h=fa-128|0;fa=h;a:{if(!b){break a}if(!(!L[b+40>>2]|(c|0)>=(g|0)&(g|0)>=0)){n=c+1|0;Ob(a,L[b+36>>2],n,d,e,f,g);Ob(a,L[b+40>>2],n,d,e,f,g)}if((c|0)<(f|0)){break a}i=P[b+20>>2];j=P[b+24>>2];f=L[b+40>>2];k=P[b+16>>2];p=P[b>>2];l=P[b+4>>2];m=P[b+8>>2];L[h+124>>2]=0;L[h+108>>2]=0;L[h+92>>2]=0;L[h+76>>2]=0;L[h+60>>2]=0;L[h+44>>2]=0;L[h+28>>2]=0;q=S(S(m+j)*S(.5));m=S(S(j-m)*S(.5));j=S(q+m);P[h+120>>2]=j;r=S(S(l+i)*S(.5));l=S(S(i-l)*S(.5));i=S(r+l);P[h+116>>2]=i;P[h+104>>2]=j;P[h+100>>2]=i;P[h+88>>2]=j;l=S(r-l);P[h+84>>2]=l;P[h+72>>2]=j;P[h+68>>2]=l;j=S(q-m);P[h+56>>2]=j;P[h+52>>2]=i;P[h+40>>2]=j;P[h+36>>2]=i;P[h+24>>2]=j;P[h+20>>2]=l;L[h+12>>2]=0;m=S(S(p+k)*S(.5));k=S(S(k-p)*S(.5));i=S(m-k);P[h+112>>2]=i;k=S(m+k);P[h+96>>2]=k;P[h+80>>2]=k;P[h+64>>2]=i;P[h+48>>2]=i;P[h+32>>2]=k;P[h+16>>2]=k;P[h>>2]=i;P[h+8>>2]=j;P[h+4>>2]=l;c=h+16|0;b=f?d:e;ha[L[L[a>>2]+8>>2]](a,h,c,b);d=h+32|0;ha[L[L[a>>2]+8>>2]](a,c,d,b);e=h+48|0;ha[L[L[a>>2]+8>>2]](a,d,e,b);ha[L[L[a>>2]+8>>2]](a,e,h,b);f=h- -64|0;g=h+80|0;ha[L[L[a>>2]+8>>2]](a,f,g,b);n=h+96|0;ha[L[L[a>>2]+8>>2]](a,g,n,b);o=h+112|0;ha[L[L[a>>2]+8>>2]](a,n,o,b);ha[L[L[a>>2]+8>>2]](a,o,f,b);ha[L[L[a>>2]+8>>2]](a,h,f,b);ha[L[L[a>>2]+8>>2]](a,c,g,b);ha[L[L[a>>2]+8>>2]](a,d,n,b);ha[L[L[a>>2]+8>>2]](a,e,o,b)}fa=h+128|0}function cc(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,f=0,g=0,h=0,i=S(0),j=0;L[b>>2]=ha[L[L[c>>2]+28>>2]](c,L[a+28>>2]);L[b+4>>2]=ha[L[L[c>>2]+28>>2]](c,L[a+32>>2]);d=ha[L[L[c>>2]+40>>2]](c,a)|0;f=ha[L[L[c>>2]+28>>2]](c,d)|0;L[b+8>>2]=f;if(f){ha[L[L[c>>2]+48>>2]](c,d)}L[b+12>>2]=L[a+4>>2];L[b+24>>2]=M[a+21|0];L[b+40>>2]=L[a+24>>2];P[b+44>>2]=P[a+16>>2];L[b+48>>2]=M[a+20|0];L[b+20>>2]=L[a+12>>2];L[b+16>>2]=L[a+8>>2];P[b+28>>2]=P[a+36>>2];i=P[a+40>>2];c=0;L[b+36>>2]=0;P[b+32>>2]=i;d=L[a+28>>2];e=L[d+488>>2];a:{if((e|0)<=0){break a}f=L[d+496>>2];if(e>>>0>=4){h=e&-4;d=0;while(1){g=c<<2;if(L[g+f>>2]==(a|0)){L[b+36>>2]=1}if(L[f+(g|4)>>2]==(a|0)){L[b+36>>2]=1}if(L[f+(g|8)>>2]==(a|0)){L[b+36>>2]=1}if(L[f+(g|12)>>2]==(a|0)){L[b+36>>2]=1}c=c+4|0;d=d+4|0;if((h|0)!=(d|0)){continue}break}}e=e&3;if(!e){break a}d=0;while(1){if(L[f+(c<<2)>>2]==(a|0)){L[b+36>>2]=1}c=c+1|0;d=d+1|0;if((e|0)!=(d|0)){continue}break}}c=L[a+32>>2];e=L[c+488>>2];b:{if((e|0)<=0){break b}f=L[c+496>>2];d=0;c=0;if(e>>>0>=4){j=e&-4;h=0;while(1){g=c<<2;if(L[g+f>>2]==(a|0)){L[b+36>>2]=1}if(L[f+(g|4)>>2]==(a|0)){L[b+36>>2]=1}if(L[f+(g|8)>>2]==(a|0)){L[b+36>>2]=1}if(L[f+(g|12)>>2]==(a|0)){L[b+36>>2]=1}c=c+4|0;h=h+4|0;if((j|0)!=(h|0)){continue}break}}e=e&3;if(!e){break b}while(1){if(L[f+(c<<2)>>2]==(a|0)){L[b+36>>2]=1}c=c+1|0;d=d+1|0;if((e|0)!=(d|0)){continue}break}}return 3583}function zD(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=S(0),f=0,g=S(0),h=S(0),i=S(0),j=S(0),k=S(0),l=S(0),m=S(0),n=S(0),o=S(0),p=S(0),q=S(0),r=S(0),s=S(0),t=S(0),u=S(0),v=S(0),w=S(0),x=S(0);f=fa-48|0;fa=f;n=P[c+8>>2];j=P[d+8>>2];p=P[c+4>>2];q=P[d+4>>2];k=P[c>>2];l=P[d>>2];e=P[a+56>>2];a:{if(S(T(e))>S(.7071067690849304)){i=P[a+52>>2];g=S(S(i*i)+S(e*e));h=S(S(1)/S(_(g)));m=S(g*h);t=S(i*h);g=P[a+48>>2];r=S(t*S(-g));o=S(h*S(-e));u=S(g*o);break a}g=P[a+48>>2];i=P[a+52>>2];m=S(S(g*g)+S(i*i));h=S(S(1)/S(_(m)));u=S(m*h);v=S(h*S(-i));r=S(e*v);o=S(g*h);m=S(o*S(-e))}h=P[a+64>>2];L[f+44>>2]=0;L[f+28>>2]=0;s=S(S(j+n)*S(.5));w=S(S(l+k)*S(.5));x=S(S(q+p)*S(.5));h=S(S(S(e*s)+S(S(g*w)+S(x*i)))-h);s=S(s-S(e*h));e=S(S(j-n)*S(.5));j=S(e*e);e=S(S(l-k)*S(.5));k=S(e*e);e=S(S(q-p)*S(.5));e=S(_(S(j+S(k+S(e*e)))));j=S(e*t);p=S(s-j);n=S(e*u);q=S(p-n);P[f+40>>2]=q;k=S(x-S(i*h));l=S(e*o);o=S(k-l);i=S(e*r);r=S(o-i);P[f+36>>2]=r;j=S(j+s);P[f+24>>2]=j-n;k=S(l+k);P[f+20>>2]=k-i;L[f+12>>2]=0;g=S(w-S(g*h));h=S(e*v);l=S(g-h);e=S(e*m);m=S(l-e);P[f+32>>2]=m;g=S(h+g);P[f+16>>2]=g-e;h=S(n+j);P[f+8>>2]=h;j=S(i+k);P[f+4>>2]=j;g=S(e+g);P[f>>2]=g;ha[L[L[b>>2]+8>>2]](b,f,0,0);L[f+44>>2]=0;P[f+40>>2]=h;P[f+36>>2]=j;L[f+28>>2]=0;P[f+24>>2]=n+p;P[f+20>>2]=i+o;P[f+32>>2]=g;P[f+16>>2]=e+l;L[f+12>>2]=0;P[f+8>>2]=q;P[f+4>>2]=r;P[f>>2]=m;ha[L[L[b>>2]+8>>2]](b,f,0,1);fa=f+48|0}function hD(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0;a:{b:{if(M[a+165|0]){l=a+92|0;if(L[l>>2]>=(b|0)){break a}if(b){L[8513]=L[8513]+1;f=ha[L[6798]](b<<4,16)|0}else{f=0}e=L[a+88>>2];c:{if((e|0)<=0){break c}if((e|0)!=1){j=e&-2;while(1){g=d<<4;h=g+f|0;c=g+L[a+96>>2]|0;k=L[c+4>>2];L[h>>2]=L[c>>2];L[h+4>>2]=k;k=L[c+12>>2];L[h+8>>2]=L[c+8>>2];L[h+12>>2]=k;c=g|16;g=c+f|0;c=c+L[a+96>>2]|0;h=L[c+4>>2];L[g>>2]=L[c>>2];L[g+4>>2]=h;h=L[c+12>>2];L[g+8>>2]=L[c+8>>2];L[g+12>>2]=h;d=d+2|0;i=i+2|0;if((j|0)!=(i|0)){continue}break}}if(!(e&1)){break c}d=d<<4;e=d+f|0;d=d+L[a+96>>2]|0;c=L[d+4>>2];L[e>>2]=L[d>>2];L[e+4>>2]=c;c=L[d+12>>2];L[e+8>>2]=L[d+8>>2];L[e+12>>2]=c}d=L[a+96>>2];if(!(d?!d|!M[a+100|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](d)}L[a+96>>2]=f;J[a+100|0]=1;break b}l=a+112|0;if(L[l>>2]>=(b|0)){break a}if(b){L[8513]=L[8513]+1;f=ha[L[6798]](b<<2,16)|0}else{f=0}e=L[a+116>>2];g=L[a+108>>2];d:{e:{if((g|0)>0){if(g>>>0>=4){h=g&-4;while(1){c=d<<2;P[c+f>>2]=P[c+e>>2];j=c|4;P[j+f>>2]=P[e+j>>2];j=c|8;P[j+f>>2]=P[e+j>>2];c=c|12;P[c+f>>2]=P[c+e>>2];d=d+4|0;i=i+4|0;if((h|0)!=(i|0)){continue}break}}c=g&3;if(c){while(1){i=d<<2;P[i+f>>2]=P[e+i>>2];d=d+1|0;k=k+1|0;if((c|0)!=(k|0)){continue}break}}if(M[a+120|0]){break e}break d}if(!e|!M[a+120|0]){break d}}if(e){L[8514]=L[8514]+1;ha[L[6799]](e)}}L[a+116>>2]=f;J[a+120|0]=1}L[l>>2]=b}}function Qz(a,b,c){a=a|0;b=S(b);c=S(c);var d=0,e=0,f=S(0),g=0,h=0,i=S(0),j=S(0),k=S(0),l=S(0),m=S(0),n=S(0),o=0,p=S(0),q=S(0),r=S(0),s=S(0),t=0,u=S(0),v=S(0),w=S(0),x=S(0),y=S(0),z=S(0),A=S(0),B=S(0),C=S(0);h=fa-16|0;fa=h;t=L[a+792>>2];if((t|0)>0){b=S(P[a+336>>2]*b);c=P[a+452>>2];while(1){d=L[a+800>>2]+R(o,96)|0;w=P[d+36>>2];x=P[d+28>>2];y=P[d+32>>2];z=P[d+52>>2];A=P[d+44>>2];B=P[d+48>>2];e=L[d+20>>2];k=P[e+328>>2];f=P[d+12>>2];l=P[d+4>>2];p=P[d+8>>2];g=L[d>>2];i=P[g+16>>2];m=P[d+80>>2];u=P[d+76>>2];j=P[e+332>>2];n=S(S(b*S(S(S(S(f*P[e+44>>2])+S(S(l*P[e+36>>2])+S(p*P[e+40>>2])))+P[e+60>>2])-i))+S(S(c*S(S(S(k*m)-S(u*j))+P[e+320>>2]))-S(i-P[g+32>>2])));C=i;i=P[d+92>>2];q=P[d+24>>2];r=P[g+8>>2];s=j;j=P[d+84>>2];v=P[e+336>>2];m=S(S(b*S(S(S(S(f*P[e+12>>2])+S(S(l*P[e+4>>2])+S(p*P[e+8>>2])))+P[e+52>>2])-r))+S(S(c*S(S(S(s*j)-S(m*v))+P[e+312>>2]))-S(r-P[g+24>>2])));s=S(S(S(f*P[e+28>>2])+S(S(l*P[e+20>>2])+S(p*P[e+24>>2])))+P[e+56>>2]);f=P[g+12>>2];k=S(S(b*S(s-f))+S(S(c*S(S(S(v*u)-S(j*k))+P[e+316>>2]))-S(f-P[g+28>>2])));l=S(q*S(S(P[d+68>>2]*n)+S(S(P[d+60>>2]*m)+S(k*P[d- -64>>2]))));P[g+16>>2]=C+S(i*l);j=f;f=S(q*S(S(z*n)+S(S(A*m)+S(k*B))));P[g+12>>2]=j+S(i*f);n=S(q*S(S(w*n)+S(S(x*m)+S(k*y))));P[g+8>>2]=r+S(i*n);L[h+12>>2]=0;P[h+8>>2]=-l;P[h+4>>2]=-f;P[h>>2]=-n;rb(e,h,d+76|0);o=o+1|0;if((t|0)!=(o|0)){continue}break}}fa=h+16|0}function We(a,b,c){var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=S(0),m=0;d=Og(a);L[d>>2]=13876;L[d+4>>2]=4;J[d+108|0]=1;L[d+104>>2]=0;L[d+96>>2]=0;L[d+100>>2]=0;if((c|0)<=0){L[d+96>>2]=c;Sb(d);return d}L[8513]=L[8513]+1;a=ha[L[6798]](c<<4,16)|0;e=L[d+96>>2];a:{if((e|0)<=0){break a}if((e|0)!=1){j=e&-2;while(1){h=f<<4;i=h+a|0;g=h+L[d+104>>2]|0;k=L[g+4>>2];L[i>>2]=L[g>>2];L[i+4>>2]=k;k=L[g+12>>2];L[i+8>>2]=L[g+8>>2];L[i+12>>2]=k;g=h|16;h=g+a|0;g=g+L[d+104>>2]|0;i=L[g+4>>2];L[h>>2]=L[g>>2];L[h+4>>2]=i;i=L[g+12>>2];L[h+8>>2]=L[g+8>>2];L[h+12>>2]=i;f=f+2|0;m=m+2|0;if((j|0)!=(m|0)){continue}break}}if(!(e&1)){break a}f=f<<4;e=f+a|0;f=f+L[d+104>>2]|0;g=L[f+4>>2];L[e>>2]=L[f>>2];L[e+4>>2]=g;g=L[f+12>>2];L[e+8>>2]=L[f+8>>2];L[e+12>>2]=g}f=L[d+104>>2];if(!(f?!f|!M[d+108|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](f)}L[d+104>>2]=a;J[d+108|0]=1;L[d+100>>2]=c;L[d+96>>2]=c;b:{if((c|0)<=0){break b}f=0;if((c|0)!=1){g=c&-2;a=0;while(1){h=L[b+4>>2];i=L[b>>2];l=P[b+8>>2];j=f<<4;e=j+L[d+104>>2]|0;L[e+12>>2]=0;P[e+8>>2]=l;L[e>>2]=i;L[e+4>>2]=h;b=b+16|0;h=L[b>>2];i=L[b+4>>2];e=L[d+104>>2]+(j|16)|0;P[e+8>>2]=P[b+8>>2];L[e+12>>2]=0;L[e>>2]=h;L[e+4>>2]=i;f=f+2|0;b=b+16|0;a=a+2|0;if((g|0)!=(a|0)){continue}break}}if(!(c&1)){break b}c=L[b+4>>2];e=L[b>>2];l=P[b+8>>2];a=L[d+104>>2]+(f<<4)|0;L[a+12>>2]=0;P[a+8>>2]=l;L[a>>2]=e;L[a+4>>2]=c}Sb(d);return d}function yj(a,b){var c=0;c=fa-112|0;fa=c;L[c+108>>2]=a;L[c+104>>2]=b;b=L[c+108>>2];P[c+100>>2]=$b(L[c+104>>2]);P[c+96>>2]=S(2)/P[c+100>>2];a=fa-16|0;L[a+12>>2]=L[c+104>>2];P[c+92>>2]=P[L[a+12>>2]>>2]*P[c+96>>2];L[a+12>>2]=L[c+104>>2];P[c+88>>2]=P[L[a+12>>2]+4>>2]*P[c+96>>2];L[a+12>>2]=L[c+104>>2];P[c+84>>2]=P[L[a+12>>2]+8>>2]*P[c+96>>2];L[a+12>>2]=L[c+104>>2];P[c+80>>2]=P[L[a+12>>2]+12>>2]*P[c+92>>2];L[a+12>>2]=L[c+104>>2];P[c+76>>2]=P[L[a+12>>2]+12>>2]*P[c+88>>2];L[a+12>>2]=L[c+104>>2];P[c+72>>2]=P[L[a+12>>2]+12>>2]*P[c+84>>2];L[a+12>>2]=L[c+104>>2];P[c+68>>2]=P[L[a+12>>2]>>2]*P[c+92>>2];L[a+12>>2]=L[c+104>>2];P[c+64>>2]=P[L[a+12>>2]>>2]*P[c+88>>2];L[a+12>>2]=L[c+104>>2];P[c+60>>2]=P[L[a+12>>2]>>2]*P[c+84>>2];L[a+12>>2]=L[c+104>>2];P[c+56>>2]=P[L[a+12>>2]+4>>2]*P[c+88>>2];L[a+12>>2]=L[c+104>>2];P[c+52>>2]=P[L[a+12>>2]+4>>2]*P[c+84>>2];L[a+12>>2]=L[c+104>>2];P[c+48>>2]=P[L[a+12>>2]+8>>2]*P[c+84>>2];P[c+44>>2]=S(1)-S(P[c+56>>2]+P[c+48>>2]);P[c+40>>2]=P[c+64>>2]-P[c+72>>2];P[c+36>>2]=P[c+60>>2]+P[c+76>>2];P[c+32>>2]=P[c+64>>2]+P[c+72>>2];P[c+28>>2]=S(1)-S(P[c+68>>2]+P[c+48>>2]);P[c+24>>2]=P[c+52>>2]-P[c+80>>2];P[c+20>>2]=P[c+60>>2]-P[c+76>>2];P[c+16>>2]=P[c+52>>2]+P[c+80>>2];P[c+12>>2]=S(1)-S(P[c+68>>2]+P[c+56>>2]);md(b,c+44|0,c+40|0,c+36|0,c+32|0,c+28|0,c+24|0,c+20|0,c+16|0,c+12|0);fa=c+112|0}function tg(a,b,c){var d=S(0),e=S(0),f=S(0),g=S(0),h=S(0),i=S(0),j=S(0),k=0;d=P[c+100>>2];g=P[c+24>>2];h=P[c+16>>2];i=P[c+20>>2];e=P[c+108>>2];e=S(S(S(P[c+112>>2]-S(d*P[c+116>>2]))-S(S(S(S(g*P[a+72>>2])+S(S(h*P[a+64>>2])+S(i*P[a+68>>2])))+S(S(P[c+8>>2]*P[a+88>>2])+S(S(P[c>>2]*P[a+80>>2])+S(P[c+4>>2]*P[a+84>>2]))))*e))-S(S(S(S(P[c+56>>2]*P[b+72>>2])+S(S(P[c+48>>2]*P[b+64>>2])+S(P[c+52>>2]*P[b+68>>2])))+S(S(P[c+40>>2]*P[b+88>>2])+S(S(P[c+32>>2]*P[b+80>>2])+S(P[c+36>>2]*P[b+84>>2]))))*e));j=S(d+e);f=P[c+120>>2];k=j>2]=k?f:j;d=k?S(f-d):e;if(L[a+240>>2]){P[a+64>>2]=S(P[a+112>>2]*S(d*S(h*P[a+128>>2])))+P[a+64>>2];P[a+68>>2]=S(S(d*S(i*P[a+132>>2]))*P[a+116>>2])+P[a+68>>2];P[a+72>>2]=S(S(d*S(g*P[a+136>>2]))*P[a+120>>2])+P[a+72>>2];e=P[c+72>>2];f=P[c+68>>2];P[a+80>>2]=S(S(d*P[a+96>>2])*P[c+64>>2])+P[a+80>>2];g=P[a+104>>2];P[a+84>>2]=S(f*S(d*P[a+100>>2]))+P[a+84>>2];P[a+88>>2]=S(e*S(d*g))+P[a+88>>2]}if(L[b+240>>2]){e=P[c+56>>2];f=P[c+52>>2];P[b+64>>2]=S(P[b+112>>2]*S(d*S(P[c+48>>2]*P[b+128>>2])))+P[b+64>>2];P[b+68>>2]=S(S(d*S(f*P[b+132>>2]))*P[b+116>>2])+P[b+68>>2];P[b+72>>2]=S(S(d*S(e*P[b+136>>2]))*P[b+120>>2])+P[b+72>>2];e=P[c+88>>2];f=P[c+84>>2];P[b+80>>2]=S(S(d*P[b+96>>2])*P[c+80>>2])+P[b+80>>2];g=P[b+104>>2];P[b+84>>2]=S(f*S(d*P[b+100>>2]))+P[b+84>>2];P[b+88>>2]=S(e*S(d*g))+P[b+88>>2]}}function lh(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;f=fa-96|0;fa=f;e=L[a+8>>2];a:{if((e|0)!=L[a+12>>2]){break a}k=e?e<<1:1;if((k|0)<=(e|0)){break a}if(k){L[8513]=L[8513]+1;h=ha[L[6798]](k<<2,16)|0;e=L[a+8>>2]}b:{if((e|0)<=0){break b}if(e>>>0>=4){l=e&-4;while(1){g=i<<2;L[g+h>>2]=L[g+L[a+16>>2]>>2];j=g|4;L[j+h>>2]=L[j+L[a+16>>2]>>2];j=g|8;L[j+h>>2]=L[j+L[a+16>>2]>>2];g=g|12;L[g+h>>2]=L[g+L[a+16>>2]>>2];i=i+4|0;m=m+4|0;if((l|0)!=(m|0)){continue}break}}g=e&3;if(!g){break b}while(1){l=i<<2;L[l+h>>2]=L[l+L[a+16>>2]>>2];i=i+1|0;n=n+1|0;if((g|0)!=(n|0)){continue}break}}i=L[a+16>>2];if(!(!i|!M[a+20|0])){if(i){L[8514]=L[8514]+1;ha[L[6799]](i)}e=L[a+8>>2]}L[a+16>>2]=h;J[a+20|0]=1;L[a+12>>2]=k}L[L[a+16>>2]+(e<<2)>>2]=b;L[a+8>>2]=e+1;e=L[b+16>>2];L[f+40>>2]=L[b+12>>2];L[f+44>>2]=e;e=L[b+8>>2];L[f+32>>2]=L[b+4>>2];L[f+36>>2]=e;e=L[b+32>>2];L[f+56>>2]=L[b+28>>2];L[f+60>>2]=e;e=L[b+24>>2];L[f+48>>2]=L[b+20>>2];L[f+52>>2]=e;e=L[b+48>>2];L[f+72>>2]=L[b+44>>2];L[f+76>>2]=e;e=L[b+40>>2];L[f+64>>2]=L[b+36>>2];L[f+68>>2]=e;e=L[b+64>>2];L[f+88>>2]=L[b+60>>2];L[f+92>>2]=e;e=L[b+56>>2];L[f+80>>2]=L[b+52>>2];L[f+84>>2]=e;e=L[b+192>>2];h=f+16|0;ha[L[L[e>>2]+8>>2]](e,f+32|0,h,f);e=L[a+68>>2];L[b+188>>2]=ha[L[L[e>>2]+8>>2]](e,h,f,L[L[b+192>>2]+4>>2],b,c,d,L[a+24>>2],0);fa=f+96|0}function yt(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0;f=fa-16|0;fa=f;L[f+12>>2]=a;L[f+8>>2]=b;L[f+4>>2]=c;L[f>>2]=d;d=oa(608);b=L[f+4>>2];a=L[f>>2];e=ub(d,5,L[f+12>>2],L[f+8>>2]);L[e>>2]=19392;c=L[b+12>>2];L[e+308>>2]=L[b+8>>2];L[e+312>>2]=c;c=L[b+4>>2];L[e+300>>2]=L[b>>2];L[e+304>>2]=c;c=L[b+28>>2];L[e+324>>2]=L[b+24>>2];L[e+328>>2]=c;c=L[b+20>>2];L[e+316>>2]=L[b+16>>2];L[e+320>>2]=c;c=L[b+44>>2];L[e+340>>2]=L[b+40>>2];L[e+344>>2]=c;c=L[b+36>>2];L[e+332>>2]=L[b+32>>2];L[e+336>>2]=c;c=L[b+60>>2];L[e+356>>2]=L[b+56>>2];L[e+360>>2]=c;c=L[b+52>>2];L[e+348>>2]=L[b+48>>2];L[e+352>>2]=c;b=L[a+12>>2];L[e+372>>2]=L[a+8>>2];L[e+376>>2]=b;b=L[a+4>>2];L[e+364>>2]=L[a>>2];L[e+368>>2]=b;b=L[a+20>>2];L[e+380>>2]=L[a+16>>2];L[e+384>>2]=b;b=L[a+28>>2];L[e+388>>2]=L[a+24>>2];L[e+392>>2]=b;b=L[a+36>>2];L[e+396>>2]=L[a+32>>2];L[e+400>>2]=b;b=L[a+44>>2];L[e+404>>2]=L[a+40>>2];L[e+408>>2]=b;b=L[a+52>>2];L[e+412>>2]=L[a+48>>2];L[e+416>>2]=b;b=L[a+60>>2];L[e+420>>2]=L[a+56>>2];L[e+424>>2]=b;J[e+552|0]=0;L[e+572>>2]=-1082130432;L[e+524>>2]=0;L[e+444>>2]=1566444395;L[e+448>>2]=1566444395;L[e+592>>2]=0;L[e+428>>2]=1065353216;L[e+432>>2]=1050253722;L[e+436>>2]=1065353216;L[e+440>>2]=1008981770;L[e+596>>2]=0;L[e+600>>2]=1060320051;L[e+604>>2]=0;L[e+452>>2]=1566444395;L[e+456>>2]=1028443341;fa=f+16|0;return d|0}function eG(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;L[7545]=L[7545]+1;d=c<<16|b;d=(d<<15^-1)+d|0;d=R(d>>10^d,9);d=d>>6^d;d=(d<<11^-1)+d|0;m=d>>16^d;d=L[a+12>>2];k=m&d-1;e=L[L[a+40>>2]+(k<<2)>>2];a:{if((e|0)!=-1){i=L[a+60>>2];j=L[a+16>>2];while(1){f=j+R(e,12)|0;if(L[f>>2]==(b|0)&L[f+4>>2]==(c|0)){break a}e=L[i+(e<<2)>>2];if((e|0)!=-1){continue}break}}b:{c:{i=L[a+8>>2];f=i;if((f|0)==(d|0)){j=d?d<<1:1;n=(j|0)<=(d|0);if(!n){break c}}else{d=f}L[a+8>>2]=d+1;f=L[a+16>>2];break b}d:{if(!j){f=0;break d}L[8513]=L[8513]+1;f=ha[L[6798]](R(j,12),16)|0;d=L[a+8>>2]}e:{if((d|0)<=0){break e}e=0;if((d|0)!=1){p=d&-2;while(1){g=R(e,12);h=g+L[a+16>>2]|0;l=L[h+4>>2];g=f+g|0;L[g>>2]=L[h>>2];L[g+4>>2]=l;L[g+8>>2]=L[h+8>>2];g=R(e|1,12);h=g+L[a+16>>2]|0;l=L[h+4>>2];g=f+g|0;L[g>>2]=L[h>>2];L[g+4>>2]=l;L[g+8>>2]=L[h+8>>2];e=e+2|0;o=o+2|0;if((p|0)!=(o|0)){continue}break}}if(!(d&1)){break e}e=R(e,12);d=e+f|0;e=e+L[a+16>>2]|0;h=L[e+4>>2];L[d>>2]=L[e>>2];L[d+4>>2]=h;L[d+8>>2]=L[e+8>>2]}d=L[a+16>>2];if(!(d?!d|!M[a+20|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](d)}L[a+16>>2]=f;J[a+20|0]=1;L[a+12>>2]=j;L[a+8>>2]=L[a+8>>2]+1;if(n){break b}dh(a);k=L[a+12>>2]-1&m}f=R(i,12)+f|0;L[f+8>>2]=0;L[f+4>>2]=c;L[f>>2]=b;b=L[a+60>>2]+(i<<2)|0;a=L[a+40>>2]+(k<<2)|0;L[b>>2]=L[a>>2];L[a>>2]=i}return f|0}function Hc(a,b){var c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0;e=fa-32|0;fa=e;a:{if(!L[a>>2]){break a}g=(b|0)<0?L[a+12>>2]:b;if((g|0)<=0){break a}while(1){h=0;b=L[a>>2];f=b+40|0;if(L[f>>2]){while(1){d=L[b+32>>2];b:{if(d>>>0<=b>>>0){d=b;break b}c=L[d+40>>2];l=(c|0)==(b|0);i=((b|0)!=(c|0))<<2;j=L[(i+d|0)+36>>2];c=L[d+32>>2];if(c){k=(((L[c+40>>2]==(d|0))<<2)+c|0)+36|0}else{k=a}L[k>>2]=b;L[j+32>>2]=b;L[d+32>>2]=b;L[b+32>>2]=c;L[d+36>>2]=L[b+36>>2];L[d+40>>2]=L[f>>2];L[L[b+36>>2]+32>>2]=d;L[L[f>>2]+32>>2]=d;c=b+36|0;L[c+(l<<2)>>2]=d;L[c+i>>2]=j;c=d+24|0;f=L[c+4>>2];L[e+24>>2]=L[c>>2];L[e+28>>2]=f;c=d+16|0;f=L[c+4>>2];L[e+16>>2]=L[c>>2];L[e+20>>2]=f;c=d+8|0;f=L[c+4>>2];L[e+8>>2]=L[c>>2];L[e+12>>2]=f;c=L[d+4>>2];L[e>>2]=L[d>>2];L[e+4>>2]=c;c=b+24|0;f=L[c+4>>2];L[d+24>>2]=L[c>>2];L[d+28>>2]=f;c=b+16|0;f=L[c+4>>2];L[d+16>>2]=L[c>>2];L[d+20>>2]=f;c=b+8|0;f=L[c+4>>2];L[d+8>>2]=L[c>>2];L[d+12>>2]=f;c=L[b+4>>2];L[d>>2]=L[b>>2];L[d+4>>2]=c;c=L[e+28>>2];L[b+24>>2]=L[e+24>>2];L[b+28>>2]=c;c=L[e+20>>2];L[b+16>>2]=L[e+16>>2];L[b+20>>2]=c;c=L[e+12>>2];L[b+8>>2]=L[e+8>>2];L[b+12>>2]=c;c=L[e+4>>2];L[b>>2]=L[e>>2];L[b+4>>2]=c}b=L[a+16>>2]>>>h|0;h=h+1&31;b=L[(((b&1)<<2)+d|0)+36>>2];f=b+40|0;if(L[f>>2]){continue}break}}d=Fd(a,b);Ed(a,d?L[a>>2]:0,b);L[a+16>>2]=L[a+16>>2]+1;g=g-1|0;if(g){continue}break}}fa=e+32|0}function Kl(a,b,c,d){var e=0,f=0,g=S(0),h=S(0),i=0,j=S(0),k=0,l=S(0),m=0,n=S(0),o=S(0),p=S(0),q=S(0),r=S(0),s=S(0);j=S(S(S(P[b+8>>2]*P[a+8>>2])+S(S(P[b>>2]*P[a>>2])+S(P[b+4>>2]*P[a+4>>2])))-P[a+12>>2]);if(!(j>S(1.1920928955078125e-7))){e=L[b+4>>2];L[d>>2]=L[b>>2];L[d+4>>2]=e;e=L[b+12>>2];L[d+8>>2]=L[b+8>>2];L[d+12>>2]=e;e=1}m=1;a:{if((c|0)<=1){g=j;break a}h=j;while(1){i=(m<<4)+b|0;n=P[i+8>>2];o=P[i>>2];p=P[i+4>>2];g=S(S(S(n*P[a+8>>2])+S(S(o*P[a>>2])+S(p*P[a+4>>2])))-P[a+12>>2]);k=g>S(1.1920928955078125e-7);if((k|0)!=(h>S(1.1920928955078125e-7)|0)){f=i-16|0;q=P[f>>2];r=P[f+4>>2];s=P[f+8>>2];f=(e<<4)+d|0;L[f+12>>2]=0;h=S(S(-h)/S(g-h));l=S(S(1)-h);P[f+8>>2]=S(n*h)+S(s*l);P[f+4>>2]=S(p*h)+S(l*r);P[f>>2]=S(o*h)+S(l*q);e=e+1|0}if(!k){k=L[i+4>>2];f=(e<<4)+d|0;L[f>>2]=L[i>>2];L[f+4>>2]=k;k=L[i+12>>2];L[f+8>>2]=L[i+8>>2];L[f+12>>2]=k;e=e+1|0}h=g;m=m+1|0;if((m|0)!=(c|0)){continue}break}}i=j>S(1.1920928955078125e-7);if((i|0)!=(g>S(1.1920928955078125e-7)|0)){a=((c<<4)+b|0)-16|0;h=P[a>>2];l=P[a+4>>2];n=P[a+8>>2];o=P[b>>2];p=P[b+4>>2];q=P[b+8>>2];a=(e<<4)+d|0;L[a+12>>2]=0;g=S(S(-g)/S(j-g));j=S(S(1)-g);P[a+8>>2]=S(n*j)+S(g*q);P[a+4>>2]=S(j*l)+S(g*p);P[a>>2]=S(j*h)+S(g*o);e=e+1|0}if(!i){c=L[b+4>>2];a=(e<<4)+d|0;L[a>>2]=L[b>>2];L[a+4>>2]=c;c=L[b+12>>2];L[a+8>>2]=L[b+8>>2];L[a+12>>2]=c;e=e+1|0}return e}function ey(a,b){a=a|0;b=b|0;var c=0,d=S(0),e=S(0),f=0,g=S(0);f=fa-16|0;fa=f;L[f+12>>2]=a;L[f+8>>2]=b;b=L[f+8>>2];a=fa-32|0;fa=a;L[a+28>>2]=L[f+12>>2];L[a+24>>2]=b;b=L[a+28>>2];d=P[b+12>>2];c=fa-16|0;L[c+12>>2]=L[a+24>>2];d=S(S(d*P[L[c+12>>2]>>2])+S(P[b>>2]*P[L[a+24>>2]+12>>2]));e=P[b+4>>2];c=fa-16|0;L[c+12>>2]=L[a+24>>2];d=S(S(e*P[L[c+12>>2]+8>>2])+d);e=P[b+8>>2];c=fa-16|0;L[c+12>>2]=L[a+24>>2];P[a+20>>2]=S(S(-e)*P[L[c+12>>2]+4>>2])+d;d=P[b+12>>2];c=fa-16|0;L[c+12>>2]=L[a+24>>2];d=S(S(d*P[L[c+12>>2]+4>>2])+S(P[b+4>>2]*P[L[a+24>>2]+12>>2]));e=P[b+8>>2];c=fa-16|0;L[c+12>>2]=L[a+24>>2];d=S(S(e*P[L[c+12>>2]>>2])+d);e=P[b>>2];c=fa-16|0;L[c+12>>2]=L[a+24>>2];P[a+16>>2]=S(S(-e)*P[L[c+12>>2]+8>>2])+d;d=P[b+12>>2];c=fa-16|0;L[c+12>>2]=L[a+24>>2];d=S(S(d*P[L[c+12>>2]+8>>2])+S(P[b+8>>2]*P[L[a+24>>2]+12>>2]));e=P[b>>2];c=fa-16|0;L[c+12>>2]=L[a+24>>2];d=S(S(e*P[L[c+12>>2]+4>>2])+d);e=P[b+4>>2];c=fa-16|0;L[c+12>>2]=L[a+24>>2];P[a+12>>2]=S(S(-e)*P[L[c+12>>2]>>2])+d;d=P[b+12>>2];e=P[L[a+24>>2]+12>>2];g=P[b>>2];c=fa-16|0;L[c+12>>2]=L[a+24>>2];d=S(S(d*e)-S(g*P[L[c+12>>2]>>2]));e=P[b+4>>2];c=fa-16|0;L[c+12>>2]=L[a+24>>2];d=S(S(S(-e)*P[L[c+12>>2]+4>>2])+d);e=P[b+8>>2];c=fa-16|0;L[c+12>>2]=L[a+24>>2];P[a+8>>2]=S(S(-e)*P[L[c+12>>2]+8>>2])+d;vc(b,a+20|0,a+16|0,a+12|0,a+8|0);fa=a+32|0;fa=f+16|0;return b|0}function lg(a,b,c){var d=0,e=0,f=S(0),g=S(0),h=S(0),i=S(0),j=S(0),k=S(0),l=S(0),m=S(0),n=S(0),o=S(0),p=S(0),q=S(0),r=S(0),s=S(0),t=S(0);d=fa+-64|0;fa=d;J[b+84|0]=0;a=L[a+116>>2];e=L[a+16>>2];L[d+8>>2]=L[a+12>>2];L[d+12>>2]=e;e=L[a+8>>2];L[d>>2]=L[a+4>>2];L[d+4>>2]=e;e=L[a+32>>2];L[d+24>>2]=L[a+28>>2];L[d+28>>2]=e;e=L[a+24>>2];L[d+16>>2]=L[a+20>>2];L[d+20>>2]=e;e=L[a+48>>2];L[d+40>>2]=L[a+44>>2];L[d+44>>2]=e;e=L[a+40>>2];L[d+32>>2]=L[a+36>>2];L[d+36>>2]=e;e=L[a+64>>2];L[d+56>>2]=L[a+60>>2];L[d+60>>2]=e;e=L[a+56>>2];L[d+48>>2]=L[a+52>>2];L[d+52>>2]=e;a:{if(!c){break a}a=L[a+480>>2];if(!a){break a}ha[L[L[a>>2]+8>>2]](a,d)}r=P[d+52>>2];i=P[d+24>>2];j=P[d+20>>2];f=P[d+56>>2];k=P[d+40>>2];l=P[d+36>>2];s=P[d+48>>2];m=P[d+8>>2];n=P[d+4>>2];o=P[d>>2];p=P[d+16>>2];q=P[d+32>>2];L[b+48>>2]=0;t=f;f=P[b+164>>2];g=P[b+156>>2];h=P[b+160>>2];P[b+44>>2]=t+S(S(k*f)+S(S(q*g)+S(l*h)));P[b+40>>2]=r+S(S(f*i)+S(S(g*p)+S(h*j)));P[b+36>>2]=s+S(S(f*m)+S(S(g*o)+S(h*n)));L[b- -64>>2]=0;f=P[b+180>>2];g=P[b+172>>2];h=P[b+176>>2];P[b+60>>2]=S(k*f)+S(S(q*g)+S(l*h));P[b+56>>2]=S(i*f)+S(S(p*g)+S(j*h));P[b+52>>2]=S(m*f)+S(S(o*g)+S(n*h));f=P[b+196>>2];g=P[b+192>>2];h=P[b+188>>2];L[b+80>>2]=0;P[b+76>>2]=S(k*f)+S(S(q*h)+S(l*g));P[b+72>>2]=S(i*f)+S(S(p*h)+S(j*g));P[b+68>>2]=S(m*f)+S(S(o*h)+S(n*g));fa=d- -64|0}function $F(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0;g=fa-160|0;fa=g;f=L[a+12>>2];a:{if(!f){break a}h=M[a+16|0];i=h?b:c;j=L[i+4>>2];b=h?c:b;h=L[b+4>>2];L[e+4>>2]=f;c=g+144|0;P[c+12>>2]=P[f+752>>2];L[c+8>>2]=j;L[c+4>>2]=h;L[c>>2]=11800;L[g+136>>2]=1566444395;b=L[b+12>>2];f=L[b+12>>2];L[g+16>>2]=L[b+8>>2];L[g+20>>2]=f;f=L[b+4>>2];L[g+8>>2]=L[b>>2];L[g+12>>2]=f;f=L[b+28>>2];L[g+32>>2]=L[b+24>>2];L[g+36>>2]=f;f=L[b+20>>2];L[g+24>>2]=L[b+16>>2];L[g+28>>2]=f;f=L[b+44>>2];L[g+48>>2]=L[b+40>>2];L[g+52>>2]=f;f=L[b+36>>2];L[g+40>>2]=L[b+32>>2];L[g+44>>2]=f;h=L[b+60>>2];f=g- -64|0;L[f>>2]=L[b+56>>2];L[f+4>>2]=h;f=L[b+52>>2];L[g+56>>2]=L[b+48>>2];L[g+60>>2]=f;b=L[i+12>>2];f=L[b+12>>2];L[g+80>>2]=L[b+8>>2];L[g+84>>2]=f;f=L[b+4>>2];L[g+72>>2]=L[b>>2];L[g+76>>2]=f;f=L[b+20>>2];L[g+88>>2]=L[b+16>>2];L[g+92>>2]=f;f=L[b+28>>2];L[g+96>>2]=L[b+24>>2];L[g+100>>2]=f;f=L[b+36>>2];L[g+104>>2]=L[b+32>>2];L[g+108>>2]=f;f=L[b+44>>2];L[g+112>>2]=L[b+40>>2];L[g+116>>2]=f;f=L[b+52>>2];L[g+120>>2]=L[b+48>>2];L[g+124>>2]=f;f=L[b+60>>2];L[g+128>>2]=L[b+56>>2];L[g+132>>2]=f;Mm(c,g+8|0,e,L[d+20>>2],M[a+16|0]);if(!M[a+8|0]){break a}a=L[e+4>>2];if(!L[a+748>>2]){break a}c=L[a+740>>2];d=L[L[e+8>>2]+8>>2];b=(c|0)==(d|0);f=a;a=L[L[e+12>>2]+8>>2];_a(f,(b?c:a)+4|0,(b?a:d)+4|0)}fa=g+160|0}function El(a,b,c,d,e,f){var g=0;L[a+4>>2]=b;L[a>>2]=18956;b=L[c+12>>2];L[a+16>>2]=L[c+8>>2];L[a+20>>2]=b;b=L[c+4>>2];L[a+8>>2]=L[c>>2];L[a+12>>2]=b;b=L[c+28>>2];L[a+32>>2]=L[c+24>>2];L[a+36>>2]=b;b=L[c+20>>2];L[a+24>>2]=L[c+16>>2];L[a+28>>2]=b;b=L[c+44>>2];L[a+48>>2]=L[c+40>>2];L[a+52>>2]=b;b=L[c+36>>2];L[a+40>>2]=L[c+32>>2];L[a+44>>2]=b;g=L[c+60>>2];b=a- -64|0;L[b>>2]=L[c+56>>2];L[b+4>>2]=g;b=L[c+52>>2];L[a+56>>2]=L[c+48>>2];L[a+60>>2]=b;b=L[d+12>>2];L[a+80>>2]=L[d+8>>2];L[a+84>>2]=b;b=L[d+4>>2];L[a+72>>2]=L[d>>2];L[a+76>>2]=b;b=L[d+28>>2];L[a+96>>2]=L[d+24>>2];L[a+100>>2]=b;b=L[d+20>>2];L[a+88>>2]=L[d+16>>2];L[a+92>>2]=b;b=L[d+44>>2];L[a+112>>2]=L[d+40>>2];L[a+116>>2]=b;b=L[d+36>>2];L[a+104>>2]=L[d+32>>2];L[a+108>>2]=b;b=L[d+60>>2];L[a+128>>2]=L[d+56>>2];L[a+132>>2]=b;b=L[d+52>>2];L[a+120>>2]=L[d+48>>2];L[a+124>>2]=b;b=L[e+12>>2];L[a+144>>2]=L[e+8>>2];L[a+148>>2]=b;b=L[e+4>>2];L[a+136>>2]=L[e>>2];L[a+140>>2]=b;b=L[e+28>>2];L[a+160>>2]=L[e+24>>2];L[a+164>>2]=b;b=L[e+20>>2];L[a+152>>2]=L[e+16>>2];L[a+156>>2]=b;b=L[e+44>>2];L[a+176>>2]=L[e+40>>2];L[a+180>>2]=b;b=L[e+36>>2];L[a+168>>2]=L[e+32>>2];L[a+172>>2]=b;b=L[e+60>>2];L[a+192>>2]=L[e+56>>2];L[a+196>>2]=b;b=L[e+52>>2];L[a+184>>2]=L[e+48>>2];L[a+188>>2]=b;L[a+208>>2]=0;P[a+204>>2]=f;L[a+200>>2]=1065353216;return a}function zt(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0,g=0;d=fa-16|0;fa=d;L[d+12>>2]=a;L[d+8>>2]=b;e=oa(608);a=L[d+8>>2];b=rg(e,5,L[d+12>>2]);L[b>>2]=19392;c=L[a+12>>2];L[b+308>>2]=L[a+8>>2];L[b+312>>2]=c;c=L[a+4>>2];L[b+300>>2]=L[a>>2];L[b+304>>2]=c;c=L[a+28>>2];L[b+324>>2]=L[a+24>>2];L[b+328>>2]=c;c=L[a+20>>2];L[b+316>>2]=L[a+16>>2];L[b+320>>2]=c;c=L[a+36>>2];L[b+332>>2]=L[a+32>>2];L[b+336>>2]=c;c=L[a+44>>2];L[b+340>>2]=L[a+40>>2];L[b+344>>2]=c;c=L[a+56>>2];f=L[a+60>>2];g=L[a+48>>2];a=L[a+52>>2];J[b+527|0]=0;L[b+356>>2]=c;L[b+360>>2]=f;L[b+348>>2]=g;L[b+352>>2]=a;a=L[b+304>>2];L[b+364>>2]=L[b+300>>2];L[b+368>>2]=a;a=L[b+312>>2];L[b+372>>2]=L[b+308>>2];L[b+376>>2]=a;a=L[b+320>>2];L[b+380>>2]=L[b+316>>2];L[b+384>>2]=a;a=L[b+328>>2];L[b+388>>2]=L[b+324>>2];L[b+392>>2]=a;a=L[b+344>>2];L[b+404>>2]=L[b+340>>2];L[b+408>>2]=a;a=L[b+336>>2];L[b+396>>2]=L[b+332>>2];L[b+400>>2]=a;J[b+552|0]=0;J[b+526|0]=0;K[b+524>>1]=0;L[b+420>>2]=0;L[b+424>>2]=0;L[b+412>>2]=0;L[b+416>>2]=0;L[b+572>>2]=-1082130432;L[b+452>>2]=1566444395;L[b+444>>2]=1566444395;L[b+448>>2]=1566444395;L[b+604>>2]=0;L[b+596>>2]=0;L[b+600>>2]=1060320051;L[b+592>>2]=0;L[b+456>>2]=1028443341;L[b+436>>2]=1065353216;L[b+440>>2]=1008981770;L[b+428>>2]=1065353216;L[b+432>>2]=1050253722;fa=d+16|0;return e|0}function OA(a,b){a=a|0;b=S(b);var c=0,d=0,e=0,f=S(0),g=0,h=S(0),i=S(0),j=S(0),k=S(0);e=L[a+8>>2];if((e|0)>0){while(1){c=L[L[a+16>>2]+(g<<2)>>2];if(!(!(M[c+236|0]&2)|!c|(!(M[c+204|0]&2)|L[c+216>>2]==2))){e=fa-32|0;fa=e;if(b!=S(0)){d=L[c+480>>2];if(d){ha[L[L[d>>2]+8>>2]](d,c+4|0)}L[c+324>>2]=0;f=S(S(1)/b);P[c+320>>2]=f*S(P[c+60>>2]-P[c+124>>2]);P[c+316>>2]=f*S(P[c+56>>2]-P[c+120>>2]);P[c+312>>2]=f*S(P[c+52>>2]-P[c+116>>2]);ec(c+68|0,c+4|0,e+16|0,e+12|0);i=P[e+16>>2];j=P[e+20>>2];k=P[e+24>>2];h=P[e+12>>2];L[c+340>>2]=0;P[c+336>>2]=f*S(h*k);P[c+332>>2]=f*S(h*j);P[c+328>>2]=f*S(i*h);d=L[c+324>>2];L[c+140>>2]=L[c+320>>2];L[c+144>>2]=d;d=L[c+316>>2];L[c+132>>2]=L[c+312>>2];L[c+136>>2]=d;d=L[c+332>>2];L[c+148>>2]=L[c+328>>2];L[c+152>>2]=d;d=L[c+340>>2];L[c+156>>2]=L[c+336>>2];L[c+160>>2]=d;d=L[c+8>>2];L[c+68>>2]=L[c+4>>2];L[c+72>>2]=d;d=L[c+16>>2];L[c+76>>2]=L[c+12>>2];L[c+80>>2]=d;d=L[c+24>>2];L[c+84>>2]=L[c+20>>2];L[c+88>>2]=d;d=L[c+32>>2];L[c+92>>2]=L[c+28>>2];L[c+96>>2]=d;d=L[c+48>>2];L[c+108>>2]=L[c+44>>2];L[c+112>>2]=d;d=L[c+40>>2];L[c+100>>2]=L[c+36>>2];L[c+104>>2]=d;d=L[c+64>>2];L[c+124>>2]=L[c+60>>2];L[c+128>>2]=d;d=L[c+56>>2];L[c+116>>2]=L[c+52>>2];L[c+120>>2]=d}fa=e+32|0;e=L[a+8>>2]}g=g+1|0;if((g|0)<(e|0)){continue}break}}}function AG(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0;f=fa-160|0;fa=f;g=L[a+12>>2];a:{if(!g){break a}h=L[c+4>>2];i=L[b+4>>2];L[e+4>>2]=g;L[f+152>>2]=1566444395;b=L[b+12>>2];g=L[b+12>>2];L[f+32>>2]=L[b+8>>2];L[f+36>>2]=g;g=L[b+4>>2];L[f+24>>2]=L[b>>2];L[f+28>>2]=g;g=L[b+28>>2];L[f+48>>2]=L[b+24>>2];L[f+52>>2]=g;g=L[b+20>>2];L[f+40>>2]=L[b+16>>2];L[f+44>>2]=g;j=L[b+44>>2];g=f- -64|0;L[g>>2]=L[b+40>>2];L[g+4>>2]=j;g=L[b+36>>2];L[f+56>>2]=L[b+32>>2];L[f+60>>2]=g;g=L[b+60>>2];L[f+80>>2]=L[b+56>>2];L[f+84>>2]=g;g=L[b+52>>2];L[f+72>>2]=L[b+48>>2];L[f+76>>2]=g;b=L[c+12>>2];c=L[b+12>>2];L[f+96>>2]=L[b+8>>2];L[f+100>>2]=c;c=L[b+4>>2];L[f+88>>2]=L[b>>2];L[f+92>>2]=c;c=L[b+20>>2];L[f+104>>2]=L[b+16>>2];L[f+108>>2]=c;c=L[b+28>>2];L[f+112>>2]=L[b+24>>2];L[f+116>>2]=c;c=L[b+36>>2];L[f+120>>2]=L[b+32>>2];L[f+124>>2]=c;c=L[b+44>>2];L[f+128>>2]=L[b+40>>2];L[f+132>>2]=c;c=L[b+52>>2];L[f+136>>2]=L[b+48>>2];L[f+140>>2]=c;c=L[b+60>>2];L[f+144>>2]=L[b+56>>2];L[f+148>>2]=c;b=f+12|0;L[b+8>>2]=h;L[b+4>>2]=i;L[b>>2]=10080;Zm(b,f+24|0,e,L[d+20>>2],0);if(!M[a+8|0]){break a}a=L[e+4>>2];if(!L[a+748>>2]){break a}c=L[a+740>>2];d=L[L[e+8>>2]+8>>2];b=(c|0)==(d|0);g=a;a=L[L[e+12>>2]+8>>2];_a(g,(b?c:a)+4|0,(b?a:d)+4|0)}fa=f+160|0}function Rb(a,b,c,d,e){var f=S(0),g=S(0),h=S(0),i=S(0),j=S(0),k=S(0),l=S(0),m=S(0),n=S(0),o=0,p=S(0);o=fa-16|0;fa=o;f=P[a+52>>2];g=P[a+56>>2];j=P[a+48>>2];h=P[b>>2];k=P[b+4>>2];i=P[b+8>>2];L[e+60>>2]=0;P[e+56>>2]=g+S(i*d);P[e+52>>2]=f+S(k*d);P[e+48>>2]=j+S(h*d);l=P[c+8>>2];m=P[c>>2];n=P[c+4>>2];f=S(_(S(S(l*l)+S(S(m*m)+S(n*n)))));g=S(f*d)>S(.7853981852531433)?S(S(.7853981852531433)/d):f;a:{if(g>2];h=P[o>>2];k=P[o+4>>2];i=P[o+12>>2];L[e+44>>2]=0;L[e+28>>2]=0;L[e+12>>2]=0;l=S(l*f);d=Fa(S(S(g*d)*S(.5)));g=S(n*f);f=S(m*f);m=S(S(S(h*l)+S(S(k*d)+S(i*g)))-S(j*f));n=S(S(S(S(d*i)-S(h*f))-S(g*k))-S(l*j));p=S(S(S(f*k)+S(S(d*j)+S(l*i)))-S(g*h));h=S(S(S(g*j)+S(S(d*h)+S(f*i)))-S(l*k));f=S(S(1)/S(_(S(S(n*n)+S(S(p*p)+S(S(h*h)+S(m*m)))))));d=S(m*f);g=S(n*f);j=S(p*f);f=S(h*f);h=S(S(2)/S(S(g*g)+S(S(j*j)+S(S(f*f)+S(d*d)))));k=S(j*h);i=S(d*k);l=S(f*h);m=S(g*l);P[e+36>>2]=i+m;n=S(f*k);h=S(d*h);p=S(g*h);P[e+32>>2]=n-p;P[e+24>>2]=i-m;i=S(f*h);g=S(g*k);P[e+16>>2]=i+g;P[e+8>>2]=n+p;P[e+4>>2]=i-g;f=S(f*l);d=S(d*h);P[e+40>>2]=S(1)-S(f+d);g=f;f=S(j*k);P[e+20>>2]=S(1)-S(g+f);P[e>>2]=S(1)-S(d+f);fa=o+16|0}function up(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=0,g=0,h=0;f=fa-32|0;fa=f;L[f+28>>2]=a;L[f+24>>2]=b;L[f+20>>2]=c;L[f+16>>2]=d;L[f+12>>2]=e;e=oa(460);a=L[f+12>>2];b=L[f+28>>2];g=L[f+24>>2];c=Wk(e,b,g,L[f+20>>2]);L[c>>2]=22792;L[c+352>>2]=1067030938;L[c+356>>2]=0;d=0;J[c+456|0]=0;L[c+452>>2]=a;J[c+340|0]=1;L[c+336>>2]=0;L[c+368>>2]=0;L[c+372>>2]=0;L[c+360>>2]=0;L[c+364>>2]=1148846080;L[c+328>>2]=0;L[c+332>>2]=0;L[c+376>>2]=0;L[c+380>>2]=0;L[c+384>>2]=0;L[c+388>>2]=0;L[c+392>>2]=0;J[c+424|0]=1;L[c+404>>2]=0;L[c+396>>2]=-1054867456;L[c+400>>2]=0;L[c+420>>2]=0;L[c+412>>2]=0;L[c+416>>2]=0;if(!a){L[8513]=L[8513]+1;a=ek(ha[L[6798]](40,16)|0);J[c+456|0]=1;L[c+452>>2]=a}J[c+350|0]=0;K[c+348>>1]=1;L[c+344>>2]=4302;L[c+388>>2]=b;L[c+384>>2]=g;g=c+408|0;gk(g);h=L[c+412>>2];if((h|0)>0){while(1){b=L[c+420>>2]+(d<<2)|0;a=L[b>>2];L[b>>2]=0;if(a){while(1){b=L[a+280>>2];ra(a);a=b;if(a){continue}break}}d=d+1|0;if((h|0)!=(d|0)){continue}break}}L[c+360>>2]=0;L[c+352>>2]=1067030938;L[c+356>>2]=0;L[c+444>>2]=1;L[c+448>>2]=1;L[c+436>>2]=0;L[c+428>>2]=1048576e3;L[c+432>>2]=0;L[c+392>>2]=0;L[c+376>>2]=0;L[c+380>>2]=0;L[c+368>>2]=0;L[c+372>>2]=0;L[c+404>>2]=0;L[c+396>>2]=-1054867456;L[c+400>>2]=0;gk(g);fa=f+32|0;return e|0}function Td(a,b,c){var d=0,e=0,f=0,g=0;e=fa-80|0;fa=e;L[e+76>>2]=a;L[e+72>>2]=b;L[e+68>>2]=c;g=L[e+72>>2];c=L[e+68>>2];b=fa-48|0;fa=b;f=e+20|0;L[b+44>>2]=f;L[b+40>>2]=g;L[b+36>>2]=c;d=L[b+36>>2];c=fa-16|0;L[c+12>>2]=L[b+40>>2];L[c+8>>2]=0;P[b+32>>2]=mc(d,L[c+12>>2]+(L[c+8>>2]<<4)|0);d=L[b+36>>2];c=fa-16|0;L[c+12>>2]=L[b+40>>2];L[c+8>>2]=0;P[b+28>>2]=lc(d,L[c+12>>2]+(L[c+8>>2]<<4)|0);d=L[b+36>>2];c=fa-16|0;L[c+12>>2]=L[b+40>>2];L[c+8>>2]=0;P[b+24>>2]=kc(d,L[c+12>>2]+(L[c+8>>2]<<4)|0);d=L[b+36>>2];c=fa-16|0;L[c+12>>2]=L[b+40>>2];L[c+8>>2]=1;P[b+20>>2]=mc(d,L[c+12>>2]+(L[c+8>>2]<<4)|0);d=L[b+36>>2];c=fa-16|0;L[c+12>>2]=L[b+40>>2];L[c+8>>2]=1;P[b+16>>2]=lc(d,L[c+12>>2]+(L[c+8>>2]<<4)|0);d=L[b+36>>2];c=fa-16|0;L[c+12>>2]=L[b+40>>2];L[c+8>>2]=1;P[b+12>>2]=kc(d,L[c+12>>2]+(L[c+8>>2]<<4)|0);d=L[b+36>>2];c=fa-16|0;L[c+12>>2]=L[b+40>>2];L[c+8>>2]=2;P[b+8>>2]=mc(d,L[c+12>>2]+(L[c+8>>2]<<4)|0);d=L[b+36>>2];c=fa-16|0;L[c+12>>2]=L[b+40>>2];L[c+8>>2]=2;P[b+4>>2]=lc(d,L[c+12>>2]+(L[c+8>>2]<<4)|0);d=L[b+36>>2];c=fa-16|0;L[c+12>>2]=L[b+40>>2];L[c+8>>2]=2;P[b>>2]=kc(d,L[c+12>>2]+(L[c+8>>2]<<4)|0);lf(f,b+32|0,b+28|0,b+24|0,b+20|0,b+16|0,b+12|0,b+8|0,b+4|0,b);fa=b+48|0;b=e+4|0;tb(b,g,L[e+68>>2]+48|0);Qf(a,f,b);fa=e+80|0}function On(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;g=L[c+4>>2];L[b+16>>2]=L[c>>2];L[b+20>>2]=g;g=L[c+12>>2];L[b+24>>2]=L[c+8>>2];L[b+28>>2]=g;g=L[d+4>>2];L[b+32>>2]=L[d>>2];L[b+36>>2]=g;g=L[d+12>>2];L[b+40>>2]=L[d+8>>2];L[b+44>>2]=g;l=N[b+12>>1];g=fa-16|0;fa=g;k=L[a+60>>2];Kd(a,g+10|0,c,0);Kd(a,g+4|0,d,1);h=L[a+68>>2];f=k+(l<<6)|0;j=N[f+48>>1];i=h+(j<<2)|0;m=N[i>>1];f=N[f+54>>1];h=h+(f<<2)|0;o=N[h>>1];p=N[g+4>>1];n=i;i=N[g+10>>1];K[n>>1]=i;K[h>>1]=N[g+4>>1];h=i-m|0;if((h|0)<0){Jd(a,0,j)}i=p-o|0;if((i|0)>0){bf(a,0,f)}if((h|0)>0){af(a,0,j,e)}if((i|0)<0){Id(a,0,f,e)}h=L[a+72>>2];f=k+(l<<6)|0;j=N[f+50>>1];i=h+(j<<2)|0;m=N[i>>1];f=N[f+56>>1];h=h+(f<<2)|0;o=N[h>>1];p=N[g+6>>1];n=i;i=N[g+12>>1];K[n>>1]=i;K[h>>1]=N[g+6>>1];h=i-m|0;if((h|0)<0){Jd(a,1,j)}i=p-o|0;if((i|0)>0){bf(a,1,f)}if((h|0)>0){af(a,1,j,e)}if((i|0)<0){Id(a,1,f,e)}j=L[a+76>>2];k=k+(l<<6)|0;l=N[k+52>>1];f=j+(l<<2)|0;h=N[f>>1];k=N[k+58>>1];j=j+(k<<2)|0;i=N[j>>1];m=N[g+8>>1];n=f;f=N[g+14>>1];K[n>>1]=f;K[j>>1]=N[g+8>>1];j=f-h|0;if((j|0)<0){Jd(a,2,l)}f=m-i|0;if((f|0)>0){bf(a,2,k)}if((j|0)>0){af(a,2,l,e)}if((f|0)<0){Id(a,2,k,e)}fa=g+16|0;a=L[a+108>>2];if(a){ha[L[L[a>>2]+16>>2]](a,L[b+60>>2],c,d,e)}}function Xy(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;a:{if(ha[L[L[c>>2]+16>>2]](c)|0){break a}h=L[b+712>>2];f=ha[L[L[c>>2]+36>>2]](c)|0;b:{if(!(ha[L[L[c>>2]+8>>2]](c)|0)){break b}a=ha[L[L[c>>2]+20>>2]](c)|0;i=ha[L[L[c>>2]+24>>2]](c)|0;if((h|0)<=0){break b}a=f+(a<<2)|0;g=L[b+720>>2];if((h|0)!=1){j=h&-2;i=i<<2;while(1){e=g+R(d,104)|0;k=L[e+8>>2];l=L[e+12>>2];P[a+8>>2]=P[e+16>>2];L[a>>2]=k;L[a+4>>2]=l;e=g+R(d|1,104)|0;k=L[e+8>>2];l=L[e+12>>2];a=a+i|0;P[a+8>>2]=P[e+16>>2];L[a>>2]=k;L[a+4>>2]=l;a=a+i|0;d=d+2|0;m=m+2|0;if((j|0)!=(m|0)){continue}break}}if(!(h&1)){break b}d=g+R(d,104)|0;g=L[d+8>>2];i=L[d+12>>2];P[a+8>>2]=P[d+16>>2];L[a>>2]=g;L[a+4>>2]=i}if(!(ha[L[L[c>>2]+12>>2]](c)|0)){break a}a=ha[L[L[c>>2]+28>>2]](c)|0;c=ha[L[L[c>>2]+32>>2]](c)|0;if((h|0)<=0){break a}a=f+(a<<2)|0;b=L[b+720>>2];d=0;if((h|0)!=1){i=h&-2;c=c<<2;g=0;while(1){f=b+R(d,104)|0;e=L[f+72>>2];j=L[f+76>>2];P[a+8>>2]=P[f+80>>2];L[a>>2]=e;L[a+4>>2]=j;f=b+R(d|1,104)|0;e=L[f+72>>2];j=L[f+76>>2];a=a+c|0;P[a+8>>2]=P[f+80>>2];L[a>>2]=e;L[a+4>>2]=j;a=a+c|0;d=d+2|0;g=g+2|0;if((i|0)!=(g|0)){continue}break}}if(!(h&1)){break a}b=b+R(d,104)|0;c=L[b+72>>2];d=L[b+76>>2];P[a+8>>2]=P[b+80>>2];L[a>>2]=c;L[a+4>>2]=d}}function gD(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0;a:{b:{if(M[a+164|0]){k=a+132|0;if(L[k>>2]>=(b|0)){break a}if(b){L[8513]=L[8513]+1;e=ha[L[6798]](b<<2,16)|0}else{e=0}d=L[a+136>>2];f=L[a+128>>2];c:{d:{if((f|0)>0){if(f>>>0>=4){l=f&-4;while(1){c=g<<2;L[c+e>>2]=L[d+c>>2];h=c|4;L[h+e>>2]=L[d+h>>2];h=c|8;L[h+e>>2]=L[d+h>>2];c=c|12;L[c+e>>2]=L[d+c>>2];g=g+4|0;i=i+4|0;if((l|0)!=(i|0)){continue}break}}c=f&3;if(c){while(1){f=g<<2;L[f+e>>2]=L[d+f>>2];g=g+1|0;j=j+1|0;if((c|0)!=(j|0)){continue}break}}if(M[a+140|0]){break d}break c}if(!d|!M[a+140|0]){break c}}if(d){L[8514]=L[8514]+1;ha[L[6799]](d)}}L[a+136>>2]=e;J[a+140|0]=1;break b}k=a+152|0;if(L[k>>2]>=(b|0)){break a}if(b){L[8513]=L[8513]+1;e=ha[L[6798]](b<<1,16)|0}else{e=0}d=L[a+156>>2];f=L[a+148>>2];e:{f:{if((f|0)>0){if(f>>>0>=4){l=f&-4;while(1){c=g<<1;K[c+e>>1]=N[d+c>>1];h=c|2;K[h+e>>1]=N[d+h>>1];h=c|4;K[h+e>>1]=N[d+h>>1];c=c|6;K[c+e>>1]=N[d+c>>1];g=g+4|0;i=i+4|0;if((l|0)!=(i|0)){continue}break}}c=f&3;if(c){while(1){f=g<<1;K[f+e>>1]=N[d+f>>1];g=g+1|0;j=j+1|0;if((c|0)!=(j|0)){continue}break}}if(M[a+160|0]){break f}break e}if(!d|!M[a+160|0]){break e}}if(d){L[8514]=L[8514]+1;ha[L[6799]](d)}}L[a+156>>2]=e;J[a+160|0]=1}L[k>>2]=b}}function iF(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;db(a,b,c);P[b+20>>2]=P[a+72>>2];d=L[a+16>>2];L[b+12>>2]=0;L[b+16>>2]=d;if(d){g=ha[L[L[c>>2]+16>>2]](c,76,d)|0;d=L[g+8>>2];L[b+12>>2]=ha[L[L[c>>2]+28>>2]](c,d);if(L[b+16>>2]>0){f=L[a+24>>2];while(1){e=R(h,80);f=e+f|0;P[d+72>>2]=P[f+72>>2];L[d+64>>2]=ha[L[L[c>>2]+28>>2]](c,L[f+64>>2]);if(!(ha[L[L[c>>2]+24>>2]](c,L[(e+L[a+24>>2]|0)+64>>2])|0)){f=L[(e+L[a+24>>2]|0)+64>>2];f=(k=c,l=ha[L[L[f>>2]+52>>2]](f)|0,m=1,j=L[L[c>>2]+16>>2],ha[j](k|0,l|0,m|0)|0);i=L[(e+L[a+24>>2]|0)+64>>2];m=c,l=f,k=ha[L[L[i>>2]+56>>2]](i,L[f+8>>2],c)|0,n=1346455635,o=L[(e+L[a+24>>2]|0)+64>>2],j=L[L[c>>2]+20>>2],ha[j](m|0,l|0,k|0,n|0,o|0)}f=L[a+24>>2];e=e+f|0;L[d+68>>2]=L[e+68>>2];P[d>>2]=P[e>>2];P[d+4>>2]=P[e+4>>2];P[d+8>>2]=P[e+8>>2];P[d+12>>2]=P[e+12>>2];P[d+16>>2]=P[e+16>>2];P[d+20>>2]=P[e+20>>2];P[d+24>>2]=P[e+24>>2];P[d+28>>2]=P[e+28>>2];P[d+32>>2]=P[e+32>>2];P[d+36>>2]=P[e+36>>2];P[d+40>>2]=P[e+40>>2];P[d+44>>2]=P[e+44>>2];P[d+48>>2]=P[e+48>>2];P[d+52>>2]=P[e+52>>2];P[d+56>>2]=P[e+56>>2];P[d+60>>2]=P[e+60>>2];d=d+76|0;h=h+1|0;if((h|0)>2]){continue}break}}ha[L[L[c>>2]+20>>2]](c,g,4186,1497453121,L[g+8>>2])}return 4038}function EC(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=0,g=0,h=S(0),i=S(0),j=S(0),k=S(0),l=S(0),m=S(0),n=S(0),o=S(0),p=S(0),q=S(0),r=S(0),s=S(0),t=S(0),u=S(0),v=S(0),w=S(0),x=S(0),y=S(0),z=S(0),A=S(0),B=S(0),C=0,D=S(0),E=S(0),F=S(0);f=fa+-64|0;fa=f;C=ha[L[L[a>>2]+92>>2]](a)|0;g=L[L[a+184>>2]+(b<<2)>>2];a:{if(C){a=L[a+164>>2]+(b<<6)|0;q=P[a+32>>2];r=P[a>>2];s=P[a+16>>2];t=P[a+56>>2];u=P[a+52>>2];v=P[a+48>>2];w=P[a+36>>2];x=P[a+20>>2];y=P[a+4>>2];z=P[a+40>>2];A=P[a+24>>2];B=P[a+8>>2];D=P[c+52>>2];E=P[c+56>>2];h=P[c+24>>2];i=P[c+20>>2];j=P[c+40>>2];k=P[c+36>>2];F=P[c+48>>2];l=P[c+8>>2];m=P[c>>2];n=P[c+4>>2];o=P[c+16>>2];p=P[c+32>>2];L[f+60>>2]=0;L[f+44>>2]=0;L[f+28>>2]=0;P[f+40>>2]=S(z*j)+S(S(B*p)+S(A*k));P[f+36>>2]=S(w*j)+S(S(y*p)+S(x*k));P[f+24>>2]=S(z*h)+S(S(B*o)+S(A*i));P[f+20>>2]=S(w*h)+S(S(y*o)+S(x*i));P[f+56>>2]=E+S(S(t*j)+S(S(v*p)+S(k*u)));P[f+52>>2]=D+S(S(t*h)+S(S(v*o)+S(i*u)));L[f+12>>2]=0;P[f+32>>2]=S(q*j)+S(S(r*p)+S(s*k));P[f+16>>2]=S(q*h)+S(S(r*o)+S(s*i));P[f>>2]=S(q*l)+S(S(r*m)+S(s*n));P[f+8>>2]=S(z*l)+S(S(B*m)+S(n*A));P[f+4>>2]=S(w*l)+S(S(y*m)+S(n*x));P[f+48>>2]=F+S(S(t*l)+S(S(v*m)+S(n*u)));ha[L[L[g>>2]+8>>2]](g,f,d,e);break a}ha[L[L[g>>2]+8>>2]](g,c,d,e)}fa=f- -64|0}function en(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=S(0),g=0,h=0;c=fa-784|0;fa=c;L[c+732>>2]=0;L[c+736>>2]=0;L[c+744>>2]=0;L[c+748>>2]=0;L[c+740>>2]=1065353216;L[c+752>>2]=0;L[c+756>>2]=0;L[c+764>>2]=0;L[c+768>>2]=0;L[c+760>>2]=1065353216;L[c+772>>2]=0;L[c+776>>2]=0;L[c+780>>2]=0;L[c+724>>2]=0;L[c+728>>2]=0;L[c+720>>2]=1065353216;L[c+712>>2]=0;L[c+716>>2]=0;L[c+544>>2]=6864;P[c+708>>2]=P[a+200>>2];f=P[a+196>>2];g=c+492|0;d=g;L[d+4>>2]=35;L[d+8>>2]=0;L[d>>2]=14328;L[d+44>>2]=1025758986;L[d+12>>2]=1065353216;L[d+16>>2]=1065353216;L[d>>2]=14044;L[d+20>>2]=1065353216;L[d+24>>2]=0;P[d+44>>2]=f;P[d+28>>2]=f;L[d+4>>2]=8;L[d>>2]=16192;d=yb(c+388|0);L[d+4>>2]=1;L[d>>2]=2236;h=L[b+12>>2];e=d- -64|0;L[e>>2]=L[b+8>>2];L[e+4>>2]=h;e=L[b+4>>2];L[d+56>>2]=L[b>>2];L[d+60>>2]=e;e=L[b+20>>2];L[d+72>>2]=L[b+16>>2];L[d+76>>2]=e;e=L[b+28>>2];L[d+80>>2]=L[b+24>>2];L[d+84>>2]=e;e=L[b+36>>2];L[d+88>>2]=L[b+32>>2];L[d+92>>2]=e;e=L[b+44>>2];L[d+96>>2]=L[b+40>>2];L[d+100>>2]=e;J[c+360|0]=0;L[c+336>>2]=953267991;b=c+12|0;L[b+12>>2]=d;L[b+8>>2]=g;L[b+4>>2]=c+28;L[b>>2]=19064;g=b;b=c+720|0;a:{if(!Cl(g,a+4|0,a+68|0,b,b,c+544|0)){break a}f=P[c+708>>2];if(!(f>2])){break a}P[a+200>>2]=f}Oa(d);fa=c+784|0}function ik(a,b){var c=0,d=0,e=0,f=0,g=0,h=0,i=0;a=gh(a,b);L[a>>2]=22296;L[8513]=L[8513]+1;c=ha[L[6798]](8,16)|0;L[c>>2]=22384;J[c+4|0]=0;L[a+92>>2]=c;L[8513]=L[8513]+1;c=ha[L[6798]](8,16)|0;L[c>>2]=22464;J[c+4|0]=0;L[a+96>>2]=c;L[8513]=L[8513]+1;c=ha[L[6798]](8,16)|0;L[c>>2]=22464;L[a+100>>2]=c;J[c+4|0]=1;L[8513]=L[8513]+1;c=ha[L[6798]](8,16)|0;L[c>>2]=22544;J[c+4|0]=0;L[a+104>>2]=c;L[8513]=L[8513]+1;c=ha[L[6798]](8,16)|0;L[c>>2]=22628;L[a+108>>2]=c;J[c+4|0]=1;a:{if(!M[a+20|0]){break a}c=L[a+16>>2];if(!c|L[c>>2]>155){break a}c=L[c+16>>2];if(c){L[8514]=L[8514]+1;ha[L[6799]](c)}c=L[a+16>>2];if(c){L[8514]=L[8514]+1;ha[L[6799]](c)}L[8513]=L[8513]+1;e=ha[L[6798]](20,16)|0;b=L[b+12>>2];L[e+4>>2]=b;L[e>>2]=156;L[8513]=L[8513]+1;b=ha[L[6798]](R(b,156),16)|0;L[e+12>>2]=b;L[e+16>>2]=b;g=L[e+4>>2];L[e+8>>2]=g;f=g-1|0;b:{if(!f){break b}c=L[e>>2];h=f&7;if(h){while(1){d=b;b=b+c|0;L[d>>2]=b;f=f-1|0;i=i+1|0;if((i|0)!=(h|0)){continue}break}}if(g-2>>>0<7){break b}while(1){d=b;b=b+c|0;L[d>>2]=b;d=b;b=b+c|0;L[d>>2]=b;d=b;b=b+c|0;L[d>>2]=b;d=b;b=b+c|0;L[d>>2]=b;d=b;b=b+c|0;L[d>>2]=b;d=b;b=b+c|0;L[d>>2]=b;d=b;b=b+c|0;L[d>>2]=b;d=b;b=b+c|0;L[d>>2]=b;f=f-8|0;if(f){continue}break}}L[b>>2]=0;L[a+16>>2]=e}}function gk(a){var b=0,c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0;L[a+32>>2]=262144;c=L[a+4>>2];a:{if((c|0)>=2383){break a}if(L[a+8>>2]<2383){L[8513]=L[8513]+1;g=ha[L[6798]](9532,16)|0;i=L[a+4>>2];b:{if((i|0)<=0){break b}if(i>>>0>=4){j=i&-4;while(1){h=e<<2;L[h+g>>2]=L[L[a+12>>2]+h>>2];d=h|4;L[d+g>>2]=L[d+L[a+12>>2]>>2];d=h|8;L[d+g>>2]=L[d+L[a+12>>2]>>2];d=h|12;L[d+g>>2]=L[d+L[a+12>>2]>>2];e=e+4|0;f=f+4|0;if((j|0)!=(f|0)){continue}break}}j=i&3;if(!j){break b}while(1){d=e<<2;L[d+g>>2]=L[d+L[a+12>>2]>>2];e=e+1|0;b=b+1|0;if((j|0)!=(b|0)){continue}break}}b=L[a+12>>2];if(!(b?!b|!M[a+16|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+12>>2]=g;J[a+16|0]=1;L[a+8>>2]=2383}d=(c^-1)+2383|0;b=2383-c&3;if(b){e=0;while(1){L[L[a+12>>2]+(c<<2)>>2]=0;c=c+1|0;e=e+1|0;if((b|0)!=(e|0)){continue}break}}if(d>>>0<3){break a}while(1){b=c<<2;L[b+L[a+12>>2]>>2]=0;L[(b+L[a+12>>2]|0)+4>>2]=0;L[(b+L[a+12>>2]|0)+8>>2]=0;L[(b+L[a+12>>2]|0)+12>>2]=0;c=c+4|0;if((c|0)!=2383){continue}break}}L[a+4>>2]=2383;f=0;while(1){b=L[a+12>>2]+(f<<2)|0;c=L[b>>2];L[b>>2]=0;if(c){while(1){b=L[c+280>>2];ra(c);c=b;if(b){continue}break}}f=f+1|0;if((f|0)!=2383){continue}break}L[a+36>>2]=1;L[a+40>>2]=1;L[a+28>>2]=0;L[a+20>>2]=1048576e3;L[a+24>>2]=0}function cl(a){a=a|0;var b=0;L[a>>2]=19944;b=L[a+176>>2];if(!(b?!b|!M[a+180|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+176>>2]=0;J[a+180|0]=1;L[a+168>>2]=0;L[a+172>>2]=0;b=L[a+156>>2];if(!(b?!b|!M[a+160|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+156>>2]=0;J[a+160|0]=1;L[a+148>>2]=0;L[a+152>>2]=0;b=L[a+136>>2];if(!(b?!b|!M[a+140|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+136>>2]=0;J[a+140|0]=1;L[a+128>>2]=0;L[a+132>>2]=0;b=L[a+116>>2];if(!(b?!b|!M[a+120|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+116>>2]=0;J[a+120|0]=1;L[a+108>>2]=0;L[a+112>>2]=0;b=L[a+96>>2];if(!(b?!b|!M[a+100|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+96>>2]=0;J[a+100|0]=1;L[a+88>>2]=0;L[a+92>>2]=0;b=L[a+76>>2];if(!(b?!b|!M[a+80|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+76>>2]=0;J[a+80|0]=1;L[a+68>>2]=0;L[a+72>>2]=0;b=L[a+56>>2];if(!(b?!b|!M[a+60|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+56>>2]=0;J[a+60|0]=1;L[a+48>>2]=0;L[a+52>>2]=0;b=L[a+36>>2];if(!(b?!b|!M[a+40|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+36>>2]=0;J[a+40|0]=1;L[a+28>>2]=0;L[a+32>>2]=0;b=L[a+16>>2];if(!(b?!b|!M[a+20|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+16>>2]=0;J[a+20|0]=1;L[a+8>>2]=0;L[a+12>>2]=0;return a|0}function yc(a,b){var c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;d=L[a+16>>2];c=L[b+16>>2];if((d|0)!=(c|0)){return d-c|0}if(!d){return 0}n=d;e=L[b+8>>2];f=L[a+4>>2];i=L[b+12>>2];k=L[a>>2];j=mI(i,0,k,0);d=ga;g=f;c=0;f=mI(i,0,f,c);h=d+f|0;d=ga+c|0;l=e;i=0;e=mI(e,i,g,c);c=f>>>0>h>>>0?d+1|0:d;f=ga;g=f+h|0;d=g;f=f>>>0>d>>>0?c+1|0:c;c=0;g=e;e=e+j|0;j=g>>>0>e>>>0?c+1|0:c;g=j+d|0;d=f;d=g>>>0>>0?d+1|0:d;h=g;j=0;f=mI(k,m,l,i);i=j+f|0;c=ga+e|0;c=f>>>0>i>>>0?c+1|0:c;g=c;e=(e|0)==(c|0)&i>>>0>>0|c>>>0>>0;c=d;d=e+h|0;c=d>>>0>>0?c+1|0:c;j=d;k=c;e=L[b>>2];d=L[b+4>>2];b=L[a+8>>2];a=L[a+12>>2];c=0;l=b;f=mI(d,c,b,0);b=ga;h=a;a=mI(d,c,a,0);b=b+a|0;d=ga;d=a>>>0>b>>>0?d+1|0:d;a=mI(e,0,h,c);c=d;d=b;b=ga;h=d+b|0;d=h;b=b>>>0>d>>>0?c+1|0:c;c=0;h=a;a=a+f|0;f=h>>>0>a>>>0?c+1|0:c;h=f+d|0;d=b;d=f>>>0>h>>>0?d+1|0:d;f=0;e=mI(e,m,l,m);b=f+e|0;c=ga+a|0;c=b>>>0>>0?c+1|0:c;e=c;a=(a|0)==(c|0)&b>>>0>>0|a>>>0>c>>>0;c=d;d=a;a=a+h|0;c=d>>>0>a>>>0?c+1|0:c;d=-1;a:{if((c|0)==(k|0)&a>>>0>j>>>0|c>>>0>k>>>0){break a}d=1;if((c|0)==(k|0)&a>>>0>>0|c>>>0>>0){break a}d=-1;if((e|0)==(g|0)&b>>>0>i>>>0|e>>>0>g>>>0){break a}d=(e|0)==(g|0)&b>>>0>>0|e>>>0>>0}return R(n,d)}function Gy(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=0,g=0,h=0;if(Wa(a,L[b+8>>2],e)){if(!(L[b+28>>2]==1|L[b+4>>2]!=(c|0))){L[b+28>>2]=d}return}a:{if(Wa(a,L[b>>2],e)){if(!(L[b+16>>2]!=(c|0)&L[b+20>>2]!=(c|0))){if((d|0)!=1){break a}L[b+32>>2]=1;return}L[b+32>>2]=d;if(L[b+44>>2]!=4){f=a+16|0;h=f+(L[a+12>>2]<<3)|0;d=0;b:{c:{while(1){d:{if(f>>>0>=h>>>0){break d}K[b+52>>1]=0;Vf(f,b,c,c,1,e);if(M[b+54|0]){break d}e:{if(!M[b+53|0]){break e}if(M[b+52|0]){d=1;if(L[b+24>>2]==1){break c}g=1;if(M[a+8|0]&2){break e}break c}g=1;if(!(J[a+8|0]&1)){break c}}f=f+8|0;continue}break}a=4;if(!g){break b}}a=3}L[b+44>>2]=a;if(d&1){break a}}L[b+20>>2]=c;L[b+40>>2]=L[b+40>>2]+1;if(L[b+36>>2]!=1|L[b+24>>2]!=2){break a}J[b+54|0]=1;return}g=L[a+12>>2];h=a+16|0;le(h,b,c,d,e);f=a+24|0;g=h+(g<<3)|0;if(f>>>0>=g>>>0){break a}a=L[a+8>>2];if(!(!(a&2)&L[b+36>>2]!=1)){while(1){if(M[b+54|0]){break a}le(f,b,c,d,e);f=f+8|0;if(g>>>0>f>>>0){continue}break}break a}if(!(a&1)){while(1){if(M[b+54|0]|L[b+36>>2]==1){break a}le(f,b,c,d,e);f=f+8|0;if(g>>>0>f>>>0){continue}break a}}while(1){if(M[b+54|0]|L[b+36>>2]==1&L[b+24>>2]==1){break a}le(f,b,c,d,e);f=f+8|0;if(g>>>0>f>>>0){continue}break}}}function fg(a,b,c,d){var e=0,f=0,g=0;e=fa-128|0;fa=e;L[e+112>>2]=16;L[e+116>>2]=981668463;L[e+108>>2]=b;L[e+104>>2]=c;L[e+100>>2]=1;b=e- -64|0;L[b>>2]=0;J[e+68|0]=1;J[e+96|0]=1;L[e+56>>2]=0;L[e+60>>2]=0;L[e+92>>2]=0;L[e+84>>2]=0;L[e+88>>2]=0;L[e+72>>2]=0;L[e+76>>2]=0;L[e+48>>2]=0;J[e+44|0]=1;J[e+40|0]=1;L[e+36>>2]=0;L[e+28>>2]=0;L[e+32>>2]=0;L[e+16>>2]=0;J[e+20|0]=1;L[e+8>>2]=0;L[e+12>>2]=0;L[e+120>>2]=c;ak(e+4|0,e+100|0,e+44|0);L[8513]=L[8513]+1;a=Ac(ha[L[6798]](1252,16)|0,a,L[e+48>>2],L[b>>2],0);if(L[e+72>>2]>0){while(1){f=L[e+92>>2]+R(g,12)|0;b=L[f+8>>2];c=L[f>>2];f=L[f+4>>2];if((c|0)<(f|0)){Ha(a,c,f,0,0)}if((b|0)>(f|0)){Ha(a,f,b,0,0)}if((b|0)<(c|0)){Ha(a,b,c,0,0)}pb(a,c,f,b,0);g=g+1|0;if((g|0)>2]){continue}break}}$j(e+44|0);if(d){yk(a)}b=L[e+36>>2];if(!(b?!b|!M[e+40|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[e+36>>2]=0;J[e+40|0]=1;L[e+28>>2]=0;L[e+32>>2]=0;b=L[e+16>>2];if(!(b?!b|!M[e+20|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}b=L[e+92>>2];if(!(b?!b|!M[e+96|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[e+92>>2]=0;J[e+96|0]=1;L[e+84>>2]=0;L[e+88>>2]=0;b=L[e+64>>2];if(!(b?!b|!M[e+68|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}fa=e+128|0;return a}function AE(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0;e=fa-80|0;fa=e;a:{if((d|0)<=0){break a}if(d>>>0>=8){j=d&-8;while(1){f=i<<4;L[(f+c|0)+12>>2]=-581039253;L[((f|16)+c|0)+12>>2]=-581039253;L[((f|32)+c|0)+12>>2]=-581039253;L[((f|48)+c|0)+12>>2]=-581039253;L[((f|64)+c|0)+12>>2]=-581039253;L[((f|80)+c|0)+12>>2]=-581039253;L[((f|96)+c|0)+12>>2]=-581039253;L[((f|112)+c|0)+12>>2]=-581039253;i=i+8|0;g=g+8|0;if((j|0)!=(g|0)){continue}break}}g=d&7;if(g){while(1){L[((i<<4)+c|0)+12>>2]=-581039253;i=i+1|0;h=h+1|0;if((g|0)!=(h|0)){continue}break}}if((d|0)<=0){break a}f=e- -64|0;i=0;while(1){L[e+40>>2]=14628;L[e+52>>2]=0;L[e+56>>2]=0;L[e+44>>2]=0;L[e+48>>2]=0;L[e+60>>2]=-581039253;g=i<<4;j=g+b|0;h=L[j+12>>2];L[f+8>>2]=L[j+8>>2];L[f+12>>2]=h;h=L[j+4>>2];L[f>>2]=L[j>>2];L[f+4>>2]=h;L[e+32>>2]=1566444395;L[e+36>>2]=0;L[e+24>>2]=1566444395;L[e+28>>2]=1566444395;h=L[a+92>>2];L[e+16>>2]=-581039253;L[e+20>>2]=0;L[e+8>>2]=-581039253;L[e+12>>2]=-581039253;ha[L[L[h>>2]+8>>2]](h,e+40|0,e+8|0,e+24|0);h=L[e+56>>2];g=c+g|0;L[g+8>>2]=L[e+52>>2];L[g+12>>2]=h;h=L[e+48>>2];L[g>>2]=L[e+44>>2];L[g+4>>2]=h;i=i+1|0;if((i|0)!=(d|0)){continue}break}}fa=e+80|0}function KA(a,b,c,d){a=a|0;b=S(b);c=c|0;d=S(d);var e=0,f=0,g=0,h=0,i=S(0);e=fa-16|0;fa=e;xc(L[8515]);$f(34064);L[8517]=L[8517]+1;f=L[8520];L[8520]=f+1;if(!f){xc(e);f=L[8515];h=L[e>>2]-L[f>>2]|0;L[8519]=(L[e+8>>2]-L[f+8>>2]|0)+R(h,1e6)}L[8525]=0;xc(e);f=L[8515];h=L[e>>2]-L[f>>2]|0;L[8526]=(L[e+8>>2]-L[f+8>>2]|0)+R(h,1e6);fa=e+16|0;wa(3069);a:{if(c){P[a+268>>2]=d;b=S(P[a+264>>2]+b);P[a+264>>2]=b;if(!(b>=d)){break a}i=b;b=S(b/d);b:{if(S(T(b))>2]=i-S(S(g|0)*d);break a}L[a+268>>2]=0;P[a+264>>2]=M[a+300|0]?S(0):b;d=b;g=!(S(T(b))>2]+20>>2]](a)|0){e=ha[L[L[a>>2]+20>>2]](a)|0;J[33160]=ha[L[L[e>>2]+48>>2]](e)>>>4&1}c:{if(g){e=(c|0)>(g|0)?g:c;ha[L[L[a>>2]+164>>2]](a,S(d*S(e|0)));ha[L[L[a>>2]+168>>2]](a);if((e|0)<=0){break c}if((e|0)!=1){f=e&-2;c=0;while(1){ha[L[L[a>>2]+160>>2]](a,d);ha[L[L[a>>2]+80>>2]](a);ha[L[L[a>>2]+160>>2]](a,d);ha[L[L[a>>2]+80>>2]](a);c=c+2|0;if((f|0)!=(c|0)){continue}break}}if(!(e&1)){break c}ha[L[L[a>>2]+160>>2]](a,d);ha[L[L[a>>2]+80>>2]](a);break c}ha[L[L[a>>2]+80>>2]](a)}ha[L[L[a>>2]+120>>2]](a);L[8525]=L[8525]+1;va();return g|0}function tG(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0;a=L[b>>2];e=ha[L[L[a>>2]+56>>2]](a,48)|0;L[e>>2]=8684;L[e+4>>2]=L[b>>2];L[e>>2]=8712;L[e>>2]=9916;J[e+28|0]=1;L[e+24>>2]=0;L[e+16>>2]=0;L[e+20>>2]=0;a=L[b+4>>2];J[e+36|0]=0;L[e+32>>2]=a;L[8513]=L[8513]+1;a=ha[L[6798]](68,16)|0;J[a+24|0]=0;J[a+20|0]=1;L[a>>2]=11520;L[a+16>>2]=0;J[a+44|0]=1;L[a+8>>2]=0;L[a+12>>2]=0;L[a+40>>2]=0;J[a- -64|0]=1;L[a+32>>2]=0;L[a+36>>2]=0;L[a+60>>2]=0;L[a+52>>2]=0;L[a+56>>2]=0;L[8513]=L[8513]+1;b=ha[L[6798]](24,16)|0;h=L[a+8>>2];a:{if((h|0)<=0){break a}if((h|0)!=1){l=h&-2;while(1){f=R(g,12);i=f+L[a+16>>2]|0;j=L[i+4>>2];f=b+f|0;L[f>>2]=L[i>>2];L[f+4>>2]=j;L[f+8>>2]=L[i+8>>2];f=R(g|1,12);i=f+L[a+16>>2]|0;j=L[i+4>>2];f=b+f|0;L[f>>2]=L[i>>2];L[f+4>>2]=j;L[f+8>>2]=L[i+8>>2];g=g+2|0;k=k+2|0;if((l|0)!=(k|0)){continue}break}}if(!(h&1)){break a}h=R(g,12);g=h+L[a+16>>2]|0;i=L[g+4>>2];h=b+h|0;L[h>>2]=L[g>>2];L[h+4>>2]=i;L[h+8>>2]=L[g+8>>2]}g=L[a+16>>2];if(!(g?!g|!M[a+20|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](g)}L[a+16>>2]=b;J[a+20|0]=1;L[a+12>>2]=2;dh(a);L[e+8>>2]=a;L[e+40>>2]=L[L[c+4>>2]+68>>2];L[e+44>>2]=L[L[d+4>>2]+68>>2];return e|0}function ys(a){a=a|0;var b=0,c=0,d=0,e=0,f=0;e=fa-16|0;fa=e;L[e+12>>2]=a;f=sa(284);a=L[e+12>>2];c=fa-16|0;fa=c;L[c+12>>2]=f;L[c+8>>2]=a;d=fa-16|0;fa=d;a=L[c+12>>2];L[d+12>>2]=a;b=L[d+12>>2];L[(fa-16|0)+12>>2]=b;L[(fa-16|0)+12>>2]=b+16;L[(fa-16|0)+12>>2]=b+36;L[(fa-16|0)+12>>2]=b+52;L[(fa-16|0)+12>>2]=b+68;fa=d+16|0;Pb(a+92|0);L[(fa-16|0)+12>>2]=a+156;L[(fa-16|0)+12>>2]=a+172;L[(fa-16|0)+12>>2]=a+188;P[a+204>>2]=P[L[c+8>>2]+48>>2];P[a+208>>2]=P[L[c+8>>2]+52>>2];P[a+212>>2]=P[L[c+8>>2]+56>>2];P[a+216>>2]=P[L[c+8>>2]+60>>2];P[a+220>>2]=P[L[c+8>>2]+64>>2];P[a+224>>2]=P[L[c+8>>2]+68>>2];b=L[c+8>>2];d=L[b+4>>2];L[a+156>>2]=L[b>>2];L[a+160>>2]=d;d=L[b+12>>2];L[a+164>>2]=L[b+8>>2];L[a+168>>2]=d;b=L[c+8>>2];d=L[b+20>>2];L[a+172>>2]=L[b+16>>2];L[a+176>>2]=d;d=L[b+28>>2];L[a+180>>2]=L[b+24>>2];L[a+184>>2]=d;b=L[c+8>>2];d=L[b+36>>2];L[a+188>>2]=L[b+32>>2];L[a+192>>2]=d;d=L[b+44>>2];L[a+196>>2]=L[b+40>>2];L[a+200>>2]=d;P[a+228>>2]=P[L[c+8>>2]+72>>2];P[a+232>>2]=0;P[a+252>>2]=0;P[a+236>>2]=0;P[a+240>>2]=0;P[a+256>>2]=0;P[a+244>>2]=.10000000149011612;J[a+260|0]=J[L[c+8>>2]+80|0]&1;P[a+248>>2]=P[L[c+8>>2]+76>>2];fa=c+16|0;fa=e+16|0;return f|0}function uk(a,b,c,d,e,f){var g=S(0),h=S(0),i=S(0),j=S(0),k=S(0),l=S(0),m=S(0),n=S(0),o=S(0),p=S(0),q=S(0),r=S(0),s=S(0),t=S(0),u=S(0),v=S(0),w=S(0),x=S(0),y=S(0),z=S(0);n=S(-1);o=P[b+8>>2];p=P[d>>2];g=P[c>>2];k=S(p-g);v=P[e+4>>2];l=P[c+4>>2];m=S(v-l);w=P[e>>2];h=S(w-g);r=P[d+4>>2];i=S(r-l);s=S(S(k*m)-S(h*i));j=P[b>>2];t=i;x=P[e+8>>2];i=P[c+8>>2];q=S(x-i);y=P[d+8>>2];u=S(y-i);m=S(S(t*q)-S(m*u));t=P[b+4>>2];k=S(S(u*h)-S(q*k));h=S(S(o*s)+S(S(j*m)+S(t*k)));a:{if(S(T(h))>2];u=P[a>>2];z=P[a+4>>2];n=S(S(-S(S(S(q*s)+S(S(u*m)+S(k*z)))-S(S(i*s)+S(S(g*m)+S(l*k)))))/h);b:{if(!(n>S(11920928955078125e-22))|!(f>n)){break b}j=S(u+S(j*n));f=S(g-j);h=S(z+S(t*n));g=S(r-h);p=S(p-j);l=S(l-h);r=S(q+S(o*n));o=S(y-r);i=S(i-r);if(!(S(S(s*S(S(f*g)-S(p*l)))+S(S(m*S(S(l*o)-S(g*i)))+S(k*S(S(i*p)-S(o*f)))))>S(-11920928955078125e-22))){break b}h=S(v-h);j=S(w-j);q=S(s*S(S(p*h)-S(j*g)));t=g;g=S(x-r);if(!(S(q+S(S(m*S(S(t*g)-S(h*o)))+S(k*S(S(o*j)-S(g*p)))))>S(-11920928955078125e-22))){break b}if(S(S(s*S(S(j*l)-S(f*h)))+S(S(m*S(S(h*i)-S(l*g)))+S(k*S(S(g*f)-S(i*j)))))>S(-11920928955078125e-22)){break a}}n=S(-1)}return n}function zB(a,b,c){a=a|0;b=b|0;c=c|0;cc(a,b,c);P[b+52>>2]=P[a+48>>2];P[b+56>>2]=P[a+52>>2];P[b+60>>2]=P[a+56>>2];P[b- -64>>2]=P[a+60>>2];P[b+68>>2]=P[a- -64>>2];P[b+72>>2]=P[a+68>>2];P[b+76>>2]=P[a+72>>2];P[b+80>>2]=P[a+76>>2];P[b+84>>2]=P[a+80>>2];P[b+88>>2]=P[a+84>>2];P[b+92>>2]=P[a+88>>2];P[b+96>>2]=P[a+92>>2];P[b+100>>2]=P[a+96>>2];P[b+104>>2]=P[a+100>>2];P[b+108>>2]=P[a+104>>2];P[b+112>>2]=P[a+108>>2];P[b+116>>2]=P[a+112>>2];P[b+120>>2]=P[a+116>>2];P[b+124>>2]=P[a+120>>2];P[b+128>>2]=P[a+124>>2];P[b+132>>2]=P[a+128>>2];P[b+136>>2]=P[a+132>>2];P[b+140>>2]=P[a+136>>2];P[b+144>>2]=P[a+140>>2];P[b+148>>2]=P[a+144>>2];P[b+152>>2]=P[a+148>>2];P[b+156>>2]=P[a+152>>2];P[b+160>>2]=P[a+156>>2];P[b+164>>2]=P[a+160>>2];P[b+168>>2]=P[a+164>>2];P[b+172>>2]=P[a+168>>2];P[b+176>>2]=P[a+172>>2];P[b+228>>2]=P[a+868>>2];P[b+212>>2]=P[a+872>>2];P[b+196>>2]=P[a+680>>2];P[b+180>>2]=P[a+696>>2];P[b+232>>2]=P[a+932>>2];P[b+216>>2]=P[a+936>>2];P[b+200>>2]=P[a+684>>2];P[b+184>>2]=P[a+700>>2];P[b+236>>2]=P[a+996>>2];P[b+220>>2]=P[a+1e3>>2];P[b+204>>2]=P[a+688>>2];P[b+188>>2]=P[a+704>>2];L[b+244>>2]=M[a+1300|0];L[b+248>>2]=M[a+1301|0];return 3404}function jc(a,b,c,d){var e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0;while(1){q=c;g=L[a+12>>2]+((c+d|0)/2<<4)|0;r=L[g+8>>2];l=L[g+4>>2];k=L[g>>2];g=d;while(1){s=L[a+12>>2];while(1){e=-1;i=-1;f=(c<<4)+s|0;m=L[f>>2];if(m){i=L[m+12>>2]}e=k?L[k+12>>2]:e;j=-1;h=-1;n=L[f+4>>2];if(n){h=L[n+12>>2]}j=l?L[l+12>>2]:j;a:{b:{if((e|0)<(i|0)){break b}e=(k|0)==(m|0)&(h|0)>(j|0);if(!(e|(k|0)!=(m|0))){if((l|0)!=(n|0)){break a}if(O[f+8>>2]>r>>>0){break b}break a}if(!e){break a}}c=c+1|0;continue}break}while(1){t=g<<4;e=t+s|0;i=-1;j=-1;j=k?L[k+12>>2]:j;h=L[e>>2];if(h){i=L[h+12>>2]}u=-1;o=-1;o=l?L[l+12>>2]:o;p=L[e+4>>2];if(p){u=L[p+12>>2]}c:{d:{if((i|0)<(j|0)){break d}i=(h|0)==(k|0)&(u|0)<(o|0);if(!(i|(h|0)!=(k|0))){if((l|0)!=(p|0)){break c}if(O[e+8>>2]>>0){break d}break c}if(!i){break c}}g=g-1|0;continue}break}if((c|0)<=(g|0)){i=L[f+8>>2];j=L[f+12>>2];h=L[e+4>>2];L[f>>2]=L[e>>2];L[f+4>>2]=h;h=L[e+12>>2];L[f+8>>2]=L[e+8>>2];L[f+12>>2]=h;f=L[a+12>>2]+t|0;L[f+4>>2]=n;L[f+8>>2]=i;L[f+12>>2]=j;L[f>>2]=m;g=g-1|0;c=c+1|0}if((c|0)<=(g|0)){continue}break}if((g|0)>(q|0)){jc(a,b,q,g)}if((c|0)<(d|0)){continue}break}}function dD(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=S(0),f=S(0),g=S(0),h=S(0),i=S(0),j=S(0),k=S(0),l=S(0),m=S(0),n=S(0),o=S(0),p=S(0),q=S(0),r=S(0),s=S(0),t=S(0),u=S(0),v=S(0),w=S(0),x=S(0),y=S(0),z=S(0),A=S(0),B=S(0),C=S(0),D=S(0),E=S(0),F=S(0);h=P[a+24>>2];f=P[a+40>>2];u=P[a+20>>2];v=P[a+36>>2];w=P[a+16>>2];x=P[a+32>>2];y=S(ha[L[L[a>>2]+48>>2]](a));z=S(ha[L[L[a>>2]+48>>2]](a));A=S(ha[L[L[a>>2]+48>>2]](a));B=P[b+52>>2];i=P[b+24>>2];j=P[b+20>>2];k=P[b+56>>2];l=P[a+20>>2];o=P[a+36>>2];m=P[a+24>>2];C=P[a+40>>2];e=P[b+40>>2];n=P[b+36>>2];D=P[b+48>>2];q=P[b+8>>2];r=P[b>>2];s=P[b+4>>2];t=P[b+16>>2];E=P[a+16>>2];F=P[a+32>>2];g=P[b+32>>2];L[c+12>>2]=0;p=k;k=S(S(C+m)*S(.5));m=S(S(F+E)*S(.5));l=S(S(o+l)*S(.5));o=S(p+S(S(e*k)+S(S(g*m)+S(n*l))));h=S(A+S(S(f-h)*S(.5)));p=S(h*S(T(e)));e=S(y+S(S(x-w)*S(.5)));f=S(e*S(T(g)));g=S(z+S(S(v-u)*S(.5)));n=S(p+S(f+S(g*S(T(n)))));P[c+8>>2]=o-n;f=S(B+S(S(k*i)+S(S(m*t)+S(l*j))));i=S(S(h*S(T(i)))+S(S(e*S(T(t)))+S(g*S(T(j)))));P[c+4>>2]=f-i;j=S(D+S(S(k*q)+S(S(m*r)+S(l*s))));e=S(S(h*S(T(q)))+S(S(e*S(T(r)))+S(g*S(T(s)))));P[c>>2]=j-e;L[d+12>>2]=0;P[d+8>>2]=n+o;P[d+4>>2]=i+f;P[d>>2]=e+j}function ez(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0;ha[L[L[b>>2]+32>>2]](b);d=ha[L[L[b>>2]+16>>2]](b,104,1)|0;c=pa(L[d+8>>2],0,104);P[c+88>>2]=P[a+248>>2];P[c+92>>2]=P[a+252>>2];P[c+96>>2]=P[a+256>>2];P[c+100>>2]=P[a+260>>2];P[c>>2]=P[a+92>>2];P[c+4>>2]=P[a+96>>2];P[c+8>>2]=P[a+100>>2];P[c+12>>2]=P[a+104>>2];P[c+16>>2]=P[a+108>>2];P[c+20>>2]=P[a+116>>2];P[c+24>>2]=P[a+120>>2];P[c+28>>2]=P[a+124>>2];P[c+32>>2]=P[a+128>>2];P[c+36>>2]=P[a+132>>2];P[c+40>>2]=P[a+140>>2];P[c+44>>2]=P[a+144>>2];P[c+48>>2]=P[a+148>>2];P[c+52>>2]=P[a+152>>2];P[c+56>>2]=P[a+168>>2];P[c+60>>2]=P[a+172>>2];L[c+64>>2]=L[a+112>>2];L[c+68>>2]=L[a+156>>2];L[c+72>>2]=L[a+160>>2];L[c+76>>2]=L[a+164>>2];L[c+80>>2]=L[a+136>>2];ha[L[L[b>>2]+20>>2]](b,d,3661,1145853764,c);d=L[a+8>>2];if((d|0)>0){while(1){c=L[L[a+16>>2]+(e<<2)>>2];if(M[c+236|0]&8){d=(g=b,h=ha[L[L[c>>2]+16>>2]](c)|0,i=1,f=L[L[b>>2]+16>>2],ha[f](g|0,h|0,i|0)|0);i=b,h=d,g=ha[L[L[c>>2]+20>>2]](c,L[d+8>>2],b)|0,j=1497645651,k=c,f=L[L[b>>2]+20>>2],ha[f](i|0,h|0,g|0,j|0,k|0);d=L[a+8>>2]}e=e+1|0;if((e|0)<(d|0)){continue}break}}Lk(a,b);jh(a,b);ha[L[L[b>>2]+36>>2]](b)}function fG(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0;L[7544]=L[7544]+1;k=L[a+40>>2];d=c<<16|b;d=(d<<15^-1)+d|0;d=R(d>>10^d,9);d=d>>6^d;d=(d<<11^-1)+d|0;i=k+((L[a+12>>2]-1&(d>>16^d))<<2)|0;d=L[i>>2];a:{if((d|0)==-1){break a}f=L[a+60>>2];g=L[a+16>>2];e=d;while(1){j=g+R(e,12)|0;if(!(L[j>>2]==(b|0)&L[j+4>>2]==(c|0))){e=L[(e<<2)+f>>2];if((e|0)!=-1){continue}break a}break}l=L[(g+R(e,12)|0)+8>>2];b:{c:{if((d|0)==(e|0)){break c}while(1){b=d;d=L[(b<<2)+f>>2];if((e|0)!=(d|0)){continue}break}if((b|0)==-1){break c}L[(b<<2)+f>>2]=L[(e<<2)+f>>2];break b}L[i>>2]=L[(e<<2)+f>>2]}h=L[a+8>>2]-1|0;if((h|0)!=(e|0)){d:{e:{g=g+R(h,12)|0;b=L[g+4>>2]<<16|L[g>>2];b=(b<<15^-1)+b|0;b=R(b>>10^b,9);b=b>>6^b;b=(b<<11^-1)+b|0;i=L[a+12>>2]-1&(b>>16^b);d=k+(i<<2)|0;b=L[d>>2];if((h|0)==(b|0)){break e}while(1){c=b;b=L[(b<<2)+f>>2];if((h|0)!=(b|0)){continue}break}if((c|0)==-1){break e}L[(c<<2)+f>>2]=L[(h<<2)+f>>2];break d}L[d>>2]=L[(h<<2)+f>>2]}b=L[g+4>>2];L[j>>2]=L[g>>2];L[j+4>>2]=b;L[j+8>>2]=L[g+8>>2];b=L[a+40>>2]+(i<<2)|0;L[L[a+60>>2]+(e<<2)>>2]=L[b>>2];L[b>>2]=e;e=L[a+8>>2]-1|0}L[a+8>>2]=e}return l|0}function Vl(a,b){a=a|0;b=b|0;var c=0,d=0,e=0;c=fa-48|0;fa=c;d=L[b+4>>2];e=L[a+48>>2];L[e+4>>2]=L[b>>2];L[e+8>>2]=d;d=L[b+12>>2];L[e+12>>2]=L[b+8>>2];L[e+16>>2]=d;L[c+44>>2]=0;L[c+36>>2]=0;L[c+40>>2]=0;L[c+32>>2]=1065353216;e=c+16|0;b=c+32|0;ha[L[L[a>>2]+68>>2]](e,a,b);P[a+32>>2]=P[c+16>>2]+P[a+12>>2];L[c+32>>2]=-1082130432;ha[L[L[a>>2]+68>>2]](c,a,b);d=L[c+12>>2];L[c+24>>2]=L[c+8>>2];L[c+28>>2]=d;d=L[c+4>>2];L[c+16>>2]=L[c>>2];L[c+20>>2]=d;P[a+16>>2]=P[c+16>>2]-P[a+12>>2];L[c+40>>2]=0;L[c+44>>2]=0;L[c+32>>2]=0;L[c+36>>2]=0;L[c+36>>2]=1065353216;ha[L[L[a>>2]+68>>2]](e,a,b);P[a+36>>2]=P[c+20>>2]+P[a+12>>2];L[c+36>>2]=-1082130432;ha[L[L[a>>2]+68>>2]](c,a,b);d=L[c+12>>2];L[c+24>>2]=L[c+8>>2];L[c+28>>2]=d;d=L[c+4>>2];L[c+16>>2]=L[c>>2];L[c+20>>2]=d;P[a+20>>2]=P[c+20>>2]-P[a+12>>2];L[c+40>>2]=0;L[c+44>>2]=0;L[c+40>>2]=1065353216;L[c+32>>2]=0;L[c+36>>2]=0;ha[L[L[a>>2]+68>>2]](e,a,b);P[a+40>>2]=P[c+24>>2]+P[a+12>>2];L[c+40>>2]=-1082130432;ha[L[L[a>>2]+68>>2]](c,a,b);b=L[c+12>>2];L[c+24>>2]=L[c+8>>2];L[c+28>>2]=b;b=L[c+4>>2];L[c+16>>2]=L[c>>2];L[c+20>>2]=b;P[a+24>>2]=P[c+24>>2]-P[a+12>>2];fa=c+48|0}function zF(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0,g=S(0),h=S(0),i=S(0),j=S(0),k=S(0),l=S(0),m=S(0),n=0,o=S(0),p=0,q=0,r=0,s=S(0);f=fa-16|0;fa=f;e=(L[a+52>>2]+2|0)%3|0;if((d|0)>0){p=a+28|0;o=P[p+(e<<2)>>2];while(1){L[f+8>>2]=0;L[f+12>>2]=0;L[f>>2]=0;L[f+4>>2]=0;e=L[a+52>>2]<<2;P[e+f>>2]=P[e+p>>2];r=q<<4;e=r+b|0;g=P[e+8>>2];h=P[e>>2];j=P[e+4>>2];i=P[f>>2];k=P[f+4>>2];s=S(-0xde0b6b000000000);m=S(P[f+8>>2]+S(o*g));g=S(ha[L[L[a>>2]+48>>2]](a));l=P[e+8>>2];m=S(m-S(g*l));i=S(i+S(o*h));h=P[e>>2];i=S(i-S(g*h));k=S(k+S(o*j));j=P[e+4>>2];k=S(k-S(g*j));g=S(S(l*m)+S(S(h*i)+S(j*k)));if(g>S(-0xde0b6b000000000)){n=c+r|0;L[n+12>>2]=0;P[n+8>>2]=m;P[n+4>>2]=k;P[n>>2]=i;l=P[e+8>>2];j=P[e+4>>2];h=P[e>>2];s=g}L[f+8>>2]=0;L[f+12>>2]=0;L[f>>2]=0;L[f+4>>2]=0;n=L[a+52>>2]<<2;P[n+f>>2]=-P[n+p>>2];m=P[f+4>>2];i=P[f>>2];l=S(P[f+8>>2]+S(o*l));g=S(ha[L[L[a>>2]+48>>2]](a));k=P[e+8>>2];l=S(l-S(g*k));h=S(i+S(o*h));i=P[e>>2];h=S(h-S(g*i));m=S(m+S(o*j));j=P[e+4>>2];g=S(m-S(g*j));if(S(S(k*l)+S(S(i*h)+S(j*g)))>s){e=c+r|0;L[e+12>>2]=0;P[e+8>>2]=l;P[e+4>>2]=g;P[e>>2]=h}q=q+1|0;if((q|0)!=(d|0)){continue}break}}fa=f+16|0}function qa(a,b,c){var d=0,e=0,f=0;if(c>>>0>=512){da(a|0,b|0,c|0);return a}e=a+c|0;a:{if(!((a^b)&3)){b:{if(!(a&3)){c=a;break b}if(!c){c=a;break b}c=a;while(1){J[c|0]=M[b|0];b=b+1|0;c=c+1|0;if(!(c&3)){break b}if(c>>>0>>0){continue}break}}d=e&-4;c:{if(d>>>0<64){break c}f=d+-64|0;if(f>>>0>>0){break c}while(1){L[c>>2]=L[b>>2];L[c+4>>2]=L[b+4>>2];L[c+8>>2]=L[b+8>>2];L[c+12>>2]=L[b+12>>2];L[c+16>>2]=L[b+16>>2];L[c+20>>2]=L[b+20>>2];L[c+24>>2]=L[b+24>>2];L[c+28>>2]=L[b+28>>2];L[c+32>>2]=L[b+32>>2];L[c+36>>2]=L[b+36>>2];L[c+40>>2]=L[b+40>>2];L[c+44>>2]=L[b+44>>2];L[c+48>>2]=L[b+48>>2];L[c+52>>2]=L[b+52>>2];L[c+56>>2]=L[b+56>>2];L[c+60>>2]=L[b+60>>2];b=b- -64|0;c=c- -64|0;if(f>>>0>=c>>>0){continue}break}}if(c>>>0>=d>>>0){break a}while(1){L[c>>2]=L[b>>2];b=b+4|0;c=c+4|0;if(d>>>0>c>>>0){continue}break}break a}if(e>>>0<4){c=a;break a}d=e-4|0;if(d>>>0>>0){c=a;break a}c=a;while(1){J[c|0]=M[b|0];J[c+1|0]=M[b+1|0];J[c+2|0]=M[b+2|0];J[c+3|0]=M[b+3|0];b=b+4|0;c=c+4|0;if(d>>>0>=c>>>0){continue}break}}if(c>>>0>>0){while(1){J[c|0]=M[b|0];b=b+1|0;c=c+1|0;if((e|0)!=(c|0)){continue}break}}return a}function Wo(a,b,c){a=a|0;b=b|0;c=S(c);var d=0,e=0,f=0,g=0,h=0;d=fa-288|0;fa=d;L[d+284>>2]=a;L[d+280>>2]=b;P[d+276>>2]=c;a=L[d+284>>2];b=fa-16|0;L[b+12>>2]=L[d+280>>2];f=L[b+12>>2]+48|0;e=L[f+12>>2];L[d+264>>2]=L[f+8>>2];L[d+268>>2]=e;e=L[f+4>>2];L[d+256>>2]=L[f>>2];L[d+260>>2]=e;L[b+12>>2]=L[d+280>>2];b=L[b+12>>2];P[d+204>>2]=0;P[d+200>>2]=0;e=d+208|0;f=d+276|0;la(e,f,d+204|0,d+200|0);g=d+224|0;ua(g,b,e);e=d+240|0;b=d+256|0;ta(e,b,g);P[d+180>>2]=.699999988079071;P[d+176>>2]=0;P[d+172>>2]=0;g=d+184|0;la(g,d+180|0,d+176|0,d+172|0);ha[L[L[a>>2]+8>>2]](a,b,e,g);e=fa-16|0;L[e+12>>2]=L[d+280>>2];e=L[e+12>>2];P[d+120>>2]=0;P[d+116>>2]=0;g=d+124|0;la(g,d+120|0,f,d+116|0);h=d+140|0;ua(h,e,g);e=d+156|0;ta(e,b,h);P[d+96>>2]=0;P[d+92>>2]=.699999988079071;P[d+88>>2]=0;g=d+100|0;la(g,d+96|0,d+92|0,d+88|0);ha[L[L[a>>2]+8>>2]](a,b,e,g);e=fa-16|0;L[e+12>>2]=L[d+280>>2];e=L[e+12>>2];P[d+36>>2]=0;P[d+32>>2]=0;g=d+40|0;la(g,d+36|0,d+32|0,f);f=d+56|0;ua(f,e,g);e=d+72|0;ta(e,b,f);P[d+12>>2]=0;P[d+8>>2]=0;P[d+4>>2]=.699999988079071;f=d+16|0;la(f,d+12|0,d+8|0,d+4|0);ha[L[L[a>>2]+8>>2]](a,b,e,f);fa=d+288|0}function AF(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=S(0),f=S(0),g=S(0),h=S(0),i=S(0),j=S(0),k=0,l=S(0),m=S(0),n=S(0),o=S(0),p=S(0),q=S(0),r=S(0);d=fa-16|0;fa=d;L[a>>2]=0;L[a+4>>2]=0;L[a+8>>2]=0;L[a+12>>2]=0;e=P[c+8>>2];h=P[c>>2];f=P[c+4>>2];g=S(S(e*e)+S(S(h*h)+S(f*f)));a:{if(g>2];f=P[c+((k+2|0)%3<<2)>>2];L[d+8>>2]=0;L[d+12>>2]=0;L[d>>2]=0;L[d+4>>2]=0;k=k<<2;P[k+d>>2]=P[c+k>>2];m=P[d+4>>2];n=P[d>>2];h=S(-0xde0b6b000000000);p=S(j*f);i=S(p+P[d+8>>2]);l=S(ha[L[L[b>>2]+48>>2]](b));o=S(i-S(j*l));q=S(e*f);m=S(S(m+q)-S(e*l));i=n;n=S(g*f);l=S(S(i+n)-S(g*l));f=S(S(j*o)+S(S(g*l)+S(e*m)));if(f>S(-0xde0b6b000000000)){L[a+12>>2]=0;P[a+8>>2]=o;P[a+4>>2]=m;P[a>>2]=l;h=f}L[d+8>>2]=0;L[d+12>>2]=0;L[d>>2]=0;L[d+4>>2]=0;k=L[b+52>>2]<<2;P[k+d>>2]=-P[c+k>>2];f=P[d+4>>2];l=P[d>>2];r=h;m=j;i=S(p+P[d+8>>2]);h=S(ha[L[L[b>>2]+48>>2]](b));j=S(i-S(j*h));o=g;g=S(S(n+l)-S(g*h));i=e;e=S(S(q+f)-S(e*h));if(r>2]=0;P[a+8>>2]=j;P[a+4>>2]=e;P[a>>2]=g}fa=d+16|0}function il(a,b,c,d,e,f,g,h,i){var j=0,k=0,l=0,m=0,n=S(0),o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0;j=fa-80|0;fa=j;L[j+52>>2]=0;L[j+44>>2]=0;L[j+48>>2]=1045220557;L[j+76>>2]=0;s=b+4|0;t=a+756|0;u=a+772|0;v=a+740|0;w=a+1096|0;x=a+1080|0;y=a+1064|0;z=a+792|0;A=a+808|0;B=a+696|0;C=a+824|0;D=a+840|0;p=a+680|0;while(1){k=M[(m+p|0)+108|0];l=m<<2;q=p+l|0;r=L[q+176>>2];a:{if(!r){o=k;k=1;if(!o){break a}}L[j+72>>2]=r;L[j+56>>2]=0;P[j+68>>2]=P[l+D>>2];P[j+64>>2]=P[l+C>>2];n=P[a+732>>2];J[j+60|0]=k;P[j+36>>2]=n;P[j+20>>2]=P[l+B>>2];P[j+40>>2]=P[a+728>>2];n=P[q>>2];L[j+32>>2]=0;P[j+16>>2]=n;P[j+28>>2]=P[l+A>>2];P[j+24>>2]=P[l+z>>2];P[j>>2]=P[l+y>>2];P[j+4>>2]=P[l+x>>2];n=P[l+w>>2];L[j+12>>2]=0;P[j+8>>2]=n;k=L[a+1304>>2]>>R(m,3);P[j+44>>2]=P[(k&1?l+v|0:L[b+32>>2])>>2];P[j+52>>2]=P[(k&2?l+u|0:L[b+32>>2])>>2];P[j+48>>2]=P[(k&4?l+t|0:s)>>2];o=j+16|0;k=0;b:{if(!M[a+1301|0]){break b}k=1;if(!L[(((m>>>0>1?-2:1)+m<<6)+a|0)+924>>2]){break b}k=!L[(((m?m-1|0:2)<<6)+a|0)+924>>2]}c=Ce(a,o,d,e,f,g,h,i,b,c,j,0,k)+c|0}m=m+1|0;if((m|0)!=3){continue}break}fa=j+80|0;return c}function vk(a){var b=0,c=S(0),d=S(0),e=0,f=0,g=0,h=0,i=S(0),j=S(0),k=0,l=S(0),m=S(0),n=S(0),o=S(0),p=S(0),q=S(0),r=0,s=S(0),t=S(0),u=0,v=S(0),w=S(0);b=fa-32|0;fa=b;u=a+988|0;Gd(u);if(L[a+752>>2]>0){while(1){h=L[a+760>>2]+R(r,44)|0;k=L[h+16>>2];g=L[h+12>>2];f=L[h+8>>2];e=L[f+12>>2];L[b+16>>2]=L[f+8>>2];L[b+20>>2]=e;e=L[f+20>>2];L[b+24>>2]=L[f+16>>2];L[b+28>>2]=e;e=L[f+20>>2];L[b+8>>2]=L[f+16>>2];L[b+12>>2]=e;e=L[f+12>>2];L[b>>2]=L[f+8>>2];L[b+4>>2]=e;l=P[b+4>>2];m=P[b>>2];d=P[g+8>>2];if(m>d){P[b>>2]=d;m=d}n=P[b+8>>2];s=P[b+28>>2];v=P[b+24>>2];w=P[b+20>>2];o=P[b+16>>2];t=P[b+12>>2];i=P[g+12>>2];if(i>2]=i;l=i}j=P[g+16>>2];if(j>2]=j;n=j}c=P[g+20>>2];if(c>2]=c;t=c}if(d>o){P[b+16>>2]=d;o=d}if(c>s){P[b+28>>2]=c;s=c}p=P[k+12>>2];g=p>2];e=d>2];c=P[k+20>>2];if(c>2]=c}if(c>s){P[b+28>>2]=c}P[b+4>>2]=g?p:l;P[b>>2]=e?d:m;P[b+8>>2]=n>q?q:n;c=j>v?j:v;P[b+24>>2]=(cw?i:w;P[b+20>>2]=(c>2]=(d>o?d:o)+S(0);L[h+40>>2]=Bb(u,b,h);r=r+1|0;if((r|0)>2]){continue}break}}fa=b+32|0}function LE(a,b,c,d,e,f,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;var h=S(0),i=S(0),j=0,k=0,l=S(0),m=S(0),n=S(0),o=0;L[d>>2]=2139095039;L[e>>2]=-8388609;o=L[a+96>>2];if((o|0)<=0){h=S(-34028234663852886e22)}else{while(1){k=L[a+104>>2]+(j<<4)|0;h=S(P[k+8>>2]*P[a+20>>2]);i=S(P[k>>2]*P[a+12>>2]);l=S(P[k+4>>2]*P[a+16>>2]);m=S(S(S(h*P[b+40>>2])+S(S(i*P[b+32>>2])+S(l*P[b+36>>2])))+P[b+56>>2]);n=S(S(S(h*P[b+8>>2])+S(S(i*P[b>>2])+S(l*P[b+4>>2])))+P[b+48>>2]);i=S(S(S(h*P[b+24>>2])+S(S(i*P[b+16>>2])+S(l*P[b+20>>2])))+P[b+52>>2]);h=S(S(m*P[c+8>>2])+S(S(n*P[c>>2])+S(i*P[c+4>>2])));if(h>2]){P[d>>2]=h;L[f+12>>2]=0;P[f+8>>2]=m;P[f+4>>2]=i;P[f>>2]=n}if(h>P[e>>2]){P[e>>2]=h;L[g+12>>2]=0;P[g+8>>2]=m;P[g+4>>2]=i;P[g>>2]=n}j=j+1|0;if((o|0)!=(j|0)){continue}break}h=P[e>>2]}i=P[d>>2];if(h>2]=h;P[e>>2]=i;b=L[f+12>>2];a=fa-16|0;L[a+8>>2]=L[f+8>>2];L[a+12>>2]=b;b=L[f+4>>2];L[a>>2]=L[f>>2];L[a+4>>2]=b;b=L[g+12>>2];L[f+8>>2]=L[g+8>>2];L[f+12>>2]=b;b=L[g+4>>2];L[f>>2]=L[g>>2];L[f+4>>2]=b;b=L[a+12>>2];L[g+8>>2]=L[a+8>>2];L[g+12>>2]=b;b=L[a+4>>2];L[g>>2]=L[a>>2];L[g+4>>2]=b}}function UB(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=S(0),f=S(0),g=S(0),h=S(0),i=S(0),j=S(0),k=S(0),l=S(0),m=S(0),n=S(0),o=S(0),p=S(0);e=S(1);d=L[b>>2];a:{if((d|0)==L[a+80>>2]|M[d+204|0]&4){break a}b:{if(c){g=P[b+16>>2];h=P[b+12>>2];f=P[b+8>>2];break b}f=P[b+16>>2];i=P[b+8>>2];j=P[b+12>>2];g=S(S(P[d+44>>2]*f)+S(S(P[d+36>>2]*i)+S(j*P[d+40>>2])));h=S(S(P[d+28>>2]*f)+S(S(P[d+20>>2]*i)+S(j*P[d+24>>2])));f=S(S(P[d+12>>2]*f)+S(S(P[d+4>>2]*i)+S(P[d+8>>2]*j)))}if(P[a+100>>2]>S(S(P[a+92>>2]*g)+S(S(P[a+84>>2]*f)+S(h*P[a+88>>2])))){break a}e=P[b+40>>2];L[a+76>>2]=d;P[a+4>>2]=e;c:{if(c){c=L[b+12>>2];L[a+44>>2]=L[b+8>>2];L[a+48>>2]=c;c=L[b+20>>2];L[a+52>>2]=L[b+16>>2];L[a+56>>2]=c;break c}f=P[d+8>>2];i=P[d+12>>2];j=P[d+20>>2];k=P[d+24>>2];l=P[d+28>>2];m=P[d+36>>2];n=P[d+40>>2];e=P[b+12>>2];o=P[d+44>>2];g=P[b+16>>2];p=P[d+4>>2];h=P[b+8>>2];L[a+56>>2]=0;P[a+52>>2]=S(o*g)+S(S(m*h)+S(e*n));P[a+48>>2]=S(l*g)+S(S(j*h)+S(e*k));P[a+44>>2]=S(i*g)+S(S(p*h)+S(f*e))}c=L[b+28>>2];L[a+60>>2]=L[b+24>>2];L[a+64>>2]=c;c=L[b+36>>2];L[a+68>>2]=L[b+32>>2];L[a+72>>2]=c;e=P[b+40>>2]}return S(e)}function Bk(a){var b=0,c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0;L[8513]=L[8513]+1;c=ha[L[6798]](20,16)|0;L[c>>2]=0;L[c+4>>2]=0;L[c+16>>2]=0;L[c+8>>2]=0;L[c+12>>2]=0;a:{if(L[a+872>>2]>0){b=L[L[a+880>>2]>>2];d=L[b+4>>2];L[c>>2]=L[b>>2];L[c+4>>2]=d;L[c+16>>2]=L[b+16>>2];d=L[b+12>>2];L[c+8>>2]=L[b+8>>2];L[c+12>>2]=d;break a}L[c>>2]=0;L[c+4>>2]=0;L[c+16>>2]=0;L[c+8>>2]=0;L[c+12>>2]=0}b=L[a+872>>2];b:{if((b|0)!=L[a+876>>2]){break b}h=b?b<<1:1;if((h|0)<=(b|0)){break b}if(h){L[8513]=L[8513]+1;f=ha[L[6798]](h<<2,16)|0;b=L[a+872>>2]}c:{if((b|0)<=0){break c}if(b>>>0>=4){i=b&-4;while(1){d=e<<2;L[d+f>>2]=L[d+L[a+880>>2]>>2];g=d|4;L[g+f>>2]=L[g+L[a+880>>2]>>2];g=d|8;L[g+f>>2]=L[g+L[a+880>>2]>>2];d=d|12;L[d+f>>2]=L[d+L[a+880>>2]>>2];e=e+4|0;j=j+4|0;if((i|0)!=(j|0)){continue}break}}d=b&3;if(!d){break c}while(1){i=e<<2;L[i+f>>2]=L[i+L[a+880>>2]>>2];e=e+1|0;k=k+1|0;if((d|0)!=(k|0)){continue}break}}e=L[a+880>>2];if(!(!e|!M[a+884|0])){if(e){L[8514]=L[8514]+1;ha[L[6799]](e)}b=L[a+872>>2]}L[a+880>>2]=f;J[a+884|0]=1;L[a+876>>2]=h}L[L[a+880>>2]+(b<<2)>>2]=c;L[a+872>>2]=b+1;return c}function HF(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0;db(a,b,c);d=L[a+48>>2];ha[L[L[d>>2]+56>>2]](d,b+12|0,c)|0;P[b+52>>2]=P[a+12>>2];a:{b:{if(!L[a+52>>2]){break b}if(ha[L[L[c>>2]+52>>2]](c)&1){break b}d=ha[L[L[c>>2]+24>>2]](c,L[a+52>>2])|0;if(d){L[b+44>>2]=0;L[b+40>>2]=d;break a}d=ha[L[L[c>>2]+28>>2]](c,L[a+52>>2])|0;L[b+44>>2]=0;L[b+40>>2]=d;d=L[a+52>>2];d=(g=c,h=ha[L[L[d>>2]+12>>2]](d)|0,i=1,f=L[L[c>>2]+16>>2],ha[f](g|0,h|0,i|0)|0);e=L[a+52>>2];i=c,h=d,g=ha[L[L[e>>2]+16>>2]](e,L[d+8>>2],c)|0,j=1213612625,k=L[a+52>>2],f=L[L[c>>2]+20>>2],ha[f](i|0,h|0,g|0,j|0,k|0);break a}L[b+40>>2]=0;L[b+44>>2]=0}c:{if(!L[a+56>>2]){break c}if(ha[L[L[c>>2]+52>>2]](c)&2){break c}d=ha[L[L[c>>2]+24>>2]](c,L[a+56>>2])|0;if(d){L[b+48>>2]=d;return 3933}L[b+48>>2]=ha[L[L[c>>2]+28>>2]](c,L[a+56>>2]);b=L[a+56>>2];b=(k=c,j=ha[L[L[b>>2]+8>>2]](b)|0,g=1,f=L[L[c>>2]+16>>2],ha[f](k|0,j|0,g|0)|0);d=L[a+56>>2];g=c,j=b,k=ha[L[L[d>>2]+12>>2]](d,L[b+8>>2],c)|0,h=1346456916,i=L[a+56>>2],f=L[L[c>>2]+20>>2],ha[f](g|0,j|0,k|0,h|0,i|0);return 3933}L[b+48>>2]=0;return 3933}function gl(a,b,c,d,e,f){a=ub(a,4,b,c);L[a>>2]=19768;b=L[d+12>>2];L[a+560>>2]=L[d+8>>2];L[a+564>>2]=b;b=L[d+4>>2];L[a+552>>2]=L[d>>2];L[a+556>>2]=b;b=L[d+28>>2];L[a+576>>2]=L[d+24>>2];L[a+580>>2]=b;b=L[d+20>>2];L[a+568>>2]=L[d+16>>2];L[a+572>>2]=b;b=L[d+44>>2];L[a+592>>2]=L[d+40>>2];L[a+596>>2]=b;b=L[d+36>>2];L[a+584>>2]=L[d+32>>2];L[a+588>>2]=b;b=L[d+60>>2];L[a+608>>2]=L[d+56>>2];L[a+612>>2]=b;b=L[d+52>>2];L[a+600>>2]=L[d+48>>2];L[a+604>>2]=b;b=L[e+12>>2];L[a+624>>2]=L[e+8>>2];L[a+628>>2]=b;b=L[e+4>>2];L[a+616>>2]=L[e>>2];L[a+620>>2]=b;b=L[e+20>>2];L[a+632>>2]=L[e+16>>2];L[a+636>>2]=b;b=L[e+28>>2];L[a+640>>2]=L[e+24>>2];L[a+644>>2]=b;b=L[e+36>>2];L[a+648>>2]=L[e+32>>2];L[a+652>>2]=b;b=L[e+44>>2];L[a+656>>2]=L[e+40>>2];L[a+660>>2]=b;b=L[e+52>>2];L[a+664>>2]=L[e+48>>2];L[a+668>>2]=b;b=L[e+60>>2];L[a+672>>2]=L[e+56>>2];L[a+676>>2]=b;L[a+688>>2]=0;L[a+692>>2]=-1082130432;L[a+696>>2]=1063675494;L[a+700>>2]=1050253722;L[a+704>>2]=1065353216;L[a+708>>2]=0;L[a+712>>2]=0;J[a+716|0]=0;J[a+740|0]=f;L[a+748>>2]=0;L[a+736>>2]=16777216;P[a+732>>2]=f?S(-1):S(1)}function fC(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0,g=0,h=S(0),i=S(0),j=S(0),k=S(0),l=S(0),m=0,n=S(0);e=fa-672|0;fa=e;f=yb(e+568|0);L[f+4>>2]=1;L[f>>2]=2236;m=L[b+12>>2];g=f- -64|0;L[g>>2]=L[b+8>>2];L[g+4>>2]=m;g=L[b+4>>2];L[f+56>>2]=L[b>>2];L[f+60>>2]=g;g=L[b+28>>2];L[f+80>>2]=L[b+24>>2];L[f+84>>2]=g;g=L[b+20>>2];L[f+72>>2]=L[b+16>>2];L[f+76>>2]=g;g=L[b+44>>2];L[f+96>>2]=L[b+40>>2];L[f+100>>2]=g;g=L[b+36>>2];L[f+88>>2]=L[b+32>>2];L[f+92>>2]=g;P[f+44>>2]=P[a+204>>2];J[e+540|0]=0;L[e+516>>2]=953267991;L[e+204>>2]=18492;g=L[a+4>>2];b=e+180|0;L[b+20>>2]=0;L[b+16>>2]=f;L[b+12>>2]=g;L[b+8>>2]=e+204;L[b+4>>2]=e+208;L[b>>2]=18268;L[e+4>>2]=6864;L[e+168>>2]=1065353216;L[e+172>>2]=0;P[e+176>>2]=P[a+208>>2];g=b;b=a+136|0;a:{if(!Il(g,a+8|0,a+72|0,b,b,e+4|0)){break a}h=P[e+144>>2];i=P[e+136>>2];j=P[e+140>>2];k=S(S(h*h)+S(S(i*i)+S(j*j)));if(!(k>S(9999999747378752e-20))){break a}l=P[e+168>>2];if(!(l>2])){break a}n=h;h=S(S(1)/S(_(k)));P[e+144>>2]=n*h;P[e+140>>2]=j*h;P[e+136>>2]=i*h;S(ha[L[L[a>>2]+12>>2]](a,e+136|0,e+152|0,l,c,d))}Oa(f);fa=e+672|0}function oB(a,b,c){a=a|0;b=b|0;c=c|0;cc(a,b,c);P[b+52>>2]=P[a+552>>2];P[b+56>>2]=P[a+556>>2];P[b+60>>2]=P[a+560>>2];P[b- -64>>2]=P[a+564>>2];P[b+68>>2]=P[a+568>>2];P[b+72>>2]=P[a+572>>2];P[b+76>>2]=P[a+576>>2];P[b+80>>2]=P[a+580>>2];P[b+84>>2]=P[a+584>>2];P[b+88>>2]=P[a+588>>2];P[b+92>>2]=P[a+592>>2];P[b+96>>2]=P[a+596>>2];P[b+100>>2]=P[a+600>>2];P[b+104>>2]=P[a+604>>2];P[b+108>>2]=P[a+608>>2];P[b+112>>2]=P[a+612>>2];P[b+116>>2]=P[a+616>>2];P[b+120>>2]=P[a+620>>2];P[b+124>>2]=P[a+624>>2];P[b+128>>2]=P[a+628>>2];P[b+132>>2]=P[a+632>>2];P[b+136>>2]=P[a+636>>2];P[b+140>>2]=P[a+640>>2];P[b+144>>2]=P[a+644>>2];P[b+148>>2]=P[a+648>>2];P[b+152>>2]=P[a+652>>2];P[b+156>>2]=P[a+656>>2];P[b+160>>2]=P[a+660>>2];P[b+164>>2]=P[a+664>>2];P[b+168>>2]=P[a+668>>2];P[b+172>>2]=P[a+672>>2];P[b+176>>2]=P[a+676>>2];L[b+184>>2]=M[a+736|0];L[b+188>>2]=M[a+737|0];P[b+196>>2]=P[a+684>>2];P[b+192>>2]=P[a+680>>2];L[b+180>>2]=M[a+740|0];c=a+688|0;P[b+200>>2]=we(c);P[b+204>>2]=xe(c);P[b+208>>2]=P[a+696>>2];P[b+212>>2]=P[a+700>>2];P[b+216>>2]=P[a+704>>2];return 3556}function DA(a,b){a=a|0;b=S(b);var c=0,d=S(0),e=0,f=S(0),g=0,h=S(0);wa(3159);if(L[a+232>>2]>0){while(1){c=L[L[a+240>>2]+(g<<2)>>2];a:{if(!c){break a}b:{c:{d:{e=L[c+216>>2];switch(e-2|0){case 0:case 2:break c;default:break d}}e:{d=P[c+320>>2];f=S(d*d);d=P[c+312>>2];h=S(d*d);d=P[c+316>>2];f=S(f+S(h+S(d*d)));d=P[c+472>>2];if(!(f>2];f=S(d*d);d=P[c+328>>2];h=S(d*d);d=P[c+332>>2];f=S(f+S(h+S(d*d)));d=P[c+476>>2];if(!(f>2]=P[c+220>>2]+b;break b}L[c+220>>2]=0;if((L[c+216>>2]&-2)!=4){L[c+216>>2]=0}e=L[c+216>>2]}if((e|0)==4){break a}}f:{if(M[33160]){break f}d=P[6796];if(d==S(0)|!(d>2])&(e&-2)!=2){break f}if(M[c+204|0]&3){if((L[c+216>>2]&-2)!=4){L[c+216>>2]=2}break a}if((e|0)==1){if((L[c+216>>2]&-2)!=4){L[c+216>>2]=3}e=L[c+216>>2]}if((e|0)!=2){break a}L[c+328>>2]=0;L[c+332>>2]=0;L[c+312>>2]=0;L[c+316>>2]=0;L[c+336>>2]=0;L[c+340>>2]=0;L[c+320>>2]=0;L[c+324>>2]=0;L[c+260>>2]=L[c+260>>2]+2;break a}if((L[c+216>>2]&-2)!=4){L[c+216>>2]=1}}g=g+1|0;if((g|0)>2]){continue}break}}va()}function WD(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0;db(a,b,c);P[b+28>>2]=P[a+28>>2];P[b+32>>2]=P[a+32>>2];P[b+36>>2]=P[a+36>>2];P[b+40>>2]=P[a+40>>2];P[b+12>>2]=P[a+12>>2];P[b+16>>2]=P[a+16>>2];P[b+20>>2]=P[a+20>>2];P[b+24>>2]=P[a+24>>2];P[b+44>>2]=P[a+44>>2];d=L[a+92>>2];if(d){f=ha[L[L[c>>2]+28>>2]](c,L[a+100>>2])|0;L[b+56>>2]=d;L[b+52>>2]=f;b=0;h=ha[L[L[c>>2]+16>>2]](c,20,d)|0;a:{if((d|0)<=0){f=L[a+100>>2];break a}g=L[a+120>>2];f=L[a+100>>2];a=L[h+8>>2];if((d|0)!=1){k=d&-2;while(1){e=(b<<4)+f|0;P[a>>2]=P[e>>2];P[a+4>>2]=P[e+4>>2];P[a+8>>2]=P[e+8>>2];P[a+12>>2]=P[e+12>>2];P[a+16>>2]=P[(b<<2)+g>>2];i=b|1;e=(i<<4)+f|0;P[a+20>>2]=P[e>>2];P[a+24>>2]=P[e+4>>2];P[a+28>>2]=P[e+8>>2];P[a+32>>2]=P[e+12>>2];P[a+36>>2]=P[(i<<2)+g>>2];a=a+40|0;b=b+2|0;j=j+2|0;if((k|0)!=(j|0)){continue}break}}if(!(d&1)){break a}d=(b<<4)+f|0;P[a>>2]=P[d>>2];P[a+4>>2]=P[d+4>>2];P[a+8>>2]=P[d+8>>2];P[a+12>>2]=P[d+12>>2];P[a+16>>2]=P[(b<<2)+g>>2]}ha[L[L[c>>2]+20>>2]](c,h,2514,1497453121,f);return 3957}L[b+52>>2]=0;L[b+56>>2]=0;return 3957}function bG(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=S(0),g=0,h=0,i=S(0),j=S(0),k=S(0),l=S(0),m=S(0),n=S(0),o=S(0),p=S(0);d=fa-32|0;fa=d;a=L[a+12>>2];a:{if(!a){break a}L[e+4>>2]=a;g=L[b+12>>2];h=L[c+12>>2];n=P[h+56>>2];i=S(P[g+56>>2]-n);o=P[h+48>>2];m=S(P[g+48>>2]-o);p=P[h+52>>2];j=S(P[g+52>>2]-p);f=S(_(S(S(i*i)+S(S(m*m)+S(j*j)))));b=L[b+4>>2];k=S(P[b+28>>2]*P[b+12>>2]);b=L[c+4>>2];l=S(P[b+28>>2]*P[b+12>>2]);k=S(k+l);if(f>k){if(!L[a+748>>2]){break a}c=L[a+740>>2];g=L[L[e+8>>2]+8>>2];b=(c|0)==(g|0);h=a;a=L[L[e+12>>2]+8>>2];_a(h,(b?c:a)+4|0,(b?a:g)+4|0);break a}L[d+24>>2]=0;L[d+28>>2]=0;L[d+16>>2]=1065353216;L[d+20>>2]=0;k=S(f-k);b:{if(!(f>S(1.1920928955078125e-7))){f=S(1);i=S(0);j=S(0);break b}f=S(S(1)/f);i=S(i*f);P[d+24>>2]=i;j=S(j*f);P[d+20>>2]=j;f=S(m*f);P[d+16>>2]=f}L[d+12>>2]=0;P[d+8>>2]=S(l*i)+n;P[d+4>>2]=S(l*j)+p;P[d>>2]=S(l*f)+o;ha[L[L[e>>2]+16>>2]](e,d+16|0,d,k);a=L[e+4>>2];if(!L[a+748>>2]){break a}c=L[a+740>>2];g=L[L[e+8>>2]+8>>2];b=(c|0)==(g|0);h=a;a=L[L[e+12>>2]+8>>2];_a(h,(b?c:a)+4|0,(b?a:g)+4|0)}fa=d+32|0}function Sw(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0,g=0,h=0;d=fa-16|0;fa=d;L[d+12>>2]=a;L[d+8>>2]=b;a=L[d+8>>2];e=fa-16|0;fa=e;L[e+12>>2]=L[d+12>>2]+24;L[e+8>>2]=a;a=L[e+8>>2];b=fa-48|0;fa=b;L[b+44>>2]=L[e+12>>2];L[b+40>>2]=a;g=L[b+44>>2];a=fa-16|0;L[a+12>>2]=L[b+40>>2];L[b+36>>2]=L[L[a+12>>2]+4>>2];c=L[b+36>>2];L[b+32>>2]=0;L[b+24>>2]=0;L[b+28>>2]=0;L[b+16>>2]=0;L[b+20>>2]=0;L[b+8>>2]=0;L[b+12>>2]=0;L[b>>2]=0;L[b+4>>2]=0;rf(b);a=fa-32|0;fa=a;L[a+28>>2]=g;L[a+24>>2]=c;L[a+20>>2]=b;f=fa-16|0;c=L[a+28>>2];L[f+12>>2]=c;L[a+16>>2]=L[L[f+12>>2]+4>>2];a:{if(L[a+24>>2]>2]){L[a+12>>2]=L[a+24>>2];while(1){if(L[a+12>>2]>2]){rc(L[c+12>>2]+R(L[a+12>>2],36)|0);L[a+12>>2]=L[a+12>>2]+1;continue}break}break a}f=L[a+24>>2];h=fa-16|0;L[h+12>>2]=c;if(L[L[h+12>>2]+4>>2]<(f|0)){Fh(c,L[a+24>>2])}L[a+8>>2]=L[a+16>>2];while(1){if(L[a+8>>2]>2]){Eh(L[c+12>>2]+R(L[a+8>>2],36)|0,L[a+20>>2]);L[a+8>>2]=L[a+8>>2]+1;continue}break}}L[c+4>>2]=L[a+24>>2];fa=a+32|0;rc(b);Gh(L[b+40>>2],L[b+36>>2],L[g+12>>2]);fa=b+48|0;fa=e+16|0;fa=d+16|0}function lF(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=S(0),f=S(0),g=S(0),h=S(0),i=S(0),j=S(0),k=S(0),l=S(0),m=S(0),n=S(0),o=S(0),p=S(0),q=S(0),r=S(0),s=S(0),t=S(0),u=S(0),v=S(0),w=S(0),x=S(0),y=S(0);a:{if(L[a+16>>2]){g=P[a+56>>2];e=P[a+40>>2];h=S(S(g+e)*S(.5));f=P[a+52>>2];k=P[a+36>>2];i=S(S(f+k)*S(.5));l=S(S(g-e)*S(.5));u=S(S(f-k)*S(.5));e=P[a+48>>2];f=P[a+32>>2];g=S(S(e+f)*S(.5));e=S(S(e-f)*S(.5));break a}e=S(0)}v=S(ha[L[L[a>>2]+48>>2]](a));w=S(ha[L[L[a>>2]+48>>2]](a));p=S(ha[L[L[a>>2]+48>>2]](a));x=P[b+52>>2];f=P[b+20>>2];k=P[b+24>>2];o=P[b+56>>2];m=P[b+36>>2];j=P[b+40>>2];y=P[b+48>>2];q=P[b+8>>2];r=P[b>>2];s=P[b+4>>2];t=P[b+16>>2];n=P[b+32>>2];L[c+12>>2]=0;o=S(o+S(S(h*j)+S(S(g*n)+S(i*m))));l=S(l+p);p=S(l*S(T(j)));e=S(e+v);j=S(u+w);m=S(p+S(S(e*S(T(n)))+S(j*S(T(m)))));P[c+8>>2]=o-m;n=S(x+S(S(h*k)+S(S(g*t)+S(i*f))));f=S(S(l*S(T(k)))+S(S(e*S(T(t)))+S(j*S(T(f)))));P[c+4>>2]=n-f;h=S(y+S(S(h*q)+S(S(g*r)+S(i*s))));i=S(S(l*S(T(q)))+S(S(e*S(T(r)))+S(j*S(T(s)))));P[c>>2]=h-i;L[d+12>>2]=0;P[d+8>>2]=m+o;P[d+4>>2]=f+n;P[d>>2]=i+h}function Xa(a,b,c){var d=0,e=S(0),f=0,g=0,h=S(0),i=S(0),j=S(0),k=S(0),l=S(0),m=S(0),n=S(0),o=S(0),p=S(0),q=S(0),r=S(0),s=S(0),t=S(0),u=S(0),v=0,w=S(0),x=S(0),y=S(0);d=fa-48|0;fa=d;f=L[b+120>>2];v=L[b+124>>2];g=L[b>>2]+(v>>1)|0;if(v&1){f=L[f+L[g>>2]>>2]}ha[f|0](d,g,c);h=P[c+8>>2];i=P[c+4>>2];k=P[c>>2];f=L[b+124>>2];g=L[b+4>>2]+(f>>1)|0;c=L[b+120>>2];c=f&1?L[L[g>>2]+c>>2]:c;l=P[b+16>>2];m=P[b+12>>2];n=P[b+32>>2];o=P[b+24>>2];p=P[b+28>>2];q=P[b+48>>2];e=P[b+40>>2];r=P[b+44>>2];s=P[b+8>>2];L[d+28>>2]=0;j=e;e=S(-k);P[d+24>>2]=S(S(j*e)-S(r*i))-S(q*h);P[d+20>>2]=S(S(o*e)-S(p*i))-S(n*h);P[d+16>>2]=S(S(s*e)-S(m*i))-S(l*h);ha[c|0](d+32|0,g,d+16|0);w=P[b+104>>2];x=P[b- -64>>2];y=P[b+60>>2];h=P[b+108>>2];i=P[b+80>>2];k=P[b+72>>2];l=P[b+76>>2];m=P[b+112>>2];n=P[b+96>>2];o=P[b+88>>2];p=P[b+92>>2];q=P[b+56>>2];j=P[d+40>>2];t=P[d+32>>2];u=P[d+36>>2];e=P[d>>2];r=P[d+4>>2];s=P[d+8>>2];L[a+12>>2]=0;P[a+8>>2]=s-S(m+S(S(j*n)+S(S(t*o)+S(u*p))));P[a+4>>2]=r-S(h+S(S(j*i)+S(S(t*k)+S(u*l))));P[a>>2]=e-S(w+S(S(j*x)+S(S(t*q)+S(u*y))));fa=d+48|0}function tB(a,b){a=a|0;b=b|0;var c=S(0),d=0,e=0,f=S(0),g=S(0),h=S(0),i=S(0),j=S(0),k=S(0),l=S(0),m=S(0),n=S(0),o=S(0),p=S(0),q=S(0),r=S(0),s=S(0),t=S(0),u=S(0),v=S(0),w=S(0);a:{b:{if(M[a+738|0]){L[b>>2]=0;a=0;break b}L[b>>2]=5;L[b+4>>2]=1;d=L[a+32>>2];c=P[a+652>>2];f=P[a+620>>2];g=P[a+636>>2];l=S(S(P[d+44>>2]*c)+S(S(P[d+36>>2]*f)+S(g*P[d+40>>2])));e=L[a+28>>2];m=P[e+44>>2];h=P[a+584>>2];n=P[e+36>>2];i=P[a+552>>2];j=P[a+568>>2];o=P[e+40>>2];u=S(l*S(S(m*h)+S(S(n*i)+S(j*o))));p=S(S(P[d+12>>2]*c)+S(S(P[d+4>>2]*f)+S(g*P[d+8>>2])));q=P[e+12>>2];r=P[e+4>>2];s=P[e+8>>2];v=S(p*S(S(q*h)+S(S(r*i)+S(j*s))));t=P[e+28>>2];k=S(t*h);h=P[e+20>>2];w=S(h*i);i=P[e+24>>2];k=S(k+S(w+S(j*i)));j=S(S(P[d+28>>2]*c)+S(S(P[d+20>>2]*f)+S(g*P[d+24>>2])));c=P[a+588>>2];f=P[a+556>>2];g=P[a+572>>2];c=S(Za(S(u+S(v+S(k*j))),S(S(l*S(S(m*c)+S(S(n*f)+S(o*g))))+S(S(p*S(S(q*c)+S(S(r*f)+S(s*g))))+S(S(S(t*c)+S(S(h*f)+S(i*g)))*j))))*P[a+732>>2]);P[a+728>>2]=c;_k(a+688|0,c);if(!(M[a+716|0]|M[a+737|0])){break a}L[b>>2]=L[b>>2]+1;a=L[b+4>>2]-1|0}L[b+4>>2]=a}}function Fo(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,f=0;d=fa+-64|0;fa=d;L[d+60>>2]=a;L[d+56>>2]=b;J[d+55|0]=c;b=L[d+60>>2];L[b+8>>2]=L[L[d+56>>2]>>2];Hf(b+20|0,L[d+56>>2]);L[(fa-16|0)+12>>2]=d+32;a:{if(J[d+55|0]&1){a=L[d+56>>2];c=L[a+20>>2];L[d+40>>2]=L[a+16>>2];L[d+44>>2]=c;c=L[a+12>>2];L[d+32>>2]=L[a+8>>2];L[d+36>>2]=c;break a}a=fa-16|0;L[a+12>>2]=L[b+8>>2];L[a+12>>2]=L[a+12>>2]+4;ua(d+16|0,L[a+12>>2],L[d+56>>2]+8|0);a=L[d+28>>2];L[d+40>>2]=L[d+24>>2];L[d+44>>2]=a;a=L[d+20>>2];L[d+32>>2]=L[d+16>>2];L[d+36>>2]=a}_h(b+72|0,d+32|0);L[(fa-16|0)+12>>2]=d;ai(d,b+40|0,b+56|0,P[L[d+56>>2]+24>>2]);_h(b+92|0,d);a=L[d+56>>2]+24|0;c=fa-16|0;fa=c;L[c+12>>2]=b+112;L[c+8>>2]=a;e=fa-16|0;a=L[c+12>>2];L[e+12>>2]=a;L[c+4>>2]=L[L[e+12>>2]+4>>2];e=L[c+4>>2];f=fa-16|0;L[f+12>>2]=a;if(L[L[f+12>>2]+8>>2]==(e|0)){e=fa-16|0;L[e+12>>2]=a;f=L[L[e+12>>2]+4>>2];L[e+12>>2]=a;L[e+8>>2]=f;if(L[e+8>>2]){e=L[e+8>>2]<<1}else{e=1}Wh(a,e)}P[L[a+12>>2]+(L[a+4>>2]<<2)>>2]=P[L[c+8>>2]>>2];L[a+4>>2]=L[a+4>>2]+1;fa=c+16|0;fa=d- -64|0;return S(P[b+4>>2])}function kp(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=S(0),g=0,h=S(0),i=0,j=0,k=0,l=S(0),m=0,n=0,o=S(0),p=S(0),q=S(0);g=fa-32|0;fa=g;L[g+28>>2]=a;L[g+24>>2]=b;L[g+20>>2]=c;L[g+16>>2]=d;L[g+12>>2]=e;m=L[g+24>>2];i=L[g+20>>2];j=L[g+16>>2];a=0;k=L[g+12>>2];c=k+3|0;a:{if((k|0)>=-2){l=S(c|0);L[8513]=L[8513]+1;e=ha[L[6798]](c<<4,16)|0;d=e;while(1){f=S(0);h=S(.5);b=a;if(b){while(1){f=S(f+(b&1?h:S(-0)));n=b>>>0<2;b=b>>>1|0;h=S(h*S(.5));if(!n){continue}break}}L[d+12>>2]=0;f=S(S(f+f)+S(-1));P[d+8>>2]=f;h=S(S(S(S(a<<1)*S(3.1415927410125732))+S(3.1415927410125732))/l);f=S(_(S(S(1)-S(f*f))));P[d+4>>2]=Ea(h)*f;P[d>>2]=Fa(h)*f;d=d+16|0;a=a+1|0;if((c|0)!=(a|0)){continue}break}if((k|0)>=-2){d=(c|0)<=1?1:c;a=0;while(1){f=P[i>>2];h=P[j>>2];l=P[i+4>>2];o=P[j+4>>2];p=P[i+8>>2];q=P[j+8>>2];b=e+(a<<4)|0;L[b+12>>2]=0;P[b+8>>2]=p+S(q*P[b+8>>2]);P[b+4>>2]=l+S(o*P[b+4>>2]);P[b>>2]=f+S(h*P[b>>2]);a=a+1|0;if((d|0)!=(a|0)){continue}break}}a=fg(m,e,c,1);if(e){L[8514]=L[8514]+1;ha[L[6799]](e)}break a}a=fg(m,0,c,1)}fa=g+32|0;return a|0}function eg(a){a=a|0;var b=0,c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0;L[a>>2]=21988;if(L[a+104>>2]>0){while(1){i=L[a+112>>2]+(f<<3)|0;d=L[i+4>>2];g=L[L[a+4>>2]+684>>2];c=L[g+60>>2];if((c|0)>0){e=0;while(1){h=0;j=L[g+68>>2]+(e<<2)|0;b=L[j>>2];if(b){while(1){c=L[b+280>>2];a:{if(L[b+276>>2]!=(d|0)){h=b;break a}L[(h?h+280|0:j)>>2]=c;ra(b)}b=c;if(b){continue}break}c=L[g+60>>2]}e=e+1|0;if((e|0)<(c|0)){continue}break}d=L[i+4>>2]}if(d){ha[L[L[d>>2]+4>>2]](d)}f=f+1|0;if((f|0)>2]){continue}break}}jk(a+60|0);b=L[a+132>>2];if(!(b?!b|!M[a+136|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+132>>2]=0;J[a+136|0]=1;L[a+124>>2]=0;L[a+128>>2]=0;b=L[a+112>>2];if(!(b?!b|!M[a+116|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+112>>2]=0;J[a+116|0]=1;L[a+104>>2]=0;L[a+108>>2]=0;b=L[a+92>>2];if(!(b?!b|!M[a+96|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+92>>2]=0;J[a+96|0]=1;L[a+84>>2]=0;L[a+88>>2]=0;b=L[a+72>>2];if(!(b?!b|!M[a+76|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+72>>2]=0;J[a+76|0]=1;b=a- -64|0;L[b>>2]=0;L[b+4>>2]=0;return a|0}function jl(a,b,c,d,e,f,g,h,i){var j=0,k=0,l=0;k=fa-16|0;fa=k;if(L[a+924>>2]|M[a+912|0]){j=a+1216|0;l=L[j+4>>2];L[k+8>>2]=L[j>>2];L[k+12>>2]=l;j=L[a+1212>>2];L[k>>2]=L[a+1208>>2];L[k+4>>2]=j;j=L[a+1304>>2];if(!(j&512)){P[a+896>>2]=P[L[b+32>>2]>>2]}if(!(j&1024)){P[a+904>>2]=P[L[b+32>>2]>>2]}if(!(j&2048)){P[a+900>>2]=P[b+4>>2]}c=Ce(a,a+868|0,d,e,f,g,h,i,b,c,k,1,0)+c|0}if(L[a+988>>2]|M[a+976|0]){j=a+1232|0;l=L[j+4>>2];L[k+8>>2]=L[j>>2];L[k+12>>2]=l;j=a+1224|0;l=L[j+4>>2];L[k>>2]=L[j>>2];L[k+4>>2]=l;j=L[a+1304>>2];if(!(j&4096)){P[a+960>>2]=P[L[b+32>>2]>>2]}if(!(j&8192)){P[a+968>>2]=P[L[b+32>>2]>>2]}if(!(j&16384)){P[a+964>>2]=P[b+4>>2]}c=Ce(a,a+932|0,d,e,f,g,h,i,b,c,k,1,0)+c|0}if(L[a+1052>>2]|M[a+1040|0]){j=a+1248|0;l=L[j+4>>2];L[k+8>>2]=L[j>>2];L[k+12>>2]=l;j=a+1240|0;l=L[j+4>>2];L[k>>2]=L[j>>2];L[k+4>>2]=l;j=L[a+1304>>2];if(!(j&32768)){P[a+1024>>2]=P[L[b+32>>2]>>2]}if(!(j&65536)){P[a+1032>>2]=P[L[b+32>>2]>>2]}if(!(j&131072)){P[a+1028>>2]=P[b+4>>2]}c=Ce(a,a+996|0,d,e,f,g,h,i,b,c,k,1,0)+c|0}fa=k+16|0;return c}function Pm(a){var b=0,c=0,d=0,e=0,f=0,g=0,h=0,i=0;b=L[a+16>>2];if(!(b?!b|!M[a+20|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+16>>2]=0;J[a+20|0]=1;L[a+8>>2]=0;L[a+12>>2]=0;b=L[a+40>>2];if(!(b?!b|!M[a+44|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+40>>2]=0;J[a+44|0]=1;L[a+32>>2]=0;L[a+36>>2]=0;b=L[a+60>>2];if(!(b?!b|!M[a- -64|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+60>>2]=0;J[a+64|0]=1;L[a+52>>2]=0;L[a+56>>2]=0;if(L[a+12>>2]<=1){L[8513]=L[8513]+1;f=ha[L[6798]](24,16)|0;d=L[a+8>>2];a:{if((d|0)<=0){break a}b=0;if((d|0)!=1){i=d&-2;while(1){c=R(b,12);e=c+L[a+16>>2]|0;g=L[e+4>>2];c=c+f|0;L[c>>2]=L[e>>2];L[c+4>>2]=g;L[c+8>>2]=L[e+8>>2];c=R(b|1,12);e=c+L[a+16>>2]|0;g=L[e+4>>2];c=c+f|0;L[c>>2]=L[e>>2];L[c+4>>2]=g;L[c+8>>2]=L[e+8>>2];b=b+2|0;h=h+2|0;if((h|0)!=(i|0)){continue}break}}if(!(d&1)){break a}d=R(b,12);b=d+L[a+16>>2]|0;e=L[b+4>>2];d=d+f|0;L[d>>2]=L[b>>2];L[d+4>>2]=e;L[d+8>>2]=L[b+8>>2]}b=L[a+16>>2];if(!(b?!b|!M[a+20|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+16>>2]=f;J[a+20|0]=1;L[a+12>>2]=2}dh(a)}function iG(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;f=L[a+188>>2];j=L[b>>2];d=L[a+268>>2];a:{b:{if((d|0)<=0){break b}g=L[a+276>>2];while(1){if(L[g+(e<<2)>>2]!=(j|0)){e=e+1|0;if((e|0)!=(d|0)){continue}break b}break}if((d|0)!=(e|0)){break a}}m=c?c:f;c:{if(L[a+272>>2]!=(d|0)){break c}g=d?d<<1:1;if((g|0)<=(d|0)){break c}d:{if(!g){c=0;break d}L[8513]=L[8513]+1;c=ha[L[6798]](g<<2,16)|0;d=L[a+268>>2]}e:{if((d|0)<=0){break e}e=0;if(d>>>0>=4){i=d&-4;while(1){f=e<<2;L[f+c>>2]=L[f+L[a+276>>2]>>2];h=f|4;L[h+c>>2]=L[h+L[a+276>>2]>>2];h=f|8;L[h+c>>2]=L[h+L[a+276>>2]>>2];f=f|12;L[f+c>>2]=L[f+L[a+276>>2]>>2];e=e+4|0;k=k+4|0;if((i|0)!=(k|0)){continue}break}}f=d&3;if(!f){break e}while(1){i=e<<2;L[i+c>>2]=L[i+L[a+276>>2]>>2];e=e+1|0;l=l+1|0;if((f|0)!=(l|0)){continue}break}}e=L[a+276>>2];if(!(!e|!M[a+280|0])){if(e){L[8514]=L[8514]+1;ha[L[6799]](e)}d=L[a+268>>2]}L[a+276>>2]=c;J[a+280|0]=1;L[a+272>>2]=g}L[L[a+276>>2]+(d<<2)>>2]=j;L[a+268>>2]=d+1;a=L[a+284>>2];ha[L[L[a>>2]+8>>2]](a,m,b)|0}}function Ky(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,f=0,g=0;e=fa+-64|0;fa=e;d=1;a:{if(Wa(a,b,0)){break a}d=0;if(!b){break a}d=fa+-64|0;fa=d;f=L[b>>2];g=L[f-4>>2];f=L[f-8>>2];L[d+32>>2]=0;L[d+36>>2]=0;L[d+40>>2]=0;L[d+44>>2]=0;L[d+48>>2]=0;L[d+52>>2]=0;J[d+55|0]=0;J[d+56|0]=0;J[d+57|0]=0;J[d+58|0]=0;J[d+59|0]=0;J[d+60|0]=0;J[d+61|0]=0;J[d+62|0]=0;L[d+24>>2]=0;L[d+28>>2]=0;L[d+20>>2]=0;L[d+16>>2]=26868;L[d+12>>2]=b;L[d+8>>2]=26916;f=b+f|0;b=0;b:{if(Wa(g,26916,0)){L[d+56>>2]=1;ha[L[L[g>>2]+20>>2]](g,d+8|0,f,f,1,0);b=L[d+32>>2]==1?f:0;break b}ha[L[L[g>>2]+24>>2]](g,d+8|0,f,1,0);c:{switch(L[d+44>>2]){case 0:b=L[d+48>>2]==1?L[d+36>>2]==1?L[d+40>>2]==1?L[d+28>>2]:0:0:0;break b;case 1:break c;default:break b}}if(L[d+32>>2]!=1){if(L[d+48>>2]|L[d+36>>2]!=1|L[d+40>>2]!=1){break b}}b=L[d+24>>2]}fa=d- -64|0;d=0;if(!b){break a}pa(e+12|0,0,52);L[e+56>>2]=1;L[e+20>>2]=-1;L[e+16>>2]=a;L[e+8>>2]=b;ha[L[L[b>>2]+28>>2]](b,e+8|0,L[c>>2],1);a=L[e+32>>2];if((a|0)==1){L[c>>2]=L[e+24>>2]}d=(a|0)==1}fa=e- -64|0;return d|0}function pg(a){a=a|0;var b=0;L[a>>2]=20352;if(M[a+272|0]){b=L[a+204>>2];ha[L[L[b>>2]>>2]](b)|0;b=L[a+204>>2];if(b){L[8514]=L[8514]+1;ha[L[6799]](b)}}b=L[a+196>>2];if(b){ha[L[L[b>>2]>>2]](b)|0;b=L[a+196>>2];if(b){L[8514]=L[8514]+1;ha[L[6799]](b)}}if(M[a+273|0]){b=L[a+200>>2];ha[L[L[b>>2]>>2]](b)|0;b=L[a+200>>2];if(b){L[8514]=L[8514]+1;ha[L[6799]](b)}}b=L[a+316>>2];if(!(b?!b|!M[a+320|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+316>>2]=0;J[a+320|0]=1;L[a+308>>2]=0;L[a+312>>2]=0;b=L[a+288>>2];if(!(b?!b|!M[a+292|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+288>>2]=0;J[a+292|0]=1;L[a+280>>2]=0;L[a+284>>2]=0;b=L[a+240>>2];if(!(b?!b|!M[a+244|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+240>>2]=0;J[a+244|0]=1;L[a+232>>2]=0;L[a+236>>2]=0;b=L[a+220>>2];if(!(b?!b|!M[a+224|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+220>>2]=0;J[a+224|0]=1;L[a+212>>2]=0;L[a+216>>2]=0;b=L[a+188>>2];if(!(b?!b|!M[a+192|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+188>>2]=0;J[a+192|0]=1;L[a+180>>2]=0;L[a+184>>2]=0;return nh(a)|0}function np(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;var g=0,h=S(0),i=0,j=0,k=S(0),l=0,m=S(0),n=S(0),o=0,p=S(0),q=S(0),r=S(0),s=S(0);g=fa-32|0;fa=g;L[g+28>>2]=a;L[g+24>>2]=b;L[g+20>>2]=c;L[g+16>>2]=d;L[g+12>>2]=e;L[g+8>>2]=f;o=L[g+24>>2];c=L[g+20>>2];f=L[g+16>>2];l=L[g+8>>2];a=0;d=L[g+12>>2];b=d+2|0;L[8513]=L[8513]+1;e=ha[L[6798]](b>>>0>268435455?-1:b<<4,16)|0;j=sa(b>>>0>1073741823?-1:b<<2);if((d|0)>=-1){p=S(d+1|0);while(1){q=P[f>>2];m=P[c>>2];r=P[f+4>>2];n=P[c+4>>2];k=P[f+8>>2];h=P[c+8>>2];i=e+(a<<4)|0;L[i+12>>2]=0;s=h;k=S(k-h);h=S(S(a|0)/p);P[i+8>>2]=s+S(k*h);P[i+4>>2]=n+S(S(r-n)*h);P[i>>2]=m+S(S(q-m)*h);L[(a<<2)+j>>2]=1065353216;a=a+1|0;if((b|0)!=(a|0)){continue}break}}L[8513]=L[8513]+1;c=Ac(ha[L[6798]](1252,16)|0,o,b,e,j);if(l&1){P[L[c+720>>2]+88>>2]=0;J[c+924|0]=1}if(l&2){P[(L[c+720>>2]+R(d+1|0,104)|0)+88>>2]=0;J[c+924|0]=1}if(e){L[8514]=L[8514]+1;ha[L[6799]](e)}ra(j);if((d|0)>=0){a=1;while(1){Ha(c,a-1|0,a,0,0);a=a+1|0;if((b|0)!=(a|0)){continue}break}}fa=g+32|0;return c|0}function Cc(a,b,c,d,e,f,g){var h=S(0),i=S(0),j=0,k=0,l=S(0),m=S(0),n=S(0),o=0;L[d>>2]=2139095039;L[e>>2]=-8388609;o=L[a+8>>2];if((o|0)<=0){h=S(-34028234663852886e22)}else{while(1){k=L[a+16>>2]+(j<<4)|0;h=P[k+8>>2];i=P[k>>2];l=P[k+4>>2];m=S(S(S(h*P[b+40>>2])+S(S(i*P[b+32>>2])+S(l*P[b+36>>2])))+P[b+56>>2]);n=S(S(S(h*P[b+8>>2])+S(S(i*P[b>>2])+S(l*P[b+4>>2])))+P[b+48>>2]);i=S(S(S(h*P[b+24>>2])+S(S(i*P[b+16>>2])+S(l*P[b+20>>2])))+P[b+52>>2]);h=S(S(m*P[c+8>>2])+S(S(n*P[c>>2])+S(i*P[c+4>>2])));if(h>2]){P[d>>2]=h;L[f+12>>2]=0;P[f+8>>2]=m;P[f+4>>2]=i;P[f>>2]=n}if(h>P[e>>2]){P[e>>2]=h;L[g+12>>2]=0;P[g+8>>2]=m;P[g+4>>2]=i;P[g>>2]=n}j=j+1|0;if((o|0)!=(j|0)){continue}break}h=P[e>>2]}i=P[d>>2];if(h>2]=h;P[e>>2]=i;b=L[f+12>>2];a=fa-16|0;L[a+8>>2]=L[f+8>>2];L[a+12>>2]=b;b=L[f+4>>2];L[a>>2]=L[f>>2];L[a+4>>2]=b;b=L[g+12>>2];L[f+8>>2]=L[g+8>>2];L[f+12>>2]=b;b=L[g+4>>2];L[f>>2]=L[g>>2];L[f+4>>2]=b;b=L[a+12>>2];L[g+8>>2]=L[a+8>>2];L[g+12>>2]=b;b=L[a+4>>2];L[g>>2]=L[a>>2];L[g+4>>2]=b}}function KB(a,b,c){a=a|0;b=b|0;c=c|0;cc(a,b,c);P[b+52>>2]=P[a+300>>2];P[b+56>>2]=P[a+304>>2];P[b+60>>2]=P[a+308>>2];P[b- -64>>2]=P[a+312>>2];P[b+68>>2]=P[a+316>>2];P[b+72>>2]=P[a+320>>2];P[b+76>>2]=P[a+324>>2];P[b+80>>2]=P[a+328>>2];P[b+84>>2]=P[a+332>>2];P[b+88>>2]=P[a+336>>2];P[b+92>>2]=P[a+340>>2];P[b+96>>2]=P[a+344>>2];P[b+100>>2]=P[a+348>>2];P[b+104>>2]=P[a+352>>2];P[b+108>>2]=P[a+356>>2];P[b+112>>2]=P[a+360>>2];P[b+116>>2]=P[a+364>>2];P[b+120>>2]=P[a+368>>2];P[b+124>>2]=P[a+372>>2];P[b+128>>2]=P[a+376>>2];P[b+132>>2]=P[a+380>>2];P[b+136>>2]=P[a+384>>2];P[b+140>>2]=P[a+388>>2];P[b+144>>2]=P[a+392>>2];P[b+148>>2]=P[a+396>>2];P[b+152>>2]=P[a+400>>2];P[b+156>>2]=P[a+404>>2];P[b+160>>2]=P[a+408>>2];P[b+164>>2]=P[a+412>>2];P[b+168>>2]=P[a+416>>2];P[b+172>>2]=P[a+420>>2];P[b+176>>2]=P[a+424>>2];P[b+180>>2]=P[a+444>>2];P[b+184>>2]=P[a+448>>2];P[b+188>>2]=P[a+452>>2];P[b+192>>2]=P[a+428>>2];P[b+196>>2]=P[a+432>>2];P[b+200>>2]=P[a+436>>2];P[b+204>>2]=P[a+440>>2];return 3321}function Yj(a,b,c,d){var e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;h=fa-16|0;fa=h;while(1){m=c;g=L[a+12>>2]+((c+d|0)/2<<4)|0;n=L[g+8>>2];k=L[g+4>>2];l=L[g>>2];g=d;while(1){i=L[a+12>>2];while(1){a:{f=(c<<4)+i|0;e=L[f+4>>2];b:{if((e|0)<(k|0)){break b}if((e|0)!=(k|0)){break a}e=L[f>>2];if((e|0)<(l|0)){break b}if((e|0)!=(l|0)|L[f+8>>2]>=(n|0)){break a}}c=c+1|0;continue}break}while(1){c:{o=g<<4;e=o+i|0;j=L[e+4>>2];d:{if((j|0)>(k|0)){break d}if((k|0)!=(j|0)){break c}j=L[e>>2];if((j|0)>(l|0)){break d}if((l|0)!=(j|0)|L[e+8>>2]<=(n|0)){break c}}g=g-1|0;continue}break}if((c|0)<=(g|0)){i=L[f+12>>2];L[h+8>>2]=L[f+8>>2];L[h+12>>2]=i;i=L[f+4>>2];L[h>>2]=L[f>>2];L[h+4>>2]=i;i=L[e+4>>2];L[f>>2]=L[e>>2];L[f+4>>2]=i;i=L[e+12>>2];L[f+8>>2]=L[e+8>>2];L[f+12>>2]=i;e=L[h+4>>2];f=L[a+12>>2]+o|0;L[f>>2]=L[h>>2];L[f+4>>2]=e;e=L[h+12>>2];L[f+8>>2]=L[h+8>>2];L[f+12>>2]=e;g=g-1|0;c=c+1|0}if((c|0)<=(g|0)){continue}break}if((g|0)>(m|0)){Yj(a,b,m,g)}if((c|0)<(d|0)){continue}break}fa=h+16|0}function Fd(a,b){var c=0,d=0,e=S(0),f=S(0),g=S(0),h=S(0),i=S(0),j=S(0),k=S(0),l=S(0),m=S(0),n=S(0),o=S(0),p=S(0),q=S(0);if(L[a>>2]==(b|0)){L[a>>2]=0;return 0}d=L[b+32>>2];c=L[(((L[d+40>>2]!=(b|0))<<2)+d|0)+36>>2];b=L[d+32>>2];a:{b:{if(b){L[((((d|0)==L[b+40>>2])<<2)+b|0)+36>>2]=c;L[c+32>>2]=b;c=L[a+4>>2];if(c){L[8514]=L[8514]+1;ha[L[6799]](c)}L[a+4>>2]=d;while(1){q=P[b>>2];d=L[b+36>>2];e=P[d>>2];c=L[b+40>>2];k=P[c>>2];e=e>2]=e;k=P[b+16>>2];f=P[d+16>>2];l=P[c+16>>2];f=f>l?f:l;P[b+16>>2]=f;l=P[b+4>>2];g=P[d+4>>2];m=P[c+4>>2];g=g>2]=g;m=P[b+20>>2];h=P[d+20>>2];n=P[c+20>>2];h=h>n?h:n;P[b+20>>2]=h;n=P[b+8>>2];i=P[d+8>>2];o=P[c+8>>2];i=i>2]=i;o=P[b+24>>2];j=P[d+24>>2];p=P[c+24>>2];j=j>p?j:p;P[b+24>>2]=j;c:{if(e!=q|l!=g|(n!=i|k!=f)){break c}if(m!=h){break c}if(o==j){break a}}b=L[b+32>>2];if(b){continue}break}break b}L[a>>2]=c;L[c+32>>2]=0;b=L[a+4>>2];if(b){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+4>>2]=d}b=L[a>>2]}return b}function cy(a,b,c,d){a=a|0;b=S(b);c=S(c);d=S(d);var e=0,f=0;e=fa-16|0;fa=e;L[e+12>>2]=a;P[e+8>>2]=b;P[e+4>>2]=c;P[e>>2]=d;b=P[e+8>>2];c=P[e+4>>2];d=P[e>>2];a=fa-96|0;fa=a;L[a+92>>2]=L[e+12>>2];P[a+88>>2]=b;P[a+84>>2]=c;P[a+80>>2]=d;f=L[a+92>>2];P[a+76>>2]=Ra(P[a+88>>2]);P[a+72>>2]=Ra(P[a+84>>2]);P[a+68>>2]=Ra(P[a+80>>2]);P[a+64>>2]=Qa(P[a+88>>2]);P[a+60>>2]=Qa(P[a+84>>2]);P[a+56>>2]=Qa(P[a+80>>2]);P[a+52>>2]=P[a+76>>2]*P[a+68>>2];P[a+48>>2]=P[a+76>>2]*P[a+56>>2];P[a+44>>2]=P[a+64>>2]*P[a+68>>2];P[a+40>>2]=P[a+64>>2]*P[a+56>>2];P[a+36>>2]=P[a+72>>2]*P[a+68>>2];P[a+32>>2]=S(P[a+60>>2]*P[a+44>>2])-P[a+48>>2];P[a+28>>2]=S(P[a+60>>2]*P[a+52>>2])+P[a+40>>2];P[a+24>>2]=P[a+72>>2]*P[a+56>>2];P[a+20>>2]=S(P[a+60>>2]*P[a+40>>2])+P[a+52>>2];P[a+16>>2]=S(P[a+60>>2]*P[a+48>>2])-P[a+44>>2];P[a+12>>2]=-P[a+60>>2];P[a+8>>2]=P[a+72>>2]*P[a+64>>2];P[a+4>>2]=P[a+72>>2]*P[a+76>>2];md(f,a+36|0,a+32|0,a+28|0,a+24|0,a+20|0,a+16|0,a+12|0,a+8|0,a+4|0);fa=a+96|0;fa=e+16|0}function tm(a,b,c){var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;d=L[a+96>>2];a:{if((d|0)!=L[a+100>>2]){break a}j=d?d<<1:1;if((j|0)<=(d|0)){break a}if(j){L[8513]=L[8513]+1;f=ha[L[6798]](j<<4,16)|0;d=L[a+96>>2]}b:{if((d|0)<=0){break b}if((d|0)!=1){m=d&-2;while(1){h=g<<4;i=h+f|0;e=h+L[a+104>>2]|0;k=L[e+4>>2];L[i>>2]=L[e>>2];L[i+4>>2]=k;k=L[e+12>>2];L[i+8>>2]=L[e+8>>2];L[i+12>>2]=k;e=h|16;h=e+f|0;e=e+L[a+104>>2]|0;i=L[e+4>>2];L[h>>2]=L[e>>2];L[h+4>>2]=i;i=L[e+12>>2];L[h+8>>2]=L[e+8>>2];L[h+12>>2]=i;g=g+2|0;l=l+2|0;if((l|0)!=(m|0)){continue}break}}if(!(d&1)){break b}d=g<<4;g=d+f|0;d=d+L[a+104>>2]|0;e=L[d+4>>2];L[g>>2]=L[d>>2];L[g+4>>2]=e;e=L[d+12>>2];L[g+8>>2]=L[d+8>>2];L[g+12>>2]=e}d=L[a+104>>2];if(!(d?!d|!M[a+108|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](d)}L[a+104>>2]=f;J[a+108|0]=1;L[a+100>>2]=j;d=L[a+96>>2]}f=L[b+4>>2];d=L[a+104>>2]+(d<<4)|0;L[d>>2]=L[b>>2];L[d+4>>2]=f;f=L[b+12>>2];L[d+8>>2]=L[b+8>>2];L[d+12>>2]=f;L[a+96>>2]=L[a+96>>2]+1;if(c){Sb(a)}}function Xk(a,b,c,d){var e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;while(1){n=c;m=L[L[a+12>>2]+((c+d|0)/2<<2)>>2];f=d;while(1){k=L[a+12>>2];j=L[L[m+740>>2]+208>>2];g=(j|0)<0;a:{if(!g){while(1){h=c;l=(c<<2)+k|0;i=L[l>>2];e=L[L[i+740>>2]+208>>2];if((e|0)<0){e=L[L[i+744>>2]+208>>2]}c=h+1|0;if((e|0)<(j|0)){continue}break a}}o=L[L[m+744>>2]+208>>2];while(1){h=c;l=(c<<2)+k|0;i=L[l>>2];e=L[L[i+740>>2]+208>>2];if((e|0)<0){e=L[L[i+744>>2]+208>>2]}c=h+1|0;if((e|0)<(o|0)){continue}break}}b:{if(!g){while(1){c=f;g=L[(c<<2)+k>>2];e=L[L[g+740>>2]+208>>2];if((e|0)<0){e=L[L[g+744>>2]+208>>2]}f=c-1|0;if((e|0)>(j|0)){continue}break b}}j=L[L[m+744>>2]+208>>2];while(1){c=f;g=L[(c<<2)+k>>2];e=L[L[g+740>>2]+208>>2];if((e|0)<0){e=L[L[g+744>>2]+208>>2]}f=c-1|0;if((e|0)>(j|0)){continue}break}}c:{if((c|0)<(h|0)){f=c;c=h;break c}L[l>>2]=g;L[L[a+12>>2]+(c<<2)>>2]=i;f=c-1|0;c=h+1|0}if((c|0)<=(f|0)){continue}break}if((f|0)>(n|0)){Xk(a,b,n,f)}if((c|0)<(d|0)){continue}break}}function Kf(a,b){var c=0,d=0,e=0,f=0,g=0,h=0;f=fa-16|0;fa=f;L[f+12>>2]=a;L[f+8>>2]=b;a=L[f+8>>2];b=fa-32|0;fa=b;L[b+28>>2]=L[f+12>>2];L[b+24>>2]=a;h=L[b+28>>2];a=fa-16|0;L[a+12>>2]=L[b+24>>2];L[b+20>>2]=L[L[a+12>>2]+4>>2];e=L[b+20>>2];c=b+4|0;L[(fa-16|0)+12>>2]=c;a=fa-32|0;fa=a;L[a+28>>2]=h;L[a+24>>2]=e;L[a+20>>2]=c;c=fa-16|0;e=L[a+28>>2];L[c+12>>2]=e;L[a+16>>2]=L[L[c+12>>2]+4>>2];a:{if(L[a+24>>2]>2]){L[a+12>>2]=L[a+24>>2];while(1){if(L[a+12>>2]>2]){L[a+12>>2]=L[a+12>>2]+1;continue}break}break a}c=L[a+24>>2];d=fa-16|0;L[d+12>>2]=e;if(L[L[d+12>>2]+4>>2]<(c|0)){Xh(e,L[a+24>>2])}L[a+8>>2]=L[a+16>>2];while(1){if(L[a+8>>2]>2]){d=L[e+12>>2]+(L[a+8>>2]<<4)|0;c=fa-16|0;L[c+12>>2]=16;L[c+8>>2]=d;d=L[a+20>>2];g=L[d+4>>2];c=L[c+8>>2];L[c>>2]=L[d>>2];L[c+4>>2]=g;g=L[d+12>>2];L[c+8>>2]=L[d+8>>2];L[c+12>>2]=g;L[a+8>>2]=L[a+8>>2]+1;continue}break}}L[e+4>>2]=L[a+24>>2];fa=a+32|0;Uh(L[b+24>>2],L[b+20>>2],L[h+12>>2]);fa=b+32|0;fa=f+16|0}function tp(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;f=fa-16|0;fa=f;L[f+12>>2]=a;L[f+8>>2]=b;K[f+6>>1]=c;K[f+4>>1]=d;j=L[f+8>>2];m=N[f+6>>1]<<16>>16;n=N[f+4>>1]<<16>>16;d=0;c=0;a=L[f+12>>2];b=L[a+328>>2];a:{if((b|0)!=L[a+332>>2]){break a}h=b?b<<1:1;if((h|0)<=(b|0)){break a}if(h){L[8513]=L[8513]+1;c=ha[L[6798]](h<<2,16)|0;b=L[a+328>>2]}b:{if((b|0)<=0){break b}if(b>>>0>=4){i=b&-4;while(1){e=d<<2;L[e+c>>2]=L[e+L[a+336>>2]>>2];g=e|4;L[g+c>>2]=L[g+L[a+336>>2]>>2];g=e|8;L[g+c>>2]=L[g+L[a+336>>2]>>2];e=e|12;L[e+c>>2]=L[e+L[a+336>>2]>>2];d=d+4|0;k=k+4|0;if((i|0)!=(k|0)){continue}break}}e=b&3;if(!e){break b}while(1){i=d<<2;L[i+c>>2]=L[i+L[a+336>>2]>>2];d=d+1|0;l=l+1|0;if((e|0)!=(l|0)){continue}break}}d=L[a+336>>2];if(!(!d|!M[a+340|0])){if(d){L[8514]=L[8514]+1;ha[L[6799]](d)}b=L[a+328>>2]}L[a+336>>2]=c;J[a+340|0]=1;L[a+332>>2]=h}L[L[a+336>>2]+(b<<2)>>2]=j;L[a+328>>2]=b+1;L[j+284>>2]=L[a+452>>2];lh(a,j,m,n);fa=f+16|0}function ob(a){var b=S(0),c=0,d=0,e=S(0);d=(E(a),x(2));c=d&2147483647;if(c>>>0>=1065353216){if((c|0)==1065353216){return(d|0)>=0?S(0):S(3.141592502593994)}return S(S(0)/S(a-a))}a:{if(c>>>0<=1056964607){b=S(1.570796251296997);if(c>>>0<847249409){break a}b=S(a*a);return S(S(S(S(7.549789415861596e-8)-S(a*S(S(S(S(b*S(S(b*S(-.008656363002955914))+S(-.04274342209100723)))+S(.16666586697101593))*b)/S(S(b*S(-.7066296339035034))+S(1)))))-a)+S(1.570796251296997))}if((d|0)<0){a=S(S(a+S(1))*S(.5));b=S(_(a));a=S(S(1.570796251296997)-S(b+S(S(b*S(S(S(S(a*S(S(a*S(-.008656363002955914))+S(-.04274342209100723)))+S(.16666586697101593))*a)/S(S(a*S(-.7066296339035034))+S(1))))+S(-7.549789415861596e-8))));return S(a+a)}a=S(S(S(1)-a)*S(.5));e=S(_(a));b=(z(2,(E(e),x(2))&-4096),F());a=S(S(S(e*S(S(S(S(a*S(S(a*S(-.008656363002955914))+S(-.04274342209100723)))+S(.16666586697101593))*a)/S(S(a*S(-.7066296339035034))+S(1))))+S(S(a-S(b*b))/S(e+b)))+b);b=S(a+a)}return b}function ME(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0;db(a,b,c);P[b+28>>2]=P[a+28>>2];P[b+32>>2]=P[a+32>>2];P[b+36>>2]=P[a+36>>2];P[b+40>>2]=P[a+40>>2];P[b+12>>2]=P[a+12>>2];P[b+16>>2]=P[a+16>>2];P[b+20>>2]=P[a+20>>2];P[b+24>>2]=P[a+24>>2];P[b+44>>2]=P[a+44>>2];d=L[a+96>>2];L[b+60>>2]=d;if(d){e=ha[L[L[c>>2]+28>>2]](c,L[a+104>>2])|0;L[b+56>>2]=0;L[b+52>>2]=e;g=ha[L[L[c>>2]+16>>2]](c,16,d)|0;a:{if((d|0)<=0){a=L[a+104>>2];break a}a=L[a+104>>2];b=L[g+8>>2];if((d|0)!=1){j=d&-2;while(1){h=f<<4;e=h+a|0;P[b>>2]=P[e>>2];P[b+4>>2]=P[e+4>>2];P[b+8>>2]=P[e+8>>2];P[b+12>>2]=P[e+12>>2];e=(h|16)+a|0;P[b+16>>2]=P[e>>2];P[b+20>>2]=P[e+4>>2];P[b+24>>2]=P[e+8>>2];P[b+28>>2]=P[e+12>>2];b=b+32|0;f=f+2|0;i=i+2|0;if((j|0)!=(i|0)){continue}break}}if(!(d&1)){break a}d=(f<<4)+a|0;P[b>>2]=P[d>>2];P[b+4>>2]=P[d+4>>2];P[b+8>>2]=P[d+8>>2];P[b+12>>2]=P[d+12>>2]}ha[L[L[c>>2]+20>>2]](c,g,3686,1497453121,a);return 3862}L[b+52>>2]=0;L[b+56>>2]=0;return 3862}function UA(a,b,c){a=a|0;b=b|0;c=c|0;cc(a,b,c);P[b+52>>2]=P[a+52>>2];P[b+56>>2]=P[a+56>>2];P[b+60>>2]=P[a+60>>2];P[b- -64>>2]=P[a- -64>>2];P[b+68>>2]=P[a+68>>2];P[b+72>>2]=P[a+72>>2];P[b+76>>2]=P[a+76>>2];P[b+80>>2]=P[a+80>>2];P[b+84>>2]=P[a+84>>2];P[b+88>>2]=P[a+88>>2];P[b+92>>2]=P[a+92>>2];P[b+96>>2]=P[a+96>>2];P[b+100>>2]=P[a+100>>2];P[b+104>>2]=P[a+104>>2];P[b+108>>2]=P[a+108>>2];P[b+112>>2]=P[a+112>>2];P[b+116>>2]=P[a+116>>2];P[b+120>>2]=P[a+120>>2];P[b+124>>2]=P[a+124>>2];P[b+128>>2]=P[a+128>>2];P[b+132>>2]=P[a+132>>2];P[b+136>>2]=P[a+136>>2];P[b+140>>2]=P[a+140>>2];P[b+144>>2]=P[a+144>>2];P[b+148>>2]=P[a+148>>2];P[b+152>>2]=P[a+152>>2];P[b+156>>2]=P[a+156>>2];P[b+160>>2]=P[a+160>>2];P[b+164>>2]=P[a+164>>2];P[b+168>>2]=P[a+168>>2];P[b+172>>2]=P[a+172>>2];P[b+176>>2]=P[a+176>>2];P[b+180>>2]=P[a+188>>2];P[b+184>>2]=P[a+184>>2];P[b+188>>2]=P[a+196>>2];P[b+192>>2]=P[a+192>>2];L[b+196>>2]=M[a+180|0];L[b+200>>2]=M[a+49|0];return 3347}function Pk(a,b,c,d){var e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;while(1){n=c;m=L[L[a+12>>2]+((c+d|0)/2<<2)>>2];f=d;while(1){k=L[a+12>>2];j=L[L[m+28>>2]+208>>2];g=(j|0)<0;a:{if(!g){while(1){h=c;l=(c<<2)+k|0;i=L[l>>2];e=L[L[i+28>>2]+208>>2];if((e|0)<0){e=L[L[i+32>>2]+208>>2]}c=h+1|0;if((e|0)<(j|0)){continue}break a}}o=L[L[m+32>>2]+208>>2];while(1){h=c;l=(c<<2)+k|0;i=L[l>>2];e=L[L[i+28>>2]+208>>2];if((e|0)<0){e=L[L[i+32>>2]+208>>2]}c=h+1|0;if((e|0)<(o|0)){continue}break}}b:{if(!g){while(1){c=f;g=L[(c<<2)+k>>2];e=L[L[g+28>>2]+208>>2];if((e|0)<0){e=L[L[g+32>>2]+208>>2]}f=c-1|0;if((e|0)>(j|0)){continue}break b}}j=L[L[m+32>>2]+208>>2];while(1){c=f;g=L[(c<<2)+k>>2];e=L[L[g+28>>2]+208>>2];if((e|0)<0){e=L[L[g+32>>2]+208>>2]}f=c-1|0;if((e|0)>(j|0)){continue}break}}c:{if((c|0)<(h|0)){f=c;c=h;break c}L[l>>2]=g;L[L[a+12>>2]+(c<<2)>>2]=i;f=c-1|0;c=h+1|0}if((c|0)<=(f|0)){continue}break}if((f|0)>(n|0)){Pk(a,b,n,f)}if((c|0)<(d|0)){continue}break}}function FA(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0;if(!(M[b+204|0]&3|J[b+504|0]&1)){te(b,a+248|0)}if(L[b+192>>2]){a:{if(!(J[b+204|0]&1)){c=L[a+232>>2];b:{if((c|0)!=L[a+236>>2]){break b}h=c?c<<1:1;if((h|0)<=(c|0)){break b}if(h){L[8513]=L[8513]+1;f=ha[L[6798]](h<<2,16)|0;c=L[a+232>>2]}c:{if((c|0)<=0){break c}if(c>>>0>=4){i=c&-4;while(1){d=e<<2;L[d+f>>2]=L[d+L[a+240>>2]>>2];g=d|4;L[g+f>>2]=L[g+L[a+240>>2]>>2];g=d|8;L[g+f>>2]=L[g+L[a+240>>2]>>2];d=d|12;L[d+f>>2]=L[d+L[a+240>>2]>>2];e=e+4|0;j=j+4|0;if((i|0)!=(j|0)){continue}break}}d=c&3;if(!d){break c}while(1){i=e<<2;L[i+f>>2]=L[i+L[a+240>>2]>>2];e=e+1|0;k=k+1|0;if((d|0)!=(k|0)){continue}break}}e=L[a+240>>2];if(!(!e|!M[a+244|0])){if(e){L[8514]=L[8514]+1;ha[L[6799]](e)}c=L[a+232>>2]}L[a+240>>2]=f;J[a+244|0]=1;L[a+236>>2]=h}L[L[a+240>>2]+(c<<2)>>2]=b;L[a+232>>2]=c+1;break a}if((L[b+216>>2]&-2)!=4){L[b+216>>2]=2}}c=b;b=L[b+204>>2]&3;ha[L[L[a>>2]+36>>2]](a,c,b?2:1,b?-3:-1)}}function bm(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=S(0),f=S(0),g=S(0),h=S(0),i=S(0),j=S(0),k=S(0),l=S(0),m=S(0),n=S(0),o=S(0),p=S(0),q=S(0),r=S(0),s=S(0),t=S(0),u=S(0),v=S(0),w=S(0),x=S(0),y=S(0),z=S(0);e=S(ha[L[L[a>>2]+48>>2]](a));y=P[b+52>>2];i=P[b+24>>2];j=P[b+20>>2];k=P[b+56>>2];g=P[b+40>>2];h=P[a- -64>>2];f=P[a+80>>2];l=P[b+36>>2];p=P[a+60>>2];q=P[a+76>>2];z=P[b+48>>2];r=P[b+8>>2];s=P[b>>2];t=P[b+4>>2];u=P[b+16>>2];v=P[b+32>>2];w=P[a+56>>2];x=P[a+72>>2];L[c+12>>2]=0;m=k;k=S(S(f+h)*S(.5));n=S(S(x+w)*S(.5));o=S(S(q+p)*S(.5));m=S(m+S(S(g*k)+S(S(v*n)+S(l*o))));h=S(e+S(S(f-h)*S(.5)));f=S(h*S(T(g)));g=S(e+S(S(x-w)*S(.5)));e=S(e+S(S(q-p)*S(.5)));f=S(f+S(S(g*S(T(v)))+S(e*S(T(l)))));P[c+8>>2]=m-f;l=S(y+S(S(k*i)+S(S(n*u)+S(o*j))));i=S(S(h*S(T(i)))+S(S(g*S(T(u)))+S(e*S(T(j)))));P[c+4>>2]=l-i;j=S(z+S(S(k*r)+S(S(n*s)+S(o*t))));e=S(S(h*S(T(r)))+S(S(g*S(T(s)))+S(e*S(T(t)))));P[c>>2]=j-e;L[d+12>>2]=0;P[d+8>>2]=f+m;P[d+4>>2]=i+l;P[d>>2]=e+j}function lG(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0;i=L[b>>2];c=L[a+268>>2];a:{b:{if((c|0)<=0){break b}e=L[a+276>>2];b=0;while(1){if(L[e+(b<<2)>>2]!=(i|0)){b=b+1|0;if((c|0)!=(b|0)){continue}break b}break}if((b|0)!=(c|0)){break a}}c:{if(L[a+272>>2]!=(c|0)){break c}g=c?c<<1:1;if((g|0)<=(c|0)){break c}d:{if(!g){e=0;break d}L[8513]=L[8513]+1;e=ha[L[6798]](g<<2,16)|0;c=L[a+268>>2]}e:{if((c|0)<=0){break e}b=0;if(c>>>0>=4){h=c&-4;while(1){d=b<<2;L[d+e>>2]=L[d+L[a+276>>2]>>2];f=d|4;L[f+e>>2]=L[f+L[a+276>>2]>>2];f=d|8;L[f+e>>2]=L[f+L[a+276>>2]>>2];d=d|12;L[d+e>>2]=L[d+L[a+276>>2]>>2];b=b+4|0;j=j+4|0;if((h|0)!=(j|0)){continue}break}}d=c&3;if(!d){break e}while(1){h=b<<2;L[h+e>>2]=L[h+L[a+276>>2]>>2];b=b+1|0;k=k+1|0;if((d|0)!=(k|0)){continue}break}}b=L[a+276>>2];if(!(!b|!M[a+280|0])){if(b){L[8514]=L[8514]+1;ha[L[6799]](b)}c=L[a+268>>2]}L[a+276>>2]=e;J[a+280|0]=1;L[a+272>>2]=g}L[L[a+276>>2]+(c<<2)>>2]=i;L[a+268>>2]=c+1}}function FE(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=S(0),f=S(0),g=S(0),h=S(0),i=S(0),j=S(0),k=S(0),l=S(0),m=S(0),n=S(0),o=S(0),p=S(0),q=S(0),r=S(0),s=S(0),t=S(0),u=S(0),v=S(0),w=S(0),x=S(0),y=S(0),z=S(0);e=S(ha[L[L[a>>2]+48>>2]](a));y=P[b+52>>2];i=P[b+24>>2];j=P[b+20>>2];k=P[b+56>>2];g=P[b+40>>2];h=P[a+60>>2];f=P[a+76>>2];l=P[b+36>>2];p=P[a+56>>2];q=P[a+72>>2];z=P[b+48>>2];r=P[b+8>>2];s=P[b>>2];t=P[b+4>>2];u=P[b+16>>2];v=P[b+32>>2];w=P[a+52>>2];x=P[a+68>>2];L[c+12>>2]=0;m=k;k=S(S(f+h)*S(.5));n=S(S(x+w)*S(.5));o=S(S(q+p)*S(.5));m=S(m+S(S(g*k)+S(S(v*n)+S(l*o))));h=S(e+S(S(f-h)*S(.5)));f=S(h*S(T(g)));g=S(e+S(S(x-w)*S(.5)));e=S(e+S(S(q-p)*S(.5)));f=S(f+S(S(g*S(T(v)))+S(e*S(T(l)))));P[c+8>>2]=m-f;l=S(y+S(S(k*i)+S(S(n*u)+S(o*j))));i=S(S(h*S(T(i)))+S(S(g*S(T(u)))+S(e*S(T(j)))));P[c+4>>2]=l-i;j=S(z+S(S(k*r)+S(S(n*s)+S(o*t))));e=S(S(h*S(T(r)))+S(S(g*S(T(s)))+S(e*S(T(t)))));P[c>>2]=j-e;L[d+12>>2]=0;P[d+8>>2]=f+m;P[d+4>>2]=i+l;P[d>>2]=e+j}function yB(a,b){a=a|0;b=b|0;var c=S(0),d=S(0);if(M[a+1309|0]){c=S(S(P[a+1256>>2]-P[a+1316>>2])*P[a+1340>>2]);P[a+792>>2]=c*S(S(P[b>>2]*P[a+1364>>2])/S(L[b+48>>2]));P[a+808>>2]=S(T(c))/P[b>>2]}if(M[a+1310|0]){c=S(S(P[a+1260>>2]-P[a+1320>>2])*P[a+1344>>2]);P[a+796>>2]=c*S(S(P[b>>2]*P[a+1368>>2])/S(L[b+48>>2]));P[a+812>>2]=S(T(c))/P[b>>2]}if(M[a+1311|0]){c=S(S(P[a+1264>>2]-P[a+1324>>2])*P[a+1348>>2]);P[a+800>>2]=c*S(S(P[b>>2]*P[a+1372>>2])/S(L[b+48>>2]));P[a+816>>2]=S(T(c))/P[b>>2]}if(M[a+1312|0]){c=S(P[a+1352>>2]*S(-S(P[a+1192>>2]-P[a+1328>>2])));d=P[b>>2];P[a+876>>2]=c*S(S(d*P[a+1376>>2])/S(L[b+48>>2]));P[a+880>>2]=S(T(c))/d}if(M[a+1313|0]){c=S(P[a+1356>>2]*S(-S(P[a+1196>>2]-P[a+1332>>2])));d=P[b>>2];P[a+940>>2]=c*S(S(d*P[a+1380>>2])/S(L[b+48>>2]));P[a+944>>2]=S(T(c))/d}if(M[a+1314|0]){c=S(P[a+1360>>2]*S(-S(P[a+1200>>2]-P[a+1336>>2])));d=P[b>>2];P[a+1004>>2]=c*S(S(d*P[a+1384>>2])/S(L[b+48>>2]));P[a+1008>>2]=S(T(c))/d}kl(a,b)}function En(a,b,c,d,e,f,g,h,i){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;i=i|0;h=fa-48|0;fa=h;L[8513]=L[8513]+1;d=ha[L[6798]](64,16)|0;K[d+6>>1]=g;K[d+4>>1]=f;L[d>>2]=e;e=L[b+4>>2];L[d+16>>2]=L[b>>2];L[d+20>>2]=e;e=L[b+12>>2];L[d+24>>2]=L[b+8>>2];L[d+28>>2]=e;e=L[c+4>>2];L[d+32>>2]=L[c>>2];L[d+36>>2]=e;e=L[c+12>>2];L[d+40>>2]=L[c+8>>2];L[d+44>>2]=e;L[d+8>>2]=0;L[d+52>>2]=0;L[d+56>>2]=0;e=L[b+12>>2];L[h+24>>2]=L[b+8>>2];L[h+28>>2]=e;e=L[b+4>>2];L[h+16>>2]=L[b>>2];L[h+20>>2]=e;b=L[c+12>>2];L[h+40>>2]=L[c+8>>2];L[h+44>>2]=b;b=L[c+4>>2];L[h+32>>2]=L[c>>2];L[h+36>>2]=b;L[d+60>>2]=L[a+144>>2];b=L[a+188>>2]+1|0;L[a+188>>2]=b;L[d+12>>2]=b;c=a+4|0;L[d+48>>2]=Bb(c,h+16|0,d);b=L[a+144>>2];L[d+52>>2]=0;b=(b<<2)+a|0;L[d+56>>2]=L[b+124>>2];e=L[b+124>>2];if(e){L[e+52>>2]=d}L[b+124>>2]=d;if(!M[a+193|0]){L[h+12>>2]=d;L[h+4>>2]=5824;L[h+8>>2]=a;e=c;b=h+16|0;c=h+4|0;Vb(e,L[a+4>>2],b,c);a=a- -64|0;Vb(a,L[a>>2],b,c)}fa=h+48|0;return d|0}function LA(a){a=a|0;var b=0,c=0,d=S(0),e=0,f=0,g=0,h=0;f=fa+-64|0;fa=f;wa(2746);a:{if(M[a+274|0]){c=L[a+8>>2];if((c|0)<=0){break a}while(1){b=L[L[a+16>>2]+(e<<2)>>2];if(!(!(M[b+236|0]&2)|!b|(!L[b+480>>2]|M[b+204|0]&3))){c=b+68|0;g=b+132|0;h=b+148|0;b:{c:{if(!M[a+300|0]){break c}d=P[a+268>>2];if(d==S(0)){break c}d=S(P[a+264>>2]-d);break b}d=S(P[a+264>>2]*P[b+244>>2])}Rb(c,g,h,d,f);b=L[b+480>>2];ha[L[L[b>>2]+12>>2]](b,f);c=L[a+8>>2]}e=e+1|0;if((c|0)>(e|0)){continue}break}break a}c=L[a+232>>2];if((c|0)<=0){break a}while(1){d:{e:{b=L[L[a+240>>2]+(e<<2)>>2];switch(L[b+216>>2]-2|0){case 0:case 3:break d;default:break e}}if(!L[b+480>>2]|M[b+204|0]&3){break d}c=b+68|0;g=b+132|0;h=b+148|0;f:{g:{if(!M[a+300|0]){break g}d=P[a+268>>2];if(d==S(0)){break g}d=S(P[a+264>>2]-d);break f}d=S(P[a+264>>2]*P[b+244>>2])}Rb(c,g,h,d,f);b=L[b+480>>2];ha[L[L[b>>2]+12>>2]](b,f);c=L[a+232>>2]}e=e+1|0;if((c|0)>(e|0)){continue}break}}va();fa=f- -64|0}function EA(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;if(!(M[b+204|0]&3|J[b+504|0]&1)){te(b,a+248|0)}if(L[b+192>>2]){a:{if(!(J[b+204|0]&1)){e=L[a+232>>2];b:{if((e|0)!=L[a+236>>2]){break b}j=e?e<<1:1;if((j|0)<=(e|0)){break b}if(j){L[8513]=L[8513]+1;h=ha[L[6798]](j<<2,16)|0;e=L[a+232>>2]}c:{if((e|0)<=0){break c}if(e>>>0>=4){k=e&-4;while(1){f=g<<2;L[f+h>>2]=L[f+L[a+240>>2]>>2];i=f|4;L[i+h>>2]=L[i+L[a+240>>2]>>2];i=f|8;L[i+h>>2]=L[i+L[a+240>>2]>>2];f=f|12;L[f+h>>2]=L[f+L[a+240>>2]>>2];g=g+4|0;l=l+4|0;if((k|0)!=(l|0)){continue}break}}f=e&3;if(!f){break c}while(1){k=g<<2;L[k+h>>2]=L[k+L[a+240>>2]>>2];g=g+1|0;m=m+1|0;if((f|0)!=(m|0)){continue}break}}g=L[a+240>>2];if(!(!g|!M[a+244|0])){if(g){L[8514]=L[8514]+1;ha[L[6799]](g)}e=L[a+232>>2]}L[a+240>>2]=h;J[a+244|0]=1;L[a+236>>2]=j}L[L[a+240>>2]+(e<<2)>>2]=b;L[a+232>>2]=e+1;break a}if((L[b+216>>2]&-2)!=4){L[b+216>>2]=2}}ha[L[L[a>>2]+36>>2]](a,b,c,d)}}function Fk(a,b){var c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0;c=L[a+488>>2];a:{b:{if((c|0)<=0){break b}f=L[a+496>>2];while(1){if(L[f+(d<<2)>>2]!=(b|0)){d=d+1|0;if((d|0)!=(c|0)){continue}break b}break}if((c|0)!=(d|0)){break a}}c:{if(L[a+492>>2]!=(c|0)){break c}h=c?c<<1:1;if((h|0)<=(c|0)){break c}d:{if(!h){f=0;break d}L[8513]=L[8513]+1;f=ha[L[6798]](h<<2,16)|0;c=L[a+488>>2]}e:{if((c|0)<=0){break e}d=0;if(c>>>0>=4){i=c&-4;while(1){e=d<<2;L[e+f>>2]=L[e+L[a+496>>2]>>2];g=e|4;L[g+f>>2]=L[g+L[a+496>>2]>>2];g=e|8;L[g+f>>2]=L[g+L[a+496>>2]>>2];e=e|12;L[e+f>>2]=L[e+L[a+496>>2]>>2];d=d+4|0;j=j+4|0;if((i|0)!=(j|0)){continue}break}}e=c&3;if(!e){break e}while(1){i=d<<2;L[i+f>>2]=L[i+L[a+496>>2]>>2];d=d+1|0;k=k+1|0;if((e|0)!=(k|0)){continue}break}}d=L[a+496>>2];if(!(!d|!M[a+500|0])){if(d){L[8514]=L[8514]+1;ha[L[6799]](d)}c=L[a+488>>2]}L[a+496>>2]=f;J[a+500|0]=1;L[a+492>>2]=h}L[L[a+496>>2]+(c<<2)>>2]=b;L[a+488>>2]=c+1}L[a+256>>2]=1}function Mh(a,b){var c=0,d=0,e=0,f=0,g=0,h=0;c=fa-176|0;fa=c;L[c+172>>2]=a;L[c+168>>2]=b;b=c+136|0;a=L[c+172>>2];ta(b,a+16|0,a);P[c+132>>2]=.5;e=c+152|0;Ga(e,b,c+132|0);d=c+116|0;La(d,a+16|0,e);tb(c+100|0,L[c+168>>2],e);b=L[c+112>>2];L[c+160>>2]=L[c+108>>2];L[c+164>>2]=b;b=L[c+104>>2];L[c+152>>2]=L[c+100>>2];L[c+156>>2]=b;b=fa-16|0;L[b+12>>2]=L[c+168>>2];L[b+12>>2]=L[b+12>>2];L[b+8>>2]=0;h=c+68|0;df(h,L[b+12>>2]+(L[b+8>>2]<<4)|0);f=fa-16|0;L[f+12>>2]=L[c+168>>2];b=fa-16|0;L[b+12>>2]=L[f+12>>2];L[b+8>>2]=1;f=c+52|0;df(f,L[b+12>>2]+(L[b+8>>2]<<4)|0);g=fa-16|0;L[g+12>>2]=L[c+168>>2];b=fa-16|0;L[b+12>>2]=L[g+12>>2];L[b+8>>2]=2;g=c+36|0;df(g,L[b+12>>2]+(L[b+8>>2]<<4)|0);b=c+84|0;Vd(b,d,h,f,g);La(c+20|0,e,b);d=L[c+24>>2];L[a>>2]=L[c+20>>2];L[a+4>>2]=d;d=L[c+32>>2];L[a+8>>2]=L[c+28>>2];L[a+12>>2]=d;ta(c+4|0,e,b);b=L[c+8>>2];L[a+16>>2]=L[c+4>>2];L[a+20>>2]=b;b=L[c+16>>2];L[a+24>>2]=L[c+12>>2];L[a+28>>2]=b;fa=c+176|0}function yp(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0,g=0,h=0;d=fa-16|0;fa=d;L[d+12>>2]=a;L[d+8>>2]=b;a=L[d+8>>2];e=fa-16|0;fa=e;L[e+12>>2]=L[d+12>>2]+788;L[e+8>>2]=a;a=L[e+8>>2];b=fa-112|0;fa=b;L[b+108>>2]=L[e+12>>2];L[b+104>>2]=a;g=L[b+108>>2];a=fa-16|0;L[a+12>>2]=L[b+104>>2];L[b+100>>2]=L[L[a+12>>2]+4>>2];f=L[b+100>>2];c=b+4|0;pa(c,0,96);mi(c);a=fa-32|0;fa=a;L[a+28>>2]=g;L[a+24>>2]=f;L[a+20>>2]=c;f=fa-16|0;c=L[a+28>>2];L[f+12>>2]=c;L[a+16>>2]=L[L[f+12>>2]+4>>2];a:{if(L[a+24>>2]>2]){L[a+12>>2]=L[a+24>>2];while(1){if(L[a+12>>2]>2]){L[a+12>>2]=L[a+12>>2]+1;continue}break}break a}f=L[a+24>>2];h=fa-16|0;L[h+12>>2]=c;if(L[L[h+12>>2]+4>>2]<(f|0)){ji(c,L[a+24>>2])}L[a+8>>2]=L[a+16>>2];while(1){if(L[a+8>>2]>2]){qf(L[c+12>>2]+R(L[a+8>>2],96)|0,L[a+20>>2]);L[a+8>>2]=L[a+8>>2]+1;continue}break}}L[c+4>>2]=L[a+24>>2];fa=a+32|0;Dh(L[b+104>>2],L[b+100>>2],L[g+12>>2]);fa=b+112|0;fa=e+16|0;fa=d+16|0}function qe(a,b,c){var d=S(0),e=S(0),f=S(0),g=S(0),h=S(0),i=S(0),j=0,k=S(0),l=S(0),m=S(0),n=S(0),o=S(0),p=S(0),q=S(0),r=S(0),s=S(0),t=S(0),u=S(0),v=S(0);j=L[a+4>>2];if(j){rb(j,b,c)}a=L[a>>2];if(a){n=P[a+220>>2];o=P[a+212>>2];p=P[a+216>>2];q=P[a+204>>2];r=P[a+196>>2];s=P[a+200>>2];t=P[a+188>>2];u=P[a+184>>2];v=P[a+180>>2];g=P[c+4>>2];h=P[c+8>>2];k=P[c>>2];d=P[b+8>>2];f=P[b+4>>2];i=P[b>>2];e=P[a+128>>2];l=S(i*e);P[a+244>>2]=l+P[a+244>>2];m=S(e*f);P[a+248>>2]=m+P[a+248>>2];e=S(e*d);P[a+252>>2]=e+P[a+252>>2];P[a+316>>2]=l+P[a+316>>2];P[a+320>>2]=m+P[a+320>>2];P[a+324>>2]=e+P[a+324>>2];e=S(S(k*f)-S(i*g));f=S(S(g*d)-S(f*h));d=S(S(h*i)-S(d*k));g=S(S(t*e)+S(S(v*f)+S(u*d)));P[a+260>>2]=g+P[a+260>>2];h=S(S(q*e)+S(S(r*f)+S(d*s)));P[a+264>>2]=h+P[a+264>>2];d=S(S(n*e)+S(S(o*f)+S(d*p)));P[a+268>>2]=d+P[a+268>>2];P[a+332>>2]=g+P[a+332>>2];P[a+336>>2]=h+P[a+336>>2];P[a+340>>2]=d+P[a+340>>2];L[a+308>>2]=L[a+308>>2]+1}}function jt(a){a=a|0;var b=0,c=S(0),d=0,e=S(0),f=S(0),g=S(0),h=S(0),i=S(0),j=0,k=S(0),l=S(0),m=S(0),n=S(0),o=S(0),p=S(0),q=S(0),r=S(0),s=S(0),t=S(0),u=S(0),v=S(0),w=S(0);j=fa-16|0;fa=j;L[j+12>>2]=a;a=L[j+12>>2];b=L[a+32>>2];c=P[a+652>>2];e=P[a+620>>2];f=P[a+636>>2];l=S(S(P[b+44>>2]*c)+S(S(P[b+36>>2]*e)+S(f*P[b+40>>2])));d=L[a+28>>2];m=P[d+44>>2];g=P[a+584>>2];n=P[d+36>>2];h=P[a+552>>2];i=P[a+568>>2];o=P[d+40>>2];u=S(l*S(S(m*g)+S(S(n*h)+S(i*o))));p=S(S(P[b+12>>2]*c)+S(S(P[b+4>>2]*e)+S(f*P[b+8>>2])));q=P[d+12>>2];r=P[d+4>>2];s=P[d+8>>2];v=S(p*S(S(q*g)+S(S(r*h)+S(i*s))));t=P[d+28>>2];k=S(t*g);g=P[d+20>>2];w=S(g*h);h=P[d+24>>2];k=S(k+S(w+S(i*h)));i=S(S(P[b+28>>2]*c)+S(S(P[b+20>>2]*e)+S(f*P[b+24>>2])));c=P[a+588>>2];e=P[a+556>>2];f=P[a+572>>2];c=Za(S(u+S(v+S(k*i))),S(S(l*S(S(m*c)+S(S(n*e)+S(o*f))))+S(S(p*S(S(q*c)+S(S(r*e)+S(s*f))))+S(S(S(t*c)+S(S(g*e)+S(h*f)))*i))));fa=j+16|0;return S(S(c*P[a+732>>2]))}function dE(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=S(0),f=S(0),g=S(0),h=S(0),i=S(0),j=S(0),k=S(0),l=S(0),m=S(0),n=S(0),o=S(0),p=S(0),q=S(0),r=S(0),s=S(0),t=S(0),u=S(0),v=S(0),w=S(0),x=S(0),y=S(0),z=S(0),A=S(0),B=S(0);k=P[b+56>>2];n=P[b+36>>2];o=P[b+40>>2];l=P[b+52>>2];h=P[b+20>>2];f=P[a+112>>2];i=P[a+20>>2];p=P[a+36>>2];g=P[b+24>>2];e=P[a+116>>2];j=P[a+24>>2];q=P[a+40>>2];r=P[b+32>>2];m=P[b+48>>2];s=P[b>>2];t=P[b+4>>2];u=P[b+8>>2];v=P[b+16>>2];w=P[a+108>>2];x=P[a+16>>2];y=P[a+32>>2];z=S(ha[L[L[a>>2]+48>>2]](a));A=S(ha[L[L[a>>2]+48>>2]](a));B=S(ha[L[L[a>>2]+48>>2]](a));L[c+12>>2]=0;e=S(S(e*S(q-j))*S(.5));j=S(e*S(T(g)));g=S(S(w*S(y-x))*S(.5));f=S(S(f*S(p-i))*S(.5));h=S(A+S(j+S(S(g*S(T(v)))+S(f*S(T(h))))));P[c+4>>2]=l-h;i=S(z+S(S(e*S(T(u)))+S(S(g*S(T(s)))+S(f*S(T(t))))));P[c>>2]=m-i;e=S(B+S(S(e*S(T(o)))+S(S(g*S(T(r)))+S(f*S(T(n))))));P[c+8>>2]=k-e;L[d+12>>2]=0;P[d+8>>2]=k+e;P[d+4>>2]=l+h;P[d>>2]=m+i}function Dd(a,b,c,d,e){var f=0,g=S(0),h=0,i=S(0),j=0;i=P[c>>2];a:{b:{if(!(i>=P[b>>2])){g=P[c+4>>2];break b}g=P[c+4>>2];if(!(g>=P[b+4>>2])|!(P[b+8>>2]<=P[c+8>>2])|(!(P[b+16>>2]>=P[c+16>>2])|!(P[b+20>>2]>=P[c+20>>2]))){break b}f=0;if(P[b+24>>2]>=P[c+24>>2]){break a}}P[c+4>>2]=g-e;P[c>>2]=i-e;P[c+8>>2]=P[c+8>>2]-e;P[c+16>>2]=P[c+16>>2]+e;P[c+20>>2]=P[c+20>>2]+e;P[c+24>>2]=P[c+24>>2]+e;e=P[d>>2];f=((e>S(0))<<4)+c|0;P[f>>2]=e+P[f>>2];e=P[d+4>>2];f=(e>S(0)?20:4)+c|0;P[f>>2]=e+P[f>>2];e=P[d+8>>2];d=(e>S(0)?24:8)+c|0;P[d>>2]=e+P[d>>2];d=Fd(a,b);c:{if(!d){d=0;break c}h=L[a+8>>2];if((h|0)>=0){if(!h){break c}while(1){f=L[d+32>>2];if(!f){break c}d=f;j=j+1|0;if((h|0)!=(j|0)){continue}break}break c}d=L[a>>2]}f=L[c+4>>2];L[b>>2]=L[c>>2];L[b+4>>2]=f;f=L[c+28>>2];L[b+24>>2]=L[c+24>>2];L[b+28>>2]=f;f=L[c+20>>2];L[b+16>>2]=L[c+16>>2];L[b+20>>2]=f;f=L[c+12>>2];L[b+8>>2]=L[c+8>>2];L[b+12>>2]=f;Ed(a,d,b);f=1}return f}function Ag(a,b,c,d,e,f){var g=0,h=0,i=0;a:{if(M[d+55|0]==(b|0)){break a}g=e<<2;h=L[g+18460>>2];b:{if(S(S(S(P[d+8>>2]*P[c+24>>2])+S(S(P[d>>2]*P[c+16>>2])+S(P[d+4>>2]*P[c+20>>2])))-P[d+16>>2])>2],L[a+g>>2],c,0);if(!a){break a}L[a+32>>2]=d;J[a+52|0]=e;J[(d+e|0)+52|0]=0;L[((e<<2)+d|0)+32>>2]=a;b=L[f>>2];c:{if(b){L[b+36>>2]=a;J[b+53|0]=2;L[a+40>>2]=b;J[a+54|0]=1;break c}L[f+4>>2]=a}L[f>>2]=a;a=f+8|0;break b}J[d+55|0]=b;e=L[g+18472>>2];if(!Ag(a,b,c,L[((h<<2)+d|0)+32>>2],M[(d+h|0)+52|0],f)){break a}if(!Ag(a,b,c,L[((e<<2)+d|0)+32>>2],M[(d+e|0)+52|0],f)){break a}b=L[d+48>>2];if(b){L[b+44>>2]=L[d+44>>2]}b=L[d+44>>2];if(b){L[b+48>>2]=L[d+48>>2]}if(L[a+9280>>2]==(d|0)){L[a+9280>>2]=L[d+48>>2]}b=a+9284|0;L[b>>2]=L[b>>2]-1;L[d+44>>2]=0;L[d+48>>2]=L[a+9288>>2];b=L[a+9288>>2];if(b){L[b+44>>2]=d}L[a+9288>>2]=d;a=a+9292|0}i=1;L[a>>2]=L[a>>2]+1}return i}function Na(a,b){var c=0,d=0,e=0,f=0,g=0,h=0;a:{f=(E(b),x(2));c=f<<1;b:{if(!c){break b}h=(E(a),x(2));e=h>>>23&255;if((e|0)==255){break b}if(((E(b),x(2))&2147483647)>>>0<2139095041){break a}}a=S(a*b);return S(a/a)}d=h<<1;if(d>>>0<=c>>>0){return(d|0)==(c|0)?S(a*S(0)):a}g=f>>>23&255;c:{if(!e){e=0;d=h<<9;if((d|0)>=0){while(1){e=e-1|0;d=d<<1;if((d|0)>=0){continue}break}}d=h<<1-e;break c}d=h&8388607|8388608}d:{if(!g){g=0;c=f<<9;if((c|0)>=0){while(1){g=g-1|0;c=c<<1;if((c|0)>=0){continue}break}}c=f<<1-g;break d}c=f&8388607|8388608}f=c;if((e|0)>(g|0)){while(1){e:{c=d-f|0;if((c|0)<0){break e}d=c;if(d){break e}return S(a*S(0))}d=d<<1;e=e-1|0;if((g|0)<(e|0)){continue}break}e=g}f:{c=d-f|0;if((c|0)<0){break f}d=c;if(d){break f}return S(a*S(0))}g:{if(d>>>0>8388607){c=d;break g}while(1){e=e-1|0;f=d>>>0<4194304;c=d<<1;d=c;if(f){continue}break}}return z(2,h&-2147483648|((e|0)>0?c-8388608|e<<23:c>>>1-e|0)),F()}function bc(a,b,c,d){var e=0,f=0,g=0,h=0,i=0,j=0,k=0;L[8513]=L[8513]+1;e=ha[L[6798]](36,16)|0;L[e+28>>2]=-1;L[e+32>>2]=0;L[e+12>>2]=-1;L[e+16>>2]=-1;L[e+8>>2]=d;L[e+4>>2]=c;L[e>>2]=b;L[e+20>>2]=-1;b=L[a+4>>2];L[e+24>>2]=b;a:{if(L[a+8>>2]!=(b|0)){break a}h=b?b<<1:1;if((h|0)<=(b|0)){break a}b:{if(!h){c=0;break b}L[8513]=L[8513]+1;c=ha[L[6798]](h<<2,16)|0;b=L[a+4>>2]}c:{if((b|0)<=0){break c}d=0;if(b>>>0>=4){i=b&-4;while(1){f=d<<2;L[f+c>>2]=L[f+L[a+12>>2]>>2];g=f|4;L[g+c>>2]=L[g+L[a+12>>2]>>2];g=f|8;L[g+c>>2]=L[g+L[a+12>>2]>>2];f=f|12;L[f+c>>2]=L[f+L[a+12>>2]>>2];d=d+4|0;j=j+4|0;if((i|0)!=(j|0)){continue}break}}f=b&3;if(!f){break c}while(1){i=d<<2;L[i+c>>2]=L[i+L[a+12>>2]>>2];d=d+1|0;k=k+1|0;if((f|0)!=(k|0)){continue}break}}d=L[a+12>>2];if(!(!d|!M[a+16|0])){if(d){L[8514]=L[8514]+1;ha[L[6799]](d)}b=L[a+4>>2]}L[a+12>>2]=c;J[a+16|0]=1;L[a+8>>2]=h}L[L[a+12>>2]+(b<<2)>>2]=e;L[a+4>>2]=b+1;return e}function mC(a){a=a|0;var b=0,c=0,d=0,e=S(0),f=S(0),g=S(0),h=0,i=S(0),j=S(0),k=S(0),l=S(0),m=0,n=0;L[a+16>>2]=2139095039;L[a+20>>2]=2139095039;L[a+40>>2]=-8388609;h=a+32|0;L[h>>2]=-8388609;L[h+4>>2]=-8388609;L[a+24>>2]=2139095039;d=L[a+152>>2];if(d){n=a+16|0;m=L[a+160>>2];i=S(34028234663852886e22);j=S(-34028234663852886e22);k=S(-34028234663852886e22);e=S(-34028234663852886e22);l=S(34028234663852886e22);f=S(34028234663852886e22);while(1){d=d-1|0;c=d<<2;b=L[c+m>>2];if(M[b+48|0]){ha[L[L[b>>2]+68>>2]](b);J[b+48|0]=0;j=P[a+40>>2];k=P[a+36>>2];e=P[a+32>>2];i=P[a+24>>2];l=P[a+20>>2];f=P[a+16>>2];m=L[a+160>>2];b=L[c+m>>2]}g=P[b+16>>2];f=f>g?g:f;P[a+16>>2]=f;c=b+16|0;l=P[(P[b+20>>2]>2];P[a+20>>2]=l;i=P[(P[b+24>>2]>2];P[a+24>>2]=i;c=b+32|0;g=P[c>>2];e=e>2]=e;k=P[(P[b+36>>2]>k?c:h)+4>>2];P[a+36>>2]=k;j=P[(P[b+40>>2]>j?c:h)+8>>2];P[a+40>>2]=j;if(d){continue}break}}}function aD(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=S(0),f=0,g=S(0),h=S(0),i=S(0);d=fa-144|0;fa=d;L[d+72>>2]=0;L[d+76>>2]=0;f=d- -64|0;L[f>>2]=0;L[f+4>>2]=0;L[d+108>>2]=0;L[d+112>>2]=0;L[d+116>>2]=0;L[d+120>>2]=0;L[d+52>>2]=0;L[d+56>>2]=0;L[d+84>>2]=0;L[d+88>>2]=0;L[d+80>>2]=1065353216;L[d+92>>2]=0;L[d+96>>2]=0;L[d+100>>2]=1065353216;L[d+104>>2]=0;L[d+44>>2]=0;L[d+48>>2]=0;L[d+60>>2]=1065353216;L[d+124>>2]=-581039253;L[d+40>>2]=17192;e=P[c+8>>2];g=P[c>>2];h=P[c+4>>2];L[d+140>>2]=0;i=S(h*S(0));P[d+136>>2]=e+S(S(g*P[d+68>>2])+i);e=S(e*S(0));P[d+132>>2]=e+S(h+S(g*P[f>>2]));P[d+128>>2]=e+S(g+i);L[d+32>>2]=1566444395;L[d+36>>2]=0;L[d+24>>2]=1566444395;L[d+28>>2]=1566444395;L[d+16>>2]=-581039253;L[d+20>>2]=0;L[d+8>>2]=-581039253;L[d+12>>2]=-581039253;ha[L[L[b>>2]+64>>2]](b,d+40|0,d+8|0,d+24|0);b=L[d+56>>2];L[a+8>>2]=L[d+52>>2];L[a+12>>2]=b;b=L[d+48>>2];L[a>>2]=L[d+44>>2];L[a+4>>2]=b;fa=d+144|0}function Sg(a,b){var c=S(0),d=S(0),e=0,f=S(0),g=S(0),h=S(0),i=S(0),j=S(0),k=S(0);L[a+4>>2]=35;L[a+8>>2]=0;L[a>>2]=14328;L[a+44>>2]=1025758986;L[a+12>>2]=1065353216;L[a+16>>2]=1065353216;L[a>>2]=14044;L[a+20>>2]=1065353216;L[a+24>>2]=0;L[a+52>>2]=1;L[a>>2]=14692;d=P[b>>2];c=P[b+4>>2];e=d>2]>(e?d:c)?!e:2)<<2)+b>>2]*S(.10000000149011612));d=P[a+44>>2];if(c>2]=a;f=P[L[e+12>>2]+44>>2];P[a+44>>2]=c;c=P[a+36>>2];g=P[a+32>>2];h=P[a+28>>2];i=S(ha[L[L[a>>2]+48>>2]](a));j=S(ha[L[L[a>>2]+48>>2]](a));k=S(ha[L[L[a>>2]+48>>2]](a));L[a+40>>2]=0;P[a+32>>2]=S(d+g)-j;P[a+28>>2]=S(d+h)-i;P[a+36>>2]=S(f+c)-k;e=L[a>>2]}else{e=14692}d=S(ha[L[e+48>>2]](a));c=S(ha[L[L[a>>2]+48>>2]](a));f=S(ha[L[L[a>>2]+48>>2]](a));g=P[b>>2];h=P[b+4>>2];i=P[b+8>>2];L[a+40>>2]=0;L[a+4>>2]=13;P[a+36>>2]=S(i*P[a+20>>2])-f;P[a+32>>2]=S(h*P[a+16>>2])-c;P[a+28>>2]=S(g*P[a+12>>2])-d;return a}function Dx(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0,g=0,h=0;d=fa-16|0;fa=d;L[d+12>>2]=a;L[d+8>>2]=b;a=L[d+8>>2];e=fa-16|0;fa=e;L[e+12>>2]=L[d+12>>2]+112;L[e+8>>2]=a;a=L[e+8>>2];b=fa-16|0;fa=b;L[b+12>>2]=L[e+12>>2];L[b+8>>2]=a;g=L[b+12>>2];a=fa-16|0;L[a+12>>2]=L[b+8>>2];L[b+4>>2]=L[L[a+12>>2]+4>>2];c=L[b+4>>2];P[b>>2]=0;a=fa-32|0;fa=a;L[a+28>>2]=g;L[a+24>>2]=c;L[a+20>>2]=b;f=fa-16|0;c=L[a+28>>2];L[f+12>>2]=c;L[a+16>>2]=L[L[f+12>>2]+4>>2];a:{if(L[a+24>>2]>2]){L[a+12>>2]=L[a+24>>2];while(1){if(L[a+12>>2]>2]){L[a+12>>2]=L[a+12>>2]+1;continue}break}break a}f=L[a+24>>2];h=fa-16|0;L[h+12>>2]=c;if(L[L[h+12>>2]+4>>2]<(f|0)){Wh(c,L[a+24>>2])}L[a+8>>2]=L[a+16>>2];while(1){if(L[a+8>>2]>2]){P[L[c+12>>2]+(L[a+8>>2]<<2)>>2]=P[L[a+20>>2]>>2];L[a+8>>2]=L[a+8>>2]+1;continue}break}}L[c+4>>2]=L[a+24>>2];fa=a+32|0;Th(L[b+8>>2],L[b+4>>2],L[g+12>>2]);fa=b+16|0;fa=e+16|0;fa=d+16|0}function ew(a,b,c){a=a|0;b=b|0;c=S(c);var d=0,e=0;e=fa-16|0;fa=e;L[e+12>>2]=a;L[e+8>>2]=b;P[e+4>>2]=c;b=L[e+8>>2];c=P[e+4>>2];a=fa-16|0;fa=a;L[a+12>>2]=L[e+12>>2];L[a+8>>2]=b;P[a+4>>2]=c;b=L[a+12>>2];d=fa-16|0;L[d+12>>2]=L[a+8>>2];c=S(P[L[d+12>>2]>>2]-P[a+4>>2]);d=fa-16|0;L[d+12>>2]=b;P[L[d+12>>2]>>2]=c;d=fa-16|0;L[d+12>>2]=L[a+8>>2];c=S(P[L[d+12>>2]+4>>2]-P[a+4>>2]);d=fa-16|0;L[d+12>>2]=b;P[L[d+12>>2]+4>>2]=c;d=fa-16|0;L[d+12>>2]=L[a+8>>2];c=S(P[L[d+12>>2]+8>>2]-P[a+4>>2]);d=fa-16|0;L[d+12>>2]=b;P[L[d+12>>2]+8>>2]=c;d=fa-16|0;L[d+12>>2]=L[a+8>>2]+16;c=S(P[L[d+12>>2]>>2]+P[a+4>>2]);d=fa-16|0;b=b+16|0;L[d+12>>2]=b;P[L[d+12>>2]>>2]=c;d=fa-16|0;L[d+12>>2]=L[a+8>>2]+16;c=S(P[L[d+12>>2]+4>>2]+P[a+4>>2]);d=fa-16|0;L[d+12>>2]=b;P[L[d+12>>2]+4>>2]=c;d=fa-16|0;L[d+12>>2]=L[a+8>>2]+16;c=S(P[L[d+12>>2]+8>>2]+P[a+4>>2]);d=fa-16|0;L[d+12>>2]=b;P[L[d+12>>2]+8>>2]=c;fa=a+16|0;fa=e+16|0}function uy(a,b,c,d){a=a|0;b=S(b);c=S(c);d=S(d);var e=0,f=0;e=fa-16|0;fa=e;L[e+12>>2]=a;P[e+8>>2]=b;P[e+4>>2]=c;P[e>>2]=d;a=fa-80|0;fa=a;L[a+76>>2]=L[e+12>>2];L[a+72>>2]=e+8;L[a+68>>2]=e+4;L[a+64>>2]=e;f=L[a+76>>2];P[a+60>>2]=P[L[a+72>>2]>>2]*S(.5);P[a+56>>2]=P[L[a+68>>2]>>2]*S(.5);P[a+52>>2]=P[L[a+64>>2]>>2]*S(.5);P[a+48>>2]=Ra(P[a+60>>2]);P[a+44>>2]=Qa(P[a+60>>2]);P[a+40>>2]=Ra(P[a+56>>2]);P[a+36>>2]=Qa(P[a+56>>2]);P[a+32>>2]=Ra(P[a+52>>2]);P[a+28>>2]=Qa(P[a+52>>2]);P[a+24>>2]=S(S(P[a+28>>2]*P[a+40>>2])*P[a+48>>2])-S(S(P[a+32>>2]*P[a+36>>2])*P[a+44>>2]);P[a+20>>2]=S(S(P[a+32>>2]*P[a+36>>2])*P[a+48>>2])+S(S(P[a+28>>2]*P[a+40>>2])*P[a+44>>2]);P[a+16>>2]=S(S(P[a+32>>2]*P[a+40>>2])*P[a+44>>2])-S(S(P[a+28>>2]*P[a+36>>2])*P[a+48>>2]);P[a+12>>2]=S(S(P[a+32>>2]*P[a+40>>2])*P[a+48>>2])+S(S(P[a+28>>2]*P[a+36>>2])*P[a+44>>2]);vc(f,a+24|0,a+20|0,a+16|0,a+12|0);fa=a+80|0;fa=e+16|0}function Za(a,b){var c=0,d=0,e=0,f=S(0),g=0;if(!(((E(a),x(2))&2147483647)>>>0<2139095041&((E(b),x(2))&2147483647)>>>0<=2139095040)){return S(a+b)}c=(E(b),x(2));if((c|0)==1065353216){return Tj(a)}g=c>>>30&2;d=(E(a),x(2));e=g|d>>>31;a:{b:{d=d&2147483647;c:{if(!d){d:{switch(e-2|0){case 0:return S(3.1415927410125732);case 1:break d;default:break c}}return S(-3.1415927410125732)}c=c&2147483647;if((c|0)!=2139095040){if(!c|!((d|0)!=2139095040&d>>>0<=c+218103808>>>0)){break a}e:{if(g){f=S(0);if(c>>>0>d+218103808>>>0){break e}}f=Tj(S(T(S(a/b))))}a=f;f:{switch(e|0){case 1:return S(-a);case 2:return S(S(3.1415927410125732)-S(a+S(8.742277657347586e-8)));case 0:break c;default:break f}}return S(S(a+S(8.742277657347586e-8))+S(-3.1415927410125732))}if((d|0)==2139095040){break b}a=P[(e<<2)+23308>>2]}return a}return P[(e<<2)+23292>>2]}return z(2,(E(a),x(2))&-2147483648|1070141403),F()}function SC(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0;g=fa-128|0;fa=g;e=yb(g+24|0);L[e+4>>2]=1;h=L[b+12>>2];f=e- -64|0;L[f>>2]=L[b+8>>2];L[f+4>>2]=h;f=L[b+4>>2];L[e+56>>2]=L[b>>2];L[e+60>>2]=f;f=L[b+20>>2];L[e+72>>2]=L[b+16>>2];L[e+76>>2]=f;f=L[b+28>>2];L[e+80>>2]=L[b+24>>2];L[e+84>>2]=f;f=L[b+40>>2];h=L[b+44>>2];i=L[b+32>>2];b=L[b+36>>2];L[e>>2]=2036;L[e+96>>2]=f;L[e+100>>2]=h;L[e+88>>2]=i;L[e+92>>2]=b;P[e+44>>2]=P[a+24>>2];b=L[a+4>>2];i=M[a+20|0];a:{if(i){L[b+28>>2]=c;f=b+24|0;break a}L[b+36>>2]=c;f=b+32|0}L[f>>2]=d;f=L[a+12>>2];h=L[f+8>>2];j=L[f+12>>2];L[g+20>>2]=d;L[g+16>>2]=c;L[g+12>>2]=j;L[g+8>>2]=h;L[g+4>>2]=e;L[g>>2]=f;d=L[b+16>>2];c=L[d+8>>2];b:{if(L[c+8>>2]==(h|0)){d=d+8|0;break b}c=L[d+12>>2];d=d+12|0}L[d>>2]=g;vd(b,L[a+8>>2],g,L[a+16>>2],e,(i|0)!=0);a=L[L[a+4>>2]+16>>2];L[(L[L[a+8>>2]+8>>2]==L[g+8>>2]?8:12)+a>>2]=c;Oa(e);fa=g+128|0}function aF(a,b,c){a=a|0;b=b|0;c=c|0;var d=S(0),e=S(0),f=S(0),g=0,h=S(0),i=S(0),j=0,k=0;e=S(P[b+60>>2]*S(.5));j=L[b+64>>2];k=L[b+68>>2];g=k<<2;d=P[c+8>>2];i=S(d*d);d=P[c>>2];f=S(d*d);d=P[c+4>>2];a:{b:{if(P[g+c>>2]>S(P[b+52>>2]*S(_(S(i+S(f+S(d*d))))))){L[(j<<2)+a>>2]=0;P[a+g>>2]=e;g=L[b+72>>2];break b}d=P[(j<<2)+c>>2];g=L[b+72>>2];f=P[(g<<2)+c>>2];h=S(_(S(S(d*d)+S(f*f))));if(h>S(1.1920928955078125e-7)){i=d;d=S(P[b+56>>2]/h);P[(j<<2)+a>>2]=i*d;P[(k<<2)+a>>2]=-e;e=S(f*d);break a}L[(j<<2)+a>>2]=0;P[(k<<2)+a>>2]=-e}e=S(0)}P[(g<<2)+a>>2]=e;if(S(ha[L[L[b>>2]+48>>2]](b))!=S(0)){e=P[c+4>>2];d=P[c>>2];f=P[c+8>>2];h=S(ha[L[L[b>>2]+48>>2]](b));b=S(S(f*f)+S(S(d*d)+S(e*e)))>2]=P[a>>2]+S(h*S(i*d));P[a+4>>2]=P[a+4>>2]+S(h*S(e*d));P[a+8>>2]=P[a+8>>2]+S(h*S(f*d))}}function xF(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=S(0),g=S(0),h=0,i=S(0),j=S(0),k=S(0),l=S(0),m=0,n=S(0),o=S(0),p=S(0),q=S(0),r=S(0),s=S(0),t=S(0),u=S(0),v=S(0),w=S(0),x=S(0),y=S(0);e=fa-16|0;fa=e;m=a+28|0;h=L[a+52>>2];g=P[m+((h+2|0)%3<<2)>>2];P[e+8>>2]=g;P[e+4>>2]=g;P[e>>2]=g;h=h<<2;P[h+e>>2]=g+P[h+m>>2];i=S(ha[L[L[a>>2]+48>>2]](a));j=S(ha[L[L[a>>2]+48>>2]](a));f=S(ha[L[L[a>>2]+48>>2]](a));g=P[b+52>>2];k=P[b+20>>2];p=P[b+24>>2];n=P[b+56>>2];l=P[b+36>>2];q=P[b+40>>2];o=P[b+48>>2];r=P[b+8>>2];s=P[b>>2];t=P[b+4>>2];u=P[b+16>>2];v=P[b+32>>2];w=P[e>>2];x=P[e+4>>2];y=P[e+8>>2];L[c+12>>2]=0;f=S(f+y);i=S(i+w);j=S(j+x);l=S(S(f*S(T(q)))+S(S(i*S(T(v)))+S(j*S(T(l)))));P[c+8>>2]=n-l;k=S(S(f*S(T(p)))+S(S(i*S(T(u)))+S(j*S(T(k)))));P[c+4>>2]=g-k;f=S(S(f*S(T(r)))+S(S(i*S(T(s)))+S(j*S(T(t)))));P[c>>2]=o-f;L[d+12>>2]=0;P[d+8>>2]=n+l;P[d+4>>2]=k+g;P[d>>2]=f+o;fa=e+16|0}function kA(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=S(0),f=S(0),g=S(0),h=S(0),i=S(0),j=S(0),k=S(0),l=S(0),m=S(0),n=S(0),o=S(0),p=S(0);e=S(1);d=L[b>>2];if(!((d|0)==L[a+80>>2]|M[d+204|0]&4|S(-P[a+84>>2])<=S(S(P[b+16>>2]*S(P[a+36>>2]-P[a+20>>2]))+S(S(P[b+8>>2]*S(P[a+28>>2]-P[a+12>>2]))+S(S(P[a+32>>2]-P[a+16>>2])*P[b+12>>2]))))){e=P[b+40>>2];L[a+76>>2]=d;P[a+4>>2]=e;a:{if(c){c=b+8|0;d=L[c+4>>2];L[a+44>>2]=L[c>>2];L[a+48>>2]=d;d=L[c+12>>2];L[a+52>>2]=L[c+8>>2];L[a+56>>2]=d;break a}h=P[d+12>>2];i=P[d+8>>2];j=P[d+28>>2];k=P[d+20>>2];l=P[d+24>>2];m=P[d+44>>2];n=P[d+36>>2];o=P[d+40>>2];p=P[d+4>>2];e=P[b+16>>2];f=P[b+8>>2];g=P[b+12>>2];L[a+56>>2]=0;P[a+52>>2]=S(m*e)+S(S(n*f)+S(g*o));P[a+48>>2]=S(j*e)+S(S(k*f)+S(g*l));P[a+44>>2]=S(h*e)+S(S(p*f)+S(i*g))}c=L[b+28>>2];L[a+60>>2]=L[b+24>>2];L[a+64>>2]=c;c=L[b+36>>2];L[a+68>>2]=L[b+32>>2];L[a+72>>2]=c;e=P[b+40>>2]}return S(e)}function NB(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;d=L[b+4>>2];L[a+300>>2]=L[b>>2];L[a+304>>2]=d;d=L[b+12>>2];L[a+308>>2]=L[b+8>>2];L[a+312>>2]=d;d=L[b+28>>2];L[a+324>>2]=L[b+24>>2];L[a+328>>2]=d;d=L[b+20>>2];L[a+316>>2]=L[b+16>>2];L[a+320>>2]=d;d=L[b+44>>2];L[a+340>>2]=L[b+40>>2];L[a+344>>2]=d;d=L[b+36>>2];L[a+332>>2]=L[b+32>>2];L[a+336>>2]=d;d=L[b+60>>2];L[a+356>>2]=L[b+56>>2];L[a+360>>2]=d;d=L[b+52>>2];L[a+348>>2]=L[b+48>>2];L[a+352>>2]=d;b=L[c+12>>2];L[a+372>>2]=L[c+8>>2];L[a+376>>2]=b;b=L[c+4>>2];L[a+364>>2]=L[c>>2];L[a+368>>2]=b;b=L[c+20>>2];L[a+380>>2]=L[c+16>>2];L[a+384>>2]=b;b=L[c+28>>2];L[a+388>>2]=L[c+24>>2];L[a+392>>2]=b;b=L[c+36>>2];L[a+396>>2]=L[c+32>>2];L[a+400>>2]=b;b=L[c+44>>2];L[a+404>>2]=L[c+40>>2];L[a+408>>2]=b;b=L[c+60>>2];L[a+420>>2]=L[c+56>>2];L[a+424>>2]=b;b=L[c+52>>2];L[a+412>>2]=L[c+48>>2];L[a+416>>2]=b;ha[L[L[a>>2]+8>>2]](a)}function Lb(a,b,c){var d=0,e=S(0),f=0;d=fa-32|0;fa=d;L[d+28>>2]=a;L[d+24>>2]=b;L[d+20>>2]=c;b=L[d+28>>2];a:{if(L[b+44>>2]==1){L[d+16>>2]=L[b+36>>2]+R(L[d+24>>2],L[b+48>>2]);f=Q[L[d+16>>2]>>3];a=fa-16|0;b=b+12|0;L[a+12>>2]=b;e=S(f*+P[L[a+12>>2]>>2]);L[a+12>>2]=L[d+20>>2];P[L[a+12>>2]>>2]=e;f=Q[L[d+16>>2]+8>>3];L[a+12>>2]=b;e=S(f*+P[L[a+12>>2]+4>>2]);L[a+12>>2]=L[d+20>>2];P[L[a+12>>2]+4>>2]=e;f=Q[L[d+16>>2]+16>>3];L[a+12>>2]=b;e=S(f*+P[L[a+12>>2]+8>>2]);break a}L[d+12>>2]=L[b+36>>2]+R(L[d+24>>2],L[b+48>>2]);e=P[L[d+12>>2]>>2];a=fa-16|0;b=b+12|0;L[a+12>>2]=b;e=S(e*P[L[a+12>>2]>>2]);L[a+12>>2]=L[d+20>>2];P[L[a+12>>2]>>2]=e;e=P[L[d+12>>2]+4>>2];L[a+12>>2]=b;e=S(e*P[L[a+12>>2]+4>>2]);L[a+12>>2]=L[d+20>>2];P[L[a+12>>2]+4>>2]=e;e=P[L[d+12>>2]+8>>2];L[a+12>>2]=b;e=S(e*P[L[a+12>>2]+8>>2])}a=fa-16|0;L[a+12>>2]=L[d+20>>2];P[L[a+12>>2]+8>>2]=e;fa=d+32|0}function cw(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,f=0,g=0,h=0;f=fa-16|0;fa=f;L[f+12>>2]=a;L[f+8>>2]=b;L[f+4>>2]=c;g=oa(104);a=L[f+12>>2];b=L[f+8>>2];d=L[f+4>>2];c=fa-16|0;fa=c;L[c+12>>2]=g;L[c+8>>2]=a;L[c+4>>2]=b;L[c>>2]=d;a=L[c+8>>2];d=L[c+4>>2];e=L[c>>2];b=fa-32|0;fa=b;h=L[c+12>>2];L[b+24>>2]=h;L[b+20>>2]=a;L[b+16>>2]=d;L[b+12>>2]=e;a=L[b+24>>2];L[b+28>>2]=a;yb(a);L[a>>2]=2236;d=a+56|0;e=d+48|0;while(1){L[(fa-16|0)+12>>2]=d;d=d+16|0;if((e|0)!=(d|0)){continue}break}L[a+4>>2]=1;d=L[b+20>>2];e=L[d+4>>2];L[a+56>>2]=L[d>>2];L[a+60>>2]=e;e=L[d+12>>2];L[a+64>>2]=L[d+8>>2];L[a+68>>2]=e;d=L[b+16>>2];e=L[d+4>>2];L[a+72>>2]=L[d>>2];L[a+76>>2]=e;e=L[d+12>>2];L[a+80>>2]=L[d+8>>2];L[a+84>>2]=e;d=L[b+12>>2];e=L[d+4>>2];L[a+88>>2]=L[d>>2];L[a+92>>2]=e;e=L[d+12>>2];L[a+96>>2]=L[d+8>>2];L[a+100>>2]=e;fa=b+32|0;L[h>>2]=2036;fa=c+16|0;fa=f+16|0;return g|0}function Tz(a,b,c){a=a|0;b=S(b);c=c|0;var d=S(0),e=0,f=S(0),g=S(0),h=S(0),i=S(0),j=S(0);e=L[a+8>>2];if(e){ib(e,0)}e=L[a+12>>2];if(e){ib(e,0)}e=L[a+20>>2];if(e){ib(e,0)}e=L[a+24>>2];if(e){ib(e,0)}e=L[a+156>>2];L[a+156>>2]=e+1;J[a+152|0]=(e|0)>=L[a+160>>2];if(!e){L[a+84>>2]=0;f=S(S(1)/b);d=P[a+64>>2];b=S(f*S(P[a+72>>2]*d));g=S(f*S(d*P[a+80>>2]));f=S(f*S(d*P[a+76>>2]));d=P[a+68>>2];if(d>S(0)){L[a+100>>2]=0;h=S(d*g);i=S(b*d);j=S(d*f);P[a+96>>2]=S(P[a+144>>2]*h)+S(S(P[a+136>>2]*i)+S(j*P[a+140>>2]));P[a+92>>2]=S(P[a+128>>2]*h)+S(S(P[a+120>>2]*i)+S(j*P[a+124>>2]));P[a+88>>2]=S(P[a+112>>2]*h)+S(S(P[a+104>>2]*i)+S(j*P[a+108>>2]));d=S(S(1)-d);g=S(d*g);f=S(d*f);b=S(b*d)}d=S(S(1)/S(c|0));P[a+80>>2]=d*g;P[a+76>>2]=d*f;P[a+72>>2]=d*b;return}a=a+72|0;L[a>>2]=0;L[a+4>>2]=0;L[a+24>>2]=0;L[a+28>>2]=0;L[a+16>>2]=0;L[a+20>>2]=0;L[a+8>>2]=0;L[a+12>>2]=0}function QE(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=S(0),f=0,g=0,h=S(0),i=S(0),j=0,k=S(0),l=S(0),m=S(0),n=S(0),o=S(0),p=0,q=S(0),r=0,s=0;d=L[b+96>>2];if((d|0)>0){r=d&1;l=P[b+12>>2];h=S(P[c>>2]*l);m=P[b+20>>2];i=S(P[c+8>>2]*m);n=P[b+16>>2];k=S(P[c+4>>2]*n);j=L[b+104>>2];a:{if((d|0)==1){b=0;c=-1;e=S(-34028234663852886e22);break a}s=d&-2;b=0;c=-1;e=S(-34028234663852886e22);d=0;while(1){f=(b<<4)+j|0;o=S(S(P[f+8>>2]*i)+S(S(P[f>>2]*h)+S(k*P[f+4>>2])));f=o>e;p=b|1;g=(p<<4)+j|0;q=S(S(P[g+8>>2]*i)+S(S(P[g>>2]*h)+S(k*P[g+4>>2])));e=f?o:e;g=q>e;e=g?q:e;c=g?p:f?b:c;b=b+2|0;d=d+2|0;if((s|0)!=(d|0)){continue}break}}if(r){d=b;b=(b<<4)+j|0;c=S(S(P[b+8>>2]*i)+S(S(P[b>>2]*h)+S(k*P[b+4>>2])))>e?d:c}b=(c<<4)+j|0;e=P[b>>2];h=P[b+4>>2];i=P[b+8>>2];L[a+12>>2]=0;P[a+8>>2]=m*i;P[a+4>>2]=n*h;P[a>>2]=l*e;return}L[a>>2]=0;L[a+4>>2]=0;L[a+8>>2]=0;L[a+12>>2]=0}function Zz(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0,g=S(0),h=S(0),i=S(0),j=S(0);e=fa-96|0;fa=e;L[e+24>>2]=-65535;L[e+28>>2]=0;L[e+16>>2]=1065353216;L[e+20>>2]=0;L[e+12>>2]=1476;f=L[b+12>>2];L[e+40>>2]=L[b+8>>2];L[e+44>>2]=f;f=L[b+4>>2];L[e+32>>2]=L[b>>2];L[e+36>>2]=f;f=L[c+12>>2];L[e+56>>2]=L[c+8>>2];L[e+60>>2]=f;f=L[c+4>>2];L[e+48>>2]=L[c>>2];L[e+52>>2]=f;a=L[a+4>>2];ha[L[L[a>>2]+32>>2]](a,b,c,e+12|0);b=0;a=L[e+20>>2];if(!(!a|!(M[a+236|0]&2)|M[a+204|0]&4)){b=L[e+84>>2];L[d>>2]=L[e+80>>2];L[d+4>>2]=b;b=L[e+92>>2];L[d+8>>2]=L[e+88>>2];L[d+12>>2]=b;b=L[e+68>>2];L[d+16>>2]=L[e+64>>2];L[d+20>>2]=b;b=L[e+76>>2];L[d+24>>2]=L[e+72>>2];L[d+28>>2]=b;g=P[d+24>>2];h=P[d+16>>2];i=P[d+20>>2];j=S(S(1)/S(_(S(S(g*g)+S(S(h*h)+S(i*i))))));P[d+16>>2]=h*j;P[d+24>>2]=g*j;P[d+20>>2]=i*j;P[d+32>>2]=P[e+16>>2];b=a}fa=e+96|0;return b|0}function PC(a,b,c){a=a|0;b=S(b);c=c|0;var d=S(0),e=S(0),f=0,g=0,h=S(0),i=S(0),j=S(0),k=S(0),l=S(0),m=0,n=0,o=0;ha[L[L[a>>2]+112>>2]](a);L[c+8>>2]=0;L[c+12>>2]=0;L[c>>2]=0;L[c+4>>2]=0;f=L[a+184>>2];a:{if(!f){break a}b=S(b/S(f|0));m=L[a+192>>2];n=L[a+180>>2];if(L[a+188>>2]==1){while(1){f=f-1|0;g=R(m,f)+n|0;o=Q[g+16>>3];d=P[a+164>>2];h=S(Q[g>>3]*+P[a+156>>2]);h=S(h*h);e=S(Q[g+8>>3]*+P[a+160>>2]);e=S(e*e);i=S(S(b*S(h+e))+i);P[c+8>>2]=i;d=S(o*+d);d=S(d*d);j=S(S(b*S(h+d))+j);P[c+4>>2]=j;k=S(k+S(b*S(e+d)));P[c>>2]=k;if(f){continue}break}break a}while(1){f=f-1|0;g=R(m,f)+n|0;d=P[g+8>>2];h=P[a+164>>2];e=S(P[a+156>>2]*P[g>>2]);e=S(e*e);l=S(P[g+4>>2]*P[a+160>>2]);l=S(l*l);i=S(S(b*S(e+l))+i);P[c+8>>2]=i;d=S(d*h);d=S(d*d);j=S(S(b*S(e+d))+j);P[c+4>>2]=j;k=S(k+S(b*S(l+d)));P[c>>2]=k;if(f){continue}break}}ha[L[L[a>>2]+116>>2]](a)}function bf(a,b,c){var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;a:{e=L[((b<<2)+a|0)+68>>2]+(c<<2)|0;d=N[e+6>>1];if(!d){break a}j=b<<1;f=L[a+60>>2]+(N[e+2>>1]<<6)|0;g=f+54|0;l=j+g|0;c=e+4|0;i=f+48|0;b=1<>1];if(h>>>0>N[e>>1]){break a}m=L[a+60>>2];b=m+(d<<6)|0;if(h&1){b=(b+j|0)+54|0}else{d=b+k|0;b:{if(N[g>>1]>1]|N[d+54>>1]>1]){break b}d=b+f|0;if(N[o>>1]>1]|N[d+54>>1]>1]){break b}d=L[a+92>>2];h=(N[e+2>>1]<<6)+m|0;ha[L[L[d>>2]+8>>2]](d,h,b)|0;d=L[a+96>>2];if(!d){break b}ha[L[L[d>>2]+8>>2]](d,h,b)|0}b=(b+j|0)+48|0}K[b>>1]=N[b>>1]-1;K[l>>1]=N[l>>1]+1;b=N[e>>1]|N[e+2>>1]<<16;d=N[c>>1]|N[c+2>>1]<<16;K[e>>1]=d;K[e+2>>1]=d>>>16;K[c>>1]=b;K[c+2>>1]=b>>>16;e=e+4|0;b=c;c=b+4|0;d=N[b+6>>1];if(d){continue}break}}}function hx(a){a=a|0;var b=S(0),c=S(0),d=0,e=0,f=0,g=S(0),h=S(0),i=S(0),j=S(0),k=0,l=S(0),m=S(0);f=fa-16|0;fa=f;L[f+12>>2]=a;k=oa(56);e=L[f+12>>2];a=yb(k);L[a+4>>2]=0;L[a>>2]=11860;c=P[e>>2];b=P[e+4>>2];d=c>2]>(d?c:b)?!d:2)<<2)+e>>2]*S(.10000000149011612));c=P[a+44>>2];if(b>2]=a;g=P[L[d+12>>2]+44>>2];P[a+44>>2]=b;b=P[a+36>>2];h=P[a+32>>2];i=P[a+28>>2];j=S(ha[L[L[a>>2]+48>>2]](a));l=S(ha[L[L[a>>2]+48>>2]](a));m=S(ha[L[L[a>>2]+48>>2]](a));L[a+40>>2]=0;P[a+32>>2]=S(c+h)-l;P[a+28>>2]=S(c+i)-j;P[a+36>>2]=S(g+b)-m;d=L[a>>2]}else{d=11860}c=S(ha[L[d+48>>2]](a));b=S(ha[L[L[a>>2]+48>>2]](a));g=S(ha[L[L[a>>2]+48>>2]](a));h=P[e>>2];i=P[e+4>>2];j=P[e+8>>2];L[a+40>>2]=0;P[a+36>>2]=S(j*P[a+20>>2])-g;P[a+32>>2]=S(i*P[a+16>>2])-b;P[a+28>>2]=S(h*P[a+12>>2])-c;fa=f+16|0;return k|0}function ws(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=S(0),f=S(0),g=S(0),h=S(0),i=S(0),j=S(0),k=S(0),l=S(0),m=S(0),n=S(0);d=fa-16|0;fa=d;L[d+12>>2]=a;L[d+8>>2]=b;L[d+4>>2]=c;b=L[d+8>>2];a=L[d+12>>2];a:{if(M[a+84|0]){e=P[a+8>>2];f=P[a>>2];j=P[a+4>>2];g=S(S(e*P[a+60>>2])+S(S(f*P[a+52>>2])+S(j*P[a+56>>2])));if(g>=S(-.10000000149011612)){L[a+272>>2]=0;P[a+268>>2]=10;break a}g=S(S(-1)/g);i=e;e=P[b+328>>2];h=S(P[a+20>>2]-P[b+56>>2]);k=S(P[a+16>>2]-P[b+52>>2]);l=P[b+332>>2];m=S(i*S(P[b+320>>2]+S(S(e*h)-S(k*l))));i=f;f=S(P[a+24>>2]-P[b+60>>2]);n=h;h=P[b+336>>2];P[a+272>>2]=g*S(m+S(S(i*S(P[b+312>>2]+S(S(l*f)-S(n*h))))+S(j*S(S(S(h*k)-S(f*e))+P[b+316>>2]))));P[a+268>>2]=g;break a}L[a+272>>2]=0;L[a+12>>2]=0;P[a+32>>2]=P[a+204>>2];P[a>>2]=-P[a+52>>2];P[a+8>>2]=-P[a+60>>2];P[a+4>>2]=-P[a+56>>2];P[a+268>>2]=1}fa=d+16|0}function fu(a){a=a|0;var b=S(0),c=S(0),d=S(0),e=S(0),f=S(0),g=S(0),h=S(0),i=S(0),j=S(0),k=S(0),l=0,m=S(0),n=S(0),o=S(0),p=S(0),q=S(0);l=fa-16|0;fa=l;L[l+12>>2]=a;a=L[l+12>>2];L[a+308>>2]=0;L[a+292>>2]=0;L[a+276>>2]=0;c=P[a+44>>2];h=P[a+404>>2];d=S(c*h);e=P[a+36>>2];i=P[a+396>>2];f=S(e*i);g=P[a+40>>2];q=P[a+400>>2];b=S(g*q);P[a+304>>2]=S(c*d)+S(S(e*f)+S(g*b));m=P[a+28>>2];n=P[a+20>>2];o=P[a+24>>2];P[a+300>>2]=S(m*d)+S(S(n*f)+S(o*b));p=P[a+12>>2];j=S(p*d);d=P[a+4>>2];k=S(d*f);f=P[a+8>>2];P[a+296>>2]=j+S(k+S(f*b));b=S(h*m);j=S(i*n);k=S(q*o);P[a+288>>2]=S(c*b)+S(S(e*j)+S(g*k));P[a+284>>2]=S(m*b)+S(S(n*j)+S(o*k));P[a+280>>2]=S(p*b)+S(S(d*j)+S(f*k));b=c;c=S(p*h);h=e;e=S(d*i);i=g;g=S(f*q);P[a+272>>2]=S(b*c)+S(S(h*e)+S(i*g));P[a+268>>2]=S(m*c)+S(S(n*e)+S(g*o));P[a+264>>2]=S(p*c)+S(S(d*e)+S(f*g));fa=l+16|0}function um(a,b,c,d){var e=0,f=0,g=0;e=fa+-64|0;fa=e;g=R(b,80);f=g+L[a+24>>2]|0;b=L[c+4>>2];L[f>>2]=L[c>>2];L[f+4>>2]=b;b=L[c+12>>2];L[f+8>>2]=L[c+8>>2];L[f+12>>2]=b;b=L[c+28>>2];L[f+24>>2]=L[c+24>>2];L[f+28>>2]=b;b=L[c+20>>2];L[f+16>>2]=L[c+16>>2];L[f+20>>2]=b;b=L[c+44>>2];L[f+40>>2]=L[c+40>>2];L[f+44>>2]=b;b=L[c+36>>2];L[f+32>>2]=L[c+32>>2];L[f+36>>2]=b;b=L[c+60>>2];L[f+56>>2]=L[c+56>>2];L[f+60>>2]=b;b=L[c+52>>2];L[f+48>>2]=L[c+48>>2];L[f+52>>2]=b;if(L[a+64>>2]){b=L[(L[a+24>>2]+g|0)+64>>2];ha[L[L[b>>2]+8>>2]](b,c,e+48|0,e+32|0);c=L[e+60>>2];L[e+8>>2]=L[e+56>>2];L[e+12>>2]=c;b=L[e+44>>2];L[e+24>>2]=L[e+40>>2];L[e+28>>2]=b;b=L[e+36>>2];L[e+16>>2]=L[e+32>>2];L[e+20>>2]=b;b=L[e+52>>2];L[e>>2]=L[e+48>>2];L[e+4>>2]=b;Gc(L[a+64>>2],L[(L[a+24>>2]+g|0)+76>>2],e)}if(d){ha[L[L[a>>2]+68>>2]](a)}fa=e- -64|0}function Pq(a){a=a|0;var b=0,c=0,d=0,e=0,f=0,g=0,h=0,i=0;c=fa-32|0;fa=c;L[c+28>>2]=a;if(!M[29900]){L[(fa-16|0)+12>>2]=29884;J[29900]=1}a=fa-16|0;fa=a;L[a+12>>2]=L[c+28>>2];g=L[a+12>>2];L[a+8>>2]=L[g+116>>2]+4;d=fa-16|0;L[d+12>>2]=L[a+8>>2];b=fa-16|0;L[b+12>>2]=L[d+12>>2];L[b+8>>2]=0;d=fa-16|0;L[d+12>>2]=L[b+12>>2]+(L[b+8>>2]<<4);d=L[d+12>>2];h=L[g+128>>2]<<2;e=fa-16|0;L[e+12>>2]=L[a+8>>2];b=fa-16|0;L[b+12>>2]=L[e+12>>2];L[b+8>>2]=1;e=fa-16|0;L[e+12>>2]=L[b+12>>2]+(L[b+8>>2]<<4);e=L[e+12>>2];i=L[g+128>>2]<<2;f=fa-16|0;L[f+12>>2]=L[a+8>>2];b=fa-16|0;L[b+12>>2]=L[f+12>>2];L[b+8>>2]=2;f=fa-16|0;L[f+12>>2]=L[b+12>>2]+(L[b+8>>2]<<4);la(c+12|0,d+h|0,e+i|0,L[f+12>>2]+(L[g+128>>2]<<2)|0);fa=a+16|0;a=L[c+16>>2];L[7471]=L[c+12>>2];L[7472]=a;a=L[c+24>>2];L[7473]=L[c+20>>2];L[7474]=a;fa=c+32|0;return 29884}function BA(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0;d=L[a+212>>2];a:{if((d|0)!=L[a+216>>2]){break a}i=d?d<<1:1;if((i|0)<=(d|0)){break a}if(i){L[8513]=L[8513]+1;g=ha[L[6798]](i<<2,16)|0;d=L[a+212>>2]}b:{if((d|0)<=0){break b}if(d>>>0>=4){j=d&-4;while(1){e=f<<2;L[e+g>>2]=L[e+L[a+220>>2]>>2];h=e|4;L[h+g>>2]=L[h+L[a+220>>2]>>2];h=e|8;L[h+g>>2]=L[h+L[a+220>>2]>>2];e=e|12;L[e+g>>2]=L[e+L[a+220>>2]>>2];f=f+4|0;k=k+4|0;if((j|0)!=(k|0)){continue}break}}e=d&3;if(!e){break b}while(1){j=f<<2;L[j+g>>2]=L[j+L[a+220>>2]>>2];f=f+1|0;l=l+1|0;if((e|0)!=(l|0)){continue}break}}f=L[a+220>>2];if(!(!f|!M[a+224|0])){if(f){L[8514]=L[8514]+1;ha[L[6799]](f)}d=L[a+212>>2]}L[a+220>>2]=g;J[a+224|0]=1;L[a+216>>2]=i}L[L[a+220>>2]+(d<<2)>>2]=b;L[a+212>>2]=d+1;if(c){Fk(L[b+28>>2],b);Fk(L[b+32>>2],b)}}function ep(a,b,c,d){a=a|0;b=S(b);c=c|0;d=d|0;var e=0,f=0,g=0;e=fa-112|0;fa=e;L[e+108>>2]=a;P[e+104>>2]=b;L[e+100>>2]=c;L[e+96>>2]=d;a=L[e+108>>2];d=fa-16|0;c=d;L[c+12>>2]=L[e+100>>2];c=L[c+12>>2]+48|0;f=L[c+12>>2];L[e+88>>2]=L[c+8>>2];L[e+92>>2]=f;f=L[c+4>>2];L[e+80>>2]=L[c>>2];L[e+84>>2]=f;L[d+12>>2]=L[e+100>>2];c=e- -64|0;nc(c,L[d+12>>2],1);f=fa-16|0;L[f+12>>2]=L[e+100>>2];d=e+48|0;nc(d,L[f+12>>2],0);P[e+44>>2]=-1.5707963705062866;P[e+40>>2]=1.5707963705062866;P[e+36>>2]=-1.5707963705062866;P[e+32>>2]=1.5707963705062866;P[e+28>>2]=30;f=e+80|0;ha[L[L[a>>2]+64>>2]](a,f,c,d,P[e+104>>2],P[e+44>>2],P[e+40>>2],P[e+36>>2],P[e+32>>2],L[e+96>>2],P[e+28>>2],0);g=e+12|0;Zb(g,d);ha[L[L[a>>2]+64>>2]](a,f,c,g,P[e+104>>2],P[e+44>>2],P[e+40>>2],P[e+36>>2],P[e+32>>2],L[e+96>>2],P[e+28>>2],0);fa=e+112|0}function af(a,b,c,d){var e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0;a:{g=L[((b<<2)+a|0)+68>>2]+(c<<2)|0;f=N[g+6>>1];if(!f){break a}i=b<<1;j=i+(L[a+60>>2]+(N[g+2>>1]<<6)|0)|0;c=g+4|0;k=1<>1];if(e>>>0>N[g>>1]){break a}b=f<<6;f=L[a+60>>2];b=b+f|0;b:{if(e&1){f=f+(N[g+2>>1]<<6)|0;e=k<<1;h=f+e|0;e=b+e|0;c:{if(N[h+54>>1]>1]|N[e+54>>1]>1]){break c}e=l<<1;h=e+f|0;e=b+e|0;if(N[h+54>>1]>1]|N[e+54>>1]>1]){break c}e=L[a+92>>2];ha[L[L[e>>2]+12>>2]](e,f,b,d)|0;e=L[a+96>>2];if(!e){break c}ha[L[L[e>>2]+12>>2]](e,f,b,d)|0}b=(b+i|0)+54|0;break b}b=(b+i|0)+48|0}K[b>>1]=N[b>>1]-1;K[j+48>>1]=N[j+48>>1]+1;b=N[g>>1]|N[g+2>>1]<<16;f=N[c>>1]|N[c+2>>1]<<16;K[g>>1]=f;K[g+2>>1]=f>>>16;K[c>>1]=b;K[c+2>>1]=b>>>16;g=g+4|0;b=c;c=b+4|0;f=N[b+6>>1];if(f){continue}break}}}function Ts(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0,g=S(0),h=S(0),i=S(0),j=S(0),k=S(0),l=S(0),m=S(0),n=S(0),o=0;e=fa-16|0;fa=e;L[e+12>>2]=a;L[e+8>>2]=b;L[e+4>>2]=c;L[e>>2]=d;o=oa(96);a=L[e+4>>2];b=L[e>>2];d=fa-32|0;fa=d;c=ub(o,11,L[e+12>>2],L[e+8>>2]);L[c>>2]=19484;f=L[a+52>>2];L[c+48>>2]=L[a+48>>2];L[c+52>>2]=f;f=L[a+60>>2];L[c+56>>2]=L[a+56>>2];L[c+60>>2]=f;f=L[b+52>>2];L[c+64>>2]=L[b+48>>2];L[c+68>>2]=f;f=L[b+60>>2];L[c+72>>2]=L[b+56>>2];L[c+76>>2]=f;Ma(a,d+16|0);Ma(b,d);g=P[d+24>>2];h=P[d+8>>2];i=P[d+20>>2];j=P[d+4>>2];k=P[d+28>>2];l=P[d+12>>2];m=P[d>>2];n=P[d+16>>2];P[c+92>>2]=S(g*h)+S(S(i*j)+S(S(k*l)+S(m*n)));P[c+88>>2]=S(i*m)+S(S(S(l*g)-S(k*h))-S(n*j));P[c+84>>2]=S(n*h)+S(S(S(l*i)-S(k*j))-S(g*m));P[c+80>>2]=S(g*j)+S(S(S(l*n)-S(k*m))-S(i*h));fa=d+32|0;fa=e+16|0;return o|0}function cB(a,b,c,d,e,f,g,h,i){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;i=i|0;a:{if(!L[h+44>>2]){break a}d=L[h+20>>2];b:{c:{if(J[h+65|0]&1){if((d|0)<=0){break a}e=0;b=L[a+28>>2];if((b|0)<=0){break a}break c}if((d|0)<=0){break a}e=0;b=L[a+28>>2];if((b|0)<=0){break a}break b}while(1){c=0;if((b|0)>0){while(1){f=L[a+16>>2];d=L[a+36>>2]+R(L[L[a+116>>2]+(c<<2)>>2],152)|0;bl(f+R(L[d+144>>2],244)|0,f+R(L[d+148>>2],244)|0,d);c=c+1|0;if((c|0)!=(b|0)){continue}break}d=L[h+20>>2]}e=e+1|0;if((e|0)>=(d|0)){break a}b=L[a+28>>2];continue}}while(1){c=0;if((b|0)>0){while(1){f=L[a+16>>2];d=L[a+36>>2]+R(L[L[a+116>>2]+(c<<2)>>2],152)|0;bl(f+R(L[d+144>>2],244)|0,f+R(L[d+148>>2],244)|0,d);c=c+1|0;if((c|0)!=(b|0)){continue}break}d=L[h+20>>2]}e=e+1|0;if((e|0)>=(d|0)){break a}b=L[a+28>>2];continue}}}function Tj(a){var b=0,c=0,d=S(0),e=S(0),f=0,g=S(0);f=(E(a),x(2));c=f&2147483647;if(c>>>0>=1283457024){return((E(a),x(2))&2147483647)>>>0>2139095040?a:(z(2,(E(a),x(2))&-2147483648|1070141402),F())}a:{b:{if(c>>>0<=1054867455){b=-1;if(c>>>0>=964689920){break b}break a}a=S(T(a));if(c>>>0<=1066926079){if(c>>>0<=1060110335){a=S(S(S(a+a)+S(-1))/S(a+S(2)));b=0;break b}a=S(S(a+S(-1))/S(a+S(1)));b=1;break b}if(c>>>0<=1075576831){a=S(S(a+S(-1.5))/S(S(a*S(1.5))+S(1)));b=2;break b}a=S(S(-1)/a);b=3}e=S(a*a);d=S(e*e);g=S(d*S(S(d*S(-.106480173766613))+S(-.19999158382415771)));d=S(e*S(S(d*S(S(d*S(.06168760731816292))+S(.14253635704517365)))+S(.333333283662796)));if(c>>>0<=1054867455){return S(a-S(a*S(g+d)))}b=b<<2;a=S(P[b+23328>>2]-S(S(S(a*S(g+d))-P[b+23344>>2])-a));a=(f|0)<0?S(-a):a}return a}function UG(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0;c=L[a+20>>2];if(!(!c|!M[a+16|0])){d=L[b+4>>2];a:{if((d|0)!=L[b+8>>2]){break a}h=d?d<<1:1;if((h|0)<=(d|0)){break a}if(h){L[8513]=L[8513]+1;f=ha[L[6798]](h<<2,16)|0;d=L[b+4>>2]}b:{if((d|0)<=0){break b}c=0;if(d>>>0>=4){i=d&-4;while(1){e=c<<2;L[e+f>>2]=L[e+L[b+12>>2]>>2];g=e|4;L[g+f>>2]=L[g+L[b+12>>2]>>2];g=e|8;L[g+f>>2]=L[g+L[b+12>>2]>>2];e=e|12;L[e+f>>2]=L[e+L[b+12>>2]>>2];c=c+4|0;j=j+4|0;if((i|0)!=(j|0)){continue}break}}e=d&3;if(!e){break b}while(1){i=c<<2;L[i+f>>2]=L[i+L[b+12>>2]>>2];c=c+1|0;k=k+1|0;if((e|0)!=(k|0)){continue}break}}c=L[b+12>>2];if(!(!c|!M[b+16|0])){if(c){L[8514]=L[8514]+1;ha[L[6799]](c)}d=L[b+4>>2]}L[b+12>>2]=f;J[b+16|0]=1;L[b+8>>2]=h;c=L[a+20>>2]}L[L[b+12>>2]+(d<<2)>>2]=c;L[b+4>>2]=d+1}}function Pt(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=S(0),g=S(0),h=S(0),i=0,j=S(0),k=S(0),l=S(0),m=S(0),n=S(0),o=S(0),p=S(0),q=S(0),r=S(0),s=S(0),t=S(0),u=S(0);d=fa-16|0;fa=d;L[d+12>>2]=a;L[d+8>>2]=b;i=oa(360);c=L[d+8>>2];b=L[d+12>>2];a=rg(i,3,b);L[a>>2]=19852;e=L[c+4>>2];L[a+300>>2]=L[c>>2];L[a+304>>2]=e;e=L[c+12>>2];L[a+308>>2]=L[c+8>>2];L[a+312>>2]=e;j=P[b+52>>2];k=P[b+8>>2];l=P[b+12>>2];m=P[b+56>>2];n=P[b+20>>2];o=P[b+24>>2];p=P[b+28>>2];q=P[b+60>>2];r=P[b+36>>2];s=P[b+40>>2];f=P[c+8>>2];t=P[b+44>>2];u=P[b+4>>2];g=P[c>>2];h=P[c+4>>2];L[a+356>>2]=0;L[a+348>>2]=1050253722;L[a+352>>2]=1065353216;J[a+344|0]=0;L[a+328>>2]=0;L[a+332>>2]=0;P[a+324>>2]=q+S(S(f*t)+S(S(g*r)+S(h*s)));P[a+320>>2]=m+S(S(f*p)+S(S(g*n)+S(h*o)));P[a+316>>2]=j+S(S(f*l)+S(S(g*u)+S(h*k)));fa=d+16|0;return i|0}function zd(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0;c=L[a+12>>2];if(!(!c|!M[a+8|0])){d=L[b+4>>2];a:{if((d|0)!=L[b+8>>2]){break a}h=d?d<<1:1;if((h|0)<=(d|0)){break a}if(h){L[8513]=L[8513]+1;f=ha[L[6798]](h<<2,16)|0;d=L[b+4>>2]}b:{if((d|0)<=0){break b}c=0;if(d>>>0>=4){i=d&-4;while(1){e=c<<2;L[e+f>>2]=L[e+L[b+12>>2]>>2];g=e|4;L[g+f>>2]=L[g+L[b+12>>2]>>2];g=e|8;L[g+f>>2]=L[g+L[b+12>>2]>>2];e=e|12;L[e+f>>2]=L[e+L[b+12>>2]>>2];c=c+4|0;j=j+4|0;if((i|0)!=(j|0)){continue}break}}e=d&3;if(!e){break b}while(1){i=c<<2;L[i+f>>2]=L[i+L[b+12>>2]>>2];c=c+1|0;k=k+1|0;if((e|0)!=(k|0)){continue}break}}c=L[b+12>>2];if(!(!c|!M[b+16|0])){if(c){L[8514]=L[8514]+1;ha[L[6799]](c)}d=L[b+4>>2]}L[b+12>>2]=f;J[b+16|0]=1;L[b+8>>2]=h;c=L[a+12>>2]}L[L[b+12>>2]+(d<<2)>>2]=c;L[b+4>>2]=d+1}}function BE(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=S(0),f=S(0),g=S(0),h=S(0),i=S(0);d=fa-80|0;fa=d;L[a>>2]=0;L[a+4>>2]=0;L[a+8>>2]=0;L[a+12>>2]=0;f=P[c+8>>2];h=P[c>>2];g=P[c+4>>2];e=S(S(f*f)+S(S(h*h)+S(g*g)));a:{if(e>2];e=S(h*e)}L[d+52>>2]=0;L[d+56>>2]=0;P[d+76>>2]=g;P[d+72>>2]=f;P[d+68>>2]=i;L[d+44>>2]=0;L[d+48>>2]=0;P[d+64>>2]=e;L[d+60>>2]=-581039253;L[d+40>>2]=14628;L[d+32>>2]=1566444395;L[d+36>>2]=0;L[d+24>>2]=1566444395;L[d+28>>2]=1566444395;b=L[b+92>>2];L[d+16>>2]=-581039253;L[d+20>>2]=0;L[d+8>>2]=-581039253;L[d+12>>2]=-581039253;ha[L[L[b>>2]+8>>2]](b,d+40|0,d+8|0,d+24|0);b=L[d+56>>2];L[a+8>>2]=L[d+52>>2];L[a+12>>2]=b;b=L[d+48>>2];L[a>>2]=L[d+44>>2];L[a+4>>2]=b;fa=d+80|0}function CE(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=S(0),f=S(0),g=S(0),h=0,i=S(0),j=S(0),k=S(0),l=S(0);d=fa-32|0;fa=d;h=L[c+12>>2];L[d+24>>2]=L[c+8>>2];L[d+28>>2]=h;h=L[c+4>>2];L[d+16>>2]=L[c>>2];L[d+20>>2]=h;e=P[d+24>>2];f=P[d+16>>2];g=P[d+20>>2];if(S(S(e*e)+S(S(f*f)+S(g*g)))>2]=0;g=S(-1);f=S(-1);e=S(-1)}i=e;e=S(S(1)/S(_(S(S(e*e)+S(S(f*f)+S(g*g))))));P[d+24>>2]=i*e;P[d+20>>2]=g*e;P[d+16>>2]=f*e;Te(d,b,d+16|0);a:{b:{switch(L[b+4>>2]){case 8:e=S(P[b+28>>2]*P[b+12>>2]);break a;case 0:case 1:case 4:case 5:case 10:case 11:case 13:e=P[b+44>>2];break a;default:break b}}e=S(ha[L[L[b>>2]+48>>2]](b))}f=P[d>>2];g=P[d+16>>2];i=P[d+4>>2];j=P[d+20>>2];k=P[d+8>>2];l=P[d+24>>2];L[a+12>>2]=0;P[a+8>>2]=k+S(e*l);P[a+4>>2]=i+S(e*j);P[a>>2]=f+S(e*g);fa=d+32|0}function Id(a,b,c,d){var e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0;h=L[((b<<2)+a|0)+68>>2];e=c<<2;c=h+e|0;g=c-4|0;f=N[g>>1];if(f>>>0>N[c>>1]){j=b<<1;h=j+(L[a+60>>2]+(N[(e+h|0)+2>>1]<<6)|0)|0;k=1<>2];b=e+(N[c-2>>1]<<6)|0;if(f&1){b=(b+j|0)+54|0}else{f=e+(N[c+2>>1]<<6)|0;e=k<<1;i=f+e|0;e=b+e|0;a:{if(N[i+54>>1]>1]|N[e+54>>1]>1]){break a}e=l<<1;i=e+f|0;e=b+e|0;if(N[i+54>>1]>1]|N[e+54>>1]>1]){break a}e=L[a+92>>2];ha[L[L[e>>2]+12>>2]](e,f,b,d)|0;e=L[a+96>>2];if(!e){break a}ha[L[L[e>>2]+12>>2]](e,f,b,d)|0}b=(b+j|0)+48|0}K[b>>1]=N[b>>1]+1;K[h+54>>1]=N[h+54>>1]-1;b=N[c>>1]|N[c+2>>1]<<16;f=N[g>>1]|N[g+2>>1]<<16;K[c>>1]=f;K[c+2>>1]=f>>>16;K[g>>1]=b;K[g+2>>1]=b>>>16;g=g-4|0;f=N[g>>1];c=c-4|0;if(f>>>0>N[c>>1]){continue}break}}}function rA(a,b){a=a|0;b=b|0;var c=0,d=0;ha[L[L[b>>2]+32>>2]](b);d=ha[L[L[b>>2]+16>>2]](b,104,1)|0;c=pa(L[d+8>>2],0,104);P[c+88>>2]=P[a+248>>2];P[c+92>>2]=P[a+252>>2];P[c+96>>2]=P[a+256>>2];P[c+100>>2]=P[a+260>>2];P[c>>2]=P[a+92>>2];P[c+4>>2]=P[a+96>>2];P[c+8>>2]=P[a+100>>2];P[c+12>>2]=P[a+104>>2];P[c+16>>2]=P[a+108>>2];P[c+20>>2]=P[a+116>>2];P[c+24>>2]=P[a+120>>2];P[c+28>>2]=P[a+124>>2];P[c+32>>2]=P[a+128>>2];P[c+36>>2]=P[a+132>>2];P[c+40>>2]=P[a+140>>2];P[c+44>>2]=P[a+144>>2];P[c+48>>2]=P[a+148>>2];P[c+52>>2]=P[a+152>>2];P[c+56>>2]=P[a+168>>2];P[c+60>>2]=P[a+172>>2];L[c+64>>2]=L[a+112>>2];L[c+68>>2]=L[a+156>>2];L[c+72>>2]=L[a+160>>2];L[c+76>>2]=L[a+164>>2];L[c+80>>2]=L[a+136>>2];ha[L[L[b>>2]+20>>2]](b,d,3661,1145853764,c);Lk(a,b);jh(a,b);ha[L[L[b>>2]+36>>2]](b)}function Fa(a){var b=S(0),c=0,d=0,e=0,f=0;c=fa-16|0;fa=c;e=(E(a),x(2));d=e&2147483647;a:{if(d>>>0<=1061752794){b=S(1);if(d>>>0<964689920){break a}b=bb(+a);break a}if(d>>>0<=1081824209){if(d>>>0>=1075235812){b=S(-bb(((e|0)<0?3.141592653589793:-3.141592653589793)+ +a));break a}f=+a;if((e|0)<0){b=ab(f+1.5707963267948966);break a}b=ab(1.5707963267948966-f);break a}if(d>>>0<=1088565717){if(d>>>0>=1085271520){b=bb(((e|0)<0?6.283185307179586:-6.283185307179586)+ +a);break a}if((e|0)<0){b=ab(-4.71238898038469-+a);break a}b=ab(+a+-4.71238898038469);break a}b=S(a-a);if(d>>>0>=2139095040){break a}b:{switch(Sj(a,c+8|0)&3){case 0:b=bb(Q[c+8>>3]);break a;case 1:b=ab(-Q[c+8>>3]);break a;case 2:b=S(-bb(Q[c+8>>3]));break a;default:break b}}b=ab(Q[c+8>>3])}a=b;fa=c+16|0;return a}function WC(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0;c=L[a+12>>2];if(c){d=L[b+4>>2];a:{if((d|0)!=L[b+8>>2]){break a}h=d?d<<1:1;if((h|0)<=(d|0)){break a}if(h){L[8513]=L[8513]+1;f=ha[L[6798]](h<<2,16)|0;d=L[b+4>>2]}b:{if((d|0)<=0){break b}c=0;if(d>>>0>=4){i=d&-4;while(1){e=c<<2;L[e+f>>2]=L[e+L[b+12>>2]>>2];g=e|4;L[g+f>>2]=L[g+L[b+12>>2]>>2];g=e|8;L[g+f>>2]=L[g+L[b+12>>2]>>2];e=e|12;L[e+f>>2]=L[e+L[b+12>>2]>>2];c=c+4|0;j=j+4|0;if((i|0)!=(j|0)){continue}break}}e=d&3;if(!e){break b}while(1){i=c<<2;L[i+f>>2]=L[i+L[b+12>>2]>>2];c=c+1|0;k=k+1|0;if((e|0)!=(k|0)){continue}break}}c=L[b+12>>2];if(!(!c|!M[b+16|0])){if(c){L[8514]=L[8514]+1;ha[L[6799]](c)}d=L[b+4>>2]}L[b+12>>2]=f;J[b+16|0]=1;L[b+8>>2]=h;c=L[a+12>>2]}L[L[b+12>>2]+(d<<2)>>2]=c;L[b+4>>2]=d+1}}function QG(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0;c=L[a+76>>2];if(c){d=L[b+4>>2];a:{if((d|0)!=L[b+8>>2]){break a}h=d?d<<1:1;if((h|0)<=(d|0)){break a}if(h){L[8513]=L[8513]+1;f=ha[L[6798]](h<<2,16)|0;d=L[b+4>>2]}b:{if((d|0)<=0){break b}c=0;if(d>>>0>=4){i=d&-4;while(1){e=c<<2;L[e+f>>2]=L[e+L[b+12>>2]>>2];g=e|4;L[g+f>>2]=L[g+L[b+12>>2]>>2];g=e|8;L[g+f>>2]=L[g+L[b+12>>2]>>2];e=e|12;L[e+f>>2]=L[e+L[b+12>>2]>>2];c=c+4|0;j=j+4|0;if((i|0)!=(j|0)){continue}break}}e=d&3;if(!e){break b}while(1){i=c<<2;L[i+f>>2]=L[i+L[b+12>>2]>>2];c=c+1|0;k=k+1|0;if((e|0)!=(k|0)){continue}break}}c=L[b+12>>2];if(!(!c|!M[b+16|0])){if(c){L[8514]=L[8514]+1;ha[L[6799]](c)}d=L[b+4>>2]}L[b+12>>2]=f;J[b+16|0]=1;L[b+8>>2]=h;c=L[a+76>>2]}L[L[b+12>>2]+(d<<2)>>2]=c;L[b+4>>2]=d+1}}function rt(a,b){a=a|0;b=b|0;var c=S(0),d=S(0),e=0,f=S(0),g=S(0),h=S(0),i=S(0),j=S(0),k=S(0),l=S(0),m=S(0),n=S(0),o=S(0),p=S(0),q=S(0),r=0;e=fa-16|0;fa=e;L[e+12>>2]=a;L[e+8>>2]=b;b=L[e+8>>2];a=fa-48|0;fa=a;r=L[e+12>>2];Ma(r+364|0,a+16|0);c=P[b+4>>2];d=P[b+8>>2];f=P[b>>2];g=P[b+12>>2];h=P[a+24>>2];i=P[a+20>>2];j=P[a+28>>2];k=P[a+16>>2];Ma(r+300|0,a);l=S(S(h*d)+S(S(i*c)+S(S(j*g)+S(k*f))));m=P[a+12>>2];n=P[a>>2];o=S(S(h*c)+S(S(S(j*f)-S(g*k))-S(i*d)));p=S(S(k*d)+S(S(S(j*c)-S(g*i))-S(h*f)));q=P[a+4>>2];c=S(S(i*f)+S(S(S(j*d)-S(g*h))-S(k*c)));d=P[a+8>>2];P[a+44>>2]=S(S(S(l*m)-S(n*o))-S(p*q))-S(c*d);P[a+40>>2]=S(S(o*q)+S(S(l*d)+S(c*m)))-S(p*n);P[a+36>>2]=S(S(c*n)+S(S(l*q)+S(p*m)))-S(o*d);P[a+32>>2]=S(S(p*d)+S(S(l*n)+S(o*m)))-S(c*q);ol(r,a+32|0);fa=a+48|0;fa=e+16|0}function Jd(a,b,c){var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;c=L[((b<<2)+a|0)+68>>2]+(c<<2)|0;e=c-4|0;d=N[e>>1];if(d>>>0>N[c>>1]){i=b<<1;g=L[a+60>>2]+(N[c+2>>1]<<6)|0;f=g+48|0;l=i+f|0;b=1<>2]+(N[c-2>>1]<<6)|0;a:{if(d&1){d=b+j|0;b:{if(N[n>>1]>1]|N[d+54>>1]>1]){break b}d=b+k|0;if(N[h>>1]>1]|N[d+54>>1]>1]){break b}d=L[a+92>>2];ha[L[L[d>>2]+8>>2]](d,g,b)|0;d=L[a+96>>2];if(!d){break b}ha[L[L[d>>2]+8>>2]](d,g,b)|0}b=(b+i|0)+54|0;break a}b=(b+i|0)+48|0}K[b>>1]=N[b>>1]+1;K[l>>1]=N[l>>1]-1;b=N[c>>1]|N[c+2>>1]<<16;d=N[e>>1]|N[e+2>>1]<<16;K[c>>1]=d;K[c+2>>1]=d>>>16;K[e>>1]=b;K[e+2>>1]=b>>>16;e=e-4|0;d=N[e>>1];c=c-4|0;if(d>>>0>N[c>>1]){continue}break}}}function Cz(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,f=0,g=S(0),h=S(0),i=S(0),j=S(0),k=S(0),l=0,m=S(0),n=0,o=0,p=0;d=L[b+52>>2];f=L[d+32>>2];b=L[f>>2];d=L[d+24>>2];if((d|0)>=2){h=P[c+8>>2];i=P[c>>2];j=P[c+4>>2];k=S(S(h*P[b+16>>2])+S(S(i*P[b+8>>2])+S(j*P[b+12>>2])));b=1;c=d-1|0;o=c&1;a:{if((d|0)==2){c=0;break a}p=c&-2;c=0;while(1){d=L[(b<<2)+f>>2];g=S(S(h*P[d+16>>2])+S(S(i*P[d+8>>2])+S(j*P[d+12>>2])));l=g>k;d=b+1|0;e=L[(d<<2)+f>>2];m=S(S(h*P[e+16>>2])+S(S(i*P[e+8>>2])+S(j*P[e+12>>2])));g=l?g:k;e=m>g;k=e?m:g;c=e?d:l?b:c;b=b+2|0;n=n+2|0;if((p|0)!=(n|0)){continue}break}}if(o){d=b;b=L[(b<<2)+f>>2];c=S(S(h*P[b+16>>2])+S(S(i*P[b+8>>2])+S(j*P[b+12>>2])))>k?d:c}b=L[(c<<2)+f>>2]}c=L[b+12>>2];L[a>>2]=L[b+8>>2];L[a+4>>2]=c;c=L[b+20>>2];L[a+8>>2]=L[b+16>>2];L[a+12>>2]=c}function Ea(a){var b=0,c=0,d=0,e=0;b=fa-16|0;fa=b;e=(E(a),x(2));c=e&2147483647;a:{if(c>>>0<=1061752794){if(c>>>0<964689920){break a}a=ab(+a);break a}if(c>>>0<=1081824209){d=+a;if(c>>>0<=1075235811){if((e|0)<0){a=S(-bb(d+1.5707963267948966));break a}a=bb(d+-1.5707963267948966);break a}a=ab(-(((e|0)>=0?-3.141592653589793:3.141592653589793)+d));break a}if(c>>>0<=1088565717){if(c>>>0<=1085271519){d=+a;if((e|0)<0){a=bb(d+4.71238898038469);break a}a=S(-bb(d+-4.71238898038469));break a}a=ab(((e|0)<0?6.283185307179586:-6.283185307179586)+ +a);break a}if(c>>>0>=2139095040){a=S(a-a);break a}b:{switch(Sj(a,b+8|0)&3){case 0:a=ab(Q[b+8>>3]);break a;case 1:a=bb(Q[b+8>>3]);break a;case 2:a=ab(-Q[b+8>>3]);break a;default:break b}}a=S(-bb(Q[b+8>>3]))}fa=b+16|0;return a}function ng(a,b){var c=0,d=0,e=0;c=fa-144|0;fa=c;d=Cd(a);L[d>>2]=20800;J[d+500|0]=1;L[d+496>>2]=0;L[d+488>>2]=0;L[d+492>>2]=0;L[c+76>>2]=0;L[c+8>>2]=0;P[c+4>>2]=0;a=L[b+12>>2];L[c+88>>2]=L[b+8>>2];L[c+92>>2]=a;e=L[b>>2];b=L[b+4>>2];a=c;L[a+16>>2]=0;L[a+20>>2]=0;L[a+24>>2]=0;L[a+28>>2]=0;L[a+32>>2]=1065353216;L[a+36>>2]=0;L[a+40>>2]=0;L[a+44>>2]=0;L[a+48>>2]=0;L[a+52>>2]=1065353216;L[a+56>>2]=0;L[a+60>>2]=0;c=a- -64|0;L[c>>2]=0;L[c+4>>2]=0;L[a+72>>2]=0;L[a+80>>2]=e;L[a+84>>2]=b;L[a+136>>2]=1008981770;L[a+140>>2]=1008981770;L[a+128>>2]=1000593162;L[a+132>>2]=1008981770;J[a+124|0]=0;L[a+120>>2]=1065353216;L[a+112>>2]=0;L[a+116>>2]=1061997773;L[a+104>>2]=1056964608;L[a+108>>2]=0;L[a+96>>2]=0;L[a+100>>2]=0;L[a+12>>2]=1065353216;Kk(d,a+4|0);fa=a+144|0}function zA(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0;c=L[a+280>>2];a:{if((c|0)!=L[a+284>>2]){break a}h=c?c<<1:1;if((h|0)<=(c|0)){break a}if(h){L[8513]=L[8513]+1;f=ha[L[6798]](h<<2,16)|0;c=L[a+280>>2]}b:{if((c|0)<=0){break b}if(c>>>0>=4){i=c&-4;while(1){d=e<<2;L[d+f>>2]=L[d+L[a+288>>2]>>2];g=d|4;L[g+f>>2]=L[g+L[a+288>>2]>>2];g=d|8;L[g+f>>2]=L[g+L[a+288>>2]>>2];d=d|12;L[d+f>>2]=L[d+L[a+288>>2]>>2];e=e+4|0;j=j+4|0;if((i|0)!=(j|0)){continue}break}}d=c&3;if(!d){break b}while(1){i=e<<2;L[i+f>>2]=L[i+L[a+288>>2]>>2];e=e+1|0;k=k+1|0;if((d|0)!=(k|0)){continue}break}}e=L[a+288>>2];if(!(!e|!M[a+292|0])){if(e){L[8514]=L[8514]+1;ha[L[6799]](e)}c=L[a+280>>2]}L[a+288>>2]=f;J[a+292|0]=1;L[a+284>>2]=h}L[L[a+288>>2]+(c<<2)>>2]=b;L[a+280>>2]=c+1}function _v(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=0;f=fa-32|0;fa=f;L[f+28>>2]=a;L[f+24>>2]=b;L[f+20>>2]=c;L[f+16>>2]=d;L[f+12>>2]=e;a=L[f+24>>2];c=L[f+20>>2];d=L[f+16>>2];e=L[f+12>>2];b=fa-32|0;fa=b;L[b+28>>2]=L[f+28>>2];L[b+24>>2]=a;L[b+20>>2]=c;L[b+16>>2]=d;L[b+12>>2]=e;c=L[b+24>>2];d=L[c+4>>2];a=L[b+28>>2];L[a+96>>2]=L[c>>2];L[a+100>>2]=d;d=L[c+12>>2];L[a+104>>2]=L[c+8>>2];L[a+108>>2]=d;c=L[b+20>>2];d=L[c+4>>2];L[a+112>>2]=L[c>>2];L[a+116>>2]=d;d=L[c+12>>2];L[a+120>>2]=L[c+8>>2];L[a+124>>2]=d;c=L[b+16>>2];d=L[c+4>>2];L[a+128>>2]=L[c>>2];L[a+132>>2]=d;d=L[c+12>>2];L[a+136>>2]=L[c+8>>2];L[a+140>>2]=d;c=L[b+12>>2];d=L[c+4>>2];L[a+144>>2]=L[c>>2];L[a+148>>2]=d;d=L[c+12>>2];L[a+152>>2]=L[c+8>>2];L[a+156>>2]=d;Sb(a);fa=b+32|0;fa=f+32|0}function mo(a,b,c){a=a|0;b=b|0;c=S(c);var d=0,e=0,f=0;d=fa-128|0;fa=d;L[d+120>>2]=a;L[d+116>>2]=b;P[d+112>>2]=c;a=L[d+120>>2];b=d+96|0;L[(fa-16|0)+12>>2]=b;gf(a,b);P[d+92>>2]=Sa(L[d+116>>2],b);P[d+88>>2]=Sa(a+56|0,b);P[d+92>>2]=P[d+92>>2]-P[d+88>>2];a:{if(!(!(P[d+92>>2]>=S(-P[d+112>>2]))|!(P[d+92>>2]<=P[d+112>>2]))){L[d+84>>2]=0;while(1){if(L[d+84>>2]<3){e=fa-16|0;b=d+68|0;L[e+12>>2]=b;f=e;e=d+52|0;L[f+12>>2]=e;ha[L[L[a>>2]+104>>2]](a,L[d+84>>2],b,e);f=d+36|0;La(f,e,b);e=d+20|0;Ub(e,f,d+96|0);Nd(e);P[d+16>>2]=Sa(L[d+116>>2],e);P[d+12>>2]=Sa(b,e);P[d+16>>2]=P[d+16>>2]-P[d+12>>2];if(P[d+16>>2]>2])){J[d+127|0]=0;break a}else{L[d+84>>2]=L[d+84>>2]+1;continue}}break}J[d+127|0]=1;break a}J[d+127|0]=0}fa=d+128|0;return J[d+127|0]&1}function kg(a,b){var c=0,d=0,e=0,f=0;c=L[L[a+1120>>2]+(b<<2)>>2];b=L[c+348>>2];if(b){fc(a+1048|0,b)}b=L[c+52>>2];if(!(b?!b|!M[c+56|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[c+52>>2]=0;J[c+56|0]=1;L[c+44>>2]=0;L[c+48>>2]=0;b=L[c+32>>2];if(!(b?!b|!M[c+36|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[c+32>>2]=0;J[c+36|0]=1;L[c+24>>2]=0;L[c+28>>2]=0;b=L[c+12>>2];if(!(b?!b|!M[c+16|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}b=0;L[c+12>>2]=0;J[c+16|0]=1;L[c+4>>2]=0;L[c+8>>2]=0;if(c){L[8514]=L[8514]+1;ha[L[6799]](c)}d=L[a+1112>>2];a:{if((d|0)<=0){break a}e=L[a+1120>>2];while(1){f=(b<<2)+e|0;if(L[f>>2]!=(c|0)){b=b+1|0;if((d|0)!=(b|0)){continue}break a}break}if((b|0)>=(d|0)){break a}b=d-1|0;d=b<<2;L[f>>2]=L[d+e>>2];L[d+L[a+1120>>2]>>2]=c;L[a+1112>>2]=b}}function oy(a){a=a|0;var b=0,c=0,d=0,e=0,f=0;b=fa-32|0;fa=b;L[b+28>>2]=a;if(!M[29664]){Ka(29648);J[29664]=1}e=fa-16|0;fa=e;L[e+12>>2]=L[b+28>>2];a=L[e+12>>2];P[e+8>>2]=Sf(a);c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=e+8;f=L[c+12>>2];P[c+4>>2]=S(1)/P[L[c+8>>2]>>2];a=fa-32|0;fa=a;L[a+28>>2]=f;L[a+24>>2]=c+4;d=fa-16|0;f=L[a+28>>2];L[d+12>>2]=f;P[a+20>>2]=P[L[d+12>>2]>>2]*P[L[a+24>>2]>>2];d=fa-16|0;L[d+12>>2]=f;P[a+16>>2]=P[L[d+12>>2]+4>>2]*P[L[a+24>>2]>>2];d=fa-16|0;L[d+12>>2]=f;P[a+12>>2]=P[L[d+12>>2]+8>>2]*P[L[a+24>>2]>>2];P[a+8>>2]=P[f+12>>2]*P[L[a+24>>2]>>2];ie(b+12|0,a+20|0,a+16|0,a+12|0,a+8|0);fa=a+32|0;fa=c+16|0;fa=e+16|0;a=L[b+16>>2];L[7412]=L[b+12>>2];L[7413]=a;a=L[b+24>>2];L[7414]=L[b+20>>2];L[7415]=a;fa=b+32|0;return 29648}function ZE(a,b,c){a=a|0;b=S(b);c=c|0;var d=0,e=S(0),f=S(0),g=S(0),h=0,i=S(0),j=S(0),k=S(0),l=S(0);d=fa-96|0;fa=d;L[d+44>>2]=0;L[d+48>>2]=0;L[d+56>>2]=0;L[d+60>>2]=0;L[d+52>>2]=1065353216;h=d- -64|0;L[h>>2]=0;L[h+4>>2]=0;L[d+76>>2]=0;L[d+80>>2]=0;L[d+72>>2]=1065353216;L[d+84>>2]=0;L[d+88>>2]=0;L[d+92>>2]=0;L[d+36>>2]=0;L[d+40>>2]=0;L[d+32>>2]=1065353216;ha[L[L[a>>2]+8>>2]](a,d+32|0,d+16|0,d);i=P[d+24>>2];j=P[d+8>>2];f=P[d+16>>2];g=P[d>>2];k=P[d+20>>2];l=P[d+4>>2];e=S(ha[L[L[a>>2]+48>>2]](a));L[c+12>>2]=0;b=S(b*S(.0833333283662796));f=S(e+S(S(g-f)*S(.5)));f=S(f+f);f=S(f*f);g=S(e+S(S(l-k)*S(.5)));g=S(g+g);g=S(g*g);P[c+8>>2]=b*S(f+g);e=S(e+S(S(j-i)*S(.5)));e=S(e+e);e=S(e*e);P[c+4>>2]=b*S(f+e);P[c>>2]=b*S(g+e);fa=d+96|0}function JD(a,b,c){a=a|0;b=S(b);c=c|0;var d=0,e=S(0),f=S(0),g=S(0),h=0,i=S(0),j=S(0),k=S(0),l=S(0);d=fa-96|0;fa=d;e=S(ha[L[L[a>>2]+48>>2]](a));L[d+44>>2]=0;L[d+48>>2]=0;L[d+56>>2]=0;L[d+60>>2]=0;L[d+52>>2]=1065353216;h=d- -64|0;L[h>>2]=0;L[h+4>>2]=0;L[d+76>>2]=0;L[d+80>>2]=0;L[d+72>>2]=1065353216;L[d+84>>2]=0;L[d+88>>2]=0;L[d+92>>2]=0;L[d+36>>2]=0;L[d+40>>2]=0;L[d+32>>2]=1065353216;ha[L[L[a>>2]+8>>2]](a,d+32|0,d+16|0,d);i=P[d+24>>2];j=P[d+8>>2];f=P[d+16>>2];g=P[d>>2];k=P[d+20>>2];l=P[d+4>>2];L[c+12>>2]=0;b=S(b*S(.0833333283662796));f=S(e+S(S(g-f)*S(.5)));f=S(f+f);f=S(f*f);g=S(e+S(S(l-k)*S(.5)));g=S(g+g);g=S(g*g);P[c+8>>2]=b*S(f+g);e=S(e+S(S(j-i)*S(.5)));e=S(e+e);e=S(e*e);P[c+4>>2]=b*S(f+e);P[c>>2]=b*S(g+e);fa=d+96|0}function bF(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=S(0),f=0,g=0,h=0,i=S(0),j=0,k=S(0),l=0,m=S(0),n=0,o=0,p=S(0);if((d|0)>0){f=fa-16|0;while(1){i=S(P[a+60>>2]*S(.5));j=L[a+64>>2];o=l<<4;g=o+b|0;e=P[g+8>>2];h=L[a+68>>2]<<2;m=S(e*e);e=P[g>>2];k=S(e*e);e=P[g+4>>2];a:{b:{if(P[g+h>>2]>S(P[a+52>>2]*S(_(S(m+S(k+S(e*e))))))){L[(j<<2)+f>>2]=0;P[f+h>>2]=i;j=L[a+72>>2];break b}n=j<<2;e=P[g+n>>2];j=L[a+72>>2];k=P[g+(j<<2)>>2];p=S(_(S(S(e*e)+S(k*k))));if(p>S(1.1920928955078125e-7)){m=e;e=S(P[a+56>>2]/p);P[f+n>>2]=m*e;P[f+h>>2]=-i;i=S(k*e);break a}L[f+n>>2]=0;P[f+h>>2]=-i}i=S(0)}P[(j<<2)+f>>2]=i;h=L[f+12>>2];g=c+o|0;L[g+8>>2]=L[f+8>>2];L[g+12>>2]=h;h=L[f+4>>2];L[g>>2]=L[f>>2];L[g+4>>2]=h;l=l+1|0;if((l|0)!=(d|0)){continue}break}}}function zc(a,b,c){var d=S(0),e=S(0),f=S(0),g=S(0),h=0,i=S(0),j=S(0),k=S(0),l=S(0),m=S(0),n=S(0),o=S(0),p=S(0),q=S(0),r=S(0),s=S(0),t=S(0);h=L[a+4>>2];if(h){rb(h,b,c)}a=L[a>>2];if(a){l=P[a+220>>2];m=P[a+212>>2];n=P[a+216>>2];o=P[a+204>>2];p=P[a+196>>2];q=P[a+200>>2];r=P[a+188>>2];s=P[a+184>>2];t=P[a+180>>2];i=P[c+4>>2];j=P[c+8>>2];k=P[c>>2];d=P[b+8>>2];e=P[b+4>>2];g=P[b>>2];f=P[a+128>>2];P[a+276>>2]=S(g*f)+P[a+276>>2];P[a+280>>2]=S(f*e)+P[a+280>>2];P[a+284>>2]=S(f*d)+P[a+284>>2];L[a+312>>2]=L[a+312>>2]+1;f=S(S(k*e)-S(g*i));e=S(S(i*d)-S(e*j));d=S(S(j*g)-S(d*k));P[a+292>>2]=S(S(r*f)+S(S(t*e)+S(s*d)))+P[a+292>>2];P[a+296>>2]=S(S(o*f)+S(S(p*e)+S(d*q)))+P[a+296>>2];P[a+300>>2]=S(S(l*f)+S(S(m*e)+S(d*n)))+P[a+300>>2]}}function Fw(a){a=a|0;var b=0,c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;a=L[c+12>>2];if(a){b=L[a+32>>2];if(!(b?!b|!M[a+36|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+32>>2]=0;J[a+36|0]=1;L[a+24>>2]=0;L[a+28>>2]=0;a:{b:{b=L[a+12>>2];c:{if(!(M[a+16|0]?b:0)){L[a+4>>2]=0;L[a+8>>2]=0;J[a+16|0]=1;break c}if(b){L[8514]=L[8514]+1;ha[L[6799]](b)}J[a+16|0]=1;L[a+12>>2]=0;L[a+4>>2]=0;L[a+8>>2]=0;b=L[a+32>>2];if(!b){break c}if(M[a+36|0]){break b}}L[a+32>>2]=0;J[a+36|0]=1;L[a+24>>2]=0;L[a+28>>2]=0;break a}if(b){L[8514]=L[8514]+1;ha[L[6799]](b)}J[a+36|0]=1;L[a+32>>2]=0;L[a+24>>2]=0;L[a+28>>2]=0;b=L[a+12>>2];if(!b|!M[a+16|0]){break a}if(b){L[8514]=L[8514]+1;ha[L[6799]](b)}}L[a+12>>2]=0;J[a+16|0]=1;L[a+4>>2]=0;L[a+8>>2]=0;Fc(a)}fa=c+16|0}function MC(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0,g=0,h=0,i=0;e=fa-128|0;fa=e;ha[L[L[a>>2]+112>>2]](a);f=L[c+12>>2];L[e+104>>2]=L[c+8>>2];L[e+108>>2]=f;f=L[c+4>>2];L[e+96>>2]=L[c>>2];L[e+100>>2]=f;c=L[d+12>>2];L[e+120>>2]=L[d+8>>2];L[e+124>>2]=c;c=L[d+4>>2];L[e+112>>2]=L[d>>2];L[e+116>>2]=c;L[e+88>>2]=0;J[e+92|0]=1;L[e+80>>2]=0;L[e+84>>2]=0;Sl(a+68|0,e+96|0,e+76|0);c=L[e+80>>2];if(c){d=L[a+172>>2];L[e+68>>2]=1008981770;while(1){c=c-1|0;f=c<<2;g=L[f+L[e+88>>2]>>2];h=ha[L[L[a>>2]+84>>2]](a)|0;i=g;g=e+4|0;ha[L[L[h>>2]+20>>2]](h,i,g);ha[L[L[b>>2]+8>>2]](b,g,d,L[L[e+88>>2]+f>>2]);if(c){continue}break}}ha[L[L[a>>2]+116>>2]](a);a=L[e+88>>2];if(!(a?!a|!M[e+92|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](a)}fa=e+128|0}function xm(a,b,c,d,e,f){var g=S(0),h=S(0),i=S(0),j=S(0),k=S(0),l=S(0),m=S(0),n=S(0),o=S(0),p=S(0),q=S(0),r=S(0),s=S(0);ha[L[L[a>>2]+8>>2]](a,b,e,f);g=P[d+8>>2];k=P[d>>2];l=P[d+4>>2];m=P[f>>2];n=P[f+4>>2];o=P[f+8>>2];p=P[e>>2];h=P[c>>2];q=P[e+4>>2];i=P[c+4>>2];r=P[e+8>>2];j=P[c+8>>2];s=S(ha[L[L[a>>2]+16>>2]](a));L[e+12>>2]=0;j=S(j*S(1));a=j>S(0);P[e+8>>2]=r+(a?S(-0):j);i=S(i*S(1));b=i>S(0);P[e+4>>2]=q+(b?S(-0):i);h=S(h*S(1));c=h>S(0);P[e>>2]=p+(c?S(-0):h);L[f+12>>2]=0;P[f+8>>2]=o+(a?j:S(-0));P[f+4>>2]=n+(b?i:S(-0));P[f>>2]=m+(c?h:S(-0));g=S(S(s*S(_(S(S(g*g)+S(S(k*k)+S(l*l))))))*S(1));P[e>>2]=P[e>>2]-g;P[e+4>>2]=P[e+4>>2]-g;P[e+8>>2]=P[e+8>>2]-g;P[f>>2]=g+P[f>>2];P[f+4>>2]=g+P[f+4>>2];P[f+8>>2]=g+P[f+8>>2]}function iy(a,b){a=a|0;b=b|0;var c=S(0),d=0,e=0,f=0;d=fa-16|0;fa=d;L[d+12>>2]=a;L[d+8>>2]=b;b=L[d+8>>2];a=fa-32|0;fa=a;L[a+24>>2]=L[d+12>>2];L[a+20>>2]=b;f=L[a+24>>2];c=S($b(f)*$b(L[a+20>>2]));b=fa-16|0;P[b+12>>2]=c;P[a+16>>2]=_(P[b+12>>2]);a:{if(_b(f,L[a+20>>2])>2]=L[a+20>>2];L[b+24>>2]=L[b+28>>2];e=fa-16|0;L[e+12>>2]=L[b+24>>2];P[b+20>>2]=-P[L[e+12>>2]>>2];L[e+12>>2]=L[b+24>>2];P[b+16>>2]=-P[L[e+12>>2]+4>>2];L[e+12>>2]=L[b+24>>2];P[b+12>>2]=-P[L[e+12>>2]+8>>2];P[b+8>>2]=-P[L[b+24>>2]+12>>2];ie(a,b+20|0,b+16|0,b+12|0,b+8|0);fa=b+32|0;c=uc(S(_b(f,a)/P[a+16>>2]));P[a+28>>2]=c+c;break a}c=uc(S(_b(f,L[a+20>>2])/P[a+16>>2]));P[a+28>>2]=c+c}fa=a+32|0;fa=d+16|0;return S(P[a+28>>2])}function EE(a,b){a=a|0;b=b|0;var c=S(0),d=0,e=S(0),f=S(0);d=fa-96|0;fa=d;c=P[b>>2];e=P[b+4>>2];f=P[b+8>>2];J[a+84|0]=1;L[a+24>>2]=0;P[a+20>>2]=T(f);P[a+16>>2]=T(e);P[a+12>>2]=T(c);if(!M[30304]){L[7553]=0;L[7554]=0;L[7552]=1065353216;L[7555]=0;L[7556]=0;L[7558]=0;L[7559]=0;L[7557]=1065353216;L[7560]=0;L[7561]=0;L[7565]=0;L[7566]=0;L[7564]=-1082130432;L[7562]=1065353216;L[7563]=0;L[7567]=0;L[7568]=0;L[7570]=0;L[7571]=0;L[7569]=-1082130432;L[7572]=0;L[7573]=0;L[7574]=-1082130432;L[7575]=0;J[30304]=1}b=pa(d,0,96);ha[L[L[a>>2]+76>>2]](a,30208,b,6);c=P[a+44>>2];P[a+68>>2]=c+P[b>>2];P[a+52>>2]=P[b+48>>2]-c;P[a+72>>2]=c+P[b+20>>2];P[a+56>>2]=P[b+68>>2]-c;P[a+76>>2]=c+P[b+40>>2];P[a+60>>2]=P[b+88>>2]-c;fa=b+96|0}function pa(a,b,c){var d=0,e=0,f=0,g=0;a:{if(!c){break a}J[a|0]=b;d=a+c|0;J[d-1|0]=b;if(c>>>0<3){break a}J[a+2|0]=b;J[a+1|0]=b;J[d-3|0]=b;J[d-2|0]=b;if(c>>>0<7){break a}J[a+3|0]=b;J[d-4|0]=b;if(c>>>0<9){break a}d=0-a&3;e=d+a|0;b=R(b&255,16843009);L[e>>2]=b;d=c-d&-4;c=d+e|0;L[c-4>>2]=b;if(d>>>0<9){break a}L[e+8>>2]=b;L[e+4>>2]=b;L[c-8>>2]=b;L[c-12>>2]=b;if(d>>>0<25){break a}L[e+24>>2]=b;L[e+20>>2]=b;L[e+16>>2]=b;L[e+12>>2]=b;L[c-16>>2]=b;L[c-20>>2]=b;L[c-24>>2]=b;L[c-28>>2]=b;g=e&4|24;c=d-g|0;if(c>>>0<32){break a}d=mI(b,0,1,1);f=ga;b=e+g|0;while(1){L[b+24>>2]=d;L[b+28>>2]=f;L[b+16>>2]=d;L[b+20>>2]=f;L[b+8>>2]=d;L[b+12>>2]=f;L[b>>2]=d;L[b+4>>2]=f;b=b+32|0;c=c-32|0;if(c>>>0>31){continue}break}}return a}function fH(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0,g=0;c=fa-96|0;fa=c;b=L[b>>2];a:{if((b|0)==L[a+4>>2]){break a}d=L[a+12>>2];if(!(ha[L[L[d>>2]+8>>2]](d,L[b+188>>2])|0)){break a}d=L[a+4>>2];e=L[d+192>>2];L[c+88>>2]=-1;L[c+92>>2]=-1;L[c+84>>2]=d+4;L[c+80>>2]=d;L[c+76>>2]=e;L[c+72>>2]=0;d=L[b+192>>2];L[c+64>>2]=-1;L[c+68>>2]=-1;L[c+60>>2]=b+4;L[c+56>>2]=b;L[c+52>>2]=d;L[c+48>>2]=0;b=L[L[a+8>>2]+24>>2];d=ha[L[L[b>>2]+8>>2]](b,c+72|0,c+48|0,0)|0;if(!d){break a}e=L[a+12>>2];b=c+12|0;f=c+48|0;L[b+12>>2]=f;g=c+72|0;L[b+8>>2]=g;L[b+4>>2]=0;L[b>>2]=11584;L[b+32>>2]=e;L[b>>2]=8520;ha[L[L[d>>2]+8>>2]](d,g,f,L[a+8>>2]+28|0,b);ha[L[L[d>>2]>>2]](d)|0;a=L[L[a+8>>2]+24>>2];ha[L[L[a>>2]+60>>2]](a,d)}fa=c+96|0;return 1}function ok(a,b){var c=0,d=0,e=S(0),f=S(0),g=0;c=fa-32|0;fa=c;d=L[b+388>>2];g=(d&L[a+388>>2]&48)-16|0;a:{if(g){if((g|0)!=16){break a}if(!(d&64)&(a|0)==(b|0)){break a}L[c+20>>2]=0;L[c+4>>2]=1065353216;L[c>>2]=21776;P[c+8>>2]=P[a+456>>2];d=L[a+192>>2];e=S(ha[L[L[d>>2]+48>>2]](d));d=L[b+192>>2];P[c+12>>2]=e+S(ha[L[L[d>>2]+48>>2]](d));e=P[b+316>>2];f=P[a+316>>2];L[c+28>>2]=b;L[c+24>>2]=a;P[c+16>>2]=e>f?f:e;gg(L[a+1048>>2],L[b+1048>>2],c);break a}if((a|0)==(b|0)){break a}L[c>>2]=21860;d=L[a+192>>2];e=S(ha[L[L[d>>2]+48>>2]](d));d=L[b+192>>2];f=S(ha[L[L[d>>2]+48>>2]](d));L[c+8>>2]=b;L[c+4>>2]=a;P[c+12>>2]=e+f;gg(L[a+928>>2],L[b+988>>2],c);L[c+8>>2]=a;L[c+4>>2]=b;gg(L[b+928>>2],L[a+988>>2],c)}fa=c+32|0}function Ht(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=0;f=fa-32|0;fa=f;L[f+28>>2]=a;L[f+24>>2]=b;L[f+20>>2]=c;L[f+16>>2]=d;J[f+15|0]=e;c=oa(1388);a=ml(c,L[f+28>>2],L[f+24>>2],L[f+20>>2],L[f+16>>2],J[f+15|0]&1);L[a+4>>2]=9;L[a>>2]=19664;L[a+1364>>2]=1065353216;L[a+1368>>2]=1065353216;b=a+1309|0;J[b|0]=0;J[b+1|0]=0;J[b+2|0]=0;J[b+3|0]=0;b=a+1313|0;J[b|0]=0;J[b+1|0]=0;b=a+1316|0;L[b>>2]=0;L[b+4>>2]=0;b=a+1324|0;L[b>>2]=0;L[b+4>>2]=0;b=a+1332|0;L[b>>2]=0;L[b+4>>2]=0;b=a+1340|0;L[b>>2]=0;L[b+4>>2]=0;b=a+1348|0;L[b>>2]=0;L[b+4>>2]=0;b=a+1356|0;L[b>>2]=0;L[b+4>>2]=0;b=a+1380|0;L[b>>2]=1065353216;L[b+4>>2]=1065353216;a=a+1372|0;L[a>>2]=1065353216;L[a+4>>2]=1065353216;fa=f+32|0;return c|0}function Wg(a){a=a|0;var b=0;L[a>>2]=12192;b=L[a+160>>2];if(!(b?!b|!M[a+164|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+160>>2]=0;J[a+164|0]=1;L[a+152>>2]=0;L[a+156>>2]=0;b=L[a+136>>2];if(!(b?!b|!M[a+140|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+136>>2]=0;J[a+140|0]=1;L[a+128>>2]=0;L[a+132>>2]=0;b=L[a+116>>2];if(!(b?!b|!M[a+120|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+116>>2]=0;J[a+120|0]=1;L[a+108>>2]=0;L[a+112>>2]=0;b=L[a+96>>2];if(!(b?!b|!M[a+100|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+96>>2]=0;J[a+100|0]=1;L[a+88>>2]=0;L[a+92>>2]=0;b=L[a+76>>2];if(!(b?!b|!M[a+80|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+76>>2]=0;J[a+80|0]=1;L[a+68>>2]=0;L[a+72>>2]=0;return a|0}function Nz(a,b,c){a=a|0;b=S(b);c=S(c);var d=0,e=S(0),f=S(0),g=S(0),h=S(0),i=0,j=0,k=S(0),l=S(0),m=S(0),n=S(0),o=S(0),p=0;j=L[a+732>>2];if((j|0)>0){p=L[a+740>>2];while(1){d=R(i,52)+p|0;e=P[d+24>>2];a:{if(!(e>S(0))){break a}g=P[d+28>>2];a=L[d+12>>2];d=L[d+8>>2];k=P[d+16>>2];c=S(P[a+16>>2]-k);l=P[d+8>>2];f=S(P[a+8>>2]-l);m=P[d+12>>2];h=S(P[a+12>>2]-m);n=S(S(c*c)+S(S(f*f)+S(h*h)));o=S(g+n);if(!(o>S(1.1920928955078125e-7))){break a}g=S(S(S(g-n)/S(e*o))*b);e=S(g*P[d+88>>2]);P[d+16>>2]=k-S(c*e);P[d+12>>2]=m-S(h*e);P[d+8>>2]=l-S(f*e);e=f;f=S(g*P[a+88>>2]);P[a+8>>2]=P[a+8>>2]+S(e*f);P[a+16>>2]=S(c*f)+P[a+16>>2];P[a+12>>2]=S(h*f)+P[a+12>>2]}i=i+1|0;if((j|0)!=(i|0)){continue}break}}}function gI(a,b,c){a=a|0;b=b|0;c=c|0;var d=S(0),e=S(0),f=0,g=S(0),h=S(0),i=S(0),j=S(0),k=S(0),l=S(0);f=L[a- -64>>2];a=L[a+4>>2];a:{if(a){if(f){e=P[a+24>>2];d=P[f+24>>2];g=e>d?e:d;e=P[a+20>>2];d=P[f+20>>2];h=e>d?e:d;e=P[a+8>>2];d=P[f+8>>2];i=e>2];d=P[f+4>>2];j=e>2];d=P[f+16>>2];k=e>d?e:d;d=P[a>>2];e=P[f>>2];d=e>d?d:e;break a}l=P[a+28>>2];g=P[a+24>>2];h=P[a+20>>2];k=P[a+16>>2];e=P[a+12>>2];i=P[a+8>>2];j=P[a+4>>2];d=P[a>>2];break a}d=S(0);if(!f){break a}l=P[f+28>>2];g=P[f+24>>2];h=P[f+20>>2];k=P[f+16>>2];e=P[f+12>>2];i=P[f+8>>2];j=P[f+4>>2];d=P[f>>2]}P[b+12>>2]=e;P[b+8>>2]=i;P[b+4>>2]=j;P[b>>2]=d;P[c+12>>2]=l;P[c+8>>2]=g;P[c+4>>2]=h;P[c>>2]=k}function Cd(a){L[a+188>>2]=0;L[a+192>>2]=0;L[a+180>>2]=0;L[a+184>>2]=1566444395;L[a+164>>2]=1065353216;L[a+168>>2]=1065353216;L[a+244>>2]=1065353216;L[a+236>>2]=1;L[a+240>>2]=0;L[a+228>>2]=0;L[a+232>>2]=0;L[a+220>>2]=0;L[a+224>>2]=1056964608;L[a+212>>2]=-1;L[a+216>>2]=1;L[a+204>>2]=1;L[a+208>>2]=-1;L[a+248>>2]=0;L[a+252>>2]=0;L[a+4>>2]=1065353216;L[a+172>>2]=1065353216;L[a+176>>2]=0;L[a>>2]=6712;L[a+196>>2]=0;L[a+200>>2]=0;L[a+256>>2]=0;L[a+260>>2]=0;L[a+16>>2]=0;L[a+20>>2]=0;L[a+8>>2]=0;L[a+12>>2]=0;L[a+28>>2]=0;L[a+32>>2]=0;L[a+24>>2]=1065353216;L[a+36>>2]=0;L[a+40>>2]=0;L[a+48>>2]=0;L[a+52>>2]=0;L[a+44>>2]=1065353216;L[a+56>>2]=0;L[a+60>>2]=0;L[a- -64>>2]=0;return a}function Lk(a,b){var c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0;d=L[a+8>>2];if((d|0)>0){while(1){c=L[L[a+16>>2]+(e<<2)>>2];if(M[c+236|0]&2){d=(g=b,h=ha[L[L[c>>2]+16>>2]](c)|0,i=1,f=L[L[b>>2]+16>>2],ha[f](g|0,h|0,i|0)|0);i=b,h=d,g=ha[L[L[c>>2]+20>>2]](c,L[d+8>>2],b)|0,j=1497645650,k=c,f=L[L[b>>2]+20>>2],ha[f](i|0,h|0,g|0,j|0,k|0);d=L[a+8>>2]}e=e+1|0;if((d|0)>(e|0)){continue}break}}if(L[a+212>>2]>0){e=0;while(1){c=L[L[a+220>>2]+(e<<2)>>2];d=(k=b,j=ha[L[L[c>>2]+36>>2]](c)|0,g=1,f=L[L[b>>2]+16>>2],ha[f](k|0,j|0,g|0)|0);g=b,j=d,k=ha[L[L[c>>2]+40>>2]](c,L[d+8>>2],b)|0,h=1397641027,i=c,f=L[L[b>>2]+20>>2],ha[f](g|0,j|0,k|0,h|0,i|0);e=e+1|0;if((e|0)>2]){continue}break}}}function Dk(a){a=a|0;var b=0;L[a>>2]=20864;b=L[a+144>>2];if(!(b?!b|!M[a+148|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+144>>2]=0;J[a+148|0]=1;L[a+136>>2]=0;L[a+140>>2]=0;b=L[a+76>>2];if(!(b?!b|!M[a+80|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+76>>2]=0;J[a+80|0]=1;L[a+68>>2]=0;L[a+72>>2]=0;b=L[a+56>>2];if(!(b?!b|!M[a+60|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+56>>2]=0;J[a+60|0]=1;L[a+48>>2]=0;L[a+52>>2]=0;b=L[a+36>>2];if(!(b?!b|!M[a+40|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+36>>2]=0;J[a+40|0]=1;L[a+28>>2]=0;L[a+32>>2]=0;b=L[a+16>>2];if(!(b?!b|!M[a+20|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+16>>2]=0;J[a+20|0]=1;L[a+8>>2]=0;L[a+12>>2]=0;return a|0}function jv(){var a=0;a=oa(772);L[a>>2]=1025;L[a+124>>2]=0;L[a+128>>2]=0;J[a+120|0]=0;L[a+116>>2]=0;L[a+132>>2]=0;L[a+136>>2]=0;L[a+140>>2]=0;L[a+144>>2]=0;L[a+148>>2]=0;L[a+152>>2]=0;L[a+308>>2]=0;L[a+312>>2]=0;J[a+304|0]=0;L[a+300>>2]=0;L[a+316>>2]=0;L[a+320>>2]=0;L[a+324>>2]=0;L[a+328>>2]=0;L[a+332>>2]=0;L[a+336>>2]=0;L[a+492>>2]=0;L[a+496>>2]=0;J[a+488|0]=0;L[a+484>>2]=0;L[a+500>>2]=0;L[a+504>>2]=0;L[a+508>>2]=0;L[a+512>>2]=0;L[a+516>>2]=0;L[a+520>>2]=0;J[a+672|0]=0;L[a+668>>2]=0;L[a+676>>2]=0;L[a+680>>2]=0;L[a+684>>2]=0;L[a+688>>2]=0;L[a+692>>2]=0;L[a+696>>2]=0;L[a+700>>2]=0;L[a+704>>2]=0;L[a+748>>2]=0;L[a+768>>2]=0;L[a+740>>2]=0;L[a+744>>2]=0;return a|0}function jC(a,b,c,d,e,f,g,h,i,j){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;i=i|0;j=j|0;var k=S(0),l=S(0),m=S(0),n=S(0),o=S(0),p=S(0);a=fa-80|0;fa=a;k=P[e+52>>2];l=P[f+52>>2];m=P[e+56>>2];n=P[f+56>>2];o=P[e+48>>2];p=P[f+48>>2];L[a+76>>2]=0;P[a+64>>2]=p-o;P[a+72>>2]=n-m;P[a+68>>2]=l-k;b=Bg(c,e,d,f,a- -64|0,a+8|0,1);a:{if(!b){if(!Hl(c,e,d,f,a- -64|0,a+8|0)){break a}}c=L[a+16>>2];L[h>>2]=L[a+12>>2];L[h+4>>2]=c;c=L[a+24>>2];L[h+8>>2]=L[a+20>>2];L[h+12>>2]=c;c=L[a+40>>2];L[i+8>>2]=L[a+36>>2];L[i+12>>2]=c;c=L[a+32>>2];L[i>>2]=L[a+28>>2];L[i+4>>2]=c;c=L[a+56>>2];L[g+8>>2]=L[a+52>>2];L[g+12>>2]=c;c=L[a+48>>2];L[g>>2]=L[a+44>>2];L[g+4>>2]=c}fa=a+80|0;return b|0}function Qp(a,b){a=a|0;b=b|0;var c=S(0),d=S(0),e=S(0),f=S(0),g=S(0),h=S(0),i=0,j=S(0),k=S(0),l=S(0),m=0;i=fa-16|0;fa=i;L[i+12>>2]=a;L[i+8>>2]=b;m=L[i+12>>2];b=L[i+8>>2];a=fa+-64|0;fa=a;L[a+56>>2]=0;L[a+60>>2]=0;L[a+48>>2]=0;L[a+52>>2]=0;e=P[b+12>>2];g=P[b+8>>2];c=P[b>>2];d=P[b+4>>2];L[a+44>>2]=0;L[a+28>>2]=0;j=S(S(2)/S(S(e*e)+S(S(g*g)+S(S(c*c)+S(d*d)))));k=S(g*j);f=S(d*k);h=S(c*j);l=S(e*h);P[a+36>>2]=f+l;P[a+24>>2]=f-l;f=S(c*h);h=d;d=S(d*j);j=S(h*d);P[a+40>>2]=S(1)-S(f+j);g=S(g*k);P[a+20>>2]=S(1)-S(f+g);L[a+12>>2]=0;f=S(c*k);h=S(e*d);P[a+32>>2]=f-h;c=S(c*d);e=S(e*k);P[a+16>>2]=c+e;P[a+8>>2]=f+h;P[a+4>>2]=c-e;P[a>>2]=S(1)-S(j+g);jg(m,a);fa=a- -64|0;fa=i+16|0}function ne(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0,g=0,h=0;e=fa-16|0;fa=e;L[e+12>>2]=a;L[e+8>>2]=b;L[e+4>>2]=c;L[e>>2]=d;d=L[e+12>>2];b=L[e+4>>2];h=L[e>>2];a=fa-96|0;fa=a;c=L[e+8>>2];f=L[c+192>>2];L[a+88>>2]=-1;L[a+92>>2]=-1;L[a+84>>2]=c+4;L[a+80>>2]=c;L[a+76>>2]=f;L[a+72>>2]=0;c=L[b+192>>2];L[a+64>>2]=-1;L[a+68>>2]=-1;L[a+60>>2]=b+4;L[a+56>>2]=b;L[a+52>>2]=c;L[a+48>>2]=0;b=L[d+24>>2];c=ha[L[L[b>>2]+8>>2]](b,a+72|0,a+48|0,0)|0;if(c){b=a+12|0;f=a+48|0;L[b+12>>2]=f;g=a+72|0;L[b+8>>2]=g;L[b+4>>2]=0;L[b>>2]=11584;L[b+32>>2]=h;L[b>>2]=8520;ha[L[L[c>>2]+8>>2]](c,g,f,d+28|0,b);ha[L[L[c>>2]>>2]](c)|0;b=L[d+24>>2];ha[L[L[b>>2]+60>>2]](b,c)}fa=a+96|0;fa=e+16|0}function Lm(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=S(0),f=S(0),g=S(0),h=S(0),i=S(0),j=S(0),k=S(0),l=S(0),m=S(0),n=S(0),o=S(0),p=S(0),q=S(0),r=S(0),s=S(0),t=S(0),u=S(0);e=S(ha[L[L[a>>2]+48>>2]](a));j=P[b+52>>2];h=P[b+20>>2];m=P[b+24>>2];k=P[b+56>>2];i=P[b+36>>2];n=P[a+32>>2];f=P[b+40>>2];g=P[a+36>>2];l=P[b+48>>2];o=P[b>>2];p=P[b+4>>2];q=P[b+8>>2];r=P[b+16>>2];s=P[b+32>>2];t=P[a+28>>2];L[c+12>>2]=0;g=S(e+g);u=S(g*S(T(f)));f=S(e+t);e=S(e+n);i=S(u+S(S(f*S(T(s)))+S(e*S(T(i)))));P[c+8>>2]=k-i;h=S(S(g*S(T(m)))+S(S(f*S(T(r)))+S(e*S(T(h)))));P[c+4>>2]=j-h;e=S(S(g*S(T(q)))+S(S(f*S(T(o)))+S(e*S(T(p)))));P[c>>2]=l-e;L[d+12>>2]=0;P[d+8>>2]=k+i;P[d+4>>2]=h+j;P[d>>2]=e+l}function RH(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,f=0,g=0,h=S(0);d=fa-80|0;fa=d;e=L[L[a>>2]>>2];f=L[L[a+4>>2]>>2];a:{if(!(ha[L[L[b>>2]+24>>2]](b,e,f)|0)){break a}g=L[e+192>>2];L[d+72>>2]=-1;L[d+76>>2]=-1;L[d+68>>2]=e+4;L[d+64>>2]=e;L[d+60>>2]=g;L[d+56>>2]=0;g=L[f+192>>2];L[d+48>>2]=-1;L[d+52>>2]=-1;L[d+44>>2]=f+4;L[d+40>>2]=f;L[d+36>>2]=g;L[d+32>>2]=0;if(!L[a+8>>2]){b=ha[L[L[b>>2]+8>>2]](b,d+56|0,d+32|0,0)|0;L[a+8>>2]=b;if(!b){break a}}L[d+12>>2]=d+32;L[d+8>>2]=d+56;L[d+4>>2]=0;L[d>>2]=11584;a=L[a+8>>2];b=L[a>>2];if(L[c+8>>2]==1){ha[L[b+8>>2]](a,d+56|0,d+32|0,c,d);break a}h=S(ha[L[b+12>>2]](a,e,f,c,d));if(!(h>2])){break a}P[c+12>>2]=h}fa=d+80|0}function wE(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=S(0),f=S(0),g=S(0),h=S(0),i=S(0);f=P[a+20>>2];g=P[a+32>>2];h=P[a+24>>2];i=P[a+28>>2];e=S(S(g*P[b+8>>2])+S(S(h*P[b>>2])+S(i*P[b+4>>2])));if(f>2]=e;c=L[b+12>>2];L[a+12>>2]=L[b+8>>2];L[a+16>>2]=c;c=L[b+4>>2];L[a+4>>2]=L[b>>2];L[a+8>>2]=c;f=e}e=S(S(g*P[b+24>>2])+S(S(h*P[b+16>>2])+S(i*P[b+20>>2])));if(e>f){P[a+20>>2]=e;c=L[b+28>>2];L[a+12>>2]=L[b+24>>2];L[a+16>>2]=c;c=L[b+20>>2];L[a+4>>2]=L[b+16>>2];L[a+8>>2]=c}else{e=f}f=S(S(g*P[b+40>>2])+S(S(h*P[b+32>>2])+S(i*P[b+36>>2])));if(e>2]=f;c=L[b+44>>2];L[a+12>>2]=L[b+40>>2];L[a+16>>2]=c;c=L[b+36>>2];L[a+4>>2]=L[b+32>>2];L[a+8>>2]=c}}function sF(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=S(0),f=S(0),g=0,h=S(0),i=S(0),j=S(0),k=S(0),l=S(0),m=S(0),n=S(0);d=fa-96|0;fa=d;L[d+44>>2]=0;L[d+48>>2]=0;L[d+56>>2]=0;L[d+60>>2]=0;L[d+52>>2]=1065353216;g=d- -64|0;L[g>>2]=0;L[g+4>>2]=0;L[d+76>>2]=0;L[d+80>>2]=0;L[d+72>>2]=1065353216;L[d+84>>2]=0;L[d+88>>2]=0;L[d+92>>2]=0;L[d+36>>2]=0;L[d+40>>2]=0;L[d+32>>2]=1065353216;ha[L[L[a>>2]+8>>2]](a,d+32|0,d+16|0,d);h=P[d+8>>2];i=P[d+24>>2];e=S(h-i);m=S(e*e);e=P[d>>2];j=P[d+16>>2];f=S(e-j);n=S(f*f);f=P[d+4>>2];k=P[d+20>>2];l=S(f-k);P[c>>2]=S(_(S(m+S(n+S(l*l)))))*S(.5);L[b+12>>2]=0;P[b+8>>2]=S(h+i)*S(.5);P[b+4>>2]=S(f+k)*S(.5);P[b>>2]=S(e+j)*S(.5);fa=d+96|0}function ZC(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=S(0),f=S(0),g=S(0),h=S(0),i=S(0);f=P[a+84>>2];g=P[a+96>>2];h=P[a+88>>2];i=P[a+92>>2];e=S(S(g*P[b+8>>2])+S(S(h*P[b>>2])+S(i*P[b+4>>2])));if(f>2]=e;c=L[b+12>>2];L[a+12>>2]=L[b+8>>2];L[a+16>>2]=c;c=L[b+4>>2];L[a+4>>2]=L[b>>2];L[a+8>>2]=c;f=e}e=S(S(g*P[b+24>>2])+S(S(h*P[b+16>>2])+S(i*P[b+20>>2])));if(e>f){P[a+84>>2]=e;c=L[b+28>>2];L[a+12>>2]=L[b+24>>2];L[a+16>>2]=c;c=L[b+20>>2];L[a+4>>2]=L[b+16>>2];L[a+8>>2]=c}else{e=f}f=S(S(g*P[b+40>>2])+S(S(h*P[b+32>>2])+S(i*P[b+36>>2])));if(e>2]=f;c=L[b+44>>2];L[a+12>>2]=L[b+40>>2];L[a+16>>2]=c;c=L[b+36>>2];L[a+4>>2]=L[b+32>>2];L[a+8>>2]=c}}function zg(a,b,c,d){var e=S(0),f=S(0),g=S(0),h=S(0),i=S(0),j=S(0),k=S(0),l=S(0),m=S(0),n=S(0),o=S(0),p=S(0);i=P[c+24>>2];e=P[b+24>>2];l=S(i-e);j=P[c+16>>2];g=P[b+16>>2];m=S(j-g);f=P[a+4>>2];o=P[a>>2];k=P[c+20>>2];h=P[b+20>>2];n=S(k-h);p=P[a+8>>2];a=S(S(e*S(S(m*f)-S(o*n)))+S(S(g*S(S(n*p)-S(f*l)))+S(h*S(S(l*o)-S(p*m)))))S(0)){break a}f=S(S(i*i)+S(S(j*j)+S(k*k)));if(S(S(i*l)+S(S(j*m)+S(k*n)))S(0)?e:S(0)}P[d>>2]=_(f)}return a}function Sx(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0;e=fa-16|0;fa=e;L[e+12>>2]=a;L[e+8>>2]=b;a=L[e+8>>2];b=fa-32|0;fa=b;L[b+28>>2]=L[e+12>>2];L[b+24>>2]=a;a=b+8|0;f=L[b+28>>2];ua(a,f,L[b+24>>2]+48|0);hb(f+48|0,a);c=L[b+24>>2];a=fa-48|0;fa=a;L[a+44>>2]=f;L[a+40>>2]=c;c=L[a+44>>2];P[a+36>>2]=mc(L[a+40>>2],c);P[a+32>>2]=lc(L[a+40>>2],c);P[a+28>>2]=kc(L[a+40>>2],c);d=c+16|0;P[a+24>>2]=mc(L[a+40>>2],d);P[a+20>>2]=lc(L[a+40>>2],d);P[a+16>>2]=kc(L[a+40>>2],d);d=c+32|0;P[a+12>>2]=mc(L[a+40>>2],d);P[a+8>>2]=lc(L[a+40>>2],d);P[a+4>>2]=kc(L[a+40>>2],d);md(c,a+36|0,a+32|0,a+28|0,a+24|0,a+20|0,a+16|0,a+12|0,a+8|0,a+4|0);fa=a+48|0;fa=b+32|0;fa=e+16|0;return f|0}function em(a){a=a|0;var b=0,c=0,d=0,e=0;L[a>>2]=15788;b=L[a+56>>2];if(!(b?!b|!M[a+60|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+56>>2]=0;J[a+60|0]=1;L[a+48>>2]=0;L[a+52>>2]=0;e=L[a+28>>2];if((e|0)>0){while(1){b=L[a+36>>2]+R(c,36)|0;d=L[b+12>>2];if(!(d?!d|!M[b+16|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](d)}L[b+12>>2]=0;J[b+16|0]=1;L[b+4>>2]=0;L[b+8>>2]=0;c=c+1|0;if((e|0)!=(c|0)){continue}break}}b=L[a+36>>2];if(!(b?!b|!M[a+40|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+36>>2]=0;J[a+40|0]=1;L[a+28>>2]=0;L[a+32>>2]=0;b=L[a+16>>2];if(!(b?!b|!M[a+20|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+16>>2]=0;J[a+20|0]=1;L[a+8>>2]=0;L[a+12>>2]=0;return a|0}function xj(a,b){var c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;d=fa-96|0;fa=d;L[d+92>>2]=a;L[d+88>>2]=b;m=L[d+88>>2];b=fa-16|0;fa=b;h=d+40|0;L[b+12>>2]=h;L[b+8>>2]=m;e=fa-16|0;c=L[b+8>>2];L[e+12>>2]=c;n=L[e+12>>2];g=fa-16|0;e=c+16|0;L[g+12>>2]=e;o=L[g+12>>2];i=fa-16|0;g=c+32|0;L[i+12>>2]=g;i=L[i+12>>2];j=fa-16|0;L[j+12>>2]=c;j=L[j+12>>2];k=fa-16|0;L[k+12>>2]=e;k=L[k+12>>2];l=fa-16|0;L[l+12>>2]=g;l=L[l+12>>2];f=fa-16|0;L[f+12>>2]=c;c=L[f+12>>2];f=fa-16|0;L[f+12>>2]=e;e=L[f+12>>2];f=fa-16|0;L[f+12>>2]=g;lf(h,n,o,i,j+4|0,k+4|0,l+4|0,c+8|0,e+8|0,L[f+12>>2]+8|0);fa=b+16|0;b=d+8|0;Zb(b,m+48|0);c=d+24|0;ua(c,h,b);Qf(a,h,c);fa=d+96|0}function ny(a){a=a|0;var b=0,c=0,d=0,e=0;b=fa-32|0;fa=b;L[b+28>>2]=a;if(!M[29684]){L[(fa-16|0)+12>>2]=29668;J[29684]=1}d=b+12|0;a=fa-48|0;fa=a;L[a+44>>2]=L[b+28>>2];c=L[a+44>>2];P[a+40>>2]=S(S(-P[c+12>>2])*P[c+12>>2])+S(1);a:{if(P[a+40>>2]>2]=1;P[a+32>>2]=0;P[a+28>>2]=0;la(d,a+36|0,a+32|0,a+28|0);break a}e=fa-16|0;P[e+12>>2]=P[a+40>>2];P[a+24>>2]=S(1)/S(_(P[e+12>>2]));P[a+20>>2]=P[c>>2]*P[a+24>>2];P[a+16>>2]=P[c+4>>2]*P[a+24>>2];P[a+12>>2]=P[c+8>>2]*P[a+24>>2];la(d,a+20|0,a+16|0,a+12|0)}fa=a+48|0;a=L[b+16>>2];L[7417]=L[b+12>>2];L[7418]=a;a=L[b+24>>2];L[7419]=L[b+20>>2];L[7420]=a;fa=b+32|0;return 29668}function Bo(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;d=fa-32|0;fa=d;L[d+28>>2]=a;L[d+24>>2]=b;J[d+23|0]=c;a=L[d+28>>2];P[a+4>>2]=P[L[d+24>>2]+40>>2];L[a+76>>2]=L[L[d+24>>2]>>2];a:{if(J[d+23|0]&1){b=L[d+24>>2];c=L[b+12>>2];L[a+44>>2]=L[b+8>>2];L[a+48>>2]=c;c=L[b+20>>2];L[a+52>>2]=L[b+16>>2];L[a+56>>2]=c;break a}b=fa-16|0;L[b+12>>2]=L[a+76>>2];L[b+12>>2]=L[b+12>>2]+4;ua(d+4|0,L[b+12>>2],L[d+24>>2]+8|0);b=L[d+8>>2];L[a+44>>2]=L[d+4>>2];L[a+48>>2]=b;b=L[d+16>>2];L[a+52>>2]=L[d+12>>2];L[a+56>>2]=b}b=L[d+24>>2];c=L[b+28>>2];L[a+60>>2]=L[b+24>>2];L[a+64>>2]=c;c=L[b+36>>2];L[a+68>>2]=L[b+32>>2];L[a+72>>2]=c;fa=d+32|0;return S(P[L[d+24>>2]+40>>2])}function Ml(a){a=a|0;var b=0,c=0,d=0;L[a>>2]=18076;c=L[a+152>>2];b=c;a:{if(!b){break a}b:{if(!(c&1)){break b}b=c-1|0;d=L[L[a+160>>2]+(b<<2)>>2];if(!d){break b}ha[L[L[d>>2]+4>>2]](d)}if((c|0)==1){break a}while(1){c=L[(L[a+160>>2]+(b<<2)|0)-4>>2];if(c){ha[L[L[c>>2]+4>>2]](c)}b=b-2|0;c=L[L[a+160>>2]+(b<<2)>>2];if(c){ha[L[L[c>>2]+4>>2]](c)}if(b){continue}break}}b=L[a+160>>2];if(!(b?!b|!M[a+164|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+160>>2]=0;J[a+164|0]=1;L[a+152>>2]=0;L[a+156>>2]=0;L[a>>2]=4720;b=L[a+84>>2];if(!(b?!b|!M[a+88|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+84>>2]=0;J[a+88|0]=1;L[a+76>>2]=0;L[a+80>>2]=0;return a|0}function Kd(a,b,c,d){var e=S(0),f=S(0),g=S(0),h=S(0);g=S(P[c+8>>2]-P[a+16>>2]);h=P[a+48>>2];f=S(S(P[c+4>>2]-P[a+12>>2])*P[a+44>>2]);e=S(S(P[c>>2]-P[a+8>>2])*P[a+40>>2]);c=d;a:{if(e<=S(0)){break a}c=N[a+6>>1];if(e>=S(c>>>0)){c=c&N[a+4>>1]|d;break a}if(e=S(0)){c=~~e>>>0}else{c=0}c=c&N[a+4>>1]|d}e=S(g*h);K[b>>1]=c;c=d;b:{if(f<=S(0)){break b}c=N[a+6>>1];if(S(c>>>0)<=f){c=c&N[a+4>>1]|d;break b}if(f=S(0)){c=~~f>>>0}else{c=0}c=c&N[a+4>>1]|d}K[b+2>>1]=c;if(!(e<=S(0))){c=N[a+6>>1];if(e>=S(c>>>0)){K[b+4>>1]=c&N[a+4>>1]|d;return}if(e=S(0)){c=~~e>>>0}else{c=0}d=c&N[a+4>>1]|d}K[b+4>>1]=d}function qk(a,b){a=a|0;b=S(b);var c=0,d=0,e=S(0),f=S(0),g=S(0),h=0,i=0,j=S(0),k=S(0),l=S(0),m=S(0),n=S(0),o=0;i=L[a+732>>2];if((i|0)>0){o=L[a+740>>2];while(1){c=R(h,52)+o|0;d=L[c+8>>2];f=P[d+48>>2];g=P[c+44>>2];a=L[c+12>>2];j=P[c+36>>2];k=P[d+40>>2];l=P[d+44>>2];m=P[c+40>>2];n=S(S(P[c+32>>2]*S(-S(S(g*S(f-P[a+48>>2]))+S(S(j*S(k-P[a+40>>2]))+S(S(l-P[a+44>>2])*m)))))*b);e=S(P[d+88>>2]*n);P[d+48>>2]=f+S(g*e);P[d+44>>2]=l+S(m*e);P[d+40>>2]=k+S(j*e);f=P[c+44>>2];g=P[c+40>>2];e=S(n*P[a+88>>2]);P[a+40>>2]=P[a+40>>2]-S(P[c+36>>2]*e);P[a+44>>2]=P[a+44>>2]-S(e*g);P[a+48>>2]=P[a+48>>2]-S(e*f);h=h+1|0;if((i|0)!=(h|0)){continue}break}}}function It(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;d=fa-16|0;fa=d;L[d+12>>2]=a;L[d+8>>2]=b;J[d+7|0]=c;c=oa(1388);a=ll(c,L[d+12>>2],L[d+8>>2],J[d+7|0]&1);L[a+4>>2]=9;L[a>>2]=19664;L[a+1364>>2]=1065353216;L[a+1368>>2]=1065353216;b=a+1309|0;J[b|0]=0;J[b+1|0]=0;J[b+2|0]=0;J[b+3|0]=0;b=a+1313|0;J[b|0]=0;J[b+1|0]=0;b=a+1316|0;L[b>>2]=0;L[b+4>>2]=0;b=a+1324|0;L[b>>2]=0;L[b+4>>2]=0;b=a+1332|0;L[b>>2]=0;L[b+4>>2]=0;b=a+1340|0;L[b>>2]=0;L[b+4>>2]=0;b=a+1348|0;L[b>>2]=0;L[b+4>>2]=0;b=a+1356|0;L[b>>2]=0;L[b+4>>2]=0;b=a+1380|0;L[b>>2]=1065353216;L[b+4>>2]=1065353216;a=a+1372|0;L[a>>2]=1065353216;L[a+4>>2]=1065353216;fa=d+16|0;return c|0}function mF(a){a=a|0;var b=S(0),c=0,d=0,e=0,f=0;c=fa-32|0;fa=c;L[a+48>>2]=-581039253;L[a+52>>2]=-581039253;L[a+32>>2]=1566444395;L[a+36>>2]=1566444395;L[a+56>>2]=-581039253;L[a+60>>2]=0;L[a+40>>2]=1566444395;L[a+44>>2]=0;if(L[a+16>>2]>0){while(1){e=L[a+24>>2]+R(d,80)|0;f=L[e+64>>2];ha[L[L[f>>2]+8>>2]](f,e,c+16|0,c);b=P[c+16>>2];if(b>2]){P[a+32>>2]=b}b=P[c>>2];if(b>P[a+48>>2]){P[a+48>>2]=b}b=P[c+20>>2];if(b>2]){P[a+36>>2]=b}b=P[c+4>>2];if(b>P[a+52>>2]){P[a+52>>2]=b}b=P[c+24>>2];if(b>2]){P[a+40>>2]=b}b=P[c+8>>2];if(b>P[a+56>>2]){P[a+56>>2]=b}d=d+1|0;if((d|0)>2]){continue}break}}fa=c+32|0}function _z(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0,g=0,h=S(0),i=S(0),j=S(0);c=fa-48|0;fa=c;if(L[a+136>>2]>0){while(1){g=R(f,284);d=g+L[a+144>>2]|0;e=M[d+84|0];L[c+44>>2]=0;L[c+36>>2]=0;L[c+40>>2]=1065353216;P[c+32>>2]=e?S(0):S(1);e=L[d+152>>2];L[c+24>>2]=L[d+148>>2];L[c+28>>2]=e;e=L[d+144>>2];L[c+16>>2]=L[d+140>>2];L[c+20>>2]=e;d=d+(L[a+120>>2]<<2)|0;h=P[d+92>>2];i=P[d+108>>2];j=P[d+124>>2];L[c+12>>2]=0;P[c+8>>2]=j+P[c+24>>2];P[c+4>>2]=i+P[c+20>>2];P[c>>2]=h+P[c+16>>2];d=c+16|0;e=c+32|0;ha[L[L[b>>2]+8>>2]](b,d,c,e);ha[L[L[b>>2]+8>>2]](b,d,(L[a+144>>2]+g|0)+16|0,e);f=f+1|0;if((f|0)>2]){continue}break}}fa=c+48|0}function eo(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0;e=fa-48|0;fa=e;L[e+44>>2]=a;L[e+40>>2]=b;L[e+36>>2]=c;L[e+32>>2]=d;a=L[e+44>>2]+16|0;b=fa-16|0;L[b+12>>2]=e;L[b+8>>2]=a;c=L[b+8>>2];d=L[c+4>>2];a=L[b+12>>2];L[a>>2]=L[c>>2];L[a+4>>2]=d;d=L[c+12>>2];L[a+8>>2]=L[c+8>>2];L[a+12>>2]=d;b=L[b+8>>2];c=L[b+20>>2];L[a+16>>2]=L[b+16>>2];L[a+20>>2]=c;c=L[b+28>>2];L[a+24>>2]=L[b+24>>2];L[a+28>>2]=c;Mh(e,L[e+40>>2]);b=L[e+4>>2];a=L[e+36>>2];L[a>>2]=L[e>>2];L[a+4>>2]=b;b=L[e+12>>2];L[a+8>>2]=L[e+8>>2];L[a+12>>2]=b;b=L[e+20>>2];a=L[e+32>>2];L[a>>2]=L[e+16>>2];L[a+4>>2]=b;b=L[e+28>>2];L[a+8>>2]=L[e+24>>2];L[a+12>>2]=b;fa=e+48|0}function pl(a,b,c,d){var e=S(0),f=S(0),g=S(0),h=S(0),i=S(0),j=S(0),k=S(0);f=Fa(c);e=P[b+444>>2];c=Ea(c);a:{if(!(S(T(f))>S(1.1920928955078125e-7))){h=S(f*f);break a}h=S(f*f);g=S(S(c*c)/h);i=S(g/S(e*e));e=P[b+448>>2];e=S(_(S(S(g+S(1))/S(i+S(S(1)/S(e*e))))))}L[a+12>>2]=0;e=S(e*S(.5));g=S(Ea(e)/S(_(S(S(c*c)+S(h+S(0))))));c=S(g*S(-c));e=Fa(e);i=S(e*S(0));h=S(g*S(0));j=S(h*S(0));k=S(S(i+S(c*d))-j);f=S(f*g);g=S(S(i+j)-S(f*d));j=S(c*S(-0));i=S(j+S(S(f*S(-0))-S(h*d)));d=S(j+S(S(e*d)+S(f*S(0))));P[a+8>>2]=S(k*h)+S(S(S(e*g)-S(i*c))-S(d*f));P[a+4>>2]=S(d*c)+S(S(S(e*k)-S(i*f))-S(g*h));P[a>>2]=S(g*f)+S(S(S(e*d)-S(i*h))-S(k*c))}function kF(a,b,c){a=a|0;b=S(b);c=c|0;var d=0,e=S(0),f=S(0),g=S(0),h=0,i=S(0);d=fa-96|0;fa=d;L[d+44>>2]=0;L[d+48>>2]=0;L[d+56>>2]=0;L[d+60>>2]=0;L[d+52>>2]=1065353216;h=d- -64|0;L[h>>2]=0;L[h+4>>2]=0;L[d+76>>2]=0;L[d+80>>2]=0;L[d+72>>2]=1065353216;L[d+84>>2]=0;L[d+88>>2]=0;L[d+92>>2]=0;L[d+36>>2]=0;L[d+40>>2]=0;L[d+32>>2]=1065353216;ha[L[L[a>>2]+8>>2]](a,d+32|0,d+16|0,d);e=P[d+24>>2];i=P[d+8>>2];b=S(b/S(12));f=S(S(P[d>>2]-P[d+16>>2])*S(.5));f=S(f+f);f=S(f*f);g=S(S(P[d+4>>2]-P[d+20>>2])*S(.5));g=S(g+g);g=S(g*g);P[c+8>>2]=b*S(f+g);e=S(S(i-e)*S(.5));e=S(e+e);e=S(e*e);P[c+4>>2]=b*S(f+e);P[c>>2]=b*S(g+e);fa=d+96|0}function sq(a,b){a=a|0;b=b|0;var c=0,d=0,e=0;e=fa-16|0;fa=e;L[e+12>>2]=a;L[e+8>>2]=b;if(!M[3e4]){mi(29904);J[3e4]=1}b=L[e+8>>2];a=fa-16|0;L[a+12>>2]=L[e+12>>2];L[a+8>>2]=b;b=L[L[a+12>>2]+12>>2]+R(L[a+8>>2],96)|0;fa=a;L[a+12>>2]=29904;L[a+8>>2]=b;c=L[a+8>>2];d=L[c+4>>2];b=L[a+12>>2];L[b>>2]=L[c>>2];L[b+4>>2]=d;L[b+24>>2]=L[c+24>>2];d=L[c+20>>2];L[b+16>>2]=L[c+16>>2];L[b+20>>2]=d;d=L[c+12>>2];L[b+8>>2]=L[c+8>>2];L[b+12>>2]=d;qg(b+28|0,L[a+8>>2]+28|0);c=L[a+8>>2];d=L[c+80>>2];L[b+76>>2]=L[c+76>>2];L[b+80>>2]=d;L[b+92>>2]=L[c+92>>2];d=L[c+88>>2];L[b+84>>2]=L[c+84>>2];L[b+88>>2]=d;fa=a+16|0;fa=e+16|0;return 29904}function ID(a,b){a=a|0;b=b|0;var c=S(0),d=0;d=fa-96|0;fa=d;Ue(a,b);J[a+88|0]=1;if(!M[30416]){L[7581]=0;L[7582]=0;L[7580]=1065353216;L[7583]=0;L[7584]=0;L[7586]=0;L[7587]=0;L[7585]=1065353216;L[7588]=0;L[7589]=0;L[7593]=0;L[7594]=0;L[7592]=-1082130432;L[7590]=1065353216;L[7591]=0;L[7595]=0;L[7596]=0;L[7598]=0;L[7599]=0;L[7597]=-1082130432;L[7600]=0;L[7601]=0;L[7602]=-1082130432;L[7603]=0;J[30416]=1}b=pa(d,0,96);ha[L[L[a>>2]+76>>2]](a,30320,b,6);c=P[a+44>>2];P[a+72>>2]=c+P[b>>2];P[a+56>>2]=P[b+48>>2]-c;P[a+76>>2]=c+P[b+20>>2];P[a+60>>2]=P[b+68>>2]-c;P[a+80>>2]=c+P[b+40>>2];P[a- -64>>2]=P[b+88>>2]-c;fa=b+96|0}function tx(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=S(e);var f=0,g=0,h=0;f=fa-32|0;fa=f;L[f+28>>2]=a;L[f+24>>2]=b;L[f+20>>2]=c;L[f+16>>2]=d;P[f+12>>2]=e;d=sa(44);b=L[f+28>>2];c=L[f+24>>2];g=L[f+20>>2];h=L[f+16>>2];e=P[f+12>>2];a=fa-32|0;L[a+28>>2]=d;L[a+24>>2]=b;L[a+20>>2]=c;L[a+16>>2]=g;L[a+12>>2]=h;P[a+8>>2]=e;b=L[a+28>>2];L[b>>2]=L[a+24>>2];L[b+4>>2]=L[a+20>>2];c=L[a+16>>2];g=L[c+4>>2];L[b+8>>2]=L[c>>2];L[b+12>>2]=g;g=L[c+12>>2];L[b+16>>2]=L[c+8>>2];L[b+20>>2]=g;c=L[a+12>>2];g=L[c+4>>2];L[b+24>>2]=L[c>>2];L[b+28>>2]=g;g=L[c+12>>2];L[b+32>>2]=L[c+8>>2];L[b+36>>2]=g;P[b+40>>2]=P[a+8>>2];fa=f+32|0;return d|0}function Dy(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0;if(Wa(a,L[b+8>>2],f)){Wf(b,c,d,e);return}g=M[b+53|0];j=L[a+12>>2];J[b+53|0]=0;h=M[b+52|0];J[b+52|0]=0;m=a+16|0;Vf(m,b,c,d,e,f);k=M[b+53|0];g=g|k;l=M[b+52|0];h=h|l;i=a+24|0;j=(j<<3)+m|0;a:{if(i>>>0>=j>>>0){break a}while(1){h=h&1;g=g&1;if(M[b+54|0]){break a}b:{if(l){if(L[b+24>>2]==1){break a}if(M[a+8|0]&2){break b}break a}if(!k){break b}if(!(J[a+8|0]&1)){break a}}K[b+52>>1]=0;Vf(i,b,c,d,e,f);k=M[b+53|0];g=k|g;l=M[b+52|0];h=l|h;i=i+8|0;if(j>>>0>i>>>0){continue}break}}J[b+53|0]=(g&255)!=0;J[b+52|0]=(h&255)!=0}function fw(a,b){a=a|0;b=S(b);var c=0,d=0,e=0;e=fa-16|0;fa=e;L[e+12>>2]=a;P[e+8>>2]=b;b=P[e+8>>2];a=fa-16|0;fa=a;L[a+12>>2]=L[e+12>>2];P[a+8>>2]=b;b=P[a+8>>2];c=fa-16|0;d=L[a+12>>2];L[c+12>>2]=d;c=L[c+12>>2];P[c>>2]=P[c>>2]-b;b=P[a+8>>2];c=fa-16|0;L[c+12>>2]=d;c=L[c+12>>2];P[c+4>>2]=P[c+4>>2]-b;b=P[a+8>>2];c=fa-16|0;L[c+12>>2]=d;c=L[c+12>>2];P[c+8>>2]=P[c+8>>2]-b;b=P[a+8>>2];c=fa-16|0;d=d+16|0;L[c+12>>2]=d;c=L[c+12>>2];P[c>>2]=P[c>>2]+b;b=P[a+8>>2];c=fa-16|0;L[c+12>>2]=d;c=L[c+12>>2];P[c+4>>2]=P[c+4>>2]+b;b=P[a+8>>2];c=fa-16|0;L[c+12>>2]=d;d=L[c+12>>2];P[d+8>>2]=P[d+8>>2]+b;fa=a+16|0;fa=e+16|0}function ji(a,b){var c=0,d=0,e=0,f=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;b=fa-16|0;a=L[c+12>>2];L[b+12>>2]=a;if(L[L[b+12>>2]+8>>2]>2]){d=L[c+8>>2];b=fa-16|0;fa=b;L[b+8>>2]=a;L[b+4>>2]=d;e=L[b+8>>2];a:{if(L[b+4>>2]){f=L[b+4>>2];d=fa-16|0;fa=d;L[d+12>>2]=e;L[d+8>>2]=f;L[d+4>>2]=0;e=R(L[d+8>>2],96);L[8513]=L[8513]+1;e=ha[L[6798]](e,16)|0;fa=d+16|0;L[b+12>>2]=e;break a}L[b+12>>2]=0}fa=b+16|0;L[c+4>>2]=L[b+12>>2];b=fa-16|0;L[b+12>>2]=a;Dh(a,L[L[b+12>>2]+4>>2],L[c+4>>2]);b=fa-16|0;L[b+12>>2]=a;Db(a,L[L[b+12>>2]+4>>2]);jb(a);J[a+16|0]=1;L[a+12>>2]=L[c+4>>2];L[a+8>>2]=L[c+8>>2]}fa=c+16|0}function Fh(a,b){var c=0,d=0,e=0,f=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;b=fa-16|0;a=L[c+12>>2];L[b+12>>2]=a;if(L[L[b+12>>2]+8>>2]>2]){d=L[c+8>>2];b=fa-16|0;fa=b;L[b+8>>2]=a;L[b+4>>2]=d;e=L[b+8>>2];a:{if(L[b+4>>2]){f=L[b+4>>2];d=fa-16|0;fa=d;L[d+12>>2]=e;L[d+8>>2]=f;L[d+4>>2]=0;e=R(L[d+8>>2],36);L[8513]=L[8513]+1;e=ha[L[6798]](e,16)|0;fa=d+16|0;L[b+12>>2]=e;break a}L[b+12>>2]=0}fa=b+16|0;L[c+4>>2]=L[b+12>>2];b=fa-16|0;L[b+12>>2]=a;Gh(a,L[L[b+12>>2]+4>>2],L[c+4>>2]);b=fa-16|0;L[b+12>>2]=a;Hh(a,L[L[b+12>>2]+4>>2]);jb(a);J[a+16|0]=1;L[a+12>>2]=L[c+4>>2];L[a+8>>2]=L[c+8>>2]}fa=c+16|0}function Xh(a,b){var c=0,d=0,e=0,f=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;b=fa-16|0;a=L[c+12>>2];L[b+12>>2]=a;if(L[L[b+12>>2]+8>>2]>2]){d=L[c+8>>2];b=fa-16|0;fa=b;L[b+8>>2]=a;L[b+4>>2]=d;e=L[b+8>>2];a:{if(L[b+4>>2]){f=L[b+4>>2];d=fa-16|0;fa=d;L[d+12>>2]=e;L[d+8>>2]=f;L[d+4>>2]=0;e=L[d+8>>2]<<4;L[8513]=L[8513]+1;e=ha[L[6798]](e,16)|0;fa=d+16|0;L[b+12>>2]=e;break a}L[b+12>>2]=0}fa=b+16|0;L[c+4>>2]=L[b+12>>2];b=fa-16|0;L[b+12>>2]=a;Uh(a,L[L[b+12>>2]+4>>2],L[c+4>>2]);b=fa-16|0;L[b+12>>2]=a;Db(a,L[L[b+12>>2]+4>>2]);jb(a);J[a+16|0]=1;L[a+12>>2]=L[c+4>>2];L[a+8>>2]=L[c+8>>2]}fa=c+16|0}function qh(a){var b=0,c=0,d=0,e=0,f=0;J[a+28|0]=0;L[a+24>>2]=0;L[a+72>>2]=0;J[a+20|0]=1;L[a>>2]=6064;L[a+16>>2]=0;J[a+48|0]=1;L[a+8>>2]=0;L[a+12>>2]=0;L[a+44>>2]=0;J[a+68|0]=1;L[a+36>>2]=0;L[a+40>>2]=0;L[a- -64>>2]=0;L[a+56>>2]=0;L[a+60>>2]=0;L[8513]=L[8513]+1;e=ha[L[6798]](32,16)|0;f=L[a+8>>2];if((f|0)>0){while(1){c=d<<4;b=c+e|0;c=c+L[a+16>>2]|0;L[b>>2]=L[c>>2];L[b+4>>2]=L[c+4>>2];L[b+8>>2]=L[c+8>>2];L[b+12>>2]=L[c+12>>2];d=d+1|0;if((f|0)!=(d|0)){continue}break}}b=L[a+16>>2];if(!(b?!b|!M[a+20|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+16>>2]=e;J[a+20|0]=1;L[a+12>>2]=2;yn(a);return a}function Sb(a){var b=0,c=S(0);b=fa-96|0;fa=b;J[a+88|0]=1;if(!M[30416]){L[7581]=0;L[7582]=0;L[7580]=1065353216;L[7583]=0;L[7584]=0;L[7586]=0;L[7587]=0;L[7585]=1065353216;L[7588]=0;L[7589]=0;L[7593]=0;L[7594]=0;L[7592]=-1082130432;L[7590]=1065353216;L[7591]=0;L[7595]=0;L[7596]=0;L[7598]=0;L[7599]=0;L[7597]=-1082130432;L[7600]=0;L[7601]=0;L[7602]=-1082130432;L[7603]=0;J[30416]=1}b=pa(b,0,96);ha[L[L[a>>2]+76>>2]](a,30320,b,6);c=P[a+44>>2];P[a+72>>2]=P[b>>2]+c;P[a+56>>2]=P[b+48>>2]-c;P[a+76>>2]=c+P[b+20>>2];P[a+60>>2]=P[b+68>>2]-c;P[a+80>>2]=c+P[b+40>>2];P[a- -64>>2]=P[b+88>>2]-c;fa=b+96|0}function ld(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0;e=fa-16|0;fa=e;L[e+12>>2]=a;L[e+8>>2]=b;L[e+4>>2]=c;b=L[e+8>>2];c=L[e+4>>2];a=fa-16|0;fa=a;L[a+12>>2]=L[e+12>>2];L[a+8>>2]=b;L[a+4>>2]=c;c=L[a+8>>2];d=L[c+4>>2];b=L[a+12>>2];L[b+164>>2]=L[c>>2];L[b+168>>2]=d;d=L[c+12>>2];L[b+172>>2]=L[c+8>>2];L[b+176>>2]=d;d=fa-16|0;L[d+12>>2]=L[a+8>>2];c=1;a:{if(P[L[d+12>>2]>>2]!=S(1)){break a}d=fa-16|0;L[d+12>>2]=L[a+8>>2];c=1;if(P[L[d+12>>2]+4>>2]!=S(1)){break a}c=fa-16|0;L[c+12>>2]=L[a+8>>2];c=P[L[c+12>>2]+8>>2]!=S(1)}J[a+3|0]=c;if(J[a+3|0]&1){c=L[a+4>>2]}else{c=0}L[b+180>>2]=c;fa=a+16|0;fa=e+16|0}function sx(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0;e=fa-16|0;fa=e;L[e+12>>2]=a;L[e+8>>2]=b;f=sa(80);a=L[e+12>>2];c=L[e+8>>2];b=fa-16|0;fa=b;L[b+12>>2]=f;L[b+8>>2]=a;L[b+4>>2]=c;c=fa-16|0;a=L[b+12>>2];L[c+12>>2]=a;c=L[c+12>>2];L[c>>2]=2012;P[c+4>>2]=1;K[c+8>>1]=1;K[c+10>>1]=65535;L[a>>2]=1872;c=L[b+8>>2];d=L[c+4>>2];L[a+12>>2]=L[c>>2];L[a+16>>2]=d;d=L[c+12>>2];L[a+20>>2]=L[c+8>>2];L[a+24>>2]=d;c=L[b+4>>2];d=L[c+4>>2];L[a+28>>2]=L[c>>2];L[a+32>>2]=d;d=L[c+12>>2];L[a+36>>2]=L[c+8>>2];L[a+40>>2]=d;L[(fa-16|0)+12>>2]=a+44;L[(fa-16|0)+12>>2]=a+60;L[a+76>>2]=0;fa=b+16|0;fa=e+16|0;return f|0}function mn(a,b,c,d,e){a=a|0;b=b|0;c=S(c);d=d|0;e=e|0;var f=0,g=S(0),h=S(0),i=S(0),j=S(0),k=S(0),l=S(0),m=S(0),n=S(0),o=S(0),p=S(0),q=S(0),r=S(0);f=fa-48|0;fa=f;L[f+44>>2]=e;L[f+40>>2]=d;j=P[a- -64>>2];k=P[a+60>>2];l=P[a+80>>2];m=P[a+72>>2];n=P[a+76>>2];o=P[a+96>>2];p=P[a+88>>2];q=P[a+92>>2];r=P[a+56>>2];g=P[b+8>>2];h=P[b>>2];i=P[b+4>>2];b=L[a+48>>2];L[f+32>>2]=0;P[f+28>>2]=S(o*g)+S(S(p*h)+S(i*q));P[f+24>>2]=S(l*g)+S(S(m*h)+S(i*n));P[f+36>>2]=c;L[f+12>>2]=b;P[f+20>>2]=S(j*g)+S(S(r*h)+S(k*i));L[f+16>>2]=f+40;a=L[a+44>>2];c=S(ha[L[L[a>>2]+12>>2]](a,f+12|0,1));fa=f+48|0;return S(c)}function eq(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0;e=fa-16|0;fa=e;L[e+12>>2]=a;L[e+8>>2]=b;L[e+4>>2]=c;L[e>>2]=d;b=0;c=L[e+12>>2];f=L[c+752>>2];if((f|0)>0){a=L[c+720>>2];g=a+R(L[e>>2],104)|0;h=a+R(L[e+4>>2],104)|0;i=a+R(L[e+8>>2],104)|0;c=L[c+760>>2];a=0;b=1;while(1){a:{j=R(a,44)+c|0;d=L[j+8>>2];b:{if(!((d|0)==(g|0)|(d|0)==(i|0))&(d|0)!=(h|0)){break b}d=L[j+12>>2];if(!((d|0)==(g|0)|(d|0)==(i|0))&(d|0)!=(h|0)){break b}d=L[j+16>>2];if((d|0)==(g|0)|(d|0)==(i|0)|(d|0)==(h|0)){break a}}a=a+1|0;b=(f|0)>(a|0);if((a|0)!=(f|0)){continue}}break}}fa=e+16|0;return b&1}function ty(a,b,c){a=a|0;b=b|0;c=S(c);var d=0,e=0;d=fa-16|0;fa=d;L[d+12>>2]=a;L[d+8>>2]=b;P[d+4>>2]=c;b=L[d+8>>2];a=fa-48|0;fa=a;L[a+44>>2]=L[d+12>>2];L[a+40>>2]=b;L[a+36>>2]=d+4;b=L[a+44>>2];P[a+32>>2]=nf(L[a+40>>2]);P[a+28>>2]=Qa(S(P[L[a+36>>2]>>2]*S(.5)))/P[a+32>>2];e=fa-16|0;L[e+12>>2]=L[a+40>>2];P[a+24>>2]=P[L[e+12>>2]>>2]*P[a+28>>2];e=fa-16|0;L[e+12>>2]=L[a+40>>2];P[a+20>>2]=P[L[e+12>>2]+4>>2]*P[a+28>>2];e=fa-16|0;L[e+12>>2]=L[a+40>>2];P[a+16>>2]=P[L[e+12>>2]+8>>2]*P[a+28>>2];P[a+12>>2]=Ra(S(P[L[a+36>>2]>>2]*S(.5)));vc(b,a+24|0,a+20|0,a+16|0,a+12|0);fa=a+48|0;fa=d+16|0}function _C(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=S(0),f=S(0),g=0,h=S(0),i=S(0),j=0,k=0;a:{e=P[b>>2];f=P[b+16>>2];i=e>2];if(P[a+24>>2]<(h>i?i:h)){break a}g=e>f;if(P[(h<(g?e:f)?!g<<4:32)+b>>2]>2]){break a}e=P[b+8>>2];g=b+24|0;f=P[g>>2];i=e>2];if(P[a+32>>2]<(h>i?i:h)){break a}k=g;g=e>f;if(P[(h<(g?e:f)?g?b+8|0:k:j)>>2]>2]){break a}e=P[b+4>>2];g=b+20|0;f=P[g>>2];i=e>2];if(P[a+28>>2]<(h>i?i:h)){break a}k=g;g=e>f;if(P[(h<(g?e:f)?g?b+4|0:k:j)>>2]>2]){break a}a=L[a+4>>2];ha[L[L[a>>2]+8>>2]](a,b,c,d)}}function vE(a,b,c){a=a|0;b=S(b);c=c|0;var d=S(0),e=S(0),f=S(0),g=S(0),h=S(0),i=S(0),j=S(0),k=S(0);f=P[a+36>>2];d=P[a+32>>2];i=P[a+28>>2];j=S(ha[L[L[a>>2]+48>>2]](a));d=S(d+S(ha[L[L[a>>2]+48>>2]](a)));k=S(ha[L[L[a>>2]+48>>2]](a));e=S(b*S(.5));g=S(b*S(.25));h=S(b/S(12));b=S(j+i);a:{b:{switch(L[a+52>>2]){case 0:f=e;e=S(d*d);d=S(f*e);b=S(S(h*S(b*S(b*S(4))))+S(g*e));e=b;break a;case 2:b=S(b*b);e=S(e*b);d=S(k+f);d=S(S(h*S(d*S(d*S(4))))+S(g*b));b=d;break a;default:break b}}f=e;e=S(b*b);b=S(f*e);d=S(S(h*S(d*S(d*S(4))))+S(g*e));e=d}L[c+12>>2]=0;P[c+8>>2]=e;P[c+4>>2]=b;P[c>>2]=d}function gc(a){var b=0;b=L[a>>2];if(b){Hd(a,b)}b=L[a+4>>2];if(b){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+4>>2]=0;L[a+8>>2]=-1;b=L[a+32>>2];if(!(b?!b|!M[a+36|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+32>>2]=0;J[a+36|0]=1;L[a+16>>2]=0;L[a+24>>2]=0;L[a+28>>2]=0;b=L[a+52>>2];a:{if(!(M[a+56|0]?b:0)){L[a+52>>2]=0;J[a+56|0]=1;L[a+44>>2]=0;L[a+48>>2]=0;break a}if(b){L[8514]=L[8514]+1;ha[L[6799]](b)}J[a+56|0]=1;L[a+52>>2]=0;L[a+44>>2]=0;L[a+48>>2]=0;b=L[a+32>>2];if(!b|!M[a+36|0]){break a}if(b){L[8514]=L[8514]+1;ha[L[6799]](b)}}L[a+32>>2]=0;J[a+36|0]=1;L[a+24>>2]=0;L[a+28>>2]=0}function Xi(a,b,c,d,e){var f=0;f=fa-32|0;fa=f;L[f+28>>2]=a;P[f+24>>2]=b;L[f+20>>2]=c;L[f+16>>2]=d;L[f+12>>2]=e;a=L[f+28>>2];P[a>>2]=P[f+24>>2];L[a+4>>2]=L[f+20>>2];d=a+8|0;Pb(d);L[a+72>>2]=L[f+16>>2];c=L[f+12>>2];e=L[c+4>>2];L[a+76>>2]=L[c>>2];L[a+80>>2]=e;e=L[c+12>>2];L[a+84>>2]=L[c+8>>2];L[a+88>>2]=e;P[a+92>>2]=0;P[a+96>>2]=0;P[a+100>>2]=.5;P[a+104>>2]=0;P[a+108>>2]=0;P[a+112>>2]=.800000011920929;P[a+116>>2]=1;J[a+120|0]=0;P[a+124>>2]=.004999999888241291;P[a+128>>2]=.009999999776482582;P[a+132>>2]=.009999999776482582;P[a+136>>2]=.009999999776482582;ee(d);fa=f+32|0}function Ho(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;d=fa-32|0;fa=d;L[d+28>>2]=a;L[d+24>>2]=b;J[d+23|0]=c;a=L[d+28>>2];P[a+4>>2]=P[L[d+24>>2]+24>>2];L[a+8>>2]=L[L[d+24>>2]>>2];a:{if(J[d+23|0]&1){b=L[d+24>>2];c=L[b+12>>2];L[a+52>>2]=L[b+8>>2];L[a+56>>2]=c;c=L[b+20>>2];L[a+60>>2]=L[b+16>>2];L[a+64>>2]=c;break a}b=fa-16|0;L[b+12>>2]=L[a+8>>2];L[b+12>>2]=L[b+12>>2]+4;ua(d+4|0,L[b+12>>2],L[d+24>>2]+8|0);b=L[d+8>>2];L[a+52>>2]=L[d+4>>2];L[a+56>>2]=b;b=L[d+16>>2];L[a+60>>2]=L[d+12>>2];L[a+64>>2]=b}ai(a+68|0,a+20|0,a+36|0,P[L[d+24>>2]+24>>2]);fa=d+32|0;return S(P[L[d+24>>2]+24>>2])}function bw(a,b){a=a|0;b=b|0;var c=0,d=0,e=0;d=fa-16|0;fa=d;L[d+12>>2]=a;L[d+8>>2]=b;b=L[d+8>>2];a=fa+-64|0;fa=a;L[a+60>>2]=L[d+12>>2];L[a+56>>2]=b;b=L[a+60>>2];tb(a+40|0,L[a+56>>2],b+56|0);c=L[a+44>>2];L[b+56>>2]=L[a+40>>2];L[b+60>>2]=c;c=L[a+52>>2];L[b+64>>2]=L[a+48>>2];L[b+68>>2]=c;c=b+56|0;tb(a+24|0,L[a+56>>2],c+16|0);e=L[a+28>>2];L[b+72>>2]=L[a+24>>2];L[b+76>>2]=e;e=L[a+36>>2];L[b+80>>2]=L[a+32>>2];L[b+84>>2]=e;tb(a+8|0,L[a+56>>2],c+32|0);c=L[a+12>>2];L[b+88>>2]=L[a+8>>2];L[b+92>>2]=c;c=L[a+20>>2];L[b+96>>2]=L[a+16>>2];L[b+100>>2]=c;fa=a- -64|0;fa=d+16|0}function Xl(a){a=a|0;var b=0;L[a>>2]=16836;b=L[a+156>>2];if(!(b?!b|!M[a+160|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+156>>2]=0;J[a+160|0]=1;L[a+148>>2]=0;L[a+152>>2]=0;b=L[a+136>>2];if(!(b?!b|!M[a+140|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+136>>2]=0;J[a+140|0]=1;L[a+128>>2]=0;L[a+132>>2]=0;b=L[a+116>>2];if(!(b?!b|!M[a+120|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+116>>2]=0;J[a+120|0]=1;L[a+108>>2]=0;L[a+112>>2]=0;b=L[a+96>>2];if(!(b?!b|!M[a+100|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+96>>2]=0;J[a+100|0]=1;L[a+88>>2]=0;L[a+92>>2]=0;return Lg(a)|0}function fq(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,f=0,g=0,h=0,i=0;d=fa-16|0;fa=d;L[d+12>>2]=a;L[d+8>>2]=b;L[d+4>>2]=c;fa=d+16|0;a=1;e=L[d+12>>2];g=L[e+732>>2];b=0;a:{if((g|0)<=0){break a}b=L[e+720>>2];c=b+R(L[d+4>>2],104)|0;h=L[e+740>>2];f=L[h+12>>2];i=L[h+8>>2];e=R(L[d+8>>2],104)+b|0;b:{if((i|0)==(e|0)&(c|0)==(f|0)){break b}b=0;if((c|0)==(i|0)&(e|0)==(f|0)){break b}while(1){c:{b=b+1|0;if((g|0)==(b|0)){break c}f=R(b,52)+h|0;a=L[f+12>>2];f=L[f+8>>2];if((f|0)==(e|0)&(a|0)==(c|0)){break c}if((c|0)!=(f|0)|(a|0)!=(e|0)){continue}}break}a=(b|0)<(g|0)}b=a}return b&1}function zh(a){a=a|0;var b=0;L[a>>2]=5520;if(L[a+108>>2]){b=L[a+112>>2];ha[L[L[b>>2]>>2]](b)|0;b=L[a+112>>2];if(b){L[8514]=L[8514]+1;ha[L[6799]](b)}b=L[a+108>>2];ha[L[L[b>>2]>>2]](b)|0;b=L[a+108>>2];if(b){L[8514]=L[8514]+1;ha[L[6799]](b)}}b=L[a+88>>2];if(b){L[8514]=L[8514]+1;ha[L[6799]](b)}b=L[a+84>>2];if(b){L[8514]=L[8514]+1;ha[L[6799]](b)}b=L[a+80>>2];if(b){L[8514]=L[8514]+1;ha[L[6799]](b)}b=L[a+60>>2];if(b){L[8514]=L[8514]+1;ha[L[6799]](b)}if(M[a+100|0]){b=L[a+92>>2];ha[L[L[b>>2]>>2]](b)|0;b=L[a+92>>2];if(b){L[8514]=L[8514]+1;ha[L[6799]](b)}}return a|0}function ev(a){a=a|0;var b=0,c=0,d=0,e=0,f=0,g=0;f=fa-16|0;fa=f;L[f+12>>2]=a;a=sa(5260);b=L[f+12>>2];L[a+4>>2]=2;L[a+5256>>2]=b;L[a+60>>2]=232;J[a+24|0]=1;L[a>>2]=6544;L[a+20>>2]=0;L[a+28>>2]=11584;L[a+12>>2]=0;L[a+16>>2]=0;L[a+64>>2]=ha[L[L[b>>2]+12>>2]](b);L[a+68>>2]=ha[L[L[b>>2]+8>>2]](b);while(1){b=0;while(1){d=(a+R(c,144)|0)+72|0;e=L[a+5256>>2];L[d+(b<<2)>>2]=ha[L[L[e>>2]+16>>2]](e,c,b);e=b|1;g=d+(e<<2)|0;d=L[a+5256>>2];L[g>>2]=ha[L[L[d>>2]+16>>2]](d,c,e);b=b+2|0;if((b|0)!=36){continue}break}c=c+1|0;if((c|0)!=36){continue}break}fa=f+16|0;return a|0}function Jp(a,b){a=a|0;b=S(b);var c=S(0),d=0,e=S(0),f=0,g=0,h=0,i=0,j=0,k=0;f=fa-16|0;fa=f;L[f+12>>2]=a;P[f+8>>2]=b;b=P[f+8>>2];a=0;g=L[f+12>>2];h=L[g+732>>2];a:{if((h|0)<=0){break a}i=L[g+740>>2];c=P[g+1228>>2];if((h|0)!=1){k=h&-2;while(1){d=R(a,52)+i|0;e=S(S(P[d+16>>2]/c)*b);P[d+16>>2]=e;P[d+28>>2]=e*e;d=R(a|1,52)+i|0;e=S(S(P[d+16>>2]/c)*b);P[d+16>>2]=e;P[d+28>>2]=e*e;a=a+2|0;j=j+2|0;if((k|0)!=(j|0)){continue}break}}if(!(h&1)){break a}a=R(a,52)+i|0;c=S(S(P[a+16>>2]/c)*b);P[a+16>>2]=c;P[a+28>>2]=c*c}P[g+1228>>2]=b;if(L[g+216>>2]==2){ib(g,0)}fa=f+16|0}function Sv(a){a=a|0;var b=0,c=0,d=0,e=0,f=0;d=fa-16|0;fa=d;L[d+12>>2]=a;f=sa(68);a=L[d+12>>2];b=fa-16|0;fa=b;L[b+12>>2]=f;L[b+8>>2]=a;a=L[b+12>>2];L[a>>2]=0;c=fa-16|0;L[c+12>>2]=a;L[L[c+12>>2]>>2]=5048;L[a>>2]=5080;L[(fa-16|0)+12>>2]=a+12;L[a+8>>2]=L[L[b+8>>2]+8>>2];L[a+28>>2]=L[L[b+8>>2]+28>>2];P[a+4>>2]=P[L[b+8>>2]+4>>2];c=L[b+8>>2];e=L[c+16>>2];L[a+12>>2]=L[c+12>>2];L[a+16>>2]=e;e=L[c+24>>2];L[a+20>>2]=L[c+20>>2];L[a+24>>2]=e;L[a+32>>2]=0;L[a+36>>2]=0;L[a+40>>2]=0;L[a+48>>2]=0;L[a+52>>2]=0;L[a+56>>2]=0;L[a+60>>2]=0;fa=b+16|0;fa=d+16|0;return f|0}function Fy(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;if(Wa(a,L[b+8>>2],e)){if(!(L[b+28>>2]==1|L[b+4>>2]!=(c|0))){L[b+28>>2]=d}return}a:{if(Wa(a,L[b>>2],e)){if(!(L[b+16>>2]!=(c|0)&L[b+20>>2]!=(c|0))){if((d|0)!=1){break a}L[b+32>>2]=1;return}L[b+32>>2]=d;b:{if(L[b+44>>2]==4){break b}K[b+52>>1]=0;a=L[a+8>>2];ha[L[L[a>>2]+20>>2]](a,b,c,c,1,e);if(M[b+53|0]){L[b+44>>2]=3;if(!M[b+52|0]){break b}break a}L[b+44>>2]=4}L[b+20>>2]=c;L[b+40>>2]=L[b+40>>2]+1;if(L[b+36>>2]!=1|L[b+24>>2]!=2){break a}J[b+54|0]=1;return}a=L[a+8>>2];ha[L[L[a>>2]+24>>2]](a,b,c,d,e)}}function mE(a,b,c){a=a|0;b=b|0;c=c|0;var d=S(0),e=0,f=S(0),g=S(0),h=0,i=S(0),j=S(0);e=fa-16|0;fa=e;ha[L[L[b>>2]+68>>2]](e,b,c);h=L[e+12>>2];L[a+8>>2]=L[e+8>>2];L[a+12>>2]=h;h=L[e+4>>2];L[a>>2]=L[e>>2];L[a+4>>2]=h;if(S(ha[L[L[b>>2]+48>>2]](b))!=S(0)){f=P[c+4>>2];d=P[c>>2];g=P[c+8>>2];i=S(ha[L[L[b>>2]+48>>2]](b));b=S(S(g*g)+S(S(d*d)+S(f*f)))>2]=P[a>>2]+S(i*S(j*d));P[a+4>>2]=P[a+4>>2]+S(i*S(f*d));P[a+8>>2]=P[a+8>>2]+S(i*S(g*d))}fa=e+16|0}function Vm(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;d=(b|0)!=8;if(!(d|(c|0)!=8)){return L[a+60>>2]}if(!((c|0)!=1|d)){return L[a+76>>2]}if(!((b|0)!=1|(c|0)!=8)){return L[a+80>>2]}if(!(b|c)){return L[a+72>>2]}if(!((c|0)!=28|(b|0)>19)){return L[a+88>>2]}if(!((b|0)!=28|(c|0)>19)){return L[a+84>>2]}a:{if((b|0)<=19){if((c|0)<=19){return L[a+32>>2]}if(c-21>>>0>8){break a}return L[a+36>>2]}if(!((c|0)>19|b-21>>>0>8)){return L[a+40>>2]}if((b|0)!=31){break a}if((c|0)==31){return L[a+48>>2]}return L[a+44>>2]}if((c|0)==31){return L[a+52>>2]}return L[a+56>>2]}function cF(a,b,c){a=a|0;b=b|0;c=c|0;var d=S(0),e=S(0),f=S(0),g=0,h=0,i=0,j=S(0),k=S(0);e=S(P[b+60>>2]*S(.5));g=L[b+64>>2];i=L[b+68>>2];h=i<<2;d=P[c+8>>2];j=S(d*d);d=P[c>>2];f=S(d*d);d=P[c+4>>2];a:{b:{if(P[h+c>>2]>S(P[b+52>>2]*S(_(S(j+S(f+S(d*d))))))){L[(g<<2)+a>>2]=0;P[a+h>>2]=e;c=L[b+72>>2];break b}d=P[(g<<2)+c>>2];h=c;c=L[b+72>>2];f=P[h+(c<<2)>>2];k=S(_(S(S(d*d)+S(f*f))));if(k>S(1.1920928955078125e-7)){j=d;d=S(P[b+56>>2]/k);P[(g<<2)+a>>2]=j*d;P[(i<<2)+a>>2]=-e;e=S(f*d);break a}L[(g<<2)+a>>2]=0;P[(i<<2)+a>>2]=-e}e=S(0)}P[(c<<2)+a>>2]=e}function mr(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;d=fa-16|0;fa=d;L[d+12>>2]=a;L[d+8>>2]=b;L[d+4>>2]=c;a=sa(152);b=L[d+8>>2];c=L[d+4>>2];L[a+104>>2]=0;L[a+100>>2]=c;J[a+20|0]=1;L[a>>2]=20864;L[a+16>>2]=0;J[a+40|0]=1;L[a+8>>2]=0;L[a+12>>2]=0;L[a+36>>2]=0;J[a+60|0]=1;L[a+28>>2]=0;L[a+32>>2]=0;L[a+56>>2]=0;J[a+80|0]=1;L[a+48>>2]=0;L[a+52>>2]=0;L[a+76>>2]=0;J[a+148|0]=1;L[a+68>>2]=0;L[a+72>>2]=0;L[a+144>>2]=0;L[a+136>>2]=0;L[a+140>>2]=0;L[a+128>>2]=1;L[a+120>>2]=0;L[a+124>>2]=2;L[a+116>>2]=b;L[a+108>>2]=0;L[a+112>>2]=0;fa=d+16|0;return a|0}function Ih(a,b,c){var d=0;d=fa-32|0;fa=d;L[d+28>>2]=a;L[d+24>>2]=b;L[d+20>>2]=c;b=fa-16|0;a=L[d+28>>2];L[b+12>>2]=a;L[d+16>>2]=L[L[b+12>>2]+4>>2];a:{if(L[d+24>>2]>2]){L[d+12>>2]=L[d+24>>2];while(1){if(L[d+12>>2]>2]){L[d+12>>2]=L[d+12>>2]+1;continue}break}break a}b=L[d+24>>2];c=fa-16|0;L[c+12>>2]=a;if(L[L[c+12>>2]+4>>2]<(b|0)){Yh(a,L[d+24>>2])}L[d+8>>2]=L[d+16>>2];while(1){if(L[d+8>>2]>2]){L[L[a+12>>2]+(L[d+8>>2]<<2)>>2]=L[L[d+20>>2]>>2];L[d+8>>2]=L[d+8>>2]+1;continue}break}}L[a+4>>2]=L[d+24>>2];fa=d+32|0}function XA(a,b,c,d){a=a|0;b=b|0;c=S(c);d=d|0;a:{b:{c:{switch(b-2|0){case 0:if((d|0)<=0){d=a+232|0;b=512;break b}if(d>>>0<=2){d=a+264|0;b=32;break b}if((d|0)==3){d=a+248|0;b=2048;break b}if(d>>>0>5){break a}d=a+280|0;b=128;break b;case 1:if((d|0)<=0){d=a+212|0;b=1;break b}if((d|0)!=3){break a}d=a+228|0;b=4;break b;case 2:break c;default:break a}}if((d|0)<=0){d=a+244|0;b=256;break b}if(d>>>0<=2){d=a+276|0;b=16;break b}if((d|0)==3){d=a+260|0;b=1024;break b}if(d>>>0>5){break a}d=a+292|0;b=64}P[d>>2]=c;L[a+300>>2]=b|L[a+300>>2]}} -function dl(a){J[a+20|0]=1;L[a>>2]=19944;L[a+16>>2]=0;J[a+40|0]=1;L[a+8>>2]=0;L[a+12>>2]=0;L[a+36>>2]=0;J[a+60|0]=1;L[a+28>>2]=0;L[a+32>>2]=0;L[a+56>>2]=0;J[a+80|0]=1;L[a+48>>2]=0;L[a+52>>2]=0;L[a+76>>2]=0;J[a+100|0]=1;L[a+68>>2]=0;L[a+72>>2]=0;L[a+96>>2]=0;J[a+120|0]=1;L[a+88>>2]=0;L[a+92>>2]=0;L[a+116>>2]=0;J[a+140|0]=1;L[a+108>>2]=0;L[a+112>>2]=0;L[a+136>>2]=0;L[a+128>>2]=0;L[a+132>>2]=0;J[a+160|0]=1;L[a+156>>2]=0;L[a+148>>2]=0;L[a+152>>2]=0;J[a+180|0]=1;L[a+192>>2]=0;L[a+176>>2]=0;L[a+168>>2]=0;L[a+172>>2]=0;return a}function _h(a,b){var c=0,d=0,e=0;d=fa-16|0;fa=d;L[d+12>>2]=a;L[d+8>>2]=b;b=fa-16|0;a=L[d+12>>2];L[b+12>>2]=a;L[d+4>>2]=L[L[b+12>>2]+4>>2];b=L[d+4>>2];c=fa-16|0;L[c+12>>2]=a;if(L[L[c+12>>2]+8>>2]==(b|0)){b=fa-16|0;L[b+12>>2]=a;c=L[L[b+12>>2]+4>>2];L[b+12>>2]=a;L[b+8>>2]=c;if(L[b+8>>2]){b=L[b+8>>2]<<1}else{b=1}Xh(a,b)}c=L[a+12>>2]+(L[a+4>>2]<<4)|0;b=fa-16|0;L[b+12>>2]=16;L[b+8>>2]=c;c=L[d+8>>2];e=L[c+4>>2];b=L[b+8>>2];L[b>>2]=L[c>>2];L[b+4>>2]=e;e=L[c+12>>2];L[b+8>>2]=L[c+8>>2];L[b+12>>2]=e;L[a+4>>2]=L[a+4>>2]+1;fa=d+16|0}function Mn(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0,g=0,h=0,i=0;e=L[a+108>>2];if(!e){g=N[a+56>>1];if(g){e=1;h=1;while(1){f=L[a+68>>2]+(e<<2)|0;a:{if(!(J[f|0]&1)){break a}f=L[a+60>>2]+(N[f+2>>1]<<6)|0;e=0;b:{if(P[b>>2]>P[f+32>>2]){break b}e=0;if(P[c>>2]>2]){break b}e=1}if((P[c+8>>2]>2]|P[b+8>>2]>P[f+40>>2]?i:e)^1|P[c+4>>2]>2]|P[b+4>>2]>P[f+36>>2]){break a}ha[L[L[d>>2]+8>>2]](d,f)|0;g=N[a+56>>1]}h=h+1|0;e=h&65535;if(e>>>0<(g<<1|1)>>>0){continue}break}}return}ha[L[L[e>>2]+28>>2]](e,b,c,d)}function Bb(a,b,c){var d=0;d=L[a+4>>2];a:{if(d){L[a+4>>2]=0;break a}L[8513]=L[8513]+1;d=ha[L[6798]](44,16)|0;L[d>>2]=0;L[d+4>>2]=0;L[d+40>>2]=0;L[d+32>>2]=0;L[d+36>>2]=0;L[d+24>>2]=0;L[d+28>>2]=0;L[d+16>>2]=0;L[d+20>>2]=0;L[d+8>>2]=0;L[d+12>>2]=0}L[d+36>>2]=c;L[d+32>>2]=0;L[d+40>>2]=0;c=L[b+4>>2];L[d>>2]=L[b>>2];L[d+4>>2]=c;c=L[b+12>>2];L[d+8>>2]=L[b+8>>2];L[d+12>>2]=c;c=L[b+20>>2];L[d+16>>2]=L[b+16>>2];L[d+20>>2]=c;c=L[b+28>>2];L[d+24>>2]=L[b+24>>2];L[d+28>>2]=c;Ed(a,L[a>>2],d);L[a+12>>2]=L[a+12>>2]+1;return d}function jk(a){var b=0;b=L[a+12>>2];if(!(b?!b|!M[a+16|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+12>>2]=0;J[a+16|0]=1;L[a+4>>2]=0;L[a+8>>2]=0;b=L[a+32>>2];if(!(b?!b|!M[a+36|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+32>>2]=0;J[a+36|0]=1;L[a+24>>2]=0;L[a+28>>2]=0;b=L[a+52>>2];if(!(b?!b|!M[a+56|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+52>>2]=0;J[a+56|0]=1;L[a+44>>2]=0;L[a+48>>2]=0;b=L[a+72>>2];if(!(b?!b|!M[a+76|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+72>>2]=0;J[a+76|0]=1;a=a- -64|0;L[a>>2]=0;L[a+4>>2]=0}function _x(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0,g=0,h=0;e=fa-16|0;fa=e;L[e+12>>2]=a;L[e+8>>2]=b;g=sa(64);a=L[e+12>>2];b=L[e+8>>2];c=fa-16|0;fa=c;L[c+12>>2]=g;L[c+8>>2]=a;L[c+4>>2]=b;a=L[c+8>>2];d=fa-16|0;fa=d;f=L[c+12>>2];L[d+8>>2]=f;L[d+4>>2]=a;a=L[d+8>>2];L[d+12>>2]=a;h=a+48|0;b=a;while(1){L[(fa-16|0)+12>>2]=b;b=b+16|0;if((h|0)!=(b|0)){continue}break}yj(a,L[d+4>>2]);fa=d+16|0;a=L[c+4>>2];b=L[a+4>>2];L[f+48>>2]=L[a>>2];L[f+52>>2]=b;b=L[a+12>>2];L[f+56>>2]=L[a+8>>2];L[f+60>>2]=b;fa=c+16|0;fa=e+16|0;return g|0}function WA(a,b,c){a=a|0;b=b|0;c=c|0;var d=S(0);d=S(34028234663852886e22);a:{b:{switch(b-2|0){case 0:if((c|0)<=0){return S(P[a+232>>2])}if(c>>>0<=2){return S(P[a+264>>2])}if((c|0)==3){return S(P[a+248>>2])}if(c>>>0>5){break a}return S(P[a+280>>2]);case 1:if((c|0)<=0){return S(P[a+212>>2])}if((c|0)!=3){break a}return S(P[a+228>>2]);case 2:break b;default:break a}}if((c|0)<=0){return S(P[a+244>>2])}if(c>>>0<=2){return S(P[a+276>>2])}if((c|0)==3){return S(P[a+260>>2])}if(c>>>0>5){break a}d=P[a+292>>2]}return S(d)}function ED(a,b,c){a=a|0;b=b|0;c=c|0;var d=S(0),e=0,f=S(0),g=S(0),h=0,i=S(0),j=S(0);e=fa-16|0;fa=e;ha[L[L[b>>2]+68>>2]](e,b,c);h=L[e+12>>2];L[a+8>>2]=L[e+8>>2];L[a+12>>2]=h;h=L[e+4>>2];L[a>>2]=L[e>>2];L[a+4>>2]=h;f=P[c+4>>2];d=P[c>>2];g=P[c+8>>2];i=S(ha[L[L[b>>2]+48>>2]](b));b=S(S(g*g)+S(S(d*d)+S(f*f)))>2]=P[a>>2]+S(i*S(j*d));P[a+4>>2]=P[a+4>>2]+S(i*S(f*d));P[a+8>>2]=P[a+8>>2]+S(i*S(g*d));fa=e+16|0}function Jm(a){J[a+60|0]=0;L[a+52>>2]=282;L[a+144>>2]=0;J[a+80|0]=1;L[a>>2]=12192;L[a+76>>2]=0;J[a+100|0]=1;L[a+68>>2]=0;L[a+72>>2]=0;L[a+96>>2]=0;J[a+120|0]=1;L[a+88>>2]=0;L[a+92>>2]=0;L[a+116>>2]=0;J[a+140|0]=1;L[a+108>>2]=0;L[a+112>>2]=0;L[a+136>>2]=0;J[a+164|0]=1;L[a+128>>2]=0;L[a+132>>2]=0;L[a+160>>2]=0;L[a+168>>2]=0;L[a+152>>2]=0;L[a+156>>2]=0;L[a+4>>2]=-8388609;L[a+8>>2]=-8388609;L[a+12>>2]=-8388609;L[a+16>>2]=0;L[a+20>>2]=2139095039;L[a+24>>2]=2139095039;L[a+28>>2]=2139095039;L[a+32>>2]=0;return a}function Ah(a,b,c){var d=0,e=0;d=fa-32|0;L[d+28>>2]=a;L[d+24>>2]=0;L[d+20>>2]=b;L[d+16>>2]=c;c=L[d+28>>2];L[d+12>>2]=L[d+24>>2];while(1){if(L[d+12>>2]>2]){a=R(L[d+12>>2],44);b=a+L[d+16>>2]|0;a=a+L[c+12>>2]|0;e=L[a+4>>2];L[b>>2]=L[a>>2];L[b+4>>2]=e;L[b+40>>2]=L[a+40>>2];e=L[a+36>>2];L[b+32>>2]=L[a+32>>2];L[b+36>>2]=e;e=L[a+28>>2];L[b+24>>2]=L[a+24>>2];L[b+28>>2]=e;e=L[a+20>>2];L[b+16>>2]=L[a+16>>2];L[b+20>>2]=e;e=L[a+12>>2];L[b+8>>2]=L[a+8>>2];L[b+12>>2]=e;L[d+12>>2]=L[d+12>>2]+1;continue}break}}function hk(a){a=a|0;var b=0;L[a>>2]=22296;b=L[a+92>>2];ha[L[L[b>>2]>>2]](b)|0;b=L[a+92>>2];if(b){L[8514]=L[8514]+1;ha[L[6799]](b)}b=L[a+96>>2];ha[L[L[b>>2]>>2]](b)|0;b=L[a+96>>2];if(b){L[8514]=L[8514]+1;ha[L[6799]](b)}b=L[a+100>>2];ha[L[L[b>>2]>>2]](b)|0;b=L[a+100>>2];if(b){L[8514]=L[8514]+1;ha[L[6799]](b)}b=L[a+104>>2];ha[L[L[b>>2]>>2]](b)|0;b=L[a+104>>2];if(b){L[8514]=L[8514]+1;ha[L[6799]](b)}b=L[a+108>>2];ha[L[L[b>>2]>>2]](b)|0;b=L[a+108>>2];if(b){L[8514]=L[8514]+1;ha[L[6799]](b)}return fh(a)|0}function mf(a,b){var c=0,d=0;d=fa-16|0;fa=d;L[d+8>>2]=a;L[d+4>>2]=b;a=L[d+8>>2];L[d+12>>2]=a;c=a+48|0;b=a;while(1){L[(fa-16|0)+12>>2]=b;b=b+16|0;if((c|0)!=(b|0)){continue}break}b=L[d+4>>2];c=L[b+4>>2];L[a>>2]=L[b>>2];L[a+4>>2]=c;c=L[b+12>>2];L[a+8>>2]=L[b+8>>2];L[a+12>>2]=c;b=L[d+4>>2];c=L[b+20>>2];L[a+16>>2]=L[b+16>>2];L[a+20>>2]=c;c=L[b+28>>2];L[a+24>>2]=L[b+24>>2];L[a+28>>2]=c;b=L[d+4>>2];c=L[b+36>>2];L[a+32>>2]=L[b+32>>2];L[a+36>>2]=c;c=L[b+44>>2];L[a+40>>2]=L[b+40>>2];L[a+44>>2]=c;fa=d+16|0}function EB(a,b){a=a|0;b=b|0;var c=0,d=0;if(M[a+1308|0]){L[b>>2]=0;L[b+4>>2]=0;return}qd(a,L[a+28>>2]+4|0,L[a+32>>2]+4|0);L[b>>2]=0;L[b+4>>2]=6;a:{if(!(L[a+856>>2]|M[a+788|0])){c=6;d=0;break a}L[b>>2]=1;L[b+4>>2]=5;c=5;d=1}if(L[a+860>>2]|M[a+789|0]){c=c-1|0;L[b+4>>2]=c;d=d+1|0;L[b>>2]=d}if(L[a+864>>2]|M[a+790|0]){L[b+4>>2]=c-1;L[b>>2]=d+1}if(De(a,0)){L[b>>2]=L[b>>2]+1;L[b+4>>2]=L[b+4>>2]-1}if(De(a,1)){L[b>>2]=L[b>>2]+1;L[b+4>>2]=L[b+4>>2]-1}if(De(a,2)){L[b>>2]=L[b>>2]+1;L[b+4>>2]=L[b+4>>2]-1}}function Zk(a,b,c,d){var e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;while(1){k=c;l=L[L[a+12>>2]+((c+d|0)/2<<3)>>2];e=d;while(1){g=L[a+12>>2];h=c;while(1){c=h;h=c+1|0;f=(c<<3)+g|0;if(L[f>>2]<(l|0)){continue}break}i=e;while(1){e=i;i=e-1|0;m=e<<3;j=m+g|0;if(L[j>>2]>(l|0)){continue}break}if((c|0)<=(e|0)){c=L[f>>2];e=L[f+4>>2];g=L[j+4>>2];L[f>>2]=L[j>>2];L[f+4>>2]=g;f=L[a+12>>2]+m|0;L[f>>2]=c;L[f+4>>2]=e;e=i;c=h}if((c|0)<=(e|0)){continue}break}if((e|0)>(k|0)){Zk(a,b,k,e)}if((c|0)<(d|0)){continue}break}}function ZH(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,f=0,g=0;L[7539]=L[7539]+1;d=L[b+12>>2]>L[c+12>>2];e=L[(d?b:c)+12>>2];d=L[(d?c:b)+12>>2];b=e<<16|d;b=(b<<15^-1)+b|0;b=R(b>>10^b,9);b=b>>6^b;b=(b<<11^-1)+b|0;b=L[a+12>>2]-1&(b>>16^b);a:{b:{if((b|0)>=L[a+36>>2]){break b}c=L[L[a+44>>2]+(b<<2)>>2];if((c|0)==-1){break b}g=L[a- -64>>2];a=L[a+16>>2];while(1){f=c<<4;b=a+f|0;if((d|0)==L[L[b>>2]+12>>2]&L[L[(a+f|0)+4>>2]+12>>2]==(e|0)){break a}c=L[(c<<2)+g>>2];if((c|0)!=-1){continue}break}}b=0}return b|0}function Ot(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0;f=fa-16|0;fa=f;L[f+12>>2]=a;L[f+8>>2]=b;L[f+4>>2]=c;L[f>>2]=d;d=oa(360);b=L[f+4>>2];a=L[f>>2];e=ub(d,3,L[f+12>>2],L[f+8>>2]);L[e>>2]=19852;c=L[b+4>>2];L[e+300>>2]=L[b>>2];L[e+304>>2]=c;c=L[b+12>>2];L[e+308>>2]=L[b+8>>2];L[e+312>>2]=c;b=L[a+4>>2];L[e+316>>2]=L[a>>2];L[e+320>>2]=b;b=L[a+12>>2];L[e+324>>2]=L[a+8>>2];L[e+328>>2]=b;L[e+356>>2]=0;L[e+348>>2]=1050253722;L[e+352>>2]=1065353216;J[e+344|0]=0;L[e+332>>2]=0;fa=f+16|0;return d|0}function Kx(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0;e=fa-16|0;fa=e;L[e+12>>2]=a;L[e+8>>2]=b;f=sa(84);a=L[e+12>>2];c=L[e+8>>2];b=fa-16|0;fa=b;L[b+12>>2]=f;L[b+8>>2]=a;L[b+4>>2]=c;a=L[b+12>>2];wj(a);L[a>>2]=1476;c=L[b+8>>2];d=L[c+4>>2];L[a+20>>2]=L[c>>2];L[a+24>>2]=d;d=L[c+12>>2];L[a+28>>2]=L[c+8>>2];L[a+32>>2]=d;c=L[b+4>>2];d=L[c+4>>2];L[a+36>>2]=L[c>>2];L[a+40>>2]=d;d=L[c+12>>2];L[a+44>>2]=L[c+8>>2];L[a+48>>2]=d;L[(fa-16|0)+12>>2]=a+52;L[(fa-16|0)+12>>2]=a+68;fa=b+16|0;fa=e+16|0;return f|0}function Bl(a,b,c,d){var e=0,f=0;e=L[b+4>>2];L[a+292>>2]=L[b>>2];L[a+296>>2]=e;e=L[b+12>>2];L[a+300>>2]=L[b+8>>2];L[a+304>>2]=e;J[a+356|0]=1;f=L[b+4>>2];e=a+(L[a>>2]<<4)|0;L[e+4>>2]=L[b>>2];L[e+8>>2]=f;f=L[b+12>>2];L[e+12>>2]=L[b+8>>2];L[e+16>>2]=f;e=L[c+12>>2];b=(L[a>>2]<<4)+a|0;L[b+92>>2]=L[c+8>>2];L[b+96>>2]=e;e=L[c+4>>2];L[b+84>>2]=L[c>>2];L[b+88>>2]=e;c=L[d+12>>2];b=(L[a>>2]<<4)+a|0;L[b+172>>2]=L[d+8>>2];L[b+176>>2]=c;c=L[d+4>>2];L[b+164>>2]=L[d>>2];L[b+168>>2]=c;L[a>>2]=L[a>>2]+1}function Ix(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0;e=fa-16|0;fa=e;L[e+12>>2]=a;L[e+8>>2]=b;f=sa(132);a=L[e+12>>2];c=L[e+8>>2];b=fa-16|0;fa=b;L[b+12>>2]=f;L[b+8>>2]=a;L[b+4>>2]=c;a=L[b+12>>2];wj(a);L[a>>2]=1632;Mb(a+20|0);c=L[b+8>>2];d=L[c+4>>2];L[a+40>>2]=L[c>>2];L[a+44>>2]=d;d=L[c+12>>2];L[a+48>>2]=L[c+8>>2];L[a+52>>2]=d;c=L[b+4>>2];d=L[c+4>>2];L[a+56>>2]=L[c>>2];L[a+60>>2]=d;d=L[c+12>>2];L[a+64>>2]=L[c+8>>2];L[a+68>>2]=d;Mb(a+72|0);Mb(a+92|0);Mb(a+112|0);fa=b+16|0;fa=e+16|0;return f|0}function TG(a,b,c,d){a=a|0;b=b|0;c=c|0;d=S(d);var e=0,f=S(0),g=0,h=S(0),i=S(0),j=S(0),k=S(0),l=S(0),m=S(0);e=fa-16|0;fa=e;P[a+32>>2]=d;g=L[b+4>>2];L[a+8>>2]=L[b>>2];L[a+12>>2]=g;g=L[b+12>>2];L[a+16>>2]=L[b+8>>2];L[a+20>>2]=g;h=P[b+8>>2];i=P[c>>2];j=P[b>>2];k=P[c+4>>2];l=P[b+4>>2];m=P[c+8>>2];f=P[a+28>>2];L[e+12>>2]=0;P[e+8>>2]=m-S(f*h);P[e+4>>2]=k-S(f*l);P[e>>2]=i-S(j*f);d=S(S(f+P[a+24>>2])+d);P[a+32>>2]=d;if(d>2];ha[L[L[a>>2]+16>>2]](a,b,e,d);fa=e+16|0}function cC(a,b,c){a=a|0;b=b|0;c=S(c);var d=S(0),e=S(0),f=S(0),g=S(0),h=0;J[a+171|0]=0;h=L[b+4>>2];L[a+60>>2]=L[b>>2];L[a+64>>2]=h;h=L[b+12>>2];L[a+68>>2]=L[b+8>>2];L[a+72>>2]=h;d=P[a+68>>2];e=P[a+60>>2];g=P[a- -64>>2];f=S(S(1)/S(_(S(S(d*d)+S(S(e*e)+S(g*g))))));d=S(d*f);e=S(e*f);f=S(g*f);g=P[a+72>>2];a:{if(!(S(_(S(S(d*d)+S(S(e*e)+S(f*f)))))>2]=e;P[a+88>>2]=g;P[a+84>>2]=d;P[a+80>>2]=f;P[a+172>>2]=P[a+172>>2]+c}function zo(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0;e=fa-96|0;fa=e;L[e+92>>2]=a;L[e+88>>2]=b;L[e+84>>2]=c;L[e+80>>2]=d;b=e- -64|0;a=L[e+92>>2];tb(b,L[e+88>>2],a+56|0);c=e+48|0;d=a+56|0;tb(c,L[e+88>>2],d+16|0);f=e+32|0;tb(f,L[e+88>>2],d+32|0);gj(e,b,c,f,P[a+44>>2]);b=L[e+4>>2];a=L[e+84>>2];L[a>>2]=L[e>>2];L[a+4>>2]=b;b=L[e+12>>2];L[a+8>>2]=L[e+8>>2];L[a+12>>2]=b;b=L[e+20>>2];a=L[e+80>>2];L[a>>2]=L[e+16>>2];L[a+4>>2]=b;b=L[e+28>>2];L[a+8>>2]=L[e+24>>2];L[a+12>>2]=b;fa=e+96|0}function Do(a,b,c,d,e,f,g,h){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;var i=0,j=0;i=fa-80|0;fa=i;L[i+76>>2]=a;L[i+72>>2]=b;L[i+68>>2]=c;L[i+64>>2]=d;L[i+60>>2]=e;L[i+56>>2]=f;L[i+52>>2]=g;L[i+48>>2]=h;a=L[i+76>>2];L[i+44>>2]=29214;b=L[i+44>>2];c=L[i+72>>2];d=L[i+68>>2];e=L[i+64>>2];f=L[i+60>>2];g=L[i+56>>2];h=L[i+52>>2];L[i+28>>2]=L[i+48>>2];L[i+24>>2]=h;L[i+20>>2]=g;L[i+16>>2]=f;L[i+12>>2]=e;L[i+8>>2]=d;L[i+4>>2]=c;L[i>>2]=a;j=+ea(b|0,1852,i|0);fa=i+80|0;return S(S(j))}function wh(a,b,c,d){var e=0,f=0,g=0;e=fa-144|0;fa=e;L[e+140>>2]=b;L[e+136>>2]=c;P[e+132>>2]=d;f=L[e+136>>2];b=L[e+140>>2];P[e+112>>2]=Sa(f,b);c=e+116|0;Ga(c,f,e+112|0);f=e+96|0;La(f,b,c);g=e+80|0;L[(fa-16|0)+12>>2]=g;Ub(e- -64|0,L[e+136>>2],b);b=L[e+76>>2];L[e+88>>2]=L[e+72>>2];L[e+92>>2]=b;b=L[e+68>>2];L[e+80>>2]=L[e+64>>2];L[e+84>>2]=b;P[e+28>>2]=Ra(P[e+132>>2]);b=e+32|0;Ga(b,f,e+28|0);f=e+48|0;ta(f,c,b);P[e+8>>2]=Qa(P[e+132>>2]);b=e+12|0;Ga(b,g,e+8|0);ta(a,f,b);fa=e+144|0}function ve(a,b,c){var d=S(0),e=0,f=S(0),g=S(0);e=L[a+204>>2];a:{if(b==S(0)){L[a+204>>2]=e|1;break a}L[a+204>>2]=e&-2;d=S(S(1)/b)}P[a+344>>2]=d;L[a+376>>2]=0;P[a+364>>2]=P[a+380>>2]*b;P[a+372>>2]=P[a+388>>2]*b;P[a+368>>2]=P[a+384>>2]*b;b=P[c+8>>2];f=P[c+4>>2];g=P[c>>2];P[a+560>>2]=P[a+348>>2]*d;P[a+564>>2]=d*P[a+352>>2];P[a+568>>2]=d*P[a+356>>2];L[a+572>>2]=0;L[a+408>>2]=0;P[a+396>>2]=g!=S(0)?S(S(1)/g):S(0);P[a+400>>2]=f!=S(0)?S(S(1)/f):S(0);P[a+404>>2]=b!=S(0)?S(S(1)/b):S(0)}function tv(a){a=a|0;var b=0,c=0,d=0,e=0,f=0;e=fa-16|0;fa=e;L[e+12>>2]=a;f=oa(168);a=L[e+12>>2];b=fa-16|0;fa=b;L[b+12>>2]=f;L[b+8>>2]=a;c=L[b+12>>2];If(c);L[c>>2]=18076;Mb(c+148|0);L[c+144>>2]=L[b+8>>2];d=L[b+8>>2];a=fa-16|0;fa=a;L[a+12>>2]=c;L[a+8>>2]=d;c=L[a+12>>2];L[a+4>>2]=0;while(1){d=L[a+8>>2];if(L[a+4>>2]<(ha[L[L[d>>2]+28>>2]](d)|0)){d=oa(212);Yi(d,L[a+8>>2],L[a+4>>2]);L[a>>2]=d;Hf(c+148|0,a);L[a+4>>2]=L[a+4>>2]+1;continue}break}fa=a+16|0;fa=b+16|0;fa=e+16|0;return f|0}function bB(a,b,c,d,e,f,g,h,i){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;i=i|0;var j=0,k=0,l=0,m=0;wa(2692);ha[L[L[a>>2]+32>>2]](a,b,c,d,e,f,g,h,i);j=L[a+184>>2];k=L[h+20>>2];k=(j|0)>(k|0)?j:k;a:{if((k|0)<=0){break a}j=0;if((k|0)!=1){m=k&-2;while(1){S(ha[L[L[a>>2]+40>>2]](a,j,b,c,d,e,f,g,h,i));S(ha[L[L[a>>2]+40>>2]](a,j|1,b,c,d,e,f,g,h,i));j=j+2|0;l=l+2|0;if((m|0)!=(l|0)){continue}break}}if(!(k&1)){break a}S(ha[L[L[a>>2]+40>>2]](a,j,b,c,d,e,f,g,h,i))}va();return S(S(0))}function $m(a){a=a|0;var b=0,c=0,d=0,e=0,f=0;L[a>>2]=9916;b=L[a+8>>2];e=L[b+8>>2];if((e|0)>0){while(1){c=L[(L[b+16>>2]+R(d,12)|0)+8>>2];if(c){ha[L[L[c>>2]>>2]](c)|0;f=L[a+4>>2];ha[L[L[f>>2]+60>>2]](f,c)}d=d+1|0;if((e|0)!=(d|0)){continue}break}b=L[a+8>>2]}Pm(b);b=L[a+8>>2];ha[L[L[b>>2]>>2]](b)|0;b=L[a+8>>2];if(b){L[8514]=L[8514]+1;ha[L[6799]](b)}b=L[a+24>>2];if(!(b?!b|!M[a+28|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+24>>2]=0;J[a+28|0]=1;L[a+16>>2]=0;L[a+20>>2]=0;return a|0}function yF(a,b,c){a=a|0;b=S(b);c=c|0;var d=S(0),e=S(0),f=S(0),g=0,h=0,i=0;h=a+28|0;g=L[a+52>>2];d=P[h+((g+2|0)%3<<2)>>2];a=fa-16|0;L[a+12>>2]=0;P[a+8>>2]=d;P[a+4>>2]=d;P[a>>2]=d;g=g<<2;i=g+a|0;P[i>>2]=P[g+h>>2]+P[i>>2];d=P[a+8>>2];b=S(b*S(.0833333283662796));e=S(P[a>>2]+S(.03999999910593033));e=S(e+e);e=S(e*e);f=S(P[a+4>>2]+S(.03999999910593033));f=S(f+f);f=S(f*f);P[c+8>>2]=b*S(e+f);d=S(d+S(.03999999910593033));d=S(d+d);d=S(d*d);P[c+4>>2]=b*S(e+d);P[c>>2]=b*S(f+d)}function Si(a,b,c,d,e,f){var g=0;g=fa-32|0;fa=g;L[g+28>>2]=a;P[g+24>>2]=b;P[g+20>>2]=c;P[g+16>>2]=d;P[g+12>>2]=e;P[g+8>>2]=f;c=P[g+16>>2];d=P[g+12>>2];e=P[g+8>>2];a=L[g+28>>2];b=P[g+24>>2];f=S(S(P[g+20>>2]-b)*S(.5));P[a+692>>2]=f;b=Na(S(f+b),S(6.2831854820251465));a:{if(bS(3.1415927410125732))){break a}b=S(b+S(-6.2831854820251465))}P[a+704>>2]=e;P[a+700>>2]=d;P[a+696>>2]=c;P[a+688>>2]=b;fa=g+32|0}function Yn(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=0;f=fa+-64|0;fa=f;L[f+60>>2]=a;L[f+56>>2]=b;L[f+52>>2]=c;L[f+48>>2]=d;L[f+44>>2]=e;b=L[f+60>>2];a=f+12|0;Od(a);b=ha[L[L[b>>2]+84>>2]](b)|0;ha[L[L[b>>2]+16>>2]](b,L[f+56>>2],a);Mh(a,L[f+52>>2]);c=L[a+4>>2];b=L[f+48>>2];L[b>>2]=L[a>>2];L[b+4>>2]=c;c=L[a+12>>2];L[b+8>>2]=L[a+8>>2];L[b+12>>2]=c;c=L[a+20>>2];b=L[f+44>>2];L[b>>2]=L[a+16>>2];L[b+4>>2]=c;c=L[a+28>>2];L[b+8>>2]=L[a+24>>2];L[b+12>>2]=c;fa=f- -64|0}function If(a){var b=0,c=0,d=0,e=0,f=0,g=0,h=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=L[b+12>>2];L[a+12>>2]=0;L[a+4>>2]=35;L[a+8>>2]=0;L[a>>2]=13384;L[a>>2]=4720;f=a+16|0;Od(f);g=a+52|0;L[(fa-16|0)+12>>2]=g;c=fa-16|0;fa=c;L[c+12>>2]=a+68;d=fa-16|0;fa=d;h=L[c+12>>2];L[d+12>>2]=h;e=L[d+12>>2];rf(e+4|0);Od(e+24|0);L[(fa-16|0)+12>>2]=e+56;L[e>>2]=0;fa=d+16|0;L[h+72>>2]=0;fa=c+16|0;L[a+4>>2]=25;fj(f);J[a+48|0]=1;P[b+8>>2]=1;P[b+4>>2]=1;P[b>>2]=1;la(g,b+8|0,b+4|0,b);fa=b+16|0}function CC(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;d=L[c+4>>2];b=L[a+164>>2]+(b<<6)|0;L[b>>2]=L[c>>2];L[b+4>>2]=d;d=L[c+12>>2];L[b+8>>2]=L[c+8>>2];L[b+12>>2]=d;d=L[c+28>>2];L[b+24>>2]=L[c+24>>2];L[b+28>>2]=d;d=L[c+20>>2];L[b+16>>2]=L[c+16>>2];L[b+20>>2]=d;d=L[c+44>>2];L[b+40>>2]=L[c+40>>2];L[b+44>>2]=d;d=L[c+36>>2];L[b+32>>2]=L[c+32>>2];L[b+36>>2]=d;d=L[c+52>>2];L[b+48>>2]=L[c+48>>2];L[b+52>>2]=d;d=L[c+60>>2];L[b+56>>2]=L[c+56>>2];L[b+60>>2]=d;ha[L[L[a>>2]+72>>2]](a)}function fj(a){var b=0,c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;b=fa-16|0;a=L[c+12>>2];L[b+12>>2]=a;P[L[b+12>>2]>>2]=34028234663852886e22;b=fa-16|0;L[b+12>>2]=a;P[L[b+12>>2]+4>>2]=34028234663852886e22;b=fa-16|0;L[b+12>>2]=a;P[L[b+12>>2]+8>>2]=34028234663852886e22;b=fa-16|0;a=a+16|0;L[b+12>>2]=a;P[L[b+12>>2]>>2]=-34028234663852886e22;b=fa-16|0;L[b+12>>2]=a;P[L[b+12>>2]+4>>2]=-34028234663852886e22;b=fa-16|0;L[b+12>>2]=a;P[L[b+12>>2]+8>>2]=-34028234663852886e22;fa=c+16|0}function CB(a,b,c,d){a=a|0;b=b|0;c=S(c);d=d|0;var e=0;a:{b:{c:{if(d>>>0<=2){d:{switch(b-2|0){case 0:b=((d<<2)+a|0)+756|0;e=4;break b;case 2:b=((d<<2)+a|0)+772|0;e=2;break b;case 1:break d;default:break a}}b=((d<<2)+a|0)+740|0;break c}e=d-3|0;if(e>>>0>2){break a}e:{switch(b-2|0){case 0:b=((e<<6)+a|0)+900|0;e=4;break b;case 2:b=((e<<6)+a|0)+904|0;e=2;break b;case 1:break e;default:break a}}b=((e<<6)+a|0)+896|0}e=1}P[b>>2]=c;L[a+1304>>2]=L[a+1304>>2]|e<>2]=a;P[c+8>>2]=b;a=oa(84);d=L[c+12>>2];e=P[c+8>>2];L[a+12>>2]=0;L[a+4>>2]=35;L[a+8>>2]=0;L[a>>2]=13384;L[a>>2]=16320;b=P[d+8>>2];f=P[d>>2];g=P[d+4>>2];h=P[d+12>>2];L[a+68>>2]=0;L[a+72>>2]=0;P[a+64>>2]=e;P[a+60>>2]=h;L[a+76>>2]=0;L[a+80>>2]=0;L[a+4>>2]=28;e=b;b=S(S(1)/S(_(S(S(b*b)+S(S(f*f)+S(g*g))))));P[a+56>>2]=e*b;P[a+52>>2]=g*b;P[a+48>>2]=f*b;fa=c+16|0;return a|0}function nh(a){a=a|0;var b=0,c=0,d=0,e=0;L[a>>2]=6776;b=L[a+8>>2];if((b|0)>0){while(1){e=L[L[a+16>>2]+(c<<2)>>2];d=L[e+188>>2];if(d){b=L[a+68>>2];b=ha[L[L[b>>2]+36>>2]](b)|0;ha[L[L[b>>2]+40>>2]](b,d,L[a+24>>2]);b=L[a+68>>2];ha[L[L[b>>2]+12>>2]](b,d,L[a+24>>2]);L[e+188>>2]=0;b=L[a+8>>2]}c=c+1|0;if((c|0)<(b|0)){continue}break}}b=L[a+16>>2];if(!(b?!b|!M[a+20|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+16>>2]=0;J[a+20|0]=1;L[a+8>>2]=0;L[a+12>>2]=0;return a|0}function jD(a,b){a=S(a);b=S(b);var c=0,d=0;d=fa-16|0;fa=d;P[d+12>>2]=a;P[d+8>>2]=b;c=oa(76);a=P[d+12>>2];b=P[d+8>>2];L[c+4>>2]=35;L[c+8>>2]=0;L[c>>2]=14328;L[c+44>>2]=1025758986;L[c+12>>2]=1065353216;L[c+16>>2]=1065353216;L[c>>2]=14044;L[c+20>>2]=1065353216;L[c+24>>2]=0;P[c+60>>2]=b;P[c+56>>2]=a;L[c>>2]=13492;L[c+64>>2]=0;L[c+68>>2]=1;L[c+4>>2]=11;P[c+28>>2]=a;L[c+72>>2]=2;P[c+36>>2]=a;P[c+32>>2]=b;P[c+52>>2]=a/S(_(S(S(a*a)+S(b*b))));fa=d+16|0;return c|0}function ax(a,b){a=S(a);b=S(b);var c=0,d=0;d=fa-16|0;fa=d;P[d+12>>2]=a;P[d+8>>2]=b;c=oa(76);a=P[d+12>>2];b=P[d+8>>2];L[c+4>>2]=35;L[c+8>>2]=0;L[c>>2]=14328;L[c+44>>2]=1025758986;L[c+12>>2]=1065353216;L[c+16>>2]=1065353216;L[c>>2]=14044;L[c+20>>2]=1065353216;L[c+24>>2]=0;P[c+60>>2]=b;P[c+56>>2]=a;L[c+4>>2]=11;L[c+64>>2]=1;L[c+68>>2]=0;L[c>>2]=13692;P[c+28>>2]=b;L[c+72>>2]=2;P[c+32>>2]=a;P[c+36>>2]=a;P[c+52>>2]=a/S(_(S(S(a*a)+S(b*b))));fa=d+16|0;return c|0}function XC(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=0,g=0;f=L[a+12>>2];if(f){g=L[a+4>>2];ha[L[L[g>>2]+16>>2]](g,f);L[a+12>>2]=0}f=L[a+8>>2];if(f){ha[L[L[f>>2]>>2]](f)|0;f=L[a+4>>2];ha[L[L[f>>2]+60>>2]](f,L[a+8>>2]);L[a+8>>2]=0}L[a+24>>2]=-1;L[a+28>>2]=-1;L[a+20>>2]=d;L[a+16>>2]=e;L[a+32>>2]=-1;L[a+36>>2]=-1;d=L[c+4>>2];f=L[d+4>>2];e=L[b+4>>2];if(L[e+4>>2]==25){if((f|0)==25){Hg(a,b,c,e,d);return}vd(a,b,c,e,d,0);return}if((f|0)==25){vd(a,c,b,d,e,1)}}function $w(a,b){a=S(a);b=S(b);var c=0,d=0;d=fa-16|0;fa=d;P[d+12>>2]=a;P[d+8>>2]=b;c=oa(76);a=P[d+12>>2];b=P[d+8>>2];L[c+4>>2]=35;L[c+8>>2]=0;L[c>>2]=14328;L[c+44>>2]=1025758986;L[c+12>>2]=1065353216;L[c+16>>2]=1065353216;L[c>>2]=14044;L[c+20>>2]=1065353216;L[c+24>>2]=0;P[c+60>>2]=b;P[c+56>>2]=a;L[c+4>>2]=11;L[c+64>>2]=0;L[c+68>>2]=2;L[c>>2]=13592;P[c+28>>2]=a;L[c+72>>2]=1;P[c+36>>2]=b;P[c+32>>2]=a;P[c+52>>2]=a/S(_(S(S(a*a)+S(b*b))));fa=d+16|0;return c|0}function cx(a){a=S(a);var b=0,c=0,d=0,e=0,f=0;d=fa-16|0;fa=d;P[d+12>>2]=a;f=oa(52);a=P[d+12>>2];c=fa-16|0;fa=c;L[c+12>>2]=f;P[c+8>>2]=a;b=L[c+12>>2];L[b+4>>2]=35;L[b+8>>2]=0;L[b>>2]=14328;L[b+44>>2]=1025758986;L[b+12>>2]=1065353216;L[b+16>>2]=1065353216;L[b>>2]=14044;L[b+20>>2]=1065353216;L[b+24>>2]=0;L[b>>2]=16192;L[b+4>>2]=8;a=P[c+8>>2];e=fa-16|0;L[e+12>>2]=b+28;P[e+8>>2]=a;P[L[e+12>>2]>>2]=P[e+8>>2];P[b+44>>2]=P[c+8>>2];fa=c+16|0;fa=d+16|0;return f|0}function Ux(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;a=L[c+8>>2];b=fa-16|0;fa=b;L[b+12>>2]=L[c+12>>2];L[b+8>>2]=a;d=L[b+8>>2];a=fa-16|0;fa=a;f=L[b+12>>2];L[a+12>>2]=f;L[a+8>>2]=d;d=L[a+12>>2];e=L[a+8>>2];la(d,e,e+16|0,e+32|0);la(d+16|0,L[a+8>>2]+4|0,L[a+8>>2]+20|0,L[a+8>>2]+36|0);la(d+32|0,L[a+8>>2]+8|0,L[a+8>>2]+24|0,L[a+8>>2]+40|0);fa=a+16|0;la(f+48|0,L[b+8>>2]+48|0,L[b+8>>2]+52|0,L[b+8>>2]+56|0);fa=b+16|0;fa=c+16|0}function aC(a,b){a=a|0;b=b|0;var c=0,d=0,e=0;e=L[b+12>>2];c=fa-16|0;d=c+8|0;L[d>>2]=L[b+8>>2];L[d+4>>2]=e;d=L[b+4>>2];L[c>>2]=L[b>>2];L[c+4>>2]=d;a=L[a+8>>2];L[a+4>>2]=1065353216;L[a+44>>2]=1065353216;L[a+48>>2]=0;L[a+36>>2]=0;L[a+40>>2]=0;L[a+28>>2]=0;L[a+32>>2]=0;L[a+24>>2]=1065353216;L[a+16>>2]=0;L[a+20>>2]=0;L[a+8>>2]=0;L[a+12>>2]=0;L[a+260>>2]=L[a+260>>2]+1;b=L[c+4>>2];L[a+52>>2]=L[c>>2];L[a+56>>2]=b;b=L[c+12>>2];L[a+60>>2]=L[c+8>>2];L[a+64>>2]=b}function ul(a,b,c,d,e){L[a+176>>2]=e;L[a+60>>2]=0;L[a+64>>2]=0;L[a+56>>2]=1017370378;P[a+52>>2]=d;L[a+8>>2]=b;L[a+168>>2]=16842752;L[a+172>>2]=0;L[a+12>>2]=c;L[a+44>>2]=1105933107;L[a+48>>2]=0;L[a+16>>2]=0;L[a+20>>2]=0;J[a+180|0]=1;L[a+24>>2]=1113325568;L[a+28>>2]=1092616192;J[a+181|0]=0;J[a+182|0]=0;L[a+36>>2]=1061752795;L[a+40>>2]=1060439283;L[a+108>>2]=0;J[a+144|0]=1;L[a>>2]=19124;L[a+140>>2]=0;L[a+132>>2]=0;L[a+136>>2]=0;L[a+68>>2]=0;L[a+72>>2]=0}function bj(a){var b=0,c=0;b=fa-32|0;fa=b;L[b+28>>2]=a;c=fa-16|0;a=L[b+28>>2];L[c+12>>2]=a;L[L[c+12>>2]>>2]=5048;L[a>>2]=5080;L[c+12>>2]=a+12;L[a+8>>2]=0;L[a+28>>2]=0;P[a+4>>2]=.009999999776482582;P[b+8>>2]=1;P[b+4>>2]=1;P[b>>2]=1;la(b+12|0,b+8|0,b+4|0,b);c=L[b+16>>2];L[a+12>>2]=L[b+12>>2];L[a+16>>2]=c;c=L[b+24>>2];L[a+20>>2]=L[b+20>>2];L[a+24>>2]=c;L[a+32>>2]=0;L[a+36>>2]=0;L[a+40>>2]=0;L[a+48>>2]=0;L[a+52>>2]=0;L[a+56>>2]=0;L[a+60>>2]=0;fa=b+32|0}function Vp(a){a=a|0;var b=S(0),c=0,d=S(0),e=0,f=0,g=0,h=0;e=fa-16|0;fa=e;L[e+12>>2]=a;c=L[e+12>>2];a=L[c+712>>2];if((a|0)>0){g=a&1;c=L[c+720>>2];a:{if((a|0)==1){a=0;break a}h=a&-2;a=0;while(1){d=b;b=P[(c+R(a,104)|0)+88>>2];d=S(d+(b>S(0)?S(S(1)/b):S(0)));b=P[(c+R(a|1,104)|0)+88>>2];b=S(d+(b>S(0)?S(S(1)/b):S(0)));a=a+2|0;f=f+2|0;if((h|0)!=(f|0)){continue}break}}if(g){d=b;b=P[(c+R(a,104)|0)+88>>2];b=S(d+(b>S(0)?S(S(1)/b):S(0)))}}fa=e+16|0;return S(b)}function QA(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0;h=L[b+8>>2];if((h|0)>0){d=L[a+16>>2];j=L[b+16>>2];a=0;while(1){c=L[(e<<2)+j>>2];a:{if(!(M[c+204|0]&3)){b=a;i=b<<3;f=i+d|0;g=L[f>>2];if((b|0)!=(g|0)){while(1){b=(g<<3)+d|0;L[f>>2]=L[b>>2];b=L[b>>2];f=(b<<3)+d|0;g=L[f>>2];if((b|0)!=(g|0)){continue}break}}L[c+208>>2]=b;L[(d+i|0)+4>>2]=e;L[c+212>>2]=-1;a=a+1|0;break a}L[c+208>>2]=-1;L[c+212>>2]=-2}e=e+1|0;if((h|0)!=(e|0)){continue}break}}}function so(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0;e=fa-48|0;fa=e;L[e+44>>2]=a;L[e+40>>2]=b;L[e+36>>2]=c;L[e+32>>2]=d;c=L[e+44>>2];L[e+28>>2]=0;while(1){if(L[e+28>>2]>2]){L[e+24>>2]=L[e+40>>2]+(L[e+28>>2]<<4);b=e+8|0;a=c+56|0;Vd(b,L[e+24>>2],a,a+16|0,a+32|0);a=a+(Rh(b)<<4)|0;d=L[a+4>>2];b=L[e+36>>2]+(L[e+28>>2]<<4)|0;L[b>>2]=L[a>>2];L[b+4>>2]=d;d=L[a+12>>2];L[b+8>>2]=L[a+8>>2];L[b+12>>2]=d;L[e+28>>2]=L[e+28>>2]+1;continue}break}fa=e+48|0}function $B(a,b){a=a|0;b=b|0;var c=0,d=0,e=0;J[a+148|0]=0;a:{if(!rd(a,b)){break a}J[a+148|0]=1;if(!rd(a,b)){break a}J[a+148|0]=1;if(!rd(a,b)){break a}J[a+148|0]=1;if(!rd(a,b)){break a}J[a+148|0]=1;if(!rd(a,b)){break a}J[a+148|0]=1}b=L[a+8>>2];c=b+52|0;d=L[c+4>>2];L[a+92>>2]=L[c>>2];L[a+96>>2]=d;c=L[b+64>>2];L[a+100>>2]=L[b+60>>2];L[a+104>>2]=c;c=L[b+52>>2];d=L[b+56>>2];e=L[b+64>>2];L[a+120>>2]=L[b+60>>2];L[a+124>>2]=e;L[a+112>>2]=c;L[a+116>>2]=d}function dC(a,b){a=a|0;b=b|0;var c=S(0),d=S(0),e=S(0),f=S(0),g=0;J[a+171|0]=1;g=L[b+4>>2];L[a+60>>2]=L[b>>2];L[a+64>>2]=g;g=L[b+12>>2];L[a+68>>2]=L[b+8>>2];L[a+72>>2]=g;c=P[a+68>>2];d=P[a+60>>2];f=P[a- -64>>2];e=S(S(1)/S(_(S(S(c*c)+S(S(d*d)+S(f*f))))));c=S(c*e);d=S(d*e);e=S(f*e);f=P[a+72>>2];a:{if(!(S(_(S(S(c*c)+S(S(d*d)+S(e*e)))))>2]=d;P[a+88>>2]=f;P[a+84>>2]=c;P[a+80>>2]=e}function NH(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0,g=0,h=0,i=0;L[7540]=L[7540]-1;ha[L[L[a>>2]+20>>2]](a,b);c=L[b+768>>2];e=c<<2;f=L[a+20>>2];d=e+f|0;h=L[d>>2];i=d;d=L[a+12>>2]-1|0;g=d<<2;L[i>>2]=L[f+g>>2];L[L[a+20>>2]+g>>2]=h;L[L[L[a+20>>2]+e>>2]+768>>2]=c;L[a+12>>2]=d;a=L[a+68>>2];c=L[a+16>>2];if(!(c>>>0>b>>>0|c+R(L[a>>2],L[a+4>>2])>>>0<=b>>>0)){L[b>>2]=L[a+12>>2];L[a+12>>2]=b;L[a+8>>2]=L[a+8>>2]+1;return}if(b){L[8514]=L[8514]+1;ha[L[6799]](b)}}function Gf(a,b,c,d,e){var f=0;f=fa-32|0;L[f+28>>2]=a;L[f+24>>2]=b;L[f+20>>2]=c;L[f+16>>2]=d;L[f+12>>2]=e;a=L[f+28>>2];a:{if(L[a+64>>2]==3){L[f+8>>2]=L[a+52>>2]+R(L[f+24>>2],L[a+56>>2]);L[L[f+20>>2]>>2]=N[L[f+8>>2]>>1];L[L[f+16>>2]>>2]=N[L[f+8>>2]+2>>1];L[L[f+12>>2]>>2]=N[L[f+8>>2]+4>>1];break a}L[f+4>>2]=L[a+52>>2]+R(L[f+24>>2],L[a+56>>2]);L[L[f+20>>2]>>2]=L[L[f+4>>2]>>2];L[L[f+16>>2]>>2]=L[L[f+4>>2]+4>>2];L[L[f+12>>2]>>2]=L[L[f+4>>2]+8>>2]}}function Ql(a){a=a|0;var b=0;L[a>>2]=17684;b=L[a+184>>2];if(!(b?!b|!M[a+188|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+184>>2]=0;J[a+188|0]=1;L[a+176>>2]=0;L[a+180>>2]=0;b=L[a+164>>2];if(!(b?!b|!M[a+168|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+164>>2]=0;J[a+168|0]=1;L[a+156>>2]=0;L[a+160>>2]=0;L[a>>2]=4720;b=L[a+84>>2];if(!(b?!b|!M[a+88|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+84>>2]=0;J[a+88|0]=1;L[a+76>>2]=0;L[a+80>>2]=0;return a|0}function IF(a,b){a=a|0;b=b|0;var c=S(0),d=0,e=S(0),f=S(0);d=ha[L[L[a>>2]+28>>2]](a)|0;c=S(P[d+8>>2]-P[b+8>>2]);e=S(c*c);c=S(P[d>>2]-P[b>>2]);f=S(c*c);c=S(P[d+4>>2]-P[b+4>>2]);if(S(e+S(f+S(c*c)))>S(1.1920928955078125e-7)){Vl(a,b);if(M[a+61|0]){b=L[a+52>>2];ha[L[L[b>>2]>>2]](b)|0;b=L[a+52>>2];if(b){L[8514]=L[8514]+1;ha[L[6799]](b)}}L[8513]=L[8513]+1;b=gm(ha[L[6798]](172,16)|0);L[a+52>>2]=b;fm(b,L[a+48>>2],M[a+60|0],a+16|0,a+32|0);J[a+61|0]=1}}function Bd(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0;d=L[b+188>>2];if(d){c=L[a+68>>2];c=ha[L[L[c>>2]+36>>2]](c)|0;ha[L[L[c>>2]+40>>2]](c,d,L[a+24>>2]);c=L[a+68>>2];ha[L[L[c>>2]+12>>2]](c,d,L[a+24>>2]);L[b+188>>2]=0}c=L[a+8>>2];a:{if((c|0)<=0){break a}e=L[a+16>>2];d=0;while(1){f=(d<<2)+e|0;if(L[f>>2]!=(b|0)){d=d+1|0;if((c|0)!=(d|0)){continue}break a}break}if((c|0)<=(d|0)){break a}d=c-1|0;c=d<<2;L[f>>2]=L[c+e>>2];L[c+L[a+16>>2]>>2]=b;L[a+8>>2]=d}}function wm(a,b){L[a+4>>2]=31;L[a+8>>2]=0;L[a+72>>2]=0;L[a+76>>2]=1065353216;L[a+64>>2]=0;L[a+68>>2]=1;L[a+48>>2]=-581039253;L[a+52>>2]=-581039253;L[a+32>>2]=1566444395;L[a+36>>2]=1566444395;J[a+28|0]=1;L[a>>2]=13272;L[a+24>>2]=0;L[a+88>>2]=0;L[a+80>>2]=1065353216;L[a+84>>2]=1065353216;L[a+56>>2]=-581039253;L[a+60>>2]=0;L[a+40>>2]=1566444395;L[a+44>>2]=0;L[a+16>>2]=0;L[a+20>>2]=0;if(b){L[8513]=L[8513]+1;L[a+64>>2]=hc(ha[L[6798]](60,16)|0)}}function bC(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0,g=0;L[a+172>>2]=0;K[a+168>>1]=0;L[a+16>>2]=0;L[a+20>>2]=0;L[a+60>>2]=0;L[a+64>>2]=0;L[a+68>>2]=0;L[a+72>>2]=0;a=L[L[a+8>>2]+284>>2];if(L[(ha[L[L[a>>2]+28>>2]](a)|0)+4>>2]>0){while(1){d=a,e=L[L[(ha[L[L[a>>2]+28>>2]](a)|0)+12>>2]>>2],f=L[L[(ha[L[L[a>>2]+28>>2]](a)|0)+12>>2]+4>>2],g=L[b+24>>2],c=L[L[a>>2]+12>>2],ha[c](d|0,e|0,f|0,g|0)|0;if(L[(ha[L[L[a>>2]+28>>2]](a)|0)+4>>2]>0){continue}break}}}function aw(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0,g=0,h=0;d=fa-16|0;fa=d;L[d+12>>2]=a;L[d+8>>2]=b;b=L[d+8>>2];a=fa+-64|0;fa=a;L[a+60>>2]=L[d+12>>2];L[a+56>>2]=b;b=L[a+60>>2];e=b+56|0;f=a+24|0;La(f,b+72|0,e);c=a+8|0;La(c,e+32|0,e);b=a+40|0;Ub(b,f,c);Nd(b);f=L[a+56>>2];c=fa-16|0;L[c+12>>2]=b;c=L[c+12>>2];g=fa-16|0;L[g+12>>2]=b;g=L[g+12>>2]+4|0;h=fa-16|0;L[h+12>>2]=b;h=L[h+12>>2]+8|0;P[a+4>>2]=Sa(e,b);vc(f,c,g,h,a+4|0);fa=a- -64|0;fa=d+16|0}function lH(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=S(d);e=e|0;f=f|0;var g=0;g=fa+-64|0;fa=g;L[g+60>>2]=f;L[g+56>>2]=e;e=L[a+212>>2];if(P[e+4>>2]>=d){L[g+12>>2]=L[a+216>>2];L[g+16>>2]=g+56;a=L[b+12>>2];L[g+28>>2]=L[b+8>>2];L[g+32>>2]=a;a=L[b+4>>2];L[g+20>>2]=L[b>>2];L[g+24>>2]=a;a=L[c+12>>2];L[g+44>>2]=L[c+8>>2];L[g+48>>2]=a;a=L[c+4>>2];L[g+36>>2]=L[c>>2];L[g+40>>2]=a;P[g+52>>2]=d;d=S(ha[L[L[e>>2]+12>>2]](e,g+12|0,1))}fa=g- -64|0;return S(d)}function kH(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=S(d);e=e|0;f=f|0;var g=0;g=fa+-64|0;fa=g;L[g+60>>2]=f;L[g+56>>2]=e;e=L[a+212>>2];if(P[e+4>>2]>=d){L[g+12>>2]=L[a+216>>2];L[g+16>>2]=g+56;a=L[b+12>>2];L[g+28>>2]=L[b+8>>2];L[g+32>>2]=a;a=L[b+4>>2];L[g+20>>2]=L[b>>2];L[g+24>>2]=a;a=L[c+12>>2];L[g+44>>2]=L[c+8>>2];L[g+48>>2]=a;a=L[c+4>>2];L[g+36>>2]=L[c>>2];L[g+40>>2]=a;P[g+52>>2]=d;d=S(ha[L[L[e>>2]+12>>2]](e,g+12|0,0))}fa=g- -64|0;return S(d)}function lk(a,b,c,d,e){var f=0;L[a>>2]=8684;L[a+4>>2]=L[b>>2];J[a+8|0]=e;L[a>>2]=21960;f=L[b>>2];b=a+12|0;L[b+52>>2]=0;L[b+48>>2]=f;J[b+76|0]=1;L[b>>2]=21988;L[b+72>>2]=0;J[b+96|0]=1;f=b- -64|0;L[f>>2]=0;L[f+4>>2]=0;L[b+92>>2]=0;J[b+116|0]=1;L[b+84>>2]=0;L[b+88>>2]=0;L[b+112>>2]=0;J[b+136|0]=1;L[b+104>>2]=0;L[b+108>>2]=0;L[b+132>>2]=0;L[b+124>>2]=0;L[b+128>>2]=0;L[b+4>>2]=L[(e?d:c)+8>>2];L[b+8>>2]=L[(e?c:d)+8>>2];jk(b+60|0);return a}function Ug(a,b,c){a=a|0;b=b|0;c=c|0;var d=S(0),e=S(0),f=S(0),g=S(0),h=S(0);ha[L[L[b>>2]+68>>2]](a,b,c);if(S(ha[L[L[b>>2]+48>>2]](b))!=S(0)){e=P[c+4>>2];d=P[c>>2];f=P[c+8>>2];g=S(ha[L[L[b>>2]+48>>2]](b));b=S(S(f*f)+S(S(d*d)+S(e*e)))>2]=P[a>>2]+S(g*S(h*d));P[a+4>>2]=P[a+4>>2]+S(g*S(e*d));P[a+8>>2]=P[a+8>>2]+S(g*S(f*d))}}function DC(a,b,c){a=a|0;b=b|0;c=c|0;b=L[b+164>>2]+(c<<6)|0;c=L[b+4>>2];L[a>>2]=L[b>>2];L[a+4>>2]=c;c=L[b+12>>2];L[a+8>>2]=L[b+8>>2];L[a+12>>2]=c;c=L[b+28>>2];L[a+24>>2]=L[b+24>>2];L[a+28>>2]=c;c=L[b+20>>2];L[a+16>>2]=L[b+16>>2];L[a+20>>2]=c;c=L[b+36>>2];L[a+32>>2]=L[b+32>>2];L[a+36>>2]=c;c=L[b+44>>2];L[a+40>>2]=L[b+40>>2];L[a+44>>2]=c;c=L[b+60>>2];L[a+56>>2]=L[b+56>>2];L[a+60>>2]=c;c=L[b+52>>2];L[a+48>>2]=L[b+48>>2];L[a+52>>2]=c}function OE(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=S(0),g=S(0),h=S(0),i=S(0),j=S(0),k=S(0),l=0;l=L[a+96>>2];e=L[a+104>>2]+((b|0)%(l|0)<<4)|0;f=P[e>>2];g=P[e+4>>2];h=P[e+8>>2];i=P[a+16>>2];j=P[a+20>>2];k=P[a+12>>2];L[c+12>>2]=0;P[c+8>>2]=h*j;P[c+4>>2]=g*i;P[c>>2]=f*k;b=L[a+104>>2]+((b+1|0)%(l|0)<<4)|0;f=P[b>>2];g=P[b+4>>2];h=P[b+8>>2];i=P[a+16>>2];j=P[a+20>>2];k=P[a+12>>2];L[d+12>>2]=0;P[d+8>>2]=h*j;P[d+4>>2]=g*i;P[d>>2]=f*k}function lc(a,b){var c=0,d=S(0),e=S(0),f=S(0);c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;b=fa-16|0;a=L[c+12>>2];L[b+12>>2]=a;d=P[L[b+12>>2]+4>>2];b=fa-16|0;L[b+12>>2]=L[c+8>>2];e=P[L[b+12>>2]>>2];b=fa-16|0;L[b+12>>2]=a+16;f=P[L[b+12>>2]+4>>2];b=fa-16|0;L[b+12>>2]=L[c+8>>2];d=S(S(d*e)+S(f*P[L[b+12>>2]+4>>2]));b=fa-16|0;L[b+12>>2]=a+32;e=P[L[b+12>>2]+4>>2];a=fa-16|0;L[a+12>>2]=L[c+8>>2];fa=c+16|0;return S(S(e*P[L[a+12>>2]+8>>2])+d)}function kc(a,b){var c=0,d=S(0),e=S(0),f=S(0);c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;b=fa-16|0;a=L[c+12>>2];L[b+12>>2]=a;d=P[L[b+12>>2]+8>>2];b=fa-16|0;L[b+12>>2]=L[c+8>>2];e=P[L[b+12>>2]>>2];b=fa-16|0;L[b+12>>2]=a+16;f=P[L[b+12>>2]+8>>2];b=fa-16|0;L[b+12>>2]=L[c+8>>2];d=S(S(d*e)+S(f*P[L[b+12>>2]+4>>2]));b=fa-16|0;L[b+12>>2]=a+32;e=P[L[b+12>>2]+8>>2];a=fa-16|0;L[a+12>>2]=L[c+8>>2];fa=c+16|0;return S(S(e*P[L[a+12>>2]+8>>2])+d)}function hy(a,b){a=a|0;b=b|0;var c=0,d=0;d=fa-16|0;fa=d;L[d+12>>2]=a;L[d+8>>2]=b;a=L[d+8>>2];b=fa-16|0;fa=b;L[b+12>>2]=L[d+12>>2];L[b+8>>2]=a;a=L[b+12>>2];c=fa-16|0;L[c+12>>2]=L[b+8>>2];P[a>>2]=P[a>>2]+P[L[c+12>>2]>>2];c=fa-16|0;L[c+12>>2]=L[b+8>>2];P[a+4>>2]=P[a+4>>2]+P[L[c+12>>2]+4>>2];c=fa-16|0;L[c+12>>2]=L[b+8>>2];P[a+8>>2]=P[a+8>>2]+P[L[c+12>>2]+8>>2];P[a+12>>2]=P[a+12>>2]+P[L[b+8>>2]+12>>2];fa=b+16|0;fa=d+16|0;return a|0}function gy(a,b){a=a|0;b=b|0;var c=0,d=0;d=fa-16|0;fa=d;L[d+12>>2]=a;L[d+8>>2]=b;a=L[d+8>>2];b=fa-16|0;fa=b;L[b+12>>2]=L[d+12>>2];L[b+8>>2]=a;a=L[b+12>>2];c=fa-16|0;L[c+12>>2]=L[b+8>>2];P[a>>2]=P[a>>2]-P[L[c+12>>2]>>2];c=fa-16|0;L[c+12>>2]=L[b+8>>2];P[a+4>>2]=P[a+4>>2]-P[L[c+12>>2]+4>>2];c=fa-16|0;L[c+12>>2]=L[b+8>>2];P[a+8>>2]=P[a+8>>2]-P[L[c+12>>2]+8>>2];P[a+12>>2]=P[a+12>>2]-P[L[b+8>>2]+12>>2];fa=b+16|0;fa=d+16|0;return a|0}function yl(a,b){var c=0,d=S(0),e=0,f=0,g=S(0),h=S(0),i=S(0),j=S(0),k=0,l=S(0),m=S(0);f=L[a>>2];if((f|0)>0){g=P[a+308>>2];h=P[b+8>>2];i=P[b+4>>2];j=P[b>>2];while(1){k=c;c=(e<<4)+a|0;d=S(h-P[c+12>>2]);l=S(d*d);d=S(j-P[c+4>>2]);m=S(d*d);d=S(i-P[c+8>>2]);c=k|S(l+S(m+S(d*d)))<=g;e=e+1|0;if((f|0)!=(e|0)){continue}break}}if(!(P[b+12>>2]!=P[a+304>>2]|P[b+8>>2]!=P[a+300>>2]|P[b+4>>2]!=P[a+296>>2])){c=P[b>>2]==P[a+292>>2]|c}return c&1}function $a(){var a=0,b=0;b=fa-32|0;fa=b;if(!(J[30088]&1)){a=fa-48|0;fa=a;if(!(J[30140]&1)){P[a+44>>2]=1;P[a+40>>2]=0;P[a+36>>2]=0;P[a+32>>2]=0;P[a+28>>2]=1;P[a+24>>2]=0;P[a+20>>2]=0;P[a+16>>2]=0;P[a+12>>2]=1;lf(30092,a+44|0,a+40|0,a+36|0,a+32|0,a+28|0,a+24|0,a+20|0,a+16|0,a+12|0);J[30140]=1}fa=a+48|0;P[b+12>>2]=0;P[b+8>>2]=0;P[b+4>>2]=0;a=b+16|0;la(a,b+12|0,b+8|0,b+4|0);Qf(30024,30092,a);J[30088]=1}fa=b+32|0;return 30024}function pC(a,b){a=a|0;b=b|0;var c=0,d=0,e=0;c=L[b+4>>2];L[a+52>>2]=L[b>>2];L[a+56>>2]=c;c=L[b+12>>2];L[a+60>>2]=L[b+8>>2];L[a+64>>2]=c;d=L[a+152>>2];c=d;a:{if(!d){break a}if(d&1){c=d-1|0;e=L[L[a+160>>2]+(c<<2)>>2];ha[L[L[e>>2]+24>>2]](e,b)}if((d|0)==1){break a}while(1){d=L[(L[a+160>>2]+(c<<2)|0)-4>>2];ha[L[L[d>>2]+24>>2]](d,b);c=c-2|0;d=L[L[a+160>>2]+(c<<2)>>2];ha[L[L[d>>2]+24>>2]](d,b);if(c){continue}break}}J[a+48|0]=1}function mc(a,b){var c=0,d=S(0),e=S(0),f=S(0);c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;b=fa-16|0;a=L[c+12>>2];L[b+12>>2]=a;d=P[L[b+12>>2]>>2];b=fa-16|0;L[b+12>>2]=L[c+8>>2];e=P[L[b+12>>2]>>2];b=fa-16|0;L[b+12>>2]=a+16;f=P[L[b+12>>2]>>2];b=fa-16|0;L[b+12>>2]=L[c+8>>2];d=S(S(d*e)+S(f*P[L[b+12>>2]+4>>2]));b=fa-16|0;L[b+12>>2]=a+32;e=P[L[b+12>>2]>>2];a=fa-16|0;L[a+12>>2]=L[c+8>>2];fa=c+16|0;return S(S(e*P[L[a+12>>2]+8>>2])+d)}function Rp(a,b){a=a|0;b=b|0;var c=0,d=0,e=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;e=L[c+12>>2];b=L[c+8>>2];a=fa+-64|0;fa=a;L[a+12>>2]=0;L[a+16>>2]=0;L[a+24>>2]=0;L[a+28>>2]=0;L[a+20>>2]=1065353216;L[a+32>>2]=0;L[a+36>>2]=0;L[a+40>>2]=1065353216;L[a+44>>2]=0;L[a+4>>2]=0;L[a+8>>2]=0;L[a>>2]=1065353216;d=L[b+12>>2];L[a+56>>2]=L[b+8>>2];L[a+60>>2]=d;d=L[b+4>>2];L[a+48>>2]=L[b>>2];L[a+52>>2]=d;jg(e,a);fa=a- -64|0;fa=c+16|0}function pA(a){a=a|0;var b=0;L[a>>2]=20608;b=L[a+80>>2];if(!(b?!b|!M[a+84|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+80>>2]=0;J[a+84|0]=1;L[a+72>>2]=0;L[a+76>>2]=0;b=L[a+60>>2];if(!(b?!b|!M[a- -64|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+60>>2]=0;J[a+64|0]=1;L[a+52>>2]=0;L[a+56>>2]=0;b=L[a+40>>2];if(!(b?!b|!M[a+44|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+40>>2]=0;J[a+44|0]=1;L[a+32>>2]=0;L[a+36>>2]=0;return a|0}function Qm(a){a=a|0;var b=0;L[a>>2]=11520;b=L[a+60>>2];if(!(b?!b|!M[a- -64|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+60>>2]=0;J[a+64|0]=1;L[a+52>>2]=0;L[a+56>>2]=0;b=L[a+40>>2];if(!(b?!b|!M[a+44|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+40>>2]=0;J[a+44|0]=1;L[a+32>>2]=0;L[a+36>>2]=0;b=L[a+16>>2];if(!(b?!b|!M[a+20|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+16>>2]=0;J[a+20|0]=1;L[a+8>>2]=0;L[a+12>>2]=0;return a|0}function xn(a){a=a|0;var b=0;L[a>>2]=6064;b=L[a- -64>>2];if(!(b?!b|!M[a+68|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+64>>2]=0;J[a+68|0]=1;L[a+56>>2]=0;L[a+60>>2]=0;b=L[a+44>>2];if(!(b?!b|!M[a+48|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+44>>2]=0;J[a+48|0]=1;L[a+36>>2]=0;L[a+40>>2]=0;b=L[a+16>>2];if(!(b?!b|!M[a+20|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+16>>2]=0;J[a+20|0]=1;L[a+8>>2]=0;L[a+12>>2]=0;return a|0}function fk(a){a=a|0;var b=0;L[a>>2]=22792;if(M[a+456|0]){b=L[a+452>>2];ha[L[L[b>>2]>>2]](b)|0;b=L[a+452>>2];if(b){L[8514]=L[8514]+1;ha[L[6799]](b)}}b=L[a+420>>2];if(!(b?!b|!M[a+424|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+420>>2]=0;J[a+424|0]=1;L[a+412>>2]=0;L[a+416>>2]=0;b=L[a+336>>2];if(!(b?!b|!M[a+340|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+336>>2]=0;J[a+340|0]=1;L[a+328>>2]=0;L[a+332>>2]=0;return pg(a)|0}function Yk(a){a=a|0;var b=0;L[a>>2]=20292;b=L[a+56>>2];if(!(b?!b|!M[a+60|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+56>>2]=0;J[a+60|0]=1;L[a+48>>2]=0;L[a+52>>2]=0;b=L[a+36>>2];if(!(b?!b|!M[a+40|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+36>>2]=0;J[a+40|0]=1;L[a+28>>2]=0;L[a+32>>2]=0;b=L[a+16>>2];if(!(b?!b|!M[a+20|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+16>>2]=0;J[a+20|0]=1;L[a+8>>2]=0;L[a+12>>2]=0;return a|0}function nG(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0,g=0;e=L[b>>2];e=ha[L[L[e>>2]+56>>2]](e,28)|0;f=M[a+4|0];g=L[a+8>>2];a=L[a+12>>2];L[e>>2]=8684;L[e+4>>2]=L[b>>2];L[e+24>>2]=a;L[e+20>>2]=g;J[e+16|0]=f;L[e+12>>2]=0;J[e+8|0]=0;L[e>>2]=10252;a=L[e+4>>2];b=f?d:c;c=f?c:d;if(ha[L[L[a>>2]+24>>2]](a,L[b+8>>2],L[c+8>>2])|0){a=L[e+4>>2];a=ha[L[L[a>>2]+12>>2]](a,L[b+8>>2],L[c+8>>2])|0;J[e+8|0]=1;L[e+12>>2]=a}return e|0}function Ig(a,b,c){var d=0,e=0;d=L[a+12>>2];if(!d){d=L[a+4>>2];d=ha[L[L[d>>2]+12>>2]](d,L[b+8>>2],L[c+8>>2])|0;L[a+12>>2]=d}L[L[a+16>>2]+4>>2]=d;e=L[a+4>>2];d=ha[L[L[e>>2]+8>>2]](e,b,c,d)|0;e=L[a+16>>2];ha[L[L[e>>2]+8>>2]](e,L[a+28>>2],L[a+24>>2]);e=L[a+16>>2];ha[L[L[e>>2]+12>>2]](e,L[a+36>>2],L[a+32>>2]);ha[L[L[d>>2]+8>>2]](d,b,c,L[a+20>>2],L[a+16>>2]);ha[L[L[d>>2]>>2]](d)|0;a=L[a+4>>2];ha[L[L[a>>2]+60>>2]](a,d)}function qf(a,b){var c=0,d=0;d=fa-16|0;fa=d;L[d+12>>2]=a;L[d+8>>2]=b;b=L[d+8>>2];c=L[b+4>>2];a=L[d+12>>2];L[a>>2]=L[b>>2];L[a+4>>2]=c;L[a+24>>2]=L[b+24>>2];c=L[b+20>>2];L[a+16>>2]=L[b+16>>2];L[a+20>>2]=c;c=L[b+12>>2];L[a+8>>2]=L[b+8>>2];L[a+12>>2]=c;mf(a+28|0,L[d+8>>2]+28|0);b=L[d+8>>2];c=L[b+80>>2];L[a+76>>2]=L[b+76>>2];L[a+80>>2]=c;L[a+92>>2]=L[b+92>>2];c=L[b+88>>2];L[a+84>>2]=L[b+84>>2];L[a+88>>2]=c;fa=d+16|0}function ou(a,b){a=a|0;b=b|0;var c=0,d=0,e=0;d=fa-16|0;fa=d;L[d+12>>2]=a;L[d+8>>2]=b;b=L[d+8>>2];a=fa-32|0;fa=a;L[a+28>>2]=L[d+12>>2];L[a+24>>2]=b;c=L[a+24>>2];e=L[c+4>>2];b=L[a+28>>2];L[b+348>>2]=L[c>>2];L[b+352>>2]=e;e=L[c+12>>2];L[b+356>>2]=L[c+8>>2];L[b+360>>2]=e;Ga(a+8|0,b+348|0,b+344|0);c=L[a+12>>2];L[b+560>>2]=L[a+8>>2];L[b+564>>2]=c;c=L[a+20>>2];L[b+568>>2]=L[a+16>>2];L[b+572>>2]=c;fa=a+32|0;fa=d+16|0}function _k(a,b){var c=S(0);L[a+20>>2]=0;L[a+24>>2]=0;J[a+28|0]=0;c=P[a+4>>2];a:{if(!(c>=S(0))){break a}b=Na(S(b-P[a>>2]),S(6.2831854820251465));b:{if(bS(3.1415927410125732))){break b}b=S(b+S(-6.2831854820251465))}c:{if(S(-c)>b){J[a+28|0]=1;b=S(-S(c+b));c=S(1);break c}if(!(b>c)){break a}J[a+28|0]=1;b=S(c-b);c=S(-1)}P[a+24>>2]=c;P[a+20>>2]=b}}function Uh(a,b,c){var d=0,e=0;d=fa-32|0;fa=d;L[d+28>>2]=a;L[d+24>>2]=0;L[d+20>>2]=b;L[d+16>>2]=c;c=L[d+28>>2];L[d+12>>2]=L[d+24>>2];while(1){if(L[d+12>>2]>2]){b=L[d+16>>2]+(L[d+12>>2]<<4)|0;a=fa-16|0;L[a+12>>2]=16;L[a+8>>2]=b;b=L[c+12>>2]+(L[d+12>>2]<<4)|0;e=L[b+4>>2];a=L[a+8>>2];L[a>>2]=L[b>>2];L[a+4>>2]=e;e=L[b+12>>2];L[a+8>>2]=L[b+8>>2];L[a+12>>2]=e;L[d+12>>2]=L[d+12>>2]+1;continue}break}fa=d+32|0}function BB(a,b,c){a=a|0;b=b|0;c=c|0;var d=S(0);a:{b:{if(c>>>0<=2){c:{switch(b-2|0){case 0:a=((c<<2)+a|0)+756|0;break b;case 2:a=((c<<2)+a|0)+772|0;break b;case 1:break c;default:break a}}a=((c<<2)+a|0)+740|0;break b}c=c-3|0;if(c>>>0>2){break a}d:{switch(b-2|0){case 0:a=((c<<6)+a|0)+900|0;break b;case 2:a=((c<<6)+a|0)+904|0;break b;case 1:break d;default:break a}}a=((c<<6)+a|0)+896|0}d=P[a>>2]}return S(d)}function lf(a,b,c,d,e,f,g,h,i,j){var k=0;k=fa-48|0;fa=k;L[k+40>>2]=a;L[k+36>>2]=b;L[k+32>>2]=c;L[k+28>>2]=d;L[k+24>>2]=e;L[k+20>>2]=f;L[k+16>>2]=g;L[k+12>>2]=h;L[k+8>>2]=i;L[k+4>>2]=j;a=L[k+40>>2];L[k+44>>2]=a;c=a+48|0;b=a;while(1){L[(fa-16|0)+12>>2]=b;b=b+16|0;if((c|0)!=(b|0)){continue}break}md(a,L[k+36>>2],L[k+32>>2],L[k+28>>2],L[k+24>>2],L[k+20>>2],L[k+16>>2],L[k+12>>2],L[k+8>>2],L[k+4>>2]);fa=k+48|0}function Uq(a,b){a=a|0;b=S(b);var c=0,d=0,e=0,f=S(0);c=fa-16|0;fa=c;L[c+12>>2]=a;P[c+8>>2]=b;d=L[c+12>>2];if(L[d+136>>2]>0){f=S(S(1)/P[L[d+116>>2]+344>>2]);while(1){b=S(0);a=L[d+144>>2]+R(e,284)|0;if(M[a+84|0]){b=P[a+272>>2];b=S(f*S(S(S(P[a+216>>2]*S(P[a+204>>2]-P[a+32>>2]))*P[a+268>>2])-S(P[a+(b>2]*b)));b=b>2]=b;e=e+1|0;if((e|0)>2]){continue}break}}fa=c+16|0}function TB(a,b){a=a|0;b=b|0;var c=0,d=0,e=S(0);a:{b:{if(M[a+527|0]){L[b>>2]=0;a=0;break b}L[b>>2]=3;L[b+4>>2]=3;c=L[a+28>>2];d=L[a+32>>2];wg(a,c+4|0,d+4|0,c+264|0,d+264|0);c:{if(!M[a+526|0]){break c}c=L[b>>2];L[b>>2]=c+1;d=L[b+4>>2];L[b+4>>2]=d-1;e=P[a+456>>2];if(!(e>P[a+444>>2])|!(P[a+448>>2]>2]=d-2;L[b>>2]=c+2}if(!M[a+525|0]){break a}L[b>>2]=L[b>>2]+1;a=L[b+4>>2]-1|0}L[b+4>>2]=a}}function th(a,b){var c=0;L[a>>2]=5728;hc(a+4|0);hc(a- -64|0);c=!b;J[a+192|0]=c;J[a+193|0]=0;J[a+194|0]=1;L[a+164>>2]=0;L[a+140>>2]=0;L[a+144>>2]=0;L[a+176>>2]=0;L[a+168>>2]=0;L[a+172>>2]=0;L[a+156>>2]=10;L[a+160>>2]=1;L[a+148>>2]=1;L[a+152>>2]=0;if(c){L[8513]=L[8513]+1;b=qh(ha[L[6798]](76,16)|0)}L[a+188>>2]=0;L[a+136>>2]=b;L[a+180>>2]=0;L[a+184>>2]=0;L[a+124>>2]=0;L[a+128>>2]=0;L[a+132>>2]=0;return a}function Sn(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0;e=fa-32|0;fa=e;L[e+28>>2]=a;L[e+24>>2]=b;L[e+20>>2]=c;L[e+16>>2]=d;L[e+12>>2]=L[L[e+24>>2]>>2];L[e+8>>2]=L[L[e+20>>2]>>2];L[e+4>>2]=Md(L[e+12>>2]);L[e>>2]=Md(L[e+8>>2]);if(L[e+4>>2]){a=L[e+4>>2];ha[L[L[a>>2]+32>>2]](a,L[e+20>>2],L[e+16>>2],L[e+24>>2])}if(L[e>>2]){a=L[e>>2];ha[L[L[a>>2]+32>>2]](a,L[e+24>>2],L[e+16>>2],L[e+20>>2])}fa=e+32|0;return 0}function Gc(a,b,c){var d=0,e=0,f=0,g=0;e=Fd(a,b);a:{if(!e){e=0;break a}f=L[a+8>>2];if((f|0)>=0){if(!f){break a}while(1){d=L[e+32>>2];if(!d){break a}e=d;g=g+1|0;if((f|0)!=(g|0)){continue}break}break a}e=L[a>>2]}d=L[c+4>>2];L[b>>2]=L[c>>2];L[b+4>>2]=d;d=L[c+28>>2];L[b+24>>2]=L[c+24>>2];L[b+28>>2]=d;d=L[c+20>>2];L[b+16>>2]=L[c+16>>2];L[b+20>>2]=d;d=L[c+12>>2];L[b+8>>2]=L[c+8>>2];L[b+12>>2]=d;Ed(a,e,b)}function Jh(a,b,c,d){var e=0;e=fa-32|0;fa=e;L[e+28>>2]=b;L[e+24>>2]=c;L[e+20>>2]=d;b=fa-16|0;L[b+12>>2]=a;c=N[L[e+28>>2]>>1];L[b+12>>2]=L[e+20>>2];P[e+16>>2]=S(c>>>0)/P[L[b+12>>2]>>2];c=N[L[e+28>>2]+2>>1];L[b+12>>2]=L[e+20>>2];P[e+12>>2]=S(c>>>0)/P[L[b+12>>2]+4>>2];c=N[L[e+28>>2]+4>>1];L[b+12>>2]=L[e+20>>2];P[e+8>>2]=S(c>>>0)/P[L[b+12>>2]+8>>2];la(a,e+16|0,e+12|0,e+8|0);hb(a,L[e+24>>2]);fa=e+32|0}function ua(a,b,c){var d=0;d=fa-32|0;fa=d;L[d+28>>2]=b;L[d+24>>2]=c;b=fa-16|0;L[b+12>>2]=L[d+28>>2];L[b+8>>2]=0;P[d+20>>2]=Sa(L[b+12>>2]+(L[b+8>>2]<<4)|0,L[d+24>>2]);b=fa-16|0;L[b+12>>2]=L[d+28>>2];L[b+8>>2]=1;P[d+16>>2]=Sa(L[b+12>>2]+(L[b+8>>2]<<4)|0,L[d+24>>2]);b=fa-16|0;L[b+12>>2]=L[d+28>>2];L[b+8>>2]=2;P[d+12>>2]=Sa(L[b+12>>2]+(L[b+8>>2]<<4)|0,L[d+24>>2]);la(a,d+20|0,d+16|0,d+12|0);fa=d+32|0}function $g(a,b){a=a|0;b=b|0;var c=S(0),d=S(0),e=S(0),f=S(0),g=S(0),h=S(0),i=S(0),j=S(0),k=S(0);c=S(ha[L[L[a>>2]+48>>2]](a));d=S(ha[L[L[a>>2]+48>>2]](a));e=S(ha[L[L[a>>2]+48>>2]](a));f=P[a+16>>2];g=P[a+32>>2];h=P[a+20>>2];i=P[a+36>>2];j=P[a+12>>2];k=P[a+28>>2];Ue(a,b);L[a+40>>2]=0;P[a+36>>2]=S(S(S(e+i)/h)*P[a+20>>2])-e;P[a+32>>2]=S(S(S(d+g)/f)*P[a+16>>2])-d;P[a+28>>2]=S(S(S(c+k)/j)*P[a+12>>2])-c}function rE(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=S(0),g=S(0),h=S(0),i=0,j=S(0),k=0,l=S(0);if((d|0)>0){while(1){f=P[a+32>>2];g=P[a+28>>2];k=i<<4;e=k+b|0;j=P[e>>2];h=P[e+8>>2];l=S(_(S(S(j*j)+S(h*h))));a:{if(l!=S(0)){g=S(g/l);h=S(h*g);g=S(j*g);f=P[e+4>>2]>2]>2]=h;P[e+4>>2]=f;P[e>>2]=g;i=i+1|0;if((i|0)!=(d|0)){continue}break}}}function qE(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=S(0),g=S(0),h=S(0),i=0,j=S(0),k=0,l=S(0);if((d|0)>0){while(1){f=P[a+36>>2];g=P[a+28>>2];k=i<<4;e=k+b|0;j=P[e>>2];h=P[e+4>>2];l=S(_(S(S(j*j)+S(h*h))));a:{if(l!=S(0)){g=S(g/l);h=S(h*g);g=S(j*g);f=P[e+8>>2]>2]>2]=f;P[e+4>>2]=h;P[e>>2]=g;i=i+1|0;if((i|0)!=(d|0)){continue}break}}}function pe(a){var b=0,c=0;b=fa-16|0;fa=b;P[b+8>>2]=a;c=fa-16|0;fa=c;P[c+12>>2]=P[b+8>>2];P[c+8>>2]=6.2831854820251465;a=Na(P[c+12>>2],P[c+8>>2]);fa=c+16|0;P[b+8>>2]=a;a:{if(P[b+8>>2]>2]=P[b+8>>2]+S(6.2831854820251465);break a}if(P[b+8>>2]>S(3.1415927410125732)){P[b+12>>2]=P[b+8>>2]+S(-6.2831854820251465);break a}P[b+12>>2]=P[b+8>>2]}fa=b+16|0;return P[b+12>>2]}function Wn(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;d=fa-144|0;fa=d;L[d+140>>2]=a;L[d+136>>2]=b;L[d+132>>2]=c;a=L[d+140>>2];Pb(d+68|0);b=L[a+4>>2];a:{if(ha[L[L[b>>2]+92>>2]](b)&1){b=d+4|0;c=L[a+4>>2];ha[L[L[c>>2]+132>>2]](b,c,L[d+136>>2]);sb(d+68|0,b);break a}ee(d+68|0)}a=L[a+4>>2];L[d>>2]=ha[L[L[a>>2]+124>>2]](a,L[d+136>>2]);a=L[d>>2];b=L[d+132>>2];ha[L[L[a>>2]+8>>2]](a,d+68|0,b,b+16|0);fa=d+144|0}function wa(a){var b=0,c=0,d=0;d=fa-16|0;fa=d;c=L[6803];a:{if(L[c>>2]==(a|0)){b=c;break a}b=L[c+24>>2];b:{if(b){while(1){if(L[b>>2]==(a|0)){break b}b=L[b+28>>2];if(b){continue}break}}b=sa(36);Vj(b,a,c);L[b+28>>2]=L[c+24>>2];L[c+24>>2]=b}L[6803]=b}L[b+4>>2]=L[b+4>>2]+1;a=L[b+16>>2];L[b+16>>2]=a+1;if(!a){xc(d);c=L[8515];a=L[d>>2]-L[c>>2]|0;L[b+12>>2]=(L[d+8>>2]-L[c+8>>2]|0)+R(a,1e6)}fa=d+16|0}function pE(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=S(0),g=S(0),h=S(0),i=0,j=S(0),k=0,l=S(0);if((d|0)>0){while(1){f=P[a+28>>2];g=P[a+32>>2];k=i<<4;e=k+b|0;j=P[e+4>>2];h=P[e+8>>2];l=S(_(S(S(j*j)+S(h*h))));a:{if(l!=S(0)){g=S(g/l);h=S(h*g);g=S(j*g);f=P[e>>2]>2]>2]=h;P[e+4>>2]=g;P[e>>2]=f;i=i+1|0;if((i|0)!=(d|0)){continue}break}}}function Hf(a,b){var c=0,d=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;b=fa-16|0;a=L[c+12>>2];L[b+12>>2]=a;L[c+4>>2]=L[L[b+12>>2]+4>>2];b=L[c+4>>2];d=fa-16|0;L[d+12>>2]=a;if(L[L[d+12>>2]+8>>2]==(b|0)){b=fa-16|0;L[b+12>>2]=a;d=L[L[b+12>>2]+4>>2];L[b+12>>2]=a;L[b+8>>2]=d;if(L[b+8>>2]){b=L[b+8>>2]<<1}else{b=1}Yh(a,b)}L[L[a+12>>2]+(L[a+4>>2]<<2)>>2]=L[L[c+8>>2]>>2];L[a+4>>2]=L[a+4>>2]+1;fa=c+16|0}function QF(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=S(0),g=S(0),h=S(0);e=fa-48|0;fa=e;ha[L[L[a>>2]+124>>2]](a,e+32|0,d);f=P[e+32>>2];g=P[e+36>>2];h=P[e+40>>2];L[b+12>>2]=0;P[b+8>>2]=h;P[b+4>>2]=g;P[b>>2]=f;L[e+12>>2]=0;P[e+8>>2]=-h;P[e+4>>2]=-g;P[e>>2]=-f;ha[L[L[a>>2]+64>>2]](e+16|0,a,e);a=L[e+28>>2];L[c+8>>2]=L[e+24>>2];L[c+12>>2]=a;a=L[e+20>>2];L[c>>2]=L[e+16>>2];L[c+4>>2]=a;fa=e+48|0}function Og(a){var b=0;L[a+4>>2]=35;L[a+8>>2]=0;L[a>>2]=14328;L[a+44>>2]=1025758986;L[a+12>>2]=1065353216;L[a+16>>2]=1065353216;L[a>>2]=14044;L[a+20>>2]=1065353216;L[a+24>>2]=0;J[a+88|0]=0;L[a+72>>2]=-1082130432;L[a+76>>2]=-1082130432;L[a+56>>2]=1065353216;L[a+60>>2]=1065353216;L[a>>2]=15968;L[a+52>>2]=0;L[a+80>>2]=-1082130432;L[a+84>>2]=0;b=a- -64|0;L[b>>2]=1065353216;L[b+4>>2]=0;return a}function qg(a,b){var c=0,d=0;c=fa-16|0;L[c+12>>2]=a;L[c+8>>2]=b;b=L[c+8>>2];d=L[b+4>>2];a=L[c+12>>2];L[a>>2]=L[b>>2];L[a+4>>2]=d;d=L[b+12>>2];L[a+8>>2]=L[b+8>>2];L[a+12>>2]=d;b=L[c+8>>2];d=L[b+20>>2];L[a+16>>2]=L[b+16>>2];L[a+20>>2]=d;d=L[b+28>>2];L[a+24>>2]=L[b+24>>2];L[a+28>>2]=d;b=L[c+8>>2];c=L[b+36>>2];L[a+32>>2]=L[b+32>>2];L[a+36>>2]=c;c=L[b+44>>2];L[a+40>>2]=L[b+40>>2];L[a+44>>2]=c}function gx(a,b){a=S(a);b=S(b);var c=0,d=0;d=fa-16|0;fa=d;P[d+12>>2]=a;P[d+8>>2]=b;c=oa(56);a=P[d+12>>2];b=P[d+8>>2];L[c+4>>2]=35;L[c+8>>2]=0;L[c>>2]=14328;L[c+44>>2]=1025758986;L[c+12>>2]=1065353216;L[c+16>>2]=1065353216;L[c>>2]=14044;L[c+20>>2]=1065353216;L[c+24>>2]=0;L[c+52>>2]=0;L[c>>2]=12948;L[c+4>>2]=10;P[c+28>>2]=b*S(.5);L[c+40>>2]=0;P[c+36>>2]=a;P[c+32>>2]=a;fa=d+16|0;return c|0}function fx(a,b){a=S(a);b=S(b);var c=0,d=0;d=fa-16|0;fa=d;P[d+12>>2]=a;P[d+8>>2]=b;c=oa(56);a=P[d+12>>2];b=P[d+8>>2];L[c+4>>2]=35;L[c+8>>2]=0;L[c>>2]=14328;L[c+44>>2]=1025758986;L[c+12>>2]=1065353216;L[c+16>>2]=1065353216;L[c>>2]=14044;L[c+20>>2]=1065353216;L[c+24>>2]=0;L[c+52>>2]=2;L[c>>2]=13048;L[c+4>>2]=10;P[c+28>>2]=a;L[c+40>>2]=0;P[c+36>>2]=b*S(.5);P[c+32>>2]=a;fa=d+16|0;return c|0}function RD(a,b){a=S(a);b=S(b);var c=0,d=0;d=fa-16|0;fa=d;P[d+12>>2]=a;P[d+8>>2]=b;c=oa(56);a=P[d+12>>2];b=P[d+8>>2];L[c+4>>2]=35;L[c+8>>2]=0;L[c>>2]=14328;L[c+44>>2]=1025758986;L[c+12>>2]=1065353216;L[c+16>>2]=1065353216;L[c>>2]=14044;L[c+20>>2]=1065353216;L[c+24>>2]=0;L[c+52>>2]=1;L[c+4>>2]=10;L[c>>2]=12848;P[c+28>>2]=a;L[c+40>>2]=0;P[c+36>>2]=a;P[c+32>>2]=b*S(.5);fa=d+16|0;return c|0}function rg(a,b,c){var d=0;d=fa-16|0;fa=d;L[a+28>>2]=c;L[a+24>>2]=-1;K[a+20>>1]=1;L[a+16>>2]=2139095039;L[a+8>>2]=-1;L[a+12>>2]=-1;L[a+4>>2]=b;L[a>>2]=20172;if(!M[33152]){L[d+8>>2]=0;L[d+12>>2]=0;L[d>>2]=0;L[d+4>>2]=0;ng(32536,d);J[33152]=1}L[d+8>>2]=0;L[d+12>>2]=0;L[d>>2]=0;L[d+4>>2]=0;ve(32536,S(0),d);L[a+44>>2]=0;L[a+36>>2]=0;L[a+40>>2]=1050253722;L[a+32>>2]=32536;fa=d+16|0;return a}function ki(a,b){var c=0,d=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;b=fa-16|0;a=L[c+12>>2];L[b+12>>2]=a;L[c+4>>2]=L[L[b+12>>2]+4>>2];b=L[c+4>>2];d=fa-16|0;L[d+12>>2]=a;if(L[L[d+12>>2]+8>>2]==(b|0)){b=fa-16|0;L[b+12>>2]=a;d=L[L[b+12>>2]+4>>2];L[b+12>>2]=a;L[b+8>>2]=d;if(L[b+8>>2]){b=L[b+8>>2]<<1}else{b=1}ji(a,b)}qf(L[a+12>>2]+R(L[a+4>>2],96)|0,L[c+8>>2]);L[a+4>>2]=L[a+4>>2]+1;fa=c+16|0}function _g(a,b){a=a|0;b=S(b);var c=S(0),d=S(0),e=S(0),f=S(0),g=S(0),h=S(0),i=S(0),j=S(0);c=S(ha[L[L[a>>2]+48>>2]](a));d=S(ha[L[L[a>>2]+48>>2]](a));e=S(ha[L[L[a>>2]+48>>2]](a));P[a+44>>2]=b;b=P[a+36>>2];f=P[a+32>>2];g=P[a+28>>2];h=S(ha[L[L[a>>2]+48>>2]](a));i=S(ha[L[L[a>>2]+48>>2]](a));j=S(ha[L[L[a>>2]+48>>2]](a));L[a+40>>2]=0;P[a+32>>2]=S(d+f)-i;P[a+28>>2]=S(c+g)-h;P[a+36>>2]=S(e+b)-j}function gH(a,b){a=a|0;b=b|0;var c=0,d=0,e=S(0),f=S(0),g=0,h=0;c=fa-32|0;fa=c;d=L[a+184>>2];e=P[d+4>>2];a:{if(e==S(0)){break a}b=L[b>>2];if(!(ha[L[L[d>>2]+8>>2]](d,L[b+188>>2])|0)){break a}f=P[a+188>>2];d=L[a+184>>2];g=L[a+192>>2];h=L[b+192>>2];L[c+24>>2]=-1;L[c+28>>2]=-1;L[c+20>>2]=b+4;L[c+16>>2]=b;L[c+12>>2]=h;L[c+8>>2]=0;kh(g,a+36|0,a+100|0,c+8|0,d,f)}fa=c+32|0;return e!=S(0)|0}function OF(a,b,c){a=a|0;b=b|0;c=c|0;var d=S(0),e=S(0),f=S(0),g=S(0),h=S(0),i=S(0);g=P[a+36>>2];h=P[a+32>>2];d=P[a+28>>2];e=S(1);a:{b:{c:{d:{e:{switch(c|0){case 1:e=S(-1);break b;case 2:f=S(1);break c;case 3:f=S(-1);break c;case 4:d=S(1);break d;case 0:break b;case 5:break e;default:break a}}d=S(-1)}i=d;e=S(0);d=g;break b}e=S(0);d=h}P[b+8>>2]=i;P[b+4>>2]=f;P[b>>2]=e;P[b+12>>2]=-d}}function ac(a){var b=0,c=0,d=0,e=0,f=S(0);b=fa-16|0;fa=b;d=L[a+8>>2];e=L[a+12>>2];a:{if((e|0)>0|(e|0)>=0){f=S(S(S(+(d>>>0)+ +(e>>>0)*4294967296)*S(0x10000000000000000))+S(+O[a>>2]+ +O[a+4>>2]*4294967296));break a}c=L[a>>2];a=L[a+4>>2];L[b>>2]=0-c;L[b+4>>2]=0-(a+((c|0)!=0)|0);a=!(a|c);c=d^-1;d=a+c|0;a=e^-1;L[b+8>>2]=d;L[b+12>>2]=d>>>0>>0?a+1|0:a;f=S(-ac(b))}fa=b+16|0;return f}function YF(a,b,c){a=a|0;b=b|0;c=c|0;var d=S(0),e=S(0),f=S(0),g=S(0),h=S(0),i=S(0),j=S(0),k=S(0),l=S(0);d=P[b+32>>2];e=P[b+36>>2];f=P[b+28>>2];g=S(ha[L[L[b>>2]+48>>2]](b));h=S(ha[L[L[b>>2]+48>>2]](b));i=S(ha[L[L[b>>2]+48>>2]](b));j=P[c>>2];k=P[c+4>>2];l=P[c+8>>2];L[a+12>>2]=0;e=S(e+i);P[a+8>>2]=l>=S(0)?e:S(-e);d=S(d+h);P[a+4>>2]=k>=S(0)?d:S(-d);d=S(f+g);P[a>>2]=j>=S(0)?d:S(-d)}function RF(a,b,c){a=a|0;b=b|0;c=c|0;var d=S(0),e=S(0),f=S(0),g=S(0),h=S(0),i=S(0);e=P[a+36>>2];d=P[a+32>>2];f=P[a+28>>2];g=S(ha[L[L[a>>2]+48>>2]](a));h=S(ha[L[L[a>>2]+48>>2]](a));i=S(ha[L[L[a>>2]+48>>2]](a));L[c+12>>2]=0;d=S(d+h);a=b>>>1&1;P[c+4>>2]=S(d*S(!a|0))-S(S(a|0)*d);d=S(f+g);a=b&1;P[c>>2]=S(d*S(!a|0))-S(S(a|0)*d);e=S(e+i);a=b>>>2&1;P[c+8>>2]=S(e*S(!a|0))-S(S(a|0)*e)}function ie(a,b,c,d,e){var f=0;f=fa-32|0;fa=f;L[f+28>>2]=a;L[f+24>>2]=b;L[f+20>>2]=c;L[f+16>>2]=d;L[f+12>>2]=e;b=L[f+24>>2];c=L[f+20>>2];d=L[f+16>>2];e=L[f+12>>2];a=fa-32|0;L[a+28>>2]=L[f+28>>2];L[a+24>>2]=b;L[a+20>>2]=c;L[a+16>>2]=d;L[a+12>>2]=e;b=L[a+28>>2];P[b>>2]=P[L[a+24>>2]>>2];P[b+4>>2]=P[L[a+20>>2]>>2];P[b+8>>2]=P[L[a+16>>2]>>2];P[b+12>>2]=P[L[a+12>>2]>>2];fa=f+32|0}function ee(a){var b=0,c=0,d=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=fa-48|0;fa=a;c=L[b+12>>2];L[a+44>>2]=c;d=L[a+44>>2];P[a+40>>2]=1;P[a+36>>2]=0;P[a+32>>2]=0;P[a+28>>2]=0;P[a+24>>2]=1;P[a+20>>2]=0;P[a+16>>2]=0;P[a+12>>2]=0;P[a+8>>2]=1;md(d,a+40|0,a+36|0,a+32|0,a+28|0,a+24|0,a+20|0,a+16|0,a+12|0,a+8|0);fa=a+48|0;P[b+8>>2]=0;P[b+4>>2]=0;P[b>>2]=0;la(c+48|0,b+8|0,b+4|0,b);fa=b+16|0}function sp(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0,g=0;d=fa-16|0;fa=d;L[d+12>>2]=a;L[d+8>>2]=b;e=L[d+8>>2];a=0;b=L[d+12>>2];c=L[b+328>>2];a:{if((c|0)<=0){break a}f=L[b+336>>2];while(1){g=(a<<2)+f|0;if(L[g>>2]!=(e|0)){a=a+1|0;if((c|0)!=(a|0)){continue}break a}break}if((a|0)>=(c|0)){break a}a=c-1|0;c=a<<2;L[g>>2]=L[c+f>>2];L[c+L[b+336>>2]>>2]=e;L[b+328>>2]=a}Bd(b,e);fa=d+16|0}function bn(a){a=a|0;var b=0,c=0,d=0,e=0;L[a>>2]=9768;d=L[a+12>>2];if((d|0)>0){while(1){e=b<<2;c=L[e+L[a+20>>2]>>2];if(c){ha[L[L[c>>2]>>2]](c)|0;c=L[a+4>>2];ha[L[L[c>>2]+60>>2]](c,L[L[a+20>>2]+e>>2])}b=b+1|0;if((d|0)!=(b|0)){continue}break}}b=L[a+20>>2];if(!(b?!b|!M[a+24|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+20>>2]=0;J[a+24|0]=1;L[a+12>>2]=0;L[a+16>>2]=0;return a|0}function _F(a,b,c){a=a|0;b=S(b);c=c|0;var d=S(0),e=S(0),f=S(0),g=S(0),h=S(0),i=S(0);d=P[a+36>>2];e=P[a+32>>2];f=P[a+28>>2];g=S(ha[L[L[a>>2]+48>>2]](a));h=S(ha[L[L[a>>2]+48>>2]](a));i=S(ha[L[L[a>>2]+48>>2]](a));L[c+12>>2]=0;b=S(b/S(12));f=S(f+g);f=S(f+f);f=S(f*f);e=S(e+h);e=S(e+e);e=S(e*e);P[c+8>>2]=b*S(f+e);d=S(d+i);d=S(d+d);d=S(d*d);P[c+4>>2]=b*S(f+d);P[c>>2]=b*S(e+d)}function ap(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=S(d);e=e|0;f=f|0;var g=0;g=fa+-64|0;fa=g;L[g+60>>2]=a;L[g+56>>2]=b;L[g+52>>2]=c;P[g+48>>2]=d;L[g+44>>2]=e;L[g+40>>2]=f;a=L[g+60>>2];L[g+36>>2]=27558;b=L[g+36>>2];c=L[g+56>>2];e=L[g+52>>2];d=P[g+48>>2];f=L[g+44>>2];L[g+28>>2]=L[g+40>>2];L[g+24>>2]=f;Q[g+16>>3]=d;L[g+8>>2]=e;L[g+4>>2]=c;L[g>>2]=a;$(b|0,1281,g|0)|0;fa=g- -64|0}function Tn(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;d=fa-32|0;fa=d;L[d+28>>2]=a;L[d+24>>2]=b;L[d+20>>2]=c;L[d+16>>2]=L[L[d+24>>2]>>2];L[d+12>>2]=L[L[d+20>>2]>>2];L[d+8>>2]=Md(L[d+16>>2]);L[d+4>>2]=Md(L[d+12>>2]);if(L[d+8>>2]){a=L[d+8>>2];ha[L[L[a>>2]+28>>2]](a,L[d+20>>2],L[d+24>>2])}if(L[d+4>>2]){a=L[d+4>>2];ha[L[L[a>>2]+28>>2]](a,L[d+24>>2],L[d+20>>2])}fa=d+32|0;return 0}function nA(a){a=a|0;var b=0;L[a>>2]=20608;b=L[a+80>>2];if(!(b?!b|!M[a+84|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+80>>2]=0;J[a+84|0]=1;L[a+72>>2]=0;L[a+76>>2]=0;b=L[a+60>>2];if(!(b?!b|!M[a- -64|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+60>>2]=0;J[a+64|0]=1;L[a+52>>2]=0;L[a+56>>2]=0;b=L[a+40>>2];if(!(b?!b|!M[a+44|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}ra(a)}function mk(a,b){a=a|0;b=b|0;var c=0,d=0,e=S(0);c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;b=L[c+8>>2];a=fa-16|0;fa=a;L[a+12>>2]=L[c+12>>2];L[a+8>>2]=b;b=L[a+12>>2];L[a+4>>2]=0;while(1){if(L[a+4>>2]<3){d=fa-16|0;L[d+12>>2]=L[a+8>>2];e=pe(P[L[d+12>>2]+(L[a+4>>2]<<2)>>2]);P[((b+868|0)+(L[a+4>>2]<<6)|0)+4>>2]=e;L[a+4>>2]=L[a+4>>2]+1;continue}break}fa=a+16|0;fa=c+16|0}function xc(a){var b=0,c=0,d=0,e=0;d=+ca();b=d/1e3;a:{if(T(b)<0x8000000000000000){e=~~b>>>0;c=T(b)>=1?~~(b>0?V(X(b*2.3283064365386963e-10),4294967295):Y((b-+(~~b>>>0>>>0))*2.3283064365386963e-10))>>>0:0;break a}c=-2147483648}L[a>>2]=e;L[a+4>>2]=c;b=(d-(+(mI(e,c,1e3,0)>>>0)+ +(ga|0)*4294967296))*1e3;b:{if(T(b)<2147483648){c=~~b;break b}c=-2147483648}L[a+8>>2]=c}function _b(a,b){var c=0,d=S(0),e=S(0),f=S(0);c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;a=L[c+12>>2];d=P[a>>2];b=fa-16|0;L[b+12>>2]=L[c+8>>2];e=P[L[b+12>>2]>>2];f=P[a+4>>2];b=fa-16|0;L[b+12>>2]=L[c+8>>2];d=S(S(d*e)+S(f*P[L[b+12>>2]+4>>2]));e=P[a+8>>2];b=fa-16|0;L[b+12>>2]=L[c+8>>2];fa=c+16|0;return S(S(P[a+12>>2]*P[L[c+8>>2]+12>>2])+S(S(e*P[L[b+12>>2]+8>>2])+d))}function km(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=S(0),f=S(0),g=S(0),h=S(0),i=S(0),j=S(0);h=S(ha[L[L[a>>2]+48>>2]](a));i=S(ha[L[L[a>>2]+48>>2]](a));j=S(ha[L[L[a>>2]+48>>2]](a));e=P[b+52>>2];f=P[b+56>>2];g=P[b+48>>2];L[c+12>>2]=0;P[c+8>>2]=f-j;P[c+4>>2]=e-i;P[c>>2]=g-h;e=P[b+52>>2];f=P[b+56>>2];g=P[b+48>>2];L[d+12>>2]=0;P[d+8>>2]=j+f;P[d+4>>2]=i+e;P[d>>2]=h+g}function Ey(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;if(Wa(a,L[b+8>>2],e)){if(!(L[b+28>>2]==1|L[b+4>>2]!=(c|0))){L[b+28>>2]=d}return}a:{if(!Wa(a,L[b>>2],e)){break a}if(!(L[b+16>>2]!=(c|0)&L[b+20>>2]!=(c|0))){if((d|0)!=1){break a}L[b+32>>2]=1;return}L[b+20>>2]=c;L[b+32>>2]=d;L[b+40>>2]=L[b+40>>2]+1;if(!(L[b+36>>2]!=1|L[b+24>>2]!=2)){J[b+54|0]=1}L[b+44>>2]=4}}function hG(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0,g=0,h=0,i=0;a:{e=L[a+268>>2];if((e|0)<=0){break a}h=d?d:L[a+188>>2];i=L[b>>2];f=L[a+276>>2];d=0;while(1){g=(d<<2)+f|0;if(L[g>>2]!=(i|0)){d=d+1|0;if((e|0)!=(d|0)){continue}break a}break}if((d|0)>=(e|0)){break a}d=e-1|0;L[g>>2]=L[(d<<2)+f>>2];L[a+268>>2]=d;a=L[a+284>>2];ha[L[L[a>>2]+12>>2]](a,h,b,c)|0}}function JA(a,b){a=a|0;b=b|0;var c=0,d=0,e=0;c=L[b+4>>2];L[a+248>>2]=L[b>>2];L[a+252>>2]=c;c=L[b+12>>2];L[a+256>>2]=L[b+8>>2];L[a+260>>2]=c;c=L[a+232>>2];if((c|0)>0){while(1){a:{b:{e=L[L[a+240>>2]+(d<<2)>>2];switch(L[e+216>>2]-2|0){case 0:case 3:break a;default:break b}}if(J[e+504|0]&1){break a}te(e,b);c=L[a+232>>2]}d=d+1|0;if((c|0)>(d|0)){continue}break}}}function pk(a,b){a=a|0;b=b|0;var c=0,d=0,e=S(0);c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;b=L[c+8>>2];a=fa-16|0;fa=a;L[a+12>>2]=L[c+12>>2];L[a+8>>2]=b;b=L[a+12>>2];L[a+4>>2]=0;while(1){if(L[a+4>>2]<3){d=fa-16|0;L[d+12>>2]=L[a+8>>2];e=pe(P[L[d+12>>2]+(L[a+4>>2]<<2)>>2]);P[(b+868|0)+(L[a+4>>2]<<6)>>2]=e;L[a+4>>2]=L[a+4>>2]+1;continue}break}fa=a+16|0;fa=c+16|0}function jI(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0;e=fa-48|0;fa=e;L[e+44>>2]=d;L[e+40>>2]=5992;d=L[b+12>>2];L[e+16>>2]=L[b+8>>2];L[e+20>>2]=d;d=L[b+4>>2];L[e+8>>2]=L[b>>2];L[e+12>>2]=d;b=L[c+12>>2];L[e+32>>2]=L[c+8>>2];L[e+36>>2]=b;b=L[c+4>>2];L[e+24>>2]=L[c>>2];L[e+28>>2]=b;b=e+8|0;c=e+40|0;Vb(a+4|0,L[a+4>>2],b,c);a=a- -64|0;Vb(a,L[a>>2],b,c);fa=e+48|0}function xt(a,b,c){a=a|0;b=b|0;c=S(c);var d=0;d=fa-16|0;fa=d;L[d+12>>2]=a;L[d+8>>2]=b;P[d+4>>2]=c;b=L[d+8>>2];c=P[d+4>>2];a=fa-16|0;L[a+12>>2]=L[d+12>>2];L[a+8>>2]=b;P[a+4>>2]=c;b=L[a+12>>2];a:{b:{switch(L[a+8>>2]-3|0){case 0:P[b+452>>2]=P[a+4>>2];break a;case 1:P[b+448>>2]=P[a+4>>2];break a;case 2:break b;default:break a}}P[b+444>>2]=P[a+4>>2]}fa=d+16|0}function dj(a,b){var c=0,d=0,e=0,f=0;c=fa-16|0;fa=c;L[c+12>>2]=a;J[c+11|0]=b;a=L[c+12>>2];If(a);L[a>>2]=17684;b=fa-16|0;fa=b;e=a+144|0;L[b+12>>2]=e;f=fa-16|0;d=L[b+12>>2];L[f+12>>2]=d;L[L[f+12>>2]>>2]=5048;L[d>>2]=4916;L[d+4>>2]=0;fa=b+16|0;Mb(a+152|0);Mb(a+172|0);L[a+148>>2]=a;b=fa-16|0;L[b+12>>2]=a+68;L[b+8>>2]=e;L[L[b+12>>2]+72>>2]=L[b+8>>2];fa=c+16|0}function my(a){a=a|0;var b=0,c=0;b=fa-32|0;fa=b;L[b+28>>2]=a;if(!M[29704]){Ka(29688);J[29704]=1}a=fa-16|0;fa=a;L[a+12>>2]=L[b+28>>2];c=L[a+12>>2];P[a+8>>2]=-P[c>>2];P[a+4>>2]=-P[c+4>>2];P[a>>2]=-P[c+8>>2];ie(b+12|0,a+8|0,a+4|0,a,c+12|0);fa=a+16|0;a=L[b+16>>2];L[7422]=L[b+12>>2];L[7423]=a;a=L[b+24>>2];L[7424]=L[b+20>>2];L[7425]=a;fa=b+32|0;return 29688}function KC(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0,g=0;a:{e=L[a+152>>2];f=e;if(!e){break a}if(e&1){f=e-1|0;g=L[L[a+160>>2]+(f<<2)>>2];ha[L[L[g>>2]+144>>2]](g,b,c,d)}if((e|0)==1){break a}while(1){e=L[(L[a+160>>2]+(f<<2)|0)-4>>2];ha[L[L[e>>2]+144>>2]](e,b,c,d);f=f-2|0;e=L[L[a+160>>2]+(f<<2)>>2];ha[L[L[e>>2]+144>>2]](e,b,c,d);if(f){continue}break}}}function bp(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=S(f);var g=0;g=fa-32|0;fa=g;L[g+28>>2]=a;L[g+24>>2]=b;L[g+20>>2]=c;L[g+16>>2]=d;L[g+12>>2]=e;P[g+8>>2]=f;a=L[g+28>>2];ha[L[L[a>>2]+8>>2]](a,L[g+24>>2],L[g+20>>2],L[g+12>>2]);ha[L[L[a>>2]+8>>2]](a,L[g+20>>2],L[g+16>>2],L[g+12>>2]);ha[L[L[a>>2]+8>>2]](a,L[g+16>>2],L[g+24>>2],L[g+12>>2]);fa=g+32|0}function ai(a,b,c,d){var e=0;e=fa-32|0;L[e+28>>2]=a;L[e+24>>2]=b;L[e+20>>2]=c;P[e+16>>2]=d;a=L[e+28>>2];P[e+12>>2]=S(1)-P[e+16>>2];P[a>>2]=S(P[e+12>>2]*P[L[e+24>>2]>>2])+S(P[e+16>>2]*P[L[e+20>>2]>>2]);P[a+4>>2]=S(P[e+12>>2]*P[L[e+24>>2]+4>>2])+S(P[e+16>>2]*P[L[e+20>>2]+4>>2]);P[a+8>>2]=S(P[e+12>>2]*P[L[e+24>>2]+8>>2])+S(P[e+16>>2]*P[L[e+20>>2]+8>>2])}function XD(a,b,c){a=a|0;b=S(b);c=c|0;var d=S(0),e=S(0),f=S(0),g=S(0),h=S(0),i=S(0);d=P[a+76>>2];g=P[a+60>>2];e=P[a+72>>2];h=P[a+56>>2];f=P[a+68>>2];i=P[a+52>>2];L[c+12>>2]=0;b=S(b/S(12));f=S(S(f-i)*S(.5));f=S(f+f);f=S(f*f);e=S(S(e-h)*S(.5));e=S(e+e);e=S(e*e);P[c+8>>2]=b*S(f+e);d=S(S(d-g)*S(.5));d=S(d+d);d=S(d*d);P[c+4>>2]=b*S(f+d);P[c>>2]=b*S(e+d)}function WF(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0,g=0,h=S(0),i=S(0),j=S(0),k=S(0),l=S(0),m=S(0);if((d|0)>0){while(1){g=f<<4;e=g+b|0;k=P[e>>2];l=P[e+4>>2];m=P[e+8>>2];h=P[a+28>>2];i=P[a+32>>2];j=P[a+36>>2];e=c+g|0;L[e+12>>2]=0;P[e+8>>2]=m>=S(0)?j:S(-j);P[e+4>>2]=l>=S(0)?i:S(-i);P[e>>2]=k>=S(0)?h:S(-h);f=f+1|0;if((f|0)!=(d|0)){continue}break}}}function LC(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0,g=0;a:{e=L[a+152>>2];f=e;if(!e){break a}if(e&1){f=e-1|0;g=L[L[a+160>>2]+(f<<2)>>2];ha[L[L[g>>2]+64>>2]](g,b,c,d)}if((e|0)==1){break a}while(1){e=L[(L[a+160>>2]+(f<<2)|0)-4>>2];ha[L[L[e>>2]+64>>2]](e,b,c,d);f=f-2|0;e=L[L[a+160>>2]+(f<<2)>>2];ha[L[L[e>>2]+64>>2]](e,b,c,d);if(f){continue}break}}}function Gm(a,b,c,d,e){var f=0,g=0;while(1){a:{b:{if(N[e>>1]>1]|N[d>>1]>N[b+6>>1]|(N[e+4>>1]>1]|N[d+4>>1]>N[b+10>>1])){break b}if(N[e+2>>1]>1]|N[d+2>>1]>N[b+8>>1]){break b}f=L[b+12>>2];if((f|0)<0){break a}ha[L[L[c>>2]+8>>2]](c,f>>>21|0,f&2097151)}return}f=b+16|0;Gm(a,f,c,d,e);g=f;f=L[b+28>>2];b=(f|0)<0?g-(f<<4)|0:b+32|0;continue}}function nC(a,b){a=a|0;b=S(b);var c=0,d=0,e=0;P[a+12>>2]=b;c=L[a+152>>2];d=c;a:{if(!c){break a}if(c&1){d=c-1|0;e=L[L[a+160>>2]+(d<<2)>>2];ha[L[L[e>>2]+44>>2]](e,b)}if((c|0)==1){break a}while(1){c=L[(L[a+160>>2]+(d<<2)|0)-4>>2];ha[L[L[c>>2]+44>>2]](c,b);d=d-2|0;c=L[L[a+160>>2]+(d<<2)>>2];ha[L[L[c>>2]+44>>2]](c,b);if(d){continue}break}}J[a+48|0]=1}function Zp(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;b=L[c+8>>2];a=L[c+12>>2];e=L[a+712>>2];if((e|0)>0){f=L[a+720>>2];while(1){a=R(d,104)+f|0;if(P[a+88>>2]>S(0)){P[a+56>>2]=P[b>>2]+P[a+56>>2];P[a+60>>2]=P[b+4>>2]+P[a+60>>2];a=a- -64|0;P[a>>2]=P[b+8>>2]+P[a>>2]}d=d+1|0;if((e|0)!=(d|0)){continue}break}}fa=c+16|0}function Wf(a,b,c,d){J[a+53|0]=1;a:{if(L[a+4>>2]!=(c|0)){break a}J[a+52|0]=1;c=L[a+16>>2];b:{if(!c){L[a+36>>2]=1;L[a+24>>2]=d;L[a+16>>2]=b;if((d|0)!=1){break a}if(L[a+48>>2]==1){break b}break a}if((b|0)==(c|0)){c=L[a+24>>2];if((c|0)==2){L[a+24>>2]=d;c=d}if(L[a+48>>2]!=1){break a}if((c|0)==1){break b}break a}L[a+36>>2]=L[a+36>>2]+1}J[a+54|0]=1}}function Hq(){var a=0,b=0,c=0;c=sa(100);a=fa-32|0;fa=a;L[a+28>>2]=c;b=L[a+28>>2];P[b>>2]=1.2000000476837158;P[b+4>>2]=0;P[b+8>>2]=0;P[b+12>>2]=1e3;P[a+24>>2]=0;P[a+20>>2]=0;P[a+16>>2]=0;la(b+16|0,a+24|0,a+20|0,a+16|0);L[b+32>>2]=0;L[b+36>>2]=0;P[a+12>>2]=0;P[a+8>>2]=-10;P[a+4>>2]=0;la(b+40|0,a+12|0,a+8|0,a+4|0);rf(b+56|0);fa=a+32|0;return c|0}function ke(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,f=0,g=0,h=0;d=fa-16|0;fa=d;L[d+12>>2]=a;L[d+8>>2]=b;L[d+4>>2]=c;b=L[d+12>>2];h=L[d+4>>2];a=fa-48|0;fa=a;c=L[d+8>>2];e=L[c+192>>2];f=a+32|0;g=a+16|0;ha[L[L[e>>2]+8>>2]](e,c+4|0,f,g);L[a+12>>2]=h;L[a+4>>2]=c;L[a>>2]=8460;L[a+8>>2]=b;b=L[b+68>>2];ha[L[L[b>>2]+28>>2]](b,f,g,a);fa=a+48|0;fa=d+16|0}function rm(a,b,c,d,e,f,g,h){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;var i=0,j=S(0);i=fa-32|0;fa=i;L[i+28>>2]=a;L[i+24>>2]=b;L[i+20>>2]=c;L[i+16>>2]=d;L[i+12>>2]=e;L[i+8>>2]=f;L[i+4>>2]=g;L[i>>2]=h;a=L[i+28>>2];j=S(ha[L[L[a>>2]+12>>2]](a,L[i+24>>2],L[i+20>>2],L[i+16>>2],L[i+12>>2],L[i+8>>2],L[i+4>>2],L[i>>2]));fa=i+32|0;return S(j)}function hH(a,b){a=a|0;b=b|0;var c=0,d=0,e=S(0),f=0;c=fa-32|0;fa=c;d=L[a+216>>2];e=P[d+4>>2];a:{if(e==S(0)){break a}b=L[b>>2];if(!(ha[L[L[d>>2]+8>>2]](d,L[b+188>>2])|0)){break a}d=L[a+216>>2];f=L[b+192>>2];L[c+24>>2]=-1;L[c+28>>2]=-1;L[c+20>>2]=b+4;L[c+16>>2]=b;L[c+12>>2]=f;L[c+8>>2]=0;Ze(a+68|0,a+132|0,c+8|0,d)}fa=c+32|0;return e!=S(0)|0}function tb(a,b,c){var d=0,e=0,f=0,g=0,h=0,i=0,j=0;d=fa-32|0;fa=d;L[d+28>>2]=b;L[d+24>>2]=c;f=L[d+24>>2];b=fa-16|0;c=L[d+28>>2];L[b+12>>2]=c;L[b+8>>2]=0;g=L[b+12>>2];h=L[b+8>>2]<<4;L[b+12>>2]=c;L[b+8>>2]=1;i=L[b+12>>2];j=L[b+8>>2]<<4;L[b+12>>2]=c;L[b+8>>2]=2;e=d+8|0;Vd(e,f,g+h|0,i+j|0,L[b+12>>2]+(L[b+8>>2]<<4)|0);ta(a,e,c+48|0);fa=d+32|0}function me(a,b){a:{if((b|0)>=1024){a=a*898846567431158e293;if(b>>>0<2047){b=b-1023|0;break a}a=a*898846567431158e293;b=((b|0)>=3069?3069:b)-2046|0;break a}if((b|0)>-1023){break a}a=a*2004168360008973e-307;if(b>>>0>4294965304){b=b+969|0;break a}a=a*2004168360008973e-307;b=((b|0)<=-2960?-2960:b)+1938|0}z(0,0);z(1,b+1023<<20);return a*+B()}function yg(a,b,c,d,e){var f=S(0);L[a+32>>2]=c;L[a+28>>2]=b;L[a+24>>2]=d;L[a+20>>2]=e;L[a+4>>2]=0;L[a+8>>2]=1065353216;L[a+12>>2]=0;L[a+16>>2]=0;L[a>>2]=18600;L[a+36>>2]=L[b+4>>2];L[a+40>>2]=L[c+4>>2];P[a+44>>2]=ha[L[L[b>>2]+48>>2]](b);f=S(ha[L[L[c>>2]+48>>2]](c));L[a+72>>2]=1;L[a+76>>2]=1;L[a+60>>2]=-1;J[a+52|0]=0;P[a+48>>2]=f;return a}function xy(a,b,c,d){a=S(a);b=S(b);c=S(c);d=S(d);var e=0,f=0,g=0,h=0;f=fa-16|0;fa=f;P[f+12>>2]=a;P[f+8>>2]=b;P[f+4>>2]=c;P[f>>2]=d;g=oa(16);e=fa-32|0;fa=e;L[e+28>>2]=g;L[e+24>>2]=f+12;L[e+20>>2]=f+8;L[e+16>>2]=f+4;L[e+12>>2]=f;h=L[e+28>>2];la(h,L[e+24>>2],L[e+20>>2],L[e+16>>2]);P[h+12>>2]=P[L[e+12>>2]>>2];fa=e+32|0;fa=f+16|0;return g|0}function OC(a,b,c){a=a|0;b=S(b);c=c|0;var d=0,e=0,f=0;d=fa-16|0;fa=d;L[c>>2]=0;L[c+4>>2]=0;L[c+8>>2]=0;L[c+12>>2]=0;e=L[a+152>>2];if(e){b=S(b/S(e|0));while(1){e=e-1|0;f=L[L[a+160>>2]+(e<<2)>>2];ha[L[L[f>>2]+32>>2]](f,b,d);P[c>>2]=P[d>>2]+P[c>>2];P[c+4>>2]=P[d+4>>2]+P[c+4>>2];P[c+8>>2]=P[d+8>>2]+P[c+8>>2];if(e){continue}break}}fa=d+16|0}function UD(a){a=a|0;var b=0;L[a>>2]=15324;b=L[a+120>>2];if(!(b?!b|!M[a+124|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+120>>2]=0;J[a+124|0]=1;L[a+112>>2]=0;L[a+116>>2]=0;b=L[a+100>>2];if(!(b?!b|!M[a+104|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+100>>2]=0;J[a+104|0]=1;L[a+92>>2]=0;L[a+96>>2]=0;if(a){L[8514]=L[8514]+1;ha[L[6799]](a)}}function bD(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0;e=fa-48|0;fa=e;L[e+12>>2]=b;L[e+8>>2]=17056;b=L[c+12>>2];L[e+24>>2]=L[c+8>>2];L[e+28>>2]=b;b=L[c+4>>2];L[e+16>>2]=L[c>>2];L[e+20>>2]=b;b=L[d+12>>2];L[e+40>>2]=L[d+8>>2];L[e+44>>2]=b;b=L[d+4>>2];L[e+32>>2]=L[d>>2];L[e+36>>2]=b;a=L[a+48>>2];ha[L[L[a>>2]+8>>2]](a,e+8|0,c,d);fa=e+48|0}function Yh(a,b){var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;b=fa-16|0;a=L[c+12>>2];L[b+12>>2]=a;if(L[L[b+12>>2]+8>>2]>2]){L[c+4>>2]=Vh(a,L[c+8>>2]);b=fa-16|0;L[b+12>>2]=a;kf(a,L[L[b+12>>2]+4>>2],L[c+4>>2]);b=fa-16|0;L[b+12>>2]=a;Db(a,L[L[b+12>>2]+4>>2]);jb(a);J[a+16|0]=1;L[a+12>>2]=L[c+4>>2];L[a+8>>2]=L[c+8>>2]}fa=c+16|0}function Wh(a,b){var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;b=fa-16|0;a=L[c+12>>2];L[b+12>>2]=a;if(L[L[b+12>>2]+8>>2]>2]){L[c+4>>2]=Vh(a,L[c+8>>2]);b=fa-16|0;L[b+12>>2]=a;Th(a,L[L[b+12>>2]+4>>2],L[c+4>>2]);b=fa-16|0;L[b+12>>2]=a;Db(a,L[L[b+12>>2]+4>>2]);jb(a);J[a+16|0]=1;L[a+12>>2]=L[c+4>>2];L[a+8>>2]=L[c+8>>2]}fa=c+16|0}function md(a,b,c,d,e,f,g,h,i,j){var k=0;k=fa-48|0;fa=k;L[k+44>>2]=a;L[k+40>>2]=b;L[k+36>>2]=c;L[k+32>>2]=d;L[k+28>>2]=e;L[k+24>>2]=f;L[k+20>>2]=g;L[k+16>>2]=h;L[k+12>>2]=i;L[k+8>>2]=j;a=L[k+44>>2];la(a,L[k+40>>2],L[k+36>>2],L[k+32>>2]);la(a+16|0,L[k+28>>2],L[k+24>>2],L[k+20>>2]);la(a+32|0,L[k+16>>2],L[k+12>>2],L[k+8>>2]);fa=k+48|0}function Zq(a){a=a|0;var b=0,c=0,d=0,e=S(0);b=fa-16|0;fa=b;L[b+12>>2]=a;c=L[b+12>>2];if(L[c+136>>2]>0){while(1){a=L[c+144>>2]+R(d,284)|0;e=P[a+204>>2];L[a+268>>2]=1065353216;L[a+272>>2]=0;P[a+32>>2]=e;L[a+12>>2]=0;P[a+8>>2]=-P[a+60>>2];P[a+4>>2]=-P[a+56>>2];P[a>>2]=-P[a+52>>2];d=d+1|0;if((d|0)>2]){continue}break}}fa=b+16|0}function Nn(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;var g=0;g=L[a+108>>2];if(!g){e=N[a+56>>1];if(e){b=1;f=1;while(1){b=L[a+68>>2]+(b<<2)|0;if(J[b|0]&1){ha[L[L[d>>2]+8>>2]](d,L[a+60>>2]+(N[b+2>>1]<<6)|0)|0;e=N[a+56>>1]}f=f+1|0;b=f&65535;if(b>>>0<((e&65535)<<1|1)>>>0){continue}break}}return}ha[L[L[g>>2]+24>>2]](g,b,c,d,e,f)}function hz(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0;if(!(!b|L[b+236>>2]!=8)){c=L[a+328>>2];a:{if((c|0)<=0){break a}e=L[a+336>>2];while(1){f=(d<<2)+e|0;if(L[f>>2]!=(b|0)){d=d+1|0;if((c|0)!=(d|0)){continue}break a}break}if((c|0)<=(d|0)){break a}c=c-1|0;d=c<<2;L[f>>2]=L[d+e>>2];L[d+L[a+336>>2]>>2]=b;L[a+328>>2]=c}Bd(a,b);return}Sk(a,b)}function Ub(a,b,c){var d=0;d=fa-32|0;fa=d;L[d+28>>2]=b;L[d+24>>2]=c;b=L[d+28>>2];c=L[d+24>>2];P[d+20>>2]=S(P[b+4>>2]*P[c+8>>2])-S(P[b+8>>2]*P[c+4>>2]);P[d+16>>2]=S(P[b+8>>2]*P[L[d+24>>2]>>2])-S(P[b>>2]*P[L[d+24>>2]+8>>2]);P[d+12>>2]=S(P[b>>2]*P[L[d+24>>2]+4>>2])-S(P[b+4>>2]*P[L[d+24>>2]>>2]);la(a,d+20|0,d+16|0,d+12|0);fa=d+32|0}function cp(a,b,c,d,e,f,g,h,i){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;i=S(i);var j=0;j=fa-48|0;fa=j;L[j+44>>2]=a;L[j+40>>2]=b;L[j+36>>2]=c;L[j+32>>2]=d;L[j+28>>2]=e;L[j+24>>2]=f;L[j+20>>2]=g;L[j+16>>2]=h;P[j+12>>2]=i;a=L[j+44>>2];ha[L[L[a>>2]+28>>2]](a,L[j+40>>2],L[j+36>>2],L[j+32>>2],L[j+16>>2],P[j+12>>2]);fa=j+48|0}function oG(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;a=L[b>>2];a=ha[L[L[a>>2]+56>>2]](a,16)|0;L[a>>2]=8684;L[a+4>>2]=L[b>>2];L[a>>2]=8712;L[a+12>>2]=0;J[a+8|0]=0;L[a>>2]=10180;b=L[a+4>>2];if(ha[L[L[b>>2]+24>>2]](b,L[c+8>>2],L[d+8>>2])|0){b=L[a+4>>2];b=ha[L[L[b>>2]+12>>2]](b,L[c+8>>2],L[d+8>>2])|0;J[a+8|0]=1;L[a+12>>2]=b}return a|0}function fI(a,b){a=a|0;b=b|0;if(L[a+16>>2]==(0-L[a+76>>2]|0)){Gd(a+4|0);Gd(a- -64|0);L[a+164>>2]=0;L[a+144>>2]=0;J[a+193|0]=0;J[a+194|0]=1;L[a+156>>2]=10;L[a+160>>2]=1;L[a+148>>2]=1;L[a+152>>2]=0;L[a+124>>2]=0;L[a+128>>2]=0;L[a+132>>2]=0;L[a+168>>2]=0;L[a+172>>2]=0;L[a+176>>2]=0;L[a+180>>2]=0;L[a+184>>2]=0;L[a+188>>2]=0}}function $j(a){var b=0;if(L[a+12>>2]){L[a+4>>2]=0;b=L[a+20>>2];if(!(b?!b|!M[a+24|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+20>>2]=0;J[a+24|0]=1;L[a+12>>2]=0;L[a+16>>2]=0}if(L[a+40>>2]){L[a+32>>2]=0;b=L[a+48>>2];if(!(b?!b|!M[a+52|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+48>>2]=0;J[a+52|0]=1;L[a+40>>2]=0;L[a+44>>2]=0}}function mz(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=0;a=M[a+16|0];d=a?b:c;a=L[(a?c:b)+8>>2];c=L[a+268>>2];a:{b:{if((c|0)<=0){break b}e=L[d+8>>2];f=L[a+276>>2];b=0;while(1){if(L[(b<<2)+f>>2]!=(e|0)){b=b+1|0;if((c|0)!=(b|0)){continue}break b}break}if((b|0)!=(c|0)){break a}}b=L[a+284>>2];ha[L[L[b>>2]+36>>2]](b,a,d)}}function VG(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0,g=0;c=L[b>>2];c=ha[L[L[c>>2]+56>>2]](c,36)|0;e=L[b+4>>2];f=L[a+12>>2];d=L[a+8>>2];g=L[a+16>>2];a=L[a+20>>2];L[c>>2]=8684;L[c+4>>2]=L[b>>2];L[c>>2]=8712;L[c+32>>2]=a;L[c+28>>2]=g;J[c+24|0]=0;L[c+20>>2]=e;J[c+16|0]=0;L[c+12>>2]=d;L[c+8>>2]=f;L[c>>2]=8836;return c|0}function lC(a){a=a|0;var b=0,c=0,d=0;b=L[a+152>>2];c=b;a:{if(!b){break a}if(b&1){c=b-1|0;d=L[L[a+160>>2]+(c<<2)>>2];ha[L[L[d>>2]+72>>2]](d)}if((b|0)==1){break a}while(1){b=L[(L[a+160>>2]+(c<<2)|0)-4>>2];ha[L[L[b>>2]+72>>2]](b);c=c-2|0;b=L[L[a+160>>2]+(c<<2)>>2];ha[L[L[b>>2]+72>>2]](b);if(c){continue}break}}J[a+48|0]=1}function AA(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0;c=L[a+212>>2];a:{if((c|0)<=0){break a}e=L[a+220>>2];while(1){f=(d<<2)+e|0;if(L[f>>2]!=(b|0)){d=d+1|0;if((c|0)!=(d|0)){continue}break a}break}if((c|0)<=(d|0)){break a}c=c-1|0;d=c<<2;L[f>>2]=L[d+e>>2];L[d+L[a+220>>2]>>2]=b;L[a+212>>2]=c}Ek(L[b+28>>2],b);Ek(L[b+32>>2],b)}function pG(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0;e=L[b>>2];e=ha[L[L[e>>2]+56>>2]](e,20)|0;f=L[b+4>>2];a=M[a+4|0];L[e>>2]=8684;L[e+4>>2]=L[b>>2];L[e>>2]=8712;J[e+16|0]=a;L[e+12>>2]=f;J[e+8|0]=0;L[e>>2]=11720;if(!f){a=L[e+4>>2];a=ha[L[L[a>>2]+12>>2]](a,L[c+8>>2],L[d+8>>2])|0;J[e+8|0]=1;L[e+12>>2]=a}return e|0}function lu(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,f=0;d=fa-16|0;fa=d;L[d+12>>2]=a;L[d+8>>2]=b;L[d+4>>2]=c;b=L[d+8>>2];c=L[d+4>>2];a=fa-48|0;fa=a;L[a+44>>2]=L[d+12>>2];L[a+40>>2]=b;L[a+36>>2]=c;b=L[a+44>>2];Vi(b,L[a+40>>2]);c=L[a+36>>2];e=a+4|0;Kb(e,L[a+40>>2],b+348|0);f=a+20|0;Ub(f,c,e);Wi(b,f);fa=a+48|0;fa=d+16|0}function bo(a,b){a=a|0;b=S(b);var c=0,d=0;c=fa-16|0;fa=c;L[c+12>>2]=a;P[c+8>>2]=b;a=L[c+12>>2];P[a+12>>2]=P[c+8>>2];L[c+4>>2]=ha[L[L[a>>2]+88>>2]](a);while(1){d=L[c+4>>2];L[c+4>>2]=d-1;if(d){L[c>>2]=ha[L[L[a>>2]+124>>2]](a,L[c+4>>2]);d=L[c>>2];ha[L[L[d>>2]+44>>2]](d,P[c+8>>2]);continue}break}J[a+48|0]=1;fa=c+16|0}function ay(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;if(!M[29724]){L[(fa-16|0)+12>>2]=29708;J[29724]=1}b=L[c+8>>2];a=fa-16|0;L[a+12>>2]=L[c+12>>2];L[a+8>>2]=b;a=L[a+12>>2]+(L[a+8>>2]<<4)|0;b=L[a+4>>2];L[7427]=L[a>>2];L[7428]=b;b=L[a+12>>2];L[7429]=L[a+8>>2];L[7430]=b;fa=c+16|0;return 29708}function rz(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;d=(b|0)!=32;if(!(d|(c|0)!=32)){return L[a+92>>2]}a:{b:{c:{if(!d){if((c|0)>19){break c}return L[a+96>>2]}if((c|0)!=32|(b|0)>19){break b}return L[a+100>>2]}if(c-21>>>0>8){break a}return L[a+104>>2]}if((c|0)!=32|b-21>>>0>8){break a}return L[a+108>>2]}return Vm(a,b,c)|0}function vf(a,b,c,d){var e=0;e=fa-16|0;fa=e;L[e+12>>2]=a;L[e+8>>2]=b;L[e+4>>2]=c;J[e+3|0]=d;b=L[e+8>>2];c=L[e+4>>2];d=J[e+3|0]&1;a=fa-16|0;L[a+12>>2]=L[e+12>>2];L[a+8>>2]=b;L[a+4>>2]=c;J[a+3|0]=d;b=L[a+12>>2];a:{if(J[a+3|0]&1){L[b+84>>2]=L[a+8>>2];break a}L[b+80>>2]=L[a+8>>2]}L[b+88>>2]=L[a+4>>2];fa=e+16|0}function VD(a){a=a|0;var b=0;L[a>>2]=15324;b=L[a+120>>2];if(!(b?!b|!M[a+124|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+120>>2]=0;J[a+124|0]=1;L[a+112>>2]=0;L[a+116>>2]=0;b=L[a+100>>2];if(!(b?!b|!M[a+104|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+100>>2]=0;J[a+104|0]=1;L[a+92>>2]=0;L[a+96>>2]=0;return a|0}function gt(a,b,c,d){a=a|0;b=b|0;c=S(c);d=S(d);var e=0;e=fa-16|0;fa=e;L[e+12>>2]=a;J[e+11|0]=b;P[e+4>>2]=c;P[e>>2]=d;b=J[e+11|0]&1;c=P[e+4>>2];d=P[e>>2];a=fa-16|0;L[a+12>>2]=L[e+12>>2];J[a+11|0]=b;P[a+4>>2]=c;P[a>>2]=d;b=L[a+12>>2];J[b+737|0]=J[a+11|0]&1;P[b+680>>2]=P[a+4>>2];P[b+684>>2]=P[a>>2];fa=e+16|0}function $E(a,b){a=a|0;b=b|0;var c=S(0),d=0,e=0,f=S(0);e=L[a+68>>2]<<2;c=P[e+b>>2];d=e;e=a+12|0;f=S(P[a+60>>2]*S(c/P[d+e>>2]));P[a+60>>2]=f;d=L[a+64>>2]<<2;c=S(P[d+b>>2]/P[e+d>>2]);d=L[a+72>>2]<<2;c=S(P[a+56>>2]*S(S(c+S(P[d+b>>2]/P[e+d>>2]))*S(.5)));P[a+56>>2]=c;P[a+52>>2]=c/S(_(S(S(c*c)+S(f*f))));Ue(a,b)}function Rv(a){a=a|0;var b=0,c=0,d=0;b=fa-16|0;fa=b;L[b+12>>2]=a;c=fa-16|0;fa=c;L[c+12>>2]=L[b+12>>2];a=L[c+12>>2];a:{if(L[a+32>>2]>0){L[a+32>>2]=L[a+32>>2]+1;break a}d=L[a+8>>2];ha[L[L[d>>2]+16>>2]](d,a+36|0,a+40|0,a+44|0,a+48|0,a+52|0,a+56|0,a+60|0,a- -64|0,L[a+28>>2]);L[a+32>>2]=1}fa=c+16|0;fa=b+16|0}function gn(a,b,c,d,e){var f=0;L[a>>2]=8684;L[a+4>>2]=L[b>>2];L[a>>2]=8712;J[a+8|0]=e;L[a>>2]=9440;b=L[b>>2];L[a+64>>2]=0;L[a+60>>2]=b;L[a+12>>2]=9468;f=e?c:d;L[a+20>>2]=f;c=e?d:c;L[a+16>>2]=c;b=ha[L[L[b>>2]+12>>2]](b,L[c+8>>2],L[f+8>>2])|0;L[a+76>>2]=b;c=L[a+60>>2];ha[L[L[c>>2]+20>>2]](c,b);return a}function jy(a,b){a=a|0;b=b|0;var c=0,d=S(0),e=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;b=L[c+8>>2];a=fa-16|0;fa=a;L[a+12>>2]=L[c+12>>2];L[a+8>>2]=b;b=L[a+12>>2];d=S($b(b)*$b(L[a+8>>2]));e=fa-16|0;P[e+12>>2]=d;P[a+4>>2]=_(P[e+12>>2]);d=uc(S(_b(b,L[a+8>>2])/P[a+4>>2]));fa=a+16|0;fa=c+16|0;return S(d)}function cE(a,b,c){a=a|0;b=b|0;c=c|0;var d=S(0);a:{switch(L[a+96>>2]){case 0:return S(P[L[a+92>>2]+(R(L[a+64>>2],c)+b<<2)>>2]);case 5:return S(S(P[a+88>>2]*S(M[L[a+92>>2]+(R(L[a+64>>2],c)+b|0)|0])));case 3:d=S(P[a+88>>2]*S(K[L[a+92>>2]+(R(L[a+64>>2],c)+b<<1)>>1]));break;default:break a}}return S(d)}function Rm(a){a=a|0;var b=0;L[a>>2]=11408;b=L[a+284>>2];ha[L[L[b>>2]>>2]](b)|0;b=L[a+284>>2];if(b){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a>>2]=11364;b=L[a+276>>2];if(!(b?!b|!M[a+280|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+276>>2]=0;J[a+280|0]=1;L[a+268>>2]=0;L[a+272>>2]=0;L[a>>2]=6712;return a|0}function wy(a,b,c){a=a|0;b=b|0;c=S(c);var d=0;d=fa-32|0;fa=d;L[d+28>>2]=a;L[d+24>>2]=b;P[d+20>>2]=c;if(!M[29644]){L[(fa-16|0)+12>>2]=29628;J[29644]=1}wh(d+4|0,L[d+28>>2],L[d+24>>2],P[d+20>>2]);a=L[d+8>>2];L[7407]=L[d+4>>2];L[7408]=a;a=L[d+16>>2];L[7409]=L[d+12>>2];L[7410]=a;fa=d+32|0;return 29628}function Rn(a,b,c){a=a|0;b=b|0;c=S(c);var d=0;d=fa-32|0;fa=d;L[d+28>>2]=a;L[d+24>>2]=b;P[d+20>>2]=c;if(!M[29536]){L[(fa-16|0)+12>>2]=29520;J[29536]=1}wh(d+4|0,L[d+28>>2],L[d+24>>2],P[d+20>>2]);a=L[d+8>>2];L[7380]=L[d+4>>2];L[7381]=a;a=L[d+16>>2];L[7382]=L[d+12>>2];L[7383]=a;fa=d+32|0;return 29520}function GF(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0;c=L[a+52>>2];if(c){c=(f=b,g=ha[L[L[c>>2]+12>>2]](c)|0,h=1,e=L[L[b>>2]+16>>2],ha[e](f|0,g|0,h|0)|0);d=L[a+52>>2];h=b,g=c,f=ha[L[L[d>>2]+16>>2]](d,L[c+8>>2],b)|0,i=1213612625,j=L[a+52>>2],e=L[L[b>>2]+20>>2],ha[e](h|0,g|0,f|0,i|0,j|0)}}function jA(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0;c=1;a:{if(!(M[b+236|0]&2)|!b){break a}d=L[a+488>>2];if((d|0)<=0){break a}f=L[a+496>>2];c=0;a=0;while(1){e=L[(a<<2)+f>>2];if(L[e+28>>2]==(b|0)|L[e+32>>2]==(b|0)?M[e+20|0]:0){break a}a=a+1|0;c=(d|0)<=(a|0);if((a|0)!=(d|0)){continue}break}}return c|0}function FF(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0;c=L[a+56>>2];if(c){c=(f=b,g=ha[L[L[c>>2]+8>>2]](c)|0,h=1,e=L[L[b>>2]+16>>2],ha[e](f|0,g|0,h|0)|0);d=L[a+56>>2];h=b,g=c,f=ha[L[L[d>>2]+12>>2]](d,L[c+8>>2],b)|0,i=1346456916,j=L[a+56>>2],e=L[L[b>>2]+20>>2],ha[e](h|0,g|0,f|0,i|0,j|0)}}function PB(a,b,c,d){a=a|0;b=b|0;c=S(c);d=d|0;a:{switch(b-1|0){case 0:case 1:if(d>>>0<=2){P[a+600>>2]=c;L[a+592>>2]=L[a+592>>2]|2;return}P[a+432>>2]=c;return;case 2:case 3:if(d>>>0<=2){P[a+596>>2]=c;L[a+592>>2]=L[a+592>>2]|1;return}P[a+604>>2]=c;L[a+592>>2]=L[a+592>>2]|4;break;default:break a}}}function kt(a,b,c,d,e,f,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;var h=0;h=fa-32|0;fa=h;L[h+28>>2]=a;L[h+24>>2]=b;L[h+20>>2]=c;L[h+16>>2]=d;L[h+12>>2]=e;L[h+8>>2]=f;J[h+7|0]=g;a=oa(764);hl(a,L[h+28>>2],L[h+24>>2],L[h+20>>2],L[h+16>>2],L[h+12>>2],L[h+8>>2],J[h+7|0]&1);fa=h+32|0;return a|0}function cu(a,b){a=a|0;b=b|0;var c=0,d=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;a=L[c+8>>2];b=fa-16|0;L[b+12>>2]=L[c+12>>2];L[b+8>>2]=a;a=L[b+12>>2];L[a+260>>2]=L[a+260>>2]+1;b=L[b+8>>2];d=L[b+4>>2];L[a+312>>2]=L[b>>2];L[a+316>>2]=d;d=L[b+12>>2];L[a+320>>2]=L[b+8>>2];L[a+324>>2]=d;fa=c+16|0}function bu(a,b){a=a|0;b=b|0;var c=0,d=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;a=L[c+8>>2];b=fa-16|0;L[b+12>>2]=L[c+12>>2];L[b+8>>2]=a;a=L[b+12>>2];L[a+260>>2]=L[a+260>>2]+1;b=L[b+8>>2];d=L[b+4>>2];L[a+328>>2]=L[b>>2];L[a+332>>2]=d;d=L[b+12>>2];L[a+336>>2]=L[b+8>>2];L[a+340>>2]=d;fa=c+16|0}function Zt(a,b){a=a|0;b=b|0;var c=0,d=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;a=L[c+8>>2];b=fa-16|0;L[b+12>>2]=L[c+12>>2];L[b+8>>2]=a;a=L[b+12>>2];L[a+260>>2]=L[a+260>>2]+1;b=L[b+8>>2];d=L[b+4>>2];L[a+544>>2]=L[b>>2];L[a+548>>2]=d;d=L[b+12>>2];L[a+552>>2]=L[b+8>>2];L[a+556>>2]=d;fa=c+16|0}function GA(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0;c=L[a+232>>2];a:{if((c|0)<=0){break a}e=L[a+240>>2];while(1){f=(d<<2)+e|0;if(L[f>>2]!=(b|0)){d=d+1|0;if((c|0)!=(d|0)){continue}break a}break}if((c|0)<=(d|0)){break a}c=c-1|0;d=c<<2;L[f>>2]=L[d+e>>2];L[d+L[a+240>>2]>>2]=b;L[a+232>>2]=c}Bd(a,b)}function Ek(a,b){var c=0,d=0,e=0,f=0;c=L[a+488>>2];a:{if((c|0)<=0){break a}e=L[a+496>>2];while(1){f=(d<<2)+e|0;if(L[f>>2]!=(b|0)){d=d+1|0;if((d|0)!=(c|0)){continue}break a}break}if((c|0)<=(d|0)){break a}c=c-1|0;d=c<<2;L[f>>2]=L[d+e>>2];L[d+L[a+496>>2]>>2]=b;L[a+488>>2]=c}L[a+256>>2]=(c|0)>0}function DB(a){a=a|0;var b=S(0),c=S(0);b=S(1);c=P[L[a+32>>2]+344>>2];if(c!=S(0)){b=P[L[a+28>>2]+344>>2];b=S(b/S(c+b))}L[a+1296>>2]=0;c=S(S(1)-b);P[a+1292>>2]=S(b*P[a+1120>>2])+S(c*P[a+1184>>2]);P[a+1288>>2]=S(b*P[a+1116>>2])+S(c*P[a+1180>>2]);P[a+1284>>2]=S(b*P[a+1112>>2])+S(c*P[a+1176>>2])}function tE(a,b,c){a=a|0;b=b|0;c=c|0;var d=S(0),e=S(0),f=S(0),g=S(0),h=S(0),i=S(0);d=P[b+36>>2];e=P[b+28>>2];f=P[c>>2];g=P[c+4>>2];h=S(_(S(S(f*f)+S(g*g))));a:{if(h!=S(0)){e=S(e/h);i=S(g*e);e=S(f*e);d=P[c+8>>2]>2]>2]=d;P[a>>2]=e;P[a+4>>2]=i}function sc(a,b){var c=0,d=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;b=L[c+8>>2];a=fa-16|0;fa=a;L[a+12>>2]=L[c+12>>2];L[a+8>>2]=b;b=L[a+12>>2];d=fa-16|0;L[d+12>>2]=L[a+8>>2];L[a+4>>2]=L[L[d+12>>2]+4>>2];d=L[a+4>>2];L[a>>2]=0;Ih(b,d,a);kf(L[a+8>>2],L[a+4>>2],L[b+12>>2]);fa=a+16|0;fa=c+16|0}function sE(a,b,c){a=a|0;b=b|0;c=c|0;var d=S(0),e=S(0),f=S(0),g=S(0),h=S(0),i=S(0);d=P[b+32>>2];e=P[b+28>>2];f=P[c>>2];g=P[c+8>>2];h=S(_(S(S(f*f)+S(g*g))));a:{if(h!=S(0)){e=S(e/h);i=S(g*e);e=S(f*e);d=P[c+4>>2]>2]>2]=i;P[a+4>>2]=d;P[a>>2]=e}function Wx(a){a=a|0;var b=0,c=0,d=0;b=fa-32|0;fa=b;L[b+28>>2]=a;if(!M[29744]){Ka(29728);J[29744]=1}a=fa-16|0;fa=a;L[a+12>>2]=L[b+28>>2];d=L[a+12>>2];c=b+12|0;Ka(c);Ma(d,c);fa=a+16|0;a=L[b+16>>2];L[7432]=L[b+12>>2];L[7433]=a;a=L[b+24>>2];L[7434]=L[b+20>>2];L[7435]=a;fa=b+32|0;return 29728}function aj(a,b,c){var d=0;d=fa-32|0;fa=d;L[d+28>>2]=a;L[d+24>>2]=b;L[d+20>>2]=c;a=L[d+28>>2];b=d+8|0;Gf(a,L[d+24>>2],b,b+4|0,b+8|0);Lb(a,L[d+8>>2],L[d+20>>2]+56|0);Lb(a,L[d+12>>2],L[d+20>>2]+72|0);Lb(a,L[d+16>>2],L[d+20>>2]+88|0);b=L[d+20>>2];ha[L[L[b>>2]+44>>2]](b,P[a+4>>2]);fa=d+32|0} -function Dn(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;fc((L[b+60>>2]==2?64:4)+a|0,L[b+48>>2]);d=L[b+52>>2];L[(d?d+56|0:((L[b+60>>2]<<2)+a|0)+124|0)>>2]=L[b+56>>2];d=L[b+56>>2];if(d){L[d+52>>2]=L[b+52>>2]}d=L[a+136>>2];ha[L[L[d>>2]+16>>2]](d,b,c);if(b){L[8514]=L[8514]+1;ha[L[6799]](b)}J[a+194|0]=1}function uE(a,b,c){a=a|0;b=b|0;c=c|0;var d=S(0),e=S(0),f=S(0),g=S(0),h=S(0),i=S(0);e=P[b+32>>2];d=P[b+28>>2];f=P[c+4>>2];g=P[c+8>>2];h=S(_(S(S(f*f)+S(g*g))));a:{if(h!=S(0)){e=S(e/h);i=S(g*e);e=S(f*e);d=P[c>>2]>2]>2]=i;P[a>>2]=d;P[a+4>>2]=e}function Vh(a,b){var c=0,d=0;c=fa-16|0;fa=c;L[c+8>>2]=a;L[c+4>>2]=b;b=L[c+8>>2];a:{if(L[c+4>>2]){d=L[c+4>>2];a=fa-16|0;fa=a;L[a+12>>2]=b;L[a+8>>2]=d;L[a+4>>2]=0;b=L[a+8>>2]<<2;L[8513]=L[8513]+1;b=ha[L[6798]](b,16)|0;fa=a+16|0;L[c+12>>2]=b;break a}L[c+12>>2]=0}fa=c+16|0;return L[c+12>>2]}function gf(a,b){var c=0,d=0;c=fa+-64|0;fa=c;L[c+60>>2]=a;L[c+56>>2]=b;b=L[c+60>>2];a=b+56|0;d=c+24|0;La(d,b+72|0,a);b=c+8|0;La(b,a+32|0,a);Ub(c+40|0,d,b);b=L[c+44>>2];a=L[c+56>>2];L[a>>2]=L[c+40>>2];L[a+4>>2]=b;b=L[c+52>>2];L[a+8>>2]=L[c+48>>2];L[a+12>>2]=b;Nd(L[c+56>>2]);fa=c- -64|0}function yA(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0;a:{c=L[a+280>>2];if((c|0)<=0){break a}e=L[a+288>>2];while(1){f=(d<<2)+e|0;if(L[f>>2]!=(b|0)){d=d+1|0;if((c|0)!=(d|0)){continue}break a}break}if((c|0)<=(d|0)){break a}c=c-1|0;d=c<<2;L[f>>2]=L[d+e>>2];L[d+L[a+288>>2]>>2]=b;L[a+280>>2]=c}}function Un(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;d=fa-32|0;fa=d;L[d+28>>2]=a;L[d+24>>2]=b;L[d+20>>2]=c;a=L[d+28>>2];b=d+8|0;Gf(a,L[d+24>>2],b,b+4|0,b+8|0);Lb(a,L[d+8>>2],L[d+20>>2]);Lb(a,L[d+12>>2],L[d+20>>2]+16|0);Lb(a,L[d+16>>2],L[d+20>>2]+32|0);P[L[d+20>>2]+64>>2]=P[a+4>>2];fa=d+32|0}function Qv(a){a=a|0;var b=0,c=0,d=0;b=fa-16|0;fa=b;L[b+12>>2]=a;c=fa-16|0;fa=c;L[c+12>>2]=L[b+12>>2];a=L[c+12>>2];a:{if(!L[a+32>>2]){break a}if(L[a+32>>2]>1){L[a+32>>2]=L[a+32>>2]-1;break a}d=L[a+8>>2];ha[L[L[d>>2]+24>>2]](d,L[a+28>>2]);L[a+36>>2]=0;L[a+32>>2]=0}fa=c+16|0;fa=b+16|0}function nc(a,b,c){var d=0,e=0,f=0,g=0,h=0;d=fa-16|0;fa=d;L[d+12>>2]=b;L[d+8>>2]=c;c=fa-16|0;b=L[d+12>>2];L[c+12>>2]=b;c=L[c+12>>2];g=L[d+8>>2]<<2;e=fa-16|0;L[e+12>>2]=b+16;e=L[e+12>>2];h=L[d+8>>2]<<2;f=fa-16|0;L[f+12>>2]=b+32;la(a,c+g|0,e+h|0,L[f+12>>2]+(L[d+8>>2]<<2)|0);fa=d+16|0}function kG(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0;a:{c=L[a+268>>2];if((c|0)<=0){break a}f=L[b>>2];d=L[a+276>>2];b=0;while(1){e=(b<<2)+d|0;if(L[e>>2]!=(f|0)){b=b+1|0;if((c|0)!=(b|0)){continue}break a}break}if((b|0)>=(c|0)){break a}b=c-1|0;L[e>>2]=L[(b<<2)+d>>2];L[a+268>>2]=b}}function Ul(a){a=a|0;var b=0,c=0;L[a>>2]=17248;b=L[a+12>>2];if(b){c=L[a+4>>2];ha[L[L[c>>2]+16>>2]](c,b);L[a+12>>2]=0}b=L[a+8>>2];if(b){ha[L[L[b>>2]>>2]](b)|0;b=L[a+4>>2];ha[L[L[b>>2]+60>>2]](b,L[a+8>>2]);L[a+8>>2]=0}L[a+24>>2]=-1;L[a+28>>2]=-1;L[a+32>>2]=-1;L[a+36>>2]=-1;return a|0}function OB(a,b,c){a=a|0;b=b|0;c=c|0;var d=S(0);a:{b:{switch(b-1|0){case 0:case 1:if(c>>>0<=2){return S(P[a+600>>2])}if(c-3>>>0>2){break a}return S(P[a+432>>2]);case 2:case 3:break b;default:break a}}if(c>>>0<=2){return S(P[a+596>>2])}if(c-3>>>0>2){break a}d=P[a+604>>2]}return S(d)}function te(a,b){var c=S(0),d=0,e=S(0),f=S(0),g=S(0);c=P[a+344>>2];if(c!=S(0)){e=P[b>>2];f=P[b+4>>2];g=P[b+8>>2];L[a+376>>2]=0;c=S(S(1)/c);P[a+372>>2]=g*c;P[a+368>>2]=c*f;P[a+364>>2]=c*e}d=L[b+4>>2];L[a+380>>2]=L[b>>2];L[a+384>>2]=d;d=L[b+12>>2];L[a+388>>2]=L[b+8>>2];L[a+392>>2]=d}function mu(a,b){a=a|0;b=b|0;var c=0,d=0,e=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;b=L[c+8>>2];a=fa-48|0;fa=a;L[a+44>>2]=L[c+12>>2];L[a+40>>2]=b;d=fa-16|0;b=L[a+44>>2];L[d+12>>2]=b+4;e=a+8|0;ua(e,L[d+12>>2],L[a+40>>2]);d=a+24|0;Kb(d,e,b+544|0);hb(b+428|0,d);fa=a+48|0;fa=c+16|0}function ju(a,b){a=a|0;b=b|0;var c=0,d=0,e=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;b=L[c+8>>2];a=fa-48|0;fa=a;L[a+44>>2]=L[c+12>>2];L[a+40>>2]=b;d=fa-16|0;b=L[a+44>>2];L[d+12>>2]=b+4;e=a+8|0;ua(e,L[d+12>>2],L[a+40>>2]);d=a+24|0;Kb(d,e,b+348|0);hb(b+412|0,d);fa=a+48|0;fa=c+16|0}function Yp(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;d=fa-16|0;fa=d;L[d+12>>2]=a;L[d+8>>2]=b;L[d+4>>2]=c;b=L[d+8>>2];a=L[L[d+12>>2]+720>>2]+R(L[d+4>>2],104)|0;if(P[a+88>>2]>S(0)){P[a+56>>2]=P[b>>2]+P[a+56>>2];P[a+60>>2]=P[b+4>>2]+P[a+60>>2];a=a- -64|0;P[a>>2]=P[b+8>>2]+P[a>>2]}fa=d+16|0}function vF(a,b,c){a=a|0;b=b|0;c=c|0;db(a,b,c);P[b+28>>2]=P[a+28>>2];P[b+32>>2]=P[a+32>>2];P[b+36>>2]=P[a+36>>2];P[b+40>>2]=P[a+40>>2];P[b+12>>2]=P[a+12>>2];P[b+16>>2]=P[a+16>>2];P[b+20>>2]=P[a+20>>2];P[b+24>>2]=P[a+24>>2];P[b+44>>2]=P[a+44>>2];L[b+52>>2]=L[a+52>>2];return 4019}function nE(a,b,c){a=a|0;b=b|0;c=c|0;db(a,b,c);P[b+28>>2]=P[a+28>>2];P[b+32>>2]=P[a+32>>2];P[b+36>>2]=P[a+36>>2];P[b+40>>2]=P[a+40>>2];P[b+12>>2]=P[a+12>>2];P[b+16>>2]=P[a+16>>2];P[b+20>>2]=P[a+20>>2];P[b+24>>2]=P[a+24>>2];P[b+44>>2]=P[a+44>>2];L[b+52>>2]=L[a+52>>2];return 3821}function WE(a,b,c){a=a|0;b=b|0;c=c|0;db(a,b,c);P[b+28>>2]=P[a+28>>2];P[b+32>>2]=P[a+32>>2];P[b+36>>2]=P[a+36>>2];P[b+40>>2]=P[a+40>>2];P[b+12>>2]=P[a+12>>2];P[b+16>>2]=P[a+16>>2];P[b+20>>2]=P[a+20>>2];P[b+24>>2]=P[a+24>>2];P[b+44>>2]=P[a+44>>2];L[b+52>>2]=L[a+68>>2];return 3980}function Hp(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;b=L[c+8>>2];a=fa-16|0;fa=a;L[a+12>>2]=L[c+12>>2]+288;L[a+8>>2]=b;b=L[a+12>>2];qa(b,L[a+8>>2],104);sc(b+104|0,L[a+8>>2]+104|0);sc(b+124|0,L[a+8>>2]+124|0);sc(b+144|0,L[a+8>>2]+144|0);fa=a+16|0;fa=c+16|0}function zw(a,b){a=a|0;b=b|0;var c=0,d=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;b=L[c+8>>2];a=fa-16|0;fa=a;L[a+12>>2]=L[c+12>>2];L[a+8>>2]=b;d=L[a+8>>2];b=fa-16|0;L[b+12>>2]=L[a+12>>2]+12;L[b+8>>2]=d;fa=a+16|0;fa=c+16|0;return L[(L[L[b+12>>2]+12>>2]+R(L[b+8>>2],80)|0)+64>>2]}function kC(a,b,c,d){a=a|0;b=b|0;c=c|0;d=S(d);var e=0;if(P[a+36>>2]>d){J[a+40|0]=1;e=L[b+4>>2];L[a+4>>2]=L[b>>2];L[a+8>>2]=e;e=L[b+12>>2];L[a+12>>2]=L[b+8>>2];L[a+16>>2]=e;b=L[c+4>>2];L[a+20>>2]=L[c>>2];L[a+24>>2]=b;b=L[c+12>>2];L[a+28>>2]=L[c+8>>2];L[a+32>>2]=b;P[a+36>>2]=d}}function ln(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;a=L[c+8>>2];b=fa-16|0;L[b+12>>2]=L[c+12>>2];L[b+8>>2]=a;a=L[b+12>>2];P[a>>2]=P[a>>2]-P[L[b+8>>2]>>2];P[a+4>>2]=P[a+4>>2]-P[L[b+8>>2]+4>>2];P[a+8>>2]=P[a+8>>2]-P[L[b+8>>2]+8>>2];fa=c+16|0;return a|0}function Wa(a,b,c){var d=0;if(!c){return L[a+4>>2]==L[b+4>>2]}if((a|0)==(b|0)){return 1}d=L[a+4>>2];a=M[d|0];c=L[b+4>>2];b=M[c|0];a:{if(!a|(b|0)!=(a|0)){break a}while(1){b=M[c+1|0];a=M[d+1|0];if(!a){break a}c=c+1|0;d=d+1|0;if((a|0)==(b|0)){continue}break}}return(a|0)==(b|0)}function Dt(a){a=a|0;var b=0,c=0,d=0,e=0;c=fa-16|0;fa=c;L[c+12>>2]=a;a=L[c+12>>2];vg(a);P[a+1316>>2]=P[a+1256>>2];d=a+1260|0;e=L[d+4>>2];b=a+1320|0;L[b>>2]=L[d>>2];L[b+4>>2]=e;P[a+1328>>2]=P[a+1192>>2];b=a+1332|0;a=a+1196|0;d=L[a+4>>2];L[b>>2]=L[a>>2];L[b+4>>2]=d;fa=c+16|0}function gp(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0;e=fa-48|0;fa=e;L[e+44>>2]=a;L[e+40>>2]=b;L[e+36>>2]=c;L[e+32>>2]=d;a=L[e+44>>2];L[e+28>>2]=27338;b=L[e+28>>2];c=L[e+40>>2];d=L[e+36>>2];L[e+12>>2]=L[e+32>>2];L[e+8>>2]=d;L[e+4>>2]=c;L[e>>2]=a;$(b|0,1276,e|0)|0;fa=e+48|0}function PF(a,b,c){a=a|0;b=b|0;c=S(c);var d=S(0),e=S(0),f=0;d=P[b>>2];e=P[a+28>>2];a:{if(!(d<=S(e+c))|!(d>=S(S(-e)-c))){break a}d=P[b+4>>2];e=P[a+32>>2];if(!(d<=S(e+c))|!(d>=S(S(-e)-c))){break a}d=P[b+8>>2];e=P[a+36>>2];if(!(d<=S(e+c))){break a}f=d>=S(S(-e)-c)}return f|0}function va(){var a=0,b=0,c=0;c=fa-16|0;fa=c;a=L[6803];b=L[a+16>>2]-1|0;L[a+16>>2]=b;if(!(!L[a+4>>2]|b)){xc(c);b=L[8515];P[a+8>>2]=P[a+8>>2]+S(S(L[c+8>>2]+R(L[c>>2]-L[b>>2]|0,1e6)-(L[b+8>>2]+L[a+12>>2])>>>0)/S(1e3));b=L[a+16>>2]}if(!b){L[6803]=L[L[6803]+20>>2]}fa=c+16|0}function to(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0;d=fa-32|0;fa=d;L[d+28>>2]=b;L[d+24>>2]=c;c=L[d+28>>2];b=c+56|0;e=d+8|0;Vd(e,L[d+24>>2],c+56|0,b+16|0,b+32|0);b=b+(Rh(e)<<4)|0;c=L[b+4>>2];L[a>>2]=L[b>>2];L[a+4>>2]=c;c=L[b+12>>2];L[a+8>>2]=L[b+8>>2];L[a+12>>2]=c;fa=d+32|0}function Tt(a){a=a|0;var b=0,c=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=fa-32|0;fa=a;L[a+28>>2]=L[b+12>>2];c=L[a+28>>2];P[a+24>>2]=0;P[a+20>>2]=0;P[a+16>>2]=0;la(c+412|0,a+24|0,a+20|0,a+16|0);P[a+12>>2]=0;P[a+8>>2]=0;P[a+4>>2]=0;la(c+428|0,a+12|0,a+8|0,a+4|0);fa=a+32|0;fa=b+16|0}function Ch(a,b,c){var d=0;d=fa-32|0;fa=d;L[d+28>>2]=a;L[d+24>>2]=0;L[d+20>>2]=b;L[d+16>>2]=c;a=L[d+28>>2];L[d+12>>2]=L[d+24>>2];while(1){if(L[d+12>>2]>2]){b=R(L[d+12>>2],104);qa(b+L[d+16>>2]|0,b+L[a+12>>2]|0,104);L[d+12>>2]=L[d+12>>2]+1;continue}break}fa=d+32|0}function qv(a,b){a=a|0;b=b|0;var c=0,d=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;b=L[c+8>>2];a=fa-16|0;fa=a;L[a+12>>2]=L[c+12>>2];L[a+8>>2]=b;d=L[a+8>>2];b=fa-16|0;L[b+12>>2]=L[a+12>>2]+148;L[b+8>>2]=d;fa=a+16|0;fa=c+16|0;return L[L[L[b+12>>2]+12>>2]+(L[b+8>>2]<<2)>>2]}function Cj(a,b){a=a|0;b=b|0;var c=0,d=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;b=L[c+8>>2];a=fa-16|0;fa=a;L[a+12>>2]=L[c+12>>2];L[a+8>>2]=b;d=L[a+8>>2];b=fa-16|0;L[b+12>>2]=L[a+12>>2]+264;L[b+8>>2]=d;fa=a+16|0;fa=c+16|0;return L[L[L[b+12>>2]+12>>2]+(L[b+8>>2]<<2)>>2]}function zk(a,b){a=a|0;b=b|0;var c=0,d=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;b=L[c+8>>2];a=fa-16|0;L[a+12>>2]=L[c+12>>2];L[a+8>>2]=b;b=L[a+12>>2];a=L[a+8>>2];d=L[a+4>>2];L[b+680>>2]=L[a>>2];L[b+684>>2]=d;d=L[a+12>>2];L[b+688>>2]=L[a+8>>2];L[b+692>>2]=d;fa=c+16|0}function xg(a,b,c,d){var e=0;L[a>>2]=18932;e=L[b+4>>2];L[a+4>>2]=L[b>>2];L[a+8>>2]=e;e=L[b+12>>2];L[a+12>>2]=L[b+8>>2];L[a+16>>2]=e;b=L[c+4>>2];L[a+20>>2]=L[c>>2];L[a+24>>2]=b;b=L[c+12>>2];L[a+28>>2]=L[c+8>>2];L[a+32>>2]=b;L[a+40>>2]=1065353216;L[a+36>>2]=d;return a}function rk(a,b){a=a|0;b=b|0;var c=0,d=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;b=L[c+8>>2];a=fa-16|0;L[a+12>>2]=L[c+12>>2];L[a+8>>2]=b;b=L[a+12>>2];a=L[a+8>>2];d=L[a+4>>2];L[b+696>>2]=L[a>>2];L[b+700>>2]=d;d=L[a+12>>2];L[b+704>>2]=L[a+8>>2];L[b+708>>2]=d;fa=c+16|0}function Nt(a,b){a=a|0;b=b|0;var c=0,d=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;b=L[c+8>>2];a=fa-16|0;L[a+12>>2]=L[c+12>>2];L[a+8>>2]=b;b=L[a+12>>2];a=L[a+8>>2];d=L[a+4>>2];L[b+300>>2]=L[a>>2];L[b+304>>2]=d;d=L[a+12>>2];L[b+308>>2]=L[a+8>>2];L[b+312>>2]=d;fa=c+16|0}function Mt(a,b){a=a|0;b=b|0;var c=0,d=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;b=L[c+8>>2];a=fa-16|0;L[a+12>>2]=L[c+12>>2];L[a+8>>2]=b;b=L[a+12>>2];a=L[a+8>>2];d=L[a+4>>2];L[b+316>>2]=L[a>>2];L[b+320>>2]=d;d=L[a+12>>2];L[b+324>>2]=L[a+8>>2];L[b+328>>2]=d;fa=c+16|0}function rB(a,b,c,d){a=a|0;b=b|0;c=S(c);d=d|0;a:{b:{switch(d+1|0){case 0:case 6:break b;default:break a}}c:{d:{switch(b-2|0){case 0:d=a+760|0;b=2;break c;case 2:d=a+756|0;b=1;break c;case 1:break d;default:break a}}d=a+752|0;b=4}P[d>>2]=c;L[a+748>>2]=b|L[a+748>>2]}}function Uw(a){a=a|0;var b=0,c=0,d=0,e=0,f=0;b=fa-16|0;fa=b;L[b+12>>2]=a;e=L[b+12>>2];if(e){a=fa-16|0;fa=a;L[a+12>>2]=e;c=fa-16|0;fa=c;L[c+12>>2]=L[a+12>>2];f=fa-16|0;d=L[c+12>>2];L[f+12>>2]=d;Hh(d,L[L[f+12>>2]+4>>2]);jb(d);Zd(d);fa=c+16|0;fa=a+16|0;ra(e)}fa=b+16|0}function Gh(a,b,c){var d=0;d=fa-32|0;fa=d;L[d+28>>2]=a;L[d+24>>2]=0;L[d+20>>2]=b;L[d+16>>2]=c;a=L[d+28>>2];L[d+12>>2]=L[d+24>>2];while(1){if(L[d+12>>2]>2]){b=R(L[d+12>>2],36);Eh(b+L[d+16>>2]|0,b+L[a+12>>2]|0);L[d+12>>2]=L[d+12>>2]+1;continue}break}fa=d+32|0}function Dh(a,b,c){var d=0;d=fa-32|0;fa=d;L[d+28>>2]=a;L[d+24>>2]=0;L[d+20>>2]=b;L[d+16>>2]=c;a=L[d+28>>2];L[d+12>>2]=L[d+24>>2];while(1){if(L[d+12>>2]>2]){b=R(L[d+12>>2],96);qf(b+L[d+16>>2]|0,b+L[a+12>>2]|0);L[d+12>>2]=L[d+12>>2]+1;continue}break}fa=d+32|0}function lt(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;var g=0;g=fa-32|0;fa=g;L[g+28>>2]=a;L[g+24>>2]=b;L[g+20>>2]=c;L[g+16>>2]=d;L[g+12>>2]=e;L[g+8>>2]=f;a=oa(764);hl(a,L[g+28>>2],L[g+24>>2],L[g+20>>2],L[g+16>>2],L[g+12>>2],L[g+8>>2],0);fa=g+32|0;return a|0}function Vu(a,b,c){a=S(a);b=b|0;c=c|0;var d=0,e=0,f=0;d=fa-48|0;fa=d;P[d+44>>2]=a;L[d+40>>2]=b;L[d+36>>2]=c;b=sa(140);a=P[d+44>>2];c=L[d+40>>2];f=L[d+36>>2];P[d+16>>2]=0;P[d+12>>2]=0;P[d+8>>2]=0;e=d+20|0;la(e,d+16|0,d+12|0,d+8|0);Xi(b,a,c,f,e);fa=d+48|0;return b|0}function pd(a,b,c,d,e){var f=S(0);f=S(1);a:{if(b>c){break a}f=S(0);if(b==c){break a}d=S(d/e);if(d=b)|!(S(b-d)>a))){return S(S(b-a)/d)}return aS(0))){break a}if(!(!(a<=c)|!(S(c-d)c?S(0):S(1)}return f}function Hy(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0;if(Wa(a,L[b+8>>2],0)){Xf(b,c,d);return}e=L[a+12>>2];f=a+16|0;Oj(f,b,c,d);a=a+24|0;e=(e<<3)+f|0;a:{if(a>>>0>=e>>>0){break a}while(1){Oj(a,b,c,d);if(M[b+54|0]){break a}a=a+8|0;if(e>>>0>a>>>0){continue}break}}}function rb(a,b,c){var d=0,e=0;d=fa-48|0;fa=d;L[d+44>>2]=a;L[d+40>>2]=b;L[d+36>>2]=c;a=L[d+44>>2];if(P[a+344>>2]!=S(0)){Ti(a,L[d+40>>2]);b=fa-16|0;L[b+12>>2]=a+544;if(L[b+12>>2]){b=L[d+36>>2];c=d+4|0;Kb(c,L[d+40>>2],a+348|0);e=d+20|0;Ub(e,b,c);Ui(a,e)}}fa=d+48|0}function qi(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=S(d);e=e|0;f=f|0;var g=0;g=fa-32|0;fa=g;L[g+28>>2]=a;L[g+24>>2]=b;L[g+20>>2]=c;P[g+16>>2]=d;L[g+12>>2]=e;L[g+8>>2]=f;a=L[g+28>>2];ha[L[L[a>>2]+32>>2]](a,L[g+24>>2],L[g+20>>2],P[g+16>>2],L[g+12>>2],L[g+8>>2]);fa=g+32|0}function qG(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;a=L[b>>2];a=ha[L[L[a>>2]+56>>2]](a,16)|0;L[a>>2]=8684;L[a+4>>2]=L[b>>2];L[a>>2]=8712;L[a+12>>2]=0;J[a+8|0]=0;L[a>>2]=11644;b=L[a+4>>2];b=ha[L[L[b>>2]+12>>2]](b,L[c+8>>2],L[d+8>>2])|0;J[a+8|0]=1;L[a+12>>2]=b;return a|0}function JC(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;db(a,b,c);d=L[a+144>>2];ha[L[L[d>>2]+56>>2]](d,b+12|0,c)|0;P[b+56>>2]=P[a+12>>2];P[b+40>>2]=P[a+52>>2];P[b+44>>2]=P[a+56>>2];P[b+48>>2]=P[a+60>>2];P[b+52>>2]=P[a- -64>>2];L[b+60>>2]=ha[L[L[a>>2]+80>>2]](a);return 3910}function Zl(a,b,c,d,e,f,g,h,i,j){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;i=i|0;j=j|0;a=L[a+32>>2]+(j<<5)|0;L[c>>2]=L[a+12>>2];L[b>>2]=L[a+16>>2];L[d>>2]=L[a+28>>2];L[e>>2]=L[a+20>>2];L[h>>2]=L[a>>2];L[f>>2]=L[a+4>>2];L[g>>2]=L[a+8>>2];L[i>>2]=L[a+24>>2]}function wH(a){a=a|0;var b=0,c=0,d=0;wa(2870);b=L[a+8>>2];if((b|0)>0){while(1){d=L[L[a+16>>2]+(c<<2)>>2];a:{b:{if(M[a+76|0]){break b}switch(L[d+216>>2]-2|0){case 0:case 3:break a;default:break b}}rn(a,d);b=L[a+8>>2]}c=c+1|0;if((b|0)>(c|0)){continue}break}}va()}function df(a,b){var c=0,d=0;c=fa-16|0;fa=c;L[c+12>>2]=b;d=fa-16|0;b=L[c+12>>2];P[d+12>>2]=P[b>>2];P[c+8>>2]=T(P[d+12>>2]);d=fa-16|0;P[d+12>>2]=P[b+4>>2];P[c+4>>2]=T(P[d+12>>2]);d=fa-16|0;P[d+12>>2]=P[b+8>>2];P[c>>2]=T(P[d+12>>2]);la(a,c+8|0,c+4|0,c);fa=c+16|0}function Wl(a,b){a=a|0;b=b|0;var c=0,d=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;b=L[c+8>>2];a=fa-16|0;L[a+12>>2]=L[c+12>>2];L[a+8>>2]=b;b=L[a+12>>2];a=L[a+8>>2];d=L[a+4>>2];L[b+4>>2]=L[a>>2];L[b+8>>2]=d;d=L[a+12>>2];L[b+12>>2]=L[a+8>>2];L[b+16>>2]=d;fa=c+16|0}function hC(a,b,c,d){a=a|0;b=b|0;c=c|0;d=S(d);var e=0;e=L[b+4>>2];L[a+4>>2]=L[b>>2];L[a+8>>2]=e;e=L[b+12>>2];L[a+12>>2]=L[b+8>>2];L[a+16>>2]=e;b=L[c+4>>2];L[a+20>>2]=L[c>>2];L[a+24>>2]=b;b=L[c+12>>2];L[a+28>>2]=L[c+8>>2];L[a+32>>2]=b;J[a+40|0]=1;P[a+36>>2]=d}function pp(a){a=a|0;var b=0;b=fa-32|0;fa=b;L[b+28>>2]=a;if(!M[30020]){L[(fa-16|0)+12>>2]=30004;J[30020]=1}a=L[b+28>>2];ha[L[L[a>>2]+76>>2]](b+12|0,a);a=L[b+16>>2];L[7501]=L[b+12>>2];L[7502]=a;a=L[b+24>>2];L[7503]=L[b+20>>2];L[7504]=a;fa=b+32|0;return 30004}function Oy(a){a=a|0;var b=0;b=fa-32|0;fa=b;L[b+28>>2]=a;if(!M[29624]){L[(fa-16|0)+12>>2]=29608;J[29624]=1}a=L[b+28>>2];ha[L[L[a>>2]+76>>2]](b+12|0,a);a=L[b+16>>2];L[7402]=L[b+12>>2];L[7403]=a;a=L[b+24>>2];L[7404]=L[b+20>>2];L[7405]=a;fa=b+32|0;return 29608}function Gd(a){var b=0;b=L[a>>2];if(b){Hd(a,b)}b=L[a+4>>2];if(b){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+4>>2]=0;L[a+8>>2]=-1;b=L[a+32>>2];if(!(b?!b|!M[a+36|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+32>>2]=0;J[a+36|0]=1;L[a+16>>2]=0;L[a+24>>2]=0;L[a+28>>2]=0}function vD(a,b,c){a=a|0;b=b|0;c=c|0;db(a,b,c);P[b+12>>2]=P[a+68>>2];P[b+16>>2]=P[a+72>>2];P[b+20>>2]=P[a+76>>2];P[b+24>>2]=P[a+80>>2];P[b+28>>2]=P[a+48>>2];P[b+32>>2]=P[a+52>>2];P[b+36>>2]=P[a+56>>2];P[b+40>>2]=P[a+60>>2];P[b+44>>2]=P[a+64>>2];return 3996}function uH(a){a=a|0;var b=0,c=0,d=0,e=0,f=0,g=0,h=0;wa(2986);ha[L[L[a>>2]+8>>2]](a);ha[L[L[a>>2]+12>>2]](a);b=L[a+24>>2];wa(2597);if(b){c=L[a+68>>2];e=b,f=ha[L[L[c>>2]+36>>2]](c)|0,g=a+28|0,h=L[a+24>>2],d=L[L[b>>2]+32>>2],ha[d](e|0,f|0,g|0,h|0)}va();va()}function lo(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0;e=fa-16|0;fa=e;L[e+12>>2]=a;L[e+8>>2]=b;L[e+4>>2]=c;L[e>>2]=d;a=L[e+12>>2];gf(a,L[e+4>>2]);c=L[a+60>>2];b=L[e>>2];L[b>>2]=L[a+56>>2];L[b+4>>2]=c;c=L[a+68>>2];L[b+8>>2]=L[a+64>>2];L[b+12>>2]=c;fa=e+16|0}function vm(a){a=a|0;var b=0;L[a>>2]=13272;b=L[a+64>>2];if(b){gc(b);b=L[a+64>>2];if(b){L[8514]=L[8514]+1;ha[L[6799]](b)}}b=L[a+24>>2];if(!(b?!b|!M[a+28|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+24>>2]=0;J[a+28|0]=1;L[a+16>>2]=0;L[a+20>>2]=0;return a|0}function Lp(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;a=fa-16|0;fa=a;L[a+8>>2]=L[c+8>>2];b=fa-16|0;L[b+12>>2]=L[a+8>>2];a:{if(L[L[b+12>>2]+236>>2]==8){L[a+12>>2]=L[a+8>>2];break a}L[a+12>>2]=0}fa=a+16|0;fa=c+16|0;return L[a+12>>2]}function $t(a,b){a=a|0;b=b|0;var c=0,d=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;b=L[c+8>>2];a=fa-16|0;fa=a;L[a+12>>2]=L[c+12>>2];L[a+8>>2]=b;b=L[a+12>>2];L[b+480>>2]=L[a+8>>2];if(L[b+480>>2]){d=L[a+8>>2];ha[L[L[d>>2]+8>>2]](d,b+4|0)}fa=a+16|0;fa=c+16|0}function kf(a,b,c){var d=0;d=fa-32|0;L[d+28>>2]=a;L[d+24>>2]=0;L[d+20>>2]=b;L[d+16>>2]=c;a=L[d+28>>2];L[d+12>>2]=L[d+24>>2];while(1){if(L[d+12>>2]>2]){b=L[d+12>>2]<<2;L[b+L[d+16>>2]>>2]=L[b+L[a+12>>2]>>2];L[d+12>>2]=L[d+12>>2]+1;continue}break}}function Yt(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;a=fa-16|0;fa=a;L[a+8>>2]=L[c+8>>2];b=fa-16|0;L[b+12>>2]=L[a+8>>2];a:{if(L[L[b+12>>2]+236>>2]&2){L[a+12>>2]=L[a+8>>2];break a}L[a+12>>2]=0}fa=a+16|0;fa=c+16|0;return L[a+12>>2]}function Th(a,b,c){var d=0;d=fa-32|0;L[d+28>>2]=a;L[d+24>>2]=0;L[d+20>>2]=b;L[d+16>>2]=c;a=L[d+28>>2];L[d+12>>2]=L[d+24>>2];while(1){if(L[d+12>>2]>2]){b=L[d+12>>2]<<2;P[b+L[d+16>>2]>>2]=P[b+L[a+12>>2]>>2];L[d+12>>2]=L[d+12>>2]+1;continue}break}}function Ds(a){a=a|0;var b=0,c=0,d=0,e=0;c=fa-16|0;fa=c;L[c+12>>2]=a;d=sa(8);b=L[c+12>>2];a=fa-16|0;fa=a;L[a+12>>2]=d;L[a+8>>2]=b;e=fa-16|0;b=L[a+12>>2];L[e+12>>2]=b;L[L[e+12>>2]>>2]=5176;L[b>>2]=20900;L[b+4>>2]=L[a+8>>2];fa=a+16|0;fa=c+16|0;return d|0}function pF(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0,g=0,h=0,i=0;c=(e=b,f=ha[L[L[a>>2]+52>>2]](a)|0,g=1,d=L[L[b>>2]+16>>2],ha[d](e|0,f|0,g|0)|0);g=b,f=c,e=ha[L[L[a>>2]+56>>2]](a,L[c+8>>2],b)|0,h=1346455635,i=a,d=L[L[b>>2]+20>>2],ha[d](g|0,f|0,e|0,h|0,i|0)}function ky(a){a=a|0;var b=S(0),c=0,d=0;c=fa-16|0;fa=c;L[c+12>>2]=a;a=fa-16|0;fa=a;L[a+12>>2]=L[c+12>>2];d=L[a+12>>2];a:{if(_b(d,d)>2]);P[a+8>>2]=b+b;break a}b=uc(S(-P[d+12>>2]));P[a+8>>2]=b+b}fa=a+16|0;fa=c+16|0;return S(P[a+8>>2])}function gA(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0,g=0,h=0,i=0;c=(e=b,f=ha[L[L[a>>2]+16>>2]](a)|0,g=1,d=L[L[b>>2]+16>>2],ha[d](e|0,f|0,g|0)|0);g=b,f=c,e=ha[L[L[a>>2]+20>>2]](a,L[c+8>>2],b)|0,h=1497645650,i=a,d=L[L[b>>2]+20>>2],ha[d](g|0,f|0,e|0,h|0,i|0)}function AH(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0,g=0,h=0,i=0;c=(e=b,f=ha[L[L[a>>2]+16>>2]](a)|0,g=1,d=L[L[b>>2]+16>>2],ha[d](e|0,f|0,g|0)|0);g=b,f=c,e=ha[L[L[a>>2]+20>>2]](a,L[c+8>>2],b)|0,h=1245859651,i=a,d=L[L[b>>2]+20>>2],ha[d](g|0,f|0,e|0,h|0,i|0)}function vu(a,b,c){a=a|0;b=S(b);c=S(c);var d=0,e=0;d=fa-16|0;fa=d;L[d+12>>2]=a;P[d+8>>2]=b;P[d+4>>2]=c;b=P[d+8>>2];c=P[d+4>>2];a=fa-16|0;L[a+12>>2]=L[d+12>>2];P[a+8>>2]=b;P[a+4>>2]=c;e=L[a+12>>2];P[e+472>>2]=P[a+8>>2];P[e+476>>2]=P[a+4>>2];fa=d+16|0}function uo(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;d=fa-16|0;fa=d;L[d+12>>2]=a;L[d+8>>2]=b;L[d+4>>2]=c;a=L[d+12>>2];L[d>>2]=L[d+8>>2];db(a,L[d>>2],L[d+4>>2]);Sh(a+28|0,L[d>>2]+28|0);Sh(a+12|0,L[d>>2]+12|0);P[L[d>>2]+44>>2]=P[a+44>>2];fa=d+16|0;return 3884}function ad(a){a=a|0;var b=0,c=0,d=0,e=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=fa-16|0;fa=a;L[a+12>>2]=L[b+12>>2];d=fa-16|0;e=L[a+12>>2];L[d+12>>2]=e;if(L[L[d+12>>2]+216>>2]!=2){c=fa-16|0;L[c+12>>2]=e;c=L[L[c+12>>2]+216>>2]!=5}fa=a+16|0;fa=b+16|0;return c|0}function Yi(a,b,c){var d=0;d=fa-16|0;fa=d;L[d+12>>2]=a;L[d+8>>2]=b;L[d+4>>2]=c;a=L[d+12>>2];If(a);L[a>>2]=17880;c=a+144|0;bj(c);L[a+152>>2]=L[d+8>>2];L[a+172>>2]=L[d+4>>2];b=fa-16|0;L[b+12>>2]=a+68;L[b+8>>2]=c;L[L[b+12>>2]+72>>2]=L[b+8>>2];fa=d+16|0}function ta(a,b,c){var d=0;d=fa-32|0;fa=d;L[d+28>>2]=b;L[d+24>>2]=c;P[d+20>>2]=P[L[d+28>>2]>>2]+P[L[d+24>>2]>>2];P[d+16>>2]=P[L[d+28>>2]+4>>2]+P[L[d+24>>2]+4>>2];P[d+12>>2]=P[L[d+28>>2]+8>>2]+P[L[d+24>>2]+8>>2];la(a,d+20|0,d+16|0,d+12|0);fa=d+32|0}function La(a,b,c){var d=0;d=fa-32|0;fa=d;L[d+28>>2]=b;L[d+24>>2]=c;P[d+20>>2]=P[L[d+28>>2]>>2]-P[L[d+24>>2]>>2];P[d+16>>2]=P[L[d+28>>2]+4>>2]-P[L[d+24>>2]+4>>2];P[d+12>>2]=P[L[d+28>>2]+8>>2]-P[L[d+24>>2]+8>>2];la(a,d+20|0,d+16|0,d+12|0);fa=d+32|0}function Kb(a,b,c){var d=0;d=fa-32|0;fa=d;L[d+28>>2]=b;L[d+24>>2]=c;P[d+20>>2]=P[L[d+28>>2]>>2]*P[L[d+24>>2]>>2];P[d+16>>2]=P[L[d+28>>2]+4>>2]*P[L[d+24>>2]+4>>2];P[d+12>>2]=P[L[d+28>>2]+8>>2]*P[L[d+24>>2]+8>>2];la(a,d+20|0,d+16|0,d+12|0);fa=d+32|0}function XH(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0;if(L[a+8>>2]>0){while(1){e=L[a+16>>2]+(d<<4)|0;a:{if(ha[L[L[b>>2]+8>>2]](b,e)|0){ha[L[L[a>>2]+12>>2]](a,L[e>>2],L[e+4>>2],c)|0;L[7536]=L[7536]-1;break a}d=d+1|0}if(L[a+8>>2]>(d|0)){continue}break}}}function kl(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0,g=0,h=0;c=L[a+32>>2];e=c+328|0;d=L[a+28>>2];f=d+328|0;g=c+312|0;h=d+312|0;c=c+4|0;d=d+4|0;if(M[a+1301|0]){il(a,b,jl(a,b,0,d,c,h,g,f,e),d,c,h,g,f,e);return}jl(a,b,il(a,b,0,d,c,h,g,f,e),d,c,h,g,f,e)}function kI(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,i=0;c=fa-16|0;fa=c;L[c+8>>2]=5920;L[c+12>>2]=d;g=d+4|0;h=d+20|0;i=c+8|0;Bn(a+4|0,L[a+4>>2],b,g,h,P[d+32>>2],e,f,i);a=a- -64|0;Bn(a,L[a>>2],b,g,h,P[d+32>>2],e,f,i);fa=c+16|0}function NA(a){a=a|0;var b=0,c=0;if(L[a+232>>2]>0){while(1){b=L[L[a+240>>2]+(c<<2)>>2];L[b+412>>2]=0;L[b+416>>2]=0;L[b+436>>2]=0;L[b+440>>2]=0;L[b+428>>2]=0;L[b+432>>2]=0;L[b+420>>2]=0;L[b+424>>2]=0;c=c+1|0;if((c|0)>2]){continue}break}}}function iB(a,b,c){a=a|0;b=b|0;c=c|0;cc(a,b,c);P[b+52>>2]=P[a+300>>2];P[b+56>>2]=P[a+304>>2];P[b+60>>2]=P[a+308>>2];P[b- -64>>2]=P[a+312>>2];P[b+68>>2]=P[a+316>>2];P[b+72>>2]=P[a+320>>2];P[b+76>>2]=P[a+324>>2];P[b+80>>2]=P[a+328>>2];return 3523}function ht(a,b,c,d,e,f){a=a|0;b=S(b);c=S(c);d=S(d);e=S(e);f=S(f);var g=0;g=fa-32|0;fa=g;L[g+28>>2]=a;P[g+24>>2]=b;P[g+20>>2]=c;P[g+16>>2]=d;P[g+12>>2]=e;P[g+8>>2]=f;Si(L[g+28>>2],P[g+24>>2],P[g+20>>2],P[g+16>>2],P[g+12>>2],P[g+8>>2]);fa=g+32|0}function XF(a,b,c){a=a|0;b=b|0;c=c|0;var d=S(0),e=S(0),f=S(0),g=S(0),h=S(0),i=S(0);d=P[b+32>>2];e=P[b+36>>2];g=P[c+4>>2];h=P[c+8>>2];f=P[b+28>>2];i=P[c>>2];L[a+12>>2]=0;P[a>>2]=i>=S(0)?f:S(-f);P[a+8>>2]=h>=S(0)?e:S(-e);P[a+4>>2]=g>=S(0)?d:S(-d)}function Ga(a,b,c){var d=0;d=fa-32|0;fa=d;L[d+28>>2]=b;L[d+24>>2]=c;P[d+20>>2]=P[L[d+28>>2]>>2]*P[L[d+24>>2]>>2];P[d+16>>2]=P[L[d+28>>2]+4>>2]*P[L[d+24>>2]>>2];P[d+12>>2]=P[L[d+28>>2]+8>>2]*P[L[d+24>>2]>>2];la(a,d+20|0,d+16|0,d+12|0);fa=d+32|0}function vv(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;d=fa-16|0;fa=d;L[d+12>>2]=a;L[d+8>>2]=b;L[d+4>>2]=c;b=L[d+8>>2];c=L[d+4>>2];a=fa-16|0;fa=a;L[a+12>>2]=L[d+12>>2];L[a+8>>2]=b;L[a+4>>2]=c;Lb(L[a+12>>2]+144|0,L[a+8>>2],L[a+4>>2]);fa=a+16|0;fa=d+16|0}function Jc(a,b){var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;a=L[c+12>>2];L[(fa-16|0)+12>>2]=a;Zd(a);b=fa-16|0;L[b+12>>2]=L[c+8>>2];L[c+4>>2]=L[L[b+12>>2]+4>>2];b=L[c+4>>2];L[c>>2]=0;Ih(a,b,c);kf(L[c+8>>2],L[c+4>>2],L[a+12>>2]);fa=c+16|0}function re(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=S(f);var g=0;g=fa-32|0;fa=g;L[g+28>>2]=a;L[g+24>>2]=b;L[g+20>>2]=c;L[g+16>>2]=d;L[g+12>>2]=e;P[g+8>>2]=f;Ab(L[g+28>>2],L[g+24>>2],L[g+20>>2],L[g+16>>2],L[g+12>>2],P[g+8>>2]);fa=g+32|0}function $A(a,b,c,d,e,f,g,h,i,j){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;i=i|0;j=j|0;wa(2911);S(ha[L[L[a>>2]+44>>2]](a,b,c,d,e,f,g,h,i));S(ha[L[L[a>>2]+48>>2]](a,b,c,d,e,f,g,h,i));S(ha[L[L[a>>2]+36>>2]](a,b,c,h));va();return S(S(0))}function qB(a,b,c){a=a|0;b=b|0;c=c|0;var d=S(0);a:{b:{switch(c+1|0){case 0:case 6:break b;default:break a}}c:{switch(b-2|0){case 0:return S(P[a+760>>2]);case 2:return S(P[a+756>>2]);case 1:break c;default:break a}}d=P[a+752>>2]}return S(d)}function kD(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;d=L[b+4>>2];L[a+52>>2]=L[b>>2];L[a+56>>2]=d;d=L[b+12>>2];L[a+60>>2]=L[b+8>>2];L[a+64>>2]=d;b=L[c+4>>2];L[a+68>>2]=L[c>>2];L[a+72>>2]=b;b=L[c+12>>2];L[a+76>>2]=L[c+8>>2];L[a+80>>2]=b;L[a+48>>2]=1}function jb(a){var b=0,c=0,d=0;c=fa-16|0;fa=c;L[c+12>>2]=a;a=L[c+12>>2];if(L[a+12>>2]){if(J[a+16|0]&1){d=L[a+12>>2];b=fa-16|0;fa=b;L[b+12>>2]=a;L[b+8>>2]=d;d=L[b+8>>2];if(d){L[8514]=L[8514]+1;ha[L[6799]](d)}fa=b+16|0}L[a+12>>2]=0}fa=c+16|0}function KH(a,b,c){a=a|0;b=b|0;c=c|0;a:{b:{c:{switch(L[b+216>>2]-2|0){case 0:case 3:break c;default:break b}}a=0;switch(L[c+216>>2]-2|0){case 0:case 3:break a;default:break b}}if(!L[b+256>>2]){return 1}a=ha[L[L[b>>2]>>2]](b,c)|0}return a|0}function HH(a,b){a=a|0;b=b|0;var c=0;a:{if(!b){break a}a=L[a+64>>2];c=L[a+16>>2];if(c>>>0>b>>>0|R(L[a>>2],L[a+4>>2])+c>>>0<=b>>>0){break a}L[b>>2]=L[a+12>>2];L[a+12>>2]=b;L[a+8>>2]=L[a+8>>2]+1;return}if(b){L[8514]=L[8514]+1;ha[L[6799]](b)}}function $u(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=0;f=fa-32|0;fa=f;L[f+28>>2]=a;L[f+24>>2]=b;L[f+20>>2]=c;L[f+16>>2]=d;J[f+15|0]=e;a=oa(116);Ld(a,L[f+28>>2],L[f+24>>2],L[f+20>>2]&65535,L[f+16>>2],J[f+15|0]&1);fa=f+32|0;return a|0}function Pf(a,b,c){var d=0;d=fa-16|0;fa=d;L[d+12>>2]=a;L[d+8>>2]=b;L[d+4>>2]=c;b=fa-16|0;a=L[d+12>>2];L[b+12>>2]=a;L[L[b+12>>2]>>2]=1384;L[a>>2]=1416;Yb(a+4|0,L[d+8>>2]);Yb(a+68|0,L[d+4>>2]);Yb(a+132|0,L[d+8>>2]);L[a+196>>2]=0;fa=d+16|0}function po(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0;e=fa-16|0;fa=e;L[e+12>>2]=a;L[e+8>>2]=b;L[e+4>>2]=c;L[e>>2]=d;a=L[e+12>>2];ha[L[L[a>>2]+108>>2]](a,L[e+8>>2],L[e+4>>2]);ha[L[L[a>>2]+108>>2]](a,(L[e+8>>2]+1|0)%3|0,L[e>>2]);fa=e+16|0}function dn(a,b,c,d,e){L[a>>2]=8684;L[a+4>>2]=L[b>>2];L[a>>2]=8712;L[a>>2]=9768;J[a+28|0]=e;J[a+24|0]=1;L[a+20>>2]=0;L[a+12>>2]=0;L[a+16>>2]=0;b=L[b+4>>2];J[a+36|0]=0;L[a+32>>2]=b;L[a+40>>2]=L[L[(e?d:c)+4>>2]+68>>2];cn(a,c,d);return a}function OH(a,b){a=a|0;b=b|0;var c=0,d=0,e=0;if(L[b+748>>2]>0){a=0;while(1){c=R(a,184)+b|0;d=L[c+116>>2];a:{if(!d){break a}e=L[8113];if(!e){break a}ha[e|0](d)|0;L[c+116>>2]=0}a=a+1|0;if((a|0)>2]){continue}break}}L[b+748>>2]=0}function Kz(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;d=L[a+896>>2];L[b>>2]=L[a+892>>2];L[b+4>>2]=d;d=L[a+904>>2];L[b+8>>2]=L[a+900>>2];L[b+12>>2]=d;b=L[a+920>>2];L[c+8>>2]=L[a+916>>2];L[c+12>>2]=b;b=L[a+912>>2];L[c>>2]=L[a+908>>2];L[c+4>>2]=b}function Yz(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=0;f=fa-32|0;fa=f;L[f+28>>2]=a;L[f+24>>2]=b;L[f+20>>2]=c;L[f+16>>2]=d;J[f+15|0]=e;a=oa(1312);ml(a,L[f+28>>2],L[f+24>>2],L[f+20>>2],L[f+16>>2],J[f+15|0]&1);fa=f+32|0;return a|0}function Er(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;b=L[c+8>>2];a=fa-16|0;L[a+12>>2]=L[c+12>>2];L[a+8>>2]=b;b=L[a+12>>2];if(L[a+8>>2]<0){L[a+8>>2]=0}if(L[a+8>>2]>2){L[a+8>>2]=2}L[b+176>>2]=L[a+8>>2];fa=c+16|0}function mt(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=0;f=fa-32|0;fa=f;L[f+28>>2]=a;L[f+24>>2]=b;L[f+20>>2]=c;L[f+16>>2]=d;J[f+15|0]=e;a=oa(764);gl(a,L[f+28>>2],L[f+24>>2],L[f+20>>2],L[f+16>>2],J[f+15|0]&1);fa=f+32|0;return a|0}function Vv(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=0;f=fa-32|0;fa=f;L[f+28>>2]=a;L[f+24>>2]=b;L[f+20>>2]=c;L[f+16>>2]=d;L[f+12>>2]=e;a=L[f+28>>2];ha[L[L[a>>2]+120>>2]](a,L[f+24>>2],L[f+20>>2],L[f+16>>2],L[f+12>>2]);fa=f+32|0}function mH(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,f=S(0);d=fa-16|0;fa=d;L[d+8>>2]=-1;L[d+12>>2]=L[a+24>>2];if(!L[b+4>>2]){L[b+4>>2]=d+8}e=L[a+20>>2];f=S(ha[L[L[e>>2]+12>>2]](e,b,c));P[a+4>>2]=P[L[a+20>>2]+4>>2];fa=d+16|0;return S(f)}function iH(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,f=S(0);d=fa-16|0;fa=d;L[d+8>>2]=-1;L[d+12>>2]=L[a+16>>2];if(!L[b+4>>2]){L[b+4>>2]=d+8}e=L[a+12>>2];f=S(ha[L[L[e>>2]+12>>2]](e,b,c));P[a+4>>2]=P[L[a+12>>2]+4>>2];fa=d+16|0;return S(f)}function Rz(a,b){a=a|0;b=S(b);var c=0,d=S(0),e=S(0);c=fa-16|0;fa=c;if(P[a+68>>2]>S(0)){b=P[a+92>>2];d=P[a+96>>2];e=P[a+88>>2];L[c+12>>2]=0;P[c>>2]=-e;P[c+8>>2]=-d;P[c+4>>2]=-b;zc(a+4|0,c,a+164|0);zc(a+16|0,a+88|0,a+180|0)}fa=c+16|0}function Ng(a){a=a|0;var b=0,c=0,d=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=fa-16|0;fa=a;L[a+12>>2]=L[b+12>>2];c=L[a+12>>2];L[a+8>>2]=(L[c+52>>2]+2|0)%3;d=fa-16|0;L[d+12>>2]=c+28;fa=a+16|0;fa=b+16|0;return S(P[L[d+12>>2]+(L[a+8>>2]<<2)>>2])}function NE(a,b,c){a=a|0;b=b|0;c=c|0;var d=S(0),e=S(0),f=S(0),g=S(0),h=S(0),i=S(0);b=L[a+104>>2]+(b<<4)|0;d=P[b>>2];e=P[b+4>>2];f=P[b+8>>2];g=P[a+16>>2];h=P[a+20>>2];i=P[a+12>>2];L[c+12>>2]=0;P[c+8>>2]=f*h;P[c+4>>2]=e*g;P[c>>2]=d*i}function Io(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;L[c+12>>2]=a;L[c+8>>2]=b;a=L[c+12>>2];J[c+7|0]=(N[L[c+8>>2]+4>>1]<<16>>16&N[a+14>>1]<<16>>16)!=0;J[c+7|0]=J[c+7|0]&1&(N[a+12>>1]<<16>>16&N[L[c+8>>2]+6>>1]<<16>>16)!=0;return J[c+7|0]&1}function co(a,b){a=a|0;b=b|0;var c=0,d=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;b=L[c+8>>2];d=L[b+4>>2];a=L[c+12>>2];L[a+52>>2]=L[b>>2];L[a+56>>2]=d;d=L[b+12>>2];L[a+60>>2]=L[b+8>>2];L[a+64>>2]=d;ha[L[L[a>>2]+72>>2]](a);fa=c+16|0}function Gt(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0;d=fa-16|0;fa=d;L[d+12>>2]=a;L[d+8>>2]=b;J[d+7|0]=c;c=L[d+12>>2];a=L[d+8>>2];e=c+a|0;b=J[d+7|0]&1;J[e+1309|0]=b;a:{if((a|0)<=2){J[e+788|0]=b;break a}J[(c+(a<<6)|0)+720|0]=b}fa=d+16|0}function Co(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;L[c+12>>2]=a;L[c+8>>2]=b;a=L[c+12>>2];J[c+7|0]=(N[L[c+8>>2]+4>>1]<<16>>16&N[a+10>>1]<<16>>16)!=0;J[c+7|0]=J[c+7|0]&1&(N[a+8>>1]<<16>>16&N[L[c+8>>2]+6>>1]<<16>>16)!=0;return J[c+7|0]&1}function Jw(a){a=a|0;var b=0,c=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=oa(48);c=L[b+12>>2];J[a+16|0]=1;L[a+44>>2]=c;L[a+12>>2]=0;L[a+4>>2]=0;L[a+8>>2]=0;L[a+40>>2]=0;J[a+36|0]=1;L[a+32>>2]=0;L[a+24>>2]=0;L[a+28>>2]=0;fa=b+16|0;return a|0}function Eo(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;L[c+12>>2]=a;L[c+8>>2]=b;a=L[c+12>>2];J[c+7|0]=(N[L[c+8>>2]+4>>1]<<16>>16&N[a+6>>1]<<16>>16)!=0;J[c+7|0]=J[c+7|0]&1&(N[a+4>>1]<<16>>16&N[L[c+8>>2]+6>>1]<<16>>16)!=0;return J[c+7|0]&1}function MA(a){a=a|0;var b=0,c=0,d=0;b=L[a+232>>2];if((b|0)>0){while(1){a:{b:{d=L[L[a+240>>2]+(c<<2)>>2];switch(L[d+216>>2]-2|0){case 0:case 3:break a;default:break b}}Jk(d);b=L[a+232>>2]}c=c+1|0;if((b|0)>(c|0)){continue}break}}}function He(a){J[a+356|0]=1;L[a>>2]=0;J[a+312|0]=0;L[a+292>>2]=1566444395;L[a+296>>2]=1566444395;L[a+336>>2]=0;L[a+340>>2]=0;L[a+300>>2]=1566444395;L[a+304>>2]=0;L[a+344>>2]=0;L[a+348>>2]=0;J[a+352|0]=0;J[a+332|0]=M[a+332|0]&240}function Vd(a,b,c,d,e){var f=0;f=fa-32|0;fa=f;L[f+28>>2]=b;L[f+24>>2]=c;L[f+20>>2]=d;L[f+16>>2]=e;b=L[f+28>>2];P[f+12>>2]=Sa(b,L[f+24>>2]);P[f+8>>2]=Sa(b,L[f+20>>2]);P[f+4>>2]=Sa(b,L[f+16>>2]);la(a,f+12|0,f+8|0,f+4|0);fa=f+32|0}function xh(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;a=L[b+20>>2];L[c>>2]=L[b+16>>2];L[c+4>>2]=a;a=L[b+28>>2];L[c+8>>2]=L[b+24>>2];L[c+12>>2]=a;a=L[b+44>>2];L[d+8>>2]=L[b+40>>2];L[d+12>>2]=a;a=L[b+36>>2];L[d>>2]=L[b+32>>2];L[d+4>>2]=a}function oo(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;d=fa-16|0;L[d+12>>2]=a;L[d+8>>2]=b;L[d+4>>2]=c;a=(L[d+12>>2]+56|0)+(L[d+8>>2]<<4)|0;c=L[a+4>>2];b=L[d+4>>2];L[b>>2]=L[a>>2];L[b+4>>2]=c;c=L[a+12>>2];L[b+8>>2]=L[a+8>>2];L[b+12>>2]=c}function iD(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;d=L[a+56>>2];L[b>>2]=L[a+52>>2];L[b+4>>2]=d;d=L[a+64>>2];L[b+8>>2]=L[a+60>>2];L[b+12>>2]=d;b=L[a+80>>2];L[c+8>>2]=L[a+76>>2];L[c+12>>2]=b;b=L[a+72>>2];L[c>>2]=L[a+68>>2];L[c+4>>2]=b}function vc(a,b,c,d,e){var f=0;f=fa-32|0;L[f+28>>2]=a;L[f+24>>2]=b;L[f+20>>2]=c;L[f+16>>2]=d;L[f+12>>2]=e;a=L[f+28>>2];P[a>>2]=P[L[f+24>>2]>>2];P[a+4>>2]=P[L[f+20>>2]>>2];P[a+8>>2]=P[L[f+16>>2]>>2];P[a+12>>2]=P[L[f+12>>2]>>2]}function _o(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;d=fa-32|0;fa=d;L[d+28>>2]=a;L[d+24>>2]=b;L[d+20>>2]=c;a=L[d+28>>2];L[d+16>>2]=28052;b=L[d+16>>2];c=L[d+24>>2];L[d+8>>2]=L[d+20>>2];L[d+4>>2]=c;L[d>>2]=a;$(b|0,1291,d|0)|0;fa=d+32|0}function Zy(a){a=a|0;var b=0,c=0,d=0;b=L[a+24>>2];if((b|0)>0){while(1){a:{b:{d=L[L[a+32>>2]+(c<<2)>>2];switch(L[d+216>>2]-2|0){case 0:case 3:break a;default:break b}}ig(d);b=L[a+24>>2]}c=c+1|0;if((c|0)<(b|0)){continue}break}}}function Kn(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;d=L[a+12>>2];L[b>>2]=L[a+8>>2];L[b+4>>2]=d;d=L[a+20>>2];L[b+8>>2]=L[a+16>>2];L[b+12>>2]=d;b=L[a+36>>2];L[c+8>>2]=L[a+32>>2];L[c+12>>2]=b;b=L[a+28>>2];L[c>>2]=L[a+24>>2];L[c+4>>2]=b}function Jn(a,b){a=a|0;b=b|0;var c=0,d=0;if(!N[a+56>>1]){b=1;K[a+64>>1]=1;d=L[a+60>>2];c=N[a+58>>1];if(c>>>0>1){while(1){c=(b<<6)+d|0;b=b+1|0;K[c+48>>1]=b;c=N[a+58>>1];if(c>>>0>b>>>0){continue}break}}K[((c<<6)+d|0)-16>>1]=0}}function zj(a,b){var c=0;c=fa-16|0;L[c+12>>2]=a;L[c+8>>2]=b;a=L[c+12>>2];P[a>>2]=P[a>>2]*P[L[c+8>>2]>>2];P[a+4>>2]=P[a+4>>2]*P[L[c+8>>2]>>2];P[a+8>>2]=P[a+8>>2]*P[L[c+8>>2]>>2];P[a+12>>2]=P[a+12>>2]*P[L[c+8>>2]>>2];return a}function eA(a){a=a|0;var b=0;L[a>>2]=20800;b=L[a+496>>2];if(!(b?!b|!M[a+500|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+496>>2]=0;J[a+500|0]=1;L[a+488>>2]=0;L[a+492>>2]=0;L[a>>2]=6712;if(a){L[8514]=L[8514]+1;ha[L[6799]](a)}}function xl(a,b,c){var d=0;Al(a);d=L[a+248>>2];L[b>>2]=L[a+244>>2];L[b+4>>2]=d;d=L[a+256>>2];L[b+8>>2]=L[a+252>>2];L[b+12>>2]=d;b=L[a+272>>2];L[c+8>>2]=L[a+268>>2];L[c+12>>2]=b;b=L[a+264>>2];L[c>>2]=L[a+260>>2];L[c+4>>2]=b}function mv(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;d=fa-16|0;fa=d;L[d+12>>2]=a;L[d+8>>2]=b;L[d+4>>2]=c;a=sa(40);b=L[d+12>>2];L[a>>2]=8684;L[a+4>>2]=L[b>>2];L[a>>2]=8712;L[a>>2]=17248;L[a+8>>2]=0;L[a+12>>2]=0;fa=d+16|0;return a|0}function su(a,b,c){a=a|0;b=S(b);c=S(c);var d=0;d=fa-16|0;fa=d;L[d+12>>2]=a;P[d+8>>2]=b;P[d+4>>2]=c;b=P[d+8>>2];a=L[d+12>>2];c=P[d+4>>2];P[a+448>>2]=cS(1)?S(1):c;P[a+444>>2]=bS(1)?S(1):b;fa=d+16|0}function dp(a,b,c,d){a=a|0;b=b|0;c=S(c);d=d|0;var e=0;e=fa-80|0;fa=e;L[e+76>>2]=a;L[e+72>>2]=b;P[e+68>>2]=c;L[e+64>>2]=d;a=L[e+76>>2];Pb(e);ee(e);Rf(e,L[e+72>>2]);ha[L[L[a>>2]+16>>2]](a,P[e+68>>2],e,L[e+64>>2]);fa=e+80|0}function Qf(a,b,c){var d=0;d=fa-16|0;fa=d;L[d+12>>2]=a;L[d+8>>2]=b;L[d+4>>2]=c;a=L[d+12>>2];mf(a,L[d+8>>2]);b=L[d+4>>2];c=L[b+4>>2];L[a+48>>2]=L[b>>2];L[a+52>>2]=c;c=L[b+12>>2];L[a+56>>2]=L[b+8>>2];L[a+60>>2]=c;fa=d+16|0}function fp(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=0;f=fa-32|0;fa=f;L[f+28>>2]=a;L[f+24>>2]=b;L[f+20>>2]=c;L[f+16>>2]=d;L[f+12>>2]=e;a=L[f+28>>2];ha[L[L[a>>2]+8>>2]](a,L[f+24>>2],L[f+20>>2],L[f+16>>2]);fa=f+32|0}function MH(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0;e=fa-16|0;fa=e;L[e+12>>2]=d;L[e+8>>2]=a;a=L[((R(L[L[b+4>>2]+4>>2],144)+a|0)+(L[L[c+4>>2]+4>>2]<<2)|0)+72>>2];a=ha[L[L[a>>2]+8>>2]](a,e+8|0,b,c)|0;fa=e+16|0;return a|0}function it(a,b,c,d,e){a=a|0;b=S(b);c=S(c);d=S(d);e=S(e);var f=0;f=fa-32|0;fa=f;L[f+28>>2]=a;P[f+24>>2]=b;P[f+20>>2]=c;P[f+16>>2]=d;P[f+12>>2]=e;Si(L[f+28>>2],P[f+24>>2],P[f+20>>2],P[f+16>>2],P[f+12>>2],S(1));fa=f+32|0}function fo(a){a=a|0;var b=0,c=0,d=0;b=fa-16|0;fa=b;L[b+12>>2]=a;d=L[b+12>>2];L[d>>2]=4720;a=fa-16|0;fa=a;L[a+12>>2]=d+68;c=fa-16|0;fa=c;L[c+12>>2]=L[a+12>>2];rc(L[c+12>>2]+4|0);fa=c+16|0;fa=a+16|0;fa=b+16|0;return d|0}function ej(a){var b=0,c=0,d=0;b=fa-16|0;fa=b;L[b+8>>2]=a;a=L[b+8>>2];L[b+12>>2]=a;d=a+48|0;c=a;while(1){L[(fa-16|0)+12>>2]=c;c=c+16|0;if((d|0)!=(c|0)){continue}break}Ka(a+48|0);P[a+64>>2]=.009999999776482582;fa=b+16|0}function JE(a){a=a|0;var b=0;L[a>>2]=13876;b=L[a+104>>2];if(!(b?!b|!M[a+108|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+104>>2]=0;J[a+108|0]=1;L[a+96>>2]=0;L[a+100>>2]=0;a=Oa(a);if(a){L[8514]=L[8514]+1;ha[L[6799]](a)}}function qF(a){a=a|0;var b=0,c=S(0),d=S(0),e=S(0);b=fa-32|0;fa=b;ha[L[L[a>>2]+12>>2]](a,b+16|0,b+12|0);fa=b+32|0;c=P[b+24>>2];d=S(c*c);c=P[b+16>>2];e=S(c*c);c=P[b+20>>2];return S(S(P[b+12>>2]+S(_(S(d+S(e+S(c*c)))))))}function kB(a,b,c,d){a=a|0;b=b|0;c=S(c);d=d|0;a:{if((d|0)!=-1){break a}b:{c:{switch(b-1|0){case 0:case 1:d=a+336|0;b=1;break b;case 2:case 3:break c;default:break a}}d=a+340|0;b=2}P[d>>2]=c;L[a+332>>2]=b|L[a+332>>2]}}function jB(a,b,c){a=a|0;b=b|0;c=c|0;var d=S(0);d=S(34028234663852886e22);a:{if((c|0)!=-1){break a}b:{switch(b-1|0){case 0:case 1:return S(P[a+336>>2]);case 2:case 3:break b;default:break a}}d=P[a+340>>2]}return S(d)}function Qc(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;b=L[c+8>>2];a=fa-16|0;fa=a;L[a+12>>2]=L[c+12>>2];L[a+8>>2]=b;b=L[a+12>>2];L[b+260>>2]=L[b+260>>2]+1;sb(b+4|0,L[a+8>>2]);fa=a+16|0;fa=c+16|0}function ux(){var a=0,b=0,c=0,d=0;b=sa(8);L[b>>2]=0;L[b+4>>2]=0;c=fa-16|0;fa=c;L[c+12>>2]=b;a=fa-16|0;d=L[c+12>>2];L[a+12>>2]=d;a=L[a+12>>2];L[a>>2]=1836;K[a+4>>1]=1;K[a+6>>1]=65535;L[d>>2]=1716;fa=c+16|0;return b|0}function sb(a,b){var c=0,d=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;a=L[c+12>>2];qg(a,L[c+8>>2]);b=L[c+8>>2];d=L[b+52>>2];L[a+48>>2]=L[b+48>>2];L[a+52>>2]=d;d=L[b+60>>2];L[a+56>>2]=L[b+56>>2];L[a+60>>2]=d;fa=c+16|0}function mI(a,b,c,d){var e=0,f=0,g=0,h=0,i=0,j=0;e=c>>>16|0;f=a>>>16|0;j=R(e,f);g=c&65535;h=a&65535;i=R(g,h);f=(i>>>16|0)+R(f,g)|0;e=(f&65535)+R(e,h)|0;ga=(R(b,c)+j|0)+R(a,d)+(f>>>16)+(e>>>16)|0;return i&65535|e<<16}function Yb(a,b){var c=0,d=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;a=L[c+12>>2];mf(a,L[c+8>>2]);b=L[c+8>>2];d=L[b+52>>2];L[a+48>>2]=L[b+48>>2];L[a+52>>2]=d;d=L[b+60>>2];L[a+56>>2]=L[b+56>>2];L[a+60>>2]=d;fa=c+16|0}function Eh(a,b){var c=0,d=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;a=L[c+12>>2];Jc(a,L[c+8>>2]);b=L[c+8>>2];d=L[b+24>>2];L[a+20>>2]=L[b+20>>2];L[a+24>>2]=d;d=L[b+32>>2];L[a+28>>2]=L[b+28>>2];L[a+32>>2]=d;fa=c+16|0}function nv(a,b){a=a|0;b=b|0;var c=0,d=0,e=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;b=sa(8);d=L[c+12>>2];e=L[c+8>>2];a=fa-16|0;L[a+12>>2]=b;L[a+8>>2]=d;L[a+4>>2]=e;L[L[a+12>>2]>>2]=L[a+8>>2];fa=c+16|0;return b|0}function Hh(a,b){var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=0;L[c+4>>2]=b;a=L[c+12>>2];L[c>>2]=L[c+8>>2];while(1){if(L[c>>2]>2]){rc(L[a+12>>2]+R(L[c>>2],36)|0);L[c>>2]=L[c>>2]+1;continue}break}fa=c+16|0}function ip(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=0;f=fa-32|0;fa=f;L[f+28>>2]=a;L[f+24>>2]=b;L[f+20>>2]=c;L[f+16>>2]=d;J[f+15|0]=e;a=fg(L[f+24>>2],L[f+20>>2],L[f+16>>2],J[f+15|0]&1);fa=f+32|0;return a|0}function FG(a,b){a=a|0;b=b|0;var c=0,d=0,e=0;c=L[a+8>>2];d=L[c+8>>2];if((d|0)>0){a=0;while(1){e=L[(L[c+16>>2]+R(a,12)|0)+8>>2];if(e){ha[L[L[e>>2]+16>>2]](e,b);d=L[c+8>>2]}a=a+1|0;if((d|0)>(a|0)){continue}break}}}function rw(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=0;f=fa-32|0;fa=f;L[f+28>>2]=a;L[f+24>>2]=b;L[f+20>>2]=c;L[f+16>>2]=d;J[f+15|0]=e;Yl(L[f+28>>2],L[f+24>>2],L[f+20>>2],L[f+16>>2],J[f+15|0]&1);fa=f+32|0}function bq(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=0;f=fa-32|0;fa=f;L[f+28>>2]=a;L[f+24>>2]=b;L[f+20>>2]=c;L[f+16>>2]=d;J[f+15|0]=e;Ha(L[f+28>>2],L[f+24>>2],L[f+20>>2],L[f+16>>2],J[f+15|0]&1);fa=f+32|0}function aq(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=0;f=fa-32|0;fa=f;L[f+28>>2]=a;L[f+24>>2]=b;L[f+20>>2]=c;L[f+16>>2]=d;L[f+12>>2]=e;pb(L[f+28>>2],L[f+24>>2],L[f+20>>2],L[f+16>>2],L[f+12>>2]);fa=f+32|0}function Uz(a,b){a=a|0;b=b|0;var c=S(0);b=L[b+36>>2];c=uk(a+4|0,a+36|0,L[b+8>>2]+8|0,L[b+12>>2]+8|0,L[b+16>>2]+8|0,P[a+52>>2]);if(!(!(c>S(0))|!(P[a+52>>2]>c))){L[a+56>>2]=b;P[a+52>>2]=c}L[a+60>>2]=L[a+60>>2]+1}function Uj(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0;e=fa-16|0;fa=e;L[e+12>>2]=a;L[e+8>>2]=b;K[e+6>>1]=c;K[e+4>>1]=d;a=L[e+12>>2];ha[L[L[a>>2]+88>>2]](a,L[e+8>>2],N[e+6>>1]<<16>>16,N[e+4>>1]<<16>>16);fa=e+16|0}function Tp(a,b,c){a=a|0;b=b|0;c=S(c);var d=0;d=fa-16|0;fa=d;L[d+12>>2]=a;L[d+8>>2]=b;P[d+4>>2]=c;a=L[d+12>>2];c=P[d+4>>2];P[(L[a+720>>2]+R(L[d+8>>2],104)|0)+88>>2]=c>S(0)?S(S(1)/c):S(0);J[a+924|0]=1;fa=d+16|0}function Oe(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0;e=fa-16|0;fa=e;L[e+12>>2]=a;L[e+8>>2]=b;K[e+6>>1]=c;K[e+4>>1]=d;a=L[e+12>>2];ha[L[L[a>>2]+36>>2]](a,L[e+8>>2],N[e+6>>1]<<16>>16,N[e+4>>1]<<16>>16);fa=e+16|0}function Es(){var a=0,b=0;b=sa(24);a=fa-16|0;L[a+12>>2]=b;a=L[a+12>>2];P[a>>2]=5.880000114440918;P[a+4>>2]=.8299999833106995;P[a+8>>2]=.8799999952316284;P[a+12>>2]=500;P[a+16>>2]=10.5;P[a+20>>2]=6e3;return b|0}function Xf(a,b,c){var d=0;d=L[a+16>>2];if(!d){L[a+36>>2]=1;L[a+24>>2]=c;L[a+16>>2]=b;return}a:{if((b|0)==(d|0)){if(L[a+24>>2]!=2){break a}L[a+24>>2]=c;return}J[a+54|0]=1;L[a+24>>2]=2;L[a+36>>2]=L[a+36>>2]+1}}function Vc(a,b){a=a|0;b=S(b);var c=0,d=0;c=fa-16|0;fa=c;L[c+12>>2]=a;P[c+8>>2]=b;b=P[c+8>>2];a=fa-16|0;L[a+12>>2]=L[c+12>>2];P[a+8>>2]=b;d=L[a+12>>2];L[d+260>>2]=L[d+260>>2]+1;P[d+228>>2]=P[a+8>>2];fa=c+16|0}function Uc(a,b){a=a|0;b=S(b);var c=0,d=0;c=fa-16|0;fa=c;L[c+12>>2]=a;P[c+8>>2]=b;b=P[c+8>>2];a=fa-16|0;L[a+12>>2]=L[c+12>>2];P[a+8>>2]=b;d=L[a+12>>2];L[d+260>>2]=L[d+260>>2]+1;P[d+224>>2]=P[a+8>>2];fa=c+16|0}function Tc(a,b){a=a|0;b=S(b);var c=0,d=0;c=fa-16|0;fa=c;L[c+12>>2]=a;P[c+8>>2]=b;b=P[c+8>>2];a=fa-16|0;L[a+12>>2]=L[c+12>>2];P[a+8>>2]=b;d=L[a+12>>2];L[d+260>>2]=L[d+260>>2]+1;P[d+232>>2]=P[a+8>>2];fa=c+16|0}function sC(a){a=a|0;var b=0;a=L[a+140>>2];b=L[a+32>>2];if((b|0)>0){L[a+32>>2]=b+1;return}b=L[a+8>>2];ha[L[L[b>>2]+16>>2]](b,a+36|0,a+40|0,a+44|0,a+48|0,a+52|0,a+56|0,a+60|0,a- -64|0,L[a+28>>2]);L[a+32>>2]=1}function al(){var a=0;a=fa-16|0;fa=a;if(!M[33152]){L[a+8>>2]=0;L[a+12>>2]=0;L[a>>2]=0;L[a+4>>2]=0;ng(32536,a);J[33152]=1}L[a+8>>2]=0;L[a+12>>2]=0;L[a>>2]=0;L[a+4>>2]=0;ve(32536,S(0),a);fa=a+16|0;return 32536}function gB(a,b){a=a|0;b=b|0;var c=0;c=fa-80|0;fa=c;L[c+76>>2]=a;L[c+72>>2]=b;if(!M[29604]){Pb(29540);J[29604]=1}a=c+8|0;b=L[c+76>>2];ha[L[L[b>>2]+132>>2]](a,b,L[c+72>>2]);sb(29540,a);fa=c+80|0;return 29540}function Uv(a,b){a=a|0;b=b|0;var c=0;c=fa-80|0;fa=c;L[c+76>>2]=a;L[c+72>>2]=b;if(!M[29880]){Pb(29816);J[29880]=1}a=c+8|0;b=L[c+76>>2];ha[L[L[b>>2]+132>>2]](a,b,L[c+72>>2]);sb(29816,a);fa=c+80|0;return 29816}function Kj(a,b,c,d){a=a|0;b=S(b);c=c|0;d=S(d);var e=0;e=fa-16|0;fa=e;L[e+12>>2]=a;P[e+8>>2]=b;L[e+4>>2]=c;P[e>>2]=d;a=L[e+12>>2];a=ha[L[L[a>>2]+52>>2]](a,P[e+8>>2],L[e+4>>2],P[e>>2])|0;fa=e+16|0;return a|0}function ub(a,b,c,d){L[a+44>>2]=0;L[a+36>>2]=0;L[a+40>>2]=1050253722;L[a+32>>2]=d;L[a+28>>2]=c;L[a+24>>2]=-1;K[a+20>>1]=1;L[a+16>>2]=2139095039;L[a+8>>2]=-1;L[a+12>>2]=-1;L[a+4>>2]=b;L[a>>2]=20172;return a}function Gw(a){a=a|0;var b=0,c=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=fa-16|0;fa=a;L[a+12>>2]=L[b+12>>2];c=fa-16|0;L[c+12>>2]=L[a+12>>2];L[c+8>>2]=0;fa=a+16|0;fa=b+16|0;return L[L[c+12>>2]+12>>2]+(L[c+8>>2]<<4)|0}function yb(a){L[a+4>>2]=35;L[a+8>>2]=0;L[a>>2]=14328;L[a+44>>2]=1025758986;L[a+12>>2]=1065353216;L[a+16>>2]=1065353216;L[a>>2]=14044;L[a+20>>2]=1065353216;L[a+24>>2]=0;L[a+52>>2]=0;L[a>>2]=15836;return a}function Mg(a){a=a|0;var b=0,c=0,d=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=fa-16|0;fa=a;L[a+12>>2]=L[b+12>>2];c=fa-16|0;d=L[a+12>>2];L[c+12>>2]=d+28;fa=a+16|0;fa=b+16|0;return S(P[L[c+12>>2]+(L[d+52>>2]<<2)>>2])}function AC(a){a=a|0;var b=0;L[a>>2]=4720;b=L[a+84>>2];if(!(b?!b|!M[a+88|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+84>>2]=0;J[a+88|0]=1;L[a+76>>2]=0;L[a+80>>2]=0;if(a){L[8514]=L[8514]+1;ha[L[6799]](a)}}function Nd(a){var b=0,c=0;b=fa-16|0;fa=b;L[b+12>>2]=a;c=L[b+12>>2];P[b+8>>2]=nf(c);a=fa-16|0;fa=a;L[a+12>>2]=c;L[a+8>>2]=b+8;c=L[a+12>>2];P[a+4>>2]=S(1)/P[L[a+8>>2]>>2];mh(c,a+4|0);fa=a+16|0;fa=b+16|0}function Lj(a,b,c){a=a|0;b=S(b);c=c|0;var d=0;d=fa-16|0;fa=d;L[d+12>>2]=a;P[d+8>>2]=b;L[d+4>>2]=c;a=L[d+12>>2];a=ha[L[L[a>>2]+52>>2]](a,P[d+8>>2],L[d+4>>2],S(.01666666753590107))|0;fa=d+16|0;return a|0}function xe(a){var b=S(0);b=Na(S(P[a>>2]+P[a+4>>2]),S(6.2831854820251465));if(bS(3.1415927410125732)?S(b+S(-6.2831854820251465)):b}function we(a){var b=S(0);b=Na(S(P[a>>2]-P[a+4>>2]),S(6.2831854820251465));if(bS(3.1415927410125732)?S(b+S(-6.2831854820251465)):b}function av(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0;e=fa-16|0;fa=e;L[e+12>>2]=a;L[e+8>>2]=b;L[e+4>>2]=c;L[e>>2]=d;a=oa(116);Ld(a,L[e+12>>2],L[e+8>>2],L[e+4>>2]&65535,L[e>>2],0);fa=e+16|0;return a|0}function DD(a,b,c){a=a|0;b=S(b);c=c|0;var d=S(0),e=S(0);d=S(ha[L[L[a>>2]+48>>2]](a));e=S(ha[L[L[a>>2]+48>>2]](a));L[c+12>>2]=0;b=S(e*S(d*S(b*S(.4000000059604645))));P[c+8>>2]=b;P[c+4>>2]=b;P[c>>2]=b}function Nv(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=0;f=fa-32|0;fa=f;L[f+28>>2]=a;L[f+24>>2]=b;L[f+20>>2]=c;L[f+16>>2]=d;L[f+12>>2]=e;Gf(L[f+28>>2],L[f+24>>2],f+20|0,f+16|0,f+12|0);fa=f+32|0}function Bj(a,b,c,d,e){a=a|0;b=S(b);c=S(c);d=S(d);e=S(e);var f=0;f=fa-32|0;fa=f;L[f+28>>2]=a;P[f+24>>2]=b;P[f+20>>2]=c;P[f+16>>2]=d;P[f+12>>2]=e;vc(L[f+28>>2],f+24|0,f+20|0,f+16|0,f+12|0);fa=f+32|0}function tt(a,b){a=a|0;b=S(b);var c=0,d=0;c=fa-16|0;fa=c;L[c+12>>2]=a;P[c+8>>2]=b;b=P[c+8>>2];a=fa-16|0;L[a+12>>2]=L[c+12>>2];P[a+8>>2]=b;d=L[a+12>>2];P[d+572>>2]=P[a+8>>2];J[d+553|0]=0;fa=c+16|0}function st(a,b){a=a|0;b=S(b);var c=0,d=0;c=fa-16|0;fa=c;L[c+12>>2]=a;P[c+8>>2]=b;b=P[c+8>>2];a=fa-16|0;L[a+12>>2]=L[c+12>>2];P[a+8>>2]=b;d=L[a+12>>2];P[d+572>>2]=P[a+8>>2];J[d+553|0]=1;fa=c+16|0}function Dc(a){a:{switch(L[a+4>>2]){case 8:return S(P[a+28>>2]*P[a+12>>2]);case 0:case 1:case 4:case 5:case 10:case 11:case 13:return P[a+44>>2];default:break a}}return S(ha[L[L[a>>2]+48>>2]](a))}function mb(a){a=a|0;var b=0,c=0,d=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=fa-16|0;fa=a;L[a+12>>2]=L[b+12>>2];d=fa-16|0;c=L[a+12>>2];L[d+12>>2]=c;Db(c,L[L[d+12>>2]+4>>2]);jb(c);Zd(c);fa=a+16|0;fa=b+16|0}function fA(a){a=a|0;var b=0;L[a>>2]=20800;b=L[a+496>>2];if(!(b?!b|!M[a+500|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+496>>2]=0;J[a+500|0]=1;L[a+488>>2]=0;L[a+492>>2]=0;L[a>>2]=6712;return a|0}function Sm(a){a=a|0;var b=0;L[a>>2]=11364;b=L[a+276>>2];if(!(b?!b|!M[a+280|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+276>>2]=0;J[a+280|0]=1;L[a+268>>2]=0;L[a+272>>2]=0;L[a>>2]=6712;return a|0}function xu(a){a=a|0;var b=0,c=0,d=0;b=fa-16|0;fa=b;L[b+12>>2]=a;c=oa(616);d=L[b+12>>2];a=Cd(c);L[a>>2]=20800;J[a+500|0]=1;L[a+496>>2]=0;L[a+488>>2]=0;L[a+492>>2]=0;Kk(a,d);fa=b+16|0;return c|0}function Ys(a,b){a=a|0;b=S(b);var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;P[c+8>>2]=b;b=P[c+8>>2];a=fa-16|0;fa=a;L[a+12>>2]=L[c+12>>2];P[a+8>>2]=b;P[L[a+12>>2]+192>>2]=pe(P[a+8>>2]);fa=a+16|0;fa=c+16|0}function Xs(a,b){a=a|0;b=S(b);var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;P[c+8>>2]=b;b=P[c+8>>2];a=fa-16|0;fa=a;L[a+12>>2]=L[c+12>>2];P[a+8>>2]=b;P[L[a+12>>2]+196>>2]=pe(P[a+8>>2]);fa=a+16|0;fa=c+16|0}function Jx(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;b=L[c+8>>2];a=fa-16|0;L[a+12>>2]=L[c+12>>2];L[a+8>>2]=b;fa=c+16|0;return S(P[L[L[a+12>>2]+12>>2]+(L[a+8>>2]<<2)>>2])}function nt(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0;e=fa-16|0;fa=e;L[e+12>>2]=a;L[e+8>>2]=b;L[e+4>>2]=c;L[e>>2]=d;a=oa(764);gl(a,L[e+12>>2],L[e+8>>2],L[e+4>>2],L[e>>2],0);fa=e+16|0;return a|0}function lA(a,b){a=a|0;b=b|0;var c=0,d=0,e=0;c=L[b>>2];d=L[a+80>>2];if(!(!(N[b+6>>1]&N[a+8>>1])|(!(N[a+10>>1]&N[b+4>>1])|(c|0)==(d|0)))){a=L[a+92>>2];e=ha[L[L[a>>2]+28>>2]](a,d,c)|0}return e|0}function Jq(){var a=0,b=0;b=oa(288);a=Cd(b);L[a+236>>2]=4;L[a>>2]=11408;L[a+276>>2]=0;J[a+280|0]=1;L[a+268>>2]=0;L[a+272>>2]=0;L[8513]=L[8513]+1;L[a+284>>2]=qh(ha[L[6798]](76,16)|0);return b|0}function AD(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;L[c+8>>2]=-581039253;L[c+12>>2]=0;L[c>>2]=-581039253;L[c+4>>2]=-581039253;L[d+8>>2]=1566444395;L[d+12>>2]=0;L[d>>2]=1566444395;L[d+4>>2]=1566444395}function gq(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0;e=fa-16|0;fa=e;L[e+12>>2]=a;L[e+8>>2]=b;L[e+4>>2]=c;L[e>>2]=d;a=oa(1252);Ac(a,L[e+12>>2],L[e+8>>2],L[e+4>>2],L[e>>2]);fa=e+16|0;return a|0}function Yr(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;L[c+12>>2]=a;L[c+8>>2]=b;b=L[c+12>>2];a=L[c+8>>2];c=L[a+4>>2];L[b+156>>2]=L[a>>2];L[b+160>>2]=c;c=L[a+12>>2];L[b+164>>2]=L[a+8>>2];L[b+168>>2]=c}function Vr(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;L[c+12>>2]=a;L[c+8>>2]=b;b=L[c+12>>2];a=L[c+8>>2];c=L[a+4>>2];L[b+172>>2]=L[a>>2];L[b+176>>2]=c;c=L[a+12>>2];L[b+180>>2]=L[a+8>>2];L[b+184>>2]=c}function Uu(a,b,c,d){a=S(a);b=b|0;c=c|0;d=d|0;var e=0;e=fa-16|0;fa=e;P[e+12>>2]=a;L[e+8>>2]=b;L[e+4>>2]=c;L[e>>2]=d;b=sa(140);Xi(b,P[e+12>>2],L[e+8>>2],L[e+4>>2],L[e>>2]);fa=e+16|0;return b|0}function Tr(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;L[c+12>>2]=a;L[c+8>>2]=b;b=L[c+12>>2];a=L[c+8>>2];c=L[a+4>>2];L[b+188>>2]=L[a>>2];L[b+192>>2]=c;c=L[a+12>>2];L[b+196>>2]=L[a+8>>2];L[b+200>>2]=c}function Fr(a,b,c,d){a=a|0;b=b|0;c=S(c);d=d|0;var e=0;e=fa-16|0;fa=e;L[e+12>>2]=a;L[e+8>>2]=b;P[e+4>>2]=c;L[e>>2]=d;a=oa(184);ul(a,L[e+12>>2],L[e+8>>2],P[e+4>>2],L[e>>2]);fa=e+16|0;return a|0}function no(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0;e=fa-16|0;fa=e;L[e+12>>2]=a;L[e+8>>2]=b;L[e+4>>2]=c;L[e>>2]=d;a=L[e+12>>2];ha[L[L[a>>2]+124>>2]](a,L[e>>2],L[e+8>>2],L[e+4>>2]);fa=e+16|0}function hw(a,b,c,d){a=a|0;b=b|0;c=c|0;d=S(d);var e=0;e=fa-16|0;fa=e;L[e+12>>2]=a;L[e+8>>2]=b;L[e+4>>2]=c;P[e>>2]=d;a=sa(32);gj(a,L[e+12>>2],L[e+8>>2],L[e+4>>2],P[e>>2]);fa=e+16|0;return a|0}function de(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;b=L[c+8>>2];a=fa-16|0;L[a+12>>2]=L[c+12>>2];L[a+8>>2]=b;fa=c+16|0;return L[L[L[a+12>>2]+12>>2]+(L[a+8>>2]<<2)>>2]}function Sh(a,b){var c=0;c=fa-16|0;L[c+12>>2]=a;L[c+8>>2]=b;a=L[c+12>>2];L[c+4>>2]=0;while(1){if(L[c+4>>2]<4){b=L[c+4>>2]<<2;P[b+L[c+8>>2]>>2]=P[a+b>>2];L[c+4>>2]=L[c+4>>2]+1;continue}break}}function IG(a,b){a=a|0;b=b|0;var c=0,d=0,e=0;c=L[a+12>>2];if((c|0)>0){while(1){e=L[L[a+20>>2]+(d<<2)>>2];if(e){ha[L[L[e>>2]+16>>2]](e,b);c=L[a+12>>2]}d=d+1|0;if((c|0)>(d|0)){continue}break}}}function Ej(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0;e=fa-16|0;fa=e;L[e+12>>2]=a;L[e+8>>2]=b;L[e+4>>2]=c;L[e>>2]=d;a=L[e+12>>2];ha[L[L[a>>2]+8>>2]](a,L[e+8>>2],L[e+4>>2],L[e>>2])|0;fa=e+16|0}function Eb(a,b,c,d){a=a|0;b=b|0;c=S(c);d=d|0;var e=0;e=fa-16|0;fa=e;L[e+12>>2]=a;L[e+8>>2]=b;P[e+4>>2]=c;L[e>>2]=d;a=L[e+12>>2];ha[L[L[a>>2]+28>>2]](a,L[e+8>>2],P[e+4>>2],L[e>>2]);fa=e+16|0}function nf(a){var b=0,c=0,d=S(0);b=fa-16|0;fa=b;L[b+12>>2]=a;a=fa-16|0;fa=a;L[a+12>>2]=L[b+12>>2];c=L[a+12>>2];d=Sa(c,c);fa=a+16|0;a=fa-16|0;P[a+12>>2]=d;fa=b+16|0;return S(_(P[a+12>>2]))} -function jo(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0;e=fa-16|0;fa=e;L[e+12>>2]=a;L[e+8>>2]=b;L[e+4>>2]=c;L[e>>2]=d;a=L[e+12>>2];ha[L[L[a>>2]+80>>2]](a,L[e+8>>2],L[e+4>>2],L[e>>2]);fa=e+16|0}function hb(a,b){var c=0;c=fa-16|0;L[c+12>>2]=a;L[c+8>>2]=b;a=L[c+12>>2];P[a>>2]=P[a>>2]+P[L[c+8>>2]>>2];P[a+4>>2]=P[a+4>>2]+P[L[c+8>>2]+4>>2];P[a+8>>2]=P[a+8>>2]+P[L[c+8>>2]+8>>2];return a}function fe(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0;e=fa-16|0;fa=e;L[e+12>>2]=a;L[e+8>>2]=b;L[e+4>>2]=c;L[e>>2]=d;a=L[e+12>>2];ha[L[L[a>>2]+28>>2]](a,L[e+8>>2],L[e+4>>2],L[e>>2]);fa=e+16|0}function cr(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0;e=fa-16|0;fa=e;L[e+12>>2]=a;L[e+8>>2]=b;L[e+4>>2]=c;L[e>>2]=d;a=L[e+12>>2];ha[L[L[a>>2]+24>>2]](a,L[e+8>>2],L[e+4>>2],L[e>>2]);fa=e+16|0}function Yd(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0;e=fa-16|0;fa=e;L[e+12>>2]=a;L[e+8>>2]=b;L[e+4>>2]=c;L[e>>2]=d;a=L[e+12>>2];ha[L[L[a>>2]+32>>2]](a,L[e+8>>2],L[e+4>>2],L[e>>2]);fa=e+16|0}function xq(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;b=L[c+8>>2];a=fa-16|0;L[a+12>>2]=L[c+12>>2];L[a+8>>2]=b;fa=c+16|0;return L[L[a+12>>2]+12>>2]+R(L[a+8>>2],104)|0}function sf(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0;e=fa-16|0;fa=e;L[e+12>>2]=a;L[e+8>>2]=b;L[e+4>>2]=c;L[e>>2]=d;a=L[e+12>>2];ha[L[L[a>>2]+8>>2]](a,L[e+8>>2],L[e+4>>2],L[e>>2]);fa=e+16|0}function Jk(a){if(!(M[a+204|0]&3)){P[a+412>>2]=S(P[a+364>>2]*P[a+348>>2])+P[a+412>>2];P[a+416>>2]=S(P[a+368>>2]*P[a+352>>2])+P[a+416>>2];P[a+420>>2]=S(P[a+372>>2]*P[a+356>>2])+P[a+420>>2]}}function xx(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;L[c+12>>2]=a;L[c+8>>2]=b;b=L[c+12>>2];a=L[c+8>>2];c=L[a+4>>2];L[b+64>>2]=L[a>>2];L[b+68>>2]=c;c=L[a+12>>2];L[b+72>>2]=L[a+8>>2];L[b+76>>2]=c}function vj(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;L[c+12>>2]=a;L[c+8>>2]=b;b=L[c+12>>2];a=L[c+8>>2];c=L[a+4>>2];L[b+20>>2]=L[a>>2];L[b+24>>2]=c;c=L[a+12>>2];L[b+28>>2]=L[a+8>>2];L[b+32>>2]=c}function tq(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;L[c+12>>2]=a;L[c+8>>2]=b;b=L[c+12>>2];a=L[c+8>>2];c=L[a+4>>2];L[b+76>>2]=L[a>>2];L[b+80>>2]=c;c=L[a+12>>2];L[b+84>>2]=L[a+8>>2];L[b+88>>2]=c}function tj(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;L[c+12>>2]=a;L[c+8>>2]=b;b=L[c+12>>2];a=L[c+8>>2];c=L[a+4>>2];L[b+36>>2]=L[a>>2];L[b+40>>2]=c;c=L[a+12>>2];L[b+44>>2]=L[a+8>>2];L[b+48>>2]=c}function sj(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;L[c+12>>2]=a;L[c+8>>2]=b;b=L[c+12>>2];a=L[c+8>>2];c=L[a+4>>2];L[b+52>>2]=L[a>>2];L[b+56>>2]=c;c=L[a+12>>2];L[b+60>>2]=L[a+8>>2];L[b+64>>2]=c}function qj(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;L[c+12>>2]=a;L[c+8>>2]=b;b=L[c+12>>2];a=L[c+8>>2];c=L[a+4>>2];L[b+68>>2]=L[a>>2];L[b+72>>2]=c;c=L[a+12>>2];L[b+76>>2]=L[a+8>>2];L[b+80>>2]=c}function px(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;L[c+12>>2]=a;L[c+8>>2]=b;b=L[c+12>>2];a=L[c+8>>2];c=L[a+4>>2];L[b+12>>2]=L[a>>2];L[b+16>>2]=c;c=L[a+12>>2];L[b+20>>2]=L[a+8>>2];L[b+24>>2]=c}function ox(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;L[c+12>>2]=a;L[c+8>>2]=b;b=L[c+12>>2];a=L[c+8>>2];c=L[a+4>>2];L[b+28>>2]=L[a>>2];L[b+32>>2]=c;c=L[a+12>>2];L[b+36>>2]=L[a+8>>2];L[b+40>>2]=c}function oj(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;L[c+12>>2]=a;L[c+8>>2]=b;b=L[c+12>>2];a=L[c+8>>2];c=L[a+4>>2];L[b+56>>2]=L[a>>2];L[b+60>>2]=c;c=L[a+12>>2];L[b+64>>2]=L[a+8>>2];L[b+68>>2]=c}function mx(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;L[c+12>>2]=a;L[c+8>>2]=b;b=L[c+12>>2];a=L[c+8>>2];c=L[a+4>>2];L[b+44>>2]=L[a>>2];L[b+48>>2]=c;c=L[a+12>>2];L[b+52>>2]=L[a+8>>2];L[b+56>>2]=c}function lj(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;L[c+12>>2]=a;L[c+8>>2]=b;b=L[c+12>>2];a=L[c+8>>2];c=L[a+4>>2];L[b+32>>2]=L[a>>2];L[b+36>>2]=c;c=L[a+12>>2];L[b+40>>2]=L[a+8>>2];L[b+44>>2]=c}function kx(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;L[c+12>>2]=a;L[c+8>>2]=b;b=L[c+12>>2];a=L[c+8>>2];c=L[a+4>>2];L[b+60>>2]=L[a>>2];L[b+64>>2]=c;c=L[a+12>>2];L[b+68>>2]=L[a+8>>2];L[b+72>>2]=c}function jj(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;L[c+12>>2]=a;L[c+8>>2]=b;b=L[c+12>>2];a=L[c+8>>2];c=L[a+4>>2];L[b+24>>2]=L[a>>2];L[b+28>>2]=c;c=L[a+12>>2];L[b+32>>2]=L[a+8>>2];L[b+36>>2]=c}function gd(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;L[c+12>>2]=a;L[c+8>>2]=b;b=L[c+12>>2];a=L[c+8>>2];c=L[a+4>>2];L[b+16>>2]=L[a>>2];L[b+20>>2]=c;c=L[a+12>>2];L[b+24>>2]=L[a+8>>2];L[b+28>>2]=c}function Vw(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;b=L[c+8>>2];a=fa-16|0;L[a+12>>2]=L[c+12>>2];L[a+8>>2]=b;fa=c+16|0;return L[L[a+12>>2]+12>>2]+R(L[a+8>>2],36)|0}function Rf(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;L[c+12>>2]=a;L[c+8>>2]=b;b=L[c+12>>2];a=L[c+8>>2];c=L[a+4>>2];L[b+48>>2]=L[a>>2];L[b+52>>2]=c;c=L[a+12>>2];L[b+56>>2]=L[a+8>>2];L[b+60>>2]=c}function Lf(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;L[c+12>>2]=a;L[c+8>>2]=b;b=L[c+12>>2];a=L[c+8>>2];c=L[a+4>>2];L[b+40>>2]=L[a>>2];L[b+44>>2]=c;c=L[a+12>>2];L[b+48>>2]=L[a+8>>2];L[b+52>>2]=c}function Fb(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=S(0);d=fa-16|0;fa=d;L[d+12>>2]=a;L[d+8>>2]=b;L[d+4>>2]=c;a=L[d+12>>2];e=S(ha[L[L[a>>2]+32>>2]](a,L[d+8>>2],L[d+4>>2]));fa=d+16|0;return S(e)}function Bq(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;b=L[c+8>>2];a=fa-16|0;L[a+12>>2]=L[c+12>>2];L[a+8>>2]=b;fa=c+16|0;return L[L[a+12>>2]+12>>2]+R(L[a+8>>2],44)|0}function Aq(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;L[c+12>>2]=a;L[c+8>>2]=b;b=L[c+12>>2];a=L[c+8>>2];c=L[a+4>>2];L[b+72>>2]=L[a>>2];L[b+76>>2]=c;c=L[a+12>>2];L[b+80>>2]=L[a+8>>2];L[b+84>>2]=c}function yo(a,b,c){a=a|0;b=S(b);c=c|0;var d=0;d=fa-32|0;fa=d;L[d+28>>2]=a;P[d+24>>2]=b;L[d+20>>2]=c;a=L[d+20>>2];P[d+16>>2]=0;P[d+12>>2]=0;P[d+8>>2]=0;la(a,d+16|0,d+12|0,d+8|0);fa=d+32|0}function ww(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;b=L[c+8>>2];a=fa-16|0;L[a+12>>2]=L[c+12>>2];L[a+8>>2]=b;fa=c+16|0;return L[L[a+12>>2]+12>>2]+(L[a+8>>2]<<5)|0}function kj(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;L[c+12>>2]=a;L[c+8>>2]=b;b=L[c+12>>2];a=L[c+8>>2];c=L[a+4>>2];L[b+8>>2]=L[a>>2];L[b+12>>2]=c;c=L[a+12>>2];L[b+16>>2]=L[a+8>>2];L[b+20>>2]=c}function hq(a){a=a|0;var b=0,c=0,d=0;b=fa-16|0;fa=b;L[b+12>>2]=a;c=L[b+12>>2];if(c){a=fa-16|0;fa=a;L[a+12>>2]=c;d=L[a+12>>2];mb(d+144|0);mb(d+124|0);mb(d+104|0);fa=a+16|0;ra(c)}fa=b+16|0}function hc(a){L[a+16>>2]=0;L[a+8>>2]=-1;L[a+12>>2]=0;L[a>>2]=0;L[a+4>>2]=0;L[a+32>>2]=0;J[a+36|0]=1;J[a+56|0]=1;L[a+24>>2]=0;L[a+28>>2]=0;L[a+52>>2]=0;L[a+44>>2]=0;L[a+48>>2]=0;return a}function Ww(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;b=L[c+8>>2];a=fa-16|0;L[a+12>>2]=L[c+12>>2];L[a+8>>2]=b;fa=c+16|0;return L[L[a+12>>2]+12>>2]+(L[a+8>>2]<<4)|0}function wq(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;L[c+12>>2]=a;L[c+8>>2]=b;b=L[c+12>>2];a=L[c+8>>2];c=L[a+4>>2];L[b+4>>2]=L[a>>2];L[b+8>>2]=c;c=L[a+12>>2];L[b+12>>2]=L[a+8>>2];L[b+16>>2]=c}function mh(a,b){var c=0;c=fa-16|0;L[c+12>>2]=a;L[c+8>>2]=b;a=L[c+12>>2];P[a>>2]=P[a>>2]*P[L[c+8>>2]>>2];P[a+4>>2]=P[a+4>>2]*P[L[c+8>>2]>>2];P[a+8>>2]=P[a+8>>2]*P[L[c+8>>2]>>2];return a}function la(a,b,c,d){var e=0;e=fa-16|0;L[e+12>>2]=a;L[e+8>>2]=b;L[e+4>>2]=c;L[e>>2]=d;a=L[e+12>>2];P[a>>2]=P[L[e+8>>2]>>2];P[a+4>>2]=P[L[e+4>>2]>>2];P[a+8>>2]=P[L[e>>2]>>2];P[a+12>>2]=0}function fv(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;b=L[c+8>>2];a=fa-16|0;L[a+12>>2]=L[c+12>>2];L[a+8>>2]=b;fa=c+16|0;return(L[a+12>>2]+4|0)+R(L[a+8>>2],184)|0}function KE(a){a=a|0;var b=0;L[a>>2]=13876;b=L[a+104>>2];if(!(b?!b|!M[a+108|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+104>>2]=0;J[a+108|0]=1;L[a+96>>2]=0;L[a+100>>2]=0;return Oa(a)|0}function qA(a,b){a=a|0;b=S(b);var c=0,d=0;wa(2678);if(L[a+280>>2]>0){while(1){d=L[L[a+288>>2]+(c<<2)>>2];ha[L[L[d>>2]+8>>2]](d,a,b);c=c+1|0;if((c|0)>2]){continue}break}}va()}function db(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0;d=ha[L[L[c>>2]+40>>2]](c,a)|0;e=ha[L[L[c>>2]+28>>2]](c,d)|0;L[b>>2]=e;if(e){ha[L[L[c>>2]+48>>2]](c,d)}L[b+4>>2]=L[a+4>>2];return 3841}function ce(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;L[c+12>>2]=a;L[c+8>>2]=b;b=L[c+12>>2];a=L[c+8>>2];c=L[a+4>>2];L[b>>2]=L[a>>2];L[b+4>>2]=c;c=L[a+12>>2];L[b+8>>2]=L[a+8>>2];L[b+12>>2]=c}function bz(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0;e=fa-16|0;fa=e;L[e+12>>2]=a;L[e+8>>2]=b;L[e+4>>2]=c;L[e>>2]=d;a=oa(324);Wk(a,L[e+12>>2],L[e+8>>2],L[e+4>>2]);fa=e+16|0;return a|0}function Xx(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;b=L[c+8>>2];a=fa-16|0;fa=a;L[a+12>>2]=L[c+12>>2];L[a+8>>2]=b;yj(L[a+12>>2],L[a+8>>2]);fa=a+16|0;fa=c+16|0}function Xt(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;d=fa-16|0;fa=d;L[d+12>>2]=a;L[d+8>>2]=b;L[d+4>>2]=c;a=L[d+12>>2];b=L[a+192>>2];ha[L[L[b>>2]+8>>2]](b,a+4|0,L[d+8>>2],L[d+4>>2]);fa=d+16|0}function Ne(a){a=a|0;var b=0,c=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=fa-16|0;fa=a;L[a+12>>2]=L[b+12>>2];c=L[a+12>>2];if(J[c+48|0]&1){ha[L[L[c>>2]+68>>2]](c);J[c+48|0]=0}fa=a+16|0;fa=b+16|0}function tl(a){a=a|0;var b=0;L[a>>2]=19124;b=L[a+140>>2];if(!(b?!b|!M[a+144|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+140>>2]=0;J[a+144|0]=1;L[a+132>>2]=0;L[a+136>>2]=0;return a|0}function sh(a){a=a|0;var b=0;L[a>>2]=5728;if(M[a+192|0]){b=L[a+136>>2];ha[L[L[b>>2]>>2]](b)|0;b=L[a+136>>2];if(b){L[8514]=L[8514]+1;ha[L[6799]](b)}}gc(a- -64|0);gc(a+4|0);return a|0}function Md(a){var b=0;b=fa-16|0;fa=b;L[b+8>>2]=a;a=fa-16|0;L[a+12>>2]=L[b+8>>2];a:{if(L[L[a+12>>2]+236>>2]==4){L[b+12>>2]=L[b+8>>2];break a}L[b+12>>2]=0}fa=b+16|0;return L[b+12>>2]}function wv(a){a=a|0;var b=0,c=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=fa-16|0;fa=a;L[a+12>>2]=L[b+12>>2];c=fa-16|0;L[c+12>>2]=L[a+12>>2]+144;fa=a+16|0;fa=b+16|0;return L[L[c+12>>2]+40>>2]}function ly(a){a=a|0;var b=0,c=S(0);b=fa-16|0;fa=b;L[b+12>>2]=a;a=fa-16|0;fa=a;L[a+12>>2]=L[b+12>>2];c=uc(P[L[a+12>>2]+12>>2]);P[a+8>>2]=c+c;fa=a+16|0;fa=b+16|0;return S(P[a+8>>2])}function vy(a,b,c,d){a=S(a);b=S(b);c=S(c);d=S(d);var e=0,f=0;e=fa-16|0;fa=e;P[e+12>>2]=a;P[e+8>>2]=b;P[e+4>>2]=c;P[e>>2]=d;f=sa(16);ie(f,e+12|0,e+8|0,e+4|0,e);fa=e+16|0;return f|0}function rv(a){a=a|0;var b=0,c=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=fa-16|0;fa=a;L[a+12>>2]=L[b+12>>2];c=fa-16|0;L[c+12>>2]=L[a+12>>2]+148;fa=a+16|0;fa=b+16|0;return L[L[c+12>>2]+4>>2]}function gr(a){a=a|0;var b=0,c=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=fa-16|0;fa=a;L[a+12>>2]=L[b+12>>2];c=fa-16|0;L[c+12>>2]=L[a+12>>2]+132;fa=a+16|0;fa=b+16|0;return L[L[c+12>>2]+4>>2]}function Zo(a,b){a=a|0;b=b|0;var c=0;c=fa-32|0;fa=c;L[c+28>>2]=a;L[c+24>>2]=b;a=L[c+28>>2];L[c+20>>2]=28275;b=L[c+20>>2];L[c+4>>2]=L[c+24>>2];L[c>>2]=a;$(b|0,1295,c|0)|0;fa=c+32|0}function RC(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;a=L[b>>2];a=ha[L[L[a>>2]+56>>2]](a,40)|0;L[a>>2]=8684;L[a+4>>2]=L[b>>2];L[a>>2]=8712;L[a>>2]=17248;L[a+8>>2]=0;L[a+12>>2]=0;return a|0}function No(a,b){a=a|0;b=b|0;var c=0;c=fa-32|0;fa=c;L[c+28>>2]=a;L[c+24>>2]=b;a=L[c+28>>2];L[c+20>>2]=28732;b=L[c+20>>2];L[c+4>>2]=L[c+24>>2];L[c>>2]=a;$(b|0,1400,c|0)|0;fa=c+32|0}function Mo(a,b){a=a|0;b=b|0;var c=0;c=fa-32|0;fa=c;L[c+28>>2]=a;L[c+24>>2]=b;a=L[c+28>>2];L[c+20>>2]=28973;b=L[c+20>>2];L[c+4>>2]=L[c+24>>2];L[c>>2]=a;$(b|0,1403,c|0)|0;fa=c+32|0}function Dj(a){a=a|0;var b=0,c=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=fa-16|0;fa=a;L[a+12>>2]=L[b+12>>2];c=fa-16|0;L[c+12>>2]=L[a+12>>2]+264;fa=a+16|0;fa=b+16|0;return L[L[c+12>>2]+4>>2]}function $o(a,b){a=a|0;b=b|0;var c=0;c=fa-32|0;fa=c;L[c+28>>2]=a;L[c+24>>2]=b;a=L[c+28>>2];L[c+20>>2]=27808;b=L[c+20>>2];L[c+4>>2]=L[c+24>>2];L[c>>2]=a;$(b|0,1288,c|0)|0;fa=c+32|0}function Rd(a){a=a|0;var b=0,c=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=fa-16|0;fa=a;L[a+12>>2]=L[b+12>>2];c=L[L[a+12>>2]+68>>2];c=ha[L[L[c>>2]+36>>2]](c)|0;fa=a+16|0;fa=b+16|0;return c|0}function Aw(a){a=a|0;var b=0,c=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=fa-16|0;fa=a;L[a+12>>2]=L[b+12>>2];c=fa-16|0;L[c+12>>2]=L[a+12>>2]+12;fa=a+16|0;fa=b+16|0;return L[L[c+12>>2]+4>>2]}function Ws(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;J[c+11|0]=b;b=J[c+11|0]&1;a=fa-16|0;L[a+12>>2]=L[c+12>>2];J[a+11|0]=b;J[L[a+12>>2]+1096|0]=J[a+11|0]&1;fa=c+16|0}function IH(a,b){a=a|0;b=b|0;var c=0,d=0;a=L[a+64>>2];c=L[a+8>>2];if(c){b=L[a+12>>2];d=L[b>>2];L[a+8>>2]=c-1;L[a+12>>2]=d;return b|0}L[8513]=L[8513]+1;return ha[L[6798]](b,16)|0}function wt(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;J[c+11|0]=b;b=J[c+11|0]&1;a=fa-16|0;L[a+12>>2]=L[c+12>>2];J[a+11|0]=b;J[L[a+12>>2]+524|0]=J[a+11|0]&1;fa=c+16|0}function ut(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;J[c+11|0]=b;b=J[c+11|0]&1;a=fa-16|0;L[a+12>>2]=L[c+12>>2];J[a+11|0]=b;J[L[a+12>>2]+552|0]=J[a+11|0]&1;fa=c+16|0}function pr(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;J[c+11|0]=b;b=J[c+11|0]&1;a=fa-16|0;L[a+12>>2]=L[c+12>>2];J[a+11|0]=b;J[L[a+12>>2]+170|0]=J[a+11|0]&1;fa=c+16|0}function ft(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;J[c+11|0]=b;b=J[c+11|0]&1;a=fa-16|0;L[a+12>>2]=L[c+12>>2];J[a+11|0]=b;J[L[a+12>>2]+736|0]=J[a+11|0]&1;fa=c+16|0}function et(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;J[c+11|0]=b;b=J[c+11|0]&1;a=fa-16|0;L[a+12>>2]=L[c+12>>2];J[a+11|0]=b;J[L[a+12>>2]+737|0]=J[a+11|0]&1;fa=c+16|0}function dk(a){a=a|0;var b=0;L[a>>2]=23152;b=L[a+32>>2];if(!(b?!b|!M[a+36|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+32>>2]=0;J[a+36|0]=1;L[a+24>>2]=0;L[a+28>>2]=0;return a|0}function Vs(a,b){a=a|0;b=S(b);var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;P[c+8>>2]=b;b=P[c+8>>2];a=fa-16|0;L[a+12>>2]=L[c+12>>2];P[a+8>>2]=b;P[L[a+12>>2]+1104>>2]=P[a+8>>2];fa=c+16|0}function Us(a,b){a=a|0;b=S(b);var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;P[c+8>>2]=b;b=P[c+8>>2];a=fa-16|0;L[a+12>>2]=L[c+12>>2];P[a+8>>2]=b;P[L[a+12>>2]+1100>>2]=P[a+8>>2];fa=c+16|0}function Lg(a){a=a|0;var b=0;L[a>>2]=16724;b=L[a+32>>2];if(!(b?!b|!M[a+36|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+32>>2]=0;J[a+36|0]=1;L[a+24>>2]=0;L[a+28>>2]=0;return a|0}function Ib(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;J[c+11|0]=b;b=J[c+11|0]&1;a=fa-16|0;L[a+12>>2]=L[c+12>>2];J[a+11|0]=b;J[L[a+12>>2]+21|0]=J[a+11|0]&1;fa=c+16|0}function vt(a,b){a=a|0;b=S(b);var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;P[c+8>>2]=b;b=P[c+8>>2];a=fa-16|0;L[a+12>>2]=L[c+12>>2];P[a+8>>2]=b;P[L[a+12>>2]+440>>2]=P[a+8>>2];fa=c+16|0}function vn(a){a=a|0;var b=0;L[a>>2]=6544;b=L[a+20>>2];if(!(b?!b|!M[a+24|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+20>>2]=0;J[a+24|0]=1;L[a+12>>2]=0;L[a+16>>2]=0;return a|0}function tc(a,b){a=a|0;b=S(b);var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;P[c+8>>2]=b;b=P[c+8>>2];a=fa-16|0;L[a+12>>2]=L[c+12>>2];P[a+8>>2]=b;P[L[a+12>>2]+184>>2]=P[a+8>>2];fa=c+16|0}function om(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;d=fa-16|0;fa=d;L[d+12>>2]=a;L[d+8>>2]=b;K[d+6>>1]=c;a=L[d+12>>2];ha[L[L[a>>2]+36>>2]](a,L[d+8>>2],N[d+6>>1]<<16>>16,-1);fa=d+16|0}function dt(a,b){a=a|0;b=S(b);var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;P[c+8>>2]=b;b=P[c+8>>2];a=fa-16|0;L[a+12>>2]=L[c+12>>2];P[a+8>>2]=b;P[L[a+12>>2]+684>>2]=P[a+8>>2];fa=c+16|0}function bv(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;d=fa-16|0;fa=d;L[d+12>>2]=a;L[d+8>>2]=b;L[d+4>>2]=c;a=oa(116);Ld(a,L[d+12>>2],L[d+8>>2],L[d+4>>2]&65535,0,0);fa=d+16|0;return a|0}function Zs(a,b){a=a|0;b=S(b);var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;P[c+8>>2]=b;b=P[c+8>>2];a=fa-16|0;L[a+12>>2]=L[c+12>>2];P[a+8>>2]=b;P[L[a+12>>2]+188>>2]=P[a+8>>2];fa=c+16|0}function Vq(a,b){a=a|0;b=S(b);var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;P[c+8>>2]=b;b=P[c+8>>2];a=fa-16|0;L[a+12>>2]=L[c+12>>2];P[a+8>>2]=b;P[L[a+12>>2]+104>>2]=P[a+8>>2];fa=c+16|0}function Pc(a,b){a=a|0;b=S(b);var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;P[c+8>>2]=b;b=P[c+8>>2];a=fa-16|0;L[a+12>>2]=L[c+12>>2];P[a+8>>2]=b;P[L[a+12>>2]+252>>2]=P[a+8>>2];fa=c+16|0}function Mc(a,b){a=a|0;b=S(b);var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;P[c+8>>2]=b;b=P[c+8>>2];a=fa-16|0;L[a+12>>2]=L[c+12>>2];P[a+8>>2]=b;P[L[a+12>>2]+248>>2]=P[a+8>>2];fa=c+16|0}function Fj(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;d=fa-16|0;fa=d;L[d+12>>2]=a;L[d+8>>2]=b;K[d+6>>1]=c;a=L[d+12>>2];ha[L[L[a>>2]+36>>2]](a,L[d+8>>2],N[d+6>>1]<<16>>16,-3);fa=d+16|0}function BC(a){a=a|0;var b=0;L[a>>2]=4720;b=L[a+84>>2];if(!(b?!b|!M[a+88|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+84>>2]=0;J[a+88|0]=1;L[a+76>>2]=0;L[a+80>>2]=0;return a|0}function wc(a){var b=0,c=0;b=L[6804];c=a+7&-8;a=b+c|0;a:{if(a>>>0<=b>>>0?c:0){break a}if(a>>>0>ia()<<16>>>0){if(!(ba(a|0)|0)){break a}}L[6804]=a;return b}L[8527]=48;return-1}function kb(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;b=L[c+8>>2];a=fa-16|0;L[a+12>>2]=L[c+12>>2];L[a+8>>2]=b;L[L[a+12>>2]+240>>2]=L[a+8>>2];fa=c+16|0}function Wm(a,b){a=a|0;b=S(b);var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;P[c+8>>2]=b;b=P[c+8>>2];a=fa-16|0;L[a+12>>2]=L[c+12>>2];P[a+8>>2]=b;P[L[a+12>>2]+12>>2]=P[a+8>>2];fa=c+16|0}function St(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;b=L[c+8>>2];a=fa-16|0;L[a+12>>2]=L[c+12>>2];L[a+8>>2]=b;L[L[a+12>>2]+504>>2]=L[a+8>>2];fa=c+16|0}function Rc(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;b=L[c+8>>2];a=fa-16|0;L[a+12>>2]=L[c+12>>2];L[a+8>>2]=b;L[L[a+12>>2]+204>>2]=L[a+8>>2];fa=c+16|0}function Mj(a,b){a=a|0;b=S(b);var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;P[c+8>>2]=b;a=L[c+12>>2];a=ha[L[L[a>>2]+52>>2]](a,P[c+8>>2],1,S(.01666666753590107))|0;fa=c+16|0;return a|0}function In(a){a=a|0;var b=0;L[a>>2]=5584;b=L[a+16>>2];if(!(b?!b|!M[a+20|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}L[a+16>>2]=0;J[a+20|0]=1;L[a+8>>2]=0;L[a+12>>2]=0;return a|0}function Gb(a,b){a=a|0;b=S(b);var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;P[c+8>>2]=b;b=P[c+8>>2];a=fa-16|0;L[a+12>>2]=L[c+12>>2];P[a+8>>2]=b;P[L[a+12>>2]+16>>2]=P[a+8>>2];fa=c+16|0}function qo(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;d=fa-16|0;fa=d;L[d+12>>2]=a;L[d+8>>2]=b;L[d+4>>2]=c;gf(L[d+12>>2],L[d+4>>2]);if(L[d+8>>2]){P[d>>2]=-1;mh(L[d+4>>2],d)}fa=d+16|0}function SF(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0;if(b>>>0<=11){b=b<<2;e=L[b+12136>>2];b=L[b+12088>>2]}else{b=0}ha[L[L[a>>2]+108>>2]](a,b,c);ha[L[L[a>>2]+108>>2]](a,e,d)}function Qd(a,b){a=a|0;b=S(b);var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;P[c+8>>2]=b;b=P[c+8>>2];a=fa-16|0;L[a+12>>2]=L[c+12>>2];P[a+8>>2]=b;P[L[a+12>>2]+4>>2]=P[a+8>>2];fa=c+16|0}function Pd(a,b){a=a|0;b=S(b);var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;P[c+8>>2]=b;b=P[c+8>>2];a=fa-16|0;L[a+12>>2]=L[c+12>>2];P[a+8>>2]=b;P[L[a+12>>2]+8>>2]=P[a+8>>2];fa=c+16|0}function Mq(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;b=L[c+8>>2];a=fa-16|0;L[a+12>>2]=L[c+12>>2];L[a+8>>2]=b;L[L[a+12>>2]+84>>2]=L[a+8>>2];fa=c+16|0}function Lq(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;b=L[c+8>>2];a=fa-16|0;L[a+12>>2]=L[c+12>>2];L[a+8>>2]=b;L[L[a+12>>2]+88>>2]=L[a+8>>2];fa=c+16|0}function zy(){var a=0,b=0,c=0,d=0;b=sa(4);L[b>>2]=0;a=fa-16|0;fa=a;L[a+12>>2]=b;c=fa-16|0;d=L[a+12>>2];L[c+12>>2]=d;L[L[c+12>>2]>>2]=1184;L[d>>2]=1032;fa=a+16|0;return b|0}function xw(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0;e=fa-16|0;fa=e;L[e+12>>2]=a;L[e+8>>2]=b;L[e+4>>2]=c;J[e+3|0]=d;um(L[e+12>>2],L[e+8>>2],L[e+4>>2],J[e+3|0]&1);fa=e+16|0}function tf(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0;e=fa-16|0;fa=e;L[e+12>>2]=a;L[e+8>>2]=b;L[e+4>>2]=c;J[e+3|0]=d;vf(L[e+12>>2],L[e+8>>2],L[e+4>>2],J[e+3|0]&1);fa=e+16|0}function Rx(){var a=0,b=0,c=0,d=0;b=sa(4);L[b>>2]=0;a=fa-16|0;fa=a;L[a+12>>2]=b;c=fa-16|0;d=L[a+12>>2];L[c+12>>2]=d;L[L[c+12>>2]>>2]=1384;L[d>>2]=1308;fa=a+16|0;return b|0}function Ko(a,b){a=a|0;b=b|0;var c=0,d=0;c=fa-144|0;fa=c;L[c+140>>2]=a;L[c+136>>2]=b;a=c+8|0;b=L[c+140>>2];xj(a,b+68|0);d=c+72|0;Td(d,a,b+4|0);sb(L[c+136>>2],d);fa=c+144|0}function Ct(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;a=L[c+8>>2];b=L[c+12>>2];vg(b);b=b+(a<<2)|0;P[b+1316>>2]=P[b+((a|0)<3?1256:1180)>>2];fa=c+16|0}function Sd(a,b){a=a|0;b=S(b);var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;P[c+8>>2]=b;b=P[c+8>>2];a=fa-16|0;L[a+12>>2]=L[c+12>>2];P[a+8>>2]=b;P[L[a+12>>2]>>2]=P[a+8>>2];fa=c+16|0}function sw(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0;e=fa-16|0;fa=e;L[e+12>>2]=a;L[e+8>>2]=b;L[e+4>>2]=c;L[e>>2]=d;Yl(L[e+12>>2],L[e+8>>2],L[e+4>>2],L[e>>2],0);fa=e+16|0}function lr(a,b,c){a=a|0;b=S(b);c=c|0;var d=0;d=fa-16|0;fa=d;L[d+12>>2]=a;P[d+8>>2]=b;L[d+4>>2]=c;P[(L[L[d+12>>2]+144>>2]+R(L[d+4>>2],284)|0)+252>>2]=P[d+8>>2];fa=d+16|0}function kr(a,b,c){a=a|0;b=S(b);c=c|0;var d=0;d=fa-16|0;fa=d;L[d+12>>2]=a;P[d+8>>2]=b;L[d+4>>2]=c;P[(L[L[d+12>>2]+144>>2]+R(L[d+4>>2],284)|0)+232>>2]=P[d+8>>2];fa=d+16|0}function eI(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;if((b|0)!=(c|0)){d=L[L[a+4>>2]+136>>2];ha[L[L[d>>2]+8>>2]](d,L[b+36>>2],L[c+36>>2])|0;a=L[a+4>>2];L[a+160>>2]=L[a+160>>2]+1}}function dr(a,b,c){a=a|0;b=S(b);c=c|0;var d=0;d=fa-16|0;fa=d;L[d+12>>2]=a;P[d+8>>2]=b;L[d+4>>2]=c;P[(L[L[d+12>>2]+144>>2]+R(L[d+4>>2],284)|0)+256>>2]=P[d+8>>2];fa=d+16|0}function $h(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=L[b+12>>2];L[a>>2]=1632;mb(a+112|0);mb(a+92|0);mb(a+72|0);mb(a+20|0);L[(fa-16|0)+12>>2]=a;fa=b+16|0;return a|0}function Zb(a,b){var c=0;c=fa-16|0;fa=c;L[c+12>>2]=b;P[c+8>>2]=-P[L[c+12>>2]>>2];P[c+4>>2]=-P[L[c+12>>2]+4>>2];P[c>>2]=-P[L[c+12>>2]+8>>2];la(a,c+8|0,c+4|0,c);fa=c+16|0}function $k(a){var b=0,c=0;b=fa-16|0;fa=b;L[b+8>>2]=a;a=L[b+8>>2];L[b+12>>2]=a;c=a+48|0;while(1){L[(fa-16|0)+12>>2]=a;a=a+16|0;if((c|0)!=(a|0)){continue}break}fa=b+16|0}function jw(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;d=fa-16|0;fa=d;L[d+12>>2]=a;J[d+11|0]=b;J[d+10|0]=c;a=oa(76);Bm(a,L[d+12>>2],J[d+11|0]&1,J[d+10|0]&1);fa=d+16|0;return a|0}function Gr(a,b,c){a=a|0;b=b|0;c=S(c);var d=0;d=fa-16|0;fa=d;L[d+12>>2]=a;L[d+8>>2]=b;P[d+4>>2]=c;a=oa(184);ul(a,L[d+12>>2],L[d+8>>2],P[d+4>>2],1);fa=d+16|0;return a|0}function rC(a){a=a|0;var b=0;a=L[a+140>>2];b=L[a+32>>2];if(b){if((b|0)>=2){b=b-1|0}else{b=L[a+8>>2];ha[L[L[b>>2]+24>>2]](b,L[a+28>>2]);L[a+36>>2]=0;b=0}L[a+32>>2]=b}}function dA(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;d=fa-16|0;fa=d;L[d+12>>2]=a;L[d+8>>2]=b;J[d+7|0]=c;a=oa(1312);ll(a,L[d+12>>2],L[d+8>>2],J[d+7|0]&1);fa=d+16|0;return a|0}function Hd(a,b){var c=0;if(L[b+40>>2]){Hd(a,L[b+36>>2]);Hd(a,L[b+40>>2])}if(L[a>>2]==(b|0)){L[a>>2]=0}c=L[a+4>>2];if(c){L[8514]=L[8514]+1;ha[L[6799]](c)}L[a+4>>2]=b}function pz(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;c=L[b>>2];c=ha[L[L[c>>2]+56>>2]](c,20)|0;d=M[a+4|0];L[c>>2]=8684;L[c+4>>2]=L[b>>2];J[c+16|0]=d;L[c>>2]=22720;return c|0}function ot(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;d=fa-16|0;fa=d;L[d+12>>2]=a;L[d+8>>2]=b;J[d+7|0]=c;a=oa(764);fl(a,L[d+12>>2],L[d+8>>2],J[d+7|0]&1);fa=d+16|0;return a|0}function Uk(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;d=fa-16|0;fa=d;L[d+12>>2]=a;L[d+8>>2]=b;L[d+4>>2]=c;a=L[d+12>>2];ha[L[L[a>>2]+136>>2]](a,L[d+8>>2],L[d+4>>2]);fa=d+16|0}function Ui(a,b){var c=0,d=0;c=fa-48|0;fa=c;L[c+44>>2]=a;L[c+40>>2]=b;b=c+8|0;a=L[c+44>>2];ua(b,a+264|0,L[c+40>>2]);d=c+24|0;Kb(d,b,a+544|0);hb(a+328|0,d);fa=c+48|0}function Ti(a,b){var c=0,d=0;c=fa-48|0;fa=c;L[c+44>>2]=a;L[c+40>>2]=b;b=c+8|0;a=L[c+44>>2];Kb(b,L[c+40>>2],a+348|0);d=c+24|0;Ga(d,b,a+344|0);hb(a+312|0,d);fa=c+48|0}function Jt(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;L[c+12>>2]=a;L[c+8>>2]=b;a=L[c+12>>2];b=L[c+8>>2];c=L[b+4>>2];L[a+348>>2]=L[b>>2];L[a+352>>2]=c;L[a+356>>2]=L[b+8>>2]}function Dr(a,b,c){a=a|0;b=b|0;c=S(c);var d=0;d=fa-16|0;fa=d;L[d+12>>2]=a;L[d+8>>2]=b;P[d+4>>2]=c;a=L[d+12>>2];ha[L[L[a>>2]+20>>2]](a,L[d+8>>2],P[d+4>>2]);fa=d+16|0}function Ca(a,b,c){a=a|0;b=S(b);c=c|0;var d=0;d=fa-16|0;fa=d;L[d+12>>2]=a;P[d+8>>2]=b;L[d+4>>2]=c;a=L[d+12>>2];ha[L[L[a>>2]+32>>2]](a,P[d+8>>2],L[d+4>>2]);fa=d+16|0}function Be(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;d=fa-16|0;fa=d;L[d+12>>2]=a;L[d+8>>2]=b;L[d+4>>2]=c;a=L[d+12>>2];ha[L[L[a>>2]+104>>2]](a,L[d+8>>2],L[d+4>>2]);fa=d+16|0}function Ar(a,b,c){a=a|0;b=b|0;c=S(c);var d=0;d=fa-16|0;fa=d;L[d+12>>2]=a;L[d+8>>2]=b;P[d+4>>2]=c;a=L[d+12>>2];ha[L[L[a>>2]+36>>2]](a,L[d+8>>2],P[d+4>>2]);fa=d+16|0}function Ae(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;d=fa-16|0;fa=d;L[d+12>>2]=a;L[d+8>>2]=b;L[d+4>>2]=c;a=L[d+12>>2];ha[L[L[a>>2]+108>>2]](a,L[d+8>>2],L[d+4>>2]);fa=d+16|0}function li(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;d=fa-16|0;fa=d;L[d+12>>2]=a;L[d+8>>2]=b;L[d+4>>2]=c;a=L[d+12>>2];ha[L[L[a>>2]+40>>2]](a,L[d+8>>2],L[d+4>>2]);fa=d+16|0}function Tf(a,b,c){a=a|0;b=b|0;c=S(c);var d=0;d=fa-16|0;fa=d;L[d+12>>2]=a;L[d+8>>2]=b;P[d+4>>2]=c;a=L[d+12>>2];ha[L[L[a>>2]+8>>2]](a,L[d+8>>2],P[d+4>>2]);fa=d+16|0}function Rl(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;d=fa-16|0;fa=d;L[d+12>>2]=a;L[d+8>>2]=b;L[d+4>>2]=c;a=L[d+12>>2];ha[L[L[a>>2]+16>>2]](a,L[d+8>>2],L[d+4>>2]);fa=d+16|0}function Nl(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;d=fa-16|0;fa=d;L[d+12>>2]=a;L[d+8>>2]=b;L[d+4>>2]=c;a=L[d+12>>2];ha[L[L[a>>2]+20>>2]](a,L[d+8>>2],L[d+4>>2]);fa=d+16|0}function Nj(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;d=fa-16|0;fa=d;L[d+12>>2]=a;L[d+8>>2]=b;J[d+7|0]=c;a=L[d+12>>2];ha[L[L[a>>2]+56>>2]](a,L[d+8>>2],J[d+7|0]&1);fa=d+16|0}function Sa(a,b){var c=0;c=fa-16|0;L[c+12>>2]=a;L[c+8>>2]=b;a=L[c+12>>2];b=L[c+8>>2];return S(S(P[a+8>>2]*P[b+8>>2])+S(S(P[a>>2]*P[b>>2])+S(P[a+4>>2]*P[b+4>>2])))}function Iq(){var a=0,b=0,c=0,d=0;b=sa(4);a=fa-16|0;fa=a;L[a+12>>2]=b;c=fa-16|0;d=L[a+12>>2];L[c+12>>2]=d;L[L[c+12>>2]>>2]=5328;L[d>>2]=5228;fa=a+16|0;return b|0}function Oj(a,b,c,d){var e=0,f=0;e=L[a+4>>2];f=L[a>>2];a=0;a:{if(!c){break a}a=e>>8;if(!(e&1)){break a}a=L[a+L[c>>2]>>2]}ha[L[L[f>>2]+28>>2]](f,b,a+c|0,e&2?d:2)}function Jj(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;b=L[c+8>>2];a=fa-16|0;L[a+12>>2]=L[c+12>>2];L[a+8>>2]=b;L[7547]=L[a+8>>2];fa=c+16|0}function Ij(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;b=L[c+8>>2];a=fa-16|0;L[a+12>>2]=L[c+12>>2];L[a+8>>2]=b;L[8114]=L[a+8>>2];fa=c+16|0}function Hj(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;b=L[c+8>>2];a=fa-16|0;L[a+12>>2]=L[c+12>>2];L[a+8>>2]=b;L[8113]=L[a+8>>2];fa=c+16|0}function sy(a){a=a|0;var b=0,c=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=fa-16|0;fa=a;L[a+12>>2]=L[b+12>>2];c=L[a+12>>2];P[a+8>>2]=Sf(c);Aj(c,a+8|0);fa=a+16|0;fa=b+16|0}function Ft(a,b,c){a=a|0;b=b|0;c=S(c);var d=0;d=fa-16|0;fa=d;L[d+12>>2]=a;L[d+8>>2]=b;P[d+4>>2]=c;P[(L[d+12>>2]+(L[d+8>>2]<<2)|0)+1340>>2]=P[d+4>>2];fa=d+16|0}function Et(a,b,c){a=a|0;b=b|0;c=S(c);var d=0;d=fa-16|0;fa=d;L[d+12>>2]=a;L[d+8>>2]=b;P[d+4>>2]=c;P[(L[d+12>>2]+(L[d+8>>2]<<2)|0)+1364>>2]=P[d+4>>2];fa=d+16|0}function Bt(a,b,c){a=a|0;b=b|0;c=S(c);var d=0;d=fa-16|0;fa=d;L[d+12>>2]=a;L[d+8>>2]=b;P[d+4>>2]=c;P[(L[d+12>>2]+(L[d+8>>2]<<2)|0)+1316>>2]=P[d+4>>2];fa=d+16|0}function Bp(a,b,c){a=S(a);b=S(b);c=S(c);var d=0,e=0;d=fa-16|0;fa=d;P[d+12>>2]=a;P[d+8>>2]=b;P[d+4>>2]=c;e=oa(16);la(e,d+12|0,d+8|0,d+4|0);fa=d+16|0;return e|0}function go(a,b,c,d){a=a|0;b=S(b);c=S(c);d=S(d);var e=0;e=fa-16|0;fa=e;L[e+12>>2]=a;P[e+8>>2]=b;P[e+4>>2]=c;P[e>>2]=d;la(L[e+12>>2],e+8|0,e+4|0,e);fa=e+16|0}function Am(a){a=a|0;var b=0;L[a>>2]=12256;if(M[a+61|0]){b=L[a+52>>2];ha[L[L[b>>2]>>2]](b)|0;b=L[a+52>>2];if(b){L[8514]=L[8514]+1;ha[L[6799]](b)}}return a|0}function zC(a,b){a=a|0;b=b|0;var c=0;c=L[b+4>>2];L[a+156>>2]=L[b>>2];L[a+160>>2]=c;c=L[b+12>>2];L[a+164>>2]=L[b+8>>2];L[a+168>>2]=c;ha[L[L[a>>2]+72>>2]](a)}function cA(a){a=a|0;L[8292]=20800;a=L[8416];if(!(a?!a|!M[33668]:1)){L[8514]=L[8514]+1;ha[L[6799]](a)}J[33668]=1;L[8414]=0;L[8415]=0;L[8416]=0;L[8292]=6712}function TA(a){a=a|0;L[8134]=20800;a=L[8258];if(!(a?!a|!M[33036]:1)){L[8514]=L[8514]+1;ha[L[6799]](a)}J[33036]=1;L[8256]=0;L[8257]=0;L[8258]=0;L[8134]=6712}function uc(a){var b=0;b=fa-16|0;fa=b;P[b+12>>2]=a;if(P[b+12>>2]>2]=-1}if(P[b+12>>2]>S(1)){P[b+12>>2]=1}a=ob(P[b+12>>2]);fa=b+16|0;return a}function uA(a,b){a=a|0;b=b|0;var c=0;if(M[a+273|0]){c=L[a+200>>2];if(c){L[8514]=L[8514]+1;ha[L[6799]](c)}}L[a+200>>2]=b;J[a+273|0]=0;L[L[a+196>>2]+8>>2]=b}function qw(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;d=fa-16|0;fa=d;L[d+12>>2]=a;L[d+8>>2]=b;J[d+7|0]=c;a=Pe(L[d+12>>2],L[d+8>>2],J[d+7|0]&1);fa=d+16|0;return a|0}function ab(a){var b=0,c=0;b=a*a;c=b*a;return S(c*(b*b)*(b*2718311493989822e-21+-.00019839334836096632)+(c*(b*.008333329385889463+-.16666666641626524)+a))}function Np(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;d=fa-16|0;fa=d;L[d+12>>2]=a;L[d+8>>2]=b;L[d+4>>2]=c;a=xk(L[d+12>>2],L[d+8>>2],L[d+4>>2]);fa=d+16|0;return a|0}function Db(a,b){var c=0;c=fa-16|0;L[c+12>>2]=a;L[c+8>>2]=0;L[c+4>>2]=b;L[c>>2]=L[c+8>>2];while(1){if(L[c>>2]>2]){L[c>>2]=L[c>>2]+1;continue}break}}function Eq(a){a=a|0;var b=0,c=0;b=fa-16|0;fa=b;L[b+12>>2]=a;c=L[b+12>>2];if(c){a=fa-16|0;fa=a;L[a+12>>2]=c;rc(L[a+12>>2]+56|0);fa=a+16|0;ra(c)}fa=b+16|0}function Yo(a){a=a|0;var b=0,c=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=L[b+12>>2];L[b+8>>2]=28501;c=L[b+8>>2];L[b>>2]=a;a=$(c|0,1298,b|0)|0;fa=b+16|0;return a|0}function Tx(a){a=a|0;var b=0;b=fa-80|0;fa=b;L[b+76>>2]=a;if(!M[29812]){Pb(29748);J[29812]=1}a=b+12|0;xj(a,L[b+76>>2]);sb(29748,a);fa=b+80|0;return 29748}function lm(a){a=a|0;var b=S(0),c=S(0);b=P[a+28>>2];c=S(ha[L[L[a>>2]+48>>2]](a));S(ha[L[L[a>>2]+48>>2]](a));S(ha[L[L[a>>2]+48>>2]](a));return S(S(b+c))}function kE(a){a=a|0;var b=S(0),c=S(0);b=P[a+32>>2];S(ha[L[L[a>>2]+48>>2]](a));c=S(ha[L[L[a>>2]+48>>2]](a));S(ha[L[L[a>>2]+48>>2]](a));return S(S(b+c))}function aI(a,b,c){a=a|0;b=b|0;c=c|0;a:{if(!c){break a}a=L[b+8>>2];if(!a){break a}ha[L[L[a>>2]>>2]](a)|0;ha[L[L[c>>2]+60>>2]](c,L[b+8>>2]);L[b+8>>2]=0}}function Rh(a){var b=0;b=fa-16|0;L[b+12>>2]=a;a=L[b+12>>2];a:{if(P[a>>2]>2]){a=P[a+4>>2]>2]?2:1;break a}a=P[a>>2]>2]?2:0}return a}function jd(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;a=L[c+8>>2];b=L[c+12>>2];if((L[b+216>>2]&-2)!=4){L[b+216>>2]=a}fa=c+16|0}function el(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;a=L[c+12>>2];a=ha[L[L[a>>2]+124>>2]](a,L[c+8>>2])|0;fa=c+16|0;return a|0}function JH(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0;e=fa-16|0;fa=e;L[e+12>>2]=a;L[e+8>>2]=c;L[e+4>>2]=6652;ha[L[L[b>>2]+48>>2]](b,e+4|0,d);fa=e+16|0}function zE(a,b){a=a|0;b=b|0;var c=0,d=0;d=L[b+4>>2];c=L[a+92>>2];L[c+4>>2]=L[b>>2];L[c+8>>2]=d;d=L[b+12>>2];L[c+12>>2]=L[b+8>>2];L[c+16>>2]=d;Sb(a)}function kn(a){a=a|0;var b=0,c=0;L[a>>2]=8836;a:{if(!M[a+16|0]){break a}b=L[a+20>>2];if(!b){break a}c=L[a+4>>2];ha[L[L[c>>2]+16>>2]](c,b)}return a|0}function ih(a){a=a|0;var b=0;L[a>>2]=9468;b=L[a+48>>2];ha[L[L[b>>2]+20>>2]](b,L[a+64>>2]);b=L[a+48>>2];ha[L[L[b>>2]+16>>2]](b,L[a+64>>2]);return a|0}function Yq(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;fa=c+16|0;return S(P[(L[L[c+12>>2]+144>>2]+R(L[c+8>>2],284)|0)+232>>2])}function Ym(a){a=a|0;var b=0,c=0;L[a>>2]=10180;a:{if(!M[a+8|0]){break a}b=L[a+12>>2];if(!b){break a}c=L[a+4>>2];ha[L[L[c>>2]+16>>2]](c,b)}return a|0}function Xm(a){a=a|0;var b=0,c=0;L[a>>2]=10252;a:{if(!M[a+8|0]){break a}b=L[a+12>>2];if(!b){break a}c=L[a+4>>2];ha[L[L[c>>2]+16>>2]](c,b)}return a|0}function Ue(a,b){a=a|0;b=b|0;var c=S(0),d=S(0),e=S(0);c=P[b>>2];d=P[b+4>>2];e=P[b+8>>2];L[a+24>>2]=0;P[a+20>>2]=T(e);P[a+16>>2]=T(d);P[a+12>>2]=T(c)}function Om(a){a=a|0;var b=0,c=0;L[a>>2]=11644;a:{if(!M[a+8|0]){break a}b=L[a+12>>2];if(!b){break a}c=L[a+4>>2];ha[L[L[c>>2]+16>>2]](c,b)}return a|0}function Oa(a){a=a|0;var b=0;L[a>>2]=15836;b=L[a+52>>2];if(b){ha[L[L[b>>2]>>2]](b)|0;b=L[a+52>>2];if(b){L[8514]=L[8514]+1;ha[L[6799]](b)}}return a|0}function Nm(a){a=a|0;var b=0,c=0;L[a>>2]=11720;a:{if(!M[a+8|0]){break a}b=L[a+12>>2];if(!b){break a}c=L[a+4>>2];ha[L[L[c>>2]+16>>2]](c,b)}return a|0}function Lw(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;a=L[c+12>>2];a=ha[L[L[a>>2]+92>>2]](a,L[c+8>>2])&1;fa=c+16|0;return a|0}function Ik(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;a=L[c+12>>2];a=ha[L[L[a>>2]+40>>2]](a,L[c+8>>2])|0;fa=c+16|0;return a|0}function Gs(a){a=a|0;var b=0,c=S(0);b=fa-16|0;L[b+12>>2]=a;c=P[L[b+12>>2]+48>>2];a:{if(S(T(c))>2],f)){Wf(b,c,d,e);return}a=L[a+8>>2];ha[L[L[a>>2]+20>>2]](a,b,c,d,e,f)}function $H(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;d=fa-16|0;fa=d;L[d+12>>2]=c;L[d+8>>2]=a;L[d+4>>2]=b;L[d>>2]=6184;ha[L[L[a>>2]+48>>2]](a,d,c);fa=d+16|0}function ek(a){L[a+12>>2]=1065353216;L[a+4>>2]=5;L[a+8>>2]=0;J[a+16|0]=1;J[a+36|0]=1;L[a>>2]=23152;L[a+32>>2]=0;L[a+24>>2]=0;L[a+28>>2]=0;return a}function Qj(a){var b=0,c=0;c=a>>>23&255;b=0;a:{if(c>>>0<127){break a}b=2;if(c>>>0>150){break a}c=1<<150-c;b=0;if(c-1&a){break a}b=a&c?1:2}return b}function TH(a,b){a=a|0;b=b|0;var c=0;c=L[a+4>>2];if(!((c|0)!=L[b>>2]&(c|0)!=L[b+4>>2])){c=L[a+8>>2];ha[L[L[c>>2]+32>>2]](c,b,L[a+12>>2])}return 0}function cv(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;a=oa(116);Ld(a,L[c+12>>2],L[c+8>>2],16384,0,0);fa=c+16|0;return a|0}function Jo(a,b){a=a|0;b=b|0;var c=0;c=fa-80|0;fa=c;L[c+76>>2]=a;L[c+72>>2]=b;a=c+8|0;b=L[c+76>>2];Td(a,L[c+72>>2],b+68|0);sb(b+4|0,a);fa=c+80|0}function yw(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;d=fa-16|0;fa=d;L[d+12>>2]=a;L[d+8>>2]=b;L[d+4>>2]=c;um(L[d+12>>2],L[d+8>>2],L[d+4>>2],1);fa=d+16|0}function uf(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;d=fa-16|0;fa=d;L[d+12>>2]=a;L[d+8>>2]=b;L[d+4>>2]=c;vf(L[d+12>>2],L[d+8>>2],L[d+4>>2],0);fa=d+16|0}function qD(a,b,c){a=a|0;b=b|0;c=c|0;a=(b<<4)+a|0;b=L[a+108>>2];L[c+8>>2]=L[a+104>>2];L[c+12>>2]=b;b=L[a+100>>2];L[c>>2]=L[a+96>>2];L[c+4>>2]=b}function LH(a,b,c){a=a|0;b=b|0;c=c|0;a=0;b=L[b+204>>2];a:{if(b&4){break a}c=L[c+204>>2];if(c&4){break a}if(!(b&3)){return 1}a=!(c&3)}return a|0}function sr(a,b){a=a|0;b=S(b);var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;P[c+8>>2]=b;a=L[c+12>>2];b=P[c+8>>2];P[a+36>>2]=b;P[a+40>>2]=Fa(b);fa=c+16|0}function ru(a,b,c){a=a|0;b=S(b);c=c|0;var d=0;d=fa-16|0;fa=d;L[d+12>>2]=a;P[d+8>>2]=b;L[d+4>>2]=c;ve(L[d+12>>2],P[d+8>>2],L[d+4>>2]);fa=d+16|0}function qz(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;a=L[b>>2];a=ha[L[L[a>>2]+56>>2]](a,24)|0;L[a>>2]=8684;L[a+4>>2]=L[b>>2];L[a>>2]=23080;return a|0}function ir(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;d=fa-16|0;fa=d;L[d+12>>2]=a;L[d+8>>2]=b;J[d+7|0]=c;mg(L[d+12>>2],L[d+8>>2],J[d+7|0]&1);fa=d+16|0}function hu(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;d=fa-16|0;fa=d;L[d+12>>2]=a;L[d+8>>2]=b;L[d+4>>2]=c;rb(L[d+12>>2],L[d+8>>2],L[d+4>>2]);fa=d+16|0}function bb(a){var b=0;a=a*a;b=a*a;return S(a*b*(a*2439044879627741e-20+-.001388676377460993)+(b*.04166662332373906+(a*-.499999997251031+1)))}function Yw(a,b,c){a=a|0;b=b|0;c=S(c);var d=0;d=fa-16|0;L[d+12>>2]=a;L[d+8>>2]=b;P[d+4>>2]=c;P[(L[d+12>>2]+20|0)+(L[d+8>>2]<<2)>>2]=P[d+4>>2]}function Xp(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;d=fa-16|0;fa=d;L[d+12>>2]=a;L[d+8>>2]=b;L[d+4>>2]=c;se(L[d+12>>2],L[d+8>>2],L[d+4>>2]);fa=d+16|0}function Wq(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;d=fa-16|0;fa=d;L[d+12>>2]=a;L[d+8>>2]=b;J[d+7|0]=c;lg(L[d+12>>2],L[d+8>>2],J[d+7|0]&1);fa=d+16|0}function Nw(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;d=fa-16|0;fa=d;L[d+12>>2]=a;L[d+8>>2]=b;J[d+7|0]=c;tm(L[d+12>>2],L[d+8>>2],J[d+7|0]&1);fa=d+16|0}function Mv(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;d=fa-16|0;fa=d;L[d+12>>2]=a;L[d+8>>2]=b;L[d+4>>2]=c;Lb(L[d+12>>2],L[d+8>>2],L[d+4>>2]);fa=d+16|0}function Lv(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;d=fa-16|0;fa=d;L[d+12>>2]=a;L[d+8>>2]=b;L[d+4>>2]=c;aj(L[d+12>>2],L[d+8>>2],L[d+4>>2]);fa=d+16|0}function Aj(a,b){var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;a=L[c+12>>2];P[c+4>>2]=S(1)/P[L[c+8>>2]>>2];a=zj(a,c+4|0);fa=c+16|0;return a}function zl(a,b){var c=0,d=0;d=Al(a);c=L[a+288>>2];L[b+8>>2]=L[a+284>>2];L[b+12>>2]=c;c=L[a+280>>2];L[b>>2]=L[a+276>>2];L[b+4>>2]=c;return d}function rG(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;a=L[b>>2];a=ha[L[L[a>>2]+56>>2]](a,8)|0;L[a>>2]=8684;L[a+4>>2]=L[b>>2];L[a>>2]=11304;return a|0}function VF(a,b,c){a=a|0;b=b|0;c=c|0;if(b>>>0<=5){L[c+12>>2]=0;a=b<<2;P[c+8>>2]=P[a+12064>>2];P[c+4>>2]=P[a+12040>>2];P[c>>2]=P[a+12016>>2]}}function jr(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;fa=c+16|0;return(L[L[c+12>>2]+144>>2]+R(L[c+8>>2],284)|0)+92|0}function Cq(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;d=fa-16|0;L[d+12>>2]=a;L[d+8>>2]=b;L[d+4>>2]=c;L[(L[d+12>>2]+8|0)+(L[d+8>>2]<<2)>>2]=L[d+4>>2]}function wj(a){var b=0;b=fa-16|0;L[b+12>>2]=a;a=L[b+12>>2];L[a>>2]=1608;P[a+4>>2]=1;L[a+8>>2]=0;K[a+12>>1]=1;K[a+14>>1]=65535;L[a+16>>2]=0}function Im(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;a=L[c+12>>2];ha[L[L[a>>2]+36>>2]](a,L[c+8>>2],1,-1);fa=c+16|0}function Gj(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;a=L[c+12>>2];ha[L[L[a>>2]+36>>2]](a,L[c+8>>2],2,-3);fa=c+16|0}function og(a){var b=0;b=fa-16|0;L[b+12>>2]=a;a=L[b+12>>2];L[a>>2]=0;L[a+4>>2]=0;L[a+8>>2]=4096;L[a+12>>2]=4096;L[a+16>>2]=0;L[a+20>>2]=1}function lw(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;J[c+11|0]=b;a=oa(76);Bm(a,L[c+12>>2],J[c+11|0]&1,1);fa=c+16|0;return a|0}function Ay(){var a=0,b=0;b=oa(284);a=Cd(b);L[a>>2]=11364;L[a+236>>2]=4;J[a+280|0]=1;L[a+276>>2]=0;L[a+268>>2]=0;L[a+272>>2]=0;return b|0}function tw(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;J[c+15|0]=a;J[c+14|0]=b;a=oa(172);Kg(a,J[c+15|0]&1,J[c+14|0]&1);fa=c+16|0;return a|0}function pt(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;a=oa(764);fl(a,L[c+12>>2],L[c+8>>2],0);fa=c+16|0;return a|0}function ex(a){a=a|0;var b=0,c=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=oa(56);c=Sg(a,L[b+12>>2]);L[c+52>>2]=0;L[c>>2]=14796;fa=b+16|0;return a|0}function dx(a){a=a|0;var b=0,c=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=oa(56);c=Sg(a,L[b+12>>2]);L[c+52>>2]=2;L[c>>2]=14900;fa=b+16|0;return a|0}function Vj(a,b,c){L[a+4>>2]=0;L[a+8>>2]=0;L[a>>2]=b;L[a+32>>2]=0;L[a+24>>2]=0;L[a+28>>2]=0;L[a+20>>2]=c;L[a+12>>2]=0;L[a+16>>2]=0;$f(a)}function nr(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;J[c+11|0]=b;a=L[c+12>>2];ha[L[L[a>>2]+52>>2]](a,J[c+11|0]&1);fa=c+16|0}function ix(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;J[c+11|0]=b;a=oa(96);pm(a,L[c+12>>2],J[c+11|0]&1);fa=c+16|0;return a|0}function Wi(a,b){var c=0;c=fa-32|0;fa=c;L[c+28>>2]=a;L[c+24>>2]=b;a=c+8|0;b=L[c+28>>2];Kb(a,L[c+24>>2],b+544|0);hb(b+428|0,a);fa=c+32|0}function Vi(a,b){var c=0;c=fa-32|0;fa=c;L[c+28>>2]=a;L[c+24>>2]=b;a=c+8|0;b=L[c+28>>2];Kb(a,L[c+24>>2],b+348|0);hb(b+412|0,a);fa=c+32|0}function Vf(a,b,c,d,e,f){var g=0,h=0;g=L[a+4>>2];h=g>>8;a=L[a>>2];if(g&1){h=L[L[d>>2]+h>>2]}ha[L[L[a>>2]+20>>2]](a,b,c,d+h|0,g&2?e:2,f)}function Pj(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;a=L[c+12>>2];ha[L[L[a>>2]+56>>2]](a,L[c+8>>2],0);fa=c+16|0}function xv(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;a=oa(212);Yi(a,L[c+12>>2],L[c+8>>2]);fa=c+16|0;return a|0}function _q(a,b){a=a|0;b=S(b);var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;P[c+8>>2]=b;a=L[c+12>>2];ha[L[L[a>>2]+16>>2]](a,P[c+8>>2]);fa=c+16|0}function Zc(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=fa-16|0;L[a+12>>2]=L[b+12>>2];fa=b+16|0;return(L[L[a+12>>2]+204>>2]&3)!=0|0}function Ua(a,b){a=a|0;b=S(b);var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;P[c+8>>2]=b;a=L[c+12>>2];ha[L[L[a>>2]+44>>2]](a,P[c+8>>2]);fa=c+16|0}function Tq(a,b){a=a|0;b=S(b);var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;P[c+8>>2]=b;a=L[c+12>>2];ha[L[L[a>>2]+20>>2]](a,P[c+8>>2]);fa=c+16|0}function Pw(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;a=oa(112);We(a,L[c+12>>2],L[c+8>>2]);fa=c+16|0;return a|0}function Ox(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;a=oa(200);Pf(a,L[c+12>>2],L[c+8>>2]);fa=c+16|0;return a|0}function $c(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=fa-16|0;L[a+12>>2]=L[b+12>>2];fa=b+16|0;return(L[L[a+12>>2]+204>>2]&2)!=0|0}function za(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;a=L[c+12>>2];ha[L[L[a>>2]+24>>2]](a,L[c+8>>2]);fa=c+16|0}function yf(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;a=L[c+12>>2];ha[L[L[a>>2]+68>>2]](a,L[c+8>>2]);fa=c+16|0}function qq(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=fa-16|0;L[a+12>>2]=L[b+12>>2];a=L[a+12>>2];L[a+4>>2]=L[a+4>>2]-1;fa=b+16|0}function pi(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;a=L[c+12>>2];ha[L[L[a>>2]+36>>2]](a,L[c+8>>2]);fa=c+16|0}function nd(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;a=L[c+12>>2];ha[L[L[a>>2]+16>>2]](a,L[c+8>>2]);fa=c+16|0}function gi(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;a=L[c+12>>2];ha[L[L[a>>2]+44>>2]](a,L[c+8>>2]);fa=c+16|0}function er(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;fa=c+16|0;return L[L[c+12>>2]+144>>2]+R(L[c+8>>2],284)|0}function ck(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;a=L[c+12>>2];ha[L[L[a>>2]+72>>2]](a,L[c+8>>2]);fa=c+16|0}function Xj(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;a=L[c+12>>2];ha[L[L[a>>2]+84>>2]](a,L[c+8>>2]);fa=c+16|0}function Uf(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;a=L[c+12>>2];ha[L[L[a>>2]+60>>2]](a,L[c+8>>2]);fa=c+16|0}function Rj(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;a=L[c+12>>2];ha[L[L[a>>2]+92>>2]](a,L[c+8>>2]);fa=c+16|0}function RE(a,b){a=a|0;b=b|0;var c=0;c=L[b+4>>2];L[a+12>>2]=L[b>>2];L[a+16>>2]=c;c=L[b+12>>2];L[a+20>>2]=L[b+8>>2];L[a+24>>2]=c;Sb(a)}function Jb(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;a=L[c+12>>2];ha[L[L[a>>2]+12>>2]](a,L[c+8>>2]);fa=c+16|0}function Ge(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;a=L[c+12>>2];ha[L[L[a>>2]+40>>2]](a,L[c+8>>2]);fa=c+16|0}function Cr(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;a=L[c+12>>2];ha[L[L[a>>2]+28>>2]](a,L[c+8>>2]);fa=c+16|0}function Br(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;a=L[c+12>>2];ha[L[L[a>>2]+32>>2]](a,L[c+8>>2]);fa=c+16|0}function $v(){var a=0,b=0,c=0;c=oa(160);a=fa-16|0;fa=a;L[a+12>>2]=c;b=L[a+12>>2];Re(b);L[b>>2]=4548;L[b+92>>2]=4;fa=a+16|0;return c|0}function $d(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;a=L[c+12>>2];ha[L[L[a>>2]+64>>2]](a,L[c+8>>2]);fa=c+16|0}function un(a,b){a=a|0;b=b|0;var c=0,d=S(0);c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;d=Sa(L[c+12>>2],L[c+8>>2]);fa=c+16|0;return S(d)}function py(a,b){a=a|0;b=b|0;var c=0,d=S(0);c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;d=_b(L[c+12>>2],L[c+8>>2]);fa=c+16|0;return S(d)}function eh(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;a=L[c+12>>2];ha[L[L[a>>2]+8>>2]](a,L[c+8>>2]);fa=c+16|0}function Qt(){var a=0,b=0;b=sa(12);a=fa-16|0;L[a+12>>2]=b;a=L[a+12>>2];P[a>>2]=.30000001192092896;P[a+4>>2]=1;P[a+8>>2]=0;return b|0}function $q(a,b){a=a|0;b=b|0;var c=0,d=S(0);c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;d=Ck(L[c+12>>2],L[c+8>>2]);fa=c+16|0;return S(d)}function qm(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=fa-16|0;L[a+12>>2]=L[b+12>>2];fa=b+16|0;return P[L[a+12>>2]+4>>2]>2]=a;a=L[b+12>>2];L[(fa-16|0)+12>>2]=a+4;$k(a+28|0);L[(fa-16|0)+12>>2]=a+76;fa=b+16|0}function le(a,b,c,d,e){var f=0,g=0;f=L[a+4>>2];g=f>>8;a=L[a>>2];if(f&1){g=L[L[c>>2]+g>>2]}ha[L[L[a>>2]+24>>2]](a,b,c+g|0,f&2?d:2,e)}function aE(a,b){a=a|0;b=b|0;var c=0;c=L[b+4>>2];L[a+108>>2]=L[b>>2];L[a+112>>2]=c;c=L[b+12>>2];L[a+116>>2]=L[b+8>>2];L[a+120>>2]=c}function Sf(a){var b=0,c=S(0);b=fa-16|0;fa=b;L[b+12>>2]=a;c=$b(L[b+12>>2]);a=fa-16|0;P[a+12>>2]=c;fa=b+16|0;return S(_(P[a+12>>2]))}function IA(a,b){a=a|0;b=b|0;var c=0;c=L[b+252>>2];L[a>>2]=L[b+248>>2];L[a+4>>2]=c;c=L[b+260>>2];L[a+8>>2]=L[b+256>>2];L[a+12>>2]=c}function sa(a){var b=0;a=a>>>0<=1?1:a;a:{while(1){b=Yf(a);if(b){break a}b=L[8654];if(b){ha[b|0]();continue}break}aa();D()}return b}function _s(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=fa-16|0;L[a+12>>2]=L[b+12>>2];fa=b+16|0;return S(P[L[a+12>>2]+1084>>2])}function $s(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=fa-16|0;L[a+12>>2]=L[b+12>>2];fa=b+16|0;return S(P[L[a+12>>2]+1080>>2])}function uu(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=fa-16|0;L[a+12>>2]=L[b+12>>2];fa=b+16|0;return S(P[L[a+12>>2]+444>>2])}function tu(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=fa-16|0;L[a+12>>2]=L[b+12>>2];fa=b+16|0;return S(P[L[a+12>>2]+448>>2])}function ch(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=fa-16|0;L[a+12>>2]=L[b+12>>2];fa=b+16|0;return L[L[a+12>>2]+8>>2]!=0|0}function br(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=fa-16|0;L[a+12>>2]=L[b+12>>2];fa=b+16|0;return S(P[L[a+12>>2]+112>>2])}function _H(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;d=fa-16|0;fa=d;L[d+12>>2]=b;L[d+8>>2]=6356;ha[L[L[a>>2]+48>>2]](a,d+8|0,c);fa=d+16|0}function Yc(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=fa-16|0;L[a+12>>2]=L[b+12>>2];fa=b+16|0;return S(P[L[a+12>>2]+228>>2])}function Xc(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=fa-16|0;L[a+12>>2]=L[b+12>>2];fa=b+16|0;return S(P[L[a+12>>2]+224>>2])}function Wc(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=fa-16|0;L[a+12>>2]=L[b+12>>2];fa=b+16|0;return S(P[L[a+12>>2]+232>>2])}function Op(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;a=xk(L[c+12>>2],L[c+8>>2],8192);fa=c+16|0;return a|0}function Iz(a){a=a|0;if(!(J[33804]&1)){L[8449]=1065353216;L[8450]=0;L[8447]=1065353216;L[8448]=1065353216;J[33804]=1}return 33788}function wo(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=b;P[c+8>>2]=1;P[c+4>>2]=1;P[c>>2]=1;la(a,c+8|0,c+4|0,c);fa=c+16|0}function hh(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=fa-16|0;L[a+12>>2]=L[b+12>>2];fa=b+16|0;return S(P[L[a+12>>2]+12>>2])}function _c(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=fa-16|0;L[a+12>>2]=L[b+12>>2];fa=b+16|0;return L[L[a+12>>2]+204>>2]&1}function Hb(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=fa-16|0;L[a+12>>2]=L[b+12>>2];fa=b+16|0;return S(P[L[a+12>>2]+16>>2])}function yD(a,b){a=a|0;b=b|0;var c=0;c=L[b+4>>2];L[a+68>>2]=L[b>>2];L[a+72>>2]=c;c=L[b+12>>2];L[a+76>>2]=L[b+8>>2];L[a+80>>2]=c}function iE(a,b){a=a|0;b=b|0;var c=0;c=L[b+4>>2];L[a+16>>2]=L[b>>2];L[a+20>>2]=c;c=L[b+12>>2];L[a+24>>2]=L[b+8>>2];L[a+28>>2]=c}function Wd(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=fa-16|0;L[a+12>>2]=L[b+12>>2];fa=b+16|0;return S(P[L[a+12>>2]+4>>2])}function Ud(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=fa-16|0;L[a+12>>2]=L[b+12>>2];fa=b+16|0;return S(P[L[a+12>>2]+8>>2])}function Ta(a){a=a|0;var b=0,c=S(0);b=fa-16|0;fa=b;L[b+12>>2]=a;a=L[b+12>>2];c=S(ha[L[L[a>>2]+48>>2]](a));fa=b+16|0;return S(c)}function uv(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=fa-16|0;L[a+12>>2]=L[b+12>>2];fa=b+16|0;return L[L[a+12>>2]+172>>2]}function sv(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=fa-16|0;L[a+12>>2]=L[b+12>>2];fa=b+16|0;return L[L[a+12>>2]+144>>2]}function pc(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=fa-16|0;L[a+12>>2]=L[b+12>>2];fa=b+16|0;return L[L[a+12>>2]+188>>2]}function lb(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=fa-16|0;L[a+12>>2]=L[b+12>>2];fa=b+16|0;return L[L[a+12>>2]+240>>2]}function kd(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=fa-16|0;L[a+12>>2]=L[b+12>>2];fa=b+16|0;return L[L[a+12>>2]+192>>2]}function iv(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=fa-16|0;L[a+12>>2]=L[b+12>>2];fa=b+16|0;return L[L[a+12>>2]+740>>2]}function hv(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=fa-16|0;L[a+12>>2]=L[b+12>>2];fa=b+16|0;return L[L[a+12>>2]+744>>2]}function gv(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=fa-16|0;L[a+12>>2]=L[b+12>>2];fa=b+16|0;return L[L[a+12>>2]+748>>2]}function fr(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=fa-16|0;L[a+12>>2]=L[b+12>>2];fa=b+16|0;return L[L[a+12>>2]+116>>2]}function au(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=fa-16|0;L[a+12>>2]=L[b+12>>2];fa=b+16|0;return L[L[a+12>>2]+480>>2]}function Xn(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=L[L[b+12>>2]+4>>2];a=ha[L[L[a>>2]+88>>2]](a)|0;fa=b+16|0;return a|0}function Sq(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=fa-16|0;L[a+12>>2]=L[b+12>>2];fa=b+16|0;return L[L[a+12>>2]+120>>2]}function Sc(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=fa-16|0;L[a+12>>2]=L[b+12>>2];fa=b+16|0;return L[L[a+12>>2]+204>>2]}function Rt(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=fa-16|0;L[a+12>>2]=L[b+12>>2];fa=b+16|0;return L[L[a+12>>2]+504>>2]}function Rq(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=fa-16|0;L[a+12>>2]=L[b+12>>2];fa=b+16|0;return L[L[a+12>>2]+124>>2]}function Qq(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=fa-16|0;L[a+12>>2]=L[b+12>>2];fa=b+16|0;return L[L[a+12>>2]+128>>2]}function Bx(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=fa-16|0;L[a+12>>2]=L[b+12>>2];fa=b+16|0;return+P[L[a+12>>2]+120>>2]}function ye(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=fa-16|0;L[a+12>>2]=L[b+12>>2];fa=b+16|0;return L[L[a+12>>2]+68>>2]}function _d(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=fa-16|0;L[a+12>>2]=L[b+12>>2];fa=b+16|0;return L[L[a+12>>2]+24>>2]}function Xd(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=fa-16|0;L[a+12>>2]=L[b+12>>2];fa=b+16|0;return S(P[L[a+12>>2]>>2])}function Se(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=fa-16|0;L[a+12>>2]=L[b+12>>2];fa=b+16|0;return L[L[a+12>>2]+52>>2]}function Pv(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=fa-16|0;L[a+12>>2]=L[b+12>>2];fa=b+16|0;return L[L[a+12>>2]+40>>2]}function Oq(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=fa-16|0;L[a+12>>2]=L[b+12>>2];fa=b+16|0;return L[L[a+12>>2]+84>>2]}function Mx(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=fa-16|0;L[a+12>>2]=L[b+12>>2];fa=b+16|0;return L[L[a+12>>2]+12>>2]}function Kq(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=fa-16|0;L[a+12>>2]=L[b+12>>2];fa=b+16|0;return L[L[a+12>>2]+88>>2]}function Iy(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;if(Wa(a,L[b+8>>2],0)){Xf(b,c,d);return}a=L[a+8>>2];ha[L[L[a>>2]+28>>2]](a,b,c,d)}function Ax(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=fa-16|0;L[a+12>>2]=L[b+12>>2];fa=b+16|0;return+P[L[a+12>>2]+80>>2]}function pn(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;a=hb(L[c+12>>2],L[c+8>>2]);fa=c+16|0;return a|0}function dv(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=L[b+12>>2];a=ha[L[L[a>>2]+36>>2]](a)|0;fa=b+16|0;return S(S(a|0))}function Ya(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=fa-16|0;L[a+12>>2]=L[b+12>>2];fa=b+16|0;return L[L[a+12>>2]+4>>2]}function Lx(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=fa-16|0;L[a+12>>2]=L[b+12>>2];fa=b+16|0;return L[L[a+12>>2]+8>>2]}function rp(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=fa-16|0;L[a+12>>2]=L[b+12>>2];fa=b+16|0;return L[a+12>>2]+352|0}function qu(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=fa-16|0;L[a+12>>2]=L[b+12>>2];fa=b+16|0;return L[a+12>>2]+348|0}function qp(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=fa-16|0;L[a+12>>2]=L[b+12>>2];fa=b+16|0;return L[a+12>>2]+324|0}function oa(a){var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=L[b+12>>2];L[8513]=L[8513]+1;a=ha[L[6798]](a,16)|0;fa=b+16|0;return a}function eu(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=fa-16|0;L[a+12>>2]=L[b+12>>2];fa=b+16|0;return L[a+12>>2]+312|0}function du(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=fa-16|0;L[a+12>>2]=L[b+12>>2];fa=b+16|0;return L[a+12>>2]+328|0}function cj(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=fa-16|0;L[a+12>>2]=L[b+12>>2];fa=b+16|0;return L[a+12>>2]+144|0}function _t(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=fa-16|0;L[a+12>>2]=L[b+12>>2];fa=b+16|0;return L[a+12>>2]+544|0}function Vt(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=fa-16|0;L[a+12>>2]=L[b+12>>2];fa=b+16|0;return L[a+12>>2]+380|0}function Lt(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=fa-16|0;L[a+12>>2]=L[b+12>>2];fa=b+16|0;return L[a+12>>2]+300|0}function Kt(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=fa-16|0;L[a+12>>2]=L[b+12>>2];fa=b+16|0;return L[a+12>>2]+316|0}function xf(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=fa-16|0;L[a+12>>2]=L[b+12>>2];fa=b+16|0;return L[a+12>>2]+92|0}function sn(a,b){a=a|0;b=S(b);var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;P[c+8>>2]=b;a=mh(L[c+12>>2],c+8|0);fa=c+16|0;return a|0}function ow(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=fa-16|0;L[a+12>>2]=L[b+12>>2];fa=b+16|0;return L[a+12>>2]+20|0}function oe(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=fa-16|0;L[a+12>>2]=L[b+12>>2];fa=b+16|0;return L[a+12>>2]+48|0}function fy(a,b){a=a|0;b=S(b);var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;P[c+8>>2]=b;a=zj(L[c+12>>2],c+8|0);fa=c+16|0;return a|0}function dy(a,b){a=a|0;b=S(b);var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;P[c+8>>2]=b;a=Aj(L[c+12>>2],c+8|0);fa=c+16|0;return a|0}function Cx(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=fa-16|0;L[a+12>>2]=L[b+12>>2];fa=b+16|0;return L[a+12>>2]+32|0}function $e(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=fa-16|0;L[a+12>>2]=L[b+12>>2];fa=b+16|0;return L[a+12>>2]+28|0}function qc(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=fa-16|0;L[a+12>>2]=L[b+12>>2];fa=b+16|0;return L[a+12>>2]+4|0}function nw(){var a=0;a=oa(32);L[a+12>>2]=0;L[a+4>>2]=35;L[a+8>>2]=0;L[a>>2]=13384;L[a+4>>2]=27;L[a>>2]=15100;return a|0}function Zw(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;L[c+12>>2]=a;L[c+8>>2]=b;return S(P[(L[c+12>>2]+20|0)+(L[c+8>>2]<<2)>>2])}function TC(a,b){a=a|0;b=b|0;var c=0,d=0;c=L[a+4>>2];d=L[c>>2];ha[L[L[d>>2]+108>>2]](d,b,c+108|0);return L[a+4>>2]+108|0}function vl(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=L[b+12>>2];a=ha[L[L[a>>2]+84>>2]](a)|0;fa=b+16|0;return a|0} -function fc(a,b){var c=0;Fd(a,b);c=L[a+4>>2];if(c){L[8514]=L[8514]+1;ha[L[6799]](c)}L[a+4>>2]=b;L[a+12>>2]=L[a+12>>2]-1}function Ee(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=L[b+12>>2];a=ha[L[L[a>>2]+100>>2]](a)&1;fa=b+16|0;return a|0}function ya(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=L[b+12>>2];a=ha[L[L[a>>2]+28>>2]](a)|0;fa=b+16|0;return a|0}function wr(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=L[b+12>>2];a=ha[L[L[a>>2]+40>>2]](a)&1;fa=b+16|0;return a|0}function td(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=L[b+12>>2];a=ha[L[L[a>>2]+36>>2]](a)|0;fa=b+16|0;return a|0}function rl(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=L[b+12>>2];a=ha[L[L[a>>2]+88>>2]](a)|0;fa=b+16|0;return a|0}function ql(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=L[b+12>>2];a=ha[L[L[a>>2]+92>>2]](a)&1;fa=b+16|0;return a|0}function pv(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=L[b+12>>2];a=ha[L[L[a>>2]+52>>2]](a)|0;fa=b+16|0;return a|0}function or(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=L[b+12>>2];a=ha[L[L[a>>2]+48>>2]](a)&1;fa=b+16|0;return a|0}function he(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=L[b+12>>2];a=ha[L[L[a>>2]+20>>2]](a)|0;fa=b+16|0;return a|0}function fi(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=L[b+12>>2];a=ha[L[L[a>>2]+48>>2]](a)|0;fa=b+16|0;return a|0}function Tl(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=L[b+12>>2];a=ha[L[L[a>>2]+12>>2]](a)|0;fa=b+16|0;return a|0}function Od(a){var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=L[b+12>>2];L[(fa-16|0)+12>>2]=a;L[(fa-16|0)+12>>2]=a+16;fa=b+16|0}function Mw(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=L[b+12>>2];a=ha[L[L[a>>2]+96>>2]](a)|0;fa=b+16|0;return a|0}function Le(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=L[b+12>>2];a=ha[L[L[a>>2]+76>>2]](a)|0;fa=b+16|0;return a|0}function Hn(a){a=a|0;var b=0;L[a>>2]=5584;b=L[a+16>>2];if(!(b?!b|!M[a+20|0]:1)){L[8514]=L[8514]+1;ha[L[6799]](b)}ra(a)}function Fe(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=L[b+12>>2];a=ha[L[L[a>>2]+96>>2]](a)&1;fa=b+16|0;return a|0}function Dl(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=L[b+12>>2];a=ha[L[L[a>>2]+80>>2]](a)|0;fa=b+16|0;return a|0}function zr(a,b){a=a|0;b=S(b);var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;P[c+8>>2]=b;P[L[c+12>>2]+24>>2]=P[c+8>>2];fa=c+16|0}function yr(a,b){a=a|0;b=S(b);var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;P[c+8>>2]=b;P[L[c+12>>2]+28>>2]=P[c+8>>2];fa=c+16|0}function xr(a,b){a=a|0;b=S(b);var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;P[c+8>>2]=b;P[L[c+12>>2]+32>>2]=P[c+8>>2];fa=c+16|0}function ur(a,b){a=a|0;b=S(b);var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;P[c+8>>2]=b;P[L[c+12>>2]+44>>2]=P[c+8>>2];fa=c+16|0}function id(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;L[L[c+12>>2]+216>>2]=L[c+8>>2];fa=c+16|0}function Jg(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=L[b+12>>2];a=ha[L[L[a>>2]+8>>2]](a)&1;fa=b+16|0;return a|0}function HG(a,b){a=a|0;b=b|0;var c=0,d=0;c=a;d=L[L[L[a+4>>2]+4>>2]+24>>2];a=L[b+36>>2];an(c,L[(d+R(a,80)|0)+64>>2],a)}function Ap(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;sc(L[c+12>>2]+868|0,L[c+8>>2]);fa=c+16|0}function vq(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;qg(L[c+12>>2]+28|0,L[c+8>>2]);fa=c+16|0}function Xr(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;sb(L[c+12>>2]+92|0,L[c+8>>2]);fa=c+16|0}function Vx(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=fa-16|0;L[a+12>>2]=L[b+12>>2];fa=b+16|0;return L[a+12>>2]}function UC(a,b){a=a|0;b=b|0;var c=0,d=0;c=L[a+4>>2];d=L[c>>2];ha[L[L[d>>2]+104>>2]](d,b,c+4|0);return L[a+4>>2]+4|0}function Hx(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;sc(L[c+12>>2]+20|0,L[c+8>>2]);fa=c+16|0}function Gx(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;Kf(L[c+12>>2]+72|0,L[c+8>>2]);fa=c+16|0}function Fx(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;Kf(L[c+12>>2]+92|0,L[c+8>>2]);fa=c+16|0}function Dq(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;L[c+12>>2]=a;L[c+8>>2]=b;return L[(L[c+12>>2]+8|0)+(L[c+8>>2]<<2)>>2]}function wf(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;vf(L[c+12>>2],L[c+8>>2],0,0);fa=c+16|0}function Tw(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;Kf(L[c+12>>2]+4|0,L[c+8>>2]);fa=c+16|0}function Nx(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;sb(L[c+12>>2]+4|0,L[c+8>>2]);fa=c+16|0}function $f(a){var b=0;while(1){L[a+4>>2]=0;L[a+8>>2]=0;b=L[a+24>>2];if(b){$f(b)}a=L[a+28>>2];if(a){continue}break}}function az(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;a=L[b+8>>2];b=L[a+284>>2];ha[L[L[b>>2]+40>>2]](b,a,L[c+8>>2])}function _r(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;qa(L[c+12>>2],L[c+8>>2],92);fa=c+16|0}function bd(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;J[c+11|0]=b;ib(L[c+12>>2],J[c+11|0]&1);fa=c+16|0}function Xq(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;lg(L[c+12>>2],L[c+8>>2],1);fa=c+16|0}function Ow(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;tm(L[c+12>>2],L[c+8>>2],1);fa=c+16|0}function Fc(a){var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=L[b+12>>2];if(a){L[8514]=L[8514]+1;ha[L[6799]](a)}fa=b+16|0}function wu(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;Gk(L[c+12>>2],L[c+8>>2]);fa=c+16|0}function rq(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;ki(L[c+12>>2],L[c+8>>2]);fa=c+16|0}function qt(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;ol(L[c+12>>2],L[c+8>>2]);fa=c+16|0}function pw(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;Qe(L[c+12>>2],L[c+8>>2]);fa=c+16|0}function nu(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;Wi(L[c+12>>2],L[c+8>>2]);fa=c+16|0}function ku(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;Vi(L[c+12>>2],L[c+8>>2]);fa=c+16|0}function je(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;rn(L[c+12>>2],L[c+8>>2]);fa=c+16|0}function iu(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;Ui(L[c+12>>2],L[c+8>>2]);fa=c+16|0}function gu(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;Ti(L[c+12>>2],L[c+8>>2]);fa=c+16|0}function by(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;Ma(L[c+12>>2],L[c+8>>2]);fa=c+16|0}function _w(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;sc(L[c+12>>2],L[c+8>>2]);fa=c+16|0}function Yx(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;Rf(L[c+12>>2],L[c+8>>2]);fa=c+16|0}function Ut(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;te(L[c+12>>2],L[c+8>>2]);fa=c+16|0}function Sp(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;fa=c;L[c+12>>2]=a;L[c+8>>2]=b;jg(L[c+12>>2],L[c+8>>2]);fa=c+16|0}function Ka(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=L[b+12>>2];L[(fa-16|0)+12>>2]=a;fa=b+16|0;return a|0}function Bh(a){var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=fa-16|0;L[a+12>>2]=L[b+12>>2];L[L[a+12>>2]>>2]=0;fa=b+16|0}function ym(a,b){a=a|0;b=b|0;L[a>>2]=0;L[a+4>>2]=0;L[a+8>>2]=0;L[a+12>>2]=0;L[a+(L[b+52>>2]<<2)>>2]=1065353216}function Qy(a,b){a=a|0;b=b|0;var c=0;a=ha[L[6800]]((a+b|0)+3|0)|0;if(a){c=(a+b|0)+3&0-b;L[c-4>>2]=a}return c|0}function ef(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0;e=fa-16|0;L[e+12>>2]=a;L[e+8>>2]=b;L[e+4>>2]=c;L[e>>2]=d}function Yl(a,b,c,d,e){var f=0;f=L[a+32>>2];L[f>>2]=L[f>>2]+1;Qe(a,Pe(a,b,e));Qe(a,Pe(a,c,e));Qe(a,Pe(a,d,e))}function Px(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=oa(200);Pf(a,L[b+12>>2],$a());fa=b+16|0;return a|0}function ma(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=L[b+12>>2];if(a){ha[L[L[a>>2]+4>>2]](a)}fa=b+16|0}function Lc(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=L[b+12>>2];if(a){ha[L[L[a>>2]+8>>2]](a)}fa=b+16|0}function Zd(a){var b=0;b=fa-16|0;L[b+12>>2]=a;a=L[b+12>>2];J[a+16|0]=1;L[a+12>>2]=0;L[a+4>>2]=0;L[a+8>>2]=0}function uw(a){a=a|0;var b=0;b=fa-16|0;fa=b;J[b+15|0]=a;a=oa(172);Kg(a,J[b+15|0]&1,1);fa=b+16|0;return a|0}function Qw(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=oa(112);We(a,L[b+12>>2],0);fa=b+16|0;return a|0}function oz(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;a=L[b>>2];return lk(ha[L[L[a>>2]+56>>2]](a,156)|0,b,c,d,0)|0}function nz(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;a=L[b>>2];return lk(ha[L[L[a>>2]+56>>2]](a,156)|0,b,c,d,1)|0}function jx(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=oa(96);pm(a,L[b+12>>2],1);fa=b+16|0;return a|0}function wp(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=sa(112);ik(a,L[b+12>>2]);fa=b+16|0;return a|0}function wG(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;a=L[b>>2];return gn(ha[L[L[a>>2]+56>>2]](a,80)|0,b,c,d,0)|0}function vG(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;a=L[b>>2];return gn(ha[L[L[a>>2]+56>>2]](a,80)|0,b,c,d,1)|0}function uG(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;a=L[b>>2];return dn(ha[L[L[a>>2]+56>>2]](a,44)|0,b,c,d,0)|0}function sG(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;a=L[b>>2];return dn(ha[L[L[a>>2]+56>>2]](a,44)|0,b,c,d,1)|0}function Yv(a){a=a|0;var b=0;b=fa-16|0;fa=b;J[b+15|0]=a;a=oa(192);dj(a,J[b+15|0]&1);fa=b+16|0;return a|0}function yu(a,b){a=a|0;b=S(b);var c=0;c=fa-16|0;L[c+12>>2]=a;P[c+8>>2]=b;P[L[c+12>>2]+136>>2]=P[c+8>>2]}function xa(a,b,c){var d=0;d=fa-16|0;fa=d;L[d+12>>2]=b;L[d+8>>2]=c;tb(a,L[d+12>>2],L[d+8>>2]);fa=d+16|0}function vr(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=L[b+12>>2];ha[L[L[a>>2]+44>>2]](a);fa=b+16|0}function us(a,b){a=a|0;b=S(b);var c=0;c=fa-16|0;L[c+12>>2]=a;P[c+8>>2]=b;P[L[c+12>>2]+216>>2]=P[c+8>>2]}function ts(a,b){a=a|0;b=S(b);var c=0;c=fa-16|0;L[c+12>>2]=a;P[c+8>>2]=b;P[L[c+12>>2]+228>>2]=P[c+8>>2]}function rs(a,b){a=a|0;b=S(b);var c=0;c=fa-16|0;L[c+12>>2]=a;P[c+8>>2]=b;P[L[c+12>>2]+252>>2]=P[c+8>>2]}function rD(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=oa(56);Sg(a,L[b+12>>2]);fa=b+16|0;return a|0}function ps(a,b){a=a|0;b=S(b);var c=0;c=fa-16|0;L[c+12>>2]=a;P[c+8>>2]=b;P[L[c+12>>2]+244>>2]=P[c+8>>2]}function oA(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=sa(92);gh(a,L[b+12>>2]);fa=b+16|0;return a|0}function ns(a,b){a=a|0;b=S(b);var c=0;c=fa-16|0;L[c+12>>2]=a;P[c+8>>2]=b;P[L[c+12>>2]+204>>2]=P[c+8>>2]}function ls(a,b){a=a|0;b=S(b);var c=0;c=fa-16|0;L[c+12>>2]=a;P[c+8>>2]=b;P[L[c+12>>2]+212>>2]=P[c+8>>2]}function js(a,b){a=a|0;b=S(b);var c=0;c=fa-16|0;L[c+12>>2]=a;P[c+8>>2]=b;P[L[c+12>>2]+220>>2]=P[c+8>>2]}function is(a,b){a=a|0;b=S(b);var c=0;c=fa-16|0;L[c+12>>2]=a;P[c+8>>2]=b;P[L[c+12>>2]+224>>2]=P[c+8>>2]}function im(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;L[c+12>>2]=a;K[c+10>>1]=b;K[L[c+12>>2]+10>>1]=N[c+10>>1]}function hs(a,b){a=a|0;b=S(b);var c=0;c=fa-16|0;L[c+12>>2]=a;P[c+8>>2]=b;P[L[c+12>>2]+232>>2]=P[c+8>>2]}function ge(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=L[b+12>>2];ha[L[L[a>>2]+24>>2]](a);fa=b+16|0}function fs(a,b){a=a|0;b=S(b);var c=0;c=fa-16|0;L[c+12>>2]=a;P[c+8>>2]=b;P[L[c+12>>2]+248>>2]=P[c+8>>2]}function ds(a,b){a=a|0;b=S(b);var c=0;c=fa-16|0;L[c+12>>2]=a;P[c+8>>2]=b;P[L[c+12>>2]+208>>2]=P[c+8>>2]}function bs(a,b){a=a|0;b=S(b);var c=0;c=fa-16|0;L[c+12>>2]=a;P[c+8>>2]=b;P[L[c+12>>2]+276>>2]=P[c+8>>2]}function Zg(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;L[c+12>>2]=a;K[c+10>>1]=b;K[L[c+12>>2]+12>>1]=N[c+10>>1]}function Xb(a,b,c){var d=0;d=fa-16|0;fa=d;L[d+12>>2]=b;L[d+8>>2]=c;Ga(a,L[d+8>>2],L[d+12>>2]);fa=d+16|0}function Vg(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;L[c+12>>2]=a;K[c+10>>1]=b;K[L[c+12>>2]+14>>1]=N[c+10>>1]}function Rr(a,b){a=a|0;b=S(b);var c=0;c=fa-16|0;L[c+12>>2]=a;P[c+8>>2]=b;P[L[c+12>>2]+236>>2]=P[c+8>>2]}function Qu(a,b){a=a|0;b=S(b);var c=0;c=fa-16|0;L[c+12>>2]=a;P[c+8>>2]=b;P[L[c+12>>2]+100>>2]=P[c+8>>2]}function Pr(a,b){a=a|0;b=S(b);var c=0;c=fa-16|0;L[c+12>>2]=a;P[c+8>>2]=b;P[L[c+12>>2]+240>>2]=P[c+8>>2]}function Pb(a){var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=L[b+12>>2];$k(a);L[(fa-16|0)+12>>2]=a+48;fa=b+16|0}function Ou(a,b){a=a|0;b=S(b);var c=0;c=fa-16|0;L[c+12>>2]=a;P[c+8>>2]=b;P[L[c+12>>2]+104>>2]=P[c+8>>2]}function Nr(a,b){a=a|0;b=S(b);var c=0;c=fa-16|0;L[c+12>>2]=a;P[c+8>>2]=b;P[L[c+12>>2]+256>>2]=P[c+8>>2]}function Mu(a,b){a=a|0;b=S(b);var c=0;c=fa-16|0;L[c+12>>2]=a;P[c+8>>2]=b;P[L[c+12>>2]+108>>2]=P[c+8>>2]}function Me(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=L[b+12>>2];ha[L[L[a>>2]+72>>2]](a);fa=b+16|0}function Lr(a,b){a=a|0;b=S(b);var c=0;c=fa-16|0;L[c+12>>2]=a;P[c+8>>2]=b;P[L[c+12>>2]+268>>2]=P[c+8>>2]}function Ku(a,b){a=a|0;b=S(b);var c=0;c=fa-16|0;L[c+12>>2]=a;P[c+8>>2]=b;P[L[c+12>>2]+112>>2]=P[c+8>>2]}function Jr(a,b){a=a|0;b=S(b);var c=0;c=fa-16|0;L[c+12>>2]=a;P[c+8>>2]=b;P[L[c+12>>2]+272>>2]=P[c+8>>2]}function Iu(a,b){a=a|0;b=S(b);var c=0;c=fa-16|0;L[c+12>>2]=a;P[c+8>>2]=b;P[L[c+12>>2]+116>>2]=P[c+8>>2]}function Hs(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;L[c+12>>2]=a;J[c+11|0]=b;L[L[c+12>>2]+44>>2]=J[c+11|0]&1}function Hr(a,b){a=a|0;b=S(b);var c=0;c=fa-16|0;L[c+12>>2]=a;P[c+8>>2]=b;P[L[c+12>>2]+280>>2]=P[c+8>>2]}function Gu(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;L[c+12>>2]=a;J[c+11|0]=b;J[L[c+12>>2]+120|0]=J[c+11|0]&1}function Eu(a,b){a=a|0;b=S(b);var c=0;c=fa-16|0;L[c+12>>2]=a;P[c+8>>2]=b;P[L[c+12>>2]+124>>2]=P[c+8>>2]}function Dw(a){a=a|0;var b=0;b=fa-16|0;fa=b;J[b+15|0]=a;a=oa(92);wm(a,J[b+15|0]&1);fa=b+16|0;return a|0}function Cu(a,b){a=a|0;b=S(b);var c=0;c=fa-16|0;L[c+12>>2]=a;P[c+8>>2]=b;P[L[c+12>>2]+128>>2]=P[c+8>>2]}function Au(a,b){a=a|0;b=S(b);var c=0;c=fa-16|0;L[c+12>>2]=a;P[c+8>>2]=b;P[L[c+12>>2]+132>>2]=P[c+8>>2]}function $r(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;L[c+12>>2]=a;J[c+11|0]=b;J[L[c+12>>2]+260|0]=J[c+11|0]&1}function zs(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;L[c+12>>2]=a;J[c+11|0]=b;J[L[c+12>>2]+80|0]=J[c+11|0]&1}function zf(a,b){a=a|0;b=S(b);var c=0;c=fa-16|0;L[c+12>>2]=a;P[c+8>>2]=b;P[L[c+12>>2]+32>>2]=P[c+8>>2]}function yq(a,b){a=a|0;b=S(b);var c=0;c=fa-16|0;L[c+12>>2]=a;P[c+8>>2]=b;P[L[c+12>>2]+88>>2]=P[c+8>>2]}function yi(a,b){a=a|0;b=S(b);var c=0;c=fa-16|0;L[c+12>>2]=a;P[c+8>>2]=b;P[L[c+12>>2]+64>>2]=P[c+8>>2]}function wi(a,b){a=a|0;b=S(b);var c=0;c=fa-16|0;L[c+12>>2]=a;P[c+8>>2]=b;P[L[c+12>>2]+68>>2]=P[c+8>>2]}function vx(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;L[c+12>>2]=a;L[c+8>>2]=b;L[L[c+12>>2]+112>>2]=L[c+8>>2]}function ui(a,b){a=a|0;b=S(b);var c=0;c=fa-16|0;L[c+12>>2]=a;P[c+8>>2]=b;P[L[c+12>>2]+72>>2]=P[c+8>>2]}function si(a,b){a=a|0;b=S(b);var c=0;c=fa-16|0;L[c+12>>2]=a;P[c+8>>2]=b;P[L[c+12>>2]+76>>2]=P[c+8>>2]}function ry(a){a=a|0;var b=0,c=S(0);b=fa-16|0;fa=b;L[b+12>>2]=a;c=$b(L[b+12>>2]);fa=b+16|0;return S(c)}function qy(a){a=a|0;var b=0,c=S(0);b=fa-16|0;fa=b;L[b+12>>2]=a;c=Sf(L[b+12>>2]);fa=b+16|0;return S(c)}function pq(a,b){a=a|0;b=S(b);var c=0;c=fa-16|0;L[c+12>>2]=a;P[c+8>>2]=b;P[L[c+12>>2]+80>>2]=P[c+8>>2]}function ov(){var a=0,b=0;b=sa(8);a=fa-16|0;L[a+12>>2]=b;a=L[a+12>>2];L[a>>2]=0;L[a+4>>2]=0;return b|0}function ni(a,b){a=a|0;b=S(b);var c=0;c=fa-16|0;L[c+12>>2]=a;P[c+8>>2]=b;P[L[c+12>>2]+24>>2]=P[c+8>>2]}function mm(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;L[c+12>>2]=a;K[c+10>>1]=b;K[L[c+12>>2]+8>>1]=N[c+10>>1]}function iq(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;L[c+12>>2]=a;L[c+8>>2]=b;L[L[c+12>>2]+100>>2]=L[c+8>>2]}function hj(a,b){a=a|0;b=S(b);var c=0;c=fa-16|0;L[c+12>>2]=a;P[c+8>>2]=b;P[L[c+12>>2]+40>>2]=P[c+8>>2]}function hi(a,b){a=a|0;b=S(b);var c=0;c=fa-16|0;L[c+12>>2]=a;P[c+8>>2]=b;P[L[c+12>>2]+44>>2]=P[c+8>>2]}function di(a){a=a|0;var b=0,c=S(0);b=fa-16|0;fa=b;L[b+12>>2]=a;c=nf(L[b+12>>2]);fa=b+16|0;return S(c)}function Su(a,b){a=a|0;b=S(b);var c=0;c=fa-16|0;L[c+12>>2]=a;P[c+8>>2]=b;P[L[c+12>>2]+96>>2]=P[c+8>>2]}function Rs(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;L[c+12>>2]=a;J[c+11|0]=b;J[L[c+12>>2]+16|0]=J[c+11|0]&1}function Qi(a,b){a=a|0;b=S(b);var c=0;c=fa-16|0;L[c+12>>2]=a;P[c+8>>2]=b;P[L[c+12>>2]+28>>2]=P[c+8>>2]}function Ps(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;L[c+12>>2]=a;J[c+11|0]=b;J[L[c+12>>2]+24|0]=J[c+11|0]&1}function Ns(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;L[c+12>>2]=a;J[c+11|0]=b;J[L[c+12>>2]+25|0]=J[c+11|0]&1}function Mi(a,b){a=a|0;b=S(b);var c=0;c=fa-16|0;L[c+12>>2]=a;P[c+8>>2]=b;P[L[c+12>>2]+16>>2]=P[c+8>>2]}function Ls(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;L[c+12>>2]=a;J[c+11|0]=b;J[L[c+12>>2]+26|0]=J[c+11|0]&1}function Ki(a,b){a=a|0;b=S(b);var c=0;c=fa-16|0;L[c+12>>2]=a;P[c+8>>2]=b;P[L[c+12>>2]+20>>2]=P[c+8>>2]}function Kc(a,b){a=a|0;b=S(b);var c=0;c=fa-16|0;L[c+12>>2]=a;P[c+8>>2]=b;P[L[c+12>>2]+12>>2]=P[c+8>>2]}function Js(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;L[c+12>>2]=a;J[c+11|0]=b;J[L[c+12>>2]+32|0]=J[c+11|0]&1}function Gi(a,b){a=a|0;b=S(b);var c=0;c=fa-16|0;L[c+12>>2]=a;P[c+8>>2]=b;P[L[c+12>>2]+48>>2]=P[c+8>>2]}function Ei(a,b){a=a|0;b=S(b);var c=0;c=fa-16|0;L[c+12>>2]=a;P[c+8>>2]=b;P[L[c+12>>2]+52>>2]=P[c+8>>2]}function Ef(a,b){a=a|0;b=S(b);var c=0;c=fa-16|0;L[c+12>>2]=a;P[c+8>>2]=b;P[L[c+12>>2]+92>>2]=P[c+8>>2]}function Ci(a,b){a=a|0;b=S(b);var c=0;c=fa-16|0;L[c+12>>2]=a;P[c+8>>2]=b;P[L[c+12>>2]+56>>2]=P[c+8>>2]}function Bs(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;L[c+12>>2]=a;J[c+11|0]=b;J[L[c+12>>2]+84|0]=J[c+11|0]&1}function Bf(a,b){a=a|0;b=S(b);var c=0;c=fa-16|0;L[c+12>>2]=a;P[c+8>>2]=b;P[L[c+12>>2]+36>>2]=P[c+8>>2]}function Ai(a,b){a=a|0;b=S(b);var c=0;c=fa-16|0;L[c+12>>2]=a;P[c+8>>2]=b;P[L[c+12>>2]+60>>2]=P[c+8>>2]}function yv(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;L[c+12>>2]=a;L[c+8>>2]=b;L[L[c+12>>2]+64>>2]=L[c+8>>2]}function qx(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;L[c+12>>2]=a;L[c+8>>2]=b;L[L[c+12>>2]+76>>2]=L[c+8>>2]}function oq(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;L[c+12>>2]=a;L[c+8>>2]=b;L[L[c+12>>2]+84>>2]=L[c+8>>2]}function mq(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;L[c+12>>2]=a;L[c+8>>2]=b;L[L[c+12>>2]+92>>2]=L[c+8>>2]}function kq(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;L[c+12>>2]=a;L[c+8>>2]=b;L[L[c+12>>2]+96>>2]=L[c+8>>2]}function eb(a,b){a=a|0;b=S(b);var c=0;c=fa-16|0;L[c+12>>2]=a;P[c+8>>2]=b;P[L[c+12>>2]+4>>2]=P[c+8>>2]}function _i(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;L[c+12>>2]=a;L[c+8>>2]=b;L[L[c+12>>2]+32>>2]=L[c+8>>2]}function Ve(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;L[c+12>>2]=a;L[c+8>>2]=b;L[L[c+12>>2]+16>>2]=L[c+8>>2]}function Ni(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;L[c+12>>2]=a;L[c+8>>2]=b;L[L[c+12>>2]+20>>2]=L[c+8>>2]}function Nc(a,b){a=a|0;b=S(b);var c=0;c=fa-16|0;L[c+12>>2]=a;P[c+8>>2]=b;P[L[c+12>>2]+8>>2]=P[c+8>>2]}function Jv(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;L[c+12>>2]=a;L[c+8>>2]=b;L[L[c+12>>2]+28>>2]=L[c+8>>2]}function Ii(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;L[c+12>>2]=a;L[c+8>>2]=b;L[L[c+12>>2]+88>>2]=L[c+8>>2]}function Hv(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;L[c+12>>2]=a;L[c+8>>2]=b;L[L[c+12>>2]+40>>2]=L[c+8>>2]}function Fv(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;L[c+12>>2]=a;L[c+8>>2]=b;L[L[c+12>>2]+44>>2]=L[c+8>>2]}function Fs(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;L[c+12>>2]=a;L[c+8>>2]=b;P[L[c+12>>2]+48>>2]=L[c+8>>2]}function Fq(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;L[c+12>>2]=a;L[c+8>>2]=b;L[L[c+12>>2]+36>>2]=L[c+8>>2]}function Dv(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;L[c+12>>2]=a;L[c+8>>2]=b;L[L[c+12>>2]+48>>2]=L[c+8>>2]}function Bv(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;L[c+12>>2]=a;L[c+8>>2]=b;L[L[c+12>>2]+56>>2]=L[c+8>>2]}function Av(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;L[c+12>>2]=a;L[c+8>>2]=b;L[L[c+12>>2]+60>>2]=L[c+8>>2]}function xd(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;L[c+12>>2]=a;L[c+8>>2]=b;L[L[c+12>>2]+8>>2]=L[c+8>>2]}function cd(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;L[c+12>>2]=a;L[c+8>>2]=b;L[L[c+12>>2]+4>>2]=L[c+8>>2]}function Yu(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;L[c+12>>2]=a;L[c+8>>2]=b;K[L[c+12>>2]+4>>1]=L[c+8>>2]}function Wu(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;L[c+12>>2]=a;L[c+8>>2]=b;K[L[c+12>>2]+6>>1]=L[c+8>>2]}function Mb(a){var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=L[b+12>>2];L[(fa-16|0)+12>>2]=a;Zd(a);fa=b+16|0}function ae(a,b){a=a|0;b=S(b);var c=0;c=fa-16|0;L[c+12>>2]=a;P[c+8>>2]=b;P[L[c+12>>2]>>2]=P[c+8>>2]}function $b(a){var b=0,c=S(0);b=fa-16|0;fa=b;L[b+12>>2]=a;a=L[b+12>>2];c=_b(a,a);fa=b+16|0;return c}function ed(a,b){a=a|0;b=b|0;var c=0;c=fa-16|0;L[c+12>>2]=a;L[c+8>>2]=b;L[L[c+12>>2]>>2]=L[c+8>>2]}function ar(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;fa=b+16|0;return L[L[b+12>>2]+116>>2]+4|0}function Kp(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;fa=b+16|0;return S(P[L[b+12>>2]+1228>>2])}function xs(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;fa=b+16|0;return S(P[L[b+12>>2]+204>>2])}function xp(){var a=0,b=0,c=0;a=fa-32|0;fa=a;b=sa(112);c=a+8|0;og(c);ik(b,c);fa=a+32|0;return b|0}function nb(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=L[b+12>>2];if(a){mb(a);ra(a)}fa=b+16|0}function Xw(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=L[b+12>>2];if(a){rc(a);ra(a)}fa=b+16|0}function tr(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;fa=b+16|0;return S(P[L[b+12>>2]+44>>2])}function rr(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;fa=b+16|0;return S(P[L[b+12>>2]+36>>2])}function jf(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=L[b+12>>2];hf(a);fa=b+16|0;return a|0}function hf(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=L[b+12>>2];Oa(a);fa=b+16|0;return a|0}function Sk(a,b){a=a|0;b=b|0;if(!(!b|!(L[b+236>>2]&2))){ha[L[L[a>>2]+92>>2]](a,b);return}Bd(a,b)}function Oh(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=L[b+12>>2];jf(a);fa=b+16|0;return a|0}function CA(){var a=0,b=0,c=0;a=fa-32|0;fa=a;b=sa(92);c=a+8|0;og(c);gh(b,c);fa=a+32|0;return b|0}function By(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;if(Wa(a,L[b+8>>2],f)){Wf(b,c,d,e)}}function dq(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=Bk(L[b+12>>2]);fa=b+16|0;return a|0}function qr(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;fa=b+16|0;return L[L[b+12>>2]+8>>2]}function Hw(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;fa=b+16|0;return L[L[b+12>>2]+4>>2]}function tD(a){a=a|0;a=L[a+92>>2]-2|0;if(a>>>0<=2){a=L[(a<<2)+16592>>2]}else{a=0}return a|0}function ko(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=L[b+12>>2];hf(a);Fc(a);fa=b+16|0}function jz(a,b){a=a|0;b=S(b);Nk(a,b);wa(2370);a=L[a+452>>2];ha[L[L[a>>2]+24>>2]](a,b);va()}function io(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=L[b+12>>2];Oh(a);Fc(a);fa=b+16|0}function ff(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;d=fa-16|0;L[d+12>>2]=a;L[d+8>>2]=b;L[d+4>>2]=c}function VB(a,b,c){a=a|0;b=b|0;c=S(c);ha[L[L[a>>2]+32>>2]](a,b);ha[L[L[a>>2]+36>>2]](a,b,c)}function Lo(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=L[b+12>>2];Ka(a);Fc(a);fa=b+16|0}function Go(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=L[b+12>>2];$h(a);ra(a);fa=b+16|0}function Da(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=L[b+12>>2];if(a){ra(a)}fa=b+16|0}function DH(a,b){a=a|0;b=b|0;var c=0;c=b;b=L[a+8>>2];ha[L[b+60>>2]](c,b,L[a+4>>2]);return 0}function Cb(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=L[b+12>>2];Ka(a);ra(a);fa=b+16|0}function Ao(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=L[b+12>>2];jf(a);Fc(a);fa=b+16|0}function Ad(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;a=L[b+12>>2];if(a){Fc(a)}fa=b+16|0}function vH(a){a=a|0;var b=0;wa(2623);b=L[a+68>>2];ha[L[L[b>>2]+32>>2]](b,L[a+24>>2]);va()}function ib(a,b){if(M[a+204|0]&3?b:1){if((L[a+216>>2]&-2)!=4){L[a+216>>2]=1}L[a+220>>2]=0}}function Gl(a,b,c,d,e){if(Hl(a,30024,b,c,d,e)){a=1}else{a=Bg(a,30024,b,c,d,e,0)}return a}function jm(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return N[L[b+12>>2]+10>>1]<<16>>16}function bh(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return N[L[b+12>>2]+12>>1]<<16>>16}function Yg(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return N[L[b+12>>2]+14>>1]<<16>>16}function YB(a){a=a|0;if(ha[L[L[a>>2]+40>>2]](a)|0){J[a+169|0]=1;P[a+16>>2]=P[a+28>>2]}}function Wz(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;L[a+128>>2]=d;L[a+124>>2]=c;L[a+120>>2]=b}function Ra(a){var b=0;b=fa-16|0;fa=b;P[b+12>>2]=a;a=Fa(P[b+12>>2]);fa=b+16|0;return a}function Qa(a){var b=0;b=fa-16|0;fa=b;P[b+12>>2]=a;a=Ea(P[b+12>>2]);fa=b+16|0;return a}function nm(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return N[L[b+12>>2]+8>>1]<<16>>16}function _f(a){var b=0;b=L[a+24>>2];if(b){_f(b);ra(b)}a=L[a+28>>2];if(a){_f(a);ra(a)}}function Zu(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return N[L[b+12>>2]+4>>1]<<16>>16}function Xu(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return N[L[b+12>>2]+6>>1]<<16>>16}function rH(a,b){a=a|0;b=b|0;ha[L[L[b>>2]+32>>2]](b);jh(a,b);ha[L[L[b>>2]+36>>2]](b)}function XE(a,b){a=a|0;b=b|0;L[a+8>>2]=0;L[a+12>>2]=0;L[a>>2]=0;L[a+4>>2]=1065353216}function UE(a,b){a=a|0;b=b|0;L[a+8>>2]=1065353216;L[a+12>>2]=0;L[a>>2]=0;L[a+4>>2]=0}function SE(a,b){a=a|0;b=b|0;L[a+8>>2]=0;L[a+12>>2]=0;L[a>>2]=1065353216;L[a+4>>2]=0}function Qg(a,b,c){a=a|0;b=S(b);c=c|0;L[c>>2]=0;L[c+4>>2]=0;L[c+8>>2]=0;L[c+12>>2]=0}function dd(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;ib(L[b+12>>2],0);fa=b+16|0}function Is(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return L[L[b+12>>2]+44>>2]!=0|0}function GD(a,b,c){a=a|0;b=b|0;c=c|0;L[a>>2]=0;L[a+4>>2]=0;L[a+8>>2]=0;L[a+12>>2]=0}function zu(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return S(P[L[b+12>>2]+136>>2])}function zH(a,b){a=a|0;b=b|0;L[a+200>>2]=b;L[a+192>>2]=b;L[a+260>>2]=L[a+260>>2]+1}function vs(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return S(P[L[b+12>>2]+216>>2])}function ss(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return S(P[L[b+12>>2]+252>>2])}function qs(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return S(P[L[b+12>>2]+244>>2])}function os(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return S(P[L[b+12>>2]+204>>2])}function ms(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return S(P[L[b+12>>2]+212>>2])}function kw(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return S(P[L[b+12>>2]+228>>2])}function ks(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return S(P[L[b+12>>2]+220>>2])}function gs(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return S(P[L[b+12>>2]+248>>2])}function es(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return S(P[L[b+12>>2]+208>>2])}function cs(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return S(P[L[b+12>>2]+276>>2])}function Xv(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return S(P[L[b+12>>2]+224>>2])}function VC(a,b){a=a|0;b=b|0;a=L[L[a+4>>2]>>2];return ha[L[L[a>>2]+128>>2]](a,b)|0}function Sr(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return S(P[L[b+12>>2]+236>>2])}function Ru(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return S(P[L[b+12>>2]+100>>2])}function Qr(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return S(P[L[b+12>>2]+240>>2])}function Pu(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return S(P[L[b+12>>2]+104>>2])}function Or(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return S(P[L[b+12>>2]+256>>2])}function Nu(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return S(P[L[b+12>>2]+108>>2])}function Mr(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return S(P[L[b+12>>2]+268>>2])}function Lu(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return S(P[L[b+12>>2]+112>>2])}function Kr(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return S(P[L[b+12>>2]+272>>2])}function Ju(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return S(P[L[b+12>>2]+116>>2])}function Iv(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return S(P[L[b+12>>2]+232>>2])}function Ir(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return S(P[L[b+12>>2]+280>>2])}function Fu(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return S(P[L[b+12>>2]+124>>2])}function Du(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return S(P[L[b+12>>2]+128>>2])}function Bu(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return S(P[L[b+12>>2]+132>>2])}function zx(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return S(P[L[b+12>>2]+80>>2])}function zq(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return S(P[L[b+12>>2]+88>>2])}function zi(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return S(P[L[b+12>>2]+64>>2])}function xi(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return S(P[L[b+12>>2]+68>>2])}function vi(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return S(P[L[b+12>>2]+72>>2])}function ti(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return S(P[L[b+12>>2]+76>>2])}function oi(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return S(P[L[b+12>>2]+24>>2])}function oc(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return S(P[L[b+12>>2]+12>>2])}function ij(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return S(P[L[b+12>>2]+40>>2])}function ii(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return S(P[L[b+12>>2]+44>>2])}function gw(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;fj(L[b+12>>2]);fa=b+16|0}function Zx(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;ee(L[b+12>>2]);fa=b+16|0}function ZG(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;a=a-4|0;ha[L[L[a>>2]+8>>2]](a,b,c,d)}function Wt(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;Jk(L[b+12>>2]);fa=b+16|0}function Tu(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return S(P[L[b+12>>2]+96>>2])}function Ri(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return S(P[L[b+12>>2]+28>>2])}function Oi(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return S(P[L[b+12>>2]+16>>2])}function Li(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return S(P[L[b+12>>2]+20>>2])}function Lh(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;Nd(L[b+12>>2]);fa=b+16|0}function Kw(a){a=a|0;var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;Sb(L[b+12>>2]);fa=b+16|0}function Hi(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return S(P[L[b+12>>2]+48>>2])}function Fi(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return S(P[L[b+12>>2]+52>>2])}function Ff(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return S(P[L[b+12>>2]+92>>2])}function Di(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return S(P[L[b+12>>2]+56>>2])}function Cf(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return S(P[L[b+12>>2]+36>>2])}function Bi(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return S(P[L[b+12>>2]+60>>2])}function Af(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return S(P[L[b+12>>2]+32>>2])}function fb(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return S(P[L[b+12>>2]+4>>2])}function as(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return J[L[b+12>>2]+260|0]&1}function Oc(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return S(P[L[b+12>>2]+8>>2])}function Hu(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return J[L[b+12>>2]+120|0]&1}function wx(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return L[L[b+12>>2]+112>>2]}function jq(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return L[L[b+12>>2]+100>>2]}function Ss(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return J[L[b+12>>2]+16|0]&1}function Qs(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return J[L[b+12>>2]+24|0]&1}function Os(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return J[L[b+12>>2]+25|0]&1}function Ms(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return J[L[b+12>>2]+26|0]&1}function Ks(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return J[L[b+12>>2]+32|0]&1}function Cs(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return J[L[b+12>>2]+84|0]&1}function As(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return J[L[b+12>>2]+80|0]&1}function zv(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return L[L[b+12>>2]+64>>2]}function rx(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return L[L[b+12>>2]+76>>2]}function pm(a,b,c){a=Og(a);L[a+92>>2]=b;L[a>>2]=14456;L[a+4>>2]=3;if(c){Sb(a)}}function nq(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return L[L[b+12>>2]+92>>2]}function lq(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return L[L[b+12>>2]+96>>2]}function be(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return S(P[L[b+12>>2]>>2])}function Zi(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return L[L[b+12>>2]+60>>2]}function Xe(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return L[L[b+12>>2]+16>>2]}function SH(a,b){a=a|0;b=b|0;a=L[a+4>>2];return(a|0)==L[b>>2]|(a|0)==L[b+4>>2]}function Pi(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return L[L[b+12>>2]+20>>2]}function Ov(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return L[L[b+12>>2]+40>>2]}function Nq(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return L[L[b+12>>2]+84>>2]}function Kv(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return L[L[b+12>>2]+28>>2]}function Ji(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return L[L[b+12>>2]+88>>2]}function Gv(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return L[L[b+12>>2]+44>>2]}function Gq(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return L[L[b+12>>2]+36>>2]}function Ev(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return L[L[b+12>>2]+48>>2]}function Cv(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return L[L[b+12>>2]+56>>2]}function $i(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return L[L[b+12>>2]+32>>2]}function yd(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return L[L[b+12>>2]+8>>2]}function od(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return L[L[b+12>>2]+4>>2]}function Jy(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;if(Wa(a,L[b+8>>2],0)){Xf(b,c,d)}}function zn(a,b){a=a|0;b=b|0;a=L[a+4>>2];ha[L[L[a>>2]+8>>2]](a,L[b+36>>2])|0}function yx(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return L[b+12>>2]- -64|0}function zp(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return L[b+12>>2]+788|0}function rf(a){var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;Mb(L[b+12>>2]);fa=b+16|0}function rc(a){var b=0;b=fa-16|0;fa=b;L[b+12>>2]=a;mb(L[b+12>>2]);fa=b+16|0}function pu(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return L[b+12>>2]+348|0}function nH(a,b){a=a|0;b=b|0;a=L[a+20>>2];return ha[L[L[a>>2]+8>>2]](a,b)|0}function jH(a,b){a=a|0;b=b|0;a=L[a+12>>2];return ha[L[L[a>>2]+8>>2]](a,b)|0}function fd(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return L[L[b+12>>2]>>2]}function Zr(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return L[b+12>>2]+156|0}function Wr(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return L[b+12>>2]+172|0}function Ur(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return L[b+12>>2]+188|0}function Ip(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return L[b+12>>2]+288|0}function Gp(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return L[b+12>>2]+708|0}function Ex(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return L[b+12>>2]+112|0}function Ep(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return L[b+12>>2]+748|0}function Cp(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return L[b+12>>2]+868|0}function uq(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return L[b+12>>2]+76|0}function uj(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return L[b+12>>2]+36|0}function rj(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return L[b+12>>2]+68|0}function ri(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return L[b+12>>2]+92|0}function pj(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return L[b+12>>2]+56|0}function nx(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return L[b+12>>2]+44|0}function nj(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return L[b+12>>2]+72|0}function nI(a){var b=0;b=a&31;a=0-a&31;return(-1>>>b&-2)<>>a}function mj(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return L[b+12>>2]+32|0}function lz(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return L[b+12>>2]+48|0}function lx(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return L[b+12>>2]+60|0}function jn(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return L[b+12>>2]+28|0}function hd(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return L[b+12>>2]+16|0}function eE(a){a=a|0;L[a>>2]=15204;if(a){L[8514]=L[8514]+1;ha[L[6799]](a)}}function dc(a){a=a|0;L[a>>2]=20172;if(a){L[8514]=L[8514]+1;ha[L[6799]](a)}}function _m(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return L[b+12>>2]+12|0}function _E(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;ha[L[L[a>>2]+80>>2]](a,b,c,d)}function Of(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return L[b+12>>2]+20|0}function Nf(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return L[b+12>>2]+52|0}function Mf(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return L[b+12>>2]+40|0}function Jf(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return L[b+12>>2]+24|0}function aH(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;ha[L[L[a>>2]+8>>2]](a,b,c,d)}function Zh(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return L[b+12>>2]+8|0}function Df(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return L[b+12>>2]+4|0}function BH(a){a=a|0;L[a>>2]=6712;if(a){L[8514]=L[8514]+1;ha[L[6799]](a)}}function dI(a,b){a=a|0;b=b|0;ha[L[L[a>>2]+8>>2]](a,b,L[L[a+8>>2]+48>>2])}function _n(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;J[L[b+12>>2]+48|0]=1}function rF(a,b){a=a|0;b=S(b);return S(S(S(ha[L[L[a>>2]+16>>2]](a))*b))}function Re(a){a=Og(a);L[a+92>>2]=0;L[a>>2]=16432;L[a+4>>2]=2;return a}function FD(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;if((d|0)>0){pa(c,0,d<<4)}}function Va(a){a=a|0;var b=0;b=fa-16|0;L[b+12>>2]=a;return L[b+12>>2]}function yh(a){a=a|0;a=zh(a);if(a){L[8514]=L[8514]+1;ha[L[6799]](a)}}function qC(a){a=a|0;a=Ml(a);if(a){L[8514]=L[8514]+1;ha[L[6799]](a)}}function pD(a){a=a|0;a=L[a+92>>2];return((a|0)==4?4:((a|0)==3)<<1)|0}function fD(a){a=a|0;a=Xl(a);if(a){L[8514]=L[8514]+1;ha[L[6799]](a)}}function ah(a){a=a|0;a=Oa(a);if(a){L[8514]=L[8514]+1;ha[L[6799]](a)}}function IC(a){a=a|0;a=Ql(a);if(a){L[8514]=L[8514]+1;ha[L[6799]](a)}}function wC(a,b){a=a|0;b=S(b);P[a+148>>2]=b;ha[L[L[a>>2]+72>>2]](a)}function mB(a,b){a=a|0;b=b|0;a=M[a+344|0]?0:3;L[b+4>>2]=a;L[b>>2]=a}function Tb(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;return S(S(1))}function DG(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;return S(S(0))}function oF(a){a=a|0;vm(a);if(a){L[8514]=L[8514]+1;ha[L[6799]](a)}}function mG(a){a=a|0;Sm(a);if(a){L[8514]=L[8514]+1;ha[L[6799]](a)}}function mD(a){a=a|0;Lg(a);if(a){L[8514]=L[8514]+1;ha[L[6799]](a)}}function kz(a){a=a|0;fk(a);if(a){L[8514]=L[8514]+1;ha[L[6799]](a)}}function jG(a){a=a|0;Rm(a);if(a){L[8514]=L[8514]+1;ha[L[6799]](a)}}function hB(a){a=a|0;cl(a);if(a){L[8514]=L[8514]+1;ha[L[6799]](a)}}function eC(a){a=a|0;tl(a);if(a){L[8514]=L[8514]+1;ha[L[6799]](a)}}function Vz(a){a=a|0;Ak(a);if(a){L[8514]=L[8514]+1;ha[L[6799]](a)}}function PA(a){a=a|0;pg(a);if(a){L[8514]=L[8514]+1;ha[L[6799]](a)}}function ND(a){a=a|0;em(a);if(a){L[8514]=L[8514]+1;ha[L[6799]](a)}}function KF(a){a=a|0;Am(a);if(a){L[8514]=L[8514]+1;ha[L[6799]](a)}}function Hm(a){a=a|0;Wg(a);if(a){L[8514]=L[8514]+1;ha[L[6799]](a)}}function QD(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return Dm(a,b,c,d)|0}function CF(a,b,c){a=a|0;b=b|0;c=c|0;ha[L[L[b>>2]+68>>2]](a,b,c)}function Bz(a,b,c){a=a|0;b=b|0;c=c|0;ha[L[L[b>>2]+64>>2]](a,b,c)}function cI(a,b,c){a=a|0;b=b|0;c=S(c);ha[L[L[a>>2]+12>>2]](a,b)}function Xz(a,b,c){a=a|0;b=b|0;c=S(c);ha[L[L[a>>2]+16>>2]](a,c)}function Cn(){var a=0;a=sa(16);L[8515]=a;xc(a);Vj(34064,2499,0)}function eH(a,b,c){a=a|0;b=b|0;c=c|0;L[a+24>>2]=c;L[a+16>>2]=b}function dH(a,b,c){a=a|0;b=b|0;c=c|0;L[a+28>>2]=c;L[a+20>>2]=b}function Wp(){var a=0;a=oa(16);L[(fa-16|0)+12>>2]=a;return a|0}function XB(a){a=a|0;return P[a+16>>2]==S(0)&P[a+20>>2]==S(0)}function Pa(a){a=a|0;if(a){L[8514]=L[8514]+1;ha[L[6799]](a)}}function Ol(a,b){a=a|0;b=b|0;return L[L[a+184>>2]+(b<<2)>>2]}function Mk(a,b){a=a|0;b=b|0;return L[L[a+220>>2]+(b<<2)>>2]}function FH(a,b){a=a|0;b=b|0;return L[L[a+20>>2]+(b<<2)>>2]}function Qx(){var a=0;a=oa(200);Pf(a,$a(),$a());return a|0}function Dz(a){a=a|0;return S(S(ha[L[L[a>>2]+48>>2]](a)))}function uD(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;bm(a,b,c,d)}function kk(a){a=a|0;L[a>>2]=21960;eg(a+12|0);return a|0}function HA(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;lh(a,b,c,d)}function fn(a){a=a|0;L[a>>2]=9440;ih(a+12|0);return a|0}function BD(a){a=a|0;return S(S(P[a+28>>2]*P[a+12>>2]))}function Rk(a,b){a=a|0;b=b|0;ha[L[L[a>>2]+64>>2]](a,b)}function Qk(a,b){a=a|0;b=b|0;ha[L[L[a>>2]+68>>2]](a,b)}function EH(a){a=a|0;return(L[a+12>>2]?L[a+20>>2]:0)|0}function xo(a){a=a|0;L[(fa-16|0)+12>>2]=a;return 3211}function ho(a){a=a|0;L[(fa-16|0)+12>>2]=a;return 4348}function ZB(a){a=a|0;return ha[L[L[a>>2]+48>>2]](a)|0}function MB(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=S(e)}function Gn(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return 0}function vw(){var a=0;a=oa(172);Kg(a,1,1);return a|0}function tC(a,b,c){a=a|0;b=b|0;c=c|0;aj(a+144|0,b,c)}function Tm(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0}function Rw(){var a=0;a=oa(112);We(a,0,0);return a|0}function vo(a){a=a|0;L[(fa-16|0)+12>>2]=a;return 52}function lI(a){if(a){return 31-U(a-1^a)|0}return 32}function ao(a){a=a|0;L[(fa-16|0)+12>>2]=a;return 12}function Zn(a){a=a|0;L[(fa-16|0)+12>>2]=a;return 25}function GB(a,b,c){a=a|0;b=b|0;c=c|0;return S(S(0))}function vg(a){qd(a,L[a+28>>2]+4|0,L[a+32>>2]+4|0)}function ro(a){a=a|0;L[(fa-16|0)+12>>2]=a;return 2}function _u(){var a=0;a=sa(196);th(a,0);return a|0}function Zv(){var a=0;a=oa(192);dj(a,1);return a|0}function Ry(a){a=a|0;if(a){ha[L[6801]](L[a-4>>2])}}function Qh(a){a=a|0;L[(fa-16|0)+12>>2]=a;return 3}function Ph(a){a=a|0;L[(fa-16|0)+12>>2]=a;return 1}function Nh(a){a=a|0;L[(fa-16|0)+12>>2]=a;return 0}function JB(a,b){a=a|0;b=b|0;L[b>>2]=6;L[b+4>>2]=6}function Ew(){var a=0;a=oa(92);wm(a,1);return a|0}function ue(a,b,c){Rb(a+4|0,a+312|0,a+328|0,b,c)}function At(){var a=0;a=oa(196);dl(a);return a|0}function yy(){var a=0;a=oa(16);Ka(a);return a|0}function vp(){var a=0;a=sa(40);ek(a);return a|0}function kv(){var a=0;a=sa(24);og(a);return a|0}function dw(){var a=0;a=sa(72);ej(a);return a|0}function Tv(){var a=0;a=sa(68);bj(a);return a|0}function $x(){var a=0;a=sa(64);Pb(a);return a|0}function Tg(a,b,c){a=a|0;b=b|0;c=S(c);return 0}function vh(a,b,c){a=a|0;b=b|0;c=c|0;return 0}function qb(a){a=a|0;L[(fa-16|0)+12>>2]=a;D()}function nl(a){a=a|0;L[a>>2]=20172;return a|0}function hn(a,b,c,d){a=a|0;b=b|0;c=c|0;d=S(d)}function gm(a){a=Jm(a);L[a>>2]=15460;return a}function fE(a){a=a|0;L[a>>2]=15204;return a|0}function HB(a,b,c,d){a=a|0;b=b|0;c=S(c);d=d|0}function zb(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0}function Wy(a,b,c){a=a|0;b=b|0;c=c|0;ok(b,c)}function FC(a){a=a|0;return L[a+156>>2]!=0|0}function CH(a){a=a|0;L[a>>2]=6712;return a|0}function lD(a){a=a|0;return L[a+48>>2]==1|0}function Ny(a){a=a|0;a=L[8515];if(a){ra(a)}}function yE(a){a=a|0;return L[a+92>>2]+4|0}function vC(a){a=a|0;return S(P[a+148>>2])}function fF(a,b){a=a|0;b=S(b);P[a+72>>2]=b}function cD(a){a=a|0;return L[a+48>>2]+4|0}function DF(a,b){a=a|0;b=S(b);P[a+12>>2]=b}function $l(a,b){a=a|0;b=S(b);P[a+44>>2]=b}function wn(a,b){a=a|0;b=b|0;L[a+72>>2]=b}function eF(a){a=a|0;return S(P[a+72>>2])}function WB(a,b){a=a|0;b=b|0;J[a+180|0]=b}function UH(a,b){a=a|0;b=b|0;L[a+24>>2]=b}function Ty(a,b){a=a|0;b=b|0;L[a+4>>2]=b} -function Kh(a){a=a|0;L[(fa-16|0)+12>>2]=a}function Sy(a,b){a=a|0;b=b|0;L[a+8>>2]=b}function uC(a){a=a|0;return L[a+204>>2]}function tA(a){a=a|0;return L[a+200>>2]}function sA(a){a=a|0;return L[a+212>>2]}function GC(a){a=a|0;return L[a+176>>2]}function An(a){a=a|0;return L[a+136>>2]}function tn(a){a=a|0;return L[a+68>>2]}function sm(a){a=a|0;return L[a+96>>2]}function qH(a){a=a|0;return L[a+72>>2]}function ic(a){a=a|0;return L[a+16>>2]}function cf(a){a=a|0;return L[a+92>>2]}function Um(a){a=a|0;return L[a+24>>2]}function GH(a){a=a|0;return L[a+12>>2]}function wd(a,b){a=a|0;b=b|0;return 0}function rh(a,b){a=a|0;b=b|0;return 1}function ph(a){a=a|0;return L[a+8>>2]}function Rg(a,b,c){a=a|0;b=S(b);c=c|0}function HD(a){a=a|0;return L[a+4>>2]}function Aa(a,b,c){a=a|0;b=b|0;c=c|0}function yC(a){a=a|0;return a+156|0}function SD(a){a=a|0;return Wg(a)|0}function Py(a){a=a|0;return Yf(a)|0}function Pl(a){a=a|0;return a+144|0}function $D(a){a=a|0;return a+108|0}function xD(a){a=a|0;return a+68|0}function hF(a){a=a|0;return a+76|0}function hE(a){a=a|0;return a+16|0}function _A(a){a=a|0;L[a+192>>2]=0}function uh(a){a=a|0;return a+4|0}function $G(a){a=a|0;return a-4|0}function zG(a){a=a|0;Xm(a);ra(a)}function xz(a){a=a|0;kk(a);ra(a)}function xH(a){a=a|0;nh(a);ra(a)}function xG(a){a=a|0;fh(a);ra(a)}function xE(a){a=a|0;return 3113}function xC(a){a=a|0;return 2478}function wz(a){a=a|0;eg(a);ra(a)}function wF(a){a=a|0;return 3193}function wD(a){a=a|0;return 4324}function uF(a){a=a|0;return 4280}function tF(a){a=a|0;return 4245}function sz(a){a=a|0;hk(a);ra(a)}function oE(a){a=a|0;return 4254}function oC(a){a=a|0;return 3127}function lE(a){a=a|0;return 4264}function jE(a){a=a|0;return 4229}function gG(a){a=a|0;Qm(a);ra(a)}function gF(a){a=a|0;return 3247}function gE(a){a=a|0;return 2364}function cG(a){a=a|0;Om(a);ra(a)}function bI(a){a=a|0;xn(a);ra(a)}function bA(a){a=a|0;Dk(a);ra(a)}function aG(a){a=a|0;Nm(a);ra(a)}function _D(a){a=a|0;return 4336}function ZF(a){a=a|0;return 2404}function YG(a){a=a|0;kn(a);ra(a)}function YE(a){a=a|0;return 3206}function YC(a){a=a|0;Ul(a);ra(a)}function VE(a){a=a|0;return 4239}function TE(a){a=a|0;return 4274}function TD(a){a=a|0;return 3181}function SA(a){a=a|0;Yk(a);ra(a)}function RG(a){a=a|0;fn(a);ra(a)}function QH(a){a=a|0;vn(a);ra(a)}function PG(a){a=a|0;ih(a);ra(a)}function LG(a){a=a|0;bn(a);ra(a)}function IE(a){a=a|0;return 2408}function Hz(a){a=a|0;return 2395}function HC(a){a=a|0;return 3220}function GG(a){a=a|0;$m(a);ra(a)}function Fn(a){a=a|0;sh(a);ra(a)}function Ez(a){a=a|0;return 4289}function EF(a){a=a|0;return 4301}function CD(a){a=a|0;return 4317}function BG(a){a=a|0;Ym(a);ra(a)}function $y(a){a=a|0;dk(a);ra(a)}function $C(a){a=a|0;return 4304}function yH(a){a=a|0;return 256}function wB(a){a=a|0;return 348}function pB(a){a=a|0;return 220}function oI(a,b){ga=a;return b} -function iA(a){a=a|0;return 488}function VA(a){a=a|0;return 204}function Mz(a){a=a|0;return 428}function LB(a){a=a|0;return 212}function Ba(a){a=a|0;return a|0}function AB(a){a=a|0;return 252}function hm(a){a=a|0;return 64}function eD(a){a=a|0;return 28}function dF(a){a=a|0;return 24}function _l(a){a=a|0;return 52}function _G(a){a=a|0;ra(a-4|0)}function Ye(a){a=a|0;return 60}function TF(a){a=a|0;return 12}function My(a){a=a|0;_f(34064)}function HE(a){a=a|0;return 68}function Cm(a){a=a|0;return 84}function Az(a){a=a|0;return 32}function pH(a,b){a=a|0;b=S(b)}function dz(a){a=a|0;return 4}function UF(a){a=a|0;return 8}function Km(a){a=a|0;return 6}function Ja(a){a=a|0;return 0}function Ic(a){a=a|0;return 1}function Fg(a){a=a|0;return 2}function op(){return sa(1)|0}function Ia(a,b){a=a|0;b=b|0}function na(a){a=a|0;ra(a)}function gb(a){a=a|0;D()}function Hk(a,b){Gk(a,b)}function pf(){return 1}function of(){return 2}function hp(){return 5}function ei(){return 0}function ci(){return 3}function bi(){return 4}function Ly(){aa();D()}function Wb(a){a=a|0} -// EMSCRIPTEN_END_FUNCS -g=M;r(s);var ha=e([null,Ka,Cb,gp,fp,ep,dp,cp,bp,ap,$o,_o,Zo,Yo,Xo,Wo,Vo,Uo,To,So,Ro,Qo,Po,Oo,Va,qb,Ly,Ka,Cb,No,Mo,Va,qb,Ka,Lo,Ko,Jo,Ka,Cb,Io,Ho,Va,qb,$h,Go,Fo,Ka,Cb,Eo,Do,Va,qb,Ka,Cb,Co,Bo,Va,qb,jf,Ao,zo,sF,qF,rF,Ue,_m,yo,xo,wo,hi,ii,vo,uo,pF,Ug,to,DE,so,GE,ro,qo,MD,Qh,Qh,po,oo,Ph,no,mo,lo,hf,ko,jo,Oh,io,uD,ID,JD,ho,LD,KD,Nh,ff,cf,tD,sD,qD,pD,zb,Tg,wd,fo,qb,eo,co,Nf,bo,oc,ao,db,ef,$n,_n,Zn,Kh,Kh,Yn,ef,ef,Ka,Cb,Nh,Xn,Wn,ff,Va,qb,Ka,Cb,Ph,Zi,Vn,Un,Va,qb,Ka,Cb,Tn,Sn,ff,Va,qb,zh,yh,Qn,Pn,On,xh,Nn,Mn,Ln,cf,cf,Kn,Jn,Wb,yh,In,Hn,vh,Gn,Aa,ic,ic,uh,Aa,Ja,Aa,Ia,Aa,vh,Ic,Ia,Ia,sh,Fn,En,Dn,iI,xh,kI,jI,hI,An,An,gI,fI,Wb,Ba,na,eI,dI,cI,rh,rh,na,Aa,zn,na,zn,xn,bI,VH,YH,_H,ic,ic,uh,aI,ph,$H,UH,XH,ZH,Ja,wn,WH,Ba,na,TH,na,SH,RH,vn,QH,MH,PH,NH,OH,KH,LH,JH,GH,FH,EH,tn,tn,IH,HH,na,DH,rh,CH,BH,zH,yH,oh,AH,nh,xH,wH,vH,wn,qH,on,sH,tH,lh,Bd,uH,rH,pH,Ia,Aa,Ba,na,Ba,na,gC,mn,na,mn,na,oH,na,nH,mH,na,fC,lH,na,kH,na,jH,iH,Ba,na,hH,na,gH,na,fH,Ba,na,eH,dH,cH,Ba,na,bH,aH,$G,_G,ZG,Ba,gb,Ba,gb,Ba,na,VG,kn,YG,XG,WG,UG,na,Aa,Aa,hn,na,Aa,Aa,TG,na,SG,fn,RG,NG,MG,QG,ih,PG,OG,na,en,bn,LG,KG,JG,IG,na,HG,$m,GG,EG,DG,FG,na,CG,Ia,Ba,na,Zm,Ym,BG,AG,Tb,zd,Xm,zG,yG,Tb,zd,fh,xG,ph,ic,Vm,Um,Ba,na,wG,na,vG,na,uG,na,tG,na,sG,na,rG,na,qG,na,pG,na,oG,na,nG,na,Tm,Tb,Ia,Sm,mG,lG,kG,Rm,jG,iG,hG,Qm,gG,fG,eG,ic,na,dG,Om,cG,bG,Tb,zd,Nm,aG,$F,Tb,zd,na,Mm,Oa,ah,Lm,$g,_F,ZF,_g,YF,XF,WF,Km,VF,UF,TF,SF,RF,Km,QF,PF,OF,Wg,Hm,Dm,Cm,LF,NF,MF,Am,KF,dD,IF,cD,Qg,EF,DF,Ye,HF,JF,aD,CF,GF,FF,Ba,na,zm,na,zm,na,BF,Ba,Pa,xF,$g,yF,wF,ym,_g,Ye,vF,AF,zF,Pa,uF,Pa,tF,vm,oF,lF,jF,hF,kF,gF,fF,eF,dF,iF,nF,mF,Ba,gb,Pa,_E,$E,ZE,YE,XE,Ye,WE,aF,cF,bF,Pa,VE,UE,Pa,TE,SE,KE,JE,bm,RE,IE,HE,ME,Ug,QE,PE,sm,sm,OE,NE,Ja,zb,Tg,LE,gb,gb,FE,EE,gb,ah,zE,yE,xE,Ug,BE,AE,Ja,Ja,zb,Aa,Ja,zb,Tg,Ba,na,wE,Pa,Lm,$g,vE,oE,ym,_g,Ye,nE,mE,sE,rE,lm,Pa,lE,uE,pE,kE,Pa,jE,tE,qE,lm,Ba,Pa,km,iE,hE,Rg,gE,zb,fE,eE,dE,aE,$D,Qg,_D,bE,cE,VD,UD,XD,TD,hm,WD,ZD,YD,SD,Hm,QD,na,PD,na,OD,em,ND,gb,gb,Pa,km,DD,CD,$l,BD,ED,GD,FD,Ba,Pa,AD,yD,xD,Qg,wD,_l,vD,zD,ah,Lg,mD,oD,Zl,Zl,Ia,Ia,Um,Ia,Ia,lD,kD,iD,eD,nD,Xl,fD,hD,gD,Ba,Pa,Vl,$C,bD,na,_C,na,ZC,Ul,YC,XC,Tb,WC,VC,Ba,na,UC,na,TC,na,na,SC,na,RC,Ql,IC,QC,HC,Ja,Pl,GC,FC,Ja,Ja,Aa,Aa,EC,Ol,Ol,DC,CC,BC,AC,zC,yC,PC,xC,wC,vC,MC,Ic,Pl,uC,Ja,Ic,Ja,tC,Aa,sC,rC,wd,wd,Aa,Aa,NC,Ml,qC,pC,OC,oC,nC,hm,JC,LC,mC,lC,Fg,Ja,Ja,Ja,Ja,Ja,Aa,Aa,Wb,Wb,Tm,wd,wd,Aa,Aa,zb,KC,Ba,na,Il,na,Aa,Aa,kC,na,Eg,CE,Te,Ba,na,jC,na,wb,na,iC,na,Aa,Aa,hC,gb,gb,na,Cl,tl,eC,VB,Ia,dC,cC,bC,aC,$B,_B,ZB,YB,XB,WB,na,UB,nl,dc,RB,MB,TB,SB,QB,PB,OB,LB,KB,NB,nl,dc,Wb,JB,IB,hn,HB,GB,_l,cc,dc,FB,EB,kl,CB,BB,AB,zB,DB,dc,yB,wB,vB,xB,dc,uB,tB,sB,rB,qB,pB,oB,dc,nB,mB,lB,kB,jB,Cm,iB,cl,hB,Aa,$A,Aa,_A,Ic,fB,cB,aB,dB,eB,bB,dc,ZA,YA,XA,WA,VA,UA,TA,gb,Yk,SA,RA,QA,pg,PA,Vk,HA,Sk,rA,KA,BA,AA,zA,yA,JA,IA,LA,FA,EA,GA,uA,tA,sA,Mk,Mk,Fg,NA,Rk,Qk,Rk,Qk,Nk,vA,wA,xA,DA,Tk,OA,MA,Ia,qA,pA,nA,mA,na,lA,kA,jA,fA,eA,iA,hA,gA,cA,Dk,bA,Xz,_z,aA,$z,Wz,na,Zz,qk,Ak,Vz,Ia,Mz,Lz,Kz,na,Uz,Ba,na,Tz,Sz,Rz,Fg,Pa,Jz,Ia,Iz,Rg,Hz,zb,na,Gz,na,Fz,Pa,zb,Rg,Ez,$l,Dz,Cz,Bz,zb,Az,na,zz,na,yz,Nz,Qz,Pz,Oz,kk,xz,uz,tz,Ia,eg,wz,vz,na,en,hk,sz,rz,na,qz,na,pz,na,oz,na,nz,Ba,na,mz,Tb,Ia,fk,kz,gz,fz,hz,ez,dz,jz,iz,na,cz,Ba,na,az,Tb,zd,dk,$y,Ja,Ic,_y,Ia,Uy,Yy,Zy,Vy,Wy,Ty,HD,Sy,ph,Xy,Qy,Ry,Py,na,Ny,My,Ba,na,Wb,Wb,Ky,By,Ey,Jy,na,Cy,Fy,Iy,na,Dy,Gy,Hy]);function ia(){return I.byteLength/65536|0}return{"h":Cn,"i":za,"j":ya,"k":Ca,"l":Ua,"m":Ta,"n":ma,"o":_d,"p":Yd,"q":Rd,"r":$e,"s":Im,"t":om,"u":Oe,"v":Ge,"w":ye,"x":re,"y":ne,"z":ke,"A":je,"B":nd,"C":he,"D":ge,"E":fe,"F":ma,"G":ld,"H":kd,"I":tc,"J":jd,"K":id,"L":dd,"M":bd,"N":ad,"O":$c,"P":_c,"Q":Zc,"R":Yc,"S":Xc,"T":Wc,"U":Vc,"V":Uc,"W":Tc,"X":qc,"Y":Sc,"Z":Rc,"_":Qc,"$":Jb,"aa":Pc,"ba":Mc,"ca":lb,"da":kb,"ea":lb,"fa":kb,"ga":pc,"ha":Lc,"ia":za,"ja":ya,"ka":Ca,"la":ma,"ma":ma,"na":Ib,"oa":Hb,"pa":Gb,"qa":Fb,"ra":Eb,"sa":ma,"ta":$d,"ua":yf,"va":xf,"wa":wf,"xa":uf,"ya":tf,"za":_d,"Aa":Yd,"Ba":Rd,"Ca":$e,"Da":Im,"Ea":om,"Fa":Oe,"Ga":Ge,"Ha":ye,"Ia":re,"Ja":ne,"Ka":ke,"La":je,"Ma":nd,"Na":he,"Oa":ge,"Pa":fe,"Qa":ma,"Ra":sf,"Sa":qi,"Ta":pi,"Ua":li,"Va":gi,"Wa":fi,"Xa":ma,"Ya":Wp,"Za":Bp,"_a":di,"$a":Xd,"ab":Wd,"bb":Ud,"cb":Sd,"db":Qd,"eb":Pd,"fb":go,"gb":Lh,"hb":Rn,"ib":un,"jb":sn,"kb":pn,"lb":ln,"mb":Ad,"nb":Xd,"ob":Wd,"pb":Ud,"qb":hh,"rb":Sd,"sb":Qd,"tb":Pd,"ub":Wm,"vb":Da,"wb":eh,"xb":Jb,"yb":ma,"zb":ch,"Ab":bh,"Bb":Zg,"Cb":Yg,"Db":Vg,"Eb":fb,"Fb":eb,"Gb":yd,"Hb":xd,"Ib":Xe,"Jb":Ve,"Kb":ma,"Lb":rm,"Mb":ma,"Nb":qm,"Ob":nm,"Pb":mm,"Qb":jm,"Rb":im,"Sb":fb,"Tb":eb,"Ub":ma,"Vb":za,"Wb":ya,"Xb":Ca,"Yb":Ua,"Zb":Ta,"_b":ma,"$b":RD,"ac":Ua,"bc":Ta,"cc":Se,"dc":Ng,"ec":Mg,"fc":za,"gc":ya,"hc":Ca,"ic":ma,"jc":rD,"kc":Ua,"lc":Ta,"mc":za,"nc":ya,"oc":Ca,"pc":ma,"qc":jD,"rc":za,"sc":ya,"tc":Ca,"uc":ma,"vc":Wl,"wc":ma,"xc":za,"yc":ya,"zc":Ca,"Ac":ma,"Bc":Jg,"Cc":Tl,"Dc":Rl,"Ec":Nl,"Fc":ma,"Gc":Ne,"Hc":Me,"Ic":Le,"Jc":td,"Kc":Dl,"Lc":vl,"Mc":rl,"Nc":ql,"Oc":Fe,"Pc":Ee,"Qc":Be,"Rc":Ae,"Sc":el,"Tc":gB,"Uc":Uk,"Vc":za,"Wc":ya,"Xc":Ca,"Yc":ma,"Zc":ma,"_c":CA,"$c":oA,"ad":ma,"bd":td,"cd":Ik,"dd":ma,"ed":dA,"fd":Yz,"gd":zk,"hd":rk,"id":pk,"jd":mk,"kd":oe,"ld":Ib,"md":Hb,"nd":Gb,"od":Fb,"pd":Eb,"qd":ma,"rd":bz,"sd":ck,"td":Oy,"ud":Xj,"vd":Uj,"wd":Rj,"xd":Pj,"yd":Nj,"zd":Uf,"Ad":Mj,"Bd":Lj,"Cd":Kj,"Dd":Jj,"Ed":Ij,"Fd":Hj,"Gd":_d,"Hd":Yd,"Id":Rd,"Jd":$e,"Kd":Gj,"Ld":Fj,"Md":Oe,"Nd":Ge,"Od":ye,"Pd":re,"Qd":ne,"Rd":ke,"Sd":je,"Td":nd,"Ud":he,"Vd":ge,"Wd":fe,"Xd":$d,"Yd":yf,"Zd":xf,"_d":wf,"$d":uf,"ae":tf,"be":ma,"ce":Ej,"de":ma,"ee":Tf,"fe":ma,"ge":Ay,"he":Dj,"ie":Cj,"je":ld,"ke":kd,"le":tc,"me":jd,"ne":id,"oe":dd,"pe":bd,"qe":ad,"re":$c,"se":_c,"te":Zc,"ue":Yc,"ve":Xc,"we":Wc,"xe":Vc,"ye":Uc,"ze":Tc,"Ae":qc,"Be":Sc,"Ce":Rc,"De":Qc,"Ee":Jb,"Fe":Pc,"Ge":Mc,"He":lb,"Ie":kb,"Je":lb,"Ke":kb,"Le":pc,"Me":Lc,"Ne":ma,"Oe":Da,"Pe":zy,"Qe":sf,"Re":qi,"Se":pi,"Te":li,"Ue":gi,"Ve":fi,"We":ma,"Xe":yy,"Ye":xy,"Ze":hh,"_e":Bj,"$e":di,"af":Xd,"bf":Wd,"cf":Ud,"df":Sd,"ef":Qd,"ff":Pd,"gf":Lh,"hf":wy,"jf":un,"kf":sn,"lf":pn,"mf":ln,"nf":Ad,"of":vy,"pf":Bj,"qf":uy,"rf":ty,"sf":sy,"tf":ry,"uf":qy,"vf":py,"wf":oy,"xf":ny,"yf":my,"zf":ly,"Af":ky,"Bf":jy,"Cf":iy,"Df":hy,"Ef":gy,"Ff":fy,"Gf":ey,"Hf":dy,"If":Xd,"Jf":Wd,"Kf":Ud,"Lf":hh,"Mf":Sd,"Nf":Qd,"Of":Pd,"Pf":Wm,"Qf":Da,"Rf":cy,"Sf":by,"Tf":ay,"Uf":Da,"Vf":$x,"Wf":_x,"Xf":Zx,"Yf":Yx,"Zf":Xx,"_f":oe,"$f":Wx,"ag":Vx,"bg":Ux,"cg":Tx,"dg":Sx,"eg":Da,"fg":Rx,"gg":eh,"hg":Jb,"ig":ma,"jg":Qx,"kg":Px,"lg":Ox,"mg":eh,"ng":Jb,"og":Df,"pg":Nx,"qg":ma,"rg":Mx,"sg":Lx,"tg":Ya,"ug":Kx,"vg":ch,"wg":Of,"xg":vj,"yg":uj,"zg":tj,"Ag":Nf,"Bg":sj,"Cg":rj,"Dg":qj,"Eg":bh,"Fg":Zg,"Gg":Yg,"Hg":Vg,"Ig":fb,"Jg":eb,"Kg":yd,"Lg":xd,"Mg":Xe,"Ng":Ve,"Og":ma,"Pg":Ya,"Qg":de,"Rg":nb,"Sg":Ya,"Tg":Jx,"Ug":nb,"Vg":Ix,"Wg":ch,"Xg":Of,"Yg":Hx,"Zg":Mf,"_g":Lf,"$g":pj,"ah":oj,"bh":nj,"ch":Gx,"dh":ri,"eh":Fx,"fh":Ex,"gh":Dx,"hh":bh,"ih":Zg,"jh":Yg,"kh":Vg,"lh":fb,"mh":eb,"nh":yd,"oh":xd,"ph":Xe,"qh":Ve,"rh":ma,"sh":oe,"th":Cx,"uh":Bx,"vh":Ax,"wh":Va,"xh":ce,"yh":hd,"zh":gd,"Ah":mj,"Bh":lj,"Ch":lz,"Dh":Rf,"Eh":yx,"Fh":xx,"Gh":wx,"Hh":vx,"Ih":Da,"Jh":ux,"Kh":rm,"Lh":ma,"Mh":fd,"Nh":ed,"Oh":od,"Ph":cd,"Qh":Da,"Rh":tx,"Sh":fd,"Th":ed,"Uh":od,"Vh":cd,"Wh":Zh,"Xh":kj,"Yh":Jf,"Zh":jj,"_h":ij,"$h":hj,"ai":Da,"bi":sx,"ci":qm,"di":rx,"ei":qx,"fi":_m,"gi":px,"hi":jn,"ii":ox,"ji":nx,"ki":mx,"li":lx,"mi":kx,"ni":nm,"oi":mm,"pi":jm,"qi":im,"ri":fb,"si":eb,"ti":ma,"ui":jx,"vi":ix,"wi":za,"xi":ya,"yi":Ca,"zi":Ua,"Ai":Ta,"Bi":ma,"Ci":hx,"Di":Ua,"Ei":Ta,"Fi":za,"Gi":ya,"Hi":Ca,"Ii":ma,"Ji":gx,"Ki":Ua,"Li":Ta,"Mi":Se,"Ni":Ng,"Oi":Mg,"Pi":za,"Qi":ya,"Ri":Ca,"Si":ma,"Ti":fx,"Ui":Ua,"Vi":Ta,"Wi":Se,"Xi":Ng,"Yi":Mg,"Zi":za,"_i":ya,"$i":Ca,"aj":ma,"bj":ex,"cj":Ua,"dj":Ta,"ej":za,"fj":ya,"gj":Ca,"hj":ma,"ij":dx,"jj":Ua,"kj":Ta,"lj":za,"mj":ya,"nj":Ca,"oj":ma,"pj":cx,"qj":Ua,"rj":Ta,"sj":za,"tj":ya,"uj":Ca,"vj":ma,"wj":bx,"xj":za,"yj":ya,"zj":Ca,"Aj":ma,"Bj":ax,"Cj":za,"Dj":ya,"Ej":Ca,"Fj":ma,"Gj":$w,"Hj":za,"Ij":ya,"Jj":Ca,"Kj":ma,"Lj":Ya,"Mj":de,"Nj":nb,"Oj":Va,"Pj":_w,"Qj":Zw,"Rj":Yw,"Sj":Xw,"Tj":Ya,"Uj":Ww,"Vj":nb,"Wj":Ya,"Xj":Vw,"Yj":Uw,"Zj":Df,"_j":Tw,"$j":Jf,"ak":Sw,"bk":ma,"ck":Rw,"dk":Qw,"ek":Pw,"fk":Ow,"gk":Nw,"hk":Ua,"ik":Ta,"jk":Mw,"kk":Lw,"lk":Kw,"mk":Se,"nk":za,"ok":ya,"pk":Ca,"qk":ma,"rk":Jw,"sk":Iw,"tk":Hw,"uk":Gw,"vk":Fw,"wk":Ew,"xk":Dw,"yk":Cw,"zk":$d,"Ak":Bw,"Bk":Aw,"Ck":zw,"Dk":yw,"Ek":xw,"Fk":Ua,"Gk":Ta,"Hk":za,"Ik":ya,"Jk":Ca,"Kk":ma,"Lk":fd,"Mk":ed,"Nk":Ad,"Ok":Ya,"Pk":ww,"Qk":nb,"Rk":vw,"Sk":uw,"Tk":tw,"Uk":sw,"Vk":rw,"Wk":qw,"Xk":pw,"Yk":ow,"Zk":Wl,"_k":ma,"$k":nw,"al":za,"bl":ya,"cl":Ca,"dl":ma,"el":mw,"fl":za,"gl":ya,"hl":Ca,"il":ma,"jl":lw,"kl":jw,"ll":za,"ml":ya,"nl":Ca,"ol":ma,"pl":iw,"ql":Ua,"rl":Ta,"sl":za,"tl":ya,"ul":Ca,"vl":ma,"wl":hw,"xl":gw,"yl":fw,"zl":ew,"Al":Da,"Bl":dw,"Cl":Da,"Dl":cw,"El":sf,"Fl":bw,"Gl":aw,"Hl":ma,"Il":$v,"Jl":_v,"Kl":ma,"Ll":Tl,"Ml":Rl,"Nl":Nl,"Ol":Jg,"Pl":od,"Ql":cd,"Rl":ma,"Sl":Zv,"Tl":Yv,"Ul":ql,"Vl":vl,"Wl":cj,"Xl":rl,"Yl":Wv,"Zl":el,"_l":Vv,"$l":Uv,"am":Uk,"bm":Ca,"cm":td,"dm":Dl,"em":za,"fm":ya,"gm":Ne,"hm":Me,"im":Le,"jm":Fe,"km":Ee,"lm":Be,"mm":Ae,"nm":ma,"om":Tv,"pm":Sv,"qm":Rv,"rm":Qv,"sm":Jg,"tm":Pv,"um":Nv,"vm":Mv,"wm":Lv,"xm":fb,"ym":eb,"zm":yd,"Am":xd,"Bm":Kv,"Cm":Jv,"Dm":$i,"Em":_i,"Fm":Ov,"Gm":Hv,"Hm":Gv,"Im":Fv,"Jm":Ev,"Km":Dv,"Lm":Cv,"Mm":Bv,"Nm":Zi,"Om":Av,"Pm":zv,"Qm":yv,"Rm":ma,"Sm":xv,"Tm":cj,"Um":wv,"Vm":vv,"Wm":uv,"Xm":za,"Ym":ya,"Zm":Ne,"_m":Me,"$m":Le,"an":Fe,"bn":Ee,"cn":Be,"dn":Ae,"en":ma,"fn":tv,"gn":sv,"hn":rv,"jn":qv,"kn":pv,"ln":za,"mn":ya,"nn":Ne,"on":Me,"pn":Le,"qn":Fe,"rn":Ee,"sn":Be,"tn":Ae,"un":ma,"vn":ov,"wn":nv,"xn":fd,"yn":ed,"zn":od,"An":cd,"Bn":Da,"Cn":mv,"Dn":lv,"En":ma,"Fn":kv,"Gn":Da,"Hn":jv,"In":iv,"Jn":hv,"Kn":gv,"Ln":fv,"Mn":Ad,"Nn":ev,"On":td,"Pn":Ik,"Qn":ma,"Rn":ma,"Sn":Uf,"Tn":dv,"Un":ma,"Vn":cv,"Wn":bv,"Xn":av,"Yn":$u,"Zn":ma,"_n":td,"$n":ma,"ao":ma,"bo":_u,"co":ma,"eo":Zu,"fo":Yu,"go":Xu,"ho":Wu,"io":Ad,"jo":Vu,"ko":Uu,"lo":Ff,"mo":Ef,"no":Tu,"oo":Su,"po":Ru,"qo":Qu,"ro":Pu,"so":Ou,"to":Nu,"uo":Mu,"vo":Lu,"wo":Ku,"xo":Ju,"yo":Iu,"zo":Hu,"Ao":Gu,"Bo":Fu,"Co":Eu,"Do":Du,"Eo":Cu,"Fo":Bu,"Go":Au,"Ho":zu,"Io":yu,"Jo":Da,"Ko":xu,"Lo":qc,"Mo":wu,"No":vu,"Oo":uu,"Po":tu,"Qo":su,"Ro":ru,"So":qu,"To":ou,"Uo":nu,"Vo":mu,"Wo":lu,"Xo":ku,"Yo":ju,"Zo":iu,"_o":hu,"$o":gu,"ap":fu,"bp":eu,"cp":du,"dp":cu,"ep":bu,"fp":au,"gp":$t,"hp":_t,"ip":Zt,"jp":Yt,"kp":Xt,"lp":Wt,"mp":Vt,"np":Ut,"op":pc,"pp":Tt,"qp":St,"rp":Rt,"sp":ld,"tp":kd,"up":tc,"vp":jd,"wp":id,"xp":dd,"yp":bd,"zp":ad,"Ap":$c,"Bp":_c,"Cp":Zc,"Dp":Yc,"Ep":Xc,"Fp":Wc,"Gp":Vc,"Hp":Uc,"Ip":Tc,"Jp":qc,"Kp":Sc,"Lp":Rc,"Mp":Qc,"Np":Jb,"Op":Pc,"Pp":Mc,"Qp":lb,"Rp":kb,"Sp":lb,"Tp":kb,"Up":pc,"Vp":Lc,"Wp":Qt,"Xp":be,"Yp":ae,"Zp":fb,"_p":eb,"$p":Oc,"aq":Nc,"bq":Da,"cq":Pt,"dq":Ot,"eq":Nt,"fq":Mt,"gq":Lt,"hq":Kt,"iq":Ib,"jq":Hb,"kq":Gb,"lq":Fb,"mq":Eb,"nq":pu,"oq":Jt,"pq":ma,"qq":It,"rq":Ht,"sq":Gt,"tq":Ft,"uq":Et,"vq":Dt,"wq":Ct,"xq":Bt,"yq":zk,"zq":rk,"Aq":pk,"Bq":mk,"Cq":oe,"Dq":Ib,"Eq":Hb,"Fq":Gb,"Gq":Fb,"Hq":Eb,"Iq":ma,"Jq":At,"Kq":ma,"Lq":zt,"Mq":yt,"Nq":xt,"Oq":wt,"Pq":vt,"Qq":ut,"Rq":tt,"Sq":st,"Tq":rt,"Uq":qt,"Vq":Ib,"Wq":Hb,"Xq":Gb,"Yq":Fb,"Zq":Eb,"_q":ma,"$q":pt,"ar":ot,"br":nt,"cr":mt,"dr":lt,"er":kt,"fr":jt,"gr":it,"hr":ht,"ir":gt,"jr":ft,"kr":et,"lr":dt,"mr":ct,"nr":Ib,"or":Hb,"pr":Gb,"qr":Fb,"rr":Eb,"sr":ma,"tr":bt,"ur":at,"vr":$s,"wr":_s,"xr":tc,"yr":Zs,"zr":Ys,"Ar":Xs,"Br":Ws,"Cr":Vs,"Dr":Us,"Er":Ib,"Fr":Hb,"Gr":Gb,"Hr":Fb,"Ir":Eb,"Jr":ma,"Kr":Ts,"Lr":Ib,"Mr":Hb,"Nr":Gb,"Or":Fb,"Pr":Eb,"Qr":ma,"Rr":ma,"Sr":be,"Tr":ae,"Ur":od,"Vr":cd,"Wr":yd,"Xr":xd,"Yr":oc,"Zr":Kc,"_r":Ss,"$r":Rs,"as":Qs,"bs":Ps,"cs":Os,"ds":Ns,"es":Ms,"fs":Ls,"gs":Ri,"hs":Qi,"is":Ks,"js":Js,"ks":Cf,"ls":Bf,"ms":Da,"ns":Is,"os":Hs,"ps":Gs,"qs":Fs,"rs":Pi,"ss":Ni,"ts":Da,"us":Es,"vs":be,"ws":ae,"xs":fb,"ys":eb,"zs":Oc,"As":Nc,"Bs":oc,"Cs":Kc,"Ds":Oi,"Es":Mi,"Fs":Li,"Gs":Ki,"Hs":Va,"Is":ce,"Js":hd,"Ks":gd,"Ls":Af,"Ms":zf,"Ns":Da,"Os":Ds,"Ps":Ej,"Qs":ma,"Rs":Va,"Ss":ce,"Ts":hd,"Us":gd,"Vs":Af,"Ws":zf,"Xs":uj,"Ys":tj,"Zs":Nf,"_s":sj,"$s":rj,"at":qj,"bt":Cs,"ct":Bs,"dt":Ji,"et":Ii,"ft":Da,"gt":Va,"ht":ce,"it":hd,"jt":gd,"kt":mj,"lt":lj,"mt":Hi,"nt":Gi,"ot":Fi,"pt":Ei,"qt":Di,"rt":Ci,"st":Bi,"tt":Ai,"ut":zi,"vt":yi,"wt":xi,"xt":wi,"yt":vi,"zt":ui,"At":ti,"Bt":si,"Ct":As,"Dt":zs,"Et":Da,"Ft":ys,"Gt":xs,"Ht":ws,"It":vs,"Jt":us,"Kt":kw,"Lt":ts,"Mt":ss,"Nt":rs,"Ot":qs,"Pt":ps,"Qt":os,"Rt":ns,"St":ms,"Tt":ls,"Ut":ks,"Vt":js,"Wt":Xv,"Xt":is,"Yt":Iv,"Zt":hs,"_t":gs,"$t":fs,"au":es,"bu":ds,"cu":cs,"du":bs,"eu":as,"fu":$r,"gu":Va,"hu":_r,"iu":Zr,"ju":Yr,"ku":ri,"lu":Xr,"mu":Wr,"nu":Vr,"ou":Ur,"pu":Tr,"qu":Sr,"ru":Rr,"su":Qr,"tu":Pr,"uu":Or,"vu":Nr,"wu":Mr,"xu":Lr,"yu":Kr,"zu":Jr,"Au":Ir,"Bu":Hr,"Cu":Da,"Du":Gr,"Eu":Fr,"Fu":Er,"Gu":nd,"Hu":Dr,"Iu":Cr,"Ju":Br,"Ku":Ar,"Lu":zr,"Mu":yr,"Nu":xr,"Ou":wr,"Pu":vr,"Qu":ur,"Ru":tr,"Su":sr,"Tu":rr,"Uu":qr,"Vu":pr,"Wu":or,"Xu":nr,"Yu":Tf,"Zu":ma,"_u":mr,"$u":lr,"av":kr,"bv":jr,"cv":ir,"dv":hr,"ev":gr,"fv":fr,"gv":er,"hv":dr,"iv":cr,"jv":br,"kv":ar,"lv":$q,"mv":_q,"nv":Zq,"ov":Yq,"pv":Xq,"qv":Wq,"rv":Vq,"sv":Uq,"tv":Tq,"uv":Sq,"vv":Rq,"wv":Qq,"xv":Pq,"yv":Oq,"zv":Mq,"Av":Lq,"Bv":Kq,"Cv":Tf,"Dv":ma,"Ev":Jq,"Fv":ld,"Gv":kd,"Hv":tc,"Iv":jd,"Jv":id,"Kv":dd,"Lv":bd,"Mv":ad,"Nv":$c,"Ov":_c,"Pv":Zc,"Qv":Yc,"Rv":Xc,"Sv":Wc,"Tv":Vc,"Uv":Uc,"Vv":Tc,"Wv":qc,"Xv":Sc,"Yv":Rc,"Zv":Qc,"_v":Jb,"$v":Pc,"aw":Mc,"bw":lb,"cw":kb,"dw":lb,"ew":kb,"fw":pc,"gw":Dj,"hw":Cj,"iw":Lc,"jw":Iq,"kw":ma,"lw":Hq,"mw":be,"nw":ae,"ow":fb,"pw":eb,"qw":Oc,"rw":Nc,"sw":oc,"tw":Kc,"uw":hd,"vw":gd,"ww":$i,"xw":_i,"yw":Gq,"zw":Fq,"Aw":Mf,"Bw":Lf,"Cw":Eq,"Dw":Dq,"Ew":Cq,"Fw":Of,"Gw":vj,"Hw":Cf,"Iw":Bf,"Jw":Da,"Kw":Ya,"Lw":Bq,"Mw":nb,"Nw":Zh,"Ow":kj,"Pw":Jf,"Qw":jj,"Rw":Mf,"Sw":Lf,"Tw":pj,"Uw":oj,"Vw":nj,"Ww":Aq,"Xw":zq,"Yw":yq,"Zw":Ff,"_w":Ef,"$w":Da,"ax":Ya,"bx":xq,"cx":nb,"dx":fb,"ex":eb,"fx":Oc,"gx":Nc,"hx":oc,"ix":Kc,"jx":Xe,"kx":Ve,"lx":Da,"mx":Ya,"nx":de,"ox":nb,"px":fd,"qx":ed,"rx":Df,"sx":wq,"tx":Pi,"ux":Ni,"vx":oi,"wx":ni,"xx":jn,"yx":vq,"zx":uq,"Ax":tq,"Bx":Ff,"Cx":Ef,"Dx":Da,"Ex":Ya,"Fx":sq,"Gx":mb,"Hx":rq,"Ix":qq,"Jx":nb,"Kx":fb,"Lx":eb,"Mx":Oc,"Nx":Nc,"Ox":oc,"Px":Kc,"Qx":Oi,"Rx":Mi,"Sx":Li,"Tx":Ki,"Ux":oi,"Vx":ni,"Wx":Ri,"Xx":Qi,"Yx":Af,"Zx":zf,"_x":Cf,"$x":Bf,"ay":ij,"by":hj,"cy":ii,"dy":hi,"ey":Hi,"fy":Gi,"gy":Fi,"hy":Ei,"iy":Di,"jy":Ci,"ky":Bi,"ly":Ai,"my":zi,"ny":yi,"oy":xi,"py":wi,"qy":vi,"ry":ui,"sy":ti,"ty":si,"uy":zx,"vy":pq,"wy":Nq,"xy":oq,"yy":Ji,"zy":Ii,"Ay":nq,"By":mq,"Cy":lq,"Dy":kq,"Ey":jq,"Fy":iq,"Gy":hq,"Hy":gq,"Iy":fq,"Jy":eq,"Ky":dq,"Ly":cq,"My":bq,"Ny":aq,"Oy":$p,"Py":_p,"Qy":Zp,"Ry":Yp,"Sy":Xp,"Ty":Vp,"Uy":Up,"Vy":Tp,"Wy":Sp,"Xy":Rp,"Yy":Qp,"Zy":Pp,"_y":Op,"$y":Np,"az":Mp,"bz":Lp,"cz":Kp,"dz":Jp,"ez":ld,"fz":kd,"gz":tc,"hz":jd,"iz":id,"jz":dd,"kz":bd,"lz":ad,"mz":$c,"nz":_c,"oz":Zc,"pz":Yc,"qz":Xc,"rz":Wc,"sz":Vc,"tz":Uc,"uz":Tc,"vz":qc,"wz":Sc,"xz":Rc,"yz":Qc,"zz":Jb,"Az":Pc,"Bz":Mc,"Cz":lb,"Dz":kb,"Ez":lb,"Fz":kb,"Gz":pc,"Hz":Ip,"Iz":Hp,"Jz":Gp,"Kz":Fp,"Lz":Ep,"Mz":Dp,"Nz":Cp,"Oz":Ap,"Pz":zp,"Qz":yp,"Rz":Lc,"Sz":xp,"Tz":wp,"Uz":ma,"Vz":vp,"Wz":ma,"Xz":Ya,"Yz":de,"Zz":nb,"_z":up,"$z":tp,"aA":sp,"bA":Ge,"cA":rp,"dA":qp,"eA":_d,"fA":Yd,"gA":Rd,"hA":$e,"iA":Gj,"jA":Fj,"kA":Oe,"lA":ye,"mA":re,"nA":ne,"oA":ke,"pA":je,"qA":nd,"rA":he,"sA":ge,"tA":fe,"uA":ck,"vA":pp,"wA":Xj,"xA":Uj,"yA":Rj,"zA":Pj,"AA":Nj,"BA":Uf,"CA":Mj,"DA":Lj,"EA":Kj,"FA":Jj,"GA":Ij,"HA":Hj,"IA":$d,"JA":yf,"KA":xf,"LA":wf,"MA":uf,"NA":tf,"OA":ma,"PA":op,"QA":np,"RA":mp,"SA":lp,"TA":kp,"UA":jp,"VA":ip,"WA":Da,"XA":ei,"YA":pf,"ZA":of,"_A":ci,"$A":bi,"aB":hp,"bB":ei,"cB":pf,"dB":of,"eB":pf,"fB":of,"gB":ci,"hB":bi,"iB":ha,"jB":Yf}}return ja(ka)} -// EMSCRIPTEN_END_ASM - - -)(a)}function Aa(a){return{then:function(c){c({instance:new za(a)})}}}var Ba=Error,WebAssembly={};wa=[];"object"!=typeof WebAssembly&&Ca("no native wasm support detected"); -var Da,Ea=!1,Fa="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0; -function Ga(a,c){if(a){var d=Ha,e=a+c;for(c=a;d[c]&&!(c>=e);)++c;if(16g?e+=String.fromCharCode(g):(g-=65536,e+=String.fromCharCode(55296|g>>10,56320|g&1023))}}else e+=String.fromCharCode(g)}a=e}}else a="";return a} -var Ja,Ha,Ka,La,Ma,ya=b.INITIAL_MEMORY||67108864;65536<=ya||Ca("INITIAL_MEMORY should be larger than STACK_SIZE, was "+ya+"! (STACK_SIZE=65536)");Da=b.wasmMemory?b.wasmMemory:new xa;var Na=Da.buffer;b.HEAP8=Ja=new Int8Array(Na);b.HEAP16=new Int16Array(Na);b.HEAP32=Ka=new Int32Array(Na);b.HEAPU8=Ha=new Uint8Array(Na);b.HEAPU16=new Uint16Array(Na);b.HEAPU32=new Uint32Array(Na);b.HEAPF32=La=new Float32Array(Na);b.HEAPF64=Ma=new Float64Array(Na);ya=Da.buffer.byteLength;var Oa,Pa=[],Qa=[],Ra=[],Sa=!1; -function Ta(){var a=b.preRun.shift();Pa.unshift(a)}Math.imul||(Math.imul=function(a,c){var d=a&65535,e=c&65535;return d*e+((a>>>16)*e+d*(c>>>16)<<16)|0});if(!Math.fround){var Ua=new Float32Array(1);Math.fround=function(a){Ua[0]=a;return Ua[0]}}Math.clz32||(Math.clz32=function(a){var c=32,d=a>>16;d&&(c-=16,a=d);if(d=a>>8)c-=8,a=d;if(d=a>>4)c-=4,a=d;if(d=a>>2)c-=2,a=d;return a>>1?c-2:c-a});Math.trunc||(Math.trunc=function(a){return 0>a?Math.ceil(a):Math.floor(a)});var Va=0,Wa=null,Xa=null; -function Ca(a){if(b.onAbort)b.onAbort(a);a="Aborted("+a+")";va(a);Ea=!0;a=new Ba(a+". Build with -sASSERTIONS for more info.");ka(a);throw a;}var Ya="data:application/octet-stream;base64,",Za;Za="<<< WASM_BINARY_FILE >>>";if(!Za.startsWith(Ya)){var $a=Za;Za=b.locateFile?b.locateFile($a,pa):pa+$a}function ab(a){try{if(a==Za&&wa)return new Uint8Array(wa);var c=ua(a);if(c)return c;if(sa)return sa(a);throw"both async and sync fetching of the wasm failed";}catch(d){Ca(d)}} -function bb(a){if(!wa&&(ma||na)){if("function"==typeof fetch&&!a.startsWith("file://"))return fetch(a,{credentials:"same-origin"}).then(function(c){if(!c.ok)throw"failed to load wasm binary file at '"+a+"'";return c.arrayBuffer()}).catch(function(){return ab(a)});if(ra)return new Promise(function(c,d){ra(a,function(e){c(new Uint8Array(e))},d)})}return Promise.resolve().then(function(){return ab(a)})} -function cb(a,c,d){return bb(a).then(function(){return Aa(c)}).then(function(e){return e}).then(d,function(e){va("failed to asynchronously prepare wasm: "+e);Ca(e)})} -function db(a,c){var d=Za;return wa||"function"!=typeof WebAssembly.instantiateStreaming||d.startsWith(Ya)||d.startsWith("file://")||oa||"function"!=typeof fetch?cb(d,a,c):fetch(d,{credentials:"same-origin"}).then(function(e){return WebAssembly.instantiateStreaming(e,a).then(c,function(g){va("wasm streaming compile failed: "+g);va("falling back to ArrayBuffer instantiation");return cb(d,a,c)})})} -var eb={27338:function(a,c,d,e){a=b.getCache(b.DebugDrawer)[a];if(!a.hasOwnProperty("drawLine"))throw"a JSImplementation must implement all functions, you forgot DebugDrawer::drawLine.";a.drawLine(c,d,e)},27558:function(a,c,d,e,g,m){a=b.getCache(b.DebugDrawer)[a];if(!a.hasOwnProperty("drawContactPoint"))throw"a JSImplementation must implement all functions, you forgot DebugDrawer::drawContactPoint.";a.drawContactPoint(c,d,e,g,m)},27808:function(a,c){a=b.getCache(b.DebugDrawer)[a];if(!a.hasOwnProperty("reportErrorWarning"))throw"a JSImplementation must implement all functions, you forgot DebugDrawer::reportErrorWarning."; -a.reportErrorWarning(c)},28052:function(a,c,d){a=b.getCache(b.DebugDrawer)[a];if(!a.hasOwnProperty("draw3dText"))throw"a JSImplementation must implement all functions, you forgot DebugDrawer::draw3dText.";a.draw3dText(c,d)},28275:function(a,c){a=b.getCache(b.DebugDrawer)[a];if(!a.hasOwnProperty("setDebugMode"))throw"a JSImplementation must implement all functions, you forgot DebugDrawer::setDebugMode.";a.setDebugMode(c)},28501:function(a){a=b.getCache(b.DebugDrawer)[a];if(!a.hasOwnProperty("getDebugMode"))throw"a JSImplementation must implement all functions, you forgot DebugDrawer::getDebugMode."; -return a.getDebugMode()},28732:function(a,c){a=b.getCache(b.MotionState)[a];if(!a.hasOwnProperty("getWorldTransform"))throw"a JSImplementation must implement all functions, you forgot MotionState::getWorldTransform.";a.getWorldTransform(c)},28973:function(a,c){a=b.getCache(b.MotionState)[a];if(!a.hasOwnProperty("setWorldTransform"))throw"a JSImplementation must implement all functions, you forgot MotionState::setWorldTransform.";a.setWorldTransform(c)},29214:function(a,c,d,e,g,m,y,W){a=b.getCache(b.ConcreteContactResultCallback)[a]; -if(!a.hasOwnProperty("addSingleResult"))throw"a JSImplementation must implement all functions, you forgot ConcreteContactResultCallback::addSingleResult.";return a.addSingleResult(c,d,e,g,m,y,W)}};function fb(a){for(;0>=2;e=Ha[c++];)d+=105!=e&d,gb.push(105==e?Ka[d]:Ma[d++>>1]),++d;return eb[a].apply(null,gb)} -var ib=[],jb=void 0,kb=[],lb="function"==typeof atob?atob:function(a){var c="",d=0;a=a.replace(/[^A-Za-z0-9\+\/=]/g,"");do{var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(a.charAt(d++));var g="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(a.charAt(d++));var m="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(a.charAt(d++));var y="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(a.charAt(d++)); -e=e<<2|g>>4;g=(g&15)<<4|m>>2;var W=(m&3)<<6|y;c+=String.fromCharCode(e);64!==m&&(c+=String.fromCharCode(g));64!==y&&(c+=String.fromCharCode(W))}while(d=ib.length&&(ib.length=e+1),ib[e]=g=Oa.get(e));(e=g)&&jb.set(e,d)}}if(c=jb.get(a)||0)return c;if(kb.length)c=kb.pop();else{try{Oa.grow(1)}catch(m){if(!(m instanceof RangeError))throw m;throw"Unable to grow wasm table. Set ALLOW_TABLE_GROWTH.";}c=Oa.length-1}try{d=c,Oa.set(d,a),ib[d]=Oa.get(d)}catch(m){if(!(m instanceof TypeError))throw m;d=c;Oa.set(d,void 0);ib[d]=Oa.get(d)}jb.set(a, -c);return c};var aE;Xa=function bE(){aE||cE();aE||(Xa=bE)}; -function cE(){function a(){if(!aE&&(aE=!0,b.calledRun=!0,!Ea)){Sa=!0;fb(Qa);ja(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();Ra.unshift(c)}fb(Ra)}}if(!(0=eE?(0>>=0;switch(c.BYTES_PER_ELEMENT){case 2:d>>>=1;break;case 4:d>>>=2;break;case 8:d>>>=3}for(var e=0;e=e?c++:2047>=e?c+=2:55296<=e&&57343>=e?(c+=4,++d):c+=3}c=Array(c+1);e=c.length;d=0;if(0=m){var y=a.charCodeAt(++g);m=65536+((m&1023)<<10)|y&1023}if(127>=m){if(d>=e)break;c[d++]=m}else{if(2047>=m){if(d+1>=e)break;c[d++]=192|m>>6}else{if(65535>=m){if(d+2>=e)break;c[d++]=224|m>>12}else{if(d+3>=e)break;c[d++]=240|m>>18;c[d++]= -128|m>>12&63}c[d++]=128|m>>6&63}c[d++]=128|m&63}}c[d]=0}a=jE(c,Ja);kE(c,Ja,a);return a}return a}function mE(a){if("object"===typeof a){var c=jE(a,La);kE(a,La,c);return c}return a}function l(){throw"cannot construct a btCollisionShape, no constructor in IDL";}l.prototype=Object.create(f.prototype);l.prototype.constructor=l;l.prototype.lB=l;l.mB={};b.btCollisionShape=l;l.prototype.setLocalScaling=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);nb(c,a)}; -l.prototype.getLocalScaling=function(){return k(ob(this.kB),n)};l.prototype.calculateLocalInertia=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);pb(d,a,c)};l.prototype.setMargin=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);qb(c,a)};l.prototype.getMargin=function(){return rb(this.kB)};l.prototype.__destroy__=function(){sb(this.kB)};function nE(){throw"cannot construct a btCollisionWorld, no constructor in IDL";}nE.prototype=Object.create(f.prototype); -nE.prototype.constructor=nE;nE.prototype.lB=nE;nE.mB={};b.btCollisionWorld=nE;nE.prototype.getDispatcher=function(){return k(tb(this.kB),oE)};nE.prototype.rayTest=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);ub(e,a,c,d)};nE.prototype.getPairCache=function(){return k(vb(this.kB),pE)};nE.prototype.getDispatchInfo=function(){return k(wb(this.kB),q)}; -nE.prototype.addCollisionObject=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);void 0===c?xb(e,a):void 0===d?yb(e,a,c):zb(e,a,c,d)};nE.prototype.removeCollisionObject=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Ab(c,a)};nE.prototype.getBroadphase=function(){return k(Bb(this.kB),qE)}; -nE.prototype.convexSweepTest=function(a,c,d,e,g){var m=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);g&&"object"===typeof g&&(g=g.kB);Cb(m,a,c,d,e,g)};nE.prototype.contactPairTest=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);Db(e,a,c,d)}; -nE.prototype.contactTest=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);Fb(d,a,c)};nE.prototype.updateSingleAabb=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Gb(c,a)};nE.prototype.setDebugDrawer=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Hb(c,a)};nE.prototype.getDebugDrawer=function(){return k(Ib(this.kB),rE)};nE.prototype.debugDrawWorld=function(){Jb(this.kB)}; -nE.prototype.debugDrawObject=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);Kb(e,a,c,d)};nE.prototype.__destroy__=function(){Lb(this.kB)};function r(){throw"cannot construct a btCollisionObject, no constructor in IDL";}r.prototype=Object.create(f.prototype);r.prototype.constructor=r;r.prototype.lB=r;r.mB={};b.btCollisionObject=r; -r.prototype.setAnisotropicFriction=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);Mb(d,a,c)};r.prototype.getCollisionShape=function(){return k(Nb(this.kB),l)};r.prototype.setContactProcessingThreshold=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Ob(c,a)};r.prototype.setActivationState=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Pb(c,a)}; -r.prototype.forceActivationState=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Qb(c,a)};r.prototype.activate=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);void 0===a?Rb(c):Sb(c,a)};r.prototype.isActive=function(){return!!Tb(this.kB)};r.prototype.isKinematicObject=function(){return!!Ub(this.kB)};r.prototype.isStaticObject=function(){return!!Vb(this.kB)};r.prototype.isStaticOrKinematicObject=function(){return!!Wb(this.kB)};r.prototype.getRestitution=function(){return Xb(this.kB)}; -r.prototype.getFriction=function(){return Yb(this.kB)};r.prototype.getRollingFriction=function(){return Zb(this.kB)};r.prototype.setRestitution=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);$b(c,a)};r.prototype.setFriction=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);ac(c,a)};r.prototype.setRollingFriction=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);bc(c,a)};r.prototype.getWorldTransform=function(){return k(cc(this.kB),t)};r.prototype.getCollisionFlags=function(){return dc(this.kB)}; -r.prototype.setCollisionFlags=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);ec(c,a)};r.prototype.setWorldTransform=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);gc(c,a)};r.prototype.setCollisionShape=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);hc(c,a)};r.prototype.setCcdMotionThreshold=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);ic(c,a)};r.prototype.setCcdSweptSphereRadius=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);jc(c,a)}; -r.prototype.getUserIndex=function(){return kc(this.kB)};r.prototype.setUserIndex=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);lc(c,a)};r.prototype.getUserPointer=function(){return k(mc(this.kB),sE)};r.prototype.setUserPointer=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);nc(c,a)};r.prototype.getBroadphaseHandle=function(){return k(oc(this.kB),tE)};r.prototype.__destroy__=function(){pc(this.kB)}; -function uE(){throw"cannot construct a btConcaveShape, no constructor in IDL";}uE.prototype=Object.create(l.prototype);uE.prototype.constructor=uE;uE.prototype.lB=uE;uE.mB={};b.btConcaveShape=uE;uE.prototype.setLocalScaling=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);qc(c,a)};uE.prototype.getLocalScaling=function(){return k(sc(this.kB),n)};uE.prototype.calculateLocalInertia=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);tc(d,a,c)}; -uE.prototype.__destroy__=function(){uc(this.kB)};function vE(){throw"cannot construct a btCollisionAlgorithm, no constructor in IDL";}vE.prototype=Object.create(f.prototype);vE.prototype.constructor=vE;vE.prototype.lB=vE;vE.mB={};b.btCollisionAlgorithm=vE;vE.prototype.__destroy__=function(){vc(this.kB)};function wE(){throw"cannot construct a btTypedConstraint, no constructor in IDL";}wE.prototype=Object.create(f.prototype);wE.prototype.constructor=wE;wE.prototype.lB=wE;wE.mB={}; -b.btTypedConstraint=wE;wE.prototype.enableFeedback=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);wc(c,a)};wE.prototype.getBreakingImpulseThreshold=function(){return xc(this.kB)};wE.prototype.setBreakingImpulseThreshold=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);yc(c,a)};wE.prototype.getParam=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);return zc(d,a,c)}; -wE.prototype.setParam=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);Ac(e,a,c,d)};wE.prototype.__destroy__=function(){Bc(this.kB)};function xE(){throw"cannot construct a btDynamicsWorld, no constructor in IDL";}xE.prototype=Object.create(nE.prototype);xE.prototype.constructor=xE;xE.prototype.lB=xE;xE.mB={};b.btDynamicsWorld=xE;xE.prototype.addAction=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Cc(c,a)}; -xE.prototype.removeAction=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Dc(c,a)};xE.prototype.getSolverInfo=function(){return k(Ec(this.kB),u)};xE.prototype.setInternalTickCallback=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);void 0===c?Fc(e,a):void 0===d?Gc(e,a,c):Ic(e,a,c,d)};xE.prototype.getDispatcher=function(){return k(Jc(this.kB),oE)}; -xE.prototype.rayTest=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);Kc(e,a,c,d)};xE.prototype.getPairCache=function(){return k(Lc(this.kB),pE)};xE.prototype.getDispatchInfo=function(){return k(Mc(this.kB),q)}; -xE.prototype.addCollisionObject=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);void 0===c?Nc(e,a):void 0===d?Oc(e,a,c):Pc(e,a,c,d)};xE.prototype.removeCollisionObject=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Qc(c,a)};xE.prototype.getBroadphase=function(){return k(Rc(this.kB),qE)}; -xE.prototype.convexSweepTest=function(a,c,d,e,g){var m=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);g&&"object"===typeof g&&(g=g.kB);Sc(m,a,c,d,e,g)};xE.prototype.contactPairTest=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);Tc(e,a,c,d)}; -xE.prototype.contactTest=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);Wc(d,a,c)};xE.prototype.updateSingleAabb=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Xc(c,a)};xE.prototype.setDebugDrawer=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Yc(c,a)};xE.prototype.getDebugDrawer=function(){return k(Zc(this.kB),rE)};xE.prototype.debugDrawWorld=function(){$c(this.kB)}; -xE.prototype.debugDrawObject=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);ad(e,a,c,d)};xE.prototype.__destroy__=function(){bd(this.kB)};function rE(){throw"cannot construct a btIDebugDraw, no constructor in IDL";}rE.prototype=Object.create(f.prototype);rE.prototype.constructor=rE;rE.prototype.lB=rE;rE.mB={};b.btIDebugDraw=rE; -rE.prototype.drawLine=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);cd(e,a,c,d)};rE.prototype.drawContactPoint=function(a,c,d,e,g){var m=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);g&&"object"===typeof g&&(g=g.kB);dd(m,a,c,d,e,g)}; -rE.prototype.reportErrorWarning=function(a){var c=this.kB;iE();a=a&&"object"===typeof a?a.kB:lE(a);ed(c,a)};rE.prototype.draw3dText=function(a,c){var d=this.kB;iE();a&&"object"===typeof a&&(a=a.kB);c=c&&"object"===typeof c?c.kB:lE(c);fd(d,a,c)};rE.prototype.setDebugMode=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);gd(c,a)};rE.prototype.getDebugMode=function(){return hd(this.kB)};rE.prototype.__destroy__=function(){jd(this.kB)}; -function n(a,c,d){a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);this.kB=void 0===a?kd():void 0===c?_emscripten_bind_btVector3_btVector3_1(a):void 0===d?_emscripten_bind_btVector3_btVector3_2(a,c):ld(a,c,d);h(n)[this.kB]=this}n.prototype=Object.create(f.prototype);n.prototype.constructor=n;n.prototype.lB=n;n.mB={};b.btVector3=n;n.prototype.length=n.prototype.length=function(){return md(this.kB)};n.prototype.x=n.prototype.x=function(){return nd(this.kB)}; -n.prototype.y=n.prototype.y=function(){return od(this.kB)};n.prototype.z=n.prototype.z=function(){return pd(this.kB)};n.prototype.setX=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);qd(c,a)};n.prototype.setY=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);rd(c,a)};n.prototype.setZ=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);sd(c,a)}; -n.prototype.setValue=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);td(e,a,c,d)};n.prototype.normalize=n.prototype.normalize=function(){ud(this.kB)};n.prototype.rotate=n.prototype.rotate=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);return k(vd(d,a,c),n)};n.prototype.dot=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return wd(c,a)}; -n.prototype.op_mul=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return k(xd(c,a),n)};n.prototype.op_add=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return k(yd(c,a),n)};n.prototype.op_sub=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return k(zd(c,a),n)};n.prototype.__destroy__=function(){Ad(this.kB)};function yE(){throw"cannot construct a btQuadWord, no constructor in IDL";}yE.prototype=Object.create(f.prototype);yE.prototype.constructor=yE; -yE.prototype.lB=yE;yE.mB={};b.btQuadWord=yE;yE.prototype.x=yE.prototype.x=function(){return Bd(this.kB)};yE.prototype.y=yE.prototype.y=function(){return Cd(this.kB)};yE.prototype.z=yE.prototype.z=function(){return Dd(this.kB)};yE.prototype.w=yE.prototype.w=function(){return Ed(this.kB)};yE.prototype.setX=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Fd(c,a)};yE.prototype.setY=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Gd(c,a)}; -yE.prototype.setZ=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Hd(c,a)};yE.prototype.setW=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Id(c,a)};yE.prototype.__destroy__=function(){Jd(this.kB)};function zE(){throw"cannot construct a btMotionState, no constructor in IDL";}zE.prototype=Object.create(f.prototype);zE.prototype.constructor=zE;zE.prototype.lB=zE;zE.mB={};b.btMotionState=zE; -zE.prototype.getWorldTransform=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Kd(c,a)};zE.prototype.setWorldTransform=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Ld(c,a)};zE.prototype.__destroy__=function(){Md(this.kB)};function v(){throw"cannot construct a RayResultCallback, no constructor in IDL";}v.prototype=Object.create(f.prototype);v.prototype.constructor=v;v.prototype.lB=v;v.mB={};b.RayResultCallback=v;v.prototype.hasHit=function(){return!!Nd(this.kB)}; -v.prototype.get_m_collisionFilterGroup=v.prototype.nB=function(){return Od(this.kB)};v.prototype.set_m_collisionFilterGroup=v.prototype.pB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Pd(c,a)};Object.defineProperty(v.prototype,"m_collisionFilterGroup",{get:v.prototype.nB,set:v.prototype.pB});v.prototype.get_m_collisionFilterMask=v.prototype.oB=function(){return Qd(this.kB)}; -v.prototype.set_m_collisionFilterMask=v.prototype.qB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Rd(c,a)};Object.defineProperty(v.prototype,"m_collisionFilterMask",{get:v.prototype.oB,set:v.prototype.qB});v.prototype.get_m_closestHitFraction=v.prototype.rB=function(){return Sd(this.kB)};v.prototype.set_m_closestHitFraction=v.prototype.sB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Td(c,a)};Object.defineProperty(v.prototype,"m_closestHitFraction",{get:v.prototype.rB,set:v.prototype.sB}); -v.prototype.get_m_collisionObject=v.prototype.yB=function(){return k(Ud(this.kB),r)};v.prototype.set_m_collisionObject=v.prototype.GB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Vd(c,a)};Object.defineProperty(v.prototype,"m_collisionObject",{get:v.prototype.yB,set:v.prototype.GB});v.prototype.get_m_flags=v.prototype.vB=function(){return Wd(this.kB)};v.prototype.set_m_flags=v.prototype.wB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Xd(c,a)}; -Object.defineProperty(v.prototype,"m_flags",{get:v.prototype.vB,set:v.prototype.wB});v.prototype.__destroy__=function(){Yd(this.kB)};function AE(){throw"cannot construct a ContactResultCallback, no constructor in IDL";}AE.prototype=Object.create(f.prototype);AE.prototype.constructor=AE;AE.prototype.lB=AE;AE.mB={};b.ContactResultCallback=AE; -AE.prototype.addSingleResult=function(a,c,d,e,g,m,y){var W=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);g&&"object"===typeof g&&(g=g.kB);m&&"object"===typeof m&&(m=m.kB);y&&"object"===typeof y&&(y=y.kB);return Zd(W,a,c,d,e,g,m,y)};AE.prototype.__destroy__=function(){$d(this.kB)};function w(){throw"cannot construct a ConvexResultCallback, no constructor in IDL";}w.prototype=Object.create(f.prototype); -w.prototype.constructor=w;w.prototype.lB=w;w.mB={};b.ConvexResultCallback=w;w.prototype.hasHit=function(){return!!ae(this.kB)};w.prototype.get_m_collisionFilterGroup=w.prototype.nB=function(){return be(this.kB)};w.prototype.set_m_collisionFilterGroup=w.prototype.pB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);ce(c,a)};Object.defineProperty(w.prototype,"m_collisionFilterGroup",{get:w.prototype.nB,set:w.prototype.pB});w.prototype.get_m_collisionFilterMask=w.prototype.oB=function(){return de(this.kB)}; -w.prototype.set_m_collisionFilterMask=w.prototype.qB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);ee(c,a)};Object.defineProperty(w.prototype,"m_collisionFilterMask",{get:w.prototype.oB,set:w.prototype.qB});w.prototype.get_m_closestHitFraction=w.prototype.rB=function(){return fe(this.kB)};w.prototype.set_m_closestHitFraction=w.prototype.sB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);ge(c,a)};Object.defineProperty(w.prototype,"m_closestHitFraction",{get:w.prototype.rB,set:w.prototype.sB}); -w.prototype.__destroy__=function(){he(this.kB)};function BE(){throw"cannot construct a btConvexShape, no constructor in IDL";}BE.prototype=Object.create(l.prototype);BE.prototype.constructor=BE;BE.prototype.lB=BE;BE.mB={};b.btConvexShape=BE;BE.prototype.setLocalScaling=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);ie(c,a)};BE.prototype.getLocalScaling=function(){return k(je(this.kB),n)}; -BE.prototype.calculateLocalInertia=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);ke(d,a,c)};BE.prototype.setMargin=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);le(c,a)};BE.prototype.getMargin=function(){return me(this.kB)};BE.prototype.__destroy__=function(){ne(this.kB)};function CE(a,c){a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);this.kB=oe(a,c);h(CE)[this.kB]=this}CE.prototype=Object.create(l.prototype); -CE.prototype.constructor=CE;CE.prototype.lB=CE;CE.mB={};b.btCapsuleShape=CE;CE.prototype.setMargin=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);pe(c,a)};CE.prototype.getMargin=function(){return qe(this.kB)};CE.prototype.getUpAxis=function(){return re(this.kB)};CE.prototype.getRadius=function(){return se(this.kB)};CE.prototype.getHalfHeight=function(){return te(this.kB)};CE.prototype.setLocalScaling=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);ue(c,a)}; -CE.prototype.getLocalScaling=function(){return k(ve(this.kB),n)};CE.prototype.calculateLocalInertia=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);we(d,a,c)};CE.prototype.__destroy__=function(){xe(this.kB)};function DE(a){a&&"object"===typeof a&&(a=a.kB);this.kB=ye(a);h(DE)[this.kB]=this}DE.prototype=Object.create(l.prototype);DE.prototype.constructor=DE;DE.prototype.lB=DE;DE.mB={};b.btCylinderShape=DE; -DE.prototype.setMargin=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);ze(c,a)};DE.prototype.getMargin=function(){return Ae(this.kB)};DE.prototype.setLocalScaling=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Be(c,a)};DE.prototype.getLocalScaling=function(){return k(Ce(this.kB),n)};DE.prototype.calculateLocalInertia=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);De(d,a,c)};DE.prototype.__destroy__=function(){Ee(this.kB)}; -function EE(a,c){a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);this.kB=Fe(a,c);h(EE)[this.kB]=this}EE.prototype=Object.create(l.prototype);EE.prototype.constructor=EE;EE.prototype.lB=EE;EE.mB={};b.btConeShape=EE;EE.prototype.setLocalScaling=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Ge(c,a)};EE.prototype.getLocalScaling=function(){return k(He(this.kB),n)}; -EE.prototype.calculateLocalInertia=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);Ie(d,a,c)};EE.prototype.__destroy__=function(){Je(this.kB)};function FE(){throw"cannot construct a btStridingMeshInterface, no constructor in IDL";}FE.prototype=Object.create(f.prototype);FE.prototype.constructor=FE;FE.prototype.lB=FE;FE.mB={};b.btStridingMeshInterface=FE;FE.prototype.setScaling=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Ke(c,a)}; -FE.prototype.__destroy__=function(){Le(this.kB)};function GE(){throw"cannot construct a btTriangleMeshShape, no constructor in IDL";}GE.prototype=Object.create(uE.prototype);GE.prototype.constructor=GE;GE.prototype.lB=GE;GE.mB={};b.btTriangleMeshShape=GE;GE.prototype.setLocalScaling=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Me(c,a)};GE.prototype.getLocalScaling=function(){return k(Ne(this.kB),n)}; -GE.prototype.calculateLocalInertia=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);Oe(d,a,c)};GE.prototype.__destroy__=function(){Pe(this.kB)};function HE(){throw"cannot construct a btPrimitiveManagerBase, no constructor in IDL";}HE.prototype=Object.create(f.prototype);HE.prototype.constructor=HE;HE.prototype.lB=HE;HE.mB={};b.btPrimitiveManagerBase=HE;HE.prototype.is_trimesh=function(){return!!Qe(this.kB)};HE.prototype.get_primitive_count=function(){return Re(this.kB)}; -HE.prototype.get_primitive_box=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);Se(d,a,c)};HE.prototype.get_primitive_triangle=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);Te(d,a,c)};HE.prototype.__destroy__=function(){Ue(this.kB)};function IE(){throw"cannot construct a btGImpactShapeInterface, no constructor in IDL";}IE.prototype=Object.create(uE.prototype);IE.prototype.constructor=IE;IE.prototype.lB=IE; -IE.mB={};b.btGImpactShapeInterface=IE;IE.prototype.updateBound=function(){Ve(this.kB)};IE.prototype.postUpdate=function(){We(this.kB)};IE.prototype.getShapeType=function(){return Xe(this.kB)};IE.prototype.getName=function(){return Ga(Ye(this.kB))};IE.prototype.getGImpactShapeType=function(){return Ze(this.kB)};IE.prototype.getPrimitiveManager=function(){return k($e(this.kB),HE)};IE.prototype.getNumChildShapes=function(){return af(this.kB)};IE.prototype.childrenHasTransform=function(){return!!bf(this.kB)}; -IE.prototype.needsRetrieveTriangles=function(){return!!cf(this.kB)};IE.prototype.needsRetrieveTetrahedrons=function(){return!!df(this.kB)};IE.prototype.getBulletTriangle=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);ef(d,a,c)};IE.prototype.getBulletTetrahedron=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);ff(d,a,c)}; -IE.prototype.getChildShape=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return k(gf(c,a),l)};IE.prototype.getChildTransform=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return k(hf(c,a),t)};IE.prototype.setChildTransform=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);jf(d,a,c)};IE.prototype.setLocalScaling=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);kf(c,a)}; -IE.prototype.getLocalScaling=function(){return k(lf(this.kB),n)};IE.prototype.calculateLocalInertia=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);mf(d,a,c)};IE.prototype.__destroy__=function(){nf(this.kB)};function JE(){throw"cannot construct a btActivatingCollisionAlgorithm, no constructor in IDL";}JE.prototype=Object.create(vE.prototype);JE.prototype.constructor=JE;JE.prototype.lB=JE;JE.mB={};b.btActivatingCollisionAlgorithm=JE; -JE.prototype.__destroy__=function(){of(this.kB)};function KE(a){a&&"object"===typeof a&&(a=a.kB);this.kB=void 0===a?pf():qf(a);h(KE)[this.kB]=this}KE.prototype=Object.create(f.prototype);KE.prototype.constructor=KE;KE.prototype.lB=KE;KE.mB={};b.btDefaultCollisionConfiguration=KE;KE.prototype.__destroy__=function(){rf(this.kB)};function oE(){throw"cannot construct a btDispatcher, no constructor in IDL";}oE.prototype=Object.create(f.prototype);oE.prototype.constructor=oE;oE.prototype.lB=oE;oE.mB={}; -b.btDispatcher=oE;oE.prototype.getNumManifolds=function(){return sf(this.kB)};oE.prototype.getManifoldByIndexInternal=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return k(tf(c,a),LE)};oE.prototype.__destroy__=function(){uf(this.kB)}; -function ME(a,c,d,e,g){a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);g&&"object"===typeof g&&(g=g.kB);this.kB=void 0===e?vf(a,c,d):void 0===g?_emscripten_bind_btGeneric6DofConstraint_btGeneric6DofConstraint_4(a,c,d,e):wf(a,c,d,e,g);h(ME)[this.kB]=this}ME.prototype=Object.create(wE.prototype);ME.prototype.constructor=ME;ME.prototype.lB=ME;ME.mB={};b.btGeneric6DofConstraint=ME; -ME.prototype.setLinearLowerLimit=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);xf(c,a)};ME.prototype.setLinearUpperLimit=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);yf(c,a)};ME.prototype.setAngularLowerLimit=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);zf(c,a)};ME.prototype.setAngularUpperLimit=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Af(c,a)};ME.prototype.getFrameOffsetA=function(){return k(Bf(this.kB),t)}; -ME.prototype.enableFeedback=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Cf(c,a)};ME.prototype.getBreakingImpulseThreshold=function(){return Df(this.kB)};ME.prototype.setBreakingImpulseThreshold=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Ef(c,a)};ME.prototype.getParam=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);return Ff(d,a,c)}; -ME.prototype.setParam=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);Gf(e,a,c,d)};ME.prototype.__destroy__=function(){Hf(this.kB)};function x(a,c,d,e){a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);this.kB=If(a,c,d,e);h(x)[this.kB]=this}x.prototype=Object.create(xE.prototype);x.prototype.constructor=x;x.prototype.lB=x;x.mB={}; -b.btDiscreteDynamicsWorld=x;x.prototype.setGravity=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Jf(c,a)};x.prototype.getGravity=function(){return k(Kf(this.kB),n)};x.prototype.addRigidBody=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);void 0===c?Lf(e,a):void 0===d?_emscripten_bind_btDiscreteDynamicsWorld_addRigidBody_2(e,a,c):Mf(e,a,c,d)}; -x.prototype.removeRigidBody=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Nf(c,a)};x.prototype.addConstraint=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);void 0===c?Of(d,a):Pf(d,a,c)};x.prototype.removeConstraint=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Qf(c,a)}; -x.prototype.stepSimulation=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);return void 0===c?Rf(e,a):void 0===d?Sf(e,a,c):Tf(e,a,c,d)};x.prototype.setContactAddedCallback=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Uf(c,a)};x.prototype.setContactProcessedCallback=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Vf(c,a)}; -x.prototype.setContactDestroyedCallback=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Wf(c,a)};x.prototype.getDispatcher=function(){return k(Xf(this.kB),oE)};x.prototype.rayTest=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);Yf(e,a,c,d)};x.prototype.getPairCache=function(){return k(Zf(this.kB),pE)};x.prototype.getDispatchInfo=function(){return k($f(this.kB),q)}; -x.prototype.addCollisionObject=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);void 0===c?ag(e,a):void 0===d?bg(e,a,c):cg(e,a,c,d)};x.prototype.removeCollisionObject=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);dg(c,a)};x.prototype.getBroadphase=function(){return k(eg(this.kB),qE)}; -x.prototype.convexSweepTest=function(a,c,d,e,g){var m=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);g&&"object"===typeof g&&(g=g.kB);fg(m,a,c,d,e,g)};x.prototype.contactPairTest=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);gg(e,a,c,d)}; -x.prototype.contactTest=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);hg(d,a,c)};x.prototype.updateSingleAabb=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);ig(c,a)};x.prototype.setDebugDrawer=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);jg(c,a)};x.prototype.getDebugDrawer=function(){return k(kg(this.kB),rE)};x.prototype.debugDrawWorld=function(){lg(this.kB)}; -x.prototype.debugDrawObject=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);mg(e,a,c,d)};x.prototype.addAction=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);ng(c,a)};x.prototype.removeAction=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);og(c,a)};x.prototype.getSolverInfo=function(){return k(pg(this.kB),u)}; -x.prototype.setInternalTickCallback=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);void 0===c?qg(e,a):void 0===d?rg(e,a,c):sg(e,a,c,d)};x.prototype.__destroy__=function(){tg(this.kB)};function NE(){throw"cannot construct a btVehicleRaycaster, no constructor in IDL";}NE.prototype=Object.create(f.prototype);NE.prototype.constructor=NE;NE.prototype.lB=NE;NE.mB={};b.btVehicleRaycaster=NE; -NE.prototype.castRay=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);ug(e,a,c,d)};NE.prototype.__destroy__=function(){vg(this.kB)};function OE(){throw"cannot construct a btActionInterface, no constructor in IDL";}OE.prototype=Object.create(f.prototype);OE.prototype.constructor=OE;OE.prototype.lB=OE;OE.mB={};b.btActionInterface=OE; -OE.prototype.updateAction=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);wg(d,a,c)};OE.prototype.__destroy__=function(){xg(this.kB)};function z(){this.kB=yg();h(z)[this.kB]=this}z.prototype=Object.create(r.prototype);z.prototype.constructor=z;z.prototype.lB=z;z.mB={};b.btGhostObject=z;z.prototype.getNumOverlappingObjects=function(){return zg(this.kB)}; -z.prototype.getOverlappingObject=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return k(Ag(c,a),r)};z.prototype.setAnisotropicFriction=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);Bg(d,a,c)};z.prototype.getCollisionShape=function(){return k(Cg(this.kB),l)};z.prototype.setContactProcessingThreshold=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Dg(c,a)}; -z.prototype.setActivationState=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Eg(c,a)};z.prototype.forceActivationState=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Fg(c,a)};z.prototype.activate=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);void 0===a?Gg(c):Hg(c,a)};z.prototype.isActive=function(){return!!Ig(this.kB)};z.prototype.isKinematicObject=function(){return!!Jg(this.kB)};z.prototype.isStaticObject=function(){return!!Kg(this.kB)}; -z.prototype.isStaticOrKinematicObject=function(){return!!Lg(this.kB)};z.prototype.getRestitution=function(){return Mg(this.kB)};z.prototype.getFriction=function(){return Ng(this.kB)};z.prototype.getRollingFriction=function(){return Og(this.kB)};z.prototype.setRestitution=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Pg(c,a)};z.prototype.setFriction=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Qg(c,a)}; -z.prototype.setRollingFriction=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Rg(c,a)};z.prototype.getWorldTransform=function(){return k(Sg(this.kB),t)};z.prototype.getCollisionFlags=function(){return Tg(this.kB)};z.prototype.setCollisionFlags=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Ug(c,a)};z.prototype.setWorldTransform=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Vg(c,a)}; -z.prototype.setCollisionShape=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Wg(c,a)};z.prototype.setCcdMotionThreshold=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Xg(c,a)};z.prototype.setCcdSweptSphereRadius=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Yg(c,a)};z.prototype.getUserIndex=function(){return Zg(this.kB)};z.prototype.setUserIndex=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);$g(c,a)}; -z.prototype.getUserPointer=function(){return k(ah(this.kB),sE)};z.prototype.setUserPointer=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);bh(c,a)};z.prototype.getBroadphaseHandle=function(){return k(ch(this.kB),tE)};z.prototype.__destroy__=function(){dh(this.kB)};function PE(){throw"cannot construct a btSoftBodySolver, no constructor in IDL";}PE.prototype=Object.create(f.prototype);PE.prototype.constructor=PE;PE.prototype.lB=PE;PE.mB={};b.btSoftBodySolver=PE;PE.prototype.__destroy__=function(){eh(this.kB)}; -function sE(){throw"cannot construct a VoidPtr, no constructor in IDL";}sE.prototype=Object.create(f.prototype);sE.prototype.constructor=sE;sE.prototype.lB=sE;sE.mB={};b.VoidPtr=sE;sE.prototype.__destroy__=function(){fh(this.kB)};function QE(){this.kB=gh();h(QE)[this.kB]=this}QE.prototype=Object.create(rE.prototype);QE.prototype.constructor=QE;QE.prototype.lB=QE;QE.mB={};b.DebugDrawer=QE; -QE.prototype.drawLine=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);hh(e,a,c,d)};QE.prototype.drawContactPoint=function(a,c,d,e,g){var m=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);g&&"object"===typeof g&&(g=g.kB);ih(m,a,c,d,e,g)}; -QE.prototype.reportErrorWarning=function(a){var c=this.kB;iE();a=a&&"object"===typeof a?a.kB:lE(a);jh(c,a)};QE.prototype.draw3dText=function(a,c){var d=this.kB;iE();a&&"object"===typeof a&&(a=a.kB);c=c&&"object"===typeof c?c.kB:lE(c);kh(d,a,c)};QE.prototype.setDebugMode=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);lh(c,a)};QE.prototype.getDebugMode=function(){return mh(this.kB)};QE.prototype.__destroy__=function(){nh(this.kB)}; -function A(a,c,d,e){a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);this.kB=void 0===a?oh():void 0===c?_emscripten_bind_btVector4_btVector4_1(a):void 0===d?_emscripten_bind_btVector4_btVector4_2(a,c):void 0===e?_emscripten_bind_btVector4_btVector4_3(a,c,d):ph(a,c,d,e);h(A)[this.kB]=this}A.prototype=Object.create(n.prototype);A.prototype.constructor=A;A.prototype.lB=A;A.mB={};b.btVector4=A; -A.prototype.w=A.prototype.w=function(){return qh(this.kB)};A.prototype.setValue=function(a,c,d,e){var g=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);rh(g,a,c,d,e)};A.prototype.length=A.prototype.length=function(){return sh(this.kB)};A.prototype.x=A.prototype.x=function(){return th(this.kB)};A.prototype.y=A.prototype.y=function(){return uh(this.kB)};A.prototype.z=A.prototype.z=function(){return vh(this.kB)}; -A.prototype.setX=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);wh(c,a)};A.prototype.setY=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);xh(c,a)};A.prototype.setZ=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);yh(c,a)};A.prototype.normalize=A.prototype.normalize=function(){zh(this.kB)};A.prototype.rotate=A.prototype.rotate=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);return k(Ah(d,a,c),n)}; -A.prototype.dot=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return Bh(c,a)};A.prototype.op_mul=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return k(Ch(c,a),n)};A.prototype.op_add=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return k(Dh(c,a),n)};A.prototype.op_sub=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return k(Eh(c,a),n)};A.prototype.__destroy__=function(){Fh(this.kB)}; -function B(a,c,d,e){a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);this.kB=Gh(a,c,d,e);h(B)[this.kB]=this}B.prototype=Object.create(yE.prototype);B.prototype.constructor=B;B.prototype.lB=B;B.mB={};b.btQuaternion=B;B.prototype.setValue=function(a,c,d,e){var g=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);Hh(g,a,c,d,e)}; -B.prototype.setEulerZYX=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);Ih(e,a,c,d)};B.prototype.setRotation=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);Jh(d,a,c)};B.prototype.normalize=B.prototype.normalize=function(){Kh(this.kB)};B.prototype.length2=function(){return Lh(this.kB)};B.prototype.length=B.prototype.length=function(){return Mh(this.kB)}; -B.prototype.dot=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return Nh(c,a)};B.prototype.normalized=function(){return k(Oh(this.kB),B)};B.prototype.getAxis=function(){return k(Ph(this.kB),n)};B.prototype.inverse=B.prototype.inverse=function(){return k(Qh(this.kB),B)};B.prototype.getAngle=function(){return Rh(this.kB)};B.prototype.getAngleShortestPath=function(){return Sh(this.kB)}; -B.prototype.angle=B.prototype.angle=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return Th(c,a)};B.prototype.angleShortestPath=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return Uh(c,a)};B.prototype.op_add=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return k(Vh(c,a),B)};B.prototype.op_sub=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return k(Wh(c,a),B)}; -B.prototype.op_mul=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return k(Xh(c,a),B)};B.prototype.op_mulq=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return k(Yh(c,a),B)};B.prototype.op_div=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return k(Zh(c,a),B)};B.prototype.x=B.prototype.x=function(){return $h(this.kB)};B.prototype.y=B.prototype.y=function(){return ai(this.kB)};B.prototype.z=B.prototype.z=function(){return bi(this.kB)}; -B.prototype.w=B.prototype.w=function(){return ci(this.kB)};B.prototype.setX=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);di(c,a)};B.prototype.setY=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);ei(c,a)};B.prototype.setZ=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);fi(c,a)};B.prototype.setW=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);gi(c,a)};B.prototype.__destroy__=function(){hi(this.kB)}; -function RE(){throw"cannot construct a btMatrix3x3, no constructor in IDL";}RE.prototype=Object.create(f.prototype);RE.prototype.constructor=RE;RE.prototype.lB=RE;RE.mB={};b.btMatrix3x3=RE;RE.prototype.setEulerZYX=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);ii(e,a,c,d)};RE.prototype.getRotation=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);ji(c,a)}; -RE.prototype.getRow=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return k(ki(c,a),n)};RE.prototype.__destroy__=function(){li(this.kB)};function t(a,c){a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);this.kB=void 0===a?mi():void 0===c?_emscripten_bind_btTransform_btTransform_1(a):ni(a,c);h(t)[this.kB]=this}t.prototype=Object.create(f.prototype);t.prototype.constructor=t;t.prototype.lB=t;t.mB={};b.btTransform=t;t.prototype.setIdentity=function(){oi(this.kB)}; -t.prototype.setOrigin=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);pi(c,a)};t.prototype.setRotation=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);qi(c,a)};t.prototype.getOrigin=function(){return k(ri(this.kB),n)};t.prototype.getRotation=function(){return k(si(this.kB),B)};t.prototype.getBasis=function(){return k(ti(this.kB),RE)};t.prototype.setFromOpenGLMatrix=function(a){var c=this.kB;iE();"object"==typeof a&&(a=mE(a));ui(c,a)}; -t.prototype.inverse=t.prototype.inverse=function(){return k(vi(this.kB),t)};t.prototype.op_mul=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return k(wi(c,a),t)};t.prototype.__destroy__=function(){xi(this.kB)};function SE(){this.kB=yi();h(SE)[this.kB]=this}SE.prototype=Object.create(zE.prototype);SE.prototype.constructor=SE;SE.prototype.lB=SE;SE.mB={};b.MotionState=SE;SE.prototype.getWorldTransform=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);zi(c,a)}; -SE.prototype.setWorldTransform=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Ai(c,a)};SE.prototype.__destroy__=function(){Bi(this.kB)};function TE(a,c){a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);this.kB=void 0===a?Ci():void 0===c?Di(a):Ei(a,c);h(TE)[this.kB]=this}TE.prototype=Object.create(zE.prototype);TE.prototype.constructor=TE;TE.prototype.lB=TE;TE.mB={};b.btDefaultMotionState=TE; -TE.prototype.getWorldTransform=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Fi(c,a)};TE.prototype.setWorldTransform=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Gi(c,a)};TE.prototype.get_m_graphicsWorldTrans=TE.prototype.sD=function(){return k(Hi(this.kB),t)};TE.prototype.set_m_graphicsWorldTrans=TE.prototype.lG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Ii(c,a)};Object.defineProperty(TE.prototype,"m_graphicsWorldTrans",{get:TE.prototype.sD,set:TE.prototype.lG}); -TE.prototype.__destroy__=function(){Ji(this.kB)};function UE(){throw"cannot construct a btCollisionObjectWrapper, no constructor in IDL";}UE.prototype=Object.create(f.prototype);UE.prototype.constructor=UE;UE.prototype.lB=UE;UE.mB={};b.btCollisionObjectWrapper=UE;UE.prototype.getWorldTransform=function(){return k(Ki(this.kB),t)};UE.prototype.getCollisionObject=function(){return k(Li(this.kB),r)};UE.prototype.getCollisionShape=function(){return k(Mi(this.kB),l)}; -function C(a,c){a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);this.kB=Ni(a,c);h(C)[this.kB]=this}C.prototype=Object.create(v.prototype);C.prototype.constructor=C;C.prototype.lB=C;C.mB={};b.ClosestRayResultCallback=C;C.prototype.hasHit=function(){return!!Oi(this.kB)};C.prototype.get_m_rayFromWorld=C.prototype.RB=function(){return k(Pi(this.kB),n)};C.prototype.set_m_rayFromWorld=C.prototype.aC=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Qi(c,a)}; -Object.defineProperty(C.prototype,"m_rayFromWorld",{get:C.prototype.RB,set:C.prototype.aC});C.prototype.get_m_rayToWorld=C.prototype.SB=function(){return k(Ri(this.kB),n)};C.prototype.set_m_rayToWorld=C.prototype.bC=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Si(c,a)};Object.defineProperty(C.prototype,"m_rayToWorld",{get:C.prototype.SB,set:C.prototype.bC});C.prototype.get_m_hitNormalWorld=C.prototype.AB=function(){return k(Ti(this.kB),n)}; -C.prototype.set_m_hitNormalWorld=C.prototype.IB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Ui(c,a)};Object.defineProperty(C.prototype,"m_hitNormalWorld",{get:C.prototype.AB,set:C.prototype.IB});C.prototype.get_m_hitPointWorld=C.prototype.BB=function(){return k(Vi(this.kB),n)};C.prototype.set_m_hitPointWorld=C.prototype.JB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Wi(c,a)};Object.defineProperty(C.prototype,"m_hitPointWorld",{get:C.prototype.BB,set:C.prototype.JB}); -C.prototype.get_m_collisionFilterGroup=C.prototype.nB=function(){return Xi(this.kB)};C.prototype.set_m_collisionFilterGroup=C.prototype.pB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Yi(c,a)};Object.defineProperty(C.prototype,"m_collisionFilterGroup",{get:C.prototype.nB,set:C.prototype.pB});C.prototype.get_m_collisionFilterMask=C.prototype.oB=function(){return Zi(this.kB)}; -C.prototype.set_m_collisionFilterMask=C.prototype.qB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);$i(c,a)};Object.defineProperty(C.prototype,"m_collisionFilterMask",{get:C.prototype.oB,set:C.prototype.qB});C.prototype.get_m_closestHitFraction=C.prototype.rB=function(){return aj(this.kB)};C.prototype.set_m_closestHitFraction=C.prototype.sB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);bj(c,a)};Object.defineProperty(C.prototype,"m_closestHitFraction",{get:C.prototype.rB,set:C.prototype.sB}); -C.prototype.get_m_collisionObject=C.prototype.yB=function(){return k(cj(this.kB),r)};C.prototype.set_m_collisionObject=C.prototype.GB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);dj(c,a)};Object.defineProperty(C.prototype,"m_collisionObject",{get:C.prototype.yB,set:C.prototype.GB});C.prototype.get_m_flags=C.prototype.vB=function(){return ej(this.kB)};C.prototype.set_m_flags=C.prototype.wB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);fj(c,a)}; -Object.defineProperty(C.prototype,"m_flags",{get:C.prototype.vB,set:C.prototype.wB});C.prototype.__destroy__=function(){gj(this.kB)};function VE(){throw"cannot construct a btConstCollisionObjectArray, no constructor in IDL";}VE.prototype=Object.create(f.prototype);VE.prototype.constructor=VE;VE.prototype.lB=VE;VE.mB={};b.btConstCollisionObjectArray=VE;VE.prototype.size=VE.prototype.size=function(){return hj(this.kB)}; -VE.prototype.at=VE.prototype.at=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return k(ij(c,a),r)};VE.prototype.__destroy__=function(){jj(this.kB)};function WE(){throw"cannot construct a btScalarArray, no constructor in IDL";}WE.prototype=Object.create(f.prototype);WE.prototype.constructor=WE;WE.prototype.lB=WE;WE.mB={};b.btScalarArray=WE;WE.prototype.size=WE.prototype.size=function(){return kj(this.kB)}; -WE.prototype.at=WE.prototype.at=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return lj(c,a)};WE.prototype.__destroy__=function(){mj(this.kB)};function D(a,c){a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);this.kB=nj(a,c);h(D)[this.kB]=this}D.prototype=Object.create(v.prototype);D.prototype.constructor=D;D.prototype.lB=D;D.mB={};b.AllHitsRayResultCallback=D;D.prototype.hasHit=function(){return!!oj(this.kB)}; -D.prototype.get_m_collisionObjects=D.prototype.aD=function(){return k(pj(this.kB),VE)};D.prototype.set_m_collisionObjects=D.prototype.UF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);qj(c,a)};Object.defineProperty(D.prototype,"m_collisionObjects",{get:D.prototype.aD,set:D.prototype.UF});D.prototype.get_m_rayFromWorld=D.prototype.RB=function(){return k(rj(this.kB),n)};D.prototype.set_m_rayFromWorld=D.prototype.aC=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);sj(c,a)}; -Object.defineProperty(D.prototype,"m_rayFromWorld",{get:D.prototype.RB,set:D.prototype.aC});D.prototype.get_m_rayToWorld=D.prototype.SB=function(){return k(tj(this.kB),n)};D.prototype.set_m_rayToWorld=D.prototype.bC=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);uj(c,a)};Object.defineProperty(D.prototype,"m_rayToWorld",{get:D.prototype.SB,set:D.prototype.bC});D.prototype.get_m_hitNormalWorld=D.prototype.AB=function(){return k(vj(this.kB),XE)}; -D.prototype.set_m_hitNormalWorld=D.prototype.IB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);wj(c,a)};Object.defineProperty(D.prototype,"m_hitNormalWorld",{get:D.prototype.AB,set:D.prototype.IB});D.prototype.get_m_hitPointWorld=D.prototype.BB=function(){return k(xj(this.kB),XE)};D.prototype.set_m_hitPointWorld=D.prototype.JB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);yj(c,a)};Object.defineProperty(D.prototype,"m_hitPointWorld",{get:D.prototype.BB,set:D.prototype.JB}); -D.prototype.get_m_hitFractions=D.prototype.xD=function(){return k(zj(this.kB),WE)};D.prototype.set_m_hitFractions=D.prototype.qG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Aj(c,a)};Object.defineProperty(D.prototype,"m_hitFractions",{get:D.prototype.xD,set:D.prototype.qG});D.prototype.get_m_collisionFilterGroup=D.prototype.nB=function(){return Bj(this.kB)};D.prototype.set_m_collisionFilterGroup=D.prototype.pB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Cj(c,a)}; -Object.defineProperty(D.prototype,"m_collisionFilterGroup",{get:D.prototype.nB,set:D.prototype.pB});D.prototype.get_m_collisionFilterMask=D.prototype.oB=function(){return Dj(this.kB)};D.prototype.set_m_collisionFilterMask=D.prototype.qB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Ej(c,a)};Object.defineProperty(D.prototype,"m_collisionFilterMask",{get:D.prototype.oB,set:D.prototype.qB});D.prototype.get_m_closestHitFraction=D.prototype.rB=function(){return Fj(this.kB)}; -D.prototype.set_m_closestHitFraction=D.prototype.sB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Gj(c,a)};Object.defineProperty(D.prototype,"m_closestHitFraction",{get:D.prototype.rB,set:D.prototype.sB});D.prototype.get_m_collisionObject=D.prototype.yB=function(){return k(Hj(this.kB),r)};D.prototype.set_m_collisionObject=D.prototype.GB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Ij(c,a)};Object.defineProperty(D.prototype,"m_collisionObject",{get:D.prototype.yB,set:D.prototype.GB}); -D.prototype.get_m_flags=D.prototype.vB=function(){return Jj(this.kB)};D.prototype.set_m_flags=D.prototype.wB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Kj(c,a)};Object.defineProperty(D.prototype,"m_flags",{get:D.prototype.vB,set:D.prototype.wB});D.prototype.__destroy__=function(){Lj(this.kB)};function F(){throw"cannot construct a btManifoldPoint, no constructor in IDL";}F.prototype=Object.create(f.prototype);F.prototype.constructor=F;F.prototype.lB=F;F.mB={};b.btManifoldPoint=F; -F.prototype.getPositionWorldOnA=function(){return k(Mj(this.kB),n)};F.prototype.getPositionWorldOnB=function(){return k(Nj(this.kB),n)};F.prototype.getAppliedImpulse=function(){return Oj(this.kB)};F.prototype.getDistance=function(){return Pj(this.kB)};F.prototype.get_m_localPointA=F.prototype.ND=function(){return k(Qj(this.kB),n)};F.prototype.set_m_localPointA=F.prototype.GG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Rj(c,a)}; -Object.defineProperty(F.prototype,"m_localPointA",{get:F.prototype.ND,set:F.prototype.GG});F.prototype.get_m_localPointB=F.prototype.OD=function(){return k(Sj(this.kB),n)};F.prototype.set_m_localPointB=F.prototype.HG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Tj(c,a)};Object.defineProperty(F.prototype,"m_localPointB",{get:F.prototype.OD,set:F.prototype.HG});F.prototype.get_m_positionWorldOnB=F.prototype.eE=function(){return k(Uj(this.kB),n)}; -F.prototype.set_m_positionWorldOnB=F.prototype.ZG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Vj(c,a)};Object.defineProperty(F.prototype,"m_positionWorldOnB",{get:F.prototype.eE,set:F.prototype.ZG});F.prototype.get_m_positionWorldOnA=F.prototype.dE=function(){return k(Wj(this.kB),n)};F.prototype.set_m_positionWorldOnA=F.prototype.YG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Xj(c,a)};Object.defineProperty(F.prototype,"m_positionWorldOnA",{get:F.prototype.dE,set:F.prototype.YG}); -F.prototype.get_m_normalWorldOnB=F.prototype.ZD=function(){return k(Yj(this.kB),n)};F.prototype.set_m_normalWorldOnB=F.prototype.TG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Zj(c,a)};Object.defineProperty(F.prototype,"m_normalWorldOnB",{get:F.prototype.ZD,set:F.prototype.TG});F.prototype.get_m_userPersistentData=F.prototype.GE=function(){return ak(this.kB)};F.prototype.set_m_userPersistentData=F.prototype.AH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);bk(c,a)}; -Object.defineProperty(F.prototype,"m_userPersistentData",{get:F.prototype.GE,set:F.prototype.AH});F.prototype.__destroy__=function(){ck(this.kB)};function YE(){this.kB=dk();h(YE)[this.kB]=this}YE.prototype=Object.create(AE.prototype);YE.prototype.constructor=YE;YE.prototype.lB=YE;YE.mB={};b.ConcreteContactResultCallback=YE; -YE.prototype.addSingleResult=function(a,c,d,e,g,m,y){var W=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);g&&"object"===typeof g&&(g=g.kB);m&&"object"===typeof m&&(m=m.kB);y&&"object"===typeof y&&(y=y.kB);return ek(W,a,c,d,e,g,m,y)};YE.prototype.__destroy__=function(){fk(this.kB)};function ZE(){throw"cannot construct a LocalShapeInfo, no constructor in IDL";}ZE.prototype=Object.create(f.prototype); -ZE.prototype.constructor=ZE;ZE.prototype.lB=ZE;ZE.mB={};b.LocalShapeInfo=ZE;ZE.prototype.get_m_shapePart=ZE.prototype.nE=function(){return gk(this.kB)};ZE.prototype.set_m_shapePart=ZE.prototype.hH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);hk(c,a)};Object.defineProperty(ZE.prototype,"m_shapePart",{get:ZE.prototype.nE,set:ZE.prototype.hH});ZE.prototype.get_m_triangleIndex=ZE.prototype.CE=function(){return ik(this.kB)}; -ZE.prototype.set_m_triangleIndex=ZE.prototype.wH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);jk(c,a)};Object.defineProperty(ZE.prototype,"m_triangleIndex",{get:ZE.prototype.CE,set:ZE.prototype.wH});ZE.prototype.__destroy__=function(){kk(this.kB)};function H(a,c,d,e,g){a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);g&&"object"===typeof g&&(g=g.kB);this.kB=lk(a,c,d,e,g);h(H)[this.kB]=this} -H.prototype=Object.create(f.prototype);H.prototype.constructor=H;H.prototype.lB=H;H.mB={};b.LocalConvexResult=H;H.prototype.get_m_hitCollisionObject=H.prototype.PB=function(){return k(mk(this.kB),r)};H.prototype.set_m_hitCollisionObject=H.prototype.ZB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);nk(c,a)};Object.defineProperty(H.prototype,"m_hitCollisionObject",{get:H.prototype.PB,set:H.prototype.ZB});H.prototype.get_m_localShapeInfo=H.prototype.PD=function(){return k(ok(this.kB),ZE)}; -H.prototype.set_m_localShapeInfo=H.prototype.IG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);pk(c,a)};Object.defineProperty(H.prototype,"m_localShapeInfo",{get:H.prototype.PD,set:H.prototype.IG});H.prototype.get_m_hitNormalLocal=H.prototype.zD=function(){return k(qk(this.kB),n)};H.prototype.set_m_hitNormalLocal=H.prototype.sG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);rk(c,a)};Object.defineProperty(H.prototype,"m_hitNormalLocal",{get:H.prototype.zD,set:H.prototype.sG}); -H.prototype.get_m_hitPointLocal=H.prototype.BD=function(){return k(sk(this.kB),n)};H.prototype.set_m_hitPointLocal=H.prototype.uG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);tk(c,a)};Object.defineProperty(H.prototype,"m_hitPointLocal",{get:H.prototype.BD,set:H.prototype.uG});H.prototype.get_m_hitFraction=H.prototype.wD=function(){return uk(this.kB)};H.prototype.set_m_hitFraction=H.prototype.pG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);vk(c,a)}; -Object.defineProperty(H.prototype,"m_hitFraction",{get:H.prototype.wD,set:H.prototype.pG});H.prototype.__destroy__=function(){wk(this.kB)};function I(a,c){a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);this.kB=xk(a,c);h(I)[this.kB]=this}I.prototype=Object.create(w.prototype);I.prototype.constructor=I;I.prototype.lB=I;I.mB={};b.ClosestConvexResultCallback=I;I.prototype.hasHit=function(){return!!yk(this.kB)}; -I.prototype.get_m_hitCollisionObject=I.prototype.PB=function(){return k(zk(this.kB),r)};I.prototype.set_m_hitCollisionObject=I.prototype.ZB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Ak(c,a)};Object.defineProperty(I.prototype,"m_hitCollisionObject",{get:I.prototype.PB,set:I.prototype.ZB});I.prototype.get_m_convexFromWorld=I.prototype.fD=function(){return k(Bk(this.kB),n)}; -I.prototype.set_m_convexFromWorld=I.prototype.ZF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Ck(c,a)};Object.defineProperty(I.prototype,"m_convexFromWorld",{get:I.prototype.fD,set:I.prototype.ZF});I.prototype.get_m_convexToWorld=I.prototype.gD=function(){return k(Dk(this.kB),n)};I.prototype.set_m_convexToWorld=I.prototype.$F=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Ek(c,a)};Object.defineProperty(I.prototype,"m_convexToWorld",{get:I.prototype.gD,set:I.prototype.$F}); -I.prototype.get_m_hitNormalWorld=I.prototype.AB=function(){return k(Fk(this.kB),n)};I.prototype.set_m_hitNormalWorld=I.prototype.IB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Gk(c,a)};Object.defineProperty(I.prototype,"m_hitNormalWorld",{get:I.prototype.AB,set:I.prototype.IB});I.prototype.get_m_hitPointWorld=I.prototype.BB=function(){return k(Hk(this.kB),n)};I.prototype.set_m_hitPointWorld=I.prototype.JB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Ik(c,a)}; -Object.defineProperty(I.prototype,"m_hitPointWorld",{get:I.prototype.BB,set:I.prototype.JB});I.prototype.get_m_collisionFilterGroup=I.prototype.nB=function(){return Jk(this.kB)};I.prototype.set_m_collisionFilterGroup=I.prototype.pB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Kk(c,a)};Object.defineProperty(I.prototype,"m_collisionFilterGroup",{get:I.prototype.nB,set:I.prototype.pB});I.prototype.get_m_collisionFilterMask=I.prototype.oB=function(){return Lk(this.kB)}; -I.prototype.set_m_collisionFilterMask=I.prototype.qB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Mk(c,a)};Object.defineProperty(I.prototype,"m_collisionFilterMask",{get:I.prototype.oB,set:I.prototype.qB});I.prototype.get_m_closestHitFraction=I.prototype.rB=function(){return Nk(this.kB)};I.prototype.set_m_closestHitFraction=I.prototype.sB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Ok(c,a)};Object.defineProperty(I.prototype,"m_closestHitFraction",{get:I.prototype.rB,set:I.prototype.sB}); -I.prototype.__destroy__=function(){Pk(this.kB)};function $E(a,c){a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);this.kB=void 0===c?Qk(a):Rk(a,c);h($E)[this.kB]=this}$E.prototype=Object.create(BE.prototype);$E.prototype.constructor=$E;$E.prototype.lB=$E;$E.mB={};b.btConvexTriangleMeshShape=$E;$E.prototype.setLocalScaling=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Sk(c,a)};$E.prototype.getLocalScaling=function(){return k(Tk(this.kB),n)}; -$E.prototype.calculateLocalInertia=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);Uk(d,a,c)};$E.prototype.setMargin=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Vk(c,a)};$E.prototype.getMargin=function(){return Wk(this.kB)};$E.prototype.__destroy__=function(){Xk(this.kB)};function aF(a){a&&"object"===typeof a&&(a=a.kB);this.kB=Yk(a);h(aF)[this.kB]=this}aF.prototype=Object.create(l.prototype);aF.prototype.constructor=aF;aF.prototype.lB=aF; -aF.mB={};b.btBoxShape=aF;aF.prototype.setMargin=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Zk(c,a)};aF.prototype.getMargin=function(){return $k(this.kB)};aF.prototype.setLocalScaling=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);al(c,a)};aF.prototype.getLocalScaling=function(){return k(bl(this.kB),n)};aF.prototype.calculateLocalInertia=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);cl(d,a,c)};aF.prototype.__destroy__=function(){dl(this.kB)}; -function bF(a,c){a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);this.kB=el(a,c);h(bF)[this.kB]=this}bF.prototype=Object.create(CE.prototype);bF.prototype.constructor=bF;bF.prototype.lB=bF;bF.mB={};b.btCapsuleShapeX=bF;bF.prototype.setMargin=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);fl(c,a)};bF.prototype.getMargin=function(){return gl(this.kB)};bF.prototype.getUpAxis=function(){return hl(this.kB)};bF.prototype.getRadius=function(){return il(this.kB)}; -bF.prototype.getHalfHeight=function(){return jl(this.kB)};bF.prototype.setLocalScaling=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);kl(c,a)};bF.prototype.getLocalScaling=function(){return k(ll(this.kB),n)};bF.prototype.calculateLocalInertia=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);ml(d,a,c)};bF.prototype.__destroy__=function(){nl(this.kB)}; -function cF(a,c){a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);this.kB=ol(a,c);h(cF)[this.kB]=this}cF.prototype=Object.create(CE.prototype);cF.prototype.constructor=cF;cF.prototype.lB=cF;cF.mB={};b.btCapsuleShapeZ=cF;cF.prototype.setMargin=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);pl(c,a)};cF.prototype.getMargin=function(){return ql(this.kB)};cF.prototype.getUpAxis=function(){return rl(this.kB)};cF.prototype.getRadius=function(){return sl(this.kB)}; -cF.prototype.getHalfHeight=function(){return tl(this.kB)};cF.prototype.setLocalScaling=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);ul(c,a)};cF.prototype.getLocalScaling=function(){return k(vl(this.kB),n)};cF.prototype.calculateLocalInertia=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);wl(d,a,c)};cF.prototype.__destroy__=function(){xl(this.kB)};function dF(a){a&&"object"===typeof a&&(a=a.kB);this.kB=yl(a);h(dF)[this.kB]=this} -dF.prototype=Object.create(DE.prototype);dF.prototype.constructor=dF;dF.prototype.lB=dF;dF.mB={};b.btCylinderShapeX=dF;dF.prototype.setMargin=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);zl(c,a)};dF.prototype.getMargin=function(){return Al(this.kB)};dF.prototype.setLocalScaling=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Bl(c,a)};dF.prototype.getLocalScaling=function(){return k(Cl(this.kB),n)}; -dF.prototype.calculateLocalInertia=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);Dl(d,a,c)};dF.prototype.__destroy__=function(){El(this.kB)};function eF(a){a&&"object"===typeof a&&(a=a.kB);this.kB=Fl(a);h(eF)[this.kB]=this}eF.prototype=Object.create(DE.prototype);eF.prototype.constructor=eF;eF.prototype.lB=eF;eF.mB={};b.btCylinderShapeZ=eF;eF.prototype.setMargin=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Gl(c,a)}; -eF.prototype.getMargin=function(){return Hl(this.kB)};eF.prototype.setLocalScaling=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Il(c,a)};eF.prototype.getLocalScaling=function(){return k(Jl(this.kB),n)};eF.prototype.calculateLocalInertia=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);Kl(d,a,c)};eF.prototype.__destroy__=function(){Ll(this.kB)};function fF(a){a&&"object"===typeof a&&(a=a.kB);this.kB=Ml(a);h(fF)[this.kB]=this}fF.prototype=Object.create(l.prototype); -fF.prototype.constructor=fF;fF.prototype.lB=fF;fF.mB={};b.btSphereShape=fF;fF.prototype.setMargin=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Nl(c,a)};fF.prototype.getMargin=function(){return Ol(this.kB)};fF.prototype.setLocalScaling=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Pl(c,a)};fF.prototype.getLocalScaling=function(){return k(Ql(this.kB),n)}; -fF.prototype.calculateLocalInertia=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);Rl(d,a,c)};fF.prototype.__destroy__=function(){Sl(this.kB)};function gF(a,c,d){iE();a&&"object"===typeof a&&(a=a.kB);"object"==typeof c&&(c=mE(c));d&&"object"===typeof d&&(d=d.kB);this.kB=Tl(a,c,d);h(gF)[this.kB]=this}gF.prototype=Object.create(l.prototype);gF.prototype.constructor=gF;gF.prototype.lB=gF;gF.mB={};b.btMultiSphereShape=gF; -gF.prototype.setLocalScaling=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Ul(c,a)};gF.prototype.getLocalScaling=function(){return k(Vl(this.kB),n)};gF.prototype.calculateLocalInertia=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);Wl(d,a,c)};gF.prototype.__destroy__=function(){Xl(this.kB)};function hF(a,c){a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);this.kB=Yl(a,c);h(hF)[this.kB]=this}hF.prototype=Object.create(EE.prototype); -hF.prototype.constructor=hF;hF.prototype.lB=hF;hF.mB={};b.btConeShapeX=hF;hF.prototype.setLocalScaling=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Zl(c,a)};hF.prototype.getLocalScaling=function(){return k($l(this.kB),n)};hF.prototype.calculateLocalInertia=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);am(d,a,c)};hF.prototype.__destroy__=function(){bm(this.kB)}; -function iF(a,c){a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);this.kB=cm(a,c);h(iF)[this.kB]=this}iF.prototype=Object.create(EE.prototype);iF.prototype.constructor=iF;iF.prototype.lB=iF;iF.mB={};b.btConeShapeZ=iF;iF.prototype.setLocalScaling=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);dm(c,a)};iF.prototype.getLocalScaling=function(){return k(em(this.kB),n)}; -iF.prototype.calculateLocalInertia=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);fm(d,a,c)};iF.prototype.__destroy__=function(){gm(this.kB)};function jF(){throw"cannot construct a btIntArray, no constructor in IDL";}jF.prototype=Object.create(f.prototype);jF.prototype.constructor=jF;jF.prototype.lB=jF;jF.mB={};b.btIntArray=jF;jF.prototype.size=jF.prototype.size=function(){return hm(this.kB)}; -jF.prototype.at=jF.prototype.at=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return im(c,a)};jF.prototype.__destroy__=function(){jm(this.kB)};function kF(){throw"cannot construct a btFace, no constructor in IDL";}kF.prototype=Object.create(f.prototype);kF.prototype.constructor=kF;kF.prototype.lB=kF;kF.mB={};b.btFace=kF;kF.prototype.get_m_indices=kF.prototype.ED=function(){return k(km(this.kB),jF)}; -kF.prototype.set_m_indices=kF.prototype.xG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);lm(c,a)};Object.defineProperty(kF.prototype,"m_indices",{get:kF.prototype.ED,set:kF.prototype.xG});kF.prototype.get_m_plane=kF.prototype.cE=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return mm(c,a)};kF.prototype.set_m_plane=kF.prototype.XG=function(a,c){var d=this.kB;iE();a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);nm(d,a,c)}; -Object.defineProperty(kF.prototype,"m_plane",{get:kF.prototype.cE,set:kF.prototype.XG});kF.prototype.__destroy__=function(){om(this.kB)};function XE(){throw"cannot construct a btVector3Array, no constructor in IDL";}XE.prototype=Object.create(f.prototype);XE.prototype.constructor=XE;XE.prototype.lB=XE;XE.mB={};b.btVector3Array=XE;XE.prototype.size=XE.prototype.size=function(){return pm(this.kB)}; -XE.prototype.at=XE.prototype.at=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return k(qm(c,a),n)};XE.prototype.__destroy__=function(){rm(this.kB)};function lF(){throw"cannot construct a btFaceArray, no constructor in IDL";}lF.prototype=Object.create(f.prototype);lF.prototype.constructor=lF;lF.prototype.lB=lF;lF.mB={};b.btFaceArray=lF;lF.prototype.size=lF.prototype.size=function(){return sm(this.kB)}; -lF.prototype.at=lF.prototype.at=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return k(tm(c,a),kF)};lF.prototype.__destroy__=function(){um(this.kB)};function mF(){throw"cannot construct a btConvexPolyhedron, no constructor in IDL";}mF.prototype=Object.create(f.prototype);mF.prototype.constructor=mF;mF.prototype.lB=mF;mF.mB={};b.btConvexPolyhedron=mF;mF.prototype.get_m_vertices=mF.prototype.IE=function(){return k(wm(this.kB),XE)}; -mF.prototype.set_m_vertices=mF.prototype.CH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);xm(c,a)};Object.defineProperty(mF.prototype,"m_vertices",{get:mF.prototype.IE,set:mF.prototype.CH});mF.prototype.get_m_faces=mF.prototype.OB=function(){return k(ym(this.kB),lF)};mF.prototype.set_m_faces=mF.prototype.YB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);zm(c,a)};Object.defineProperty(mF.prototype,"m_faces",{get:mF.prototype.OB,set:mF.prototype.YB}); -mF.prototype.__destroy__=function(){Am(this.kB)};function nF(a,c){iE();"object"==typeof a&&(a=mE(a));c&&"object"===typeof c&&(c=c.kB);this.kB=void 0===a?Bm():void 0===c?Cm(a):Dm(a,c);h(nF)[this.kB]=this}nF.prototype=Object.create(l.prototype);nF.prototype.constructor=nF;nF.prototype.lB=nF;nF.mB={};b.btConvexHullShape=nF;nF.prototype.addPoint=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);void 0===c?Em(d,a):Fm(d,a,c)}; -nF.prototype.setMargin=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Gm(c,a)};nF.prototype.getMargin=function(){return Hm(this.kB)};nF.prototype.getNumVertices=function(){return Im(this.kB)};nF.prototype.initializePolyhedralFeatures=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return!!Jm(c,a)};nF.prototype.recalcLocalAabb=function(){Km(this.kB)};nF.prototype.getConvexPolyhedron=function(){return k(Lm(this.kB),mF)}; -nF.prototype.setLocalScaling=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Mm(c,a)};nF.prototype.getLocalScaling=function(){return k(Nm(this.kB),n)};nF.prototype.calculateLocalInertia=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);Om(d,a,c)};nF.prototype.__destroy__=function(){Pm(this.kB)};function oF(a){a&&"object"===typeof a&&(a=a.kB);this.kB=Qm(a);h(oF)[this.kB]=this}oF.prototype=Object.create(f.prototype);oF.prototype.constructor=oF; -oF.prototype.lB=oF;oF.mB={};b.btShapeHull=oF;oF.prototype.buildHull=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return!!Rm(c,a)};oF.prototype.numVertices=function(){return Sm(this.kB)};oF.prototype.getVertexPointer=function(){return k(Tm(this.kB),n)};oF.prototype.__destroy__=function(){Um(this.kB)};function pF(a){a&&"object"===typeof a&&(a=a.kB);this.kB=void 0===a?Vm():Wm(a);h(pF)[this.kB]=this}pF.prototype=Object.create(l.prototype);pF.prototype.constructor=pF;pF.prototype.lB=pF; -pF.mB={};b.btCompoundShape=pF;pF.prototype.addChildShape=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);Xm(d,a,c)};pF.prototype.removeChildShape=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Ym(c,a)};pF.prototype.removeChildShapeByIndex=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Zm(c,a)};pF.prototype.getNumChildShapes=function(){return $m(this.kB)}; -pF.prototype.getChildShape=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return k(an(c,a),l)};pF.prototype.updateChildTransform=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);void 0===d?bn(e,a,c):cn(e,a,c,d)};pF.prototype.setMargin=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);dn(c,a)};pF.prototype.getMargin=function(){return en(this.kB)}; -pF.prototype.setLocalScaling=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);fn(c,a)};pF.prototype.getLocalScaling=function(){return k(gn(this.kB),n)};pF.prototype.calculateLocalInertia=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);hn(d,a,c)};pF.prototype.__destroy__=function(){jn(this.kB)};function qF(){throw"cannot construct a btIndexedMesh, no constructor in IDL";}qF.prototype=Object.create(f.prototype);qF.prototype.constructor=qF; -qF.prototype.lB=qF;qF.mB={};b.btIndexedMesh=qF;qF.prototype.get_m_numTriangles=qF.prototype.aE=function(){return kn(this.kB)};qF.prototype.set_m_numTriangles=qF.prototype.VG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);ln(c,a)};Object.defineProperty(qF.prototype,"m_numTriangles",{get:qF.prototype.aE,set:qF.prototype.VG});qF.prototype.__destroy__=function(){mn(this.kB)};function rF(){throw"cannot construct a btIndexedMeshArray, no constructor in IDL";}rF.prototype=Object.create(f.prototype); -rF.prototype.constructor=rF;rF.prototype.lB=rF;rF.mB={};b.btIndexedMeshArray=rF;rF.prototype.size=rF.prototype.size=function(){return nn(this.kB)};rF.prototype.at=rF.prototype.at=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return k(on(c,a),qF)};rF.prototype.__destroy__=function(){pn(this.kB)};function sF(a,c){a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);this.kB=void 0===a?qn():void 0===c?rn(a):sn(a,c);h(sF)[this.kB]=this}sF.prototype=Object.create(FE.prototype); -sF.prototype.constructor=sF;sF.prototype.lB=sF;sF.mB={};b.btTriangleMesh=sF;sF.prototype.addTriangle=function(a,c,d,e){var g=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);void 0===e?tn(g,a,c,d):un(g,a,c,d,e)};sF.prototype.findOrAddVertex=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);return vn(d,a,c)}; -sF.prototype.addIndex=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);wn(c,a)};sF.prototype.getIndexedMeshArray=function(){return k(xn(this.kB),rF)};sF.prototype.setScaling=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);yn(c,a)};sF.prototype.__destroy__=function(){zn(this.kB)};function tF(){this.kB=An();h(tF)[this.kB]=this}tF.prototype=Object.create(uE.prototype);tF.prototype.constructor=tF;tF.prototype.lB=tF;tF.mB={};b.btEmptyShape=tF; -tF.prototype.setLocalScaling=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Bn(c,a)};tF.prototype.getLocalScaling=function(){return k(Cn(this.kB),n)};tF.prototype.calculateLocalInertia=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);Dn(d,a,c)};tF.prototype.__destroy__=function(){En(this.kB)};function uF(a,c){a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);this.kB=Fn(a,c);h(uF)[this.kB]=this}uF.prototype=Object.create(uE.prototype); -uF.prototype.constructor=uF;uF.prototype.lB=uF;uF.mB={};b.btStaticPlaneShape=uF;uF.prototype.setLocalScaling=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Gn(c,a)};uF.prototype.getLocalScaling=function(){return k(Hn(this.kB),n)};uF.prototype.calculateLocalInertia=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);In(d,a,c)};uF.prototype.__destroy__=function(){Jn(this.kB)}; -function vF(a,c,d){a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);this.kB=void 0===d?Kn(a,c):Ln(a,c,d);h(vF)[this.kB]=this}vF.prototype=Object.create(GE.prototype);vF.prototype.constructor=vF;vF.prototype.lB=vF;vF.mB={};b.btBvhTriangleMeshShape=vF;vF.prototype.setLocalScaling=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Mn(c,a)};vF.prototype.getLocalScaling=function(){return k(Nn(this.kB),n)}; -vF.prototype.calculateLocalInertia=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);On(d,a,c)};vF.prototype.__destroy__=function(){Pn(this.kB)}; -function wF(a,c,d,e,g,m,y,W,E){a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);g&&"object"===typeof g&&(g=g.kB);m&&"object"===typeof m&&(m=m.kB);y&&"object"===typeof y&&(y=y.kB);W&&"object"===typeof W&&(W=W.kB);E&&"object"===typeof E&&(E=E.kB);this.kB=Qn(a,c,d,e,g,m,y,W,E);h(wF)[this.kB]=this}wF.prototype=Object.create(uE.prototype);wF.prototype.constructor=wF;wF.prototype.lB=wF;wF.mB={}; -b.btHeightfieldTerrainShape=wF;wF.prototype.setMargin=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Rn(c,a)};wF.prototype.getMargin=function(){return Sn(this.kB)};wF.prototype.setLocalScaling=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Tn(c,a)};wF.prototype.getLocalScaling=function(){return k(Un(this.kB),n)};wF.prototype.calculateLocalInertia=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);Vn(d,a,c)}; -wF.prototype.__destroy__=function(){Wn(this.kB)};function xF(a,c,d,e){a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);this.kB=Xn(a,c,d,e);h(xF)[this.kB]=this}xF.prototype=Object.create(f.prototype);xF.prototype.constructor=xF;xF.prototype.lB=xF;xF.mB={};b.btAABB=xF;xF.prototype.invalidate=function(){Yn(this.kB)};xF.prototype.increment_margin=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Zn(c,a)}; -xF.prototype.copy_with_margin=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);$n(d,a,c)};xF.prototype.__destroy__=function(){ao(this.kB)};function yF(){this.kB=bo();h(yF)[this.kB]=this}yF.prototype=Object.create(f.prototype);yF.prototype.constructor=yF;yF.prototype.lB=yF;yF.mB={};b.btPrimitiveTriangle=yF;yF.prototype.__destroy__=function(){co(this.kB)}; -function zF(a,c,d){a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);this.kB=eo(a,c,d);h(zF)[this.kB]=this}zF.prototype=Object.create(f.prototype);zF.prototype.constructor=zF;zF.prototype.lB=zF;zF.mB={};b.btTriangleShapeEx=zF;zF.prototype.getAabb=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);fo(e,a,c,d)}; -zF.prototype.applyTransform=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);go(c,a)};zF.prototype.buildTriPlane=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);ho(c,a)};zF.prototype.__destroy__=function(){io(this.kB)};function AF(){this.kB=jo();h(AF)[this.kB]=this}AF.prototype=Object.create(f.prototype);AF.prototype.constructor=AF;AF.prototype.lB=AF;AF.mB={};b.btTetrahedronShapeEx=AF; -AF.prototype.setVertices=function(a,c,d,e){var g=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);ko(g,a,c,d,e)};AF.prototype.__destroy__=function(){lo(this.kB)};function BF(){throw"cannot construct a CompoundPrimitiveManager, no constructor in IDL";}BF.prototype=Object.create(HE.prototype);BF.prototype.constructor=BF;BF.prototype.lB=BF;BF.mB={};b.CompoundPrimitiveManager=BF; -BF.prototype.get_primitive_count=function(){return mo(this.kB)};BF.prototype.get_primitive_box=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);no(d,a,c)};BF.prototype.get_primitive_triangle=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);oo(d,a,c)};BF.prototype.is_trimesh=function(){return!!po(this.kB)};BF.prototype.get_m_compoundShape=BF.prototype.bD=function(){return k(qo(this.kB),J)}; -BF.prototype.set_m_compoundShape=BF.prototype.VF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);ro(c,a)};Object.defineProperty(BF.prototype,"m_compoundShape",{get:BF.prototype.bD,set:BF.prototype.VF});BF.prototype.__destroy__=function(){so(this.kB)};function J(a){a&&"object"===typeof a&&(a=a.kB);this.kB=void 0===a?to():uo(a);h(J)[this.kB]=this}J.prototype=Object.create(IE.prototype);J.prototype.constructor=J;J.prototype.lB=J;J.mB={};b.btGImpactCompoundShape=J; -J.prototype.childrenHasTransform=function(){return!!vo(this.kB)};J.prototype.getPrimitiveManager=function(){return k(wo(this.kB),HE)};J.prototype.getCompoundPrimitiveManager=function(){return k(xo(this.kB),BF)};J.prototype.getNumChildShapes=function(){return yo(this.kB)};J.prototype.addChildShape=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);zo(d,a,c)}; -J.prototype.getChildShape=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return k(Ao(c,a),l)};J.prototype.getChildAabb=function(a,c,d,e){var g=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);Bo(g,a,c,d,e)};J.prototype.getChildTransform=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return k(Co(c,a),t)}; -J.prototype.setChildTransform=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);Do(d,a,c)};J.prototype.calculateLocalInertia=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);Eo(d,a,c)};J.prototype.getName=function(){return Ga(Fo(this.kB))};J.prototype.getGImpactShapeType=function(){return Go(this.kB)};J.prototype.setLocalScaling=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Ho(c,a)}; -J.prototype.getLocalScaling=function(){return k(Io(this.kB),n)};J.prototype.updateBound=function(){Jo(this.kB)};J.prototype.postUpdate=function(){Ko(this.kB)};J.prototype.getShapeType=function(){return Lo(this.kB)};J.prototype.needsRetrieveTriangles=function(){return!!Mo(this.kB)};J.prototype.needsRetrieveTetrahedrons=function(){return!!No(this.kB)};J.prototype.getBulletTriangle=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);Oo(d,a,c)}; -J.prototype.getBulletTetrahedron=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);Po(d,a,c)};J.prototype.__destroy__=function(){Qo(this.kB)};function K(a){a&&"object"===typeof a&&(a=a.kB);this.kB=void 0===a?Ro():So(a);h(K)[this.kB]=this}K.prototype=Object.create(HE.prototype);K.prototype.constructor=K;K.prototype.lB=K;K.mB={};b.TrimeshPrimitiveManager=K;K.prototype.lock=K.prototype.lock=function(){To(this.kB)};K.prototype.unlock=K.prototype.unlock=function(){Uo(this.kB)}; -K.prototype.is_trimesh=function(){return!!Vo(this.kB)};K.prototype.get_vertex_count=function(){return Wo(this.kB)};K.prototype.get_indices=function(a,c,d,e){var g=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);Xo(g,a,c,d,e)};K.prototype.get_vertex=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);Yo(d,a,c)}; -K.prototype.get_bullet_triangle=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);Zo(d,a,c)};K.prototype.get_m_margin=K.prototype.SD=function(){return $o(this.kB)};K.prototype.set_m_margin=K.prototype.LG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);ap(c,a)};Object.defineProperty(K.prototype,"m_margin",{get:K.prototype.SD,set:K.prototype.LG});K.prototype.get_m_meshInterface=K.prototype.VD=function(){return k(bp(this.kB),FE)}; -K.prototype.set_m_meshInterface=K.prototype.OG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);cp(c,a)};Object.defineProperty(K.prototype,"m_meshInterface",{get:K.prototype.VD,set:K.prototype.OG});K.prototype.get_m_part=K.prototype.bE=function(){return dp(this.kB)};K.prototype.set_m_part=K.prototype.WG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);ep(c,a)};Object.defineProperty(K.prototype,"m_part",{get:K.prototype.bE,set:K.prototype.WG}); -K.prototype.get_m_lock_count=K.prototype.QD=function(){return fp(this.kB)};K.prototype.set_m_lock_count=K.prototype.JG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);gp(c,a)};Object.defineProperty(K.prototype,"m_lock_count",{get:K.prototype.QD,set:K.prototype.JG});K.prototype.get_numverts=K.prototype.SE=function(){return hp(this.kB)};K.prototype.set_numverts=K.prototype.MH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);ip(c,a)}; -Object.defineProperty(K.prototype,"numverts",{get:K.prototype.SE,set:K.prototype.MH});K.prototype.get_type=K.prototype.WE=function(){return jp(this.kB)};K.prototype.set_type=K.prototype.QH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);kp(c,a)};Object.defineProperty(K.prototype,"type",{get:K.prototype.WE,set:K.prototype.QH});K.prototype.get_stride=K.prototype.UE=function(){return lp(this.kB)}; -K.prototype.set_stride=K.prototype.OH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);mp(c,a)};Object.defineProperty(K.prototype,"stride",{get:K.prototype.UE,set:K.prototype.OH});K.prototype.get_indexstride=K.prototype.nC=function(){return np(this.kB)};K.prototype.set_indexstride=K.prototype.gF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);op(c,a)};Object.defineProperty(K.prototype,"indexstride",{get:K.prototype.nC,set:K.prototype.gF}); -K.prototype.get_numfaces=K.prototype.RE=function(){return pp(this.kB)};K.prototype.set_numfaces=K.prototype.LH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);qp(c,a)};Object.defineProperty(K.prototype,"numfaces",{get:K.prototype.RE,set:K.prototype.LH});K.prototype.get_indicestype=K.prototype.oC=function(){return rp(this.kB)};K.prototype.set_indicestype=K.prototype.hF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);sp(c,a)}; -Object.defineProperty(K.prototype,"indicestype",{get:K.prototype.oC,set:K.prototype.hF});K.prototype.__destroy__=function(){tp(this.kB)};function CF(a,c){a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);this.kB=up(a,c);h(CF)[this.kB]=this}CF.prototype=Object.create(IE.prototype);CF.prototype.constructor=CF;CF.prototype.lB=CF;CF.mB={};b.btGImpactMeshShapePart=CF;CF.prototype.getTrimeshPrimitiveManager=function(){return k(vp(this.kB),K)};CF.prototype.getVertexCount=function(){return wp(this.kB)}; -CF.prototype.getVertex=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);xp(d,a,c)};CF.prototype.getPart=function(){return yp(this.kB)};CF.prototype.setLocalScaling=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);zp(c,a)};CF.prototype.getLocalScaling=function(){return k(Ap(this.kB),n)};CF.prototype.updateBound=function(){Bp(this.kB)};CF.prototype.postUpdate=function(){Cp(this.kB)};CF.prototype.getShapeType=function(){return Dp(this.kB)}; -CF.prototype.needsRetrieveTriangles=function(){return!!Ep(this.kB)};CF.prototype.needsRetrieveTetrahedrons=function(){return!!Fp(this.kB)};CF.prototype.getBulletTriangle=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);Gp(d,a,c)};CF.prototype.getBulletTetrahedron=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);Hp(d,a,c)};CF.prototype.__destroy__=function(){Ip(this.kB)}; -function DF(a){a&&"object"===typeof a&&(a=a.kB);this.kB=Jp(a);h(DF)[this.kB]=this}DF.prototype=Object.create(IE.prototype);DF.prototype.constructor=DF;DF.prototype.lB=DF;DF.mB={};b.btGImpactMeshShape=DF;DF.prototype.getMeshInterface=function(){return k(Kp(this.kB),FE)};DF.prototype.getMeshPartCount=function(){return Lp(this.kB)};DF.prototype.getMeshPart=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return k(Mp(c,a),CF)};DF.prototype.calculateSerializeBufferSize=function(){return Np(this.kB)}; -DF.prototype.setLocalScaling=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Op(c,a)};DF.prototype.getLocalScaling=function(){return k(Pp(this.kB),n)};DF.prototype.updateBound=function(){Qp(this.kB)};DF.prototype.postUpdate=function(){Rp(this.kB)};DF.prototype.getShapeType=function(){return Sp(this.kB)};DF.prototype.needsRetrieveTriangles=function(){return!!Tp(this.kB)};DF.prototype.needsRetrieveTetrahedrons=function(){return!!Up(this.kB)}; -DF.prototype.getBulletTriangle=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);Vp(d,a,c)};DF.prototype.getBulletTetrahedron=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);Wp(d,a,c)};DF.prototype.__destroy__=function(){Xp(this.kB)}; -function EF(a,c){a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);this.kB=void 0===a?Yp():void 0===c?_emscripten_bind_btCollisionAlgorithmConstructionInfo_btCollisionAlgorithmConstructionInfo_1(a):Zp(a,c);h(EF)[this.kB]=this}EF.prototype=Object.create(f.prototype);EF.prototype.constructor=EF;EF.prototype.lB=EF;EF.mB={};b.btCollisionAlgorithmConstructionInfo=EF;EF.prototype.get_m_dispatcher1=EF.prototype.lD=function(){return k($p(this.kB),oE)}; -EF.prototype.set_m_dispatcher1=EF.prototype.eG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);aq(c,a)};Object.defineProperty(EF.prototype,"m_dispatcher1",{get:EF.prototype.lD,set:EF.prototype.eG});EF.prototype.get_m_manifold=EF.prototype.RD=function(){return k(bq(this.kB),LE)};EF.prototype.set_m_manifold=EF.prototype.KG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);cq(c,a)};Object.defineProperty(EF.prototype,"m_manifold",{get:EF.prototype.RD,set:EF.prototype.KG}); -EF.prototype.__destroy__=function(){dq(this.kB)};function FF(a,c,d){a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);this.kB=eq(a,c,d);h(FF)[this.kB]=this}FF.prototype=Object.create(JE.prototype);FF.prototype.constructor=FF;FF.prototype.lB=FF;FF.mB={};b.btGImpactCollisionAlgorithm=FF;FF.prototype.registerAlgorithm=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);fq(c,a)};FF.prototype.__destroy__=function(){gq(this.kB)}; -function GF(){this.kB=hq();h(GF)[this.kB]=this}GF.prototype=Object.create(f.prototype);GF.prototype.constructor=GF;GF.prototype.lB=GF;GF.mB={};b.btDefaultCollisionConstructionInfo=GF;GF.prototype.__destroy__=function(){iq(this.kB)};function LE(){this.kB=jq();h(LE)[this.kB]=this}LE.prototype=Object.create(f.prototype);LE.prototype.constructor=LE;LE.prototype.lB=LE;LE.mB={};b.btPersistentManifold=LE;LE.prototype.getBody0=function(){return k(kq(this.kB),r)}; -LE.prototype.getBody1=function(){return k(lq(this.kB),r)};LE.prototype.getNumContacts=function(){return mq(this.kB)};LE.prototype.getContactPoint=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return k(nq(c,a),F)};LE.prototype.__destroy__=function(){oq(this.kB)};function HF(a){a&&"object"===typeof a&&(a=a.kB);this.kB=pq(a);h(HF)[this.kB]=this}HF.prototype=Object.create(oE.prototype);HF.prototype.constructor=HF;HF.prototype.lB=HF;HF.mB={};b.btCollisionDispatcher=HF; -HF.prototype.getNumManifolds=function(){return qq(this.kB)};HF.prototype.getManifoldByIndexInternal=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return k(rq(c,a),LE)};HF.prototype.__destroy__=function(){sq(this.kB)};function IF(){throw"cannot construct a btOverlappingPairCallback, no constructor in IDL";}IF.prototype=Object.create(f.prototype);IF.prototype.constructor=IF;IF.prototype.lB=IF;IF.mB={};b.btOverlappingPairCallback=IF;IF.prototype.__destroy__=function(){tq(this.kB)}; -function pE(){throw"cannot construct a btOverlappingPairCache, no constructor in IDL";}pE.prototype=Object.create(f.prototype);pE.prototype.constructor=pE;pE.prototype.lB=pE;pE.mB={};b.btOverlappingPairCache=pE;pE.prototype.setInternalGhostPairCallback=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);uq(c,a)};pE.prototype.getNumOverlappingPairs=function(){return vq(this.kB)};pE.prototype.__destroy__=function(){wq(this.kB)}; -function JF(a,c,d,e,g){a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);g&&"object"===typeof g&&(g=g.kB);this.kB=void 0===d?xq(a,c):void 0===e?yq(a,c,d):void 0===g?zq(a,c,d,e):Aq(a,c,d,e,g);h(JF)[this.kB]=this}JF.prototype=Object.create(f.prototype);JF.prototype.constructor=JF;JF.prototype.lB=JF;JF.mB={};b.btAxisSweep3=JF;JF.prototype.__destroy__=function(){Bq(this.kB)}; -function qE(){throw"cannot construct a btBroadphaseInterface, no constructor in IDL";}qE.prototype=Object.create(f.prototype);qE.prototype.constructor=qE;qE.prototype.lB=qE;qE.mB={};b.btBroadphaseInterface=qE;qE.prototype.getOverlappingPairCache=function(){return k(Cq(this.kB),pE)};qE.prototype.__destroy__=function(){Dq(this.kB)};function KF(){throw"cannot construct a btCollisionConfiguration, no constructor in IDL";}KF.prototype=Object.create(f.prototype);KF.prototype.constructor=KF; -KF.prototype.lB=KF;KF.mB={};b.btCollisionConfiguration=KF;KF.prototype.__destroy__=function(){Eq(this.kB)};function LF(){this.kB=Fq();h(LF)[this.kB]=this}LF.prototype=Object.create(f.prototype);LF.prototype.constructor=LF;LF.prototype.lB=LF;LF.mB={};b.btDbvtBroadphase=LF;LF.prototype.__destroy__=function(){Gq(this.kB)};function tE(){throw"cannot construct a btBroadphaseProxy, no constructor in IDL";}tE.prototype=Object.create(f.prototype);tE.prototype.constructor=tE;tE.prototype.lB=tE;tE.mB={}; -b.btBroadphaseProxy=tE;tE.prototype.get_m_collisionFilterGroup=tE.prototype.nB=function(){return Hq(this.kB)};tE.prototype.set_m_collisionFilterGroup=tE.prototype.pB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Iq(c,a)};Object.defineProperty(tE.prototype,"m_collisionFilterGroup",{get:tE.prototype.nB,set:tE.prototype.pB});tE.prototype.get_m_collisionFilterMask=tE.prototype.oB=function(){return Jq(this.kB)}; -tE.prototype.set_m_collisionFilterMask=tE.prototype.qB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Kq(c,a)};Object.defineProperty(tE.prototype,"m_collisionFilterMask",{get:tE.prototype.oB,set:tE.prototype.qB});tE.prototype.__destroy__=function(){Lq(this.kB)};function L(a,c,d,e){a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);this.kB=void 0===e?Mq(a,c,d):Nq(a,c,d,e);h(L)[this.kB]=this}L.prototype=Object.create(f.prototype); -L.prototype.constructor=L;L.prototype.lB=L;L.mB={};b.btRigidBodyConstructionInfo=L;L.prototype.get_m_linearDamping=L.prototype.KD=function(){return Oq(this.kB)};L.prototype.set_m_linearDamping=L.prototype.DG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Pq(c,a)};Object.defineProperty(L.prototype,"m_linearDamping",{get:L.prototype.KD,set:L.prototype.DG});L.prototype.get_m_angularDamping=L.prototype.OC=function(){return Qq(this.kB)}; -L.prototype.set_m_angularDamping=L.prototype.HF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Rq(c,a)};Object.defineProperty(L.prototype,"m_angularDamping",{get:L.prototype.OC,set:L.prototype.HF});L.prototype.get_m_friction=L.prototype.rD=function(){return Sq(this.kB)};L.prototype.set_m_friction=L.prototype.kG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Tq(c,a)};Object.defineProperty(L.prototype,"m_friction",{get:L.prototype.rD,set:L.prototype.kG}); -L.prototype.get_m_rollingFriction=L.prototype.kE=function(){return Uq(this.kB)};L.prototype.set_m_rollingFriction=L.prototype.eH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Vq(c,a)};Object.defineProperty(L.prototype,"m_rollingFriction",{get:L.prototype.kE,set:L.prototype.eH});L.prototype.get_m_restitution=L.prototype.iE=function(){return Wq(this.kB)};L.prototype.set_m_restitution=L.prototype.cH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Xq(c,a)}; -Object.defineProperty(L.prototype,"m_restitution",{get:L.prototype.iE,set:L.prototype.cH});L.prototype.get_m_linearSleepingThreshold=L.prototype.LD=function(){return Yq(this.kB)};L.prototype.set_m_linearSleepingThreshold=L.prototype.EG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Zq(c,a)};Object.defineProperty(L.prototype,"m_linearSleepingThreshold",{get:L.prototype.LD,set:L.prototype.EG});L.prototype.get_m_angularSleepingThreshold=L.prototype.PC=function(){return $q(this.kB)}; -L.prototype.set_m_angularSleepingThreshold=L.prototype.IF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);ar(c,a)};Object.defineProperty(L.prototype,"m_angularSleepingThreshold",{get:L.prototype.PC,set:L.prototype.IF});L.prototype.get_m_additionalDamping=L.prototype.JC=function(){return!!br(this.kB)};L.prototype.set_m_additionalDamping=L.prototype.CF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);cr(c,a)}; -Object.defineProperty(L.prototype,"m_additionalDamping",{get:L.prototype.JC,set:L.prototype.CF});L.prototype.get_m_additionalDampingFactor=L.prototype.KC=function(){return dr(this.kB)};L.prototype.set_m_additionalDampingFactor=L.prototype.DF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);er(c,a)};Object.defineProperty(L.prototype,"m_additionalDampingFactor",{get:L.prototype.KC,set:L.prototype.DF});L.prototype.get_m_additionalLinearDampingThresholdSqr=L.prototype.LC=function(){return fr(this.kB)}; -L.prototype.set_m_additionalLinearDampingThresholdSqr=L.prototype.EF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);gr(c,a)};Object.defineProperty(L.prototype,"m_additionalLinearDampingThresholdSqr",{get:L.prototype.LC,set:L.prototype.EF});L.prototype.get_m_additionalAngularDampingThresholdSqr=L.prototype.IC=function(){return hr(this.kB)};L.prototype.set_m_additionalAngularDampingThresholdSqr=L.prototype.BF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);ir(c,a)}; -Object.defineProperty(L.prototype,"m_additionalAngularDampingThresholdSqr",{get:L.prototype.IC,set:L.prototype.BF});L.prototype.get_m_additionalAngularDampingFactor=L.prototype.HC=function(){return jr(this.kB)};L.prototype.set_m_additionalAngularDampingFactor=L.prototype.AF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);kr(c,a)};Object.defineProperty(L.prototype,"m_additionalAngularDampingFactor",{get:L.prototype.HC,set:L.prototype.AF});L.prototype.__destroy__=function(){lr(this.kB)}; -function M(a){a&&"object"===typeof a&&(a=a.kB);this.kB=mr(a);h(M)[this.kB]=this}M.prototype=Object.create(r.prototype);M.prototype.constructor=M;M.prototype.lB=M;M.mB={};b.btRigidBody=M;M.prototype.getCenterOfMassTransform=function(){return k(nr(this.kB),t)};M.prototype.setCenterOfMassTransform=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);or(c,a)};M.prototype.setSleepingThresholds=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);pr(d,a,c)}; -M.prototype.getLinearDamping=function(){return qr(this.kB)};M.prototype.getAngularDamping=function(){return rr(this.kB)};M.prototype.setDamping=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);sr(d,a,c)};M.prototype.setMassProps=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);tr(d,a,c)};M.prototype.getLinearFactor=function(){return k(ur(this.kB),n)}; -M.prototype.setLinearFactor=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);vr(c,a)};M.prototype.applyTorque=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);wr(c,a)};M.prototype.applyLocalTorque=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);xr(c,a)};M.prototype.applyForce=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);yr(d,a,c)}; -M.prototype.applyCentralForce=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);zr(c,a)};M.prototype.applyCentralLocalForce=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Ar(c,a)};M.prototype.applyTorqueImpulse=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Br(c,a)};M.prototype.applyImpulse=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);Cr(d,a,c)}; -M.prototype.applyCentralImpulse=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Dr(c,a)};M.prototype.updateInertiaTensor=function(){Er(this.kB)};M.prototype.getLinearVelocity=function(){return k(Fr(this.kB),n)};M.prototype.getAngularVelocity=function(){return k(Gr(this.kB),n)};M.prototype.setLinearVelocity=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Hr(c,a)};M.prototype.setAngularVelocity=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Ir(c,a)}; -M.prototype.getMotionState=function(){return k(Jr(this.kB),zE)};M.prototype.setMotionState=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Kr(c,a)};M.prototype.getAngularFactor=function(){return k(Lr(this.kB),n)};M.prototype.setAngularFactor=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Mr(c,a)};M.prototype.upcast=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return k(Nr(c,a),M)}; -M.prototype.getAabb=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);Or(d,a,c)};M.prototype.applyGravity=function(){Pr(this.kB)};M.prototype.getGravity=function(){return k(Qr(this.kB),n)};M.prototype.setGravity=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Rr(c,a)};M.prototype.getBroadphaseProxy=function(){return k(Sr(this.kB),tE)};M.prototype.clearForces=function(){Tr(this.kB)}; -M.prototype.setFlags=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Ur(c,a)};M.prototype.getFlags=function(){return Vr(this.kB)};M.prototype.setAnisotropicFriction=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);Wr(d,a,c)};M.prototype.getCollisionShape=function(){return k(Xr(this.kB),l)};M.prototype.setContactProcessingThreshold=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Yr(c,a)}; -M.prototype.setActivationState=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Zr(c,a)};M.prototype.forceActivationState=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);$r(c,a)};M.prototype.activate=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);void 0===a?as(c):bs(c,a)};M.prototype.isActive=function(){return!!cs(this.kB)};M.prototype.isKinematicObject=function(){return!!ds(this.kB)};M.prototype.isStaticObject=function(){return!!es(this.kB)}; -M.prototype.isStaticOrKinematicObject=function(){return!!gs(this.kB)};M.prototype.getRestitution=function(){return hs(this.kB)};M.prototype.getFriction=function(){return is(this.kB)};M.prototype.getRollingFriction=function(){return js(this.kB)};M.prototype.setRestitution=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);ks(c,a)};M.prototype.setFriction=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);ls(c,a)}; -M.prototype.setRollingFriction=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);ms(c,a)};M.prototype.getWorldTransform=function(){return k(ns(this.kB),t)};M.prototype.getCollisionFlags=function(){return ps(this.kB)};M.prototype.setCollisionFlags=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);qs(c,a)};M.prototype.setWorldTransform=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);rs(c,a)}; -M.prototype.setCollisionShape=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);ss(c,a)};M.prototype.setCcdMotionThreshold=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);ts(c,a)};M.prototype.setCcdSweptSphereRadius=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);us(c,a)};M.prototype.getUserIndex=function(){return vs(this.kB)};M.prototype.setUserIndex=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);xs(c,a)}; -M.prototype.getUserPointer=function(){return k(ys(this.kB),sE)};M.prototype.setUserPointer=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);zs(c,a)};M.prototype.getBroadphaseHandle=function(){return k(As(this.kB),tE)};M.prototype.__destroy__=function(){Bs(this.kB)};function MF(){this.kB=Cs();h(MF)[this.kB]=this}MF.prototype=Object.create(f.prototype);MF.prototype.constructor=MF;MF.prototype.lB=MF;MF.mB={};b.btConstraintSetting=MF;MF.prototype.get_m_tau=MF.prototype.zE=function(){return Ds(this.kB)}; -MF.prototype.set_m_tau=MF.prototype.tH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Es(c,a)};Object.defineProperty(MF.prototype,"m_tau",{get:MF.prototype.zE,set:MF.prototype.tH});MF.prototype.get_m_damping=MF.prototype.hD=function(){return Fs(this.kB)};MF.prototype.set_m_damping=MF.prototype.aG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Gs(c,a)};Object.defineProperty(MF.prototype,"m_damping",{get:MF.prototype.hD,set:MF.prototype.aG}); -MF.prototype.get_m_impulseClamp=MF.prototype.DD=function(){return Hs(this.kB)};MF.prototype.set_m_impulseClamp=MF.prototype.wG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Is(c,a)};Object.defineProperty(MF.prototype,"m_impulseClamp",{get:MF.prototype.DD,set:MF.prototype.wG});MF.prototype.__destroy__=function(){Js(this.kB)}; -function NF(a,c,d,e){a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);this.kB=void 0===d?Ks(a,c):void 0===e?_emscripten_bind_btPoint2PointConstraint_btPoint2PointConstraint_3(a,c,d):Ls(a,c,d,e);h(NF)[this.kB]=this}NF.prototype=Object.create(wE.prototype);NF.prototype.constructor=NF;NF.prototype.lB=NF;NF.mB={};b.btPoint2PointConstraint=NF; -NF.prototype.setPivotA=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Ms(c,a)};NF.prototype.setPivotB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Ns(c,a)};NF.prototype.getPivotInA=function(){return k(Os(this.kB),n)};NF.prototype.getPivotInB=function(){return k(Ps(this.kB),n)};NF.prototype.enableFeedback=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Qs(c,a)};NF.prototype.getBreakingImpulseThreshold=function(){return Rs(this.kB)}; -NF.prototype.setBreakingImpulseThreshold=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Ss(c,a)};NF.prototype.getParam=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);return Ts(d,a,c)};NF.prototype.setParam=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);Us(e,a,c,d)};NF.prototype.get_m_setting=NF.prototype.mE=function(){return k(Vs(this.kB),MF)}; -NF.prototype.set_m_setting=NF.prototype.gH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Ws(c,a)};Object.defineProperty(NF.prototype,"m_setting",{get:NF.prototype.mE,set:NF.prototype.gH});NF.prototype.__destroy__=function(){Xs(this.kB)}; -function OF(a,c,d,e,g){a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);g&&"object"===typeof g&&(g=g.kB);this.kB=void 0===e?Ys(a,c,d):void 0===g?_emscripten_bind_btGeneric6DofSpringConstraint_btGeneric6DofSpringConstraint_4(a,c,d,e):Zs(a,c,d,e,g);h(OF)[this.kB]=this}OF.prototype=Object.create(ME.prototype);OF.prototype.constructor=OF;OF.prototype.lB=OF;OF.mB={};b.btGeneric6DofSpringConstraint=OF; -OF.prototype.enableSpring=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);$s(d,a,c)};OF.prototype.setStiffness=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);at(d,a,c)};OF.prototype.setDamping=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);bt(d,a,c)}; -OF.prototype.setEquilibriumPoint=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);void 0===a?ct(d):void 0===c?dt(d,a):et(d,a,c)};OF.prototype.setLinearLowerLimit=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);ft(c,a)};OF.prototype.setLinearUpperLimit=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);gt(c,a)};OF.prototype.setAngularLowerLimit=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);ht(c,a)}; -OF.prototype.setAngularUpperLimit=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);it(c,a)};OF.prototype.getFrameOffsetA=function(){return k(jt(this.kB),t)};OF.prototype.enableFeedback=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);kt(c,a)};OF.prototype.getBreakingImpulseThreshold=function(){return lt(this.kB)};OF.prototype.setBreakingImpulseThreshold=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);mt(c,a)}; -OF.prototype.getParam=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);return nt(d,a,c)};OF.prototype.setParam=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);ot(e,a,c,d)};OF.prototype.__destroy__=function(){pt(this.kB)};function PF(){this.kB=qt();h(PF)[this.kB]=this}PF.prototype=Object.create(f.prototype);PF.prototype.constructor=PF;PF.prototype.lB=PF;PF.mB={}; -b.btSequentialImpulseConstraintSolver=PF;PF.prototype.__destroy__=function(){rt(this.kB)};function QF(a,c,d,e){a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);this.kB=void 0===d?st(a,c):void 0===e?_emscripten_bind_btConeTwistConstraint_btConeTwistConstraint_3(a,c,d):tt(a,c,d,e);h(QF)[this.kB]=this}QF.prototype=Object.create(wE.prototype);QF.prototype.constructor=QF;QF.prototype.lB=QF;QF.mB={}; -b.btConeTwistConstraint=QF;QF.prototype.setLimit=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);ut(d,a,c)};QF.prototype.setAngularOnly=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);vt(c,a)};QF.prototype.setDamping=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);wt(c,a)};QF.prototype.enableMotor=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);xt(c,a)}; -QF.prototype.setMaxMotorImpulse=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);yt(c,a)};QF.prototype.setMaxMotorImpulseNormalized=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);zt(c,a)};QF.prototype.setMotorTarget=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);At(c,a)};QF.prototype.setMotorTargetInConstraintSpace=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Bt(c,a)}; -QF.prototype.enableFeedback=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Ct(c,a)};QF.prototype.getBreakingImpulseThreshold=function(){return Dt(this.kB)};QF.prototype.setBreakingImpulseThreshold=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Et(c,a)};QF.prototype.getParam=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);return Ft(d,a,c)}; -QF.prototype.setParam=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);Gt(e,a,c,d)};QF.prototype.__destroy__=function(){Ht(this.kB)}; -function RF(a,c,d,e,g,m,y){a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);g&&"object"===typeof g&&(g=g.kB);m&&"object"===typeof m&&(m=m.kB);y&&"object"===typeof y&&(y=y.kB);this.kB=void 0===d?It(a,c):void 0===e?Jt(a,c,d):void 0===g?Kt(a,c,d,e):void 0===m?Lt(a,c,d,e,g):void 0===y?Mt(a,c,d,e,g,m):Nt(a,c,d,e,g,m,y);h(RF)[this.kB]=this}RF.prototype=Object.create(wE.prototype);RF.prototype.constructor=RF; -RF.prototype.lB=RF;RF.mB={};b.btHingeConstraint=RF;RF.prototype.getHingeAngle=function(){return Ot(this.kB)};RF.prototype.setLimit=function(a,c,d,e,g){var m=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);g&&"object"===typeof g&&(g=g.kB);void 0===g?Pt(m,a,c,d,e):Qt(m,a,c,d,e,g)}; -RF.prototype.enableAngularMotor=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);Rt(e,a,c,d)};RF.prototype.setAngularOnly=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);St(c,a)};RF.prototype.enableMotor=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Tt(c,a)};RF.prototype.setMaxMotorImpulse=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Ut(c,a)}; -RF.prototype.setMotorTarget=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);Vt(d,a,c)};RF.prototype.enableFeedback=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Wt(c,a)};RF.prototype.getBreakingImpulseThreshold=function(){return Xt(this.kB)};RF.prototype.setBreakingImpulseThreshold=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Yt(c,a)}; -RF.prototype.getParam=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);return Zt(d,a,c)};RF.prototype.setParam=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);$t(e,a,c,d)};RF.prototype.__destroy__=function(){au(this.kB)}; -function SF(a,c,d,e,g){a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);g&&"object"===typeof g&&(g=g.kB);this.kB=void 0===e?bu(a,c,d):void 0===g?_emscripten_bind_btSliderConstraint_btSliderConstraint_4(a,c,d,e):cu(a,c,d,e,g);h(SF)[this.kB]=this}SF.prototype=Object.create(wE.prototype);SF.prototype.constructor=SF;SF.prototype.lB=SF;SF.mB={};b.btSliderConstraint=SF;SF.prototype.getLinearPos=function(){return du(this.kB)}; -SF.prototype.getAngularPos=function(){return eu(this.kB)};SF.prototype.setLowerLinLimit=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);fu(c,a)};SF.prototype.setUpperLinLimit=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);gu(c,a)};SF.prototype.setLowerAngLimit=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);hu(c,a)};SF.prototype.setUpperAngLimit=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);iu(c,a)}; -SF.prototype.setPoweredLinMotor=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);ju(c,a)};SF.prototype.setMaxLinMotorForce=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);ku(c,a)};SF.prototype.setTargetLinMotorVelocity=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);lu(c,a)};SF.prototype.enableFeedback=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);mu(c,a)};SF.prototype.getBreakingImpulseThreshold=function(){return nu(this.kB)}; -SF.prototype.setBreakingImpulseThreshold=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);ou(c,a)};SF.prototype.getParam=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);return pu(d,a,c)};SF.prototype.setParam=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);qu(e,a,c,d)};SF.prototype.__destroy__=function(){ru(this.kB)}; -function TF(a,c,d,e){a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);this.kB=su(a,c,d,e);h(TF)[this.kB]=this}TF.prototype=Object.create(wE.prototype);TF.prototype.constructor=TF;TF.prototype.lB=TF;TF.mB={};b.btFixedConstraint=TF;TF.prototype.enableFeedback=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);tu(c,a)};TF.prototype.getBreakingImpulseThreshold=function(){return uu(this.kB)}; -TF.prototype.setBreakingImpulseThreshold=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);vu(c,a)};TF.prototype.getParam=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);return wu(d,a,c)};TF.prototype.setParam=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);xu(e,a,c,d)};TF.prototype.__destroy__=function(){yu(this.kB)}; -function UF(){throw"cannot construct a btConstraintSolver, no constructor in IDL";}UF.prototype=Object.create(f.prototype);UF.prototype.constructor=UF;UF.prototype.lB=UF;UF.mB={};b.btConstraintSolver=UF;UF.prototype.__destroy__=function(){zu(this.kB)};function q(){throw"cannot construct a btDispatcherInfo, no constructor in IDL";}q.prototype=Object.create(f.prototype);q.prototype.constructor=q;q.prototype.lB=q;q.mB={};b.btDispatcherInfo=q;q.prototype.get_m_timeStep=q.prototype.BE=function(){return Au(this.kB)}; -q.prototype.set_m_timeStep=q.prototype.vH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Bu(c,a)};Object.defineProperty(q.prototype,"m_timeStep",{get:q.prototype.BE,set:q.prototype.vH});q.prototype.get_m_stepCount=q.prototype.sE=function(){return Cu(this.kB)};q.prototype.set_m_stepCount=q.prototype.mH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Du(c,a)};Object.defineProperty(q.prototype,"m_stepCount",{get:q.prototype.sE,set:q.prototype.mH}); -q.prototype.get_m_dispatchFunc=q.prototype.jD=function(){return Eu(this.kB)};q.prototype.set_m_dispatchFunc=q.prototype.cG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Fu(c,a)};Object.defineProperty(q.prototype,"m_dispatchFunc",{get:q.prototype.jD,set:q.prototype.cG});q.prototype.get_m_timeOfImpact=q.prototype.AE=function(){return Gu(this.kB)};q.prototype.set_m_timeOfImpact=q.prototype.uH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Hu(c,a)}; -Object.defineProperty(q.prototype,"m_timeOfImpact",{get:q.prototype.AE,set:q.prototype.uH});q.prototype.get_m_useContinuous=q.prototype.DE=function(){return!!Iu(this.kB)};q.prototype.set_m_useContinuous=q.prototype.xH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Ju(c,a)};Object.defineProperty(q.prototype,"m_useContinuous",{get:q.prototype.DE,set:q.prototype.xH});q.prototype.get_m_enableSatConvex=q.prototype.oD=function(){return!!Ku(this.kB)}; -q.prototype.set_m_enableSatConvex=q.prototype.hG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Lu(c,a)};Object.defineProperty(q.prototype,"m_enableSatConvex",{get:q.prototype.oD,set:q.prototype.hG});q.prototype.get_m_enableSPU=q.prototype.nD=function(){return!!Mu(this.kB)};q.prototype.set_m_enableSPU=q.prototype.gG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Nu(c,a)};Object.defineProperty(q.prototype,"m_enableSPU",{get:q.prototype.nD,set:q.prototype.gG}); -q.prototype.get_m_useEpa=q.prototype.FE=function(){return!!Ou(this.kB)};q.prototype.set_m_useEpa=q.prototype.zH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Pu(c,a)};Object.defineProperty(q.prototype,"m_useEpa",{get:q.prototype.FE,set:q.prototype.zH});q.prototype.get_m_allowedCcdPenetration=q.prototype.MC=function(){return Qu(this.kB)};q.prototype.set_m_allowedCcdPenetration=q.prototype.FF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Ru(c,a)}; -Object.defineProperty(q.prototype,"m_allowedCcdPenetration",{get:q.prototype.MC,set:q.prototype.FF});q.prototype.get_m_useConvexConservativeDistanceUtil=q.prototype.EE=function(){return!!Su(this.kB)};q.prototype.set_m_useConvexConservativeDistanceUtil=q.prototype.yH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Tu(c,a)};Object.defineProperty(q.prototype,"m_useConvexConservativeDistanceUtil",{get:q.prototype.EE,set:q.prototype.yH}); -q.prototype.get_m_convexConservativeDistanceThreshold=q.prototype.eD=function(){return Uu(this.kB)};q.prototype.set_m_convexConservativeDistanceThreshold=q.prototype.YF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Vu(c,a)};Object.defineProperty(q.prototype,"m_convexConservativeDistanceThreshold",{get:q.prototype.eD,set:q.prototype.YF});q.prototype.__destroy__=function(){Wu(this.kB)};function u(){throw"cannot construct a btContactSolverInfo, no constructor in IDL";}u.prototype=Object.create(f.prototype); -u.prototype.constructor=u;u.prototype.lB=u;u.mB={};b.btContactSolverInfo=u;u.prototype.get_m_splitImpulse=u.prototype.pE=function(){return!!Xu(this.kB)};u.prototype.set_m_splitImpulse=u.prototype.jH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Yu(c,a)};Object.defineProperty(u.prototype,"m_splitImpulse",{get:u.prototype.pE,set:u.prototype.jH});u.prototype.get_m_splitImpulsePenetrationThreshold=u.prototype.qE=function(){return Zu(this.kB)}; -u.prototype.set_m_splitImpulsePenetrationThreshold=u.prototype.kH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);$u(c,a)};Object.defineProperty(u.prototype,"m_splitImpulsePenetrationThreshold",{get:u.prototype.qE,set:u.prototype.kH});u.prototype.get_m_numIterations=u.prototype.$D=function(){return av(this.kB)};u.prototype.set_m_numIterations=u.prototype.UG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);bv(c,a)}; -Object.defineProperty(u.prototype,"m_numIterations",{get:u.prototype.$D,set:u.prototype.UG});u.prototype.__destroy__=function(){cv(this.kB)};function N(){this.kB=dv();h(N)[this.kB]=this}N.prototype=Object.create(f.prototype);N.prototype.constructor=N;N.prototype.lB=N;N.mB={};b.btVehicleTuning=N;N.prototype.get_m_suspensionStiffness=N.prototype.EB=function(){return ev(this.kB)};N.prototype.set_m_suspensionStiffness=N.prototype.MB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);fv(c,a)}; -Object.defineProperty(N.prototype,"m_suspensionStiffness",{get:N.prototype.EB,set:N.prototype.MB});N.prototype.get_m_suspensionCompression=N.prototype.tE=function(){return gv(this.kB)};N.prototype.set_m_suspensionCompression=N.prototype.nH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);hv(c,a)};Object.defineProperty(N.prototype,"m_suspensionCompression",{get:N.prototype.tE,set:N.prototype.nH});N.prototype.get_m_suspensionDamping=N.prototype.uE=function(){return iv(this.kB)}; -N.prototype.set_m_suspensionDamping=N.prototype.oH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);jv(c,a)};Object.defineProperty(N.prototype,"m_suspensionDamping",{get:N.prototype.uE,set:N.prototype.oH});N.prototype.get_m_maxSuspensionTravelCm=N.prototype.DB=function(){return kv(this.kB)};N.prototype.set_m_maxSuspensionTravelCm=N.prototype.LB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);lv(c,a)}; -Object.defineProperty(N.prototype,"m_maxSuspensionTravelCm",{get:N.prototype.DB,set:N.prototype.LB});N.prototype.get_m_frictionSlip=N.prototype.zB=function(){return mv(this.kB)};N.prototype.set_m_frictionSlip=N.prototype.HB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);nv(c,a)};Object.defineProperty(N.prototype,"m_frictionSlip",{get:N.prototype.zB,set:N.prototype.HB});N.prototype.get_m_maxSuspensionForce=N.prototype.CB=function(){return ov(this.kB)}; -N.prototype.set_m_maxSuspensionForce=N.prototype.KB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);pv(c,a)};Object.defineProperty(N.prototype,"m_maxSuspensionForce",{get:N.prototype.CB,set:N.prototype.KB});function VF(){throw"cannot construct a btVehicleRaycasterResult, no constructor in IDL";}VF.prototype=Object.create(f.prototype);VF.prototype.constructor=VF;VF.prototype.lB=VF;VF.mB={};b.btVehicleRaycasterResult=VF; -VF.prototype.get_m_hitPointInWorld=VF.prototype.AD=function(){return k(qv(this.kB),n)};VF.prototype.set_m_hitPointInWorld=VF.prototype.tG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);rv(c,a)};Object.defineProperty(VF.prototype,"m_hitPointInWorld",{get:VF.prototype.AD,set:VF.prototype.tG});VF.prototype.get_m_hitNormalInWorld=VF.prototype.yD=function(){return k(sv(this.kB),n)}; -VF.prototype.set_m_hitNormalInWorld=VF.prototype.rG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);tv(c,a)};Object.defineProperty(VF.prototype,"m_hitNormalInWorld",{get:VF.prototype.yD,set:VF.prototype.rG});VF.prototype.get_m_distFraction=VF.prototype.mD=function(){return uv(this.kB)};VF.prototype.set_m_distFraction=VF.prototype.fG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);vv(c,a)};Object.defineProperty(VF.prototype,"m_distFraction",{get:VF.prototype.mD,set:VF.prototype.fG}); -VF.prototype.__destroy__=function(){wv(this.kB)};function WF(a){a&&"object"===typeof a&&(a=a.kB);this.kB=xv(a);h(WF)[this.kB]=this}WF.prototype=Object.create(NE.prototype);WF.prototype.constructor=WF;WF.prototype.lB=WF;WF.mB={};b.btDefaultVehicleRaycaster=WF;WF.prototype.castRay=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);yv(e,a,c,d)};WF.prototype.__destroy__=function(){zv(this.kB)}; -function O(){throw"cannot construct a RaycastInfo, no constructor in IDL";}O.prototype=Object.create(f.prototype);O.prototype.constructor=O;O.prototype.lB=O;O.mB={};b.RaycastInfo=O;O.prototype.get_m_contactNormalWS=O.prototype.cD=function(){return k(Av(this.kB),n)};O.prototype.set_m_contactNormalWS=O.prototype.WF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Bv(c,a)};Object.defineProperty(O.prototype,"m_contactNormalWS",{get:O.prototype.cD,set:O.prototype.WF}); -O.prototype.get_m_contactPointWS=O.prototype.dD=function(){return k(Cv(this.kB),n)};O.prototype.set_m_contactPointWS=O.prototype.XF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Dv(c,a)};Object.defineProperty(O.prototype,"m_contactPointWS",{get:O.prototype.dD,set:O.prototype.XF});O.prototype.get_m_suspensionLength=O.prototype.vE=function(){return Ev(this.kB)};O.prototype.set_m_suspensionLength=O.prototype.pH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Fv(c,a)}; -Object.defineProperty(O.prototype,"m_suspensionLength",{get:O.prototype.vE,set:O.prototype.pH});O.prototype.get_m_hardPointWS=O.prototype.vD=function(){return k(Gv(this.kB),n)};O.prototype.set_m_hardPointWS=O.prototype.oG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Hv(c,a)};Object.defineProperty(O.prototype,"m_hardPointWS",{get:O.prototype.vD,set:O.prototype.oG});O.prototype.get_m_wheelDirectionWS=O.prototype.KE=function(){return k(Iv(this.kB),n)}; -O.prototype.set_m_wheelDirectionWS=O.prototype.EH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Jv(c,a)};Object.defineProperty(O.prototype,"m_wheelDirectionWS",{get:O.prototype.KE,set:O.prototype.EH});O.prototype.get_m_wheelAxleWS=O.prototype.JE=function(){return k(Kv(this.kB),n)};O.prototype.set_m_wheelAxleWS=O.prototype.DH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Lv(c,a)};Object.defineProperty(O.prototype,"m_wheelAxleWS",{get:O.prototype.JE,set:O.prototype.DH}); -O.prototype.get_m_isInContact=O.prototype.GD=function(){return!!Mv(this.kB)};O.prototype.set_m_isInContact=O.prototype.zG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Nv(c,a)};Object.defineProperty(O.prototype,"m_isInContact",{get:O.prototype.GD,set:O.prototype.zG});O.prototype.get_m_groundObject=O.prototype.uD=function(){return Ov(this.kB)};O.prototype.set_m_groundObject=O.prototype.nG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Pv(c,a)}; -Object.defineProperty(O.prototype,"m_groundObject",{get:O.prototype.uD,set:O.prototype.nG});O.prototype.__destroy__=function(){Qv(this.kB)};function P(){throw"cannot construct a btWheelInfoConstructionInfo, no constructor in IDL";}P.prototype=Object.create(f.prototype);P.prototype.constructor=P;P.prototype.lB=P;P.mB={};b.btWheelInfoConstructionInfo=P;P.prototype.get_m_chassisConnectionCS=P.prototype.YC=function(){return k(Rv(this.kB),n)}; -P.prototype.set_m_chassisConnectionCS=P.prototype.RF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Sv(c,a)};Object.defineProperty(P.prototype,"m_chassisConnectionCS",{get:P.prototype.YC,set:P.prototype.RF});P.prototype.get_m_wheelDirectionCS=P.prototype.UB=function(){return k(Tv(this.kB),n)};P.prototype.set_m_wheelDirectionCS=P.prototype.dC=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Uv(c,a)};Object.defineProperty(P.prototype,"m_wheelDirectionCS",{get:P.prototype.UB,set:P.prototype.dC}); -P.prototype.get_m_wheelAxleCS=P.prototype.TB=function(){return k(Vv(this.kB),n)};P.prototype.set_m_wheelAxleCS=P.prototype.cC=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Wv(c,a)};Object.defineProperty(P.prototype,"m_wheelAxleCS",{get:P.prototype.TB,set:P.prototype.cC});P.prototype.get_m_suspensionRestLength=P.prototype.xE=function(){return Xv(this.kB)};P.prototype.set_m_suspensionRestLength=P.prototype.rH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Yv(c,a)}; -Object.defineProperty(P.prototype,"m_suspensionRestLength",{get:P.prototype.xE,set:P.prototype.rH});P.prototype.get_m_maxSuspensionTravelCm=P.prototype.DB=function(){return Zv(this.kB)};P.prototype.set_m_maxSuspensionTravelCm=P.prototype.LB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);$v(c,a)};Object.defineProperty(P.prototype,"m_maxSuspensionTravelCm",{get:P.prototype.DB,set:P.prototype.LB});P.prototype.get_m_wheelRadius=P.prototype.LE=function(){return aw(this.kB)}; -P.prototype.set_m_wheelRadius=P.prototype.FH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);bw(c,a)};Object.defineProperty(P.prototype,"m_wheelRadius",{get:P.prototype.LE,set:P.prototype.FH});P.prototype.get_m_suspensionStiffness=P.prototype.EB=function(){return cw(this.kB)};P.prototype.set_m_suspensionStiffness=P.prototype.MB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);dw(c,a)};Object.defineProperty(P.prototype,"m_suspensionStiffness",{get:P.prototype.EB,set:P.prototype.MB}); -P.prototype.get_m_wheelsDampingCompression=P.prototype.VB=function(){return ew(this.kB)};P.prototype.set_m_wheelsDampingCompression=P.prototype.eC=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);fw(c,a)};Object.defineProperty(P.prototype,"m_wheelsDampingCompression",{get:P.prototype.VB,set:P.prototype.eC});P.prototype.get_m_wheelsDampingRelaxation=P.prototype.WB=function(){return gw(this.kB)}; -P.prototype.set_m_wheelsDampingRelaxation=P.prototype.fC=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);hw(c,a)};Object.defineProperty(P.prototype,"m_wheelsDampingRelaxation",{get:P.prototype.WB,set:P.prototype.fC});P.prototype.get_m_frictionSlip=P.prototype.zB=function(){return iw(this.kB)};P.prototype.set_m_frictionSlip=P.prototype.HB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);jw(c,a)};Object.defineProperty(P.prototype,"m_frictionSlip",{get:P.prototype.zB,set:P.prototype.HB}); -P.prototype.get_m_maxSuspensionForce=P.prototype.CB=function(){return kw(this.kB)};P.prototype.set_m_maxSuspensionForce=P.prototype.KB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);lw(c,a)};Object.defineProperty(P.prototype,"m_maxSuspensionForce",{get:P.prototype.CB,set:P.prototype.KB});P.prototype.get_m_bIsFrontWheel=P.prototype.NB=function(){return!!mw(this.kB)};P.prototype.set_m_bIsFrontWheel=P.prototype.XB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);nw(c,a)}; -Object.defineProperty(P.prototype,"m_bIsFrontWheel",{get:P.prototype.NB,set:P.prototype.XB});P.prototype.__destroy__=function(){ow(this.kB)};function Q(a){a&&"object"===typeof a&&(a=a.kB);this.kB=pw(a);h(Q)[this.kB]=this}Q.prototype=Object.create(f.prototype);Q.prototype.constructor=Q;Q.prototype.lB=Q;Q.mB={};b.btWheelInfo=Q;Q.prototype.getSuspensionRestLength=function(){return qw(this.kB)}; -Q.prototype.updateWheel=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);rw(d,a,c)};Q.prototype.get_m_suspensionStiffness=Q.prototype.EB=function(){return sw(this.kB)};Q.prototype.set_m_suspensionStiffness=Q.prototype.MB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);tw(c,a)};Object.defineProperty(Q.prototype,"m_suspensionStiffness",{get:Q.prototype.EB,set:Q.prototype.MB});Q.prototype.get_m_frictionSlip=Q.prototype.zB=function(){return uw(this.kB)}; -Q.prototype.set_m_frictionSlip=Q.prototype.HB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);vw(c,a)};Object.defineProperty(Q.prototype,"m_frictionSlip",{get:Q.prototype.zB,set:Q.prototype.HB});Q.prototype.get_m_engineForce=Q.prototype.pD=function(){return ww(this.kB)};Q.prototype.set_m_engineForce=Q.prototype.iG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);xw(c,a)};Object.defineProperty(Q.prototype,"m_engineForce",{get:Q.prototype.pD,set:Q.prototype.iG}); -Q.prototype.get_m_rollInfluence=Q.prototype.jE=function(){return yw(this.kB)};Q.prototype.set_m_rollInfluence=Q.prototype.dH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);zw(c,a)};Object.defineProperty(Q.prototype,"m_rollInfluence",{get:Q.prototype.jE,set:Q.prototype.dH});Q.prototype.get_m_suspensionRestLength1=Q.prototype.yE=function(){return Aw(this.kB)};Q.prototype.set_m_suspensionRestLength1=Q.prototype.sH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Bw(c,a)}; -Object.defineProperty(Q.prototype,"m_suspensionRestLength1",{get:Q.prototype.yE,set:Q.prototype.sH});Q.prototype.get_m_wheelsRadius=Q.prototype.ME=function(){return Cw(this.kB)};Q.prototype.set_m_wheelsRadius=Q.prototype.GH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Dw(c,a)};Object.defineProperty(Q.prototype,"m_wheelsRadius",{get:Q.prototype.ME,set:Q.prototype.GH});Q.prototype.get_m_wheelsDampingCompression=Q.prototype.VB=function(){return Ew(this.kB)}; -Q.prototype.set_m_wheelsDampingCompression=Q.prototype.eC=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Fw(c,a)};Object.defineProperty(Q.prototype,"m_wheelsDampingCompression",{get:Q.prototype.VB,set:Q.prototype.eC});Q.prototype.get_m_wheelsDampingRelaxation=Q.prototype.WB=function(){return Gw(this.kB)};Q.prototype.set_m_wheelsDampingRelaxation=Q.prototype.fC=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Hw(c,a)}; -Object.defineProperty(Q.prototype,"m_wheelsDampingRelaxation",{get:Q.prototype.WB,set:Q.prototype.fC});Q.prototype.get_m_steering=Q.prototype.rE=function(){return Iw(this.kB)};Q.prototype.set_m_steering=Q.prototype.lH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Jw(c,a)};Object.defineProperty(Q.prototype,"m_steering",{get:Q.prototype.rE,set:Q.prototype.lH});Q.prototype.get_m_maxSuspensionForce=Q.prototype.CB=function(){return Kw(this.kB)}; -Q.prototype.set_m_maxSuspensionForce=Q.prototype.KB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Lw(c,a)};Object.defineProperty(Q.prototype,"m_maxSuspensionForce",{get:Q.prototype.CB,set:Q.prototype.KB});Q.prototype.get_m_maxSuspensionTravelCm=Q.prototype.DB=function(){return Mw(this.kB)};Q.prototype.set_m_maxSuspensionTravelCm=Q.prototype.LB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Nw(c,a)}; -Object.defineProperty(Q.prototype,"m_maxSuspensionTravelCm",{get:Q.prototype.DB,set:Q.prototype.LB});Q.prototype.get_m_wheelsSuspensionForce=Q.prototype.NE=function(){return Ow(this.kB)};Q.prototype.set_m_wheelsSuspensionForce=Q.prototype.HH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Pw(c,a)};Object.defineProperty(Q.prototype,"m_wheelsSuspensionForce",{get:Q.prototype.NE,set:Q.prototype.HH});Q.prototype.get_m_bIsFrontWheel=Q.prototype.NB=function(){return!!Qw(this.kB)}; -Q.prototype.set_m_bIsFrontWheel=Q.prototype.XB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Rw(c,a)};Object.defineProperty(Q.prototype,"m_bIsFrontWheel",{get:Q.prototype.NB,set:Q.prototype.XB});Q.prototype.get_m_raycastInfo=Q.prototype.hE=function(){return k(Sw(this.kB),O)};Q.prototype.set_m_raycastInfo=Q.prototype.bH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Tw(c,a)};Object.defineProperty(Q.prototype,"m_raycastInfo",{get:Q.prototype.hE,set:Q.prototype.bH}); -Q.prototype.get_m_chassisConnectionPointCS=Q.prototype.ZC=function(){return k(Uw(this.kB),n)};Q.prototype.set_m_chassisConnectionPointCS=Q.prototype.SF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Vw(c,a)};Object.defineProperty(Q.prototype,"m_chassisConnectionPointCS",{get:Q.prototype.ZC,set:Q.prototype.SF});Q.prototype.get_m_worldTransform=Q.prototype.OE=function(){return k(Ww(this.kB),t)}; -Q.prototype.set_m_worldTransform=Q.prototype.IH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Xw(c,a)};Object.defineProperty(Q.prototype,"m_worldTransform",{get:Q.prototype.OE,set:Q.prototype.IH});Q.prototype.get_m_wheelDirectionCS=Q.prototype.UB=function(){return k(Yw(this.kB),n)};Q.prototype.set_m_wheelDirectionCS=Q.prototype.dC=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Zw(c,a)};Object.defineProperty(Q.prototype,"m_wheelDirectionCS",{get:Q.prototype.UB,set:Q.prototype.dC}); -Q.prototype.get_m_wheelAxleCS=Q.prototype.TB=function(){return k($w(this.kB),n)};Q.prototype.set_m_wheelAxleCS=Q.prototype.cC=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);ax(c,a)};Object.defineProperty(Q.prototype,"m_wheelAxleCS",{get:Q.prototype.TB,set:Q.prototype.cC});Q.prototype.get_m_rotation=Q.prototype.lE=function(){return bx(this.kB)};Q.prototype.set_m_rotation=Q.prototype.fH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);cx(c,a)}; -Object.defineProperty(Q.prototype,"m_rotation",{get:Q.prototype.lE,set:Q.prototype.fH});Q.prototype.get_m_deltaRotation=Q.prototype.iD=function(){return dx(this.kB)};Q.prototype.set_m_deltaRotation=Q.prototype.bG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);ex(c,a)};Object.defineProperty(Q.prototype,"m_deltaRotation",{get:Q.prototype.iD,set:Q.prototype.bG});Q.prototype.get_m_brake=Q.prototype.SC=function(){return fx(this.kB)}; -Q.prototype.set_m_brake=Q.prototype.LF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);gx(c,a)};Object.defineProperty(Q.prototype,"m_brake",{get:Q.prototype.SC,set:Q.prototype.LF});Q.prototype.get_m_clippedInvContactDotSuspension=Q.prototype.$C=function(){return hx(this.kB)};Q.prototype.set_m_clippedInvContactDotSuspension=Q.prototype.TF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);ix(c,a)}; -Object.defineProperty(Q.prototype,"m_clippedInvContactDotSuspension",{get:Q.prototype.$C,set:Q.prototype.TF});Q.prototype.get_m_suspensionRelativeVelocity=Q.prototype.wE=function(){return jx(this.kB)};Q.prototype.set_m_suspensionRelativeVelocity=Q.prototype.qH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);kx(c,a)};Object.defineProperty(Q.prototype,"m_suspensionRelativeVelocity",{get:Q.prototype.wE,set:Q.prototype.qH});Q.prototype.get_m_skidInfo=Q.prototype.oE=function(){return lx(this.kB)}; -Q.prototype.set_m_skidInfo=Q.prototype.iH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);mx(c,a)};Object.defineProperty(Q.prototype,"m_skidInfo",{get:Q.prototype.oE,set:Q.prototype.iH});Q.prototype.__destroy__=function(){nx(this.kB)};function YF(a,c,d,e){a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);this.kB=void 0===e?ox(a,c,d):px(a,c,d,e);h(YF)[this.kB]=this}YF.prototype=Object.create(OE.prototype); -YF.prototype.constructor=YF;YF.prototype.lB=YF;YF.mB={};b.btKinematicCharacterController=YF;YF.prototype.setUpAxis=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);qx(c,a)};YF.prototype.setWalkDirection=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);rx(c,a)};YF.prototype.setVelocityForTimeInterval=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);sx(d,a,c)}; -YF.prototype.warp=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);tx(c,a)};YF.prototype.preStep=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);ux(c,a)};YF.prototype.playerStep=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);vx(d,a,c)};YF.prototype.setFallSpeed=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);wx(c,a)};YF.prototype.setJumpSpeed=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);xx(c,a)}; -YF.prototype.setMaxJumpHeight=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);yx(c,a)};YF.prototype.canJump=function(){return!!zx(this.kB)};YF.prototype.jump=function(){Ax(this.kB)};YF.prototype.setGravity=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Bx(c,a)};YF.prototype.getGravity=function(){return Cx(this.kB)};YF.prototype.setMaxSlope=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Dx(c,a)};YF.prototype.getMaxSlope=function(){return Ex(this.kB)}; -YF.prototype.getGhostObject=function(){return k(Fx(this.kB),R)};YF.prototype.setUseGhostSweepTest=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Gx(c,a)};YF.prototype.onGround=function(){return!!Hx(this.kB)};YF.prototype.setUpInterpolate=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Ix(c,a)};YF.prototype.updateAction=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);Jx(d,a,c)};YF.prototype.__destroy__=function(){Kx(this.kB)}; -function S(a,c,d){a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);this.kB=Lx(a,c,d);h(S)[this.kB]=this}S.prototype=Object.create(OE.prototype);S.prototype.constructor=S;S.prototype.lB=S;S.mB={};b.btRaycastVehicle=S;S.prototype.applyEngineForce=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);Mx(d,a,c)}; -S.prototype.setSteeringValue=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);Nx(d,a,c)};S.prototype.getWheelTransformWS=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return k(Ox(c,a),t)};S.prototype.updateWheelTransform=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);Px(d,a,c)}; -S.prototype.addWheel=function(a,c,d,e,g,m,y){var W=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);g&&"object"===typeof g&&(g=g.kB);m&&"object"===typeof m&&(m=m.kB);y&&"object"===typeof y&&(y=y.kB);return k(Qx(W,a,c,d,e,g,m,y),Q)};S.prototype.getNumWheels=function(){return Rx(this.kB)};S.prototype.getRigidBody=function(){return k(Sx(this.kB),M)}; -S.prototype.getWheelInfo=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return k(Tx(c,a),Q)};S.prototype.setBrake=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);Ux(d,a,c)};S.prototype.setCoordinateSystem=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);Vx(e,a,c,d)};S.prototype.getCurrentSpeedKmHour=function(){return Wx(this.kB)}; -S.prototype.getChassisWorldTransform=function(){return k(Xx(this.kB),t)};S.prototype.rayCast=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return Yx(c,a)};S.prototype.updateVehicle=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Zx(c,a)};S.prototype.resetSuspension=function(){$x(this.kB)};S.prototype.getSteeringValue=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return ay(c,a)}; -S.prototype.updateWheelTransformsWS=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);void 0===c?by(d,a):cy(d,a,c)};S.prototype.setPitchControl=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);dy(c,a)};S.prototype.updateSuspension=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);ey(c,a)};S.prototype.updateFriction=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);fy(c,a)};S.prototype.getRightAxis=function(){return gy(this.kB)}; -S.prototype.getUpAxis=function(){return hy(this.kB)};S.prototype.getForwardAxis=function(){return iy(this.kB)};S.prototype.getForwardVector=function(){return k(jy(this.kB),n)};S.prototype.getUserConstraintType=function(){return ky(this.kB)};S.prototype.setUserConstraintType=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);ly(c,a)};S.prototype.setUserConstraintId=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);my(c,a)};S.prototype.getUserConstraintId=function(){return ny(this.kB)}; -S.prototype.updateAction=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);oy(d,a,c)};S.prototype.__destroy__=function(){py(this.kB)};function R(){this.kB=qy();h(R)[this.kB]=this}R.prototype=Object.create(z.prototype);R.prototype.constructor=R;R.prototype.lB=R;R.mB={};b.btPairCachingGhostObject=R;R.prototype.setAnisotropicFriction=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);ry(d,a,c)}; -R.prototype.getCollisionShape=function(){return k(sy(this.kB),l)};R.prototype.setContactProcessingThreshold=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);ty(c,a)};R.prototype.setActivationState=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);uy(c,a)};R.prototype.forceActivationState=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);vy(c,a)};R.prototype.activate=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);void 0===a?wy(c):xy(c,a)}; -R.prototype.isActive=function(){return!!yy(this.kB)};R.prototype.isKinematicObject=function(){return!!zy(this.kB)};R.prototype.isStaticObject=function(){return!!Ay(this.kB)};R.prototype.isStaticOrKinematicObject=function(){return!!By(this.kB)};R.prototype.getRestitution=function(){return Cy(this.kB)};R.prototype.getFriction=function(){return Dy(this.kB)};R.prototype.getRollingFriction=function(){return Ey(this.kB)}; -R.prototype.setRestitution=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Fy(c,a)};R.prototype.setFriction=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Gy(c,a)};R.prototype.setRollingFriction=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Hy(c,a)};R.prototype.getWorldTransform=function(){return k(Iy(this.kB),t)};R.prototype.getCollisionFlags=function(){return Jy(this.kB)}; -R.prototype.setCollisionFlags=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Ky(c,a)};R.prototype.setWorldTransform=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Ly(c,a)};R.prototype.setCollisionShape=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);My(c,a)};R.prototype.setCcdMotionThreshold=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Ny(c,a)};R.prototype.setCcdSweptSphereRadius=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Oy(c,a)}; -R.prototype.getUserIndex=function(){return Py(this.kB)};R.prototype.setUserIndex=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Qy(c,a)};R.prototype.getUserPointer=function(){return k(Ry(this.kB),sE)};R.prototype.setUserPointer=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Sy(c,a)};R.prototype.getBroadphaseHandle=function(){return k(Ty(this.kB),tE)};R.prototype.getNumOverlappingObjects=function(){return Uy(this.kB)}; -R.prototype.getOverlappingObject=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return k(Vy(c,a),r)};R.prototype.__destroy__=function(){Wy(this.kB)};function ZF(){this.kB=Xy();h(ZF)[this.kB]=this}ZF.prototype=Object.create(f.prototype);ZF.prototype.constructor=ZF;ZF.prototype.lB=ZF;ZF.mB={};b.btGhostPairCallback=ZF;ZF.prototype.__destroy__=function(){Yy(this.kB)};function T(){this.kB=Zy();h(T)[this.kB]=this}T.prototype=Object.create(f.prototype);T.prototype.constructor=T; -T.prototype.lB=T;T.mB={};b.btSoftBodyWorldInfo=T;T.prototype.get_air_density=T.prototype.jC=function(){return $y(this.kB)};T.prototype.set_air_density=T.prototype.cF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);az(c,a)};Object.defineProperty(T.prototype,"air_density",{get:T.prototype.jC,set:T.prototype.cF});T.prototype.get_water_density=T.prototype.YE=function(){return bz(this.kB)}; -T.prototype.set_water_density=T.prototype.SH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);cz(c,a)};Object.defineProperty(T.prototype,"water_density",{get:T.prototype.YE,set:T.prototype.SH});T.prototype.get_water_offset=T.prototype.$E=function(){return dz(this.kB)};T.prototype.set_water_offset=T.prototype.UH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);ez(c,a)};Object.defineProperty(T.prototype,"water_offset",{get:T.prototype.$E,set:T.prototype.UH}); -T.prototype.get_m_maxDisplacement=T.prototype.UD=function(){return fz(this.kB)};T.prototype.set_m_maxDisplacement=T.prototype.NG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);gz(c,a)};Object.defineProperty(T.prototype,"m_maxDisplacement",{get:T.prototype.UD,set:T.prototype.NG});T.prototype.get_water_normal=T.prototype.ZE=function(){return k(hz(this.kB),n)};T.prototype.set_water_normal=T.prototype.TH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);iz(c,a)}; -Object.defineProperty(T.prototype,"water_normal",{get:T.prototype.ZE,set:T.prototype.TH});T.prototype.get_m_broadphase=T.prototype.TC=function(){return k(jz(this.kB),qE)};T.prototype.set_m_broadphase=T.prototype.MF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);kz(c,a)};Object.defineProperty(T.prototype,"m_broadphase",{get:T.prototype.TC,set:T.prototype.MF});T.prototype.get_m_dispatcher=T.prototype.kD=function(){return k(lz(this.kB),oE)}; -T.prototype.set_m_dispatcher=T.prototype.dG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);mz(c,a)};Object.defineProperty(T.prototype,"m_dispatcher",{get:T.prototype.kD,set:T.prototype.dG});T.prototype.get_m_gravity=T.prototype.tD=function(){return k(nz(this.kB),n)};T.prototype.set_m_gravity=T.prototype.mG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);oz(c,a)};Object.defineProperty(T.prototype,"m_gravity",{get:T.prototype.tD,set:T.prototype.mG});T.prototype.__destroy__=function(){pz(this.kB)}; -function $F(){throw"cannot construct a Face, no constructor in IDL";}$F.prototype=Object.create(f.prototype);$F.prototype.constructor=$F;$F.prototype.lB=$F;$F.mB={};b.Face=$F;$F.prototype.get_m_n=$F.prototype.QB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return k(qz(c,a),Node)};$F.prototype.set_m_n=$F.prototype.$B=function(a,c){var d=this.kB;iE();a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);rz(d,a,c)}; -Object.defineProperty($F.prototype,"m_n",{get:$F.prototype.QB,set:$F.prototype.$B});$F.prototype.get_m_normal=$F.prototype.YD=function(){return k(sz(this.kB),n)};$F.prototype.set_m_normal=$F.prototype.SG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);tz(c,a)};Object.defineProperty($F.prototype,"m_normal",{get:$F.prototype.YD,set:$F.prototype.SG});$F.prototype.get_m_ra=$F.prototype.gE=function(){return uz(this.kB)}; -$F.prototype.set_m_ra=$F.prototype.aH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);vz(c,a)};Object.defineProperty($F.prototype,"m_ra",{get:$F.prototype.gE,set:$F.prototype.aH});$F.prototype.__destroy__=function(){wz(this.kB)};function aG(){throw"cannot construct a tFaceArray, no constructor in IDL";}aG.prototype=Object.create(f.prototype);aG.prototype.constructor=aG;aG.prototype.lB=aG;aG.mB={};b.tFaceArray=aG;aG.prototype.size=aG.prototype.size=function(){return xz(this.kB)}; -aG.prototype.at=aG.prototype.at=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return k(yz(c,a),$F)};aG.prototype.__destroy__=function(){zz(this.kB)};function Node(){throw"cannot construct a Node, no constructor in IDL";}Node.prototype=Object.create(f.prototype);Node.prototype.constructor=Node;Node.prototype.lB=Node;Node.mB={};b.Node=Node;Node.prototype.get_m_x=Node.prototype.PE=function(){return k(Az(this.kB),n)}; -Node.prototype.set_m_x=Node.prototype.JH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Bz(c,a)};Object.defineProperty(Node.prototype,"m_x",{get:Node.prototype.PE,set:Node.prototype.JH});Node.prototype.get_m_q=Node.prototype.fE=function(){return k(Cz(this.kB),n)};Node.prototype.set_m_q=Node.prototype.$G=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Dz(c,a)};Object.defineProperty(Node.prototype,"m_q",{get:Node.prototype.fE,set:Node.prototype.$G}); -Node.prototype.get_m_v=Node.prototype.HE=function(){return k(Ez(this.kB),n)};Node.prototype.set_m_v=Node.prototype.BH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Fz(c,a)};Object.defineProperty(Node.prototype,"m_v",{get:Node.prototype.HE,set:Node.prototype.BH});Node.prototype.get_m_f=Node.prototype.qD=function(){return k(Gz(this.kB),n)};Node.prototype.set_m_f=Node.prototype.jG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Hz(c,a)}; -Object.defineProperty(Node.prototype,"m_f",{get:Node.prototype.qD,set:Node.prototype.jG});Node.prototype.get_m_n=Node.prototype.QB=function(){return k(Iz(this.kB),n)};Node.prototype.set_m_n=Node.prototype.$B=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Jz(c,a)};Object.defineProperty(Node.prototype,"m_n",{get:Node.prototype.QB,set:Node.prototype.$B});Node.prototype.get_m_im=Node.prototype.CD=function(){return Kz(this.kB)}; -Node.prototype.set_m_im=Node.prototype.vG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Lz(c,a)};Object.defineProperty(Node.prototype,"m_im",{get:Node.prototype.CD,set:Node.prototype.vG});Node.prototype.get_m_area=Node.prototype.QC=function(){return Mz(this.kB)};Node.prototype.set_m_area=Node.prototype.JF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Nz(c,a)};Object.defineProperty(Node.prototype,"m_area",{get:Node.prototype.QC,set:Node.prototype.JF}); -Node.prototype.__destroy__=function(){Oz(this.kB)};function bG(){throw"cannot construct a tNodeArray, no constructor in IDL";}bG.prototype=Object.create(f.prototype);bG.prototype.constructor=bG;bG.prototype.lB=bG;bG.mB={};b.tNodeArray=bG;bG.prototype.size=bG.prototype.size=function(){return Pz(this.kB)};bG.prototype.at=bG.prototype.at=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return k(Qz(c,a),Node)};bG.prototype.__destroy__=function(){Rz(this.kB)}; -function U(){throw"cannot construct a Material, no constructor in IDL";}U.prototype=Object.create(f.prototype);U.prototype.constructor=U;U.prototype.lB=U;U.mB={};b.Material=U;U.prototype.get_m_kLST=U.prototype.ID=function(){return Sz(this.kB)};U.prototype.set_m_kLST=U.prototype.BG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Tz(c,a)};Object.defineProperty(U.prototype,"m_kLST",{get:U.prototype.ID,set:U.prototype.BG});U.prototype.get_m_kAST=U.prototype.HD=function(){return Uz(this.kB)}; -U.prototype.set_m_kAST=U.prototype.AG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Vz(c,a)};Object.defineProperty(U.prototype,"m_kAST",{get:U.prototype.HD,set:U.prototype.AG});U.prototype.get_m_kVST=U.prototype.JD=function(){return Wz(this.kB)};U.prototype.set_m_kVST=U.prototype.CG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Xz(c,a)};Object.defineProperty(U.prototype,"m_kVST",{get:U.prototype.JD,set:U.prototype.CG});U.prototype.get_m_flags=U.prototype.vB=function(){return Yz(this.kB)}; -U.prototype.set_m_flags=U.prototype.wB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Zz(c,a)};Object.defineProperty(U.prototype,"m_flags",{get:U.prototype.vB,set:U.prototype.wB});U.prototype.__destroy__=function(){$z(this.kB)};function cG(){throw"cannot construct a tMaterialArray, no constructor in IDL";}cG.prototype=Object.create(f.prototype);cG.prototype.constructor=cG;cG.prototype.lB=cG;cG.mB={};b.tMaterialArray=cG;cG.prototype.size=cG.prototype.size=function(){return aA(this.kB)}; -cG.prototype.at=cG.prototype.at=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return k(bA(c,a),U)};cG.prototype.__destroy__=function(){cA(this.kB)};function V(){throw"cannot construct a Anchor, no constructor in IDL";}V.prototype=Object.create(f.prototype);V.prototype.constructor=V;V.prototype.lB=V;V.mB={};b.Anchor=V;V.prototype.get_m_node=V.prototype.WD=function(){return k(dA(this.kB),Node)}; -V.prototype.set_m_node=V.prototype.PG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);eA(c,a)};Object.defineProperty(V.prototype,"m_node",{get:V.prototype.WD,set:V.prototype.PG});V.prototype.get_m_local=V.prototype.MD=function(){return k(fA(this.kB),n)};V.prototype.set_m_local=V.prototype.FG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);gA(c,a)};Object.defineProperty(V.prototype,"m_local",{get:V.prototype.MD,set:V.prototype.FG}); -V.prototype.get_m_body=V.prototype.RC=function(){return k(hA(this.kB),M)};V.prototype.set_m_body=V.prototype.KF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);iA(c,a)};Object.defineProperty(V.prototype,"m_body",{get:V.prototype.RC,set:V.prototype.KF});V.prototype.get_m_influence=V.prototype.FD=function(){return jA(this.kB)};V.prototype.set_m_influence=V.prototype.yG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);kA(c,a)}; -Object.defineProperty(V.prototype,"m_influence",{get:V.prototype.FD,set:V.prototype.yG});V.prototype.get_m_c0=V.prototype.UC=function(){return k(lA(this.kB),RE)};V.prototype.set_m_c0=V.prototype.NF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);mA(c,a)};Object.defineProperty(V.prototype,"m_c0",{get:V.prototype.UC,set:V.prototype.NF});V.prototype.get_m_c1=V.prototype.VC=function(){return k(nA(this.kB),n)}; -V.prototype.set_m_c1=V.prototype.OF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);oA(c,a)};Object.defineProperty(V.prototype,"m_c1",{get:V.prototype.VC,set:V.prototype.OF});V.prototype.get_m_c2=V.prototype.WC=function(){return pA(this.kB)};V.prototype.set_m_c2=V.prototype.PF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);qA(c,a)};Object.defineProperty(V.prototype,"m_c2",{get:V.prototype.WC,set:V.prototype.PF});V.prototype.__destroy__=function(){rA(this.kB)}; -function dG(){throw"cannot construct a tAnchorArray, no constructor in IDL";}dG.prototype=Object.create(f.prototype);dG.prototype.constructor=dG;dG.prototype.lB=dG;dG.mB={};b.tAnchorArray=dG;dG.prototype.size=dG.prototype.size=function(){return sA(this.kB)};dG.prototype.at=dG.prototype.at=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return k(tA(c,a),V)};dG.prototype.clear=dG.prototype.clear=function(){uA(this.kB)}; -dG.prototype.push_back=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);vA(c,a)};dG.prototype.pop_back=function(){wA(this.kB)};dG.prototype.__destroy__=function(){xA(this.kB)};function X(){throw"cannot construct a Config, no constructor in IDL";}X.prototype=Object.create(f.prototype);X.prototype.constructor=X;X.prototype.lB=X;X.mB={};b.Config=X;X.prototype.get_kVCF=X.prototype.GC=function(){return yA(this.kB)}; -X.prototype.set_kVCF=X.prototype.zF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);zA(c,a)};Object.defineProperty(X.prototype,"kVCF",{get:X.prototype.GC,set:X.prototype.zF});X.prototype.get_kDP=X.prototype.tC=function(){return AA(this.kB)};X.prototype.set_kDP=X.prototype.mF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);BA(c,a)};Object.defineProperty(X.prototype,"kDP",{get:X.prototype.tC,set:X.prototype.mF});X.prototype.get_kDG=X.prototype.sC=function(){return CA(this.kB)}; -X.prototype.set_kDG=X.prototype.lF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);DA(c,a)};Object.defineProperty(X.prototype,"kDG",{get:X.prototype.sC,set:X.prototype.lF});X.prototype.get_kLF=X.prototype.vC=function(){return EA(this.kB)};X.prototype.set_kLF=X.prototype.oF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);FA(c,a)};Object.defineProperty(X.prototype,"kLF",{get:X.prototype.vC,set:X.prototype.oF});X.prototype.get_kPR=X.prototype.xC=function(){return GA(this.kB)}; -X.prototype.set_kPR=X.prototype.qF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);HA(c,a)};Object.defineProperty(X.prototype,"kPR",{get:X.prototype.xC,set:X.prototype.qF});X.prototype.get_kVC=X.prototype.FC=function(){return IA(this.kB)};X.prototype.set_kVC=X.prototype.yF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);JA(c,a)};Object.defineProperty(X.prototype,"kVC",{get:X.prototype.FC,set:X.prototype.yF});X.prototype.get_kDF=X.prototype.rC=function(){return KA(this.kB)}; -X.prototype.set_kDF=X.prototype.kF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);LA(c,a)};Object.defineProperty(X.prototype,"kDF",{get:X.prototype.rC,set:X.prototype.kF});X.prototype.get_kMT=X.prototype.wC=function(){return MA(this.kB)};X.prototype.set_kMT=X.prototype.pF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);NA(c,a)};Object.defineProperty(X.prototype,"kMT",{get:X.prototype.wC,set:X.prototype.pF});X.prototype.get_kCHR=X.prototype.qC=function(){return OA(this.kB)}; -X.prototype.set_kCHR=X.prototype.jF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);PA(c,a)};Object.defineProperty(X.prototype,"kCHR",{get:X.prototype.qC,set:X.prototype.jF});X.prototype.get_kKHR=X.prototype.uC=function(){return QA(this.kB)};X.prototype.set_kKHR=X.prototype.nF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);RA(c,a)};Object.defineProperty(X.prototype,"kKHR",{get:X.prototype.uC,set:X.prototype.nF});X.prototype.get_kSHR=X.prototype.yC=function(){return SA(this.kB)}; -X.prototype.set_kSHR=X.prototype.rF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);TA(c,a)};Object.defineProperty(X.prototype,"kSHR",{get:X.prototype.yC,set:X.prototype.rF});X.prototype.get_kAHR=X.prototype.pC=function(){return UA(this.kB)};X.prototype.set_kAHR=X.prototype.iF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);VA(c,a)};Object.defineProperty(X.prototype,"kAHR",{get:X.prototype.pC,set:X.prototype.iF});X.prototype.get_kSRHR_CL=X.prototype.BC=function(){return WA(this.kB)}; -X.prototype.set_kSRHR_CL=X.prototype.uF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);XA(c,a)};Object.defineProperty(X.prototype,"kSRHR_CL",{get:X.prototype.BC,set:X.prototype.uF});X.prototype.get_kSKHR_CL=X.prototype.zC=function(){return YA(this.kB)};X.prototype.set_kSKHR_CL=X.prototype.sF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);ZA(c,a)};Object.defineProperty(X.prototype,"kSKHR_CL",{get:X.prototype.zC,set:X.prototype.sF});X.prototype.get_kSSHR_CL=X.prototype.DC=function(){return $A(this.kB)}; -X.prototype.set_kSSHR_CL=X.prototype.wF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);aB(c,a)};Object.defineProperty(X.prototype,"kSSHR_CL",{get:X.prototype.DC,set:X.prototype.wF});X.prototype.get_kSR_SPLT_CL=X.prototype.CC=function(){return bB(this.kB)};X.prototype.set_kSR_SPLT_CL=X.prototype.vF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);cB(c,a)};Object.defineProperty(X.prototype,"kSR_SPLT_CL",{get:X.prototype.CC,set:X.prototype.vF}); -X.prototype.get_kSK_SPLT_CL=X.prototype.AC=function(){return dB(this.kB)};X.prototype.set_kSK_SPLT_CL=X.prototype.tF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);eB(c,a)};Object.defineProperty(X.prototype,"kSK_SPLT_CL",{get:X.prototype.AC,set:X.prototype.tF});X.prototype.get_kSS_SPLT_CL=X.prototype.EC=function(){return fB(this.kB)};X.prototype.set_kSS_SPLT_CL=X.prototype.xF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);gB(c,a)}; -Object.defineProperty(X.prototype,"kSS_SPLT_CL",{get:X.prototype.EC,set:X.prototype.xF});X.prototype.get_maxvolume=X.prototype.QE=function(){return hB(this.kB)};X.prototype.set_maxvolume=X.prototype.KH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);iB(c,a)};Object.defineProperty(X.prototype,"maxvolume",{get:X.prototype.QE,set:X.prototype.KH});X.prototype.get_timescale=X.prototype.VE=function(){return jB(this.kB)}; -X.prototype.set_timescale=X.prototype.PH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);kB(c,a)};Object.defineProperty(X.prototype,"timescale",{get:X.prototype.VE,set:X.prototype.PH});X.prototype.get_viterations=X.prototype.XE=function(){return lB(this.kB)};X.prototype.set_viterations=X.prototype.RH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);mB(c,a)};Object.defineProperty(X.prototype,"viterations",{get:X.prototype.XE,set:X.prototype.RH}); -X.prototype.get_piterations=X.prototype.TE=function(){return nB(this.kB)};X.prototype.set_piterations=X.prototype.NH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);oB(c,a)};Object.defineProperty(X.prototype,"piterations",{get:X.prototype.TE,set:X.prototype.NH});X.prototype.get_diterations=X.prototype.mC=function(){return pB(this.kB)};X.prototype.set_diterations=X.prototype.fF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);qB(c,a)}; -Object.defineProperty(X.prototype,"diterations",{get:X.prototype.mC,set:X.prototype.fF});X.prototype.get_citerations=X.prototype.kC=function(){return rB(this.kB)};X.prototype.set_citerations=X.prototype.dF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);sB(c,a)};Object.defineProperty(X.prototype,"citerations",{get:X.prototype.kC,set:X.prototype.dF});X.prototype.get_collisions=X.prototype.lC=function(){return tB(this.kB)}; -X.prototype.set_collisions=X.prototype.eF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);uB(c,a)};Object.defineProperty(X.prototype,"collisions",{get:X.prototype.lC,set:X.prototype.eF});X.prototype.__destroy__=function(){vB(this.kB)};function Y(a,c,d,e){iE();a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);"object"==typeof e&&(e=mE(e));this.kB=wB(a,c,d,e);h(Y)[this.kB]=this}Y.prototype=Object.create(r.prototype); -Y.prototype.constructor=Y;Y.prototype.lB=Y;Y.mB={};b.btSoftBody=Y;Y.prototype.checkLink=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);return!!xB(d,a,c)};Y.prototype.checkFace=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);return!!yB(e,a,c,d)};Y.prototype.appendMaterial=function(){return k(zB(this.kB),U)}; -Y.prototype.appendNode=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);AB(d,a,c)};Y.prototype.appendLink=function(a,c,d,e){var g=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);BB(g,a,c,d,e)}; -Y.prototype.appendFace=function(a,c,d,e){var g=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);CB(g,a,c,d,e)};Y.prototype.appendTetra=function(a,c,d,e,g){var m=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);g&&"object"===typeof g&&(g=g.kB);DB(m,a,c,d,e,g)}; -Y.prototype.appendAnchor=function(a,c,d,e){var g=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);EB(g,a,c,d,e)};Y.prototype.addForce=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);void 0===c?FB(d,a):GB(d,a,c)};Y.prototype.addAeroForceToNode=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);HB(d,a,c)}; -Y.prototype.getTotalMass=function(){return IB(this.kB)};Y.prototype.setTotalMass=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);JB(d,a,c)};Y.prototype.setMass=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);KB(d,a,c)};Y.prototype.transform=Y.prototype.transform=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);LB(c,a)}; -Y.prototype.translate=Y.prototype.translate=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);MB(c,a)};Y.prototype.rotate=Y.prototype.rotate=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);NB(c,a)};Y.prototype.scale=Y.prototype.scale=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);OB(c,a)};Y.prototype.generateClusters=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);return void 0===c?PB(d,a):QB(d,a,c)}; -Y.prototype.generateBendingConstraints=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);return RB(d,a,c)};Y.prototype.upcast=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return k(SB(c,a),Y)};Y.prototype.getRestLengthScale=function(){return TB(this.kB)};Y.prototype.setRestLengthScale=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);UB(c,a)}; -Y.prototype.setAnisotropicFriction=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);VB(d,a,c)};Y.prototype.getCollisionShape=function(){return k(WB(this.kB),l)};Y.prototype.setContactProcessingThreshold=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);XB(c,a)};Y.prototype.setActivationState=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);YB(c,a)}; -Y.prototype.forceActivationState=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);ZB(c,a)};Y.prototype.activate=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);void 0===a?$B(c):aC(c,a)};Y.prototype.isActive=function(){return!!bC(this.kB)};Y.prototype.isKinematicObject=function(){return!!cC(this.kB)};Y.prototype.isStaticObject=function(){return!!dC(this.kB)};Y.prototype.isStaticOrKinematicObject=function(){return!!eC(this.kB)};Y.prototype.getRestitution=function(){return fC(this.kB)}; -Y.prototype.getFriction=function(){return gC(this.kB)};Y.prototype.getRollingFriction=function(){return hC(this.kB)};Y.prototype.setRestitution=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);iC(c,a)};Y.prototype.setFriction=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);jC(c,a)};Y.prototype.setRollingFriction=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);kC(c,a)};Y.prototype.getWorldTransform=function(){return k(lC(this.kB),t)};Y.prototype.getCollisionFlags=function(){return mC(this.kB)}; -Y.prototype.setCollisionFlags=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);nC(c,a)};Y.prototype.setWorldTransform=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);oC(c,a)};Y.prototype.setCollisionShape=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);pC(c,a)};Y.prototype.setCcdMotionThreshold=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);qC(c,a)};Y.prototype.setCcdSweptSphereRadius=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);rC(c,a)}; -Y.prototype.getUserIndex=function(){return sC(this.kB)};Y.prototype.setUserIndex=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);tC(c,a)};Y.prototype.getUserPointer=function(){return k(uC(this.kB),sE)};Y.prototype.setUserPointer=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);vC(c,a)};Y.prototype.getBroadphaseHandle=function(){return k(wC(this.kB),tE)};Y.prototype.get_m_cfg=Y.prototype.XC=function(){return k(xC(this.kB),X)}; -Y.prototype.set_m_cfg=Y.prototype.QF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);yC(c,a)};Object.defineProperty(Y.prototype,"m_cfg",{get:Y.prototype.XC,set:Y.prototype.QF});Y.prototype.get_m_nodes=Y.prototype.XD=function(){return k(zC(this.kB),bG)};Y.prototype.set_m_nodes=Y.prototype.QG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);AC(c,a)};Object.defineProperty(Y.prototype,"m_nodes",{get:Y.prototype.XD,set:Y.prototype.QG}); -Y.prototype.get_m_faces=Y.prototype.OB=function(){return k(BC(this.kB),aG)};Y.prototype.set_m_faces=Y.prototype.YB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);CC(c,a)};Object.defineProperty(Y.prototype,"m_faces",{get:Y.prototype.OB,set:Y.prototype.YB});Y.prototype.get_m_materials=Y.prototype.TD=function(){return k(DC(this.kB),cG)};Y.prototype.set_m_materials=Y.prototype.MG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);EC(c,a)}; -Object.defineProperty(Y.prototype,"m_materials",{get:Y.prototype.TD,set:Y.prototype.MG});Y.prototype.get_m_anchors=Y.prototype.NC=function(){return k(FC(this.kB),dG)};Y.prototype.set_m_anchors=Y.prototype.GF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);GC(c,a)};Object.defineProperty(Y.prototype,"m_anchors",{get:Y.prototype.NC,set:Y.prototype.GF});Y.prototype.__destroy__=function(){HC(this.kB)}; -function eG(a){a&&"object"===typeof a&&(a=a.kB);this.kB=void 0===a?IC():JC(a);h(eG)[this.kB]=this}eG.prototype=Object.create(KE.prototype);eG.prototype.constructor=eG;eG.prototype.lB=eG;eG.mB={};b.btSoftBodyRigidBodyCollisionConfiguration=eG;eG.prototype.__destroy__=function(){KC(this.kB)};function fG(){this.kB=LC();h(fG)[this.kB]=this}fG.prototype=Object.create(PE.prototype);fG.prototype.constructor=fG;fG.prototype.lB=fG;fG.mB={};b.btDefaultSoftBodySolver=fG;fG.prototype.__destroy__=function(){MC(this.kB)}; -function gG(){throw"cannot construct a btSoftBodyArray, no constructor in IDL";}gG.prototype=Object.create(f.prototype);gG.prototype.constructor=gG;gG.prototype.lB=gG;gG.mB={};b.btSoftBodyArray=gG;gG.prototype.size=gG.prototype.size=function(){return NC(this.kB)};gG.prototype.at=gG.prototype.at=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return k(OC(c,a),Y)};gG.prototype.__destroy__=function(){PC(this.kB)}; -function Z(a,c,d,e,g){a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);g&&"object"===typeof g&&(g=g.kB);this.kB=QC(a,c,d,e,g);h(Z)[this.kB]=this}Z.prototype=Object.create(x.prototype);Z.prototype.constructor=Z;Z.prototype.lB=Z;Z.mB={};b.btSoftRigidDynamicsWorld=Z; -Z.prototype.addSoftBody=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);RC(e,a,c,d)};Z.prototype.removeSoftBody=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);SC(c,a)};Z.prototype.removeCollisionObject=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);TC(c,a)};Z.prototype.getWorldInfo=function(){return k(UC(this.kB),T)};Z.prototype.getSoftBodyArray=function(){return k(VC(this.kB),gG)}; -Z.prototype.getDispatcher=function(){return k(WC(this.kB),oE)};Z.prototype.rayTest=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);XC(e,a,c,d)};Z.prototype.getPairCache=function(){return k(YC(this.kB),pE)};Z.prototype.getDispatchInfo=function(){return k(ZC(this.kB),q)}; -Z.prototype.addCollisionObject=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);void 0===c?$C(e,a):void 0===d?aD(e,a,c):bD(e,a,c,d)};Z.prototype.getBroadphase=function(){return k(cD(this.kB),qE)}; -Z.prototype.convexSweepTest=function(a,c,d,e,g){var m=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);g&&"object"===typeof g&&(g=g.kB);dD(m,a,c,d,e,g)};Z.prototype.contactPairTest=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);eD(e,a,c,d)}; -Z.prototype.contactTest=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);fD(d,a,c)};Z.prototype.updateSingleAabb=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);gD(c,a)};Z.prototype.setDebugDrawer=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);hD(c,a)};Z.prototype.getDebugDrawer=function(){return k(iD(this.kB),rE)};Z.prototype.debugDrawWorld=function(){jD(this.kB)}; -Z.prototype.debugDrawObject=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);kD(e,a,c,d)};Z.prototype.setGravity=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);lD(c,a)};Z.prototype.getGravity=function(){return k(mD(this.kB),n)}; -Z.prototype.addRigidBody=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);void 0===c?nD(e,a):void 0===d?_emscripten_bind_btSoftRigidDynamicsWorld_addRigidBody_2(e,a,c):oD(e,a,c,d)};Z.prototype.removeRigidBody=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);pD(c,a)}; -Z.prototype.addConstraint=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);void 0===c?qD(d,a):rD(d,a,c)};Z.prototype.removeConstraint=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);sD(c,a)};Z.prototype.stepSimulation=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);return void 0===c?tD(e,a):void 0===d?uD(e,a,c):vD(e,a,c,d)}; -Z.prototype.setContactAddedCallback=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);wD(c,a)};Z.prototype.setContactProcessedCallback=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);xD(c,a)};Z.prototype.setContactDestroyedCallback=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);yD(c,a)};Z.prototype.addAction=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);zD(c,a)};Z.prototype.removeAction=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);AD(c,a)}; -Z.prototype.getSolverInfo=function(){return k(BD(this.kB),u)};Z.prototype.setInternalTickCallback=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);void 0===c?CD(e,a):void 0===d?DD(e,a,c):ED(e,a,c,d)};Z.prototype.__destroy__=function(){FD(this.kB)};function hG(){this.kB=GD();h(hG)[this.kB]=this}hG.prototype=Object.create(f.prototype);hG.prototype.constructor=hG;hG.prototype.lB=hG;hG.mB={};b.btSoftBodyHelpers=hG; -hG.prototype.CreateRope=function(a,c,d,e,g){var m=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);g&&"object"===typeof g&&(g=g.kB);return k(HD(m,a,c,d,e,g),Y)}; -hG.prototype.CreatePatch=function(a,c,d,e,g,m,y,W,E){var p=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);g&&"object"===typeof g&&(g=g.kB);m&&"object"===typeof m&&(m=m.kB);y&&"object"===typeof y&&(y=y.kB);W&&"object"===typeof W&&(W=W.kB);E&&"object"===typeof E&&(E=E.kB);return k(ID(p,a,c,d,e,g,m,y,W,E),Y)}; -hG.prototype.CreatePatchUV=function(a,c,d,e,g,m,y,W,E,p){var G=this.kB;iE();a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);g&&"object"===typeof g&&(g=g.kB);m&&"object"===typeof m&&(m=m.kB);y&&"object"===typeof y&&(y=y.kB);W&&"object"===typeof W&&(W=W.kB);E&&"object"===typeof E&&(E=E.kB);"object"==typeof p&&(p=mE(p));return k(JD(G,a,c,d,e,g,m,y,W,E,p),Y)}; -hG.prototype.CreateEllipsoid=function(a,c,d,e){var g=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);return k(KD(g,a,c,d,e),Y)}; -hG.prototype.CreateFromTriMesh=function(a,c,d,e,g){var m=this.kB;iE();a&&"object"===typeof a&&(a=a.kB);"object"==typeof c&&(c=mE(c));if("object"==typeof d&&"object"===typeof d){var y=jE(d,Ka);kE(d,Ka,y);d=y}e&&"object"===typeof e&&(e=e.kB);g&&"object"===typeof g&&(g=g.kB);return k(LD(m,a,c,d,e,g),Y)}; -hG.prototype.CreateFromConvexHull=function(a,c,d,e){var g=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);return k(MD(g,a,c,d,e),Y)};hG.prototype.__destroy__=function(){ND(this.kB)}; -(function(){function a(){b.PHY_FLOAT=OD();b.PHY_DOUBLE=PD();b.PHY_INTEGER=QD();b.PHY_SHORT=RD();b.PHY_FIXEDPOINT88=SD();b.PHY_UCHAR=TD();b.CONST_GIMPACT_COMPOUND_SHAPE=UD();b.CONST_GIMPACT_TRIMESH_SHAPE_PART=VD();b.CONST_GIMPACT_TRIMESH_SHAPE=WD();b.BT_CONSTRAINT_ERP=XD();b.BT_CONSTRAINT_STOP_ERP=YD();b.BT_CONSTRAINT_CFM=ZD();b.BT_CONSTRAINT_STOP_CFM=$D()}Sa?a():Qa.unshift(a)})();b.CONTACT_ADDED_CALLBACK_SIGNATURE="iiiiiiii";b.CONTACT_DESTROYED_CALLBACK_SIGNATURE="ii"; -b.CONTACT_PROCESSED_CALLBACK_SIGNATURE="iiii";b.INTERNAL_TICK_CALLBACK_SIGNATURE="vif";this.Ammo=b; - - - return Ammo.ready -} - -); -})(); -if (typeof exports === 'object' && typeof module === 'object') - module.exports = Ammo; -else if (typeof define === 'function' && define['amd']) - define([], function() { return Ammo; }); -else if (typeof exports === 'object') - exports["Ammo"] = Ammo; diff --git a/frontend/apps/artcraft/app/public/jsm/libs/ammo.wasm.js b/frontend/apps/artcraft/app/public/jsm/libs/ammo.wasm.js deleted file mode 100644 index 46ab297aee..0000000000 --- a/frontend/apps/artcraft/app/public/jsm/libs/ammo.wasm.js +++ /dev/null @@ -1,921 +0,0 @@ -// This is ammo.js, a port of Bullet Physics to JavaScript. zlib licensed. - -var Ammo = (() => { - var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined; - if (typeof __filename !== 'undefined') _scriptDir = _scriptDir || __filename; - return ( -function(Ammo = {}) { - -var b;b||(b=typeof Ammo !== 'undefined' ? Ammo : {});var aa,ba;b.ready=new Promise(function(a,c){aa=a;ba=c});var ca=Object.assign({},b),da="object"==typeof window,ea="function"==typeof importScripts,fa="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node,ha="",ia,ja,ka; -if(fa){var fs=require("fs"),la=require("path");ha=ea?la.dirname(ha)+"/":__dirname+"/";ia=(a,c)=>{a=a.startsWith("file://")?new URL(a):la.normalize(a);return fs.readFileSync(a,c?void 0:"utf8")};ka=a=>{a=ia(a,!0);a.buffer||(a=new Uint8Array(a));return a};ja=(a,c,d)=>{a=a.startsWith("file://")?new URL(a):la.normalize(a);fs.readFile(a,function(e,g){e?d(e):c(g.buffer)})};1{var c=new XMLHttpRequest;c.open("GET",a,!1);c.send(null);return c.responseText},ea&&(ka=a=>{var c=new XMLHttpRequest;c.open("GET",a,!1);c.responseType="arraybuffer";c.send(null);return new Uint8Array(c.response)}),ja=(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)};b.print||console.log.bind(console);var ma=b.printErr||console.warn.bind(console);Object.assign(b,ca);ca=null;var na;b.wasmBinary&&(na=b.wasmBinary);var noExitRuntime=b.noExitRuntime||!0;"object"!=typeof WebAssembly&&oa("no native wasm support detected");var pa,qa=!1,ra="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0; -function sa(a,c){if(a){var d=ta,e=a+c;for(c=a;d[c]&&!(c>=e);)++c;if(16g?e+=String.fromCharCode(g):(g-=65536,e+=String.fromCharCode(55296|g>>10,56320|g&1023))}}else e+=String.fromCharCode(g)}a=e}}else a="";return a} -var ua,ta,va,wa,xa,ya,za=[],Aa=[],Ba=[],Ca=!1;function Ea(){var a=b.preRun.shift();za.unshift(a)}var Fa=0,Ga=null,Ha=null;function oa(a){if(b.onAbort)b.onAbort(a);a="Aborted("+a+")";ma(a);qa=!0;a=new WebAssembly.RuntimeError(a+". Build with -sASSERTIONS for more info.");ba(a);throw a;}function Ia(a){return a.startsWith("data:application/octet-stream;base64,")}var Ja;Ja="ammo.wasm.wasm";if(!Ia(Ja)){var Ka=Ja;Ja=b.locateFile?b.locateFile(Ka,ha):ha+Ka} -function La(a){try{if(a==Ja&&na)return new Uint8Array(na);if(ka)return ka(a);throw"both async and sync fetching of the wasm failed";}catch(c){oa(c)}} -function Ma(a){if(!na&&(da||ea)){if("function"==typeof fetch&&!a.startsWith("file://"))return fetch(a,{credentials:"same-origin"}).then(function(c){if(!c.ok)throw"failed to load wasm binary file at '"+a+"'";return c.arrayBuffer()}).catch(function(){return La(a)});if(ja)return new Promise(function(c,d){ja(a,function(e){c(new Uint8Array(e))},d)})}return Promise.resolve().then(function(){return La(a)})} -function Na(a,c,d){return Ma(a).then(function(e){return WebAssembly.instantiate(e,c)}).then(function(e){return e}).then(d,function(e){ma("failed to asynchronously prepare wasm: "+e);oa(e)})} -function Oa(a,c){var d=Ja;return na||"function"!=typeof WebAssembly.instantiateStreaming||Ia(d)||d.startsWith("file://")||fa||"function"!=typeof fetch?Na(d,a,c):fetch(d,{credentials:"same-origin"}).then(function(e){return WebAssembly.instantiateStreaming(e,a).then(c,function(g){ma("wasm streaming compile failed: "+g);ma("falling back to ArrayBuffer instantiation");return Na(d,a,c)})})} -var Pa={27338:(a,c,d,e)=>{a=b.getCache(b.DebugDrawer)[a];if(!a.hasOwnProperty("drawLine"))throw"a JSImplementation must implement all functions, you forgot DebugDrawer::drawLine.";a.drawLine(c,d,e)},27558:(a,c,d,e,g,n)=>{a=b.getCache(b.DebugDrawer)[a];if(!a.hasOwnProperty("drawContactPoint"))throw"a JSImplementation must implement all functions, you forgot DebugDrawer::drawContactPoint.";a.drawContactPoint(c,d,e,g,n)},27808:(a,c)=>{a=b.getCache(b.DebugDrawer)[a];if(!a.hasOwnProperty("reportErrorWarning"))throw"a JSImplementation must implement all functions, you forgot DebugDrawer::reportErrorWarning."; -a.reportErrorWarning(c)},28052:(a,c,d)=>{a=b.getCache(b.DebugDrawer)[a];if(!a.hasOwnProperty("draw3dText"))throw"a JSImplementation must implement all functions, you forgot DebugDrawer::draw3dText.";a.draw3dText(c,d)},28275:(a,c)=>{a=b.getCache(b.DebugDrawer)[a];if(!a.hasOwnProperty("setDebugMode"))throw"a JSImplementation must implement all functions, you forgot DebugDrawer::setDebugMode.";a.setDebugMode(c)},28501:a=>{a=b.getCache(b.DebugDrawer)[a];if(!a.hasOwnProperty("getDebugMode"))throw"a JSImplementation must implement all functions, you forgot DebugDrawer::getDebugMode."; -return a.getDebugMode()},28732:(a,c)=>{a=b.getCache(b.MotionState)[a];if(!a.hasOwnProperty("getWorldTransform"))throw"a JSImplementation must implement all functions, you forgot MotionState::getWorldTransform.";a.getWorldTransform(c)},28973:(a,c)=>{a=b.getCache(b.MotionState)[a];if(!a.hasOwnProperty("setWorldTransform"))throw"a JSImplementation must implement all functions, you forgot MotionState::setWorldTransform.";a.setWorldTransform(c)},29214:(a,c,d,e,g,n,z,T)=>{a=b.getCache(b.ConcreteContactResultCallback)[a]; -if(!a.hasOwnProperty("addSingleResult"))throw"a JSImplementation must implement all functions, you forgot ConcreteContactResultCallback::addSingleResult.";return a.addSingleResult(c,d,e,g,n,z,T)}};function Qa(a){for(;0>=2;e=ta[c++];)d+=105!=e&d,Ra.push(105==e?va[d]:xa[d++>>1]),++d;return Pa[a].apply(null,Ra)} -var Ta=[],Ua=void 0,Va=[],Wa={b:function(){oa("")},f:function(a,c,d){return Sa(a,c,d)},a:function(a,c,d){return Sa(a,c,d)},d:function(){return Date.now()},e:function(a,c,d){ta.copyWithin(a,c,c+d)},c:function(){oa("OOM")}}; -(function(){function a(d){d=d.exports;b.asm=d;pa=b.asm.g;var e=pa.buffer;b.HEAP8=ua=new Int8Array(e);b.HEAP16=new Int16Array(e);b.HEAP32=va=new Int32Array(e);b.HEAPU8=ta=new Uint8Array(e);b.HEAPU16=new Uint16Array(e);b.HEAPU32=new Uint32Array(e);b.HEAPF32=wa=new Float32Array(e);b.HEAPF64=xa=new Float64Array(e);ya=b.asm.iB;Aa.unshift(b.asm.h);Fa--;b.monitorRunDependencies&&b.monitorRunDependencies(Fa);0==Fa&&(null!==Ga&&(clearInterval(Ga),Ga=null),Ha&&(e=Ha,Ha=null,e()));return d}var c={a:Wa};Fa++; -b.monitorRunDependencies&&b.monitorRunDependencies(Fa);if(b.instantiateWasm)try{return b.instantiateWasm(c,a)}catch(d){ma("Module.instantiateWasm callback failed with error: "+d),ba(d)}Oa(c,function(d){a(d.instance)}).catch(ba);return{}})(); -var Xa=b._emscripten_bind_btCollisionShape_setLocalScaling_1=function(){return(Xa=b._emscripten_bind_btCollisionShape_setLocalScaling_1=b.asm.i).apply(null,arguments)},Ya=b._emscripten_bind_btCollisionShape_getLocalScaling_0=function(){return(Ya=b._emscripten_bind_btCollisionShape_getLocalScaling_0=b.asm.j).apply(null,arguments)},Za=b._emscripten_bind_btCollisionShape_calculateLocalInertia_2=function(){return(Za=b._emscripten_bind_btCollisionShape_calculateLocalInertia_2=b.asm.k).apply(null,arguments)}, -$a=b._emscripten_bind_btCollisionShape_setMargin_1=function(){return($a=b._emscripten_bind_btCollisionShape_setMargin_1=b.asm.l).apply(null,arguments)},ab=b._emscripten_bind_btCollisionShape_getMargin_0=function(){return(ab=b._emscripten_bind_btCollisionShape_getMargin_0=b.asm.m).apply(null,arguments)},bb=b._emscripten_bind_btCollisionShape___destroy___0=function(){return(bb=b._emscripten_bind_btCollisionShape___destroy___0=b.asm.n).apply(null,arguments)},cb=b._emscripten_bind_btCollisionWorld_getDispatcher_0= -function(){return(cb=b._emscripten_bind_btCollisionWorld_getDispatcher_0=b.asm.o).apply(null,arguments)},db=b._emscripten_bind_btCollisionWorld_rayTest_3=function(){return(db=b._emscripten_bind_btCollisionWorld_rayTest_3=b.asm.p).apply(null,arguments)},eb=b._emscripten_bind_btCollisionWorld_getPairCache_0=function(){return(eb=b._emscripten_bind_btCollisionWorld_getPairCache_0=b.asm.q).apply(null,arguments)},fb=b._emscripten_bind_btCollisionWorld_getDispatchInfo_0=function(){return(fb=b._emscripten_bind_btCollisionWorld_getDispatchInfo_0= -b.asm.r).apply(null,arguments)},gb=b._emscripten_bind_btCollisionWorld_addCollisionObject_1=function(){return(gb=b._emscripten_bind_btCollisionWorld_addCollisionObject_1=b.asm.s).apply(null,arguments)},hb=b._emscripten_bind_btCollisionWorld_addCollisionObject_2=function(){return(hb=b._emscripten_bind_btCollisionWorld_addCollisionObject_2=b.asm.t).apply(null,arguments)},ib=b._emscripten_bind_btCollisionWorld_addCollisionObject_3=function(){return(ib=b._emscripten_bind_btCollisionWorld_addCollisionObject_3= -b.asm.u).apply(null,arguments)},jb=b._emscripten_bind_btCollisionWorld_removeCollisionObject_1=function(){return(jb=b._emscripten_bind_btCollisionWorld_removeCollisionObject_1=b.asm.v).apply(null,arguments)},kb=b._emscripten_bind_btCollisionWorld_getBroadphase_0=function(){return(kb=b._emscripten_bind_btCollisionWorld_getBroadphase_0=b.asm.w).apply(null,arguments)},lb=b._emscripten_bind_btCollisionWorld_convexSweepTest_5=function(){return(lb=b._emscripten_bind_btCollisionWorld_convexSweepTest_5=b.asm.x).apply(null, -arguments)},mb=b._emscripten_bind_btCollisionWorld_contactPairTest_3=function(){return(mb=b._emscripten_bind_btCollisionWorld_contactPairTest_3=b.asm.y).apply(null,arguments)},nb=b._emscripten_bind_btCollisionWorld_contactTest_2=function(){return(nb=b._emscripten_bind_btCollisionWorld_contactTest_2=b.asm.z).apply(null,arguments)},ob=b._emscripten_bind_btCollisionWorld_updateSingleAabb_1=function(){return(ob=b._emscripten_bind_btCollisionWorld_updateSingleAabb_1=b.asm.A).apply(null,arguments)},pb= -b._emscripten_bind_btCollisionWorld_setDebugDrawer_1=function(){return(pb=b._emscripten_bind_btCollisionWorld_setDebugDrawer_1=b.asm.B).apply(null,arguments)},qb=b._emscripten_bind_btCollisionWorld_getDebugDrawer_0=function(){return(qb=b._emscripten_bind_btCollisionWorld_getDebugDrawer_0=b.asm.C).apply(null,arguments)},rb=b._emscripten_bind_btCollisionWorld_debugDrawWorld_0=function(){return(rb=b._emscripten_bind_btCollisionWorld_debugDrawWorld_0=b.asm.D).apply(null,arguments)},sb=b._emscripten_bind_btCollisionWorld_debugDrawObject_3= -function(){return(sb=b._emscripten_bind_btCollisionWorld_debugDrawObject_3=b.asm.E).apply(null,arguments)},tb=b._emscripten_bind_btCollisionWorld___destroy___0=function(){return(tb=b._emscripten_bind_btCollisionWorld___destroy___0=b.asm.F).apply(null,arguments)},ub=b._emscripten_bind_btCollisionObject_setAnisotropicFriction_2=function(){return(ub=b._emscripten_bind_btCollisionObject_setAnisotropicFriction_2=b.asm.G).apply(null,arguments)},vb=b._emscripten_bind_btCollisionObject_getCollisionShape_0= -function(){return(vb=b._emscripten_bind_btCollisionObject_getCollisionShape_0=b.asm.H).apply(null,arguments)},wb=b._emscripten_bind_btCollisionObject_setContactProcessingThreshold_1=function(){return(wb=b._emscripten_bind_btCollisionObject_setContactProcessingThreshold_1=b.asm.I).apply(null,arguments)},xb=b._emscripten_bind_btCollisionObject_setActivationState_1=function(){return(xb=b._emscripten_bind_btCollisionObject_setActivationState_1=b.asm.J).apply(null,arguments)},yb=b._emscripten_bind_btCollisionObject_forceActivationState_1= -function(){return(yb=b._emscripten_bind_btCollisionObject_forceActivationState_1=b.asm.K).apply(null,arguments)},zb=b._emscripten_bind_btCollisionObject_activate_0=function(){return(zb=b._emscripten_bind_btCollisionObject_activate_0=b.asm.L).apply(null,arguments)},Ab=b._emscripten_bind_btCollisionObject_activate_1=function(){return(Ab=b._emscripten_bind_btCollisionObject_activate_1=b.asm.M).apply(null,arguments)},Bb=b._emscripten_bind_btCollisionObject_isActive_0=function(){return(Bb=b._emscripten_bind_btCollisionObject_isActive_0= -b.asm.N).apply(null,arguments)},Cb=b._emscripten_bind_btCollisionObject_isKinematicObject_0=function(){return(Cb=b._emscripten_bind_btCollisionObject_isKinematicObject_0=b.asm.O).apply(null,arguments)},Db=b._emscripten_bind_btCollisionObject_isStaticObject_0=function(){return(Db=b._emscripten_bind_btCollisionObject_isStaticObject_0=b.asm.P).apply(null,arguments)},Eb=b._emscripten_bind_btCollisionObject_isStaticOrKinematicObject_0=function(){return(Eb=b._emscripten_bind_btCollisionObject_isStaticOrKinematicObject_0= -b.asm.Q).apply(null,arguments)},Fb=b._emscripten_bind_btCollisionObject_getRestitution_0=function(){return(Fb=b._emscripten_bind_btCollisionObject_getRestitution_0=b.asm.R).apply(null,arguments)},Gb=b._emscripten_bind_btCollisionObject_getFriction_0=function(){return(Gb=b._emscripten_bind_btCollisionObject_getFriction_0=b.asm.S).apply(null,arguments)},Hb=b._emscripten_bind_btCollisionObject_getRollingFriction_0=function(){return(Hb=b._emscripten_bind_btCollisionObject_getRollingFriction_0=b.asm.T).apply(null, -arguments)},Ib=b._emscripten_bind_btCollisionObject_setRestitution_1=function(){return(Ib=b._emscripten_bind_btCollisionObject_setRestitution_1=b.asm.U).apply(null,arguments)},Jb=b._emscripten_bind_btCollisionObject_setFriction_1=function(){return(Jb=b._emscripten_bind_btCollisionObject_setFriction_1=b.asm.V).apply(null,arguments)},Kb=b._emscripten_bind_btCollisionObject_setRollingFriction_1=function(){return(Kb=b._emscripten_bind_btCollisionObject_setRollingFriction_1=b.asm.W).apply(null,arguments)}, -Lb=b._emscripten_bind_btCollisionObject_getWorldTransform_0=function(){return(Lb=b._emscripten_bind_btCollisionObject_getWorldTransform_0=b.asm.X).apply(null,arguments)},Mb=b._emscripten_bind_btCollisionObject_getCollisionFlags_0=function(){return(Mb=b._emscripten_bind_btCollisionObject_getCollisionFlags_0=b.asm.Y).apply(null,arguments)},Nb=b._emscripten_bind_btCollisionObject_setCollisionFlags_1=function(){return(Nb=b._emscripten_bind_btCollisionObject_setCollisionFlags_1=b.asm.Z).apply(null,arguments)}, -Ob=b._emscripten_bind_btCollisionObject_setWorldTransform_1=function(){return(Ob=b._emscripten_bind_btCollisionObject_setWorldTransform_1=b.asm._).apply(null,arguments)},Pb=b._emscripten_bind_btCollisionObject_setCollisionShape_1=function(){return(Pb=b._emscripten_bind_btCollisionObject_setCollisionShape_1=b.asm.$).apply(null,arguments)},Qb=b._emscripten_bind_btCollisionObject_setCcdMotionThreshold_1=function(){return(Qb=b._emscripten_bind_btCollisionObject_setCcdMotionThreshold_1=b.asm.aa).apply(null, -arguments)},Rb=b._emscripten_bind_btCollisionObject_setCcdSweptSphereRadius_1=function(){return(Rb=b._emscripten_bind_btCollisionObject_setCcdSweptSphereRadius_1=b.asm.ba).apply(null,arguments)},Sb=b._emscripten_bind_btCollisionObject_getUserIndex_0=function(){return(Sb=b._emscripten_bind_btCollisionObject_getUserIndex_0=b.asm.ca).apply(null,arguments)},Tb=b._emscripten_bind_btCollisionObject_setUserIndex_1=function(){return(Tb=b._emscripten_bind_btCollisionObject_setUserIndex_1=b.asm.da).apply(null, -arguments)},Ub=b._emscripten_bind_btCollisionObject_getUserPointer_0=function(){return(Ub=b._emscripten_bind_btCollisionObject_getUserPointer_0=b.asm.ea).apply(null,arguments)},Vb=b._emscripten_bind_btCollisionObject_setUserPointer_1=function(){return(Vb=b._emscripten_bind_btCollisionObject_setUserPointer_1=b.asm.fa).apply(null,arguments)},Wb=b._emscripten_bind_btCollisionObject_getBroadphaseHandle_0=function(){return(Wb=b._emscripten_bind_btCollisionObject_getBroadphaseHandle_0=b.asm.ga).apply(null, -arguments)},Xb=b._emscripten_bind_btCollisionObject___destroy___0=function(){return(Xb=b._emscripten_bind_btCollisionObject___destroy___0=b.asm.ha).apply(null,arguments)},Yb=b._emscripten_bind_btConcaveShape_setLocalScaling_1=function(){return(Yb=b._emscripten_bind_btConcaveShape_setLocalScaling_1=b.asm.ia).apply(null,arguments)},Zb=b._emscripten_bind_btConcaveShape_getLocalScaling_0=function(){return(Zb=b._emscripten_bind_btConcaveShape_getLocalScaling_0=b.asm.ja).apply(null,arguments)},$b=b._emscripten_bind_btConcaveShape_calculateLocalInertia_2= -function(){return($b=b._emscripten_bind_btConcaveShape_calculateLocalInertia_2=b.asm.ka).apply(null,arguments)},ac=b._emscripten_bind_btConcaveShape___destroy___0=function(){return(ac=b._emscripten_bind_btConcaveShape___destroy___0=b.asm.la).apply(null,arguments)},bc=b._emscripten_bind_btCollisionAlgorithm___destroy___0=function(){return(bc=b._emscripten_bind_btCollisionAlgorithm___destroy___0=b.asm.ma).apply(null,arguments)},cc=b._emscripten_bind_btTypedConstraint_enableFeedback_1=function(){return(cc= -b._emscripten_bind_btTypedConstraint_enableFeedback_1=b.asm.na).apply(null,arguments)},ec=b._emscripten_bind_btTypedConstraint_getBreakingImpulseThreshold_0=function(){return(ec=b._emscripten_bind_btTypedConstraint_getBreakingImpulseThreshold_0=b.asm.oa).apply(null,arguments)},fc=b._emscripten_bind_btTypedConstraint_setBreakingImpulseThreshold_1=function(){return(fc=b._emscripten_bind_btTypedConstraint_setBreakingImpulseThreshold_1=b.asm.pa).apply(null,arguments)},gc=b._emscripten_bind_btTypedConstraint_getParam_2= -function(){return(gc=b._emscripten_bind_btTypedConstraint_getParam_2=b.asm.qa).apply(null,arguments)},hc=b._emscripten_bind_btTypedConstraint_setParam_3=function(){return(hc=b._emscripten_bind_btTypedConstraint_setParam_3=b.asm.ra).apply(null,arguments)},ic=b._emscripten_bind_btTypedConstraint___destroy___0=function(){return(ic=b._emscripten_bind_btTypedConstraint___destroy___0=b.asm.sa).apply(null,arguments)},jc=b._emscripten_bind_btDynamicsWorld_addAction_1=function(){return(jc=b._emscripten_bind_btDynamicsWorld_addAction_1= -b.asm.ta).apply(null,arguments)},kc=b._emscripten_bind_btDynamicsWorld_removeAction_1=function(){return(kc=b._emscripten_bind_btDynamicsWorld_removeAction_1=b.asm.ua).apply(null,arguments)},lc=b._emscripten_bind_btDynamicsWorld_getSolverInfo_0=function(){return(lc=b._emscripten_bind_btDynamicsWorld_getSolverInfo_0=b.asm.va).apply(null,arguments)},mc=b._emscripten_bind_btDynamicsWorld_setInternalTickCallback_1=function(){return(mc=b._emscripten_bind_btDynamicsWorld_setInternalTickCallback_1=b.asm.wa).apply(null, -arguments)},nc=b._emscripten_bind_btDynamicsWorld_setInternalTickCallback_2=function(){return(nc=b._emscripten_bind_btDynamicsWorld_setInternalTickCallback_2=b.asm.xa).apply(null,arguments)},oc=b._emscripten_bind_btDynamicsWorld_setInternalTickCallback_3=function(){return(oc=b._emscripten_bind_btDynamicsWorld_setInternalTickCallback_3=b.asm.ya).apply(null,arguments)},pc=b._emscripten_bind_btDynamicsWorld_getDispatcher_0=function(){return(pc=b._emscripten_bind_btDynamicsWorld_getDispatcher_0=b.asm.za).apply(null, -arguments)},qc=b._emscripten_bind_btDynamicsWorld_rayTest_3=function(){return(qc=b._emscripten_bind_btDynamicsWorld_rayTest_3=b.asm.Aa).apply(null,arguments)},rc=b._emscripten_bind_btDynamicsWorld_getPairCache_0=function(){return(rc=b._emscripten_bind_btDynamicsWorld_getPairCache_0=b.asm.Ba).apply(null,arguments)},sc=b._emscripten_bind_btDynamicsWorld_getDispatchInfo_0=function(){return(sc=b._emscripten_bind_btDynamicsWorld_getDispatchInfo_0=b.asm.Ca).apply(null,arguments)},tc=b._emscripten_bind_btDynamicsWorld_addCollisionObject_1= -function(){return(tc=b._emscripten_bind_btDynamicsWorld_addCollisionObject_1=b.asm.Da).apply(null,arguments)},uc=b._emscripten_bind_btDynamicsWorld_addCollisionObject_2=function(){return(uc=b._emscripten_bind_btDynamicsWorld_addCollisionObject_2=b.asm.Ea).apply(null,arguments)},vc=b._emscripten_bind_btDynamicsWorld_addCollisionObject_3=function(){return(vc=b._emscripten_bind_btDynamicsWorld_addCollisionObject_3=b.asm.Fa).apply(null,arguments)},wc=b._emscripten_bind_btDynamicsWorld_removeCollisionObject_1= -function(){return(wc=b._emscripten_bind_btDynamicsWorld_removeCollisionObject_1=b.asm.Ga).apply(null,arguments)},xc=b._emscripten_bind_btDynamicsWorld_getBroadphase_0=function(){return(xc=b._emscripten_bind_btDynamicsWorld_getBroadphase_0=b.asm.Ha).apply(null,arguments)},yc=b._emscripten_bind_btDynamicsWorld_convexSweepTest_5=function(){return(yc=b._emscripten_bind_btDynamicsWorld_convexSweepTest_5=b.asm.Ia).apply(null,arguments)},zc=b._emscripten_bind_btDynamicsWorld_contactPairTest_3=function(){return(zc= -b._emscripten_bind_btDynamicsWorld_contactPairTest_3=b.asm.Ja).apply(null,arguments)},Ac=b._emscripten_bind_btDynamicsWorld_contactTest_2=function(){return(Ac=b._emscripten_bind_btDynamicsWorld_contactTest_2=b.asm.Ka).apply(null,arguments)},Bc=b._emscripten_bind_btDynamicsWorld_updateSingleAabb_1=function(){return(Bc=b._emscripten_bind_btDynamicsWorld_updateSingleAabb_1=b.asm.La).apply(null,arguments)},Cc=b._emscripten_bind_btDynamicsWorld_setDebugDrawer_1=function(){return(Cc=b._emscripten_bind_btDynamicsWorld_setDebugDrawer_1= -b.asm.Ma).apply(null,arguments)},Dc=b._emscripten_bind_btDynamicsWorld_getDebugDrawer_0=function(){return(Dc=b._emscripten_bind_btDynamicsWorld_getDebugDrawer_0=b.asm.Na).apply(null,arguments)},Ec=b._emscripten_bind_btDynamicsWorld_debugDrawWorld_0=function(){return(Ec=b._emscripten_bind_btDynamicsWorld_debugDrawWorld_0=b.asm.Oa).apply(null,arguments)},Fc=b._emscripten_bind_btDynamicsWorld_debugDrawObject_3=function(){return(Fc=b._emscripten_bind_btDynamicsWorld_debugDrawObject_3=b.asm.Pa).apply(null, -arguments)},Gc=b._emscripten_bind_btDynamicsWorld___destroy___0=function(){return(Gc=b._emscripten_bind_btDynamicsWorld___destroy___0=b.asm.Qa).apply(null,arguments)},Hc=b._emscripten_bind_btIDebugDraw_drawLine_3=function(){return(Hc=b._emscripten_bind_btIDebugDraw_drawLine_3=b.asm.Ra).apply(null,arguments)},Ic=b._emscripten_bind_btIDebugDraw_drawContactPoint_5=function(){return(Ic=b._emscripten_bind_btIDebugDraw_drawContactPoint_5=b.asm.Sa).apply(null,arguments)},Jc=b._emscripten_bind_btIDebugDraw_reportErrorWarning_1= -function(){return(Jc=b._emscripten_bind_btIDebugDraw_reportErrorWarning_1=b.asm.Ta).apply(null,arguments)},Kc=b._emscripten_bind_btIDebugDraw_draw3dText_2=function(){return(Kc=b._emscripten_bind_btIDebugDraw_draw3dText_2=b.asm.Ua).apply(null,arguments)},Lc=b._emscripten_bind_btIDebugDraw_setDebugMode_1=function(){return(Lc=b._emscripten_bind_btIDebugDraw_setDebugMode_1=b.asm.Va).apply(null,arguments)},Mc=b._emscripten_bind_btIDebugDraw_getDebugMode_0=function(){return(Mc=b._emscripten_bind_btIDebugDraw_getDebugMode_0= -b.asm.Wa).apply(null,arguments)},Nc=b._emscripten_bind_btIDebugDraw___destroy___0=function(){return(Nc=b._emscripten_bind_btIDebugDraw___destroy___0=b.asm.Xa).apply(null,arguments)},Oc=b._emscripten_bind_btVector3_btVector3_0=function(){return(Oc=b._emscripten_bind_btVector3_btVector3_0=b.asm.Ya).apply(null,arguments)},Pc=b._emscripten_bind_btVector3_btVector3_3=function(){return(Pc=b._emscripten_bind_btVector3_btVector3_3=b.asm.Za).apply(null,arguments)},Qc=b._emscripten_bind_btVector3_length_0= -function(){return(Qc=b._emscripten_bind_btVector3_length_0=b.asm._a).apply(null,arguments)},Rc=b._emscripten_bind_btVector3_x_0=function(){return(Rc=b._emscripten_bind_btVector3_x_0=b.asm.$a).apply(null,arguments)},Sc=b._emscripten_bind_btVector3_y_0=function(){return(Sc=b._emscripten_bind_btVector3_y_0=b.asm.ab).apply(null,arguments)},Tc=b._emscripten_bind_btVector3_z_0=function(){return(Tc=b._emscripten_bind_btVector3_z_0=b.asm.bb).apply(null,arguments)},Uc=b._emscripten_bind_btVector3_setX_1=function(){return(Uc= -b._emscripten_bind_btVector3_setX_1=b.asm.cb).apply(null,arguments)},Vc=b._emscripten_bind_btVector3_setY_1=function(){return(Vc=b._emscripten_bind_btVector3_setY_1=b.asm.db).apply(null,arguments)},Wc=b._emscripten_bind_btVector3_setZ_1=function(){return(Wc=b._emscripten_bind_btVector3_setZ_1=b.asm.eb).apply(null,arguments)},Xc=b._emscripten_bind_btVector3_setValue_3=function(){return(Xc=b._emscripten_bind_btVector3_setValue_3=b.asm.fb).apply(null,arguments)},Yc=b._emscripten_bind_btVector3_normalize_0= -function(){return(Yc=b._emscripten_bind_btVector3_normalize_0=b.asm.gb).apply(null,arguments)},Zc=b._emscripten_bind_btVector3_rotate_2=function(){return(Zc=b._emscripten_bind_btVector3_rotate_2=b.asm.hb).apply(null,arguments)},$c=b._emscripten_bind_btVector3_dot_1=function(){return($c=b._emscripten_bind_btVector3_dot_1=b.asm.ib).apply(null,arguments)},ad=b._emscripten_bind_btVector3_op_mul_1=function(){return(ad=b._emscripten_bind_btVector3_op_mul_1=b.asm.jb).apply(null,arguments)},bd=b._emscripten_bind_btVector3_op_add_1= -function(){return(bd=b._emscripten_bind_btVector3_op_add_1=b.asm.kb).apply(null,arguments)},cd=b._emscripten_bind_btVector3_op_sub_1=function(){return(cd=b._emscripten_bind_btVector3_op_sub_1=b.asm.lb).apply(null,arguments)},dd=b._emscripten_bind_btVector3___destroy___0=function(){return(dd=b._emscripten_bind_btVector3___destroy___0=b.asm.mb).apply(null,arguments)},ed=b._emscripten_bind_btQuadWord_x_0=function(){return(ed=b._emscripten_bind_btQuadWord_x_0=b.asm.nb).apply(null,arguments)},fd=b._emscripten_bind_btQuadWord_y_0= -function(){return(fd=b._emscripten_bind_btQuadWord_y_0=b.asm.ob).apply(null,arguments)},gd=b._emscripten_bind_btQuadWord_z_0=function(){return(gd=b._emscripten_bind_btQuadWord_z_0=b.asm.pb).apply(null,arguments)},hd=b._emscripten_bind_btQuadWord_w_0=function(){return(hd=b._emscripten_bind_btQuadWord_w_0=b.asm.qb).apply(null,arguments)},jd=b._emscripten_bind_btQuadWord_setX_1=function(){return(jd=b._emscripten_bind_btQuadWord_setX_1=b.asm.rb).apply(null,arguments)},kd=b._emscripten_bind_btQuadWord_setY_1= -function(){return(kd=b._emscripten_bind_btQuadWord_setY_1=b.asm.sb).apply(null,arguments)},ld=b._emscripten_bind_btQuadWord_setZ_1=function(){return(ld=b._emscripten_bind_btQuadWord_setZ_1=b.asm.tb).apply(null,arguments)},md=b._emscripten_bind_btQuadWord_setW_1=function(){return(md=b._emscripten_bind_btQuadWord_setW_1=b.asm.ub).apply(null,arguments)},nd=b._emscripten_bind_btQuadWord___destroy___0=function(){return(nd=b._emscripten_bind_btQuadWord___destroy___0=b.asm.vb).apply(null,arguments)},od= -b._emscripten_bind_btMotionState_getWorldTransform_1=function(){return(od=b._emscripten_bind_btMotionState_getWorldTransform_1=b.asm.wb).apply(null,arguments)},pd=b._emscripten_bind_btMotionState_setWorldTransform_1=function(){return(pd=b._emscripten_bind_btMotionState_setWorldTransform_1=b.asm.xb).apply(null,arguments)},qd=b._emscripten_bind_btMotionState___destroy___0=function(){return(qd=b._emscripten_bind_btMotionState___destroy___0=b.asm.yb).apply(null,arguments)},rd=b._emscripten_bind_RayResultCallback_hasHit_0= -function(){return(rd=b._emscripten_bind_RayResultCallback_hasHit_0=b.asm.zb).apply(null,arguments)},sd=b._emscripten_bind_RayResultCallback_get_m_collisionFilterGroup_0=function(){return(sd=b._emscripten_bind_RayResultCallback_get_m_collisionFilterGroup_0=b.asm.Ab).apply(null,arguments)},td=b._emscripten_bind_RayResultCallback_set_m_collisionFilterGroup_1=function(){return(td=b._emscripten_bind_RayResultCallback_set_m_collisionFilterGroup_1=b.asm.Bb).apply(null,arguments)},ud=b._emscripten_bind_RayResultCallback_get_m_collisionFilterMask_0= -function(){return(ud=b._emscripten_bind_RayResultCallback_get_m_collisionFilterMask_0=b.asm.Cb).apply(null,arguments)},vd=b._emscripten_bind_RayResultCallback_set_m_collisionFilterMask_1=function(){return(vd=b._emscripten_bind_RayResultCallback_set_m_collisionFilterMask_1=b.asm.Db).apply(null,arguments)},wd=b._emscripten_bind_RayResultCallback_get_m_closestHitFraction_0=function(){return(wd=b._emscripten_bind_RayResultCallback_get_m_closestHitFraction_0=b.asm.Eb).apply(null,arguments)},xd=b._emscripten_bind_RayResultCallback_set_m_closestHitFraction_1= -function(){return(xd=b._emscripten_bind_RayResultCallback_set_m_closestHitFraction_1=b.asm.Fb).apply(null,arguments)},yd=b._emscripten_bind_RayResultCallback_get_m_collisionObject_0=function(){return(yd=b._emscripten_bind_RayResultCallback_get_m_collisionObject_0=b.asm.Gb).apply(null,arguments)},zd=b._emscripten_bind_RayResultCallback_set_m_collisionObject_1=function(){return(zd=b._emscripten_bind_RayResultCallback_set_m_collisionObject_1=b.asm.Hb).apply(null,arguments)},Ad=b._emscripten_bind_RayResultCallback_get_m_flags_0= -function(){return(Ad=b._emscripten_bind_RayResultCallback_get_m_flags_0=b.asm.Ib).apply(null,arguments)},Bd=b._emscripten_bind_RayResultCallback_set_m_flags_1=function(){return(Bd=b._emscripten_bind_RayResultCallback_set_m_flags_1=b.asm.Jb).apply(null,arguments)},Cd=b._emscripten_bind_RayResultCallback___destroy___0=function(){return(Cd=b._emscripten_bind_RayResultCallback___destroy___0=b.asm.Kb).apply(null,arguments)},Dd=b._emscripten_bind_ContactResultCallback_addSingleResult_7=function(){return(Dd= -b._emscripten_bind_ContactResultCallback_addSingleResult_7=b.asm.Lb).apply(null,arguments)},Ed=b._emscripten_bind_ContactResultCallback___destroy___0=function(){return(Ed=b._emscripten_bind_ContactResultCallback___destroy___0=b.asm.Mb).apply(null,arguments)},Fd=b._emscripten_bind_ConvexResultCallback_hasHit_0=function(){return(Fd=b._emscripten_bind_ConvexResultCallback_hasHit_0=b.asm.Nb).apply(null,arguments)},Gd=b._emscripten_bind_ConvexResultCallback_get_m_collisionFilterGroup_0=function(){return(Gd= -b._emscripten_bind_ConvexResultCallback_get_m_collisionFilterGroup_0=b.asm.Ob).apply(null,arguments)},Hd=b._emscripten_bind_ConvexResultCallback_set_m_collisionFilterGroup_1=function(){return(Hd=b._emscripten_bind_ConvexResultCallback_set_m_collisionFilterGroup_1=b.asm.Pb).apply(null,arguments)},Id=b._emscripten_bind_ConvexResultCallback_get_m_collisionFilterMask_0=function(){return(Id=b._emscripten_bind_ConvexResultCallback_get_m_collisionFilterMask_0=b.asm.Qb).apply(null,arguments)},Jd=b._emscripten_bind_ConvexResultCallback_set_m_collisionFilterMask_1= -function(){return(Jd=b._emscripten_bind_ConvexResultCallback_set_m_collisionFilterMask_1=b.asm.Rb).apply(null,arguments)},Kd=b._emscripten_bind_ConvexResultCallback_get_m_closestHitFraction_0=function(){return(Kd=b._emscripten_bind_ConvexResultCallback_get_m_closestHitFraction_0=b.asm.Sb).apply(null,arguments)},Ld=b._emscripten_bind_ConvexResultCallback_set_m_closestHitFraction_1=function(){return(Ld=b._emscripten_bind_ConvexResultCallback_set_m_closestHitFraction_1=b.asm.Tb).apply(null,arguments)}, -Md=b._emscripten_bind_ConvexResultCallback___destroy___0=function(){return(Md=b._emscripten_bind_ConvexResultCallback___destroy___0=b.asm.Ub).apply(null,arguments)},Nd=b._emscripten_bind_btConvexShape_setLocalScaling_1=function(){return(Nd=b._emscripten_bind_btConvexShape_setLocalScaling_1=b.asm.Vb).apply(null,arguments)},Od=b._emscripten_bind_btConvexShape_getLocalScaling_0=function(){return(Od=b._emscripten_bind_btConvexShape_getLocalScaling_0=b.asm.Wb).apply(null,arguments)},Pd=b._emscripten_bind_btConvexShape_calculateLocalInertia_2= -function(){return(Pd=b._emscripten_bind_btConvexShape_calculateLocalInertia_2=b.asm.Xb).apply(null,arguments)},Qd=b._emscripten_bind_btConvexShape_setMargin_1=function(){return(Qd=b._emscripten_bind_btConvexShape_setMargin_1=b.asm.Yb).apply(null,arguments)},Rd=b._emscripten_bind_btConvexShape_getMargin_0=function(){return(Rd=b._emscripten_bind_btConvexShape_getMargin_0=b.asm.Zb).apply(null,arguments)},Sd=b._emscripten_bind_btConvexShape___destroy___0=function(){return(Sd=b._emscripten_bind_btConvexShape___destroy___0= -b.asm._b).apply(null,arguments)},Td=b._emscripten_bind_btCapsuleShape_btCapsuleShape_2=function(){return(Td=b._emscripten_bind_btCapsuleShape_btCapsuleShape_2=b.asm.$b).apply(null,arguments)},Ud=b._emscripten_bind_btCapsuleShape_setMargin_1=function(){return(Ud=b._emscripten_bind_btCapsuleShape_setMargin_1=b.asm.ac).apply(null,arguments)},Vd=b._emscripten_bind_btCapsuleShape_getMargin_0=function(){return(Vd=b._emscripten_bind_btCapsuleShape_getMargin_0=b.asm.bc).apply(null,arguments)},Wd=b._emscripten_bind_btCapsuleShape_getUpAxis_0= -function(){return(Wd=b._emscripten_bind_btCapsuleShape_getUpAxis_0=b.asm.cc).apply(null,arguments)},Xd=b._emscripten_bind_btCapsuleShape_getRadius_0=function(){return(Xd=b._emscripten_bind_btCapsuleShape_getRadius_0=b.asm.dc).apply(null,arguments)},Yd=b._emscripten_bind_btCapsuleShape_getHalfHeight_0=function(){return(Yd=b._emscripten_bind_btCapsuleShape_getHalfHeight_0=b.asm.ec).apply(null,arguments)},Zd=b._emscripten_bind_btCapsuleShape_setLocalScaling_1=function(){return(Zd=b._emscripten_bind_btCapsuleShape_setLocalScaling_1= -b.asm.fc).apply(null,arguments)},$d=b._emscripten_bind_btCapsuleShape_getLocalScaling_0=function(){return($d=b._emscripten_bind_btCapsuleShape_getLocalScaling_0=b.asm.gc).apply(null,arguments)},ae=b._emscripten_bind_btCapsuleShape_calculateLocalInertia_2=function(){return(ae=b._emscripten_bind_btCapsuleShape_calculateLocalInertia_2=b.asm.hc).apply(null,arguments)},be=b._emscripten_bind_btCapsuleShape___destroy___0=function(){return(be=b._emscripten_bind_btCapsuleShape___destroy___0=b.asm.ic).apply(null, -arguments)},ce=b._emscripten_bind_btCylinderShape_btCylinderShape_1=function(){return(ce=b._emscripten_bind_btCylinderShape_btCylinderShape_1=b.asm.jc).apply(null,arguments)},de=b._emscripten_bind_btCylinderShape_setMargin_1=function(){return(de=b._emscripten_bind_btCylinderShape_setMargin_1=b.asm.kc).apply(null,arguments)},ee=b._emscripten_bind_btCylinderShape_getMargin_0=function(){return(ee=b._emscripten_bind_btCylinderShape_getMargin_0=b.asm.lc).apply(null,arguments)},fe=b._emscripten_bind_btCylinderShape_setLocalScaling_1= -function(){return(fe=b._emscripten_bind_btCylinderShape_setLocalScaling_1=b.asm.mc).apply(null,arguments)},ge=b._emscripten_bind_btCylinderShape_getLocalScaling_0=function(){return(ge=b._emscripten_bind_btCylinderShape_getLocalScaling_0=b.asm.nc).apply(null,arguments)},he=b._emscripten_bind_btCylinderShape_calculateLocalInertia_2=function(){return(he=b._emscripten_bind_btCylinderShape_calculateLocalInertia_2=b.asm.oc).apply(null,arguments)},ie=b._emscripten_bind_btCylinderShape___destroy___0=function(){return(ie= -b._emscripten_bind_btCylinderShape___destroy___0=b.asm.pc).apply(null,arguments)},je=b._emscripten_bind_btConeShape_btConeShape_2=function(){return(je=b._emscripten_bind_btConeShape_btConeShape_2=b.asm.qc).apply(null,arguments)},ke=b._emscripten_bind_btConeShape_setLocalScaling_1=function(){return(ke=b._emscripten_bind_btConeShape_setLocalScaling_1=b.asm.rc).apply(null,arguments)},le=b._emscripten_bind_btConeShape_getLocalScaling_0=function(){return(le=b._emscripten_bind_btConeShape_getLocalScaling_0= -b.asm.sc).apply(null,arguments)},me=b._emscripten_bind_btConeShape_calculateLocalInertia_2=function(){return(me=b._emscripten_bind_btConeShape_calculateLocalInertia_2=b.asm.tc).apply(null,arguments)},ne=b._emscripten_bind_btConeShape___destroy___0=function(){return(ne=b._emscripten_bind_btConeShape___destroy___0=b.asm.uc).apply(null,arguments)},oe=b._emscripten_bind_btStridingMeshInterface_setScaling_1=function(){return(oe=b._emscripten_bind_btStridingMeshInterface_setScaling_1=b.asm.vc).apply(null, -arguments)},pe=b._emscripten_bind_btStridingMeshInterface___destroy___0=function(){return(pe=b._emscripten_bind_btStridingMeshInterface___destroy___0=b.asm.wc).apply(null,arguments)},qe=b._emscripten_bind_btTriangleMeshShape_setLocalScaling_1=function(){return(qe=b._emscripten_bind_btTriangleMeshShape_setLocalScaling_1=b.asm.xc).apply(null,arguments)},re=b._emscripten_bind_btTriangleMeshShape_getLocalScaling_0=function(){return(re=b._emscripten_bind_btTriangleMeshShape_getLocalScaling_0=b.asm.yc).apply(null, -arguments)},se=b._emscripten_bind_btTriangleMeshShape_calculateLocalInertia_2=function(){return(se=b._emscripten_bind_btTriangleMeshShape_calculateLocalInertia_2=b.asm.zc).apply(null,arguments)},te=b._emscripten_bind_btTriangleMeshShape___destroy___0=function(){return(te=b._emscripten_bind_btTriangleMeshShape___destroy___0=b.asm.Ac).apply(null,arguments)},ue=b._emscripten_bind_btPrimitiveManagerBase_is_trimesh_0=function(){return(ue=b._emscripten_bind_btPrimitiveManagerBase_is_trimesh_0=b.asm.Bc).apply(null, -arguments)},ve=b._emscripten_bind_btPrimitiveManagerBase_get_primitive_count_0=function(){return(ve=b._emscripten_bind_btPrimitiveManagerBase_get_primitive_count_0=b.asm.Cc).apply(null,arguments)},we=b._emscripten_bind_btPrimitiveManagerBase_get_primitive_box_2=function(){return(we=b._emscripten_bind_btPrimitiveManagerBase_get_primitive_box_2=b.asm.Dc).apply(null,arguments)},xe=b._emscripten_bind_btPrimitiveManagerBase_get_primitive_triangle_2=function(){return(xe=b._emscripten_bind_btPrimitiveManagerBase_get_primitive_triangle_2= -b.asm.Ec).apply(null,arguments)},ye=b._emscripten_bind_btPrimitiveManagerBase___destroy___0=function(){return(ye=b._emscripten_bind_btPrimitiveManagerBase___destroy___0=b.asm.Fc).apply(null,arguments)},ze=b._emscripten_bind_btGImpactShapeInterface_updateBound_0=function(){return(ze=b._emscripten_bind_btGImpactShapeInterface_updateBound_0=b.asm.Gc).apply(null,arguments)},Ae=b._emscripten_bind_btGImpactShapeInterface_postUpdate_0=function(){return(Ae=b._emscripten_bind_btGImpactShapeInterface_postUpdate_0= -b.asm.Hc).apply(null,arguments)},Be=b._emscripten_bind_btGImpactShapeInterface_getShapeType_0=function(){return(Be=b._emscripten_bind_btGImpactShapeInterface_getShapeType_0=b.asm.Ic).apply(null,arguments)},Ce=b._emscripten_bind_btGImpactShapeInterface_getName_0=function(){return(Ce=b._emscripten_bind_btGImpactShapeInterface_getName_0=b.asm.Jc).apply(null,arguments)},De=b._emscripten_bind_btGImpactShapeInterface_getGImpactShapeType_0=function(){return(De=b._emscripten_bind_btGImpactShapeInterface_getGImpactShapeType_0= -b.asm.Kc).apply(null,arguments)},Ee=b._emscripten_bind_btGImpactShapeInterface_getPrimitiveManager_0=function(){return(Ee=b._emscripten_bind_btGImpactShapeInterface_getPrimitiveManager_0=b.asm.Lc).apply(null,arguments)},Fe=b._emscripten_bind_btGImpactShapeInterface_getNumChildShapes_0=function(){return(Fe=b._emscripten_bind_btGImpactShapeInterface_getNumChildShapes_0=b.asm.Mc).apply(null,arguments)},Ge=b._emscripten_bind_btGImpactShapeInterface_childrenHasTransform_0=function(){return(Ge=b._emscripten_bind_btGImpactShapeInterface_childrenHasTransform_0= -b.asm.Nc).apply(null,arguments)},He=b._emscripten_bind_btGImpactShapeInterface_needsRetrieveTriangles_0=function(){return(He=b._emscripten_bind_btGImpactShapeInterface_needsRetrieveTriangles_0=b.asm.Oc).apply(null,arguments)},Ie=b._emscripten_bind_btGImpactShapeInterface_needsRetrieveTetrahedrons_0=function(){return(Ie=b._emscripten_bind_btGImpactShapeInterface_needsRetrieveTetrahedrons_0=b.asm.Pc).apply(null,arguments)},Je=b._emscripten_bind_btGImpactShapeInterface_getBulletTriangle_2=function(){return(Je= -b._emscripten_bind_btGImpactShapeInterface_getBulletTriangle_2=b.asm.Qc).apply(null,arguments)},Ke=b._emscripten_bind_btGImpactShapeInterface_getBulletTetrahedron_2=function(){return(Ke=b._emscripten_bind_btGImpactShapeInterface_getBulletTetrahedron_2=b.asm.Rc).apply(null,arguments)},Le=b._emscripten_bind_btGImpactShapeInterface_getChildShape_1=function(){return(Le=b._emscripten_bind_btGImpactShapeInterface_getChildShape_1=b.asm.Sc).apply(null,arguments)},Me=b._emscripten_bind_btGImpactShapeInterface_getChildTransform_1= -function(){return(Me=b._emscripten_bind_btGImpactShapeInterface_getChildTransform_1=b.asm.Tc).apply(null,arguments)},Ne=b._emscripten_bind_btGImpactShapeInterface_setChildTransform_2=function(){return(Ne=b._emscripten_bind_btGImpactShapeInterface_setChildTransform_2=b.asm.Uc).apply(null,arguments)},Oe=b._emscripten_bind_btGImpactShapeInterface_setLocalScaling_1=function(){return(Oe=b._emscripten_bind_btGImpactShapeInterface_setLocalScaling_1=b.asm.Vc).apply(null,arguments)},Pe=b._emscripten_bind_btGImpactShapeInterface_getLocalScaling_0= -function(){return(Pe=b._emscripten_bind_btGImpactShapeInterface_getLocalScaling_0=b.asm.Wc).apply(null,arguments)},Qe=b._emscripten_bind_btGImpactShapeInterface_calculateLocalInertia_2=function(){return(Qe=b._emscripten_bind_btGImpactShapeInterface_calculateLocalInertia_2=b.asm.Xc).apply(null,arguments)},Re=b._emscripten_bind_btGImpactShapeInterface___destroy___0=function(){return(Re=b._emscripten_bind_btGImpactShapeInterface___destroy___0=b.asm.Yc).apply(null,arguments)},Se=b._emscripten_bind_btActivatingCollisionAlgorithm___destroy___0= -function(){return(Se=b._emscripten_bind_btActivatingCollisionAlgorithm___destroy___0=b.asm.Zc).apply(null,arguments)},Te=b._emscripten_bind_btDefaultCollisionConfiguration_btDefaultCollisionConfiguration_0=function(){return(Te=b._emscripten_bind_btDefaultCollisionConfiguration_btDefaultCollisionConfiguration_0=b.asm._c).apply(null,arguments)},Ue=b._emscripten_bind_btDefaultCollisionConfiguration_btDefaultCollisionConfiguration_1=function(){return(Ue=b._emscripten_bind_btDefaultCollisionConfiguration_btDefaultCollisionConfiguration_1= -b.asm.$c).apply(null,arguments)},Ve=b._emscripten_bind_btDefaultCollisionConfiguration___destroy___0=function(){return(Ve=b._emscripten_bind_btDefaultCollisionConfiguration___destroy___0=b.asm.ad).apply(null,arguments)},We=b._emscripten_bind_btDispatcher_getNumManifolds_0=function(){return(We=b._emscripten_bind_btDispatcher_getNumManifolds_0=b.asm.bd).apply(null,arguments)},Xe=b._emscripten_bind_btDispatcher_getManifoldByIndexInternal_1=function(){return(Xe=b._emscripten_bind_btDispatcher_getManifoldByIndexInternal_1= -b.asm.cd).apply(null,arguments)},Ye=b._emscripten_bind_btDispatcher___destroy___0=function(){return(Ye=b._emscripten_bind_btDispatcher___destroy___0=b.asm.dd).apply(null,arguments)},Ze=b._emscripten_bind_btGeneric6DofConstraint_btGeneric6DofConstraint_3=function(){return(Ze=b._emscripten_bind_btGeneric6DofConstraint_btGeneric6DofConstraint_3=b.asm.ed).apply(null,arguments)},$e=b._emscripten_bind_btGeneric6DofConstraint_btGeneric6DofConstraint_5=function(){return($e=b._emscripten_bind_btGeneric6DofConstraint_btGeneric6DofConstraint_5= -b.asm.fd).apply(null,arguments)},af=b._emscripten_bind_btGeneric6DofConstraint_setLinearLowerLimit_1=function(){return(af=b._emscripten_bind_btGeneric6DofConstraint_setLinearLowerLimit_1=b.asm.gd).apply(null,arguments)},bf=b._emscripten_bind_btGeneric6DofConstraint_setLinearUpperLimit_1=function(){return(bf=b._emscripten_bind_btGeneric6DofConstraint_setLinearUpperLimit_1=b.asm.hd).apply(null,arguments)},cf=b._emscripten_bind_btGeneric6DofConstraint_setAngularLowerLimit_1=function(){return(cf=b._emscripten_bind_btGeneric6DofConstraint_setAngularLowerLimit_1= -b.asm.id).apply(null,arguments)},df=b._emscripten_bind_btGeneric6DofConstraint_setAngularUpperLimit_1=function(){return(df=b._emscripten_bind_btGeneric6DofConstraint_setAngularUpperLimit_1=b.asm.jd).apply(null,arguments)},ef=b._emscripten_bind_btGeneric6DofConstraint_getFrameOffsetA_0=function(){return(ef=b._emscripten_bind_btGeneric6DofConstraint_getFrameOffsetA_0=b.asm.kd).apply(null,arguments)},ff=b._emscripten_bind_btGeneric6DofConstraint_enableFeedback_1=function(){return(ff=b._emscripten_bind_btGeneric6DofConstraint_enableFeedback_1= -b.asm.ld).apply(null,arguments)},gf=b._emscripten_bind_btGeneric6DofConstraint_getBreakingImpulseThreshold_0=function(){return(gf=b._emscripten_bind_btGeneric6DofConstraint_getBreakingImpulseThreshold_0=b.asm.md).apply(null,arguments)},hf=b._emscripten_bind_btGeneric6DofConstraint_setBreakingImpulseThreshold_1=function(){return(hf=b._emscripten_bind_btGeneric6DofConstraint_setBreakingImpulseThreshold_1=b.asm.nd).apply(null,arguments)},jf=b._emscripten_bind_btGeneric6DofConstraint_getParam_2=function(){return(jf= -b._emscripten_bind_btGeneric6DofConstraint_getParam_2=b.asm.od).apply(null,arguments)},kf=b._emscripten_bind_btGeneric6DofConstraint_setParam_3=function(){return(kf=b._emscripten_bind_btGeneric6DofConstraint_setParam_3=b.asm.pd).apply(null,arguments)},lf=b._emscripten_bind_btGeneric6DofConstraint___destroy___0=function(){return(lf=b._emscripten_bind_btGeneric6DofConstraint___destroy___0=b.asm.qd).apply(null,arguments)},mf=b._emscripten_bind_btDiscreteDynamicsWorld_btDiscreteDynamicsWorld_4=function(){return(mf= -b._emscripten_bind_btDiscreteDynamicsWorld_btDiscreteDynamicsWorld_4=b.asm.rd).apply(null,arguments)},nf=b._emscripten_bind_btDiscreteDynamicsWorld_setGravity_1=function(){return(nf=b._emscripten_bind_btDiscreteDynamicsWorld_setGravity_1=b.asm.sd).apply(null,arguments)},of=b._emscripten_bind_btDiscreteDynamicsWorld_getGravity_0=function(){return(of=b._emscripten_bind_btDiscreteDynamicsWorld_getGravity_0=b.asm.td).apply(null,arguments)},pf=b._emscripten_bind_btDiscreteDynamicsWorld_addRigidBody_1= -function(){return(pf=b._emscripten_bind_btDiscreteDynamicsWorld_addRigidBody_1=b.asm.ud).apply(null,arguments)},qf=b._emscripten_bind_btDiscreteDynamicsWorld_addRigidBody_3=function(){return(qf=b._emscripten_bind_btDiscreteDynamicsWorld_addRigidBody_3=b.asm.vd).apply(null,arguments)},rf=b._emscripten_bind_btDiscreteDynamicsWorld_removeRigidBody_1=function(){return(rf=b._emscripten_bind_btDiscreteDynamicsWorld_removeRigidBody_1=b.asm.wd).apply(null,arguments)},sf=b._emscripten_bind_btDiscreteDynamicsWorld_addConstraint_1= -function(){return(sf=b._emscripten_bind_btDiscreteDynamicsWorld_addConstraint_1=b.asm.xd).apply(null,arguments)},tf=b._emscripten_bind_btDiscreteDynamicsWorld_addConstraint_2=function(){return(tf=b._emscripten_bind_btDiscreteDynamicsWorld_addConstraint_2=b.asm.yd).apply(null,arguments)},uf=b._emscripten_bind_btDiscreteDynamicsWorld_removeConstraint_1=function(){return(uf=b._emscripten_bind_btDiscreteDynamicsWorld_removeConstraint_1=b.asm.zd).apply(null,arguments)},vf=b._emscripten_bind_btDiscreteDynamicsWorld_stepSimulation_1= -function(){return(vf=b._emscripten_bind_btDiscreteDynamicsWorld_stepSimulation_1=b.asm.Ad).apply(null,arguments)},wf=b._emscripten_bind_btDiscreteDynamicsWorld_stepSimulation_2=function(){return(wf=b._emscripten_bind_btDiscreteDynamicsWorld_stepSimulation_2=b.asm.Bd).apply(null,arguments)},xf=b._emscripten_bind_btDiscreteDynamicsWorld_stepSimulation_3=function(){return(xf=b._emscripten_bind_btDiscreteDynamicsWorld_stepSimulation_3=b.asm.Cd).apply(null,arguments)},yf=b._emscripten_bind_btDiscreteDynamicsWorld_setContactAddedCallback_1= -function(){return(yf=b._emscripten_bind_btDiscreteDynamicsWorld_setContactAddedCallback_1=b.asm.Dd).apply(null,arguments)},zf=b._emscripten_bind_btDiscreteDynamicsWorld_setContactProcessedCallback_1=function(){return(zf=b._emscripten_bind_btDiscreteDynamicsWorld_setContactProcessedCallback_1=b.asm.Ed).apply(null,arguments)},Af=b._emscripten_bind_btDiscreteDynamicsWorld_setContactDestroyedCallback_1=function(){return(Af=b._emscripten_bind_btDiscreteDynamicsWorld_setContactDestroyedCallback_1=b.asm.Fd).apply(null, -arguments)},Bf=b._emscripten_bind_btDiscreteDynamicsWorld_getDispatcher_0=function(){return(Bf=b._emscripten_bind_btDiscreteDynamicsWorld_getDispatcher_0=b.asm.Gd).apply(null,arguments)},Cf=b._emscripten_bind_btDiscreteDynamicsWorld_rayTest_3=function(){return(Cf=b._emscripten_bind_btDiscreteDynamicsWorld_rayTest_3=b.asm.Hd).apply(null,arguments)},Df=b._emscripten_bind_btDiscreteDynamicsWorld_getPairCache_0=function(){return(Df=b._emscripten_bind_btDiscreteDynamicsWorld_getPairCache_0=b.asm.Id).apply(null, -arguments)},Ef=b._emscripten_bind_btDiscreteDynamicsWorld_getDispatchInfo_0=function(){return(Ef=b._emscripten_bind_btDiscreteDynamicsWorld_getDispatchInfo_0=b.asm.Jd).apply(null,arguments)},Ff=b._emscripten_bind_btDiscreteDynamicsWorld_addCollisionObject_1=function(){return(Ff=b._emscripten_bind_btDiscreteDynamicsWorld_addCollisionObject_1=b.asm.Kd).apply(null,arguments)},Gf=b._emscripten_bind_btDiscreteDynamicsWorld_addCollisionObject_2=function(){return(Gf=b._emscripten_bind_btDiscreteDynamicsWorld_addCollisionObject_2= -b.asm.Ld).apply(null,arguments)},Hf=b._emscripten_bind_btDiscreteDynamicsWorld_addCollisionObject_3=function(){return(Hf=b._emscripten_bind_btDiscreteDynamicsWorld_addCollisionObject_3=b.asm.Md).apply(null,arguments)},If=b._emscripten_bind_btDiscreteDynamicsWorld_removeCollisionObject_1=function(){return(If=b._emscripten_bind_btDiscreteDynamicsWorld_removeCollisionObject_1=b.asm.Nd).apply(null,arguments)},Jf=b._emscripten_bind_btDiscreteDynamicsWorld_getBroadphase_0=function(){return(Jf=b._emscripten_bind_btDiscreteDynamicsWorld_getBroadphase_0= -b.asm.Od).apply(null,arguments)},Kf=b._emscripten_bind_btDiscreteDynamicsWorld_convexSweepTest_5=function(){return(Kf=b._emscripten_bind_btDiscreteDynamicsWorld_convexSweepTest_5=b.asm.Pd).apply(null,arguments)},Lf=b._emscripten_bind_btDiscreteDynamicsWorld_contactPairTest_3=function(){return(Lf=b._emscripten_bind_btDiscreteDynamicsWorld_contactPairTest_3=b.asm.Qd).apply(null,arguments)},Mf=b._emscripten_bind_btDiscreteDynamicsWorld_contactTest_2=function(){return(Mf=b._emscripten_bind_btDiscreteDynamicsWorld_contactTest_2= -b.asm.Rd).apply(null,arguments)},Nf=b._emscripten_bind_btDiscreteDynamicsWorld_updateSingleAabb_1=function(){return(Nf=b._emscripten_bind_btDiscreteDynamicsWorld_updateSingleAabb_1=b.asm.Sd).apply(null,arguments)},Of=b._emscripten_bind_btDiscreteDynamicsWorld_setDebugDrawer_1=function(){return(Of=b._emscripten_bind_btDiscreteDynamicsWorld_setDebugDrawer_1=b.asm.Td).apply(null,arguments)},Pf=b._emscripten_bind_btDiscreteDynamicsWorld_getDebugDrawer_0=function(){return(Pf=b._emscripten_bind_btDiscreteDynamicsWorld_getDebugDrawer_0= -b.asm.Ud).apply(null,arguments)},Qf=b._emscripten_bind_btDiscreteDynamicsWorld_debugDrawWorld_0=function(){return(Qf=b._emscripten_bind_btDiscreteDynamicsWorld_debugDrawWorld_0=b.asm.Vd).apply(null,arguments)},Rf=b._emscripten_bind_btDiscreteDynamicsWorld_debugDrawObject_3=function(){return(Rf=b._emscripten_bind_btDiscreteDynamicsWorld_debugDrawObject_3=b.asm.Wd).apply(null,arguments)},Sf=b._emscripten_bind_btDiscreteDynamicsWorld_addAction_1=function(){return(Sf=b._emscripten_bind_btDiscreteDynamicsWorld_addAction_1= -b.asm.Xd).apply(null,arguments)},Tf=b._emscripten_bind_btDiscreteDynamicsWorld_removeAction_1=function(){return(Tf=b._emscripten_bind_btDiscreteDynamicsWorld_removeAction_1=b.asm.Yd).apply(null,arguments)},Uf=b._emscripten_bind_btDiscreteDynamicsWorld_getSolverInfo_0=function(){return(Uf=b._emscripten_bind_btDiscreteDynamicsWorld_getSolverInfo_0=b.asm.Zd).apply(null,arguments)},Vf=b._emscripten_bind_btDiscreteDynamicsWorld_setInternalTickCallback_1=function(){return(Vf=b._emscripten_bind_btDiscreteDynamicsWorld_setInternalTickCallback_1= -b.asm._d).apply(null,arguments)},Wf=b._emscripten_bind_btDiscreteDynamicsWorld_setInternalTickCallback_2=function(){return(Wf=b._emscripten_bind_btDiscreteDynamicsWorld_setInternalTickCallback_2=b.asm.$d).apply(null,arguments)},Xf=b._emscripten_bind_btDiscreteDynamicsWorld_setInternalTickCallback_3=function(){return(Xf=b._emscripten_bind_btDiscreteDynamicsWorld_setInternalTickCallback_3=b.asm.ae).apply(null,arguments)},Yf=b._emscripten_bind_btDiscreteDynamicsWorld___destroy___0=function(){return(Yf= -b._emscripten_bind_btDiscreteDynamicsWorld___destroy___0=b.asm.be).apply(null,arguments)},Zf=b._emscripten_bind_btVehicleRaycaster_castRay_3=function(){return(Zf=b._emscripten_bind_btVehicleRaycaster_castRay_3=b.asm.ce).apply(null,arguments)},$f=b._emscripten_bind_btVehicleRaycaster___destroy___0=function(){return($f=b._emscripten_bind_btVehicleRaycaster___destroy___0=b.asm.de).apply(null,arguments)},ag=b._emscripten_bind_btActionInterface_updateAction_2=function(){return(ag=b._emscripten_bind_btActionInterface_updateAction_2= -b.asm.ee).apply(null,arguments)},bg=b._emscripten_bind_btActionInterface___destroy___0=function(){return(bg=b._emscripten_bind_btActionInterface___destroy___0=b.asm.fe).apply(null,arguments)},cg=b._emscripten_bind_btGhostObject_btGhostObject_0=function(){return(cg=b._emscripten_bind_btGhostObject_btGhostObject_0=b.asm.ge).apply(null,arguments)},dg=b._emscripten_bind_btGhostObject_getNumOverlappingObjects_0=function(){return(dg=b._emscripten_bind_btGhostObject_getNumOverlappingObjects_0=b.asm.he).apply(null, -arguments)},eg=b._emscripten_bind_btGhostObject_getOverlappingObject_1=function(){return(eg=b._emscripten_bind_btGhostObject_getOverlappingObject_1=b.asm.ie).apply(null,arguments)},fg=b._emscripten_bind_btGhostObject_setAnisotropicFriction_2=function(){return(fg=b._emscripten_bind_btGhostObject_setAnisotropicFriction_2=b.asm.je).apply(null,arguments)},gg=b._emscripten_bind_btGhostObject_getCollisionShape_0=function(){return(gg=b._emscripten_bind_btGhostObject_getCollisionShape_0=b.asm.ke).apply(null, -arguments)},hg=b._emscripten_bind_btGhostObject_setContactProcessingThreshold_1=function(){return(hg=b._emscripten_bind_btGhostObject_setContactProcessingThreshold_1=b.asm.le).apply(null,arguments)},ig=b._emscripten_bind_btGhostObject_setActivationState_1=function(){return(ig=b._emscripten_bind_btGhostObject_setActivationState_1=b.asm.me).apply(null,arguments)},jg=b._emscripten_bind_btGhostObject_forceActivationState_1=function(){return(jg=b._emscripten_bind_btGhostObject_forceActivationState_1=b.asm.ne).apply(null, -arguments)},kg=b._emscripten_bind_btGhostObject_activate_0=function(){return(kg=b._emscripten_bind_btGhostObject_activate_0=b.asm.oe).apply(null,arguments)},lg=b._emscripten_bind_btGhostObject_activate_1=function(){return(lg=b._emscripten_bind_btGhostObject_activate_1=b.asm.pe).apply(null,arguments)},mg=b._emscripten_bind_btGhostObject_isActive_0=function(){return(mg=b._emscripten_bind_btGhostObject_isActive_0=b.asm.qe).apply(null,arguments)},ng=b._emscripten_bind_btGhostObject_isKinematicObject_0= -function(){return(ng=b._emscripten_bind_btGhostObject_isKinematicObject_0=b.asm.re).apply(null,arguments)},og=b._emscripten_bind_btGhostObject_isStaticObject_0=function(){return(og=b._emscripten_bind_btGhostObject_isStaticObject_0=b.asm.se).apply(null,arguments)},pg=b._emscripten_bind_btGhostObject_isStaticOrKinematicObject_0=function(){return(pg=b._emscripten_bind_btGhostObject_isStaticOrKinematicObject_0=b.asm.te).apply(null,arguments)},qg=b._emscripten_bind_btGhostObject_getRestitution_0=function(){return(qg= -b._emscripten_bind_btGhostObject_getRestitution_0=b.asm.ue).apply(null,arguments)},rg=b._emscripten_bind_btGhostObject_getFriction_0=function(){return(rg=b._emscripten_bind_btGhostObject_getFriction_0=b.asm.ve).apply(null,arguments)},sg=b._emscripten_bind_btGhostObject_getRollingFriction_0=function(){return(sg=b._emscripten_bind_btGhostObject_getRollingFriction_0=b.asm.we).apply(null,arguments)},tg=b._emscripten_bind_btGhostObject_setRestitution_1=function(){return(tg=b._emscripten_bind_btGhostObject_setRestitution_1= -b.asm.xe).apply(null,arguments)},ug=b._emscripten_bind_btGhostObject_setFriction_1=function(){return(ug=b._emscripten_bind_btGhostObject_setFriction_1=b.asm.ye).apply(null,arguments)},vg=b._emscripten_bind_btGhostObject_setRollingFriction_1=function(){return(vg=b._emscripten_bind_btGhostObject_setRollingFriction_1=b.asm.ze).apply(null,arguments)},wg=b._emscripten_bind_btGhostObject_getWorldTransform_0=function(){return(wg=b._emscripten_bind_btGhostObject_getWorldTransform_0=b.asm.Ae).apply(null,arguments)}, -xg=b._emscripten_bind_btGhostObject_getCollisionFlags_0=function(){return(xg=b._emscripten_bind_btGhostObject_getCollisionFlags_0=b.asm.Be).apply(null,arguments)},yg=b._emscripten_bind_btGhostObject_setCollisionFlags_1=function(){return(yg=b._emscripten_bind_btGhostObject_setCollisionFlags_1=b.asm.Ce).apply(null,arguments)},zg=b._emscripten_bind_btGhostObject_setWorldTransform_1=function(){return(zg=b._emscripten_bind_btGhostObject_setWorldTransform_1=b.asm.De).apply(null,arguments)},Ag=b._emscripten_bind_btGhostObject_setCollisionShape_1= -function(){return(Ag=b._emscripten_bind_btGhostObject_setCollisionShape_1=b.asm.Ee).apply(null,arguments)},Bg=b._emscripten_bind_btGhostObject_setCcdMotionThreshold_1=function(){return(Bg=b._emscripten_bind_btGhostObject_setCcdMotionThreshold_1=b.asm.Fe).apply(null,arguments)},Cg=b._emscripten_bind_btGhostObject_setCcdSweptSphereRadius_1=function(){return(Cg=b._emscripten_bind_btGhostObject_setCcdSweptSphereRadius_1=b.asm.Ge).apply(null,arguments)},Dg=b._emscripten_bind_btGhostObject_getUserIndex_0= -function(){return(Dg=b._emscripten_bind_btGhostObject_getUserIndex_0=b.asm.He).apply(null,arguments)},Eg=b._emscripten_bind_btGhostObject_setUserIndex_1=function(){return(Eg=b._emscripten_bind_btGhostObject_setUserIndex_1=b.asm.Ie).apply(null,arguments)},Fg=b._emscripten_bind_btGhostObject_getUserPointer_0=function(){return(Fg=b._emscripten_bind_btGhostObject_getUserPointer_0=b.asm.Je).apply(null,arguments)},Gg=b._emscripten_bind_btGhostObject_setUserPointer_1=function(){return(Gg=b._emscripten_bind_btGhostObject_setUserPointer_1= -b.asm.Ke).apply(null,arguments)},Hg=b._emscripten_bind_btGhostObject_getBroadphaseHandle_0=function(){return(Hg=b._emscripten_bind_btGhostObject_getBroadphaseHandle_0=b.asm.Le).apply(null,arguments)},Ig=b._emscripten_bind_btGhostObject___destroy___0=function(){return(Ig=b._emscripten_bind_btGhostObject___destroy___0=b.asm.Me).apply(null,arguments)},Jg=b._emscripten_bind_btSoftBodySolver___destroy___0=function(){return(Jg=b._emscripten_bind_btSoftBodySolver___destroy___0=b.asm.Ne).apply(null,arguments)}, -Kg=b._emscripten_bind_VoidPtr___destroy___0=function(){return(Kg=b._emscripten_bind_VoidPtr___destroy___0=b.asm.Oe).apply(null,arguments)},Lg=b._emscripten_bind_DebugDrawer_DebugDrawer_0=function(){return(Lg=b._emscripten_bind_DebugDrawer_DebugDrawer_0=b.asm.Pe).apply(null,arguments)},Mg=b._emscripten_bind_DebugDrawer_drawLine_3=function(){return(Mg=b._emscripten_bind_DebugDrawer_drawLine_3=b.asm.Qe).apply(null,arguments)},Ng=b._emscripten_bind_DebugDrawer_drawContactPoint_5=function(){return(Ng= -b._emscripten_bind_DebugDrawer_drawContactPoint_5=b.asm.Re).apply(null,arguments)},Og=b._emscripten_bind_DebugDrawer_reportErrorWarning_1=function(){return(Og=b._emscripten_bind_DebugDrawer_reportErrorWarning_1=b.asm.Se).apply(null,arguments)},Pg=b._emscripten_bind_DebugDrawer_draw3dText_2=function(){return(Pg=b._emscripten_bind_DebugDrawer_draw3dText_2=b.asm.Te).apply(null,arguments)},Qg=b._emscripten_bind_DebugDrawer_setDebugMode_1=function(){return(Qg=b._emscripten_bind_DebugDrawer_setDebugMode_1= -b.asm.Ue).apply(null,arguments)},Rg=b._emscripten_bind_DebugDrawer_getDebugMode_0=function(){return(Rg=b._emscripten_bind_DebugDrawer_getDebugMode_0=b.asm.Ve).apply(null,arguments)},Sg=b._emscripten_bind_DebugDrawer___destroy___0=function(){return(Sg=b._emscripten_bind_DebugDrawer___destroy___0=b.asm.We).apply(null,arguments)},Tg=b._emscripten_bind_btVector4_btVector4_0=function(){return(Tg=b._emscripten_bind_btVector4_btVector4_0=b.asm.Xe).apply(null,arguments)},Ug=b._emscripten_bind_btVector4_btVector4_4= -function(){return(Ug=b._emscripten_bind_btVector4_btVector4_4=b.asm.Ye).apply(null,arguments)},Vg=b._emscripten_bind_btVector4_w_0=function(){return(Vg=b._emscripten_bind_btVector4_w_0=b.asm.Ze).apply(null,arguments)},Wg=b._emscripten_bind_btVector4_setValue_4=function(){return(Wg=b._emscripten_bind_btVector4_setValue_4=b.asm._e).apply(null,arguments)},Xg=b._emscripten_bind_btVector4_length_0=function(){return(Xg=b._emscripten_bind_btVector4_length_0=b.asm.$e).apply(null,arguments)},Yg=b._emscripten_bind_btVector4_x_0= -function(){return(Yg=b._emscripten_bind_btVector4_x_0=b.asm.af).apply(null,arguments)},Zg=b._emscripten_bind_btVector4_y_0=function(){return(Zg=b._emscripten_bind_btVector4_y_0=b.asm.bf).apply(null,arguments)},$g=b._emscripten_bind_btVector4_z_0=function(){return($g=b._emscripten_bind_btVector4_z_0=b.asm.cf).apply(null,arguments)},ah=b._emscripten_bind_btVector4_setX_1=function(){return(ah=b._emscripten_bind_btVector4_setX_1=b.asm.df).apply(null,arguments)},bh=b._emscripten_bind_btVector4_setY_1= -function(){return(bh=b._emscripten_bind_btVector4_setY_1=b.asm.ef).apply(null,arguments)},ch=b._emscripten_bind_btVector4_setZ_1=function(){return(ch=b._emscripten_bind_btVector4_setZ_1=b.asm.ff).apply(null,arguments)},dh=b._emscripten_bind_btVector4_normalize_0=function(){return(dh=b._emscripten_bind_btVector4_normalize_0=b.asm.gf).apply(null,arguments)},eh=b._emscripten_bind_btVector4_rotate_2=function(){return(eh=b._emscripten_bind_btVector4_rotate_2=b.asm.hf).apply(null,arguments)},fh=b._emscripten_bind_btVector4_dot_1= -function(){return(fh=b._emscripten_bind_btVector4_dot_1=b.asm.jf).apply(null,arguments)},gh=b._emscripten_bind_btVector4_op_mul_1=function(){return(gh=b._emscripten_bind_btVector4_op_mul_1=b.asm.kf).apply(null,arguments)},hh=b._emscripten_bind_btVector4_op_add_1=function(){return(hh=b._emscripten_bind_btVector4_op_add_1=b.asm.lf).apply(null,arguments)},ih=b._emscripten_bind_btVector4_op_sub_1=function(){return(ih=b._emscripten_bind_btVector4_op_sub_1=b.asm.mf).apply(null,arguments)},jh=b._emscripten_bind_btVector4___destroy___0= -function(){return(jh=b._emscripten_bind_btVector4___destroy___0=b.asm.nf).apply(null,arguments)},kh=b._emscripten_bind_btQuaternion_btQuaternion_4=function(){return(kh=b._emscripten_bind_btQuaternion_btQuaternion_4=b.asm.of).apply(null,arguments)},lh=b._emscripten_bind_btQuaternion_setValue_4=function(){return(lh=b._emscripten_bind_btQuaternion_setValue_4=b.asm.pf).apply(null,arguments)},mh=b._emscripten_bind_btQuaternion_setEulerZYX_3=function(){return(mh=b._emscripten_bind_btQuaternion_setEulerZYX_3= -b.asm.qf).apply(null,arguments)},nh=b._emscripten_bind_btQuaternion_setRotation_2=function(){return(nh=b._emscripten_bind_btQuaternion_setRotation_2=b.asm.rf).apply(null,arguments)},oh=b._emscripten_bind_btQuaternion_normalize_0=function(){return(oh=b._emscripten_bind_btQuaternion_normalize_0=b.asm.sf).apply(null,arguments)},ph=b._emscripten_bind_btQuaternion_length2_0=function(){return(ph=b._emscripten_bind_btQuaternion_length2_0=b.asm.tf).apply(null,arguments)},qh=b._emscripten_bind_btQuaternion_length_0= -function(){return(qh=b._emscripten_bind_btQuaternion_length_0=b.asm.uf).apply(null,arguments)},rh=b._emscripten_bind_btQuaternion_dot_1=function(){return(rh=b._emscripten_bind_btQuaternion_dot_1=b.asm.vf).apply(null,arguments)},sh=b._emscripten_bind_btQuaternion_normalized_0=function(){return(sh=b._emscripten_bind_btQuaternion_normalized_0=b.asm.wf).apply(null,arguments)},th=b._emscripten_bind_btQuaternion_getAxis_0=function(){return(th=b._emscripten_bind_btQuaternion_getAxis_0=b.asm.xf).apply(null, -arguments)},uh=b._emscripten_bind_btQuaternion_inverse_0=function(){return(uh=b._emscripten_bind_btQuaternion_inverse_0=b.asm.yf).apply(null,arguments)},vh=b._emscripten_bind_btQuaternion_getAngle_0=function(){return(vh=b._emscripten_bind_btQuaternion_getAngle_0=b.asm.zf).apply(null,arguments)},wh=b._emscripten_bind_btQuaternion_getAngleShortestPath_0=function(){return(wh=b._emscripten_bind_btQuaternion_getAngleShortestPath_0=b.asm.Af).apply(null,arguments)},xh=b._emscripten_bind_btQuaternion_angle_1= -function(){return(xh=b._emscripten_bind_btQuaternion_angle_1=b.asm.Bf).apply(null,arguments)},yh=b._emscripten_bind_btQuaternion_angleShortestPath_1=function(){return(yh=b._emscripten_bind_btQuaternion_angleShortestPath_1=b.asm.Cf).apply(null,arguments)},zh=b._emscripten_bind_btQuaternion_op_add_1=function(){return(zh=b._emscripten_bind_btQuaternion_op_add_1=b.asm.Df).apply(null,arguments)},Ah=b._emscripten_bind_btQuaternion_op_sub_1=function(){return(Ah=b._emscripten_bind_btQuaternion_op_sub_1=b.asm.Ef).apply(null, -arguments)},Bh=b._emscripten_bind_btQuaternion_op_mul_1=function(){return(Bh=b._emscripten_bind_btQuaternion_op_mul_1=b.asm.Ff).apply(null,arguments)},Ch=b._emscripten_bind_btQuaternion_op_mulq_1=function(){return(Ch=b._emscripten_bind_btQuaternion_op_mulq_1=b.asm.Gf).apply(null,arguments)},Dh=b._emscripten_bind_btQuaternion_op_div_1=function(){return(Dh=b._emscripten_bind_btQuaternion_op_div_1=b.asm.Hf).apply(null,arguments)},Eh=b._emscripten_bind_btQuaternion_x_0=function(){return(Eh=b._emscripten_bind_btQuaternion_x_0= -b.asm.If).apply(null,arguments)},Fh=b._emscripten_bind_btQuaternion_y_0=function(){return(Fh=b._emscripten_bind_btQuaternion_y_0=b.asm.Jf).apply(null,arguments)},Gh=b._emscripten_bind_btQuaternion_z_0=function(){return(Gh=b._emscripten_bind_btQuaternion_z_0=b.asm.Kf).apply(null,arguments)},Hh=b._emscripten_bind_btQuaternion_w_0=function(){return(Hh=b._emscripten_bind_btQuaternion_w_0=b.asm.Lf).apply(null,arguments)},Ih=b._emscripten_bind_btQuaternion_setX_1=function(){return(Ih=b._emscripten_bind_btQuaternion_setX_1= -b.asm.Mf).apply(null,arguments)},Jh=b._emscripten_bind_btQuaternion_setY_1=function(){return(Jh=b._emscripten_bind_btQuaternion_setY_1=b.asm.Nf).apply(null,arguments)},Kh=b._emscripten_bind_btQuaternion_setZ_1=function(){return(Kh=b._emscripten_bind_btQuaternion_setZ_1=b.asm.Of).apply(null,arguments)},Lh=b._emscripten_bind_btQuaternion_setW_1=function(){return(Lh=b._emscripten_bind_btQuaternion_setW_1=b.asm.Pf).apply(null,arguments)},Mh=b._emscripten_bind_btQuaternion___destroy___0=function(){return(Mh= -b._emscripten_bind_btQuaternion___destroy___0=b.asm.Qf).apply(null,arguments)},Nh=b._emscripten_bind_btMatrix3x3_setEulerZYX_3=function(){return(Nh=b._emscripten_bind_btMatrix3x3_setEulerZYX_3=b.asm.Rf).apply(null,arguments)},Oh=b._emscripten_bind_btMatrix3x3_getRotation_1=function(){return(Oh=b._emscripten_bind_btMatrix3x3_getRotation_1=b.asm.Sf).apply(null,arguments)},Ph=b._emscripten_bind_btMatrix3x3_getRow_1=function(){return(Ph=b._emscripten_bind_btMatrix3x3_getRow_1=b.asm.Tf).apply(null,arguments)}, -Qh=b._emscripten_bind_btMatrix3x3___destroy___0=function(){return(Qh=b._emscripten_bind_btMatrix3x3___destroy___0=b.asm.Uf).apply(null,arguments)},Rh=b._emscripten_bind_btTransform_btTransform_0=function(){return(Rh=b._emscripten_bind_btTransform_btTransform_0=b.asm.Vf).apply(null,arguments)},Sh=b._emscripten_bind_btTransform_btTransform_2=function(){return(Sh=b._emscripten_bind_btTransform_btTransform_2=b.asm.Wf).apply(null,arguments)},Th=b._emscripten_bind_btTransform_setIdentity_0=function(){return(Th= -b._emscripten_bind_btTransform_setIdentity_0=b.asm.Xf).apply(null,arguments)},Uh=b._emscripten_bind_btTransform_setOrigin_1=function(){return(Uh=b._emscripten_bind_btTransform_setOrigin_1=b.asm.Yf).apply(null,arguments)},Vh=b._emscripten_bind_btTransform_setRotation_1=function(){return(Vh=b._emscripten_bind_btTransform_setRotation_1=b.asm.Zf).apply(null,arguments)},Wh=b._emscripten_bind_btTransform_getOrigin_0=function(){return(Wh=b._emscripten_bind_btTransform_getOrigin_0=b.asm._f).apply(null,arguments)}, -Xh=b._emscripten_bind_btTransform_getRotation_0=function(){return(Xh=b._emscripten_bind_btTransform_getRotation_0=b.asm.$f).apply(null,arguments)},Yh=b._emscripten_bind_btTransform_getBasis_0=function(){return(Yh=b._emscripten_bind_btTransform_getBasis_0=b.asm.ag).apply(null,arguments)},Zh=b._emscripten_bind_btTransform_setFromOpenGLMatrix_1=function(){return(Zh=b._emscripten_bind_btTransform_setFromOpenGLMatrix_1=b.asm.bg).apply(null,arguments)},$h=b._emscripten_bind_btTransform_inverse_0=function(){return($h= -b._emscripten_bind_btTransform_inverse_0=b.asm.cg).apply(null,arguments)},ai=b._emscripten_bind_btTransform_op_mul_1=function(){return(ai=b._emscripten_bind_btTransform_op_mul_1=b.asm.dg).apply(null,arguments)},bi=b._emscripten_bind_btTransform___destroy___0=function(){return(bi=b._emscripten_bind_btTransform___destroy___0=b.asm.eg).apply(null,arguments)},ci=b._emscripten_bind_MotionState_MotionState_0=function(){return(ci=b._emscripten_bind_MotionState_MotionState_0=b.asm.fg).apply(null,arguments)}, -di=b._emscripten_bind_MotionState_getWorldTransform_1=function(){return(di=b._emscripten_bind_MotionState_getWorldTransform_1=b.asm.gg).apply(null,arguments)},ei=b._emscripten_bind_MotionState_setWorldTransform_1=function(){return(ei=b._emscripten_bind_MotionState_setWorldTransform_1=b.asm.hg).apply(null,arguments)},fi=b._emscripten_bind_MotionState___destroy___0=function(){return(fi=b._emscripten_bind_MotionState___destroy___0=b.asm.ig).apply(null,arguments)},gi=b._emscripten_bind_btDefaultMotionState_btDefaultMotionState_0= -function(){return(gi=b._emscripten_bind_btDefaultMotionState_btDefaultMotionState_0=b.asm.jg).apply(null,arguments)},hi=b._emscripten_bind_btDefaultMotionState_btDefaultMotionState_1=function(){return(hi=b._emscripten_bind_btDefaultMotionState_btDefaultMotionState_1=b.asm.kg).apply(null,arguments)},ii=b._emscripten_bind_btDefaultMotionState_btDefaultMotionState_2=function(){return(ii=b._emscripten_bind_btDefaultMotionState_btDefaultMotionState_2=b.asm.lg).apply(null,arguments)},ji=b._emscripten_bind_btDefaultMotionState_getWorldTransform_1= -function(){return(ji=b._emscripten_bind_btDefaultMotionState_getWorldTransform_1=b.asm.mg).apply(null,arguments)},ki=b._emscripten_bind_btDefaultMotionState_setWorldTransform_1=function(){return(ki=b._emscripten_bind_btDefaultMotionState_setWorldTransform_1=b.asm.ng).apply(null,arguments)},li=b._emscripten_bind_btDefaultMotionState_get_m_graphicsWorldTrans_0=function(){return(li=b._emscripten_bind_btDefaultMotionState_get_m_graphicsWorldTrans_0=b.asm.og).apply(null,arguments)},mi=b._emscripten_bind_btDefaultMotionState_set_m_graphicsWorldTrans_1= -function(){return(mi=b._emscripten_bind_btDefaultMotionState_set_m_graphicsWorldTrans_1=b.asm.pg).apply(null,arguments)},ni=b._emscripten_bind_btDefaultMotionState___destroy___0=function(){return(ni=b._emscripten_bind_btDefaultMotionState___destroy___0=b.asm.qg).apply(null,arguments)},oi=b._emscripten_bind_btCollisionObjectWrapper_getWorldTransform_0=function(){return(oi=b._emscripten_bind_btCollisionObjectWrapper_getWorldTransform_0=b.asm.rg).apply(null,arguments)},pi=b._emscripten_bind_btCollisionObjectWrapper_getCollisionObject_0= -function(){return(pi=b._emscripten_bind_btCollisionObjectWrapper_getCollisionObject_0=b.asm.sg).apply(null,arguments)},qi=b._emscripten_bind_btCollisionObjectWrapper_getCollisionShape_0=function(){return(qi=b._emscripten_bind_btCollisionObjectWrapper_getCollisionShape_0=b.asm.tg).apply(null,arguments)},ri=b._emscripten_bind_ClosestRayResultCallback_ClosestRayResultCallback_2=function(){return(ri=b._emscripten_bind_ClosestRayResultCallback_ClosestRayResultCallback_2=b.asm.ug).apply(null,arguments)}, -si=b._emscripten_bind_ClosestRayResultCallback_hasHit_0=function(){return(si=b._emscripten_bind_ClosestRayResultCallback_hasHit_0=b.asm.vg).apply(null,arguments)},ti=b._emscripten_bind_ClosestRayResultCallback_get_m_rayFromWorld_0=function(){return(ti=b._emscripten_bind_ClosestRayResultCallback_get_m_rayFromWorld_0=b.asm.wg).apply(null,arguments)},ui=b._emscripten_bind_ClosestRayResultCallback_set_m_rayFromWorld_1=function(){return(ui=b._emscripten_bind_ClosestRayResultCallback_set_m_rayFromWorld_1= -b.asm.xg).apply(null,arguments)},vi=b._emscripten_bind_ClosestRayResultCallback_get_m_rayToWorld_0=function(){return(vi=b._emscripten_bind_ClosestRayResultCallback_get_m_rayToWorld_0=b.asm.yg).apply(null,arguments)},wi=b._emscripten_bind_ClosestRayResultCallback_set_m_rayToWorld_1=function(){return(wi=b._emscripten_bind_ClosestRayResultCallback_set_m_rayToWorld_1=b.asm.zg).apply(null,arguments)},xi=b._emscripten_bind_ClosestRayResultCallback_get_m_hitNormalWorld_0=function(){return(xi=b._emscripten_bind_ClosestRayResultCallback_get_m_hitNormalWorld_0= -b.asm.Ag).apply(null,arguments)},yi=b._emscripten_bind_ClosestRayResultCallback_set_m_hitNormalWorld_1=function(){return(yi=b._emscripten_bind_ClosestRayResultCallback_set_m_hitNormalWorld_1=b.asm.Bg).apply(null,arguments)},zi=b._emscripten_bind_ClosestRayResultCallback_get_m_hitPointWorld_0=function(){return(zi=b._emscripten_bind_ClosestRayResultCallback_get_m_hitPointWorld_0=b.asm.Cg).apply(null,arguments)},Ai=b._emscripten_bind_ClosestRayResultCallback_set_m_hitPointWorld_1=function(){return(Ai= -b._emscripten_bind_ClosestRayResultCallback_set_m_hitPointWorld_1=b.asm.Dg).apply(null,arguments)},Bi=b._emscripten_bind_ClosestRayResultCallback_get_m_collisionFilterGroup_0=function(){return(Bi=b._emscripten_bind_ClosestRayResultCallback_get_m_collisionFilterGroup_0=b.asm.Eg).apply(null,arguments)},Ci=b._emscripten_bind_ClosestRayResultCallback_set_m_collisionFilterGroup_1=function(){return(Ci=b._emscripten_bind_ClosestRayResultCallback_set_m_collisionFilterGroup_1=b.asm.Fg).apply(null,arguments)}, -Di=b._emscripten_bind_ClosestRayResultCallback_get_m_collisionFilterMask_0=function(){return(Di=b._emscripten_bind_ClosestRayResultCallback_get_m_collisionFilterMask_0=b.asm.Gg).apply(null,arguments)},Ei=b._emscripten_bind_ClosestRayResultCallback_set_m_collisionFilterMask_1=function(){return(Ei=b._emscripten_bind_ClosestRayResultCallback_set_m_collisionFilterMask_1=b.asm.Hg).apply(null,arguments)},Fi=b._emscripten_bind_ClosestRayResultCallback_get_m_closestHitFraction_0=function(){return(Fi=b._emscripten_bind_ClosestRayResultCallback_get_m_closestHitFraction_0= -b.asm.Ig).apply(null,arguments)},Gi=b._emscripten_bind_ClosestRayResultCallback_set_m_closestHitFraction_1=function(){return(Gi=b._emscripten_bind_ClosestRayResultCallback_set_m_closestHitFraction_1=b.asm.Jg).apply(null,arguments)},Hi=b._emscripten_bind_ClosestRayResultCallback_get_m_collisionObject_0=function(){return(Hi=b._emscripten_bind_ClosestRayResultCallback_get_m_collisionObject_0=b.asm.Kg).apply(null,arguments)},Ii=b._emscripten_bind_ClosestRayResultCallback_set_m_collisionObject_1=function(){return(Ii= -b._emscripten_bind_ClosestRayResultCallback_set_m_collisionObject_1=b.asm.Lg).apply(null,arguments)},Ji=b._emscripten_bind_ClosestRayResultCallback_get_m_flags_0=function(){return(Ji=b._emscripten_bind_ClosestRayResultCallback_get_m_flags_0=b.asm.Mg).apply(null,arguments)},Ki=b._emscripten_bind_ClosestRayResultCallback_set_m_flags_1=function(){return(Ki=b._emscripten_bind_ClosestRayResultCallback_set_m_flags_1=b.asm.Ng).apply(null,arguments)},Li=b._emscripten_bind_ClosestRayResultCallback___destroy___0= -function(){return(Li=b._emscripten_bind_ClosestRayResultCallback___destroy___0=b.asm.Og).apply(null,arguments)},Mi=b._emscripten_bind_btConstCollisionObjectArray_size_0=function(){return(Mi=b._emscripten_bind_btConstCollisionObjectArray_size_0=b.asm.Pg).apply(null,arguments)},Ni=b._emscripten_bind_btConstCollisionObjectArray_at_1=function(){return(Ni=b._emscripten_bind_btConstCollisionObjectArray_at_1=b.asm.Qg).apply(null,arguments)},Oi=b._emscripten_bind_btConstCollisionObjectArray___destroy___0= -function(){return(Oi=b._emscripten_bind_btConstCollisionObjectArray___destroy___0=b.asm.Rg).apply(null,arguments)},Pi=b._emscripten_bind_btScalarArray_size_0=function(){return(Pi=b._emscripten_bind_btScalarArray_size_0=b.asm.Sg).apply(null,arguments)},Qi=b._emscripten_bind_btScalarArray_at_1=function(){return(Qi=b._emscripten_bind_btScalarArray_at_1=b.asm.Tg).apply(null,arguments)},Ri=b._emscripten_bind_btScalarArray___destroy___0=function(){return(Ri=b._emscripten_bind_btScalarArray___destroy___0= -b.asm.Ug).apply(null,arguments)},Si=b._emscripten_bind_AllHitsRayResultCallback_AllHitsRayResultCallback_2=function(){return(Si=b._emscripten_bind_AllHitsRayResultCallback_AllHitsRayResultCallback_2=b.asm.Vg).apply(null,arguments)},Ti=b._emscripten_bind_AllHitsRayResultCallback_hasHit_0=function(){return(Ti=b._emscripten_bind_AllHitsRayResultCallback_hasHit_0=b.asm.Wg).apply(null,arguments)},Ui=b._emscripten_bind_AllHitsRayResultCallback_get_m_collisionObjects_0=function(){return(Ui=b._emscripten_bind_AllHitsRayResultCallback_get_m_collisionObjects_0= -b.asm.Xg).apply(null,arguments)},Vi=b._emscripten_bind_AllHitsRayResultCallback_set_m_collisionObjects_1=function(){return(Vi=b._emscripten_bind_AllHitsRayResultCallback_set_m_collisionObjects_1=b.asm.Yg).apply(null,arguments)},Wi=b._emscripten_bind_AllHitsRayResultCallback_get_m_rayFromWorld_0=function(){return(Wi=b._emscripten_bind_AllHitsRayResultCallback_get_m_rayFromWorld_0=b.asm.Zg).apply(null,arguments)},Xi=b._emscripten_bind_AllHitsRayResultCallback_set_m_rayFromWorld_1=function(){return(Xi= -b._emscripten_bind_AllHitsRayResultCallback_set_m_rayFromWorld_1=b.asm._g).apply(null,arguments)},Yi=b._emscripten_bind_AllHitsRayResultCallback_get_m_rayToWorld_0=function(){return(Yi=b._emscripten_bind_AllHitsRayResultCallback_get_m_rayToWorld_0=b.asm.$g).apply(null,arguments)},Zi=b._emscripten_bind_AllHitsRayResultCallback_set_m_rayToWorld_1=function(){return(Zi=b._emscripten_bind_AllHitsRayResultCallback_set_m_rayToWorld_1=b.asm.ah).apply(null,arguments)},$i=b._emscripten_bind_AllHitsRayResultCallback_get_m_hitNormalWorld_0= -function(){return($i=b._emscripten_bind_AllHitsRayResultCallback_get_m_hitNormalWorld_0=b.asm.bh).apply(null,arguments)},aj=b._emscripten_bind_AllHitsRayResultCallback_set_m_hitNormalWorld_1=function(){return(aj=b._emscripten_bind_AllHitsRayResultCallback_set_m_hitNormalWorld_1=b.asm.ch).apply(null,arguments)},bj=b._emscripten_bind_AllHitsRayResultCallback_get_m_hitPointWorld_0=function(){return(bj=b._emscripten_bind_AllHitsRayResultCallback_get_m_hitPointWorld_0=b.asm.dh).apply(null,arguments)}, -cj=b._emscripten_bind_AllHitsRayResultCallback_set_m_hitPointWorld_1=function(){return(cj=b._emscripten_bind_AllHitsRayResultCallback_set_m_hitPointWorld_1=b.asm.eh).apply(null,arguments)},dj=b._emscripten_bind_AllHitsRayResultCallback_get_m_hitFractions_0=function(){return(dj=b._emscripten_bind_AllHitsRayResultCallback_get_m_hitFractions_0=b.asm.fh).apply(null,arguments)},ej=b._emscripten_bind_AllHitsRayResultCallback_set_m_hitFractions_1=function(){return(ej=b._emscripten_bind_AllHitsRayResultCallback_set_m_hitFractions_1= -b.asm.gh).apply(null,arguments)},fj=b._emscripten_bind_AllHitsRayResultCallback_get_m_collisionFilterGroup_0=function(){return(fj=b._emscripten_bind_AllHitsRayResultCallback_get_m_collisionFilterGroup_0=b.asm.hh).apply(null,arguments)},gj=b._emscripten_bind_AllHitsRayResultCallback_set_m_collisionFilterGroup_1=function(){return(gj=b._emscripten_bind_AllHitsRayResultCallback_set_m_collisionFilterGroup_1=b.asm.ih).apply(null,arguments)},hj=b._emscripten_bind_AllHitsRayResultCallback_get_m_collisionFilterMask_0= -function(){return(hj=b._emscripten_bind_AllHitsRayResultCallback_get_m_collisionFilterMask_0=b.asm.jh).apply(null,arguments)},ij=b._emscripten_bind_AllHitsRayResultCallback_set_m_collisionFilterMask_1=function(){return(ij=b._emscripten_bind_AllHitsRayResultCallback_set_m_collisionFilterMask_1=b.asm.kh).apply(null,arguments)},jj=b._emscripten_bind_AllHitsRayResultCallback_get_m_closestHitFraction_0=function(){return(jj=b._emscripten_bind_AllHitsRayResultCallback_get_m_closestHitFraction_0=b.asm.lh).apply(null, -arguments)},kj=b._emscripten_bind_AllHitsRayResultCallback_set_m_closestHitFraction_1=function(){return(kj=b._emscripten_bind_AllHitsRayResultCallback_set_m_closestHitFraction_1=b.asm.mh).apply(null,arguments)},lj=b._emscripten_bind_AllHitsRayResultCallback_get_m_collisionObject_0=function(){return(lj=b._emscripten_bind_AllHitsRayResultCallback_get_m_collisionObject_0=b.asm.nh).apply(null,arguments)},mj=b._emscripten_bind_AllHitsRayResultCallback_set_m_collisionObject_1=function(){return(mj=b._emscripten_bind_AllHitsRayResultCallback_set_m_collisionObject_1= -b.asm.oh).apply(null,arguments)},nj=b._emscripten_bind_AllHitsRayResultCallback_get_m_flags_0=function(){return(nj=b._emscripten_bind_AllHitsRayResultCallback_get_m_flags_0=b.asm.ph).apply(null,arguments)},oj=b._emscripten_bind_AllHitsRayResultCallback_set_m_flags_1=function(){return(oj=b._emscripten_bind_AllHitsRayResultCallback_set_m_flags_1=b.asm.qh).apply(null,arguments)},pj=b._emscripten_bind_AllHitsRayResultCallback___destroy___0=function(){return(pj=b._emscripten_bind_AllHitsRayResultCallback___destroy___0= -b.asm.rh).apply(null,arguments)},qj=b._emscripten_bind_btManifoldPoint_getPositionWorldOnA_0=function(){return(qj=b._emscripten_bind_btManifoldPoint_getPositionWorldOnA_0=b.asm.sh).apply(null,arguments)},rj=b._emscripten_bind_btManifoldPoint_getPositionWorldOnB_0=function(){return(rj=b._emscripten_bind_btManifoldPoint_getPositionWorldOnB_0=b.asm.th).apply(null,arguments)},sj=b._emscripten_bind_btManifoldPoint_getAppliedImpulse_0=function(){return(sj=b._emscripten_bind_btManifoldPoint_getAppliedImpulse_0= -b.asm.uh).apply(null,arguments)},tj=b._emscripten_bind_btManifoldPoint_getDistance_0=function(){return(tj=b._emscripten_bind_btManifoldPoint_getDistance_0=b.asm.vh).apply(null,arguments)},uj=b._emscripten_bind_btManifoldPoint_get_m_localPointA_0=function(){return(uj=b._emscripten_bind_btManifoldPoint_get_m_localPointA_0=b.asm.wh).apply(null,arguments)},vj=b._emscripten_bind_btManifoldPoint_set_m_localPointA_1=function(){return(vj=b._emscripten_bind_btManifoldPoint_set_m_localPointA_1=b.asm.xh).apply(null, -arguments)},wj=b._emscripten_bind_btManifoldPoint_get_m_localPointB_0=function(){return(wj=b._emscripten_bind_btManifoldPoint_get_m_localPointB_0=b.asm.yh).apply(null,arguments)},xj=b._emscripten_bind_btManifoldPoint_set_m_localPointB_1=function(){return(xj=b._emscripten_bind_btManifoldPoint_set_m_localPointB_1=b.asm.zh).apply(null,arguments)},yj=b._emscripten_bind_btManifoldPoint_get_m_positionWorldOnB_0=function(){return(yj=b._emscripten_bind_btManifoldPoint_get_m_positionWorldOnB_0=b.asm.Ah).apply(null, -arguments)},zj=b._emscripten_bind_btManifoldPoint_set_m_positionWorldOnB_1=function(){return(zj=b._emscripten_bind_btManifoldPoint_set_m_positionWorldOnB_1=b.asm.Bh).apply(null,arguments)},Aj=b._emscripten_bind_btManifoldPoint_get_m_positionWorldOnA_0=function(){return(Aj=b._emscripten_bind_btManifoldPoint_get_m_positionWorldOnA_0=b.asm.Ch).apply(null,arguments)},Bj=b._emscripten_bind_btManifoldPoint_set_m_positionWorldOnA_1=function(){return(Bj=b._emscripten_bind_btManifoldPoint_set_m_positionWorldOnA_1= -b.asm.Dh).apply(null,arguments)},Cj=b._emscripten_bind_btManifoldPoint_get_m_normalWorldOnB_0=function(){return(Cj=b._emscripten_bind_btManifoldPoint_get_m_normalWorldOnB_0=b.asm.Eh).apply(null,arguments)},Dj=b._emscripten_bind_btManifoldPoint_set_m_normalWorldOnB_1=function(){return(Dj=b._emscripten_bind_btManifoldPoint_set_m_normalWorldOnB_1=b.asm.Fh).apply(null,arguments)},Ej=b._emscripten_bind_btManifoldPoint_get_m_userPersistentData_0=function(){return(Ej=b._emscripten_bind_btManifoldPoint_get_m_userPersistentData_0= -b.asm.Gh).apply(null,arguments)},Fj=b._emscripten_bind_btManifoldPoint_set_m_userPersistentData_1=function(){return(Fj=b._emscripten_bind_btManifoldPoint_set_m_userPersistentData_1=b.asm.Hh).apply(null,arguments)},Gj=b._emscripten_bind_btManifoldPoint___destroy___0=function(){return(Gj=b._emscripten_bind_btManifoldPoint___destroy___0=b.asm.Ih).apply(null,arguments)},Hj=b._emscripten_bind_ConcreteContactResultCallback_ConcreteContactResultCallback_0=function(){return(Hj=b._emscripten_bind_ConcreteContactResultCallback_ConcreteContactResultCallback_0= -b.asm.Jh).apply(null,arguments)},Ij=b._emscripten_bind_ConcreteContactResultCallback_addSingleResult_7=function(){return(Ij=b._emscripten_bind_ConcreteContactResultCallback_addSingleResult_7=b.asm.Kh).apply(null,arguments)},Jj=b._emscripten_bind_ConcreteContactResultCallback___destroy___0=function(){return(Jj=b._emscripten_bind_ConcreteContactResultCallback___destroy___0=b.asm.Lh).apply(null,arguments)},Kj=b._emscripten_bind_LocalShapeInfo_get_m_shapePart_0=function(){return(Kj=b._emscripten_bind_LocalShapeInfo_get_m_shapePart_0= -b.asm.Mh).apply(null,arguments)},Lj=b._emscripten_bind_LocalShapeInfo_set_m_shapePart_1=function(){return(Lj=b._emscripten_bind_LocalShapeInfo_set_m_shapePart_1=b.asm.Nh).apply(null,arguments)},Mj=b._emscripten_bind_LocalShapeInfo_get_m_triangleIndex_0=function(){return(Mj=b._emscripten_bind_LocalShapeInfo_get_m_triangleIndex_0=b.asm.Oh).apply(null,arguments)},Nj=b._emscripten_bind_LocalShapeInfo_set_m_triangleIndex_1=function(){return(Nj=b._emscripten_bind_LocalShapeInfo_set_m_triangleIndex_1=b.asm.Ph).apply(null, -arguments)},Oj=b._emscripten_bind_LocalShapeInfo___destroy___0=function(){return(Oj=b._emscripten_bind_LocalShapeInfo___destroy___0=b.asm.Qh).apply(null,arguments)},Pj=b._emscripten_bind_LocalConvexResult_LocalConvexResult_5=function(){return(Pj=b._emscripten_bind_LocalConvexResult_LocalConvexResult_5=b.asm.Rh).apply(null,arguments)},Qj=b._emscripten_bind_LocalConvexResult_get_m_hitCollisionObject_0=function(){return(Qj=b._emscripten_bind_LocalConvexResult_get_m_hitCollisionObject_0=b.asm.Sh).apply(null, -arguments)},Rj=b._emscripten_bind_LocalConvexResult_set_m_hitCollisionObject_1=function(){return(Rj=b._emscripten_bind_LocalConvexResult_set_m_hitCollisionObject_1=b.asm.Th).apply(null,arguments)},Sj=b._emscripten_bind_LocalConvexResult_get_m_localShapeInfo_0=function(){return(Sj=b._emscripten_bind_LocalConvexResult_get_m_localShapeInfo_0=b.asm.Uh).apply(null,arguments)},Tj=b._emscripten_bind_LocalConvexResult_set_m_localShapeInfo_1=function(){return(Tj=b._emscripten_bind_LocalConvexResult_set_m_localShapeInfo_1= -b.asm.Vh).apply(null,arguments)},Uj=b._emscripten_bind_LocalConvexResult_get_m_hitNormalLocal_0=function(){return(Uj=b._emscripten_bind_LocalConvexResult_get_m_hitNormalLocal_0=b.asm.Wh).apply(null,arguments)},Vj=b._emscripten_bind_LocalConvexResult_set_m_hitNormalLocal_1=function(){return(Vj=b._emscripten_bind_LocalConvexResult_set_m_hitNormalLocal_1=b.asm.Xh).apply(null,arguments)},Wj=b._emscripten_bind_LocalConvexResult_get_m_hitPointLocal_0=function(){return(Wj=b._emscripten_bind_LocalConvexResult_get_m_hitPointLocal_0= -b.asm.Yh).apply(null,arguments)},Xj=b._emscripten_bind_LocalConvexResult_set_m_hitPointLocal_1=function(){return(Xj=b._emscripten_bind_LocalConvexResult_set_m_hitPointLocal_1=b.asm.Zh).apply(null,arguments)},Yj=b._emscripten_bind_LocalConvexResult_get_m_hitFraction_0=function(){return(Yj=b._emscripten_bind_LocalConvexResult_get_m_hitFraction_0=b.asm._h).apply(null,arguments)},Zj=b._emscripten_bind_LocalConvexResult_set_m_hitFraction_1=function(){return(Zj=b._emscripten_bind_LocalConvexResult_set_m_hitFraction_1= -b.asm.$h).apply(null,arguments)},ak=b._emscripten_bind_LocalConvexResult___destroy___0=function(){return(ak=b._emscripten_bind_LocalConvexResult___destroy___0=b.asm.ai).apply(null,arguments)},bk=b._emscripten_bind_ClosestConvexResultCallback_ClosestConvexResultCallback_2=function(){return(bk=b._emscripten_bind_ClosestConvexResultCallback_ClosestConvexResultCallback_2=b.asm.bi).apply(null,arguments)},ck=b._emscripten_bind_ClosestConvexResultCallback_hasHit_0=function(){return(ck=b._emscripten_bind_ClosestConvexResultCallback_hasHit_0= -b.asm.ci).apply(null,arguments)},dk=b._emscripten_bind_ClosestConvexResultCallback_get_m_hitCollisionObject_0=function(){return(dk=b._emscripten_bind_ClosestConvexResultCallback_get_m_hitCollisionObject_0=b.asm.di).apply(null,arguments)},ek=b._emscripten_bind_ClosestConvexResultCallback_set_m_hitCollisionObject_1=function(){return(ek=b._emscripten_bind_ClosestConvexResultCallback_set_m_hitCollisionObject_1=b.asm.ei).apply(null,arguments)},fk=b._emscripten_bind_ClosestConvexResultCallback_get_m_convexFromWorld_0= -function(){return(fk=b._emscripten_bind_ClosestConvexResultCallback_get_m_convexFromWorld_0=b.asm.fi).apply(null,arguments)},gk=b._emscripten_bind_ClosestConvexResultCallback_set_m_convexFromWorld_1=function(){return(gk=b._emscripten_bind_ClosestConvexResultCallback_set_m_convexFromWorld_1=b.asm.gi).apply(null,arguments)},hk=b._emscripten_bind_ClosestConvexResultCallback_get_m_convexToWorld_0=function(){return(hk=b._emscripten_bind_ClosestConvexResultCallback_get_m_convexToWorld_0=b.asm.hi).apply(null, -arguments)},ik=b._emscripten_bind_ClosestConvexResultCallback_set_m_convexToWorld_1=function(){return(ik=b._emscripten_bind_ClosestConvexResultCallback_set_m_convexToWorld_1=b.asm.ii).apply(null,arguments)},jk=b._emscripten_bind_ClosestConvexResultCallback_get_m_hitNormalWorld_0=function(){return(jk=b._emscripten_bind_ClosestConvexResultCallback_get_m_hitNormalWorld_0=b.asm.ji).apply(null,arguments)},kk=b._emscripten_bind_ClosestConvexResultCallback_set_m_hitNormalWorld_1=function(){return(kk=b._emscripten_bind_ClosestConvexResultCallback_set_m_hitNormalWorld_1= -b.asm.ki).apply(null,arguments)},lk=b._emscripten_bind_ClosestConvexResultCallback_get_m_hitPointWorld_0=function(){return(lk=b._emscripten_bind_ClosestConvexResultCallback_get_m_hitPointWorld_0=b.asm.li).apply(null,arguments)},mk=b._emscripten_bind_ClosestConvexResultCallback_set_m_hitPointWorld_1=function(){return(mk=b._emscripten_bind_ClosestConvexResultCallback_set_m_hitPointWorld_1=b.asm.mi).apply(null,arguments)},nk=b._emscripten_bind_ClosestConvexResultCallback_get_m_collisionFilterGroup_0= -function(){return(nk=b._emscripten_bind_ClosestConvexResultCallback_get_m_collisionFilterGroup_0=b.asm.ni).apply(null,arguments)},ok=b._emscripten_bind_ClosestConvexResultCallback_set_m_collisionFilterGroup_1=function(){return(ok=b._emscripten_bind_ClosestConvexResultCallback_set_m_collisionFilterGroup_1=b.asm.oi).apply(null,arguments)},pk=b._emscripten_bind_ClosestConvexResultCallback_get_m_collisionFilterMask_0=function(){return(pk=b._emscripten_bind_ClosestConvexResultCallback_get_m_collisionFilterMask_0= -b.asm.pi).apply(null,arguments)},qk=b._emscripten_bind_ClosestConvexResultCallback_set_m_collisionFilterMask_1=function(){return(qk=b._emscripten_bind_ClosestConvexResultCallback_set_m_collisionFilterMask_1=b.asm.qi).apply(null,arguments)},rk=b._emscripten_bind_ClosestConvexResultCallback_get_m_closestHitFraction_0=function(){return(rk=b._emscripten_bind_ClosestConvexResultCallback_get_m_closestHitFraction_0=b.asm.ri).apply(null,arguments)},sk=b._emscripten_bind_ClosestConvexResultCallback_set_m_closestHitFraction_1= -function(){return(sk=b._emscripten_bind_ClosestConvexResultCallback_set_m_closestHitFraction_1=b.asm.si).apply(null,arguments)},tk=b._emscripten_bind_ClosestConvexResultCallback___destroy___0=function(){return(tk=b._emscripten_bind_ClosestConvexResultCallback___destroy___0=b.asm.ti).apply(null,arguments)},uk=b._emscripten_bind_btConvexTriangleMeshShape_btConvexTriangleMeshShape_1=function(){return(uk=b._emscripten_bind_btConvexTriangleMeshShape_btConvexTriangleMeshShape_1=b.asm.ui).apply(null,arguments)}, -vk=b._emscripten_bind_btConvexTriangleMeshShape_btConvexTriangleMeshShape_2=function(){return(vk=b._emscripten_bind_btConvexTriangleMeshShape_btConvexTriangleMeshShape_2=b.asm.vi).apply(null,arguments)},wk=b._emscripten_bind_btConvexTriangleMeshShape_setLocalScaling_1=function(){return(wk=b._emscripten_bind_btConvexTriangleMeshShape_setLocalScaling_1=b.asm.wi).apply(null,arguments)},xk=b._emscripten_bind_btConvexTriangleMeshShape_getLocalScaling_0=function(){return(xk=b._emscripten_bind_btConvexTriangleMeshShape_getLocalScaling_0= -b.asm.xi).apply(null,arguments)},yk=b._emscripten_bind_btConvexTriangleMeshShape_calculateLocalInertia_2=function(){return(yk=b._emscripten_bind_btConvexTriangleMeshShape_calculateLocalInertia_2=b.asm.yi).apply(null,arguments)},zk=b._emscripten_bind_btConvexTriangleMeshShape_setMargin_1=function(){return(zk=b._emscripten_bind_btConvexTriangleMeshShape_setMargin_1=b.asm.zi).apply(null,arguments)},Ak=b._emscripten_bind_btConvexTriangleMeshShape_getMargin_0=function(){return(Ak=b._emscripten_bind_btConvexTriangleMeshShape_getMargin_0= -b.asm.Ai).apply(null,arguments)},Bk=b._emscripten_bind_btConvexTriangleMeshShape___destroy___0=function(){return(Bk=b._emscripten_bind_btConvexTriangleMeshShape___destroy___0=b.asm.Bi).apply(null,arguments)},Ck=b._emscripten_bind_btBoxShape_btBoxShape_1=function(){return(Ck=b._emscripten_bind_btBoxShape_btBoxShape_1=b.asm.Ci).apply(null,arguments)},Dk=b._emscripten_bind_btBoxShape_setMargin_1=function(){return(Dk=b._emscripten_bind_btBoxShape_setMargin_1=b.asm.Di).apply(null,arguments)},Ek=b._emscripten_bind_btBoxShape_getMargin_0= -function(){return(Ek=b._emscripten_bind_btBoxShape_getMargin_0=b.asm.Ei).apply(null,arguments)},Fk=b._emscripten_bind_btBoxShape_setLocalScaling_1=function(){return(Fk=b._emscripten_bind_btBoxShape_setLocalScaling_1=b.asm.Fi).apply(null,arguments)},Gk=b._emscripten_bind_btBoxShape_getLocalScaling_0=function(){return(Gk=b._emscripten_bind_btBoxShape_getLocalScaling_0=b.asm.Gi).apply(null,arguments)},Hk=b._emscripten_bind_btBoxShape_calculateLocalInertia_2=function(){return(Hk=b._emscripten_bind_btBoxShape_calculateLocalInertia_2= -b.asm.Hi).apply(null,arguments)},Ik=b._emscripten_bind_btBoxShape___destroy___0=function(){return(Ik=b._emscripten_bind_btBoxShape___destroy___0=b.asm.Ii).apply(null,arguments)},Jk=b._emscripten_bind_btCapsuleShapeX_btCapsuleShapeX_2=function(){return(Jk=b._emscripten_bind_btCapsuleShapeX_btCapsuleShapeX_2=b.asm.Ji).apply(null,arguments)},Kk=b._emscripten_bind_btCapsuleShapeX_setMargin_1=function(){return(Kk=b._emscripten_bind_btCapsuleShapeX_setMargin_1=b.asm.Ki).apply(null,arguments)},Lk=b._emscripten_bind_btCapsuleShapeX_getMargin_0= -function(){return(Lk=b._emscripten_bind_btCapsuleShapeX_getMargin_0=b.asm.Li).apply(null,arguments)},Mk=b._emscripten_bind_btCapsuleShapeX_getUpAxis_0=function(){return(Mk=b._emscripten_bind_btCapsuleShapeX_getUpAxis_0=b.asm.Mi).apply(null,arguments)},Nk=b._emscripten_bind_btCapsuleShapeX_getRadius_0=function(){return(Nk=b._emscripten_bind_btCapsuleShapeX_getRadius_0=b.asm.Ni).apply(null,arguments)},Ok=b._emscripten_bind_btCapsuleShapeX_getHalfHeight_0=function(){return(Ok=b._emscripten_bind_btCapsuleShapeX_getHalfHeight_0= -b.asm.Oi).apply(null,arguments)},Pk=b._emscripten_bind_btCapsuleShapeX_setLocalScaling_1=function(){return(Pk=b._emscripten_bind_btCapsuleShapeX_setLocalScaling_1=b.asm.Pi).apply(null,arguments)},Qk=b._emscripten_bind_btCapsuleShapeX_getLocalScaling_0=function(){return(Qk=b._emscripten_bind_btCapsuleShapeX_getLocalScaling_0=b.asm.Qi).apply(null,arguments)},Rk=b._emscripten_bind_btCapsuleShapeX_calculateLocalInertia_2=function(){return(Rk=b._emscripten_bind_btCapsuleShapeX_calculateLocalInertia_2= -b.asm.Ri).apply(null,arguments)},Sk=b._emscripten_bind_btCapsuleShapeX___destroy___0=function(){return(Sk=b._emscripten_bind_btCapsuleShapeX___destroy___0=b.asm.Si).apply(null,arguments)},Tk=b._emscripten_bind_btCapsuleShapeZ_btCapsuleShapeZ_2=function(){return(Tk=b._emscripten_bind_btCapsuleShapeZ_btCapsuleShapeZ_2=b.asm.Ti).apply(null,arguments)},Uk=b._emscripten_bind_btCapsuleShapeZ_setMargin_1=function(){return(Uk=b._emscripten_bind_btCapsuleShapeZ_setMargin_1=b.asm.Ui).apply(null,arguments)}, -Vk=b._emscripten_bind_btCapsuleShapeZ_getMargin_0=function(){return(Vk=b._emscripten_bind_btCapsuleShapeZ_getMargin_0=b.asm.Vi).apply(null,arguments)},Wk=b._emscripten_bind_btCapsuleShapeZ_getUpAxis_0=function(){return(Wk=b._emscripten_bind_btCapsuleShapeZ_getUpAxis_0=b.asm.Wi).apply(null,arguments)},Xk=b._emscripten_bind_btCapsuleShapeZ_getRadius_0=function(){return(Xk=b._emscripten_bind_btCapsuleShapeZ_getRadius_0=b.asm.Xi).apply(null,arguments)},Yk=b._emscripten_bind_btCapsuleShapeZ_getHalfHeight_0= -function(){return(Yk=b._emscripten_bind_btCapsuleShapeZ_getHalfHeight_0=b.asm.Yi).apply(null,arguments)},Zk=b._emscripten_bind_btCapsuleShapeZ_setLocalScaling_1=function(){return(Zk=b._emscripten_bind_btCapsuleShapeZ_setLocalScaling_1=b.asm.Zi).apply(null,arguments)},$k=b._emscripten_bind_btCapsuleShapeZ_getLocalScaling_0=function(){return($k=b._emscripten_bind_btCapsuleShapeZ_getLocalScaling_0=b.asm._i).apply(null,arguments)},al=b._emscripten_bind_btCapsuleShapeZ_calculateLocalInertia_2=function(){return(al= -b._emscripten_bind_btCapsuleShapeZ_calculateLocalInertia_2=b.asm.$i).apply(null,arguments)},bl=b._emscripten_bind_btCapsuleShapeZ___destroy___0=function(){return(bl=b._emscripten_bind_btCapsuleShapeZ___destroy___0=b.asm.aj).apply(null,arguments)},cl=b._emscripten_bind_btCylinderShapeX_btCylinderShapeX_1=function(){return(cl=b._emscripten_bind_btCylinderShapeX_btCylinderShapeX_1=b.asm.bj).apply(null,arguments)},dl=b._emscripten_bind_btCylinderShapeX_setMargin_1=function(){return(dl=b._emscripten_bind_btCylinderShapeX_setMargin_1= -b.asm.cj).apply(null,arguments)},el=b._emscripten_bind_btCylinderShapeX_getMargin_0=function(){return(el=b._emscripten_bind_btCylinderShapeX_getMargin_0=b.asm.dj).apply(null,arguments)},fl=b._emscripten_bind_btCylinderShapeX_setLocalScaling_1=function(){return(fl=b._emscripten_bind_btCylinderShapeX_setLocalScaling_1=b.asm.ej).apply(null,arguments)},gl=b._emscripten_bind_btCylinderShapeX_getLocalScaling_0=function(){return(gl=b._emscripten_bind_btCylinderShapeX_getLocalScaling_0=b.asm.fj).apply(null, -arguments)},hl=b._emscripten_bind_btCylinderShapeX_calculateLocalInertia_2=function(){return(hl=b._emscripten_bind_btCylinderShapeX_calculateLocalInertia_2=b.asm.gj).apply(null,arguments)},il=b._emscripten_bind_btCylinderShapeX___destroy___0=function(){return(il=b._emscripten_bind_btCylinderShapeX___destroy___0=b.asm.hj).apply(null,arguments)},jl=b._emscripten_bind_btCylinderShapeZ_btCylinderShapeZ_1=function(){return(jl=b._emscripten_bind_btCylinderShapeZ_btCylinderShapeZ_1=b.asm.ij).apply(null, -arguments)},kl=b._emscripten_bind_btCylinderShapeZ_setMargin_1=function(){return(kl=b._emscripten_bind_btCylinderShapeZ_setMargin_1=b.asm.jj).apply(null,arguments)},ll=b._emscripten_bind_btCylinderShapeZ_getMargin_0=function(){return(ll=b._emscripten_bind_btCylinderShapeZ_getMargin_0=b.asm.kj).apply(null,arguments)},ml=b._emscripten_bind_btCylinderShapeZ_setLocalScaling_1=function(){return(ml=b._emscripten_bind_btCylinderShapeZ_setLocalScaling_1=b.asm.lj).apply(null,arguments)},nl=b._emscripten_bind_btCylinderShapeZ_getLocalScaling_0= -function(){return(nl=b._emscripten_bind_btCylinderShapeZ_getLocalScaling_0=b.asm.mj).apply(null,arguments)},ol=b._emscripten_bind_btCylinderShapeZ_calculateLocalInertia_2=function(){return(ol=b._emscripten_bind_btCylinderShapeZ_calculateLocalInertia_2=b.asm.nj).apply(null,arguments)},pl=b._emscripten_bind_btCylinderShapeZ___destroy___0=function(){return(pl=b._emscripten_bind_btCylinderShapeZ___destroy___0=b.asm.oj).apply(null,arguments)},ql=b._emscripten_bind_btSphereShape_btSphereShape_1=function(){return(ql= -b._emscripten_bind_btSphereShape_btSphereShape_1=b.asm.pj).apply(null,arguments)},rl=b._emscripten_bind_btSphereShape_setMargin_1=function(){return(rl=b._emscripten_bind_btSphereShape_setMargin_1=b.asm.qj).apply(null,arguments)},sl=b._emscripten_bind_btSphereShape_getMargin_0=function(){return(sl=b._emscripten_bind_btSphereShape_getMargin_0=b.asm.rj).apply(null,arguments)},tl=b._emscripten_bind_btSphereShape_setLocalScaling_1=function(){return(tl=b._emscripten_bind_btSphereShape_setLocalScaling_1= -b.asm.sj).apply(null,arguments)},ul=b._emscripten_bind_btSphereShape_getLocalScaling_0=function(){return(ul=b._emscripten_bind_btSphereShape_getLocalScaling_0=b.asm.tj).apply(null,arguments)},vl=b._emscripten_bind_btSphereShape_calculateLocalInertia_2=function(){return(vl=b._emscripten_bind_btSphereShape_calculateLocalInertia_2=b.asm.uj).apply(null,arguments)},wl=b._emscripten_bind_btSphereShape___destroy___0=function(){return(wl=b._emscripten_bind_btSphereShape___destroy___0=b.asm.vj).apply(null, -arguments)},xl=b._emscripten_bind_btMultiSphereShape_btMultiSphereShape_3=function(){return(xl=b._emscripten_bind_btMultiSphereShape_btMultiSphereShape_3=b.asm.wj).apply(null,arguments)},yl=b._emscripten_bind_btMultiSphereShape_setLocalScaling_1=function(){return(yl=b._emscripten_bind_btMultiSphereShape_setLocalScaling_1=b.asm.xj).apply(null,arguments)},zl=b._emscripten_bind_btMultiSphereShape_getLocalScaling_0=function(){return(zl=b._emscripten_bind_btMultiSphereShape_getLocalScaling_0=b.asm.yj).apply(null, -arguments)},Al=b._emscripten_bind_btMultiSphereShape_calculateLocalInertia_2=function(){return(Al=b._emscripten_bind_btMultiSphereShape_calculateLocalInertia_2=b.asm.zj).apply(null,arguments)},Bl=b._emscripten_bind_btMultiSphereShape___destroy___0=function(){return(Bl=b._emscripten_bind_btMultiSphereShape___destroy___0=b.asm.Aj).apply(null,arguments)},Cl=b._emscripten_bind_btConeShapeX_btConeShapeX_2=function(){return(Cl=b._emscripten_bind_btConeShapeX_btConeShapeX_2=b.asm.Bj).apply(null,arguments)}, -Dl=b._emscripten_bind_btConeShapeX_setLocalScaling_1=function(){return(Dl=b._emscripten_bind_btConeShapeX_setLocalScaling_1=b.asm.Cj).apply(null,arguments)},El=b._emscripten_bind_btConeShapeX_getLocalScaling_0=function(){return(El=b._emscripten_bind_btConeShapeX_getLocalScaling_0=b.asm.Dj).apply(null,arguments)},Fl=b._emscripten_bind_btConeShapeX_calculateLocalInertia_2=function(){return(Fl=b._emscripten_bind_btConeShapeX_calculateLocalInertia_2=b.asm.Ej).apply(null,arguments)},Gl=b._emscripten_bind_btConeShapeX___destroy___0= -function(){return(Gl=b._emscripten_bind_btConeShapeX___destroy___0=b.asm.Fj).apply(null,arguments)},Hl=b._emscripten_bind_btConeShapeZ_btConeShapeZ_2=function(){return(Hl=b._emscripten_bind_btConeShapeZ_btConeShapeZ_2=b.asm.Gj).apply(null,arguments)},Il=b._emscripten_bind_btConeShapeZ_setLocalScaling_1=function(){return(Il=b._emscripten_bind_btConeShapeZ_setLocalScaling_1=b.asm.Hj).apply(null,arguments)},Jl=b._emscripten_bind_btConeShapeZ_getLocalScaling_0=function(){return(Jl=b._emscripten_bind_btConeShapeZ_getLocalScaling_0= -b.asm.Ij).apply(null,arguments)},Kl=b._emscripten_bind_btConeShapeZ_calculateLocalInertia_2=function(){return(Kl=b._emscripten_bind_btConeShapeZ_calculateLocalInertia_2=b.asm.Jj).apply(null,arguments)},Ll=b._emscripten_bind_btConeShapeZ___destroy___0=function(){return(Ll=b._emscripten_bind_btConeShapeZ___destroy___0=b.asm.Kj).apply(null,arguments)},Ml=b._emscripten_bind_btIntArray_size_0=function(){return(Ml=b._emscripten_bind_btIntArray_size_0=b.asm.Lj).apply(null,arguments)},Nl=b._emscripten_bind_btIntArray_at_1= -function(){return(Nl=b._emscripten_bind_btIntArray_at_1=b.asm.Mj).apply(null,arguments)},Ol=b._emscripten_bind_btIntArray___destroy___0=function(){return(Ol=b._emscripten_bind_btIntArray___destroy___0=b.asm.Nj).apply(null,arguments)},Pl=b._emscripten_bind_btFace_get_m_indices_0=function(){return(Pl=b._emscripten_bind_btFace_get_m_indices_0=b.asm.Oj).apply(null,arguments)},Ql=b._emscripten_bind_btFace_set_m_indices_1=function(){return(Ql=b._emscripten_bind_btFace_set_m_indices_1=b.asm.Pj).apply(null, -arguments)},Rl=b._emscripten_bind_btFace_get_m_plane_1=function(){return(Rl=b._emscripten_bind_btFace_get_m_plane_1=b.asm.Qj).apply(null,arguments)},Sl=b._emscripten_bind_btFace_set_m_plane_2=function(){return(Sl=b._emscripten_bind_btFace_set_m_plane_2=b.asm.Rj).apply(null,arguments)},Tl=b._emscripten_bind_btFace___destroy___0=function(){return(Tl=b._emscripten_bind_btFace___destroy___0=b.asm.Sj).apply(null,arguments)},Ul=b._emscripten_bind_btVector3Array_size_0=function(){return(Ul=b._emscripten_bind_btVector3Array_size_0= -b.asm.Tj).apply(null,arguments)},Vl=b._emscripten_bind_btVector3Array_at_1=function(){return(Vl=b._emscripten_bind_btVector3Array_at_1=b.asm.Uj).apply(null,arguments)},Wl=b._emscripten_bind_btVector3Array___destroy___0=function(){return(Wl=b._emscripten_bind_btVector3Array___destroy___0=b.asm.Vj).apply(null,arguments)},Xl=b._emscripten_bind_btFaceArray_size_0=function(){return(Xl=b._emscripten_bind_btFaceArray_size_0=b.asm.Wj).apply(null,arguments)},Yl=b._emscripten_bind_btFaceArray_at_1=function(){return(Yl= -b._emscripten_bind_btFaceArray_at_1=b.asm.Xj).apply(null,arguments)},Zl=b._emscripten_bind_btFaceArray___destroy___0=function(){return(Zl=b._emscripten_bind_btFaceArray___destroy___0=b.asm.Yj).apply(null,arguments)},$l=b._emscripten_bind_btConvexPolyhedron_get_m_vertices_0=function(){return($l=b._emscripten_bind_btConvexPolyhedron_get_m_vertices_0=b.asm.Zj).apply(null,arguments)},am=b._emscripten_bind_btConvexPolyhedron_set_m_vertices_1=function(){return(am=b._emscripten_bind_btConvexPolyhedron_set_m_vertices_1= -b.asm._j).apply(null,arguments)},bm=b._emscripten_bind_btConvexPolyhedron_get_m_faces_0=function(){return(bm=b._emscripten_bind_btConvexPolyhedron_get_m_faces_0=b.asm.$j).apply(null,arguments)},cm=b._emscripten_bind_btConvexPolyhedron_set_m_faces_1=function(){return(cm=b._emscripten_bind_btConvexPolyhedron_set_m_faces_1=b.asm.ak).apply(null,arguments)},dm=b._emscripten_bind_btConvexPolyhedron___destroy___0=function(){return(dm=b._emscripten_bind_btConvexPolyhedron___destroy___0=b.asm.bk).apply(null, -arguments)},em=b._emscripten_bind_btConvexHullShape_btConvexHullShape_0=function(){return(em=b._emscripten_bind_btConvexHullShape_btConvexHullShape_0=b.asm.ck).apply(null,arguments)},fm=b._emscripten_bind_btConvexHullShape_btConvexHullShape_1=function(){return(fm=b._emscripten_bind_btConvexHullShape_btConvexHullShape_1=b.asm.dk).apply(null,arguments)},gm=b._emscripten_bind_btConvexHullShape_btConvexHullShape_2=function(){return(gm=b._emscripten_bind_btConvexHullShape_btConvexHullShape_2=b.asm.ek).apply(null, -arguments)},hm=b._emscripten_bind_btConvexHullShape_addPoint_1=function(){return(hm=b._emscripten_bind_btConvexHullShape_addPoint_1=b.asm.fk).apply(null,arguments)},im=b._emscripten_bind_btConvexHullShape_addPoint_2=function(){return(im=b._emscripten_bind_btConvexHullShape_addPoint_2=b.asm.gk).apply(null,arguments)},jm=b._emscripten_bind_btConvexHullShape_setMargin_1=function(){return(jm=b._emscripten_bind_btConvexHullShape_setMargin_1=b.asm.hk).apply(null,arguments)},km=b._emscripten_bind_btConvexHullShape_getMargin_0= -function(){return(km=b._emscripten_bind_btConvexHullShape_getMargin_0=b.asm.ik).apply(null,arguments)},lm=b._emscripten_bind_btConvexHullShape_getNumVertices_0=function(){return(lm=b._emscripten_bind_btConvexHullShape_getNumVertices_0=b.asm.jk).apply(null,arguments)},mm=b._emscripten_bind_btConvexHullShape_initializePolyhedralFeatures_1=function(){return(mm=b._emscripten_bind_btConvexHullShape_initializePolyhedralFeatures_1=b.asm.kk).apply(null,arguments)},nm=b._emscripten_bind_btConvexHullShape_recalcLocalAabb_0= -function(){return(nm=b._emscripten_bind_btConvexHullShape_recalcLocalAabb_0=b.asm.lk).apply(null,arguments)},om=b._emscripten_bind_btConvexHullShape_getConvexPolyhedron_0=function(){return(om=b._emscripten_bind_btConvexHullShape_getConvexPolyhedron_0=b.asm.mk).apply(null,arguments)},pm=b._emscripten_bind_btConvexHullShape_setLocalScaling_1=function(){return(pm=b._emscripten_bind_btConvexHullShape_setLocalScaling_1=b.asm.nk).apply(null,arguments)},qm=b._emscripten_bind_btConvexHullShape_getLocalScaling_0= -function(){return(qm=b._emscripten_bind_btConvexHullShape_getLocalScaling_0=b.asm.ok).apply(null,arguments)},rm=b._emscripten_bind_btConvexHullShape_calculateLocalInertia_2=function(){return(rm=b._emscripten_bind_btConvexHullShape_calculateLocalInertia_2=b.asm.pk).apply(null,arguments)},sm=b._emscripten_bind_btConvexHullShape___destroy___0=function(){return(sm=b._emscripten_bind_btConvexHullShape___destroy___0=b.asm.qk).apply(null,arguments)},tm=b._emscripten_bind_btShapeHull_btShapeHull_1=function(){return(tm= -b._emscripten_bind_btShapeHull_btShapeHull_1=b.asm.rk).apply(null,arguments)},um=b._emscripten_bind_btShapeHull_buildHull_1=function(){return(um=b._emscripten_bind_btShapeHull_buildHull_1=b.asm.sk).apply(null,arguments)},wm=b._emscripten_bind_btShapeHull_numVertices_0=function(){return(wm=b._emscripten_bind_btShapeHull_numVertices_0=b.asm.tk).apply(null,arguments)},xm=b._emscripten_bind_btShapeHull_getVertexPointer_0=function(){return(xm=b._emscripten_bind_btShapeHull_getVertexPointer_0=b.asm.uk).apply(null, -arguments)},ym=b._emscripten_bind_btShapeHull___destroy___0=function(){return(ym=b._emscripten_bind_btShapeHull___destroy___0=b.asm.vk).apply(null,arguments)},zm=b._emscripten_bind_btCompoundShape_btCompoundShape_0=function(){return(zm=b._emscripten_bind_btCompoundShape_btCompoundShape_0=b.asm.wk).apply(null,arguments)},Am=b._emscripten_bind_btCompoundShape_btCompoundShape_1=function(){return(Am=b._emscripten_bind_btCompoundShape_btCompoundShape_1=b.asm.xk).apply(null,arguments)},Bm=b._emscripten_bind_btCompoundShape_addChildShape_2= -function(){return(Bm=b._emscripten_bind_btCompoundShape_addChildShape_2=b.asm.yk).apply(null,arguments)},Cm=b._emscripten_bind_btCompoundShape_removeChildShape_1=function(){return(Cm=b._emscripten_bind_btCompoundShape_removeChildShape_1=b.asm.zk).apply(null,arguments)},Dm=b._emscripten_bind_btCompoundShape_removeChildShapeByIndex_1=function(){return(Dm=b._emscripten_bind_btCompoundShape_removeChildShapeByIndex_1=b.asm.Ak).apply(null,arguments)},Em=b._emscripten_bind_btCompoundShape_getNumChildShapes_0= -function(){return(Em=b._emscripten_bind_btCompoundShape_getNumChildShapes_0=b.asm.Bk).apply(null,arguments)},Fm=b._emscripten_bind_btCompoundShape_getChildShape_1=function(){return(Fm=b._emscripten_bind_btCompoundShape_getChildShape_1=b.asm.Ck).apply(null,arguments)},Gm=b._emscripten_bind_btCompoundShape_updateChildTransform_2=function(){return(Gm=b._emscripten_bind_btCompoundShape_updateChildTransform_2=b.asm.Dk).apply(null,arguments)},Hm=b._emscripten_bind_btCompoundShape_updateChildTransform_3= -function(){return(Hm=b._emscripten_bind_btCompoundShape_updateChildTransform_3=b.asm.Ek).apply(null,arguments)},Im=b._emscripten_bind_btCompoundShape_setMargin_1=function(){return(Im=b._emscripten_bind_btCompoundShape_setMargin_1=b.asm.Fk).apply(null,arguments)},Jm=b._emscripten_bind_btCompoundShape_getMargin_0=function(){return(Jm=b._emscripten_bind_btCompoundShape_getMargin_0=b.asm.Gk).apply(null,arguments)},Km=b._emscripten_bind_btCompoundShape_setLocalScaling_1=function(){return(Km=b._emscripten_bind_btCompoundShape_setLocalScaling_1= -b.asm.Hk).apply(null,arguments)},Lm=b._emscripten_bind_btCompoundShape_getLocalScaling_0=function(){return(Lm=b._emscripten_bind_btCompoundShape_getLocalScaling_0=b.asm.Ik).apply(null,arguments)},Mm=b._emscripten_bind_btCompoundShape_calculateLocalInertia_2=function(){return(Mm=b._emscripten_bind_btCompoundShape_calculateLocalInertia_2=b.asm.Jk).apply(null,arguments)},Nm=b._emscripten_bind_btCompoundShape___destroy___0=function(){return(Nm=b._emscripten_bind_btCompoundShape___destroy___0=b.asm.Kk).apply(null, -arguments)},Om=b._emscripten_bind_btIndexedMesh_get_m_numTriangles_0=function(){return(Om=b._emscripten_bind_btIndexedMesh_get_m_numTriangles_0=b.asm.Lk).apply(null,arguments)},Pm=b._emscripten_bind_btIndexedMesh_set_m_numTriangles_1=function(){return(Pm=b._emscripten_bind_btIndexedMesh_set_m_numTriangles_1=b.asm.Mk).apply(null,arguments)},Qm=b._emscripten_bind_btIndexedMesh___destroy___0=function(){return(Qm=b._emscripten_bind_btIndexedMesh___destroy___0=b.asm.Nk).apply(null,arguments)},Rm=b._emscripten_bind_btIndexedMeshArray_size_0= -function(){return(Rm=b._emscripten_bind_btIndexedMeshArray_size_0=b.asm.Ok).apply(null,arguments)},Sm=b._emscripten_bind_btIndexedMeshArray_at_1=function(){return(Sm=b._emscripten_bind_btIndexedMeshArray_at_1=b.asm.Pk).apply(null,arguments)},Tm=b._emscripten_bind_btIndexedMeshArray___destroy___0=function(){return(Tm=b._emscripten_bind_btIndexedMeshArray___destroy___0=b.asm.Qk).apply(null,arguments)},Um=b._emscripten_bind_btTriangleMesh_btTriangleMesh_0=function(){return(Um=b._emscripten_bind_btTriangleMesh_btTriangleMesh_0= -b.asm.Rk).apply(null,arguments)},Vm=b._emscripten_bind_btTriangleMesh_btTriangleMesh_1=function(){return(Vm=b._emscripten_bind_btTriangleMesh_btTriangleMesh_1=b.asm.Sk).apply(null,arguments)},Wm=b._emscripten_bind_btTriangleMesh_btTriangleMesh_2=function(){return(Wm=b._emscripten_bind_btTriangleMesh_btTriangleMesh_2=b.asm.Tk).apply(null,arguments)},Xm=b._emscripten_bind_btTriangleMesh_addTriangle_3=function(){return(Xm=b._emscripten_bind_btTriangleMesh_addTriangle_3=b.asm.Uk).apply(null,arguments)}, -Ym=b._emscripten_bind_btTriangleMesh_addTriangle_4=function(){return(Ym=b._emscripten_bind_btTriangleMesh_addTriangle_4=b.asm.Vk).apply(null,arguments)},Zm=b._emscripten_bind_btTriangleMesh_findOrAddVertex_2=function(){return(Zm=b._emscripten_bind_btTriangleMesh_findOrAddVertex_2=b.asm.Wk).apply(null,arguments)},$m=b._emscripten_bind_btTriangleMesh_addIndex_1=function(){return($m=b._emscripten_bind_btTriangleMesh_addIndex_1=b.asm.Xk).apply(null,arguments)},an=b._emscripten_bind_btTriangleMesh_getIndexedMeshArray_0= -function(){return(an=b._emscripten_bind_btTriangleMesh_getIndexedMeshArray_0=b.asm.Yk).apply(null,arguments)},bn=b._emscripten_bind_btTriangleMesh_setScaling_1=function(){return(bn=b._emscripten_bind_btTriangleMesh_setScaling_1=b.asm.Zk).apply(null,arguments)},cn=b._emscripten_bind_btTriangleMesh___destroy___0=function(){return(cn=b._emscripten_bind_btTriangleMesh___destroy___0=b.asm._k).apply(null,arguments)},dn=b._emscripten_bind_btEmptyShape_btEmptyShape_0=function(){return(dn=b._emscripten_bind_btEmptyShape_btEmptyShape_0= -b.asm.$k).apply(null,arguments)},en=b._emscripten_bind_btEmptyShape_setLocalScaling_1=function(){return(en=b._emscripten_bind_btEmptyShape_setLocalScaling_1=b.asm.al).apply(null,arguments)},fn=b._emscripten_bind_btEmptyShape_getLocalScaling_0=function(){return(fn=b._emscripten_bind_btEmptyShape_getLocalScaling_0=b.asm.bl).apply(null,arguments)},gn=b._emscripten_bind_btEmptyShape_calculateLocalInertia_2=function(){return(gn=b._emscripten_bind_btEmptyShape_calculateLocalInertia_2=b.asm.cl).apply(null, -arguments)},hn=b._emscripten_bind_btEmptyShape___destroy___0=function(){return(hn=b._emscripten_bind_btEmptyShape___destroy___0=b.asm.dl).apply(null,arguments)},jn=b._emscripten_bind_btStaticPlaneShape_btStaticPlaneShape_2=function(){return(jn=b._emscripten_bind_btStaticPlaneShape_btStaticPlaneShape_2=b.asm.el).apply(null,arguments)},kn=b._emscripten_bind_btStaticPlaneShape_setLocalScaling_1=function(){return(kn=b._emscripten_bind_btStaticPlaneShape_setLocalScaling_1=b.asm.fl).apply(null,arguments)}, -ln=b._emscripten_bind_btStaticPlaneShape_getLocalScaling_0=function(){return(ln=b._emscripten_bind_btStaticPlaneShape_getLocalScaling_0=b.asm.gl).apply(null,arguments)},mn=b._emscripten_bind_btStaticPlaneShape_calculateLocalInertia_2=function(){return(mn=b._emscripten_bind_btStaticPlaneShape_calculateLocalInertia_2=b.asm.hl).apply(null,arguments)},nn=b._emscripten_bind_btStaticPlaneShape___destroy___0=function(){return(nn=b._emscripten_bind_btStaticPlaneShape___destroy___0=b.asm.il).apply(null,arguments)}, -on=b._emscripten_bind_btBvhTriangleMeshShape_btBvhTriangleMeshShape_2=function(){return(on=b._emscripten_bind_btBvhTriangleMeshShape_btBvhTriangleMeshShape_2=b.asm.jl).apply(null,arguments)},pn=b._emscripten_bind_btBvhTriangleMeshShape_btBvhTriangleMeshShape_3=function(){return(pn=b._emscripten_bind_btBvhTriangleMeshShape_btBvhTriangleMeshShape_3=b.asm.kl).apply(null,arguments)},qn=b._emscripten_bind_btBvhTriangleMeshShape_setLocalScaling_1=function(){return(qn=b._emscripten_bind_btBvhTriangleMeshShape_setLocalScaling_1= -b.asm.ll).apply(null,arguments)},rn=b._emscripten_bind_btBvhTriangleMeshShape_getLocalScaling_0=function(){return(rn=b._emscripten_bind_btBvhTriangleMeshShape_getLocalScaling_0=b.asm.ml).apply(null,arguments)},sn=b._emscripten_bind_btBvhTriangleMeshShape_calculateLocalInertia_2=function(){return(sn=b._emscripten_bind_btBvhTriangleMeshShape_calculateLocalInertia_2=b.asm.nl).apply(null,arguments)},tn=b._emscripten_bind_btBvhTriangleMeshShape___destroy___0=function(){return(tn=b._emscripten_bind_btBvhTriangleMeshShape___destroy___0= -b.asm.ol).apply(null,arguments)},un=b._emscripten_bind_btHeightfieldTerrainShape_btHeightfieldTerrainShape_9=function(){return(un=b._emscripten_bind_btHeightfieldTerrainShape_btHeightfieldTerrainShape_9=b.asm.pl).apply(null,arguments)},vn=b._emscripten_bind_btHeightfieldTerrainShape_setMargin_1=function(){return(vn=b._emscripten_bind_btHeightfieldTerrainShape_setMargin_1=b.asm.ql).apply(null,arguments)},wn=b._emscripten_bind_btHeightfieldTerrainShape_getMargin_0=function(){return(wn=b._emscripten_bind_btHeightfieldTerrainShape_getMargin_0= -b.asm.rl).apply(null,arguments)},xn=b._emscripten_bind_btHeightfieldTerrainShape_setLocalScaling_1=function(){return(xn=b._emscripten_bind_btHeightfieldTerrainShape_setLocalScaling_1=b.asm.sl).apply(null,arguments)},yn=b._emscripten_bind_btHeightfieldTerrainShape_getLocalScaling_0=function(){return(yn=b._emscripten_bind_btHeightfieldTerrainShape_getLocalScaling_0=b.asm.tl).apply(null,arguments)},zn=b._emscripten_bind_btHeightfieldTerrainShape_calculateLocalInertia_2=function(){return(zn=b._emscripten_bind_btHeightfieldTerrainShape_calculateLocalInertia_2= -b.asm.ul).apply(null,arguments)},An=b._emscripten_bind_btHeightfieldTerrainShape___destroy___0=function(){return(An=b._emscripten_bind_btHeightfieldTerrainShape___destroy___0=b.asm.vl).apply(null,arguments)},Bn=b._emscripten_bind_btAABB_btAABB_4=function(){return(Bn=b._emscripten_bind_btAABB_btAABB_4=b.asm.wl).apply(null,arguments)},Cn=b._emscripten_bind_btAABB_invalidate_0=function(){return(Cn=b._emscripten_bind_btAABB_invalidate_0=b.asm.xl).apply(null,arguments)},Dn=b._emscripten_bind_btAABB_increment_margin_1= -function(){return(Dn=b._emscripten_bind_btAABB_increment_margin_1=b.asm.yl).apply(null,arguments)},En=b._emscripten_bind_btAABB_copy_with_margin_2=function(){return(En=b._emscripten_bind_btAABB_copy_with_margin_2=b.asm.zl).apply(null,arguments)},Fn=b._emscripten_bind_btAABB___destroy___0=function(){return(Fn=b._emscripten_bind_btAABB___destroy___0=b.asm.Al).apply(null,arguments)},Gn=b._emscripten_bind_btPrimitiveTriangle_btPrimitiveTriangle_0=function(){return(Gn=b._emscripten_bind_btPrimitiveTriangle_btPrimitiveTriangle_0= -b.asm.Bl).apply(null,arguments)},Hn=b._emscripten_bind_btPrimitiveTriangle___destroy___0=function(){return(Hn=b._emscripten_bind_btPrimitiveTriangle___destroy___0=b.asm.Cl).apply(null,arguments)},In=b._emscripten_bind_btTriangleShapeEx_btTriangleShapeEx_3=function(){return(In=b._emscripten_bind_btTriangleShapeEx_btTriangleShapeEx_3=b.asm.Dl).apply(null,arguments)},Jn=b._emscripten_bind_btTriangleShapeEx_getAabb_3=function(){return(Jn=b._emscripten_bind_btTriangleShapeEx_getAabb_3=b.asm.El).apply(null, -arguments)},Kn=b._emscripten_bind_btTriangleShapeEx_applyTransform_1=function(){return(Kn=b._emscripten_bind_btTriangleShapeEx_applyTransform_1=b.asm.Fl).apply(null,arguments)},Ln=b._emscripten_bind_btTriangleShapeEx_buildTriPlane_1=function(){return(Ln=b._emscripten_bind_btTriangleShapeEx_buildTriPlane_1=b.asm.Gl).apply(null,arguments)},Mn=b._emscripten_bind_btTriangleShapeEx___destroy___0=function(){return(Mn=b._emscripten_bind_btTriangleShapeEx___destroy___0=b.asm.Hl).apply(null,arguments)},Nn= -b._emscripten_bind_btTetrahedronShapeEx_btTetrahedronShapeEx_0=function(){return(Nn=b._emscripten_bind_btTetrahedronShapeEx_btTetrahedronShapeEx_0=b.asm.Il).apply(null,arguments)},On=b._emscripten_bind_btTetrahedronShapeEx_setVertices_4=function(){return(On=b._emscripten_bind_btTetrahedronShapeEx_setVertices_4=b.asm.Jl).apply(null,arguments)},Pn=b._emscripten_bind_btTetrahedronShapeEx___destroy___0=function(){return(Pn=b._emscripten_bind_btTetrahedronShapeEx___destroy___0=b.asm.Kl).apply(null,arguments)}, -Qn=b._emscripten_bind_CompoundPrimitiveManager_get_primitive_count_0=function(){return(Qn=b._emscripten_bind_CompoundPrimitiveManager_get_primitive_count_0=b.asm.Ll).apply(null,arguments)},Rn=b._emscripten_bind_CompoundPrimitiveManager_get_primitive_box_2=function(){return(Rn=b._emscripten_bind_CompoundPrimitiveManager_get_primitive_box_2=b.asm.Ml).apply(null,arguments)},Sn=b._emscripten_bind_CompoundPrimitiveManager_get_primitive_triangle_2=function(){return(Sn=b._emscripten_bind_CompoundPrimitiveManager_get_primitive_triangle_2= -b.asm.Nl).apply(null,arguments)},Tn=b._emscripten_bind_CompoundPrimitiveManager_is_trimesh_0=function(){return(Tn=b._emscripten_bind_CompoundPrimitiveManager_is_trimesh_0=b.asm.Ol).apply(null,arguments)},Un=b._emscripten_bind_CompoundPrimitiveManager_get_m_compoundShape_0=function(){return(Un=b._emscripten_bind_CompoundPrimitiveManager_get_m_compoundShape_0=b.asm.Pl).apply(null,arguments)},Vn=b._emscripten_bind_CompoundPrimitiveManager_set_m_compoundShape_1=function(){return(Vn=b._emscripten_bind_CompoundPrimitiveManager_set_m_compoundShape_1= -b.asm.Ql).apply(null,arguments)},Wn=b._emscripten_bind_CompoundPrimitiveManager___destroy___0=function(){return(Wn=b._emscripten_bind_CompoundPrimitiveManager___destroy___0=b.asm.Rl).apply(null,arguments)},Xn=b._emscripten_bind_btGImpactCompoundShape_btGImpactCompoundShape_0=function(){return(Xn=b._emscripten_bind_btGImpactCompoundShape_btGImpactCompoundShape_0=b.asm.Sl).apply(null,arguments)},Yn=b._emscripten_bind_btGImpactCompoundShape_btGImpactCompoundShape_1=function(){return(Yn=b._emscripten_bind_btGImpactCompoundShape_btGImpactCompoundShape_1= -b.asm.Tl).apply(null,arguments)},Zn=b._emscripten_bind_btGImpactCompoundShape_childrenHasTransform_0=function(){return(Zn=b._emscripten_bind_btGImpactCompoundShape_childrenHasTransform_0=b.asm.Ul).apply(null,arguments)},$n=b._emscripten_bind_btGImpactCompoundShape_getPrimitiveManager_0=function(){return($n=b._emscripten_bind_btGImpactCompoundShape_getPrimitiveManager_0=b.asm.Vl).apply(null,arguments)},ao=b._emscripten_bind_btGImpactCompoundShape_getCompoundPrimitiveManager_0=function(){return(ao= -b._emscripten_bind_btGImpactCompoundShape_getCompoundPrimitiveManager_0=b.asm.Wl).apply(null,arguments)},bo=b._emscripten_bind_btGImpactCompoundShape_getNumChildShapes_0=function(){return(bo=b._emscripten_bind_btGImpactCompoundShape_getNumChildShapes_0=b.asm.Xl).apply(null,arguments)},co=b._emscripten_bind_btGImpactCompoundShape_addChildShape_2=function(){return(co=b._emscripten_bind_btGImpactCompoundShape_addChildShape_2=b.asm.Yl).apply(null,arguments)},eo=b._emscripten_bind_btGImpactCompoundShape_getChildShape_1= -function(){return(eo=b._emscripten_bind_btGImpactCompoundShape_getChildShape_1=b.asm.Zl).apply(null,arguments)},fo=b._emscripten_bind_btGImpactCompoundShape_getChildAabb_4=function(){return(fo=b._emscripten_bind_btGImpactCompoundShape_getChildAabb_4=b.asm._l).apply(null,arguments)},go=b._emscripten_bind_btGImpactCompoundShape_getChildTransform_1=function(){return(go=b._emscripten_bind_btGImpactCompoundShape_getChildTransform_1=b.asm.$l).apply(null,arguments)},ho=b._emscripten_bind_btGImpactCompoundShape_setChildTransform_2= -function(){return(ho=b._emscripten_bind_btGImpactCompoundShape_setChildTransform_2=b.asm.am).apply(null,arguments)},io=b._emscripten_bind_btGImpactCompoundShape_calculateLocalInertia_2=function(){return(io=b._emscripten_bind_btGImpactCompoundShape_calculateLocalInertia_2=b.asm.bm).apply(null,arguments)},jo=b._emscripten_bind_btGImpactCompoundShape_getName_0=function(){return(jo=b._emscripten_bind_btGImpactCompoundShape_getName_0=b.asm.cm).apply(null,arguments)},ko=b._emscripten_bind_btGImpactCompoundShape_getGImpactShapeType_0= -function(){return(ko=b._emscripten_bind_btGImpactCompoundShape_getGImpactShapeType_0=b.asm.dm).apply(null,arguments)},lo=b._emscripten_bind_btGImpactCompoundShape_setLocalScaling_1=function(){return(lo=b._emscripten_bind_btGImpactCompoundShape_setLocalScaling_1=b.asm.em).apply(null,arguments)},mo=b._emscripten_bind_btGImpactCompoundShape_getLocalScaling_0=function(){return(mo=b._emscripten_bind_btGImpactCompoundShape_getLocalScaling_0=b.asm.fm).apply(null,arguments)},no=b._emscripten_bind_btGImpactCompoundShape_updateBound_0= -function(){return(no=b._emscripten_bind_btGImpactCompoundShape_updateBound_0=b.asm.gm).apply(null,arguments)},oo=b._emscripten_bind_btGImpactCompoundShape_postUpdate_0=function(){return(oo=b._emscripten_bind_btGImpactCompoundShape_postUpdate_0=b.asm.hm).apply(null,arguments)},po=b._emscripten_bind_btGImpactCompoundShape_getShapeType_0=function(){return(po=b._emscripten_bind_btGImpactCompoundShape_getShapeType_0=b.asm.im).apply(null,arguments)},qo=b._emscripten_bind_btGImpactCompoundShape_needsRetrieveTriangles_0= -function(){return(qo=b._emscripten_bind_btGImpactCompoundShape_needsRetrieveTriangles_0=b.asm.jm).apply(null,arguments)},ro=b._emscripten_bind_btGImpactCompoundShape_needsRetrieveTetrahedrons_0=function(){return(ro=b._emscripten_bind_btGImpactCompoundShape_needsRetrieveTetrahedrons_0=b.asm.km).apply(null,arguments)},so=b._emscripten_bind_btGImpactCompoundShape_getBulletTriangle_2=function(){return(so=b._emscripten_bind_btGImpactCompoundShape_getBulletTriangle_2=b.asm.lm).apply(null,arguments)},to= -b._emscripten_bind_btGImpactCompoundShape_getBulletTetrahedron_2=function(){return(to=b._emscripten_bind_btGImpactCompoundShape_getBulletTetrahedron_2=b.asm.mm).apply(null,arguments)},uo=b._emscripten_bind_btGImpactCompoundShape___destroy___0=function(){return(uo=b._emscripten_bind_btGImpactCompoundShape___destroy___0=b.asm.nm).apply(null,arguments)},vo=b._emscripten_bind_TrimeshPrimitiveManager_TrimeshPrimitiveManager_0=function(){return(vo=b._emscripten_bind_TrimeshPrimitiveManager_TrimeshPrimitiveManager_0= -b.asm.om).apply(null,arguments)},wo=b._emscripten_bind_TrimeshPrimitiveManager_TrimeshPrimitiveManager_1=function(){return(wo=b._emscripten_bind_TrimeshPrimitiveManager_TrimeshPrimitiveManager_1=b.asm.pm).apply(null,arguments)},xo=b._emscripten_bind_TrimeshPrimitiveManager_lock_0=function(){return(xo=b._emscripten_bind_TrimeshPrimitiveManager_lock_0=b.asm.qm).apply(null,arguments)},yo=b._emscripten_bind_TrimeshPrimitiveManager_unlock_0=function(){return(yo=b._emscripten_bind_TrimeshPrimitiveManager_unlock_0= -b.asm.rm).apply(null,arguments)},zo=b._emscripten_bind_TrimeshPrimitiveManager_is_trimesh_0=function(){return(zo=b._emscripten_bind_TrimeshPrimitiveManager_is_trimesh_0=b.asm.sm).apply(null,arguments)},Ao=b._emscripten_bind_TrimeshPrimitiveManager_get_vertex_count_0=function(){return(Ao=b._emscripten_bind_TrimeshPrimitiveManager_get_vertex_count_0=b.asm.tm).apply(null,arguments)},Bo=b._emscripten_bind_TrimeshPrimitiveManager_get_indices_4=function(){return(Bo=b._emscripten_bind_TrimeshPrimitiveManager_get_indices_4= -b.asm.um).apply(null,arguments)},Co=b._emscripten_bind_TrimeshPrimitiveManager_get_vertex_2=function(){return(Co=b._emscripten_bind_TrimeshPrimitiveManager_get_vertex_2=b.asm.vm).apply(null,arguments)},Do=b._emscripten_bind_TrimeshPrimitiveManager_get_bullet_triangle_2=function(){return(Do=b._emscripten_bind_TrimeshPrimitiveManager_get_bullet_triangle_2=b.asm.wm).apply(null,arguments)},Eo=b._emscripten_bind_TrimeshPrimitiveManager_get_m_margin_0=function(){return(Eo=b._emscripten_bind_TrimeshPrimitiveManager_get_m_margin_0= -b.asm.xm).apply(null,arguments)},Fo=b._emscripten_bind_TrimeshPrimitiveManager_set_m_margin_1=function(){return(Fo=b._emscripten_bind_TrimeshPrimitiveManager_set_m_margin_1=b.asm.ym).apply(null,arguments)},Go=b._emscripten_bind_TrimeshPrimitiveManager_get_m_meshInterface_0=function(){return(Go=b._emscripten_bind_TrimeshPrimitiveManager_get_m_meshInterface_0=b.asm.zm).apply(null,arguments)},Ho=b._emscripten_bind_TrimeshPrimitiveManager_set_m_meshInterface_1=function(){return(Ho=b._emscripten_bind_TrimeshPrimitiveManager_set_m_meshInterface_1= -b.asm.Am).apply(null,arguments)},Io=b._emscripten_bind_TrimeshPrimitiveManager_get_m_part_0=function(){return(Io=b._emscripten_bind_TrimeshPrimitiveManager_get_m_part_0=b.asm.Bm).apply(null,arguments)},Jo=b._emscripten_bind_TrimeshPrimitiveManager_set_m_part_1=function(){return(Jo=b._emscripten_bind_TrimeshPrimitiveManager_set_m_part_1=b.asm.Cm).apply(null,arguments)},Ko=b._emscripten_bind_TrimeshPrimitiveManager_get_m_lock_count_0=function(){return(Ko=b._emscripten_bind_TrimeshPrimitiveManager_get_m_lock_count_0= -b.asm.Dm).apply(null,arguments)},Lo=b._emscripten_bind_TrimeshPrimitiveManager_set_m_lock_count_1=function(){return(Lo=b._emscripten_bind_TrimeshPrimitiveManager_set_m_lock_count_1=b.asm.Em).apply(null,arguments)},Mo=b._emscripten_bind_TrimeshPrimitiveManager_get_numverts_0=function(){return(Mo=b._emscripten_bind_TrimeshPrimitiveManager_get_numverts_0=b.asm.Fm).apply(null,arguments)},No=b._emscripten_bind_TrimeshPrimitiveManager_set_numverts_1=function(){return(No=b._emscripten_bind_TrimeshPrimitiveManager_set_numverts_1= -b.asm.Gm).apply(null,arguments)},Oo=b._emscripten_bind_TrimeshPrimitiveManager_get_type_0=function(){return(Oo=b._emscripten_bind_TrimeshPrimitiveManager_get_type_0=b.asm.Hm).apply(null,arguments)},Po=b._emscripten_bind_TrimeshPrimitiveManager_set_type_1=function(){return(Po=b._emscripten_bind_TrimeshPrimitiveManager_set_type_1=b.asm.Im).apply(null,arguments)},Qo=b._emscripten_bind_TrimeshPrimitiveManager_get_stride_0=function(){return(Qo=b._emscripten_bind_TrimeshPrimitiveManager_get_stride_0=b.asm.Jm).apply(null, -arguments)},Ro=b._emscripten_bind_TrimeshPrimitiveManager_set_stride_1=function(){return(Ro=b._emscripten_bind_TrimeshPrimitiveManager_set_stride_1=b.asm.Km).apply(null,arguments)},So=b._emscripten_bind_TrimeshPrimitiveManager_get_indexstride_0=function(){return(So=b._emscripten_bind_TrimeshPrimitiveManager_get_indexstride_0=b.asm.Lm).apply(null,arguments)},To=b._emscripten_bind_TrimeshPrimitiveManager_set_indexstride_1=function(){return(To=b._emscripten_bind_TrimeshPrimitiveManager_set_indexstride_1= -b.asm.Mm).apply(null,arguments)},Uo=b._emscripten_bind_TrimeshPrimitiveManager_get_numfaces_0=function(){return(Uo=b._emscripten_bind_TrimeshPrimitiveManager_get_numfaces_0=b.asm.Nm).apply(null,arguments)},Vo=b._emscripten_bind_TrimeshPrimitiveManager_set_numfaces_1=function(){return(Vo=b._emscripten_bind_TrimeshPrimitiveManager_set_numfaces_1=b.asm.Om).apply(null,arguments)},Wo=b._emscripten_bind_TrimeshPrimitiveManager_get_indicestype_0=function(){return(Wo=b._emscripten_bind_TrimeshPrimitiveManager_get_indicestype_0= -b.asm.Pm).apply(null,arguments)},Xo=b._emscripten_bind_TrimeshPrimitiveManager_set_indicestype_1=function(){return(Xo=b._emscripten_bind_TrimeshPrimitiveManager_set_indicestype_1=b.asm.Qm).apply(null,arguments)},Yo=b._emscripten_bind_TrimeshPrimitiveManager___destroy___0=function(){return(Yo=b._emscripten_bind_TrimeshPrimitiveManager___destroy___0=b.asm.Rm).apply(null,arguments)},Zo=b._emscripten_bind_btGImpactMeshShapePart_btGImpactMeshShapePart_2=function(){return(Zo=b._emscripten_bind_btGImpactMeshShapePart_btGImpactMeshShapePart_2= -b.asm.Sm).apply(null,arguments)},$o=b._emscripten_bind_btGImpactMeshShapePart_getTrimeshPrimitiveManager_0=function(){return($o=b._emscripten_bind_btGImpactMeshShapePart_getTrimeshPrimitiveManager_0=b.asm.Tm).apply(null,arguments)},ap=b._emscripten_bind_btGImpactMeshShapePart_getVertexCount_0=function(){return(ap=b._emscripten_bind_btGImpactMeshShapePart_getVertexCount_0=b.asm.Um).apply(null,arguments)},bp=b._emscripten_bind_btGImpactMeshShapePart_getVertex_2=function(){return(bp=b._emscripten_bind_btGImpactMeshShapePart_getVertex_2= -b.asm.Vm).apply(null,arguments)},cp=b._emscripten_bind_btGImpactMeshShapePart_getPart_0=function(){return(cp=b._emscripten_bind_btGImpactMeshShapePart_getPart_0=b.asm.Wm).apply(null,arguments)},dp=b._emscripten_bind_btGImpactMeshShapePart_setLocalScaling_1=function(){return(dp=b._emscripten_bind_btGImpactMeshShapePart_setLocalScaling_1=b.asm.Xm).apply(null,arguments)},ep=b._emscripten_bind_btGImpactMeshShapePart_getLocalScaling_0=function(){return(ep=b._emscripten_bind_btGImpactMeshShapePart_getLocalScaling_0= -b.asm.Ym).apply(null,arguments)},fp=b._emscripten_bind_btGImpactMeshShapePart_updateBound_0=function(){return(fp=b._emscripten_bind_btGImpactMeshShapePart_updateBound_0=b.asm.Zm).apply(null,arguments)},gp=b._emscripten_bind_btGImpactMeshShapePart_postUpdate_0=function(){return(gp=b._emscripten_bind_btGImpactMeshShapePart_postUpdate_0=b.asm._m).apply(null,arguments)},hp=b._emscripten_bind_btGImpactMeshShapePart_getShapeType_0=function(){return(hp=b._emscripten_bind_btGImpactMeshShapePart_getShapeType_0= -b.asm.$m).apply(null,arguments)},ip=b._emscripten_bind_btGImpactMeshShapePart_needsRetrieveTriangles_0=function(){return(ip=b._emscripten_bind_btGImpactMeshShapePart_needsRetrieveTriangles_0=b.asm.an).apply(null,arguments)},jp=b._emscripten_bind_btGImpactMeshShapePart_needsRetrieveTetrahedrons_0=function(){return(jp=b._emscripten_bind_btGImpactMeshShapePart_needsRetrieveTetrahedrons_0=b.asm.bn).apply(null,arguments)},kp=b._emscripten_bind_btGImpactMeshShapePart_getBulletTriangle_2=function(){return(kp= -b._emscripten_bind_btGImpactMeshShapePart_getBulletTriangle_2=b.asm.cn).apply(null,arguments)},lp=b._emscripten_bind_btGImpactMeshShapePart_getBulletTetrahedron_2=function(){return(lp=b._emscripten_bind_btGImpactMeshShapePart_getBulletTetrahedron_2=b.asm.dn).apply(null,arguments)},mp=b._emscripten_bind_btGImpactMeshShapePart___destroy___0=function(){return(mp=b._emscripten_bind_btGImpactMeshShapePart___destroy___0=b.asm.en).apply(null,arguments)},np=b._emscripten_bind_btGImpactMeshShape_btGImpactMeshShape_1= -function(){return(np=b._emscripten_bind_btGImpactMeshShape_btGImpactMeshShape_1=b.asm.fn).apply(null,arguments)},op=b._emscripten_bind_btGImpactMeshShape_getMeshInterface_0=function(){return(op=b._emscripten_bind_btGImpactMeshShape_getMeshInterface_0=b.asm.gn).apply(null,arguments)},pp=b._emscripten_bind_btGImpactMeshShape_getMeshPartCount_0=function(){return(pp=b._emscripten_bind_btGImpactMeshShape_getMeshPartCount_0=b.asm.hn).apply(null,arguments)},qp=b._emscripten_bind_btGImpactMeshShape_getMeshPart_1= -function(){return(qp=b._emscripten_bind_btGImpactMeshShape_getMeshPart_1=b.asm.jn).apply(null,arguments)},rp=b._emscripten_bind_btGImpactMeshShape_calculateSerializeBufferSize_0=function(){return(rp=b._emscripten_bind_btGImpactMeshShape_calculateSerializeBufferSize_0=b.asm.kn).apply(null,arguments)},sp=b._emscripten_bind_btGImpactMeshShape_setLocalScaling_1=function(){return(sp=b._emscripten_bind_btGImpactMeshShape_setLocalScaling_1=b.asm.ln).apply(null,arguments)},tp=b._emscripten_bind_btGImpactMeshShape_getLocalScaling_0= -function(){return(tp=b._emscripten_bind_btGImpactMeshShape_getLocalScaling_0=b.asm.mn).apply(null,arguments)},up=b._emscripten_bind_btGImpactMeshShape_updateBound_0=function(){return(up=b._emscripten_bind_btGImpactMeshShape_updateBound_0=b.asm.nn).apply(null,arguments)},vp=b._emscripten_bind_btGImpactMeshShape_postUpdate_0=function(){return(vp=b._emscripten_bind_btGImpactMeshShape_postUpdate_0=b.asm.on).apply(null,arguments)},wp=b._emscripten_bind_btGImpactMeshShape_getShapeType_0=function(){return(wp= -b._emscripten_bind_btGImpactMeshShape_getShapeType_0=b.asm.pn).apply(null,arguments)},xp=b._emscripten_bind_btGImpactMeshShape_needsRetrieveTriangles_0=function(){return(xp=b._emscripten_bind_btGImpactMeshShape_needsRetrieveTriangles_0=b.asm.qn).apply(null,arguments)},yp=b._emscripten_bind_btGImpactMeshShape_needsRetrieveTetrahedrons_0=function(){return(yp=b._emscripten_bind_btGImpactMeshShape_needsRetrieveTetrahedrons_0=b.asm.rn).apply(null,arguments)},zp=b._emscripten_bind_btGImpactMeshShape_getBulletTriangle_2= -function(){return(zp=b._emscripten_bind_btGImpactMeshShape_getBulletTriangle_2=b.asm.sn).apply(null,arguments)},Ap=b._emscripten_bind_btGImpactMeshShape_getBulletTetrahedron_2=function(){return(Ap=b._emscripten_bind_btGImpactMeshShape_getBulletTetrahedron_2=b.asm.tn).apply(null,arguments)},Bp=b._emscripten_bind_btGImpactMeshShape___destroy___0=function(){return(Bp=b._emscripten_bind_btGImpactMeshShape___destroy___0=b.asm.un).apply(null,arguments)},Cp=b._emscripten_bind_btCollisionAlgorithmConstructionInfo_btCollisionAlgorithmConstructionInfo_0= -function(){return(Cp=b._emscripten_bind_btCollisionAlgorithmConstructionInfo_btCollisionAlgorithmConstructionInfo_0=b.asm.vn).apply(null,arguments)},Dp=b._emscripten_bind_btCollisionAlgorithmConstructionInfo_btCollisionAlgorithmConstructionInfo_2=function(){return(Dp=b._emscripten_bind_btCollisionAlgorithmConstructionInfo_btCollisionAlgorithmConstructionInfo_2=b.asm.wn).apply(null,arguments)},Ep=b._emscripten_bind_btCollisionAlgorithmConstructionInfo_get_m_dispatcher1_0=function(){return(Ep=b._emscripten_bind_btCollisionAlgorithmConstructionInfo_get_m_dispatcher1_0= -b.asm.xn).apply(null,arguments)},Fp=b._emscripten_bind_btCollisionAlgorithmConstructionInfo_set_m_dispatcher1_1=function(){return(Fp=b._emscripten_bind_btCollisionAlgorithmConstructionInfo_set_m_dispatcher1_1=b.asm.yn).apply(null,arguments)},Gp=b._emscripten_bind_btCollisionAlgorithmConstructionInfo_get_m_manifold_0=function(){return(Gp=b._emscripten_bind_btCollisionAlgorithmConstructionInfo_get_m_manifold_0=b.asm.zn).apply(null,arguments)},Hp=b._emscripten_bind_btCollisionAlgorithmConstructionInfo_set_m_manifold_1= -function(){return(Hp=b._emscripten_bind_btCollisionAlgorithmConstructionInfo_set_m_manifold_1=b.asm.An).apply(null,arguments)},Ip=b._emscripten_bind_btCollisionAlgorithmConstructionInfo___destroy___0=function(){return(Ip=b._emscripten_bind_btCollisionAlgorithmConstructionInfo___destroy___0=b.asm.Bn).apply(null,arguments)},Jp=b._emscripten_bind_btGImpactCollisionAlgorithm_btGImpactCollisionAlgorithm_3=function(){return(Jp=b._emscripten_bind_btGImpactCollisionAlgorithm_btGImpactCollisionAlgorithm_3= -b.asm.Cn).apply(null,arguments)},Kp=b._emscripten_bind_btGImpactCollisionAlgorithm_registerAlgorithm_1=function(){return(Kp=b._emscripten_bind_btGImpactCollisionAlgorithm_registerAlgorithm_1=b.asm.Dn).apply(null,arguments)},Lp=b._emscripten_bind_btGImpactCollisionAlgorithm___destroy___0=function(){return(Lp=b._emscripten_bind_btGImpactCollisionAlgorithm___destroy___0=b.asm.En).apply(null,arguments)},Mp=b._emscripten_bind_btDefaultCollisionConstructionInfo_btDefaultCollisionConstructionInfo_0=function(){return(Mp= -b._emscripten_bind_btDefaultCollisionConstructionInfo_btDefaultCollisionConstructionInfo_0=b.asm.Fn).apply(null,arguments)},Np=b._emscripten_bind_btDefaultCollisionConstructionInfo___destroy___0=function(){return(Np=b._emscripten_bind_btDefaultCollisionConstructionInfo___destroy___0=b.asm.Gn).apply(null,arguments)},Op=b._emscripten_bind_btPersistentManifold_btPersistentManifold_0=function(){return(Op=b._emscripten_bind_btPersistentManifold_btPersistentManifold_0=b.asm.Hn).apply(null,arguments)},Pp= -b._emscripten_bind_btPersistentManifold_getBody0_0=function(){return(Pp=b._emscripten_bind_btPersistentManifold_getBody0_0=b.asm.In).apply(null,arguments)},Qp=b._emscripten_bind_btPersistentManifold_getBody1_0=function(){return(Qp=b._emscripten_bind_btPersistentManifold_getBody1_0=b.asm.Jn).apply(null,arguments)},Rp=b._emscripten_bind_btPersistentManifold_getNumContacts_0=function(){return(Rp=b._emscripten_bind_btPersistentManifold_getNumContacts_0=b.asm.Kn).apply(null,arguments)},Sp=b._emscripten_bind_btPersistentManifold_getContactPoint_1= -function(){return(Sp=b._emscripten_bind_btPersistentManifold_getContactPoint_1=b.asm.Ln).apply(null,arguments)},Tp=b._emscripten_bind_btPersistentManifold___destroy___0=function(){return(Tp=b._emscripten_bind_btPersistentManifold___destroy___0=b.asm.Mn).apply(null,arguments)},Up=b._emscripten_bind_btCollisionDispatcher_btCollisionDispatcher_1=function(){return(Up=b._emscripten_bind_btCollisionDispatcher_btCollisionDispatcher_1=b.asm.Nn).apply(null,arguments)},Vp=b._emscripten_bind_btCollisionDispatcher_getNumManifolds_0= -function(){return(Vp=b._emscripten_bind_btCollisionDispatcher_getNumManifolds_0=b.asm.On).apply(null,arguments)},Wp=b._emscripten_bind_btCollisionDispatcher_getManifoldByIndexInternal_1=function(){return(Wp=b._emscripten_bind_btCollisionDispatcher_getManifoldByIndexInternal_1=b.asm.Pn).apply(null,arguments)},Xp=b._emscripten_bind_btCollisionDispatcher___destroy___0=function(){return(Xp=b._emscripten_bind_btCollisionDispatcher___destroy___0=b.asm.Qn).apply(null,arguments)},Yp=b._emscripten_bind_btOverlappingPairCallback___destroy___0= -function(){return(Yp=b._emscripten_bind_btOverlappingPairCallback___destroy___0=b.asm.Rn).apply(null,arguments)},Zp=b._emscripten_bind_btOverlappingPairCache_setInternalGhostPairCallback_1=function(){return(Zp=b._emscripten_bind_btOverlappingPairCache_setInternalGhostPairCallback_1=b.asm.Sn).apply(null,arguments)},$p=b._emscripten_bind_btOverlappingPairCache_getNumOverlappingPairs_0=function(){return($p=b._emscripten_bind_btOverlappingPairCache_getNumOverlappingPairs_0=b.asm.Tn).apply(null,arguments)}, -aq=b._emscripten_bind_btOverlappingPairCache___destroy___0=function(){return(aq=b._emscripten_bind_btOverlappingPairCache___destroy___0=b.asm.Un).apply(null,arguments)},bq=b._emscripten_bind_btAxisSweep3_btAxisSweep3_2=function(){return(bq=b._emscripten_bind_btAxisSweep3_btAxisSweep3_2=b.asm.Vn).apply(null,arguments)},cq=b._emscripten_bind_btAxisSweep3_btAxisSweep3_3=function(){return(cq=b._emscripten_bind_btAxisSweep3_btAxisSweep3_3=b.asm.Wn).apply(null,arguments)},dq=b._emscripten_bind_btAxisSweep3_btAxisSweep3_4= -function(){return(dq=b._emscripten_bind_btAxisSweep3_btAxisSweep3_4=b.asm.Xn).apply(null,arguments)},eq=b._emscripten_bind_btAxisSweep3_btAxisSweep3_5=function(){return(eq=b._emscripten_bind_btAxisSweep3_btAxisSweep3_5=b.asm.Yn).apply(null,arguments)},fq=b._emscripten_bind_btAxisSweep3___destroy___0=function(){return(fq=b._emscripten_bind_btAxisSweep3___destroy___0=b.asm.Zn).apply(null,arguments)},gq=b._emscripten_bind_btBroadphaseInterface_getOverlappingPairCache_0=function(){return(gq=b._emscripten_bind_btBroadphaseInterface_getOverlappingPairCache_0= -b.asm._n).apply(null,arguments)},hq=b._emscripten_bind_btBroadphaseInterface___destroy___0=function(){return(hq=b._emscripten_bind_btBroadphaseInterface___destroy___0=b.asm.$n).apply(null,arguments)},iq=b._emscripten_bind_btCollisionConfiguration___destroy___0=function(){return(iq=b._emscripten_bind_btCollisionConfiguration___destroy___0=b.asm.ao).apply(null,arguments)},jq=b._emscripten_bind_btDbvtBroadphase_btDbvtBroadphase_0=function(){return(jq=b._emscripten_bind_btDbvtBroadphase_btDbvtBroadphase_0= -b.asm.bo).apply(null,arguments)},kq=b._emscripten_bind_btDbvtBroadphase___destroy___0=function(){return(kq=b._emscripten_bind_btDbvtBroadphase___destroy___0=b.asm.co).apply(null,arguments)},lq=b._emscripten_bind_btBroadphaseProxy_get_m_collisionFilterGroup_0=function(){return(lq=b._emscripten_bind_btBroadphaseProxy_get_m_collisionFilterGroup_0=b.asm.eo).apply(null,arguments)},mq=b._emscripten_bind_btBroadphaseProxy_set_m_collisionFilterGroup_1=function(){return(mq=b._emscripten_bind_btBroadphaseProxy_set_m_collisionFilterGroup_1= -b.asm.fo).apply(null,arguments)},nq=b._emscripten_bind_btBroadphaseProxy_get_m_collisionFilterMask_0=function(){return(nq=b._emscripten_bind_btBroadphaseProxy_get_m_collisionFilterMask_0=b.asm.go).apply(null,arguments)},oq=b._emscripten_bind_btBroadphaseProxy_set_m_collisionFilterMask_1=function(){return(oq=b._emscripten_bind_btBroadphaseProxy_set_m_collisionFilterMask_1=b.asm.ho).apply(null,arguments)},pq=b._emscripten_bind_btBroadphaseProxy___destroy___0=function(){return(pq=b._emscripten_bind_btBroadphaseProxy___destroy___0= -b.asm.io).apply(null,arguments)},qq=b._emscripten_bind_btRigidBodyConstructionInfo_btRigidBodyConstructionInfo_3=function(){return(qq=b._emscripten_bind_btRigidBodyConstructionInfo_btRigidBodyConstructionInfo_3=b.asm.jo).apply(null,arguments)},rq=b._emscripten_bind_btRigidBodyConstructionInfo_btRigidBodyConstructionInfo_4=function(){return(rq=b._emscripten_bind_btRigidBodyConstructionInfo_btRigidBodyConstructionInfo_4=b.asm.ko).apply(null,arguments)},sq=b._emscripten_bind_btRigidBodyConstructionInfo_get_m_linearDamping_0= -function(){return(sq=b._emscripten_bind_btRigidBodyConstructionInfo_get_m_linearDamping_0=b.asm.lo).apply(null,arguments)},tq=b._emscripten_bind_btRigidBodyConstructionInfo_set_m_linearDamping_1=function(){return(tq=b._emscripten_bind_btRigidBodyConstructionInfo_set_m_linearDamping_1=b.asm.mo).apply(null,arguments)},uq=b._emscripten_bind_btRigidBodyConstructionInfo_get_m_angularDamping_0=function(){return(uq=b._emscripten_bind_btRigidBodyConstructionInfo_get_m_angularDamping_0=b.asm.no).apply(null, -arguments)},vq=b._emscripten_bind_btRigidBodyConstructionInfo_set_m_angularDamping_1=function(){return(vq=b._emscripten_bind_btRigidBodyConstructionInfo_set_m_angularDamping_1=b.asm.oo).apply(null,arguments)},wq=b._emscripten_bind_btRigidBodyConstructionInfo_get_m_friction_0=function(){return(wq=b._emscripten_bind_btRigidBodyConstructionInfo_get_m_friction_0=b.asm.po).apply(null,arguments)},xq=b._emscripten_bind_btRigidBodyConstructionInfo_set_m_friction_1=function(){return(xq=b._emscripten_bind_btRigidBodyConstructionInfo_set_m_friction_1= -b.asm.qo).apply(null,arguments)},yq=b._emscripten_bind_btRigidBodyConstructionInfo_get_m_rollingFriction_0=function(){return(yq=b._emscripten_bind_btRigidBodyConstructionInfo_get_m_rollingFriction_0=b.asm.ro).apply(null,arguments)},zq=b._emscripten_bind_btRigidBodyConstructionInfo_set_m_rollingFriction_1=function(){return(zq=b._emscripten_bind_btRigidBodyConstructionInfo_set_m_rollingFriction_1=b.asm.so).apply(null,arguments)},Aq=b._emscripten_bind_btRigidBodyConstructionInfo_get_m_restitution_0= -function(){return(Aq=b._emscripten_bind_btRigidBodyConstructionInfo_get_m_restitution_0=b.asm.to).apply(null,arguments)},Bq=b._emscripten_bind_btRigidBodyConstructionInfo_set_m_restitution_1=function(){return(Bq=b._emscripten_bind_btRigidBodyConstructionInfo_set_m_restitution_1=b.asm.uo).apply(null,arguments)},Cq=b._emscripten_bind_btRigidBodyConstructionInfo_get_m_linearSleepingThreshold_0=function(){return(Cq=b._emscripten_bind_btRigidBodyConstructionInfo_get_m_linearSleepingThreshold_0=b.asm.vo).apply(null, -arguments)},Dq=b._emscripten_bind_btRigidBodyConstructionInfo_set_m_linearSleepingThreshold_1=function(){return(Dq=b._emscripten_bind_btRigidBodyConstructionInfo_set_m_linearSleepingThreshold_1=b.asm.wo).apply(null,arguments)},Eq=b._emscripten_bind_btRigidBodyConstructionInfo_get_m_angularSleepingThreshold_0=function(){return(Eq=b._emscripten_bind_btRigidBodyConstructionInfo_get_m_angularSleepingThreshold_0=b.asm.xo).apply(null,arguments)},Fq=b._emscripten_bind_btRigidBodyConstructionInfo_set_m_angularSleepingThreshold_1= -function(){return(Fq=b._emscripten_bind_btRigidBodyConstructionInfo_set_m_angularSleepingThreshold_1=b.asm.yo).apply(null,arguments)},Gq=b._emscripten_bind_btRigidBodyConstructionInfo_get_m_additionalDamping_0=function(){return(Gq=b._emscripten_bind_btRigidBodyConstructionInfo_get_m_additionalDamping_0=b.asm.zo).apply(null,arguments)},Hq=b._emscripten_bind_btRigidBodyConstructionInfo_set_m_additionalDamping_1=function(){return(Hq=b._emscripten_bind_btRigidBodyConstructionInfo_set_m_additionalDamping_1= -b.asm.Ao).apply(null,arguments)},Iq=b._emscripten_bind_btRigidBodyConstructionInfo_get_m_additionalDampingFactor_0=function(){return(Iq=b._emscripten_bind_btRigidBodyConstructionInfo_get_m_additionalDampingFactor_0=b.asm.Bo).apply(null,arguments)},Jq=b._emscripten_bind_btRigidBodyConstructionInfo_set_m_additionalDampingFactor_1=function(){return(Jq=b._emscripten_bind_btRigidBodyConstructionInfo_set_m_additionalDampingFactor_1=b.asm.Co).apply(null,arguments)},Kq=b._emscripten_bind_btRigidBodyConstructionInfo_get_m_additionalLinearDampingThresholdSqr_0= -function(){return(Kq=b._emscripten_bind_btRigidBodyConstructionInfo_get_m_additionalLinearDampingThresholdSqr_0=b.asm.Do).apply(null,arguments)},Lq=b._emscripten_bind_btRigidBodyConstructionInfo_set_m_additionalLinearDampingThresholdSqr_1=function(){return(Lq=b._emscripten_bind_btRigidBodyConstructionInfo_set_m_additionalLinearDampingThresholdSqr_1=b.asm.Eo).apply(null,arguments)},Mq=b._emscripten_bind_btRigidBodyConstructionInfo_get_m_additionalAngularDampingThresholdSqr_0=function(){return(Mq=b._emscripten_bind_btRigidBodyConstructionInfo_get_m_additionalAngularDampingThresholdSqr_0= -b.asm.Fo).apply(null,arguments)},Nq=b._emscripten_bind_btRigidBodyConstructionInfo_set_m_additionalAngularDampingThresholdSqr_1=function(){return(Nq=b._emscripten_bind_btRigidBodyConstructionInfo_set_m_additionalAngularDampingThresholdSqr_1=b.asm.Go).apply(null,arguments)},Oq=b._emscripten_bind_btRigidBodyConstructionInfo_get_m_additionalAngularDampingFactor_0=function(){return(Oq=b._emscripten_bind_btRigidBodyConstructionInfo_get_m_additionalAngularDampingFactor_0=b.asm.Ho).apply(null,arguments)}, -Pq=b._emscripten_bind_btRigidBodyConstructionInfo_set_m_additionalAngularDampingFactor_1=function(){return(Pq=b._emscripten_bind_btRigidBodyConstructionInfo_set_m_additionalAngularDampingFactor_1=b.asm.Io).apply(null,arguments)},Qq=b._emscripten_bind_btRigidBodyConstructionInfo___destroy___0=function(){return(Qq=b._emscripten_bind_btRigidBodyConstructionInfo___destroy___0=b.asm.Jo).apply(null,arguments)},Rq=b._emscripten_bind_btRigidBody_btRigidBody_1=function(){return(Rq=b._emscripten_bind_btRigidBody_btRigidBody_1= -b.asm.Ko).apply(null,arguments)},Sq=b._emscripten_bind_btRigidBody_getCenterOfMassTransform_0=function(){return(Sq=b._emscripten_bind_btRigidBody_getCenterOfMassTransform_0=b.asm.Lo).apply(null,arguments)},Tq=b._emscripten_bind_btRigidBody_setCenterOfMassTransform_1=function(){return(Tq=b._emscripten_bind_btRigidBody_setCenterOfMassTransform_1=b.asm.Mo).apply(null,arguments)},Uq=b._emscripten_bind_btRigidBody_setSleepingThresholds_2=function(){return(Uq=b._emscripten_bind_btRigidBody_setSleepingThresholds_2= -b.asm.No).apply(null,arguments)},Vq=b._emscripten_bind_btRigidBody_getLinearDamping_0=function(){return(Vq=b._emscripten_bind_btRigidBody_getLinearDamping_0=b.asm.Oo).apply(null,arguments)},Wq=b._emscripten_bind_btRigidBody_getAngularDamping_0=function(){return(Wq=b._emscripten_bind_btRigidBody_getAngularDamping_0=b.asm.Po).apply(null,arguments)},Xq=b._emscripten_bind_btRigidBody_setDamping_2=function(){return(Xq=b._emscripten_bind_btRigidBody_setDamping_2=b.asm.Qo).apply(null,arguments)},Yq=b._emscripten_bind_btRigidBody_setMassProps_2= -function(){return(Yq=b._emscripten_bind_btRigidBody_setMassProps_2=b.asm.Ro).apply(null,arguments)},Zq=b._emscripten_bind_btRigidBody_getLinearFactor_0=function(){return(Zq=b._emscripten_bind_btRigidBody_getLinearFactor_0=b.asm.So).apply(null,arguments)},$q=b._emscripten_bind_btRigidBody_setLinearFactor_1=function(){return($q=b._emscripten_bind_btRigidBody_setLinearFactor_1=b.asm.To).apply(null,arguments)},ar=b._emscripten_bind_btRigidBody_applyTorque_1=function(){return(ar=b._emscripten_bind_btRigidBody_applyTorque_1= -b.asm.Uo).apply(null,arguments)},br=b._emscripten_bind_btRigidBody_applyLocalTorque_1=function(){return(br=b._emscripten_bind_btRigidBody_applyLocalTorque_1=b.asm.Vo).apply(null,arguments)},cr=b._emscripten_bind_btRigidBody_applyForce_2=function(){return(cr=b._emscripten_bind_btRigidBody_applyForce_2=b.asm.Wo).apply(null,arguments)},dr=b._emscripten_bind_btRigidBody_applyCentralForce_1=function(){return(dr=b._emscripten_bind_btRigidBody_applyCentralForce_1=b.asm.Xo).apply(null,arguments)},er=b._emscripten_bind_btRigidBody_applyCentralLocalForce_1= -function(){return(er=b._emscripten_bind_btRigidBody_applyCentralLocalForce_1=b.asm.Yo).apply(null,arguments)},fr=b._emscripten_bind_btRigidBody_applyTorqueImpulse_1=function(){return(fr=b._emscripten_bind_btRigidBody_applyTorqueImpulse_1=b.asm.Zo).apply(null,arguments)},gr=b._emscripten_bind_btRigidBody_applyImpulse_2=function(){return(gr=b._emscripten_bind_btRigidBody_applyImpulse_2=b.asm._o).apply(null,arguments)},hr=b._emscripten_bind_btRigidBody_applyCentralImpulse_1=function(){return(hr=b._emscripten_bind_btRigidBody_applyCentralImpulse_1= -b.asm.$o).apply(null,arguments)},ir=b._emscripten_bind_btRigidBody_updateInertiaTensor_0=function(){return(ir=b._emscripten_bind_btRigidBody_updateInertiaTensor_0=b.asm.ap).apply(null,arguments)},jr=b._emscripten_bind_btRigidBody_getLinearVelocity_0=function(){return(jr=b._emscripten_bind_btRigidBody_getLinearVelocity_0=b.asm.bp).apply(null,arguments)},kr=b._emscripten_bind_btRigidBody_getAngularVelocity_0=function(){return(kr=b._emscripten_bind_btRigidBody_getAngularVelocity_0=b.asm.cp).apply(null, -arguments)},lr=b._emscripten_bind_btRigidBody_setLinearVelocity_1=function(){return(lr=b._emscripten_bind_btRigidBody_setLinearVelocity_1=b.asm.dp).apply(null,arguments)},mr=b._emscripten_bind_btRigidBody_setAngularVelocity_1=function(){return(mr=b._emscripten_bind_btRigidBody_setAngularVelocity_1=b.asm.ep).apply(null,arguments)},nr=b._emscripten_bind_btRigidBody_getMotionState_0=function(){return(nr=b._emscripten_bind_btRigidBody_getMotionState_0=b.asm.fp).apply(null,arguments)},or=b._emscripten_bind_btRigidBody_setMotionState_1= -function(){return(or=b._emscripten_bind_btRigidBody_setMotionState_1=b.asm.gp).apply(null,arguments)},pr=b._emscripten_bind_btRigidBody_getAngularFactor_0=function(){return(pr=b._emscripten_bind_btRigidBody_getAngularFactor_0=b.asm.hp).apply(null,arguments)},qr=b._emscripten_bind_btRigidBody_setAngularFactor_1=function(){return(qr=b._emscripten_bind_btRigidBody_setAngularFactor_1=b.asm.ip).apply(null,arguments)},rr=b._emscripten_bind_btRigidBody_upcast_1=function(){return(rr=b._emscripten_bind_btRigidBody_upcast_1= -b.asm.jp).apply(null,arguments)},sr=b._emscripten_bind_btRigidBody_getAabb_2=function(){return(sr=b._emscripten_bind_btRigidBody_getAabb_2=b.asm.kp).apply(null,arguments)},tr=b._emscripten_bind_btRigidBody_applyGravity_0=function(){return(tr=b._emscripten_bind_btRigidBody_applyGravity_0=b.asm.lp).apply(null,arguments)},ur=b._emscripten_bind_btRigidBody_getGravity_0=function(){return(ur=b._emscripten_bind_btRigidBody_getGravity_0=b.asm.mp).apply(null,arguments)},vr=b._emscripten_bind_btRigidBody_setGravity_1= -function(){return(vr=b._emscripten_bind_btRigidBody_setGravity_1=b.asm.np).apply(null,arguments)},wr=b._emscripten_bind_btRigidBody_getBroadphaseProxy_0=function(){return(wr=b._emscripten_bind_btRigidBody_getBroadphaseProxy_0=b.asm.op).apply(null,arguments)},xr=b._emscripten_bind_btRigidBody_clearForces_0=function(){return(xr=b._emscripten_bind_btRigidBody_clearForces_0=b.asm.pp).apply(null,arguments)},yr=b._emscripten_bind_btRigidBody_setFlags_1=function(){return(yr=b._emscripten_bind_btRigidBody_setFlags_1= -b.asm.qp).apply(null,arguments)},zr=b._emscripten_bind_btRigidBody_getFlags_0=function(){return(zr=b._emscripten_bind_btRigidBody_getFlags_0=b.asm.rp).apply(null,arguments)},Ar=b._emscripten_bind_btRigidBody_setAnisotropicFriction_2=function(){return(Ar=b._emscripten_bind_btRigidBody_setAnisotropicFriction_2=b.asm.sp).apply(null,arguments)},Br=b._emscripten_bind_btRigidBody_getCollisionShape_0=function(){return(Br=b._emscripten_bind_btRigidBody_getCollisionShape_0=b.asm.tp).apply(null,arguments)}, -Cr=b._emscripten_bind_btRigidBody_setContactProcessingThreshold_1=function(){return(Cr=b._emscripten_bind_btRigidBody_setContactProcessingThreshold_1=b.asm.up).apply(null,arguments)},Dr=b._emscripten_bind_btRigidBody_setActivationState_1=function(){return(Dr=b._emscripten_bind_btRigidBody_setActivationState_1=b.asm.vp).apply(null,arguments)},Er=b._emscripten_bind_btRigidBody_forceActivationState_1=function(){return(Er=b._emscripten_bind_btRigidBody_forceActivationState_1=b.asm.wp).apply(null,arguments)}, -Fr=b._emscripten_bind_btRigidBody_activate_0=function(){return(Fr=b._emscripten_bind_btRigidBody_activate_0=b.asm.xp).apply(null,arguments)},Gr=b._emscripten_bind_btRigidBody_activate_1=function(){return(Gr=b._emscripten_bind_btRigidBody_activate_1=b.asm.yp).apply(null,arguments)},Hr=b._emscripten_bind_btRigidBody_isActive_0=function(){return(Hr=b._emscripten_bind_btRigidBody_isActive_0=b.asm.zp).apply(null,arguments)},Ir=b._emscripten_bind_btRigidBody_isKinematicObject_0=function(){return(Ir=b._emscripten_bind_btRigidBody_isKinematicObject_0= -b.asm.Ap).apply(null,arguments)},Jr=b._emscripten_bind_btRigidBody_isStaticObject_0=function(){return(Jr=b._emscripten_bind_btRigidBody_isStaticObject_0=b.asm.Bp).apply(null,arguments)},Kr=b._emscripten_bind_btRigidBody_isStaticOrKinematicObject_0=function(){return(Kr=b._emscripten_bind_btRigidBody_isStaticOrKinematicObject_0=b.asm.Cp).apply(null,arguments)},Lr=b._emscripten_bind_btRigidBody_getRestitution_0=function(){return(Lr=b._emscripten_bind_btRigidBody_getRestitution_0=b.asm.Dp).apply(null, -arguments)},Mr=b._emscripten_bind_btRigidBody_getFriction_0=function(){return(Mr=b._emscripten_bind_btRigidBody_getFriction_0=b.asm.Ep).apply(null,arguments)},Nr=b._emscripten_bind_btRigidBody_getRollingFriction_0=function(){return(Nr=b._emscripten_bind_btRigidBody_getRollingFriction_0=b.asm.Fp).apply(null,arguments)},Or=b._emscripten_bind_btRigidBody_setRestitution_1=function(){return(Or=b._emscripten_bind_btRigidBody_setRestitution_1=b.asm.Gp).apply(null,arguments)},Pr=b._emscripten_bind_btRigidBody_setFriction_1= -function(){return(Pr=b._emscripten_bind_btRigidBody_setFriction_1=b.asm.Hp).apply(null,arguments)},Qr=b._emscripten_bind_btRigidBody_setRollingFriction_1=function(){return(Qr=b._emscripten_bind_btRigidBody_setRollingFriction_1=b.asm.Ip).apply(null,arguments)},Rr=b._emscripten_bind_btRigidBody_getWorldTransform_0=function(){return(Rr=b._emscripten_bind_btRigidBody_getWorldTransform_0=b.asm.Jp).apply(null,arguments)},Sr=b._emscripten_bind_btRigidBody_getCollisionFlags_0=function(){return(Sr=b._emscripten_bind_btRigidBody_getCollisionFlags_0= -b.asm.Kp).apply(null,arguments)},Tr=b._emscripten_bind_btRigidBody_setCollisionFlags_1=function(){return(Tr=b._emscripten_bind_btRigidBody_setCollisionFlags_1=b.asm.Lp).apply(null,arguments)},Ur=b._emscripten_bind_btRigidBody_setWorldTransform_1=function(){return(Ur=b._emscripten_bind_btRigidBody_setWorldTransform_1=b.asm.Mp).apply(null,arguments)},Vr=b._emscripten_bind_btRigidBody_setCollisionShape_1=function(){return(Vr=b._emscripten_bind_btRigidBody_setCollisionShape_1=b.asm.Np).apply(null,arguments)}, -Wr=b._emscripten_bind_btRigidBody_setCcdMotionThreshold_1=function(){return(Wr=b._emscripten_bind_btRigidBody_setCcdMotionThreshold_1=b.asm.Op).apply(null,arguments)},Xr=b._emscripten_bind_btRigidBody_setCcdSweptSphereRadius_1=function(){return(Xr=b._emscripten_bind_btRigidBody_setCcdSweptSphereRadius_1=b.asm.Pp).apply(null,arguments)},Yr=b._emscripten_bind_btRigidBody_getUserIndex_0=function(){return(Yr=b._emscripten_bind_btRigidBody_getUserIndex_0=b.asm.Qp).apply(null,arguments)},Zr=b._emscripten_bind_btRigidBody_setUserIndex_1= -function(){return(Zr=b._emscripten_bind_btRigidBody_setUserIndex_1=b.asm.Rp).apply(null,arguments)},$r=b._emscripten_bind_btRigidBody_getUserPointer_0=function(){return($r=b._emscripten_bind_btRigidBody_getUserPointer_0=b.asm.Sp).apply(null,arguments)},as=b._emscripten_bind_btRigidBody_setUserPointer_1=function(){return(as=b._emscripten_bind_btRigidBody_setUserPointer_1=b.asm.Tp).apply(null,arguments)},bs=b._emscripten_bind_btRigidBody_getBroadphaseHandle_0=function(){return(bs=b._emscripten_bind_btRigidBody_getBroadphaseHandle_0= -b.asm.Up).apply(null,arguments)},cs=b._emscripten_bind_btRigidBody___destroy___0=function(){return(cs=b._emscripten_bind_btRigidBody___destroy___0=b.asm.Vp).apply(null,arguments)},ds=b._emscripten_bind_btConstraintSetting_btConstraintSetting_0=function(){return(ds=b._emscripten_bind_btConstraintSetting_btConstraintSetting_0=b.asm.Wp).apply(null,arguments)},es=b._emscripten_bind_btConstraintSetting_get_m_tau_0=function(){return(es=b._emscripten_bind_btConstraintSetting_get_m_tau_0=b.asm.Xp).apply(null, -arguments)},gs=b._emscripten_bind_btConstraintSetting_set_m_tau_1=function(){return(gs=b._emscripten_bind_btConstraintSetting_set_m_tau_1=b.asm.Yp).apply(null,arguments)},hs=b._emscripten_bind_btConstraintSetting_get_m_damping_0=function(){return(hs=b._emscripten_bind_btConstraintSetting_get_m_damping_0=b.asm.Zp).apply(null,arguments)},is=b._emscripten_bind_btConstraintSetting_set_m_damping_1=function(){return(is=b._emscripten_bind_btConstraintSetting_set_m_damping_1=b.asm._p).apply(null,arguments)}, -js=b._emscripten_bind_btConstraintSetting_get_m_impulseClamp_0=function(){return(js=b._emscripten_bind_btConstraintSetting_get_m_impulseClamp_0=b.asm.$p).apply(null,arguments)},ks=b._emscripten_bind_btConstraintSetting_set_m_impulseClamp_1=function(){return(ks=b._emscripten_bind_btConstraintSetting_set_m_impulseClamp_1=b.asm.aq).apply(null,arguments)},ls=b._emscripten_bind_btConstraintSetting___destroy___0=function(){return(ls=b._emscripten_bind_btConstraintSetting___destroy___0=b.asm.bq).apply(null, -arguments)},ms=b._emscripten_bind_btPoint2PointConstraint_btPoint2PointConstraint_2=function(){return(ms=b._emscripten_bind_btPoint2PointConstraint_btPoint2PointConstraint_2=b.asm.cq).apply(null,arguments)},ns=b._emscripten_bind_btPoint2PointConstraint_btPoint2PointConstraint_4=function(){return(ns=b._emscripten_bind_btPoint2PointConstraint_btPoint2PointConstraint_4=b.asm.dq).apply(null,arguments)},ps=b._emscripten_bind_btPoint2PointConstraint_setPivotA_1=function(){return(ps=b._emscripten_bind_btPoint2PointConstraint_setPivotA_1= -b.asm.eq).apply(null,arguments)},qs=b._emscripten_bind_btPoint2PointConstraint_setPivotB_1=function(){return(qs=b._emscripten_bind_btPoint2PointConstraint_setPivotB_1=b.asm.fq).apply(null,arguments)},rs=b._emscripten_bind_btPoint2PointConstraint_getPivotInA_0=function(){return(rs=b._emscripten_bind_btPoint2PointConstraint_getPivotInA_0=b.asm.gq).apply(null,arguments)},ss=b._emscripten_bind_btPoint2PointConstraint_getPivotInB_0=function(){return(ss=b._emscripten_bind_btPoint2PointConstraint_getPivotInB_0= -b.asm.hq).apply(null,arguments)},ts=b._emscripten_bind_btPoint2PointConstraint_enableFeedback_1=function(){return(ts=b._emscripten_bind_btPoint2PointConstraint_enableFeedback_1=b.asm.iq).apply(null,arguments)},us=b._emscripten_bind_btPoint2PointConstraint_getBreakingImpulseThreshold_0=function(){return(us=b._emscripten_bind_btPoint2PointConstraint_getBreakingImpulseThreshold_0=b.asm.jq).apply(null,arguments)},vs=b._emscripten_bind_btPoint2PointConstraint_setBreakingImpulseThreshold_1=function(){return(vs= -b._emscripten_bind_btPoint2PointConstraint_setBreakingImpulseThreshold_1=b.asm.kq).apply(null,arguments)},xs=b._emscripten_bind_btPoint2PointConstraint_getParam_2=function(){return(xs=b._emscripten_bind_btPoint2PointConstraint_getParam_2=b.asm.lq).apply(null,arguments)},ys=b._emscripten_bind_btPoint2PointConstraint_setParam_3=function(){return(ys=b._emscripten_bind_btPoint2PointConstraint_setParam_3=b.asm.mq).apply(null,arguments)},zs=b._emscripten_bind_btPoint2PointConstraint_get_m_setting_0=function(){return(zs= -b._emscripten_bind_btPoint2PointConstraint_get_m_setting_0=b.asm.nq).apply(null,arguments)},As=b._emscripten_bind_btPoint2PointConstraint_set_m_setting_1=function(){return(As=b._emscripten_bind_btPoint2PointConstraint_set_m_setting_1=b.asm.oq).apply(null,arguments)},Bs=b._emscripten_bind_btPoint2PointConstraint___destroy___0=function(){return(Bs=b._emscripten_bind_btPoint2PointConstraint___destroy___0=b.asm.pq).apply(null,arguments)},Cs=b._emscripten_bind_btGeneric6DofSpringConstraint_btGeneric6DofSpringConstraint_3= -function(){return(Cs=b._emscripten_bind_btGeneric6DofSpringConstraint_btGeneric6DofSpringConstraint_3=b.asm.qq).apply(null,arguments)},Ds=b._emscripten_bind_btGeneric6DofSpringConstraint_btGeneric6DofSpringConstraint_5=function(){return(Ds=b._emscripten_bind_btGeneric6DofSpringConstraint_btGeneric6DofSpringConstraint_5=b.asm.rq).apply(null,arguments)},Es=b._emscripten_bind_btGeneric6DofSpringConstraint_enableSpring_2=function(){return(Es=b._emscripten_bind_btGeneric6DofSpringConstraint_enableSpring_2= -b.asm.sq).apply(null,arguments)},Fs=b._emscripten_bind_btGeneric6DofSpringConstraint_setStiffness_2=function(){return(Fs=b._emscripten_bind_btGeneric6DofSpringConstraint_setStiffness_2=b.asm.tq).apply(null,arguments)},Gs=b._emscripten_bind_btGeneric6DofSpringConstraint_setDamping_2=function(){return(Gs=b._emscripten_bind_btGeneric6DofSpringConstraint_setDamping_2=b.asm.uq).apply(null,arguments)},Hs=b._emscripten_bind_btGeneric6DofSpringConstraint_setEquilibriumPoint_0=function(){return(Hs=b._emscripten_bind_btGeneric6DofSpringConstraint_setEquilibriumPoint_0= -b.asm.vq).apply(null,arguments)},Is=b._emscripten_bind_btGeneric6DofSpringConstraint_setEquilibriumPoint_1=function(){return(Is=b._emscripten_bind_btGeneric6DofSpringConstraint_setEquilibriumPoint_1=b.asm.wq).apply(null,arguments)},Js=b._emscripten_bind_btGeneric6DofSpringConstraint_setEquilibriumPoint_2=function(){return(Js=b._emscripten_bind_btGeneric6DofSpringConstraint_setEquilibriumPoint_2=b.asm.xq).apply(null,arguments)},Ks=b._emscripten_bind_btGeneric6DofSpringConstraint_setLinearLowerLimit_1= -function(){return(Ks=b._emscripten_bind_btGeneric6DofSpringConstraint_setLinearLowerLimit_1=b.asm.yq).apply(null,arguments)},Ls=b._emscripten_bind_btGeneric6DofSpringConstraint_setLinearUpperLimit_1=function(){return(Ls=b._emscripten_bind_btGeneric6DofSpringConstraint_setLinearUpperLimit_1=b.asm.zq).apply(null,arguments)},Ms=b._emscripten_bind_btGeneric6DofSpringConstraint_setAngularLowerLimit_1=function(){return(Ms=b._emscripten_bind_btGeneric6DofSpringConstraint_setAngularLowerLimit_1=b.asm.Aq).apply(null, -arguments)},Ns=b._emscripten_bind_btGeneric6DofSpringConstraint_setAngularUpperLimit_1=function(){return(Ns=b._emscripten_bind_btGeneric6DofSpringConstraint_setAngularUpperLimit_1=b.asm.Bq).apply(null,arguments)},Os=b._emscripten_bind_btGeneric6DofSpringConstraint_getFrameOffsetA_0=function(){return(Os=b._emscripten_bind_btGeneric6DofSpringConstraint_getFrameOffsetA_0=b.asm.Cq).apply(null,arguments)},Ps=b._emscripten_bind_btGeneric6DofSpringConstraint_enableFeedback_1=function(){return(Ps=b._emscripten_bind_btGeneric6DofSpringConstraint_enableFeedback_1= -b.asm.Dq).apply(null,arguments)},Qs=b._emscripten_bind_btGeneric6DofSpringConstraint_getBreakingImpulseThreshold_0=function(){return(Qs=b._emscripten_bind_btGeneric6DofSpringConstraint_getBreakingImpulseThreshold_0=b.asm.Eq).apply(null,arguments)},Rs=b._emscripten_bind_btGeneric6DofSpringConstraint_setBreakingImpulseThreshold_1=function(){return(Rs=b._emscripten_bind_btGeneric6DofSpringConstraint_setBreakingImpulseThreshold_1=b.asm.Fq).apply(null,arguments)},Ss=b._emscripten_bind_btGeneric6DofSpringConstraint_getParam_2= -function(){return(Ss=b._emscripten_bind_btGeneric6DofSpringConstraint_getParam_2=b.asm.Gq).apply(null,arguments)},Ts=b._emscripten_bind_btGeneric6DofSpringConstraint_setParam_3=function(){return(Ts=b._emscripten_bind_btGeneric6DofSpringConstraint_setParam_3=b.asm.Hq).apply(null,arguments)},Us=b._emscripten_bind_btGeneric6DofSpringConstraint___destroy___0=function(){return(Us=b._emscripten_bind_btGeneric6DofSpringConstraint___destroy___0=b.asm.Iq).apply(null,arguments)},Vs=b._emscripten_bind_btSequentialImpulseConstraintSolver_btSequentialImpulseConstraintSolver_0= -function(){return(Vs=b._emscripten_bind_btSequentialImpulseConstraintSolver_btSequentialImpulseConstraintSolver_0=b.asm.Jq).apply(null,arguments)},Ws=b._emscripten_bind_btSequentialImpulseConstraintSolver___destroy___0=function(){return(Ws=b._emscripten_bind_btSequentialImpulseConstraintSolver___destroy___0=b.asm.Kq).apply(null,arguments)},Xs=b._emscripten_bind_btConeTwistConstraint_btConeTwistConstraint_2=function(){return(Xs=b._emscripten_bind_btConeTwistConstraint_btConeTwistConstraint_2=b.asm.Lq).apply(null, -arguments)},Ys=b._emscripten_bind_btConeTwistConstraint_btConeTwistConstraint_4=function(){return(Ys=b._emscripten_bind_btConeTwistConstraint_btConeTwistConstraint_4=b.asm.Mq).apply(null,arguments)},Zs=b._emscripten_bind_btConeTwistConstraint_setLimit_2=function(){return(Zs=b._emscripten_bind_btConeTwistConstraint_setLimit_2=b.asm.Nq).apply(null,arguments)},$s=b._emscripten_bind_btConeTwistConstraint_setAngularOnly_1=function(){return($s=b._emscripten_bind_btConeTwistConstraint_setAngularOnly_1=b.asm.Oq).apply(null, -arguments)},at=b._emscripten_bind_btConeTwistConstraint_setDamping_1=function(){return(at=b._emscripten_bind_btConeTwistConstraint_setDamping_1=b.asm.Pq).apply(null,arguments)},bt=b._emscripten_bind_btConeTwistConstraint_enableMotor_1=function(){return(bt=b._emscripten_bind_btConeTwistConstraint_enableMotor_1=b.asm.Qq).apply(null,arguments)},ct=b._emscripten_bind_btConeTwistConstraint_setMaxMotorImpulse_1=function(){return(ct=b._emscripten_bind_btConeTwistConstraint_setMaxMotorImpulse_1=b.asm.Rq).apply(null, -arguments)},dt=b._emscripten_bind_btConeTwistConstraint_setMaxMotorImpulseNormalized_1=function(){return(dt=b._emscripten_bind_btConeTwistConstraint_setMaxMotorImpulseNormalized_1=b.asm.Sq).apply(null,arguments)},et=b._emscripten_bind_btConeTwistConstraint_setMotorTarget_1=function(){return(et=b._emscripten_bind_btConeTwistConstraint_setMotorTarget_1=b.asm.Tq).apply(null,arguments)},ft=b._emscripten_bind_btConeTwistConstraint_setMotorTargetInConstraintSpace_1=function(){return(ft=b._emscripten_bind_btConeTwistConstraint_setMotorTargetInConstraintSpace_1= -b.asm.Uq).apply(null,arguments)},gt=b._emscripten_bind_btConeTwistConstraint_enableFeedback_1=function(){return(gt=b._emscripten_bind_btConeTwistConstraint_enableFeedback_1=b.asm.Vq).apply(null,arguments)},ht=b._emscripten_bind_btConeTwistConstraint_getBreakingImpulseThreshold_0=function(){return(ht=b._emscripten_bind_btConeTwistConstraint_getBreakingImpulseThreshold_0=b.asm.Wq).apply(null,arguments)},it=b._emscripten_bind_btConeTwistConstraint_setBreakingImpulseThreshold_1=function(){return(it=b._emscripten_bind_btConeTwistConstraint_setBreakingImpulseThreshold_1= -b.asm.Xq).apply(null,arguments)},jt=b._emscripten_bind_btConeTwistConstraint_getParam_2=function(){return(jt=b._emscripten_bind_btConeTwistConstraint_getParam_2=b.asm.Yq).apply(null,arguments)},kt=b._emscripten_bind_btConeTwistConstraint_setParam_3=function(){return(kt=b._emscripten_bind_btConeTwistConstraint_setParam_3=b.asm.Zq).apply(null,arguments)},lt=b._emscripten_bind_btConeTwistConstraint___destroy___0=function(){return(lt=b._emscripten_bind_btConeTwistConstraint___destroy___0=b.asm._q).apply(null, -arguments)},mt=b._emscripten_bind_btHingeConstraint_btHingeConstraint_2=function(){return(mt=b._emscripten_bind_btHingeConstraint_btHingeConstraint_2=b.asm.$q).apply(null,arguments)},nt=b._emscripten_bind_btHingeConstraint_btHingeConstraint_3=function(){return(nt=b._emscripten_bind_btHingeConstraint_btHingeConstraint_3=b.asm.ar).apply(null,arguments)},ot=b._emscripten_bind_btHingeConstraint_btHingeConstraint_4=function(){return(ot=b._emscripten_bind_btHingeConstraint_btHingeConstraint_4=b.asm.br).apply(null, -arguments)},pt=b._emscripten_bind_btHingeConstraint_btHingeConstraint_5=function(){return(pt=b._emscripten_bind_btHingeConstraint_btHingeConstraint_5=b.asm.cr).apply(null,arguments)},qt=b._emscripten_bind_btHingeConstraint_btHingeConstraint_6=function(){return(qt=b._emscripten_bind_btHingeConstraint_btHingeConstraint_6=b.asm.dr).apply(null,arguments)},rt=b._emscripten_bind_btHingeConstraint_btHingeConstraint_7=function(){return(rt=b._emscripten_bind_btHingeConstraint_btHingeConstraint_7=b.asm.er).apply(null, -arguments)},st=b._emscripten_bind_btHingeConstraint_getHingeAngle_0=function(){return(st=b._emscripten_bind_btHingeConstraint_getHingeAngle_0=b.asm.fr).apply(null,arguments)},tt=b._emscripten_bind_btHingeConstraint_setLimit_4=function(){return(tt=b._emscripten_bind_btHingeConstraint_setLimit_4=b.asm.gr).apply(null,arguments)},ut=b._emscripten_bind_btHingeConstraint_setLimit_5=function(){return(ut=b._emscripten_bind_btHingeConstraint_setLimit_5=b.asm.hr).apply(null,arguments)},vt=b._emscripten_bind_btHingeConstraint_enableAngularMotor_3= -function(){return(vt=b._emscripten_bind_btHingeConstraint_enableAngularMotor_3=b.asm.ir).apply(null,arguments)},wt=b._emscripten_bind_btHingeConstraint_setAngularOnly_1=function(){return(wt=b._emscripten_bind_btHingeConstraint_setAngularOnly_1=b.asm.jr).apply(null,arguments)},xt=b._emscripten_bind_btHingeConstraint_enableMotor_1=function(){return(xt=b._emscripten_bind_btHingeConstraint_enableMotor_1=b.asm.kr).apply(null,arguments)},yt=b._emscripten_bind_btHingeConstraint_setMaxMotorImpulse_1=function(){return(yt= -b._emscripten_bind_btHingeConstraint_setMaxMotorImpulse_1=b.asm.lr).apply(null,arguments)},zt=b._emscripten_bind_btHingeConstraint_setMotorTarget_2=function(){return(zt=b._emscripten_bind_btHingeConstraint_setMotorTarget_2=b.asm.mr).apply(null,arguments)},At=b._emscripten_bind_btHingeConstraint_enableFeedback_1=function(){return(At=b._emscripten_bind_btHingeConstraint_enableFeedback_1=b.asm.nr).apply(null,arguments)},Bt=b._emscripten_bind_btHingeConstraint_getBreakingImpulseThreshold_0=function(){return(Bt= -b._emscripten_bind_btHingeConstraint_getBreakingImpulseThreshold_0=b.asm.or).apply(null,arguments)},Ct=b._emscripten_bind_btHingeConstraint_setBreakingImpulseThreshold_1=function(){return(Ct=b._emscripten_bind_btHingeConstraint_setBreakingImpulseThreshold_1=b.asm.pr).apply(null,arguments)},Dt=b._emscripten_bind_btHingeConstraint_getParam_2=function(){return(Dt=b._emscripten_bind_btHingeConstraint_getParam_2=b.asm.qr).apply(null,arguments)},Et=b._emscripten_bind_btHingeConstraint_setParam_3=function(){return(Et= -b._emscripten_bind_btHingeConstraint_setParam_3=b.asm.rr).apply(null,arguments)},Ft=b._emscripten_bind_btHingeConstraint___destroy___0=function(){return(Ft=b._emscripten_bind_btHingeConstraint___destroy___0=b.asm.sr).apply(null,arguments)},Gt=b._emscripten_bind_btSliderConstraint_btSliderConstraint_3=function(){return(Gt=b._emscripten_bind_btSliderConstraint_btSliderConstraint_3=b.asm.tr).apply(null,arguments)},Ht=b._emscripten_bind_btSliderConstraint_btSliderConstraint_5=function(){return(Ht=b._emscripten_bind_btSliderConstraint_btSliderConstraint_5= -b.asm.ur).apply(null,arguments)},It=b._emscripten_bind_btSliderConstraint_getLinearPos_0=function(){return(It=b._emscripten_bind_btSliderConstraint_getLinearPos_0=b.asm.vr).apply(null,arguments)},Jt=b._emscripten_bind_btSliderConstraint_getAngularPos_0=function(){return(Jt=b._emscripten_bind_btSliderConstraint_getAngularPos_0=b.asm.wr).apply(null,arguments)},Kt=b._emscripten_bind_btSliderConstraint_setLowerLinLimit_1=function(){return(Kt=b._emscripten_bind_btSliderConstraint_setLowerLinLimit_1=b.asm.xr).apply(null, -arguments)},Lt=b._emscripten_bind_btSliderConstraint_setUpperLinLimit_1=function(){return(Lt=b._emscripten_bind_btSliderConstraint_setUpperLinLimit_1=b.asm.yr).apply(null,arguments)},Mt=b._emscripten_bind_btSliderConstraint_setLowerAngLimit_1=function(){return(Mt=b._emscripten_bind_btSliderConstraint_setLowerAngLimit_1=b.asm.zr).apply(null,arguments)},Nt=b._emscripten_bind_btSliderConstraint_setUpperAngLimit_1=function(){return(Nt=b._emscripten_bind_btSliderConstraint_setUpperAngLimit_1=b.asm.Ar).apply(null, -arguments)},Ot=b._emscripten_bind_btSliderConstraint_setPoweredLinMotor_1=function(){return(Ot=b._emscripten_bind_btSliderConstraint_setPoweredLinMotor_1=b.asm.Br).apply(null,arguments)},Pt=b._emscripten_bind_btSliderConstraint_setMaxLinMotorForce_1=function(){return(Pt=b._emscripten_bind_btSliderConstraint_setMaxLinMotorForce_1=b.asm.Cr).apply(null,arguments)},Qt=b._emscripten_bind_btSliderConstraint_setTargetLinMotorVelocity_1=function(){return(Qt=b._emscripten_bind_btSliderConstraint_setTargetLinMotorVelocity_1= -b.asm.Dr).apply(null,arguments)},Rt=b._emscripten_bind_btSliderConstraint_enableFeedback_1=function(){return(Rt=b._emscripten_bind_btSliderConstraint_enableFeedback_1=b.asm.Er).apply(null,arguments)},St=b._emscripten_bind_btSliderConstraint_getBreakingImpulseThreshold_0=function(){return(St=b._emscripten_bind_btSliderConstraint_getBreakingImpulseThreshold_0=b.asm.Fr).apply(null,arguments)},Tt=b._emscripten_bind_btSliderConstraint_setBreakingImpulseThreshold_1=function(){return(Tt=b._emscripten_bind_btSliderConstraint_setBreakingImpulseThreshold_1= -b.asm.Gr).apply(null,arguments)},Ut=b._emscripten_bind_btSliderConstraint_getParam_2=function(){return(Ut=b._emscripten_bind_btSliderConstraint_getParam_2=b.asm.Hr).apply(null,arguments)},Vt=b._emscripten_bind_btSliderConstraint_setParam_3=function(){return(Vt=b._emscripten_bind_btSliderConstraint_setParam_3=b.asm.Ir).apply(null,arguments)},Wt=b._emscripten_bind_btSliderConstraint___destroy___0=function(){return(Wt=b._emscripten_bind_btSliderConstraint___destroy___0=b.asm.Jr).apply(null,arguments)}, -Xt=b._emscripten_bind_btFixedConstraint_btFixedConstraint_4=function(){return(Xt=b._emscripten_bind_btFixedConstraint_btFixedConstraint_4=b.asm.Kr).apply(null,arguments)},Yt=b._emscripten_bind_btFixedConstraint_enableFeedback_1=function(){return(Yt=b._emscripten_bind_btFixedConstraint_enableFeedback_1=b.asm.Lr).apply(null,arguments)},Zt=b._emscripten_bind_btFixedConstraint_getBreakingImpulseThreshold_0=function(){return(Zt=b._emscripten_bind_btFixedConstraint_getBreakingImpulseThreshold_0=b.asm.Mr).apply(null, -arguments)},$t=b._emscripten_bind_btFixedConstraint_setBreakingImpulseThreshold_1=function(){return($t=b._emscripten_bind_btFixedConstraint_setBreakingImpulseThreshold_1=b.asm.Nr).apply(null,arguments)},au=b._emscripten_bind_btFixedConstraint_getParam_2=function(){return(au=b._emscripten_bind_btFixedConstraint_getParam_2=b.asm.Or).apply(null,arguments)},bu=b._emscripten_bind_btFixedConstraint_setParam_3=function(){return(bu=b._emscripten_bind_btFixedConstraint_setParam_3=b.asm.Pr).apply(null,arguments)}, -cu=b._emscripten_bind_btFixedConstraint___destroy___0=function(){return(cu=b._emscripten_bind_btFixedConstraint___destroy___0=b.asm.Qr).apply(null,arguments)},du=b._emscripten_bind_btConstraintSolver___destroy___0=function(){return(du=b._emscripten_bind_btConstraintSolver___destroy___0=b.asm.Rr).apply(null,arguments)},eu=b._emscripten_bind_btDispatcherInfo_get_m_timeStep_0=function(){return(eu=b._emscripten_bind_btDispatcherInfo_get_m_timeStep_0=b.asm.Sr).apply(null,arguments)},fu=b._emscripten_bind_btDispatcherInfo_set_m_timeStep_1= -function(){return(fu=b._emscripten_bind_btDispatcherInfo_set_m_timeStep_1=b.asm.Tr).apply(null,arguments)},gu=b._emscripten_bind_btDispatcherInfo_get_m_stepCount_0=function(){return(gu=b._emscripten_bind_btDispatcherInfo_get_m_stepCount_0=b.asm.Ur).apply(null,arguments)},hu=b._emscripten_bind_btDispatcherInfo_set_m_stepCount_1=function(){return(hu=b._emscripten_bind_btDispatcherInfo_set_m_stepCount_1=b.asm.Vr).apply(null,arguments)},iu=b._emscripten_bind_btDispatcherInfo_get_m_dispatchFunc_0=function(){return(iu= -b._emscripten_bind_btDispatcherInfo_get_m_dispatchFunc_0=b.asm.Wr).apply(null,arguments)},ju=b._emscripten_bind_btDispatcherInfo_set_m_dispatchFunc_1=function(){return(ju=b._emscripten_bind_btDispatcherInfo_set_m_dispatchFunc_1=b.asm.Xr).apply(null,arguments)},ku=b._emscripten_bind_btDispatcherInfo_get_m_timeOfImpact_0=function(){return(ku=b._emscripten_bind_btDispatcherInfo_get_m_timeOfImpact_0=b.asm.Yr).apply(null,arguments)},lu=b._emscripten_bind_btDispatcherInfo_set_m_timeOfImpact_1=function(){return(lu= -b._emscripten_bind_btDispatcherInfo_set_m_timeOfImpact_1=b.asm.Zr).apply(null,arguments)},mu=b._emscripten_bind_btDispatcherInfo_get_m_useContinuous_0=function(){return(mu=b._emscripten_bind_btDispatcherInfo_get_m_useContinuous_0=b.asm._r).apply(null,arguments)},nu=b._emscripten_bind_btDispatcherInfo_set_m_useContinuous_1=function(){return(nu=b._emscripten_bind_btDispatcherInfo_set_m_useContinuous_1=b.asm.$r).apply(null,arguments)},ou=b._emscripten_bind_btDispatcherInfo_get_m_enableSatConvex_0=function(){return(ou= -b._emscripten_bind_btDispatcherInfo_get_m_enableSatConvex_0=b.asm.as).apply(null,arguments)},pu=b._emscripten_bind_btDispatcherInfo_set_m_enableSatConvex_1=function(){return(pu=b._emscripten_bind_btDispatcherInfo_set_m_enableSatConvex_1=b.asm.bs).apply(null,arguments)},qu=b._emscripten_bind_btDispatcherInfo_get_m_enableSPU_0=function(){return(qu=b._emscripten_bind_btDispatcherInfo_get_m_enableSPU_0=b.asm.cs).apply(null,arguments)},ru=b._emscripten_bind_btDispatcherInfo_set_m_enableSPU_1=function(){return(ru= -b._emscripten_bind_btDispatcherInfo_set_m_enableSPU_1=b.asm.ds).apply(null,arguments)},su=b._emscripten_bind_btDispatcherInfo_get_m_useEpa_0=function(){return(su=b._emscripten_bind_btDispatcherInfo_get_m_useEpa_0=b.asm.es).apply(null,arguments)},tu=b._emscripten_bind_btDispatcherInfo_set_m_useEpa_1=function(){return(tu=b._emscripten_bind_btDispatcherInfo_set_m_useEpa_1=b.asm.fs).apply(null,arguments)},uu=b._emscripten_bind_btDispatcherInfo_get_m_allowedCcdPenetration_0=function(){return(uu=b._emscripten_bind_btDispatcherInfo_get_m_allowedCcdPenetration_0= -b.asm.gs).apply(null,arguments)},vu=b._emscripten_bind_btDispatcherInfo_set_m_allowedCcdPenetration_1=function(){return(vu=b._emscripten_bind_btDispatcherInfo_set_m_allowedCcdPenetration_1=b.asm.hs).apply(null,arguments)},wu=b._emscripten_bind_btDispatcherInfo_get_m_useConvexConservativeDistanceUtil_0=function(){return(wu=b._emscripten_bind_btDispatcherInfo_get_m_useConvexConservativeDistanceUtil_0=b.asm.is).apply(null,arguments)},xu=b._emscripten_bind_btDispatcherInfo_set_m_useConvexConservativeDistanceUtil_1= -function(){return(xu=b._emscripten_bind_btDispatcherInfo_set_m_useConvexConservativeDistanceUtil_1=b.asm.js).apply(null,arguments)},yu=b._emscripten_bind_btDispatcherInfo_get_m_convexConservativeDistanceThreshold_0=function(){return(yu=b._emscripten_bind_btDispatcherInfo_get_m_convexConservativeDistanceThreshold_0=b.asm.ks).apply(null,arguments)},zu=b._emscripten_bind_btDispatcherInfo_set_m_convexConservativeDistanceThreshold_1=function(){return(zu=b._emscripten_bind_btDispatcherInfo_set_m_convexConservativeDistanceThreshold_1= -b.asm.ls).apply(null,arguments)},Au=b._emscripten_bind_btDispatcherInfo___destroy___0=function(){return(Au=b._emscripten_bind_btDispatcherInfo___destroy___0=b.asm.ms).apply(null,arguments)},Bu=b._emscripten_bind_btContactSolverInfo_get_m_splitImpulse_0=function(){return(Bu=b._emscripten_bind_btContactSolverInfo_get_m_splitImpulse_0=b.asm.ns).apply(null,arguments)},Cu=b._emscripten_bind_btContactSolverInfo_set_m_splitImpulse_1=function(){return(Cu=b._emscripten_bind_btContactSolverInfo_set_m_splitImpulse_1= -b.asm.os).apply(null,arguments)},Du=b._emscripten_bind_btContactSolverInfo_get_m_splitImpulsePenetrationThreshold_0=function(){return(Du=b._emscripten_bind_btContactSolverInfo_get_m_splitImpulsePenetrationThreshold_0=b.asm.ps).apply(null,arguments)},Eu=b._emscripten_bind_btContactSolverInfo_set_m_splitImpulsePenetrationThreshold_1=function(){return(Eu=b._emscripten_bind_btContactSolverInfo_set_m_splitImpulsePenetrationThreshold_1=b.asm.qs).apply(null,arguments)},Fu=b._emscripten_bind_btContactSolverInfo_get_m_numIterations_0= -function(){return(Fu=b._emscripten_bind_btContactSolverInfo_get_m_numIterations_0=b.asm.rs).apply(null,arguments)},Gu=b._emscripten_bind_btContactSolverInfo_set_m_numIterations_1=function(){return(Gu=b._emscripten_bind_btContactSolverInfo_set_m_numIterations_1=b.asm.ss).apply(null,arguments)},Hu=b._emscripten_bind_btContactSolverInfo___destroy___0=function(){return(Hu=b._emscripten_bind_btContactSolverInfo___destroy___0=b.asm.ts).apply(null,arguments)},Iu=b._emscripten_bind_btVehicleTuning_btVehicleTuning_0= -function(){return(Iu=b._emscripten_bind_btVehicleTuning_btVehicleTuning_0=b.asm.us).apply(null,arguments)},Ju=b._emscripten_bind_btVehicleTuning_get_m_suspensionStiffness_0=function(){return(Ju=b._emscripten_bind_btVehicleTuning_get_m_suspensionStiffness_0=b.asm.vs).apply(null,arguments)},Ku=b._emscripten_bind_btVehicleTuning_set_m_suspensionStiffness_1=function(){return(Ku=b._emscripten_bind_btVehicleTuning_set_m_suspensionStiffness_1=b.asm.ws).apply(null,arguments)},Lu=b._emscripten_bind_btVehicleTuning_get_m_suspensionCompression_0= -function(){return(Lu=b._emscripten_bind_btVehicleTuning_get_m_suspensionCompression_0=b.asm.xs).apply(null,arguments)},Mu=b._emscripten_bind_btVehicleTuning_set_m_suspensionCompression_1=function(){return(Mu=b._emscripten_bind_btVehicleTuning_set_m_suspensionCompression_1=b.asm.ys).apply(null,arguments)},Nu=b._emscripten_bind_btVehicleTuning_get_m_suspensionDamping_0=function(){return(Nu=b._emscripten_bind_btVehicleTuning_get_m_suspensionDamping_0=b.asm.zs).apply(null,arguments)},Ou=b._emscripten_bind_btVehicleTuning_set_m_suspensionDamping_1= -function(){return(Ou=b._emscripten_bind_btVehicleTuning_set_m_suspensionDamping_1=b.asm.As).apply(null,arguments)},Pu=b._emscripten_bind_btVehicleTuning_get_m_maxSuspensionTravelCm_0=function(){return(Pu=b._emscripten_bind_btVehicleTuning_get_m_maxSuspensionTravelCm_0=b.asm.Bs).apply(null,arguments)},Qu=b._emscripten_bind_btVehicleTuning_set_m_maxSuspensionTravelCm_1=function(){return(Qu=b._emscripten_bind_btVehicleTuning_set_m_maxSuspensionTravelCm_1=b.asm.Cs).apply(null,arguments)},Ru=b._emscripten_bind_btVehicleTuning_get_m_frictionSlip_0= -function(){return(Ru=b._emscripten_bind_btVehicleTuning_get_m_frictionSlip_0=b.asm.Ds).apply(null,arguments)},Su=b._emscripten_bind_btVehicleTuning_set_m_frictionSlip_1=function(){return(Su=b._emscripten_bind_btVehicleTuning_set_m_frictionSlip_1=b.asm.Es).apply(null,arguments)},Tu=b._emscripten_bind_btVehicleTuning_get_m_maxSuspensionForce_0=function(){return(Tu=b._emscripten_bind_btVehicleTuning_get_m_maxSuspensionForce_0=b.asm.Fs).apply(null,arguments)},Uu=b._emscripten_bind_btVehicleTuning_set_m_maxSuspensionForce_1= -function(){return(Uu=b._emscripten_bind_btVehicleTuning_set_m_maxSuspensionForce_1=b.asm.Gs).apply(null,arguments)},Vu=b._emscripten_bind_btVehicleRaycasterResult_get_m_hitPointInWorld_0=function(){return(Vu=b._emscripten_bind_btVehicleRaycasterResult_get_m_hitPointInWorld_0=b.asm.Hs).apply(null,arguments)},Wu=b._emscripten_bind_btVehicleRaycasterResult_set_m_hitPointInWorld_1=function(){return(Wu=b._emscripten_bind_btVehicleRaycasterResult_set_m_hitPointInWorld_1=b.asm.Is).apply(null,arguments)}, -Xu=b._emscripten_bind_btVehicleRaycasterResult_get_m_hitNormalInWorld_0=function(){return(Xu=b._emscripten_bind_btVehicleRaycasterResult_get_m_hitNormalInWorld_0=b.asm.Js).apply(null,arguments)},Yu=b._emscripten_bind_btVehicleRaycasterResult_set_m_hitNormalInWorld_1=function(){return(Yu=b._emscripten_bind_btVehicleRaycasterResult_set_m_hitNormalInWorld_1=b.asm.Ks).apply(null,arguments)},Zu=b._emscripten_bind_btVehicleRaycasterResult_get_m_distFraction_0=function(){return(Zu=b._emscripten_bind_btVehicleRaycasterResult_get_m_distFraction_0= -b.asm.Ls).apply(null,arguments)},$u=b._emscripten_bind_btVehicleRaycasterResult_set_m_distFraction_1=function(){return($u=b._emscripten_bind_btVehicleRaycasterResult_set_m_distFraction_1=b.asm.Ms).apply(null,arguments)},av=b._emscripten_bind_btVehicleRaycasterResult___destroy___0=function(){return(av=b._emscripten_bind_btVehicleRaycasterResult___destroy___0=b.asm.Ns).apply(null,arguments)},bv=b._emscripten_bind_btDefaultVehicleRaycaster_btDefaultVehicleRaycaster_1=function(){return(bv=b._emscripten_bind_btDefaultVehicleRaycaster_btDefaultVehicleRaycaster_1= -b.asm.Os).apply(null,arguments)},cv=b._emscripten_bind_btDefaultVehicleRaycaster_castRay_3=function(){return(cv=b._emscripten_bind_btDefaultVehicleRaycaster_castRay_3=b.asm.Ps).apply(null,arguments)},dv=b._emscripten_bind_btDefaultVehicleRaycaster___destroy___0=function(){return(dv=b._emscripten_bind_btDefaultVehicleRaycaster___destroy___0=b.asm.Qs).apply(null,arguments)},ev=b._emscripten_bind_RaycastInfo_get_m_contactNormalWS_0=function(){return(ev=b._emscripten_bind_RaycastInfo_get_m_contactNormalWS_0= -b.asm.Rs).apply(null,arguments)},fv=b._emscripten_bind_RaycastInfo_set_m_contactNormalWS_1=function(){return(fv=b._emscripten_bind_RaycastInfo_set_m_contactNormalWS_1=b.asm.Ss).apply(null,arguments)},gv=b._emscripten_bind_RaycastInfo_get_m_contactPointWS_0=function(){return(gv=b._emscripten_bind_RaycastInfo_get_m_contactPointWS_0=b.asm.Ts).apply(null,arguments)},hv=b._emscripten_bind_RaycastInfo_set_m_contactPointWS_1=function(){return(hv=b._emscripten_bind_RaycastInfo_set_m_contactPointWS_1=b.asm.Us).apply(null, -arguments)},iv=b._emscripten_bind_RaycastInfo_get_m_suspensionLength_0=function(){return(iv=b._emscripten_bind_RaycastInfo_get_m_suspensionLength_0=b.asm.Vs).apply(null,arguments)},jv=b._emscripten_bind_RaycastInfo_set_m_suspensionLength_1=function(){return(jv=b._emscripten_bind_RaycastInfo_set_m_suspensionLength_1=b.asm.Ws).apply(null,arguments)},kv=b._emscripten_bind_RaycastInfo_get_m_hardPointWS_0=function(){return(kv=b._emscripten_bind_RaycastInfo_get_m_hardPointWS_0=b.asm.Xs).apply(null,arguments)}, -lv=b._emscripten_bind_RaycastInfo_set_m_hardPointWS_1=function(){return(lv=b._emscripten_bind_RaycastInfo_set_m_hardPointWS_1=b.asm.Ys).apply(null,arguments)},mv=b._emscripten_bind_RaycastInfo_get_m_wheelDirectionWS_0=function(){return(mv=b._emscripten_bind_RaycastInfo_get_m_wheelDirectionWS_0=b.asm.Zs).apply(null,arguments)},nv=b._emscripten_bind_RaycastInfo_set_m_wheelDirectionWS_1=function(){return(nv=b._emscripten_bind_RaycastInfo_set_m_wheelDirectionWS_1=b.asm._s).apply(null,arguments)},ov=b._emscripten_bind_RaycastInfo_get_m_wheelAxleWS_0= -function(){return(ov=b._emscripten_bind_RaycastInfo_get_m_wheelAxleWS_0=b.asm.$s).apply(null,arguments)},pv=b._emscripten_bind_RaycastInfo_set_m_wheelAxleWS_1=function(){return(pv=b._emscripten_bind_RaycastInfo_set_m_wheelAxleWS_1=b.asm.at).apply(null,arguments)},qv=b._emscripten_bind_RaycastInfo_get_m_isInContact_0=function(){return(qv=b._emscripten_bind_RaycastInfo_get_m_isInContact_0=b.asm.bt).apply(null,arguments)},rv=b._emscripten_bind_RaycastInfo_set_m_isInContact_1=function(){return(rv=b._emscripten_bind_RaycastInfo_set_m_isInContact_1= -b.asm.ct).apply(null,arguments)},sv=b._emscripten_bind_RaycastInfo_get_m_groundObject_0=function(){return(sv=b._emscripten_bind_RaycastInfo_get_m_groundObject_0=b.asm.dt).apply(null,arguments)},tv=b._emscripten_bind_RaycastInfo_set_m_groundObject_1=function(){return(tv=b._emscripten_bind_RaycastInfo_set_m_groundObject_1=b.asm.et).apply(null,arguments)},uv=b._emscripten_bind_RaycastInfo___destroy___0=function(){return(uv=b._emscripten_bind_RaycastInfo___destroy___0=b.asm.ft).apply(null,arguments)}, -vv=b._emscripten_bind_btWheelInfoConstructionInfo_get_m_chassisConnectionCS_0=function(){return(vv=b._emscripten_bind_btWheelInfoConstructionInfo_get_m_chassisConnectionCS_0=b.asm.gt).apply(null,arguments)},wv=b._emscripten_bind_btWheelInfoConstructionInfo_set_m_chassisConnectionCS_1=function(){return(wv=b._emscripten_bind_btWheelInfoConstructionInfo_set_m_chassisConnectionCS_1=b.asm.ht).apply(null,arguments)},xv=b._emscripten_bind_btWheelInfoConstructionInfo_get_m_wheelDirectionCS_0=function(){return(xv= -b._emscripten_bind_btWheelInfoConstructionInfo_get_m_wheelDirectionCS_0=b.asm.it).apply(null,arguments)},yv=b._emscripten_bind_btWheelInfoConstructionInfo_set_m_wheelDirectionCS_1=function(){return(yv=b._emscripten_bind_btWheelInfoConstructionInfo_set_m_wheelDirectionCS_1=b.asm.jt).apply(null,arguments)},zv=b._emscripten_bind_btWheelInfoConstructionInfo_get_m_wheelAxleCS_0=function(){return(zv=b._emscripten_bind_btWheelInfoConstructionInfo_get_m_wheelAxleCS_0=b.asm.kt).apply(null,arguments)},Av=b._emscripten_bind_btWheelInfoConstructionInfo_set_m_wheelAxleCS_1= -function(){return(Av=b._emscripten_bind_btWheelInfoConstructionInfo_set_m_wheelAxleCS_1=b.asm.lt).apply(null,arguments)},Bv=b._emscripten_bind_btWheelInfoConstructionInfo_get_m_suspensionRestLength_0=function(){return(Bv=b._emscripten_bind_btWheelInfoConstructionInfo_get_m_suspensionRestLength_0=b.asm.mt).apply(null,arguments)},Cv=b._emscripten_bind_btWheelInfoConstructionInfo_set_m_suspensionRestLength_1=function(){return(Cv=b._emscripten_bind_btWheelInfoConstructionInfo_set_m_suspensionRestLength_1= -b.asm.nt).apply(null,arguments)},Dv=b._emscripten_bind_btWheelInfoConstructionInfo_get_m_maxSuspensionTravelCm_0=function(){return(Dv=b._emscripten_bind_btWheelInfoConstructionInfo_get_m_maxSuspensionTravelCm_0=b.asm.ot).apply(null,arguments)},Ev=b._emscripten_bind_btWheelInfoConstructionInfo_set_m_maxSuspensionTravelCm_1=function(){return(Ev=b._emscripten_bind_btWheelInfoConstructionInfo_set_m_maxSuspensionTravelCm_1=b.asm.pt).apply(null,arguments)},Fv=b._emscripten_bind_btWheelInfoConstructionInfo_get_m_wheelRadius_0= -function(){return(Fv=b._emscripten_bind_btWheelInfoConstructionInfo_get_m_wheelRadius_0=b.asm.qt).apply(null,arguments)},Gv=b._emscripten_bind_btWheelInfoConstructionInfo_set_m_wheelRadius_1=function(){return(Gv=b._emscripten_bind_btWheelInfoConstructionInfo_set_m_wheelRadius_1=b.asm.rt).apply(null,arguments)},Hv=b._emscripten_bind_btWheelInfoConstructionInfo_get_m_suspensionStiffness_0=function(){return(Hv=b._emscripten_bind_btWheelInfoConstructionInfo_get_m_suspensionStiffness_0=b.asm.st).apply(null, -arguments)},Iv=b._emscripten_bind_btWheelInfoConstructionInfo_set_m_suspensionStiffness_1=function(){return(Iv=b._emscripten_bind_btWheelInfoConstructionInfo_set_m_suspensionStiffness_1=b.asm.tt).apply(null,arguments)},Jv=b._emscripten_bind_btWheelInfoConstructionInfo_get_m_wheelsDampingCompression_0=function(){return(Jv=b._emscripten_bind_btWheelInfoConstructionInfo_get_m_wheelsDampingCompression_0=b.asm.ut).apply(null,arguments)},Kv=b._emscripten_bind_btWheelInfoConstructionInfo_set_m_wheelsDampingCompression_1= -function(){return(Kv=b._emscripten_bind_btWheelInfoConstructionInfo_set_m_wheelsDampingCompression_1=b.asm.vt).apply(null,arguments)},Lv=b._emscripten_bind_btWheelInfoConstructionInfo_get_m_wheelsDampingRelaxation_0=function(){return(Lv=b._emscripten_bind_btWheelInfoConstructionInfo_get_m_wheelsDampingRelaxation_0=b.asm.wt).apply(null,arguments)},Mv=b._emscripten_bind_btWheelInfoConstructionInfo_set_m_wheelsDampingRelaxation_1=function(){return(Mv=b._emscripten_bind_btWheelInfoConstructionInfo_set_m_wheelsDampingRelaxation_1= -b.asm.xt).apply(null,arguments)},Nv=b._emscripten_bind_btWheelInfoConstructionInfo_get_m_frictionSlip_0=function(){return(Nv=b._emscripten_bind_btWheelInfoConstructionInfo_get_m_frictionSlip_0=b.asm.yt).apply(null,arguments)},Ov=b._emscripten_bind_btWheelInfoConstructionInfo_set_m_frictionSlip_1=function(){return(Ov=b._emscripten_bind_btWheelInfoConstructionInfo_set_m_frictionSlip_1=b.asm.zt).apply(null,arguments)},Pv=b._emscripten_bind_btWheelInfoConstructionInfo_get_m_maxSuspensionForce_0=function(){return(Pv= -b._emscripten_bind_btWheelInfoConstructionInfo_get_m_maxSuspensionForce_0=b.asm.At).apply(null,arguments)},Qv=b._emscripten_bind_btWheelInfoConstructionInfo_set_m_maxSuspensionForce_1=function(){return(Qv=b._emscripten_bind_btWheelInfoConstructionInfo_set_m_maxSuspensionForce_1=b.asm.Bt).apply(null,arguments)},Rv=b._emscripten_bind_btWheelInfoConstructionInfo_get_m_bIsFrontWheel_0=function(){return(Rv=b._emscripten_bind_btWheelInfoConstructionInfo_get_m_bIsFrontWheel_0=b.asm.Ct).apply(null,arguments)}, -Sv=b._emscripten_bind_btWheelInfoConstructionInfo_set_m_bIsFrontWheel_1=function(){return(Sv=b._emscripten_bind_btWheelInfoConstructionInfo_set_m_bIsFrontWheel_1=b.asm.Dt).apply(null,arguments)},Tv=b._emscripten_bind_btWheelInfoConstructionInfo___destroy___0=function(){return(Tv=b._emscripten_bind_btWheelInfoConstructionInfo___destroy___0=b.asm.Et).apply(null,arguments)},Uv=b._emscripten_bind_btWheelInfo_btWheelInfo_1=function(){return(Uv=b._emscripten_bind_btWheelInfo_btWheelInfo_1=b.asm.Ft).apply(null, -arguments)},Vv=b._emscripten_bind_btWheelInfo_getSuspensionRestLength_0=function(){return(Vv=b._emscripten_bind_btWheelInfo_getSuspensionRestLength_0=b.asm.Gt).apply(null,arguments)},Wv=b._emscripten_bind_btWheelInfo_updateWheel_2=function(){return(Wv=b._emscripten_bind_btWheelInfo_updateWheel_2=b.asm.Ht).apply(null,arguments)},Xv=b._emscripten_bind_btWheelInfo_get_m_suspensionStiffness_0=function(){return(Xv=b._emscripten_bind_btWheelInfo_get_m_suspensionStiffness_0=b.asm.It).apply(null,arguments)}, -Yv=b._emscripten_bind_btWheelInfo_set_m_suspensionStiffness_1=function(){return(Yv=b._emscripten_bind_btWheelInfo_set_m_suspensionStiffness_1=b.asm.Jt).apply(null,arguments)},Zv=b._emscripten_bind_btWheelInfo_get_m_frictionSlip_0=function(){return(Zv=b._emscripten_bind_btWheelInfo_get_m_frictionSlip_0=b.asm.Kt).apply(null,arguments)},$v=b._emscripten_bind_btWheelInfo_set_m_frictionSlip_1=function(){return($v=b._emscripten_bind_btWheelInfo_set_m_frictionSlip_1=b.asm.Lt).apply(null,arguments)},aw=b._emscripten_bind_btWheelInfo_get_m_engineForce_0= -function(){return(aw=b._emscripten_bind_btWheelInfo_get_m_engineForce_0=b.asm.Mt).apply(null,arguments)},bw=b._emscripten_bind_btWheelInfo_set_m_engineForce_1=function(){return(bw=b._emscripten_bind_btWheelInfo_set_m_engineForce_1=b.asm.Nt).apply(null,arguments)},cw=b._emscripten_bind_btWheelInfo_get_m_rollInfluence_0=function(){return(cw=b._emscripten_bind_btWheelInfo_get_m_rollInfluence_0=b.asm.Ot).apply(null,arguments)},dw=b._emscripten_bind_btWheelInfo_set_m_rollInfluence_1=function(){return(dw= -b._emscripten_bind_btWheelInfo_set_m_rollInfluence_1=b.asm.Pt).apply(null,arguments)},ew=b._emscripten_bind_btWheelInfo_get_m_suspensionRestLength1_0=function(){return(ew=b._emscripten_bind_btWheelInfo_get_m_suspensionRestLength1_0=b.asm.Qt).apply(null,arguments)},fw=b._emscripten_bind_btWheelInfo_set_m_suspensionRestLength1_1=function(){return(fw=b._emscripten_bind_btWheelInfo_set_m_suspensionRestLength1_1=b.asm.Rt).apply(null,arguments)},gw=b._emscripten_bind_btWheelInfo_get_m_wheelsRadius_0=function(){return(gw= -b._emscripten_bind_btWheelInfo_get_m_wheelsRadius_0=b.asm.St).apply(null,arguments)},hw=b._emscripten_bind_btWheelInfo_set_m_wheelsRadius_1=function(){return(hw=b._emscripten_bind_btWheelInfo_set_m_wheelsRadius_1=b.asm.Tt).apply(null,arguments)},iw=b._emscripten_bind_btWheelInfo_get_m_wheelsDampingCompression_0=function(){return(iw=b._emscripten_bind_btWheelInfo_get_m_wheelsDampingCompression_0=b.asm.Ut).apply(null,arguments)},jw=b._emscripten_bind_btWheelInfo_set_m_wheelsDampingCompression_1=function(){return(jw= -b._emscripten_bind_btWheelInfo_set_m_wheelsDampingCompression_1=b.asm.Vt).apply(null,arguments)},kw=b._emscripten_bind_btWheelInfo_get_m_wheelsDampingRelaxation_0=function(){return(kw=b._emscripten_bind_btWheelInfo_get_m_wheelsDampingRelaxation_0=b.asm.Wt).apply(null,arguments)},lw=b._emscripten_bind_btWheelInfo_set_m_wheelsDampingRelaxation_1=function(){return(lw=b._emscripten_bind_btWheelInfo_set_m_wheelsDampingRelaxation_1=b.asm.Xt).apply(null,arguments)},mw=b._emscripten_bind_btWheelInfo_get_m_steering_0= -function(){return(mw=b._emscripten_bind_btWheelInfo_get_m_steering_0=b.asm.Yt).apply(null,arguments)},nw=b._emscripten_bind_btWheelInfo_set_m_steering_1=function(){return(nw=b._emscripten_bind_btWheelInfo_set_m_steering_1=b.asm.Zt).apply(null,arguments)},ow=b._emscripten_bind_btWheelInfo_get_m_maxSuspensionForce_0=function(){return(ow=b._emscripten_bind_btWheelInfo_get_m_maxSuspensionForce_0=b.asm._t).apply(null,arguments)},pw=b._emscripten_bind_btWheelInfo_set_m_maxSuspensionForce_1=function(){return(pw= -b._emscripten_bind_btWheelInfo_set_m_maxSuspensionForce_1=b.asm.$t).apply(null,arguments)},qw=b._emscripten_bind_btWheelInfo_get_m_maxSuspensionTravelCm_0=function(){return(qw=b._emscripten_bind_btWheelInfo_get_m_maxSuspensionTravelCm_0=b.asm.au).apply(null,arguments)},rw=b._emscripten_bind_btWheelInfo_set_m_maxSuspensionTravelCm_1=function(){return(rw=b._emscripten_bind_btWheelInfo_set_m_maxSuspensionTravelCm_1=b.asm.bu).apply(null,arguments)},sw=b._emscripten_bind_btWheelInfo_get_m_wheelsSuspensionForce_0= -function(){return(sw=b._emscripten_bind_btWheelInfo_get_m_wheelsSuspensionForce_0=b.asm.cu).apply(null,arguments)},tw=b._emscripten_bind_btWheelInfo_set_m_wheelsSuspensionForce_1=function(){return(tw=b._emscripten_bind_btWheelInfo_set_m_wheelsSuspensionForce_1=b.asm.du).apply(null,arguments)},uw=b._emscripten_bind_btWheelInfo_get_m_bIsFrontWheel_0=function(){return(uw=b._emscripten_bind_btWheelInfo_get_m_bIsFrontWheel_0=b.asm.eu).apply(null,arguments)},vw=b._emscripten_bind_btWheelInfo_set_m_bIsFrontWheel_1= -function(){return(vw=b._emscripten_bind_btWheelInfo_set_m_bIsFrontWheel_1=b.asm.fu).apply(null,arguments)},ww=b._emscripten_bind_btWheelInfo_get_m_raycastInfo_0=function(){return(ww=b._emscripten_bind_btWheelInfo_get_m_raycastInfo_0=b.asm.gu).apply(null,arguments)},xw=b._emscripten_bind_btWheelInfo_set_m_raycastInfo_1=function(){return(xw=b._emscripten_bind_btWheelInfo_set_m_raycastInfo_1=b.asm.hu).apply(null,arguments)},yw=b._emscripten_bind_btWheelInfo_get_m_chassisConnectionPointCS_0=function(){return(yw= -b._emscripten_bind_btWheelInfo_get_m_chassisConnectionPointCS_0=b.asm.iu).apply(null,arguments)},zw=b._emscripten_bind_btWheelInfo_set_m_chassisConnectionPointCS_1=function(){return(zw=b._emscripten_bind_btWheelInfo_set_m_chassisConnectionPointCS_1=b.asm.ju).apply(null,arguments)},Aw=b._emscripten_bind_btWheelInfo_get_m_worldTransform_0=function(){return(Aw=b._emscripten_bind_btWheelInfo_get_m_worldTransform_0=b.asm.ku).apply(null,arguments)},Bw=b._emscripten_bind_btWheelInfo_set_m_worldTransform_1= -function(){return(Bw=b._emscripten_bind_btWheelInfo_set_m_worldTransform_1=b.asm.lu).apply(null,arguments)},Cw=b._emscripten_bind_btWheelInfo_get_m_wheelDirectionCS_0=function(){return(Cw=b._emscripten_bind_btWheelInfo_get_m_wheelDirectionCS_0=b.asm.mu).apply(null,arguments)},Dw=b._emscripten_bind_btWheelInfo_set_m_wheelDirectionCS_1=function(){return(Dw=b._emscripten_bind_btWheelInfo_set_m_wheelDirectionCS_1=b.asm.nu).apply(null,arguments)},Ew=b._emscripten_bind_btWheelInfo_get_m_wheelAxleCS_0=function(){return(Ew= -b._emscripten_bind_btWheelInfo_get_m_wheelAxleCS_0=b.asm.ou).apply(null,arguments)},Fw=b._emscripten_bind_btWheelInfo_set_m_wheelAxleCS_1=function(){return(Fw=b._emscripten_bind_btWheelInfo_set_m_wheelAxleCS_1=b.asm.pu).apply(null,arguments)},Gw=b._emscripten_bind_btWheelInfo_get_m_rotation_0=function(){return(Gw=b._emscripten_bind_btWheelInfo_get_m_rotation_0=b.asm.qu).apply(null,arguments)},Hw=b._emscripten_bind_btWheelInfo_set_m_rotation_1=function(){return(Hw=b._emscripten_bind_btWheelInfo_set_m_rotation_1= -b.asm.ru).apply(null,arguments)},Iw=b._emscripten_bind_btWheelInfo_get_m_deltaRotation_0=function(){return(Iw=b._emscripten_bind_btWheelInfo_get_m_deltaRotation_0=b.asm.su).apply(null,arguments)},Jw=b._emscripten_bind_btWheelInfo_set_m_deltaRotation_1=function(){return(Jw=b._emscripten_bind_btWheelInfo_set_m_deltaRotation_1=b.asm.tu).apply(null,arguments)},Kw=b._emscripten_bind_btWheelInfo_get_m_brake_0=function(){return(Kw=b._emscripten_bind_btWheelInfo_get_m_brake_0=b.asm.uu).apply(null,arguments)}, -Lw=b._emscripten_bind_btWheelInfo_set_m_brake_1=function(){return(Lw=b._emscripten_bind_btWheelInfo_set_m_brake_1=b.asm.vu).apply(null,arguments)},Mw=b._emscripten_bind_btWheelInfo_get_m_clippedInvContactDotSuspension_0=function(){return(Mw=b._emscripten_bind_btWheelInfo_get_m_clippedInvContactDotSuspension_0=b.asm.wu).apply(null,arguments)},Nw=b._emscripten_bind_btWheelInfo_set_m_clippedInvContactDotSuspension_1=function(){return(Nw=b._emscripten_bind_btWheelInfo_set_m_clippedInvContactDotSuspension_1= -b.asm.xu).apply(null,arguments)},Ow=b._emscripten_bind_btWheelInfo_get_m_suspensionRelativeVelocity_0=function(){return(Ow=b._emscripten_bind_btWheelInfo_get_m_suspensionRelativeVelocity_0=b.asm.yu).apply(null,arguments)},Pw=b._emscripten_bind_btWheelInfo_set_m_suspensionRelativeVelocity_1=function(){return(Pw=b._emscripten_bind_btWheelInfo_set_m_suspensionRelativeVelocity_1=b.asm.zu).apply(null,arguments)},Qw=b._emscripten_bind_btWheelInfo_get_m_skidInfo_0=function(){return(Qw=b._emscripten_bind_btWheelInfo_get_m_skidInfo_0= -b.asm.Au).apply(null,arguments)},Rw=b._emscripten_bind_btWheelInfo_set_m_skidInfo_1=function(){return(Rw=b._emscripten_bind_btWheelInfo_set_m_skidInfo_1=b.asm.Bu).apply(null,arguments)},Sw=b._emscripten_bind_btWheelInfo___destroy___0=function(){return(Sw=b._emscripten_bind_btWheelInfo___destroy___0=b.asm.Cu).apply(null,arguments)},Tw=b._emscripten_bind_btKinematicCharacterController_btKinematicCharacterController_3=function(){return(Tw=b._emscripten_bind_btKinematicCharacterController_btKinematicCharacterController_3= -b.asm.Du).apply(null,arguments)},Uw=b._emscripten_bind_btKinematicCharacterController_btKinematicCharacterController_4=function(){return(Uw=b._emscripten_bind_btKinematicCharacterController_btKinematicCharacterController_4=b.asm.Eu).apply(null,arguments)},Vw=b._emscripten_bind_btKinematicCharacterController_setUpAxis_1=function(){return(Vw=b._emscripten_bind_btKinematicCharacterController_setUpAxis_1=b.asm.Fu).apply(null,arguments)},Ww=b._emscripten_bind_btKinematicCharacterController_setWalkDirection_1= -function(){return(Ww=b._emscripten_bind_btKinematicCharacterController_setWalkDirection_1=b.asm.Gu).apply(null,arguments)},Xw=b._emscripten_bind_btKinematicCharacterController_setVelocityForTimeInterval_2=function(){return(Xw=b._emscripten_bind_btKinematicCharacterController_setVelocityForTimeInterval_2=b.asm.Hu).apply(null,arguments)},Yw=b._emscripten_bind_btKinematicCharacterController_warp_1=function(){return(Yw=b._emscripten_bind_btKinematicCharacterController_warp_1=b.asm.Iu).apply(null,arguments)}, -Zw=b._emscripten_bind_btKinematicCharacterController_preStep_1=function(){return(Zw=b._emscripten_bind_btKinematicCharacterController_preStep_1=b.asm.Ju).apply(null,arguments)},$w=b._emscripten_bind_btKinematicCharacterController_playerStep_2=function(){return($w=b._emscripten_bind_btKinematicCharacterController_playerStep_2=b.asm.Ku).apply(null,arguments)},ax=b._emscripten_bind_btKinematicCharacterController_setFallSpeed_1=function(){return(ax=b._emscripten_bind_btKinematicCharacterController_setFallSpeed_1= -b.asm.Lu).apply(null,arguments)},bx=b._emscripten_bind_btKinematicCharacterController_setJumpSpeed_1=function(){return(bx=b._emscripten_bind_btKinematicCharacterController_setJumpSpeed_1=b.asm.Mu).apply(null,arguments)},cx=b._emscripten_bind_btKinematicCharacterController_setMaxJumpHeight_1=function(){return(cx=b._emscripten_bind_btKinematicCharacterController_setMaxJumpHeight_1=b.asm.Nu).apply(null,arguments)},dx=b._emscripten_bind_btKinematicCharacterController_canJump_0=function(){return(dx=b._emscripten_bind_btKinematicCharacterController_canJump_0= -b.asm.Ou).apply(null,arguments)},ex=b._emscripten_bind_btKinematicCharacterController_jump_0=function(){return(ex=b._emscripten_bind_btKinematicCharacterController_jump_0=b.asm.Pu).apply(null,arguments)},fx=b._emscripten_bind_btKinematicCharacterController_setGravity_1=function(){return(fx=b._emscripten_bind_btKinematicCharacterController_setGravity_1=b.asm.Qu).apply(null,arguments)},gx=b._emscripten_bind_btKinematicCharacterController_getGravity_0=function(){return(gx=b._emscripten_bind_btKinematicCharacterController_getGravity_0= -b.asm.Ru).apply(null,arguments)},hx=b._emscripten_bind_btKinematicCharacterController_setMaxSlope_1=function(){return(hx=b._emscripten_bind_btKinematicCharacterController_setMaxSlope_1=b.asm.Su).apply(null,arguments)},ix=b._emscripten_bind_btKinematicCharacterController_getMaxSlope_0=function(){return(ix=b._emscripten_bind_btKinematicCharacterController_getMaxSlope_0=b.asm.Tu).apply(null,arguments)},jx=b._emscripten_bind_btKinematicCharacterController_getGhostObject_0=function(){return(jx=b._emscripten_bind_btKinematicCharacterController_getGhostObject_0= -b.asm.Uu).apply(null,arguments)},kx=b._emscripten_bind_btKinematicCharacterController_setUseGhostSweepTest_1=function(){return(kx=b._emscripten_bind_btKinematicCharacterController_setUseGhostSweepTest_1=b.asm.Vu).apply(null,arguments)},lx=b._emscripten_bind_btKinematicCharacterController_onGround_0=function(){return(lx=b._emscripten_bind_btKinematicCharacterController_onGround_0=b.asm.Wu).apply(null,arguments)},mx=b._emscripten_bind_btKinematicCharacterController_setUpInterpolate_1=function(){return(mx= -b._emscripten_bind_btKinematicCharacterController_setUpInterpolate_1=b.asm.Xu).apply(null,arguments)},nx=b._emscripten_bind_btKinematicCharacterController_updateAction_2=function(){return(nx=b._emscripten_bind_btKinematicCharacterController_updateAction_2=b.asm.Yu).apply(null,arguments)},ox=b._emscripten_bind_btKinematicCharacterController___destroy___0=function(){return(ox=b._emscripten_bind_btKinematicCharacterController___destroy___0=b.asm.Zu).apply(null,arguments)},px=b._emscripten_bind_btRaycastVehicle_btRaycastVehicle_3= -function(){return(px=b._emscripten_bind_btRaycastVehicle_btRaycastVehicle_3=b.asm._u).apply(null,arguments)},qx=b._emscripten_bind_btRaycastVehicle_applyEngineForce_2=function(){return(qx=b._emscripten_bind_btRaycastVehicle_applyEngineForce_2=b.asm.$u).apply(null,arguments)},rx=b._emscripten_bind_btRaycastVehicle_setSteeringValue_2=function(){return(rx=b._emscripten_bind_btRaycastVehicle_setSteeringValue_2=b.asm.av).apply(null,arguments)},sx=b._emscripten_bind_btRaycastVehicle_getWheelTransformWS_1= -function(){return(sx=b._emscripten_bind_btRaycastVehicle_getWheelTransformWS_1=b.asm.bv).apply(null,arguments)},tx=b._emscripten_bind_btRaycastVehicle_updateWheelTransform_2=function(){return(tx=b._emscripten_bind_btRaycastVehicle_updateWheelTransform_2=b.asm.cv).apply(null,arguments)},ux=b._emscripten_bind_btRaycastVehicle_addWheel_7=function(){return(ux=b._emscripten_bind_btRaycastVehicle_addWheel_7=b.asm.dv).apply(null,arguments)},vx=b._emscripten_bind_btRaycastVehicle_getNumWheels_0=function(){return(vx= -b._emscripten_bind_btRaycastVehicle_getNumWheels_0=b.asm.ev).apply(null,arguments)},wx=b._emscripten_bind_btRaycastVehicle_getRigidBody_0=function(){return(wx=b._emscripten_bind_btRaycastVehicle_getRigidBody_0=b.asm.fv).apply(null,arguments)},xx=b._emscripten_bind_btRaycastVehicle_getWheelInfo_1=function(){return(xx=b._emscripten_bind_btRaycastVehicle_getWheelInfo_1=b.asm.gv).apply(null,arguments)},yx=b._emscripten_bind_btRaycastVehicle_setBrake_2=function(){return(yx=b._emscripten_bind_btRaycastVehicle_setBrake_2= -b.asm.hv).apply(null,arguments)},zx=b._emscripten_bind_btRaycastVehicle_setCoordinateSystem_3=function(){return(zx=b._emscripten_bind_btRaycastVehicle_setCoordinateSystem_3=b.asm.iv).apply(null,arguments)},Ax=b._emscripten_bind_btRaycastVehicle_getCurrentSpeedKmHour_0=function(){return(Ax=b._emscripten_bind_btRaycastVehicle_getCurrentSpeedKmHour_0=b.asm.jv).apply(null,arguments)},Bx=b._emscripten_bind_btRaycastVehicle_getChassisWorldTransform_0=function(){return(Bx=b._emscripten_bind_btRaycastVehicle_getChassisWorldTransform_0= -b.asm.kv).apply(null,arguments)},Cx=b._emscripten_bind_btRaycastVehicle_rayCast_1=function(){return(Cx=b._emscripten_bind_btRaycastVehicle_rayCast_1=b.asm.lv).apply(null,arguments)},Dx=b._emscripten_bind_btRaycastVehicle_updateVehicle_1=function(){return(Dx=b._emscripten_bind_btRaycastVehicle_updateVehicle_1=b.asm.mv).apply(null,arguments)},Ex=b._emscripten_bind_btRaycastVehicle_resetSuspension_0=function(){return(Ex=b._emscripten_bind_btRaycastVehicle_resetSuspension_0=b.asm.nv).apply(null,arguments)}, -Fx=b._emscripten_bind_btRaycastVehicle_getSteeringValue_1=function(){return(Fx=b._emscripten_bind_btRaycastVehicle_getSteeringValue_1=b.asm.ov).apply(null,arguments)},Gx=b._emscripten_bind_btRaycastVehicle_updateWheelTransformsWS_1=function(){return(Gx=b._emscripten_bind_btRaycastVehicle_updateWheelTransformsWS_1=b.asm.pv).apply(null,arguments)},Hx=b._emscripten_bind_btRaycastVehicle_updateWheelTransformsWS_2=function(){return(Hx=b._emscripten_bind_btRaycastVehicle_updateWheelTransformsWS_2=b.asm.qv).apply(null, -arguments)},Ix=b._emscripten_bind_btRaycastVehicle_setPitchControl_1=function(){return(Ix=b._emscripten_bind_btRaycastVehicle_setPitchControl_1=b.asm.rv).apply(null,arguments)},Jx=b._emscripten_bind_btRaycastVehicle_updateSuspension_1=function(){return(Jx=b._emscripten_bind_btRaycastVehicle_updateSuspension_1=b.asm.sv).apply(null,arguments)},Kx=b._emscripten_bind_btRaycastVehicle_updateFriction_1=function(){return(Kx=b._emscripten_bind_btRaycastVehicle_updateFriction_1=b.asm.tv).apply(null,arguments)}, -Lx=b._emscripten_bind_btRaycastVehicle_getRightAxis_0=function(){return(Lx=b._emscripten_bind_btRaycastVehicle_getRightAxis_0=b.asm.uv).apply(null,arguments)},Mx=b._emscripten_bind_btRaycastVehicle_getUpAxis_0=function(){return(Mx=b._emscripten_bind_btRaycastVehicle_getUpAxis_0=b.asm.vv).apply(null,arguments)},Nx=b._emscripten_bind_btRaycastVehicle_getForwardAxis_0=function(){return(Nx=b._emscripten_bind_btRaycastVehicle_getForwardAxis_0=b.asm.wv).apply(null,arguments)},Ox=b._emscripten_bind_btRaycastVehicle_getForwardVector_0= -function(){return(Ox=b._emscripten_bind_btRaycastVehicle_getForwardVector_0=b.asm.xv).apply(null,arguments)},Px=b._emscripten_bind_btRaycastVehicle_getUserConstraintType_0=function(){return(Px=b._emscripten_bind_btRaycastVehicle_getUserConstraintType_0=b.asm.yv).apply(null,arguments)},Qx=b._emscripten_bind_btRaycastVehicle_setUserConstraintType_1=function(){return(Qx=b._emscripten_bind_btRaycastVehicle_setUserConstraintType_1=b.asm.zv).apply(null,arguments)},Rx=b._emscripten_bind_btRaycastVehicle_setUserConstraintId_1= -function(){return(Rx=b._emscripten_bind_btRaycastVehicle_setUserConstraintId_1=b.asm.Av).apply(null,arguments)},Sx=b._emscripten_bind_btRaycastVehicle_getUserConstraintId_0=function(){return(Sx=b._emscripten_bind_btRaycastVehicle_getUserConstraintId_0=b.asm.Bv).apply(null,arguments)},Tx=b._emscripten_bind_btRaycastVehicle_updateAction_2=function(){return(Tx=b._emscripten_bind_btRaycastVehicle_updateAction_2=b.asm.Cv).apply(null,arguments)},Ux=b._emscripten_bind_btRaycastVehicle___destroy___0=function(){return(Ux= -b._emscripten_bind_btRaycastVehicle___destroy___0=b.asm.Dv).apply(null,arguments)},Vx=b._emscripten_bind_btPairCachingGhostObject_btPairCachingGhostObject_0=function(){return(Vx=b._emscripten_bind_btPairCachingGhostObject_btPairCachingGhostObject_0=b.asm.Ev).apply(null,arguments)},Wx=b._emscripten_bind_btPairCachingGhostObject_setAnisotropicFriction_2=function(){return(Wx=b._emscripten_bind_btPairCachingGhostObject_setAnisotropicFriction_2=b.asm.Fv).apply(null,arguments)},Xx=b._emscripten_bind_btPairCachingGhostObject_getCollisionShape_0= -function(){return(Xx=b._emscripten_bind_btPairCachingGhostObject_getCollisionShape_0=b.asm.Gv).apply(null,arguments)},Yx=b._emscripten_bind_btPairCachingGhostObject_setContactProcessingThreshold_1=function(){return(Yx=b._emscripten_bind_btPairCachingGhostObject_setContactProcessingThreshold_1=b.asm.Hv).apply(null,arguments)},Zx=b._emscripten_bind_btPairCachingGhostObject_setActivationState_1=function(){return(Zx=b._emscripten_bind_btPairCachingGhostObject_setActivationState_1=b.asm.Iv).apply(null, -arguments)},$x=b._emscripten_bind_btPairCachingGhostObject_forceActivationState_1=function(){return($x=b._emscripten_bind_btPairCachingGhostObject_forceActivationState_1=b.asm.Jv).apply(null,arguments)},ay=b._emscripten_bind_btPairCachingGhostObject_activate_0=function(){return(ay=b._emscripten_bind_btPairCachingGhostObject_activate_0=b.asm.Kv).apply(null,arguments)},by=b._emscripten_bind_btPairCachingGhostObject_activate_1=function(){return(by=b._emscripten_bind_btPairCachingGhostObject_activate_1= -b.asm.Lv).apply(null,arguments)},cy=b._emscripten_bind_btPairCachingGhostObject_isActive_0=function(){return(cy=b._emscripten_bind_btPairCachingGhostObject_isActive_0=b.asm.Mv).apply(null,arguments)},dy=b._emscripten_bind_btPairCachingGhostObject_isKinematicObject_0=function(){return(dy=b._emscripten_bind_btPairCachingGhostObject_isKinematicObject_0=b.asm.Nv).apply(null,arguments)},ey=b._emscripten_bind_btPairCachingGhostObject_isStaticObject_0=function(){return(ey=b._emscripten_bind_btPairCachingGhostObject_isStaticObject_0= -b.asm.Ov).apply(null,arguments)},fy=b._emscripten_bind_btPairCachingGhostObject_isStaticOrKinematicObject_0=function(){return(fy=b._emscripten_bind_btPairCachingGhostObject_isStaticOrKinematicObject_0=b.asm.Pv).apply(null,arguments)},gy=b._emscripten_bind_btPairCachingGhostObject_getRestitution_0=function(){return(gy=b._emscripten_bind_btPairCachingGhostObject_getRestitution_0=b.asm.Qv).apply(null,arguments)},hy=b._emscripten_bind_btPairCachingGhostObject_getFriction_0=function(){return(hy=b._emscripten_bind_btPairCachingGhostObject_getFriction_0= -b.asm.Rv).apply(null,arguments)},iy=b._emscripten_bind_btPairCachingGhostObject_getRollingFriction_0=function(){return(iy=b._emscripten_bind_btPairCachingGhostObject_getRollingFriction_0=b.asm.Sv).apply(null,arguments)},jy=b._emscripten_bind_btPairCachingGhostObject_setRestitution_1=function(){return(jy=b._emscripten_bind_btPairCachingGhostObject_setRestitution_1=b.asm.Tv).apply(null,arguments)},ky=b._emscripten_bind_btPairCachingGhostObject_setFriction_1=function(){return(ky=b._emscripten_bind_btPairCachingGhostObject_setFriction_1= -b.asm.Uv).apply(null,arguments)},ly=b._emscripten_bind_btPairCachingGhostObject_setRollingFriction_1=function(){return(ly=b._emscripten_bind_btPairCachingGhostObject_setRollingFriction_1=b.asm.Vv).apply(null,arguments)},my=b._emscripten_bind_btPairCachingGhostObject_getWorldTransform_0=function(){return(my=b._emscripten_bind_btPairCachingGhostObject_getWorldTransform_0=b.asm.Wv).apply(null,arguments)},ny=b._emscripten_bind_btPairCachingGhostObject_getCollisionFlags_0=function(){return(ny=b._emscripten_bind_btPairCachingGhostObject_getCollisionFlags_0= -b.asm.Xv).apply(null,arguments)},oy=b._emscripten_bind_btPairCachingGhostObject_setCollisionFlags_1=function(){return(oy=b._emscripten_bind_btPairCachingGhostObject_setCollisionFlags_1=b.asm.Yv).apply(null,arguments)},py=b._emscripten_bind_btPairCachingGhostObject_setWorldTransform_1=function(){return(py=b._emscripten_bind_btPairCachingGhostObject_setWorldTransform_1=b.asm.Zv).apply(null,arguments)},qy=b._emscripten_bind_btPairCachingGhostObject_setCollisionShape_1=function(){return(qy=b._emscripten_bind_btPairCachingGhostObject_setCollisionShape_1= -b.asm._v).apply(null,arguments)},ry=b._emscripten_bind_btPairCachingGhostObject_setCcdMotionThreshold_1=function(){return(ry=b._emscripten_bind_btPairCachingGhostObject_setCcdMotionThreshold_1=b.asm.$v).apply(null,arguments)},sy=b._emscripten_bind_btPairCachingGhostObject_setCcdSweptSphereRadius_1=function(){return(sy=b._emscripten_bind_btPairCachingGhostObject_setCcdSweptSphereRadius_1=b.asm.aw).apply(null,arguments)},ty=b._emscripten_bind_btPairCachingGhostObject_getUserIndex_0=function(){return(ty= -b._emscripten_bind_btPairCachingGhostObject_getUserIndex_0=b.asm.bw).apply(null,arguments)},uy=b._emscripten_bind_btPairCachingGhostObject_setUserIndex_1=function(){return(uy=b._emscripten_bind_btPairCachingGhostObject_setUserIndex_1=b.asm.cw).apply(null,arguments)},vy=b._emscripten_bind_btPairCachingGhostObject_getUserPointer_0=function(){return(vy=b._emscripten_bind_btPairCachingGhostObject_getUserPointer_0=b.asm.dw).apply(null,arguments)},wy=b._emscripten_bind_btPairCachingGhostObject_setUserPointer_1= -function(){return(wy=b._emscripten_bind_btPairCachingGhostObject_setUserPointer_1=b.asm.ew).apply(null,arguments)},xy=b._emscripten_bind_btPairCachingGhostObject_getBroadphaseHandle_0=function(){return(xy=b._emscripten_bind_btPairCachingGhostObject_getBroadphaseHandle_0=b.asm.fw).apply(null,arguments)},yy=b._emscripten_bind_btPairCachingGhostObject_getNumOverlappingObjects_0=function(){return(yy=b._emscripten_bind_btPairCachingGhostObject_getNumOverlappingObjects_0=b.asm.gw).apply(null,arguments)}, -zy=b._emscripten_bind_btPairCachingGhostObject_getOverlappingObject_1=function(){return(zy=b._emscripten_bind_btPairCachingGhostObject_getOverlappingObject_1=b.asm.hw).apply(null,arguments)},Ay=b._emscripten_bind_btPairCachingGhostObject___destroy___0=function(){return(Ay=b._emscripten_bind_btPairCachingGhostObject___destroy___0=b.asm.iw).apply(null,arguments)},By=b._emscripten_bind_btGhostPairCallback_btGhostPairCallback_0=function(){return(By=b._emscripten_bind_btGhostPairCallback_btGhostPairCallback_0= -b.asm.jw).apply(null,arguments)},Cy=b._emscripten_bind_btGhostPairCallback___destroy___0=function(){return(Cy=b._emscripten_bind_btGhostPairCallback___destroy___0=b.asm.kw).apply(null,arguments)},Dy=b._emscripten_bind_btSoftBodyWorldInfo_btSoftBodyWorldInfo_0=function(){return(Dy=b._emscripten_bind_btSoftBodyWorldInfo_btSoftBodyWorldInfo_0=b.asm.lw).apply(null,arguments)},Ey=b._emscripten_bind_btSoftBodyWorldInfo_get_air_density_0=function(){return(Ey=b._emscripten_bind_btSoftBodyWorldInfo_get_air_density_0= -b.asm.mw).apply(null,arguments)},Fy=b._emscripten_bind_btSoftBodyWorldInfo_set_air_density_1=function(){return(Fy=b._emscripten_bind_btSoftBodyWorldInfo_set_air_density_1=b.asm.nw).apply(null,arguments)},Gy=b._emscripten_bind_btSoftBodyWorldInfo_get_water_density_0=function(){return(Gy=b._emscripten_bind_btSoftBodyWorldInfo_get_water_density_0=b.asm.ow).apply(null,arguments)},Hy=b._emscripten_bind_btSoftBodyWorldInfo_set_water_density_1=function(){return(Hy=b._emscripten_bind_btSoftBodyWorldInfo_set_water_density_1= -b.asm.pw).apply(null,arguments)},Iy=b._emscripten_bind_btSoftBodyWorldInfo_get_water_offset_0=function(){return(Iy=b._emscripten_bind_btSoftBodyWorldInfo_get_water_offset_0=b.asm.qw).apply(null,arguments)},Jy=b._emscripten_bind_btSoftBodyWorldInfo_set_water_offset_1=function(){return(Jy=b._emscripten_bind_btSoftBodyWorldInfo_set_water_offset_1=b.asm.rw).apply(null,arguments)},Ky=b._emscripten_bind_btSoftBodyWorldInfo_get_m_maxDisplacement_0=function(){return(Ky=b._emscripten_bind_btSoftBodyWorldInfo_get_m_maxDisplacement_0= -b.asm.sw).apply(null,arguments)},Ly=b._emscripten_bind_btSoftBodyWorldInfo_set_m_maxDisplacement_1=function(){return(Ly=b._emscripten_bind_btSoftBodyWorldInfo_set_m_maxDisplacement_1=b.asm.tw).apply(null,arguments)},My=b._emscripten_bind_btSoftBodyWorldInfo_get_water_normal_0=function(){return(My=b._emscripten_bind_btSoftBodyWorldInfo_get_water_normal_0=b.asm.uw).apply(null,arguments)},Ny=b._emscripten_bind_btSoftBodyWorldInfo_set_water_normal_1=function(){return(Ny=b._emscripten_bind_btSoftBodyWorldInfo_set_water_normal_1= -b.asm.vw).apply(null,arguments)},Oy=b._emscripten_bind_btSoftBodyWorldInfo_get_m_broadphase_0=function(){return(Oy=b._emscripten_bind_btSoftBodyWorldInfo_get_m_broadphase_0=b.asm.ww).apply(null,arguments)},Py=b._emscripten_bind_btSoftBodyWorldInfo_set_m_broadphase_1=function(){return(Py=b._emscripten_bind_btSoftBodyWorldInfo_set_m_broadphase_1=b.asm.xw).apply(null,arguments)},Qy=b._emscripten_bind_btSoftBodyWorldInfo_get_m_dispatcher_0=function(){return(Qy=b._emscripten_bind_btSoftBodyWorldInfo_get_m_dispatcher_0= -b.asm.yw).apply(null,arguments)},Ry=b._emscripten_bind_btSoftBodyWorldInfo_set_m_dispatcher_1=function(){return(Ry=b._emscripten_bind_btSoftBodyWorldInfo_set_m_dispatcher_1=b.asm.zw).apply(null,arguments)},Sy=b._emscripten_bind_btSoftBodyWorldInfo_get_m_gravity_0=function(){return(Sy=b._emscripten_bind_btSoftBodyWorldInfo_get_m_gravity_0=b.asm.Aw).apply(null,arguments)},Ty=b._emscripten_bind_btSoftBodyWorldInfo_set_m_gravity_1=function(){return(Ty=b._emscripten_bind_btSoftBodyWorldInfo_set_m_gravity_1= -b.asm.Bw).apply(null,arguments)},Uy=b._emscripten_bind_btSoftBodyWorldInfo___destroy___0=function(){return(Uy=b._emscripten_bind_btSoftBodyWorldInfo___destroy___0=b.asm.Cw).apply(null,arguments)},Vy=b._emscripten_bind_Face_get_m_n_1=function(){return(Vy=b._emscripten_bind_Face_get_m_n_1=b.asm.Dw).apply(null,arguments)},Wy=b._emscripten_bind_Face_set_m_n_2=function(){return(Wy=b._emscripten_bind_Face_set_m_n_2=b.asm.Ew).apply(null,arguments)},Xy=b._emscripten_bind_Face_get_m_normal_0=function(){return(Xy= -b._emscripten_bind_Face_get_m_normal_0=b.asm.Fw).apply(null,arguments)},Yy=b._emscripten_bind_Face_set_m_normal_1=function(){return(Yy=b._emscripten_bind_Face_set_m_normal_1=b.asm.Gw).apply(null,arguments)},Zy=b._emscripten_bind_Face_get_m_ra_0=function(){return(Zy=b._emscripten_bind_Face_get_m_ra_0=b.asm.Hw).apply(null,arguments)},$y=b._emscripten_bind_Face_set_m_ra_1=function(){return($y=b._emscripten_bind_Face_set_m_ra_1=b.asm.Iw).apply(null,arguments)},az=b._emscripten_bind_Face___destroy___0= -function(){return(az=b._emscripten_bind_Face___destroy___0=b.asm.Jw).apply(null,arguments)},bz=b._emscripten_bind_tFaceArray_size_0=function(){return(bz=b._emscripten_bind_tFaceArray_size_0=b.asm.Kw).apply(null,arguments)},cz=b._emscripten_bind_tFaceArray_at_1=function(){return(cz=b._emscripten_bind_tFaceArray_at_1=b.asm.Lw).apply(null,arguments)},dz=b._emscripten_bind_tFaceArray___destroy___0=function(){return(dz=b._emscripten_bind_tFaceArray___destroy___0=b.asm.Mw).apply(null,arguments)},ez=b._emscripten_bind_Node_get_m_x_0= -function(){return(ez=b._emscripten_bind_Node_get_m_x_0=b.asm.Nw).apply(null,arguments)},fz=b._emscripten_bind_Node_set_m_x_1=function(){return(fz=b._emscripten_bind_Node_set_m_x_1=b.asm.Ow).apply(null,arguments)},gz=b._emscripten_bind_Node_get_m_q_0=function(){return(gz=b._emscripten_bind_Node_get_m_q_0=b.asm.Pw).apply(null,arguments)},hz=b._emscripten_bind_Node_set_m_q_1=function(){return(hz=b._emscripten_bind_Node_set_m_q_1=b.asm.Qw).apply(null,arguments)},iz=b._emscripten_bind_Node_get_m_v_0=function(){return(iz= -b._emscripten_bind_Node_get_m_v_0=b.asm.Rw).apply(null,arguments)},jz=b._emscripten_bind_Node_set_m_v_1=function(){return(jz=b._emscripten_bind_Node_set_m_v_1=b.asm.Sw).apply(null,arguments)},kz=b._emscripten_bind_Node_get_m_f_0=function(){return(kz=b._emscripten_bind_Node_get_m_f_0=b.asm.Tw).apply(null,arguments)},lz=b._emscripten_bind_Node_set_m_f_1=function(){return(lz=b._emscripten_bind_Node_set_m_f_1=b.asm.Uw).apply(null,arguments)},mz=b._emscripten_bind_Node_get_m_n_0=function(){return(mz=b._emscripten_bind_Node_get_m_n_0= -b.asm.Vw).apply(null,arguments)},nz=b._emscripten_bind_Node_set_m_n_1=function(){return(nz=b._emscripten_bind_Node_set_m_n_1=b.asm.Ww).apply(null,arguments)},oz=b._emscripten_bind_Node_get_m_im_0=function(){return(oz=b._emscripten_bind_Node_get_m_im_0=b.asm.Xw).apply(null,arguments)},pz=b._emscripten_bind_Node_set_m_im_1=function(){return(pz=b._emscripten_bind_Node_set_m_im_1=b.asm.Yw).apply(null,arguments)},qz=b._emscripten_bind_Node_get_m_area_0=function(){return(qz=b._emscripten_bind_Node_get_m_area_0= -b.asm.Zw).apply(null,arguments)},rz=b._emscripten_bind_Node_set_m_area_1=function(){return(rz=b._emscripten_bind_Node_set_m_area_1=b.asm._w).apply(null,arguments)},sz=b._emscripten_bind_Node___destroy___0=function(){return(sz=b._emscripten_bind_Node___destroy___0=b.asm.$w).apply(null,arguments)},tz=b._emscripten_bind_tNodeArray_size_0=function(){return(tz=b._emscripten_bind_tNodeArray_size_0=b.asm.ax).apply(null,arguments)},uz=b._emscripten_bind_tNodeArray_at_1=function(){return(uz=b._emscripten_bind_tNodeArray_at_1= -b.asm.bx).apply(null,arguments)},vz=b._emscripten_bind_tNodeArray___destroy___0=function(){return(vz=b._emscripten_bind_tNodeArray___destroy___0=b.asm.cx).apply(null,arguments)},wz=b._emscripten_bind_Material_get_m_kLST_0=function(){return(wz=b._emscripten_bind_Material_get_m_kLST_0=b.asm.dx).apply(null,arguments)},xz=b._emscripten_bind_Material_set_m_kLST_1=function(){return(xz=b._emscripten_bind_Material_set_m_kLST_1=b.asm.ex).apply(null,arguments)},yz=b._emscripten_bind_Material_get_m_kAST_0=function(){return(yz= -b._emscripten_bind_Material_get_m_kAST_0=b.asm.fx).apply(null,arguments)},zz=b._emscripten_bind_Material_set_m_kAST_1=function(){return(zz=b._emscripten_bind_Material_set_m_kAST_1=b.asm.gx).apply(null,arguments)},Az=b._emscripten_bind_Material_get_m_kVST_0=function(){return(Az=b._emscripten_bind_Material_get_m_kVST_0=b.asm.hx).apply(null,arguments)},Bz=b._emscripten_bind_Material_set_m_kVST_1=function(){return(Bz=b._emscripten_bind_Material_set_m_kVST_1=b.asm.ix).apply(null,arguments)},Cz=b._emscripten_bind_Material_get_m_flags_0= -function(){return(Cz=b._emscripten_bind_Material_get_m_flags_0=b.asm.jx).apply(null,arguments)},Dz=b._emscripten_bind_Material_set_m_flags_1=function(){return(Dz=b._emscripten_bind_Material_set_m_flags_1=b.asm.kx).apply(null,arguments)},Ez=b._emscripten_bind_Material___destroy___0=function(){return(Ez=b._emscripten_bind_Material___destroy___0=b.asm.lx).apply(null,arguments)},Fz=b._emscripten_bind_tMaterialArray_size_0=function(){return(Fz=b._emscripten_bind_tMaterialArray_size_0=b.asm.mx).apply(null, -arguments)},Gz=b._emscripten_bind_tMaterialArray_at_1=function(){return(Gz=b._emscripten_bind_tMaterialArray_at_1=b.asm.nx).apply(null,arguments)},Hz=b._emscripten_bind_tMaterialArray___destroy___0=function(){return(Hz=b._emscripten_bind_tMaterialArray___destroy___0=b.asm.ox).apply(null,arguments)},Iz=b._emscripten_bind_Anchor_get_m_node_0=function(){return(Iz=b._emscripten_bind_Anchor_get_m_node_0=b.asm.px).apply(null,arguments)},Jz=b._emscripten_bind_Anchor_set_m_node_1=function(){return(Jz=b._emscripten_bind_Anchor_set_m_node_1= -b.asm.qx).apply(null,arguments)},Kz=b._emscripten_bind_Anchor_get_m_local_0=function(){return(Kz=b._emscripten_bind_Anchor_get_m_local_0=b.asm.rx).apply(null,arguments)},Lz=b._emscripten_bind_Anchor_set_m_local_1=function(){return(Lz=b._emscripten_bind_Anchor_set_m_local_1=b.asm.sx).apply(null,arguments)},Mz=b._emscripten_bind_Anchor_get_m_body_0=function(){return(Mz=b._emscripten_bind_Anchor_get_m_body_0=b.asm.tx).apply(null,arguments)},Nz=b._emscripten_bind_Anchor_set_m_body_1=function(){return(Nz= -b._emscripten_bind_Anchor_set_m_body_1=b.asm.ux).apply(null,arguments)},Oz=b._emscripten_bind_Anchor_get_m_influence_0=function(){return(Oz=b._emscripten_bind_Anchor_get_m_influence_0=b.asm.vx).apply(null,arguments)},Pz=b._emscripten_bind_Anchor_set_m_influence_1=function(){return(Pz=b._emscripten_bind_Anchor_set_m_influence_1=b.asm.wx).apply(null,arguments)},Qz=b._emscripten_bind_Anchor_get_m_c0_0=function(){return(Qz=b._emscripten_bind_Anchor_get_m_c0_0=b.asm.xx).apply(null,arguments)},Rz=b._emscripten_bind_Anchor_set_m_c0_1= -function(){return(Rz=b._emscripten_bind_Anchor_set_m_c0_1=b.asm.yx).apply(null,arguments)},Sz=b._emscripten_bind_Anchor_get_m_c1_0=function(){return(Sz=b._emscripten_bind_Anchor_get_m_c1_0=b.asm.zx).apply(null,arguments)},Tz=b._emscripten_bind_Anchor_set_m_c1_1=function(){return(Tz=b._emscripten_bind_Anchor_set_m_c1_1=b.asm.Ax).apply(null,arguments)},Uz=b._emscripten_bind_Anchor_get_m_c2_0=function(){return(Uz=b._emscripten_bind_Anchor_get_m_c2_0=b.asm.Bx).apply(null,arguments)},Vz=b._emscripten_bind_Anchor_set_m_c2_1= -function(){return(Vz=b._emscripten_bind_Anchor_set_m_c2_1=b.asm.Cx).apply(null,arguments)},Wz=b._emscripten_bind_Anchor___destroy___0=function(){return(Wz=b._emscripten_bind_Anchor___destroy___0=b.asm.Dx).apply(null,arguments)},Xz=b._emscripten_bind_tAnchorArray_size_0=function(){return(Xz=b._emscripten_bind_tAnchorArray_size_0=b.asm.Ex).apply(null,arguments)},Yz=b._emscripten_bind_tAnchorArray_at_1=function(){return(Yz=b._emscripten_bind_tAnchorArray_at_1=b.asm.Fx).apply(null,arguments)},Zz=b._emscripten_bind_tAnchorArray_clear_0= -function(){return(Zz=b._emscripten_bind_tAnchorArray_clear_0=b.asm.Gx).apply(null,arguments)},$z=b._emscripten_bind_tAnchorArray_push_back_1=function(){return($z=b._emscripten_bind_tAnchorArray_push_back_1=b.asm.Hx).apply(null,arguments)},aA=b._emscripten_bind_tAnchorArray_pop_back_0=function(){return(aA=b._emscripten_bind_tAnchorArray_pop_back_0=b.asm.Ix).apply(null,arguments)},bA=b._emscripten_bind_tAnchorArray___destroy___0=function(){return(bA=b._emscripten_bind_tAnchorArray___destroy___0=b.asm.Jx).apply(null, -arguments)},cA=b._emscripten_bind_Config_get_kVCF_0=function(){return(cA=b._emscripten_bind_Config_get_kVCF_0=b.asm.Kx).apply(null,arguments)},dA=b._emscripten_bind_Config_set_kVCF_1=function(){return(dA=b._emscripten_bind_Config_set_kVCF_1=b.asm.Lx).apply(null,arguments)},eA=b._emscripten_bind_Config_get_kDP_0=function(){return(eA=b._emscripten_bind_Config_get_kDP_0=b.asm.Mx).apply(null,arguments)},fA=b._emscripten_bind_Config_set_kDP_1=function(){return(fA=b._emscripten_bind_Config_set_kDP_1=b.asm.Nx).apply(null, -arguments)},gA=b._emscripten_bind_Config_get_kDG_0=function(){return(gA=b._emscripten_bind_Config_get_kDG_0=b.asm.Ox).apply(null,arguments)},hA=b._emscripten_bind_Config_set_kDG_1=function(){return(hA=b._emscripten_bind_Config_set_kDG_1=b.asm.Px).apply(null,arguments)},iA=b._emscripten_bind_Config_get_kLF_0=function(){return(iA=b._emscripten_bind_Config_get_kLF_0=b.asm.Qx).apply(null,arguments)},jA=b._emscripten_bind_Config_set_kLF_1=function(){return(jA=b._emscripten_bind_Config_set_kLF_1=b.asm.Rx).apply(null, -arguments)},kA=b._emscripten_bind_Config_get_kPR_0=function(){return(kA=b._emscripten_bind_Config_get_kPR_0=b.asm.Sx).apply(null,arguments)},lA=b._emscripten_bind_Config_set_kPR_1=function(){return(lA=b._emscripten_bind_Config_set_kPR_1=b.asm.Tx).apply(null,arguments)},mA=b._emscripten_bind_Config_get_kVC_0=function(){return(mA=b._emscripten_bind_Config_get_kVC_0=b.asm.Ux).apply(null,arguments)},nA=b._emscripten_bind_Config_set_kVC_1=function(){return(nA=b._emscripten_bind_Config_set_kVC_1=b.asm.Vx).apply(null, -arguments)},oA=b._emscripten_bind_Config_get_kDF_0=function(){return(oA=b._emscripten_bind_Config_get_kDF_0=b.asm.Wx).apply(null,arguments)},pA=b._emscripten_bind_Config_set_kDF_1=function(){return(pA=b._emscripten_bind_Config_set_kDF_1=b.asm.Xx).apply(null,arguments)},qA=b._emscripten_bind_Config_get_kMT_0=function(){return(qA=b._emscripten_bind_Config_get_kMT_0=b.asm.Yx).apply(null,arguments)},rA=b._emscripten_bind_Config_set_kMT_1=function(){return(rA=b._emscripten_bind_Config_set_kMT_1=b.asm.Zx).apply(null, -arguments)},sA=b._emscripten_bind_Config_get_kCHR_0=function(){return(sA=b._emscripten_bind_Config_get_kCHR_0=b.asm._x).apply(null,arguments)},tA=b._emscripten_bind_Config_set_kCHR_1=function(){return(tA=b._emscripten_bind_Config_set_kCHR_1=b.asm.$x).apply(null,arguments)},uA=b._emscripten_bind_Config_get_kKHR_0=function(){return(uA=b._emscripten_bind_Config_get_kKHR_0=b.asm.ay).apply(null,arguments)},vA=b._emscripten_bind_Config_set_kKHR_1=function(){return(vA=b._emscripten_bind_Config_set_kKHR_1= -b.asm.by).apply(null,arguments)},wA=b._emscripten_bind_Config_get_kSHR_0=function(){return(wA=b._emscripten_bind_Config_get_kSHR_0=b.asm.cy).apply(null,arguments)},xA=b._emscripten_bind_Config_set_kSHR_1=function(){return(xA=b._emscripten_bind_Config_set_kSHR_1=b.asm.dy).apply(null,arguments)},yA=b._emscripten_bind_Config_get_kAHR_0=function(){return(yA=b._emscripten_bind_Config_get_kAHR_0=b.asm.ey).apply(null,arguments)},zA=b._emscripten_bind_Config_set_kAHR_1=function(){return(zA=b._emscripten_bind_Config_set_kAHR_1= -b.asm.fy).apply(null,arguments)},AA=b._emscripten_bind_Config_get_kSRHR_CL_0=function(){return(AA=b._emscripten_bind_Config_get_kSRHR_CL_0=b.asm.gy).apply(null,arguments)},BA=b._emscripten_bind_Config_set_kSRHR_CL_1=function(){return(BA=b._emscripten_bind_Config_set_kSRHR_CL_1=b.asm.hy).apply(null,arguments)},CA=b._emscripten_bind_Config_get_kSKHR_CL_0=function(){return(CA=b._emscripten_bind_Config_get_kSKHR_CL_0=b.asm.iy).apply(null,arguments)},DA=b._emscripten_bind_Config_set_kSKHR_CL_1=function(){return(DA= -b._emscripten_bind_Config_set_kSKHR_CL_1=b.asm.jy).apply(null,arguments)},EA=b._emscripten_bind_Config_get_kSSHR_CL_0=function(){return(EA=b._emscripten_bind_Config_get_kSSHR_CL_0=b.asm.ky).apply(null,arguments)},FA=b._emscripten_bind_Config_set_kSSHR_CL_1=function(){return(FA=b._emscripten_bind_Config_set_kSSHR_CL_1=b.asm.ly).apply(null,arguments)},GA=b._emscripten_bind_Config_get_kSR_SPLT_CL_0=function(){return(GA=b._emscripten_bind_Config_get_kSR_SPLT_CL_0=b.asm.my).apply(null,arguments)},HA=b._emscripten_bind_Config_set_kSR_SPLT_CL_1= -function(){return(HA=b._emscripten_bind_Config_set_kSR_SPLT_CL_1=b.asm.ny).apply(null,arguments)},IA=b._emscripten_bind_Config_get_kSK_SPLT_CL_0=function(){return(IA=b._emscripten_bind_Config_get_kSK_SPLT_CL_0=b.asm.oy).apply(null,arguments)},JA=b._emscripten_bind_Config_set_kSK_SPLT_CL_1=function(){return(JA=b._emscripten_bind_Config_set_kSK_SPLT_CL_1=b.asm.py).apply(null,arguments)},KA=b._emscripten_bind_Config_get_kSS_SPLT_CL_0=function(){return(KA=b._emscripten_bind_Config_get_kSS_SPLT_CL_0=b.asm.qy).apply(null, -arguments)},LA=b._emscripten_bind_Config_set_kSS_SPLT_CL_1=function(){return(LA=b._emscripten_bind_Config_set_kSS_SPLT_CL_1=b.asm.ry).apply(null,arguments)},MA=b._emscripten_bind_Config_get_maxvolume_0=function(){return(MA=b._emscripten_bind_Config_get_maxvolume_0=b.asm.sy).apply(null,arguments)},NA=b._emscripten_bind_Config_set_maxvolume_1=function(){return(NA=b._emscripten_bind_Config_set_maxvolume_1=b.asm.ty).apply(null,arguments)},OA=b._emscripten_bind_Config_get_timescale_0=function(){return(OA= -b._emscripten_bind_Config_get_timescale_0=b.asm.uy).apply(null,arguments)},PA=b._emscripten_bind_Config_set_timescale_1=function(){return(PA=b._emscripten_bind_Config_set_timescale_1=b.asm.vy).apply(null,arguments)},QA=b._emscripten_bind_Config_get_viterations_0=function(){return(QA=b._emscripten_bind_Config_get_viterations_0=b.asm.wy).apply(null,arguments)},RA=b._emscripten_bind_Config_set_viterations_1=function(){return(RA=b._emscripten_bind_Config_set_viterations_1=b.asm.xy).apply(null,arguments)}, -SA=b._emscripten_bind_Config_get_piterations_0=function(){return(SA=b._emscripten_bind_Config_get_piterations_0=b.asm.yy).apply(null,arguments)},TA=b._emscripten_bind_Config_set_piterations_1=function(){return(TA=b._emscripten_bind_Config_set_piterations_1=b.asm.zy).apply(null,arguments)},UA=b._emscripten_bind_Config_get_diterations_0=function(){return(UA=b._emscripten_bind_Config_get_diterations_0=b.asm.Ay).apply(null,arguments)},VA=b._emscripten_bind_Config_set_diterations_1=function(){return(VA= -b._emscripten_bind_Config_set_diterations_1=b.asm.By).apply(null,arguments)},WA=b._emscripten_bind_Config_get_citerations_0=function(){return(WA=b._emscripten_bind_Config_get_citerations_0=b.asm.Cy).apply(null,arguments)},XA=b._emscripten_bind_Config_set_citerations_1=function(){return(XA=b._emscripten_bind_Config_set_citerations_1=b.asm.Dy).apply(null,arguments)},YA=b._emscripten_bind_Config_get_collisions_0=function(){return(YA=b._emscripten_bind_Config_get_collisions_0=b.asm.Ey).apply(null,arguments)}, -ZA=b._emscripten_bind_Config_set_collisions_1=function(){return(ZA=b._emscripten_bind_Config_set_collisions_1=b.asm.Fy).apply(null,arguments)},$A=b._emscripten_bind_Config___destroy___0=function(){return($A=b._emscripten_bind_Config___destroy___0=b.asm.Gy).apply(null,arguments)},aB=b._emscripten_bind_btSoftBody_btSoftBody_4=function(){return(aB=b._emscripten_bind_btSoftBody_btSoftBody_4=b.asm.Hy).apply(null,arguments)},bB=b._emscripten_bind_btSoftBody_checkLink_2=function(){return(bB=b._emscripten_bind_btSoftBody_checkLink_2= -b.asm.Iy).apply(null,arguments)},cB=b._emscripten_bind_btSoftBody_checkFace_3=function(){return(cB=b._emscripten_bind_btSoftBody_checkFace_3=b.asm.Jy).apply(null,arguments)},dB=b._emscripten_bind_btSoftBody_appendMaterial_0=function(){return(dB=b._emscripten_bind_btSoftBody_appendMaterial_0=b.asm.Ky).apply(null,arguments)},eB=b._emscripten_bind_btSoftBody_appendNode_2=function(){return(eB=b._emscripten_bind_btSoftBody_appendNode_2=b.asm.Ly).apply(null,arguments)},fB=b._emscripten_bind_btSoftBody_appendLink_4= -function(){return(fB=b._emscripten_bind_btSoftBody_appendLink_4=b.asm.My).apply(null,arguments)},gB=b._emscripten_bind_btSoftBody_appendFace_4=function(){return(gB=b._emscripten_bind_btSoftBody_appendFace_4=b.asm.Ny).apply(null,arguments)},hB=b._emscripten_bind_btSoftBody_appendTetra_5=function(){return(hB=b._emscripten_bind_btSoftBody_appendTetra_5=b.asm.Oy).apply(null,arguments)},iB=b._emscripten_bind_btSoftBody_appendAnchor_4=function(){return(iB=b._emscripten_bind_btSoftBody_appendAnchor_4=b.asm.Py).apply(null, -arguments)},jB=b._emscripten_bind_btSoftBody_addForce_1=function(){return(jB=b._emscripten_bind_btSoftBody_addForce_1=b.asm.Qy).apply(null,arguments)},kB=b._emscripten_bind_btSoftBody_addForce_2=function(){return(kB=b._emscripten_bind_btSoftBody_addForce_2=b.asm.Ry).apply(null,arguments)},lB=b._emscripten_bind_btSoftBody_addAeroForceToNode_2=function(){return(lB=b._emscripten_bind_btSoftBody_addAeroForceToNode_2=b.asm.Sy).apply(null,arguments)},mB=b._emscripten_bind_btSoftBody_getTotalMass_0=function(){return(mB= -b._emscripten_bind_btSoftBody_getTotalMass_0=b.asm.Ty).apply(null,arguments)},nB=b._emscripten_bind_btSoftBody_setTotalMass_2=function(){return(nB=b._emscripten_bind_btSoftBody_setTotalMass_2=b.asm.Uy).apply(null,arguments)},oB=b._emscripten_bind_btSoftBody_setMass_2=function(){return(oB=b._emscripten_bind_btSoftBody_setMass_2=b.asm.Vy).apply(null,arguments)},pB=b._emscripten_bind_btSoftBody_transform_1=function(){return(pB=b._emscripten_bind_btSoftBody_transform_1=b.asm.Wy).apply(null,arguments)}, -qB=b._emscripten_bind_btSoftBody_translate_1=function(){return(qB=b._emscripten_bind_btSoftBody_translate_1=b.asm.Xy).apply(null,arguments)},rB=b._emscripten_bind_btSoftBody_rotate_1=function(){return(rB=b._emscripten_bind_btSoftBody_rotate_1=b.asm.Yy).apply(null,arguments)},sB=b._emscripten_bind_btSoftBody_scale_1=function(){return(sB=b._emscripten_bind_btSoftBody_scale_1=b.asm.Zy).apply(null,arguments)},tB=b._emscripten_bind_btSoftBody_generateClusters_1=function(){return(tB=b._emscripten_bind_btSoftBody_generateClusters_1= -b.asm._y).apply(null,arguments)},uB=b._emscripten_bind_btSoftBody_generateClusters_2=function(){return(uB=b._emscripten_bind_btSoftBody_generateClusters_2=b.asm.$y).apply(null,arguments)},vB=b._emscripten_bind_btSoftBody_generateBendingConstraints_2=function(){return(vB=b._emscripten_bind_btSoftBody_generateBendingConstraints_2=b.asm.az).apply(null,arguments)},wB=b._emscripten_bind_btSoftBody_upcast_1=function(){return(wB=b._emscripten_bind_btSoftBody_upcast_1=b.asm.bz).apply(null,arguments)},xB= -b._emscripten_bind_btSoftBody_getRestLengthScale_0=function(){return(xB=b._emscripten_bind_btSoftBody_getRestLengthScale_0=b.asm.cz).apply(null,arguments)},yB=b._emscripten_bind_btSoftBody_setRestLengthScale_1=function(){return(yB=b._emscripten_bind_btSoftBody_setRestLengthScale_1=b.asm.dz).apply(null,arguments)},zB=b._emscripten_bind_btSoftBody_setAnisotropicFriction_2=function(){return(zB=b._emscripten_bind_btSoftBody_setAnisotropicFriction_2=b.asm.ez).apply(null,arguments)},AB=b._emscripten_bind_btSoftBody_getCollisionShape_0= -function(){return(AB=b._emscripten_bind_btSoftBody_getCollisionShape_0=b.asm.fz).apply(null,arguments)},BB=b._emscripten_bind_btSoftBody_setContactProcessingThreshold_1=function(){return(BB=b._emscripten_bind_btSoftBody_setContactProcessingThreshold_1=b.asm.gz).apply(null,arguments)},CB=b._emscripten_bind_btSoftBody_setActivationState_1=function(){return(CB=b._emscripten_bind_btSoftBody_setActivationState_1=b.asm.hz).apply(null,arguments)},DB=b._emscripten_bind_btSoftBody_forceActivationState_1=function(){return(DB= -b._emscripten_bind_btSoftBody_forceActivationState_1=b.asm.iz).apply(null,arguments)},EB=b._emscripten_bind_btSoftBody_activate_0=function(){return(EB=b._emscripten_bind_btSoftBody_activate_0=b.asm.jz).apply(null,arguments)},FB=b._emscripten_bind_btSoftBody_activate_1=function(){return(FB=b._emscripten_bind_btSoftBody_activate_1=b.asm.kz).apply(null,arguments)},GB=b._emscripten_bind_btSoftBody_isActive_0=function(){return(GB=b._emscripten_bind_btSoftBody_isActive_0=b.asm.lz).apply(null,arguments)}, -HB=b._emscripten_bind_btSoftBody_isKinematicObject_0=function(){return(HB=b._emscripten_bind_btSoftBody_isKinematicObject_0=b.asm.mz).apply(null,arguments)},IB=b._emscripten_bind_btSoftBody_isStaticObject_0=function(){return(IB=b._emscripten_bind_btSoftBody_isStaticObject_0=b.asm.nz).apply(null,arguments)},JB=b._emscripten_bind_btSoftBody_isStaticOrKinematicObject_0=function(){return(JB=b._emscripten_bind_btSoftBody_isStaticOrKinematicObject_0=b.asm.oz).apply(null,arguments)},KB=b._emscripten_bind_btSoftBody_getRestitution_0= -function(){return(KB=b._emscripten_bind_btSoftBody_getRestitution_0=b.asm.pz).apply(null,arguments)},LB=b._emscripten_bind_btSoftBody_getFriction_0=function(){return(LB=b._emscripten_bind_btSoftBody_getFriction_0=b.asm.qz).apply(null,arguments)},MB=b._emscripten_bind_btSoftBody_getRollingFriction_0=function(){return(MB=b._emscripten_bind_btSoftBody_getRollingFriction_0=b.asm.rz).apply(null,arguments)},NB=b._emscripten_bind_btSoftBody_setRestitution_1=function(){return(NB=b._emscripten_bind_btSoftBody_setRestitution_1= -b.asm.sz).apply(null,arguments)},OB=b._emscripten_bind_btSoftBody_setFriction_1=function(){return(OB=b._emscripten_bind_btSoftBody_setFriction_1=b.asm.tz).apply(null,arguments)},PB=b._emscripten_bind_btSoftBody_setRollingFriction_1=function(){return(PB=b._emscripten_bind_btSoftBody_setRollingFriction_1=b.asm.uz).apply(null,arguments)},QB=b._emscripten_bind_btSoftBody_getWorldTransform_0=function(){return(QB=b._emscripten_bind_btSoftBody_getWorldTransform_0=b.asm.vz).apply(null,arguments)},RB=b._emscripten_bind_btSoftBody_getCollisionFlags_0= -function(){return(RB=b._emscripten_bind_btSoftBody_getCollisionFlags_0=b.asm.wz).apply(null,arguments)},SB=b._emscripten_bind_btSoftBody_setCollisionFlags_1=function(){return(SB=b._emscripten_bind_btSoftBody_setCollisionFlags_1=b.asm.xz).apply(null,arguments)},TB=b._emscripten_bind_btSoftBody_setWorldTransform_1=function(){return(TB=b._emscripten_bind_btSoftBody_setWorldTransform_1=b.asm.yz).apply(null,arguments)},UB=b._emscripten_bind_btSoftBody_setCollisionShape_1=function(){return(UB=b._emscripten_bind_btSoftBody_setCollisionShape_1= -b.asm.zz).apply(null,arguments)},VB=b._emscripten_bind_btSoftBody_setCcdMotionThreshold_1=function(){return(VB=b._emscripten_bind_btSoftBody_setCcdMotionThreshold_1=b.asm.Az).apply(null,arguments)},WB=b._emscripten_bind_btSoftBody_setCcdSweptSphereRadius_1=function(){return(WB=b._emscripten_bind_btSoftBody_setCcdSweptSphereRadius_1=b.asm.Bz).apply(null,arguments)},XB=b._emscripten_bind_btSoftBody_getUserIndex_0=function(){return(XB=b._emscripten_bind_btSoftBody_getUserIndex_0=b.asm.Cz).apply(null, -arguments)},YB=b._emscripten_bind_btSoftBody_setUserIndex_1=function(){return(YB=b._emscripten_bind_btSoftBody_setUserIndex_1=b.asm.Dz).apply(null,arguments)},ZB=b._emscripten_bind_btSoftBody_getUserPointer_0=function(){return(ZB=b._emscripten_bind_btSoftBody_getUserPointer_0=b.asm.Ez).apply(null,arguments)},$B=b._emscripten_bind_btSoftBody_setUserPointer_1=function(){return($B=b._emscripten_bind_btSoftBody_setUserPointer_1=b.asm.Fz).apply(null,arguments)},aC=b._emscripten_bind_btSoftBody_getBroadphaseHandle_0= -function(){return(aC=b._emscripten_bind_btSoftBody_getBroadphaseHandle_0=b.asm.Gz).apply(null,arguments)},bC=b._emscripten_bind_btSoftBody_get_m_cfg_0=function(){return(bC=b._emscripten_bind_btSoftBody_get_m_cfg_0=b.asm.Hz).apply(null,arguments)},cC=b._emscripten_bind_btSoftBody_set_m_cfg_1=function(){return(cC=b._emscripten_bind_btSoftBody_set_m_cfg_1=b.asm.Iz).apply(null,arguments)},dC=b._emscripten_bind_btSoftBody_get_m_nodes_0=function(){return(dC=b._emscripten_bind_btSoftBody_get_m_nodes_0=b.asm.Jz).apply(null, -arguments)},eC=b._emscripten_bind_btSoftBody_set_m_nodes_1=function(){return(eC=b._emscripten_bind_btSoftBody_set_m_nodes_1=b.asm.Kz).apply(null,arguments)},fC=b._emscripten_bind_btSoftBody_get_m_faces_0=function(){return(fC=b._emscripten_bind_btSoftBody_get_m_faces_0=b.asm.Lz).apply(null,arguments)},gC=b._emscripten_bind_btSoftBody_set_m_faces_1=function(){return(gC=b._emscripten_bind_btSoftBody_set_m_faces_1=b.asm.Mz).apply(null,arguments)},hC=b._emscripten_bind_btSoftBody_get_m_materials_0=function(){return(hC= -b._emscripten_bind_btSoftBody_get_m_materials_0=b.asm.Nz).apply(null,arguments)},iC=b._emscripten_bind_btSoftBody_set_m_materials_1=function(){return(iC=b._emscripten_bind_btSoftBody_set_m_materials_1=b.asm.Oz).apply(null,arguments)},jC=b._emscripten_bind_btSoftBody_get_m_anchors_0=function(){return(jC=b._emscripten_bind_btSoftBody_get_m_anchors_0=b.asm.Pz).apply(null,arguments)},kC=b._emscripten_bind_btSoftBody_set_m_anchors_1=function(){return(kC=b._emscripten_bind_btSoftBody_set_m_anchors_1=b.asm.Qz).apply(null, -arguments)},lC=b._emscripten_bind_btSoftBody___destroy___0=function(){return(lC=b._emscripten_bind_btSoftBody___destroy___0=b.asm.Rz).apply(null,arguments)},mC=b._emscripten_bind_btSoftBodyRigidBodyCollisionConfiguration_btSoftBodyRigidBodyCollisionConfiguration_0=function(){return(mC=b._emscripten_bind_btSoftBodyRigidBodyCollisionConfiguration_btSoftBodyRigidBodyCollisionConfiguration_0=b.asm.Sz).apply(null,arguments)},nC=b._emscripten_bind_btSoftBodyRigidBodyCollisionConfiguration_btSoftBodyRigidBodyCollisionConfiguration_1= -function(){return(nC=b._emscripten_bind_btSoftBodyRigidBodyCollisionConfiguration_btSoftBodyRigidBodyCollisionConfiguration_1=b.asm.Tz).apply(null,arguments)},oC=b._emscripten_bind_btSoftBodyRigidBodyCollisionConfiguration___destroy___0=function(){return(oC=b._emscripten_bind_btSoftBodyRigidBodyCollisionConfiguration___destroy___0=b.asm.Uz).apply(null,arguments)},pC=b._emscripten_bind_btDefaultSoftBodySolver_btDefaultSoftBodySolver_0=function(){return(pC=b._emscripten_bind_btDefaultSoftBodySolver_btDefaultSoftBodySolver_0= -b.asm.Vz).apply(null,arguments)},qC=b._emscripten_bind_btDefaultSoftBodySolver___destroy___0=function(){return(qC=b._emscripten_bind_btDefaultSoftBodySolver___destroy___0=b.asm.Wz).apply(null,arguments)},rC=b._emscripten_bind_btSoftBodyArray_size_0=function(){return(rC=b._emscripten_bind_btSoftBodyArray_size_0=b.asm.Xz).apply(null,arguments)},sC=b._emscripten_bind_btSoftBodyArray_at_1=function(){return(sC=b._emscripten_bind_btSoftBodyArray_at_1=b.asm.Yz).apply(null,arguments)},tC=b._emscripten_bind_btSoftBodyArray___destroy___0= -function(){return(tC=b._emscripten_bind_btSoftBodyArray___destroy___0=b.asm.Zz).apply(null,arguments)},uC=b._emscripten_bind_btSoftRigidDynamicsWorld_btSoftRigidDynamicsWorld_5=function(){return(uC=b._emscripten_bind_btSoftRigidDynamicsWorld_btSoftRigidDynamicsWorld_5=b.asm._z).apply(null,arguments)},vC=b._emscripten_bind_btSoftRigidDynamicsWorld_addSoftBody_3=function(){return(vC=b._emscripten_bind_btSoftRigidDynamicsWorld_addSoftBody_3=b.asm.$z).apply(null,arguments)},wC=b._emscripten_bind_btSoftRigidDynamicsWorld_removeSoftBody_1= -function(){return(wC=b._emscripten_bind_btSoftRigidDynamicsWorld_removeSoftBody_1=b.asm.aA).apply(null,arguments)},xC=b._emscripten_bind_btSoftRigidDynamicsWorld_removeCollisionObject_1=function(){return(xC=b._emscripten_bind_btSoftRigidDynamicsWorld_removeCollisionObject_1=b.asm.bA).apply(null,arguments)},yC=b._emscripten_bind_btSoftRigidDynamicsWorld_getWorldInfo_0=function(){return(yC=b._emscripten_bind_btSoftRigidDynamicsWorld_getWorldInfo_0=b.asm.cA).apply(null,arguments)},zC=b._emscripten_bind_btSoftRigidDynamicsWorld_getSoftBodyArray_0= -function(){return(zC=b._emscripten_bind_btSoftRigidDynamicsWorld_getSoftBodyArray_0=b.asm.dA).apply(null,arguments)},AC=b._emscripten_bind_btSoftRigidDynamicsWorld_getDispatcher_0=function(){return(AC=b._emscripten_bind_btSoftRigidDynamicsWorld_getDispatcher_0=b.asm.eA).apply(null,arguments)},BC=b._emscripten_bind_btSoftRigidDynamicsWorld_rayTest_3=function(){return(BC=b._emscripten_bind_btSoftRigidDynamicsWorld_rayTest_3=b.asm.fA).apply(null,arguments)},CC=b._emscripten_bind_btSoftRigidDynamicsWorld_getPairCache_0= -function(){return(CC=b._emscripten_bind_btSoftRigidDynamicsWorld_getPairCache_0=b.asm.gA).apply(null,arguments)},DC=b._emscripten_bind_btSoftRigidDynamicsWorld_getDispatchInfo_0=function(){return(DC=b._emscripten_bind_btSoftRigidDynamicsWorld_getDispatchInfo_0=b.asm.hA).apply(null,arguments)},EC=b._emscripten_bind_btSoftRigidDynamicsWorld_addCollisionObject_1=function(){return(EC=b._emscripten_bind_btSoftRigidDynamicsWorld_addCollisionObject_1=b.asm.iA).apply(null,arguments)},FC=b._emscripten_bind_btSoftRigidDynamicsWorld_addCollisionObject_2= -function(){return(FC=b._emscripten_bind_btSoftRigidDynamicsWorld_addCollisionObject_2=b.asm.jA).apply(null,arguments)},GC=b._emscripten_bind_btSoftRigidDynamicsWorld_addCollisionObject_3=function(){return(GC=b._emscripten_bind_btSoftRigidDynamicsWorld_addCollisionObject_3=b.asm.kA).apply(null,arguments)},HC=b._emscripten_bind_btSoftRigidDynamicsWorld_getBroadphase_0=function(){return(HC=b._emscripten_bind_btSoftRigidDynamicsWorld_getBroadphase_0=b.asm.lA).apply(null,arguments)},IC=b._emscripten_bind_btSoftRigidDynamicsWorld_convexSweepTest_5= -function(){return(IC=b._emscripten_bind_btSoftRigidDynamicsWorld_convexSweepTest_5=b.asm.mA).apply(null,arguments)},JC=b._emscripten_bind_btSoftRigidDynamicsWorld_contactPairTest_3=function(){return(JC=b._emscripten_bind_btSoftRigidDynamicsWorld_contactPairTest_3=b.asm.nA).apply(null,arguments)},KC=b._emscripten_bind_btSoftRigidDynamicsWorld_contactTest_2=function(){return(KC=b._emscripten_bind_btSoftRigidDynamicsWorld_contactTest_2=b.asm.oA).apply(null,arguments)},LC=b._emscripten_bind_btSoftRigidDynamicsWorld_updateSingleAabb_1= -function(){return(LC=b._emscripten_bind_btSoftRigidDynamicsWorld_updateSingleAabb_1=b.asm.pA).apply(null,arguments)},MC=b._emscripten_bind_btSoftRigidDynamicsWorld_setDebugDrawer_1=function(){return(MC=b._emscripten_bind_btSoftRigidDynamicsWorld_setDebugDrawer_1=b.asm.qA).apply(null,arguments)},NC=b._emscripten_bind_btSoftRigidDynamicsWorld_getDebugDrawer_0=function(){return(NC=b._emscripten_bind_btSoftRigidDynamicsWorld_getDebugDrawer_0=b.asm.rA).apply(null,arguments)},OC=b._emscripten_bind_btSoftRigidDynamicsWorld_debugDrawWorld_0= -function(){return(OC=b._emscripten_bind_btSoftRigidDynamicsWorld_debugDrawWorld_0=b.asm.sA).apply(null,arguments)},PC=b._emscripten_bind_btSoftRigidDynamicsWorld_debugDrawObject_3=function(){return(PC=b._emscripten_bind_btSoftRigidDynamicsWorld_debugDrawObject_3=b.asm.tA).apply(null,arguments)},QC=b._emscripten_bind_btSoftRigidDynamicsWorld_setGravity_1=function(){return(QC=b._emscripten_bind_btSoftRigidDynamicsWorld_setGravity_1=b.asm.uA).apply(null,arguments)},RC=b._emscripten_bind_btSoftRigidDynamicsWorld_getGravity_0= -function(){return(RC=b._emscripten_bind_btSoftRigidDynamicsWorld_getGravity_0=b.asm.vA).apply(null,arguments)},SC=b._emscripten_bind_btSoftRigidDynamicsWorld_addRigidBody_1=function(){return(SC=b._emscripten_bind_btSoftRigidDynamicsWorld_addRigidBody_1=b.asm.wA).apply(null,arguments)},TC=b._emscripten_bind_btSoftRigidDynamicsWorld_addRigidBody_3=function(){return(TC=b._emscripten_bind_btSoftRigidDynamicsWorld_addRigidBody_3=b.asm.xA).apply(null,arguments)},UC=b._emscripten_bind_btSoftRigidDynamicsWorld_removeRigidBody_1= -function(){return(UC=b._emscripten_bind_btSoftRigidDynamicsWorld_removeRigidBody_1=b.asm.yA).apply(null,arguments)},VC=b._emscripten_bind_btSoftRigidDynamicsWorld_addConstraint_1=function(){return(VC=b._emscripten_bind_btSoftRigidDynamicsWorld_addConstraint_1=b.asm.zA).apply(null,arguments)},WC=b._emscripten_bind_btSoftRigidDynamicsWorld_addConstraint_2=function(){return(WC=b._emscripten_bind_btSoftRigidDynamicsWorld_addConstraint_2=b.asm.AA).apply(null,arguments)},XC=b._emscripten_bind_btSoftRigidDynamicsWorld_removeConstraint_1= -function(){return(XC=b._emscripten_bind_btSoftRigidDynamicsWorld_removeConstraint_1=b.asm.BA).apply(null,arguments)},YC=b._emscripten_bind_btSoftRigidDynamicsWorld_stepSimulation_1=function(){return(YC=b._emscripten_bind_btSoftRigidDynamicsWorld_stepSimulation_1=b.asm.CA).apply(null,arguments)},ZC=b._emscripten_bind_btSoftRigidDynamicsWorld_stepSimulation_2=function(){return(ZC=b._emscripten_bind_btSoftRigidDynamicsWorld_stepSimulation_2=b.asm.DA).apply(null,arguments)},$C=b._emscripten_bind_btSoftRigidDynamicsWorld_stepSimulation_3= -function(){return($C=b._emscripten_bind_btSoftRigidDynamicsWorld_stepSimulation_3=b.asm.EA).apply(null,arguments)},aD=b._emscripten_bind_btSoftRigidDynamicsWorld_setContactAddedCallback_1=function(){return(aD=b._emscripten_bind_btSoftRigidDynamicsWorld_setContactAddedCallback_1=b.asm.FA).apply(null,arguments)},bD=b._emscripten_bind_btSoftRigidDynamicsWorld_setContactProcessedCallback_1=function(){return(bD=b._emscripten_bind_btSoftRigidDynamicsWorld_setContactProcessedCallback_1=b.asm.GA).apply(null, -arguments)},cD=b._emscripten_bind_btSoftRigidDynamicsWorld_setContactDestroyedCallback_1=function(){return(cD=b._emscripten_bind_btSoftRigidDynamicsWorld_setContactDestroyedCallback_1=b.asm.HA).apply(null,arguments)},dD=b._emscripten_bind_btSoftRigidDynamicsWorld_addAction_1=function(){return(dD=b._emscripten_bind_btSoftRigidDynamicsWorld_addAction_1=b.asm.IA).apply(null,arguments)},eD=b._emscripten_bind_btSoftRigidDynamicsWorld_removeAction_1=function(){return(eD=b._emscripten_bind_btSoftRigidDynamicsWorld_removeAction_1= -b.asm.JA).apply(null,arguments)},fD=b._emscripten_bind_btSoftRigidDynamicsWorld_getSolverInfo_0=function(){return(fD=b._emscripten_bind_btSoftRigidDynamicsWorld_getSolverInfo_0=b.asm.KA).apply(null,arguments)},gD=b._emscripten_bind_btSoftRigidDynamicsWorld_setInternalTickCallback_1=function(){return(gD=b._emscripten_bind_btSoftRigidDynamicsWorld_setInternalTickCallback_1=b.asm.LA).apply(null,arguments)},hD=b._emscripten_bind_btSoftRigidDynamicsWorld_setInternalTickCallback_2=function(){return(hD= -b._emscripten_bind_btSoftRigidDynamicsWorld_setInternalTickCallback_2=b.asm.MA).apply(null,arguments)},iD=b._emscripten_bind_btSoftRigidDynamicsWorld_setInternalTickCallback_3=function(){return(iD=b._emscripten_bind_btSoftRigidDynamicsWorld_setInternalTickCallback_3=b.asm.NA).apply(null,arguments)},jD=b._emscripten_bind_btSoftRigidDynamicsWorld___destroy___0=function(){return(jD=b._emscripten_bind_btSoftRigidDynamicsWorld___destroy___0=b.asm.OA).apply(null,arguments)},kD=b._emscripten_bind_btSoftBodyHelpers_btSoftBodyHelpers_0= -function(){return(kD=b._emscripten_bind_btSoftBodyHelpers_btSoftBodyHelpers_0=b.asm.PA).apply(null,arguments)},lD=b._emscripten_bind_btSoftBodyHelpers_CreateRope_5=function(){return(lD=b._emscripten_bind_btSoftBodyHelpers_CreateRope_5=b.asm.QA).apply(null,arguments)},mD=b._emscripten_bind_btSoftBodyHelpers_CreatePatch_9=function(){return(mD=b._emscripten_bind_btSoftBodyHelpers_CreatePatch_9=b.asm.RA).apply(null,arguments)},nD=b._emscripten_bind_btSoftBodyHelpers_CreatePatchUV_10=function(){return(nD= -b._emscripten_bind_btSoftBodyHelpers_CreatePatchUV_10=b.asm.SA).apply(null,arguments)},oD=b._emscripten_bind_btSoftBodyHelpers_CreateEllipsoid_4=function(){return(oD=b._emscripten_bind_btSoftBodyHelpers_CreateEllipsoid_4=b.asm.TA).apply(null,arguments)},pD=b._emscripten_bind_btSoftBodyHelpers_CreateFromTriMesh_5=function(){return(pD=b._emscripten_bind_btSoftBodyHelpers_CreateFromTriMesh_5=b.asm.UA).apply(null,arguments)},qD=b._emscripten_bind_btSoftBodyHelpers_CreateFromConvexHull_4=function(){return(qD= -b._emscripten_bind_btSoftBodyHelpers_CreateFromConvexHull_4=b.asm.VA).apply(null,arguments)},rD=b._emscripten_bind_btSoftBodyHelpers___destroy___0=function(){return(rD=b._emscripten_bind_btSoftBodyHelpers___destroy___0=b.asm.WA).apply(null,arguments)},sD=b._emscripten_enum_PHY_ScalarType_PHY_FLOAT=function(){return(sD=b._emscripten_enum_PHY_ScalarType_PHY_FLOAT=b.asm.XA).apply(null,arguments)},tD=b._emscripten_enum_PHY_ScalarType_PHY_DOUBLE=function(){return(tD=b._emscripten_enum_PHY_ScalarType_PHY_DOUBLE= -b.asm.YA).apply(null,arguments)},uD=b._emscripten_enum_PHY_ScalarType_PHY_INTEGER=function(){return(uD=b._emscripten_enum_PHY_ScalarType_PHY_INTEGER=b.asm.ZA).apply(null,arguments)},vD=b._emscripten_enum_PHY_ScalarType_PHY_SHORT=function(){return(vD=b._emscripten_enum_PHY_ScalarType_PHY_SHORT=b.asm._A).apply(null,arguments)},wD=b._emscripten_enum_PHY_ScalarType_PHY_FIXEDPOINT88=function(){return(wD=b._emscripten_enum_PHY_ScalarType_PHY_FIXEDPOINT88=b.asm.$A).apply(null,arguments)},xD=b._emscripten_enum_PHY_ScalarType_PHY_UCHAR= -function(){return(xD=b._emscripten_enum_PHY_ScalarType_PHY_UCHAR=b.asm.aB).apply(null,arguments)},yD=b._emscripten_enum_eGIMPACT_SHAPE_TYPE_CONST_GIMPACT_COMPOUND_SHAPE=function(){return(yD=b._emscripten_enum_eGIMPACT_SHAPE_TYPE_CONST_GIMPACT_COMPOUND_SHAPE=b.asm.bB).apply(null,arguments)},zD=b._emscripten_enum_eGIMPACT_SHAPE_TYPE_CONST_GIMPACT_TRIMESH_SHAPE_PART=function(){return(zD=b._emscripten_enum_eGIMPACT_SHAPE_TYPE_CONST_GIMPACT_TRIMESH_SHAPE_PART=b.asm.cB).apply(null,arguments)},AD=b._emscripten_enum_eGIMPACT_SHAPE_TYPE_CONST_GIMPACT_TRIMESH_SHAPE= -function(){return(AD=b._emscripten_enum_eGIMPACT_SHAPE_TYPE_CONST_GIMPACT_TRIMESH_SHAPE=b.asm.dB).apply(null,arguments)},BD=b._emscripten_enum_btConstraintParams_BT_CONSTRAINT_ERP=function(){return(BD=b._emscripten_enum_btConstraintParams_BT_CONSTRAINT_ERP=b.asm.eB).apply(null,arguments)},CD=b._emscripten_enum_btConstraintParams_BT_CONSTRAINT_STOP_ERP=function(){return(CD=b._emscripten_enum_btConstraintParams_BT_CONSTRAINT_STOP_ERP=b.asm.fB).apply(null,arguments)},DD=b._emscripten_enum_btConstraintParams_BT_CONSTRAINT_CFM= -function(){return(DD=b._emscripten_enum_btConstraintParams_BT_CONSTRAINT_CFM=b.asm.gB).apply(null,arguments)},ED=b._emscripten_enum_btConstraintParams_BT_CONSTRAINT_STOP_CFM=function(){return(ED=b._emscripten_enum_btConstraintParams_BT_CONSTRAINT_STOP_CFM=b.asm.hB).apply(null,arguments)};b._malloc=function(){return(b._malloc=b.asm.jB).apply(null,arguments)};b.___start_em_js=27240;b.___stop_em_js=27338;b.UTF8ToString=sa; -b.addFunction=function(a,c){if(!Ua){Ua=new WeakMap;var d=ya.length;if(Ua)for(var e=0;e<0+d;e++){var g=e;var n=Ta[g];n||(g>=Ta.length&&(Ta.length=g+1),Ta[g]=n=ya.get(g));(g=n)&&Ua.set(g,e)}}if(d=Ua.get(a)||0)return d;if(Va.length)d=Va.pop();else{try{ya.grow(1)}catch(T){if(!(T instanceof RangeError))throw T;throw"Unable to grow wasm table. Set ALLOW_TABLE_GROWTH.";}d=ya.length-1}try{e=d,ya.set(e,a),Ta[e]=ya.get(e)}catch(T){if(!(T instanceof TypeError))throw T;if("function"==typeof WebAssembly.Function){e= -WebAssembly.Function;g={i:"i32",j:"i32",f:"f32",d:"f64",p:"i32"};n={parameters:[],results:"v"==c[0]?[]:[g[c[0]]]};for(var z=1;zz?e.push(z):e.push(z%128|128,z>>7);for(z=0;zg?c.push(g):c.push(g%128|128,g>>7);c.push.apply(c, -e);c.push(2,7,1,1,101,1,102,0,0,7,5,1,1,102,0,0);c=new WebAssembly.Module(new Uint8Array(c));c=(new WebAssembly.Instance(c,{e:{f:a}})).exports.f}e=d;ya.set(e,c);Ta[e]=ya.get(e)}Ua.set(a,d);return d};var FD;Ha=function GD(){FD||HD();FD||(Ha=GD)}; -function HD(){function a(){if(!FD&&(FD=!0,b.calledRun=!0,!qa)){Ca=!0;Qa(Aa);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();Ba.unshift(c)}Qa(Ba)}}if(!(0=JD?(0>>=0;switch(c.BYTES_PER_ELEMENT){case 2:d>>>=1;break;case 4:d>>>=2;break;case 8:d>>>=3}for(var e=0;e=e?c++:2047>=e?c+=2:55296<=e&&57343>=e?(c+=4,++d):c+=3}c=Array(c+1);e=c.length;d=0;if(0=n){var z=a.charCodeAt(++g);n=65536+((n&1023)<<10)|z&1023}if(127>=n){if(d>=e)break;c[d++]=n}else{if(2047>=n){if(d+1>=e)break;c[d++]=192|n>>6}else{if(65535>=n){if(d+2>=e)break;c[d++]=224|n>>12}else{if(d+3>=e)break;c[d++]=240|n>>18;c[d++]= -128|n>>12&63}c[d++]=128|n>>6&63}c[d++]=128|n&63}}c[d]=0}a=OD(c,ua);PD(c,ua,a);return a}return a}function RD(a){if("object"===typeof a){var c=OD(a,wa);PD(a,wa,c);return c}return a}function l(){throw"cannot construct a btCollisionShape, no constructor in IDL";}l.prototype=Object.create(f.prototype);l.prototype.constructor=l;l.prototype.lB=l;l.mB={};b.btCollisionShape=l;l.prototype.setLocalScaling=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Xa(c,a)}; -l.prototype.getLocalScaling=function(){return k(Ya(this.kB),m)};l.prototype.calculateLocalInertia=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);Za(d,a,c)};l.prototype.setMargin=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);$a(c,a)};l.prototype.getMargin=function(){return ab(this.kB)};l.prototype.__destroy__=function(){bb(this.kB)};function SD(){throw"cannot construct a btCollisionWorld, no constructor in IDL";}SD.prototype=Object.create(f.prototype); -SD.prototype.constructor=SD;SD.prototype.lB=SD;SD.mB={};b.btCollisionWorld=SD;SD.prototype.getDispatcher=function(){return k(cb(this.kB),TD)};SD.prototype.rayTest=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);db(e,a,c,d)};SD.prototype.getPairCache=function(){return k(eb(this.kB),UD)};SD.prototype.getDispatchInfo=function(){return k(fb(this.kB),p)}; -SD.prototype.addCollisionObject=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);void 0===c?gb(e,a):void 0===d?hb(e,a,c):ib(e,a,c,d)};SD.prototype.removeCollisionObject=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);jb(c,a)};SD.prototype.getBroadphase=function(){return k(kb(this.kB),VD)}; -SD.prototype.convexSweepTest=function(a,c,d,e,g){var n=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);g&&"object"===typeof g&&(g=g.kB);lb(n,a,c,d,e,g)};SD.prototype.contactPairTest=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);mb(e,a,c,d)}; -SD.prototype.contactTest=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);nb(d,a,c)};SD.prototype.updateSingleAabb=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);ob(c,a)};SD.prototype.setDebugDrawer=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);pb(c,a)};SD.prototype.getDebugDrawer=function(){return k(qb(this.kB),WD)};SD.prototype.debugDrawWorld=function(){rb(this.kB)}; -SD.prototype.debugDrawObject=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);sb(e,a,c,d)};SD.prototype.__destroy__=function(){tb(this.kB)};function q(){throw"cannot construct a btCollisionObject, no constructor in IDL";}q.prototype=Object.create(f.prototype);q.prototype.constructor=q;q.prototype.lB=q;q.mB={};b.btCollisionObject=q; -q.prototype.setAnisotropicFriction=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);ub(d,a,c)};q.prototype.getCollisionShape=function(){return k(vb(this.kB),l)};q.prototype.setContactProcessingThreshold=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);wb(c,a)};q.prototype.setActivationState=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);xb(c,a)}; -q.prototype.forceActivationState=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);yb(c,a)};q.prototype.activate=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);void 0===a?zb(c):Ab(c,a)};q.prototype.isActive=function(){return!!Bb(this.kB)};q.prototype.isKinematicObject=function(){return!!Cb(this.kB)};q.prototype.isStaticObject=function(){return!!Db(this.kB)};q.prototype.isStaticOrKinematicObject=function(){return!!Eb(this.kB)};q.prototype.getRestitution=function(){return Fb(this.kB)}; -q.prototype.getFriction=function(){return Gb(this.kB)};q.prototype.getRollingFriction=function(){return Hb(this.kB)};q.prototype.setRestitution=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Ib(c,a)};q.prototype.setFriction=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Jb(c,a)};q.prototype.setRollingFriction=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Kb(c,a)};q.prototype.getWorldTransform=function(){return k(Lb(this.kB),r)};q.prototype.getCollisionFlags=function(){return Mb(this.kB)}; -q.prototype.setCollisionFlags=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Nb(c,a)};q.prototype.setWorldTransform=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Ob(c,a)};q.prototype.setCollisionShape=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Pb(c,a)};q.prototype.setCcdMotionThreshold=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Qb(c,a)};q.prototype.setCcdSweptSphereRadius=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Rb(c,a)}; -q.prototype.getUserIndex=function(){return Sb(this.kB)};q.prototype.setUserIndex=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Tb(c,a)};q.prototype.getUserPointer=function(){return k(Ub(this.kB),XD)};q.prototype.setUserPointer=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Vb(c,a)};q.prototype.getBroadphaseHandle=function(){return k(Wb(this.kB),YD)};q.prototype.__destroy__=function(){Xb(this.kB)}; -function ZD(){throw"cannot construct a btConcaveShape, no constructor in IDL";}ZD.prototype=Object.create(l.prototype);ZD.prototype.constructor=ZD;ZD.prototype.lB=ZD;ZD.mB={};b.btConcaveShape=ZD;ZD.prototype.setLocalScaling=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Yb(c,a)};ZD.prototype.getLocalScaling=function(){return k(Zb(this.kB),m)};ZD.prototype.calculateLocalInertia=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);$b(d,a,c)}; -ZD.prototype.__destroy__=function(){ac(this.kB)};function $D(){throw"cannot construct a btCollisionAlgorithm, no constructor in IDL";}$D.prototype=Object.create(f.prototype);$D.prototype.constructor=$D;$D.prototype.lB=$D;$D.mB={};b.btCollisionAlgorithm=$D;$D.prototype.__destroy__=function(){bc(this.kB)};function aE(){throw"cannot construct a btTypedConstraint, no constructor in IDL";}aE.prototype=Object.create(f.prototype);aE.prototype.constructor=aE;aE.prototype.lB=aE;aE.mB={}; -b.btTypedConstraint=aE;aE.prototype.enableFeedback=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);cc(c,a)};aE.prototype.getBreakingImpulseThreshold=function(){return ec(this.kB)};aE.prototype.setBreakingImpulseThreshold=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);fc(c,a)};aE.prototype.getParam=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);return gc(d,a,c)}; -aE.prototype.setParam=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);hc(e,a,c,d)};aE.prototype.__destroy__=function(){ic(this.kB)};function bE(){throw"cannot construct a btDynamicsWorld, no constructor in IDL";}bE.prototype=Object.create(SD.prototype);bE.prototype.constructor=bE;bE.prototype.lB=bE;bE.mB={};b.btDynamicsWorld=bE;bE.prototype.addAction=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);jc(c,a)}; -bE.prototype.removeAction=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);kc(c,a)};bE.prototype.getSolverInfo=function(){return k(lc(this.kB),t)};bE.prototype.setInternalTickCallback=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);void 0===c?mc(e,a):void 0===d?nc(e,a,c):oc(e,a,c,d)};bE.prototype.getDispatcher=function(){return k(pc(this.kB),TD)}; -bE.prototype.rayTest=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);qc(e,a,c,d)};bE.prototype.getPairCache=function(){return k(rc(this.kB),UD)};bE.prototype.getDispatchInfo=function(){return k(sc(this.kB),p)}; -bE.prototype.addCollisionObject=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);void 0===c?tc(e,a):void 0===d?uc(e,a,c):vc(e,a,c,d)};bE.prototype.removeCollisionObject=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);wc(c,a)};bE.prototype.getBroadphase=function(){return k(xc(this.kB),VD)}; -bE.prototype.convexSweepTest=function(a,c,d,e,g){var n=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);g&&"object"===typeof g&&(g=g.kB);yc(n,a,c,d,e,g)};bE.prototype.contactPairTest=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);zc(e,a,c,d)}; -bE.prototype.contactTest=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);Ac(d,a,c)};bE.prototype.updateSingleAabb=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Bc(c,a)};bE.prototype.setDebugDrawer=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Cc(c,a)};bE.prototype.getDebugDrawer=function(){return k(Dc(this.kB),WD)};bE.prototype.debugDrawWorld=function(){Ec(this.kB)}; -bE.prototype.debugDrawObject=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);Fc(e,a,c,d)};bE.prototype.__destroy__=function(){Gc(this.kB)};function WD(){throw"cannot construct a btIDebugDraw, no constructor in IDL";}WD.prototype=Object.create(f.prototype);WD.prototype.constructor=WD;WD.prototype.lB=WD;WD.mB={};b.btIDebugDraw=WD; -WD.prototype.drawLine=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);Hc(e,a,c,d)};WD.prototype.drawContactPoint=function(a,c,d,e,g){var n=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);g&&"object"===typeof g&&(g=g.kB);Ic(n,a,c,d,e,g)}; -WD.prototype.reportErrorWarning=function(a){var c=this.kB;ND();a=a&&"object"===typeof a?a.kB:QD(a);Jc(c,a)};WD.prototype.draw3dText=function(a,c){var d=this.kB;ND();a&&"object"===typeof a&&(a=a.kB);c=c&&"object"===typeof c?c.kB:QD(c);Kc(d,a,c)};WD.prototype.setDebugMode=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Lc(c,a)};WD.prototype.getDebugMode=function(){return Mc(this.kB)};WD.prototype.__destroy__=function(){Nc(this.kB)}; -function m(a,c,d){a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);this.kB=void 0===a?Oc():void 0===c?_emscripten_bind_btVector3_btVector3_1(a):void 0===d?_emscripten_bind_btVector3_btVector3_2(a,c):Pc(a,c,d);h(m)[this.kB]=this}m.prototype=Object.create(f.prototype);m.prototype.constructor=m;m.prototype.lB=m;m.mB={};b.btVector3=m;m.prototype.length=m.prototype.length=function(){return Qc(this.kB)};m.prototype.x=m.prototype.x=function(){return Rc(this.kB)}; -m.prototype.y=m.prototype.y=function(){return Sc(this.kB)};m.prototype.z=m.prototype.z=function(){return Tc(this.kB)};m.prototype.setX=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Uc(c,a)};m.prototype.setY=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Vc(c,a)};m.prototype.setZ=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Wc(c,a)}; -m.prototype.setValue=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);Xc(e,a,c,d)};m.prototype.normalize=m.prototype.normalize=function(){Yc(this.kB)};m.prototype.rotate=m.prototype.rotate=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);return k(Zc(d,a,c),m)};m.prototype.dot=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return $c(c,a)}; -m.prototype.op_mul=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return k(ad(c,a),m)};m.prototype.op_add=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return k(bd(c,a),m)};m.prototype.op_sub=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return k(cd(c,a),m)};m.prototype.__destroy__=function(){dd(this.kB)};function cE(){throw"cannot construct a btQuadWord, no constructor in IDL";}cE.prototype=Object.create(f.prototype);cE.prototype.constructor=cE; -cE.prototype.lB=cE;cE.mB={};b.btQuadWord=cE;cE.prototype.x=cE.prototype.x=function(){return ed(this.kB)};cE.prototype.y=cE.prototype.y=function(){return fd(this.kB)};cE.prototype.z=cE.prototype.z=function(){return gd(this.kB)};cE.prototype.w=cE.prototype.w=function(){return hd(this.kB)};cE.prototype.setX=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);jd(c,a)};cE.prototype.setY=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);kd(c,a)}; -cE.prototype.setZ=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);ld(c,a)};cE.prototype.setW=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);md(c,a)};cE.prototype.__destroy__=function(){nd(this.kB)};function dE(){throw"cannot construct a btMotionState, no constructor in IDL";}dE.prototype=Object.create(f.prototype);dE.prototype.constructor=dE;dE.prototype.lB=dE;dE.mB={};b.btMotionState=dE; -dE.prototype.getWorldTransform=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);od(c,a)};dE.prototype.setWorldTransform=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);pd(c,a)};dE.prototype.__destroy__=function(){qd(this.kB)};function u(){throw"cannot construct a RayResultCallback, no constructor in IDL";}u.prototype=Object.create(f.prototype);u.prototype.constructor=u;u.prototype.lB=u;u.mB={};b.RayResultCallback=u;u.prototype.hasHit=function(){return!!rd(this.kB)}; -u.prototype.get_m_collisionFilterGroup=u.prototype.nB=function(){return sd(this.kB)};u.prototype.set_m_collisionFilterGroup=u.prototype.pB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);td(c,a)};Object.defineProperty(u.prototype,"m_collisionFilterGroup",{get:u.prototype.nB,set:u.prototype.pB});u.prototype.get_m_collisionFilterMask=u.prototype.oB=function(){return ud(this.kB)}; -u.prototype.set_m_collisionFilterMask=u.prototype.qB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);vd(c,a)};Object.defineProperty(u.prototype,"m_collisionFilterMask",{get:u.prototype.oB,set:u.prototype.qB});u.prototype.get_m_closestHitFraction=u.prototype.rB=function(){return wd(this.kB)};u.prototype.set_m_closestHitFraction=u.prototype.sB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);xd(c,a)};Object.defineProperty(u.prototype,"m_closestHitFraction",{get:u.prototype.rB,set:u.prototype.sB}); -u.prototype.get_m_collisionObject=u.prototype.vB=function(){return k(yd(this.kB),q)};u.prototype.set_m_collisionObject=u.prototype.CB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);zd(c,a)};Object.defineProperty(u.prototype,"m_collisionObject",{get:u.prototype.vB,set:u.prototype.CB});u.prototype.get_m_flags=u.prototype.tB=function(){return Ad(this.kB)};u.prototype.set_m_flags=u.prototype.uB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Bd(c,a)}; -Object.defineProperty(u.prototype,"m_flags",{get:u.prototype.tB,set:u.prototype.uB});u.prototype.__destroy__=function(){Cd(this.kB)};function eE(){throw"cannot construct a ContactResultCallback, no constructor in IDL";}eE.prototype=Object.create(f.prototype);eE.prototype.constructor=eE;eE.prototype.lB=eE;eE.mB={};b.ContactResultCallback=eE; -eE.prototype.addSingleResult=function(a,c,d,e,g,n,z){var T=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);g&&"object"===typeof g&&(g=g.kB);n&&"object"===typeof n&&(n=n.kB);z&&"object"===typeof z&&(z=z.kB);return Dd(T,a,c,d,e,g,n,z)};eE.prototype.__destroy__=function(){Ed(this.kB)};function v(){throw"cannot construct a ConvexResultCallback, no constructor in IDL";}v.prototype=Object.create(f.prototype); -v.prototype.constructor=v;v.prototype.lB=v;v.mB={};b.ConvexResultCallback=v;v.prototype.hasHit=function(){return!!Fd(this.kB)};v.prototype.get_m_collisionFilterGroup=v.prototype.nB=function(){return Gd(this.kB)};v.prototype.set_m_collisionFilterGroup=v.prototype.pB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Hd(c,a)};Object.defineProperty(v.prototype,"m_collisionFilterGroup",{get:v.prototype.nB,set:v.prototype.pB});v.prototype.get_m_collisionFilterMask=v.prototype.oB=function(){return Id(this.kB)}; -v.prototype.set_m_collisionFilterMask=v.prototype.qB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Jd(c,a)};Object.defineProperty(v.prototype,"m_collisionFilterMask",{get:v.prototype.oB,set:v.prototype.qB});v.prototype.get_m_closestHitFraction=v.prototype.rB=function(){return Kd(this.kB)};v.prototype.set_m_closestHitFraction=v.prototype.sB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Ld(c,a)};Object.defineProperty(v.prototype,"m_closestHitFraction",{get:v.prototype.rB,set:v.prototype.sB}); -v.prototype.__destroy__=function(){Md(this.kB)};function fE(){throw"cannot construct a btConvexShape, no constructor in IDL";}fE.prototype=Object.create(l.prototype);fE.prototype.constructor=fE;fE.prototype.lB=fE;fE.mB={};b.btConvexShape=fE;fE.prototype.setLocalScaling=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Nd(c,a)};fE.prototype.getLocalScaling=function(){return k(Od(this.kB),m)}; -fE.prototype.calculateLocalInertia=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);Pd(d,a,c)};fE.prototype.setMargin=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Qd(c,a)};fE.prototype.getMargin=function(){return Rd(this.kB)};fE.prototype.__destroy__=function(){Sd(this.kB)};function gE(a,c){a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);this.kB=Td(a,c);h(gE)[this.kB]=this}gE.prototype=Object.create(l.prototype); -gE.prototype.constructor=gE;gE.prototype.lB=gE;gE.mB={};b.btCapsuleShape=gE;gE.prototype.setMargin=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Ud(c,a)};gE.prototype.getMargin=function(){return Vd(this.kB)};gE.prototype.getUpAxis=function(){return Wd(this.kB)};gE.prototype.getRadius=function(){return Xd(this.kB)};gE.prototype.getHalfHeight=function(){return Yd(this.kB)};gE.prototype.setLocalScaling=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Zd(c,a)}; -gE.prototype.getLocalScaling=function(){return k($d(this.kB),m)};gE.prototype.calculateLocalInertia=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);ae(d,a,c)};gE.prototype.__destroy__=function(){be(this.kB)};function hE(a){a&&"object"===typeof a&&(a=a.kB);this.kB=ce(a);h(hE)[this.kB]=this}hE.prototype=Object.create(l.prototype);hE.prototype.constructor=hE;hE.prototype.lB=hE;hE.mB={};b.btCylinderShape=hE; -hE.prototype.setMargin=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);de(c,a)};hE.prototype.getMargin=function(){return ee(this.kB)};hE.prototype.setLocalScaling=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);fe(c,a)};hE.prototype.getLocalScaling=function(){return k(ge(this.kB),m)};hE.prototype.calculateLocalInertia=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);he(d,a,c)};hE.prototype.__destroy__=function(){ie(this.kB)}; -function iE(a,c){a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);this.kB=je(a,c);h(iE)[this.kB]=this}iE.prototype=Object.create(l.prototype);iE.prototype.constructor=iE;iE.prototype.lB=iE;iE.mB={};b.btConeShape=iE;iE.prototype.setLocalScaling=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);ke(c,a)};iE.prototype.getLocalScaling=function(){return k(le(this.kB),m)}; -iE.prototype.calculateLocalInertia=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);me(d,a,c)};iE.prototype.__destroy__=function(){ne(this.kB)};function jE(){throw"cannot construct a btStridingMeshInterface, no constructor in IDL";}jE.prototype=Object.create(f.prototype);jE.prototype.constructor=jE;jE.prototype.lB=jE;jE.mB={};b.btStridingMeshInterface=jE;jE.prototype.setScaling=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);oe(c,a)}; -jE.prototype.__destroy__=function(){pe(this.kB)};function kE(){throw"cannot construct a btTriangleMeshShape, no constructor in IDL";}kE.prototype=Object.create(ZD.prototype);kE.prototype.constructor=kE;kE.prototype.lB=kE;kE.mB={};b.btTriangleMeshShape=kE;kE.prototype.setLocalScaling=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);qe(c,a)};kE.prototype.getLocalScaling=function(){return k(re(this.kB),m)}; -kE.prototype.calculateLocalInertia=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);se(d,a,c)};kE.prototype.__destroy__=function(){te(this.kB)};function lE(){throw"cannot construct a btPrimitiveManagerBase, no constructor in IDL";}lE.prototype=Object.create(f.prototype);lE.prototype.constructor=lE;lE.prototype.lB=lE;lE.mB={};b.btPrimitiveManagerBase=lE;lE.prototype.is_trimesh=function(){return!!ue(this.kB)};lE.prototype.get_primitive_count=function(){return ve(this.kB)}; -lE.prototype.get_primitive_box=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);we(d,a,c)};lE.prototype.get_primitive_triangle=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);xe(d,a,c)};lE.prototype.__destroy__=function(){ye(this.kB)};function w(){throw"cannot construct a btGImpactShapeInterface, no constructor in IDL";}w.prototype=Object.create(ZD.prototype);w.prototype.constructor=w;w.prototype.lB=w; -w.mB={};b.btGImpactShapeInterface=w;w.prototype.updateBound=function(){ze(this.kB)};w.prototype.postUpdate=function(){Ae(this.kB)};w.prototype.getShapeType=function(){return Be(this.kB)};w.prototype.getName=function(){return sa(Ce(this.kB))};w.prototype.getGImpactShapeType=function(){return De(this.kB)};w.prototype.getPrimitiveManager=function(){return k(Ee(this.kB),lE)};w.prototype.getNumChildShapes=function(){return Fe(this.kB)};w.prototype.childrenHasTransform=function(){return!!Ge(this.kB)}; -w.prototype.needsRetrieveTriangles=function(){return!!He(this.kB)};w.prototype.needsRetrieveTetrahedrons=function(){return!!Ie(this.kB)};w.prototype.getBulletTriangle=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);Je(d,a,c)};w.prototype.getBulletTetrahedron=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);Ke(d,a,c)}; -w.prototype.getChildShape=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return k(Le(c,a),l)};w.prototype.getChildTransform=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return k(Me(c,a),r)};w.prototype.setChildTransform=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);Ne(d,a,c)};w.prototype.setLocalScaling=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Oe(c,a)}; -w.prototype.getLocalScaling=function(){return k(Pe(this.kB),m)};w.prototype.calculateLocalInertia=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);Qe(d,a,c)};w.prototype.__destroy__=function(){Re(this.kB)};function mE(){throw"cannot construct a btActivatingCollisionAlgorithm, no constructor in IDL";}mE.prototype=Object.create($D.prototype);mE.prototype.constructor=mE;mE.prototype.lB=mE;mE.mB={};b.btActivatingCollisionAlgorithm=mE; -mE.prototype.__destroy__=function(){Se(this.kB)};function nE(a){a&&"object"===typeof a&&(a=a.kB);this.kB=void 0===a?Te():Ue(a);h(nE)[this.kB]=this}nE.prototype=Object.create(f.prototype);nE.prototype.constructor=nE;nE.prototype.lB=nE;nE.mB={};b.btDefaultCollisionConfiguration=nE;nE.prototype.__destroy__=function(){Ve(this.kB)};function TD(){throw"cannot construct a btDispatcher, no constructor in IDL";}TD.prototype=Object.create(f.prototype);TD.prototype.constructor=TD;TD.prototype.lB=TD;TD.mB={}; -b.btDispatcher=TD;TD.prototype.getNumManifolds=function(){return We(this.kB)};TD.prototype.getManifoldByIndexInternal=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return k(Xe(c,a),oE)};TD.prototype.__destroy__=function(){Ye(this.kB)}; -function pE(a,c,d,e,g){a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);g&&"object"===typeof g&&(g=g.kB);this.kB=void 0===e?Ze(a,c,d):void 0===g?_emscripten_bind_btGeneric6DofConstraint_btGeneric6DofConstraint_4(a,c,d,e):$e(a,c,d,e,g);h(pE)[this.kB]=this}pE.prototype=Object.create(aE.prototype);pE.prototype.constructor=pE;pE.prototype.lB=pE;pE.mB={};b.btGeneric6DofConstraint=pE; -pE.prototype.setLinearLowerLimit=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);af(c,a)};pE.prototype.setLinearUpperLimit=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);bf(c,a)};pE.prototype.setAngularLowerLimit=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);cf(c,a)};pE.prototype.setAngularUpperLimit=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);df(c,a)};pE.prototype.getFrameOffsetA=function(){return k(ef(this.kB),r)}; -pE.prototype.enableFeedback=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);ff(c,a)};pE.prototype.getBreakingImpulseThreshold=function(){return gf(this.kB)};pE.prototype.setBreakingImpulseThreshold=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);hf(c,a)};pE.prototype.getParam=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);return jf(d,a,c)}; -pE.prototype.setParam=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);kf(e,a,c,d)};pE.prototype.__destroy__=function(){lf(this.kB)};function x(a,c,d,e){a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);this.kB=mf(a,c,d,e);h(x)[this.kB]=this}x.prototype=Object.create(bE.prototype);x.prototype.constructor=x;x.prototype.lB=x;x.mB={}; -b.btDiscreteDynamicsWorld=x;x.prototype.setGravity=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);nf(c,a)};x.prototype.getGravity=function(){return k(of(this.kB),m)};x.prototype.addRigidBody=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);void 0===c?pf(e,a):void 0===d?_emscripten_bind_btDiscreteDynamicsWorld_addRigidBody_2(e,a,c):qf(e,a,c,d)}; -x.prototype.removeRigidBody=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);rf(c,a)};x.prototype.addConstraint=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);void 0===c?sf(d,a):tf(d,a,c)};x.prototype.removeConstraint=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);uf(c,a)}; -x.prototype.stepSimulation=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);return void 0===c?vf(e,a):void 0===d?wf(e,a,c):xf(e,a,c,d)};x.prototype.setContactAddedCallback=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);yf(c,a)};x.prototype.setContactProcessedCallback=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);zf(c,a)}; -x.prototype.setContactDestroyedCallback=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Af(c,a)};x.prototype.getDispatcher=function(){return k(Bf(this.kB),TD)};x.prototype.rayTest=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);Cf(e,a,c,d)};x.prototype.getPairCache=function(){return k(Df(this.kB),UD)};x.prototype.getDispatchInfo=function(){return k(Ef(this.kB),p)}; -x.prototype.addCollisionObject=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);void 0===c?Ff(e,a):void 0===d?Gf(e,a,c):Hf(e,a,c,d)};x.prototype.removeCollisionObject=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);If(c,a)};x.prototype.getBroadphase=function(){return k(Jf(this.kB),VD)}; -x.prototype.convexSweepTest=function(a,c,d,e,g){var n=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);g&&"object"===typeof g&&(g=g.kB);Kf(n,a,c,d,e,g)};x.prototype.contactPairTest=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);Lf(e,a,c,d)}; -x.prototype.contactTest=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);Mf(d,a,c)};x.prototype.updateSingleAabb=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Nf(c,a)};x.prototype.setDebugDrawer=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Of(c,a)};x.prototype.getDebugDrawer=function(){return k(Pf(this.kB),WD)};x.prototype.debugDrawWorld=function(){Qf(this.kB)}; -x.prototype.debugDrawObject=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);Rf(e,a,c,d)};x.prototype.addAction=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Sf(c,a)};x.prototype.removeAction=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Tf(c,a)};x.prototype.getSolverInfo=function(){return k(Uf(this.kB),t)}; -x.prototype.setInternalTickCallback=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);void 0===c?Vf(e,a):void 0===d?Wf(e,a,c):Xf(e,a,c,d)};x.prototype.__destroy__=function(){Yf(this.kB)};function qE(){throw"cannot construct a btVehicleRaycaster, no constructor in IDL";}qE.prototype=Object.create(f.prototype);qE.prototype.constructor=qE;qE.prototype.lB=qE;qE.mB={};b.btVehicleRaycaster=qE; -qE.prototype.castRay=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);Zf(e,a,c,d)};qE.prototype.__destroy__=function(){$f(this.kB)};function rE(){throw"cannot construct a btActionInterface, no constructor in IDL";}rE.prototype=Object.create(f.prototype);rE.prototype.constructor=rE;rE.prototype.lB=rE;rE.mB={};b.btActionInterface=rE; -rE.prototype.updateAction=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);ag(d,a,c)};rE.prototype.__destroy__=function(){bg(this.kB)};function y(){this.kB=cg();h(y)[this.kB]=this}y.prototype=Object.create(q.prototype);y.prototype.constructor=y;y.prototype.lB=y;y.mB={};b.btGhostObject=y;y.prototype.getNumOverlappingObjects=function(){return dg(this.kB)}; -y.prototype.getOverlappingObject=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return k(eg(c,a),q)};y.prototype.setAnisotropicFriction=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);fg(d,a,c)};y.prototype.getCollisionShape=function(){return k(gg(this.kB),l)};y.prototype.setContactProcessingThreshold=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);hg(c,a)}; -y.prototype.setActivationState=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);ig(c,a)};y.prototype.forceActivationState=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);jg(c,a)};y.prototype.activate=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);void 0===a?kg(c):lg(c,a)};y.prototype.isActive=function(){return!!mg(this.kB)};y.prototype.isKinematicObject=function(){return!!ng(this.kB)};y.prototype.isStaticObject=function(){return!!og(this.kB)}; -y.prototype.isStaticOrKinematicObject=function(){return!!pg(this.kB)};y.prototype.getRestitution=function(){return qg(this.kB)};y.prototype.getFriction=function(){return rg(this.kB)};y.prototype.getRollingFriction=function(){return sg(this.kB)};y.prototype.setRestitution=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);tg(c,a)};y.prototype.setFriction=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);ug(c,a)}; -y.prototype.setRollingFriction=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);vg(c,a)};y.prototype.getWorldTransform=function(){return k(wg(this.kB),r)};y.prototype.getCollisionFlags=function(){return xg(this.kB)};y.prototype.setCollisionFlags=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);yg(c,a)};y.prototype.setWorldTransform=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);zg(c,a)}; -y.prototype.setCollisionShape=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Ag(c,a)};y.prototype.setCcdMotionThreshold=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Bg(c,a)};y.prototype.setCcdSweptSphereRadius=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Cg(c,a)};y.prototype.getUserIndex=function(){return Dg(this.kB)};y.prototype.setUserIndex=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Eg(c,a)}; -y.prototype.getUserPointer=function(){return k(Fg(this.kB),XD)};y.prototype.setUserPointer=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Gg(c,a)};y.prototype.getBroadphaseHandle=function(){return k(Hg(this.kB),YD)};y.prototype.__destroy__=function(){Ig(this.kB)};function sE(){throw"cannot construct a btSoftBodySolver, no constructor in IDL";}sE.prototype=Object.create(f.prototype);sE.prototype.constructor=sE;sE.prototype.lB=sE;sE.mB={};b.btSoftBodySolver=sE;sE.prototype.__destroy__=function(){Jg(this.kB)}; -function XD(){throw"cannot construct a VoidPtr, no constructor in IDL";}XD.prototype=Object.create(f.prototype);XD.prototype.constructor=XD;XD.prototype.lB=XD;XD.mB={};b.VoidPtr=XD;XD.prototype.__destroy__=function(){Kg(this.kB)};function tE(){this.kB=Lg();h(tE)[this.kB]=this}tE.prototype=Object.create(WD.prototype);tE.prototype.constructor=tE;tE.prototype.lB=tE;tE.mB={};b.DebugDrawer=tE; -tE.prototype.drawLine=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);Mg(e,a,c,d)};tE.prototype.drawContactPoint=function(a,c,d,e,g){var n=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);g&&"object"===typeof g&&(g=g.kB);Ng(n,a,c,d,e,g)}; -tE.prototype.reportErrorWarning=function(a){var c=this.kB;ND();a=a&&"object"===typeof a?a.kB:QD(a);Og(c,a)};tE.prototype.draw3dText=function(a,c){var d=this.kB;ND();a&&"object"===typeof a&&(a=a.kB);c=c&&"object"===typeof c?c.kB:QD(c);Pg(d,a,c)};tE.prototype.setDebugMode=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Qg(c,a)};tE.prototype.getDebugMode=function(){return Rg(this.kB)};tE.prototype.__destroy__=function(){Sg(this.kB)}; -function A(a,c,d,e){a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);this.kB=void 0===a?Tg():void 0===c?_emscripten_bind_btVector4_btVector4_1(a):void 0===d?_emscripten_bind_btVector4_btVector4_2(a,c):void 0===e?_emscripten_bind_btVector4_btVector4_3(a,c,d):Ug(a,c,d,e);h(A)[this.kB]=this}A.prototype=Object.create(m.prototype);A.prototype.constructor=A;A.prototype.lB=A;A.mB={};b.btVector4=A; -A.prototype.w=A.prototype.w=function(){return Vg(this.kB)};A.prototype.setValue=function(a,c,d,e){var g=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);Wg(g,a,c,d,e)};A.prototype.length=A.prototype.length=function(){return Xg(this.kB)};A.prototype.x=A.prototype.x=function(){return Yg(this.kB)};A.prototype.y=A.prototype.y=function(){return Zg(this.kB)};A.prototype.z=A.prototype.z=function(){return $g(this.kB)}; -A.prototype.setX=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);ah(c,a)};A.prototype.setY=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);bh(c,a)};A.prototype.setZ=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);ch(c,a)};A.prototype.normalize=A.prototype.normalize=function(){dh(this.kB)};A.prototype.rotate=A.prototype.rotate=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);return k(eh(d,a,c),m)}; -A.prototype.dot=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return fh(c,a)};A.prototype.op_mul=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return k(gh(c,a),m)};A.prototype.op_add=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return k(hh(c,a),m)};A.prototype.op_sub=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return k(ih(c,a),m)};A.prototype.__destroy__=function(){jh(this.kB)}; -function B(a,c,d,e){a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);this.kB=kh(a,c,d,e);h(B)[this.kB]=this}B.prototype=Object.create(cE.prototype);B.prototype.constructor=B;B.prototype.lB=B;B.mB={};b.btQuaternion=B;B.prototype.setValue=function(a,c,d,e){var g=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);lh(g,a,c,d,e)}; -B.prototype.setEulerZYX=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);mh(e,a,c,d)};B.prototype.setRotation=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);nh(d,a,c)};B.prototype.normalize=B.prototype.normalize=function(){oh(this.kB)};B.prototype.length2=function(){return ph(this.kB)};B.prototype.length=B.prototype.length=function(){return qh(this.kB)}; -B.prototype.dot=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return rh(c,a)};B.prototype.normalized=function(){return k(sh(this.kB),B)};B.prototype.getAxis=function(){return k(th(this.kB),m)};B.prototype.inverse=B.prototype.inverse=function(){return k(uh(this.kB),B)};B.prototype.getAngle=function(){return vh(this.kB)};B.prototype.getAngleShortestPath=function(){return wh(this.kB)}; -B.prototype.angle=B.prototype.angle=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return xh(c,a)};B.prototype.angleShortestPath=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return yh(c,a)};B.prototype.op_add=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return k(zh(c,a),B)};B.prototype.op_sub=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return k(Ah(c,a),B)}; -B.prototype.op_mul=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return k(Bh(c,a),B)};B.prototype.op_mulq=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return k(Ch(c,a),B)};B.prototype.op_div=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return k(Dh(c,a),B)};B.prototype.x=B.prototype.x=function(){return Eh(this.kB)};B.prototype.y=B.prototype.y=function(){return Fh(this.kB)};B.prototype.z=B.prototype.z=function(){return Gh(this.kB)}; -B.prototype.w=B.prototype.w=function(){return Hh(this.kB)};B.prototype.setX=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Ih(c,a)};B.prototype.setY=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Jh(c,a)};B.prototype.setZ=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Kh(c,a)};B.prototype.setW=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Lh(c,a)};B.prototype.__destroy__=function(){Mh(this.kB)}; -function uE(){throw"cannot construct a btMatrix3x3, no constructor in IDL";}uE.prototype=Object.create(f.prototype);uE.prototype.constructor=uE;uE.prototype.lB=uE;uE.mB={};b.btMatrix3x3=uE;uE.prototype.setEulerZYX=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);Nh(e,a,c,d)};uE.prototype.getRotation=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Oh(c,a)}; -uE.prototype.getRow=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return k(Ph(c,a),m)};uE.prototype.__destroy__=function(){Qh(this.kB)};function r(a,c){a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);this.kB=void 0===a?Rh():void 0===c?_emscripten_bind_btTransform_btTransform_1(a):Sh(a,c);h(r)[this.kB]=this}r.prototype=Object.create(f.prototype);r.prototype.constructor=r;r.prototype.lB=r;r.mB={};b.btTransform=r;r.prototype.setIdentity=function(){Th(this.kB)}; -r.prototype.setOrigin=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Uh(c,a)};r.prototype.setRotation=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Vh(c,a)};r.prototype.getOrigin=function(){return k(Wh(this.kB),m)};r.prototype.getRotation=function(){return k(Xh(this.kB),B)};r.prototype.getBasis=function(){return k(Yh(this.kB),uE)};r.prototype.setFromOpenGLMatrix=function(a){var c=this.kB;ND();"object"==typeof a&&(a=RD(a));Zh(c,a)}; -r.prototype.inverse=r.prototype.inverse=function(){return k($h(this.kB),r)};r.prototype.op_mul=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return k(ai(c,a),r)};r.prototype.__destroy__=function(){bi(this.kB)};function vE(){this.kB=ci();h(vE)[this.kB]=this}vE.prototype=Object.create(dE.prototype);vE.prototype.constructor=vE;vE.prototype.lB=vE;vE.mB={};b.MotionState=vE;vE.prototype.getWorldTransform=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);di(c,a)}; -vE.prototype.setWorldTransform=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);ei(c,a)};vE.prototype.__destroy__=function(){fi(this.kB)};function wE(a,c){a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);this.kB=void 0===a?gi():void 0===c?hi(a):ii(a,c);h(wE)[this.kB]=this}wE.prototype=Object.create(dE.prototype);wE.prototype.constructor=wE;wE.prototype.lB=wE;wE.mB={};b.btDefaultMotionState=wE; -wE.prototype.getWorldTransform=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);ji(c,a)};wE.prototype.setWorldTransform=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);ki(c,a)};wE.prototype.get_m_graphicsWorldTrans=wE.prototype.lD=function(){return k(li(this.kB),r)};wE.prototype.set_m_graphicsWorldTrans=wE.prototype.cG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);mi(c,a)};Object.defineProperty(wE.prototype,"m_graphicsWorldTrans",{get:wE.prototype.lD,set:wE.prototype.cG}); -wE.prototype.__destroy__=function(){ni(this.kB)};function xE(){throw"cannot construct a btCollisionObjectWrapper, no constructor in IDL";}xE.prototype=Object.create(f.prototype);xE.prototype.constructor=xE;xE.prototype.lB=xE;xE.mB={};b.btCollisionObjectWrapper=xE;xE.prototype.getWorldTransform=function(){return k(oi(this.kB),r)};xE.prototype.getCollisionObject=function(){return k(pi(this.kB),q)};xE.prototype.getCollisionShape=function(){return k(qi(this.kB),l)}; -function C(a,c){a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);this.kB=ri(a,c);h(C)[this.kB]=this}C.prototype=Object.create(u.prototype);C.prototype.constructor=C;C.prototype.lB=C;C.mB={};b.ClosestRayResultCallback=C;C.prototype.hasHit=function(){return!!si(this.kB)};C.prototype.get_m_rayFromWorld=C.prototype.NB=function(){return k(ti(this.kB),m)};C.prototype.set_m_rayFromWorld=C.prototype.XB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);ui(c,a)}; -Object.defineProperty(C.prototype,"m_rayFromWorld",{get:C.prototype.NB,set:C.prototype.XB});C.prototype.get_m_rayToWorld=C.prototype.OB=function(){return k(vi(this.kB),m)};C.prototype.set_m_rayToWorld=C.prototype.YB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);wi(c,a)};Object.defineProperty(C.prototype,"m_rayToWorld",{get:C.prototype.OB,set:C.prototype.YB});C.prototype.get_m_hitNormalWorld=C.prototype.xB=function(){return k(xi(this.kB),m)}; -C.prototype.set_m_hitNormalWorld=C.prototype.EB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);yi(c,a)};Object.defineProperty(C.prototype,"m_hitNormalWorld",{get:C.prototype.xB,set:C.prototype.EB});C.prototype.get_m_hitPointWorld=C.prototype.yB=function(){return k(zi(this.kB),m)};C.prototype.set_m_hitPointWorld=C.prototype.FB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Ai(c,a)};Object.defineProperty(C.prototype,"m_hitPointWorld",{get:C.prototype.yB,set:C.prototype.FB}); -C.prototype.get_m_collisionFilterGroup=C.prototype.nB=function(){return Bi(this.kB)};C.prototype.set_m_collisionFilterGroup=C.prototype.pB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Ci(c,a)};Object.defineProperty(C.prototype,"m_collisionFilterGroup",{get:C.prototype.nB,set:C.prototype.pB});C.prototype.get_m_collisionFilterMask=C.prototype.oB=function(){return Di(this.kB)}; -C.prototype.set_m_collisionFilterMask=C.prototype.qB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Ei(c,a)};Object.defineProperty(C.prototype,"m_collisionFilterMask",{get:C.prototype.oB,set:C.prototype.qB});C.prototype.get_m_closestHitFraction=C.prototype.rB=function(){return Fi(this.kB)};C.prototype.set_m_closestHitFraction=C.prototype.sB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Gi(c,a)};Object.defineProperty(C.prototype,"m_closestHitFraction",{get:C.prototype.rB,set:C.prototype.sB}); -C.prototype.get_m_collisionObject=C.prototype.vB=function(){return k(Hi(this.kB),q)};C.prototype.set_m_collisionObject=C.prototype.CB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Ii(c,a)};Object.defineProperty(C.prototype,"m_collisionObject",{get:C.prototype.vB,set:C.prototype.CB});C.prototype.get_m_flags=C.prototype.tB=function(){return Ji(this.kB)};C.prototype.set_m_flags=C.prototype.uB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Ki(c,a)}; -Object.defineProperty(C.prototype,"m_flags",{get:C.prototype.tB,set:C.prototype.uB});C.prototype.__destroy__=function(){Li(this.kB)};function yE(){throw"cannot construct a btConstCollisionObjectArray, no constructor in IDL";}yE.prototype=Object.create(f.prototype);yE.prototype.constructor=yE;yE.prototype.lB=yE;yE.mB={};b.btConstCollisionObjectArray=yE;yE.prototype.size=yE.prototype.size=function(){return Mi(this.kB)}; -yE.prototype.at=yE.prototype.at=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return k(Ni(c,a),q)};yE.prototype.__destroy__=function(){Oi(this.kB)};function zE(){throw"cannot construct a btScalarArray, no constructor in IDL";}zE.prototype=Object.create(f.prototype);zE.prototype.constructor=zE;zE.prototype.lB=zE;zE.mB={};b.btScalarArray=zE;zE.prototype.size=zE.prototype.size=function(){return Pi(this.kB)}; -zE.prototype.at=zE.prototype.at=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return Qi(c,a)};zE.prototype.__destroy__=function(){Ri(this.kB)};function D(a,c){a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);this.kB=Si(a,c);h(D)[this.kB]=this}D.prototype=Object.create(u.prototype);D.prototype.constructor=D;D.prototype.lB=D;D.mB={};b.AllHitsRayResultCallback=D;D.prototype.hasHit=function(){return!!Ti(this.kB)}; -D.prototype.get_m_collisionObjects=D.prototype.UC=function(){return k(Ui(this.kB),yE)};D.prototype.set_m_collisionObjects=D.prototype.LF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Vi(c,a)};Object.defineProperty(D.prototype,"m_collisionObjects",{get:D.prototype.UC,set:D.prototype.LF});D.prototype.get_m_rayFromWorld=D.prototype.NB=function(){return k(Wi(this.kB),m)};D.prototype.set_m_rayFromWorld=D.prototype.XB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Xi(c,a)}; -Object.defineProperty(D.prototype,"m_rayFromWorld",{get:D.prototype.NB,set:D.prototype.XB});D.prototype.get_m_rayToWorld=D.prototype.OB=function(){return k(Yi(this.kB),m)};D.prototype.set_m_rayToWorld=D.prototype.YB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Zi(c,a)};Object.defineProperty(D.prototype,"m_rayToWorld",{get:D.prototype.OB,set:D.prototype.YB});D.prototype.get_m_hitNormalWorld=D.prototype.xB=function(){return k($i(this.kB),AE)}; -D.prototype.set_m_hitNormalWorld=D.prototype.EB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);aj(c,a)};Object.defineProperty(D.prototype,"m_hitNormalWorld",{get:D.prototype.xB,set:D.prototype.EB});D.prototype.get_m_hitPointWorld=D.prototype.yB=function(){return k(bj(this.kB),AE)};D.prototype.set_m_hitPointWorld=D.prototype.FB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);cj(c,a)};Object.defineProperty(D.prototype,"m_hitPointWorld",{get:D.prototype.yB,set:D.prototype.FB}); -D.prototype.get_m_hitFractions=D.prototype.qD=function(){return k(dj(this.kB),zE)};D.prototype.set_m_hitFractions=D.prototype.hG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);ej(c,a)};Object.defineProperty(D.prototype,"m_hitFractions",{get:D.prototype.qD,set:D.prototype.hG});D.prototype.get_m_collisionFilterGroup=D.prototype.nB=function(){return fj(this.kB)};D.prototype.set_m_collisionFilterGroup=D.prototype.pB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);gj(c,a)}; -Object.defineProperty(D.prototype,"m_collisionFilterGroup",{get:D.prototype.nB,set:D.prototype.pB});D.prototype.get_m_collisionFilterMask=D.prototype.oB=function(){return hj(this.kB)};D.prototype.set_m_collisionFilterMask=D.prototype.qB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);ij(c,a)};Object.defineProperty(D.prototype,"m_collisionFilterMask",{get:D.prototype.oB,set:D.prototype.qB});D.prototype.get_m_closestHitFraction=D.prototype.rB=function(){return jj(this.kB)}; -D.prototype.set_m_closestHitFraction=D.prototype.sB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);kj(c,a)};Object.defineProperty(D.prototype,"m_closestHitFraction",{get:D.prototype.rB,set:D.prototype.sB});D.prototype.get_m_collisionObject=D.prototype.vB=function(){return k(lj(this.kB),q)};D.prototype.set_m_collisionObject=D.prototype.CB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);mj(c,a)};Object.defineProperty(D.prototype,"m_collisionObject",{get:D.prototype.vB,set:D.prototype.CB}); -D.prototype.get_m_flags=D.prototype.tB=function(){return nj(this.kB)};D.prototype.set_m_flags=D.prototype.uB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);oj(c,a)};Object.defineProperty(D.prototype,"m_flags",{get:D.prototype.tB,set:D.prototype.uB});D.prototype.__destroy__=function(){pj(this.kB)};function E(){throw"cannot construct a btManifoldPoint, no constructor in IDL";}E.prototype=Object.create(f.prototype);E.prototype.constructor=E;E.prototype.lB=E;E.mB={};b.btManifoldPoint=E; -E.prototype.getPositionWorldOnA=function(){return k(qj(this.kB),m)};E.prototype.getPositionWorldOnB=function(){return k(rj(this.kB),m)};E.prototype.getAppliedImpulse=function(){return sj(this.kB)};E.prototype.getDistance=function(){return tj(this.kB)};E.prototype.get_m_localPointA=E.prototype.GD=function(){return k(uj(this.kB),m)};E.prototype.set_m_localPointA=E.prototype.xG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);vj(c,a)}; -Object.defineProperty(E.prototype,"m_localPointA",{get:E.prototype.GD,set:E.prototype.xG});E.prototype.get_m_localPointB=E.prototype.HD=function(){return k(wj(this.kB),m)};E.prototype.set_m_localPointB=E.prototype.yG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);xj(c,a)};Object.defineProperty(E.prototype,"m_localPointB",{get:E.prototype.HD,set:E.prototype.yG});E.prototype.get_m_positionWorldOnB=E.prototype.YD=function(){return k(yj(this.kB),m)}; -E.prototype.set_m_positionWorldOnB=E.prototype.PG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);zj(c,a)};Object.defineProperty(E.prototype,"m_positionWorldOnB",{get:E.prototype.YD,set:E.prototype.PG});E.prototype.get_m_positionWorldOnA=E.prototype.XD=function(){return k(Aj(this.kB),m)};E.prototype.set_m_positionWorldOnA=E.prototype.OG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Bj(c,a)};Object.defineProperty(E.prototype,"m_positionWorldOnA",{get:E.prototype.XD,set:E.prototype.OG}); -E.prototype.get_m_normalWorldOnB=E.prototype.SD=function(){return k(Cj(this.kB),m)};E.prototype.set_m_normalWorldOnB=E.prototype.JG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Dj(c,a)};Object.defineProperty(E.prototype,"m_normalWorldOnB",{get:E.prototype.SD,set:E.prototype.JG});E.prototype.get_m_userPersistentData=E.prototype.zE=function(){return Ej(this.kB)};E.prototype.set_m_userPersistentData=E.prototype.rH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Fj(c,a)}; -Object.defineProperty(E.prototype,"m_userPersistentData",{get:E.prototype.zE,set:E.prototype.rH});E.prototype.__destroy__=function(){Gj(this.kB)};function BE(){this.kB=Hj();h(BE)[this.kB]=this}BE.prototype=Object.create(eE.prototype);BE.prototype.constructor=BE;BE.prototype.lB=BE;BE.mB={};b.ConcreteContactResultCallback=BE; -BE.prototype.addSingleResult=function(a,c,d,e,g,n,z){var T=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);g&&"object"===typeof g&&(g=g.kB);n&&"object"===typeof n&&(n=n.kB);z&&"object"===typeof z&&(z=z.kB);return Ij(T,a,c,d,e,g,n,z)};BE.prototype.__destroy__=function(){Jj(this.kB)};function CE(){throw"cannot construct a LocalShapeInfo, no constructor in IDL";}CE.prototype=Object.create(f.prototype); -CE.prototype.constructor=CE;CE.prototype.lB=CE;CE.mB={};b.LocalShapeInfo=CE;CE.prototype.get_m_shapePart=CE.prototype.gE=function(){return Kj(this.kB)};CE.prototype.set_m_shapePart=CE.prototype.ZG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Lj(c,a)};Object.defineProperty(CE.prototype,"m_shapePart",{get:CE.prototype.gE,set:CE.prototype.ZG});CE.prototype.get_m_triangleIndex=CE.prototype.vE=function(){return Mj(this.kB)}; -CE.prototype.set_m_triangleIndex=CE.prototype.nH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Nj(c,a)};Object.defineProperty(CE.prototype,"m_triangleIndex",{get:CE.prototype.vE,set:CE.prototype.nH});CE.prototype.__destroy__=function(){Oj(this.kB)};function F(a,c,d,e,g){a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);g&&"object"===typeof g&&(g=g.kB);this.kB=Pj(a,c,d,e,g);h(F)[this.kB]=this} -F.prototype=Object.create(f.prototype);F.prototype.constructor=F;F.prototype.lB=F;F.mB={};b.LocalConvexResult=F;F.prototype.get_m_hitCollisionObject=F.prototype.LB=function(){return k(Qj(this.kB),q)};F.prototype.set_m_hitCollisionObject=F.prototype.VB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Rj(c,a)};Object.defineProperty(F.prototype,"m_hitCollisionObject",{get:F.prototype.LB,set:F.prototype.VB});F.prototype.get_m_localShapeInfo=F.prototype.ID=function(){return k(Sj(this.kB),CE)}; -F.prototype.set_m_localShapeInfo=F.prototype.zG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Tj(c,a)};Object.defineProperty(F.prototype,"m_localShapeInfo",{get:F.prototype.ID,set:F.prototype.zG});F.prototype.get_m_hitNormalLocal=F.prototype.sD=function(){return k(Uj(this.kB),m)};F.prototype.set_m_hitNormalLocal=F.prototype.jG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Vj(c,a)};Object.defineProperty(F.prototype,"m_hitNormalLocal",{get:F.prototype.sD,set:F.prototype.jG}); -F.prototype.get_m_hitPointLocal=F.prototype.uD=function(){return k(Wj(this.kB),m)};F.prototype.set_m_hitPointLocal=F.prototype.lG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Xj(c,a)};Object.defineProperty(F.prototype,"m_hitPointLocal",{get:F.prototype.uD,set:F.prototype.lG});F.prototype.get_m_hitFraction=F.prototype.pD=function(){return Yj(this.kB)};F.prototype.set_m_hitFraction=F.prototype.gG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Zj(c,a)}; -Object.defineProperty(F.prototype,"m_hitFraction",{get:F.prototype.pD,set:F.prototype.gG});F.prototype.__destroy__=function(){ak(this.kB)};function G(a,c){a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);this.kB=bk(a,c);h(G)[this.kB]=this}G.prototype=Object.create(v.prototype);G.prototype.constructor=G;G.prototype.lB=G;G.mB={};b.ClosestConvexResultCallback=G;G.prototype.hasHit=function(){return!!ck(this.kB)}; -G.prototype.get_m_hitCollisionObject=G.prototype.LB=function(){return k(dk(this.kB),q)};G.prototype.set_m_hitCollisionObject=G.prototype.VB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);ek(c,a)};Object.defineProperty(G.prototype,"m_hitCollisionObject",{get:G.prototype.LB,set:G.prototype.VB});G.prototype.get_m_convexFromWorld=G.prototype.ZC=function(){return k(fk(this.kB),m)}; -G.prototype.set_m_convexFromWorld=G.prototype.QF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);gk(c,a)};Object.defineProperty(G.prototype,"m_convexFromWorld",{get:G.prototype.ZC,set:G.prototype.QF});G.prototype.get_m_convexToWorld=G.prototype.$C=function(){return k(hk(this.kB),m)};G.prototype.set_m_convexToWorld=G.prototype.RF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);ik(c,a)};Object.defineProperty(G.prototype,"m_convexToWorld",{get:G.prototype.$C,set:G.prototype.RF}); -G.prototype.get_m_hitNormalWorld=G.prototype.xB=function(){return k(jk(this.kB),m)};G.prototype.set_m_hitNormalWorld=G.prototype.EB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);kk(c,a)};Object.defineProperty(G.prototype,"m_hitNormalWorld",{get:G.prototype.xB,set:G.prototype.EB});G.prototype.get_m_hitPointWorld=G.prototype.yB=function(){return k(lk(this.kB),m)};G.prototype.set_m_hitPointWorld=G.prototype.FB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);mk(c,a)}; -Object.defineProperty(G.prototype,"m_hitPointWorld",{get:G.prototype.yB,set:G.prototype.FB});G.prototype.get_m_collisionFilterGroup=G.prototype.nB=function(){return nk(this.kB)};G.prototype.set_m_collisionFilterGroup=G.prototype.pB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);ok(c,a)};Object.defineProperty(G.prototype,"m_collisionFilterGroup",{get:G.prototype.nB,set:G.prototype.pB});G.prototype.get_m_collisionFilterMask=G.prototype.oB=function(){return pk(this.kB)}; -G.prototype.set_m_collisionFilterMask=G.prototype.qB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);qk(c,a)};Object.defineProperty(G.prototype,"m_collisionFilterMask",{get:G.prototype.oB,set:G.prototype.qB});G.prototype.get_m_closestHitFraction=G.prototype.rB=function(){return rk(this.kB)};G.prototype.set_m_closestHitFraction=G.prototype.sB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);sk(c,a)};Object.defineProperty(G.prototype,"m_closestHitFraction",{get:G.prototype.rB,set:G.prototype.sB}); -G.prototype.__destroy__=function(){tk(this.kB)};function DE(a,c){a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);this.kB=void 0===c?uk(a):vk(a,c);h(DE)[this.kB]=this}DE.prototype=Object.create(fE.prototype);DE.prototype.constructor=DE;DE.prototype.lB=DE;DE.mB={};b.btConvexTriangleMeshShape=DE;DE.prototype.setLocalScaling=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);wk(c,a)};DE.prototype.getLocalScaling=function(){return k(xk(this.kB),m)}; -DE.prototype.calculateLocalInertia=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);yk(d,a,c)};DE.prototype.setMargin=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);zk(c,a)};DE.prototype.getMargin=function(){return Ak(this.kB)};DE.prototype.__destroy__=function(){Bk(this.kB)};function EE(a){a&&"object"===typeof a&&(a=a.kB);this.kB=Ck(a);h(EE)[this.kB]=this}EE.prototype=Object.create(l.prototype);EE.prototype.constructor=EE;EE.prototype.lB=EE; -EE.mB={};b.btBoxShape=EE;EE.prototype.setMargin=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Dk(c,a)};EE.prototype.getMargin=function(){return Ek(this.kB)};EE.prototype.setLocalScaling=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Fk(c,a)};EE.prototype.getLocalScaling=function(){return k(Gk(this.kB),m)};EE.prototype.calculateLocalInertia=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);Hk(d,a,c)};EE.prototype.__destroy__=function(){Ik(this.kB)}; -function FE(a,c){a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);this.kB=Jk(a,c);h(FE)[this.kB]=this}FE.prototype=Object.create(gE.prototype);FE.prototype.constructor=FE;FE.prototype.lB=FE;FE.mB={};b.btCapsuleShapeX=FE;FE.prototype.setMargin=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Kk(c,a)};FE.prototype.getMargin=function(){return Lk(this.kB)};FE.prototype.getUpAxis=function(){return Mk(this.kB)};FE.prototype.getRadius=function(){return Nk(this.kB)}; -FE.prototype.getHalfHeight=function(){return Ok(this.kB)};FE.prototype.setLocalScaling=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Pk(c,a)};FE.prototype.getLocalScaling=function(){return k(Qk(this.kB),m)};FE.prototype.calculateLocalInertia=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);Rk(d,a,c)};FE.prototype.__destroy__=function(){Sk(this.kB)}; -function GE(a,c){a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);this.kB=Tk(a,c);h(GE)[this.kB]=this}GE.prototype=Object.create(gE.prototype);GE.prototype.constructor=GE;GE.prototype.lB=GE;GE.mB={};b.btCapsuleShapeZ=GE;GE.prototype.setMargin=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Uk(c,a)};GE.prototype.getMargin=function(){return Vk(this.kB)};GE.prototype.getUpAxis=function(){return Wk(this.kB)};GE.prototype.getRadius=function(){return Xk(this.kB)}; -GE.prototype.getHalfHeight=function(){return Yk(this.kB)};GE.prototype.setLocalScaling=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Zk(c,a)};GE.prototype.getLocalScaling=function(){return k($k(this.kB),m)};GE.prototype.calculateLocalInertia=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);al(d,a,c)};GE.prototype.__destroy__=function(){bl(this.kB)};function HE(a){a&&"object"===typeof a&&(a=a.kB);this.kB=cl(a);h(HE)[this.kB]=this} -HE.prototype=Object.create(hE.prototype);HE.prototype.constructor=HE;HE.prototype.lB=HE;HE.mB={};b.btCylinderShapeX=HE;HE.prototype.setMargin=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);dl(c,a)};HE.prototype.getMargin=function(){return el(this.kB)};HE.prototype.setLocalScaling=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);fl(c,a)};HE.prototype.getLocalScaling=function(){return k(gl(this.kB),m)}; -HE.prototype.calculateLocalInertia=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);hl(d,a,c)};HE.prototype.__destroy__=function(){il(this.kB)};function IE(a){a&&"object"===typeof a&&(a=a.kB);this.kB=jl(a);h(IE)[this.kB]=this}IE.prototype=Object.create(hE.prototype);IE.prototype.constructor=IE;IE.prototype.lB=IE;IE.mB={};b.btCylinderShapeZ=IE;IE.prototype.setMargin=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);kl(c,a)}; -IE.prototype.getMargin=function(){return ll(this.kB)};IE.prototype.setLocalScaling=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);ml(c,a)};IE.prototype.getLocalScaling=function(){return k(nl(this.kB),m)};IE.prototype.calculateLocalInertia=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);ol(d,a,c)};IE.prototype.__destroy__=function(){pl(this.kB)};function JE(a){a&&"object"===typeof a&&(a=a.kB);this.kB=ql(a);h(JE)[this.kB]=this}JE.prototype=Object.create(l.prototype); -JE.prototype.constructor=JE;JE.prototype.lB=JE;JE.mB={};b.btSphereShape=JE;JE.prototype.setMargin=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);rl(c,a)};JE.prototype.getMargin=function(){return sl(this.kB)};JE.prototype.setLocalScaling=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);tl(c,a)};JE.prototype.getLocalScaling=function(){return k(ul(this.kB),m)}; -JE.prototype.calculateLocalInertia=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);vl(d,a,c)};JE.prototype.__destroy__=function(){wl(this.kB)};function KE(a,c,d){ND();a&&"object"===typeof a&&(a=a.kB);"object"==typeof c&&(c=RD(c));d&&"object"===typeof d&&(d=d.kB);this.kB=xl(a,c,d);h(KE)[this.kB]=this}KE.prototype=Object.create(l.prototype);KE.prototype.constructor=KE;KE.prototype.lB=KE;KE.mB={};b.btMultiSphereShape=KE; -KE.prototype.setLocalScaling=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);yl(c,a)};KE.prototype.getLocalScaling=function(){return k(zl(this.kB),m)};KE.prototype.calculateLocalInertia=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);Al(d,a,c)};KE.prototype.__destroy__=function(){Bl(this.kB)};function LE(a,c){a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);this.kB=Cl(a,c);h(LE)[this.kB]=this}LE.prototype=Object.create(iE.prototype); -LE.prototype.constructor=LE;LE.prototype.lB=LE;LE.mB={};b.btConeShapeX=LE;LE.prototype.setLocalScaling=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Dl(c,a)};LE.prototype.getLocalScaling=function(){return k(El(this.kB),m)};LE.prototype.calculateLocalInertia=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);Fl(d,a,c)};LE.prototype.__destroy__=function(){Gl(this.kB)}; -function ME(a,c){a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);this.kB=Hl(a,c);h(ME)[this.kB]=this}ME.prototype=Object.create(iE.prototype);ME.prototype.constructor=ME;ME.prototype.lB=ME;ME.mB={};b.btConeShapeZ=ME;ME.prototype.setLocalScaling=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Il(c,a)};ME.prototype.getLocalScaling=function(){return k(Jl(this.kB),m)}; -ME.prototype.calculateLocalInertia=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);Kl(d,a,c)};ME.prototype.__destroy__=function(){Ll(this.kB)};function NE(){throw"cannot construct a btIntArray, no constructor in IDL";}NE.prototype=Object.create(f.prototype);NE.prototype.constructor=NE;NE.prototype.lB=NE;NE.mB={};b.btIntArray=NE;NE.prototype.size=NE.prototype.size=function(){return Ml(this.kB)}; -NE.prototype.at=NE.prototype.at=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return Nl(c,a)};NE.prototype.__destroy__=function(){Ol(this.kB)};function OE(){throw"cannot construct a btFace, no constructor in IDL";}OE.prototype=Object.create(f.prototype);OE.prototype.constructor=OE;OE.prototype.lB=OE;OE.mB={};b.btFace=OE;OE.prototype.get_m_indices=OE.prototype.xD=function(){return k(Pl(this.kB),NE)}; -OE.prototype.set_m_indices=OE.prototype.oG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Ql(c,a)};Object.defineProperty(OE.prototype,"m_indices",{get:OE.prototype.xD,set:OE.prototype.oG});OE.prototype.get_m_plane=OE.prototype.WD=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return Rl(c,a)};OE.prototype.set_m_plane=OE.prototype.NG=function(a,c){var d=this.kB;ND();a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);Sl(d,a,c)}; -Object.defineProperty(OE.prototype,"m_plane",{get:OE.prototype.WD,set:OE.prototype.NG});OE.prototype.__destroy__=function(){Tl(this.kB)};function AE(){throw"cannot construct a btVector3Array, no constructor in IDL";}AE.prototype=Object.create(f.prototype);AE.prototype.constructor=AE;AE.prototype.lB=AE;AE.mB={};b.btVector3Array=AE;AE.prototype.size=AE.prototype.size=function(){return Ul(this.kB)}; -AE.prototype.at=AE.prototype.at=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return k(Vl(c,a),m)};AE.prototype.__destroy__=function(){Wl(this.kB)};function PE(){throw"cannot construct a btFaceArray, no constructor in IDL";}PE.prototype=Object.create(f.prototype);PE.prototype.constructor=PE;PE.prototype.lB=PE;PE.mB={};b.btFaceArray=PE;PE.prototype.size=PE.prototype.size=function(){return Xl(this.kB)}; -PE.prototype.at=PE.prototype.at=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return k(Yl(c,a),OE)};PE.prototype.__destroy__=function(){Zl(this.kB)};function QE(){throw"cannot construct a btConvexPolyhedron, no constructor in IDL";}QE.prototype=Object.create(f.prototype);QE.prototype.constructor=QE;QE.prototype.lB=QE;QE.mB={};b.btConvexPolyhedron=QE;QE.prototype.get_m_vertices=QE.prototype.BE=function(){return k($l(this.kB),AE)}; -QE.prototype.set_m_vertices=QE.prototype.tH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);am(c,a)};Object.defineProperty(QE.prototype,"m_vertices",{get:QE.prototype.BE,set:QE.prototype.tH});QE.prototype.get_m_faces=QE.prototype.KB=function(){return k(bm(this.kB),PE)};QE.prototype.set_m_faces=QE.prototype.UB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);cm(c,a)};Object.defineProperty(QE.prototype,"m_faces",{get:QE.prototype.KB,set:QE.prototype.UB}); -QE.prototype.__destroy__=function(){dm(this.kB)};function RE(a,c){ND();"object"==typeof a&&(a=RD(a));c&&"object"===typeof c&&(c=c.kB);this.kB=void 0===a?em():void 0===c?fm(a):gm(a,c);h(RE)[this.kB]=this}RE.prototype=Object.create(l.prototype);RE.prototype.constructor=RE;RE.prototype.lB=RE;RE.mB={};b.btConvexHullShape=RE;RE.prototype.addPoint=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);void 0===c?hm(d,a):im(d,a,c)}; -RE.prototype.setMargin=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);jm(c,a)};RE.prototype.getMargin=function(){return km(this.kB)};RE.prototype.getNumVertices=function(){return lm(this.kB)};RE.prototype.initializePolyhedralFeatures=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return!!mm(c,a)};RE.prototype.recalcLocalAabb=function(){nm(this.kB)};RE.prototype.getConvexPolyhedron=function(){return k(om(this.kB),QE)}; -RE.prototype.setLocalScaling=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);pm(c,a)};RE.prototype.getLocalScaling=function(){return k(qm(this.kB),m)};RE.prototype.calculateLocalInertia=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);rm(d,a,c)};RE.prototype.__destroy__=function(){sm(this.kB)};function SE(a){a&&"object"===typeof a&&(a=a.kB);this.kB=tm(a);h(SE)[this.kB]=this}SE.prototype=Object.create(f.prototype);SE.prototype.constructor=SE; -SE.prototype.lB=SE;SE.mB={};b.btShapeHull=SE;SE.prototype.buildHull=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return!!um(c,a)};SE.prototype.numVertices=function(){return wm(this.kB)};SE.prototype.getVertexPointer=function(){return k(xm(this.kB),m)};SE.prototype.__destroy__=function(){ym(this.kB)};function TE(a){a&&"object"===typeof a&&(a=a.kB);this.kB=void 0===a?zm():Am(a);h(TE)[this.kB]=this}TE.prototype=Object.create(l.prototype);TE.prototype.constructor=TE;TE.prototype.lB=TE; -TE.mB={};b.btCompoundShape=TE;TE.prototype.addChildShape=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);Bm(d,a,c)};TE.prototype.removeChildShape=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Cm(c,a)};TE.prototype.removeChildShapeByIndex=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Dm(c,a)};TE.prototype.getNumChildShapes=function(){return Em(this.kB)}; -TE.prototype.getChildShape=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return k(Fm(c,a),l)};TE.prototype.updateChildTransform=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);void 0===d?Gm(e,a,c):Hm(e,a,c,d)};TE.prototype.setMargin=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Im(c,a)};TE.prototype.getMargin=function(){return Jm(this.kB)}; -TE.prototype.setLocalScaling=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Km(c,a)};TE.prototype.getLocalScaling=function(){return k(Lm(this.kB),m)};TE.prototype.calculateLocalInertia=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);Mm(d,a,c)};TE.prototype.__destroy__=function(){Nm(this.kB)};function UE(){throw"cannot construct a btIndexedMesh, no constructor in IDL";}UE.prototype=Object.create(f.prototype);UE.prototype.constructor=UE; -UE.prototype.lB=UE;UE.mB={};b.btIndexedMesh=UE;UE.prototype.get_m_numTriangles=UE.prototype.UD=function(){return Om(this.kB)};UE.prototype.set_m_numTriangles=UE.prototype.LG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Pm(c,a)};Object.defineProperty(UE.prototype,"m_numTriangles",{get:UE.prototype.UD,set:UE.prototype.LG});UE.prototype.__destroy__=function(){Qm(this.kB)};function VE(){throw"cannot construct a btIndexedMeshArray, no constructor in IDL";}VE.prototype=Object.create(f.prototype); -VE.prototype.constructor=VE;VE.prototype.lB=VE;VE.mB={};b.btIndexedMeshArray=VE;VE.prototype.size=VE.prototype.size=function(){return Rm(this.kB)};VE.prototype.at=VE.prototype.at=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return k(Sm(c,a),UE)};VE.prototype.__destroy__=function(){Tm(this.kB)};function WE(a,c){a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);this.kB=void 0===a?Um():void 0===c?Vm(a):Wm(a,c);h(WE)[this.kB]=this}WE.prototype=Object.create(jE.prototype); -WE.prototype.constructor=WE;WE.prototype.lB=WE;WE.mB={};b.btTriangleMesh=WE;WE.prototype.addTriangle=function(a,c,d,e){var g=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);void 0===e?Xm(g,a,c,d):Ym(g,a,c,d,e)};WE.prototype.findOrAddVertex=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);return Zm(d,a,c)}; -WE.prototype.addIndex=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);$m(c,a)};WE.prototype.getIndexedMeshArray=function(){return k(an(this.kB),VE)};WE.prototype.setScaling=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);bn(c,a)};WE.prototype.__destroy__=function(){cn(this.kB)};function XE(){this.kB=dn();h(XE)[this.kB]=this}XE.prototype=Object.create(ZD.prototype);XE.prototype.constructor=XE;XE.prototype.lB=XE;XE.mB={};b.btEmptyShape=XE; -XE.prototype.setLocalScaling=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);en(c,a)};XE.prototype.getLocalScaling=function(){return k(fn(this.kB),m)};XE.prototype.calculateLocalInertia=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);gn(d,a,c)};XE.prototype.__destroy__=function(){hn(this.kB)};function YE(a,c){a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);this.kB=jn(a,c);h(YE)[this.kB]=this}YE.prototype=Object.create(ZD.prototype); -YE.prototype.constructor=YE;YE.prototype.lB=YE;YE.mB={};b.btStaticPlaneShape=YE;YE.prototype.setLocalScaling=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);kn(c,a)};YE.prototype.getLocalScaling=function(){return k(ln(this.kB),m)};YE.prototype.calculateLocalInertia=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);mn(d,a,c)};YE.prototype.__destroy__=function(){nn(this.kB)}; -function ZE(a,c,d){a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);this.kB=void 0===d?on(a,c):pn(a,c,d);h(ZE)[this.kB]=this}ZE.prototype=Object.create(kE.prototype);ZE.prototype.constructor=ZE;ZE.prototype.lB=ZE;ZE.mB={};b.btBvhTriangleMeshShape=ZE;ZE.prototype.setLocalScaling=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);qn(c,a)};ZE.prototype.getLocalScaling=function(){return k(rn(this.kB),m)}; -ZE.prototype.calculateLocalInertia=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);sn(d,a,c)};ZE.prototype.__destroy__=function(){tn(this.kB)}; -function $E(a,c,d,e,g,n,z,T,Da){a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);g&&"object"===typeof g&&(g=g.kB);n&&"object"===typeof n&&(n=n.kB);z&&"object"===typeof z&&(z=z.kB);T&&"object"===typeof T&&(T=T.kB);Da&&"object"===typeof Da&&(Da=Da.kB);this.kB=un(a,c,d,e,g,n,z,T,Da);h($E)[this.kB]=this}$E.prototype=Object.create(ZD.prototype);$E.prototype.constructor=$E;$E.prototype.lB=$E;$E.mB={}; -b.btHeightfieldTerrainShape=$E;$E.prototype.setMargin=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);vn(c,a)};$E.prototype.getMargin=function(){return wn(this.kB)};$E.prototype.setLocalScaling=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);xn(c,a)};$E.prototype.getLocalScaling=function(){return k(yn(this.kB),m)};$E.prototype.calculateLocalInertia=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);zn(d,a,c)}; -$E.prototype.__destroy__=function(){An(this.kB)};function aF(a,c,d,e){a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);this.kB=Bn(a,c,d,e);h(aF)[this.kB]=this}aF.prototype=Object.create(f.prototype);aF.prototype.constructor=aF;aF.prototype.lB=aF;aF.mB={};b.btAABB=aF;aF.prototype.invalidate=function(){Cn(this.kB)};aF.prototype.increment_margin=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Dn(c,a)}; -aF.prototype.copy_with_margin=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);En(d,a,c)};aF.prototype.__destroy__=function(){Fn(this.kB)};function bF(){this.kB=Gn();h(bF)[this.kB]=this}bF.prototype=Object.create(f.prototype);bF.prototype.constructor=bF;bF.prototype.lB=bF;bF.mB={};b.btPrimitiveTriangle=bF;bF.prototype.__destroy__=function(){Hn(this.kB)}; -function cF(a,c,d){a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);this.kB=In(a,c,d);h(cF)[this.kB]=this}cF.prototype=Object.create(f.prototype);cF.prototype.constructor=cF;cF.prototype.lB=cF;cF.mB={};b.btTriangleShapeEx=cF;cF.prototype.getAabb=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);Jn(e,a,c,d)}; -cF.prototype.applyTransform=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Kn(c,a)};cF.prototype.buildTriPlane=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Ln(c,a)};cF.prototype.__destroy__=function(){Mn(this.kB)};function dF(){this.kB=Nn();h(dF)[this.kB]=this}dF.prototype=Object.create(f.prototype);dF.prototype.constructor=dF;dF.prototype.lB=dF;dF.mB={};b.btTetrahedronShapeEx=dF; -dF.prototype.setVertices=function(a,c,d,e){var g=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);On(g,a,c,d,e)};dF.prototype.__destroy__=function(){Pn(this.kB)};function eF(){throw"cannot construct a CompoundPrimitiveManager, no constructor in IDL";}eF.prototype=Object.create(lE.prototype);eF.prototype.constructor=eF;eF.prototype.lB=eF;eF.mB={};b.CompoundPrimitiveManager=eF; -eF.prototype.get_primitive_count=function(){return Qn(this.kB)};eF.prototype.get_primitive_box=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);Rn(d,a,c)};eF.prototype.get_primitive_triangle=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);Sn(d,a,c)};eF.prototype.is_trimesh=function(){return!!Tn(this.kB)};eF.prototype.get_m_compoundShape=eF.prototype.VC=function(){return k(Un(this.kB),H)}; -eF.prototype.set_m_compoundShape=eF.prototype.MF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Vn(c,a)};Object.defineProperty(eF.prototype,"m_compoundShape",{get:eF.prototype.VC,set:eF.prototype.MF});eF.prototype.__destroy__=function(){Wn(this.kB)};function H(a){a&&"object"===typeof a&&(a=a.kB);this.kB=void 0===a?Xn():Yn(a);h(H)[this.kB]=this}H.prototype=Object.create(w.prototype);H.prototype.constructor=H;H.prototype.lB=H;H.mB={};b.btGImpactCompoundShape=H; -H.prototype.childrenHasTransform=function(){return!!Zn(this.kB)};H.prototype.getPrimitiveManager=function(){return k($n(this.kB),lE)};H.prototype.getCompoundPrimitiveManager=function(){return k(ao(this.kB),eF)};H.prototype.getNumChildShapes=function(){return bo(this.kB)};H.prototype.addChildShape=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);co(d,a,c)}; -H.prototype.getChildShape=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return k(eo(c,a),l)};H.prototype.getChildAabb=function(a,c,d,e){var g=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);fo(g,a,c,d,e)};H.prototype.getChildTransform=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return k(go(c,a),r)}; -H.prototype.setChildTransform=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);ho(d,a,c)};H.prototype.calculateLocalInertia=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);io(d,a,c)};H.prototype.getName=function(){return sa(jo(this.kB))};H.prototype.getGImpactShapeType=function(){return ko(this.kB)};H.prototype.setLocalScaling=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);lo(c,a)}; -H.prototype.getLocalScaling=function(){return k(mo(this.kB),m)};H.prototype.updateBound=function(){no(this.kB)};H.prototype.postUpdate=function(){oo(this.kB)};H.prototype.getShapeType=function(){return po(this.kB)};H.prototype.needsRetrieveTriangles=function(){return!!qo(this.kB)};H.prototype.needsRetrieveTetrahedrons=function(){return!!ro(this.kB)};H.prototype.getBulletTriangle=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);so(d,a,c)}; -H.prototype.getBulletTetrahedron=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);to(d,a,c)};H.prototype.__destroy__=function(){uo(this.kB)};function I(a){a&&"object"===typeof a&&(a=a.kB);this.kB=void 0===a?vo():wo(a);h(I)[this.kB]=this}I.prototype=Object.create(lE.prototype);I.prototype.constructor=I;I.prototype.lB=I;I.mB={};b.TrimeshPrimitiveManager=I;I.prototype.lock=I.prototype.lock=function(){xo(this.kB)};I.prototype.unlock=I.prototype.unlock=function(){yo(this.kB)}; -I.prototype.is_trimesh=function(){return!!zo(this.kB)};I.prototype.get_vertex_count=function(){return Ao(this.kB)};I.prototype.get_indices=function(a,c,d,e){var g=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);Bo(g,a,c,d,e)};I.prototype.get_vertex=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);Co(d,a,c)}; -I.prototype.get_bullet_triangle=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);Do(d,a,c)};I.prototype.get_m_margin=I.prototype.LD=function(){return Eo(this.kB)};I.prototype.set_m_margin=I.prototype.CG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Fo(c,a)};Object.defineProperty(I.prototype,"m_margin",{get:I.prototype.LD,set:I.prototype.CG});I.prototype.get_m_meshInterface=I.prototype.OD=function(){return k(Go(this.kB),jE)}; -I.prototype.set_m_meshInterface=I.prototype.FG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Ho(c,a)};Object.defineProperty(I.prototype,"m_meshInterface",{get:I.prototype.OD,set:I.prototype.FG});I.prototype.get_m_part=I.prototype.VD=function(){return Io(this.kB)};I.prototype.set_m_part=I.prototype.MG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Jo(c,a)};Object.defineProperty(I.prototype,"m_part",{get:I.prototype.VD,set:I.prototype.MG}); -I.prototype.get_m_lock_count=I.prototype.JD=function(){return Ko(this.kB)};I.prototype.set_m_lock_count=I.prototype.AG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Lo(c,a)};Object.defineProperty(I.prototype,"m_lock_count",{get:I.prototype.JD,set:I.prototype.AG});I.prototype.get_numverts=I.prototype.LE=function(){return Mo(this.kB)};I.prototype.set_numverts=I.prototype.DH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);No(c,a)}; -Object.defineProperty(I.prototype,"numverts",{get:I.prototype.LE,set:I.prototype.DH});I.prototype.get_type=I.prototype.PE=function(){return Oo(this.kB)};I.prototype.set_type=I.prototype.HH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Po(c,a)};Object.defineProperty(I.prototype,"type",{get:I.prototype.PE,set:I.prototype.HH});I.prototype.get_stride=I.prototype.NE=function(){return Qo(this.kB)}; -I.prototype.set_stride=I.prototype.FH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Ro(c,a)};Object.defineProperty(I.prototype,"stride",{get:I.prototype.NE,set:I.prototype.FH});I.prototype.get_indexstride=I.prototype.gC=function(){return So(this.kB)};I.prototype.set_indexstride=I.prototype.YE=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);To(c,a)};Object.defineProperty(I.prototype,"indexstride",{get:I.prototype.gC,set:I.prototype.YE}); -I.prototype.get_numfaces=I.prototype.KE=function(){return Uo(this.kB)};I.prototype.set_numfaces=I.prototype.CH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Vo(c,a)};Object.defineProperty(I.prototype,"numfaces",{get:I.prototype.KE,set:I.prototype.CH});I.prototype.get_indicestype=I.prototype.hC=function(){return Wo(this.kB)};I.prototype.set_indicestype=I.prototype.ZE=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Xo(c,a)}; -Object.defineProperty(I.prototype,"indicestype",{get:I.prototype.hC,set:I.prototype.ZE});I.prototype.__destroy__=function(){Yo(this.kB)};function fF(a,c){a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);this.kB=Zo(a,c);h(fF)[this.kB]=this}fF.prototype=Object.create(w.prototype);fF.prototype.constructor=fF;fF.prototype.lB=fF;fF.mB={};b.btGImpactMeshShapePart=fF;fF.prototype.getTrimeshPrimitiveManager=function(){return k($o(this.kB),I)};fF.prototype.getVertexCount=function(){return ap(this.kB)}; -fF.prototype.getVertex=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);bp(d,a,c)};fF.prototype.getPart=function(){return cp(this.kB)};fF.prototype.setLocalScaling=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);dp(c,a)};fF.prototype.getLocalScaling=function(){return k(ep(this.kB),m)};fF.prototype.updateBound=function(){fp(this.kB)};fF.prototype.postUpdate=function(){gp(this.kB)};fF.prototype.getShapeType=function(){return hp(this.kB)}; -fF.prototype.needsRetrieveTriangles=function(){return!!ip(this.kB)};fF.prototype.needsRetrieveTetrahedrons=function(){return!!jp(this.kB)};fF.prototype.getBulletTriangle=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);kp(d,a,c)};fF.prototype.getBulletTetrahedron=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);lp(d,a,c)};fF.prototype.__destroy__=function(){mp(this.kB)}; -function gF(a){a&&"object"===typeof a&&(a=a.kB);this.kB=np(a);h(gF)[this.kB]=this}gF.prototype=Object.create(w.prototype);gF.prototype.constructor=gF;gF.prototype.lB=gF;gF.mB={};b.btGImpactMeshShape=gF;gF.prototype.getMeshInterface=function(){return k(op(this.kB),jE)};gF.prototype.getMeshPartCount=function(){return pp(this.kB)};gF.prototype.getMeshPart=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return k(qp(c,a),fF)};gF.prototype.calculateSerializeBufferSize=function(){return rp(this.kB)}; -gF.prototype.setLocalScaling=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);sp(c,a)};gF.prototype.getLocalScaling=function(){return k(tp(this.kB),m)};gF.prototype.updateBound=function(){up(this.kB)};gF.prototype.postUpdate=function(){vp(this.kB)};gF.prototype.getShapeType=function(){return wp(this.kB)};gF.prototype.needsRetrieveTriangles=function(){return!!xp(this.kB)};gF.prototype.needsRetrieveTetrahedrons=function(){return!!yp(this.kB)}; -gF.prototype.getBulletTriangle=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);zp(d,a,c)};gF.prototype.getBulletTetrahedron=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);Ap(d,a,c)};gF.prototype.__destroy__=function(){Bp(this.kB)}; -function hF(a,c){a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);this.kB=void 0===a?Cp():void 0===c?_emscripten_bind_btCollisionAlgorithmConstructionInfo_btCollisionAlgorithmConstructionInfo_1(a):Dp(a,c);h(hF)[this.kB]=this}hF.prototype=Object.create(f.prototype);hF.prototype.constructor=hF;hF.prototype.lB=hF;hF.mB={};b.btCollisionAlgorithmConstructionInfo=hF;hF.prototype.get_m_dispatcher1=hF.prototype.eD=function(){return k(Ep(this.kB),TD)}; -hF.prototype.set_m_dispatcher1=hF.prototype.WF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Fp(c,a)};Object.defineProperty(hF.prototype,"m_dispatcher1",{get:hF.prototype.eD,set:hF.prototype.WF});hF.prototype.get_m_manifold=hF.prototype.KD=function(){return k(Gp(this.kB),oE)};hF.prototype.set_m_manifold=hF.prototype.BG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Hp(c,a)};Object.defineProperty(hF.prototype,"m_manifold",{get:hF.prototype.KD,set:hF.prototype.BG}); -hF.prototype.__destroy__=function(){Ip(this.kB)};function iF(a,c,d){a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);this.kB=Jp(a,c,d);h(iF)[this.kB]=this}iF.prototype=Object.create(mE.prototype);iF.prototype.constructor=iF;iF.prototype.lB=iF;iF.mB={};b.btGImpactCollisionAlgorithm=iF;iF.prototype.registerAlgorithm=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Kp(c,a)};iF.prototype.__destroy__=function(){Lp(this.kB)}; -function jF(){this.kB=Mp();h(jF)[this.kB]=this}jF.prototype=Object.create(f.prototype);jF.prototype.constructor=jF;jF.prototype.lB=jF;jF.mB={};b.btDefaultCollisionConstructionInfo=jF;jF.prototype.__destroy__=function(){Np(this.kB)};function oE(){this.kB=Op();h(oE)[this.kB]=this}oE.prototype=Object.create(f.prototype);oE.prototype.constructor=oE;oE.prototype.lB=oE;oE.mB={};b.btPersistentManifold=oE;oE.prototype.getBody0=function(){return k(Pp(this.kB),q)}; -oE.prototype.getBody1=function(){return k(Qp(this.kB),q)};oE.prototype.getNumContacts=function(){return Rp(this.kB)};oE.prototype.getContactPoint=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return k(Sp(c,a),E)};oE.prototype.__destroy__=function(){Tp(this.kB)};function kF(a){a&&"object"===typeof a&&(a=a.kB);this.kB=Up(a);h(kF)[this.kB]=this}kF.prototype=Object.create(TD.prototype);kF.prototype.constructor=kF;kF.prototype.lB=kF;kF.mB={};b.btCollisionDispatcher=kF; -kF.prototype.getNumManifolds=function(){return Vp(this.kB)};kF.prototype.getManifoldByIndexInternal=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return k(Wp(c,a),oE)};kF.prototype.__destroy__=function(){Xp(this.kB)};function lF(){throw"cannot construct a btOverlappingPairCallback, no constructor in IDL";}lF.prototype=Object.create(f.prototype);lF.prototype.constructor=lF;lF.prototype.lB=lF;lF.mB={};b.btOverlappingPairCallback=lF;lF.prototype.__destroy__=function(){Yp(this.kB)}; -function UD(){throw"cannot construct a btOverlappingPairCache, no constructor in IDL";}UD.prototype=Object.create(f.prototype);UD.prototype.constructor=UD;UD.prototype.lB=UD;UD.mB={};b.btOverlappingPairCache=UD;UD.prototype.setInternalGhostPairCallback=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Zp(c,a)};UD.prototype.getNumOverlappingPairs=function(){return $p(this.kB)};UD.prototype.__destroy__=function(){aq(this.kB)}; -function mF(a,c,d,e,g){a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);g&&"object"===typeof g&&(g=g.kB);this.kB=void 0===d?bq(a,c):void 0===e?cq(a,c,d):void 0===g?dq(a,c,d,e):eq(a,c,d,e,g);h(mF)[this.kB]=this}mF.prototype=Object.create(f.prototype);mF.prototype.constructor=mF;mF.prototype.lB=mF;mF.mB={};b.btAxisSweep3=mF;mF.prototype.__destroy__=function(){fq(this.kB)}; -function VD(){throw"cannot construct a btBroadphaseInterface, no constructor in IDL";}VD.prototype=Object.create(f.prototype);VD.prototype.constructor=VD;VD.prototype.lB=VD;VD.mB={};b.btBroadphaseInterface=VD;VD.prototype.getOverlappingPairCache=function(){return k(gq(this.kB),UD)};VD.prototype.__destroy__=function(){hq(this.kB)};function nF(){throw"cannot construct a btCollisionConfiguration, no constructor in IDL";}nF.prototype=Object.create(f.prototype);nF.prototype.constructor=nF; -nF.prototype.lB=nF;nF.mB={};b.btCollisionConfiguration=nF;nF.prototype.__destroy__=function(){iq(this.kB)};function oF(){this.kB=jq();h(oF)[this.kB]=this}oF.prototype=Object.create(f.prototype);oF.prototype.constructor=oF;oF.prototype.lB=oF;oF.mB={};b.btDbvtBroadphase=oF;oF.prototype.__destroy__=function(){kq(this.kB)};function YD(){throw"cannot construct a btBroadphaseProxy, no constructor in IDL";}YD.prototype=Object.create(f.prototype);YD.prototype.constructor=YD;YD.prototype.lB=YD;YD.mB={}; -b.btBroadphaseProxy=YD;YD.prototype.get_m_collisionFilterGroup=YD.prototype.nB=function(){return lq(this.kB)};YD.prototype.set_m_collisionFilterGroup=YD.prototype.pB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);mq(c,a)};Object.defineProperty(YD.prototype,"m_collisionFilterGroup",{get:YD.prototype.nB,set:YD.prototype.pB});YD.prototype.get_m_collisionFilterMask=YD.prototype.oB=function(){return nq(this.kB)}; -YD.prototype.set_m_collisionFilterMask=YD.prototype.qB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);oq(c,a)};Object.defineProperty(YD.prototype,"m_collisionFilterMask",{get:YD.prototype.oB,set:YD.prototype.qB});YD.prototype.__destroy__=function(){pq(this.kB)};function J(a,c,d,e){a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);this.kB=void 0===e?qq(a,c,d):rq(a,c,d,e);h(J)[this.kB]=this}J.prototype=Object.create(f.prototype); -J.prototype.constructor=J;J.prototype.lB=J;J.mB={};b.btRigidBodyConstructionInfo=J;J.prototype.get_m_linearDamping=J.prototype.DD=function(){return sq(this.kB)};J.prototype.set_m_linearDamping=J.prototype.uG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);tq(c,a)};Object.defineProperty(J.prototype,"m_linearDamping",{get:J.prototype.DD,set:J.prototype.uG});J.prototype.get_m_angularDamping=J.prototype.HC=function(){return uq(this.kB)}; -J.prototype.set_m_angularDamping=J.prototype.yF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);vq(c,a)};Object.defineProperty(J.prototype,"m_angularDamping",{get:J.prototype.HC,set:J.prototype.yF});J.prototype.get_m_friction=J.prototype.kD=function(){return wq(this.kB)};J.prototype.set_m_friction=J.prototype.bG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);xq(c,a)};Object.defineProperty(J.prototype,"m_friction",{get:J.prototype.kD,set:J.prototype.bG}); -J.prototype.get_m_rollingFriction=J.prototype.dE=function(){return yq(this.kB)};J.prototype.set_m_rollingFriction=J.prototype.WG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);zq(c,a)};Object.defineProperty(J.prototype,"m_rollingFriction",{get:J.prototype.dE,set:J.prototype.WG});J.prototype.get_m_restitution=J.prototype.bE=function(){return Aq(this.kB)};J.prototype.set_m_restitution=J.prototype.UG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Bq(c,a)}; -Object.defineProperty(J.prototype,"m_restitution",{get:J.prototype.bE,set:J.prototype.UG});J.prototype.get_m_linearSleepingThreshold=J.prototype.ED=function(){return Cq(this.kB)};J.prototype.set_m_linearSleepingThreshold=J.prototype.vG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Dq(c,a)};Object.defineProperty(J.prototype,"m_linearSleepingThreshold",{get:J.prototype.ED,set:J.prototype.vG});J.prototype.get_m_angularSleepingThreshold=J.prototype.IC=function(){return Eq(this.kB)}; -J.prototype.set_m_angularSleepingThreshold=J.prototype.zF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Fq(c,a)};Object.defineProperty(J.prototype,"m_angularSleepingThreshold",{get:J.prototype.IC,set:J.prototype.zF});J.prototype.get_m_additionalDamping=J.prototype.CC=function(){return!!Gq(this.kB)};J.prototype.set_m_additionalDamping=J.prototype.tF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Hq(c,a)}; -Object.defineProperty(J.prototype,"m_additionalDamping",{get:J.prototype.CC,set:J.prototype.tF});J.prototype.get_m_additionalDampingFactor=J.prototype.DC=function(){return Iq(this.kB)};J.prototype.set_m_additionalDampingFactor=J.prototype.uF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Jq(c,a)};Object.defineProperty(J.prototype,"m_additionalDampingFactor",{get:J.prototype.DC,set:J.prototype.uF});J.prototype.get_m_additionalLinearDampingThresholdSqr=J.prototype.EC=function(){return Kq(this.kB)}; -J.prototype.set_m_additionalLinearDampingThresholdSqr=J.prototype.vF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Lq(c,a)};Object.defineProperty(J.prototype,"m_additionalLinearDampingThresholdSqr",{get:J.prototype.EC,set:J.prototype.vF});J.prototype.get_m_additionalAngularDampingThresholdSqr=J.prototype.BC=function(){return Mq(this.kB)};J.prototype.set_m_additionalAngularDampingThresholdSqr=J.prototype.sF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Nq(c,a)}; -Object.defineProperty(J.prototype,"m_additionalAngularDampingThresholdSqr",{get:J.prototype.BC,set:J.prototype.sF});J.prototype.get_m_additionalAngularDampingFactor=J.prototype.AC=function(){return Oq(this.kB)};J.prototype.set_m_additionalAngularDampingFactor=J.prototype.rF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Pq(c,a)};Object.defineProperty(J.prototype,"m_additionalAngularDampingFactor",{get:J.prototype.AC,set:J.prototype.rF});J.prototype.__destroy__=function(){Qq(this.kB)}; -function K(a){a&&"object"===typeof a&&(a=a.kB);this.kB=Rq(a);h(K)[this.kB]=this}K.prototype=Object.create(q.prototype);K.prototype.constructor=K;K.prototype.lB=K;K.mB={};b.btRigidBody=K;K.prototype.getCenterOfMassTransform=function(){return k(Sq(this.kB),r)};K.prototype.setCenterOfMassTransform=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Tq(c,a)};K.prototype.setSleepingThresholds=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);Uq(d,a,c)}; -K.prototype.getLinearDamping=function(){return Vq(this.kB)};K.prototype.getAngularDamping=function(){return Wq(this.kB)};K.prototype.setDamping=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);Xq(d,a,c)};K.prototype.setMassProps=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);Yq(d,a,c)};K.prototype.getLinearFactor=function(){return k(Zq(this.kB),m)}; -K.prototype.setLinearFactor=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);$q(c,a)};K.prototype.applyTorque=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);ar(c,a)};K.prototype.applyLocalTorque=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);br(c,a)};K.prototype.applyForce=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);cr(d,a,c)}; -K.prototype.applyCentralForce=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);dr(c,a)};K.prototype.applyCentralLocalForce=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);er(c,a)};K.prototype.applyTorqueImpulse=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);fr(c,a)};K.prototype.applyImpulse=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);gr(d,a,c)}; -K.prototype.applyCentralImpulse=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);hr(c,a)};K.prototype.updateInertiaTensor=function(){ir(this.kB)};K.prototype.getLinearVelocity=function(){return k(jr(this.kB),m)};K.prototype.getAngularVelocity=function(){return k(kr(this.kB),m)};K.prototype.setLinearVelocity=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);lr(c,a)};K.prototype.setAngularVelocity=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);mr(c,a)}; -K.prototype.getMotionState=function(){return k(nr(this.kB),dE)};K.prototype.setMotionState=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);or(c,a)};K.prototype.getAngularFactor=function(){return k(pr(this.kB),m)};K.prototype.setAngularFactor=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);qr(c,a)};K.prototype.upcast=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return k(rr(c,a),K)}; -K.prototype.getAabb=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);sr(d,a,c)};K.prototype.applyGravity=function(){tr(this.kB)};K.prototype.getGravity=function(){return k(ur(this.kB),m)};K.prototype.setGravity=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);vr(c,a)};K.prototype.getBroadphaseProxy=function(){return k(wr(this.kB),YD)};K.prototype.clearForces=function(){xr(this.kB)}; -K.prototype.setFlags=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);yr(c,a)};K.prototype.getFlags=function(){return zr(this.kB)};K.prototype.setAnisotropicFriction=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);Ar(d,a,c)};K.prototype.getCollisionShape=function(){return k(Br(this.kB),l)};K.prototype.setContactProcessingThreshold=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Cr(c,a)}; -K.prototype.setActivationState=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Dr(c,a)};K.prototype.forceActivationState=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Er(c,a)};K.prototype.activate=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);void 0===a?Fr(c):Gr(c,a)};K.prototype.isActive=function(){return!!Hr(this.kB)};K.prototype.isKinematicObject=function(){return!!Ir(this.kB)};K.prototype.isStaticObject=function(){return!!Jr(this.kB)}; -K.prototype.isStaticOrKinematicObject=function(){return!!Kr(this.kB)};K.prototype.getRestitution=function(){return Lr(this.kB)};K.prototype.getFriction=function(){return Mr(this.kB)};K.prototype.getRollingFriction=function(){return Nr(this.kB)};K.prototype.setRestitution=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Or(c,a)};K.prototype.setFriction=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Pr(c,a)}; -K.prototype.setRollingFriction=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Qr(c,a)};K.prototype.getWorldTransform=function(){return k(Rr(this.kB),r)};K.prototype.getCollisionFlags=function(){return Sr(this.kB)};K.prototype.setCollisionFlags=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Tr(c,a)};K.prototype.setWorldTransform=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Ur(c,a)}; -K.prototype.setCollisionShape=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Vr(c,a)};K.prototype.setCcdMotionThreshold=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Wr(c,a)};K.prototype.setCcdSweptSphereRadius=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Xr(c,a)};K.prototype.getUserIndex=function(){return Yr(this.kB)};K.prototype.setUserIndex=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Zr(c,a)}; -K.prototype.getUserPointer=function(){return k($r(this.kB),XD)};K.prototype.setUserPointer=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);as(c,a)};K.prototype.getBroadphaseHandle=function(){return k(bs(this.kB),YD)};K.prototype.__destroy__=function(){cs(this.kB)};function L(){this.kB=ds();h(L)[this.kB]=this}L.prototype=Object.create(f.prototype);L.prototype.constructor=L;L.prototype.lB=L;L.mB={};b.btConstraintSetting=L;L.prototype.get_m_tau=L.prototype.sE=function(){return es(this.kB)}; -L.prototype.set_m_tau=L.prototype.kH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);gs(c,a)};Object.defineProperty(L.prototype,"m_tau",{get:L.prototype.sE,set:L.prototype.kH});L.prototype.get_m_damping=L.prototype.aD=function(){return hs(this.kB)};L.prototype.set_m_damping=L.prototype.SF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);is(c,a)};Object.defineProperty(L.prototype,"m_damping",{get:L.prototype.aD,set:L.prototype.SF}); -L.prototype.get_m_impulseClamp=L.prototype.wD=function(){return js(this.kB)};L.prototype.set_m_impulseClamp=L.prototype.nG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);ks(c,a)};Object.defineProperty(L.prototype,"m_impulseClamp",{get:L.prototype.wD,set:L.prototype.nG});L.prototype.__destroy__=function(){ls(this.kB)}; -function pF(a,c,d,e){a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);this.kB=void 0===d?ms(a,c):void 0===e?_emscripten_bind_btPoint2PointConstraint_btPoint2PointConstraint_3(a,c,d):ns(a,c,d,e);h(pF)[this.kB]=this}pF.prototype=Object.create(aE.prototype);pF.prototype.constructor=pF;pF.prototype.lB=pF;pF.mB={};b.btPoint2PointConstraint=pF; -pF.prototype.setPivotA=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);ps(c,a)};pF.prototype.setPivotB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);qs(c,a)};pF.prototype.getPivotInA=function(){return k(rs(this.kB),m)};pF.prototype.getPivotInB=function(){return k(ss(this.kB),m)};pF.prototype.enableFeedback=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);ts(c,a)};pF.prototype.getBreakingImpulseThreshold=function(){return us(this.kB)}; -pF.prototype.setBreakingImpulseThreshold=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);vs(c,a)};pF.prototype.getParam=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);return xs(d,a,c)};pF.prototype.setParam=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);ys(e,a,c,d)};pF.prototype.get_m_setting=pF.prototype.fE=function(){return k(zs(this.kB),L)}; -pF.prototype.set_m_setting=pF.prototype.YG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);As(c,a)};Object.defineProperty(pF.prototype,"m_setting",{get:pF.prototype.fE,set:pF.prototype.YG});pF.prototype.__destroy__=function(){Bs(this.kB)}; -function qF(a,c,d,e,g){a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);g&&"object"===typeof g&&(g=g.kB);this.kB=void 0===e?Cs(a,c,d):void 0===g?_emscripten_bind_btGeneric6DofSpringConstraint_btGeneric6DofSpringConstraint_4(a,c,d,e):Ds(a,c,d,e,g);h(qF)[this.kB]=this}qF.prototype=Object.create(pE.prototype);qF.prototype.constructor=qF;qF.prototype.lB=qF;qF.mB={};b.btGeneric6DofSpringConstraint=qF; -qF.prototype.enableSpring=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);Es(d,a,c)};qF.prototype.setStiffness=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);Fs(d,a,c)};qF.prototype.setDamping=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);Gs(d,a,c)}; -qF.prototype.setEquilibriumPoint=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);void 0===a?Hs(d):void 0===c?Is(d,a):Js(d,a,c)};qF.prototype.setLinearLowerLimit=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Ks(c,a)};qF.prototype.setLinearUpperLimit=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Ls(c,a)};qF.prototype.setAngularLowerLimit=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Ms(c,a)}; -qF.prototype.setAngularUpperLimit=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Ns(c,a)};qF.prototype.getFrameOffsetA=function(){return k(Os(this.kB),r)};qF.prototype.enableFeedback=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Ps(c,a)};qF.prototype.getBreakingImpulseThreshold=function(){return Qs(this.kB)};qF.prototype.setBreakingImpulseThreshold=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Rs(c,a)}; -qF.prototype.getParam=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);return Ss(d,a,c)};qF.prototype.setParam=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);Ts(e,a,c,d)};qF.prototype.__destroy__=function(){Us(this.kB)};function rF(){this.kB=Vs();h(rF)[this.kB]=this}rF.prototype=Object.create(f.prototype);rF.prototype.constructor=rF;rF.prototype.lB=rF;rF.mB={}; -b.btSequentialImpulseConstraintSolver=rF;rF.prototype.__destroy__=function(){Ws(this.kB)};function sF(a,c,d,e){a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);this.kB=void 0===d?Xs(a,c):void 0===e?_emscripten_bind_btConeTwistConstraint_btConeTwistConstraint_3(a,c,d):Ys(a,c,d,e);h(sF)[this.kB]=this}sF.prototype=Object.create(aE.prototype);sF.prototype.constructor=sF;sF.prototype.lB=sF;sF.mB={}; -b.btConeTwistConstraint=sF;sF.prototype.setLimit=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);Zs(d,a,c)};sF.prototype.setAngularOnly=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);$s(c,a)};sF.prototype.setDamping=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);at(c,a)};sF.prototype.enableMotor=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);bt(c,a)}; -sF.prototype.setMaxMotorImpulse=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);ct(c,a)};sF.prototype.setMaxMotorImpulseNormalized=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);dt(c,a)};sF.prototype.setMotorTarget=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);et(c,a)};sF.prototype.setMotorTargetInConstraintSpace=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);ft(c,a)}; -sF.prototype.enableFeedback=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);gt(c,a)};sF.prototype.getBreakingImpulseThreshold=function(){return ht(this.kB)};sF.prototype.setBreakingImpulseThreshold=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);it(c,a)};sF.prototype.getParam=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);return jt(d,a,c)}; -sF.prototype.setParam=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);kt(e,a,c,d)};sF.prototype.__destroy__=function(){lt(this.kB)}; -function tF(a,c,d,e,g,n,z){a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);g&&"object"===typeof g&&(g=g.kB);n&&"object"===typeof n&&(n=n.kB);z&&"object"===typeof z&&(z=z.kB);this.kB=void 0===d?mt(a,c):void 0===e?nt(a,c,d):void 0===g?ot(a,c,d,e):void 0===n?pt(a,c,d,e,g):void 0===z?qt(a,c,d,e,g,n):rt(a,c,d,e,g,n,z);h(tF)[this.kB]=this}tF.prototype=Object.create(aE.prototype);tF.prototype.constructor=tF; -tF.prototype.lB=tF;tF.mB={};b.btHingeConstraint=tF;tF.prototype.getHingeAngle=function(){return st(this.kB)};tF.prototype.setLimit=function(a,c,d,e,g){var n=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);g&&"object"===typeof g&&(g=g.kB);void 0===g?tt(n,a,c,d,e):ut(n,a,c,d,e,g)}; -tF.prototype.enableAngularMotor=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);vt(e,a,c,d)};tF.prototype.setAngularOnly=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);wt(c,a)};tF.prototype.enableMotor=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);xt(c,a)};tF.prototype.setMaxMotorImpulse=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);yt(c,a)}; -tF.prototype.setMotorTarget=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);zt(d,a,c)};tF.prototype.enableFeedback=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);At(c,a)};tF.prototype.getBreakingImpulseThreshold=function(){return Bt(this.kB)};tF.prototype.setBreakingImpulseThreshold=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Ct(c,a)}; -tF.prototype.getParam=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);return Dt(d,a,c)};tF.prototype.setParam=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);Et(e,a,c,d)};tF.prototype.__destroy__=function(){Ft(this.kB)}; -function uF(a,c,d,e,g){a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);g&&"object"===typeof g&&(g=g.kB);this.kB=void 0===e?Gt(a,c,d):void 0===g?_emscripten_bind_btSliderConstraint_btSliderConstraint_4(a,c,d,e):Ht(a,c,d,e,g);h(uF)[this.kB]=this}uF.prototype=Object.create(aE.prototype);uF.prototype.constructor=uF;uF.prototype.lB=uF;uF.mB={};b.btSliderConstraint=uF;uF.prototype.getLinearPos=function(){return It(this.kB)}; -uF.prototype.getAngularPos=function(){return Jt(this.kB)};uF.prototype.setLowerLinLimit=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Kt(c,a)};uF.prototype.setUpperLinLimit=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Lt(c,a)};uF.prototype.setLowerAngLimit=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Mt(c,a)};uF.prototype.setUpperAngLimit=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Nt(c,a)}; -uF.prototype.setPoweredLinMotor=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Ot(c,a)};uF.prototype.setMaxLinMotorForce=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Pt(c,a)};uF.prototype.setTargetLinMotorVelocity=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Qt(c,a)};uF.prototype.enableFeedback=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Rt(c,a)};uF.prototype.getBreakingImpulseThreshold=function(){return St(this.kB)}; -uF.prototype.setBreakingImpulseThreshold=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Tt(c,a)};uF.prototype.getParam=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);return Ut(d,a,c)};uF.prototype.setParam=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);Vt(e,a,c,d)};uF.prototype.__destroy__=function(){Wt(this.kB)}; -function vF(a,c,d,e){a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);this.kB=Xt(a,c,d,e);h(vF)[this.kB]=this}vF.prototype=Object.create(aE.prototype);vF.prototype.constructor=vF;vF.prototype.lB=vF;vF.mB={};b.btFixedConstraint=vF;vF.prototype.enableFeedback=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Yt(c,a)};vF.prototype.getBreakingImpulseThreshold=function(){return Zt(this.kB)}; -vF.prototype.setBreakingImpulseThreshold=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);$t(c,a)};vF.prototype.getParam=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);return au(d,a,c)};vF.prototype.setParam=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);bu(e,a,c,d)};vF.prototype.__destroy__=function(){cu(this.kB)}; -function wF(){throw"cannot construct a btConstraintSolver, no constructor in IDL";}wF.prototype=Object.create(f.prototype);wF.prototype.constructor=wF;wF.prototype.lB=wF;wF.mB={};b.btConstraintSolver=wF;wF.prototype.__destroy__=function(){du(this.kB)};function p(){throw"cannot construct a btDispatcherInfo, no constructor in IDL";}p.prototype=Object.create(f.prototype);p.prototype.constructor=p;p.prototype.lB=p;p.mB={};b.btDispatcherInfo=p;p.prototype.get_m_timeStep=p.prototype.uE=function(){return eu(this.kB)}; -p.prototype.set_m_timeStep=p.prototype.mH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);fu(c,a)};Object.defineProperty(p.prototype,"m_timeStep",{get:p.prototype.uE,set:p.prototype.mH});p.prototype.get_m_stepCount=p.prototype.lE=function(){return gu(this.kB)};p.prototype.set_m_stepCount=p.prototype.dH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);hu(c,a)};Object.defineProperty(p.prototype,"m_stepCount",{get:p.prototype.lE,set:p.prototype.dH}); -p.prototype.get_m_dispatchFunc=p.prototype.cD=function(){return iu(this.kB)};p.prototype.set_m_dispatchFunc=p.prototype.UF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);ju(c,a)};Object.defineProperty(p.prototype,"m_dispatchFunc",{get:p.prototype.cD,set:p.prototype.UF});p.prototype.get_m_timeOfImpact=p.prototype.tE=function(){return ku(this.kB)};p.prototype.set_m_timeOfImpact=p.prototype.lH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);lu(c,a)}; -Object.defineProperty(p.prototype,"m_timeOfImpact",{get:p.prototype.tE,set:p.prototype.lH});p.prototype.get_m_useContinuous=p.prototype.wE=function(){return!!mu(this.kB)};p.prototype.set_m_useContinuous=p.prototype.oH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);nu(c,a)};Object.defineProperty(p.prototype,"m_useContinuous",{get:p.prototype.wE,set:p.prototype.oH});p.prototype.get_m_enableSatConvex=p.prototype.hD=function(){return!!ou(this.kB)}; -p.prototype.set_m_enableSatConvex=p.prototype.ZF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);pu(c,a)};Object.defineProperty(p.prototype,"m_enableSatConvex",{get:p.prototype.hD,set:p.prototype.ZF});p.prototype.get_m_enableSPU=p.prototype.gD=function(){return!!qu(this.kB)};p.prototype.set_m_enableSPU=p.prototype.YF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);ru(c,a)};Object.defineProperty(p.prototype,"m_enableSPU",{get:p.prototype.gD,set:p.prototype.YF}); -p.prototype.get_m_useEpa=p.prototype.yE=function(){return!!su(this.kB)};p.prototype.set_m_useEpa=p.prototype.qH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);tu(c,a)};Object.defineProperty(p.prototype,"m_useEpa",{get:p.prototype.yE,set:p.prototype.qH});p.prototype.get_m_allowedCcdPenetration=p.prototype.FC=function(){return uu(this.kB)};p.prototype.set_m_allowedCcdPenetration=p.prototype.wF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);vu(c,a)}; -Object.defineProperty(p.prototype,"m_allowedCcdPenetration",{get:p.prototype.FC,set:p.prototype.wF});p.prototype.get_m_useConvexConservativeDistanceUtil=p.prototype.xE=function(){return!!wu(this.kB)};p.prototype.set_m_useConvexConservativeDistanceUtil=p.prototype.pH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);xu(c,a)};Object.defineProperty(p.prototype,"m_useConvexConservativeDistanceUtil",{get:p.prototype.xE,set:p.prototype.pH}); -p.prototype.get_m_convexConservativeDistanceThreshold=p.prototype.YC=function(){return yu(this.kB)};p.prototype.set_m_convexConservativeDistanceThreshold=p.prototype.PF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);zu(c,a)};Object.defineProperty(p.prototype,"m_convexConservativeDistanceThreshold",{get:p.prototype.YC,set:p.prototype.PF});p.prototype.__destroy__=function(){Au(this.kB)};function t(){throw"cannot construct a btContactSolverInfo, no constructor in IDL";}t.prototype=Object.create(f.prototype); -t.prototype.constructor=t;t.prototype.lB=t;t.mB={};b.btContactSolverInfo=t;t.prototype.get_m_splitImpulse=t.prototype.iE=function(){return!!Bu(this.kB)};t.prototype.set_m_splitImpulse=t.prototype.aH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Cu(c,a)};Object.defineProperty(t.prototype,"m_splitImpulse",{get:t.prototype.iE,set:t.prototype.aH});t.prototype.get_m_splitImpulsePenetrationThreshold=t.prototype.jE=function(){return Du(this.kB)}; -t.prototype.set_m_splitImpulsePenetrationThreshold=t.prototype.bH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Eu(c,a)};Object.defineProperty(t.prototype,"m_splitImpulsePenetrationThreshold",{get:t.prototype.jE,set:t.prototype.bH});t.prototype.get_m_numIterations=t.prototype.TD=function(){return Fu(this.kB)};t.prototype.set_m_numIterations=t.prototype.KG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Gu(c,a)}; -Object.defineProperty(t.prototype,"m_numIterations",{get:t.prototype.TD,set:t.prototype.KG});t.prototype.__destroy__=function(){Hu(this.kB)};function M(){this.kB=Iu();h(M)[this.kB]=this}M.prototype=Object.create(f.prototype);M.prototype.constructor=M;M.prototype.lB=M;M.mB={};b.btVehicleTuning=M;M.prototype.get_m_suspensionStiffness=M.prototype.BB=function(){return Ju(this.kB)};M.prototype.set_m_suspensionStiffness=M.prototype.IB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Ku(c,a)}; -Object.defineProperty(M.prototype,"m_suspensionStiffness",{get:M.prototype.BB,set:M.prototype.IB});M.prototype.get_m_suspensionCompression=M.prototype.mE=function(){return Lu(this.kB)};M.prototype.set_m_suspensionCompression=M.prototype.eH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Mu(c,a)};Object.defineProperty(M.prototype,"m_suspensionCompression",{get:M.prototype.mE,set:M.prototype.eH});M.prototype.get_m_suspensionDamping=M.prototype.nE=function(){return Nu(this.kB)}; -M.prototype.set_m_suspensionDamping=M.prototype.fH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Ou(c,a)};Object.defineProperty(M.prototype,"m_suspensionDamping",{get:M.prototype.nE,set:M.prototype.fH});M.prototype.get_m_maxSuspensionTravelCm=M.prototype.AB=function(){return Pu(this.kB)};M.prototype.set_m_maxSuspensionTravelCm=M.prototype.HB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Qu(c,a)}; -Object.defineProperty(M.prototype,"m_maxSuspensionTravelCm",{get:M.prototype.AB,set:M.prototype.HB});M.prototype.get_m_frictionSlip=M.prototype.wB=function(){return Ru(this.kB)};M.prototype.set_m_frictionSlip=M.prototype.DB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Su(c,a)};Object.defineProperty(M.prototype,"m_frictionSlip",{get:M.prototype.wB,set:M.prototype.DB});M.prototype.get_m_maxSuspensionForce=M.prototype.zB=function(){return Tu(this.kB)}; -M.prototype.set_m_maxSuspensionForce=M.prototype.GB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Uu(c,a)};Object.defineProperty(M.prototype,"m_maxSuspensionForce",{get:M.prototype.zB,set:M.prototype.GB});function xF(){throw"cannot construct a btVehicleRaycasterResult, no constructor in IDL";}xF.prototype=Object.create(f.prototype);xF.prototype.constructor=xF;xF.prototype.lB=xF;xF.mB={};b.btVehicleRaycasterResult=xF; -xF.prototype.get_m_hitPointInWorld=xF.prototype.tD=function(){return k(Vu(this.kB),m)};xF.prototype.set_m_hitPointInWorld=xF.prototype.kG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Wu(c,a)};Object.defineProperty(xF.prototype,"m_hitPointInWorld",{get:xF.prototype.tD,set:xF.prototype.kG});xF.prototype.get_m_hitNormalInWorld=xF.prototype.rD=function(){return k(Xu(this.kB),m)}; -xF.prototype.set_m_hitNormalInWorld=xF.prototype.iG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Yu(c,a)};Object.defineProperty(xF.prototype,"m_hitNormalInWorld",{get:xF.prototype.rD,set:xF.prototype.iG});xF.prototype.get_m_distFraction=xF.prototype.fD=function(){return Zu(this.kB)};xF.prototype.set_m_distFraction=xF.prototype.XF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);$u(c,a)};Object.defineProperty(xF.prototype,"m_distFraction",{get:xF.prototype.fD,set:xF.prototype.XF}); -xF.prototype.__destroy__=function(){av(this.kB)};function yF(a){a&&"object"===typeof a&&(a=a.kB);this.kB=bv(a);h(yF)[this.kB]=this}yF.prototype=Object.create(qE.prototype);yF.prototype.constructor=yF;yF.prototype.lB=yF;yF.mB={};b.btDefaultVehicleRaycaster=yF;yF.prototype.castRay=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);cv(e,a,c,d)};yF.prototype.__destroy__=function(){dv(this.kB)}; -function N(){throw"cannot construct a RaycastInfo, no constructor in IDL";}N.prototype=Object.create(f.prototype);N.prototype.constructor=N;N.prototype.lB=N;N.mB={};b.RaycastInfo=N;N.prototype.get_m_contactNormalWS=N.prototype.WC=function(){return k(ev(this.kB),m)};N.prototype.set_m_contactNormalWS=N.prototype.NF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);fv(c,a)};Object.defineProperty(N.prototype,"m_contactNormalWS",{get:N.prototype.WC,set:N.prototype.NF}); -N.prototype.get_m_contactPointWS=N.prototype.XC=function(){return k(gv(this.kB),m)};N.prototype.set_m_contactPointWS=N.prototype.OF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);hv(c,a)};Object.defineProperty(N.prototype,"m_contactPointWS",{get:N.prototype.XC,set:N.prototype.OF});N.prototype.get_m_suspensionLength=N.prototype.oE=function(){return iv(this.kB)};N.prototype.set_m_suspensionLength=N.prototype.gH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);jv(c,a)}; -Object.defineProperty(N.prototype,"m_suspensionLength",{get:N.prototype.oE,set:N.prototype.gH});N.prototype.get_m_hardPointWS=N.prototype.oD=function(){return k(kv(this.kB),m)};N.prototype.set_m_hardPointWS=N.prototype.fG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);lv(c,a)};Object.defineProperty(N.prototype,"m_hardPointWS",{get:N.prototype.oD,set:N.prototype.fG});N.prototype.get_m_wheelDirectionWS=N.prototype.DE=function(){return k(mv(this.kB),m)}; -N.prototype.set_m_wheelDirectionWS=N.prototype.vH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);nv(c,a)};Object.defineProperty(N.prototype,"m_wheelDirectionWS",{get:N.prototype.DE,set:N.prototype.vH});N.prototype.get_m_wheelAxleWS=N.prototype.CE=function(){return k(ov(this.kB),m)};N.prototype.set_m_wheelAxleWS=N.prototype.uH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);pv(c,a)};Object.defineProperty(N.prototype,"m_wheelAxleWS",{get:N.prototype.CE,set:N.prototype.uH}); -N.prototype.get_m_isInContact=N.prototype.zD=function(){return!!qv(this.kB)};N.prototype.set_m_isInContact=N.prototype.qG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);rv(c,a)};Object.defineProperty(N.prototype,"m_isInContact",{get:N.prototype.zD,set:N.prototype.qG});N.prototype.get_m_groundObject=N.prototype.nD=function(){return sv(this.kB)};N.prototype.set_m_groundObject=N.prototype.eG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);tv(c,a)}; -Object.defineProperty(N.prototype,"m_groundObject",{get:N.prototype.nD,set:N.prototype.eG});N.prototype.__destroy__=function(){uv(this.kB)};function O(){throw"cannot construct a btWheelInfoConstructionInfo, no constructor in IDL";}O.prototype=Object.create(f.prototype);O.prototype.constructor=O;O.prototype.lB=O;O.mB={};b.btWheelInfoConstructionInfo=O;O.prototype.get_m_chassisConnectionCS=O.prototype.RC=function(){return k(vv(this.kB),m)}; -O.prototype.set_m_chassisConnectionCS=O.prototype.IF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);wv(c,a)};Object.defineProperty(O.prototype,"m_chassisConnectionCS",{get:O.prototype.RC,set:O.prototype.IF});O.prototype.get_m_wheelDirectionCS=O.prototype.QB=function(){return k(xv(this.kB),m)};O.prototype.set_m_wheelDirectionCS=O.prototype.$B=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);yv(c,a)};Object.defineProperty(O.prototype,"m_wheelDirectionCS",{get:O.prototype.QB,set:O.prototype.$B}); -O.prototype.get_m_wheelAxleCS=O.prototype.PB=function(){return k(zv(this.kB),m)};O.prototype.set_m_wheelAxleCS=O.prototype.ZB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Av(c,a)};Object.defineProperty(O.prototype,"m_wheelAxleCS",{get:O.prototype.PB,set:O.prototype.ZB});O.prototype.get_m_suspensionRestLength=O.prototype.qE=function(){return Bv(this.kB)};O.prototype.set_m_suspensionRestLength=O.prototype.iH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Cv(c,a)}; -Object.defineProperty(O.prototype,"m_suspensionRestLength",{get:O.prototype.qE,set:O.prototype.iH});O.prototype.get_m_maxSuspensionTravelCm=O.prototype.AB=function(){return Dv(this.kB)};O.prototype.set_m_maxSuspensionTravelCm=O.prototype.HB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Ev(c,a)};Object.defineProperty(O.prototype,"m_maxSuspensionTravelCm",{get:O.prototype.AB,set:O.prototype.HB});O.prototype.get_m_wheelRadius=O.prototype.EE=function(){return Fv(this.kB)}; -O.prototype.set_m_wheelRadius=O.prototype.wH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Gv(c,a)};Object.defineProperty(O.prototype,"m_wheelRadius",{get:O.prototype.EE,set:O.prototype.wH});O.prototype.get_m_suspensionStiffness=O.prototype.BB=function(){return Hv(this.kB)};O.prototype.set_m_suspensionStiffness=O.prototype.IB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Iv(c,a)};Object.defineProperty(O.prototype,"m_suspensionStiffness",{get:O.prototype.BB,set:O.prototype.IB}); -O.prototype.get_m_wheelsDampingCompression=O.prototype.RB=function(){return Jv(this.kB)};O.prototype.set_m_wheelsDampingCompression=O.prototype.aC=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Kv(c,a)};Object.defineProperty(O.prototype,"m_wheelsDampingCompression",{get:O.prototype.RB,set:O.prototype.aC});O.prototype.get_m_wheelsDampingRelaxation=O.prototype.SB=function(){return Lv(this.kB)}; -O.prototype.set_m_wheelsDampingRelaxation=O.prototype.bC=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Mv(c,a)};Object.defineProperty(O.prototype,"m_wheelsDampingRelaxation",{get:O.prototype.SB,set:O.prototype.bC});O.prototype.get_m_frictionSlip=O.prototype.wB=function(){return Nv(this.kB)};O.prototype.set_m_frictionSlip=O.prototype.DB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Ov(c,a)};Object.defineProperty(O.prototype,"m_frictionSlip",{get:O.prototype.wB,set:O.prototype.DB}); -O.prototype.get_m_maxSuspensionForce=O.prototype.zB=function(){return Pv(this.kB)};O.prototype.set_m_maxSuspensionForce=O.prototype.GB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Qv(c,a)};Object.defineProperty(O.prototype,"m_maxSuspensionForce",{get:O.prototype.zB,set:O.prototype.GB});O.prototype.get_m_bIsFrontWheel=O.prototype.JB=function(){return!!Rv(this.kB)};O.prototype.set_m_bIsFrontWheel=O.prototype.TB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Sv(c,a)}; -Object.defineProperty(O.prototype,"m_bIsFrontWheel",{get:O.prototype.JB,set:O.prototype.TB});O.prototype.__destroy__=function(){Tv(this.kB)};function P(a){a&&"object"===typeof a&&(a=a.kB);this.kB=Uv(a);h(P)[this.kB]=this}P.prototype=Object.create(f.prototype);P.prototype.constructor=P;P.prototype.lB=P;P.mB={};b.btWheelInfo=P;P.prototype.getSuspensionRestLength=function(){return Vv(this.kB)}; -P.prototype.updateWheel=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);Wv(d,a,c)};P.prototype.get_m_suspensionStiffness=P.prototype.BB=function(){return Xv(this.kB)};P.prototype.set_m_suspensionStiffness=P.prototype.IB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Yv(c,a)};Object.defineProperty(P.prototype,"m_suspensionStiffness",{get:P.prototype.BB,set:P.prototype.IB});P.prototype.get_m_frictionSlip=P.prototype.wB=function(){return Zv(this.kB)}; -P.prototype.set_m_frictionSlip=P.prototype.DB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);$v(c,a)};Object.defineProperty(P.prototype,"m_frictionSlip",{get:P.prototype.wB,set:P.prototype.DB});P.prototype.get_m_engineForce=P.prototype.iD=function(){return aw(this.kB)};P.prototype.set_m_engineForce=P.prototype.$F=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);bw(c,a)};Object.defineProperty(P.prototype,"m_engineForce",{get:P.prototype.iD,set:P.prototype.$F}); -P.prototype.get_m_rollInfluence=P.prototype.cE=function(){return cw(this.kB)};P.prototype.set_m_rollInfluence=P.prototype.VG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);dw(c,a)};Object.defineProperty(P.prototype,"m_rollInfluence",{get:P.prototype.cE,set:P.prototype.VG});P.prototype.get_m_suspensionRestLength1=P.prototype.rE=function(){return ew(this.kB)};P.prototype.set_m_suspensionRestLength1=P.prototype.jH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);fw(c,a)}; -Object.defineProperty(P.prototype,"m_suspensionRestLength1",{get:P.prototype.rE,set:P.prototype.jH});P.prototype.get_m_wheelsRadius=P.prototype.FE=function(){return gw(this.kB)};P.prototype.set_m_wheelsRadius=P.prototype.xH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);hw(c,a)};Object.defineProperty(P.prototype,"m_wheelsRadius",{get:P.prototype.FE,set:P.prototype.xH});P.prototype.get_m_wheelsDampingCompression=P.prototype.RB=function(){return iw(this.kB)}; -P.prototype.set_m_wheelsDampingCompression=P.prototype.aC=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);jw(c,a)};Object.defineProperty(P.prototype,"m_wheelsDampingCompression",{get:P.prototype.RB,set:P.prototype.aC});P.prototype.get_m_wheelsDampingRelaxation=P.prototype.SB=function(){return kw(this.kB)};P.prototype.set_m_wheelsDampingRelaxation=P.prototype.bC=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);lw(c,a)}; -Object.defineProperty(P.prototype,"m_wheelsDampingRelaxation",{get:P.prototype.SB,set:P.prototype.bC});P.prototype.get_m_steering=P.prototype.kE=function(){return mw(this.kB)};P.prototype.set_m_steering=P.prototype.cH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);nw(c,a)};Object.defineProperty(P.prototype,"m_steering",{get:P.prototype.kE,set:P.prototype.cH});P.prototype.get_m_maxSuspensionForce=P.prototype.zB=function(){return ow(this.kB)}; -P.prototype.set_m_maxSuspensionForce=P.prototype.GB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);pw(c,a)};Object.defineProperty(P.prototype,"m_maxSuspensionForce",{get:P.prototype.zB,set:P.prototype.GB});P.prototype.get_m_maxSuspensionTravelCm=P.prototype.AB=function(){return qw(this.kB)};P.prototype.set_m_maxSuspensionTravelCm=P.prototype.HB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);rw(c,a)}; -Object.defineProperty(P.prototype,"m_maxSuspensionTravelCm",{get:P.prototype.AB,set:P.prototype.HB});P.prototype.get_m_wheelsSuspensionForce=P.prototype.GE=function(){return sw(this.kB)};P.prototype.set_m_wheelsSuspensionForce=P.prototype.yH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);tw(c,a)};Object.defineProperty(P.prototype,"m_wheelsSuspensionForce",{get:P.prototype.GE,set:P.prototype.yH});P.prototype.get_m_bIsFrontWheel=P.prototype.JB=function(){return!!uw(this.kB)}; -P.prototype.set_m_bIsFrontWheel=P.prototype.TB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);vw(c,a)};Object.defineProperty(P.prototype,"m_bIsFrontWheel",{get:P.prototype.JB,set:P.prototype.TB});P.prototype.get_m_raycastInfo=P.prototype.aE=function(){return k(ww(this.kB),N)};P.prototype.set_m_raycastInfo=P.prototype.TG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);xw(c,a)};Object.defineProperty(P.prototype,"m_raycastInfo",{get:P.prototype.aE,set:P.prototype.TG}); -P.prototype.get_m_chassisConnectionPointCS=P.prototype.SC=function(){return k(yw(this.kB),m)};P.prototype.set_m_chassisConnectionPointCS=P.prototype.JF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);zw(c,a)};Object.defineProperty(P.prototype,"m_chassisConnectionPointCS",{get:P.prototype.SC,set:P.prototype.JF});P.prototype.get_m_worldTransform=P.prototype.HE=function(){return k(Aw(this.kB),r)}; -P.prototype.set_m_worldTransform=P.prototype.zH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Bw(c,a)};Object.defineProperty(P.prototype,"m_worldTransform",{get:P.prototype.HE,set:P.prototype.zH});P.prototype.get_m_wheelDirectionCS=P.prototype.QB=function(){return k(Cw(this.kB),m)};P.prototype.set_m_wheelDirectionCS=P.prototype.$B=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Dw(c,a)};Object.defineProperty(P.prototype,"m_wheelDirectionCS",{get:P.prototype.QB,set:P.prototype.$B}); -P.prototype.get_m_wheelAxleCS=P.prototype.PB=function(){return k(Ew(this.kB),m)};P.prototype.set_m_wheelAxleCS=P.prototype.ZB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Fw(c,a)};Object.defineProperty(P.prototype,"m_wheelAxleCS",{get:P.prototype.PB,set:P.prototype.ZB});P.prototype.get_m_rotation=P.prototype.eE=function(){return Gw(this.kB)};P.prototype.set_m_rotation=P.prototype.XG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Hw(c,a)}; -Object.defineProperty(P.prototype,"m_rotation",{get:P.prototype.eE,set:P.prototype.XG});P.prototype.get_m_deltaRotation=P.prototype.bD=function(){return Iw(this.kB)};P.prototype.set_m_deltaRotation=P.prototype.TF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Jw(c,a)};Object.defineProperty(P.prototype,"m_deltaRotation",{get:P.prototype.bD,set:P.prototype.TF});P.prototype.get_m_brake=P.prototype.LC=function(){return Kw(this.kB)}; -P.prototype.set_m_brake=P.prototype.CF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Lw(c,a)};Object.defineProperty(P.prototype,"m_brake",{get:P.prototype.LC,set:P.prototype.CF});P.prototype.get_m_clippedInvContactDotSuspension=P.prototype.TC=function(){return Mw(this.kB)};P.prototype.set_m_clippedInvContactDotSuspension=P.prototype.KF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Nw(c,a)}; -Object.defineProperty(P.prototype,"m_clippedInvContactDotSuspension",{get:P.prototype.TC,set:P.prototype.KF});P.prototype.get_m_suspensionRelativeVelocity=P.prototype.pE=function(){return Ow(this.kB)};P.prototype.set_m_suspensionRelativeVelocity=P.prototype.hH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Pw(c,a)};Object.defineProperty(P.prototype,"m_suspensionRelativeVelocity",{get:P.prototype.pE,set:P.prototype.hH});P.prototype.get_m_skidInfo=P.prototype.hE=function(){return Qw(this.kB)}; -P.prototype.set_m_skidInfo=P.prototype.$G=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Rw(c,a)};Object.defineProperty(P.prototype,"m_skidInfo",{get:P.prototype.hE,set:P.prototype.$G});P.prototype.__destroy__=function(){Sw(this.kB)};function zF(a,c,d,e){a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);this.kB=void 0===e?Tw(a,c,d):Uw(a,c,d,e);h(zF)[this.kB]=this}zF.prototype=Object.create(rE.prototype); -zF.prototype.constructor=zF;zF.prototype.lB=zF;zF.mB={};b.btKinematicCharacterController=zF;zF.prototype.setUpAxis=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Vw(c,a)};zF.prototype.setWalkDirection=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Ww(c,a)};zF.prototype.setVelocityForTimeInterval=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);Xw(d,a,c)}; -zF.prototype.warp=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Yw(c,a)};zF.prototype.preStep=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Zw(c,a)};zF.prototype.playerStep=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);$w(d,a,c)};zF.prototype.setFallSpeed=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);ax(c,a)};zF.prototype.setJumpSpeed=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);bx(c,a)}; -zF.prototype.setMaxJumpHeight=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);cx(c,a)};zF.prototype.canJump=function(){return!!dx(this.kB)};zF.prototype.jump=function(){ex(this.kB)};zF.prototype.setGravity=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);fx(c,a)};zF.prototype.getGravity=function(){return gx(this.kB)};zF.prototype.setMaxSlope=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);hx(c,a)};zF.prototype.getMaxSlope=function(){return ix(this.kB)}; -zF.prototype.getGhostObject=function(){return k(jx(this.kB),Q)};zF.prototype.setUseGhostSweepTest=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);kx(c,a)};zF.prototype.onGround=function(){return!!lx(this.kB)};zF.prototype.setUpInterpolate=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);mx(c,a)};zF.prototype.updateAction=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);nx(d,a,c)};zF.prototype.__destroy__=function(){ox(this.kB)}; -function R(a,c,d){a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);this.kB=px(a,c,d);h(R)[this.kB]=this}R.prototype=Object.create(rE.prototype);R.prototype.constructor=R;R.prototype.lB=R;R.mB={};b.btRaycastVehicle=R;R.prototype.applyEngineForce=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);qx(d,a,c)}; -R.prototype.setSteeringValue=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);rx(d,a,c)};R.prototype.getWheelTransformWS=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return k(sx(c,a),r)};R.prototype.updateWheelTransform=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);tx(d,a,c)}; -R.prototype.addWheel=function(a,c,d,e,g,n,z){var T=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);g&&"object"===typeof g&&(g=g.kB);n&&"object"===typeof n&&(n=n.kB);z&&"object"===typeof z&&(z=z.kB);return k(ux(T,a,c,d,e,g,n,z),P)};R.prototype.getNumWheels=function(){return vx(this.kB)};R.prototype.getRigidBody=function(){return k(wx(this.kB),K)}; -R.prototype.getWheelInfo=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return k(xx(c,a),P)};R.prototype.setBrake=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);yx(d,a,c)};R.prototype.setCoordinateSystem=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);zx(e,a,c,d)};R.prototype.getCurrentSpeedKmHour=function(){return Ax(this.kB)}; -R.prototype.getChassisWorldTransform=function(){return k(Bx(this.kB),r)};R.prototype.rayCast=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return Cx(c,a)};R.prototype.updateVehicle=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Dx(c,a)};R.prototype.resetSuspension=function(){Ex(this.kB)};R.prototype.getSteeringValue=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return Fx(c,a)}; -R.prototype.updateWheelTransformsWS=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);void 0===c?Gx(d,a):Hx(d,a,c)};R.prototype.setPitchControl=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Ix(c,a)};R.prototype.updateSuspension=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Jx(c,a)};R.prototype.updateFriction=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Kx(c,a)};R.prototype.getRightAxis=function(){return Lx(this.kB)}; -R.prototype.getUpAxis=function(){return Mx(this.kB)};R.prototype.getForwardAxis=function(){return Nx(this.kB)};R.prototype.getForwardVector=function(){return k(Ox(this.kB),m)};R.prototype.getUserConstraintType=function(){return Px(this.kB)};R.prototype.setUserConstraintType=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Qx(c,a)};R.prototype.setUserConstraintId=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Rx(c,a)};R.prototype.getUserConstraintId=function(){return Sx(this.kB)}; -R.prototype.updateAction=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);Tx(d,a,c)};R.prototype.__destroy__=function(){Ux(this.kB)};function Q(){this.kB=Vx();h(Q)[this.kB]=this}Q.prototype=Object.create(y.prototype);Q.prototype.constructor=Q;Q.prototype.lB=Q;Q.mB={};b.btPairCachingGhostObject=Q;Q.prototype.setAnisotropicFriction=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);Wx(d,a,c)}; -Q.prototype.getCollisionShape=function(){return k(Xx(this.kB),l)};Q.prototype.setContactProcessingThreshold=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Yx(c,a)};Q.prototype.setActivationState=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Zx(c,a)};Q.prototype.forceActivationState=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);$x(c,a)};Q.prototype.activate=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);void 0===a?ay(c):by(c,a)}; -Q.prototype.isActive=function(){return!!cy(this.kB)};Q.prototype.isKinematicObject=function(){return!!dy(this.kB)};Q.prototype.isStaticObject=function(){return!!ey(this.kB)};Q.prototype.isStaticOrKinematicObject=function(){return!!fy(this.kB)};Q.prototype.getRestitution=function(){return gy(this.kB)};Q.prototype.getFriction=function(){return hy(this.kB)};Q.prototype.getRollingFriction=function(){return iy(this.kB)}; -Q.prototype.setRestitution=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);jy(c,a)};Q.prototype.setFriction=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);ky(c,a)};Q.prototype.setRollingFriction=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);ly(c,a)};Q.prototype.getWorldTransform=function(){return k(my(this.kB),r)};Q.prototype.getCollisionFlags=function(){return ny(this.kB)}; -Q.prototype.setCollisionFlags=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);oy(c,a)};Q.prototype.setWorldTransform=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);py(c,a)};Q.prototype.setCollisionShape=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);qy(c,a)};Q.prototype.setCcdMotionThreshold=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);ry(c,a)};Q.prototype.setCcdSweptSphereRadius=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);sy(c,a)}; -Q.prototype.getUserIndex=function(){return ty(this.kB)};Q.prototype.setUserIndex=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);uy(c,a)};Q.prototype.getUserPointer=function(){return k(vy(this.kB),XD)};Q.prototype.setUserPointer=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);wy(c,a)};Q.prototype.getBroadphaseHandle=function(){return k(xy(this.kB),YD)};Q.prototype.getNumOverlappingObjects=function(){return yy(this.kB)}; -Q.prototype.getOverlappingObject=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return k(zy(c,a),q)};Q.prototype.__destroy__=function(){Ay(this.kB)};function AF(){this.kB=By();h(AF)[this.kB]=this}AF.prototype=Object.create(f.prototype);AF.prototype.constructor=AF;AF.prototype.lB=AF;AF.mB={};b.btGhostPairCallback=AF;AF.prototype.__destroy__=function(){Cy(this.kB)};function S(){this.kB=Dy();h(S)[this.kB]=this}S.prototype=Object.create(f.prototype);S.prototype.constructor=S; -S.prototype.lB=S;S.mB={};b.btSoftBodyWorldInfo=S;S.prototype.get_air_density=S.prototype.cC=function(){return Ey(this.kB)};S.prototype.set_air_density=S.prototype.UE=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Fy(c,a)};Object.defineProperty(S.prototype,"air_density",{get:S.prototype.cC,set:S.prototype.UE});S.prototype.get_water_density=S.prototype.RE=function(){return Gy(this.kB)}; -S.prototype.set_water_density=S.prototype.JH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Hy(c,a)};Object.defineProperty(S.prototype,"water_density",{get:S.prototype.RE,set:S.prototype.JH});S.prototype.get_water_offset=S.prototype.TE=function(){return Iy(this.kB)};S.prototype.set_water_offset=S.prototype.LH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Jy(c,a)};Object.defineProperty(S.prototype,"water_offset",{get:S.prototype.TE,set:S.prototype.LH}); -S.prototype.get_m_maxDisplacement=S.prototype.ND=function(){return Ky(this.kB)};S.prototype.set_m_maxDisplacement=S.prototype.EG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Ly(c,a)};Object.defineProperty(S.prototype,"m_maxDisplacement",{get:S.prototype.ND,set:S.prototype.EG});S.prototype.get_water_normal=S.prototype.SE=function(){return k(My(this.kB),m)};S.prototype.set_water_normal=S.prototype.KH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Ny(c,a)}; -Object.defineProperty(S.prototype,"water_normal",{get:S.prototype.SE,set:S.prototype.KH});S.prototype.get_m_broadphase=S.prototype.MC=function(){return k(Oy(this.kB),VD)};S.prototype.set_m_broadphase=S.prototype.DF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Py(c,a)};Object.defineProperty(S.prototype,"m_broadphase",{get:S.prototype.MC,set:S.prototype.DF});S.prototype.get_m_dispatcher=S.prototype.dD=function(){return k(Qy(this.kB),TD)}; -S.prototype.set_m_dispatcher=S.prototype.VF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Ry(c,a)};Object.defineProperty(S.prototype,"m_dispatcher",{get:S.prototype.dD,set:S.prototype.VF});S.prototype.get_m_gravity=S.prototype.mD=function(){return k(Sy(this.kB),m)};S.prototype.set_m_gravity=S.prototype.dG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Ty(c,a)};Object.defineProperty(S.prototype,"m_gravity",{get:S.prototype.mD,set:S.prototype.dG});S.prototype.__destroy__=function(){Uy(this.kB)}; -function U(){throw"cannot construct a Face, no constructor in IDL";}U.prototype=Object.create(f.prototype);U.prototype.constructor=U;U.prototype.lB=U;U.mB={};b.Face=U;U.prototype.get_m_n=U.prototype.MB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return k(Vy(c,a),Node)};U.prototype.set_m_n=U.prototype.WB=function(a,c){var d=this.kB;ND();a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);Wy(d,a,c)};Object.defineProperty(U.prototype,"m_n",{get:U.prototype.MB,set:U.prototype.WB}); -U.prototype.get_m_normal=U.prototype.RD=function(){return k(Xy(this.kB),m)};U.prototype.set_m_normal=U.prototype.IG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Yy(c,a)};Object.defineProperty(U.prototype,"m_normal",{get:U.prototype.RD,set:U.prototype.IG});U.prototype.get_m_ra=U.prototype.$D=function(){return Zy(this.kB)};U.prototype.set_m_ra=U.prototype.SG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);$y(c,a)}; -Object.defineProperty(U.prototype,"m_ra",{get:U.prototype.$D,set:U.prototype.SG});U.prototype.__destroy__=function(){az(this.kB)};function BF(){throw"cannot construct a tFaceArray, no constructor in IDL";}BF.prototype=Object.create(f.prototype);BF.prototype.constructor=BF;BF.prototype.lB=BF;BF.mB={};b.tFaceArray=BF;BF.prototype.size=BF.prototype.size=function(){return bz(this.kB)};BF.prototype.at=BF.prototype.at=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return k(cz(c,a),U)}; -BF.prototype.__destroy__=function(){dz(this.kB)};function Node(){throw"cannot construct a Node, no constructor in IDL";}Node.prototype=Object.create(f.prototype);Node.prototype.constructor=Node;Node.prototype.lB=Node;Node.mB={};b.Node=Node;Node.prototype.get_m_x=Node.prototype.IE=function(){return k(ez(this.kB),m)};Node.prototype.set_m_x=Node.prototype.AH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);fz(c,a)};Object.defineProperty(Node.prototype,"m_x",{get:Node.prototype.IE,set:Node.prototype.AH}); -Node.prototype.get_m_q=Node.prototype.ZD=function(){return k(gz(this.kB),m)};Node.prototype.set_m_q=Node.prototype.QG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);hz(c,a)};Object.defineProperty(Node.prototype,"m_q",{get:Node.prototype.ZD,set:Node.prototype.QG});Node.prototype.get_m_v=Node.prototype.AE=function(){return k(iz(this.kB),m)};Node.prototype.set_m_v=Node.prototype.sH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);jz(c,a)}; -Object.defineProperty(Node.prototype,"m_v",{get:Node.prototype.AE,set:Node.prototype.sH});Node.prototype.get_m_f=Node.prototype.jD=function(){return k(kz(this.kB),m)};Node.prototype.set_m_f=Node.prototype.aG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);lz(c,a)};Object.defineProperty(Node.prototype,"m_f",{get:Node.prototype.jD,set:Node.prototype.aG});Node.prototype.get_m_n=Node.prototype.MB=function(){return k(mz(this.kB),m)}; -Node.prototype.set_m_n=Node.prototype.WB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);nz(c,a)};Object.defineProperty(Node.prototype,"m_n",{get:Node.prototype.MB,set:Node.prototype.WB});Node.prototype.get_m_im=Node.prototype.vD=function(){return oz(this.kB)};Node.prototype.set_m_im=Node.prototype.mG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);pz(c,a)};Object.defineProperty(Node.prototype,"m_im",{get:Node.prototype.vD,set:Node.prototype.mG}); -Node.prototype.get_m_area=Node.prototype.JC=function(){return qz(this.kB)};Node.prototype.set_m_area=Node.prototype.AF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);rz(c,a)};Object.defineProperty(Node.prototype,"m_area",{get:Node.prototype.JC,set:Node.prototype.AF});Node.prototype.__destroy__=function(){sz(this.kB)};function CF(){throw"cannot construct a tNodeArray, no constructor in IDL";}CF.prototype=Object.create(f.prototype);CF.prototype.constructor=CF;CF.prototype.lB=CF;CF.mB={}; -b.tNodeArray=CF;CF.prototype.size=CF.prototype.size=function(){return tz(this.kB)};CF.prototype.at=CF.prototype.at=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return k(uz(c,a),Node)};CF.prototype.__destroy__=function(){vz(this.kB)};function V(){throw"cannot construct a Material, no constructor in IDL";}V.prototype=Object.create(f.prototype);V.prototype.constructor=V;V.prototype.lB=V;V.mB={};b.Material=V;V.prototype.get_m_kLST=V.prototype.BD=function(){return wz(this.kB)}; -V.prototype.set_m_kLST=V.prototype.sG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);xz(c,a)};Object.defineProperty(V.prototype,"m_kLST",{get:V.prototype.BD,set:V.prototype.sG});V.prototype.get_m_kAST=V.prototype.AD=function(){return yz(this.kB)};V.prototype.set_m_kAST=V.prototype.rG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);zz(c,a)};Object.defineProperty(V.prototype,"m_kAST",{get:V.prototype.AD,set:V.prototype.rG});V.prototype.get_m_kVST=V.prototype.CD=function(){return Az(this.kB)}; -V.prototype.set_m_kVST=V.prototype.tG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Bz(c,a)};Object.defineProperty(V.prototype,"m_kVST",{get:V.prototype.CD,set:V.prototype.tG});V.prototype.get_m_flags=V.prototype.tB=function(){return Cz(this.kB)};V.prototype.set_m_flags=V.prototype.uB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Dz(c,a)};Object.defineProperty(V.prototype,"m_flags",{get:V.prototype.tB,set:V.prototype.uB});V.prototype.__destroy__=function(){Ez(this.kB)}; -function DF(){throw"cannot construct a tMaterialArray, no constructor in IDL";}DF.prototype=Object.create(f.prototype);DF.prototype.constructor=DF;DF.prototype.lB=DF;DF.mB={};b.tMaterialArray=DF;DF.prototype.size=DF.prototype.size=function(){return Fz(this.kB)};DF.prototype.at=DF.prototype.at=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return k(Gz(c,a),V)};DF.prototype.__destroy__=function(){Hz(this.kB)};function W(){throw"cannot construct a Anchor, no constructor in IDL";} -W.prototype=Object.create(f.prototype);W.prototype.constructor=W;W.prototype.lB=W;W.mB={};b.Anchor=W;W.prototype.get_m_node=W.prototype.PD=function(){return k(Iz(this.kB),Node)};W.prototype.set_m_node=W.prototype.GG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Jz(c,a)};Object.defineProperty(W.prototype,"m_node",{get:W.prototype.PD,set:W.prototype.GG});W.prototype.get_m_local=W.prototype.FD=function(){return k(Kz(this.kB),m)}; -W.prototype.set_m_local=W.prototype.wG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Lz(c,a)};Object.defineProperty(W.prototype,"m_local",{get:W.prototype.FD,set:W.prototype.wG});W.prototype.get_m_body=W.prototype.KC=function(){return k(Mz(this.kB),K)};W.prototype.set_m_body=W.prototype.BF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Nz(c,a)};Object.defineProperty(W.prototype,"m_body",{get:W.prototype.KC,set:W.prototype.BF});W.prototype.get_m_influence=W.prototype.yD=function(){return Oz(this.kB)}; -W.prototype.set_m_influence=W.prototype.pG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Pz(c,a)};Object.defineProperty(W.prototype,"m_influence",{get:W.prototype.yD,set:W.prototype.pG});W.prototype.get_m_c0=W.prototype.NC=function(){return k(Qz(this.kB),uE)};W.prototype.set_m_c0=W.prototype.EF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Rz(c,a)};Object.defineProperty(W.prototype,"m_c0",{get:W.prototype.NC,set:W.prototype.EF}); -W.prototype.get_m_c1=W.prototype.OC=function(){return k(Sz(this.kB),m)};W.prototype.set_m_c1=W.prototype.FF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Tz(c,a)};Object.defineProperty(W.prototype,"m_c1",{get:W.prototype.OC,set:W.prototype.FF});W.prototype.get_m_c2=W.prototype.PC=function(){return Uz(this.kB)};W.prototype.set_m_c2=W.prototype.GF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);Vz(c,a)};Object.defineProperty(W.prototype,"m_c2",{get:W.prototype.PC,set:W.prototype.GF}); -W.prototype.__destroy__=function(){Wz(this.kB)};function EF(){throw"cannot construct a tAnchorArray, no constructor in IDL";}EF.prototype=Object.create(f.prototype);EF.prototype.constructor=EF;EF.prototype.lB=EF;EF.mB={};b.tAnchorArray=EF;EF.prototype.size=EF.prototype.size=function(){return Xz(this.kB)};EF.prototype.at=EF.prototype.at=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return k(Yz(c,a),W)};EF.prototype.clear=EF.prototype.clear=function(){Zz(this.kB)}; -EF.prototype.push_back=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);$z(c,a)};EF.prototype.pop_back=function(){aA(this.kB)};EF.prototype.__destroy__=function(){bA(this.kB)};function X(){throw"cannot construct a Config, no constructor in IDL";}X.prototype=Object.create(f.prototype);X.prototype.constructor=X;X.prototype.lB=X;X.mB={};b.Config=X;X.prototype.get_kVCF=X.prototype.zC=function(){return cA(this.kB)}; -X.prototype.set_kVCF=X.prototype.qF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);dA(c,a)};Object.defineProperty(X.prototype,"kVCF",{get:X.prototype.zC,set:X.prototype.qF});X.prototype.get_kDP=X.prototype.mC=function(){return eA(this.kB)};X.prototype.set_kDP=X.prototype.dF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);fA(c,a)};Object.defineProperty(X.prototype,"kDP",{get:X.prototype.mC,set:X.prototype.dF});X.prototype.get_kDG=X.prototype.lC=function(){return gA(this.kB)}; -X.prototype.set_kDG=X.prototype.cF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);hA(c,a)};Object.defineProperty(X.prototype,"kDG",{get:X.prototype.lC,set:X.prototype.cF});X.prototype.get_kLF=X.prototype.oC=function(){return iA(this.kB)};X.prototype.set_kLF=X.prototype.fF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);jA(c,a)};Object.defineProperty(X.prototype,"kLF",{get:X.prototype.oC,set:X.prototype.fF});X.prototype.get_kPR=X.prototype.qC=function(){return kA(this.kB)}; -X.prototype.set_kPR=X.prototype.hF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);lA(c,a)};Object.defineProperty(X.prototype,"kPR",{get:X.prototype.qC,set:X.prototype.hF});X.prototype.get_kVC=X.prototype.yC=function(){return mA(this.kB)};X.prototype.set_kVC=X.prototype.pF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);nA(c,a)};Object.defineProperty(X.prototype,"kVC",{get:X.prototype.yC,set:X.prototype.pF});X.prototype.get_kDF=X.prototype.kC=function(){return oA(this.kB)}; -X.prototype.set_kDF=X.prototype.bF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);pA(c,a)};Object.defineProperty(X.prototype,"kDF",{get:X.prototype.kC,set:X.prototype.bF});X.prototype.get_kMT=X.prototype.pC=function(){return qA(this.kB)};X.prototype.set_kMT=X.prototype.gF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);rA(c,a)};Object.defineProperty(X.prototype,"kMT",{get:X.prototype.pC,set:X.prototype.gF});X.prototype.get_kCHR=X.prototype.jC=function(){return sA(this.kB)}; -X.prototype.set_kCHR=X.prototype.aF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);tA(c,a)};Object.defineProperty(X.prototype,"kCHR",{get:X.prototype.jC,set:X.prototype.aF});X.prototype.get_kKHR=X.prototype.nC=function(){return uA(this.kB)};X.prototype.set_kKHR=X.prototype.eF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);vA(c,a)};Object.defineProperty(X.prototype,"kKHR",{get:X.prototype.nC,set:X.prototype.eF});X.prototype.get_kSHR=X.prototype.rC=function(){return wA(this.kB)}; -X.prototype.set_kSHR=X.prototype.iF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);xA(c,a)};Object.defineProperty(X.prototype,"kSHR",{get:X.prototype.rC,set:X.prototype.iF});X.prototype.get_kAHR=X.prototype.iC=function(){return yA(this.kB)};X.prototype.set_kAHR=X.prototype.$E=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);zA(c,a)};Object.defineProperty(X.prototype,"kAHR",{get:X.prototype.iC,set:X.prototype.$E});X.prototype.get_kSRHR_CL=X.prototype.uC=function(){return AA(this.kB)}; -X.prototype.set_kSRHR_CL=X.prototype.lF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);BA(c,a)};Object.defineProperty(X.prototype,"kSRHR_CL",{get:X.prototype.uC,set:X.prototype.lF});X.prototype.get_kSKHR_CL=X.prototype.sC=function(){return CA(this.kB)};X.prototype.set_kSKHR_CL=X.prototype.jF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);DA(c,a)};Object.defineProperty(X.prototype,"kSKHR_CL",{get:X.prototype.sC,set:X.prototype.jF});X.prototype.get_kSSHR_CL=X.prototype.wC=function(){return EA(this.kB)}; -X.prototype.set_kSSHR_CL=X.prototype.nF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);FA(c,a)};Object.defineProperty(X.prototype,"kSSHR_CL",{get:X.prototype.wC,set:X.prototype.nF});X.prototype.get_kSR_SPLT_CL=X.prototype.vC=function(){return GA(this.kB)};X.prototype.set_kSR_SPLT_CL=X.prototype.mF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);HA(c,a)};Object.defineProperty(X.prototype,"kSR_SPLT_CL",{get:X.prototype.vC,set:X.prototype.mF}); -X.prototype.get_kSK_SPLT_CL=X.prototype.tC=function(){return IA(this.kB)};X.prototype.set_kSK_SPLT_CL=X.prototype.kF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);JA(c,a)};Object.defineProperty(X.prototype,"kSK_SPLT_CL",{get:X.prototype.tC,set:X.prototype.kF});X.prototype.get_kSS_SPLT_CL=X.prototype.xC=function(){return KA(this.kB)};X.prototype.set_kSS_SPLT_CL=X.prototype.oF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);LA(c,a)}; -Object.defineProperty(X.prototype,"kSS_SPLT_CL",{get:X.prototype.xC,set:X.prototype.oF});X.prototype.get_maxvolume=X.prototype.JE=function(){return MA(this.kB)};X.prototype.set_maxvolume=X.prototype.BH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);NA(c,a)};Object.defineProperty(X.prototype,"maxvolume",{get:X.prototype.JE,set:X.prototype.BH});X.prototype.get_timescale=X.prototype.OE=function(){return OA(this.kB)}; -X.prototype.set_timescale=X.prototype.GH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);PA(c,a)};Object.defineProperty(X.prototype,"timescale",{get:X.prototype.OE,set:X.prototype.GH});X.prototype.get_viterations=X.prototype.QE=function(){return QA(this.kB)};X.prototype.set_viterations=X.prototype.IH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);RA(c,a)};Object.defineProperty(X.prototype,"viterations",{get:X.prototype.QE,set:X.prototype.IH}); -X.prototype.get_piterations=X.prototype.ME=function(){return SA(this.kB)};X.prototype.set_piterations=X.prototype.EH=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);TA(c,a)};Object.defineProperty(X.prototype,"piterations",{get:X.prototype.ME,set:X.prototype.EH});X.prototype.get_diterations=X.prototype.fC=function(){return UA(this.kB)};X.prototype.set_diterations=X.prototype.XE=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);VA(c,a)}; -Object.defineProperty(X.prototype,"diterations",{get:X.prototype.fC,set:X.prototype.XE});X.prototype.get_citerations=X.prototype.dC=function(){return WA(this.kB)};X.prototype.set_citerations=X.prototype.VE=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);XA(c,a)};Object.defineProperty(X.prototype,"citerations",{get:X.prototype.dC,set:X.prototype.VE});X.prototype.get_collisions=X.prototype.eC=function(){return YA(this.kB)}; -X.prototype.set_collisions=X.prototype.WE=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);ZA(c,a)};Object.defineProperty(X.prototype,"collisions",{get:X.prototype.eC,set:X.prototype.WE});X.prototype.__destroy__=function(){$A(this.kB)};function Y(a,c,d,e){ND();a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);"object"==typeof e&&(e=RD(e));this.kB=aB(a,c,d,e);h(Y)[this.kB]=this}Y.prototype=Object.create(q.prototype); -Y.prototype.constructor=Y;Y.prototype.lB=Y;Y.mB={};b.btSoftBody=Y;Y.prototype.checkLink=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);return!!bB(d,a,c)};Y.prototype.checkFace=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);return!!cB(e,a,c,d)};Y.prototype.appendMaterial=function(){return k(dB(this.kB),V)}; -Y.prototype.appendNode=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);eB(d,a,c)};Y.prototype.appendLink=function(a,c,d,e){var g=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);fB(g,a,c,d,e)}; -Y.prototype.appendFace=function(a,c,d,e){var g=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);gB(g,a,c,d,e)};Y.prototype.appendTetra=function(a,c,d,e,g){var n=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);g&&"object"===typeof g&&(g=g.kB);hB(n,a,c,d,e,g)}; -Y.prototype.appendAnchor=function(a,c,d,e){var g=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);iB(g,a,c,d,e)};Y.prototype.addForce=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);void 0===c?jB(d,a):kB(d,a,c)};Y.prototype.addAeroForceToNode=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);lB(d,a,c)}; -Y.prototype.getTotalMass=function(){return mB(this.kB)};Y.prototype.setTotalMass=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);nB(d,a,c)};Y.prototype.setMass=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);oB(d,a,c)};Y.prototype.transform=Y.prototype.transform=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);pB(c,a)}; -Y.prototype.translate=Y.prototype.translate=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);qB(c,a)};Y.prototype.rotate=Y.prototype.rotate=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);rB(c,a)};Y.prototype.scale=Y.prototype.scale=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);sB(c,a)};Y.prototype.generateClusters=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);return void 0===c?tB(d,a):uB(d,a,c)}; -Y.prototype.generateBendingConstraints=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);return vB(d,a,c)};Y.prototype.upcast=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return k(wB(c,a),Y)};Y.prototype.getRestLengthScale=function(){return xB(this.kB)};Y.prototype.setRestLengthScale=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);yB(c,a)}; -Y.prototype.setAnisotropicFriction=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);zB(d,a,c)};Y.prototype.getCollisionShape=function(){return k(AB(this.kB),l)};Y.prototype.setContactProcessingThreshold=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);BB(c,a)};Y.prototype.setActivationState=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);CB(c,a)}; -Y.prototype.forceActivationState=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);DB(c,a)};Y.prototype.activate=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);void 0===a?EB(c):FB(c,a)};Y.prototype.isActive=function(){return!!GB(this.kB)};Y.prototype.isKinematicObject=function(){return!!HB(this.kB)};Y.prototype.isStaticObject=function(){return!!IB(this.kB)};Y.prototype.isStaticOrKinematicObject=function(){return!!JB(this.kB)};Y.prototype.getRestitution=function(){return KB(this.kB)}; -Y.prototype.getFriction=function(){return LB(this.kB)};Y.prototype.getRollingFriction=function(){return MB(this.kB)};Y.prototype.setRestitution=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);NB(c,a)};Y.prototype.setFriction=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);OB(c,a)};Y.prototype.setRollingFriction=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);PB(c,a)};Y.prototype.getWorldTransform=function(){return k(QB(this.kB),r)};Y.prototype.getCollisionFlags=function(){return RB(this.kB)}; -Y.prototype.setCollisionFlags=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);SB(c,a)};Y.prototype.setWorldTransform=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);TB(c,a)};Y.prototype.setCollisionShape=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);UB(c,a)};Y.prototype.setCcdMotionThreshold=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);VB(c,a)};Y.prototype.setCcdSweptSphereRadius=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);WB(c,a)}; -Y.prototype.getUserIndex=function(){return XB(this.kB)};Y.prototype.setUserIndex=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);YB(c,a)};Y.prototype.getUserPointer=function(){return k(ZB(this.kB),XD)};Y.prototype.setUserPointer=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);$B(c,a)};Y.prototype.getBroadphaseHandle=function(){return k(aC(this.kB),YD)};Y.prototype.get_m_cfg=Y.prototype.QC=function(){return k(bC(this.kB),X)}; -Y.prototype.set_m_cfg=Y.prototype.HF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);cC(c,a)};Object.defineProperty(Y.prototype,"m_cfg",{get:Y.prototype.QC,set:Y.prototype.HF});Y.prototype.get_m_nodes=Y.prototype.QD=function(){return k(dC(this.kB),CF)};Y.prototype.set_m_nodes=Y.prototype.HG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);eC(c,a)};Object.defineProperty(Y.prototype,"m_nodes",{get:Y.prototype.QD,set:Y.prototype.HG}); -Y.prototype.get_m_faces=Y.prototype.KB=function(){return k(fC(this.kB),BF)};Y.prototype.set_m_faces=Y.prototype.UB=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);gC(c,a)};Object.defineProperty(Y.prototype,"m_faces",{get:Y.prototype.KB,set:Y.prototype.UB});Y.prototype.get_m_materials=Y.prototype.MD=function(){return k(hC(this.kB),DF)};Y.prototype.set_m_materials=Y.prototype.DG=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);iC(c,a)}; -Object.defineProperty(Y.prototype,"m_materials",{get:Y.prototype.MD,set:Y.prototype.DG});Y.prototype.get_m_anchors=Y.prototype.GC=function(){return k(jC(this.kB),EF)};Y.prototype.set_m_anchors=Y.prototype.xF=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);kC(c,a)};Object.defineProperty(Y.prototype,"m_anchors",{get:Y.prototype.GC,set:Y.prototype.xF});Y.prototype.__destroy__=function(){lC(this.kB)}; -function FF(a){a&&"object"===typeof a&&(a=a.kB);this.kB=void 0===a?mC():nC(a);h(FF)[this.kB]=this}FF.prototype=Object.create(nE.prototype);FF.prototype.constructor=FF;FF.prototype.lB=FF;FF.mB={};b.btSoftBodyRigidBodyCollisionConfiguration=FF;FF.prototype.__destroy__=function(){oC(this.kB)};function GF(){this.kB=pC();h(GF)[this.kB]=this}GF.prototype=Object.create(sE.prototype);GF.prototype.constructor=GF;GF.prototype.lB=GF;GF.mB={};b.btDefaultSoftBodySolver=GF;GF.prototype.__destroy__=function(){qC(this.kB)}; -function HF(){throw"cannot construct a btSoftBodyArray, no constructor in IDL";}HF.prototype=Object.create(f.prototype);HF.prototype.constructor=HF;HF.prototype.lB=HF;HF.mB={};b.btSoftBodyArray=HF;HF.prototype.size=HF.prototype.size=function(){return rC(this.kB)};HF.prototype.at=HF.prototype.at=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);return k(sC(c,a),Y)};HF.prototype.__destroy__=function(){tC(this.kB)}; -function Z(a,c,d,e,g){a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);g&&"object"===typeof g&&(g=g.kB);this.kB=uC(a,c,d,e,g);h(Z)[this.kB]=this}Z.prototype=Object.create(x.prototype);Z.prototype.constructor=Z;Z.prototype.lB=Z;Z.mB={};b.btSoftRigidDynamicsWorld=Z; -Z.prototype.addSoftBody=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);vC(e,a,c,d)};Z.prototype.removeSoftBody=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);wC(c,a)};Z.prototype.removeCollisionObject=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);xC(c,a)};Z.prototype.getWorldInfo=function(){return k(yC(this.kB),S)};Z.prototype.getSoftBodyArray=function(){return k(zC(this.kB),HF)}; -Z.prototype.getDispatcher=function(){return k(AC(this.kB),TD)};Z.prototype.rayTest=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);BC(e,a,c,d)};Z.prototype.getPairCache=function(){return k(CC(this.kB),UD)};Z.prototype.getDispatchInfo=function(){return k(DC(this.kB),p)}; -Z.prototype.addCollisionObject=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);void 0===c?EC(e,a):void 0===d?FC(e,a,c):GC(e,a,c,d)};Z.prototype.getBroadphase=function(){return k(HC(this.kB),VD)}; -Z.prototype.convexSweepTest=function(a,c,d,e,g){var n=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);g&&"object"===typeof g&&(g=g.kB);IC(n,a,c,d,e,g)};Z.prototype.contactPairTest=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);JC(e,a,c,d)}; -Z.prototype.contactTest=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);KC(d,a,c)};Z.prototype.updateSingleAabb=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);LC(c,a)};Z.prototype.setDebugDrawer=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);MC(c,a)};Z.prototype.getDebugDrawer=function(){return k(NC(this.kB),WD)};Z.prototype.debugDrawWorld=function(){OC(this.kB)}; -Z.prototype.debugDrawObject=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);PC(e,a,c,d)};Z.prototype.setGravity=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);QC(c,a)};Z.prototype.getGravity=function(){return k(RC(this.kB),m)}; -Z.prototype.addRigidBody=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);void 0===c?SC(e,a):void 0===d?_emscripten_bind_btSoftRigidDynamicsWorld_addRigidBody_2(e,a,c):TC(e,a,c,d)};Z.prototype.removeRigidBody=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);UC(c,a)}; -Z.prototype.addConstraint=function(a,c){var d=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);void 0===c?VC(d,a):WC(d,a,c)};Z.prototype.removeConstraint=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);XC(c,a)};Z.prototype.stepSimulation=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);return void 0===c?YC(e,a):void 0===d?ZC(e,a,c):$C(e,a,c,d)}; -Z.prototype.setContactAddedCallback=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);aD(c,a)};Z.prototype.setContactProcessedCallback=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);bD(c,a)};Z.prototype.setContactDestroyedCallback=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);cD(c,a)};Z.prototype.addAction=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);dD(c,a)};Z.prototype.removeAction=function(a){var c=this.kB;a&&"object"===typeof a&&(a=a.kB);eD(c,a)}; -Z.prototype.getSolverInfo=function(){return k(fD(this.kB),t)};Z.prototype.setInternalTickCallback=function(a,c,d){var e=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);void 0===c?gD(e,a):void 0===d?hD(e,a,c):iD(e,a,c,d)};Z.prototype.__destroy__=function(){jD(this.kB)};function IF(){this.kB=kD();h(IF)[this.kB]=this}IF.prototype=Object.create(f.prototype);IF.prototype.constructor=IF;IF.prototype.lB=IF;IF.mB={};b.btSoftBodyHelpers=IF; -IF.prototype.CreateRope=function(a,c,d,e,g){var n=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);g&&"object"===typeof g&&(g=g.kB);return k(lD(n,a,c,d,e,g),Y)}; -IF.prototype.CreatePatch=function(a,c,d,e,g,n,z,T,Da){var dc=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);g&&"object"===typeof g&&(g=g.kB);n&&"object"===typeof n&&(n=n.kB);z&&"object"===typeof z&&(z=z.kB);T&&"object"===typeof T&&(T=T.kB);Da&&"object"===typeof Da&&(Da=Da.kB);return k(mD(dc,a,c,d,e,g,n,z,T,Da),Y)}; -IF.prototype.CreatePatchUV=function(a,c,d,e,g,n,z,T,Da,dc){var JF=this.kB;ND();a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);g&&"object"===typeof g&&(g=g.kB);n&&"object"===typeof n&&(n=n.kB);z&&"object"===typeof z&&(z=z.kB);T&&"object"===typeof T&&(T=T.kB);Da&&"object"===typeof Da&&(Da=Da.kB);"object"==typeof dc&&(dc=RD(dc));return k(nD(JF,a,c,d,e,g,n,z,T,Da,dc),Y)}; -IF.prototype.CreateEllipsoid=function(a,c,d,e){var g=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);return k(oD(g,a,c,d,e),Y)}; -IF.prototype.CreateFromTriMesh=function(a,c,d,e,g){var n=this.kB;ND();a&&"object"===typeof a&&(a=a.kB);"object"==typeof c&&(c=RD(c));if("object"==typeof d&&"object"===typeof d){var z=OD(d,va);PD(d,va,z);d=z}e&&"object"===typeof e&&(e=e.kB);g&&"object"===typeof g&&(g=g.kB);return k(pD(n,a,c,d,e,g),Y)}; -IF.prototype.CreateFromConvexHull=function(a,c,d,e){var g=this.kB;a&&"object"===typeof a&&(a=a.kB);c&&"object"===typeof c&&(c=c.kB);d&&"object"===typeof d&&(d=d.kB);e&&"object"===typeof e&&(e=e.kB);return k(qD(g,a,c,d,e),Y)};IF.prototype.__destroy__=function(){rD(this.kB)}; -(function(){function a(){b.PHY_FLOAT=sD();b.PHY_DOUBLE=tD();b.PHY_INTEGER=uD();b.PHY_SHORT=vD();b.PHY_FIXEDPOINT88=wD();b.PHY_UCHAR=xD();b.CONST_GIMPACT_COMPOUND_SHAPE=yD();b.CONST_GIMPACT_TRIMESH_SHAPE_PART=zD();b.CONST_GIMPACT_TRIMESH_SHAPE=AD();b.BT_CONSTRAINT_ERP=BD();b.BT_CONSTRAINT_STOP_ERP=CD();b.BT_CONSTRAINT_CFM=DD();b.BT_CONSTRAINT_STOP_CFM=ED()}Ca?a():Aa.unshift(a)})();b.CONTACT_ADDED_CALLBACK_SIGNATURE="iiiiiiii";b.CONTACT_DESTROYED_CALLBACK_SIGNATURE="ii"; -b.CONTACT_PROCESSED_CALLBACK_SIGNATURE="iiii";b.INTERNAL_TICK_CALLBACK_SIGNATURE="vif";this.Ammo=b; - - - return Ammo.ready -} - -); -})(); -if (typeof exports === 'object' && typeof module === 'object') - module.exports = Ammo; -else if (typeof define === 'function' && define['amd']) - define([], function() { return Ammo; }); -else if (typeof exports === 'object') - exports["Ammo"] = Ammo; diff --git a/frontend/apps/artcraft/app/public/jsm/libs/ammo.wasm.wasm b/frontend/apps/artcraft/app/public/jsm/libs/ammo.wasm.wasm deleted file mode 100644 index a013d060a5..0000000000 Binary files a/frontend/apps/artcraft/app/public/jsm/libs/ammo.wasm.wasm and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/avatars/0.webp b/frontend/apps/artcraft/app/public/resources/avatars/0.webp deleted file mode 100644 index f95afe03b2..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/avatars/0.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/avatars/1.webp b/frontend/apps/artcraft/app/public/resources/avatars/1.webp deleted file mode 100644 index 6acf0da539..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/avatars/1.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/avatars/10.webp b/frontend/apps/artcraft/app/public/resources/avatars/10.webp deleted file mode 100644 index f6fd4df884..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/avatars/10.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/avatars/11.webp b/frontend/apps/artcraft/app/public/resources/avatars/11.webp deleted file mode 100644 index c14bcebda5..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/avatars/11.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/avatars/12.webp b/frontend/apps/artcraft/app/public/resources/avatars/12.webp deleted file mode 100644 index 0078476c03..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/avatars/12.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/avatars/13.webp b/frontend/apps/artcraft/app/public/resources/avatars/13.webp deleted file mode 100644 index e8b1635f36..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/avatars/13.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/avatars/14.webp b/frontend/apps/artcraft/app/public/resources/avatars/14.webp deleted file mode 100644 index fd532381f9..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/avatars/14.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/avatars/15.webp b/frontend/apps/artcraft/app/public/resources/avatars/15.webp deleted file mode 100644 index c61aea6d96..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/avatars/15.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/avatars/16.webp b/frontend/apps/artcraft/app/public/resources/avatars/16.webp deleted file mode 100644 index f112d25df5..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/avatars/16.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/avatars/17.webp b/frontend/apps/artcraft/app/public/resources/avatars/17.webp deleted file mode 100644 index f7ab766002..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/avatars/17.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/avatars/18.webp b/frontend/apps/artcraft/app/public/resources/avatars/18.webp deleted file mode 100644 index fa3fc2f0ac..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/avatars/18.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/avatars/19.webp b/frontend/apps/artcraft/app/public/resources/avatars/19.webp deleted file mode 100644 index 0207cd889e..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/avatars/19.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/avatars/2.webp b/frontend/apps/artcraft/app/public/resources/avatars/2.webp deleted file mode 100644 index 03777b780f..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/avatars/2.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/avatars/20.webp b/frontend/apps/artcraft/app/public/resources/avatars/20.webp deleted file mode 100644 index 367f411541..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/avatars/20.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/avatars/21.webp b/frontend/apps/artcraft/app/public/resources/avatars/21.webp deleted file mode 100644 index e6eeb4d155..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/avatars/21.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/avatars/22.webp b/frontend/apps/artcraft/app/public/resources/avatars/22.webp deleted file mode 100644 index f8c0ffca87..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/avatars/22.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/avatars/23.webp b/frontend/apps/artcraft/app/public/resources/avatars/23.webp deleted file mode 100644 index 15137375b5..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/avatars/23.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/avatars/24.webp b/frontend/apps/artcraft/app/public/resources/avatars/24.webp deleted file mode 100644 index 4e925a9e35..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/avatars/24.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/avatars/3.webp b/frontend/apps/artcraft/app/public/resources/avatars/3.webp deleted file mode 100644 index ccb44b0afc..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/avatars/3.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/avatars/4.webp b/frontend/apps/artcraft/app/public/resources/avatars/4.webp deleted file mode 100644 index 421877e2e4..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/avatars/4.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/avatars/5.webp b/frontend/apps/artcraft/app/public/resources/avatars/5.webp deleted file mode 100644 index 2b4db489a0..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/avatars/5.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/avatars/6.webp b/frontend/apps/artcraft/app/public/resources/avatars/6.webp deleted file mode 100644 index dc8e5a2d96..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/avatars/6.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/avatars/7.webp b/frontend/apps/artcraft/app/public/resources/avatars/7.webp deleted file mode 100644 index d711281f67..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/avatars/7.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/avatars/8.webp b/frontend/apps/artcraft/app/public/resources/avatars/8.webp deleted file mode 100644 index a71c77e64a..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/avatars/8.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/avatars/9.webp b/frontend/apps/artcraft/app/public/resources/avatars/9.webp deleted file mode 100644 index bf72a412ce..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/avatars/9.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/characters/img01.png b/frontend/apps/artcraft/app/public/resources/characters/img01.png deleted file mode 100644 index da2e4a4edc..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/characters/img01.png and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/characters/img02.png b/frontend/apps/artcraft/app/public/resources/characters/img02.png deleted file mode 100644 index e8d82b5118..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/characters/img02.png and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/characters/img03.png b/frontend/apps/artcraft/app/public/resources/characters/img03.png deleted file mode 100644 index 65f45ed1d5..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/characters/img03.png and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/characters/img04.png b/frontend/apps/artcraft/app/public/resources/characters/img04.png deleted file mode 100644 index 58b3b402aa..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/characters/img04.png and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/characters/img05.png b/frontend/apps/artcraft/app/public/resources/characters/img05.png deleted file mode 100644 index 2760307d2c..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/characters/img05.png and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/characters/img06.png b/frontend/apps/artcraft/app/public/resources/characters/img06.png deleted file mode 100644 index df89a6bc09..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/characters/img06.png and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/characters/img07.png b/frontend/apps/artcraft/app/public/resources/characters/img07.png deleted file mode 100644 index 8f8bab1bfc..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/characters/img07.png and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/characters/img08.png b/frontend/apps/artcraft/app/public/resources/characters/img08.png deleted file mode 100644 index 5cb4e1d0d2..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/characters/img08.png and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/characters/img09.png b/frontend/apps/artcraft/app/public/resources/characters/img09.png deleted file mode 100644 index f4631bf2c0..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/characters/img09.png and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/characters/img10.png b/frontend/apps/artcraft/app/public/resources/characters/img10.png deleted file mode 100644 index 4388f07c95..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/characters/img10.png and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/characters/img11.png b/frontend/apps/artcraft/app/public/resources/characters/img11.png deleted file mode 100644 index 85cc64d37f..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/characters/img11.png and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/characters/img12.png b/frontend/apps/artcraft/app/public/resources/characters/img12.png deleted file mode 100644 index 05b14a54e6..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/characters/img12.png and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/characters/img13.png b/frontend/apps/artcraft/app/public/resources/characters/img13.png deleted file mode 100644 index ae0af1c8d5..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/characters/img13.png and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/characters/img14.png b/frontend/apps/artcraft/app/public/resources/characters/img14.png deleted file mode 100644 index fa32a7a3e7..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/characters/img14.png and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/characters/img15.png b/frontend/apps/artcraft/app/public/resources/characters/img15.png deleted file mode 100644 index 039b9666c9..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/characters/img15.png and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/characters/roko.png b/frontend/apps/artcraft/app/public/resources/characters/roko.png deleted file mode 100644 index 9c5a9a0b5e..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/characters/roko.png and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/characters_gif/Baseball Bunt.webp b/frontend/apps/artcraft/app/public/resources/characters_gif/Baseball Bunt.webp deleted file mode 100644 index 1bc0779051..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/characters_gif/Baseball Bunt.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/characters_gif/Breakdance Ready.webp b/frontend/apps/artcraft/app/public/resources/characters_gif/Breakdance Ready.webp deleted file mode 100644 index 0341b774a6..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/characters_gif/Breakdance Ready.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/characters_gif/Breakdance Uprock Var 1.webp b/frontend/apps/artcraft/app/public/resources/characters_gif/Breakdance Uprock Var 1.webp deleted file mode 100644 index 02faff7b67..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/characters_gif/Breakdance Uprock Var 1.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/characters_gif/Catwalk Walk Forward Crossed.webp b/frontend/apps/artcraft/app/public/resources/characters_gif/Catwalk Walk Forward Crossed.webp deleted file mode 100644 index 30e905ff21..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/characters_gif/Catwalk Walk Forward Crossed.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/characters_gif/Convulsing.webp b/frontend/apps/artcraft/app/public/resources/characters_gif/Convulsing.webp deleted file mode 100644 index 4217107595..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/characters_gif/Convulsing.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/characters_gif/Corkscrew Evade.webp b/frontend/apps/artcraft/app/public/resources/characters_gif/Corkscrew Evade.webp deleted file mode 100644 index a60da25e2f..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/characters_gif/Corkscrew Evade.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/characters_gif/Femme Peek Around Corner.webp b/frontend/apps/artcraft/app/public/resources/characters_gif/Femme Peek Around Corner.webp deleted file mode 100644 index 78d1e85984..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/characters_gif/Femme Peek Around Corner.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/characters_gif/Getting Bit.webp b/frontend/apps/artcraft/app/public/resources/characters_gif/Getting Bit.webp deleted file mode 100644 index dc7583905f..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/characters_gif/Getting Bit.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/characters_gif/Ginga Variation 3.webp b/frontend/apps/artcraft/app/public/resources/characters_gif/Ginga Variation 3.webp deleted file mode 100644 index 2604231308..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/characters_gif/Ginga Variation 3.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/characters_gif/Great Sword Impact.webp b/frontend/apps/artcraft/app/public/resources/characters_gif/Great Sword Impact.webp deleted file mode 100644 index b2a8f63cd1..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/characters_gif/Great Sword Impact.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/characters_gif/Jump Forward.webp b/frontend/apps/artcraft/app/public/resources/characters_gif/Jump Forward.webp deleted file mode 100644 index 95321baded..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/characters_gif/Jump Forward.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/characters_gif/Laying Breathless.webp b/frontend/apps/artcraft/app/public/resources/characters_gif/Laying Breathless.webp deleted file mode 100644 index 6d608b40be..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/characters_gif/Laying Breathless.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/characters_gif/Leaning.webp b/frontend/apps/artcraft/app/public/resources/characters_gif/Leaning.webp deleted file mode 100644 index de6ca04563..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/characters_gif/Leaning.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/characters_gif/Lengthy Head Nod.webp b/frontend/apps/artcraft/app/public/resources/characters_gif/Lengthy Head Nod.webp deleted file mode 100644 index 62215bbf73..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/characters_gif/Lengthy Head Nod.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/characters_gif/Look Around.webp b/frontend/apps/artcraft/app/public/resources/characters_gif/Look Around.webp deleted file mode 100644 index 0fc3b39e38..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/characters_gif/Look Around.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/characters_gif/Orc Walk.webp b/frontend/apps/artcraft/app/public/resources/characters_gif/Orc Walk.webp deleted file mode 100644 index ac1f04cee7..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/characters_gif/Orc Walk.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/characters_gif/Pushing.webp b/frontend/apps/artcraft/app/public/resources/characters_gif/Pushing.webp deleted file mode 100644 index 08050dad13..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/characters_gif/Pushing.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/characters_gif/Right Hook.webp b/frontend/apps/artcraft/app/public/resources/characters_gif/Right Hook.webp deleted file mode 100644 index bd7035ccd0..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/characters_gif/Right Hook.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/characters_gif/Right Strafe Walking.webp b/frontend/apps/artcraft/app/public/resources/characters_gif/Right Strafe Walking.webp deleted file mode 100644 index cdacfec2ed..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/characters_gif/Right Strafe Walking.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/characters_gif/Run Look Back.webp b/frontend/apps/artcraft/app/public/resources/characters_gif/Run Look Back.webp deleted file mode 100644 index ce57476f38..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/characters_gif/Run Look Back.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/characters_gif/Sitting Yell.webp b/frontend/apps/artcraft/app/public/resources/characters_gif/Sitting Yell.webp deleted file mode 100644 index 8241892b46..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/characters_gif/Sitting Yell.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/characters_gif/Sneaking Forward.webp b/frontend/apps/artcraft/app/public/resources/characters_gif/Sneaking Forward.webp deleted file mode 100644 index 30723e9bbc..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/characters_gif/Sneaking Forward.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/characters_gif/Standard Walk.webp b/frontend/apps/artcraft/app/public/resources/characters_gif/Standard Walk.webp deleted file mode 100644 index 9801212f76..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/characters_gif/Standard Walk.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/characters_gif/Sword And Shield Casting.webp b/frontend/apps/artcraft/app/public/resources/characters_gif/Sword And Shield Casting.webp deleted file mode 100644 index 3e94e94fd2..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/characters_gif/Sword And Shield Casting.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/characters_gif/Sword And Shield Jump.webp b/frontend/apps/artcraft/app/public/resources/characters_gif/Sword And Shield Jump.webp deleted file mode 100644 index d3403312b4..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/characters_gif/Sword And Shield Jump.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/characters_gif/Texting While Standing.webp b/frontend/apps/artcraft/app/public/resources/characters_gif/Texting While Standing.webp deleted file mode 100644 index 7e23caad00..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/characters_gif/Texting While Standing.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/characters_gif/Texting.webp b/frontend/apps/artcraft/app/public/resources/characters_gif/Texting.webp deleted file mode 100644 index aa2c26d800..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/characters_gif/Texting.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/characters_gif/Tonic Seizure.webp b/frontend/apps/artcraft/app/public/resources/characters_gif/Tonic Seizure.webp deleted file mode 100644 index 1bcff1a9e7..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/characters_gif/Tonic Seizure.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/characters_gif/Twist Dance.webp b/frontend/apps/artcraft/app/public/resources/characters_gif/Twist Dance.webp deleted file mode 100644 index 95451e1bb4..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/characters_gif/Twist Dance.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/characters_gif/Uppercut.webp b/frontend/apps/artcraft/app/public/resources/characters_gif/Uppercut.webp deleted file mode 100644 index 7160a2c630..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/characters_gif/Uppercut.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/characters_gif/Zombie Biting.webp b/frontend/apps/artcraft/app/public/resources/characters_gif/Zombie Biting.webp deleted file mode 100644 index 8769927de0..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/characters_gif/Zombie Biting.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/fonts/CarterOneRegular.json b/frontend/apps/artcraft/app/public/resources/fonts/CarterOneRegular.json deleted file mode 100644 index 3ce2206375..0000000000 --- a/frontend/apps/artcraft/app/public/resources/fonts/CarterOneRegular.json +++ /dev/null @@ -1,1647 +0,0 @@ -{ - "glyphs": { - "0": { - "ha": 1105, - "x_min": 94, - "x_max": 1096, - "o": "m 94 460 q 126 677 94 576 q 225 853 159 778 q 388 970 290 928 q 617 1013 486 1013 q 767 994 699 1013 q 888 940 835 975 q 980 859 941 906 q 1045 755 1019 811 q 1083 637 1071 699 q 1096 510 1096 574 q 1059 280 1096 382 q 954 109 1021 179 q 791 2 886 39 q 581 -35 696 -35 q 384 0 473 -35 q 230 99 294 35 q 130 255 165 164 q 94 460 94 347 m 387 486 q 395 376 387 432 q 426 275 404 321 q 487 201 448 230 q 587 173 526 173 q 663 188 630 173 q 721 228 696 203 q 762 287 745 254 q 789 359 779 321 q 804 437 800 397 q 808 514 808 477 q 804 578 808 545 q 790 646 800 612 q 765 710 781 680 q 728 763 749 740 q 677 800 706 787 q 610 814 648 814 q 533 800 566 814 q 474 762 499 786 q 432 707 449 739 q 406 638 416 675 q 391 563 395 602 q 387 486 387 524 z " - }, - "1": { - "ha": 468, - "x_min": 112, - "x_max": 441, - "o": "m 153 876 q 156 910 154 900 q 172 922 159 920 l 407 979 q 425 981 417 981 q 438 975 434 981 q 441 952 441 969 l 401 113 q 399 87 401 98 q 393 71 397 77 q 383 61 389 64 q 369 54 377 57 l 157 -8 q 141 -10 149 -10 q 121 -4 130 -10 q 112 20 112 3 q 112 22 112 20 q 113 35 112 24 q 114 67 113 45 q 117 130 115 90 q 122 232 119 170 q 129 384 125 294 q 139 595 134 474 q 153 876 145 717 z " - }, - "2": { - "ha": 768, - "x_min": 67, - "x_max": 758, - "o": "m 682 613 q 663 579 676 602 q 633 528 650 557 q 595 466 615 499 q 554 400 574 433 q 514 336 533 367 q 480 282 494 306 q 456 245 465 259 q 448 231 448 231 q 453 231 448 231 q 480 232 461 231 q 523 236 498 234 q 575 241 547 238 q 631 246 604 244 q 683 250 659 248 q 723 252 707 252 q 758 237 758 252 q 752 218 758 227 q 747 207 747 208 l 650 24 q 648 21 648 24 q 646 18 648 18 q 621 3 633 5 q 602 1 610 2 q 500 -1 544 0 q 420 -2 456 -1 q 356 -2 385 -2 q 299 -3 327 -3 q 244 -3 272 -3 q 183 -3 216 -3 q 93 7 118 -3 q 67 37 67 17 q 76 67 67 50 q 100 106 85 84 q 188 231 143 168 q 273 353 233 294 q 348 461 314 411 q 404 545 382 511 q 430 598 422 574 q 438 645 438 623 q 427 693 438 672 q 396 729 416 714 q 349 751 376 743 q 292 758 323 758 q 214 746 254 758 q 135 709 174 734 q 113 701 121 701 q 103 707 106 701 q 101 718 101 713 q 108 780 101 745 q 123 848 115 815 q 138 904 132 880 q 145 931 145 928 q 163 944 146 931 q 216 971 180 956 q 310 1000 252 987 q 450 1013 367 1013 q 548 992 498 1013 q 636 937 597 972 q 699 854 675 902 q 724 751 724 806 q 713 684 724 718 q 682 613 703 650 z " - }, - "3": { - "ha": 752, - "x_min": 65, - "x_max": 730, - "o": "m 441 -33 q 413 -35 427 -34 q 387 -35 399 -35 q 315 -31 349 -35 q 249 -17 281 -26 q 183 6 216 -7 q 111 35 149 19 q 97 44 102 37 q 91 58 93 50 q 89 75 90 66 q 88 90 89 83 q 84 120 87 98 q 78 167 81 142 q 71 213 75 191 q 66 243 68 235 q 65 249 65 245 q 72 264 65 258 q 87 270 79 270 q 93 269 90 270 q 142 237 117 254 q 195 208 167 221 q 256 186 224 195 q 329 177 289 177 q 406 198 380 177 q 431 271 431 220 q 428 308 431 288 q 414 345 425 328 q 383 374 404 362 q 330 386 363 386 l 208 386 q 210 405 208 389 q 215 443 212 420 q 221 489 218 465 q 228 535 224 514 q 233 572 231 557 q 236 588 235 587 q 244 617 240 610 q 253 625 249 625 q 278 620 265 621 q 304 618 291 618 q 377 644 351 618 q 404 717 404 669 q 399 749 404 733 q 384 776 394 764 q 357 795 373 788 q 319 803 341 803 q 269 800 294 803 q 219 792 243 797 q 171 781 194 787 q 129 768 148 774 q 131 802 131 781 q 131 823 131 812 q 130 845 130 833 q 132 888 130 866 q 138 928 133 909 q 151 960 142 946 q 176 978 160 973 q 241 997 214 990 q 292 1007 269 1004 q 340 1011 316 1010 q 394 1013 363 1013 q 507 998 450 1013 q 611 951 564 983 q 687 872 657 920 q 716 759 716 825 q 704 681 716 716 q 674 618 692 646 q 635 569 656 590 q 595 534 614 549 q 640 504 616 523 q 683 456 663 486 q 716 386 703 427 q 730 290 730 345 q 708 177 730 233 q 647 77 686 121 q 555 2 608 32 q 441 -33 503 -27 z " - }, - "4": { - "ha": 917, - "x_min": 16, - "x_max": 914, - "o": "m 913 387 q 910 372 912 382 q 905 348 907 361 q 900 319 903 335 q 894 289 897 304 l 878 212 q 873 196 876 201 q 858 189 869 191 q 823 187 846 187 q 758 187 800 187 l 746 63 q 743 51 745 57 q 734 42 741 45 q 712 33 730 40 q 671 18 695 26 q 621 -1 648 9 q 569 -19 593 -11 q 526 -33 545 -27 q 500 -38 507 -38 q 483 -33 490 -38 q 476 -14 476 -28 q 479 69 476 19 q 488 184 482 119 q 374 183 430 184 q 269 182 317 182 q 184 182 220 182 q 129 182 147 182 q 43 186 69 182 q 16 205 16 190 q 23 224 16 213 q 45 261 29 234 q 84 326 62 288 q 134 408 107 363 q 188 497 161 452 l 329 730 q 375 813 355 772 q 419 888 395 854 q 476 947 443 922 q 564 983 510 972 l 779 1040 q 797 1042 789 1042 q 809 1038 804 1042 q 813 1021 813 1034 l 813 1013 q 808 899 810 950 q 802 803 805 848 q 797 715 800 758 q 791 627 793 673 q 785 531 788 582 q 780 416 783 479 q 855 418 825 418 q 890 419 884 419 q 906 413 898 418 q 914 395 914 409 q 913 387 914 389 m 507 408 q 521 506 515 454 q 531 612 527 558 q 538 718 535 665 q 543 821 541 771 l 296 408 l 507 408 z " - }, - "5": { - "ha": 732, - "x_min": 41, - "x_max": 715, - "o": "m 96 188 q 103 195 98 191 q 116 199 108 199 l 120 199 q 169 194 146 195 q 223 193 192 193 q 291 198 258 193 q 349 216 323 203 q 391 255 375 230 q 406 320 406 280 q 388 394 406 367 q 340 433 370 420 q 276 449 311 446 q 206 452 241 452 q 182 452 193 452 q 163 452 172 452 q 134 455 142 452 q 126 471 126 458 q 127 482 126 476 q 129 496 127 488 q 139 619 131 557 q 157 742 146 680 q 178 864 167 803 q 198 986 189 925 q 452 1015 327 1001 q 707 1046 576 1029 q 715 1031 715 1046 q 713 1019 715 1024 q 709 1005 713 1017 q 701 976 706 994 q 690 937 696 958 q 679 893 684 915 q 667 853 673 872 q 658 821 662 833 q 635 785 651 798 q 596 766 618 772 q 549 757 574 759 q 496 755 523 755 q 452 755 475 755 q 409 755 429 755 q 382 753 393 755 q 363 744 371 751 q 353 722 356 736 q 349 684 349 708 q 493 660 427 680 q 609 601 559 640 q 687 503 659 562 q 715 360 715 444 q 693 223 715 283 q 634 120 671 164 q 548 46 597 76 q 441 -2 498 16 q 324 -27 385 -20 q 206 -35 264 -35 q 123 -31 163 -35 q 52 -10 83 -26 q 45 -5 49 -9 q 41 1 41 -1 l 96 188 z " - }, - "6": { - "ha": 873, - "x_min": 79, - "x_max": 875, - "o": "m 450 -35 q 287 -3 356 -35 q 171 82 217 28 q 101 208 124 136 q 79 361 79 280 q 95 484 79 425 q 139 596 111 542 q 202 702 166 650 q 278 802 239 753 q 357 899 317 851 q 432 994 397 946 q 443 1008 437 1000 q 456 1022 449 1016 q 470 1033 463 1029 q 487 1038 477 1038 l 657 1038 q 686 1033 674 1038 q 699 1018 699 1028 q 688 996 699 1008 q 579 848 628 926 q 487 685 530 770 q 534 694 511 692 q 581 697 556 697 q 711 668 656 697 q 803 592 766 639 q 857 488 839 546 q 875 372 875 430 q 848 206 875 281 q 767 78 821 131 q 634 -5 713 24 q 450 -35 554 -35 m 387 325 q 391 280 387 305 q 404 231 394 254 q 430 192 414 208 q 473 176 447 176 q 518 187 499 176 q 549 216 536 198 q 570 256 562 233 q 581 303 577 279 q 586 351 585 327 q 587 393 587 374 q 585 441 587 416 q 575 486 583 466 q 550 518 566 505 q 504 531 533 531 q 442 510 465 531 q 407 458 419 489 q 391 391 395 427 q 387 325 387 355 z " - }, - "7": { - "ha": 723, - "x_min": 69, - "x_max": 791, - "o": "m 770 897 l 621 517 q 561 366 591 441 q 505 222 531 290 q 457 102 478 155 q 425 21 436 50 q 410 -17 414 -3 q 401 -36 405 -30 q 393 -45 397 -43 q 380 -49 389 -47 q 326 -61 354 -55 q 271 -71 298 -66 q 219 -80 244 -76 q 174 -87 194 -84 q 167 -87 172 -87 q 150 -81 155 -87 q 144 -64 144 -74 q 151 -40 144 -54 q 174 16 157 -24 q 214 111 191 56 q 264 231 237 166 q 319 362 292 296 l 458 701 l 321 700 q 263 700 293 700 q 206 699 234 699 q 154 699 178 699 q 111 699 129 699 q 80 702 90 699 q 69 714 69 705 q 73 732 69 723 q 77 742 77 741 q 103 798 90 771 q 129 850 116 825 q 154 903 141 876 q 179 958 166 929 q 181 961 180 960 q 182 964 181 963 q 205 980 194 977 q 225 982 216 982 q 357 983 300 983 q 460 984 414 984 q 544 985 507 985 q 617 986 582 985 q 688 986 652 986 q 766 986 724 986 q 791 964 791 986 q 786 937 791 954 q 770 897 781 921 z " - }, - "8": { - "ha": 868, - "x_min": 76, - "x_max": 848, - "o": "m 425 -35 q 341 -28 383 -35 q 261 -6 300 -21 q 189 32 222 9 q 130 87 155 55 q 90 159 104 119 q 76 251 76 200 q 89 339 76 300 q 123 411 101 378 q 173 475 144 445 q 234 536 202 505 q 160 619 183 571 q 137 726 137 667 q 152 817 137 777 q 195 890 168 858 q 259 945 222 922 q 339 983 296 968 q 429 1006 382 998 q 526 1013 477 1013 q 626 997 575 1013 q 716 948 676 980 q 782 870 757 916 q 808 765 808 824 q 799 702 808 732 q 777 647 791 673 q 746 598 764 621 q 710 557 728 576 q 764 512 739 537 q 808 455 789 487 q 838 382 827 422 q 848 290 848 341 q 830 190 848 235 q 781 109 812 145 q 707 46 749 73 q 618 1 665 19 q 522 -26 572 -17 q 425 -35 472 -35 m 381 269 q 385 213 381 243 q 398 156 388 182 q 428 111 409 129 q 478 93 447 93 q 510 104 496 93 q 532 133 523 115 q 548 173 542 151 q 557 216 554 195 q 562 257 561 238 q 564 288 564 276 q 558 339 564 311 q 541 393 553 368 q 511 435 530 418 q 468 452 493 452 q 434 442 448 452 q 411 417 420 433 q 396 382 401 402 q 387 342 390 363 q 382 303 383 322 q 381 269 381 283 m 391 742 q 396 699 391 722 q 413 656 401 676 q 441 623 424 636 q 484 610 458 610 q 522 626 508 610 q 543 666 536 643 q 552 715 550 690 q 553 756 553 740 q 549 796 553 775 q 536 834 545 817 q 511 863 527 851 q 473 874 496 874 q 433 861 449 874 q 408 828 417 848 q 395 785 399 808 q 391 742 391 762 z " - }, - "9": { - "ha": 899, - "x_min": 74, - "x_max": 905, - "o": "m 417 -14 q 399 2 399 -9 q 406 18 399 9 q 444 80 426 47 q 478 149 463 113 q 506 218 493 184 q 527 283 518 253 q 456 267 492 273 q 384 261 419 261 q 261 289 318 261 q 163 362 205 316 q 98 468 121 408 q 74 592 74 528 q 93 714 74 657 q 147 817 113 770 q 228 900 181 863 q 328 961 274 937 q 439 999 381 986 q 557 1013 498 1013 q 700 977 636 1013 q 810 884 764 941 q 880 756 855 827 q 905 614 905 685 q 889 484 905 547 q 847 360 873 420 q 786 244 821 300 q 713 135 751 188 q 634 33 674 82 q 558 -62 595 -16 q 553 -66 556 -64 q 545 -68 550 -68 q 536 -66 541 -68 q 504 -49 518 -56 q 476 -35 490 -41 q 448 -24 463 -29 q 417 -14 434 -18 m 371 642 q 379 573 371 606 q 405 515 387 541 q 450 475 422 490 q 517 460 477 460 q 543 462 532 460 q 571 471 553 465 q 583 523 578 501 q 590 564 588 545 q 594 602 593 583 q 595 646 595 621 q 594 681 595 661 q 589 722 593 701 q 580 764 586 743 q 563 800 574 784 q 537 825 553 815 q 500 835 522 835 q 437 816 463 835 q 397 769 412 798 q 377 706 382 741 q 371 642 371 672 z " - }, - " ": { - "ha": 298, - "x_min": 0, - "x_max": 0, - "o": "" - }, - " ": { - "ha": 298, - "x_min": 0, - "x_max": 0, - "o": "" - }, - "!": { - "ha": 373, - "x_min": 49, - "x_max": 416, - "o": "m 362 793 q 320 582 340 688 q 281 369 299 477 q 277 338 280 347 q 262 327 274 329 q 210 317 235 322 q 155 304 184 311 q 149 306 150 304 q 148 311 148 307 l 141 981 q 146 1011 142 1002 q 161 1023 149 1020 q 277 1052 218 1036 q 402 1086 336 1069 q 408 1086 404 1086 q 416 1080 416 1086 q 413 1063 416 1079 q 406 1022 410 1047 q 396 965 401 997 q 385 902 391 934 q 373 842 378 871 q 362 793 367 813 m 338 232 q 335 187 336 203 q 334 164 334 172 q 333 154 333 156 q 333 151 333 152 q 332 147 332 150 q 331 134 332 144 q 329 105 330 124 q 325 53 328 86 q 320 22 323 31 q 305 11 317 14 q 184 -13 248 -1 q 62 -45 121 -26 q 56 -46 60 -46 l 50 -41 q 49 -39 49 -39 l 64 146 q 68 177 65 168 q 83 189 71 186 q 200 212 141 199 q 325 238 259 224 q 331 239 327 239 q 338 232 338 239 z " - }, - "\"": { - "ha": 747, - "x_min": 118, - "x_max": 802, - "o": "m 136 532 q 127 733 131 628 q 118 941 123 838 l 118 949 q 122 974 118 967 q 138 982 126 980 q 205 982 170 982 q 276 983 241 983 q 347 983 312 983 q 412 983 381 983 q 422 980 418 983 q 427 967 427 977 l 427 963 l 321 531 q 316 512 318 520 q 312 500 315 505 q 306 493 310 495 q 296 490 302 490 q 225 490 260 490 q 150 489 191 489 q 142 494 144 489 q 138 507 139 500 q 136 522 136 514 q 136 532 136 529 m 511 532 q 502 733 506 628 q 493 941 498 838 l 493 949 q 497 974 493 967 q 513 982 501 980 q 581 982 545 982 q 651 983 616 983 q 722 983 687 983 q 787 983 756 983 q 798 980 793 983 q 802 967 802 977 l 802 963 l 696 531 q 691 512 693 520 q 687 500 690 505 q 681 493 685 495 q 671 490 677 490 q 600 490 635 490 q 525 489 566 489 q 517 494 519 489 q 513 507 514 500 q 511 522 511 514 q 511 532 511 529 z " - }, - "#": { - "ha": 1114, - "x_min": 69, - "x_max": 1147, - "o": "m 275 474 l 296 561 l 202 561 q 141 564 161 561 q 121 578 121 568 q 128 601 121 583 q 144 640 134 618 q 165 684 153 661 q 186 724 176 707 q 200 737 194 731 q 221 744 206 743 l 341 742 q 371 871 357 807 q 399 1001 385 935 q 408 1028 404 1021 q 420 1036 411 1036 l 425 1036 q 478 1019 451 1028 q 531 1001 505 1009 q 584 985 558 992 q 635 973 610 977 q 643 969 640 972 q 647 962 647 967 l 591 739 l 709 736 q 739 868 724 802 q 769 1001 754 933 q 777 1028 774 1021 q 790 1036 781 1036 l 795 1036 q 847 1019 821 1028 q 901 1001 874 1009 q 954 985 928 992 q 1004 973 980 977 q 1013 969 1009 972 q 1017 962 1017 967 l 961 739 q 1017 746 990 743 q 1067 752 1044 750 q 1105 756 1089 755 q 1128 758 1121 758 q 1141 755 1134 758 q 1147 741 1147 751 q 1136 711 1147 735 q 1107 650 1125 687 l 1075 587 q 1061 572 1070 577 q 1034 566 1051 568 q 988 565 1016 565 q 918 566 960 566 l 896 473 q 980 485 943 481 q 1029 490 1017 490 q 1041 486 1034 490 q 1048 472 1048 483 q 1042 452 1048 468 q 1028 414 1037 437 q 1009 362 1020 391 q 989 305 999 334 q 978 290 984 295 q 951 285 971 285 l 924 285 q 891 285 910 285 q 850 286 873 285 l 780 3 q 777 -17 777 -7 q 766 -26 777 -26 q 748 -22 758 -26 l 619 14 q 601 19 614 16 q 576 28 589 23 q 553 42 563 34 q 543 60 543 50 q 545 68 543 62 q 560 126 553 99 q 574 181 567 154 q 587 234 581 208 q 601 288 594 260 q 541 289 570 288 q 481 290 511 289 l 410 3 q 407 -17 408 -7 q 397 -26 407 -26 q 378 -22 389 -26 l 250 14 q 232 19 244 16 q 206 28 219 23 q 183 42 193 34 q 174 60 174 50 q 175 68 174 62 q 205 182 191 130 q 232 292 218 235 q 156 292 187 292 q 106 294 125 292 q 78 298 87 295 q 69 309 69 302 q 77 332 69 315 q 96 371 84 349 q 122 415 108 393 q 148 456 136 438 q 161 469 155 463 q 182 475 168 475 l 275 474 m 644 468 q 655 516 649 492 q 667 564 661 540 q 607 563 636 564 q 549 563 578 563 l 526 470 l 644 468 z " - }, - "$": { - "ha": 673, - "x_min": 83, - "x_max": 676, - "o": "m 517 927 q 602 920 566 924 q 658 914 638 917 l 676 715 q 662 716 675 715 q 633 720 650 718 q 598 723 616 722 q 569 725 581 725 q 532 723 555 725 q 487 713 509 720 q 450 693 465 706 q 434 658 434 680 q 451 610 434 631 q 492 568 467 589 q 547 525 517 547 q 601 476 576 503 q 643 415 626 449 q 659 336 659 380 q 644 265 659 298 q 601 204 628 232 q 538 153 574 176 q 463 113 503 130 q 461 79 463 102 q 457 30 459 57 q 453 -27 455 2 q 450 -81 451 -56 l 396 -80 q 368 -81 387 -80 q 325 -84 349 -82 q 278 -86 302 -85 q 235 -87 254 -87 l 242 42 l 189 40 q 137 38 165 39 q 83 37 109 37 q 106 140 94 90 q 130 243 118 190 q 217 257 175 247 q 291 281 258 267 q 342 314 323 296 q 361 353 361 332 q 356 379 361 365 q 335 410 351 393 q 291 451 319 428 q 214 503 262 473 q 128 583 154 540 q 102 676 102 625 q 121 745 102 710 q 168 809 139 780 q 233 860 197 839 q 306 888 269 881 l 327 1017 q 329 1032 328 1026 q 330 1042 329 1038 q 332 1048 330 1046 q 340 1050 334 1050 q 438 1058 387 1054 q 538 1070 490 1063 q 544 1069 543 1070 q 545 1065 545 1067 q 542 1050 545 1064 q 535 1016 539 1036 q 526 972 530 996 q 517 927 521 948 z " - }, - "%": { - "ha": 1487, - "x_min": 103, - "x_max": 1476, - "o": "m 717 586 q 827 720 770 652 q 938 857 883 789 q 950 871 946 867 q 961 876 954 876 q 967 876 966 876 q 1032 825 1000 849 q 1096 782 1063 802 q 1110 775 1101 780 q 1118 766 1118 771 q 1116 761 1118 763 l 582 113 q 575 103 576 106 q 568 100 574 100 q 561 101 565 100 q 549 104 556 102 q 487 153 510 136 q 450 180 463 171 q 431 193 437 190 q 422 200 426 197 q 416 209 417 203 q 416 222 416 214 q 493 312 456 268 q 566 400 530 356 q 639 491 602 445 q 717 586 676 536 m 103 764 q 121 889 103 831 q 175 989 139 947 q 265 1056 211 1031 q 391 1080 319 1080 q 508 1056 458 1080 q 591 991 558 1031 q 639 899 623 951 q 654 791 654 846 q 634 661 654 718 q 576 564 614 604 q 487 503 539 524 q 372 482 435 482 q 263 502 313 482 q 178 559 214 522 q 123 648 142 595 q 103 764 103 700 m 277 778 q 281 724 277 751 q 296 675 285 697 q 326 639 307 653 q 375 625 345 625 q 428 641 407 625 q 461 682 449 657 q 479 735 474 706 q 484 793 484 765 q 479 842 484 816 q 463 890 474 868 q 433 927 452 913 q 387 942 414 942 q 334 927 355 942 q 300 888 313 912 q 282 836 287 865 q 277 778 277 806 m 924 247 q 942 372 924 314 q 996 472 960 429 q 1086 538 1032 514 q 1212 563 1140 563 q 1330 538 1280 563 q 1412 474 1379 514 q 1460 381 1444 433 q 1476 273 1476 329 q 1455 143 1476 201 q 1398 46 1435 86 q 1308 -14 1360 7 q 1193 -35 1256 -35 q 1084 -15 1134 -35 q 999 41 1035 5 q 944 130 964 78 q 924 247 924 182 m 1098 260 q 1102 207 1098 234 q 1117 158 1106 180 q 1147 122 1128 136 q 1196 108 1166 108 q 1249 124 1228 108 q 1283 164 1270 140 q 1300 218 1295 189 q 1305 275 1305 248 q 1300 325 1305 298 q 1284 373 1295 351 q 1254 410 1273 395 q 1208 425 1236 425 q 1155 410 1176 425 q 1121 371 1134 395 q 1103 318 1108 347 q 1098 260 1098 289 z " - }, - "&": { - "ha": 1058, - "x_min": 54, - "x_max": 1080, - "o": "m 54 201 q 56 242 54 222 q 65 281 58 261 q 89 324 73 302 q 132 373 104 346 q 202 433 160 400 q 306 509 245 467 q 243 623 263 566 q 222 736 222 681 q 247 831 222 787 q 317 910 271 876 q 432 963 364 943 q 589 982 500 982 q 631 978 608 982 q 679 964 654 973 q 726 939 703 954 q 767 900 749 923 q 796 848 785 878 q 807 779 807 818 q 795 714 807 743 q 759 656 783 686 q 698 593 735 627 q 611 515 661 559 l 772 385 q 787 372 780 378 q 802 367 794 366 q 809 373 806 372 q 817 374 813 374 l 971 517 q 1002 498 983 512 q 1038 466 1021 484 q 1067 430 1055 448 q 1080 398 1080 411 q 1077 385 1080 390 l 954 256 l 962 250 q 976 239 968 245 q 995 225 985 233 q 1018 209 1006 217 q 1042 192 1029 200 q 1050 182 1048 187 q 1051 175 1051 176 q 1043 151 1051 165 q 1022 121 1035 137 q 995 87 1010 104 q 964 55 979 70 q 937 27 949 39 q 917 8 924 14 q 903 1 910 1 q 893 5 897 1 l 757 89 q 636 28 688 52 q 539 -9 585 5 q 451 -29 494 -24 q 357 -35 408 -35 q 245 -20 300 -35 q 149 23 191 -6 q 80 97 106 53 q 54 201 54 141 m 349 245 q 353 215 349 230 q 367 187 357 199 q 395 166 377 174 q 440 158 412 158 q 465 159 449 158 q 500 167 480 161 q 544 185 519 173 q 594 220 568 198 l 433 377 q 403 359 418 369 q 376 333 388 349 q 356 297 363 318 q 349 245 349 275 m 536 823 q 499 817 515 823 q 473 799 483 810 q 457 773 463 787 q 452 742 452 758 q 464 691 452 717 q 496 645 475 665 q 572 714 549 680 q 595 773 595 747 q 579 810 595 796 q 536 823 564 823 z " - }, - "'": { - "ha": 372, - "x_min": 118, - "x_max": 427, - "o": "m 136 532 q 127 732 131 627 q 118 940 123 838 l 118 949 q 122 973 118 966 q 138 981 126 979 q 205 982 170 981 q 276 982 241 982 q 347 982 312 982 q 412 983 381 983 q 422 979 418 983 q 427 966 427 976 l 427 962 l 321 530 q 316 512 318 519 q 312 499 315 504 q 306 492 310 494 q 296 490 302 490 q 225 489 260 490 q 150 488 191 488 q 142 494 144 488 q 138 506 139 499 q 136 521 136 513 q 136 532 136 528 z " - }, - "(": { - "ha": 568, - "x_min": 68, - "x_max": 616, - "o": "m 524 63 q 516 13 520 35 q 507 -30 511 -9 q 497 -73 502 -51 q 487 -123 492 -94 q 473 -136 484 -136 q 471 -135 471 -136 q 469 -135 470 -135 q 287 -74 363 -119 q 162 37 211 -28 q 91 184 113 102 q 68 354 68 265 q 74 448 68 394 q 96 561 80 502 q 139 680 112 620 q 210 793 167 741 q 276 863 237 826 q 364 931 315 899 q 470 986 413 963 q 590 1015 528 1009 q 598 1011 593 1015 q 604 995 602 1008 q 606 974 604 995 q 610 923 608 952 q 614 861 612 893 q 616 808 616 829 q 612 792 616 796 q 596 785 607 788 q 498 729 543 770 q 421 633 454 689 q 370 510 389 577 q 351 373 351 442 q 360 283 351 327 q 388 201 369 239 q 438 137 408 164 q 511 96 469 109 q 521 90 517 95 q 525 74 525 85 q 525 69 525 71 q 524 63 525 66 z " - }, - ")": { - "ha": 569, - "x_min": 58, - "x_max": 574, - "o": "m 58 63 q 64 88 58 81 q 76 96 69 94 q 171 150 131 113 q 238 237 212 187 q 277 345 264 287 q 290 459 290 402 q 277 570 290 517 q 241 667 264 623 q 183 741 217 710 q 107 785 149 772 q 94 790 98 787 q 90 800 90 793 q 91 808 90 806 q 102 861 95 829 q 116 923 109 893 q 129 973 123 952 q 135 995 135 994 q 144 1011 138 1008 q 153 1015 149 1015 q 268 986 214 1009 q 364 931 321 963 q 440 863 408 899 q 494 793 473 826 q 532 720 517 758 q 556 641 547 681 q 570 562 566 602 q 574 486 574 522 q 561 345 574 414 q 523 210 549 275 q 456 88 496 145 q 361 -14 416 31 q 236 -91 307 -60 q 80 -135 166 -122 q 78 -135 79 -135 q 76 -136 77 -136 q 64 -123 64 -136 q 63 -81 64 -100 q 61 -44 62 -62 q 59 -10 60 -27 q 58 26 58 7 l 58 63 l 58 63 z " - }, - "*": { - "ha": 865, - "x_min": 79, - "x_max": 835, - "o": "m 294 347 l 224 397 q 115 468 152 444 q 79 507 79 493 q 82 517 79 511 q 92 534 85 524 q 109 561 98 545 q 136 599 120 576 l 174 654 q 181 660 178 658 q 190 663 185 663 q 213 650 199 663 l 260 610 q 309 570 282 592 q 365 524 336 547 l 368 553 q 379 671 374 629 q 387 734 383 713 q 396 761 391 755 q 409 768 401 766 l 421 768 q 450 767 429 768 q 495 766 471 766 q 539 765 518 766 q 569 765 561 765 l 573 765 q 587 758 583 762 q 592 741 592 753 q 592 736 592 739 q 591 730 592 733 l 581 669 q 572 606 576 641 q 564 532 568 570 q 613 579 588 555 q 660 624 638 604 q 699 656 682 644 q 724 669 715 669 q 732 667 728 669 q 740 661 736 665 l 778 606 q 803 568 793 584 q 821 542 814 553 q 831 525 828 531 q 835 514 835 518 q 832 504 835 509 q 822 493 830 499 q 800 476 814 486 q 762 449 786 466 q 703 408 738 433 q 618 347 667 383 l 798 208 q 819 188 813 195 q 826 176 825 181 q 821 163 826 170 q 808 144 815 157 q 781 106 800 132 q 726 32 762 81 q 712 24 721 24 q 689 35 701 24 l 539 153 l 526 -13 q 523 -37 525 -28 q 519 -50 522 -45 q 513 -56 517 -54 q 503 -57 509 -57 l 490 -57 q 481 -57 486 -57 q 469 -58 476 -58 q 423 -55 454 -58 q 340 -50 393 -53 q 327 -42 332 -50 q 321 -22 321 -35 l 340 149 l 218 62 q 205 54 211 57 q 195 52 200 52 q 180 59 186 52 q 129 115 147 96 q 106 144 111 134 q 93 163 98 157 q 87 176 87 170 q 94 188 87 181 q 116 208 100 195 l 294 347 z " - }, - "+": { - "ha": 652, - "x_min": 73, - "x_max": 654, - "o": "m 256 357 q 196 357 222 357 q 154 357 170 357 q 93 360 113 357 q 73 376 73 364 q 77 401 73 382 q 86 445 81 420 q 96 493 91 469 q 104 535 101 518 q 115 550 106 543 q 139 557 124 557 l 275 559 l 277 574 q 281 653 280 620 q 286 707 283 686 q 296 738 289 728 q 317 748 302 748 q 320 748 318 748 q 323 747 321 747 q 336 748 328 747 q 355 748 345 748 q 379 749 366 749 q 404 749 392 749 l 469 751 q 483 744 478 749 q 488 728 488 740 q 488 726 488 726 q 487 721 488 725 q 486 708 487 717 q 484 682 486 699 q 480 635 483 664 q 475 563 478 606 l 486 564 q 535 565 511 564 q 579 566 559 566 q 614 567 600 566 q 635 567 629 567 q 647 563 640 567 q 654 547 654 559 q 650 521 653 546 q 643 452 648 496 l 635 387 q 628 373 631 377 q 616 366 624 368 q 595 364 609 364 q 557 363 581 363 l 458 361 l 450 262 q 445 219 448 236 q 437 193 441 203 q 428 180 433 184 q 414 176 422 176 q 383 177 403 176 q 341 178 363 177 q 298 179 319 178 q 261 179 276 179 q 248 187 253 180 q 243 208 243 194 l 243 212 l 256 357 z " - }, - ",": { - "ha": 398, - "x_min": 56, - "x_max": 361, - "o": "m 176 -225 q 164 -219 169 -221 q 152 -214 160 -218 q 129 -202 144 -210 q 85 -178 114 -194 q 63 -159 63 -166 q 65 -153 63 -157 q 106 -89 85 -123 q 147 -21 127 -56 l 90 -20 l 77 -20 q 62 -19 68 -20 q 56 -14 56 -18 l 56 -12 q 60 34 58 17 q 62 59 62 50 q 63 73 63 68 q 64 80 64 77 q 65 88 64 83 q 66 104 65 93 q 68 136 66 116 q 73 189 70 156 q 77 220 74 212 q 92 231 80 229 q 156 231 123 231 q 222 232 189 231 q 287 232 255 232 q 349 232 319 232 q 361 216 361 232 l 349 50 q 345 24 347 35 q 341 6 343 14 q 337 -11 340 -3 q 332 -30 335 -19 q 318 -55 328 -39 q 296 -87 309 -70 q 271 -123 284 -105 q 246 -157 258 -141 q 226 -184 235 -173 q 214 -200 217 -196 q 209 -207 212 -203 q 202 -216 206 -212 q 193 -224 198 -220 q 184 -227 189 -227 q 176 -225 180 -227 z " - }, - "-": { - "ha": 650, - "x_min": 65, - "x_max": 659, - "o": "m 437 573 q 505 575 472 574 q 565 577 538 576 q 612 579 592 578 q 640 581 632 581 q 652 576 646 581 q 659 561 659 572 q 653 538 659 555 q 636 499 646 522 q 613 447 626 475 q 587 387 600 418 q 582 376 584 380 q 575 369 579 372 q 566 365 572 366 q 549 363 559 363 q 427 361 488 362 q 312 359 366 360 q 215 357 258 358 q 146 357 172 357 q 85 360 105 357 q 65 376 65 364 q 74 394 65 379 q 96 430 82 410 q 126 474 109 451 q 161 517 144 498 q 193 550 178 537 q 219 564 209 564 l 437 573 z " - }, - ".": { - "ha": 389, - "x_min": 61, - "x_max": 353, - "o": "m 61 -26 q 63 25 62 6 q 64 54 64 43 q 64 68 64 64 q 64 76 64 72 q 65 85 64 79 q 66 103 65 90 q 68 137 66 115 q 71 196 69 159 q 76 227 73 218 q 91 237 79 235 q 216 238 151 237 q 338 239 281 238 q 349 235 345 239 q 353 222 353 232 l 334 9 q 329 -21 331 -13 q 313 -31 326 -30 q 195 -33 256 -32 q 68 -33 134 -33 q 63 -33 64 -33 q 61 -28 61 -32 l 61 -26 z " - }, - "/": { - "ha": 591, - "x_min": 39, - "x_max": 646, - "o": "m 301 640 q 380 819 342 729 q 459 1001 418 908 q 473 1028 468 1021 q 487 1036 477 1036 l 492 1036 q 564 1004 528 1021 q 635 980 600 987 q 643 977 640 979 q 646 971 646 975 l 646 969 l 211 10 q 207 -1 208 4 q 204 -11 205 -7 q 199 -17 202 -15 q 191 -20 197 -20 q 174 -15 183 -20 l 105 14 q 89 19 100 16 q 67 28 78 23 q 47 40 56 33 q 39 56 39 47 q 42 68 39 62 q 102 198 73 134 q 161 329 131 261 q 225 473 191 397 q 301 640 259 549 z " - }, - ":": { - "ha": 453, - "x_min": 108, - "x_max": 413, - "o": "m 121 493 q 123 544 123 525 q 124 572 124 562 q 125 587 125 583 q 125 594 125 591 q 125 604 125 598 q 126 622 125 609 q 128 656 127 634 q 132 715 130 678 q 136 746 133 737 q 151 756 139 754 q 276 756 211 756 q 399 758 341 757 q 409 754 405 758 q 413 741 413 751 l 394 528 q 389 497 391 506 q 374 488 387 489 q 255 486 316 487 q 129 486 195 486 q 123 486 125 486 q 121 490 121 487 l 121 493 m 108 -26 q 110 25 109 6 q 111 54 111 43 q 111 68 111 64 q 111 76 111 72 q 112 85 111 79 q 113 103 112 90 q 115 137 113 115 q 118 196 116 159 q 122 227 119 218 q 138 237 125 235 q 262 238 197 237 q 385 239 328 238 q 395 235 391 239 q 399 222 399 232 l 380 9 q 375 -21 378 -13 q 360 -31 373 -30 q 242 -33 302 -32 q 115 -33 181 -33 q 110 -33 111 -33 q 108 -28 108 -32 l 108 -26 z " - }, - ";": { - "ha": 439, - "x_min": 95, - "x_max": 401, - "o": "m 216 -224 q 204 -218 208 -220 q 192 -212 199 -216 q 169 -200 184 -208 q 124 -176 153 -193 q 102 -157 102 -165 q 104 -152 102 -155 q 145 -88 124 -121 q 186 -20 167 -54 l 129 -19 l 117 -19 q 101 -18 107 -19 q 95 -12 95 -17 l 95 -11 q 99 35 98 18 q 102 61 101 52 q 103 74 102 70 q 103 81 103 78 q 104 90 104 85 q 105 106 104 94 q 107 137 106 117 q 112 191 109 157 q 116 222 113 213 q 132 232 119 231 q 195 232 162 232 q 261 233 229 233 q 327 233 294 233 q 389 233 359 233 q 400 217 400 233 l 388 52 q 384 26 386 36 q 381 7 382 16 q 377 -9 379 -1 q 371 -28 374 -18 q 357 -53 367 -38 q 336 -86 348 -68 q 310 -122 323 -104 q 286 -156 297 -140 q 265 -183 274 -172 q 254 -199 256 -195 q 249 -206 252 -201 q 241 -215 245 -210 q 233 -222 237 -219 q 223 -226 228 -226 q 216 -224 220 -226 m 110 492 q 112 543 111 524 q 113 572 113 562 q 113 586 113 582 q 113 594 113 590 q 114 603 113 597 q 115 621 114 608 q 117 655 115 633 q 120 714 118 677 q 124 745 121 736 q 140 755 127 753 q 264 756 199 755 q 387 757 330 756 q 397 753 393 757 q 401 741 401 750 l 382 528 q 377 497 380 505 q 362 487 375 488 q 244 486 304 486 q 117 485 183 485 q 112 486 113 485 q 110 490 110 486 l 110 492 z " - }, - "<": { - "ha": 730, - "x_min": 78, - "x_max": 703, - "o": "m 697 220 q 703 212 703 216 q 701 204 703 208 q 654 100 673 153 q 616 -7 635 46 q 600 -20 612 -20 q 589 -18 594 -20 q 574 -12 583 -16 l 129 248 q 100 265 107 258 q 92 286 92 272 q 87 390 90 337 q 79 500 85 443 q 78 502 79 501 q 78 503 78 503 l 79 508 q 82 514 79 511 q 87 516 85 516 q 145 542 109 527 q 224 573 180 556 q 319 609 269 591 q 422 648 370 628 q 527 687 475 667 q 627 724 579 706 q 657 730 648 730 q 668 720 666 730 q 677 610 672 667 q 694 502 682 553 q 686 486 694 487 l 388 376 q 418 361 395 372 q 471 334 441 349 q 536 301 502 319 q 603 268 571 283 q 660 239 635 252 q 697 220 686 226 z " - }, - "=": { - "ha": 720, - "x_min": 111, - "x_max": 671, - "o": "m 389 602 q 478 603 435 602 q 556 605 521 604 q 616 607 591 606 q 652 608 642 608 q 665 604 658 608 q 671 588 671 600 q 666 563 672 583 q 649 508 659 543 l 633 454 q 622 437 628 443 q 595 431 615 431 q 473 429 534 430 q 358 427 412 428 q 261 425 304 426 q 192 425 218 425 q 131 428 151 425 q 111 444 111 432 q 115 464 111 448 q 124 499 119 479 q 136 539 130 519 q 149 576 143 560 q 163 590 157 583 q 184 598 169 597 l 389 602 m 389 283 q 478 284 435 283 q 556 287 521 286 q 616 289 591 288 q 652 290 642 290 q 665 286 658 290 q 671 270 671 281 q 666 245 672 265 q 649 190 659 224 l 633 136 q 622 119 628 125 q 595 113 615 113 q 473 111 534 112 q 358 109 412 110 q 261 107 304 108 q 192 106 218 106 q 131 110 151 106 q 111 125 111 114 q 115 146 111 130 q 124 181 119 161 q 136 221 130 201 q 149 258 143 242 q 163 272 157 264 q 184 280 169 279 l 389 283 z " - }, - ">": { - "ha": 713, - "x_min": 90, - "x_max": 714, - "o": "m 95 220 q 132 239 106 226 q 189 268 157 252 q 256 301 221 283 q 321 334 290 319 q 374 361 351 349 q 404 376 397 372 l 106 486 q 98 502 98 487 q 115 610 110 553 q 124 720 120 667 q 135 730 126 730 q 165 724 144 730 q 265 687 213 706 q 370 648 317 667 q 473 609 422 628 q 568 573 524 591 q 647 542 612 556 q 705 516 683 527 q 710 514 707 516 q 713 508 713 511 l 714 503 q 714 502 714 503 q 713 500 713 501 q 705 390 707 443 q 700 286 702 337 q 692 265 700 272 q 663 248 685 258 l 218 -12 q 203 -18 209 -16 q 193 -20 198 -20 q 182 -17 185 -20 q 176 -7 178 -14 q 137 100 156 46 q 91 204 117 153 q 90 212 90 208 q 91 217 90 215 q 95 220 92 218 z " - }, - "?": { - "ha": 791, - "x_min": 98, - "x_max": 800, - "o": "m 294 406 q 383 469 340 431 q 457 549 425 507 q 508 634 489 591 q 526 711 526 676 q 505 773 526 749 q 436 797 484 797 q 391 790 409 797 q 363 774 374 784 q 349 751 353 764 q 345 728 345 739 q 349 699 345 712 q 354 682 354 686 q 345 675 354 677 q 314 669 335 673 q 257 660 292 666 q 170 639 222 653 q 140 631 151 633 q 123 629 129 629 q 110 640 115 629 q 102 664 105 650 q 99 692 100 677 q 98 717 98 707 q 129 828 98 779 q 209 911 159 878 q 320 963 258 945 q 445 981 382 981 q 591 957 526 981 q 703 893 656 932 q 774 805 749 854 q 800 710 800 757 q 786 634 800 671 q 750 560 773 596 q 697 490 728 524 q 634 425 667 456 q 567 366 601 394 q 500 312 532 337 q 495 308 499 310 q 488 306 492 306 q 483 307 486 306 q 478 309 479 307 q 432 330 452 321 q 391 348 411 340 q 351 362 372 356 q 305 374 330 369 q 291 381 296 376 q 287 390 287 385 q 293 398 292 393 q 294 406 294 404 m 296 -26 q 298 25 298 6 q 299 54 299 43 q 300 68 300 64 q 300 76 300 72 q 300 85 300 79 q 301 103 300 90 q 303 137 302 115 q 307 196 304 159 q 311 227 308 218 q 326 237 314 235 q 451 238 386 237 q 574 239 516 238 q 585 234 581 239 q 588 218 588 230 l 569 9 q 564 -21 566 -13 q 549 -31 562 -30 q 430 -33 491 -32 q 304 -33 370 -33 q 297 -32 298 -33 q 296 -26 296 -31 z " - }, - "@": { - "ha": 1207, - "x_min": 82, - "x_max": 1213, - "o": "m 710 330 q 723 413 718 378 q 731 471 728 447 q 735 510 734 494 q 738 536 737 526 q 711 556 728 546 q 676 567 695 567 q 645 558 658 567 q 622 534 631 549 q 606 503 612 520 q 596 468 600 485 q 591 435 593 450 q 590 410 590 420 q 606 329 590 355 q 650 304 621 304 q 677 311 662 304 q 710 330 693 318 m 732 236 q 665 181 699 199 q 598 164 631 164 q 520 180 557 164 q 454 227 483 197 q 407 300 425 257 q 390 397 390 343 q 412 521 390 465 q 472 618 435 578 q 558 681 510 659 q 659 703 607 703 q 715 691 690 703 q 763 659 741 678 q 767 679 766 671 q 769 690 768 686 q 775 696 771 694 q 789 698 780 697 q 861 692 825 692 q 937 691 897 691 l 892 364 q 892 356 892 361 q 892 347 892 351 q 896 313 892 328 q 906 285 899 297 q 921 267 912 273 q 939 260 930 260 q 969 272 953 260 q 999 312 985 284 q 1022 386 1013 340 q 1031 500 1031 432 q 1011 614 1031 559 q 950 710 991 669 q 845 776 909 751 q 696 801 782 801 q 567 780 624 801 q 467 724 510 759 q 394 645 424 690 q 345 555 363 601 q 317 465 326 509 q 308 386 308 420 q 334 243 308 302 q 413 147 361 184 q 543 92 465 109 q 723 75 621 75 q 741 69 734 75 q 747 43 747 63 q 744 14 747 31 q 736 -30 741 -4 q 725 -78 730 -60 q 714 -105 720 -96 q 701 -117 708 -115 q 684 -119 694 -119 q 432 -92 544 -119 q 243 -7 321 -64 q 124 136 165 50 q 82 338 82 222 q 107 525 82 437 q 176 687 132 613 q 282 819 220 760 q 419 918 345 878 q 580 981 494 959 q 756 1002 665 1002 q 950 962 865 1002 q 1094 853 1035 922 q 1183 693 1152 785 q 1213 500 1213 602 q 1191 361 1213 429 q 1129 241 1168 294 q 1040 157 1090 189 q 934 125 989 125 q 826 151 876 125 q 732 236 775 176 z " - }, - "A": { - "ha": 940, - "x_min": 29, - "x_max": 965, - "o": "m 45 50 q 64 89 54 67 q 81 137 73 111 l 100 182 q 75 221 87 200 q 52 265 62 243 q 36 310 42 288 q 29 353 29 332 q 40 356 29 355 q 66 357 50 357 q 101 358 82 358 q 135 359 119 359 q 162 360 151 359 q 172 360 172 360 q 203 437 188 401 q 233 511 218 474 q 262 588 248 549 q 292 671 277 627 q 348 819 321 755 q 399 938 375 883 q 408 950 401 945 q 422 960 414 956 q 436 967 429 964 q 448 971 444 970 q 468 977 450 972 q 509 989 486 983 q 555 1000 532 995 q 591 1004 578 1004 l 604 1004 q 624 999 614 1004 q 637 979 634 994 q 707 797 670 896 q 779 580 744 699 q 817 459 798 516 q 853 348 835 402 q 890 239 871 294 q 928 127 909 185 q 941 89 935 103 q 953 66 947 75 q 962 55 958 58 q 965 47 965 51 q 952 39 965 43 l 806 -9 q 773 -21 790 -15 q 741 -32 756 -27 q 715 -40 726 -37 q 699 -43 704 -43 l 695 -43 q 682 -37 686 -43 q 676 -26 677 -31 q 663 15 669 -3 q 649 51 656 33 q 636 89 643 68 q 624 137 630 109 q 616 143 623 140 q 602 146 610 145 q 584 148 593 148 q 566 149 574 149 q 525 148 541 149 q 496 148 509 148 q 473 147 484 147 q 446 146 462 146 q 405 147 426 146 q 368 148 385 147 l 329 149 q 294 58 311 100 q 256 -31 276 15 q 249 -39 254 -36 q 239 -43 244 -43 q 234 -42 235 -43 q 123 5 168 -18 q 45 50 79 28 m 503 659 q 470 550 486 599 q 441 463 454 500 q 418 398 428 425 q 405 358 409 372 l 405 352 q 404 347 405 348 l 567 347 q 551 414 559 380 q 534 485 543 448 q 518 565 526 522 q 503 659 510 608 z " - }, - "B": { - "ha": 970, - "x_min": 85, - "x_max": 971, - "o": "m 172 9 q 153 19 158 12 q 149 35 149 26 q 149 38 149 37 q 149 41 149 39 q 161 194 155 114 q 175 358 168 275 q 190 524 182 441 q 205 684 197 606 l 204 684 q 189 680 201 684 q 160 670 176 675 q 128 661 144 665 q 102 657 112 657 q 89 664 93 657 q 85 679 85 671 q 87 690 85 685 q 125 789 106 743 q 165 884 145 836 q 272 933 216 912 q 384 967 328 954 q 497 988 441 981 q 606 996 553 996 q 746 980 680 996 q 860 933 811 964 q 936 853 908 901 q 964 741 964 806 q 952 688 964 713 q 921 638 940 662 q 878 595 901 615 q 831 559 854 575 q 889 516 863 535 q 934 475 916 496 q 962 428 952 454 q 971 365 971 402 q 951 256 971 308 q 896 160 931 204 q 813 79 861 115 q 710 18 766 43 q 592 -21 654 -7 q 467 -35 530 -35 q 405 -31 444 -35 q 324 -19 366 -26 q 240 -5 281 -13 q 172 9 199 3 m 484 753 q 463 590 471 673 q 447 430 454 508 q 436 283 441 353 q 427 158 431 213 q 485 161 454 158 q 548 172 517 164 q 609 191 579 179 q 661 220 638 203 q 696 262 683 238 q 710 317 710 286 q 699 351 710 336 q 669 376 687 366 q 629 394 651 387 q 587 405 608 401 q 549 412 566 410 q 523 416 532 414 q 511 422 513 417 q 508 436 508 428 q 519 463 508 445 q 549 511 530 480 l 577 556 q 617 573 595 563 q 656 596 638 583 q 687 626 675 610 q 699 663 699 643 q 675 748 699 718 q 606 777 651 777 q 484 753 554 777 z " - }, - "C": { - "ha": 878, - "x_min": 85, - "x_max": 899, - "o": "m 85 458 q 103 602 85 533 q 155 730 121 671 q 235 839 188 790 q 340 923 282 888 q 467 977 399 958 q 610 996 535 996 q 715 988 670 996 q 794 968 760 980 q 850 942 827 956 q 888 915 873 928 q 887 910 887 915 q 889 873 887 900 q 893 812 890 846 q 897 745 895 779 q 899 686 899 711 q 896 676 899 682 q 882 671 893 671 q 867 673 876 671 q 831 692 853 677 q 781 723 810 707 q 716 751 752 739 q 639 764 681 764 q 538 742 583 764 q 460 681 492 720 q 411 589 429 642 q 393 473 393 536 q 406 367 393 417 q 443 278 418 316 q 504 217 467 240 q 590 195 541 195 q 659 197 629 195 q 714 206 688 200 q 765 222 740 212 q 818 248 789 233 q 825 249 819 249 q 831 245 829 249 q 833 230 833 241 l 833 149 q 832 105 833 126 q 832 66 832 83 q 831 39 831 50 q 830 28 831 28 q 763 -4 799 9 q 690 -23 728 -16 q 614 -33 652 -31 q 541 -35 576 -35 q 362 1 446 -35 q 217 102 279 37 q 121 258 156 168 q 85 458 85 349 z " - }, - "D": { - "ha": 1047, - "x_min": 79, - "x_max": 1055, - "o": "m 116 -35 q 105 -28 109 -34 q 102 -14 102 -22 q 104 -3 102 -8 l 188 156 q 190 177 189 159 q 194 223 192 195 q 198 284 196 250 q 203 351 201 318 q 209 415 206 385 q 213 465 211 445 q 215 490 214 473 q 218 528 216 507 q 221 575 219 550 q 225 625 223 600 l 235 767 q 197 759 216 763 q 158 751 177 754 q 123 745 140 747 q 94 743 106 743 q 83 749 87 743 q 79 764 79 756 q 83 777 79 772 l 256 937 q 297 968 277 956 q 347 987 318 980 q 419 996 376 994 q 526 998 461 998 q 724 975 637 998 q 869 909 810 952 q 948 846 913 879 q 1006 772 983 812 q 1042 683 1030 732 q 1055 574 1055 635 q 1020 368 1055 458 q 926 210 985 277 q 786 96 866 142 q 616 20 707 49 q 429 -22 526 -9 q 239 -35 332 -35 l 116 -35 m 510 781 l 502 699 q 493 608 498 656 q 485 510 489 559 q 477 411 481 460 q 469 321 473 363 q 463 245 466 279 q 458 193 460 212 l 456 172 q 595 199 538 172 q 687 272 652 225 q 738 380 722 318 q 754 515 754 443 q 740 614 754 566 q 699 705 726 662 q 632 770 671 749 q 543 792 593 792 q 526 788 535 792 q 510 781 516 785 z " - }, - "E": { - "ha": 799, - "x_min": 92, - "x_max": 856, - "o": "m 694 563 q 684 536 691 553 q 666 497 676 519 q 645 451 656 475 q 623 401 634 426 q 616 387 619 391 q 605 380 612 382 q 584 378 597 378 q 547 377 571 378 l 453 375 l 434 168 l 782 168 l 782 141 q 770 123 781 140 q 747 83 760 106 q 718 37 733 60 q 693 -1 703 14 q 677 -20 686 -13 q 658 -31 669 -27 q 635 -35 648 -34 q 608 -35 623 -35 q 480 -33 547 -35 q 349 -26 414 -30 q 220 -17 283 -22 q 104 -6 157 -12 q 95 -1 99 -5 q 92 10 92 4 q 95 22 89 10 q 113 52 102 33 q 139 93 125 70 q 165 140 153 117 l 176 293 q 181 351 179 332 q 182 371 182 370 q 122 375 142 372 q 102 390 102 378 q 112 410 102 395 q 136 445 121 425 q 166 485 150 464 q 194 524 182 506 l 211 754 l 209 754 q 182 753 194 753 q 159 753 170 753 q 113 756 127 753 q 99 770 99 760 q 107 790 99 775 q 127 824 115 805 q 153 865 140 844 q 178 905 167 886 l 218 974 l 502 974 l 836 998 q 840 998 837 998 q 846 996 843 998 q 853 990 850 994 q 856 979 856 986 l 846 943 q 834 912 841 928 q 819 878 827 895 l 789 799 q 779 781 785 787 q 753 774 772 775 q 638 770 701 773 q 492 764 574 767 q 490 749 490 755 q 488 727 490 743 l 485 696 q 481 649 484 674 q 474 587 478 624 q 542 590 509 589 q 602 592 574 591 q 649 594 629 593 q 677 595 669 595 q 689 591 682 595 q 696 575 696 587 q 694 563 696 570 z " - }, - "F": { - "ha": 817, - "x_min": 90, - "x_max": 907, - "o": "m 770 557 q 760 528 767 547 q 743 485 752 509 q 722 434 733 461 q 699 382 710 408 q 688 365 694 370 q 662 359 682 359 l 464 355 l 439 54 q 436 42 439 48 q 428 33 433 37 q 412 25 426 32 q 377 10 398 19 q 331 -9 356 1 q 281 -27 306 -19 q 237 -42 257 -36 q 205 -47 216 -47 q 180 -42 191 -47 q 169 -22 169 -37 q 171 53 168 12 q 176 137 173 94 q 184 220 180 179 q 191 295 188 261 l 195 352 q 114 355 138 352 q 90 371 90 358 q 100 394 90 380 q 132 441 114 414 q 166 496 150 469 q 196 543 183 522 q 212 568 208 563 l 224 754 q 202 754 212 754 q 185 753 193 753 q 170 752 177 753 q 156 752 163 752 q 110 756 123 752 q 96 770 96 760 q 104 789 96 774 q 124 824 112 804 q 150 864 136 843 q 174 904 163 886 l 215 973 l 524 984 q 642 988 583 986 q 751 993 701 991 q 837 997 801 995 q 887 999 873 998 q 891 999 888 999 q 897 997 894 998 q 904 991 901 995 q 907 979 907 987 q 897 952 907 975 q 870 884 888 929 l 840 805 q 829 787 836 793 q 804 781 823 781 q 757 779 781 780 q 708 776 733 777 l 502 766 q 496 726 498 739 q 494 705 494 713 q 494 688 494 696 q 493 661 494 680 q 491 640 492 648 q 489 622 490 631 q 487 604 488 614 q 486 581 486 595 q 573 583 530 582 q 653 586 616 585 q 715 588 689 587 q 753 589 742 589 q 765 585 758 589 q 772 570 772 581 q 770 557 772 564 z " - }, - "G": { - "ha": 992, - "x_min": 85, - "x_max": 1027, - "o": "m 85 438 q 103 588 85 516 q 154 721 121 659 q 234 834 187 783 q 340 921 281 884 q 466 977 398 957 q 610 996 534 996 q 714 988 669 996 q 793 969 760 981 q 849 943 827 957 q 887 916 872 928 q 886 911 886 916 q 888 873 886 901 q 892 813 890 846 q 896 746 895 780 q 898 686 898 711 q 895 677 898 682 q 882 672 892 672 q 867 674 876 672 q 831 693 852 678 q 780 723 809 707 q 716 752 751 739 q 638 764 680 764 q 537 741 583 764 q 460 676 492 718 q 410 577 428 634 q 393 452 393 519 q 404 342 393 393 q 436 253 414 290 q 491 193 458 215 q 568 172 524 172 q 665 190 610 172 l 680 286 l 551 286 q 576 414 566 368 q 597 485 587 461 q 616 515 606 509 q 640 521 627 521 l 997 521 q 1020 519 1013 521 q 1027 505 1027 517 q 1025 490 1027 498 q 1022 469 1024 481 l 988 355 q 978 322 982 334 q 968 304 974 310 q 951 297 962 298 q 921 296 941 296 q 908 288 910 296 q 905 269 906 279 q 897 210 901 239 q 889 155 892 180 q 881 110 885 130 q 873 82 877 91 q 789 31 827 53 q 714 -6 751 9 q 635 -28 677 -20 q 541 -35 594 -35 q 361 -1 445 -35 q 217 97 278 34 q 120 246 155 159 q 85 438 85 333 z " - }, - "H": { - "ha": 1010, - "x_min": 55, - "x_max": 1013, - "o": "m 722 893 q 727 927 722 918 q 745 939 731 936 l 978 996 q 996 998 987 998 q 1009 992 1006 998 q 1013 969 1013 987 l 1004 863 q 997 770 1001 816 q 985 689 993 724 l 972 593 q 962 500 967 550 q 952 389 958 450 l 920 54 q 918 42 920 48 q 909 33 916 36 q 887 24 904 31 q 846 9 869 18 q 795 -10 822 0 q 743 -28 768 -20 q 700 -41 719 -36 q 674 -47 681 -47 q 657 -42 665 -47 q 650 -22 650 -37 q 660 145 650 60 q 677 316 669 231 q 678 334 678 326 q 679 351 677 342 l 431 351 l 403 54 q 400 42 402 48 q 391 33 399 37 q 365 23 389 32 q 309 4 340 15 q 247 -19 277 -7 q 199 -36 216 -30 q 179 -43 191 -39 q 156 -47 168 -47 q 139 -41 146 -47 q 132 -22 132 -36 q 135 53 132 11 q 140 140 137 94 q 149 234 144 186 q 158 329 153 282 l 159 349 q 80 352 104 349 q 55 368 55 355 q 65 391 55 376 q 97 436 79 410 q 131 489 115 463 q 161 536 148 515 q 178 563 174 557 l 194 726 q 195 747 194 728 q 199 792 197 766 q 203 846 201 818 q 208 893 205 873 q 211 926 209 917 q 227 939 214 936 l 458 996 q 476 998 467 998 q 489 992 486 998 q 492 969 492 987 q 485 880 488 920 q 479 806 482 840 q 473 740 476 771 q 463 676 469 709 l 450 571 l 696 574 q 709 727 702 664 q 719 827 717 790 q 722 876 721 861 q 722 893 722 891 z " - }, - "I": { - "ha": 453, - "x_min": 94, - "x_max": 450, - "o": "m 94 -22 l 128 442 q 153 785 145 675 q 161 893 161 894 q 163 913 162 905 q 165 927 163 922 q 171 935 168 932 q 181 939 174 938 l 416 996 q 434 998 425 998 q 447 992 444 998 q 450 969 450 987 q 443 890 446 927 q 438 821 440 854 q 435 756 437 787 q 432 695 434 726 q 425 629 428 662 q 419 560 422 595 q 413 485 416 524 q 406 398 410 445 l 376 41 q 374 29 376 35 q 365 20 372 23 q 357 17 364 20 q 337 10 349 14 q 309 1 325 5 q 274 -8 292 -4 q 221 -22 243 -15 q 180 -34 198 -28 q 148 -43 163 -40 q 118 -47 133 -47 q 101 -41 108 -47 q 94 -22 94 -36 z " - }, - "J": { - "ha": 517, - "x_min": 37, - "x_max": 517, - "o": "m 228 893 q 229 913 229 905 q 232 927 230 922 q 237 935 233 932 q 248 939 240 938 l 482 996 q 500 998 491 998 q 513 992 509 998 q 517 969 517 986 l 496 751 l 484 621 q 476 533 480 576 q 468 454 472 490 q 462 390 465 418 q 458 345 459 361 l 456 325 q 427 177 451 248 q 363 53 403 106 q 269 -33 323 -1 q 148 -65 214 -65 q 97 -64 114 -65 q 74 -59 81 -62 q 65 -51 66 -56 q 59 -39 63 -46 l 37 126 q 41 132 37 127 q 48 138 45 136 q 96 159 73 147 q 139 188 120 172 q 169 228 157 205 q 182 281 181 250 l 228 893 z " - }, - "K": { - "ha": 957, - "x_min": 96, - "x_max": 983, - "o": "m 448 970 q 445 938 446 960 q 441 888 444 916 q 437 827 439 859 q 432 765 435 795 q 428 709 430 734 q 424 669 425 684 l 458 705 l 555 824 q 590 868 572 846 q 622 906 608 889 q 644 935 635 924 q 654 948 653 947 l 956 973 q 962 974 957 974 l 967 974 q 983 966 983 974 q 978 955 983 961 q 965 938 974 948 q 933 901 954 925 q 888 848 913 877 q 838 788 864 819 q 789 731 812 758 q 751 686 767 705 q 731 662 735 667 l 688 621 q 577 518 645 580 q 622 471 598 496 q 668 422 646 446 q 708 380 690 399 q 735 351 726 361 l 945 109 q 954 102 948 104 q 964 97 959 99 q 974 93 970 95 q 977 87 977 90 q 968 74 977 83 q 948 58 963 68 q 913 35 933 47 q 870 10 893 23 q 826 -13 847 -3 q 786 -31 804 -24 q 759 -37 768 -37 q 729 -25 745 -37 q 692 13 713 -12 q 640 78 670 39 q 568 170 610 117 q 521 230 544 201 q 477 286 498 260 q 440 333 457 312 q 413 366 424 353 q 401 356 408 361 q 390 345 395 351 l 366 54 q 364 42 366 48 q 355 33 362 36 l 163 -36 q 143 -43 155 -39 q 119 -47 131 -47 q 102 -41 109 -47 q 96 -22 96 -36 q 104 82 99 18 q 115 228 109 146 q 127 406 121 309 q 141 609 134 503 l 160 895 q 161 915 161 907 q 163 928 162 923 q 168 937 165 934 q 178 941 172 939 l 413 997 q 431 1000 422 1000 q 444 994 441 1000 q 448 970 448 988 z " - }, - "L": { - "ha": 693, - "x_min": 57, - "x_max": 719, - "o": "m 454 972 q 452 931 454 956 q 447 881 450 907 q 442 826 445 854 q 436 776 439 799 q 433 736 434 753 q 431 715 431 720 q 426 637 429 673 q 419 566 422 601 q 412 493 416 530 q 404 410 408 455 q 395 309 400 364 q 385 181 390 253 l 665 210 q 696 212 684 212 q 715 207 711 212 q 719 192 719 202 q 718 188 719 191 q 715 179 718 186 q 708 159 713 172 q 696 123 704 146 l 682 79 q 668 40 674 57 q 652 10 661 22 q 628 -10 642 -3 q 591 -20 614 -18 q 553 -22 577 -21 q 496 -24 528 -23 q 428 -26 465 -25 q 352 -30 391 -28 q 275 -32 314 -31 q 202 -33 237 -32 q 138 -34 168 -33 q 90 -35 109 -35 q 65 -33 73 -35 q 57 -24 57 -30 q 62 -2 57 -16 q 74 29 66 12 q 91 65 81 46 q 109 101 100 83 l 127 343 q 138 469 132 405 q 147 592 143 532 l 159 772 q 164 864 163 836 q 165 896 165 893 q 168 916 167 908 q 170 930 168 924 q 175 938 172 935 q 185 942 178 941 l 423 998 q 441 1001 431 1001 q 452 997 449 1001 q 455 980 455 992 q 455 976 455 979 q 454 972 454 974 z " - }, - "M": { - "ha": 1173, - "x_min": 43, - "x_max": 1141, - "o": "m 975 998 q 981 999 978 999 q 987 1000 984 1000 q 1006 992 999 1000 q 1017 964 1014 984 q 1021 930 1018 952 q 1028 881 1024 908 q 1036 826 1031 854 q 1044 773 1040 798 q 1050 732 1047 749 q 1053 710 1053 715 q 1080 517 1068 590 q 1096 410 1091 445 l 1141 43 l 1135 22 q 1117 11 1133 18 q 1078 -4 1101 4 q 1027 -19 1055 -12 q 977 -33 1000 -26 q 938 -42 954 -39 q 922 -46 922 -46 q 896 -22 905 -46 q 880 38 886 1 q 870 118 874 75 q 862 201 867 161 q 854 269 858 235 q 847 338 851 302 l 821 536 l 569 75 q 546 52 557 59 q 524 45 534 45 q 501 54 509 45 q 489 75 492 62 q 467 148 476 118 q 450 201 458 177 q 435 249 442 226 q 420 302 429 272 q 401 373 412 332 q 376 474 391 414 l 355 376 l 257 -38 q 240 -46 255 -46 q 201 -41 226 -46 q 150 -27 176 -35 q 97 -11 123 -20 q 57 4 72 -3 q 48 11 54 5 q 43 26 43 16 q 45 38 43 29 q 51 59 47 47 q 57 83 54 71 q 64 104 61 95 q 80 159 73 127 q 94 222 87 190 q 105 283 100 254 q 115 332 110 312 l 198 721 l 223 831 q 232 872 228 852 q 240 908 237 892 q 245 935 243 924 q 248 946 248 945 l 417 998 q 434 997 427 998 q 443 985 441 995 l 578 551 l 763 941 l 975 998 z " - }, - "N": { - "ha": 935, - "x_min": 102, - "x_max": 909, - "o": "m 672 909 q 682 941 677 931 q 699 955 686 951 l 875 996 q 892 999 883 999 q 905 993 901 999 q 909 970 909 987 q 903 920 905 954 q 899 846 900 886 q 897 766 897 806 q 896 696 896 726 l 896 659 q 895 567 896 616 q 893 467 895 517 q 891 366 892 416 q 888 273 890 317 l 884 157 q 884 151 884 154 q 884 146 884 149 l 884 136 q 884 116 884 124 q 884 102 884 109 q 883 90 884 96 q 878 80 882 85 q 867 69 874 75 q 848 56 860 64 q 825 42 841 51 q 791 21 810 33 q 751 -3 772 9 q 714 -25 731 -15 q 687 -41 697 -35 q 676 -47 676 -47 l 361 437 l 333 41 q 331 29 332 35 q 321 20 329 23 q 300 11 315 17 q 266 -2 286 5 q 223 -17 245 -9 q 182 -32 201 -25 q 147 -42 162 -38 q 126 -46 132 -46 q 109 -41 116 -46 q 102 -21 102 -35 q 118 164 109 64 q 135 369 127 264 q 150 579 143 474 q 162 778 157 684 q 154 796 162 781 q 135 829 145 811 q 116 863 124 847 q 107 883 107 879 q 112 892 107 888 q 129 903 117 896 l 310 1005 q 316 1006 312 1005 q 322 1006 319 1006 q 334 1005 330 1006 q 343 994 338 1003 l 672 401 l 672 909 z " - }, - "O": { - "ha": 1096, - "x_min": 81, - "x_max": 1098, - "o": "m 380 463 q 391 365 380 414 q 426 276 401 315 q 490 212 450 237 q 589 188 530 188 q 669 207 635 191 q 728 248 703 222 q 769 306 753 273 q 795 375 785 339 q 808 450 804 412 q 812 523 812 488 q 799 616 812 571 q 760 696 786 661 q 696 751 734 730 q 607 772 658 772 q 535 758 567 772 q 477 718 503 743 q 434 661 452 693 q 405 594 416 629 q 387 526 393 560 q 380 463 381 492 m 513 -35 q 331 3 411 -35 q 196 105 251 41 q 111 255 140 170 q 81 435 81 340 q 112 632 81 542 q 196 791 142 722 q 325 908 250 861 q 490 979 400 956 q 502 992 498 979 q 510 1021 507 1005 q 518 1049 513 1036 q 532 1062 523 1062 q 768 1016 663 1048 q 947 922 873 983 q 1059 767 1020 861 q 1098 540 1098 674 q 1077 378 1098 454 q 1018 238 1056 302 q 927 123 980 174 q 808 37 873 73 q 668 -17 743 2 q 513 -35 593 -35 z " - }, - "P": { - "ha": 910, - "x_min": 92, - "x_max": 950, - "o": "m 950 705 q 939 600 949 646 q 909 517 928 554 q 862 451 890 480 q 800 395 835 421 q 651 322 732 347 q 489 297 570 297 q 462 298 475 297 q 435 300 449 298 l 413 52 l 401 31 q 378 20 400 28 q 324 1 357 12 l 281 -13 q 245 -26 261 -20 q 216 -37 230 -33 q 190 -44 203 -42 q 163 -47 177 -47 q 148 -42 153 -47 q 142 -24 142 -37 l 150 92 q 155 162 152 127 q 161 241 158 197 l 174 404 q 181 503 178 453 q 188 597 184 552 q 194 681 191 642 q 199 749 197 720 q 140 737 162 741 q 106 733 118 733 q 92 745 92 733 q 110 810 102 779 q 125 866 117 838 q 138 915 133 895 q 146 933 142 927 q 158 944 151 940 q 176 950 165 947 q 203 959 187 954 q 240 968 216 963 q 293 978 263 973 q 359 988 323 983 q 430 997 394 993 q 502 1003 467 1000 q 568 1005 537 1005 q 715 991 646 1005 q 836 942 784 977 q 919 850 888 908 q 950 705 950 792 m 454 501 q 457 488 454 494 q 472 482 460 482 q 517 491 491 482 q 569 516 543 499 q 618 558 595 533 q 652 617 640 583 q 660 652 656 631 q 663 701 663 673 q 630 771 663 749 q 544 793 597 793 q 524 792 535 793 q 503 789 513 791 q 486 782 493 786 q 479 772 479 779 l 477 758 q 475 729 477 749 q 470 683 473 709 q 466 629 468 657 q 461 574 463 600 q 457 529 458 549 q 454 501 455 509 z " - }, - "Q": { - "ha": 1096, - "x_min": 81, - "x_max": 1100, - "o": "m 513 -35 q 331 3 411 -35 q 196 105 251 41 q 111 255 140 170 q 81 435 81 340 q 112 632 81 542 q 196 791 142 722 q 325 908 250 861 q 490 979 400 956 q 502 990 498 979 q 508 1014 505 1000 q 514 1041 511 1028 q 524 1059 517 1054 q 844 985 763 1027 q 918 943 886 964 q 975 897 949 922 q 1020 839 1000 871 q 1061 761 1040 806 q 1092 643 1082 713 l 1093 635 q 1098 580 1096 609 q 1100 518 1100 551 q 1062 306 1100 401 q 956 140 1023 212 q 989 102 974 120 q 1017 71 1005 85 q 1035 46 1028 56 q 1042 31 1042 35 q 1030 13 1042 23 q 1000 -10 1018 2 q 961 -35 982 -22 q 922 -56 940 -47 q 890 -72 903 -66 q 876 -78 878 -78 q 866 -75 871 -78 q 859 -68 862 -72 l 775 15 q 657 -22 718 -9 q 529 -35 597 -35 l 513 -35 m 384 463 q 393 369 384 416 q 422 282 401 323 q 423 281 423 281 q 488 214 448 239 q 589 188 528 188 l 603 189 l 595 199 q 569 230 579 216 q 559 250 559 243 q 578 273 559 263 l 736 353 q 743 355 740 355 q 755 345 748 355 q 777 321 763 336 q 804 420 795 366 q 812 523 812 474 q 786 653 812 596 q 695 749 760 711 q 649 768 673 762 q 594 773 624 773 q 540 763 564 773 q 495 736 515 752 q 459 700 475 720 q 431 664 443 681 q 409 621 418 646 q 394 567 400 595 q 386 511 389 539 q 384 463 384 484 z " - }, - "R": { - "ha": 999, - "x_min": 83, - "x_max": 1026, - "o": "m 446 54 q 444 42 446 48 q 435 33 442 37 q 408 23 432 32 q 352 4 384 15 q 290 -19 321 -7 q 243 -36 259 -30 q 223 -43 235 -39 q 199 -47 211 -47 q 183 -42 190 -47 q 176 -24 176 -37 q 177 30 176 5 q 182 82 179 55 q 188 142 184 109 q 193 220 191 175 q 201 335 197 280 q 209 450 205 391 l 218 566 q 222 624 220 595 q 227 685 224 654 l 234 768 q 230 769 234 769 q 212 767 224 769 q 181 761 199 764 q 142 754 163 758 q 98 747 121 750 q 88 749 93 747 q 83 755 83 751 q 84 759 83 758 l 194 951 q 274 967 231 959 q 367 983 317 976 q 472 994 416 989 q 590 998 528 998 q 727 984 661 997 q 846 942 794 972 q 929 862 898 913 q 961 734 961 812 q 946 656 961 692 q 909 591 932 620 q 859 540 886 562 q 807 503 832 518 q 764 478 783 487 q 738 466 745 469 q 739 463 738 465 q 743 455 740 460 q 753 438 747 449 q 770 410 760 428 q 795 366 781 393 q 831 302 810 339 q 879 220 852 265 q 941 122 906 174 q 968 110 953 112 q 996 107 983 107 q 1017 105 1008 106 q 1026 97 1026 104 q 1015 84 1026 92 q 989 70 1004 77 q 959 56 974 62 q 935 45 943 49 q 901 29 919 37 q 863 13 884 22 q 818 -9 843 3 q 762 -38 793 -21 q 747 -44 754 -43 q 734 -46 740 -46 q 713 -40 722 -46 q 698 -26 704 -35 q 688 -10 692 -18 q 682 4 684 -1 l 479 430 l 446 54 m 488 513 q 559 531 522 513 q 627 576 597 549 q 677 640 658 604 q 697 711 697 675 q 579 809 697 809 q 542 806 557 809 q 515 802 527 803 l 488 513 z " - }, - "S": { - "ha": 745, - "x_min": 106, - "x_max": 732, - "o": "m 107 252 q 107 254 107 253 q 106 255 106 254 q 119 267 106 267 q 132 260 125 267 q 214 205 169 226 q 311 185 258 185 q 344 188 326 185 q 378 198 362 191 q 406 217 395 205 q 417 246 417 229 q 408 281 417 266 q 382 308 398 297 q 364 321 376 312 q 336 343 352 331 q 304 369 321 355 q 272 396 287 383 q 244 418 256 408 q 226 434 232 429 q 162 494 186 464 q 127 558 139 525 q 111 627 115 591 q 108 703 108 663 q 136 816 108 762 q 217 909 165 869 q 341 972 269 949 q 503 996 414 996 q 535 993 513 996 q 583 985 557 991 q 636 970 609 980 q 686 946 663 961 q 697 935 693 941 q 703 918 702 930 q 709 810 707 863 q 714 697 711 757 q 709 682 714 686 q 697 678 705 678 q 686 682 690 678 q 645 721 666 702 q 601 754 624 740 q 552 778 578 769 q 495 787 526 787 q 458 784 477 787 q 425 772 440 781 q 401 750 410 764 q 392 714 392 736 q 398 674 392 691 q 427 642 404 657 l 589 532 q 662 468 634 500 q 705 406 690 437 q 727 344 721 374 q 732 285 732 314 q 717 195 732 237 q 674 118 701 153 q 611 54 647 82 q 533 6 574 26 q 447 -25 492 -14 q 360 -35 403 -35 q 295 -34 327 -35 q 232 -29 262 -33 q 173 -15 201 -24 q 119 10 144 -6 l 107 252 z " - }, - "T": { - "ha": 786, - "x_min": 58, - "x_max": 886, - "o": "m 243 -22 q 250 74 246 28 q 256 163 253 120 l 280 484 q 287 550 284 520 q 291 609 290 581 q 295 668 293 638 q 298 733 296 697 q 251 734 276 734 q 199 734 227 734 l 68 734 q 59 740 61 734 q 58 750 58 745 l 58 755 l 132 951 l 132 954 q 136 959 132 957 q 156 963 140 962 q 337 974 250 968 q 511 983 425 979 q 683 991 597 987 q 859 998 768 995 q 877 996 867 998 q 886 981 886 994 q 885 979 886 980 q 884 976 884 977 q 864 923 873 948 q 846 873 855 898 q 828 824 838 849 q 808 771 819 799 q 806 765 808 770 q 800 752 804 759 q 789 739 795 745 q 772 732 782 732 q 765 732 768 732 q 758 732 762 732 l 576 732 q 570 659 573 698 q 563 584 567 621 l 513 54 q 511 42 513 48 q 502 33 509 36 l 310 -36 q 290 -43 302 -39 q 267 -47 278 -47 q 250 -42 257 -47 q 243 -24 243 -37 l 243 -22 z " - }, - "U": { - "ha": 935, - "x_min": 103, - "x_max": 937, - "o": "m 937 970 q 932 916 935 951 q 924 835 928 880 q 915 741 920 790 q 906 646 910 691 q 898 564 901 601 q 893 509 895 528 q 845 261 879 365 q 755 92 810 158 q 622 -4 699 26 q 442 -35 544 -35 q 311 -10 372 -35 q 203 62 249 16 q 130 173 157 108 q 103 317 103 237 q 105 354 103 327 q 110 419 106 380 q 116 507 113 458 q 124 612 120 556 l 132 724 q 138 827 136 786 q 143 893 140 868 q 150 930 145 918 q 165 945 155 941 l 396 996 q 414 999 405 999 q 429 993 425 999 q 433 970 433 987 l 381 435 q 376 384 380 412 q 373 327 373 356 q 377 288 373 309 q 393 249 382 267 q 425 217 405 230 q 477 205 445 205 q 539 221 515 205 q 577 266 563 238 q 598 328 591 293 q 608 399 604 363 q 616 500 612 442 q 626 623 621 557 l 646 894 q 647 914 647 906 q 649 928 648 922 q 655 936 650 933 q 669 940 659 939 l 900 996 q 918 999 909 999 q 932 993 928 999 q 937 970 937 987 z " - }, - "V": { - "ha": 885, - "x_min": 94, - "x_max": 962, - "o": "m 596 60 q 590 43 593 51 q 582 28 587 35 q 570 16 577 21 q 552 7 563 10 q 467 -17 509 -7 q 382 -41 425 -26 q 368 -45 374 -43 q 357 -46 362 -46 q 339 -40 345 -46 q 331 -24 334 -34 l 99 898 q 94 927 94 916 q 103 952 94 942 q 134 968 113 962 q 189 980 155 975 q 271 992 222 985 q 311 997 295 996 q 339 999 328 999 q 365 992 359 999 q 377 972 372 986 l 507 412 l 689 927 q 696 945 693 938 q 708 957 699 951 q 733 967 716 962 q 783 979 751 972 q 867 994 834 989 q 921 999 901 999 q 955 993 947 999 q 962 975 962 987 q 961 965 963 970 q 956 953 958 960 l 596 60 z " - }, - "W": { - "ha": 1242, - "x_min": 80, - "x_max": 1301, - "o": "m 1052 920 q 1059 940 1055 932 q 1078 951 1063 948 l 1278 998 q 1281 998 1279 998 q 1284 999 1283 999 q 1298 991 1294 999 q 1301 975 1301 983 q 1301 970 1301 974 q 1300 964 1301 966 l 1019 111 q 1001 66 1008 83 q 987 38 994 49 q 971 19 980 26 q 946 4 962 12 q 908 -13 931 -3 q 850 -40 885 -23 q 831 -46 838 -46 q 814 -38 820 -46 q 806 -20 809 -30 l 690 393 l 545 94 q 529 73 541 86 q 502 45 517 59 q 471 17 486 31 q 446 -4 456 4 q 428 -19 437 -12 q 408 -33 418 -26 q 388 -42 397 -39 q 371 -46 379 -46 q 348 -26 353 -46 l 85 901 q 82 912 83 907 q 80 922 80 918 q 88 951 80 939 q 117 970 96 962 q 171 984 137 979 q 257 992 205 989 q 298 997 281 996 q 326 998 315 998 q 352 992 346 998 q 363 972 358 986 l 503 434 l 618 633 l 572 838 q 568 862 568 854 q 576 887 568 878 q 604 903 585 897 q 653 913 623 909 q 729 924 684 918 q 763 928 749 927 q 787 930 777 930 q 815 924 808 930 q 826 904 823 918 l 918 486 l 1052 920 z " - }, - "X": { - "ha": 844, - "x_min": 56, - "x_max": 880, - "o": "m 302 978 q 308 979 308 979 l 314 979 q 336 971 326 979 q 358 945 347 964 q 379 905 366 931 q 410 848 393 878 q 442 786 426 817 q 471 733 458 755 l 583 927 l 852 981 q 858 982 855 982 q 865 983 861 983 q 880 971 880 983 q 878 961 880 967 q 872 947 876 954 l 749 728 l 701 644 q 654 566 679 608 q 608 486 629 524 q 630 447 620 466 q 649 412 641 428 q 664 385 658 397 q 673 368 669 374 l 838 55 l 836 30 q 827 22 836 28 q 803 9 818 16 q 770 -7 789 1 q 731 -22 751 -15 l 683 -38 q 664 -42 674 -38 q 642 -47 653 -47 q 624 -42 632 -47 q 606 -24 615 -38 q 572 28 591 -2 q 531 98 553 59 l 456 230 l 349 49 l 328 28 q 316 22 328 26 q 286 11 304 18 q 244 -3 267 5 q 198 -17 221 -10 q 155 -30 176 -24 q 120 -39 134 -35 q 97 -43 112 -39 q 70 -47 81 -47 q 60 -44 64 -47 q 56 -37 56 -42 q 62 -16 56 -31 q 78 19 68 -1 q 101 63 88 39 q 126 111 113 87 q 151 156 139 134 q 172 194 163 178 q 243 326 205 258 l 320 465 l 84 886 q 77 909 77 897 q 83 919 77 917 l 302 978 z " - }, - "Y": { - "ha": 756, - "x_min": 73, - "x_max": 861, - "o": "m 81 903 q 95 910 85 906 q 118 920 104 915 q 146 932 131 926 q 177 945 161 939 l 256 976 q 272 980 264 980 q 284 977 277 980 q 298 966 290 974 l 455 662 l 459 672 l 526 796 q 552 842 539 819 q 574 882 564 864 q 591 910 584 899 q 599 921 597 921 l 831 979 q 845 981 840 981 q 861 967 861 981 q 859 958 860 964 q 855 945 859 952 l 656 576 q 626 520 641 548 q 596 468 610 492 q 571 422 582 443 q 553 389 559 402 l 548 367 l 510 113 q 507 94 508 101 q 503 81 505 86 q 497 73 500 77 q 486 66 493 70 l 294 -35 q 271 -43 283 -40 q 248 -47 259 -47 q 229 -42 237 -47 q 220 -25 220 -37 l 220 -22 q 230 67 223 16 q 245 168 237 119 l 283 419 q 255 480 273 442 q 217 562 237 518 q 175 653 197 606 q 133 742 153 700 q 99 815 114 783 q 76 862 83 847 q 73 883 73 872 q 74 895 73 889 q 81 903 76 901 z " - }, - "Z": { - "ha": 847, - "x_min": 70, - "x_max": 854, - "o": "m 139 0 q 123 2 131 0 q 108 8 115 3 q 97 20 101 12 q 92 41 92 28 q 93 43 92 42 q 94 46 94 45 l 447 666 q 432 670 447 668 q 395 672 418 671 q 345 674 372 673 q 293 676 318 675 q 249 676 269 676 q 223 677 230 677 q 155 676 186 677 q 88 675 123 675 q 75 680 81 675 q 70 692 70 685 q 71 693 71 692 q 71 697 71 695 l 159 907 q 177 931 165 922 q 206 945 190 940 q 240 952 222 950 q 276 954 258 954 q 422 950 350 954 q 565 944 494 947 q 708 938 637 941 q 853 935 780 935 l 853 907 l 523 290 q 523 288 523 288 q 522 286 522 288 q 529 278 522 279 q 541 277 536 277 l 675 277 q 754 282 716 277 q 833 287 792 287 q 848 282 841 287 q 854 269 854 277 q 853 263 854 270 l 744 46 q 724 20 739 30 q 689 6 709 11 q 643 0 668 1 q 591 -1 618 -1 q 375 -1 485 -1 q 139 0 266 0 z " - }, - "[": { - "ha": 545, - "x_min": 85, - "x_max": 616, - "o": "m 153 897 q 157 922 154 913 q 165 936 161 931 q 174 942 169 941 q 182 944 178 943 l 597 983 q 601 983 597 983 q 607 981 604 983 q 613 975 610 979 q 616 964 616 971 q 607 929 616 960 q 580 852 597 898 l 550 774 q 542 759 547 764 q 524 750 537 753 q 488 745 511 747 q 422 739 464 743 q 418 697 421 730 q 410 616 414 664 q 400 513 406 569 q 388 401 394 456 l 365 120 l 496 121 q 504 114 504 121 q 502 104 504 110 q 496 94 499 99 q 489 75 495 92 q 474 35 482 58 q 456 -11 465 12 q 441 -49 447 -35 q 418 -72 431 -66 q 389 -77 406 -77 q 367 -76 378 -77 q 342 -74 355 -75 q 278 -71 311 -72 q 213 -67 245 -69 q 151 -63 181 -66 q 96 -54 121 -60 q 86 -46 88 -53 q 85 -31 85 -39 q 86 -2 85 -28 q 91 65 88 24 q 98 161 94 107 q 106 273 102 214 q 115 393 111 332 q 124 509 120 454 l 153 897 z " - }, - "\\": { - "ha": 742, - "x_min": 111, - "x_max": 719, - "o": "m 456 640 q 532 473 498 549 q 596 329 566 397 q 655 198 627 261 q 715 68 684 134 q 719 56 719 60 q 710 40 719 47 q 691 28 702 33 q 668 19 680 23 q 652 14 657 16 l 584 -15 q 566 -20 574 -20 q 554 -11 556 -20 q 547 10 551 -1 l 112 969 q 111 971 111 970 q 115 977 111 975 q 122 980 118 979 q 194 1004 158 987 q 266 1036 229 1021 l 270 1036 q 284 1028 279 1036 q 298 1001 290 1021 q 377 819 339 908 q 456 640 415 729 z " - }, - "]": { - "ha": 547, - "x_min": 20, - "x_max": 542, - "o": "m 470 1 q 465 -24 469 -15 q 458 -38 462 -33 q 449 -44 454 -43 q 441 -46 445 -45 l 258 -52 q 187 -55 222 -54 q 122 -57 152 -56 q 71 -58 92 -58 q 40 -58 49 -58 q 36 -58 39 -58 q 30 -56 33 -58 q 23 -50 26 -54 q 20 -39 20 -46 q 27 -11 20 -37 q 50 61 34 16 l 73 131 q 84 149 77 142 q 110 155 90 155 l 215 159 q 217 182 216 165 q 220 224 218 199 q 224 281 222 250 q 229 349 227 313 q 235 422 232 385 q 241 496 238 460 l 261 778 l 130 777 q 121 780 123 777 q 119 789 119 783 q 120 796 119 792 q 120 804 120 800 q 120 821 120 806 q 121 858 121 837 q 122 900 121 878 q 122 933 122 921 q 133 961 122 955 q 161 967 143 967 q 185 966 172 967 q 212 965 198 965 l 531 965 q 541 957 539 965 q 542 943 542 949 q 541 925 542 939 q 539 893 541 911 q 537 852 538 874 q 533 812 535 831 q 530 763 532 795 q 524 690 528 730 q 517 606 521 650 q 510 521 513 562 q 503 445 506 479 q 499 389 500 410 l 470 1 z " - }, - "^": { - "ha": 807, - "x_min": 28, - "x_max": 768, - "o": "m 507 62 q 496 98 503 73 q 481 153 490 122 q 463 216 472 183 q 446 279 454 250 q 432 329 437 308 q 424 358 426 351 l 267 60 q 250 52 264 52 q 199 62 226 58 q 145 69 172 66 q 90 74 117 72 q 37 78 62 76 q 28 87 28 80 q 39 119 28 95 q 92 219 64 167 q 147 324 119 271 q 202 427 175 376 q 252 522 229 478 q 296 602 276 566 q 332 659 317 637 q 335 664 332 661 q 341 667 338 667 l 346 668 q 347 668 347 668 q 349 667 348 667 q 457 658 404 661 q 562 654 511 655 q 572 652 568 654 q 580 646 576 650 q 587 635 584 642 q 594 617 590 628 l 765 145 q 767 133 766 138 q 768 123 768 127 q 753 102 768 107 q 637 83 696 93 q 522 58 579 73 q 513 57 517 57 q 507 62 508 57 z " - }, - "_": { - "ha": 706, - "x_min": 14, - "x_max": 672, - "o": "m 113 -39 q 37 -36 60 -39 q 14 -23 14 -33 q 18 -6 14 -18 q 30 18 22 5 q 47 46 37 31 q 67 72 56 60 q 89 92 78 84 q 111 100 100 100 l 349 107 q 383 107 359 107 q 439 108 408 108 q 505 109 471 109 q 568 110 538 110 q 617 111 597 111 q 640 111 637 111 q 656 108 648 111 q 667 101 662 105 q 672 87 672 96 q 670 61 672 79 q 665 26 668 43 l 659 -20 q 653 -31 658 -27 q 626 -35 648 -35 l 519 -35 q 474 -35 498 -35 q 428 -36 451 -35 q 385 -36 406 -36 q 347 -36 363 -36 l 113 -39 z " - }, - "`": { - "ha": 380, - "x_min": 17, - "x_max": 341, - "o": "m 117 968 q 90 1015 101 996 q 70 1051 79 1034 q 50 1087 60 1068 q 24 1135 39 1107 q 19 1149 20 1143 q 17 1162 18 1156 q 20 1174 17 1169 q 31 1181 24 1178 q 83 1210 56 1196 q 138 1240 111 1225 q 194 1272 166 1255 q 246 1305 221 1288 q 256 1309 253 1309 q 261 1303 260 1309 l 337 907 q 340 892 338 898 q 341 881 341 886 q 339 869 341 875 q 330 861 337 864 q 304 849 316 854 q 280 838 292 844 q 255 825 268 832 q 225 808 241 819 q 218 806 222 806 q 204 815 212 806 q 185 843 197 824 q 158 893 174 863 q 117 968 141 924 z " - }, - "a": { - "ha": 846, - "x_min": 71, - "x_max": 844, - "o": "m 774 136 q 773 131 773 134 q 773 127 773 129 q 779 99 773 110 q 790 80 784 87 q 802 69 797 73 q 808 61 808 64 q 787 43 808 52 l 605 -35 q 600 -35 604 -35 q 589 -26 595 -35 q 579 -2 584 -16 q 569 30 574 13 q 562 60 565 46 q 469 -12 519 11 q 371 -35 420 -35 q 260 -10 314 -35 q 163 61 205 15 q 96 174 121 108 q 71 321 71 239 q 99 498 71 418 q 175 636 127 578 q 287 725 223 694 q 423 757 351 757 q 519 736 474 757 q 606 683 565 715 q 610 715 610 703 q 613 734 611 728 q 623 744 616 741 q 645 747 629 746 q 742 760 694 754 q 844 768 791 766 l 774 136 m 571 392 q 580 465 578 431 q 584 528 583 499 q 561 545 573 536 q 533 561 548 553 q 503 574 519 569 q 469 578 487 578 q 408 555 433 578 q 368 496 383 531 q 346 423 353 462 q 340 355 340 385 q 368 198 340 248 q 446 148 396 148 q 492 159 467 148 q 543 191 517 171 l 571 392 z " - }, - "b": { - "ha": 895, - "x_min": 79, - "x_max": 888, - "o": "m 368 221 q 387 194 374 208 q 416 168 399 180 q 452 150 433 157 q 493 142 472 142 q 548 165 522 142 q 593 226 574 188 q 623 314 612 264 q 634 416 634 363 q 628 477 634 448 q 610 528 623 507 q 579 563 598 550 q 532 576 559 576 q 452 550 488 576 q 390 484 415 524 l 368 221 m 115 -33 q 100 -35 106 -35 q 79 -9 79 -35 q 79 -3 79 -6 q 80 5 79 1 l 159 964 q 159 968 159 966 q 159 972 159 970 q 159 977 159 975 q 159 980 159 979 q 163 990 159 986 q 186 998 168 994 l 376 1044 q 396 1050 384 1045 q 420 1055 408 1055 q 436 1050 429 1055 q 444 1035 444 1046 q 444 1032 444 1034 q 444 1029 444 1031 q 440 1000 443 1026 q 434 936 437 973 q 427 855 431 898 q 419 774 422 812 q 413 710 416 736 q 410 680 410 684 q 512 735 459 713 q 618 757 565 757 q 739 728 688 757 q 823 651 789 699 q 872 541 856 604 q 888 412 888 479 q 878 305 888 359 q 849 201 868 251 q 803 109 831 152 q 738 33 774 65 q 657 -17 702 1 q 560 -35 612 -35 q 445 -7 497 -35 q 348 64 393 20 q 346 39 347 48 q 341 24 345 29 q 330 16 338 19 q 308 9 323 13 q 282 3 300 7 q 237 -7 263 -1 q 179 -20 211 -13 q 115 -33 148 -26 z " - }, - "c": { - "ha": 714, - "x_min": 68, - "x_max": 736, - "o": "m 68 331 q 101 497 68 420 q 192 633 134 575 q 329 724 250 690 q 500 757 408 757 q 608 747 564 757 q 682 724 653 736 q 723 701 710 711 q 736 690 736 690 q 733 667 736 686 q 727 624 730 648 q 720 573 723 599 q 717 528 717 547 q 715 520 717 524 q 704 516 713 516 q 680 522 696 516 q 642 534 665 528 q 590 547 619 541 q 524 553 560 553 q 444 537 479 553 q 382 493 408 521 q 342 426 356 465 q 328 342 328 387 q 343 263 328 296 q 382 209 357 230 q 438 179 406 189 q 505 170 470 170 q 587 181 546 170 q 665 212 629 192 q 671 213 667 213 q 676 210 674 213 q 677 197 677 206 q 677 144 677 175 q 677 85 677 113 q 676 37 677 57 q 675 18 675 18 q 622 -9 650 1 q 563 -25 593 -19 q 503 -33 533 -31 q 444 -35 472 -35 q 296 -9 364 -35 q 177 66 227 18 q 97 181 126 114 q 68 331 68 249 z " - }, - "d": { - "ha": 901, - "x_min": 71, - "x_max": 920, - "o": "m 595 386 q 599 431 597 408 q 605 481 602 455 q 561 547 589 522 q 490 572 532 572 q 418 548 448 572 q 372 489 389 524 q 346 415 354 454 q 338 346 338 376 q 343 273 338 309 q 357 208 347 237 q 383 161 367 179 q 424 143 399 143 q 521 170 484 145 q 581 231 558 195 l 595 386 m 831 68 q 831 65 831 67 q 831 62 831 64 q 831 57 831 59 q 831 53 831 55 q 827 43 831 47 q 804 35 823 39 l 623 -24 q 603 -31 615 -27 q 579 -35 591 -35 q 563 -31 570 -35 q 555 -13 555 -26 q 556 7 555 -1 q 556 21 556 14 q 558 35 557 27 q 560 54 559 42 q 455 -11 509 14 q 342 -35 401 -35 q 226 -4 277 -35 q 141 78 176 26 q 89 197 106 130 q 71 336 71 264 q 101 508 71 431 q 185 641 132 586 q 309 727 238 696 q 458 757 379 757 q 540 734 501 757 q 614 677 579 712 q 618 749 616 710 q 624 828 621 788 q 629 908 627 869 q 634 980 632 947 q 638 990 634 986 q 661 998 643 994 l 852 1044 q 871 1050 859 1045 q 895 1055 884 1055 q 912 1050 904 1055 q 920 1035 920 1046 q 919 1029 920 1034 q 919 1023 919 1025 l 831 68 z " - }, - "e": { - "ha": 774, - "x_min": 68, - "x_max": 771, - "o": "m 486 757 q 603 733 550 757 q 693 670 655 709 q 751 585 730 632 q 771 490 771 537 q 745 405 771 448 q 673 329 720 363 q 562 274 627 295 q 418 253 496 253 q 333 261 378 253 q 350 211 336 232 q 386 176 364 190 q 435 156 408 163 q 492 150 463 150 q 554 156 524 150 q 612 171 585 161 q 666 192 640 180 q 715 215 692 203 q 725 217 721 216 q 734 218 730 218 q 733 208 734 218 q 733 177 733 197 q 733 130 733 157 q 732 68 732 102 q 734 61 734 64 q 735 56 735 58 q 720 38 735 47 q 681 18 705 28 q 626 -1 657 8 q 564 -19 595 -11 q 502 -31 532 -26 q 450 -35 472 -35 q 308 -10 376 -35 q 185 63 239 16 q 100 178 132 111 q 68 331 68 246 q 99 497 68 420 q 185 633 130 575 q 317 724 240 690 q 486 757 393 757 m 477 576 q 426 565 450 576 q 384 531 403 553 q 350 478 364 509 q 327 410 336 447 q 443 435 397 422 q 517 463 489 449 q 556 491 545 477 q 568 517 568 505 q 558 541 568 530 q 536 559 549 551 q 506 572 522 568 q 477 576 490 576 z " - }, - "f": { - "ha": 617, - "x_min": 47, - "x_max": 783, - "o": "m 157 -10 q 160 22 158 -3 q 166 85 163 47 q 174 172 170 123 q 184 278 178 221 q 195 396 189 334 q 207 521 201 458 l 117 521 q 64 524 80 521 q 47 536 47 527 q 54 551 47 539 q 72 579 61 563 q 94 615 82 596 q 118 651 106 634 q 137 680 129 667 q 147 694 145 692 l 230 694 l 243 802 q 278 946 253 888 q 339 1040 302 1004 q 424 1092 376 1076 q 526 1107 471 1107 q 638 1094 580 1107 q 757 1058 697 1081 q 776 1049 770 1053 q 783 1039 783 1045 q 778 1025 783 1034 q 746 957 756 983 q 729 916 735 931 q 719 896 723 901 q 707 891 715 891 q 698 893 703 891 q 688 898 694 895 q 640 914 664 907 q 594 921 616 921 q 542 902 564 921 q 507 830 519 883 q 494 764 499 800 q 486 694 490 729 l 663 694 q 674 691 669 694 q 679 678 679 687 q 671 654 679 675 q 648 599 663 633 l 623 544 q 613 529 618 534 q 593 523 608 524 l 475 523 q 461 383 468 452 q 448 253 454 314 q 437 145 442 193 q 430 73 433 98 q 429 65 429 71 q 430 60 429 62 q 430 57 430 58 q 426 47 430 51 q 403 39 421 43 l 224 -24 q 205 -31 217 -27 q 181 -35 193 -35 q 163 -30 170 -35 q 157 -10 157 -24 z " - }, - "g": { - "ha": 878, - "x_min": 69, - "x_max": 871, - "o": "m 576 484 q 557 515 569 499 q 530 545 545 532 q 496 567 514 559 q 457 576 477 576 q 405 553 429 576 q 362 491 380 530 q 333 404 344 453 q 323 302 323 355 q 329 240 323 269 q 347 190 334 212 q 378 155 359 168 q 425 142 397 142 q 499 168 465 142 q 557 234 533 193 q 559 268 557 248 q 562 316 560 288 q 567 382 564 344 q 575 473 570 420 l 576 484 m 800 74 q 770 -52 793 7 q 710 -158 746 -110 q 627 -245 673 -207 q 529 -310 581 -283 q 422 -350 477 -336 q 313 -364 367 -364 q 255 -362 285 -364 q 197 -354 225 -360 q 142 -338 168 -349 q 96 -311 117 -328 l 96 -311 q 101 -287 96 -307 q 114 -239 106 -267 q 129 -182 121 -212 q 142 -132 136 -153 q 147 -119 144 -123 q 153 -116 150 -116 q 158 -117 157 -116 q 195 -138 178 -130 q 232 -152 212 -146 q 274 -159 251 -157 q 328 -161 297 -161 q 412 -142 375 -161 q 475 -95 448 -124 q 517 -31 501 -66 q 539 38 533 4 q 440 -15 490 5 q 339 -35 390 -35 q 218 -7 269 -35 q 134 68 168 21 q 85 177 101 116 q 69 306 69 239 q 79 413 69 359 q 108 517 89 467 q 156 611 127 567 q 222 687 184 654 q 304 738 259 720 q 404 757 350 757 q 512 731 462 757 q 602 667 562 705 q 604 687 604 680 q 608 698 605 694 q 617 704 610 702 q 635 709 623 706 q 663 714 643 710 q 709 725 682 719 q 769 738 736 731 q 835 752 802 745 q 850 754 843 754 q 871 727 871 754 q 871 721 871 724 q 870 714 871 718 l 800 74 z " - }, - "h": { - "ha": 901, - "x_min": 81, - "x_max": 878, - "o": "m 159 986 q 158 994 159 990 q 158 1000 158 997 q 163 1011 158 1006 q 186 1020 168 1015 l 376 1065 q 396 1072 384 1067 q 420 1076 408 1076 q 444 1055 444 1076 q 441 1027 444 1053 q 436 961 439 1000 q 429 875 433 922 q 420 787 425 829 q 413 713 416 745 q 408 672 410 682 q 474 705 439 690 q 544 732 509 721 q 613 750 578 744 q 681 757 648 757 q 758 745 722 757 q 821 706 794 733 q 863 634 848 678 q 878 525 878 589 q 878 491 878 509 q 875 456 877 474 l 846 178 q 842 119 842 150 q 841 56 841 88 q 841 46 841 50 q 842 40 842 43 q 837 31 842 34 q 814 22 831 27 l 648 -24 q 628 -31 640 -26 q 604 -35 616 -35 q 587 -30 593 -35 q 581 -10 581 -25 q 588 72 585 41 q 593 122 591 103 q 596 150 595 140 q 598 168 597 160 q 600 185 599 176 q 603 214 602 195 q 608 264 605 233 q 616 347 611 296 q 622 400 618 374 q 625 450 625 427 q 622 502 625 478 q 611 542 618 525 q 589 568 603 558 q 555 577 576 577 q 512 570 539 577 q 459 548 486 564 q 411 507 432 532 q 388 444 391 481 q 379 359 382 392 q 374 304 376 326 q 371 269 372 282 q 370 245 370 256 q 368 229 369 242 q 364 197 366 216 q 360 158 362 179 q 356 119 358 138 q 354 88 355 101 q 353 71 353 75 q 353 62 353 66 q 353 55 353 58 q 348 46 353 50 q 326 37 343 42 l 149 -24 q 129 -31 141 -27 q 105 -35 117 -35 q 88 -30 95 -35 q 81 -10 81 -24 l 159 986 z " - }, - "i": { - "ha": 415, - "x_min": 73, - "x_max": 439, - "o": "m 99 288 q 117 471 108 380 q 132 658 125 562 q 137 689 134 680 q 152 700 140 697 q 273 724 210 711 q 395 756 336 736 q 401 757 397 757 q 408 751 408 757 l 347 91 q 342 60 345 68 q 328 49 340 52 q 211 9 270 31 q 86 -35 152 -12 q 80 -35 84 -35 q 73 -28 73 -35 q 74 -10 73 -28 q 78 35 75 7 q 83 98 80 63 q 89 167 85 132 q 94 233 92 201 q 99 288 97 265 m 150 829 q 153 873 152 858 q 155 897 154 889 q 155 907 155 905 q 156 910 155 909 q 156 914 156 911 q 157 927 157 917 q 159 956 158 937 q 163 1008 161 975 q 168 1039 165 1030 q 183 1050 171 1047 q 304 1074 241 1061 q 426 1106 367 1086 q 432 1107 428 1107 q 437 1101 434 1103 l 439 1100 l 425 914 q 419 883 422 892 q 405 872 416 874 q 288 848 347 861 q 163 823 229 836 q 157 822 161 822 q 150 829 150 822 z " - }, - "j": { - "ha": 420, - "x_min": -193, - "x_max": 441, - "o": "m 152 829 q 155 873 154 858 q 157 897 156 889 q 157 907 157 905 q 158 910 157 909 q 158 914 158 911 q 159 927 159 917 q 161 956 160 937 q 165 1008 163 975 q 170 1039 167 1030 q 185 1050 173 1047 q 306 1074 243 1061 q 428 1106 369 1086 q 434 1107 430 1107 q 439 1101 436 1103 l 441 1100 l 427 914 q 421 883 425 892 q 407 872 418 874 q 290 848 349 861 q 165 823 231 836 q 159 822 163 822 q 152 829 152 822 m 77 60 q 90 185 83 115 q 105 335 98 256 q 121 496 113 414 q 134 658 128 579 q 139 689 136 680 q 154 700 142 697 q 275 724 212 711 q 397 756 338 736 q 403 757 399 757 q 410 751 410 757 l 360 196 l 347 88 q 257 -146 329 -69 q 47 -223 184 -223 q 11 -219 34 -223 q -39 -209 -12 -216 q -93 -195 -65 -203 q -142 -178 -120 -186 q -178 -162 -164 -170 q -193 -149 -193 -155 q -188 -134 -193 -143 q -157 -69 -168 -95 q -140 -28 -146 -43 q -131 -7 -134 -13 q -119 -1 -127 -1 q -98 -7 -113 -1 q -51 -24 -74 -17 q -4 -31 -27 -31 q 23 -26 9 -31 q 47 -12 36 -22 q 65 16 58 -1 q 77 60 73 34 z " - }, - "k": { - "ha": 853, - "x_min": 77, - "x_max": 881, - "o": "m 447 1029 l 422 794 q 413 698 418 747 q 403 604 408 649 q 394 522 398 559 q 387 459 390 484 l 434 511 l 510 600 q 538 632 524 616 q 562 661 551 648 q 580 682 573 673 q 588 692 587 690 l 861 711 q 865 711 863 711 q 869 711 867 711 q 881 705 881 711 q 867 684 881 701 l 654 447 q 621 411 640 431 q 578 365 602 390 l 677 247 l 848 63 q 854 58 850 60 q 862 55 858 56 q 868 52 865 54 q 871 47 871 50 q 870 43 871 44 q 864 37 869 41 q 843 24 858 33 q 807 4 827 15 q 764 -18 787 -7 q 719 -38 741 -29 q 679 -53 697 -47 q 650 -59 661 -59 q 634 -55 642 -59 q 617 -40 627 -51 q 585 -1 604 -25 q 543 52 566 23 q 497 112 521 81 q 453 171 474 142 q 414 221 431 199 q 387 258 397 244 q 380 253 384 254 q 374 248 377 251 q 369 242 371 245 q 367 231 367 238 q 366 216 367 229 q 362 186 364 203 q 359 149 361 169 q 355 112 357 130 q 352 82 353 95 q 351 67 351 70 q 351 59 351 62 q 351 54 351 56 q 346 42 351 46 q 321 33 341 39 l 144 -24 q 124 -31 136 -27 q 100 -35 112 -35 q 84 -31 91 -35 q 77 -13 77 -26 l 162 964 q 161 971 162 968 q 161 977 161 974 q 166 988 161 983 q 189 998 171 994 l 380 1044 q 399 1050 387 1045 q 423 1055 412 1055 q 440 1050 432 1055 q 448 1035 448 1046 q 447 1032 448 1034 q 447 1029 447 1031 z " - }, - "l": { - "ha": 422, - "x_min": 79, - "x_max": 439, - "o": "m 128 574 q 141 758 136 667 q 153 944 146 848 q 157 975 154 966 q 172 986 160 983 q 299 1009 235 998 q 426 1041 362 1021 q 432 1042 428 1042 q 439 1035 439 1042 l 351 66 l 351 55 q 347 45 351 49 q 324 37 342 41 l 146 -28 q 127 -36 139 -32 q 103 -39 115 -39 q 86 -35 94 -39 q 79 -18 79 -30 l 79 -14 q 90 120 85 54 q 101 255 95 185 q 113 403 106 325 q 128 574 120 481 z " - }, - "m": { - "ha": 1322, - "x_min": 73, - "x_max": 1301, - "o": "m 1068 -24 q 1048 -31 1061 -26 q 1025 -35 1036 -35 q 1008 -31 1015 -35 q 1001 -14 1001 -26 l 1001 -10 q 1009 70 1006 39 q 1015 120 1013 101 q 1018 149 1017 139 q 1021 167 1019 159 q 1023 186 1022 176 q 1026 215 1024 196 q 1031 264 1028 233 q 1039 345 1034 295 q 1045 399 1042 372 q 1048 448 1048 426 q 1045 500 1048 477 q 1034 540 1042 524 q 1013 566 1026 557 q 978 576 999 576 q 944 570 965 576 q 903 551 924 565 q 865 514 882 537 q 843 457 848 492 l 843 454 q 828 320 835 377 q 817 223 822 264 q 809 155 812 182 q 804 110 806 128 q 801 79 802 91 q 800 56 800 66 q 801 46 800 50 q 801 40 801 43 q 796 31 801 35 q 773 22 791 27 l 614 -24 q 594 -31 606 -26 q 570 -35 582 -35 q 554 -31 561 -35 q 547 -14 547 -26 l 547 -10 q 554 70 551 39 q 560 120 557 101 q 564 149 562 139 q 566 167 565 159 q 568 186 567 176 q 571 215 570 196 q 576 264 573 233 q 584 345 579 295 q 590 399 587 372 q 593 448 593 426 q 590 500 593 477 q 580 540 587 524 q 561 566 573 557 q 530 576 549 576 q 493 569 516 576 q 446 547 469 562 q 405 506 422 531 q 384 443 387 480 q 375 360 378 393 q 370 308 372 328 q 367 274 368 287 q 365 251 366 262 q 363 236 364 248 q 360 206 361 223 q 356 169 358 189 q 353 131 355 149 q 351 101 352 114 q 350 86 350 89 l 350 74 q 349 62 350 67 q 345 54 349 58 q 335 46 342 50 q 317 39 329 43 l 140 -24 q 120 -31 132 -27 q 96 -35 108 -35 q 80 -31 87 -35 q 73 -14 73 -26 l 134 677 q 139 708 136 700 q 154 720 142 717 q 280 744 216 732 q 406 777 345 757 q 413 775 412 777 q 414 770 414 773 l 405 671 q 461 699 430 684 q 527 727 492 714 q 596 748 561 740 q 666 757 632 757 q 752 735 713 757 q 818 665 792 714 q 883 701 848 684 q 952 730 917 718 q 1024 749 988 743 q 1094 756 1060 756 q 1175 744 1137 756 q 1241 704 1213 732 q 1285 632 1269 676 q 1301 524 1301 587 q 1301 490 1301 507 q 1298 454 1300 473 l 1267 164 q 1263 112 1263 136 q 1262 56 1262 87 q 1262 46 1262 50 q 1263 40 1263 43 q 1258 31 1263 34 q 1235 22 1253 27 l 1068 -24 z " - }, - "n": { - "ha": 897, - "x_min": 73, - "x_max": 876, - "o": "m 644 -24 q 625 -31 637 -26 q 601 -35 612 -35 q 584 -31 591 -35 q 577 -14 577 -26 l 577 -10 q 584 52 581 26 q 589 98 587 77 q 593 139 591 119 q 597 188 595 160 q 604 253 600 215 q 613 347 608 290 q 619 417 616 381 q 622 484 622 453 q 619 521 622 504 q 608 551 616 538 q 587 570 600 564 q 552 577 573 577 q 509 570 536 577 q 454 548 481 564 q 406 507 427 532 q 382 444 385 481 q 375 358 378 394 q 369 298 372 323 q 365 258 366 273 q 362 231 363 242 q 360 216 361 229 q 357 187 359 204 q 354 151 355 170 q 350 115 352 132 q 348 86 349 98 q 347 71 347 74 q 347 62 347 66 q 347 55 347 58 q 342 46 347 50 q 319 37 337 42 l 140 -24 q 120 -31 132 -27 q 96 -35 108 -35 q 80 -31 87 -35 q 73 -14 73 -26 l 134 679 q 139 710 136 701 q 155 721 142 718 q 281 746 216 733 q 408 778 347 758 q 415 776 414 778 q 416 771 416 774 q 415 767 416 770 q 413 755 415 764 q 409 726 412 745 q 400 672 406 707 q 488 716 447 699 q 565 742 529 732 q 633 754 602 751 q 693 757 665 757 q 832 699 789 757 q 876 525 876 641 q 875 491 876 509 q 872 456 874 474 l 841 164 q 837 112 838 136 q 836 56 836 87 q 837 46 836 50 q 837 40 837 43 q 832 31 837 34 q 809 22 827 27 l 644 -24 z " - }, - "o": { - "ha": 890, - "x_min": 68, - "x_max": 885, - "o": "m 454 -35 q 287 -4 359 -35 q 165 79 214 27 q 92 198 117 131 q 68 338 68 266 q 92 476 68 411 q 158 594 115 542 q 260 681 201 646 q 392 728 320 715 q 403 732 403 728 q 401 746 403 740 q 399 758 399 753 q 402 768 399 765 q 408 770 405 770 q 629 741 538 770 q 777 661 720 711 q 859 541 833 610 q 885 392 885 471 q 851 212 885 291 q 759 77 817 132 q 622 -6 700 22 q 454 -35 543 -35 m 329 346 q 337 273 329 309 q 362 208 345 237 q 410 161 380 179 q 482 143 439 143 q 537 157 513 144 q 577 190 560 170 q 605 235 594 210 q 623 287 616 260 q 632 339 629 313 q 635 386 635 365 q 624 455 635 421 q 593 515 614 489 q 543 556 573 541 q 473 572 513 572 q 405 548 433 572 q 360 489 377 524 q 336 415 344 454 q 329 346 329 376 z " - }, - "p": { - "ha": 899, - "x_min": 50, - "x_max": 895, - "o": "m 385 473 q 377 368 380 408 q 372 301 374 327 q 369 261 370 276 q 367 234 368 247 q 413 168 382 193 q 486 142 444 142 q 552 166 524 142 q 598 227 580 189 q 627 310 617 264 q 636 401 636 356 q 630 471 636 439 q 610 526 623 503 q 578 563 597 549 q 532 576 559 576 q 489 567 511 576 q 448 546 468 559 q 413 516 429 532 q 387 484 397 499 l 385 473 m 398 672 q 517 734 455 711 q 648 757 580 757 q 758 731 711 757 q 835 660 804 705 q 880 558 865 616 q 895 437 895 500 q 884 326 895 382 q 852 217 873 270 q 800 119 831 165 q 728 38 768 73 q 638 -16 688 4 q 531 -35 589 -35 q 434 -15 480 -35 q 347 38 387 5 q 345 13 347 35 q 340 -39 343 -8 q 334 -104 338 -69 q 328 -170 331 -139 q 324 -221 326 -200 q 322 -246 322 -243 q 322 -255 322 -252 q 323 -262 323 -259 q 318 -272 323 -268 q 295 -280 313 -275 l 117 -326 q 97 -332 109 -328 q 73 -336 85 -336 q 57 -332 64 -336 q 50 -314 50 -327 l 132 679 q 137 710 134 701 q 153 721 140 718 q 279 746 214 733 q 406 778 345 758 q 413 776 412 778 q 414 771 414 774 q 413 767 414 770 q 411 755 413 764 q 407 726 410 745 q 398 672 404 707 z " - }, - "q": { - "ha": 884, - "x_min": 70, - "x_max": 871, - "o": "m 576 487 q 558 519 570 503 q 530 549 546 535 q 496 571 515 562 q 458 579 478 579 q 406 556 430 579 q 363 495 381 533 q 334 407 345 456 q 323 305 323 358 q 329 244 323 273 q 347 193 335 215 q 379 159 359 172 q 425 146 398 146 q 500 171 466 146 q 557 237 534 197 q 559 271 558 252 q 563 319 561 291 q 568 386 565 347 q 576 477 571 424 l 576 487 m 836 755 q 850 758 844 758 q 871 731 871 758 q 871 725 871 728 q 871 718 871 722 l 783 -222 q 783 -230 783 -224 q 783 -235 783 -233 q 783 -238 783 -237 q 779 -248 783 -244 q 756 -256 774 -252 l 576 -322 q 557 -329 569 -324 q 533 -333 545 -333 q 516 -329 524 -333 q 509 -314 509 -325 q 509 -308 509 -310 q 511 -289 510 -305 q 515 -249 513 -273 q 519 -195 517 -225 q 525 -133 522 -165 q 530 -72 527 -102 q 534 -17 532 -41 q 538 23 536 7 q 540 41 539 39 q 441 -13 491 9 q 340 -35 391 -35 q 219 -7 270 -35 q 135 70 168 22 q 86 179 102 117 q 70 309 70 241 q 80 416 70 362 q 109 520 90 470 q 157 613 128 570 q 222 688 185 656 q 305 739 260 720 q 404 757 351 757 q 513 733 464 757 q 603 671 562 709 q 605 690 604 683 q 608 701 606 697 q 617 707 611 705 q 636 712 624 709 q 663 718 644 713 q 710 728 683 722 q 770 741 737 734 q 836 755 802 748 z " - }, - "r": { - "ha": 613, - "x_min": 73, - "x_max": 678, - "o": "m 636 552 q 604 555 622 553 q 567 557 587 557 q 506 552 537 557 q 449 532 475 547 q 404 491 422 517 q 379 423 385 465 q 371 341 374 373 q 367 288 368 309 q 365 255 366 267 q 363 231 363 242 q 362 216 363 229 q 359 188 361 204 q 355 153 357 172 q 351 117 353 134 q 348 89 349 101 q 347 74 347 77 q 348 65 347 68 q 348 58 348 61 q 343 48 348 52 q 320 40 338 45 l 140 -24 q 121 -31 133 -27 q 97 -35 109 -35 q 80 -31 87 -35 q 73 -14 73 -26 l 132 658 q 137 689 134 680 q 152 700 140 697 q 279 725 214 712 q 407 757 345 737 q 413 755 412 757 q 414 750 414 753 q 414 746 414 749 q 412 734 414 743 q 407 705 410 724 q 399 651 404 686 q 468 696 430 675 q 543 731 505 716 q 616 754 581 745 q 678 762 652 762 l 636 552 z " - }, - "s": { - "ha": 584, - "x_min": 84, - "x_max": 568, - "o": "m 85 187 q 84 188 85 188 q 84 189 84 189 q 94 198 84 198 q 104 193 100 198 q 166 151 132 168 q 242 135 201 135 q 267 137 253 135 q 294 145 281 140 q 316 160 307 151 q 324 182 324 169 q 317 210 324 197 q 297 231 309 222 q 273 247 290 235 q 237 273 256 259 q 200 298 218 286 q 176 316 183 311 q 128 363 146 339 q 100 412 110 387 q 88 465 91 437 q 85 524 85 493 q 111 614 85 572 q 177 688 136 656 q 270 738 218 720 q 376 757 322 757 q 465 743 421 757 q 545 697 508 730 q 550 613 549 654 q 554 526 551 572 q 550 514 554 517 q 541 511 546 511 q 532 515 536 511 q 500 544 517 530 q 466 570 484 559 q 428 588 448 581 q 385 595 408 595 q 356 593 370 595 q 330 584 342 591 q 312 567 319 578 q 304 539 304 556 q 309 505 304 519 q 332 477 314 491 l 458 392 q 514 346 492 368 q 547 300 535 323 q 564 256 559 278 q 568 212 568 234 q 540 105 568 151 q 467 27 512 58 q 366 -19 422 -3 q 252 -35 309 -35 q 169 -26 209 -35 q 94 2 128 -17 l 85 187 z " - }, - "t": { - "ha": 633, - "x_min": 51, - "x_max": 659, - "o": "m 447 523 q 429 381 437 452 q 418 248 420 310 q 422 204 418 222 q 434 176 427 186 q 453 162 442 166 q 477 157 464 157 q 525 164 499 157 q 576 180 551 170 q 590 185 585 184 q 600 187 596 187 q 609 181 607 187 q 614 160 612 175 q 621 119 616 144 q 637 54 626 93 q 638 48 637 50 q 638 43 638 45 q 631 30 638 34 q 608 20 624 26 q 549 1 580 11 q 488 -17 518 -9 q 430 -30 458 -25 q 381 -35 402 -35 q 216 21 268 -35 q 164 193 164 77 q 165 233 164 212 q 169 276 167 254 q 181 405 176 344 q 191 521 186 465 l 120 521 q 67 524 83 521 q 51 536 51 527 q 58 551 51 539 q 75 579 64 563 q 98 615 85 596 q 121 651 110 634 q 140 680 132 667 q 151 694 149 692 l 199 694 q 209 781 205 746 q 215 839 212 816 q 219 874 217 862 q 223 893 221 887 q 230 901 226 899 q 239 904 233 903 q 298 915 270 910 q 355 926 327 920 q 413 938 384 931 q 475 955 443 945 q 477 955 477 955 q 480 956 478 956 q 488 950 488 956 l 488 949 q 478 845 485 911 q 462 694 471 779 l 644 694 q 654 691 649 694 q 659 678 659 687 q 651 654 659 675 q 628 599 643 633 l 604 544 q 594 529 599 534 q 573 523 589 524 l 447 523 z " - }, - "u": { - "ha": 868, - "x_min": 79, - "x_max": 862, - "o": "m 798 84 q 793 53 796 62 q 778 42 789 45 q 657 9 720 26 q 536 -35 595 -7 q 530 -35 534 -35 q 523 -33 524 -35 q 522 -26 522 -30 q 523 -22 522 -25 q 524 -9 523 -18 q 528 16 526 0 q 534 60 530 33 q 400 -13 458 10 q 296 -35 341 -35 q 131 19 182 -35 q 79 182 79 74 q 79 223 79 202 q 83 265 80 243 q 96 402 91 345 q 105 500 102 460 q 111 565 109 540 q 115 608 113 591 q 118 636 117 625 q 120 658 119 647 q 125 688 123 680 q 140 700 127 697 q 201 711 172 706 q 258 722 230 716 q 315 734 286 728 q 377 751 345 741 q 380 751 378 751 q 382 751 381 751 q 391 746 391 751 l 391 745 q 386 701 388 722 q 382 660 384 681 q 377 614 380 638 q 372 557 375 589 q 363 483 368 525 q 352 385 359 441 q 344 304 348 345 q 340 229 340 264 q 342 194 340 210 q 352 167 345 178 q 371 150 359 156 q 401 144 382 144 q 439 150 415 144 q 488 173 464 157 q 531 215 513 189 q 553 281 550 241 q 561 393 557 348 q 568 469 565 438 q 572 521 570 500 q 576 561 574 542 q 579 603 578 581 q 582 658 581 625 q 587 689 584 680 q 602 700 590 697 q 728 725 664 712 q 854 757 793 737 q 861 755 860 757 q 862 750 862 753 l 798 84 z " - }, - "v": { - "ha": 760, - "x_min": 69, - "x_max": 819, - "o": "m 580 750 q 590 757 583 757 q 593 756 591 757 q 595 756 594 756 q 700 724 646 736 q 806 700 753 711 q 819 685 819 697 q 811 658 819 676 l 532 64 q 522 44 526 52 q 514 32 518 37 q 505 25 510 27 q 494 22 500 23 q 389 -2 442 12 q 279 -35 336 -15 q 277 -35 278 -35 q 276 -35 277 -35 l 271 -35 q 266 -33 268 -35 q 263 -28 264 -31 q 240 47 253 1 q 211 150 227 93 q 178 271 195 207 q 144 402 161 336 q 109 534 126 469 q 75 658 92 600 q 69 688 69 679 q 80 700 69 697 q 190 724 133 711 q 298 756 247 736 q 304 757 300 757 q 313 750 313 757 l 403 294 q 414 324 406 302 q 434 375 422 345 q 459 441 446 405 q 488 514 473 477 q 517 588 503 551 q 544 657 531 625 q 566 713 556 689 q 580 750 575 738 z " - }, - "w": { - "ha": 1147, - "x_min": 77, - "x_max": 1185, - "o": "m 503 690 q 515 700 505 698 q 627 725 570 712 q 738 757 685 738 q 747 750 747 757 l 817 288 l 946 750 q 956 757 949 757 q 959 756 958 757 q 962 756 960 756 q 1066 724 1013 736 q 1173 700 1120 711 q 1185 685 1185 697 q 1177 658 1185 676 l 959 53 q 949 34 954 41 q 941 21 945 26 q 932 15 937 17 q 921 11 928 12 q 817 -13 869 0 q 707 -45 764 -26 q 705 -46 705 -45 q 703 -46 704 -46 l 699 -46 q 693 -44 695 -46 q 690 -39 691 -41 q 673 33 683 -10 q 653 130 664 77 q 630 243 642 182 q 605 367 618 303 l 519 64 q 512 44 515 52 q 503 32 508 36 q 493 25 498 27 q 481 22 488 23 q 376 -2 429 12 q 267 -35 323 -15 q 264 -35 265 -35 q 263 -35 264 -35 l 258 -35 q 253 -33 255 -35 q 250 -28 250 -31 q 229 47 241 1 q 202 150 216 93 q 174 271 189 206 q 143 401 159 335 q 112 533 127 468 q 83 658 97 599 q 77 676 78 669 q 77 688 77 683 q 87 700 77 697 q 197 724 140 711 q 305 756 254 736 q 311 757 307 757 q 321 750 320 757 l 397 281 l 503 690 z " - }, - "x": { - "ha": 726, - "x_min": 15, - "x_max": 773, - "o": "m 475 -39 q 465 -21 474 -39 q 441 23 456 -4 q 409 85 427 51 q 372 153 391 119 q 321 85 347 119 q 277 23 296 51 q 244 -21 257 -4 q 231 -39 231 -39 q 218 -46 226 -46 q 212 -45 214 -46 q 168 -27 192 -35 q 120 -13 144 -20 q 70 -1 95 -7 q 22 11 45 5 q 15 18 15 12 q 20 30 15 22 q 37 53 26 37 l 262 360 q 181 508 221 435 q 100 658 142 581 q 88 679 92 671 q 84 692 84 686 q 93 700 84 698 q 197 724 144 711 q 296 756 250 736 q 302 757 298 757 q 313 750 311 757 l 415 566 l 557 750 q 570 757 562 757 q 575 756 574 757 q 668 724 616 736 q 766 700 719 711 q 773 694 773 698 q 768 681 773 688 q 751 658 762 673 q 636 508 692 581 q 526 360 581 436 l 688 53 q 699 33 695 40 q 703 20 703 25 q 695 11 703 13 q 591 -13 644 -1 q 492 -45 538 -26 q 486 -46 490 -46 q 475 -39 479 -46 z " - }, - "y": { - "ha": 763, - "x_min": 77, - "x_max": 807, - "o": "m 370 -309 q 367 -314 369 -312 q 361 -315 366 -315 q 355 -315 357 -315 q 309 -300 331 -306 q 266 -289 288 -294 q 222 -279 245 -283 q 175 -269 200 -275 q 164 -265 168 -268 q 161 -254 161 -262 q 163 -244 161 -252 q 175 -213 165 -237 q 204 -143 184 -189 q 258 -20 224 -97 q 235 62 248 14 q 208 165 222 109 q 178 284 193 222 q 146 411 162 347 q 114 538 130 475 q 83 658 98 601 q 78 676 79 669 q 77 688 77 683 q 88 700 77 697 q 198 724 141 711 q 306 756 255 736 q 312 757 308 757 q 321 750 321 757 l 404 294 q 415 324 407 302 q 433 375 422 345 q 456 441 444 405 q 483 514 469 477 q 510 588 496 551 q 534 657 523 625 q 554 713 546 689 q 568 750 563 738 q 578 757 570 757 q 581 756 580 757 q 583 756 581 756 q 688 724 634 736 q 794 700 741 711 q 807 685 807 697 q 799 658 807 676 l 519 26 l 370 -309 z " - }, - "z": { - "ha": 673, - "x_min": 57, - "x_max": 667, - "o": "m 173 0 q 144 1 159 0 q 116 6 129 3 q 95 16 104 10 q 87 33 87 22 q 87 35 87 33 q 88 37 88 36 l 328 528 q 264 527 299 528 q 193 525 229 526 q 125 524 157 524 q 71 523 93 523 q 60 527 64 523 q 57 537 57 532 l 57 540 l 125 703 q 146 727 131 722 q 176 732 161 732 q 410 728 295 732 q 644 724 525 724 q 659 720 651 724 q 667 708 667 715 q 665 703 667 707 l 450 234 q 454 232 450 233 q 464 231 458 231 q 475 230 469 230 q 485 230 481 230 q 568 232 528 230 q 648 234 608 234 q 661 231 656 234 q 667 217 667 227 q 665 216 667 216 l 580 37 q 558 17 574 24 q 520 6 543 9 q 470 1 498 2 q 414 0 443 0 l 173 0 z " - }, - "{": { - "ha": 571, - "x_min": 39, - "x_max": 624, - "o": "m 113 630 q 178 657 151 636 q 227 709 205 678 q 265 776 248 739 q 302 851 283 813 q 347 927 322 890 q 407 993 372 964 q 492 1043 443 1023 q 609 1067 541 1063 l 612 1067 q 621 1065 618 1067 q 624 1055 624 1063 q 616 988 618 1017 q 610 932 613 959 q 604 876 608 905 q 591 808 600 846 q 583 783 589 789 q 569 775 576 776 q 516 750 535 771 q 486 701 498 730 q 464 638 473 671 q 437 574 454 604 q 392 522 420 545 q 316 493 364 500 q 409 418 380 458 q 439 330 439 377 q 438 312 439 321 q 438 294 438 302 q 458 181 438 222 q 513 123 478 141 q 522 118 518 122 q 526 103 526 113 q 525 97 526 100 q 524 90 525 94 q 512 40 518 62 q 501 -3 507 18 q 490 -45 496 -23 q 477 -96 484 -67 q 472 -106 475 -103 q 463 -109 468 -109 q 460 -108 461 -109 q 458 -108 460 -108 q 349 -73 404 -99 q 251 -1 294 -47 q 180 111 208 45 q 153 267 153 177 q 154 286 153 276 q 154 304 154 295 q 146 350 154 330 q 126 384 139 370 q 96 406 113 397 q 58 418 78 414 q 44 422 49 419 q 39 437 39 425 q 41 466 39 449 q 46 503 43 484 q 53 540 50 522 q 60 574 57 559 q 65 598 63 589 q 67 608 67 608 q 82 624 71 621 q 113 630 92 627 z " - }, - "|": { - "ha": 404, - "x_min": 82, - "x_max": 415, - "o": "m 131 574 q 148 771 141 673 q 162 971 155 869 q 166 1002 163 994 q 182 1013 170 1010 q 294 1022 239 1017 q 408 1035 350 1027 q 414 1033 413 1035 q 415 1028 415 1031 l 327 9 l 327 -6 q 322 -16 327 -12 q 300 -24 318 -20 l 149 -62 q 130 -69 142 -65 q 106 -73 117 -73 q 89 -68 96 -73 q 82 -52 82 -64 l 82 -48 q 92 94 87 25 q 102 236 97 163 q 115 391 108 309 q 131 574 122 473 z " - }, - "}": { - "ha": 571, - "x_min": 44, - "x_max": 616, - "o": "m 576 616 q 606 611 596 614 q 616 594 616 608 q 615 584 616 594 q 613 557 614 573 q 610 519 612 541 q 606 477 608 498 q 600 435 603 455 q 592 400 596 415 q 584 382 589 387 q 567 377 578 378 q 498 325 528 366 q 452 208 469 284 q 420 114 442 156 q 367 38 397 71 q 298 -21 336 4 q 220 -65 260 -47 q 139 -93 180 -83 q 60 -108 98 -104 q 58 -108 58 -108 q 56 -109 57 -109 q 44 -96 44 -109 q 44 -70 44 -82 q 45 -47 45 -58 q 44 -9 45 -26 q 44 31 44 7 q 45 60 44 45 q 48 89 45 75 q 55 112 50 102 q 67 123 59 121 q 111 155 90 138 q 148 197 131 173 q 179 256 165 222 q 202 336 193 290 q 245 424 214 383 q 336 500 277 465 q 275 520 298 505 q 239 556 252 535 q 222 601 227 576 q 215 652 217 626 q 211 702 213 677 q 202 746 210 726 q 181 779 195 766 q 138 795 166 792 q 129 801 133 797 q 124 817 124 806 q 124 823 124 820 q 125 829 125 825 q 131 890 127 863 q 139 942 134 917 q 148 994 143 967 q 159 1055 153 1021 q 164 1065 160 1063 q 174 1067 168 1067 l 177 1067 q 294 1042 248 1063 q 369 991 340 1021 q 413 922 397 960 q 439 845 429 884 q 457 767 450 805 q 479 697 465 728 q 515 644 492 666 q 576 616 537 623 z " - }, - "~": { - "ha": 735, - "x_min": 77, - "x_max": 753, - "o": "m 490 591 q 514 566 503 573 q 541 558 526 558 q 571 569 562 558 q 584 594 580 581 q 589 620 587 608 q 597 631 591 631 q 609 631 599 631 q 633 632 618 631 q 664 633 647 633 q 696 635 681 634 q 722 636 711 636 q 736 637 733 637 q 747 634 741 637 q 753 624 753 631 q 736 525 753 575 q 687 435 719 475 q 612 369 656 394 q 514 343 568 343 q 471 347 492 343 q 428 362 450 351 q 385 394 407 374 q 341 446 363 414 q 317 467 330 463 q 287 471 304 471 q 260 465 271 471 q 244 447 250 458 q 236 423 238 436 q 233 397 233 410 q 228 386 233 391 q 214 381 222 381 q 179 381 192 381 q 154 380 165 380 q 131 379 143 380 q 98 379 118 379 q 84 382 90 379 q 77 391 77 385 q 96 507 77 454 q 145 597 114 559 q 219 655 177 634 q 309 675 261 675 q 360 673 336 675 q 405 663 383 671 q 448 638 427 655 q 490 591 469 621 z " - }, - "¡": { - "ha": 373, - "x_min": 48, - "x_max": 415, - "o": "m 102 247 q 144 458 123 353 q 182 671 165 564 q 187 702 184 693 q 202 713 190 711 q 254 724 229 718 q 309 736 280 729 q 315 735 314 736 q 316 730 316 733 l 323 60 q 318 28 321 37 q 303 18 315 20 q 186 -13 245 4 q 62 -45 127 -29 q 56 -46 60 -46 q 48 -39 48 -46 q 51 -23 48 -39 q 58 18 54 -7 q 68 75 62 43 q 79 137 73 106 q 91 198 85 169 q 102 247 97 227 m 125 808 q 129 853 127 838 q 130 877 130 869 q 131 886 131 884 q 131 889 131 888 q 132 893 132 890 q 133 906 132 897 q 135 935 134 916 q 139 987 136 954 q 143 1018 140 1010 q 159 1029 146 1027 q 279 1054 216 1041 q 401 1086 342 1066 q 408 1086 404 1086 q 413 1081 410 1082 l 415 1080 l 400 894 q 395 863 398 871 q 380 852 392 854 q 264 828 323 841 q 139 802 205 815 q 133 802 137 802 q 125 808 125 802 z " - }, - "¢": { - "ha": 737, - "x_min": 68, - "x_max": 737, - "o": "m 68 331 q 98 491 68 416 q 179 624 127 566 q 302 718 231 682 q 458 763 374 755 l 465 840 q 468 871 466 863 q 477 883 469 880 q 506 883 493 883 q 530 884 518 884 q 555 885 542 884 q 585 885 568 885 q 598 880 592 885 q 605 857 605 875 l 596 757 q 660 740 633 750 q 704 721 686 730 q 729 705 721 711 q 737 697 737 698 q 734 674 737 693 q 727 631 731 656 q 721 580 724 606 q 718 535 718 554 q 715 528 718 532 q 705 524 713 524 q 687 527 698 524 q 660 536 675 531 q 624 547 644 542 q 579 556 604 553 l 545 146 q 605 159 578 150 q 666 188 632 169 q 671 189 667 189 q 676 185 675 189 q 678 172 678 182 q 678 120 678 151 q 678 61 678 89 q 677 13 677 33 q 675 -7 676 -7 q 606 -39 643 -28 q 528 -55 568 -50 l 522 -132 q 521 -145 521 -140 q 520 -154 521 -150 q 516 -160 519 -157 q 505 -166 513 -163 l 450 -171 l 399 -171 q 390 -166 393 -171 q 386 -151 386 -162 q 389 -102 386 -125 q 393 -56 391 -79 q 263 -16 323 -47 q 161 67 204 16 q 93 184 117 117 q 68 331 68 252 m 443 543 q 359 465 389 518 q 329 342 329 412 q 349 236 329 283 q 411 163 370 188 q 416 224 413 191 q 421 294 418 258 q 428 367 425 330 q 434 439 431 404 l 443 543 z " - }, - "£": { - "ha": 755, - "x_min": 59, - "x_max": 789, - "o": "m 194 -39 q 189 -39 190 -39 q 161 -39 173 -39 q 140 -39 149 -39 q 79 -36 99 -39 q 59 -20 59 -32 q 72 1 59 -15 q 103 38 84 18 q 143 81 121 59 q 183 119 165 102 q 198 271 189 186 q 217 446 207 356 l 147 446 q 94 449 111 446 q 78 462 78 452 q 83 476 78 465 q 97 505 89 488 q 116 541 106 522 q 134 576 125 559 q 150 605 143 593 q 157 620 156 617 l 240 620 l 250 762 q 276 883 257 826 q 330 982 295 939 q 419 1048 365 1024 q 549 1073 473 1073 q 640 1063 596 1073 q 716 1041 683 1053 q 769 1016 749 1028 q 789 998 789 1003 q 787 992 789 995 q 784 984 786 989 q 755 922 766 948 q 738 879 744 896 q 727 854 731 862 q 718 846 723 846 q 715 848 719 846 q 658 871 686 862 q 600 880 629 880 q 548 861 570 880 q 513 789 526 842 q 504 707 508 751 q 496 620 499 663 l 673 620 q 684 616 679 620 q 689 604 689 612 q 681 579 689 600 q 658 524 673 558 l 633 469 q 624 454 629 459 q 603 448 618 448 l 486 448 q 467 289 475 366 q 452 151 458 211 q 539 155 498 153 q 615 156 581 156 q 673 157 649 157 q 709 157 698 157 q 721 153 714 157 q 728 138 728 149 q 722 118 728 132 q 705 85 715 104 q 682 41 695 65 q 655 -9 669 17 q 644 -27 650 -21 q 618 -33 637 -33 q 593 -33 616 -33 q 534 -34 570 -33 q 453 -36 498 -35 q 362 -37 408 -37 q 272 -39 316 -38 q 194 -39 228 -39 z " - }, - "¤": { - "ha": 866, - "x_min": 119, - "x_max": 833, - "o": "m 119 555 q 139 669 119 617 q 197 763 160 720 l 172 790 q 153 812 160 803 q 146 829 146 821 q 155 842 146 837 q 170 854 157 844 q 198 878 182 865 q 227 903 213 891 q 245 918 241 914 q 259 924 252 924 q 269 921 265 924 l 273 918 l 327 859 q 412 888 368 878 q 503 898 456 898 q 583 889 546 898 q 652 863 620 880 l 703 918 q 717 924 709 924 q 730 918 724 924 q 749 903 735 914 q 778 878 763 891 q 806 854 793 865 q 821 842 819 844 q 829 829 829 837 q 813 800 829 817 l 802 788 q 774 758 791 777 q 815 673 801 718 q 829 580 829 629 q 813 468 829 518 q 768 376 798 417 l 822 317 q 830 304 827 311 q 833 292 833 298 q 828 277 833 282 q 800 248 815 262 q 772 224 785 235 q 751 208 760 214 q 741 202 742 202 q 709 221 730 202 q 653 277 688 239 q 450 229 565 229 q 372 237 408 229 q 304 258 336 244 l 295 248 q 235 202 253 203 q 227 205 230 202 q 209 218 222 208 q 181 243 196 229 q 155 270 166 256 q 143 292 143 283 q 146 304 143 298 q 154 317 149 311 l 184 351 q 135 446 151 394 q 119 555 119 498 m 483 725 q 422 710 449 725 q 378 670 396 694 q 350 615 359 646 q 340 553 340 584 q 349 497 340 524 q 373 450 357 471 q 416 417 390 430 q 476 405 441 405 q 537 419 511 405 q 581 458 563 434 q 607 512 598 481 q 616 572 616 542 q 608 629 616 602 q 584 678 600 656 q 542 712 567 699 q 483 725 517 725 z " - }, - "¥": { - "ha": 857, - "x_min": 120, - "x_max": 907, - "o": "m 296 491 q 266 558 282 522 q 232 632 249 595 q 197 705 214 669 q 166 772 180 741 q 140 826 151 803 q 122 862 128 850 l 121 867 q 120 878 120 869 q 121 890 120 884 q 127 903 123 897 q 141 910 132 906 q 164 920 151 915 q 193 932 178 926 q 224 945 208 939 l 302 976 q 318 980 311 980 q 330 977 323 980 q 345 966 336 974 l 501 662 l 505 672 l 572 796 q 598 842 585 819 q 620 882 610 864 q 637 910 630 899 q 645 921 644 921 l 878 979 q 891 981 886 981 q 907 967 907 981 q 905 958 906 964 q 901 945 905 952 l 776 711 l 661 500 q 702 501 684 500 q 728 501 720 501 q 745 498 737 500 q 756 491 751 495 q 761 477 761 486 q 759 451 761 469 q 754 416 757 433 l 748 370 q 746 363 747 366 q 742 359 745 361 q 732 356 739 357 q 715 355 726 355 q 664 353 693 353 q 591 353 634 353 l 582 296 q 654 298 623 297 q 696 298 684 298 q 712 295 705 298 q 723 288 718 292 q 728 275 728 283 q 726 248 728 266 q 722 213 724 231 l 715 168 q 714 161 715 163 q 709 156 713 158 q 700 153 706 154 q 682 152 693 152 q 630 151 661 151 q 556 151 600 151 l 543 71 q 539 52 541 59 q 535 40 537 45 q 529 31 532 35 q 519 24 525 28 l 340 -22 q 317 -31 329 -28 q 294 -35 305 -35 q 275 -30 283 -35 q 267 -13 267 -24 l 267 -10 q 274 64 269 22 q 286 148 279 105 l 231 148 q 155 151 179 148 q 131 164 131 155 q 135 181 131 170 q 147 205 140 192 q 164 233 155 218 q 184 259 174 248 q 207 279 195 271 q 228 288 218 287 l 310 289 q 311 294 310 293 l 319 351 l 263 351 q 188 354 212 351 q 163 367 163 357 q 168 384 163 372 q 180 408 172 395 q 197 436 187 421 q 217 462 206 450 q 239 482 228 474 q 260 490 250 490 l 296 491 z " - }, - "¦": { - "ha": 387, - "x_min": 70, - "x_max": 407, - "o": "m 122 566 q 129 664 126 628 q 133 720 132 701 q 135 748 134 740 q 136 761 136 755 q 138 775 137 767 q 141 805 139 784 q 145 866 142 827 q 154 971 149 905 q 158 1002 155 993 q 174 1013 161 1011 q 286 1032 231 1023 q 399 1055 342 1041 l 407 1048 l 367 616 l 367 601 q 362 591 367 595 q 340 583 357 587 l 192 549 q 171 544 184 548 q 146 541 157 541 q 129 545 136 541 q 122 562 122 550 l 122 566 m 70 -57 q 77 42 74 5 q 81 98 79 78 q 83 125 82 117 q 84 139 83 133 q 86 153 85 144 q 89 183 87 161 q 93 243 90 204 q 102 349 96 282 q 106 379 103 371 q 121 391 109 388 q 234 412 178 401 q 347 439 290 422 l 355 433 l 315 7 l 315 -8 q 310 -18 315 -15 q 288 -26 306 -21 l 137 -71 q 118 -78 130 -73 q 96 -82 107 -82 q 77 -78 85 -82 q 70 -61 70 -74 l 70 -57 z " - }, - "§": { - "ha": 720, - "x_min": 82, - "x_max": 713, - "o": "m 136 96 q 135 97 136 96 q 134 100 134 98 q 142 106 134 106 q 155 102 148 106 q 235 60 192 76 q 326 43 279 43 q 348 45 336 43 q 371 52 361 47 q 389 64 382 56 q 397 83 397 71 q 386 114 397 99 q 358 139 374 130 q 261 194 310 165 q 172 259 212 223 q 107 343 132 296 q 82 454 82 390 q 116 575 82 524 q 214 648 151 627 q 200 680 207 663 q 188 716 193 698 q 179 754 182 735 q 176 790 176 772 q 193 863 176 829 q 244 922 211 897 q 325 961 277 947 q 433 975 373 975 q 449 974 437 975 q 479 971 462 973 q 517 964 497 968 q 554 953 536 960 q 585 937 572 946 q 602 916 597 928 q 625 831 614 873 q 650 745 636 790 q 650 739 650 743 q 640 730 650 730 q 631 733 634 730 q 592 763 612 748 q 552 788 572 777 q 509 807 531 800 q 464 814 487 814 q 439 812 452 814 q 417 805 427 810 q 401 792 408 800 q 395 771 395 784 q 437 702 395 727 q 547 628 501 662 q 624 565 593 594 q 672 512 654 536 q 699 466 690 487 q 710 426 708 445 q 713 391 713 408 q 702 324 713 355 q 673 269 692 293 q 631 227 655 244 q 579 199 606 209 q 610 135 601 167 q 618 75 618 103 q 598 -8 618 28 q 545 -72 578 -45 q 470 -113 512 -98 q 382 -127 427 -127 q 282 -122 330 -127 q 189 -92 234 -117 l 136 96 m 423 477 q 384 492 404 486 q 342 498 364 498 q 318 496 330 498 q 296 489 305 494 q 280 476 286 484 q 274 456 274 468 q 278 429 274 443 q 290 406 283 416 q 355 372 321 385 q 426 359 389 359 q 449 361 436 359 q 472 368 461 363 q 490 380 483 372 q 498 399 498 388 q 491 424 498 412 q 474 444 484 435 l 456 456 l 423 477 z " - }, - "¨": { - "ha": 806, - "x_min": 60, - "x_max": 747, - "o": "m 60 833 q 63 889 62 871 q 64 913 64 906 q 64 924 64 921 q 65 936 64 926 q 66 966 65 945 q 69 1031 67 987 q 74 1060 71 1052 q 87 1069 77 1067 q 200 1069 140 1069 q 310 1070 259 1070 q 319 1066 317 1070 q 322 1053 322 1063 l 305 864 q 300 837 303 844 q 288 827 298 829 q 181 826 236 827 q 67 826 127 826 q 62 827 64 826 q 60 831 60 827 l 60 833 m 485 831 q 488 895 487 874 q 489 924 489 916 q 489 936 490 933 q 489 946 489 939 q 491 972 490 954 q 494 1031 492 991 q 498 1058 496 1050 q 511 1067 501 1066 q 624 1068 565 1067 q 734 1069 683 1068 q 743 1066 739 1069 q 747 1055 747 1063 l 730 863 q 725 836 728 843 q 711 827 723 828 q 604 825 659 826 q 488 825 549 825 q 486 825 486 825 q 485 829 485 825 l 485 831 z " - }, - "©": { - "ha": 1112, - "x_min": 90, - "x_max": 1105, - "o": "m 559 70 q 675 84 619 70 q 780 123 731 98 q 868 186 828 149 q 937 271 908 224 q 981 374 965 318 q 996 494 996 430 q 971 633 996 568 q 900 746 945 698 q 790 822 854 794 q 650 850 726 850 q 484 821 563 850 q 347 738 406 791 q 253 609 288 684 q 218 442 218 534 q 241 300 218 368 q 309 181 264 233 q 416 100 353 130 q 559 70 479 70 m 534 -43 q 349 -3 431 -43 q 209 103 267 36 q 121 258 151 170 q 90 443 90 346 q 136 661 90 563 q 258 828 181 758 q 438 936 336 898 q 654 974 541 974 q 837 938 754 974 q 979 839 920 901 q 1072 691 1039 776 q 1105 510 1105 606 q 1085 354 1105 427 q 1027 219 1065 280 q 938 109 990 157 q 823 27 886 60 q 686 -25 759 -7 q 534 -43 613 -43 m 299 438 q 325 576 299 512 q 396 689 351 641 q 505 764 442 736 q 640 791 567 791 q 708 786 679 791 q 760 773 738 781 q 796 756 781 766 q 820 739 810 747 l 820 736 q 821 712 820 729 q 824 673 822 694 q 826 629 825 651 q 827 590 827 606 q 825 584 827 587 q 813 581 823 581 q 791 590 805 581 q 758 611 777 600 q 713 631 739 622 q 659 641 688 641 q 593 626 623 641 q 543 586 564 612 q 510 525 522 560 q 499 447 499 489 q 507 383 499 413 q 531 330 515 353 q 571 293 547 307 q 627 279 595 279 q 671 281 652 279 q 707 287 690 283 q 740 298 724 291 q 774 315 756 304 q 782 313 780 315 q 785 302 785 312 q 785 264 785 286 q 784 221 785 241 q 784 186 784 201 q 783 172 783 172 q 739 151 762 159 q 692 138 716 142 q 643 132 667 134 q 595 130 618 130 q 478 153 532 130 q 385 216 425 175 q 322 313 345 256 q 299 438 299 370 z " - }, - "ª": { - "ha": 669, - "x_min": 92, - "x_max": 694, - "o": "m 639 505 q 643 480 639 490 q 652 464 647 470 q 661 453 657 457 q 665 447 665 450 q 650 433 665 439 l 509 372 q 505 372 508 372 q 496 379 500 372 q 488 398 492 387 q 480 422 484 409 q 474 446 477 435 q 402 390 441 408 q 326 372 363 372 q 239 392 281 372 q 164 447 197 411 q 112 535 132 484 q 92 650 92 586 q 114 787 92 725 q 173 894 136 850 q 260 963 211 939 q 366 988 310 988 q 440 972 406 988 q 508 931 475 956 q 511 957 511 947 q 514 971 512 966 q 522 978 516 977 q 539 981 527 980 q 615 991 578 987 q 694 998 652 996 l 639 505 m 481 705 q 487 742 484 724 q 490 776 489 760 l 492 810 q 474 823 484 816 q 452 836 464 830 q 428 846 441 842 q 402 850 415 850 q 354 831 374 850 q 323 786 335 812 q 306 729 311 759 q 301 675 301 699 q 323 553 301 592 q 385 515 345 515 q 419 524 400 515 q 459 548 439 532 l 481 705 z " - }, - "«": { - "ha": 1378, - "x_min": 73, - "x_max": 1361, - "o": "m 681 220 q 686 212 686 216 q 684 204 686 209 q 634 99 654 153 q 591 -7 613 45 q 574 -20 587 -20 q 563 -18 568 -20 q 548 -12 557 -16 l 114 248 q 85 265 92 258 q 79 286 79 272 q 78 390 79 337 q 74 500 78 443 q 74 502 74 501 q 73 503 73 503 l 75 508 q 78 514 75 511 q 83 516 81 516 q 142 542 106 527 q 223 573 178 556 q 319 609 268 590 q 424 647 371 628 q 530 686 477 667 q 631 724 583 706 q 662 730 652 730 q 673 720 671 730 q 676 610 674 667 q 690 502 679 553 q 687 490 690 494 q 681 486 685 487 l 378 376 q 408 361 386 372 q 460 334 430 349 q 524 301 490 318 q 589 267 558 283 q 645 238 621 251 q 681 220 669 226 m 1352 220 q 1358 212 1358 216 q 1356 204 1358 209 q 1305 99 1326 153 q 1263 -7 1284 45 q 1245 -20 1258 -20 q 1234 -18 1240 -20 q 1219 -12 1229 -16 l 785 248 q 757 265 764 258 q 750 286 750 272 q 750 390 750 337 q 745 500 749 443 q 745 502 745 501 q 745 503 745 503 l 746 508 q 749 514 747 511 q 754 516 752 516 q 813 542 777 527 q 895 573 850 556 q 991 609 939 590 q 1096 647 1042 628 q 1202 686 1149 667 q 1303 724 1255 706 q 1333 730 1324 730 q 1344 720 1342 730 q 1348 610 1345 667 q 1361 502 1350 553 q 1359 490 1361 494 q 1352 486 1356 487 l 1050 376 q 1079 361 1057 372 q 1131 334 1101 349 q 1195 301 1161 318 q 1261 267 1230 283 q 1316 238 1292 251 q 1352 220 1341 226 z " - }, - "¬": { - "ha": 718, - "x_min": 74, - "x_max": 671, - "o": "m 174 351 q 97 354 121 351 q 74 367 74 357 q 78 384 74 372 q 90 408 83 395 q 107 436 98 421 q 127 462 117 450 q 150 482 138 474 q 171 490 161 490 l 410 497 q 480 499 446 498 q 542 500 514 500 q 590 502 570 501 q 620 503 610 503 q 660 499 648 503 q 671 479 671 496 q 671 470 671 474 q 671 462 671 465 l 667 386 q 666 358 667 378 q 664 315 665 339 q 661 263 663 290 q 657 214 659 237 q 655 175 656 191 q 654 157 654 159 q 650 140 652 148 q 642 129 647 134 q 628 124 637 124 q 608 125 620 124 q 582 128 596 126 q 552 132 568 130 q 522 137 536 134 q 511 142 515 138 q 508 159 508 145 q 510 196 507 176 q 513 234 512 215 l 522 355 q 461 355 492 355 q 408 354 430 355 l 174 351 z " - }, - "®": { - "ha": 1112, - "x_min": 90, - "x_max": 1105, - "o": "m 553 242 q 551 235 552 239 q 546 230 550 231 q 529 223 541 227 q 502 213 517 218 q 471 203 487 208 q 441 193 455 197 q 419 186 428 189 q 410 183 410 183 q 400 186 404 183 q 395 196 395 189 q 397 235 395 208 q 401 299 399 262 q 407 378 404 335 q 415 467 411 422 q 422 556 418 512 q 429 640 426 601 q 427 641 429 641 q 399 637 420 641 q 351 628 377 633 q 342 633 342 628 q 342 635 342 634 l 406 746 q 507 765 451 755 q 635 774 564 774 q 715 766 676 774 q 784 739 754 758 q 832 691 814 721 q 850 616 850 661 q 842 573 850 593 q 820 538 833 554 q 791 510 807 522 q 761 489 775 498 q 736 475 747 480 q 722 467 725 469 q 723 464 722 467 q 728 455 724 462 q 740 435 732 448 q 761 400 748 422 q 793 346 774 378 q 839 267 812 313 q 854 260 846 262 q 870 259 863 259 q 883 258 878 258 q 888 253 888 257 q 882 245 888 250 q 867 237 876 241 q 849 229 858 233 q 836 222 840 224 q 816 214 826 218 q 794 204 806 210 q 768 192 783 199 q 735 175 753 184 q 726 171 730 172 q 719 170 722 170 q 706 174 711 170 q 698 181 701 177 q 692 191 694 186 q 689 199 690 195 l 572 446 l 553 242 m 576 494 q 618 505 597 494 q 658 531 640 515 q 687 564 675 546 q 698 596 698 581 q 629 664 698 664 q 615 663 622 664 q 604 662 609 663 l 592 660 l 576 494 m 559 70 q 675 84 619 70 q 780 123 731 98 q 868 186 828 149 q 937 271 908 224 q 981 374 965 318 q 996 494 996 430 q 971 633 996 568 q 900 746 945 698 q 790 822 854 794 q 650 850 726 850 q 484 821 563 850 q 347 738 406 791 q 253 609 288 684 q 218 442 218 534 q 241 300 218 368 q 309 181 264 233 q 416 100 353 130 q 559 70 479 70 m 534 -43 q 349 -3 431 -43 q 209 103 267 36 q 121 258 151 170 q 90 443 90 346 q 136 661 90 563 q 258 828 181 758 q 438 936 336 898 q 654 974 541 974 q 837 938 754 974 q 979 839 920 901 q 1072 691 1039 776 q 1105 510 1105 606 q 1085 354 1105 427 q 1027 219 1065 280 q 938 109 990 157 q 823 27 886 60 q 686 -25 759 -7 q 534 -43 613 -43 z " - }, - "°": { - "ha": 683, - "x_min": 89, - "x_max": 712, - "o": "m 398 378 q 276 398 333 378 q 178 455 220 418 q 113 548 136 493 q 89 671 89 602 q 114 791 89 734 q 183 890 139 848 q 287 957 227 932 q 418 982 347 982 q 533 962 479 982 q 627 905 587 942 q 689 817 667 869 q 712 702 712 765 q 690 584 712 642 q 628 480 669 526 q 529 406 587 434 q 398 378 471 378 m 513 672 q 514 684 513 677 q 514 696 514 690 q 509 739 514 716 q 494 780 505 762 q 465 811 483 799 q 420 823 447 823 q 357 810 384 823 q 314 775 331 797 q 288 728 296 754 q 279 674 279 701 q 283 630 279 653 q 299 587 288 606 q 329 554 310 567 q 378 540 348 541 q 434 552 410 540 q 475 583 458 564 q 500 625 491 602 q 513 672 509 648 z " - }, - "±": { - "ha": 709, - "x_min": 62, - "x_max": 684, - "o": "m 287 448 q 226 447 252 447 q 184 447 200 447 q 124 451 144 447 q 104 466 104 454 q 107 491 104 472 q 116 535 111 511 q 126 584 121 559 q 135 625 132 608 q 145 640 136 633 q 170 648 155 647 l 306 650 l 307 664 q 312 743 311 710 q 316 798 313 777 q 326 828 319 819 q 347 838 333 838 q 350 838 349 838 q 354 838 352 838 q 367 838 358 838 q 386 839 375 838 q 410 839 397 839 q 435 840 422 840 l 499 842 q 513 834 509 839 q 518 818 518 830 q 518 816 518 817 q 518 811 518 815 q 517 798 517 807 q 515 772 516 789 q 511 725 513 754 q 505 653 509 696 l 517 654 q 566 655 542 654 q 610 656 590 656 q 645 657 630 656 q 665 657 659 657 q 677 653 671 657 q 684 637 684 649 q 681 611 684 636 q 673 543 678 586 l 666 477 q 658 463 662 467 q 647 456 654 458 q 626 454 640 454 q 588 453 612 454 l 489 451 l 480 352 q 475 310 478 326 q 468 283 472 293 q 458 270 464 274 q 445 267 452 267 q 414 267 433 267 q 372 268 394 267 q 328 269 350 269 q 292 269 307 269 q 278 277 283 271 q 273 298 273 284 l 273 302 l 287 448 m 162 5 q 86 8 109 5 q 62 21 62 11 q 67 38 62 26 q 79 62 71 49 q 96 90 86 75 q 116 116 105 104 q 138 136 127 128 q 159 144 149 144 l 398 151 q 426 152 406 151 q 469 152 445 152 q 520 153 494 153 q 570 154 547 154 q 609 155 593 155 q 627 155 625 155 q 644 152 636 155 q 655 145 650 149 q 660 132 660 140 q 658 105 660 123 q 653 70 656 87 l 647 24 q 645 18 646 20 q 641 13 644 15 q 631 10 637 11 q 614 9 625 9 l 531 9 q 496 9 514 9 q 460 8 477 9 q 426 8 442 8 q 396 8 409 8 l 162 5 z " - }, - "²": { - "ha": 498, - "x_min": 90, - "x_max": 519, - "o": "m 472 764 q 461 742 469 756 q 442 710 453 728 q 418 672 431 692 q 393 631 406 651 l 326 526 q 327 525 326 525 l 328 525 q 356 527 335 525 q 404 532 378 529 q 456 536 430 534 q 498 538 482 538 q 519 529 519 538 q 516 517 519 524 q 513 511 513 511 l 452 397 q 451 395 452 397 q 450 393 451 393 q 435 384 442 385 q 422 382 428 383 q 333 381 369 382 q 269 380 297 380 q 217 380 241 380 q 162 380 193 380 q 105 386 121 380 q 90 405 90 393 q 95 424 90 413 q 110 448 101 434 l 190 561 q 286 699 251 644 q 321 783 321 753 q 314 813 321 800 q 294 835 307 826 q 266 849 282 844 q 230 854 249 854 q 181 846 206 854 q 132 823 155 839 q 118 818 122 818 q 112 822 113 818 q 111 829 111 826 q 115 868 111 846 q 124 910 119 890 q 134 945 130 930 q 138 962 138 960 q 149 969 139 962 q 182 987 159 977 q 240 1005 204 997 q 328 1013 275 1013 q 389 1000 358 1013 q 444 965 419 987 q 483 914 468 943 q 498 850 498 884 q 492 808 498 829 q 472 764 486 786 z " - }, - "³": { - "ha": 507, - "x_min": 101, - "x_max": 503, - "o": "m 328 368 q 295 366 311 366 q 252 369 272 366 q 212 377 232 372 q 172 391 192 382 q 128 408 151 399 q 117 424 121 410 q 112 455 114 437 q 107 495 109 474 q 101 534 105 517 q 114 550 101 550 q 117 549 117 550 q 147 531 132 541 q 179 513 162 521 q 217 499 197 505 q 260 494 237 494 q 307 507 291 494 q 322 551 322 520 q 320 569 322 559 q 312 586 318 578 q 293 600 305 594 q 261 605 281 605 l 187 605 q 189 616 187 607 q 192 639 190 626 q 196 667 193 652 q 200 695 198 682 q 203 717 201 708 q 204 727 204 726 q 209 745 207 741 q 214 750 212 750 q 233 748 224 750 q 251 746 241 746 q 291 763 277 746 q 305 805 305 779 q 293 841 305 825 q 254 857 281 857 q 193 850 224 857 q 139 836 163 844 q 140 845 140 840 q 140 857 140 850 q 140 870 140 863 q 140 884 140 877 q 141 909 140 897 q 144 933 142 922 q 153 952 147 944 q 168 963 158 960 q 207 974 191 970 q 238 980 224 978 q 267 983 253 983 q 300 984 281 984 q 368 975 334 984 q 431 947 403 966 q 477 899 459 928 q 494 831 494 870 q 487 783 494 804 q 469 745 480 762 q 446 716 458 728 q 422 694 433 703 q 450 678 435 688 q 476 652 464 667 q 495 614 488 636 q 503 563 503 592 q 490 494 503 528 q 453 433 477 460 q 398 388 430 406 q 328 368 366 370 z " - }, - "´": { - "ha": 431, - "x_min": 32, - "x_max": 415, - "o": "m 255 944 q 205 876 225 903 q 172 833 185 849 q 152 812 159 818 q 140 806 144 806 q 133 808 136 806 q 107 825 119 818 q 85 838 96 832 q 65 849 75 844 q 41 861 54 854 q 32 875 32 866 q 34 888 33 880 q 40 907 36 895 l 165 1271 q 172 1284 169 1280 q 180 1287 176 1287 q 186 1285 183 1287 q 193 1282 190 1284 q 299 1220 246 1246 q 403 1168 351 1195 q 415 1149 415 1160 q 404 1122 415 1139 q 360 1071 377 1091 q 327 1033 342 1051 q 296 994 312 1015 q 255 944 279 974 z " - }, - "µ": { - "ha": 888, - "x_min": 55, - "x_max": 890, - "o": "m 108 235 q 138 544 128 438 q 149 658 148 650 q 154 688 151 680 q 169 700 157 697 q 230 711 201 706 q 287 722 258 716 q 344 734 315 728 q 406 751 373 741 q 408 751 407 751 q 411 751 410 751 q 419 745 419 751 q 414 701 416 722 q 409 660 412 681 q 405 614 407 639 q 399 557 402 589 q 391 483 395 525 q 380 385 387 441 q 373 315 376 351 q 368 248 370 279 q 388 175 368 197 q 439 153 408 153 q 486 163 461 153 q 531 191 510 174 q 565 232 551 209 q 581 281 579 255 q 590 393 586 348 q 596 469 593 438 q 601 521 599 500 q 605 561 603 542 q 608 603 606 581 q 610 658 609 625 q 615 689 612 680 q 631 700 618 697 q 757 725 692 712 q 883 757 821 737 q 889 755 888 757 q 890 750 890 753 l 827 73 q 824 54 825 62 q 821 42 823 47 q 816 36 819 38 q 806 31 812 33 q 747 15 778 23 q 686 -2 717 7 q 624 -21 654 -11 q 564 -45 593 -32 q 558 -46 563 -46 q 552 -44 553 -46 q 551 -39 551 -42 q 551 -35 551 -38 q 552 -21 551 -31 q 555 8 553 -11 q 563 60 558 27 q 529 33 549 45 q 487 12 509 21 q 441 -1 465 3 q 397 -6 418 -6 q 351 2 370 -6 q 326 30 332 11 l 302 -168 q 301 -177 301 -170 l 301 -183 q 297 -193 301 -189 q 275 -201 293 -196 l 118 -222 q 99 -224 111 -223 q 77 -225 87 -225 q 62 -221 68 -225 q 55 -206 55 -217 q 56 -201 55 -202 q 82 12 68 -95 q 108 235 96 119 z " - }, - "μ": { - "ha": 888, - "x_min": 55, - "x_max": 890, - "o": "m 108 235 q 138 544 128 438 q 149 658 148 650 q 154 688 151 680 q 169 700 157 697 q 230 711 201 706 q 287 722 258 716 q 344 734 315 728 q 406 751 373 741 q 408 751 407 751 q 411 751 410 751 q 419 745 419 751 q 414 701 416 722 q 409 660 412 681 q 405 614 407 639 q 399 557 402 589 q 391 483 395 525 q 380 385 387 441 q 373 315 376 351 q 368 248 370 279 q 388 175 368 197 q 439 153 408 153 q 486 163 461 153 q 531 191 510 174 q 565 232 551 209 q 581 281 579 255 q 590 393 586 348 q 596 469 593 438 q 601 521 599 500 q 605 561 603 542 q 608 603 606 581 q 610 658 609 625 q 615 689 612 680 q 631 700 618 697 q 757 725 692 712 q 883 757 821 737 q 889 755 888 757 q 890 750 890 753 l 827 73 q 824 54 825 62 q 821 42 823 47 q 816 36 819 38 q 806 31 812 33 q 747 15 778 23 q 686 -2 717 7 q 624 -21 654 -11 q 564 -45 593 -32 q 558 -46 563 -46 q 552 -44 553 -46 q 551 -39 551 -42 q 551 -35 551 -38 q 552 -21 551 -31 q 555 8 553 -11 q 563 60 558 27 q 529 33 549 45 q 487 12 509 21 q 441 -1 465 3 q 397 -6 418 -6 q 351 2 370 -6 q 326 30 332 11 l 302 -168 q 301 -177 301 -170 l 301 -183 q 297 -193 301 -189 q 275 -201 293 -196 l 118 -222 q 99 -224 111 -223 q 77 -225 87 -225 q 62 -221 68 -225 q 55 -206 55 -217 q 56 -201 55 -202 q 82 12 68 -95 q 108 235 96 119 z " - }, - "¶": { - "ha": 896, - "x_min": 102, - "x_max": 920, - "o": "m 441 14 q 430 -4 439 1 q 399 -15 421 -9 q 386 -17 397 -16 q 361 -19 376 -18 q 329 -23 346 -21 q 296 -26 311 -24 q 270 -28 281 -27 q 255 -29 258 -29 q 237 -25 246 -29 q 229 -8 229 -21 q 229 -3 229 -4 l 306 479 q 221 518 259 495 q 157 570 183 541 q 116 635 130 599 q 102 713 102 671 q 119 803 102 764 q 165 872 136 843 q 233 923 194 902 q 317 956 273 943 q 410 975 362 969 q 505 981 458 981 q 606 977 552 981 q 711 968 661 973 q 801 958 761 963 q 859 948 841 952 q 885 940 874 943 q 902 933 895 937 q 911 923 908 929 q 914 904 913 916 q 916 873 915 891 q 917 837 916 856 q 918 800 917 818 q 919 767 918 781 q 919 743 919 752 q 920 734 920 734 q 903 722 916 722 q 814 724 881 722 q 791 585 804 663 q 762 404 778 506 q 740 250 750 323 q 731 185 736 218 q 722 121 726 152 q 714 62 718 90 q 707 14 710 34 q 696 -4 706 2 q 666 -15 687 -10 q 642 -18 663 -16 q 598 -23 622 -20 q 554 -27 574 -25 q 528 -29 533 -29 q 511 -24 519 -29 q 503 -6 503 -20 l 577 449 q 550 447 564 448 q 523 446 536 446 l 509 446 q 492 346 499 395 q 477 250 484 296 q 468 185 473 218 q 457 120 463 152 q 448 61 452 89 q 441 14 444 34 z " - }, - "·": { - "ha": 380, - "x_min": 106, - "x_max": 397, - "o": "m 106 553 q 108 603 107 585 q 109 632 109 622 q 109 646 109 642 q 109 654 109 650 q 110 663 109 658 q 111 681 110 669 q 113 716 111 694 q 116 774 114 738 q 120 805 117 797 q 136 816 123 814 q 260 816 195 816 q 383 817 326 817 q 393 814 389 817 q 397 801 397 810 l 378 588 q 373 557 376 566 q 358 547 371 549 q 240 546 300 547 q 113 545 179 545 q 107 546 109 545 q 106 550 106 547 l 106 553 z " - }, - "¸": { - "ha": 370, - "x_min": 43, - "x_max": 339, - "o": "m 336 -262 q 313 -320 330 -294 q 273 -365 296 -346 q 219 -394 249 -383 q 159 -404 190 -404 q 99 -400 130 -404 q 43 -382 67 -396 l 45 -383 q 44 -378 44 -382 q 45 -357 44 -370 q 48 -330 46 -345 q 52 -302 50 -315 q 57 -279 54 -288 l 60 -279 q 64 -281 64 -279 l 64 -281 q 84 -289 75 -286 q 104 -294 94 -292 q 127 -296 115 -296 q 157 -297 140 -297 q 201 -280 185 -297 q 216 -241 216 -263 q 204 -208 216 -221 q 170 -195 191 -195 q 106 -192 132 -195 q 69 -189 79 -189 q 63 -186 64 -189 q 62 -180 62 -184 q 70 -159 65 -174 q 79 -126 74 -144 q 88 -89 83 -109 q 96 -53 92 -69 q 102 -25 100 -36 q 104 -12 104 -14 l 117 -12 q 147 -12 129 -12 q 183 -12 165 -12 l 226 -12 l 193 -108 q 215 -105 205 -106 q 233 -104 224 -104 q 289 -116 268 -104 q 320 -144 309 -127 q 335 -184 332 -162 q 339 -230 339 -207 q 338 -246 339 -238 q 336 -262 338 -254 z " - }, - "¹": { - "ha": 349, - "x_min": 130, - "x_max": 338, - "o": "m 155 915 q 158 936 156 930 q 168 944 159 942 l 317 980 q 323 981 320 981 q 328 981 326 981 q 336 978 334 981 q 338 963 338 974 l 313 432 q 308 405 312 412 q 292 395 303 398 l 158 355 q 152 354 155 354 q 148 353 149 353 q 135 357 140 353 q 130 373 130 361 q 130 378 130 374 q 130 398 130 382 q 133 449 131 415 q 137 543 134 483 q 144 694 140 603 q 155 915 149 785 z " - }, - "º": { - "ha": 698, - "x_min": 88, - "x_max": 726, - "o": "m 390 370 q 259 395 315 370 q 164 459 202 419 q 107 552 126 500 q 88 662 88 605 q 107 770 88 719 q 159 862 125 821 q 238 929 192 902 q 341 966 285 956 q 349 970 349 966 q 348 981 349 975 q 347 989 347 986 q 349 997 347 995 q 354 999 351 999 q 525 976 454 999 q 641 913 596 953 q 705 820 685 873 q 726 704 726 766 q 699 563 726 625 q 627 458 673 500 q 520 393 581 415 q 390 370 459 370 m 292 668 q 298 611 292 640 q 318 561 304 583 q 355 524 332 538 q 412 510 378 510 q 471 532 448 512 q 507 581 494 553 q 525 642 520 610 q 530 699 530 673 q 522 753 530 726 q 498 800 514 779 q 459 832 482 820 q 404 845 435 845 q 351 826 372 845 q 316 780 330 807 q 297 722 303 752 q 292 668 292 691 z " - }, - "»": { - "ha": 1364, - "x_min": 78, - "x_max": 1374, - "o": "m 755 220 q 792 239 766 226 q 849 268 817 252 q 916 301 881 283 q 981 334 950 319 q 1034 361 1011 349 q 1064 376 1057 372 l 766 486 q 758 502 758 487 q 775 610 770 553 q 784 720 780 667 q 795 730 786 730 q 825 724 804 730 q 925 687 873 706 q 1030 648 977 667 q 1133 609 1082 628 q 1227 573 1183 591 q 1307 542 1272 556 q 1365 516 1343 527 q 1370 514 1367 516 q 1373 508 1373 511 l 1374 503 q 1374 502 1374 503 q 1373 500 1373 501 q 1364 390 1367 443 q 1360 286 1362 337 q 1352 265 1360 272 q 1323 248 1345 258 l 878 -12 q 863 -18 869 -16 q 852 -20 858 -20 q 842 -17 845 -20 q 836 -7 838 -14 q 797 100 816 46 q 751 204 777 153 q 749 212 749 208 q 750 217 749 215 q 755 220 751 218 m 83 220 q 120 239 95 226 q 178 268 146 252 q 244 301 210 283 q 309 334 279 319 q 362 361 340 349 q 393 376 385 372 l 94 486 q 86 502 86 487 q 103 610 98 553 q 113 720 109 667 q 123 730 115 730 q 154 724 132 730 q 254 687 201 706 q 358 648 306 667 q 461 609 411 628 q 556 573 512 591 q 636 542 600 556 q 694 516 671 527 q 699 514 696 516 q 702 508 701 511 l 703 503 q 702 502 703 503 q 702 500 702 501 q 693 390 696 443 q 688 286 690 337 q 681 265 688 272 q 652 248 673 258 l 207 -12 q 192 -18 197 -16 q 181 -20 186 -20 q 170 -17 174 -20 q 164 -7 167 -14 q 125 100 144 46 q 79 204 106 153 q 78 212 78 208 q 79 217 78 215 q 83 220 80 218 z " - }, - "¼": { - "ha": 1161, - "x_min": 121, - "x_max": 1151, - "o": "m 147 915 q 150 936 148 930 q 159 944 151 942 l 309 980 q 315 981 312 981 q 319 981 317 981 q 328 978 326 981 q 330 963 330 974 l 305 432 q 299 405 304 412 q 284 395 295 398 l 150 355 q 144 354 146 354 q 140 353 141 353 q 127 357 132 353 q 121 373 121 361 q 121 378 121 374 q 122 398 121 382 q 124 449 123 415 q 129 543 126 483 q 136 694 132 603 q 147 915 140 785 m 502 640 q 581 819 543 729 q 660 1001 619 908 q 673 1028 669 1021 q 688 1036 678 1036 l 692 1036 q 765 1004 729 1021 q 836 980 800 987 q 843 977 840 979 q 846 971 846 975 l 846 969 l 412 10 q 408 -1 409 4 q 405 -11 406 -7 q 400 -17 403 -15 q 392 -20 397 -20 q 374 -15 384 -20 l 306 14 q 290 19 300 16 q 268 28 279 23 q 248 40 256 33 q 239 56 239 47 q 243 68 239 62 q 303 198 274 134 q 362 329 332 261 q 426 473 392 397 q 502 640 460 549 m 1138 197 q 1128 147 1133 173 q 1126 137 1126 140 q 1120 133 1126 134 q 1098 132 1114 132 q 1051 132 1082 132 l 1043 52 q 1042 45 1043 49 q 1036 39 1040 41 q 1022 34 1033 38 q 996 23 1011 29 q 963 12 981 18 q 930 0 946 5 q 903 -9 915 -5 q 886 -12 890 -12 q 876 -9 880 -12 q 871 3 871 -6 q 873 56 871 24 q 879 130 876 88 q 806 129 842 130 q 739 129 770 129 q 685 129 708 129 q 650 128 661 128 q 595 131 611 128 q 578 143 578 134 q 579 148 578 145 q 583 155 580 151 q 597 179 587 161 q 621 220 607 196 q 653 272 635 243 q 688 329 670 300 l 777 477 q 806 531 793 505 q 835 579 819 557 q 872 617 850 601 q 928 640 894 633 l 1064 675 q 1070 676 1067 676 q 1076 677 1073 677 q 1084 674 1081 677 q 1086 663 1086 671 l 1086 659 q 1081 554 1084 599 q 1076 469 1078 510 q 1070 382 1073 427 q 1065 278 1067 338 q 1113 279 1094 279 q 1135 279 1132 279 q 1146 276 1141 279 q 1151 264 1151 272 q 1150 259 1151 260 l 1138 197 m 890 272 q 899 335 895 302 q 906 402 903 368 q 911 470 909 436 q 914 536 913 504 l 757 272 l 890 272 z " - }, - "½": { - "ha": 1185, - "x_min": 123, - "x_max": 1166, - "o": "m 149 915 q 151 936 149 930 q 161 944 153 942 l 310 980 q 316 981 313 981 q 321 981 319 981 q 329 978 327 981 q 332 963 332 974 l 307 432 q 301 405 305 412 q 286 395 296 398 l 151 355 q 145 354 148 354 q 141 353 142 353 q 128 357 134 353 q 123 373 123 361 q 123 378 123 374 q 123 398 123 382 q 126 449 124 415 q 130 543 127 483 q 137 694 133 603 q 149 915 142 785 m 503 640 q 583 819 545 729 q 661 1001 621 908 q 675 1028 670 1021 q 689 1036 680 1036 l 694 1036 q 766 1004 730 1021 q 838 980 802 987 q 845 977 842 979 q 848 971 848 975 l 848 969 l 413 10 q 409 -1 410 4 q 406 -11 408 -7 q 401 -17 404 -15 q 393 -20 399 -20 q 376 -15 385 -20 l 307 14 q 291 19 302 16 q 269 28 280 23 q 249 40 258 33 q 241 56 241 47 q 244 68 241 62 q 304 198 275 134 q 363 329 333 261 q 427 473 393 397 q 503 640 461 549 m 1118 382 q 1107 360 1115 374 q 1088 329 1099 347 q 1065 290 1078 311 q 1039 249 1052 269 l 972 144 q 973 143 972 143 l 975 143 q 1003 145 981 143 q 1050 150 1024 147 q 1102 155 1076 153 q 1144 157 1128 157 q 1166 147 1166 157 q 1163 136 1166 142 q 1160 129 1160 130 l 1099 15 q 1098 13 1098 15 q 1097 12 1097 12 q 1081 2 1088 3 q 1069 1 1074 1 q 979 -1 1015 0 q 916 -2 943 -1 q 863 -2 888 -2 q 808 -2 839 -2 q 752 4 768 -2 q 736 23 736 11 q 742 42 736 31 q 756 66 747 52 l 836 179 q 932 317 897 262 q 967 401 967 371 q 960 431 967 418 q 941 453 953 444 q 912 467 928 463 q 876 472 895 472 q 827 465 852 472 q 778 441 802 457 q 764 436 768 436 q 758 440 760 436 q 757 448 757 444 q 761 486 757 464 q 771 528 766 508 q 780 563 776 548 q 785 580 785 578 q 795 588 785 580 q 828 605 806 595 q 886 623 850 615 q 974 631 922 631 q 1035 618 1004 631 q 1090 584 1065 606 q 1129 532 1114 562 q 1145 468 1145 503 q 1138 426 1145 448 q 1118 382 1132 404 z " - }, - "¾": { - "ha": 1305, - "x_min": 92, - "x_max": 1294, - "o": "m 319 368 q 286 366 301 366 q 242 369 262 366 q 202 377 222 372 q 162 391 182 382 q 119 408 142 399 q 108 424 111 410 q 102 455 104 437 q 98 495 100 474 q 92 534 96 517 q 104 550 92 550 q 108 549 107 550 q 137 531 122 541 q 170 513 153 521 q 207 499 187 505 q 251 494 227 494 q 297 507 281 494 q 313 551 313 520 q 311 569 313 559 q 302 586 309 578 q 284 600 296 594 q 252 605 272 605 l 178 605 q 179 616 178 607 q 182 639 180 626 q 186 667 184 652 q 190 695 189 682 q 193 717 192 708 q 195 727 195 726 q 200 745 197 741 q 205 750 202 750 q 223 748 214 750 q 241 746 232 746 q 281 763 267 746 q 296 805 296 779 q 284 841 296 825 q 245 857 272 857 q 184 850 214 857 q 130 836 153 844 q 131 845 130 840 q 131 857 131 850 q 131 870 131 863 q 130 884 130 877 q 131 909 130 897 q 135 933 132 922 q 143 952 138 944 q 158 963 149 960 q 198 974 181 970 q 229 980 214 978 q 258 983 243 983 q 290 984 272 984 q 359 975 324 984 q 421 947 393 966 q 467 899 450 928 q 485 831 485 870 q 478 783 485 804 q 460 745 471 762 q 436 716 449 728 q 412 694 423 703 q 440 678 426 688 q 466 652 454 667 q 486 614 478 636 q 494 563 494 592 q 480 494 494 528 q 444 433 467 460 q 388 388 420 406 q 319 368 356 370 m 645 640 q 724 819 686 729 q 803 1001 762 908 q 817 1028 812 1021 q 831 1036 821 1036 l 836 1036 q 908 1004 872 1021 q 979 980 943 987 q 986 977 983 979 q 989 971 989 975 l 989 969 l 555 10 q 551 -1 552 4 q 548 -11 549 -7 q 543 -17 546 -15 q 535 -20 541 -20 q 517 -15 527 -20 l 449 14 q 433 19 444 16 q 411 28 422 23 q 391 40 399 33 q 382 56 382 47 q 386 68 382 62 q 446 198 417 134 q 505 329 475 261 q 569 473 535 397 q 645 640 603 549 m 1281 197 q 1271 147 1276 173 q 1269 137 1270 140 q 1263 133 1269 134 q 1241 132 1257 132 q 1194 132 1225 132 l 1186 52 q 1185 45 1186 49 q 1179 39 1183 41 q 1165 34 1176 38 q 1139 23 1154 29 q 1106 12 1124 18 q 1074 0 1089 5 q 1046 -9 1058 -5 q 1029 -12 1034 -12 q 1019 -9 1023 -12 q 1015 3 1015 -6 q 1017 56 1015 24 q 1022 130 1019 88 q 949 129 985 130 q 882 129 913 129 q 828 129 851 129 q 793 128 804 128 q 738 131 754 128 q 722 143 722 134 q 722 148 722 145 q 726 155 723 151 q 740 179 730 161 q 764 220 750 196 q 796 272 779 243 q 831 329 813 300 l 920 477 q 949 531 937 505 q 978 579 962 557 q 1015 617 994 601 q 1071 640 1037 633 l 1207 675 q 1213 676 1211 676 q 1219 677 1216 677 q 1227 674 1224 677 q 1230 663 1230 671 l 1230 659 q 1224 554 1227 599 q 1219 469 1221 510 q 1213 382 1216 427 q 1208 278 1211 338 q 1256 279 1237 279 q 1278 279 1275 279 q 1289 276 1284 279 q 1294 264 1294 272 q 1293 259 1294 260 l 1281 197 m 1034 272 q 1042 335 1038 302 q 1049 402 1046 368 q 1054 470 1052 436 q 1057 536 1056 504 l 900 272 l 1034 272 z " - }, - "¿": { - "ha": 791, - "x_min": 73, - "x_max": 776, - "o": "m 580 541 q 491 479 533 516 q 416 399 448 441 q 366 314 385 356 q 347 236 347 271 q 368 174 347 198 q 437 151 389 151 q 482 157 465 151 q 510 174 500 164 q 525 196 521 184 q 529 220 529 208 q 524 248 529 235 q 520 265 520 261 q 529 273 520 271 q 560 278 539 275 q 617 288 581 282 q 703 309 652 294 q 734 316 723 314 q 751 318 745 318 q 763 308 758 318 q 771 284 768 298 q 775 255 774 270 q 776 231 776 240 q 745 119 776 168 q 665 36 714 70 q 553 -16 615 2 q 429 -34 491 -34 q 283 -9 348 -34 q 171 55 217 16 q 99 142 124 94 q 74 237 74 191 q 87 314 74 276 q 123 387 101 351 q 176 457 146 423 q 240 522 206 491 q 307 582 273 553 q 373 636 341 610 q 378 640 374 638 q 386 642 382 642 q 391 641 388 642 q 395 639 394 640 q 442 617 421 627 q 482 600 463 608 q 523 585 502 591 q 568 573 543 579 q 582 567 578 571 q 587 558 587 562 q 581 549 581 554 q 580 541 580 544 m 577 973 q 575 923 576 941 q 574 894 574 904 q 574 880 574 884 q 574 872 574 876 q 573 863 574 868 q 572 845 573 857 q 570 810 572 832 q 567 751 569 788 q 563 721 566 729 q 547 710 560 712 q 423 710 488 710 q 300 709 357 709 q 289 713 292 709 q 286 729 286 718 l 305 938 q 310 969 307 960 q 325 979 312 977 q 443 980 383 979 q 570 981 504 981 q 576 980 575 981 q 577 973 577 979 z " - }, - "À": { - "ha": 940, - "x_min": 29, - "x_max": 965, - "o": "m 45 50 q 64 89 54 67 q 81 137 73 111 l 100 182 q 75 221 87 200 q 52 265 62 243 q 36 310 42 288 q 29 353 29 332 q 40 356 29 355 q 66 357 50 357 q 101 358 82 358 q 135 359 119 359 q 162 360 151 359 q 172 360 172 360 q 203 437 188 401 q 233 511 218 474 q 262 588 248 549 q 292 671 277 627 q 348 819 321 755 q 399 938 375 883 q 408 950 401 945 q 422 960 414 956 q 436 967 429 964 q 448 971 444 970 q 468 977 450 972 q 509 989 486 983 q 555 1000 532 995 q 591 1004 578 1004 l 604 1004 q 624 999 614 1004 q 637 979 634 994 q 707 797 670 896 q 779 580 744 699 q 817 459 798 516 q 853 348 835 402 q 890 239 871 294 q 928 127 909 185 q 941 89 935 103 q 953 66 947 75 q 962 55 958 58 q 965 47 965 51 q 952 39 965 43 l 806 -9 q 773 -21 790 -15 q 741 -32 756 -27 q 715 -40 726 -37 q 699 -43 704 -43 l 695 -43 q 682 -37 686 -43 q 676 -26 677 -31 q 663 15 669 -3 q 649 51 656 33 q 636 89 643 68 q 624 137 630 109 q 616 143 623 140 q 602 146 610 145 q 584 148 593 148 q 566 149 574 149 q 525 148 541 149 q 496 148 509 148 q 473 147 484 147 q 446 146 462 146 q 405 147 426 146 q 368 148 385 147 l 329 149 q 294 58 311 100 q 256 -31 276 15 q 249 -39 254 -36 q 239 -43 244 -43 q 234 -42 235 -43 q 123 5 168 -18 q 45 50 79 28 m 503 659 q 470 550 486 599 q 441 463 454 500 q 418 398 428 425 q 405 358 409 372 l 405 352 q 404 347 405 348 l 567 347 q 551 414 559 380 q 534 485 543 448 q 518 565 526 522 q 503 659 510 608 m 437 1194 q 410 1242 421 1223 q 390 1278 399 1261 q 370 1314 380 1295 q 344 1362 359 1333 q 339 1376 340 1369 q 337 1388 338 1383 q 340 1400 337 1396 q 351 1408 344 1404 q 403 1437 376 1422 q 458 1467 431 1451 q 514 1498 486 1482 q 566 1532 541 1514 q 576 1535 573 1535 q 581 1530 580 1535 l 657 1133 q 660 1119 659 1124 q 661 1107 661 1113 q 659 1096 661 1101 q 650 1087 657 1090 q 624 1076 636 1081 q 600 1064 612 1070 q 575 1052 588 1059 q 545 1035 562 1045 q 538 1032 543 1032 q 524 1041 532 1032 q 506 1070 517 1050 q 478 1120 494 1089 q 437 1194 461 1151 z " - }, - "Á": { - "ha": 940, - "x_min": 29, - "x_max": 965, - "o": "m 45 50 q 64 89 54 67 q 81 137 73 111 l 100 182 q 75 221 87 200 q 52 265 62 243 q 36 310 42 288 q 29 353 29 332 q 40 356 29 355 q 66 357 50 357 q 101 358 82 358 q 135 359 119 359 q 162 360 151 359 q 172 360 172 360 q 203 437 188 401 q 233 511 218 474 q 262 588 248 549 q 292 671 277 627 q 348 819 321 755 q 399 938 375 883 q 408 950 401 945 q 422 960 414 956 q 436 967 429 964 q 448 971 444 970 q 468 977 450 972 q 509 989 486 983 q 555 1000 532 995 q 591 1004 578 1004 l 604 1004 q 624 999 614 1004 q 637 979 634 994 q 707 797 670 896 q 779 580 744 699 q 817 459 798 516 q 853 348 835 402 q 890 239 871 294 q 928 127 909 185 q 941 89 935 103 q 953 66 947 75 q 962 55 958 58 q 965 47 965 51 q 952 39 965 43 l 806 -9 q 773 -21 790 -15 q 741 -32 756 -27 q 715 -40 726 -37 q 699 -43 704 -43 l 695 -43 q 682 -37 686 -43 q 676 -26 677 -31 q 663 15 669 -3 q 649 51 656 33 q 636 89 643 68 q 624 137 630 109 q 616 143 623 140 q 602 146 610 145 q 584 148 593 148 q 566 149 574 149 q 525 148 541 149 q 496 148 509 148 q 473 147 484 147 q 446 146 462 146 q 405 147 426 146 q 368 148 385 147 l 329 149 q 294 58 311 100 q 256 -31 276 15 q 249 -39 254 -36 q 239 -43 244 -43 q 234 -42 235 -43 q 123 5 168 -18 q 45 50 79 28 m 503 659 q 470 550 486 599 q 441 463 454 500 q 418 398 428 425 q 405 358 409 372 l 405 352 q 404 347 405 348 l 567 347 q 551 414 559 380 q 534 485 543 448 q 518 565 526 522 q 503 659 510 608 m 529 1171 q 479 1102 499 1129 q 446 1060 459 1076 q 426 1038 433 1044 q 414 1032 418 1032 q 407 1035 410 1032 q 381 1052 393 1044 q 359 1064 370 1059 q 339 1076 349 1070 q 315 1087 328 1081 q 306 1101 306 1093 q 308 1114 307 1107 q 314 1133 310 1122 l 439 1497 q 446 1510 443 1507 q 454 1514 450 1514 q 460 1512 457 1514 q 467 1508 464 1510 q 573 1447 520 1472 q 677 1394 625 1421 q 689 1376 689 1387 q 677 1348 689 1365 q 634 1298 651 1318 q 601 1259 616 1278 q 570 1221 586 1241 q 529 1171 553 1200 z " - }, - "Â": { - "ha": 940, - "x_min": 29, - "x_max": 965, - "o": "m 45 50 q 64 89 54 67 q 81 137 73 111 l 100 182 q 75 221 87 200 q 52 265 62 243 q 36 310 42 288 q 29 353 29 332 q 40 356 29 355 q 66 357 50 357 q 101 358 82 358 q 135 359 119 359 q 162 360 151 359 q 172 360 172 360 q 203 437 188 401 q 233 511 218 474 q 262 588 248 549 q 292 671 277 627 q 348 819 321 755 q 399 938 375 883 q 408 950 401 945 q 422 960 414 956 q 436 967 429 964 q 448 971 444 970 q 468 977 450 972 q 509 989 486 983 q 555 1000 532 995 q 591 1004 578 1004 l 604 1004 q 624 999 614 1004 q 637 979 634 994 q 707 797 670 896 q 779 580 744 699 q 817 459 798 516 q 853 348 835 402 q 890 239 871 294 q 928 127 909 185 q 941 89 935 103 q 953 66 947 75 q 962 55 958 58 q 965 47 965 51 q 952 39 965 43 l 806 -9 q 773 -21 790 -15 q 741 -32 756 -27 q 715 -40 726 -37 q 699 -43 704 -43 l 695 -43 q 682 -37 686 -43 q 676 -26 677 -31 q 663 15 669 -3 q 649 51 656 33 q 636 89 643 68 q 624 137 630 109 q 616 143 623 140 q 602 146 610 145 q 584 148 593 148 q 566 149 574 149 q 525 148 541 149 q 496 148 509 148 q 473 147 484 147 q 446 146 462 146 q 405 147 426 146 q 368 148 385 147 l 329 149 q 294 58 311 100 q 256 -31 276 15 q 249 -39 254 -36 q 239 -43 244 -43 q 234 -42 235 -43 q 123 5 168 -18 q 45 50 79 28 m 503 659 q 470 550 486 599 q 441 463 454 500 q 418 398 428 425 q 405 358 409 372 l 405 352 q 404 347 405 348 l 567 347 q 551 414 559 380 q 534 485 543 448 q 518 565 526 522 q 503 659 510 608 m 695 1354 q 721 1321 710 1335 q 739 1295 731 1307 q 754 1273 747 1284 q 769 1251 761 1263 q 782 1232 773 1244 q 801 1206 791 1220 q 817 1179 810 1192 q 824 1156 824 1165 q 811 1137 824 1147 q 779 1119 798 1128 q 742 1103 761 1110 q 713 1091 724 1095 q 692 1082 703 1088 q 670 1071 681 1076 q 649 1062 659 1065 q 635 1058 640 1058 q 624 1064 630 1058 q 610 1084 618 1069 l 522 1271 q 440 1167 481 1218 q 357 1064 399 1117 q 349 1059 355 1059 q 333 1065 345 1059 q 303 1079 320 1071 q 269 1095 286 1086 q 237 1110 251 1104 q 219 1119 230 1114 q 197 1129 208 1124 q 180 1140 187 1135 q 173 1150 173 1145 q 179 1166 173 1157 q 199 1187 185 1175 l 301 1303 q 376 1386 340 1345 q 450 1470 413 1427 q 468 1480 459 1479 q 485 1481 477 1481 l 588 1481 q 604 1480 596 1481 q 618 1469 612 1478 q 627 1455 618 1468 q 646 1426 635 1443 q 671 1389 658 1409 q 695 1354 684 1369 z " - }, - "Ã": { - "ha": 940, - "x_min": 29, - "x_max": 965, - "o": "m 45 50 q 64 89 54 67 q 81 137 73 111 l 100 182 q 75 221 87 200 q 52 265 62 243 q 36 310 42 288 q 29 353 29 332 q 40 356 29 355 q 66 357 50 357 q 101 358 82 358 q 135 359 119 359 q 162 360 151 359 q 172 360 172 360 q 203 437 188 401 q 233 511 218 474 q 262 588 248 549 q 292 671 277 627 q 348 819 321 755 q 399 938 375 883 q 408 950 401 945 q 422 960 414 956 q 436 967 429 964 q 448 971 444 970 q 468 977 450 972 q 509 989 486 983 q 555 1000 532 995 q 591 1004 578 1004 l 604 1004 q 624 999 614 1004 q 637 979 634 994 q 707 797 670 896 q 779 580 744 699 q 817 459 798 516 q 853 348 835 402 q 890 239 871 294 q 928 127 909 185 q 941 89 935 103 q 953 66 947 75 q 962 55 958 58 q 965 47 965 51 q 952 39 965 43 l 806 -9 q 773 -21 790 -15 q 741 -32 756 -27 q 715 -40 726 -37 q 699 -43 704 -43 l 695 -43 q 682 -37 686 -43 q 676 -26 677 -31 q 663 15 669 -3 q 649 51 656 33 q 636 89 643 68 q 624 137 630 109 q 616 143 623 140 q 602 146 610 145 q 584 148 593 148 q 566 149 574 149 q 525 148 541 149 q 496 148 509 148 q 473 147 484 147 q 446 146 462 146 q 405 147 426 146 q 368 148 385 147 l 329 149 q 294 58 311 100 q 256 -31 276 15 q 249 -39 254 -36 q 239 -43 244 -43 q 234 -42 235 -43 q 123 5 168 -18 q 45 50 79 28 m 503 659 q 470 550 486 599 q 441 463 454 500 q 418 398 428 425 q 405 358 409 372 l 405 352 q 404 347 405 348 l 567 347 q 551 414 559 380 q 534 485 543 448 q 518 565 526 522 q 503 659 510 608 m 574 1297 q 598 1272 587 1280 q 624 1265 609 1265 q 654 1276 645 1265 q 667 1301 663 1287 q 673 1326 671 1315 q 681 1337 675 1337 q 692 1338 682 1337 q 716 1339 702 1338 q 747 1340 730 1339 q 779 1342 764 1341 q 805 1343 794 1343 q 819 1343 817 1343 q 831 1341 825 1343 q 837 1331 837 1338 q 820 1232 837 1282 q 771 1141 802 1182 q 695 1075 739 1101 q 597 1050 651 1050 q 554 1054 576 1050 q 512 1069 533 1058 q 469 1100 490 1080 q 425 1153 447 1120 q 400 1174 413 1169 q 370 1178 388 1178 q 344 1171 354 1178 q 328 1154 334 1164 q 319 1129 321 1143 q 317 1103 317 1116 q 311 1093 317 1098 q 297 1088 306 1088 q 262 1087 275 1088 q 238 1087 249 1087 q 214 1086 227 1086 q 181 1086 201 1086 q 167 1088 174 1086 q 161 1097 161 1091 q 179 1214 161 1161 q 229 1303 197 1266 q 302 1361 260 1341 q 393 1382 345 1382 q 443 1380 420 1382 q 489 1370 467 1378 q 531 1345 511 1362 q 574 1297 552 1328 z " - }, - "Ä": { - "ha": 940, - "x_min": 29, - "x_max": 965, - "o": "m 45 50 q 64 89 54 67 q 81 137 73 111 l 100 182 q 75 221 87 200 q 52 265 62 243 q 36 310 42 288 q 29 353 29 332 q 40 356 29 355 q 66 357 50 357 q 101 358 82 358 q 135 359 119 359 q 162 360 151 359 q 172 360 172 360 q 203 437 188 401 q 233 511 218 474 q 262 588 248 549 q 292 671 277 627 q 348 819 321 755 q 399 938 375 883 q 408 950 401 945 q 422 960 414 956 q 436 967 429 964 q 448 971 444 970 q 468 977 450 972 q 509 989 486 983 q 555 1000 532 995 q 591 1004 578 1004 l 604 1004 q 624 999 614 1004 q 637 979 634 994 q 707 797 670 896 q 779 580 744 699 q 817 459 798 516 q 853 348 835 402 q 890 239 871 294 q 928 127 909 185 q 941 89 935 103 q 953 66 947 75 q 962 55 958 58 q 965 47 965 51 q 952 39 965 43 l 806 -9 q 773 -21 790 -15 q 741 -32 756 -27 q 715 -40 726 -37 q 699 -43 704 -43 l 695 -43 q 682 -37 686 -43 q 676 -26 677 -31 q 663 15 669 -3 q 649 51 656 33 q 636 89 643 68 q 624 137 630 109 q 616 143 623 140 q 602 146 610 145 q 584 148 593 148 q 566 149 574 149 q 525 148 541 149 q 496 148 509 148 q 473 147 484 147 q 446 146 462 146 q 405 147 426 146 q 368 148 385 147 l 329 149 q 294 58 311 100 q 256 -31 276 15 q 249 -39 254 -36 q 239 -43 244 -43 q 234 -42 235 -43 q 123 5 168 -18 q 45 50 79 28 m 503 659 q 470 550 486 599 q 441 463 454 500 q 418 398 428 425 q 405 358 409 372 l 405 352 q 404 347 405 348 l 567 347 q 551 414 559 380 q 534 485 543 448 q 518 565 526 522 q 503 659 510 608 m 155 1059 q 158 1115 157 1098 q 159 1140 159 1133 q 159 1150 159 1147 q 160 1162 159 1153 q 161 1193 160 1172 q 164 1258 162 1214 q 169 1286 165 1278 q 182 1295 172 1294 q 295 1296 235 1295 q 405 1297 354 1297 q 414 1293 412 1297 q 417 1279 417 1289 l 400 1090 q 395 1063 398 1071 q 382 1054 393 1055 q 276 1053 331 1053 q 162 1053 222 1053 q 157 1053 159 1053 q 155 1057 155 1054 l 155 1059 m 580 1058 q 583 1121 582 1101 q 584 1151 584 1142 q 584 1162 585 1160 q 584 1173 584 1165 q 586 1199 585 1181 q 589 1257 587 1217 q 593 1285 591 1277 q 606 1294 596 1293 q 719 1294 660 1294 q 829 1295 778 1295 q 838 1293 834 1295 q 842 1282 842 1290 l 825 1090 q 820 1062 823 1069 q 806 1053 818 1055 q 699 1052 754 1053 q 583 1051 644 1051 q 581 1052 581 1051 q 580 1055 580 1052 l 580 1058 z " - }, - "Å": { - "ha": 940, - "x_min": 29, - "x_max": 965, - "o": "m 45 50 q 64 89 54 67 q 81 137 73 111 l 100 182 q 75 221 87 200 q 52 265 62 243 q 36 310 42 288 q 29 353 29 332 q 40 356 29 355 q 66 357 50 357 q 101 358 82 358 q 135 359 119 359 q 162 360 151 359 q 172 360 172 360 q 203 437 188 401 q 233 511 218 474 q 262 588 248 549 q 292 671 277 627 q 348 819 321 755 q 399 938 375 883 q 408 950 401 945 q 422 960 414 956 q 436 967 429 964 q 448 971 444 970 q 468 977 450 972 q 509 989 486 983 q 555 1000 532 995 q 591 1004 578 1004 l 604 1004 q 624 999 614 1004 q 637 979 634 994 q 707 797 670 896 q 779 580 744 699 q 817 459 798 516 q 853 348 835 402 q 890 239 871 294 q 928 127 909 185 q 941 89 935 103 q 953 66 947 75 q 962 55 958 58 q 965 47 965 51 q 952 39 965 43 l 806 -9 q 773 -21 790 -15 q 741 -32 756 -27 q 715 -40 726 -37 q 699 -43 704 -43 l 695 -43 q 682 -37 686 -43 q 676 -26 677 -31 q 663 15 669 -3 q 649 51 656 33 q 636 89 643 68 q 624 137 630 109 q 616 143 623 140 q 602 146 610 145 q 584 148 593 148 q 566 149 574 149 q 525 148 541 149 q 496 148 509 148 q 473 147 484 147 q 446 146 462 146 q 405 147 426 146 q 368 148 385 147 l 329 149 q 294 58 311 100 q 256 -31 276 15 q 249 -39 254 -36 q 239 -43 244 -43 q 234 -42 235 -43 q 123 5 168 -18 q 45 50 79 28 m 503 659 q 470 550 486 599 q 441 463 454 500 q 418 398 428 425 q 405 358 409 372 l 405 352 q 404 347 405 348 l 567 347 q 551 414 559 380 q 534 485 543 448 q 518 565 526 522 q 503 659 510 608 m 496 1035 q 422 1047 456 1035 q 362 1082 387 1059 q 322 1139 336 1105 q 307 1215 307 1172 q 323 1288 307 1253 q 366 1348 338 1322 q 430 1389 393 1374 q 509 1404 467 1404 q 579 1392 547 1404 q 637 1358 612 1380 q 675 1303 661 1335 q 689 1233 689 1272 q 675 1161 689 1196 q 637 1097 662 1125 q 577 1052 612 1069 q 496 1035 541 1035 m 567 1215 q 568 1222 568 1219 q 568 1229 568 1225 q 565 1255 568 1241 q 555 1281 562 1269 q 538 1300 549 1293 q 511 1308 527 1308 q 472 1299 488 1308 q 445 1277 455 1291 q 429 1247 434 1264 q 424 1214 424 1231 q 427 1187 424 1201 q 436 1162 429 1173 q 454 1142 443 1150 q 484 1134 466 1135 q 519 1141 505 1134 q 544 1160 534 1148 q 559 1186 553 1172 q 567 1215 565 1201 z " - }, - "Æ": { - "ha": 1179, - "x_min": 10, - "x_max": 1197, - "o": "m 1063 549 q 1058 522 1061 539 q 1049 484 1054 505 q 1038 437 1044 462 q 1025 387 1031 412 q 1021 373 1023 377 q 1011 366 1018 368 q 991 364 1004 364 q 954 363 978 363 l 860 361 l 882 168 l 1188 189 q 1197 175 1197 189 q 1194 161 1197 167 q 1187 143 1194 160 q 1171 103 1181 126 q 1152 56 1162 80 q 1135 19 1141 33 q 1122 0 1130 7 q 1104 -11 1114 -7 q 1081 -15 1094 -14 q 1052 -16 1067 -16 q 946 -17 1001 -16 q 837 -19 891 -18 q 730 -22 782 -20 q 634 -26 678 -24 q 624 -28 629 -26 q 612 -29 619 -29 q 600 -23 603 -29 q 597 -12 597 -18 q 588 63 592 28 q 578 137 584 97 q 572 143 577 140 q 558 146 566 145 q 541 148 550 148 q 523 149 531 149 q 491 148 503 149 q 469 148 479 148 q 450 147 459 147 q 429 146 441 146 q 389 147 409 146 q 351 148 368 147 l 313 149 q 294 119 303 134 q 275 89 284 104 q 254 54 266 75 q 229 13 241 33 q 203 -22 216 -7 q 183 -36 191 -36 q 178 -35 179 -36 q 79 12 119 -12 q 10 56 39 35 q 37 96 23 74 q 63 137 52 118 l 90 182 q 65 248 77 210 q 54 326 54 285 q 57 353 54 342 q 68 356 57 355 q 95 357 79 357 q 129 358 111 358 q 164 359 148 359 q 191 359 180 359 q 201 360 201 359 q 217 388 201 359 q 259 464 233 417 q 319 570 286 511 q 388 691 352 629 q 457 812 423 753 q 519 916 492 871 q 531 929 524 923 q 547 939 539 935 q 563 945 555 943 q 575 949 570 948 q 596 951 578 949 q 637 956 614 954 q 684 960 661 958 q 722 962 708 962 l 901 972 q 970 977 936 975 q 1035 980 1005 979 q 1086 982 1064 981 q 1116 983 1107 983 q 1121 983 1117 983 q 1129 980 1125 983 q 1137 970 1133 977 q 1140 951 1140 964 q 1139 936 1140 946 q 1135 911 1137 925 q 1131 883 1133 898 q 1125 852 1128 867 l 1112 774 q 1105 756 1109 762 q 1080 749 1101 750 q 967 745 1029 748 q 822 739 904 742 l 838 573 q 905 576 872 574 q 964 578 937 577 q 1011 580 991 579 q 1039 581 1031 581 q 1043 580 1039 581 q 1051 577 1046 580 q 1059 568 1055 574 q 1063 549 1063 561 m 503 508 q 479 458 491 483 q 458 413 468 433 q 442 377 449 392 q 433 358 435 363 q 430 347 433 353 l 566 347 q 565 413 566 378 q 565 486 565 448 q 564 562 564 524 q 564 637 564 600 l 503 508 z " - }, - "Ç": { - "ha": 879, - "x_min": 87, - "x_max": 900, - "o": "m 87 458 q 105 602 87 533 q 156 730 123 671 q 236 839 189 790 q 342 923 283 888 q 468 977 400 958 q 612 996 536 996 q 716 988 671 996 q 795 968 762 980 q 851 942 829 956 q 889 915 874 928 q 888 910 888 915 q 890 873 888 900 q 894 812 892 846 q 898 745 897 779 q 900 686 900 711 q 897 676 900 682 q 884 671 895 671 q 869 673 878 671 q 833 692 854 677 q 782 723 811 707 q 718 751 753 739 q 640 764 682 764 q 539 742 585 764 q 462 681 494 720 q 412 589 430 642 q 395 473 395 536 q 407 367 395 417 q 444 278 419 316 q 506 217 469 240 q 591 195 543 195 q 660 197 630 195 q 715 206 690 200 q 766 222 741 212 q 819 248 791 233 q 826 249 821 249 q 832 245 831 249 q 834 230 834 241 l 834 149 q 834 105 834 126 q 833 66 833 83 q 832 39 833 50 q 831 28 832 28 q 765 -4 800 9 q 691 -23 729 -16 q 616 -33 654 -31 q 543 -35 578 -35 q 363 1 447 -35 q 219 102 280 37 q 122 258 157 168 q 87 458 87 349 m 643 -262 q 620 -320 637 -294 q 579 -365 603 -346 q 526 -394 555 -383 q 465 -404 496 -404 q 405 -400 437 -404 q 350 -382 374 -396 l 351 -383 q 351 -378 351 -382 q 352 -357 351 -370 q 354 -330 353 -345 q 358 -302 356 -315 q 363 -279 361 -288 l 367 -279 q 371 -281 371 -279 l 370 -281 q 391 -289 381 -286 q 411 -294 400 -292 q 434 -296 421 -296 q 463 -297 446 -297 q 507 -280 492 -297 q 523 -241 523 -263 q 510 -208 523 -221 q 476 -195 498 -195 q 412 -192 439 -195 q 376 -189 386 -189 q 369 -186 370 -189 q 368 -180 368 -184 q 376 -159 372 -174 q 385 -126 380 -144 q 394 -89 390 -109 q 402 -53 399 -69 q 409 -25 406 -36 q 411 -12 411 -14 l 424 -12 q 454 -12 435 -12 q 490 -12 472 -12 l 532 -12 l 500 -108 q 521 -105 511 -106 q 540 -104 531 -104 q 595 -116 574 -104 q 627 -144 616 -127 q 642 -184 638 -162 q 646 -230 646 -207 q 645 -246 646 -238 q 643 -262 644 -254 z " - }, - "È": { - "ha": 799, - "x_min": 92, - "x_max": 856, - "o": "m 694 563 q 684 536 691 553 q 666 497 676 519 q 645 451 656 475 q 623 401 634 426 q 616 387 619 391 q 605 380 612 382 q 584 378 597 378 q 547 377 571 378 l 453 375 l 434 168 l 782 168 l 782 141 q 770 123 781 140 q 747 83 760 106 q 718 37 733 60 q 693 -1 703 14 q 677 -20 686 -13 q 658 -31 669 -27 q 635 -35 648 -34 q 608 -35 623 -35 q 480 -33 547 -35 q 349 -26 414 -30 q 220 -17 283 -22 q 104 -6 157 -12 q 95 -1 99 -5 q 92 10 92 4 q 95 22 89 10 q 113 52 102 33 q 139 93 125 70 q 165 140 153 117 l 176 293 q 181 351 179 332 q 182 371 182 370 q 122 375 142 372 q 102 390 102 378 q 112 410 102 395 q 136 445 121 425 q 166 485 150 464 q 194 524 182 506 l 211 754 l 209 754 q 182 753 194 753 q 159 753 170 753 q 113 756 127 753 q 99 770 99 760 q 107 790 99 775 q 127 824 115 805 q 153 865 140 844 q 178 905 167 886 l 218 974 l 502 974 l 836 998 q 840 998 837 998 q 846 996 843 998 q 853 990 850 994 q 856 979 856 986 l 846 943 q 834 912 841 928 q 819 878 827 895 l 789 799 q 779 781 785 787 q 753 774 772 775 q 638 770 701 773 q 492 764 574 767 q 490 749 490 755 q 488 727 490 743 l 485 696 q 481 649 484 674 q 474 587 478 624 q 542 590 509 589 q 602 592 574 591 q 649 594 629 593 q 677 595 669 595 q 689 591 682 595 q 696 575 696 587 q 694 563 696 570 m 411 1194 q 385 1242 395 1223 q 364 1278 374 1261 q 344 1314 355 1295 q 318 1362 333 1333 q 313 1376 314 1369 q 311 1388 312 1383 q 315 1400 311 1396 q 325 1408 318 1404 q 377 1437 350 1422 q 433 1467 405 1451 q 488 1498 460 1482 q 541 1532 515 1514 q 550 1535 547 1535 q 555 1530 554 1535 l 631 1133 q 634 1119 633 1124 q 635 1107 635 1113 q 633 1096 635 1101 q 625 1087 631 1090 q 598 1076 610 1081 q 574 1064 586 1070 q 549 1052 562 1059 q 519 1035 536 1045 q 512 1032 517 1032 q 498 1041 506 1032 q 480 1070 491 1050 q 452 1120 469 1089 q 411 1194 435 1151 z " - }, - "É": { - "ha": 799, - "x_min": 92, - "x_max": 856, - "o": "m 694 563 q 684 536 691 553 q 666 497 676 519 q 645 451 656 475 q 623 401 634 426 q 616 387 619 391 q 605 380 612 382 q 584 378 597 378 q 547 377 571 378 l 453 375 l 434 168 l 782 168 l 782 141 q 770 123 781 140 q 747 83 760 106 q 718 37 733 60 q 693 -1 703 14 q 677 -20 686 -13 q 658 -31 669 -27 q 635 -35 648 -34 q 608 -35 623 -35 q 480 -33 547 -35 q 349 -26 414 -30 q 220 -17 283 -22 q 104 -6 157 -12 q 95 -1 99 -5 q 92 10 92 4 q 95 22 89 10 q 113 52 102 33 q 139 93 125 70 q 165 140 153 117 l 176 293 q 181 351 179 332 q 182 371 182 370 q 122 375 142 372 q 102 390 102 378 q 112 410 102 395 q 136 445 121 425 q 166 485 150 464 q 194 524 182 506 l 211 754 l 209 754 q 182 753 194 753 q 159 753 170 753 q 113 756 127 753 q 99 770 99 760 q 107 790 99 775 q 127 824 115 805 q 153 865 140 844 q 178 905 167 886 l 218 974 l 502 974 l 836 998 q 840 998 837 998 q 846 996 843 998 q 853 990 850 994 q 856 979 856 986 l 846 943 q 834 912 841 928 q 819 878 827 895 l 789 799 q 779 781 785 787 q 753 774 772 775 q 638 770 701 773 q 492 764 574 767 q 490 749 490 755 q 488 727 490 743 l 485 696 q 481 649 484 674 q 474 587 478 624 q 542 590 509 589 q 602 592 574 591 q 649 594 629 593 q 677 595 669 595 q 689 591 682 595 q 696 575 696 587 q 694 563 696 570 m 504 1171 q 454 1102 474 1129 q 421 1060 434 1076 q 401 1038 408 1044 q 389 1032 393 1032 q 382 1035 385 1032 q 356 1052 368 1044 q 334 1064 345 1059 q 314 1076 324 1070 q 290 1087 303 1081 q 281 1101 281 1093 q 283 1114 281 1107 q 289 1133 285 1122 l 414 1497 q 421 1510 418 1507 q 429 1514 425 1514 q 435 1512 432 1514 q 442 1508 439 1510 q 548 1447 495 1472 q 652 1394 600 1421 q 664 1376 664 1387 q 652 1348 664 1365 q 609 1298 626 1318 q 576 1259 591 1278 q 545 1221 561 1241 q 504 1171 528 1200 z " - }, - "Ê": { - "ha": 799, - "x_min": 92, - "x_max": 856, - "o": "m 694 563 q 684 536 691 553 q 666 497 676 519 q 645 451 656 475 q 623 401 634 426 q 616 387 619 391 q 605 380 612 382 q 584 378 597 378 q 547 377 571 378 l 453 375 l 434 168 l 782 168 l 782 141 q 770 123 781 140 q 747 83 760 106 q 718 37 733 60 q 693 -1 703 14 q 677 -20 686 -13 q 658 -31 669 -27 q 635 -35 648 -34 q 608 -35 623 -35 q 480 -33 547 -35 q 349 -26 414 -30 q 220 -17 283 -22 q 104 -6 157 -12 q 95 -1 99 -5 q 92 10 92 4 q 95 22 89 10 q 113 52 102 33 q 139 93 125 70 q 165 140 153 117 l 176 293 q 181 351 179 332 q 182 371 182 370 q 122 375 142 372 q 102 390 102 378 q 112 410 102 395 q 136 445 121 425 q 166 485 150 464 q 194 524 182 506 l 211 754 l 209 754 q 182 753 194 753 q 159 753 170 753 q 113 756 127 753 q 99 770 99 760 q 107 790 99 775 q 127 824 115 805 q 153 865 140 844 q 178 905 167 886 l 218 974 l 502 974 l 836 998 q 840 998 837 998 q 846 996 843 998 q 853 990 850 994 q 856 979 856 986 l 846 943 q 834 912 841 928 q 819 878 827 895 l 789 799 q 779 781 785 787 q 753 774 772 775 q 638 770 701 773 q 492 764 574 767 q 490 749 490 755 q 488 727 490 743 l 485 696 q 481 649 484 674 q 474 587 478 624 q 542 590 509 589 q 602 592 574 591 q 649 594 629 593 q 677 595 669 595 q 689 591 682 595 q 696 575 696 587 q 694 563 696 570 m 670 1354 q 695 1321 685 1335 q 714 1295 706 1307 q 729 1273 722 1284 q 744 1251 736 1263 q 757 1232 748 1244 q 775 1206 766 1220 q 792 1179 785 1192 q 799 1156 799 1165 q 786 1137 799 1147 q 754 1119 772 1128 q 717 1103 736 1110 q 688 1091 699 1095 q 667 1082 678 1088 q 645 1071 656 1076 q 624 1062 633 1065 q 610 1058 615 1058 q 599 1064 605 1058 q 585 1084 593 1069 l 497 1271 q 415 1167 456 1218 q 332 1064 374 1117 q 323 1059 330 1059 q 308 1065 320 1059 q 278 1079 295 1071 q 243 1095 261 1086 q 212 1110 226 1104 q 194 1119 205 1114 q 172 1129 182 1124 q 155 1140 162 1135 q 148 1150 148 1145 q 154 1166 148 1157 q 174 1187 160 1175 l 276 1303 q 351 1386 315 1345 q 425 1470 388 1427 q 443 1480 434 1479 q 460 1481 452 1481 l 563 1481 q 579 1480 571 1481 q 593 1469 587 1478 q 602 1455 593 1468 q 621 1426 610 1443 q 646 1389 633 1409 q 670 1354 659 1369 z " - }, - "Ë": { - "ha": 799, - "x_min": 92, - "x_max": 856, - "o": "m 694 563 q 684 536 691 553 q 666 497 676 519 q 645 451 656 475 q 623 401 634 426 q 616 387 619 391 q 605 380 612 382 q 584 378 597 378 q 547 377 571 378 l 453 375 l 434 168 l 782 168 l 782 141 q 770 123 781 140 q 747 83 760 106 q 718 37 733 60 q 693 -1 703 14 q 677 -20 686 -13 q 658 -31 669 -27 q 635 -35 648 -34 q 608 -35 623 -35 q 480 -33 547 -35 q 349 -26 414 -30 q 220 -17 283 -22 q 104 -6 157 -12 q 95 -1 99 -5 q 92 10 92 4 q 95 22 89 10 q 113 52 102 33 q 139 93 125 70 q 165 140 153 117 l 176 293 q 181 351 179 332 q 182 371 182 370 q 122 375 142 372 q 102 390 102 378 q 112 410 102 395 q 136 445 121 425 q 166 485 150 464 q 194 524 182 506 l 211 754 l 209 754 q 182 753 194 753 q 159 753 170 753 q 113 756 127 753 q 99 770 99 760 q 107 790 99 775 q 127 824 115 805 q 153 865 140 844 q 178 905 167 886 l 218 974 l 502 974 l 836 998 q 840 998 837 998 q 846 996 843 998 q 853 990 850 994 q 856 979 856 986 l 846 943 q 834 912 841 928 q 819 878 827 895 l 789 799 q 779 781 785 787 q 753 774 772 775 q 638 770 701 773 q 492 764 574 767 q 490 749 490 755 q 488 727 490 743 l 485 696 q 481 649 484 674 q 474 587 478 624 q 542 590 509 589 q 602 592 574 591 q 649 594 629 593 q 677 595 669 595 q 689 591 682 595 q 696 575 696 587 q 694 563 696 570 m 130 1059 q 132 1115 132 1098 q 133 1140 133 1133 q 134 1150 134 1147 q 134 1162 134 1153 q 135 1193 134 1172 q 138 1258 136 1214 q 143 1286 140 1278 q 157 1295 146 1294 q 269 1296 210 1295 q 379 1297 328 1297 q 389 1293 386 1297 q 391 1279 391 1289 l 374 1090 q 370 1063 372 1071 q 357 1054 367 1055 q 251 1053 305 1053 q 136 1053 196 1053 q 131 1053 133 1053 q 130 1057 130 1054 l 130 1059 m 554 1058 q 557 1121 556 1101 q 558 1151 558 1142 q 558 1162 559 1160 q 558 1173 558 1165 q 560 1199 559 1181 q 564 1257 561 1217 q 568 1285 565 1277 q 581 1294 570 1293 q 693 1294 634 1294 q 803 1295 752 1295 q 812 1293 808 1295 q 816 1282 816 1290 l 800 1090 q 794 1062 797 1069 q 781 1053 792 1055 q 673 1052 728 1053 q 557 1051 618 1051 q 555 1052 555 1051 q 554 1055 554 1052 l 554 1058 z " - }, - "Ì": { - "ha": 453, - "x_min": 94, - "x_max": 450, - "o": "m 94 -22 l 128 442 q 153 785 145 675 q 161 893 161 894 q 163 913 162 905 q 165 927 163 922 q 171 935 168 932 q 181 939 174 938 l 416 996 q 434 998 425 998 q 447 992 444 998 q 450 969 450 987 q 443 890 446 927 q 438 821 440 854 q 435 756 437 787 q 432 695 434 726 q 425 629 428 662 q 419 560 422 595 q 413 485 416 524 q 406 398 410 445 l 376 41 q 374 29 376 35 q 365 20 372 23 q 357 17 364 20 q 337 10 349 14 q 309 1 325 5 q 274 -8 292 -4 q 221 -22 243 -15 q 180 -34 198 -28 q 148 -43 163 -40 q 118 -47 133 -47 q 101 -41 108 -47 q 94 -22 94 -36 m 207 1194 q 180 1242 191 1223 q 160 1278 170 1261 q 140 1314 151 1295 q 114 1362 129 1333 q 109 1376 110 1369 q 107 1388 108 1383 q 111 1400 107 1396 q 121 1408 114 1404 q 173 1437 146 1422 q 229 1467 201 1451 q 284 1498 256 1482 q 336 1532 311 1514 q 346 1535 343 1535 q 351 1530 350 1535 l 427 1133 q 430 1119 429 1124 q 431 1107 431 1113 q 429 1096 431 1101 q 420 1087 427 1090 q 394 1076 406 1081 q 370 1064 382 1070 q 345 1052 358 1059 q 315 1035 332 1045 q 308 1032 313 1032 q 294 1041 302 1032 q 276 1070 287 1050 q 248 1120 264 1089 q 207 1194 231 1151 z " - }, - "Í": { - "ha": 453, - "x_min": 77, - "x_max": 460, - "o": "m 94 -22 l 128 442 q 153 785 145 675 q 161 893 161 894 q 163 913 162 905 q 165 927 163 922 q 171 935 168 932 q 181 939 174 938 l 416 996 q 434 998 425 998 q 447 992 444 998 q 450 969 450 987 q 443 890 446 927 q 438 821 440 854 q 435 756 437 787 q 432 695 434 726 q 425 629 428 662 q 419 560 422 595 q 413 485 416 524 q 406 398 410 445 l 376 41 q 374 29 376 35 q 365 20 372 23 q 357 17 364 20 q 337 10 349 14 q 309 1 325 5 q 274 -8 292 -4 q 221 -22 243 -15 q 180 -34 198 -28 q 148 -43 163 -40 q 118 -47 133 -47 q 101 -41 108 -47 q 94 -22 94 -36 m 300 1171 q 250 1102 270 1129 q 217 1060 230 1076 q 197 1038 204 1044 q 184 1032 189 1032 q 178 1035 180 1032 q 152 1052 163 1044 q 130 1064 140 1059 q 110 1076 120 1070 q 86 1087 99 1081 q 77 1101 77 1093 q 79 1114 77 1107 q 85 1133 81 1122 l 210 1497 q 217 1510 214 1507 q 224 1514 220 1514 q 231 1512 228 1514 q 238 1508 235 1510 q 343 1447 291 1472 q 448 1394 396 1421 q 460 1376 460 1387 q 448 1348 460 1365 q 405 1298 422 1318 q 372 1259 387 1278 q 340 1221 357 1241 q 300 1171 324 1200 z " - }, - "Î": { - "ha": 453, - "x_min": -54, - "x_max": 597, - "o": "m 94 -22 l 128 442 q 153 785 145 675 q 161 893 161 894 q 163 913 162 905 q 165 927 163 922 q 171 935 168 932 q 181 939 174 938 l 416 996 q 434 998 425 998 q 447 992 444 998 q 450 969 450 987 q 443 890 446 927 q 438 821 440 854 q 435 756 437 787 q 432 695 434 726 q 425 629 428 662 q 419 560 422 595 q 413 485 416 524 q 406 398 410 445 l 376 41 q 374 29 376 35 q 365 20 372 23 q 357 17 364 20 q 337 10 349 14 q 309 1 325 5 q 274 -8 292 -4 q 221 -22 243 -15 q 180 -34 198 -28 q 148 -43 163 -40 q 118 -47 133 -47 q 101 -41 108 -47 q 94 -22 94 -36 m 468 1354 q 493 1321 483 1335 q 512 1295 504 1307 q 527 1273 520 1284 q 542 1251 534 1263 q 555 1232 546 1244 q 573 1206 564 1220 q 590 1179 583 1192 q 597 1156 597 1165 q 584 1137 597 1147 q 552 1119 570 1128 q 515 1103 534 1110 q 486 1091 496 1095 q 465 1082 476 1088 q 443 1071 454 1076 q 422 1062 431 1065 q 408 1058 413 1058 q 397 1064 403 1058 q 382 1084 391 1069 l 295 1271 q 213 1167 254 1218 q 130 1064 172 1117 q 121 1059 127 1059 q 105 1065 118 1059 q 76 1079 93 1071 q 41 1095 59 1086 q 10 1110 24 1104 q -8 1119 3 1114 q -30 1129 -20 1124 q -47 1140 -40 1135 q -54 1150 -54 1145 q -48 1166 -54 1157 q -28 1187 -42 1175 l 74 1303 q 149 1386 113 1345 q 222 1470 186 1427 q 241 1480 232 1479 q 258 1481 250 1481 l 361 1481 q 377 1480 369 1481 q 391 1469 385 1478 q 399 1455 391 1468 q 419 1426 408 1443 q 444 1389 431 1409 q 468 1354 457 1369 z " - }, - "Ï": { - "ha": 453, - "x_min": -73, - "x_max": 614, - "o": "m 94 -22 l 128 442 q 153 785 145 675 q 161 893 161 894 q 163 913 162 905 q 165 927 163 922 q 171 935 168 932 q 181 939 174 938 l 416 996 q 434 998 425 998 q 447 992 444 998 q 450 969 450 987 q 443 890 446 927 q 438 821 440 854 q 435 756 437 787 q 432 695 434 726 q 425 629 428 662 q 419 560 422 595 q 413 485 416 524 q 406 398 410 445 l 376 41 q 374 29 376 35 q 365 20 372 23 q 357 17 364 20 q 337 10 349 14 q 309 1 325 5 q 274 -8 292 -4 q 221 -22 243 -15 q 180 -34 198 -28 q 148 -43 163 -40 q 118 -47 133 -47 q 101 -41 108 -47 q 94 -22 94 -36 m -73 1059 q -70 1115 -71 1098 q -69 1140 -69 1133 q -68 1150 -68 1147 q -68 1162 -68 1153 q -67 1193 -68 1172 q -64 1258 -66 1214 q -59 1286 -62 1278 q -45 1295 -56 1294 q 67 1296 7 1295 q 177 1297 126 1297 q 186 1293 184 1297 q 189 1279 189 1289 l 172 1090 q 168 1063 170 1071 q 155 1054 165 1055 q 48 1053 103 1053 q -66 1053 -6 1053 q -71 1053 -69 1053 q -73 1057 -73 1054 l -73 1059 m 352 1058 q 355 1121 354 1101 q 356 1151 356 1142 q 356 1162 357 1160 q 356 1173 356 1165 q 358 1199 357 1181 q 361 1257 359 1217 q 366 1285 363 1277 q 378 1294 368 1293 q 491 1294 432 1294 q 601 1295 550 1295 q 610 1293 606 1295 q 614 1282 614 1290 l 597 1090 q 592 1062 595 1069 q 578 1053 590 1055 q 471 1052 526 1053 q 355 1051 416 1051 q 353 1052 353 1051 q 352 1055 352 1052 l 352 1058 z " - }, - "Ð": { - "ha": 1050, - "x_min": 39, - "x_max": 1058, - "o": "m 224 564 l 233 689 q 236 721 235 705 q 238 752 237 736 q 200 745 220 748 q 162 739 180 741 q 126 734 143 736 q 98 732 110 732 q 86 739 90 732 q 83 753 83 746 q 87 766 83 762 l 259 922 q 299 952 279 941 q 347 971 319 964 q 414 980 375 978 q 514 983 454 983 q 640 975 576 983 q 765 949 705 968 q 879 901 825 931 q 972 825 932 871 q 1035 718 1012 780 q 1058 574 1058 656 q 1023 369 1058 458 q 929 214 989 280 q 790 103 869 149 q 620 30 710 58 q 432 -13 529 1 q 243 -31 336 -27 l 119 -35 q 109 -27 112 -33 q 105 -14 105 -21 q 108 -3 105 -7 l 191 156 q 194 178 192 159 q 197 225 195 197 q 202 287 199 253 q 208 355 205 321 q 156 355 178 355 q 119 355 133 355 q 59 358 79 355 q 39 374 39 362 q 47 393 39 377 q 69 429 56 408 q 100 473 83 450 q 134 516 117 496 q 167 549 151 536 q 193 562 182 562 l 224 564 m 513 766 q 505 686 510 736 q 494 574 500 636 q 570 577 537 576 q 614 578 602 578 q 626 574 619 578 q 633 559 633 570 q 626 536 633 553 q 610 497 620 520 q 587 445 600 473 q 560 385 574 416 q 554 370 557 375 q 544 363 551 366 q 521 361 536 361 q 476 360 505 361 l 460 173 q 598 199 542 173 q 690 272 655 226 q 742 380 726 318 q 758 515 758 443 q 743 614 758 566 q 702 698 729 662 q 635 755 675 734 q 547 777 596 777 q 529 773 538 777 q 513 766 519 770 z " - }, - "Ñ": { - "ha": 935, - "x_min": 102, - "x_max": 909, - "o": "m 672 909 q 682 941 677 931 q 699 955 686 951 l 875 996 q 892 999 883 999 q 905 993 901 999 q 909 970 909 987 q 903 920 905 954 q 899 846 900 886 q 897 766 897 806 q 896 696 896 726 l 896 659 q 895 567 896 616 q 893 467 895 517 q 891 366 892 416 q 888 273 890 317 l 884 157 q 884 151 884 154 q 884 146 884 149 l 884 136 q 884 116 884 124 q 884 102 884 109 q 883 90 884 96 q 878 80 882 85 q 867 69 874 75 q 848 56 860 64 q 825 42 841 51 q 791 21 810 33 q 751 -3 772 9 q 714 -25 731 -15 q 687 -41 697 -35 q 676 -47 676 -47 l 361 437 l 333 41 q 331 29 332 35 q 321 20 329 23 q 300 11 315 17 q 266 -2 286 5 q 223 -17 245 -9 q 182 -32 201 -25 q 147 -42 162 -38 q 126 -46 132 -46 q 109 -41 116 -46 q 102 -21 102 -35 q 118 164 109 64 q 135 369 127 264 q 150 579 143 474 q 162 778 157 684 q 154 796 162 781 q 135 829 145 811 q 116 863 124 847 q 107 883 107 879 q 112 892 107 888 q 129 903 117 896 l 310 1005 q 316 1006 312 1005 q 322 1006 319 1006 q 334 1005 330 1006 q 343 994 338 1003 l 672 401 l 672 909 m 583 1297 q 607 1272 595 1280 q 633 1265 618 1265 q 663 1276 654 1265 q 676 1301 672 1287 q 682 1326 680 1315 q 690 1337 684 1337 q 701 1338 691 1337 q 725 1339 711 1338 q 756 1340 739 1339 q 788 1342 773 1341 q 814 1343 803 1343 q 828 1343 825 1343 q 840 1341 833 1343 q 846 1331 846 1338 q 828 1232 846 1282 q 780 1141 811 1182 q 704 1075 748 1101 q 606 1050 660 1050 q 563 1054 585 1050 q 520 1069 542 1058 q 477 1100 499 1080 q 433 1153 456 1120 q 409 1174 422 1169 q 379 1178 397 1178 q 353 1171 363 1178 q 336 1154 342 1164 q 328 1129 330 1143 q 326 1103 326 1116 q 320 1093 326 1098 q 306 1088 315 1088 q 271 1087 284 1088 q 247 1087 258 1087 q 223 1086 235 1086 q 190 1086 210 1086 q 176 1088 182 1086 q 170 1097 170 1091 q 188 1214 170 1161 q 238 1303 206 1266 q 311 1361 269 1341 q 401 1382 353 1382 q 452 1380 429 1382 q 497 1370 475 1378 q 540 1345 519 1362 q 583 1297 561 1328 z " - }, - "Ò": { - "ha": 1103, - "x_min": 85, - "x_max": 1101, - "o": "m 384 463 q 394 365 384 414 q 429 276 405 315 q 494 212 454 237 q 593 188 534 188 q 672 207 638 191 q 731 248 707 222 q 772 306 756 273 q 798 375 789 339 q 811 450 808 412 q 815 523 815 488 q 802 616 815 571 q 764 696 789 661 q 700 751 738 730 q 610 772 661 772 q 538 758 570 772 q 481 718 506 743 q 438 661 456 693 q 408 594 420 629 q 390 526 396 560 q 384 463 385 492 m 516 -35 q 334 3 414 -35 q 199 105 254 41 q 114 255 144 170 q 85 435 85 340 q 115 632 85 542 q 199 791 145 722 q 329 908 254 861 q 493 979 404 956 q 506 992 501 979 q 513 1021 510 1005 q 522 1049 517 1036 q 535 1062 526 1062 q 772 1016 667 1048 q 950 922 877 983 q 1062 767 1023 861 q 1101 540 1101 674 q 1080 378 1101 454 q 1021 238 1059 302 q 930 123 983 174 q 812 37 877 73 q 672 -17 747 2 q 516 -35 597 -35 m 534 1194 q 507 1242 518 1223 q 487 1278 496 1261 q 467 1314 477 1295 q 441 1362 456 1333 q 436 1376 437 1369 q 434 1388 435 1383 q 437 1400 434 1396 q 448 1408 441 1404 q 500 1437 473 1422 q 555 1467 528 1451 q 611 1498 583 1482 q 663 1532 638 1514 q 673 1535 670 1535 q 678 1530 677 1535 l 754 1133 q 757 1119 755 1124 q 758 1107 758 1113 q 756 1096 758 1101 q 747 1087 754 1090 q 721 1076 733 1081 q 697 1064 709 1070 q 672 1052 685 1059 q 642 1035 659 1045 q 635 1032 640 1032 q 621 1041 629 1032 q 603 1070 614 1050 q 575 1120 591 1089 q 534 1194 558 1151 z " - }, - "Ó": { - "ha": 1103, - "x_min": 85, - "x_max": 1101, - "o": "m 384 463 q 394 365 384 414 q 429 276 405 315 q 494 212 454 237 q 593 188 534 188 q 672 207 638 191 q 731 248 707 222 q 772 306 756 273 q 798 375 789 339 q 811 450 808 412 q 815 523 815 488 q 802 616 815 571 q 764 696 789 661 q 700 751 738 730 q 610 772 661 772 q 538 758 570 772 q 481 718 506 743 q 438 661 456 693 q 408 594 420 629 q 390 526 396 560 q 384 463 385 492 m 516 -35 q 334 3 414 -35 q 199 105 254 41 q 114 255 144 170 q 85 435 85 340 q 115 632 85 542 q 199 791 145 722 q 329 908 254 861 q 493 979 404 956 q 506 992 501 979 q 513 1021 510 1005 q 522 1049 517 1036 q 535 1062 526 1062 q 772 1016 667 1048 q 950 922 877 983 q 1062 767 1023 861 q 1101 540 1101 674 q 1080 378 1101 454 q 1021 238 1059 302 q 930 123 983 174 q 812 37 877 73 q 672 -17 747 2 q 516 -35 597 -35 m 626 1171 q 576 1102 596 1129 q 543 1060 556 1076 q 523 1038 530 1044 q 511 1032 515 1032 q 504 1035 507 1032 q 478 1052 490 1044 q 456 1064 467 1059 q 436 1076 446 1070 q 412 1087 425 1081 q 403 1101 403 1093 q 405 1114 404 1107 q 411 1133 407 1122 l 536 1497 q 543 1510 540 1507 q 551 1514 547 1514 q 557 1512 554 1514 q 564 1508 561 1510 q 670 1447 617 1472 q 774 1394 722 1421 q 786 1376 786 1387 q 774 1348 786 1365 q 731 1298 748 1318 q 698 1259 713 1278 q 667 1221 683 1241 q 626 1171 650 1200 z " - }, - "Ô": { - "ha": 1096, - "x_min": 81, - "x_max": 1098, - "o": "m 380 463 q 391 365 380 414 q 426 276 401 315 q 490 212 450 237 q 589 188 530 188 q 669 207 635 191 q 728 248 703 222 q 769 306 753 273 q 795 375 785 339 q 808 450 804 412 q 812 523 812 488 q 799 616 812 571 q 760 696 786 661 q 696 751 734 730 q 607 772 658 772 q 535 758 567 772 q 477 718 503 743 q 434 661 452 693 q 405 594 416 629 q 387 526 393 560 q 380 463 381 492 m 513 -35 q 331 3 411 -35 q 196 105 251 41 q 111 255 140 170 q 81 435 81 340 q 112 632 81 542 q 196 791 142 722 q 325 908 250 861 q 490 979 400 956 q 502 992 498 979 q 510 1021 507 1005 q 518 1049 513 1036 q 532 1062 523 1062 q 768 1016 663 1048 q 947 922 873 983 q 1059 767 1020 861 q 1098 540 1098 674 q 1077 378 1098 454 q 1018 238 1056 302 q 927 123 980 174 q 808 37 873 73 q 668 -17 743 2 q 513 -35 593 -35 m 789 1354 q 814 1321 804 1335 q 833 1295 825 1307 q 848 1273 841 1284 q 863 1251 854 1263 q 876 1232 867 1244 q 894 1206 885 1220 q 910 1179 903 1192 q 918 1156 918 1165 q 904 1137 918 1147 q 873 1119 891 1128 q 836 1103 854 1110 q 806 1091 817 1095 q 786 1082 797 1088 q 763 1071 774 1076 q 743 1062 752 1065 q 729 1058 734 1058 q 718 1064 724 1058 q 703 1084 712 1069 l 616 1271 q 533 1167 574 1218 q 451 1064 492 1117 q 442 1059 448 1059 q 426 1065 439 1059 q 397 1079 414 1071 q 362 1095 380 1086 q 331 1110 345 1104 q 312 1119 323 1114 q 291 1129 301 1124 q 274 1140 281 1135 q 267 1150 267 1145 q 273 1166 267 1157 q 292 1187 279 1175 l 395 1303 q 470 1386 433 1345 q 543 1470 507 1427 q 562 1480 553 1479 q 578 1481 571 1481 l 682 1481 q 698 1480 690 1481 q 711 1469 706 1478 q 720 1455 712 1468 q 740 1426 728 1443 q 765 1389 751 1409 q 789 1354 778 1369 z " - }, - "Õ": { - "ha": 1096, - "x_min": 81, - "x_max": 1098, - "o": "m 380 463 q 391 365 380 414 q 426 276 401 315 q 490 212 450 237 q 589 188 530 188 q 669 207 635 191 q 728 248 703 222 q 769 306 753 273 q 795 375 785 339 q 808 450 804 412 q 812 523 812 488 q 799 616 812 571 q 760 696 786 661 q 696 751 734 730 q 607 772 658 772 q 535 758 567 772 q 477 718 503 743 q 434 661 452 693 q 405 594 416 629 q 387 526 393 560 q 380 463 381 492 m 513 -35 q 331 3 411 -35 q 196 105 251 41 q 111 255 140 170 q 81 435 81 340 q 112 632 81 542 q 196 791 142 722 q 325 908 250 861 q 490 979 400 956 q 502 992 498 979 q 510 1021 507 1005 q 518 1049 513 1036 q 532 1062 523 1062 q 768 1016 663 1048 q 947 922 873 983 q 1059 767 1020 861 q 1098 540 1098 674 q 1077 378 1098 454 q 1018 238 1056 302 q 927 123 980 174 q 808 37 873 73 q 668 -17 743 2 q 513 -35 593 -35 m 667 1297 q 691 1272 680 1280 q 718 1265 703 1265 q 748 1276 739 1265 q 761 1301 757 1287 q 766 1326 764 1315 q 774 1337 768 1337 q 786 1338 776 1337 q 810 1339 795 1338 q 841 1340 824 1339 q 873 1342 858 1341 q 899 1343 888 1343 q 913 1343 910 1343 q 924 1341 918 1343 q 930 1331 930 1338 q 913 1232 930 1282 q 864 1141 896 1182 q 789 1075 833 1101 q 691 1050 745 1050 q 648 1054 669 1050 q 605 1069 627 1058 q 562 1100 584 1080 q 518 1153 541 1120 q 494 1174 507 1169 q 464 1178 481 1178 q 437 1171 448 1178 q 421 1154 427 1164 q 413 1129 415 1143 q 410 1103 410 1116 q 405 1093 410 1098 q 391 1088 399 1088 q 356 1087 369 1088 q 331 1087 342 1087 q 308 1086 320 1086 q 275 1086 295 1086 q 261 1088 267 1086 q 254 1097 254 1091 q 273 1214 254 1161 q 322 1303 291 1266 q 396 1361 354 1341 q 486 1382 438 1382 q 537 1380 513 1382 q 582 1370 560 1378 q 625 1345 604 1362 q 667 1297 646 1328 z " - }, - "Ö": { - "ha": 1096, - "x_min": 81, - "x_max": 1098, - "o": "m 380 463 q 391 365 380 414 q 426 276 401 315 q 490 212 450 237 q 589 188 530 188 q 669 207 635 191 q 728 248 703 222 q 769 306 753 273 q 795 375 785 339 q 808 450 804 412 q 812 523 812 488 q 799 616 812 571 q 760 696 786 661 q 696 751 734 730 q 607 772 658 772 q 535 758 567 772 q 477 718 503 743 q 434 661 452 693 q 405 594 416 629 q 387 526 393 560 q 380 463 381 492 m 513 -35 q 331 3 411 -35 q 196 105 251 41 q 111 255 140 170 q 81 435 81 340 q 112 632 81 542 q 196 791 142 722 q 325 908 250 861 q 490 979 400 956 q 502 992 498 979 q 510 1021 507 1005 q 518 1049 513 1036 q 532 1062 523 1062 q 768 1016 663 1048 q 947 922 873 983 q 1059 767 1020 861 q 1098 540 1098 674 q 1077 378 1098 454 q 1018 238 1056 302 q 927 123 980 174 q 808 37 873 73 q 668 -17 743 2 q 513 -35 593 -35 m 249 1059 q 252 1115 251 1098 q 253 1140 252 1133 q 253 1150 253 1147 q 253 1162 253 1153 q 255 1193 254 1172 q 258 1258 256 1214 q 262 1286 259 1278 q 276 1295 266 1294 q 388 1296 329 1295 q 498 1297 448 1297 q 508 1293 505 1297 q 511 1279 511 1289 l 494 1090 q 489 1063 492 1071 q 476 1054 486 1055 q 370 1053 425 1053 q 256 1053 315 1053 q 251 1053 252 1053 q 249 1057 249 1054 l 249 1059 m 673 1058 q 676 1121 675 1101 q 678 1151 677 1142 q 678 1162 678 1160 q 678 1173 677 1165 q 679 1199 678 1181 q 683 1257 680 1217 q 687 1285 684 1277 q 700 1294 690 1293 q 812 1294 753 1294 q 922 1295 871 1295 q 931 1293 928 1295 q 935 1282 935 1290 l 919 1090 q 914 1062 916 1069 q 900 1053 911 1055 q 792 1052 848 1053 q 677 1051 737 1051 q 674 1052 675 1051 q 673 1055 673 1052 l 673 1058 z " - }, - "×": { - "ha": 671, - "x_min": 106, - "x_max": 648, - "o": "m 372 313 q 306 244 332 272 q 262 198 279 216 q 233 173 244 180 q 213 165 222 165 q 205 168 208 165 q 194 181 202 170 q 176 207 186 192 q 154 240 165 222 q 133 273 142 257 q 117 300 123 288 q 111 316 111 312 q 114 329 111 322 q 123 343 116 336 l 242 465 l 233 476 q 139 584 172 546 q 106 633 106 623 q 109 643 106 637 q 120 657 113 648 q 141 679 127 665 q 175 714 155 692 l 219 761 q 233 766 229 766 q 244 762 239 766 q 257 749 250 758 l 292 711 q 332 668 309 692 q 380 612 354 643 l 388 621 q 485 722 450 685 q 529 758 519 758 q 538 754 534 758 q 549 742 543 751 q 561 727 553 737 q 579 704 569 717 q 601 676 590 690 q 622 651 612 663 q 637 633 631 640 q 643 625 643 625 q 646 616 645 621 q 648 608 648 612 q 632 582 648 598 q 598 547 616 566 l 512 458 l 600 357 q 632 314 622 332 q 644 286 643 296 q 641 278 644 281 q 630 267 639 276 q 608 244 621 257 q 580 217 595 231 q 551 190 565 202 q 527 170 538 178 q 513 162 517 162 q 501 165 507 162 q 489 176 495 168 l 372 313 z " - }, - "Ø": { - "ha": 1101, - "x_min": 83, - "x_max": 1099, - "o": "m 528 -35 q 452 -28 489 -35 l 408 -121 q 400 -141 402 -132 q 388 -151 398 -151 q 370 -146 380 -151 l 302 -117 q 286 -112 296 -115 q 263 -103 275 -108 q 244 -91 252 -98 q 235 -75 235 -84 q 240 -57 235 -69 q 253 -29 245 -45 q 269 3 260 -14 q 286 36 278 20 q 200 113 237 68 q 136 212 162 158 q 97 326 111 265 q 83 451 83 387 q 129 669 83 571 q 252 836 174 766 q 431 944 329 906 q 648 982 534 982 q 742 972 694 982 q 759 1008 751 989 q 775 1041 767 1026 q 790 1066 783 1056 q 803 1076 797 1076 l 808 1076 q 880 1043 844 1061 q 951 1019 916 1026 q 959 1016 956 1018 q 962 1010 962 1014 l 962 1008 l 909 901 q 988 829 953 870 q 1048 739 1023 787 q 1085 634 1072 690 q 1099 518 1099 578 q 1078 362 1099 435 q 1021 227 1058 288 q 931 117 983 165 q 816 35 880 68 q 679 -17 752 1 q 528 -35 606 -35 m 382 463 q 390 376 382 419 q 415 295 397 334 q 458 384 439 343 q 495 465 477 425 q 533 546 513 505 q 576 638 552 588 l 646 779 q 623 782 635 781 q 600 783 612 783 q 527 768 559 783 q 470 726 494 752 q 429 667 446 701 q 402 598 412 634 q 387 527 392 562 q 382 463 382 492 m 812 513 q 806 585 812 549 q 786 651 800 620 l 554 178 q 599 174 574 174 q 675 193 642 177 q 731 235 707 210 q 771 294 755 261 q 796 363 787 327 q 809 438 805 400 q 812 513 812 476 z " - }, - "Ù": { - "ha": 935, - "x_min": 103, - "x_max": 937, - "o": "m 937 970 q 932 916 935 951 q 924 835 928 880 q 915 741 920 790 q 906 646 910 691 q 898 564 901 601 q 893 509 895 528 q 845 261 879 365 q 755 92 810 158 q 622 -4 699 26 q 442 -35 544 -35 q 311 -10 372 -35 q 203 62 249 16 q 130 173 157 108 q 103 317 103 237 q 105 354 103 327 q 110 419 106 380 q 116 507 113 458 q 124 612 120 556 l 132 724 q 138 827 136 786 q 143 893 140 868 q 150 930 145 918 q 165 945 155 941 l 396 996 q 414 999 405 999 q 429 993 425 999 q 433 970 433 987 l 381 435 q 376 384 380 412 q 373 327 373 356 q 377 288 373 309 q 393 249 382 267 q 425 217 405 230 q 477 205 445 205 q 539 221 515 205 q 577 266 563 238 q 598 328 591 293 q 608 399 604 363 q 616 500 612 442 q 626 623 621 557 l 646 894 q 647 914 647 906 q 649 928 648 922 q 655 936 650 933 q 669 940 659 939 l 900 996 q 918 999 909 999 q 932 993 928 999 q 937 970 937 987 m 452 1194 q 426 1242 437 1223 q 406 1278 415 1261 q 385 1314 396 1295 q 359 1362 374 1333 q 354 1376 355 1369 q 353 1388 353 1383 q 356 1400 353 1396 q 366 1408 359 1404 q 419 1437 391 1422 q 474 1467 446 1451 q 529 1498 502 1482 q 582 1532 557 1514 q 591 1535 589 1535 q 597 1530 595 1535 l 673 1133 q 675 1119 674 1124 q 677 1107 677 1113 q 675 1096 677 1101 q 666 1087 673 1090 q 640 1076 652 1081 q 615 1064 627 1070 q 590 1052 604 1059 q 561 1035 577 1045 q 553 1032 558 1032 q 540 1041 547 1032 q 521 1070 532 1050 q 493 1120 510 1089 q 452 1194 477 1151 z " - }, - "Ú": { - "ha": 935, - "x_min": 103, - "x_max": 937, - "o": "m 937 970 q 932 916 935 951 q 924 835 928 880 q 915 741 920 790 q 906 646 910 691 q 898 564 901 601 q 893 509 895 528 q 845 261 879 365 q 755 92 810 158 q 622 -4 699 26 q 442 -35 544 -35 q 311 -10 372 -35 q 203 62 249 16 q 130 173 157 108 q 103 317 103 237 q 105 354 103 327 q 110 419 106 380 q 116 507 113 458 q 124 612 120 556 l 132 724 q 138 827 136 786 q 143 893 140 868 q 150 930 145 918 q 165 945 155 941 l 396 996 q 414 999 405 999 q 429 993 425 999 q 433 970 433 987 l 381 435 q 376 384 380 412 q 373 327 373 356 q 377 288 373 309 q 393 249 382 267 q 425 217 405 230 q 477 205 445 205 q 539 221 515 205 q 577 266 563 238 q 598 328 591 293 q 608 399 604 363 q 616 500 612 442 q 626 623 621 557 l 646 894 q 647 914 647 906 q 649 928 648 922 q 655 936 650 933 q 669 940 659 939 l 900 996 q 918 999 909 999 q 932 993 928 999 q 937 970 937 987 m 545 1171 q 495 1102 515 1129 q 463 1060 475 1076 q 442 1038 450 1044 q 430 1032 435 1032 q 423 1035 426 1032 q 397 1052 409 1044 q 376 1064 386 1059 q 355 1076 366 1070 q 332 1087 345 1081 q 322 1101 322 1093 q 325 1114 323 1107 q 330 1133 326 1122 l 456 1497 q 463 1510 459 1507 q 470 1514 466 1514 q 477 1512 473 1514 q 484 1508 480 1510 q 589 1447 536 1472 q 693 1394 642 1421 q 705 1376 705 1387 q 694 1348 705 1365 q 650 1298 667 1318 q 617 1259 633 1278 q 586 1221 602 1241 q 545 1171 570 1200 z " - }, - "Û": { - "ha": 935, - "x_min": 103, - "x_max": 937, - "o": "m 937 970 q 932 916 935 951 q 924 835 928 880 q 915 741 920 790 q 906 646 910 691 q 898 564 901 601 q 893 509 895 528 q 845 261 879 365 q 755 92 810 158 q 622 -4 699 26 q 442 -35 544 -35 q 311 -10 372 -35 q 203 62 249 16 q 130 173 157 108 q 103 317 103 237 q 105 354 103 327 q 110 419 106 380 q 116 507 113 458 q 124 612 120 556 l 132 724 q 138 827 136 786 q 143 893 140 868 q 150 930 145 918 q 165 945 155 941 l 396 996 q 414 999 405 999 q 429 993 425 999 q 433 970 433 987 l 381 435 q 376 384 380 412 q 373 327 373 356 q 377 288 373 309 q 393 249 382 267 q 425 217 405 230 q 477 205 445 205 q 539 221 515 205 q 577 266 563 238 q 598 328 591 293 q 608 399 604 363 q 616 500 612 442 q 626 623 621 557 l 646 894 q 647 914 647 906 q 649 928 648 922 q 655 936 650 933 q 669 940 659 939 l 900 996 q 918 999 909 999 q 932 993 928 999 q 937 970 937 987 m 711 1354 q 737 1321 726 1335 q 755 1295 747 1307 q 770 1273 764 1284 q 785 1251 777 1263 q 799 1232 789 1244 q 817 1206 808 1220 q 833 1179 826 1192 q 840 1156 840 1165 q 827 1137 840 1147 q 795 1119 814 1128 q 759 1103 777 1110 q 729 1091 740 1095 q 708 1082 720 1088 q 686 1071 697 1076 q 666 1062 675 1065 q 652 1058 656 1058 q 641 1064 646 1058 q 626 1084 635 1069 l 538 1271 q 456 1167 497 1218 q 374 1064 415 1117 q 365 1059 371 1059 q 349 1065 361 1059 q 319 1079 336 1071 q 285 1095 302 1086 q 254 1110 267 1104 q 235 1119 246 1114 q 214 1129 224 1124 q 196 1140 203 1135 q 189 1150 189 1145 q 195 1166 189 1157 q 215 1187 201 1175 l 317 1303 q 393 1386 356 1345 q 466 1470 429 1427 q 485 1480 475 1479 q 501 1481 494 1481 l 604 1481 q 621 1480 612 1481 q 634 1469 629 1478 q 643 1455 635 1468 q 663 1426 651 1443 q 687 1389 674 1409 q 711 1354 701 1369 z " - }, - "Ü": { - "ha": 935, - "x_min": 103, - "x_max": 937, - "o": "m 937 970 q 932 916 935 951 q 924 835 928 880 q 915 741 920 790 q 906 646 910 691 q 898 564 901 601 q 893 509 895 528 q 845 261 879 365 q 755 92 810 158 q 622 -4 699 26 q 442 -35 544 -35 q 311 -10 372 -35 q 203 62 249 16 q 130 173 157 108 q 103 317 103 237 q 105 354 103 327 q 110 419 106 380 q 116 507 113 458 q 124 612 120 556 l 132 724 q 138 827 136 786 q 143 893 140 868 q 150 930 145 918 q 165 945 155 941 l 396 996 q 414 999 405 999 q 429 993 425 999 q 433 970 433 987 l 381 435 q 376 384 380 412 q 373 327 373 356 q 377 288 373 309 q 393 249 382 267 q 425 217 405 230 q 477 205 445 205 q 539 221 515 205 q 577 266 563 238 q 598 328 591 293 q 608 399 604 363 q 616 500 612 442 q 626 623 621 557 l 646 894 q 647 914 647 906 q 649 928 648 922 q 655 936 650 933 q 669 940 659 939 l 900 996 q 918 999 909 999 q 932 993 928 999 q 937 970 937 987 m 171 1059 q 174 1115 173 1098 q 175 1140 174 1133 q 175 1150 175 1147 q 175 1162 175 1153 q 177 1193 176 1172 q 180 1258 178 1214 q 184 1286 181 1278 q 198 1295 188 1294 q 310 1296 251 1295 q 420 1297 370 1297 q 430 1293 427 1297 q 433 1279 433 1289 l 416 1090 q 411 1063 414 1071 q 398 1054 408 1055 q 292 1053 347 1053 q 178 1053 237 1053 q 173 1053 174 1053 q 171 1057 171 1054 l 171 1059 m 595 1058 q 598 1121 597 1101 q 600 1151 600 1142 q 600 1162 600 1160 q 600 1173 600 1165 q 601 1199 600 1181 q 605 1257 602 1217 q 609 1285 606 1277 q 622 1294 612 1293 q 734 1294 675 1294 q 844 1295 793 1295 q 853 1293 850 1295 q 857 1282 857 1290 l 841 1090 q 836 1062 838 1069 q 822 1053 833 1055 q 714 1052 770 1053 q 599 1051 659 1051 q 596 1052 597 1051 q 595 1055 595 1052 l 595 1058 z " - }, - "Ý": { - "ha": 756, - "x_min": 73, - "x_max": 861, - "o": "m 81 903 q 95 910 85 906 q 118 920 104 915 q 146 932 131 926 q 177 945 161 939 l 256 976 q 272 980 264 980 q 284 977 277 980 q 298 966 290 974 l 455 662 l 459 672 l 526 796 q 552 842 539 819 q 574 882 564 864 q 591 910 584 899 q 599 921 597 921 l 831 979 q 845 981 840 981 q 861 967 861 981 q 859 958 860 964 q 855 945 859 952 l 656 576 q 626 520 641 548 q 596 468 610 492 q 571 422 582 443 q 553 389 559 402 l 548 367 l 510 113 q 507 94 508 101 q 503 81 505 86 q 497 73 500 77 q 486 66 493 70 l 294 -35 q 271 -43 283 -40 q 248 -47 259 -47 q 229 -42 237 -47 q 220 -25 220 -37 l 220 -22 q 230 67 223 16 q 245 168 237 119 l 283 419 q 255 480 273 442 q 217 562 237 518 q 175 653 197 606 q 133 742 153 700 q 99 815 114 783 q 76 862 83 847 q 73 883 73 872 q 74 895 73 889 q 81 903 76 901 m 476 1171 q 426 1102 446 1129 q 393 1060 406 1076 q 373 1038 380 1044 q 361 1032 366 1032 q 354 1035 357 1032 q 328 1052 340 1044 q 307 1064 317 1059 q 286 1076 296 1070 q 262 1087 275 1081 q 253 1101 253 1093 q 255 1114 254 1107 q 261 1133 257 1122 l 387 1497 q 393 1510 390 1507 q 401 1514 397 1514 q 408 1512 404 1514 q 414 1508 411 1510 q 520 1447 467 1472 q 624 1394 572 1421 q 636 1376 636 1387 q 625 1348 636 1365 q 581 1298 598 1318 q 548 1259 564 1278 q 517 1221 533 1241 q 476 1171 500 1200 z " - }, - "Þ": { - "ha": 872, - "x_min": 104, - "x_max": 907, - "o": "m 907 630 q 888 515 907 568 q 836 420 869 463 q 758 345 802 378 q 662 291 713 313 q 555 258 610 269 q 447 247 500 247 q 420 248 433 247 q 393 250 407 248 l 375 64 l 363 43 q 352 36 363 41 q 324 26 341 32 q 286 13 307 20 q 244 -2 265 5 q 204 -15 223 -9 q 172 -26 184 -22 q 149 -33 162 -30 q 125 -35 136 -35 q 110 -31 115 -35 q 104 -12 104 -26 q 108 39 106 11 q 112 96 110 66 q 116 157 114 126 q 121 216 119 188 l 132 353 q 146 534 140 456 q 156 674 152 613 q 132 672 136 672 q 117 684 117 672 q 122 703 117 684 q 135 749 127 722 q 150 805 142 776 q 163 854 158 834 q 183 878 164 867 l 198 1016 l 210 1037 q 220 1043 210 1039 q 248 1054 231 1048 q 287 1066 265 1059 q 329 1081 308 1074 q 370 1095 351 1088 q 401 1106 389 1101 q 424 1112 410 1109 q 448 1115 437 1115 q 463 1110 458 1115 q 469 1092 469 1105 q 466 1055 467 1072 q 463 1020 465 1038 q 460 980 462 1002 q 456 928 458 958 q 526 930 495 930 q 672 916 603 930 q 793 868 741 902 q 877 775 846 833 q 907 630 907 718 m 412 451 q 415 438 412 444 q 430 432 418 432 q 465 437 445 432 q 506 453 485 443 q 548 480 528 464 q 584 518 568 496 q 610 567 600 540 q 620 627 620 594 q 587 696 620 674 q 501 719 554 719 q 480 718 492 719 q 460 714 469 717 q 444 708 450 711 q 436 698 437 704 q 435 683 436 698 q 431 646 433 669 q 427 596 429 624 q 421 541 424 568 q 416 490 418 513 q 412 451 414 466 z " - }, - "ß": { - "ha": 926, - "x_min": 83, - "x_max": 920, - "o": "m 91 115 q 102 287 98 203 q 109 449 105 371 q 121 596 113 526 q 146 725 130 665 q 192 831 163 784 q 267 912 221 879 q 378 964 313 946 q 534 982 444 982 q 674 963 609 982 q 786 910 739 943 q 861 833 834 877 q 888 742 888 790 q 855 638 888 691 q 745 538 821 586 q 818 494 786 514 q 873 452 850 474 q 907 404 895 431 q 920 338 920 376 q 902 225 920 279 q 852 125 884 172 q 777 42 821 79 q 680 -21 732 5 q 569 -62 628 -47 q 449 -76 510 -76 q 431 -71 437 -76 q 423 -55 426 -66 q 420 -23 420 -43 q 417 26 419 -3 q 414 63 416 47 q 412 92 412 79 q 418 120 412 110 q 441 133 424 130 q 524 152 484 140 q 593 185 563 163 q 641 238 623 206 q 659 317 659 271 q 646 352 659 337 q 613 377 633 366 q 569 394 593 387 q 522 405 545 401 q 480 412 499 410 q 451 416 460 414 q 439 422 442 417 q 436 435 436 428 q 447 460 436 445 q 477 503 457 475 l 505 543 q 545 559 524 549 q 585 583 566 570 q 615 613 603 596 q 627 649 627 629 q 603 734 627 705 q 534 764 579 764 q 499 759 521 764 q 456 740 477 753 q 417 703 434 726 q 397 642 400 679 q 381 507 387 571 q 373 385 376 443 q 368 274 370 327 q 361 172 366 221 l 349 -8 q 338 -22 348 -18 q 321 -26 329 -26 q 209 -10 265 -18 q 106 9 152 -2 q 88 20 93 12 q 83 35 83 27 q 86 75 83 59 q 91 115 89 92 z " - }, - "à": { - "ha": 846, - "x_min": 71, - "x_max": 844, - "o": "m 774 136 q 773 131 773 134 q 773 127 773 129 q 779 99 773 110 q 790 80 784 87 q 802 69 797 73 q 808 61 808 64 q 787 43 808 52 l 605 -35 q 600 -35 604 -35 q 589 -26 595 -35 q 579 -2 584 -16 q 569 30 574 13 q 562 60 565 46 q 469 -12 519 11 q 371 -35 420 -35 q 260 -10 314 -35 q 163 61 205 15 q 96 174 121 108 q 71 321 71 239 q 99 498 71 418 q 175 636 127 578 q 287 725 223 694 q 423 757 351 757 q 519 736 474 757 q 606 683 565 715 q 610 715 610 703 q 613 734 611 728 q 623 744 616 741 q 645 747 629 746 q 742 760 694 754 q 844 768 791 766 l 774 136 m 571 392 q 580 465 578 431 q 584 528 583 499 q 561 545 573 536 q 533 561 548 553 q 503 574 519 569 q 469 578 487 578 q 408 555 433 578 q 368 496 383 531 q 346 423 353 462 q 340 355 340 385 q 368 198 340 248 q 446 148 396 148 q 492 159 467 148 q 543 191 517 171 l 571 392 m 395 968 q 368 1015 379 996 q 348 1051 357 1034 q 328 1087 338 1068 q 302 1135 317 1107 q 297 1149 298 1143 q 295 1162 296 1156 q 298 1174 295 1169 q 309 1181 302 1178 q 361 1210 334 1196 q 416 1240 389 1225 q 472 1272 444 1255 q 524 1305 499 1288 q 534 1309 531 1309 q 539 1303 538 1309 l 615 907 q 618 892 616 898 q 619 881 619 886 q 617 869 619 875 q 608 861 615 864 q 582 849 594 854 q 558 838 570 844 q 533 825 546 832 q 503 808 519 819 q 496 806 500 806 q 482 815 490 806 q 464 843 475 824 q 436 893 452 863 q 395 968 419 924 z " - }, - "á": { - "ha": 846, - "x_min": 71, - "x_max": 844, - "o": "m 774 136 q 773 131 773 134 q 773 127 773 129 q 779 99 773 110 q 790 80 784 87 q 802 69 797 73 q 808 61 808 64 q 787 43 808 52 l 605 -35 q 600 -35 604 -35 q 589 -26 595 -35 q 579 -2 584 -16 q 569 30 574 13 q 562 60 565 46 q 469 -12 519 11 q 371 -35 420 -35 q 260 -10 314 -35 q 163 61 205 15 q 96 174 121 108 q 71 321 71 239 q 99 498 71 418 q 175 636 127 578 q 287 725 223 694 q 423 757 351 757 q 519 736 474 757 q 606 683 565 715 q 610 715 610 703 q 613 734 611 728 q 623 744 616 741 q 645 747 629 746 q 742 760 694 754 q 844 768 791 766 l 774 136 m 571 392 q 580 465 578 431 q 584 528 583 499 q 561 545 573 536 q 533 561 548 553 q 503 574 519 569 q 469 578 487 578 q 408 555 433 578 q 368 496 383 531 q 346 423 353 462 q 340 355 340 385 q 368 198 340 248 q 446 148 396 148 q 492 159 467 148 q 543 191 517 171 l 571 392 m 488 944 q 438 876 458 903 q 405 833 418 849 q 385 812 392 818 q 372 806 377 806 q 366 808 368 806 q 340 825 351 818 q 318 838 328 832 q 297 849 308 844 q 274 861 287 854 q 264 875 264 866 q 267 888 265 880 q 273 907 269 895 l 398 1271 q 405 1284 401 1280 q 412 1287 408 1287 q 419 1285 416 1287 q 426 1282 422 1284 q 531 1220 479 1246 q 635 1168 584 1195 q 648 1149 648 1160 q 636 1122 648 1139 q 592 1071 610 1091 q 560 1033 575 1051 q 528 994 545 1015 q 488 944 512 974 z " - }, - "â": { - "ha": 846, - "x_min": 71, - "x_max": 844, - "o": "m 774 136 q 773 131 773 134 q 773 127 773 129 q 779 99 773 110 q 790 80 784 87 q 802 69 797 73 q 808 61 808 64 q 787 43 808 52 l 605 -35 q 600 -35 604 -35 q 589 -26 595 -35 q 579 -2 584 -16 q 569 30 574 13 q 562 60 565 46 q 469 -12 519 11 q 371 -35 420 -35 q 260 -10 314 -35 q 163 61 205 15 q 96 174 121 108 q 71 321 71 239 q 99 498 71 418 q 175 636 127 578 q 287 725 223 694 q 423 757 351 757 q 519 736 474 757 q 606 683 565 715 q 610 715 610 703 q 613 734 611 728 q 623 744 616 741 q 645 747 629 746 q 742 760 694 754 q 844 768 791 766 l 774 136 m 571 392 q 580 465 578 431 q 584 528 583 499 q 561 545 573 536 q 533 561 548 553 q 503 574 519 569 q 469 578 487 578 q 408 555 433 578 q 368 496 383 531 q 346 423 353 462 q 340 355 340 385 q 368 198 340 248 q 446 148 396 148 q 492 159 467 148 q 543 191 517 171 l 571 392 m 654 1127 q 679 1095 669 1109 q 698 1069 690 1080 q 713 1047 706 1057 q 728 1024 720 1036 q 741 1006 732 1018 q 759 980 750 994 q 775 952 768 966 q 783 930 783 939 q 769 911 783 920 q 738 892 756 901 q 701 876 720 884 q 671 865 682 869 q 651 856 662 861 q 628 844 640 850 q 608 835 617 839 q 594 831 599 831 q 583 837 589 831 q 568 858 577 843 l 481 1044 q 398 941 439 991 q 316 838 357 890 q 307 833 313 833 q 291 839 304 833 q 262 852 279 844 q 227 869 245 860 q 196 884 210 878 q 177 892 189 887 q 156 903 166 897 q 139 913 146 908 q 132 924 132 919 q 138 939 132 930 q 157 961 144 948 l 260 1076 q 335 1160 298 1119 q 408 1243 372 1200 q 427 1254 418 1253 q 444 1255 436 1255 l 547 1255 q 563 1253 555 1255 q 576 1242 571 1252 q 585 1229 577 1241 q 605 1199 593 1217 q 630 1162 616 1182 q 654 1127 643 1143 z " - }, - "ã": { - "ha": 846, - "x_min": 71, - "x_max": 844, - "o": "m 774 136 q 773 131 773 134 q 773 127 773 129 q 779 99 773 110 q 790 80 784 87 q 802 69 797 73 q 808 61 808 64 q 787 43 808 52 l 605 -35 q 600 -35 604 -35 q 589 -26 595 -35 q 579 -2 584 -16 q 569 30 574 13 q 562 60 565 46 q 469 -12 519 11 q 371 -35 420 -35 q 260 -10 314 -35 q 163 61 205 15 q 96 174 121 108 q 71 321 71 239 q 99 498 71 418 q 175 636 127 578 q 287 725 223 694 q 423 757 351 757 q 519 736 474 757 q 606 683 565 715 q 610 715 610 703 q 613 734 611 728 q 623 744 616 741 q 645 747 629 746 q 742 760 694 754 q 844 768 791 766 l 774 136 m 571 392 q 580 465 578 431 q 584 528 583 499 q 561 545 573 536 q 533 561 548 553 q 503 574 519 569 q 469 578 487 578 q 408 555 433 578 q 368 496 383 531 q 346 423 353 462 q 340 355 340 385 q 368 198 340 248 q 446 148 396 148 q 492 159 467 148 q 543 191 517 171 l 571 392 m 532 1071 q 556 1046 545 1053 q 582 1038 567 1038 q 612 1049 603 1038 q 625 1075 621 1061 q 631 1100 629 1088 q 639 1111 633 1111 q 650 1111 640 1111 q 674 1112 660 1112 q 705 1114 688 1113 q 737 1115 722 1114 q 763 1117 752 1116 q 777 1117 774 1117 q 789 1114 783 1117 q 795 1104 795 1112 q 778 1005 795 1055 q 729 915 760 956 q 653 849 697 874 q 555 823 609 823 q 512 827 534 823 q 470 843 491 831 q 427 874 448 854 q 382 926 405 894 q 358 947 371 943 q 328 951 346 951 q 302 945 312 951 q 286 927 292 938 q 277 903 279 916 q 275 877 275 890 q 269 866 275 871 q 255 861 264 861 q 220 861 233 861 q 196 860 207 861 q 172 860 184 860 q 139 859 159 859 q 125 862 132 859 q 119 871 119 865 q 137 987 119 935 q 187 1077 155 1040 q 260 1135 218 1114 q 351 1156 302 1156 q 401 1154 378 1156 q 447 1143 425 1152 q 489 1118 469 1135 q 532 1071 510 1101 z " - }, - "ä": { - "ha": 846, - "x_min": 71, - "x_max": 844, - "o": "m 774 136 q 773 131 773 134 q 773 127 773 129 q 779 99 773 110 q 790 80 784 87 q 802 69 797 73 q 808 61 808 64 q 787 43 808 52 l 605 -35 q 600 -35 604 -35 q 589 -26 595 -35 q 579 -2 584 -16 q 569 30 574 13 q 562 60 565 46 q 469 -12 519 11 q 371 -35 420 -35 q 260 -10 314 -35 q 163 61 205 15 q 96 174 121 108 q 71 321 71 239 q 99 498 71 418 q 175 636 127 578 q 287 725 223 694 q 423 757 351 757 q 519 736 474 757 q 606 683 565 715 q 610 715 610 703 q 613 734 611 728 q 623 744 616 741 q 645 747 629 746 q 742 760 694 754 q 844 768 791 766 l 774 136 m 571 392 q 580 465 578 431 q 584 528 583 499 q 561 545 573 536 q 533 561 548 553 q 503 574 519 569 q 469 578 487 578 q 408 555 433 578 q 368 496 383 531 q 346 423 353 462 q 340 355 340 385 q 368 198 340 248 q 446 148 396 148 q 492 159 467 148 q 543 191 517 171 l 571 392 m 113 833 q 116 889 115 871 q 117 913 117 906 q 117 924 117 921 q 118 936 117 926 q 119 966 118 945 q 122 1031 120 987 q 127 1060 123 1052 q 140 1069 130 1067 q 253 1069 193 1069 q 363 1070 312 1070 q 372 1066 370 1070 q 375 1053 375 1063 l 358 864 q 353 837 356 844 q 340 827 351 829 q 234 826 289 827 q 120 826 180 826 q 115 827 117 826 q 113 831 113 827 l 113 833 m 538 831 q 541 895 540 874 q 542 924 542 916 q 542 936 543 933 q 542 946 542 939 q 544 972 543 954 q 547 1031 545 991 q 551 1058 549 1050 q 564 1067 554 1066 q 677 1068 618 1067 q 787 1069 736 1068 q 796 1066 792 1069 q 800 1055 800 1063 l 783 863 q 778 836 781 843 q 764 827 776 828 q 657 825 712 826 q 541 825 602 825 q 538 825 539 825 q 538 829 538 825 l 538 831 z " - }, - "å": { - "ha": 846, - "x_min": 71, - "x_max": 844, - "o": "m 774 136 q 773 131 773 134 q 773 127 773 129 q 779 99 773 110 q 790 80 784 87 q 802 69 797 73 q 808 61 808 64 q 787 43 808 52 l 605 -35 q 600 -35 604 -35 q 589 -26 595 -35 q 579 -2 584 -16 q 569 30 574 13 q 562 60 565 46 q 469 -12 519 11 q 371 -35 420 -35 q 260 -10 314 -35 q 163 61 205 15 q 96 174 121 108 q 71 321 71 239 q 99 498 71 418 q 175 636 127 578 q 287 725 223 694 q 423 757 351 757 q 519 736 474 757 q 606 683 565 715 q 610 715 610 703 q 613 734 611 728 q 623 744 616 741 q 645 747 629 746 q 742 760 694 754 q 844 768 791 766 l 774 136 m 571 392 q 580 465 578 431 q 584 528 583 499 q 561 545 573 536 q 533 561 548 553 q 503 574 519 569 q 469 578 487 578 q 408 555 433 578 q 368 496 383 531 q 346 423 353 462 q 340 355 340 385 q 368 198 340 248 q 446 148 396 148 q 492 159 467 148 q 543 191 517 171 l 571 392 m 455 808 q 380 821 415 808 q 320 856 346 833 q 280 912 295 879 q 266 988 266 945 q 281 1061 266 1027 q 324 1122 297 1096 q 388 1163 351 1147 q 468 1178 425 1178 q 538 1166 505 1178 q 595 1131 571 1154 q 634 1077 620 1109 q 648 1006 648 1045 q 634 934 648 970 q 596 870 621 899 q 535 825 571 842 q 455 808 500 808 m 526 989 q 526 996 526 992 q 526 1002 526 999 q 524 1028 526 1015 q 514 1054 521 1042 q 496 1074 507 1066 q 469 1081 486 1081 q 430 1073 447 1081 q 403 1051 414 1064 q 388 1021 393 1038 q 382 987 382 1004 q 385 961 382 975 q 395 935 388 947 q 413 916 401 924 q 443 907 425 908 q 478 915 463 907 q 502 933 492 922 q 518 960 512 945 q 526 989 524 975 z " - }, - "æ": { - "ha": 1300, - "x_min": 70, - "x_max": 1299, - "o": "m 734 604 q 858 716 787 675 q 1015 758 928 758 q 1080 748 1046 758 q 1145 720 1114 738 q 1205 675 1177 701 q 1254 617 1233 649 q 1286 548 1274 585 q 1299 471 1299 511 q 1295 422 1299 447 q 1284 372 1291 397 q 1275 342 1284 351 q 1243 329 1265 334 q 1186 321 1221 325 q 1099 306 1151 317 q 1033 294 1067 299 q 966 285 1000 290 q 899 275 932 280 q 833 261 865 269 q 851 208 836 231 q 892 171 867 186 q 947 150 916 157 q 1012 143 979 143 q 1075 150 1044 143 q 1133 166 1105 156 q 1186 189 1160 176 q 1235 215 1212 202 q 1245 217 1241 216 q 1254 218 1250 218 q 1254 207 1254 218 q 1253 175 1253 196 q 1253 125 1253 155 q 1252 61 1253 96 q 1255 49 1255 54 q 1252 40 1255 43 q 1244 34 1249 37 q 1190 8 1222 22 q 1120 -16 1158 -5 q 1044 -34 1083 -27 q 970 -41 1005 -41 q 889 -33 929 -41 q 812 -9 849 -25 q 742 29 775 6 q 682 82 709 52 q 606 27 646 50 q 527 -11 567 4 q 447 -34 486 -26 q 370 -41 407 -41 q 259 -16 313 -41 q 163 55 205 9 q 95 168 121 102 q 70 315 70 233 q 98 492 70 412 q 174 630 126 572 q 287 719 222 687 q 422 750 351 750 q 599 731 518 750 q 754 684 680 713 l 734 604 m 562 185 q 578 329 572 269 q 588 430 584 389 q 594 497 592 471 q 597 542 596 524 q 540 562 573 551 q 469 572 507 572 q 407 549 432 572 q 367 490 382 525 q 346 417 352 456 q 339 349 339 378 q 367 192 339 241 q 446 142 395 142 q 500 153 471 142 q 562 185 530 165 m 998 576 q 939 565 966 576 q 891 531 913 553 q 854 478 870 509 q 827 410 838 447 l 1105 465 q 1106 470 1105 467 q 1106 475 1106 473 q 1096 519 1106 500 q 1070 551 1086 538 q 1035 570 1055 564 q 998 576 1016 576 z " - }, - "ç": { - "ha": 716, - "x_min": 69, - "x_max": 738, - "o": "m 69 331 q 102 497 69 420 q 193 633 135 575 q 330 724 251 690 q 502 757 409 757 q 610 747 565 757 q 683 724 654 736 q 725 701 711 711 q 738 690 738 690 q 735 667 738 686 q 728 624 732 648 q 721 573 724 599 q 718 528 718 547 q 716 520 718 524 q 705 516 714 516 q 682 522 697 516 q 643 534 666 528 q 591 547 621 541 q 526 553 562 553 q 445 537 481 553 q 383 493 409 521 q 343 426 357 465 q 330 342 330 387 q 344 263 330 296 q 383 209 359 230 q 439 179 408 189 q 507 170 471 170 q 589 181 547 170 q 667 212 630 192 q 672 213 668 213 q 677 210 675 213 q 679 197 679 206 q 679 144 679 175 q 679 85 679 113 q 677 37 678 57 q 676 18 677 18 q 623 -9 652 1 q 565 -25 595 -19 q 504 -33 534 -31 q 445 -35 473 -35 q 297 -9 366 -35 q 178 66 229 18 q 98 181 127 114 q 69 331 69 249 m 552 -262 q 529 -320 546 -294 q 488 -365 512 -346 q 435 -394 465 -383 q 374 -404 406 -404 q 314 -400 346 -404 q 259 -382 283 -396 l 260 -383 q 260 -378 260 -382 q 261 -357 260 -370 q 263 -330 262 -345 q 268 -302 265 -315 q 273 -279 270 -288 l 276 -279 q 280 -281 280 -279 l 279 -281 q 300 -289 290 -286 q 320 -294 309 -292 q 343 -296 330 -296 q 372 -297 355 -297 q 416 -280 401 -297 q 432 -241 432 -263 q 419 -208 432 -221 q 385 -195 407 -195 q 321 -192 348 -195 q 285 -189 295 -189 q 278 -186 279 -189 q 277 -180 277 -184 q 285 -159 281 -174 q 294 -126 290 -144 q 303 -89 299 -109 q 312 -53 308 -69 q 318 -25 315 -36 q 320 -12 320 -14 l 333 -12 q 363 -12 345 -12 q 399 -12 381 -12 l 441 -12 l 409 -108 q 430 -105 420 -106 q 449 -104 440 -104 q 504 -116 484 -104 q 536 -144 525 -127 q 551 -184 547 -162 q 555 -230 555 -207 q 554 -246 555 -238 q 552 -262 553 -254 z " - }, - "è": { - "ha": 774, - "x_min": 68, - "x_max": 771, - "o": "m 486 757 q 603 733 550 757 q 693 670 655 709 q 751 585 730 632 q 771 490 771 537 q 745 405 771 448 q 673 329 720 363 q 562 274 627 295 q 418 253 496 253 q 333 261 378 253 q 350 211 336 232 q 386 176 364 190 q 435 156 408 163 q 492 150 463 150 q 554 156 524 150 q 612 171 585 161 q 666 192 640 180 q 715 215 692 203 q 725 217 721 216 q 734 218 730 218 q 733 208 734 218 q 733 177 733 197 q 733 130 733 157 q 732 68 732 102 q 734 61 734 64 q 735 56 735 58 q 720 38 735 47 q 681 18 705 28 q 626 -1 657 8 q 564 -19 595 -11 q 502 -31 532 -26 q 450 -35 472 -35 q 308 -10 376 -35 q 185 63 239 16 q 100 178 132 111 q 68 331 68 246 q 99 497 68 420 q 185 633 130 575 q 317 724 240 690 q 486 757 393 757 m 477 576 q 426 565 450 576 q 384 531 403 553 q 350 478 364 509 q 327 410 336 447 q 443 435 397 422 q 517 463 489 449 q 556 491 545 477 q 568 517 568 505 q 558 541 568 530 q 536 559 549 551 q 506 572 522 568 q 477 576 490 576 m 380 968 q 353 1015 364 996 q 333 1051 342 1034 q 313 1087 323 1068 q 287 1135 302 1107 q 282 1149 283 1143 q 280 1162 281 1156 q 283 1174 280 1169 q 294 1181 287 1178 q 346 1210 319 1196 q 401 1240 374 1225 q 457 1272 429 1255 q 509 1305 484 1288 q 519 1309 516 1309 q 524 1303 523 1309 l 600 907 q 603 892 602 898 q 604 881 604 886 q 602 869 604 875 q 593 861 600 864 q 567 849 579 854 q 543 838 555 844 q 518 825 531 832 q 488 808 505 819 q 481 806 486 806 q 467 815 475 806 q 449 843 460 824 q 421 893 437 863 q 380 968 404 924 z " - }, - "é": { - "ha": 774, - "x_min": 68, - "x_max": 771, - "o": "m 486 757 q 603 733 550 757 q 693 670 655 709 q 751 585 730 632 q 771 490 771 537 q 745 405 771 448 q 673 329 720 363 q 562 274 627 295 q 418 253 496 253 q 333 261 378 253 q 350 211 336 232 q 386 176 364 190 q 435 156 408 163 q 492 150 463 150 q 554 156 524 150 q 612 171 585 161 q 666 192 640 180 q 715 215 692 203 q 725 217 721 216 q 734 218 730 218 q 733 208 734 218 q 733 177 733 197 q 733 130 733 157 q 732 68 732 102 q 734 61 734 64 q 735 56 735 58 q 720 38 735 47 q 681 18 705 28 q 626 -1 657 8 q 564 -19 595 -11 q 502 -31 532 -26 q 450 -35 472 -35 q 308 -10 376 -35 q 185 63 239 16 q 100 178 132 111 q 68 331 68 246 q 99 497 68 420 q 185 633 130 575 q 317 724 240 690 q 486 757 393 757 m 477 576 q 426 565 450 576 q 384 531 403 553 q 350 478 364 509 q 327 410 336 447 q 443 435 397 422 q 517 463 489 449 q 556 491 545 477 q 568 517 568 505 q 558 541 568 530 q 536 559 549 551 q 506 572 522 568 q 477 576 490 576 m 473 944 q 423 876 443 903 q 390 833 403 849 q 370 812 377 818 q 357 806 362 806 q 351 808 353 806 q 325 825 336 818 q 303 838 313 832 q 282 849 293 844 q 259 861 272 854 q 250 875 250 866 q 252 888 250 880 q 258 907 254 895 l 383 1271 q 390 1284 387 1280 q 397 1287 393 1287 q 404 1285 401 1287 q 411 1282 408 1284 q 516 1220 464 1246 q 621 1168 569 1195 q 633 1149 633 1160 q 621 1122 633 1139 q 577 1071 595 1091 q 545 1033 560 1051 q 513 994 530 1015 q 473 944 497 974 z " - }, - "ê": { - "ha": 774, - "x_min": 68, - "x_max": 771, - "o": "m 486 757 q 603 733 550 757 q 693 670 655 709 q 751 585 730 632 q 771 490 771 537 q 745 405 771 448 q 673 329 720 363 q 562 274 627 295 q 418 253 496 253 q 333 261 378 253 q 350 211 336 232 q 386 176 364 190 q 435 156 408 163 q 492 150 463 150 q 554 156 524 150 q 612 171 585 161 q 666 192 640 180 q 715 215 692 203 q 725 217 721 216 q 734 218 730 218 q 733 208 734 218 q 733 177 733 197 q 733 130 733 157 q 732 68 732 102 q 734 61 734 64 q 735 56 735 58 q 720 38 735 47 q 681 18 705 28 q 626 -1 657 8 q 564 -19 595 -11 q 502 -31 532 -26 q 450 -35 472 -35 q 308 -10 376 -35 q 185 63 239 16 q 100 178 132 111 q 68 331 68 246 q 99 497 68 420 q 185 633 130 575 q 317 724 240 690 q 486 757 393 757 m 477 576 q 426 565 450 576 q 384 531 403 553 q 350 478 364 509 q 327 410 336 447 q 443 435 397 422 q 517 463 489 449 q 556 491 545 477 q 568 517 568 505 q 558 541 568 530 q 536 559 549 551 q 506 572 522 568 q 477 576 490 576 m 633 1127 q 658 1095 648 1109 q 677 1069 669 1080 q 692 1047 685 1057 q 707 1024 699 1036 q 720 1006 711 1018 q 738 980 729 994 q 754 952 747 966 q 762 930 762 939 q 748 911 762 920 q 717 892 735 901 q 680 876 699 884 q 650 865 661 869 q 630 856 641 861 q 607 844 618 850 q 587 835 596 839 q 573 831 578 831 q 562 837 568 831 q 547 858 556 843 l 460 1044 q 377 941 418 991 q 295 838 336 890 q 286 833 292 833 q 270 839 283 833 q 241 852 258 844 q 206 869 224 860 q 175 884 189 878 q 156 892 168 887 q 135 903 145 897 q 118 913 125 908 q 111 924 111 919 q 117 939 111 930 q 136 961 123 948 l 239 1076 q 314 1160 277 1119 q 387 1243 351 1200 q 406 1254 397 1253 q 422 1255 415 1255 l 526 1255 q 542 1253 534 1255 q 555 1242 550 1252 q 564 1229 556 1241 q 584 1199 572 1217 q 609 1162 595 1182 q 633 1127 622 1143 z " - }, - "ë": { - "ha": 774, - "x_min": 68, - "x_max": 785, - "o": "m 486 757 q 603 733 550 757 q 693 670 655 709 q 751 585 730 632 q 771 490 771 537 q 745 405 771 448 q 673 329 720 363 q 562 274 627 295 q 418 253 496 253 q 333 261 378 253 q 350 211 336 232 q 386 176 364 190 q 435 156 408 163 q 492 150 463 150 q 554 156 524 150 q 612 171 585 161 q 666 192 640 180 q 715 215 692 203 q 725 217 721 216 q 734 218 730 218 q 733 208 734 218 q 733 177 733 197 q 733 130 733 157 q 732 68 732 102 q 734 61 734 64 q 735 56 735 58 q 720 38 735 47 q 681 18 705 28 q 626 -1 657 8 q 564 -19 595 -11 q 502 -31 532 -26 q 450 -35 472 -35 q 308 -10 376 -35 q 185 63 239 16 q 100 178 132 111 q 68 331 68 246 q 99 497 68 420 q 185 633 130 575 q 317 724 240 690 q 486 757 393 757 m 477 576 q 426 565 450 576 q 384 531 403 553 q 350 478 364 509 q 327 410 336 447 q 443 435 397 422 q 517 463 489 449 q 556 491 545 477 q 568 517 568 505 q 558 541 568 530 q 536 559 549 551 q 506 572 522 568 q 477 576 490 576 m 98 833 q 101 889 100 871 q 102 913 102 906 q 102 924 102 921 q 103 936 102 926 q 104 966 103 945 q 107 1031 105 987 q 112 1060 109 1052 q 125 1069 115 1067 q 238 1069 178 1069 q 348 1070 297 1070 q 357 1066 355 1070 q 360 1053 360 1063 l 343 864 q 338 837 341 844 q 326 827 336 829 q 219 826 274 827 q 105 826 165 826 q 100 827 102 826 q 98 831 98 827 l 98 833 m 523 831 q 526 895 525 874 q 527 924 527 916 q 527 936 528 933 q 527 946 527 939 q 529 972 528 954 q 532 1031 530 991 q 536 1058 534 1050 q 549 1067 539 1066 q 662 1068 603 1067 q 772 1069 721 1068 q 781 1066 777 1069 q 785 1055 785 1063 l 768 863 q 763 836 766 843 q 749 827 761 828 q 642 825 697 826 q 526 825 587 825 q 524 825 524 825 q 523 829 523 825 l 523 831 z " - }, - "ì": { - "ha": 414, - "x_min": 73, - "x_max": 417, - "o": "m 99 288 q 117 471 109 380 q 132 658 125 562 q 137 689 134 680 q 152 700 140 697 q 273 724 210 711 q 395 756 336 736 q 401 757 397 757 q 408 751 408 757 l 347 80 q 342 49 345 58 q 328 38 340 41 q 211 -2 270 20 q 86 -45 152 -24 q 80 -46 84 -46 q 73 -39 73 -46 q 74 -20 73 -39 q 78 26 75 -2 q 83 91 80 55 q 89 163 85 127 q 94 232 92 199 q 99 288 97 264 m 193 968 q 166 1015 177 996 q 146 1051 155 1034 q 125 1087 136 1068 q 100 1135 115 1107 q 95 1149 96 1143 q 93 1162 94 1156 q 96 1174 93 1169 q 106 1181 100 1178 q 159 1210 132 1196 q 214 1240 186 1225 q 270 1272 242 1255 q 322 1305 297 1288 q 332 1309 329 1309 q 337 1303 336 1309 l 413 907 q 416 892 414 898 q 417 881 417 886 q 415 869 417 875 q 406 861 413 864 q 380 849 392 854 q 356 838 368 844 q 331 825 344 832 q 301 808 317 819 q 294 806 298 806 q 280 815 288 806 q 261 843 273 824 q 234 893 250 863 q 193 968 217 924 z " - }, - "í": { - "ha": 414, - "x_min": 62, - "x_max": 446, - "o": "m 99 288 q 117 471 109 380 q 132 658 125 562 q 137 689 134 680 q 152 700 140 697 q 273 724 210 711 q 395 756 336 736 q 401 757 397 757 q 408 751 408 757 l 347 80 q 342 49 345 58 q 328 38 340 41 q 211 -2 270 20 q 86 -45 152 -24 q 80 -46 84 -46 q 73 -39 73 -46 q 74 -20 73 -39 q 78 26 75 -2 q 83 91 80 55 q 89 163 85 127 q 94 232 92 199 q 99 288 97 264 m 286 944 q 236 876 256 903 q 203 833 216 849 q 182 812 190 818 q 170 806 175 806 q 163 808 166 806 q 138 825 149 818 q 116 838 126 832 q 95 849 106 844 q 72 861 85 854 q 62 875 62 866 q 65 888 63 880 q 71 907 66 895 l 196 1271 q 203 1284 199 1280 q 210 1287 206 1287 q 217 1285 214 1287 q 224 1282 220 1284 q 329 1220 277 1246 q 433 1168 382 1195 q 446 1149 446 1160 q 434 1122 446 1139 q 390 1071 408 1091 q 358 1033 373 1051 q 326 994 342 1015 q 286 944 310 974 z " - }, - "î": { - "ha": 414, - "x_min": -68, - "x_max": 583, - "o": "m 99 288 q 117 471 109 380 q 132 658 125 562 q 137 689 134 680 q 152 700 140 697 q 273 724 210 711 q 395 756 336 736 q 401 757 397 757 q 408 751 408 757 l 347 80 q 342 49 345 58 q 328 38 340 41 q 211 -2 270 20 q 86 -45 152 -24 q 80 -46 84 -46 q 73 -39 73 -46 q 74 -20 73 -39 q 78 26 75 -2 q 83 91 80 55 q 89 163 85 127 q 94 232 92 199 q 99 288 97 264 m 454 1127 q 479 1095 469 1109 q 498 1069 490 1080 q 513 1047 506 1057 q 528 1024 519 1036 q 541 1006 532 1018 q 559 980 550 994 q 575 952 568 966 q 583 930 583 939 q 569 911 583 920 q 538 892 556 901 q 501 876 519 884 q 471 865 482 869 q 451 856 462 861 q 428 844 439 850 q 408 835 417 839 q 394 831 399 831 q 383 837 389 831 q 368 858 377 843 l 281 1044 q 198 941 239 991 q 116 838 157 890 q 107 833 113 833 q 91 839 104 833 q 62 852 79 844 q 27 869 45 860 q -4 884 9 878 q -23 892 -12 887 q -44 903 -34 897 q -61 913 -54 908 q -68 924 -68 919 q -62 939 -68 930 q -43 961 -56 948 l 60 1076 q 135 1160 98 1119 q 208 1243 172 1200 q 227 1254 218 1253 q 243 1255 236 1255 l 347 1255 q 363 1253 355 1255 q 376 1242 371 1252 q 385 1229 377 1241 q 405 1199 393 1217 q 430 1162 416 1182 q 454 1127 443 1143 z " - }, - "ï": { - "ha": 414, - "x_min": -87, - "x_max": 600, - "o": "m 99 288 q 117 471 109 380 q 132 658 125 562 q 137 689 134 680 q 152 700 140 697 q 273 724 210 711 q 395 756 336 736 q 401 757 397 757 q 408 751 408 757 l 347 80 q 342 49 345 58 q 328 38 340 41 q 211 -2 270 20 q 86 -45 152 -24 q 80 -46 84 -46 q 73 -39 73 -46 q 74 -20 73 -39 q 78 26 75 -2 q 83 91 80 55 q 89 163 85 127 q 94 232 92 199 q 99 288 97 264 m -87 833 q -84 889 -85 871 q -83 913 -83 906 q -83 924 -83 921 q -82 936 -83 926 q -81 966 -82 945 q -78 1031 -80 987 q -73 1060 -77 1052 q -60 1069 -70 1067 q 53 1069 -7 1069 q 163 1070 112 1070 q 172 1066 170 1070 q 175 1053 175 1063 l 158 864 q 153 837 156 844 q 140 827 151 829 q 34 826 89 827 q -80 826 -20 826 q -85 827 -83 826 q -87 831 -87 827 l -87 833 m 338 831 q 341 895 340 874 q 342 924 342 916 q 342 936 342 933 q 342 946 342 939 q 343 972 342 954 q 347 1031 345 991 q 351 1058 349 1050 q 364 1067 354 1066 q 477 1068 418 1067 q 587 1069 536 1068 q 596 1066 592 1069 q 600 1055 600 1063 l 583 863 q 578 836 581 843 q 564 827 576 828 q 457 825 512 826 q 341 825 401 825 q 338 825 339 825 q 338 829 338 825 l 338 831 z " - }, - "ð": { - "ha": 899, - "x_min": 72, - "x_max": 888, - "o": "m 373 747 q 362 745 367 745 q 337 755 352 745 q 308 779 322 766 q 283 804 294 792 q 273 821 273 817 q 332 853 273 832 l 399 873 q 381 902 391 886 q 360 933 370 918 q 343 960 351 948 q 336 976 336 972 q 353 991 336 986 q 384 1001 370 996 q 411 1012 398 1006 q 438 1026 425 1018 q 468 1043 452 1034 q 477 1046 473 1046 q 486 1044 482 1046 q 491 1040 489 1042 q 537 987 513 1014 q 585 931 561 960 l 681 961 q 699 965 693 965 q 708 963 705 965 q 715 957 712 960 l 741 922 q 767 884 759 897 q 777 867 776 871 q 772 858 777 862 q 765 854 767 854 l 674 824 q 755 712 717 770 q 824 593 794 654 q 871 467 853 532 q 888 336 888 403 q 877 245 888 290 q 843 159 866 200 q 786 82 821 117 q 703 21 751 47 q 595 -20 656 -5 q 461 -35 535 -35 q 296 -1 368 -35 q 174 87 224 33 q 98 210 124 142 q 72 347 72 278 q 91 474 72 412 q 149 585 110 536 q 249 662 189 633 q 391 692 309 692 q 455 684 430 692 q 492 667 479 676 q 474 715 484 690 q 453 766 465 740 l 373 747 m 356 336 q 367 271 358 305 q 393 208 376 237 q 436 161 410 180 q 500 142 463 142 q 542 156 526 142 q 567 191 558 170 q 579 238 576 212 q 582 288 582 264 q 580 348 582 323 q 573 395 578 373 q 559 442 568 418 q 537 500 550 466 q 511 508 521 506 q 488 511 501 511 q 427 498 452 511 q 386 465 401 486 q 362 416 370 444 q 355 357 355 388 q 355 347 355 352 q 356 336 355 341 z " - }, - "ñ": { - "ha": 897, - "x_min": 73, - "x_max": 876, - "o": "m 644 -24 q 625 -31 637 -26 q 601 -35 612 -35 q 584 -31 591 -35 q 577 -14 577 -26 l 577 -10 q 584 52 581 26 q 589 98 587 77 q 593 139 591 119 q 597 188 595 160 q 604 253 600 215 q 613 347 608 290 q 619 417 616 381 q 622 484 622 453 q 619 521 622 504 q 608 551 616 538 q 587 570 600 564 q 552 577 573 577 q 509 570 536 577 q 454 548 481 564 q 406 507 427 532 q 382 444 385 481 q 375 358 378 394 q 369 298 372 323 q 365 258 366 273 q 362 231 363 242 q 360 216 361 229 q 357 187 359 204 q 354 151 355 170 q 350 115 352 132 q 348 86 349 98 q 347 71 347 74 q 347 62 347 66 q 347 55 347 58 q 342 46 347 50 q 319 37 337 42 l 140 -24 q 120 -31 132 -27 q 96 -35 108 -35 q 80 -31 87 -35 q 73 -14 73 -26 l 134 679 q 139 710 136 701 q 155 721 142 718 q 281 746 216 733 q 408 778 347 758 q 415 776 414 778 q 416 771 416 774 q 415 767 416 770 q 413 755 415 764 q 409 726 412 745 q 400 672 406 707 q 488 716 447 699 q 565 742 529 732 q 633 754 602 751 q 693 757 665 757 q 832 699 789 757 q 876 525 876 641 q 875 491 876 509 q 872 456 874 474 l 841 164 q 837 112 838 136 q 836 56 836 87 q 837 46 836 50 q 837 40 837 43 q 832 31 837 34 q 809 22 827 27 l 644 -24 m 547 1071 q 571 1046 560 1053 q 597 1038 583 1038 q 628 1049 618 1038 q 641 1075 637 1061 q 646 1100 644 1088 q 654 1111 648 1111 q 666 1111 656 1111 q 690 1112 675 1112 q 721 1114 704 1113 q 753 1115 738 1114 q 779 1117 768 1116 q 793 1117 790 1117 q 804 1114 798 1117 q 810 1104 810 1112 q 793 1005 810 1055 q 744 915 776 956 q 669 849 713 874 q 571 823 625 823 q 528 827 549 823 q 485 843 507 831 q 442 874 464 854 q 398 926 420 894 q 374 947 387 943 q 344 951 361 951 q 317 945 328 951 q 301 927 307 938 q 293 903 295 916 q 290 877 290 890 q 285 866 290 871 q 271 861 279 861 q 236 861 249 861 q 211 860 222 861 q 188 860 200 860 q 155 859 175 859 q 141 862 147 859 q 134 871 134 865 q 153 987 134 935 q 202 1077 171 1040 q 276 1135 234 1114 q 366 1156 318 1156 q 417 1154 393 1156 q 462 1143 440 1152 q 505 1118 484 1135 q 547 1071 526 1101 z " - }, - "ò": { - "ha": 890, - "x_min": 68, - "x_max": 885, - "o": "m 454 -35 q 287 -4 359 -35 q 165 79 214 27 q 92 198 117 131 q 68 338 68 266 q 92 476 68 411 q 158 594 115 542 q 260 681 201 646 q 392 728 320 715 q 403 732 403 728 q 401 746 403 740 q 399 758 399 753 q 402 768 399 765 q 408 770 405 770 q 629 741 538 770 q 777 661 720 711 q 859 541 833 610 q 885 392 885 471 q 851 212 885 291 q 759 77 817 132 q 622 -6 700 22 q 454 -35 543 -35 m 329 346 q 337 273 329 309 q 362 208 345 237 q 410 161 380 179 q 482 143 439 143 q 537 157 513 144 q 577 190 560 170 q 605 235 594 210 q 623 287 616 260 q 632 339 629 313 q 635 386 635 365 q 624 455 635 421 q 593 515 614 489 q 543 556 573 541 q 473 572 513 572 q 405 548 433 572 q 360 489 377 524 q 336 415 344 454 q 329 346 329 376 m 416 968 q 389 1015 400 996 q 369 1051 378 1034 q 349 1087 359 1068 q 323 1135 338 1107 q 318 1149 319 1143 q 316 1162 317 1156 q 319 1174 316 1169 q 330 1181 323 1178 q 382 1210 355 1196 q 437 1240 410 1225 q 493 1272 465 1255 q 545 1305 520 1288 q 555 1309 552 1309 q 560 1303 559 1309 l 636 907 q 639 892 637 898 q 640 881 640 886 q 638 869 640 875 q 629 861 636 864 q 603 849 615 854 q 579 838 591 844 q 554 825 567 832 q 524 808 541 819 q 517 806 522 806 q 503 815 511 806 q 485 843 496 824 q 457 893 473 863 q 416 968 440 924 z " - }, - "ó": { - "ha": 890, - "x_min": 68, - "x_max": 885, - "o": "m 454 -35 q 287 -4 359 -35 q 165 79 214 27 q 92 198 117 131 q 68 338 68 266 q 92 476 68 411 q 158 594 115 542 q 260 681 201 646 q 392 728 320 715 q 403 732 403 728 q 401 746 403 740 q 399 758 399 753 q 402 768 399 765 q 408 770 405 770 q 629 741 538 770 q 777 661 720 711 q 859 541 833 610 q 885 392 885 471 q 851 212 885 291 q 759 77 817 132 q 622 -6 700 22 q 454 -35 543 -35 m 329 346 q 337 273 329 309 q 362 208 345 237 q 410 161 380 179 q 482 143 439 143 q 537 157 513 144 q 577 190 560 170 q 605 235 594 210 q 623 287 616 260 q 632 339 629 313 q 635 386 635 365 q 624 455 635 421 q 593 515 614 489 q 543 556 573 541 q 473 572 513 572 q 405 548 433 572 q 360 489 377 524 q 336 415 344 454 q 329 346 329 376 m 508 944 q 458 876 478 903 q 425 833 438 849 q 405 812 412 818 q 393 806 397 806 q 386 808 389 806 q 360 825 372 818 q 338 838 349 832 q 318 849 328 844 q 294 861 307 854 q 285 875 285 866 q 287 888 286 880 q 293 907 289 895 l 418 1271 q 425 1284 422 1280 q 433 1287 429 1287 q 439 1285 436 1287 q 446 1282 443 1284 q 552 1220 499 1246 q 656 1168 604 1195 q 668 1149 668 1160 q 656 1122 668 1139 q 613 1071 630 1091 q 580 1033 595 1051 q 549 994 565 1015 q 508 944 532 974 z " - }, - "ô": { - "ha": 890, - "x_min": 68, - "x_max": 885, - "o": "m 454 -35 q 287 -4 359 -35 q 165 79 214 27 q 92 198 117 131 q 68 338 68 266 q 92 476 68 411 q 158 594 115 542 q 260 681 201 646 q 392 728 320 715 q 403 732 403 728 q 401 746 403 740 q 399 758 399 753 q 402 768 399 765 q 408 770 405 770 q 629 741 538 770 q 777 661 720 711 q 859 541 833 610 q 885 392 885 471 q 851 212 885 291 q 759 77 817 132 q 622 -6 700 22 q 454 -35 543 -35 m 329 346 q 337 273 329 309 q 362 208 345 237 q 410 161 380 179 q 482 143 439 143 q 537 157 513 144 q 577 190 560 170 q 605 235 594 210 q 623 287 616 260 q 632 339 629 313 q 635 386 635 365 q 624 455 635 421 q 593 515 614 489 q 543 556 573 541 q 473 572 513 572 q 405 548 433 572 q 360 489 377 524 q 336 415 344 454 q 329 346 329 376 m 672 1127 q 697 1095 687 1109 q 716 1069 708 1080 q 731 1047 724 1057 q 746 1024 738 1036 q 759 1006 750 1018 q 778 980 768 994 q 794 952 787 966 q 801 930 801 939 q 788 911 801 920 q 756 892 774 901 q 719 876 738 884 q 690 865 701 869 q 669 856 680 861 q 647 844 658 850 q 626 835 635 839 q 612 831 617 831 q 601 837 607 831 q 587 858 595 843 l 499 1044 q 417 941 458 991 q 334 838 376 890 q 326 833 332 833 q 310 839 322 833 q 280 852 297 844 q 245 869 263 860 q 214 884 228 878 q 196 892 207 887 q 174 903 184 897 q 157 913 164 908 q 150 924 150 919 q 156 939 150 930 q 176 961 162 948 l 278 1076 q 353 1160 317 1119 q 427 1243 390 1200 q 445 1254 436 1253 q 462 1255 454 1255 l 565 1255 q 581 1253 573 1255 q 595 1242 589 1252 q 604 1229 595 1241 q 623 1199 612 1217 q 648 1162 635 1182 q 672 1127 661 1143 z " - }, - "õ": { - "ha": 890, - "x_min": 68, - "x_max": 885, - "o": "m 454 -35 q 287 -4 359 -35 q 165 79 214 27 q 92 198 117 131 q 68 338 68 266 q 92 476 68 411 q 158 594 115 542 q 260 681 201 646 q 392 728 320 715 q 403 732 403 728 q 401 746 403 740 q 399 758 399 753 q 402 768 399 765 q 408 770 405 770 q 629 741 538 770 q 777 661 720 711 q 859 541 833 610 q 885 392 885 471 q 851 212 885 291 q 759 77 817 132 q 622 -6 700 22 q 454 -35 543 -35 m 329 346 q 337 273 329 309 q 362 208 345 237 q 410 161 380 179 q 482 143 439 143 q 537 157 513 144 q 577 190 560 170 q 605 235 594 210 q 623 287 616 260 q 632 339 629 313 q 635 386 635 365 q 624 455 635 421 q 593 515 614 489 q 543 556 573 541 q 473 572 513 572 q 405 548 433 572 q 360 489 377 524 q 336 415 344 454 q 329 346 329 376 m 553 1071 q 577 1046 566 1053 q 603 1038 588 1038 q 633 1049 624 1038 q 646 1075 642 1061 q 652 1100 650 1088 q 660 1111 654 1111 q 671 1111 661 1111 q 695 1112 681 1112 q 726 1114 709 1113 q 758 1115 743 1114 q 784 1117 773 1116 q 798 1117 795 1117 q 810 1114 804 1117 q 816 1104 816 1112 q 799 1005 816 1055 q 750 915 781 956 q 674 849 718 874 q 576 823 630 823 q 533 827 555 823 q 491 843 512 831 q 448 874 469 854 q 404 926 426 894 q 379 947 392 943 q 349 951 367 951 q 323 945 333 951 q 307 927 313 938 q 298 903 300 916 q 296 877 296 890 q 290 866 296 871 q 276 861 285 861 q 241 861 254 861 q 217 860 228 861 q 193 860 205 860 q 160 859 180 859 q 146 862 153 859 q 140 871 140 865 q 158 987 140 935 q 208 1077 176 1040 q 281 1135 239 1114 q 372 1156 323 1156 q 422 1154 399 1156 q 468 1143 446 1152 q 510 1118 490 1135 q 553 1071 531 1101 z " - }, - "ö": { - "ha": 890, - "x_min": 68, - "x_max": 885, - "o": "m 454 -35 q 287 -4 359 -35 q 165 79 214 27 q 92 198 117 131 q 68 338 68 266 q 92 476 68 411 q 158 594 115 542 q 260 681 201 646 q 392 728 320 715 q 403 732 403 728 q 401 746 403 740 q 399 758 399 753 q 402 768 399 765 q 408 770 405 770 q 629 741 538 770 q 777 661 720 711 q 859 541 833 610 q 885 392 885 471 q 851 212 885 291 q 759 77 817 132 q 622 -6 700 22 q 454 -35 543 -35 m 329 346 q 337 273 329 309 q 362 208 345 237 q 410 161 380 179 q 482 143 439 143 q 537 157 513 144 q 577 190 560 170 q 605 235 594 210 q 623 287 616 260 q 632 339 629 313 q 635 386 635 365 q 624 455 635 421 q 593 515 614 489 q 543 556 573 541 q 473 572 513 572 q 405 548 433 572 q 360 489 377 524 q 336 415 344 454 q 329 346 329 376 m 134 833 q 137 889 136 871 q 138 913 138 906 q 138 924 138 921 q 139 936 138 926 q 140 966 139 945 q 143 1031 141 987 q 148 1060 144 1052 q 161 1069 151 1067 q 274 1069 214 1069 q 384 1070 333 1070 q 393 1066 391 1070 q 396 1053 396 1063 l 379 864 q 374 837 377 844 q 361 827 372 829 q 255 826 310 827 q 141 826 201 826 q 136 827 138 826 q 134 831 134 827 l 134 833 m 559 831 q 562 895 561 874 q 563 924 563 916 q 563 936 564 933 q 563 946 563 939 q 565 972 564 954 q 568 1031 566 991 q 572 1058 570 1050 q 585 1067 575 1066 q 698 1068 639 1067 q 808 1069 757 1068 q 817 1066 813 1069 q 821 1055 821 1063 l 804 863 q 799 836 802 843 q 785 827 797 828 q 678 825 733 826 q 562 825 623 825 q 559 825 560 825 q 559 829 559 825 l 559 831 z " - }, - "÷": { - "ha": 924, - "x_min": 65, - "x_max": 928, - "o": "m 384 635 q 386 686 385 667 q 387 715 387 705 q 387 729 387 725 q 387 737 387 733 q 388 746 387 741 q 389 764 388 751 q 391 799 389 777 q 394 857 392 821 q 398 888 395 880 q 414 899 401 897 q 538 899 473 899 q 661 900 604 899 q 671 897 667 900 q 675 884 675 893 l 656 671 q 651 640 654 648 q 636 630 649 631 q 518 629 578 629 q 391 628 457 628 q 386 629 387 628 q 384 633 384 629 l 384 635 m 370 -26 q 372 25 372 6 q 373 54 373 43 q 374 68 374 64 q 374 76 374 72 q 374 85 374 79 q 375 103 374 90 q 377 137 376 115 q 380 196 378 159 q 385 227 382 218 q 400 237 388 235 q 525 238 460 237 q 648 239 590 238 q 658 235 654 239 q 662 222 662 232 l 643 9 q 638 -21 640 -13 q 623 -31 635 -30 q 504 -33 565 -32 q 378 -33 444 -33 q 372 -33 374 -33 q 370 -28 370 -32 l 370 -26 m 391 553 q 568 555 484 554 q 720 558 652 557 q 836 559 788 559 q 904 560 884 560 q 908 560 905 560 q 917 556 912 559 q 925 547 921 553 q 928 528 928 541 q 923 502 927 519 q 915 464 920 486 q 906 417 911 442 q 896 366 901 392 q 889 349 894 355 q 864 343 884 343 q 722 341 793 342 q 582 340 650 340 q 449 338 513 339 q 329 337 385 338 q 228 337 273 337 q 150 336 182 336 q 87 340 109 336 q 65 357 65 345 q 71 379 65 363 q 85 415 76 395 q 106 459 94 436 q 130 500 117 481 q 153 532 142 519 q 174 544 165 544 l 391 553 z " - }, - "ø": { - "ha": 888, - "x_min": 68, - "x_max": 886, - "o": "m 394 -39 q 379 -38 387 -39 q 365 -37 372 -38 l 318 -128 q 310 -147 313 -138 q 300 -156 307 -155 q 284 -150 294 -156 l 228 -115 q 215 -109 224 -113 q 197 -99 206 -104 q 182 -86 189 -93 q 175 -71 175 -79 q 179 -57 175 -64 l 217 15 q 153 76 180 41 q 106 153 125 111 q 78 242 87 195 q 68 338 68 290 q 105 507 68 431 q 204 637 142 583 q 349 721 267 691 q 524 750 432 750 q 592 744 559 750 l 629 817 q 644 842 638 835 q 655 850 649 849 q 661 849 659 850 q 690 830 675 840 q 720 811 705 821 q 749 794 734 802 q 779 781 764 786 q 784 778 782 780 q 787 773 787 777 q 786 771 787 772 q 786 770 786 771 l 741 683 q 801 627 774 659 q 847 558 828 595 q 876 479 866 522 q 886 392 886 437 q 868 267 886 325 q 818 160 850 208 q 741 76 785 113 q 641 13 696 39 q 524 -25 586 -12 q 394 -39 461 -39 m 330 346 q 332 300 330 323 q 342 256 335 278 q 381 333 360 293 q 424 413 402 373 q 466 493 445 454 q 505 569 487 533 q 474 572 488 572 q 406 548 433 572 q 361 489 378 524 q 337 415 345 454 q 330 346 330 376 m 635 386 q 624 459 635 422 l 460 144 q 467 143 463 143 q 473 143 470 143 q 532 155 507 143 q 575 186 557 167 q 604 231 593 206 q 623 283 616 256 q 633 337 630 311 q 635 386 635 363 z " - }, - "ù": { - "ha": 868, - "x_min": 79, - "x_max": 862, - "o": "m 798 84 q 793 53 796 62 q 778 42 789 45 q 657 9 720 26 q 536 -35 595 -7 q 530 -35 534 -35 q 523 -33 524 -35 q 522 -26 522 -30 q 523 -22 522 -25 q 524 -9 523 -18 q 528 16 526 0 q 534 60 530 33 q 400 -13 458 10 q 296 -35 341 -35 q 131 19 182 -35 q 79 182 79 74 q 79 223 79 202 q 83 265 80 243 q 96 402 91 345 q 105 500 102 460 q 111 565 109 540 q 115 608 113 591 q 118 636 117 625 q 120 658 119 647 q 125 688 123 680 q 140 700 127 697 q 201 711 172 706 q 258 722 230 716 q 315 734 286 728 q 377 751 345 741 q 380 751 378 751 q 382 751 381 751 q 391 746 391 751 l 391 745 q 386 701 388 722 q 382 660 384 681 q 377 614 380 638 q 372 557 375 589 q 363 483 368 525 q 352 385 359 441 q 344 304 348 345 q 340 229 340 264 q 342 194 340 210 q 352 167 345 178 q 371 150 359 156 q 401 144 382 144 q 439 150 415 144 q 488 173 464 157 q 531 215 513 189 q 553 281 550 241 q 561 393 557 348 q 568 469 565 438 q 572 521 570 500 q 576 561 574 542 q 579 603 578 581 q 582 658 581 625 q 587 689 584 680 q 602 700 590 697 q 728 725 664 712 q 854 757 793 737 q 861 755 860 757 q 862 750 862 753 l 798 84 m 406 968 q 379 1015 390 996 q 359 1051 368 1034 q 338 1087 349 1068 q 313 1135 328 1107 q 308 1149 309 1143 q 306 1162 307 1156 q 309 1174 306 1169 q 319 1181 313 1178 q 372 1210 345 1196 q 427 1240 399 1225 q 483 1272 455 1255 q 535 1305 510 1288 q 545 1309 542 1309 q 550 1303 549 1309 l 626 907 q 629 892 627 898 q 630 881 630 886 q 628 869 630 875 q 619 861 626 864 q 593 849 605 854 q 569 838 581 844 q 544 825 557 832 q 514 808 530 819 q 507 806 511 806 q 493 815 500 806 q 474 843 486 824 q 447 893 463 863 q 406 968 430 924 z " - }, - "ú": { - "ha": 868, - "x_min": 79, - "x_max": 862, - "o": "m 798 84 q 793 53 796 62 q 778 42 789 45 q 657 9 720 26 q 536 -35 595 -7 q 530 -35 534 -35 q 523 -33 524 -35 q 522 -26 522 -30 q 523 -22 522 -25 q 524 -9 523 -18 q 528 16 526 0 q 534 60 530 33 q 400 -13 458 10 q 296 -35 341 -35 q 131 19 182 -35 q 79 182 79 74 q 79 223 79 202 q 83 265 80 243 q 96 402 91 345 q 105 500 102 460 q 111 565 109 540 q 115 608 113 591 q 118 636 117 625 q 120 658 119 647 q 125 688 123 680 q 140 700 127 697 q 201 711 172 706 q 258 722 230 716 q 315 734 286 728 q 377 751 345 741 q 380 751 378 751 q 382 751 381 751 q 391 746 391 751 l 391 745 q 386 701 388 722 q 382 660 384 681 q 377 614 380 638 q 372 557 375 589 q 363 483 368 525 q 352 385 359 441 q 344 304 348 345 q 340 229 340 264 q 342 194 340 210 q 352 167 345 178 q 371 150 359 156 q 401 144 382 144 q 439 150 415 144 q 488 173 464 157 q 531 215 513 189 q 553 281 550 241 q 561 393 557 348 q 568 469 565 438 q 572 521 570 500 q 576 561 574 542 q 579 603 578 581 q 582 658 581 625 q 587 689 584 680 q 602 700 590 697 q 728 725 664 712 q 854 757 793 737 q 861 755 860 757 q 862 750 862 753 l 798 84 m 498 944 q 448 876 468 903 q 415 833 428 849 q 395 812 402 818 q 382 806 387 806 q 376 808 378 806 q 350 825 361 818 q 328 838 338 832 q 308 849 318 844 q 284 861 297 854 q 275 875 275 866 q 277 888 275 880 q 283 907 279 895 l 408 1271 q 415 1284 412 1280 q 422 1287 418 1287 q 429 1285 426 1287 q 436 1282 433 1284 q 542 1220 489 1246 q 646 1168 594 1195 q 658 1149 658 1160 q 646 1122 658 1139 q 603 1071 620 1091 q 570 1033 585 1051 q 538 994 555 1015 q 498 944 522 974 z " - }, - "û": { - "ha": 868, - "x_min": 79, - "x_max": 862, - "o": "m 798 84 q 793 53 796 62 q 778 42 789 45 q 657 9 720 26 q 536 -35 595 -7 q 530 -35 534 -35 q 523 -33 524 -35 q 522 -26 522 -30 q 523 -22 522 -25 q 524 -9 523 -18 q 528 16 526 0 q 534 60 530 33 q 400 -13 458 10 q 296 -35 341 -35 q 131 19 182 -35 q 79 182 79 74 q 79 223 79 202 q 83 265 80 243 q 96 402 91 345 q 105 500 102 460 q 111 565 109 540 q 115 608 113 591 q 118 636 117 625 q 120 658 119 647 q 125 688 123 680 q 140 700 127 697 q 201 711 172 706 q 258 722 230 716 q 315 734 286 728 q 377 751 345 741 q 380 751 378 751 q 382 751 381 751 q 391 746 391 751 l 391 745 q 386 701 388 722 q 382 660 384 681 q 377 614 380 638 q 372 557 375 589 q 363 483 368 525 q 352 385 359 441 q 344 304 348 345 q 340 229 340 264 q 342 194 340 210 q 352 167 345 178 q 371 150 359 156 q 401 144 382 144 q 439 150 415 144 q 488 173 464 157 q 531 215 513 189 q 553 281 550 241 q 561 393 557 348 q 568 469 565 438 q 572 521 570 500 q 576 561 574 542 q 579 603 578 581 q 582 658 581 625 q 587 689 584 680 q 602 700 590 697 q 728 725 664 712 q 854 757 793 737 q 861 755 860 757 q 862 750 862 753 l 798 84 m 664 1127 q 689 1095 679 1109 q 708 1069 700 1080 q 723 1047 716 1057 q 738 1024 730 1036 q 751 1006 742 1018 q 769 980 760 994 q 786 952 779 966 q 793 930 793 939 q 780 911 793 920 q 748 892 766 901 q 711 876 730 884 q 682 865 692 869 q 661 856 672 861 q 638 844 650 850 q 618 835 627 839 q 604 831 609 831 q 593 837 599 831 q 578 858 587 843 l 491 1044 q 409 941 450 991 q 326 838 368 890 q 317 833 323 833 q 301 839 314 833 q 272 852 289 844 q 237 869 255 860 q 206 884 220 878 q 188 892 199 887 q 166 903 176 897 q 149 913 156 908 q 142 924 142 919 q 148 939 142 930 q 168 961 154 948 l 270 1076 q 345 1160 309 1119 q 418 1243 382 1200 q 437 1254 428 1253 q 454 1255 446 1255 l 557 1255 q 573 1253 565 1255 q 587 1242 581 1252 q 595 1229 587 1241 q 615 1199 604 1217 q 640 1162 627 1182 q 664 1127 653 1143 z " - }, - "ü": { - "ha": 868, - "x_min": 79, - "x_max": 862, - "o": "m 798 84 q 793 53 796 62 q 778 42 789 45 q 657 9 720 26 q 536 -35 595 -7 q 530 -35 534 -35 q 523 -33 524 -35 q 522 -26 522 -30 q 523 -22 522 -25 q 524 -9 523 -18 q 528 16 526 0 q 534 60 530 33 q 400 -13 458 10 q 296 -35 341 -35 q 131 19 182 -35 q 79 182 79 74 q 79 223 79 202 q 83 265 80 243 q 96 402 91 345 q 105 500 102 460 q 111 565 109 540 q 115 608 113 591 q 118 636 117 625 q 120 658 119 647 q 125 688 123 680 q 140 700 127 697 q 201 711 172 706 q 258 722 230 716 q 315 734 286 728 q 377 751 345 741 q 380 751 378 751 q 382 751 381 751 q 391 746 391 751 l 391 745 q 386 701 388 722 q 382 660 384 681 q 377 614 380 638 q 372 557 375 589 q 363 483 368 525 q 352 385 359 441 q 344 304 348 345 q 340 229 340 264 q 342 194 340 210 q 352 167 345 178 q 371 150 359 156 q 401 144 382 144 q 439 150 415 144 q 488 173 464 157 q 531 215 513 189 q 553 281 550 241 q 561 393 557 348 q 568 469 565 438 q 572 521 570 500 q 576 561 574 542 q 579 603 578 581 q 582 658 581 625 q 587 689 584 680 q 602 700 590 697 q 728 725 664 712 q 854 757 793 737 q 861 755 860 757 q 862 750 862 753 l 798 84 m 124 833 q 127 889 126 871 q 128 913 127 906 q 128 924 128 921 q 129 936 128 926 q 130 966 129 945 q 133 1031 131 987 q 138 1060 134 1052 q 151 1069 141 1067 q 263 1069 204 1069 q 374 1070 323 1070 q 383 1066 380 1070 q 386 1053 386 1063 l 369 864 q 364 837 367 844 q 351 827 361 829 q 245 826 300 827 q 131 826 191 826 q 126 827 127 826 q 124 831 124 827 l 124 833 m 549 831 q 552 895 551 874 q 553 924 553 916 q 553 936 553 933 q 553 946 553 939 q 554 972 553 954 q 558 1031 555 991 q 562 1058 559 1050 q 575 1067 565 1066 q 688 1068 629 1067 q 798 1069 747 1068 q 807 1066 803 1069 q 810 1055 810 1063 l 794 863 q 789 836 791 843 q 775 827 787 828 q 668 825 723 826 q 552 825 612 825 q 549 825 550 825 q 549 829 549 825 l 549 831 z " - }, - "ý": { - "ha": 763, - "x_min": 77, - "x_max": 807, - "o": "m 370 -309 q 367 -314 369 -312 q 361 -315 366 -315 q 355 -315 357 -315 q 309 -300 331 -306 q 266 -289 288 -294 q 222 -279 245 -283 q 175 -269 200 -275 q 164 -265 168 -268 q 161 -254 161 -262 q 163 -244 161 -252 q 175 -213 165 -237 q 204 -143 184 -189 q 258 -20 224 -97 q 235 62 248 14 q 208 165 222 109 q 178 284 193 222 q 146 411 162 347 q 114 538 130 475 q 83 658 98 601 q 78 676 79 669 q 77 688 77 683 q 88 700 77 697 q 198 724 141 711 q 306 756 255 736 q 312 757 308 757 q 321 750 321 757 l 404 294 q 415 324 407 302 q 433 375 422 345 q 456 441 444 405 q 483 514 469 477 q 510 588 496 551 q 534 657 523 625 q 554 713 546 689 q 568 750 563 738 q 578 757 570 757 q 581 756 580 757 q 583 756 581 756 q 688 724 634 736 q 794 700 741 711 q 807 685 807 697 q 799 658 807 676 l 519 26 l 370 -309 m 460 944 q 411 876 431 903 q 378 833 391 849 q 357 812 365 818 q 345 806 350 806 q 338 808 341 806 q 313 825 324 818 q 291 838 301 832 q 270 849 281 844 q 247 861 260 854 q 237 875 237 866 q 240 888 238 880 q 245 907 241 895 l 371 1271 q 378 1284 374 1280 q 385 1287 381 1287 q 392 1285 389 1287 q 399 1282 395 1284 q 504 1220 452 1246 q 608 1168 557 1195 q 621 1149 621 1160 q 609 1122 621 1139 q 565 1071 583 1091 q 533 1033 548 1051 q 501 994 517 1015 q 460 944 485 974 z " - }, - "þ": { - "ha": 902, - "x_min": 53, - "x_max": 898, - "o": "m 388 471 q 381 365 384 406 q 376 299 378 324 q 372 259 374 273 q 370 231 371 244 q 416 165 386 191 q 490 140 447 140 q 555 163 527 140 q 602 224 583 186 q 630 307 621 261 q 640 399 640 353 q 633 468 640 436 q 614 523 627 500 q 582 560 601 547 q 536 573 562 573 q 493 565 514 573 q 452 543 471 556 q 416 513 432 530 q 390 481 400 496 l 388 471 m 406 665 q 523 727 463 703 q 651 751 583 751 q 761 725 715 751 q 838 656 808 699 q 883 555 869 612 q 898 435 898 498 q 887 323 898 380 q 855 215 876 267 q 803 116 834 162 q 731 36 772 70 q 642 -18 691 1 q 534 -38 592 -38 q 437 -18 484 -38 q 350 35 391 3 q 348 11 350 32 q 344 -41 347 -11 q 338 -107 341 -72 q 332 -172 334 -142 q 327 -224 329 -203 q 326 -249 326 -245 q 326 -258 326 -254 q 326 -265 326 -262 q 321 -274 326 -271 q 298 -283 316 -278 l 120 -328 q 100 -335 113 -330 q 77 -339 88 -339 q 60 -334 67 -339 q 53 -318 53 -330 l 134 658 q 136 679 134 661 q 140 722 138 696 q 145 775 142 747 q 151 829 149 804 q 155 871 153 854 q 157 892 157 889 q 156 902 157 898 q 155 908 155 905 q 160 918 155 914 q 184 926 165 922 l 362 972 q 382 978 370 974 q 406 983 394 982 q 422 978 415 983 q 429 962 429 973 l 429 958 l 406 665 z " - }, - "ÿ": { - "ha": 763, - "x_min": 77, - "x_max": 807, - "o": "m 370 -309 q 367 -314 369 -312 q 361 -315 366 -315 q 355 -315 357 -315 q 309 -300 331 -306 q 266 -289 288 -294 q 222 -279 245 -283 q 175 -269 200 -275 q 164 -265 168 -268 q 161 -254 161 -262 q 163 -244 161 -252 q 175 -213 165 -237 q 204 -143 184 -189 q 258 -20 224 -97 q 235 62 248 14 q 208 165 222 109 q 178 284 193 222 q 146 411 162 347 q 114 538 130 475 q 83 658 98 601 q 78 676 79 669 q 77 688 77 683 q 88 700 77 697 q 198 724 141 711 q 306 756 255 736 q 312 757 308 757 q 321 750 321 757 l 404 294 q 415 324 407 302 q 433 375 422 345 q 456 441 444 405 q 483 514 469 477 q 510 588 496 551 q 534 657 523 625 q 554 713 546 689 q 568 750 563 738 q 578 757 570 757 q 581 756 580 757 q 583 756 581 756 q 688 724 634 736 q 794 700 741 711 q 807 685 807 697 q 799 658 807 676 l 519 26 l 370 -309 m 87 833 q 90 889 89 871 q 91 913 90 906 q 91 924 91 921 q 91 936 91 926 q 93 966 92 945 q 96 1031 94 987 q 100 1060 97 1052 q 114 1069 104 1067 q 226 1069 167 1069 q 336 1070 286 1070 q 346 1066 343 1070 q 349 1053 349 1063 l 332 864 q 327 837 330 844 q 314 827 324 829 q 208 826 262 827 q 94 826 153 826 q 89 827 90 826 q 87 831 87 827 l 87 833 m 511 831 q 514 895 513 874 q 516 924 515 916 q 516 936 516 933 q 516 946 515 939 q 517 972 516 954 q 521 1031 518 991 q 525 1058 522 1050 q 538 1067 528 1066 q 650 1068 591 1067 q 760 1069 709 1068 q 769 1066 766 1069 q 773 1055 773 1063 l 757 863 q 752 836 754 843 q 738 827 749 828 q 630 825 686 826 q 515 825 575 825 q 512 825 513 825 q 511 829 511 825 l 511 831 z " - }, - "Ğ": { - "ha": 992, - "x_min": 85, - "x_max": 1027, - "o": "m 85 438 q 103 588 85 516 q 154 721 121 659 q 234 834 187 783 q 340 921 281 884 q 466 977 398 957 q 610 996 534 996 q 714 988 669 996 q 793 969 760 981 q 849 943 827 957 q 887 916 872 928 q 886 911 886 916 q 888 873 886 901 q 892 813 890 846 q 896 746 895 780 q 898 686 898 711 q 895 677 898 682 q 882 672 892 672 q 867 674 876 672 q 831 693 852 678 q 780 723 809 707 q 716 752 751 739 q 638 764 680 764 q 537 741 583 764 q 460 676 492 718 q 410 577 428 634 q 393 452 393 519 q 404 342 393 393 q 436 253 414 290 q 491 193 458 215 q 568 172 524 172 q 665 190 610 172 l 680 286 l 551 286 q 576 414 566 368 q 597 485 587 461 q 616 515 606 509 q 640 521 627 521 l 997 521 q 1020 519 1013 521 q 1027 505 1027 517 q 1025 490 1027 498 q 1022 469 1024 481 l 988 355 q 978 322 982 334 q 968 304 974 310 q 951 297 962 298 q 921 296 941 296 q 908 288 910 296 q 905 269 906 279 q 897 210 901 239 q 889 155 892 180 q 881 110 885 130 q 873 82 877 91 q 789 31 827 53 q 714 -6 751 9 q 635 -28 677 -20 q 541 -35 594 -35 q 361 -1 445 -35 q 217 97 278 34 q 120 246 155 159 q 85 438 85 333 m 633 1203 q 635 1211 633 1207 q 644 1216 637 1214 q 662 1220 650 1219 q 694 1221 674 1221 q 726 1220 714 1221 q 745 1217 739 1219 q 753 1212 751 1215 q 755 1204 755 1209 q 740 1140 755 1172 q 696 1083 724 1108 q 630 1043 668 1059 q 548 1027 592 1027 q 479 1036 512 1027 q 422 1060 447 1044 q 384 1098 398 1076 q 369 1151 369 1121 q 370 1164 369 1157 q 372 1180 371 1171 q 376 1197 374 1190 q 385 1209 378 1204 q 405 1216 391 1213 q 444 1218 418 1218 q 469 1217 460 1218 q 483 1214 478 1216 q 490 1210 488 1213 q 491 1204 491 1207 q 490 1198 491 1203 q 490 1187 490 1193 q 492 1168 490 1178 q 502 1151 495 1159 q 522 1138 509 1143 q 552 1133 534 1133 q 588 1139 572 1133 q 613 1154 603 1145 q 628 1174 623 1163 q 633 1194 633 1184 l 633 1203 l 633 1203 z " - }, - "ğ": { - "ha": 878, - "x_min": 69, - "x_max": 871, - "o": "m 576 484 q 557 515 569 499 q 530 545 545 532 q 496 567 514 559 q 457 576 477 576 q 405 553 429 576 q 362 491 380 530 q 333 404 344 453 q 323 302 323 355 q 329 240 323 269 q 347 190 334 212 q 378 155 359 168 q 425 142 397 142 q 499 168 465 142 q 557 234 533 193 q 559 268 557 248 q 562 316 560 288 q 567 382 564 344 q 575 473 570 420 l 576 484 m 800 74 q 770 -52 793 7 q 710 -158 746 -110 q 627 -245 673 -207 q 529 -310 581 -283 q 422 -350 477 -336 q 313 -364 367 -364 q 255 -362 285 -364 q 197 -354 225 -360 q 142 -338 168 -349 q 96 -311 117 -328 l 96 -311 q 101 -287 96 -307 q 114 -239 106 -267 q 129 -182 121 -212 q 142 -132 136 -153 q 147 -119 144 -123 q 153 -116 150 -116 q 158 -117 157 -116 q 195 -138 178 -130 q 232 -152 212 -146 q 274 -159 251 -157 q 328 -161 297 -161 q 412 -142 375 -161 q 475 -95 448 -124 q 517 -31 501 -66 q 539 38 533 4 q 440 -15 490 5 q 339 -35 390 -35 q 218 -7 269 -35 q 134 68 168 21 q 85 177 101 116 q 69 306 69 239 q 79 413 69 359 q 108 517 89 467 q 156 611 127 567 q 222 687 184 654 q 304 738 259 720 q 404 757 350 757 q 512 731 462 757 q 602 667 562 705 q 604 687 604 680 q 608 698 605 694 q 617 704 610 702 q 635 709 623 706 q 663 714 643 710 q 709 725 682 719 q 769 738 736 731 q 835 752 802 745 q 850 754 843 754 q 871 727 871 754 q 871 721 871 724 q 870 714 871 718 l 800 74 m 534 991 q 536 998 534 995 q 545 1004 538 1002 q 563 1008 551 1006 q 595 1009 575 1009 q 627 1008 615 1009 q 646 1005 640 1007 q 654 1000 652 1003 q 656 992 656 997 q 641 928 656 960 q 597 871 625 896 q 531 831 569 846 q 449 815 493 815 q 380 823 413 815 q 323 847 348 831 q 284 886 299 863 q 270 939 270 909 q 271 952 270 945 q 273 968 272 959 q 277 985 275 978 q 286 997 279 992 q 306 1003 292 1001 q 345 1006 319 1006 q 370 1005 361 1006 q 384 1002 379 1004 q 391 998 389 1000 q 392 992 392 995 q 391 986 392 991 q 391 975 391 981 q 393 956 391 966 q 403 939 396 947 q 422 926 410 931 q 453 921 435 921 q 489 927 473 921 q 514 942 504 932 q 529 961 524 951 q 534 982 534 972 l 534 991 l 534 991 z " - }, - "İ": { - "ha": 453, - "x_min": 94, - "x_max": 450, - "o": "m 94 -22 l 128 442 q 153 785 145 675 q 161 893 161 894 q 163 913 162 905 q 165 927 163 922 q 171 935 168 932 q 181 939 174 938 l 416 996 q 434 998 425 998 q 447 992 444 998 q 450 969 450 987 q 443 890 446 927 q 438 821 440 854 q 435 756 437 787 q 432 695 434 726 q 425 629 428 662 q 419 560 422 595 q 413 485 416 524 q 406 398 410 445 l 376 41 q 374 29 376 35 q 365 20 372 23 q 357 17 364 20 q 337 10 349 14 q 309 1 325 5 q 274 -8 292 -4 q 221 -22 243 -15 q 180 -34 198 -28 q 148 -43 163 -40 q 118 -47 133 -47 q 101 -41 108 -47 q 94 -22 94 -36 m 123 1162 q 125 1212 124 1194 q 126 1241 125 1231 q 126 1255 126 1251 q 126 1263 126 1259 q 126 1272 126 1267 q 127 1290 127 1278 q 130 1325 128 1303 q 133 1383 131 1347 q 137 1414 134 1406 q 153 1425 140 1423 q 277 1425 212 1425 q 400 1426 342 1426 q 410 1423 406 1426 q 414 1410 414 1419 l 395 1197 q 390 1166 393 1175 q 375 1156 388 1158 q 257 1155 317 1156 q 130 1154 196 1154 q 124 1155 126 1154 q 123 1159 123 1156 l 123 1162 z " - }, - "ı": { - "ha": 414, - "x_min": 73, - "x_max": 408, - "o": "m 99 288 q 117 471 109 380 q 132 658 125 562 q 137 689 134 680 q 152 700 140 697 q 273 724 210 711 q 395 756 336 736 q 401 757 397 757 q 408 751 408 757 l 347 80 q 342 49 345 58 q 328 38 340 41 q 211 -2 270 20 q 86 -45 152 -24 q 80 -46 84 -46 q 73 -39 73 -46 q 74 -20 73 -39 q 78 26 75 -2 q 83 91 80 55 q 89 163 85 127 q 94 232 92 199 q 99 288 97 264 z " - }, - "Ł": { - "ha": 694, - "x_min": 57, - "x_max": 719, - "o": "m 454 972 q 452 931 454 956 q 447 881 450 907 q 442 826 445 854 q 436 776 439 799 q 433 736 434 753 q 431 715 431 720 q 426 637 429 673 q 419 566 422 601 q 412 493 416 530 q 404 410 408 455 q 395 309 400 364 q 385 181 390 253 l 665 210 q 696 212 684 212 q 715 207 711 212 q 719 192 719 202 q 718 188 719 191 q 715 179 718 186 q 708 159 713 172 q 696 123 704 146 l 682 79 q 668 40 674 57 q 652 10 661 22 q 628 -10 642 -3 q 591 -20 614 -18 q 553 -22 577 -21 q 496 -24 528 -23 q 428 -26 465 -25 q 352 -30 391 -28 q 275 -32 314 -31 q 202 -33 237 -32 q 138 -34 168 -33 q 90 -35 109 -35 q 65 -33 73 -35 q 57 -24 57 -30 q 62 -2 57 -16 q 74 29 66 12 q 91 65 81 46 q 109 101 100 83 l 127 343 q 138 469 132 405 q 147 592 143 532 l 159 772 q 164 864 163 836 q 165 896 165 893 q 168 916 167 908 q 170 930 168 924 q 175 938 172 935 q 185 942 178 941 l 423 998 q 441 1001 431 1001 q 452 997 449 1001 q 455 980 455 992 q 455 976 455 979 q 454 972 454 974 m 454 573 q 521 575 488 574 q 581 577 554 576 q 628 579 608 578 q 656 581 648 581 q 669 576 662 581 q 675 561 675 572 q 669 538 675 555 q 652 499 663 522 q 629 447 642 475 q 603 387 616 418 q 598 376 600 380 q 592 369 595 372 q 582 365 588 366 q 566 363 576 363 q 444 361 505 362 q 329 359 382 360 q 231 357 275 358 q 162 357 188 357 q 101 360 121 357 q 81 376 81 364 q 90 394 81 379 q 112 430 98 410 q 143 474 125 451 q 177 517 160 498 q 210 550 194 537 q 235 564 225 564 l 454 573 z " - }, - "ł": { - "ha": 585, - "x_min": 37, - "x_max": 631, - "o": "m 203 574 q 217 758 212 667 q 228 944 222 848 q 232 975 229 966 q 248 986 235 983 q 374 1009 311 998 q 501 1041 437 1021 q 507 1042 503 1042 q 515 1035 515 1042 l 427 66 l 427 55 q 422 45 427 49 q 399 37 417 41 l 222 -28 q 202 -36 214 -32 q 178 -39 190 -39 q 162 -35 169 -39 q 155 -18 155 -30 l 155 -14 q 165 120 160 54 q 176 255 170 185 q 189 403 182 325 q 203 574 195 481 m 410 573 q 477 575 444 574 q 537 577 510 576 q 584 579 564 578 q 612 581 604 581 q 625 576 618 581 q 631 561 631 572 q 625 538 631 555 q 608 499 618 522 q 585 447 598 475 q 559 387 572 418 q 554 376 556 380 q 548 369 551 372 q 538 365 544 366 q 522 363 532 363 q 399 361 460 362 q 284 359 338 360 q 187 357 231 358 q 118 357 144 357 q 57 360 77 357 q 37 376 37 364 q 46 394 37 379 q 68 430 54 410 q 99 474 81 451 q 133 517 116 498 q 165 550 150 537 q 191 564 181 564 l 410 573 z " - }, - "Œ": { - "ha": 1391, - "x_min": 86, - "x_max": 1438, - "o": "m 517 -35 q 336 5 416 -35 q 201 111 256 44 q 116 266 145 178 q 86 451 86 354 q 105 601 86 530 q 160 730 125 671 q 243 836 195 789 q 351 915 292 883 q 477 965 410 947 q 616 982 545 982 q 737 962 682 982 q 840 907 793 942 l 842 946 q 980 956 914 951 q 1106 964 1046 960 l 1419 983 q 1422 983 1419 983 q 1429 981 1426 983 q 1435 975 1432 979 q 1438 964 1438 971 q 1429 929 1438 960 q 1402 852 1419 898 l 1372 774 q 1361 756 1367 762 q 1335 749 1355 750 q 1239 745 1293 748 q 1116 739 1186 742 l 1097 573 q 1165 576 1132 574 q 1225 578 1198 577 q 1272 580 1252 579 q 1300 581 1292 581 q 1312 576 1305 581 q 1319 561 1319 572 q 1313 539 1319 555 q 1296 499 1306 523 q 1273 447 1286 476 q 1246 387 1260 418 q 1239 373 1242 377 q 1228 366 1236 368 q 1207 364 1221 364 q 1171 363 1194 363 l 1076 361 l 1058 169 l 1379 169 l 1379 141 q 1368 122 1378 140 q 1343 82 1358 105 q 1315 36 1329 60 q 1290 -1 1300 13 q 1274 -21 1283 -14 q 1255 -31 1265 -28 q 1232 -35 1244 -35 q 1204 -36 1219 -36 q 1095 -33 1152 -36 q 982 -26 1038 -31 q 873 -17 926 -22 q 775 -6 821 -12 q 767 -1 770 -5 q 763 10 763 4 q 764 16 763 11 l 772 56 q 651 -12 715 11 q 517 -35 587 -35 m 385 463 q 396 359 385 411 q 433 267 408 308 q 500 199 458 225 q 602 174 541 174 q 677 193 645 177 q 734 235 710 210 q 773 294 758 261 q 799 363 789 327 q 811 438 808 400 q 815 513 815 476 q 802 614 815 565 q 763 700 789 663 q 696 761 736 738 q 603 783 656 783 q 529 768 562 783 q 473 726 497 752 q 432 667 449 701 q 405 598 415 634 q 390 527 395 562 q 385 463 385 492 z " - }, - "œ": { - "ha": 1354, - "x_min": 69, - "x_max": 1358, - "o": "m 395 -39 q 254 -7 315 -39 q 152 77 193 24 q 90 198 111 130 q 69 338 69 266 q 105 507 69 431 q 201 637 140 583 q 341 721 261 691 q 511 750 422 750 q 648 720 585 750 q 758 636 710 689 q 889 730 815 696 q 1050 765 963 765 q 1167 742 1112 765 q 1265 679 1223 720 q 1333 581 1308 637 q 1358 457 1358 524 q 1344 358 1358 408 q 1335 325 1344 338 q 1304 305 1326 312 q 1247 295 1283 298 q 1159 292 1212 292 q 1023 288 1092 290 q 886 281 954 286 q 903 213 888 241 q 939 166 917 184 q 988 138 960 147 q 1044 130 1015 130 q 1109 137 1078 130 q 1169 155 1140 144 q 1224 181 1198 167 q 1274 208 1251 195 q 1276 209 1275 208 q 1277 209 1276 209 q 1284 195 1282 209 q 1288 161 1287 181 q 1290 120 1289 142 q 1290 82 1290 98 q 1289 46 1290 61 q 1284 27 1287 31 q 1234 -7 1265 9 q 1168 -36 1204 -24 q 1095 -55 1133 -47 q 1023 -62 1057 -62 q 930 -52 973 -62 q 851 -24 888 -43 q 782 20 814 -6 q 721 81 749 47 q 658 30 689 52 q 590 -8 627 7 q 506 -31 553 -23 q 395 -39 458 -39 m 330 346 q 338 273 330 309 q 364 208 346 237 q 411 161 382 179 q 484 143 440 143 q 533 157 512 144 q 570 190 555 170 q 596 235 586 210 q 612 287 606 260 q 620 339 618 313 q 623 386 623 365 q 613 455 623 421 q 585 515 604 489 q 538 556 566 541 q 475 572 511 572 q 406 548 434 572 q 362 489 378 524 q 338 415 345 454 q 330 346 330 376 m 1050 576 q 992 566 1019 576 q 944 536 966 555 q 907 490 923 517 q 880 430 890 463 l 1165 451 q 1165 456 1165 454 q 1166 462 1166 459 q 1155 512 1166 490 q 1127 548 1144 534 q 1090 569 1111 562 q 1050 576 1069 576 z " - }, - "Ş": { - "ha": 746, - "x_min": 106, - "x_max": 732, - "o": "m 107 252 q 107 254 107 253 q 106 255 106 254 q 119 267 106 267 q 132 260 125 267 q 214 205 169 226 q 311 185 258 185 q 344 188 326 185 q 378 198 362 191 q 406 217 395 205 q 417 246 417 229 q 408 281 417 266 q 382 308 398 297 q 364 321 376 312 q 336 343 352 331 q 304 369 321 355 q 272 396 287 383 q 244 418 256 408 q 226 434 232 429 q 162 494 186 464 q 127 558 139 525 q 111 627 115 591 q 108 703 108 663 q 136 816 108 762 q 217 909 165 869 q 341 972 269 949 q 503 996 414 996 q 535 993 513 996 q 583 985 557 991 q 636 970 609 980 q 686 946 663 961 q 697 935 693 941 q 703 918 702 930 q 709 810 707 863 q 714 697 711 757 q 709 682 714 686 q 697 678 705 678 q 686 682 690 678 q 645 721 666 702 q 601 754 624 740 q 552 778 578 769 q 495 787 526 787 q 458 784 477 787 q 425 772 440 781 q 401 750 410 764 q 392 714 392 736 q 398 674 392 691 q 427 642 404 657 l 589 532 q 662 468 634 500 q 705 406 690 437 q 727 344 721 374 q 732 285 732 314 q 717 195 732 237 q 674 118 701 153 q 611 54 647 82 q 533 6 574 26 q 447 -25 492 -14 q 360 -35 403 -35 q 295 -34 327 -35 q 232 -29 262 -33 q 173 -15 201 -24 q 119 10 144 -6 l 107 252 m 562 -262 q 539 -320 556 -294 q 498 -365 522 -346 q 445 -394 475 -383 q 385 -404 416 -404 q 325 -400 356 -404 q 269 -382 293 -396 l 271 -383 q 270 -378 270 -382 q 271 -357 270 -370 q 274 -330 272 -345 q 278 -302 275 -315 q 283 -279 280 -288 l 286 -279 q 290 -281 290 -279 l 290 -281 q 310 -289 300 -286 q 330 -294 319 -292 q 353 -296 340 -296 q 382 -297 366 -297 q 427 -280 411 -297 q 442 -241 442 -263 q 430 -208 442 -221 q 395 -195 417 -195 q 332 -192 358 -195 q 295 -189 305 -189 q 289 -186 290 -189 q 288 -180 288 -184 q 295 -159 291 -174 q 304 -126 300 -144 q 314 -89 309 -109 q 322 -53 318 -69 q 328 -25 326 -36 q 330 -12 330 -14 l 343 -12 q 373 -12 355 -12 q 409 -12 391 -12 l 452 -12 l 419 -108 q 440 -105 431 -106 q 459 -104 450 -104 q 514 -116 494 -104 q 546 -144 535 -127 q 561 -184 557 -162 q 565 -230 565 -207 q 564 -246 565 -238 q 562 -262 564 -254 z " - }, - "ş": { - "ha": 587, - "x_min": 85, - "x_max": 570, - "o": "m 86 187 q 86 188 86 188 q 85 189 85 189 q 95 198 85 198 q 106 193 101 198 q 168 151 133 168 q 243 135 203 135 q 269 137 254 135 q 296 145 283 140 q 317 160 309 151 q 326 182 326 169 q 318 210 326 197 q 298 231 311 222 q 275 247 292 235 q 238 273 258 259 q 202 298 219 286 q 178 316 184 311 q 129 363 147 339 q 102 412 111 387 q 90 465 92 437 q 87 524 87 493 q 112 614 87 572 q 178 688 137 656 q 271 738 219 720 q 378 757 323 757 q 466 743 422 757 q 547 697 509 730 q 551 613 550 654 q 555 526 553 572 q 551 514 555 517 q 542 511 547 511 q 534 515 537 511 q 502 544 518 530 q 468 570 486 559 q 429 588 450 581 q 386 595 409 595 q 357 593 372 595 q 332 584 343 591 q 313 567 320 578 q 306 539 306 556 q 311 505 306 519 q 333 477 315 491 l 459 392 q 515 346 494 368 q 549 300 536 323 q 565 256 561 278 q 570 212 570 234 q 542 105 570 151 q 469 27 513 58 q 367 -19 424 -3 q 254 -35 311 -35 q 170 -26 210 -35 q 95 2 130 -17 l 86 187 m 471 -262 q 448 -320 465 -294 q 407 -365 431 -346 q 354 -394 383 -383 q 293 -404 324 -404 q 233 -400 264 -404 q 178 -382 201 -396 l 179 -383 q 178 -378 178 -382 q 179 -357 178 -370 q 182 -330 180 -345 q 186 -302 184 -315 q 191 -279 189 -288 l 195 -279 q 199 -281 199 -279 l 198 -281 q 218 -289 209 -286 q 238 -294 228 -292 q 261 -296 249 -296 q 291 -297 274 -297 q 335 -280 319 -297 q 351 -241 351 -263 q 338 -208 351 -221 q 304 -195 326 -195 q 240 -192 267 -195 q 203 -189 214 -189 q 197 -186 198 -189 q 196 -180 196 -184 q 204 -159 199 -174 q 213 -126 208 -144 q 222 -89 218 -109 q 230 -53 227 -69 q 236 -25 234 -36 q 239 -12 239 -14 l 252 -12 q 281 -12 263 -12 q 317 -12 300 -12 l 360 -12 l 328 -108 q 349 -105 339 -106 q 368 -104 359 -104 q 423 -116 402 -104 q 455 -144 444 -127 q 470 -184 466 -162 q 473 -230 473 -207 q 473 -246 473 -238 q 471 -262 472 -254 z " - }, - "Š": { - "ha": 745, - "x_min": 92, - "x_max": 743, - "o": "m 107 252 q 107 254 107 253 q 106 255 106 254 q 119 267 106 267 q 132 260 125 267 q 214 205 169 226 q 311 185 258 185 q 344 188 326 185 q 378 198 362 191 q 406 217 395 205 q 417 246 417 229 q 408 281 417 266 q 382 308 398 297 q 364 321 376 312 q 336 343 352 331 q 304 369 321 355 q 272 396 287 383 q 244 418 256 408 q 226 434 232 429 q 162 494 186 464 q 127 558 139 525 q 111 627 115 591 q 108 703 108 663 q 136 816 108 762 q 217 909 165 869 q 341 972 269 949 q 503 996 414 996 q 535 993 513 996 q 583 985 557 991 q 636 970 609 980 q 686 946 663 961 q 697 935 693 941 q 703 918 702 930 q 709 810 707 863 q 714 697 711 757 q 709 682 714 686 q 697 678 705 678 q 686 682 690 678 q 645 721 666 702 q 601 754 624 740 q 552 778 578 769 q 495 787 526 787 q 458 784 477 787 q 425 772 440 781 q 401 750 410 764 q 392 714 392 736 q 398 674 392 691 q 427 642 404 657 l 589 532 q 662 468 634 500 q 705 406 690 437 q 727 344 721 374 q 732 285 732 314 q 717 195 732 237 q 674 118 701 153 q 611 54 647 82 q 533 6 574 26 q 447 -25 492 -14 q 360 -35 403 -35 q 295 -34 327 -35 q 232 -29 262 -33 q 173 -15 201 -24 q 119 10 144 -6 l 107 252 m 222 1194 q 186 1241 200 1223 q 161 1277 173 1260 q 137 1312 150 1293 q 104 1362 125 1331 q 95 1379 98 1371 q 92 1392 92 1386 q 114 1414 92 1401 q 166 1440 136 1427 q 226 1465 196 1453 q 273 1485 256 1476 q 280 1487 277 1487 q 290 1482 286 1487 q 301 1466 294 1477 l 400 1289 l 564 1482 q 570 1486 566 1486 q 582 1483 574 1485 q 605 1472 589 1480 q 671 1439 640 1453 q 736 1408 702 1426 q 743 1398 743 1405 q 737 1383 743 1392 q 718 1362 732 1374 q 590 1219 653 1290 q 465 1078 526 1147 q 450 1068 458 1070 q 437 1067 443 1067 l 427 1067 l 322 1067 q 310 1068 316 1067 q 300 1078 304 1070 q 291 1092 300 1079 q 271 1122 283 1104 q 246 1159 259 1139 q 222 1194 233 1179 z " - }, - "š": { - "ha": 585, - "x_min": 1, - "x_max": 652, - "o": "m 85 187 q 85 188 85 188 q 85 189 85 189 q 94 198 85 198 q 105 193 100 198 q 167 151 132 168 q 243 135 202 135 q 268 137 254 135 q 295 145 282 140 q 316 160 308 151 q 325 182 325 169 q 317 210 325 197 q 298 231 310 222 q 274 247 291 235 q 238 273 257 259 q 201 298 218 286 q 177 316 184 311 q 129 363 146 339 q 101 412 111 387 q 89 465 92 437 q 86 524 86 493 q 111 614 86 572 q 177 688 136 656 q 271 738 218 720 q 377 757 323 757 q 465 743 422 757 q 546 697 509 730 q 551 613 549 654 q 555 526 552 572 q 551 514 555 517 q 541 511 547 511 q 533 515 536 511 q 501 544 517 530 q 467 570 485 559 q 429 588 449 581 q 385 595 408 595 q 357 593 371 595 q 331 584 342 591 q 312 567 319 578 q 305 539 305 556 q 310 505 305 519 q 332 477 315 491 l 458 392 q 514 346 493 368 q 548 300 536 323 q 565 256 560 278 q 569 212 569 234 q 541 105 569 151 q 468 27 513 58 q 367 -19 423 -3 q 253 -35 310 -35 q 169 -26 210 -35 q 94 2 129 -17 l 85 187 m 132 968 q 96 1015 109 996 q 71 1050 82 1034 q 46 1086 59 1067 q 14 1135 34 1105 q 4 1152 7 1145 q 1 1165 1 1160 q 23 1187 1 1175 q 75 1213 45 1200 q 135 1238 105 1226 q 182 1258 165 1250 q 189 1260 186 1260 q 199 1255 195 1260 q 210 1239 203 1251 l 309 1063 l 473 1256 q 479 1259 475 1259 q 491 1256 483 1259 q 514 1245 498 1254 q 580 1213 549 1226 q 645 1181 611 1199 q 652 1171 652 1179 q 646 1156 652 1165 q 627 1135 641 1147 q 499 992 562 1063 q 374 851 435 921 q 359 842 367 844 q 346 840 352 840 l 336 840 l 231 840 q 219 842 225 840 q 210 851 214 844 q 200 865 209 852 q 180 895 192 878 q 155 932 168 913 q 132 968 142 952 z " - }, - "Ÿ": { - "ha": 756, - "x_min": 73, - "x_max": 861, - "o": "m 81 903 q 95 910 85 906 q 118 920 104 915 q 146 932 131 926 q 177 945 161 939 l 256 976 q 272 980 264 980 q 284 977 277 980 q 298 966 290 974 l 455 662 l 459 672 l 526 796 q 552 842 539 819 q 574 882 564 864 q 591 910 584 899 q 599 921 597 921 l 831 979 q 845 981 840 981 q 861 967 861 981 q 859 958 860 964 q 855 945 859 952 l 656 576 q 626 520 641 548 q 596 468 610 492 q 571 422 582 443 q 553 389 559 402 l 548 367 l 510 113 q 507 94 508 101 q 503 81 505 86 q 497 73 500 77 q 486 66 493 70 l 294 -35 q 271 -43 283 -40 q 248 -47 259 -47 q 229 -42 237 -47 q 220 -25 220 -37 l 220 -22 q 230 67 223 16 q 245 168 237 119 l 283 419 q 255 480 273 442 q 217 562 237 518 q 175 653 197 606 q 133 742 153 700 q 99 815 114 783 q 76 862 83 847 q 73 883 73 872 q 74 895 73 889 q 81 903 76 901 m 102 1059 q 105 1115 104 1098 q 106 1140 106 1133 q 106 1150 106 1147 q 107 1162 106 1153 q 108 1193 107 1172 q 111 1258 109 1214 q 116 1286 113 1278 q 130 1295 119 1294 q 242 1296 182 1295 q 352 1297 301 1297 q 361 1293 359 1297 q 364 1279 364 1289 l 347 1090 q 342 1063 345 1071 q 330 1054 340 1055 q 223 1053 278 1053 q 109 1053 169 1053 q 104 1053 106 1053 q 102 1057 102 1054 l 102 1059 m 527 1058 q 530 1121 529 1101 q 531 1151 531 1142 q 531 1162 532 1160 q 531 1173 531 1165 q 533 1199 532 1181 q 536 1257 534 1217 q 541 1285 538 1277 q 553 1294 543 1293 q 666 1294 607 1294 q 776 1295 725 1295 q 785 1293 781 1295 q 789 1282 789 1290 l 772 1090 q 767 1062 770 1069 q 753 1053 765 1055 q 646 1052 701 1053 q 530 1051 591 1051 q 528 1052 528 1051 q 527 1055 527 1052 l 527 1058 z " - }, - "Ž": { - "ha": 847, - "x_min": 70, - "x_max": 854, - "o": "m 139 0 q 123 2 131 0 q 108 8 115 3 q 97 20 101 12 q 92 41 92 28 q 93 43 92 42 q 94 46 94 45 l 447 666 q 432 670 447 668 q 395 672 418 671 q 345 674 372 673 q 293 676 318 675 q 249 676 269 676 q 223 677 230 677 q 155 676 186 677 q 88 675 123 675 q 75 680 81 675 q 70 692 70 685 q 71 693 71 692 q 71 697 71 695 l 159 907 q 177 931 165 922 q 206 945 190 940 q 240 952 222 950 q 276 954 258 954 q 422 950 350 954 q 565 944 494 947 q 708 938 637 941 q 853 935 780 935 l 853 907 l 523 290 q 523 288 523 288 q 522 286 522 288 q 529 278 522 279 q 541 277 536 277 l 675 277 q 754 282 716 277 q 833 287 792 287 q 848 282 841 287 q 854 269 854 277 q 853 263 854 270 l 744 46 q 724 20 739 30 q 689 6 709 11 q 643 0 668 1 q 591 -1 618 -1 q 375 -1 485 -1 q 139 0 266 0 m 261 1194 q 225 1241 239 1223 q 200 1277 212 1260 q 176 1312 189 1293 q 143 1362 163 1331 q 134 1379 136 1371 q 131 1392 131 1386 q 153 1414 131 1401 q 205 1440 175 1427 q 265 1465 235 1453 q 311 1485 295 1476 q 319 1487 315 1487 q 329 1482 324 1487 q 340 1466 333 1477 l 439 1289 l 602 1482 q 608 1486 604 1486 q 620 1483 612 1485 q 644 1472 628 1480 q 709 1439 678 1453 q 774 1408 741 1426 q 781 1398 781 1405 q 776 1383 781 1392 q 757 1362 770 1374 q 628 1219 692 1290 q 503 1078 565 1147 q 489 1068 496 1070 q 475 1067 481 1067 l 466 1067 l 361 1067 q 349 1068 355 1067 q 339 1078 343 1070 q 330 1092 338 1079 q 310 1122 321 1104 q 284 1159 298 1139 q 261 1194 271 1179 z " - }, - "ž": { - "ha": 673, - "x_min": 38, - "x_max": 688, - "o": "m 173 0 q 144 1 159 0 q 116 6 129 3 q 95 16 104 10 q 87 33 87 22 q 87 35 87 33 q 88 37 88 36 l 328 528 q 264 527 299 528 q 193 525 229 526 q 125 524 157 524 q 71 523 93 523 q 60 527 64 523 q 57 537 57 532 l 57 540 l 125 703 q 146 727 131 722 q 176 732 161 732 q 410 728 295 732 q 644 724 525 724 q 659 720 651 724 q 667 708 667 715 q 665 703 667 707 l 450 234 q 454 232 450 233 q 464 231 458 231 q 475 230 469 230 q 485 230 481 230 q 568 232 528 230 q 648 234 608 234 q 661 231 656 234 q 667 217 667 227 q 665 216 667 216 l 580 37 q 558 17 574 24 q 520 6 543 9 q 470 1 498 2 q 414 0 443 0 l 173 0 m 168 968 q 132 1015 146 996 q 107 1050 119 1034 q 83 1086 96 1067 q 50 1135 71 1105 q 41 1152 43 1145 q 38 1165 38 1160 q 60 1187 38 1175 q 112 1213 82 1200 q 172 1238 142 1226 q 218 1258 202 1250 q 226 1260 222 1260 q 236 1255 231 1260 q 247 1239 240 1251 l 346 1063 l 509 1256 q 515 1259 511 1259 q 527 1256 519 1259 q 551 1245 535 1254 q 616 1213 585 1226 q 682 1181 648 1199 q 688 1171 688 1179 q 683 1156 688 1165 q 664 1135 677 1147 q 535 992 599 1063 q 410 851 472 921 q 396 842 404 844 q 382 840 389 840 l 373 840 l 268 840 q 256 842 262 840 q 246 851 250 844 q 237 865 245 852 q 217 895 229 878 q 192 932 205 913 q 168 968 178 952 z " - }, - "ƒ": { - "ha": 623, - "x_min": -123, - "x_max": 785, - "o": "m 178 191 q 181 224 179 197 q 188 294 184 251 q 197 395 191 338 q 210 521 202 453 l 119 521 q 66 524 83 521 q 50 536 50 527 q 57 551 50 539 q 74 579 64 563 q 97 615 85 596 q 120 651 109 634 q 140 680 132 667 q 150 694 148 692 l 233 694 l 246 802 q 336 1037 264 960 q 546 1114 408 1114 q 582 1110 559 1114 q 631 1100 605 1106 q 685 1085 658 1093 q 735 1069 713 1077 q 771 1053 757 1061 q 785 1039 785 1045 q 781 1025 785 1034 q 749 958 760 984 q 732 917 739 932 q 722 897 726 902 q 710 891 718 891 q 702 893 707 890 q 690 898 698 895 q 643 914 667 907 q 597 921 618 921 q 544 902 566 921 q 509 830 522 883 q 497 764 502 800 q 489 694 493 729 l 666 694 q 676 691 671 694 q 682 678 682 687 q 673 654 682 675 q 650 599 665 633 l 626 544 q 616 529 621 534 q 595 523 611 524 l 478 523 q 453 311 465 420 q 425 81 441 202 q 392 -59 414 1 q 334 -157 370 -118 q 244 -216 297 -197 q 120 -235 192 -235 q 84 -231 107 -235 q 33 -221 60 -227 q -22 -207 6 -215 q -72 -190 -50 -198 q -109 -174 -95 -182 q -123 -159 -123 -165 q -119 -145 -123 -154 q -87 -79 -98 -105 q -71 -37 -77 -52 q -60 -15 -64 -21 q -49 -9 -56 -9 q -39 -15 -45 -14 q -26 -16 -34 -16 q 21 -32 -3 -25 q 68 -39 45 -39 q 110 -28 93 -39 q 138 2 127 -16 q 156 45 149 21 q 167 95 163 70 q 173 146 171 121 q 178 191 176 171 z " - }, - "Ȁ": { - "ha": 940, - "x_min": 29, - "x_max": 965, - "o": "m 45 50 q 64 89 54 67 q 81 137 73 111 l 100 182 q 75 221 87 200 q 52 265 62 243 q 36 310 42 288 q 29 353 29 332 q 40 356 29 355 q 66 357 50 357 q 101 358 82 358 q 135 359 119 359 q 162 360 151 359 q 172 360 172 360 q 203 437 188 401 q 233 511 218 474 q 262 588 248 549 q 292 671 277 627 q 348 819 321 755 q 399 938 375 883 q 408 950 401 945 q 422 960 414 956 q 436 967 429 964 q 448 971 444 970 q 468 977 450 972 q 509 989 486 983 q 555 1000 532 995 q 591 1004 578 1004 l 604 1004 q 624 999 614 1004 q 637 979 634 994 q 707 797 670 896 q 779 580 744 699 q 817 459 798 516 q 853 348 835 402 q 890 239 871 294 q 928 127 909 185 q 941 89 935 103 q 953 66 947 75 q 962 55 958 58 q 965 47 965 51 q 952 39 965 43 l 806 -9 q 773 -21 790 -15 q 741 -32 756 -27 q 715 -40 726 -37 q 699 -43 704 -43 l 695 -43 q 682 -37 686 -43 q 676 -26 677 -31 q 663 15 669 -3 q 649 51 656 33 q 636 89 643 68 q 624 137 630 109 q 616 143 623 140 q 602 146 610 145 q 584 148 593 148 q 566 149 574 149 q 525 148 541 149 q 496 148 509 148 q 473 147 484 147 q 446 146 462 146 q 405 147 426 146 q 368 148 385 147 l 329 149 q 294 58 311 100 q 256 -31 276 15 q 249 -39 254 -36 q 239 -43 244 -43 q 234 -42 235 -43 q 123 5 168 -18 q 45 50 79 28 m 503 659 q 470 550 486 599 q 441 463 454 500 q 418 398 428 425 q 405 358 409 372 l 405 352 q 404 347 405 348 l 567 347 q 551 414 559 380 q 534 485 543 448 q 518 565 526 522 q 503 659 510 608 m 613 1180 q 594 1227 602 1208 q 579 1264 586 1246 q 564 1300 572 1281 q 545 1348 556 1319 q 542 1359 543 1354 q 541 1369 541 1364 q 545 1384 541 1379 q 558 1394 549 1389 q 665 1452 609 1422 q 772 1518 721 1481 q 775 1519 772 1519 q 778 1520 778 1520 q 779 1521 779 1520 q 781 1521 780 1521 q 786 1516 786 1521 l 825 1119 q 825 1108 825 1113 q 825 1100 825 1103 q 823 1083 825 1088 q 811 1073 820 1078 q 783 1061 795 1067 q 757 1050 770 1056 q 730 1037 745 1044 q 698 1021 716 1030 q 690 1018 695 1018 q 677 1027 684 1018 q 663 1056 671 1036 q 643 1106 654 1075 q 613 1180 631 1137 m 274 1180 q 248 1227 258 1208 q 228 1263 237 1246 q 207 1300 218 1280 q 181 1348 196 1319 q 176 1362 177 1355 q 174 1374 174 1369 q 178 1386 174 1381 q 188 1394 181 1390 q 240 1422 213 1408 q 296 1452 268 1437 q 351 1484 323 1468 q 404 1518 378 1500 q 413 1521 410 1521 q 418 1516 417 1521 l 494 1119 q 497 1104 496 1110 q 498 1093 498 1099 q 496 1082 498 1087 q 488 1073 494 1076 q 461 1061 473 1067 q 437 1050 450 1056 q 412 1037 425 1044 q 382 1021 399 1030 q 375 1018 380 1018 q 361 1027 369 1018 q 343 1056 354 1036 q 315 1106 332 1075 q 274 1180 298 1137 z " - }, - "ȁ": { - "ha": 846, - "x_min": 71, - "x_max": 844, - "o": "m 774 136 q 773 131 773 134 q 773 127 773 129 q 779 99 773 110 q 790 80 784 87 q 802 69 797 73 q 808 61 808 64 q 787 43 808 52 l 605 -35 q 600 -35 604 -35 q 589 -26 595 -35 q 579 -2 584 -16 q 569 30 574 13 q 562 60 565 46 q 469 -12 519 11 q 371 -35 420 -35 q 260 -10 314 -35 q 163 61 205 15 q 96 174 121 108 q 71 321 71 239 q 99 498 71 418 q 175 636 127 578 q 287 725 223 694 q 423 757 351 757 q 519 736 474 757 q 606 683 565 715 q 610 715 610 703 q 613 734 611 728 q 623 744 616 741 q 645 747 629 746 q 742 760 694 754 q 844 768 791 766 l 774 136 m 571 392 q 580 465 578 431 q 584 528 583 499 q 561 545 573 536 q 533 561 548 553 q 503 574 519 569 q 469 578 487 578 q 408 555 433 578 q 368 496 383 531 q 346 423 353 462 q 340 355 340 385 q 368 198 340 248 q 446 148 396 148 q 492 159 467 148 q 543 191 517 171 l 571 392 m 576 968 q 556 1015 564 996 q 542 1052 549 1034 q 527 1088 534 1069 q 507 1135 519 1107 q 505 1147 506 1142 q 504 1156 504 1152 q 508 1172 504 1166 q 521 1181 512 1177 q 628 1239 572 1210 q 734 1305 684 1269 q 738 1307 734 1307 q 741 1308 741 1308 q 742 1309 741 1308 q 743 1309 743 1309 q 749 1303 749 1309 l 787 907 q 788 896 787 901 q 788 888 788 891 q 785 871 788 876 q 774 861 783 866 q 745 849 758 854 q 720 838 732 844 q 693 825 707 832 q 661 808 679 818 q 652 806 658 806 q 640 815 646 806 q 626 843 634 824 q 605 893 617 863 q 576 968 593 924 m 237 968 q 211 1015 221 996 q 190 1051 200 1034 q 170 1087 180 1068 q 144 1135 159 1107 q 138 1150 140 1143 q 137 1162 137 1157 q 140 1174 137 1169 q 151 1181 144 1178 q 203 1210 176 1196 q 258 1240 231 1225 q 314 1272 286 1255 q 366 1305 341 1288 q 376 1309 373 1309 q 381 1303 380 1309 l 457 907 q 460 892 458 898 q 461 881 461 886 q 459 869 461 875 q 450 861 457 864 q 424 849 436 854 q 400 838 412 844 q 375 825 388 832 q 345 808 361 818 q 338 806 342 806 q 324 815 332 806 q 306 843 317 824 q 278 893 294 863 q 237 968 261 924 z " - }, - "Ȃ": { - "ha": 940, - "x_min": 29, - "x_max": 965, - "o": "m 45 50 q 64 89 54 67 q 81 137 73 111 l 100 182 q 75 221 87 200 q 52 265 62 243 q 36 310 42 288 q 29 353 29 332 q 40 356 29 355 q 66 357 50 357 q 101 358 82 358 q 135 359 119 359 q 162 360 151 359 q 172 360 172 360 q 203 437 188 401 q 233 511 218 474 q 262 588 248 549 q 292 671 277 627 q 348 819 321 755 q 399 938 375 883 q 408 950 401 945 q 422 960 414 956 q 436 967 429 964 q 448 971 444 970 q 468 977 450 972 q 509 989 486 983 q 555 1000 532 995 q 591 1004 578 1004 l 604 1004 q 624 999 614 1004 q 637 979 634 994 q 707 797 670 896 q 779 580 744 699 q 817 459 798 516 q 853 348 835 402 q 890 239 871 294 q 928 127 909 185 q 941 89 935 103 q 953 66 947 75 q 962 55 958 58 q 965 47 965 51 q 952 39 965 43 l 806 -9 q 773 -21 790 -15 q 741 -32 756 -27 q 715 -40 726 -37 q 699 -43 704 -43 l 695 -43 q 682 -37 686 -43 q 676 -26 677 -31 q 663 15 669 -3 q 649 51 656 33 q 636 89 643 68 q 624 137 630 109 q 616 143 623 140 q 602 146 610 145 q 584 148 593 148 q 566 149 574 149 q 525 148 541 149 q 496 148 509 148 q 473 147 484 147 q 446 146 462 146 q 405 147 426 146 q 368 148 385 147 l 329 149 q 294 58 311 100 q 256 -31 276 15 q 249 -39 254 -36 q 239 -43 244 -43 q 234 -42 235 -43 q 123 5 168 -18 q 45 50 79 28 m 503 659 q 470 550 486 599 q 441 463 454 500 q 418 398 428 425 q 405 358 409 372 l 405 352 q 404 347 405 348 l 567 347 q 551 414 559 380 q 534 485 543 448 q 518 565 526 522 q 503 659 510 608 m 564 1046 q 565 1054 564 1049 q 566 1064 566 1059 q 549 1099 566 1082 q 496 1116 531 1116 q 459 1109 474 1116 q 436 1092 445 1102 q 424 1070 427 1082 q 420 1048 420 1059 q 421 1047 420 1048 q 421 1046 421 1047 q 419 1040 420 1043 q 412 1035 417 1037 q 397 1032 407 1033 q 371 1031 388 1031 q 335 1033 348 1031 q 316 1038 322 1034 q 308 1048 309 1042 q 307 1062 307 1054 q 322 1129 307 1100 q 367 1179 338 1159 q 432 1211 395 1200 q 513 1221 470 1221 q 592 1207 559 1221 q 646 1168 625 1192 q 676 1114 667 1144 q 686 1053 686 1084 q 685 1041 686 1046 q 676 1033 683 1036 q 656 1029 669 1030 q 621 1027 644 1027 q 591 1028 602 1027 q 573 1031 580 1029 q 565 1036 567 1033 q 563 1042 563 1038 q 563 1044 563 1043 q 564 1046 564 1044 z " - }, - "ȃ": { - "ha": 846, - "x_min": 71, - "x_max": 844, - "o": "m 774 136 q 773 131 773 134 q 773 127 773 129 q 779 99 773 110 q 790 80 784 87 q 802 69 797 73 q 808 61 808 64 q 787 43 808 52 l 605 -35 q 600 -35 604 -35 q 589 -26 595 -35 q 579 -2 584 -16 q 569 30 574 13 q 562 60 565 46 q 469 -12 519 11 q 371 -35 420 -35 q 260 -10 314 -35 q 163 61 205 15 q 96 174 121 108 q 71 321 71 239 q 99 498 71 418 q 175 636 127 578 q 287 725 223 694 q 423 757 351 757 q 519 736 474 757 q 606 683 565 715 q 610 715 610 703 q 613 734 611 728 q 623 744 616 741 q 645 747 629 746 q 742 760 694 754 q 844 768 791 766 l 774 136 m 571 392 q 580 465 578 431 q 584 528 583 499 q 561 545 573 536 q 533 561 548 553 q 503 574 519 569 q 469 578 487 578 q 408 555 433 578 q 368 496 383 531 q 346 423 353 462 q 340 355 340 385 q 368 198 340 248 q 446 148 396 148 q 492 159 467 148 q 543 191 517 171 l 571 392 m 526 833 q 527 842 526 837 q 528 852 528 846 q 511 887 528 870 q 458 903 493 903 q 421 897 436 903 q 398 880 407 890 q 386 858 389 869 q 382 836 382 846 q 383 835 382 836 q 383 834 383 835 q 381 828 382 831 q 374 823 379 825 q 359 820 369 821 q 333 819 350 819 q 297 820 310 819 q 278 826 284 822 q 270 836 271 830 q 269 850 269 842 q 284 917 269 888 q 329 967 300 947 q 394 998 357 987 q 475 1009 432 1009 q 554 995 521 1009 q 608 956 587 980 q 638 902 629 932 q 648 840 648 871 q 647 829 648 833 q 638 821 645 824 q 618 817 631 818 q 583 815 606 815 q 553 816 564 815 q 535 819 542 817 q 527 823 529 821 q 525 829 525 826 q 525 831 525 831 q 526 833 526 832 z " - }, - "Ȅ": { - "ha": 799, - "x_min": 92, - "x_max": 856, - "o": "m 694 563 q 684 536 691 553 q 666 497 676 519 q 645 451 656 475 q 623 401 634 426 q 616 387 619 391 q 605 380 612 382 q 584 378 597 378 q 547 377 571 378 l 453 375 l 434 168 l 782 168 l 782 141 q 770 123 781 140 q 747 83 760 106 q 718 37 733 60 q 693 -1 703 14 q 677 -20 686 -13 q 658 -31 669 -27 q 635 -35 648 -34 q 608 -35 623 -35 q 480 -33 547 -35 q 349 -26 414 -30 q 220 -17 283 -22 q 104 -6 157 -12 q 95 -1 99 -5 q 92 10 92 4 q 95 22 89 10 q 113 52 102 33 q 139 93 125 70 q 165 140 153 117 l 176 293 q 181 351 179 332 q 182 371 182 370 q 122 375 142 372 q 102 390 102 378 q 112 410 102 395 q 136 445 121 425 q 166 485 150 464 q 194 524 182 506 l 211 754 l 209 754 q 182 753 194 753 q 159 753 170 753 q 113 756 127 753 q 99 770 99 760 q 107 790 99 775 q 127 824 115 805 q 153 865 140 844 q 178 905 167 886 l 218 974 l 502 974 l 836 998 q 840 998 837 998 q 846 996 843 998 q 853 990 850 994 q 856 979 856 986 l 846 943 q 834 912 841 928 q 819 878 827 895 l 789 799 q 779 781 785 787 q 753 774 772 775 q 638 770 701 773 q 492 764 574 767 q 490 749 490 755 q 488 727 490 743 l 485 696 q 481 649 484 674 q 474 587 478 624 q 542 590 509 589 q 602 592 574 591 q 649 594 629 593 q 677 595 669 595 q 689 591 682 595 q 696 575 696 587 q 694 563 696 570 m 589 1180 q 570 1227 578 1208 q 555 1264 562 1246 q 540 1300 548 1281 q 521 1348 532 1319 q 518 1359 519 1354 q 517 1369 517 1364 q 522 1384 517 1379 q 534 1394 526 1389 q 641 1452 585 1422 q 748 1518 697 1481 q 751 1519 748 1519 q 754 1520 754 1520 q 755 1521 755 1520 q 757 1521 756 1521 q 762 1516 762 1521 l 801 1119 q 801 1108 801 1113 q 802 1100 802 1103 q 799 1083 802 1088 q 787 1073 796 1078 q 759 1061 772 1067 q 733 1050 746 1056 q 707 1037 721 1044 q 674 1021 692 1030 q 666 1018 671 1018 q 654 1027 660 1018 q 639 1056 648 1036 q 619 1106 631 1075 q 589 1180 607 1137 m 250 1180 q 224 1227 235 1208 q 204 1263 214 1246 q 183 1300 194 1280 q 157 1348 172 1319 q 152 1362 153 1355 q 151 1374 151 1369 q 154 1386 151 1381 q 164 1394 157 1390 q 217 1422 189 1408 q 272 1452 244 1437 q 327 1484 300 1468 q 380 1518 355 1500 q 389 1521 387 1521 q 395 1516 393 1521 l 471 1119 q 473 1104 472 1110 q 475 1093 475 1099 q 473 1082 475 1087 q 464 1073 471 1076 q 438 1061 450 1067 q 414 1050 426 1056 q 388 1037 401 1044 q 359 1021 375 1030 q 351 1018 356 1018 q 338 1027 345 1018 q 319 1056 330 1036 q 291 1106 308 1075 q 250 1180 275 1137 z " - }, - "ȅ": { - "ha": 774, - "x_min": 68, - "x_max": 771, - "o": "m 486 757 q 603 733 550 757 q 693 670 655 709 q 751 585 730 632 q 771 490 771 537 q 745 405 771 448 q 673 329 720 363 q 562 274 627 295 q 418 253 496 253 q 333 261 378 253 q 350 211 336 232 q 386 176 364 190 q 435 156 408 163 q 492 150 463 150 q 554 156 524 150 q 612 171 585 161 q 666 192 640 180 q 715 215 692 203 q 725 217 721 216 q 734 218 730 218 q 733 208 734 218 q 733 177 733 197 q 733 130 733 157 q 732 68 732 102 q 734 61 734 64 q 735 56 735 58 q 720 38 735 47 q 681 18 705 28 q 626 -1 657 8 q 564 -19 595 -11 q 502 -31 532 -26 q 450 -35 472 -35 q 308 -10 376 -35 q 185 63 239 16 q 100 178 132 111 q 68 331 68 246 q 99 497 68 420 q 185 633 130 575 q 317 724 240 690 q 486 757 393 757 m 477 576 q 426 565 450 576 q 384 531 403 553 q 350 478 364 509 q 327 410 336 447 q 443 435 397 422 q 517 463 489 449 q 556 491 545 477 q 568 517 568 505 q 558 541 568 530 q 536 559 549 551 q 506 572 522 568 q 477 576 490 576 m 536 968 q 517 1015 525 996 q 502 1052 509 1034 q 487 1088 495 1069 q 468 1135 479 1107 q 466 1147 467 1142 q 465 1156 465 1152 q 469 1172 465 1166 q 481 1181 473 1177 q 588 1239 532 1210 q 695 1305 644 1269 q 698 1307 695 1307 q 701 1308 701 1308 q 703 1309 702 1308 q 704 1309 703 1309 q 709 1303 709 1309 l 748 907 q 748 896 748 901 q 749 888 749 891 q 746 871 749 876 q 734 861 743 866 q 706 849 719 854 q 681 838 693 844 q 654 825 668 832 q 621 808 640 818 q 613 806 618 806 q 601 815 607 806 q 586 843 595 824 q 566 893 578 863 q 536 968 554 924 m 197 968 q 171 1015 182 996 q 151 1051 161 1034 q 130 1087 141 1068 q 104 1135 119 1107 q 99 1150 100 1143 q 98 1162 98 1157 q 101 1174 98 1169 q 111 1181 104 1178 q 164 1210 136 1196 q 219 1240 191 1225 q 274 1272 247 1255 q 327 1305 302 1288 q 336 1309 334 1309 q 342 1303 340 1309 l 418 907 q 420 892 419 898 q 422 881 422 886 q 420 869 422 875 q 411 861 418 864 q 385 849 397 854 q 361 838 373 844 q 335 825 349 832 q 306 808 322 818 q 298 806 303 806 q 285 815 292 806 q 266 843 277 824 q 238 893 255 863 q 197 968 222 924 z " - }, - "Ȇ": { - "ha": 799, - "x_min": 92, - "x_max": 856, - "o": "m 694 563 q 684 536 691 553 q 666 497 676 519 q 645 451 656 475 q 623 401 634 426 q 616 387 619 391 q 605 380 612 382 q 584 378 597 378 q 547 377 571 378 l 453 375 l 434 168 l 782 168 l 782 141 q 770 123 781 140 q 747 83 760 106 q 718 37 733 60 q 693 -1 703 14 q 677 -20 686 -13 q 658 -31 669 -27 q 635 -35 648 -34 q 608 -35 623 -35 q 480 -33 547 -35 q 349 -26 414 -30 q 220 -17 283 -22 q 104 -6 157 -12 q 95 -1 99 -5 q 92 10 92 4 q 95 22 89 10 q 113 52 102 33 q 139 93 125 70 q 165 140 153 117 l 176 293 q 181 351 179 332 q 182 371 182 370 q 122 375 142 372 q 102 390 102 378 q 112 410 102 395 q 136 445 121 425 q 166 485 150 464 q 194 524 182 506 l 211 754 l 209 754 q 182 753 194 753 q 159 753 170 753 q 113 756 127 753 q 99 770 99 760 q 107 790 99 775 q 127 824 115 805 q 153 865 140 844 q 178 905 167 886 l 218 974 l 502 974 l 836 998 q 840 998 837 998 q 846 996 843 998 q 853 990 850 994 q 856 979 856 986 l 846 943 q 834 912 841 928 q 819 878 827 895 l 789 799 q 779 781 785 787 q 753 774 772 775 q 638 770 701 773 q 492 764 574 767 q 490 749 490 755 q 488 727 490 743 l 485 696 q 481 649 484 674 q 474 587 478 624 q 542 590 509 589 q 602 592 574 591 q 649 594 629 593 q 677 595 669 595 q 689 591 682 595 q 696 575 696 587 q 694 563 696 570 m 539 1046 q 541 1054 540 1049 q 542 1064 542 1059 q 524 1099 542 1082 q 471 1116 507 1116 q 435 1109 450 1116 q 412 1092 420 1102 q 399 1070 403 1082 q 396 1048 396 1059 q 396 1047 396 1048 q 397 1046 397 1047 q 394 1040 396 1043 q 388 1035 393 1037 q 373 1032 382 1033 q 347 1031 363 1031 q 311 1033 323 1031 q 291 1038 298 1034 q 283 1048 285 1042 q 282 1062 282 1054 q 298 1129 282 1100 q 342 1179 314 1159 q 408 1211 370 1200 q 488 1221 446 1221 q 567 1207 534 1221 q 621 1168 600 1192 q 652 1114 642 1144 q 662 1053 662 1084 q 660 1041 662 1046 q 652 1033 659 1036 q 632 1029 645 1030 q 596 1027 619 1027 q 567 1028 578 1027 q 549 1031 555 1029 q 541 1036 543 1033 q 538 1042 538 1038 q 539 1044 538 1043 q 539 1046 539 1044 z " - }, - "ȇ": { - "ha": 774, - "x_min": 68, - "x_max": 771, - "o": "m 486 757 q 603 733 550 757 q 693 670 655 709 q 751 585 730 632 q 771 490 771 537 q 745 405 771 448 q 673 329 720 363 q 562 274 627 295 q 418 253 496 253 q 333 261 378 253 q 350 211 336 232 q 386 176 364 190 q 435 156 408 163 q 492 150 463 150 q 554 156 524 150 q 612 171 585 161 q 666 192 640 180 q 715 215 692 203 q 725 217 721 216 q 734 218 730 218 q 733 208 734 218 q 733 177 733 197 q 733 130 733 157 q 732 68 732 102 q 734 61 734 64 q 735 56 735 58 q 720 38 735 47 q 681 18 705 28 q 626 -1 657 8 q 564 -19 595 -11 q 502 -31 532 -26 q 450 -35 472 -35 q 308 -10 376 -35 q 185 63 239 16 q 100 178 132 111 q 68 331 68 246 q 99 497 68 420 q 185 633 130 575 q 317 724 240 690 q 486 757 393 757 m 477 576 q 426 565 450 576 q 384 531 403 553 q 350 478 364 509 q 327 410 336 447 q 443 435 397 422 q 517 463 489 449 q 556 491 545 477 q 568 517 568 505 q 558 541 568 530 q 536 559 549 551 q 506 572 522 568 q 477 576 490 576 m 486 833 q 488 842 487 837 q 489 852 489 846 q 471 887 489 870 q 418 903 454 903 q 382 897 397 903 q 359 880 368 890 q 347 858 350 869 q 343 836 343 846 q 343 835 343 836 q 344 834 344 835 q 341 828 343 831 q 335 823 340 825 q 320 820 330 821 q 294 819 311 819 q 258 820 271 819 q 238 826 245 822 q 231 836 232 830 q 229 850 229 842 q 245 917 229 888 q 289 967 261 947 q 355 998 317 987 q 435 1009 393 1009 q 514 995 481 1009 q 568 956 547 980 q 599 902 589 932 q 609 840 609 871 q 607 829 609 833 q 599 821 606 824 q 579 817 592 818 q 543 815 566 815 q 514 816 525 815 q 496 819 503 817 q 488 823 490 821 q 486 829 486 826 q 486 831 486 831 q 486 833 486 832 z " - }, - "Ȉ": { - "ha": 452, - "x_min": -54, - "x_max": 597, - "o": "m 94 -22 l 128 442 q 153 785 145 675 q 161 893 161 894 q 163 913 162 905 q 165 927 163 922 q 171 935 168 932 q 181 939 174 938 l 416 996 q 434 998 425 998 q 447 992 444 998 q 450 969 450 987 q 443 890 446 927 q 438 821 440 854 q 435 756 437 787 q 432 695 434 726 q 425 629 428 662 q 419 560 422 595 q 413 485 416 524 q 406 398 410 445 l 376 41 q 374 29 376 35 q 365 20 372 23 q 357 17 364 20 q 337 10 349 14 q 309 1 325 5 q 274 -8 292 -4 q 221 -22 243 -15 q 180 -34 198 -28 q 148 -43 163 -40 q 118 -47 133 -47 q 101 -41 108 -47 q 94 -22 94 -36 m 385 1180 q 366 1227 374 1208 q 351 1264 358 1246 q 336 1300 344 1281 q 317 1348 328 1319 q 314 1359 315 1354 q 313 1369 313 1364 q 317 1384 313 1379 q 330 1394 321 1389 q 437 1452 381 1422 q 544 1518 493 1481 q 547 1519 544 1519 q 550 1520 550 1520 q 551 1521 551 1520 q 553 1521 552 1521 q 558 1516 558 1521 l 597 1119 q 597 1108 597 1113 q 597 1100 597 1103 q 595 1083 597 1088 q 583 1073 592 1078 q 555 1061 568 1067 q 529 1050 542 1056 q 503 1037 517 1044 q 470 1021 488 1030 q 462 1018 467 1018 q 450 1027 456 1018 q 435 1056 444 1036 q 415 1106 427 1075 q 385 1180 403 1137 m 46 1180 q 20 1227 31 1208 q 0 1263 9 1246 q -21 1300 -10 1280 q -47 1348 -32 1319 q -52 1362 -51 1355 q -54 1374 -54 1369 q -50 1386 -54 1381 q -40 1394 -47 1390 q 13 1422 -15 1408 q 68 1452 40 1437 q 123 1484 96 1468 q 176 1518 151 1500 q 185 1521 182 1521 q 191 1516 189 1521 l 267 1119 q 269 1104 268 1110 q 271 1093 271 1099 q 269 1082 271 1087 q 260 1073 267 1076 q 234 1061 245 1067 q 210 1050 222 1056 q 184 1037 197 1044 q 155 1021 171 1030 q 147 1018 152 1018 q 134 1027 141 1018 q 115 1056 126 1036 q 87 1106 104 1075 q 46 1180 71 1137 z " - }, - "ȉ": { - "ha": 415, - "x_min": -66, - "x_max": 585, - "o": "m 99 288 q 117 471 109 380 q 132 658 125 562 q 137 689 134 680 q 152 700 140 697 q 273 724 210 711 q 395 756 336 736 q 401 757 397 757 q 408 751 408 757 l 347 80 q 342 49 345 58 q 328 38 340 41 q 211 -2 270 20 q 86 -45 152 -24 q 80 -46 84 -46 q 73 -39 73 -46 q 74 -20 73 -39 q 78 26 75 -2 q 83 91 80 55 q 89 163 85 127 q 94 232 92 199 q 99 288 97 264 m 372 968 q 353 1015 361 996 q 338 1052 345 1034 q 323 1088 331 1069 q 304 1135 315 1107 q 301 1147 302 1142 q 300 1156 300 1152 q 304 1172 300 1166 q 317 1181 309 1177 q 424 1239 368 1210 q 531 1305 480 1269 q 534 1307 531 1307 q 537 1308 537 1308 q 538 1309 538 1308 q 540 1309 539 1309 q 545 1303 545 1309 l 584 907 q 584 896 584 901 q 585 888 585 891 q 582 871 585 876 q 570 861 579 866 q 542 849 555 854 q 516 838 529 844 q 490 825 504 832 q 457 808 475 818 q 449 806 454 806 q 437 815 443 806 q 422 843 431 824 q 402 893 414 863 q 372 968 390 924 m 33 968 q 7 1015 18 996 q -13 1051 -3 1034 q -34 1087 -23 1068 q -60 1135 -45 1107 q -65 1150 -64 1143 q -66 1162 -66 1157 q -63 1174 -66 1169 q -53 1181 -60 1178 q 0 1210 -28 1196 q 55 1240 27 1225 q 110 1272 83 1255 q 163 1305 138 1288 q 172 1309 170 1309 q 178 1303 176 1309 l 254 907 q 256 892 255 898 q 258 881 258 886 q 256 869 258 875 q 247 861 254 864 q 221 849 233 854 q 197 838 209 844 q 171 825 184 832 q 142 808 158 818 q 134 806 139 806 q 121 815 128 806 q 102 843 113 824 q 74 893 91 863 q 33 968 58 924 z " - }, - "Ȋ": { - "ha": 452, - "x_min": 76, - "x_max": 456, - "o": "m 94 -22 l 128 442 q 153 785 145 675 q 161 893 161 894 q 163 913 162 905 q 165 927 163 922 q 171 935 168 932 q 181 939 174 938 l 416 996 q 434 998 425 998 q 447 992 444 998 q 450 969 450 987 q 443 890 446 927 q 438 821 440 854 q 435 756 437 787 q 432 695 434 726 q 425 629 428 662 q 419 560 422 595 q 413 485 416 524 q 406 398 410 445 l 376 41 q 374 29 376 35 q 365 20 372 23 q 357 17 364 20 q 337 10 349 14 q 309 1 325 5 q 274 -8 292 -4 q 221 -22 243 -15 q 180 -34 198 -28 q 148 -43 163 -40 q 118 -47 133 -47 q 101 -41 108 -47 q 94 -22 94 -36 m 333 1046 q 335 1054 334 1049 q 336 1064 336 1059 q 318 1099 336 1082 q 265 1116 300 1116 q 229 1109 243 1116 q 205 1092 214 1102 q 193 1070 197 1082 q 190 1048 190 1059 q 190 1047 190 1048 q 191 1046 191 1047 q 188 1040 190 1043 q 181 1035 186 1037 q 167 1032 176 1033 q 140 1031 157 1031 q 104 1033 117 1031 q 85 1038 92 1034 q 77 1048 79 1042 q 76 1062 76 1054 q 92 1129 76 1100 q 136 1179 108 1159 q 202 1211 164 1200 q 282 1221 239 1221 q 361 1207 328 1221 q 415 1168 394 1192 q 446 1114 436 1144 q 456 1053 456 1084 q 454 1041 456 1046 q 446 1033 452 1036 q 426 1029 439 1030 q 390 1027 413 1027 q 360 1028 372 1027 q 343 1031 349 1029 q 334 1036 336 1033 q 332 1042 332 1038 q 333 1044 332 1043 q 333 1046 333 1044 z " - }, - "ȋ": { - "ha": 414, - "x_min": 52, - "x_max": 432, - "o": "m 98 288 q 116 471 108 380 q 132 658 124 562 q 136 689 133 680 q 151 700 139 697 q 272 724 209 711 q 394 756 335 736 q 400 757 396 757 q 408 751 408 757 l 347 80 q 342 49 345 58 q 327 38 339 41 q 210 -2 269 20 q 85 -45 151 -24 q 79 -46 83 -46 q 72 -39 72 -46 q 73 -20 72 -39 q 77 26 75 -2 q 82 91 79 55 q 88 163 85 127 q 94 232 91 199 q 98 288 96 264 m 309 833 q 311 842 310 837 q 312 852 312 846 q 294 887 312 870 q 241 903 277 903 q 205 897 220 903 q 182 880 191 890 q 170 858 173 869 q 166 836 166 846 q 166 835 166 836 q 167 834 167 835 q 164 828 166 831 q 158 823 163 825 q 143 820 153 821 q 117 819 134 819 q 78 821 91 819 q 59 828 64 823 q 53 839 54 832 q 52 857 52 846 q 69 921 52 893 q 115 969 86 949 q 180 999 143 989 q 258 1009 218 1009 q 337 995 304 1009 q 391 956 370 980 q 422 902 412 932 q 432 840 432 871 q 430 829 432 833 q 422 821 429 824 q 402 817 415 818 q 366 815 389 815 q 337 816 348 815 q 319 819 326 817 q 311 823 313 821 q 309 829 309 826 q 309 831 309 831 q 309 833 309 832 z " - }, - "Ȍ": { - "ha": 1103, - "x_min": 85, - "x_max": 1101, - "o": "m 384 463 q 394 365 384 414 q 429 276 405 315 q 494 212 454 237 q 593 188 534 188 q 672 207 638 191 q 731 248 707 222 q 772 306 756 273 q 798 375 789 339 q 811 450 808 412 q 815 523 815 488 q 802 616 815 571 q 764 696 789 661 q 700 751 738 730 q 610 772 661 772 q 538 758 570 772 q 481 718 506 743 q 438 661 456 693 q 408 594 420 629 q 390 526 396 560 q 384 463 385 492 m 516 -35 q 334 3 414 -35 q 199 105 254 41 q 114 255 144 170 q 85 435 85 340 q 115 632 85 542 q 199 791 145 722 q 329 908 254 861 q 493 979 404 956 q 506 992 501 979 q 513 1021 510 1005 q 522 1049 517 1036 q 535 1062 526 1062 q 772 1016 667 1048 q 950 922 877 983 q 1062 767 1023 861 q 1101 540 1101 674 q 1080 378 1101 454 q 1021 238 1059 302 q 930 123 983 174 q 812 37 877 73 q 672 -17 747 2 q 516 -35 597 -35 m 709 1180 q 689 1227 697 1208 q 674 1264 682 1246 q 660 1300 667 1281 q 640 1348 652 1319 q 638 1359 639 1354 q 637 1369 637 1364 q 641 1384 637 1379 q 654 1394 645 1389 q 761 1452 705 1422 q 867 1518 817 1481 q 870 1519 867 1519 q 873 1520 873 1520 q 875 1521 874 1520 q 876 1521 876 1521 q 882 1516 882 1521 l 920 1119 q 921 1108 920 1113 q 921 1100 921 1103 q 918 1083 921 1088 q 907 1073 916 1078 q 878 1061 891 1067 q 853 1050 865 1056 q 826 1037 840 1044 q 793 1021 812 1030 q 785 1018 791 1018 q 773 1027 779 1018 q 759 1056 767 1036 q 738 1106 750 1075 q 709 1180 726 1137 m 370 1180 q 343 1227 354 1208 q 323 1263 333 1246 q 302 1300 313 1280 q 277 1348 292 1319 q 271 1362 273 1355 q 270 1374 270 1369 q 273 1386 270 1381 q 283 1394 277 1390 q 336 1422 309 1408 q 391 1452 363 1437 q 447 1484 419 1468 q 499 1518 474 1500 q 509 1521 506 1521 q 514 1516 513 1521 l 590 1119 q 593 1104 591 1110 q 594 1093 594 1099 q 592 1082 594 1087 q 583 1073 590 1076 q 557 1061 569 1067 q 533 1050 545 1056 q 508 1037 521 1044 q 478 1021 494 1030 q 471 1018 475 1018 q 457 1027 465 1018 q 438 1056 450 1036 q 411 1106 427 1075 q 370 1180 394 1137 z " - }, - "ȍ": { - "ha": 890, - "x_min": 68, - "x_max": 885, - "o": "m 454 -35 q 287 -4 359 -35 q 165 79 214 27 q 92 198 117 131 q 68 338 68 266 q 92 476 68 411 q 158 594 115 542 q 260 681 201 646 q 392 728 320 715 q 403 732 403 728 q 401 746 403 740 q 399 758 399 753 q 402 768 399 765 q 408 770 405 770 q 629 741 538 770 q 777 661 720 711 q 859 541 833 610 q 885 392 885 471 q 851 212 885 291 q 759 77 817 132 q 622 -6 700 22 q 454 -35 543 -35 m 329 346 q 337 273 329 309 q 362 208 345 237 q 410 161 380 179 q 482 143 439 143 q 537 157 513 144 q 577 190 560 170 q 605 235 594 210 q 623 287 616 260 q 632 339 629 313 q 635 386 635 365 q 624 455 635 421 q 593 515 614 489 q 543 556 573 541 q 473 572 513 572 q 405 548 433 572 q 360 489 377 524 q 336 415 344 454 q 329 346 329 376 m 592 968 q 573 1015 581 996 q 558 1052 565 1034 q 543 1088 551 1069 q 524 1135 535 1107 q 521 1147 522 1142 q 520 1156 520 1152 q 524 1172 520 1166 q 537 1181 528 1177 q 644 1239 588 1210 q 751 1305 700 1269 q 754 1307 751 1307 q 757 1308 757 1308 q 758 1309 758 1308 q 760 1309 759 1309 q 765 1303 765 1309 l 804 907 q 804 896 804 901 q 804 888 804 891 q 802 871 804 876 q 790 861 799 866 q 762 849 774 854 q 736 838 749 844 q 709 825 724 832 q 677 808 695 818 q 669 806 674 806 q 656 815 663 806 q 642 843 650 824 q 622 893 633 863 q 592 968 610 924 m 253 968 q 227 1015 237 996 q 207 1051 216 1034 q 186 1087 197 1068 q 160 1135 175 1107 q 155 1150 156 1143 q 153 1162 153 1157 q 157 1174 153 1169 q 167 1181 160 1178 q 219 1210 192 1196 q 275 1240 247 1225 q 330 1272 302 1255 q 382 1305 357 1288 q 392 1309 389 1309 q 397 1303 396 1309 l 473 907 q 476 892 475 898 q 477 881 477 886 q 475 869 477 875 q 467 861 473 864 q 440 849 452 854 q 416 838 429 844 q 391 825 404 832 q 361 808 378 818 q 354 806 359 806 q 340 815 348 806 q 322 843 333 824 q 294 893 311 863 q 253 968 277 924 z " - }, - "Ȏ": { - "ha": 1103, - "x_min": 85, - "x_max": 1101, - "o": "m 384 463 q 394 365 384 414 q 429 276 405 315 q 494 212 454 237 q 593 188 534 188 q 672 207 638 191 q 731 248 707 222 q 772 306 756 273 q 798 375 789 339 q 811 450 808 412 q 815 523 815 488 q 802 616 815 571 q 764 696 789 661 q 700 751 738 730 q 610 772 661 772 q 538 758 570 772 q 481 718 506 743 q 438 661 456 693 q 408 594 420 629 q 390 526 396 560 q 384 463 385 492 m 516 -35 q 334 3 414 -35 q 199 105 254 41 q 114 255 144 170 q 85 435 85 340 q 115 632 85 542 q 199 791 145 722 q 329 908 254 861 q 493 979 404 956 q 506 992 501 979 q 513 1021 510 1005 q 522 1049 517 1036 q 535 1062 526 1062 q 772 1016 667 1048 q 950 922 877 983 q 1062 767 1023 861 q 1101 540 1101 674 q 1080 378 1101 454 q 1021 238 1059 302 q 930 123 983 174 q 812 37 877 73 q 672 -17 747 2 q 516 -35 597 -35 m 659 1046 q 660 1054 659 1049 q 661 1064 661 1059 q 644 1099 661 1082 q 591 1116 626 1116 q 554 1109 569 1116 q 531 1092 540 1102 q 519 1070 522 1082 q 515 1048 515 1059 q 516 1047 515 1048 q 516 1046 516 1047 q 514 1040 515 1043 q 507 1035 512 1037 q 492 1032 502 1033 q 466 1031 483 1031 q 430 1033 443 1031 q 411 1038 417 1034 q 403 1048 404 1042 q 401 1062 401 1054 q 417 1129 401 1100 q 461 1179 433 1159 q 527 1211 490 1200 q 608 1221 565 1221 q 687 1207 654 1221 q 741 1168 720 1192 q 771 1114 762 1144 q 781 1053 781 1084 q 780 1041 781 1046 q 771 1033 778 1036 q 751 1029 764 1030 q 715 1027 739 1027 q 686 1028 697 1027 q 668 1031 675 1029 q 660 1036 662 1033 q 658 1042 658 1038 q 658 1044 658 1043 q 659 1046 659 1044 z " - }, - "ȏ": { - "ha": 890, - "x_min": 68, - "x_max": 885, - "o": "m 454 -35 q 287 -4 359 -35 q 165 79 214 27 q 92 198 117 131 q 68 338 68 266 q 92 476 68 411 q 158 594 115 542 q 260 681 201 646 q 392 728 320 715 q 403 732 403 728 q 401 746 403 740 q 399 758 399 753 q 402 768 399 765 q 408 770 405 770 q 629 741 538 770 q 777 661 720 711 q 859 541 833 610 q 885 392 885 471 q 851 212 885 291 q 759 77 817 132 q 622 -6 700 22 q 454 -35 543 -35 m 329 346 q 337 273 329 309 q 362 208 345 237 q 410 161 380 179 q 482 143 439 143 q 537 157 513 144 q 577 190 560 170 q 605 235 594 210 q 623 287 616 260 q 632 339 629 313 q 635 386 635 365 q 624 455 635 421 q 593 515 614 489 q 543 556 573 541 q 473 572 513 572 q 405 548 433 572 q 360 489 377 524 q 336 415 344 454 q 329 346 329 376 m 542 833 q 544 842 543 837 q 545 852 545 846 q 527 887 545 870 q 474 903 509 903 q 438 897 452 903 q 414 880 423 890 q 402 858 406 869 q 399 836 399 846 q 399 835 399 836 q 399 834 399 835 q 397 828 399 831 q 390 823 395 825 q 376 820 385 821 q 349 819 366 819 q 313 820 326 819 q 294 826 300 822 q 286 836 288 830 q 285 850 285 842 q 301 917 285 888 q 345 967 317 947 q 411 998 373 987 q 491 1009 448 1009 q 570 995 537 1009 q 624 956 603 980 q 655 902 645 932 q 665 840 665 871 q 663 829 665 833 q 654 821 661 824 q 635 817 648 818 q 599 815 622 815 q 569 816 581 815 q 552 819 558 817 q 543 823 545 821 q 541 829 541 826 q 542 831 541 831 q 542 833 542 832 z " - }, - "Ȑ": { - "ha": 999, - "x_min": 83, - "x_max": 1026, - "o": "m 446 54 q 444 42 446 48 q 435 33 442 37 q 408 23 432 32 q 352 4 384 15 q 290 -19 321 -7 q 243 -36 259 -30 q 223 -43 235 -39 q 199 -47 211 -47 q 183 -42 190 -47 q 176 -24 176 -37 q 177 30 176 5 q 182 82 179 55 q 188 142 184 109 q 193 220 191 175 q 201 335 197 280 q 209 450 205 391 l 218 566 q 222 624 220 595 q 227 685 224 654 l 234 768 q 230 769 234 769 q 212 767 224 769 q 181 761 199 764 q 142 754 163 758 q 98 747 121 750 q 88 749 93 747 q 83 755 83 751 q 84 759 83 758 l 194 951 q 274 967 231 959 q 367 983 317 976 q 472 994 416 989 q 590 998 528 998 q 727 984 661 997 q 846 942 794 972 q 929 862 898 913 q 961 734 961 812 q 946 656 961 692 q 909 591 932 620 q 859 540 886 562 q 807 503 832 518 q 764 478 783 487 q 738 466 745 469 q 739 463 738 465 q 743 455 740 460 q 753 438 747 449 q 770 410 760 428 q 795 366 781 393 q 831 302 810 339 q 879 220 852 265 q 941 122 906 174 q 968 110 953 112 q 996 107 983 107 q 1017 105 1008 106 q 1026 97 1026 104 q 1015 84 1026 92 q 989 70 1004 77 q 959 56 974 62 q 935 45 943 49 q 901 29 919 37 q 863 13 884 22 q 818 -9 843 3 q 762 -38 793 -21 q 747 -44 754 -43 q 734 -46 740 -46 q 713 -40 722 -46 q 698 -26 704 -35 q 688 -10 692 -18 q 682 4 684 -1 l 479 430 l 446 54 m 488 513 q 559 531 522 513 q 627 576 597 549 q 677 640 658 604 q 697 711 697 675 q 579 809 697 809 q 542 806 557 809 q 515 802 527 803 l 488 513 m 668 1180 q 649 1227 656 1208 q 634 1264 641 1246 q 619 1300 627 1281 q 600 1348 611 1319 q 597 1359 598 1354 q 596 1369 596 1364 q 600 1384 596 1379 q 613 1394 604 1389 q 720 1452 664 1422 q 827 1518 776 1481 q 830 1519 827 1519 q 833 1520 833 1520 q 834 1521 833 1520 q 836 1521 835 1521 q 841 1516 841 1521 l 880 1119 q 880 1108 880 1113 q 880 1100 880 1103 q 878 1083 880 1088 q 866 1073 875 1078 q 838 1061 850 1067 q 812 1050 825 1056 q 785 1037 800 1044 q 753 1021 771 1030 q 745 1018 750 1018 q 732 1027 739 1018 q 718 1056 726 1036 q 697 1106 709 1075 q 668 1180 686 1137 m 329 1180 q 303 1227 313 1208 q 282 1263 292 1246 q 262 1300 273 1280 q 236 1348 251 1319 q 231 1362 232 1355 q 229 1374 229 1369 q 233 1386 229 1381 q 243 1394 236 1390 q 295 1422 268 1408 q 351 1452 323 1437 q 406 1484 378 1468 q 458 1518 433 1500 q 468 1521 465 1521 q 473 1516 472 1521 l 549 1119 q 552 1104 551 1110 q 553 1093 553 1099 q 551 1082 553 1087 q 543 1073 549 1076 q 516 1061 528 1067 q 492 1050 505 1056 q 467 1037 480 1044 q 437 1021 454 1030 q 430 1018 435 1018 q 416 1027 424 1018 q 398 1056 409 1036 q 370 1106 387 1075 q 329 1180 353 1137 z " - }, - "ȑ": { - "ha": 613, - "x_min": 32, - "x_max": 683, - "o": "m 636 552 q 604 555 622 553 q 567 557 587 557 q 506 552 537 557 q 449 532 475 547 q 404 491 422 517 q 379 423 385 465 q 371 341 374 373 q 367 288 368 309 q 365 255 366 267 q 363 231 363 242 q 362 216 363 229 q 359 188 361 204 q 355 153 357 172 q 351 117 353 134 q 348 89 349 101 q 347 74 347 77 q 348 65 347 68 q 348 58 348 61 q 343 48 348 52 q 320 40 338 45 l 140 -24 q 121 -31 133 -27 q 97 -35 109 -35 q 80 -31 87 -35 q 73 -14 73 -26 l 132 658 q 137 689 134 680 q 152 700 140 697 q 279 725 214 712 q 407 757 345 737 q 413 755 412 757 q 414 750 414 753 q 414 746 414 749 q 412 734 414 743 q 407 705 410 724 q 399 651 404 686 q 468 696 430 675 q 543 731 505 716 q 616 754 581 745 q 678 762 652 762 l 636 552 m 471 968 q 451 1015 459 996 q 436 1052 444 1034 q 421 1088 429 1069 q 402 1135 414 1107 q 400 1147 401 1142 q 399 1156 399 1152 q 403 1172 399 1166 q 416 1181 407 1177 q 523 1239 467 1210 q 629 1305 578 1269 q 632 1307 629 1307 q 635 1308 635 1308 q 637 1309 636 1308 q 638 1309 637 1309 q 644 1303 644 1309 l 682 907 q 683 896 682 901 q 683 888 683 891 q 680 871 683 876 q 669 861 677 866 q 640 849 653 854 q 615 838 627 844 q 588 825 602 832 q 555 808 574 818 q 547 806 553 806 q 535 815 541 806 q 520 843 529 824 q 500 893 512 863 q 471 968 488 924 m 132 968 q 105 1015 116 996 q 85 1051 95 1034 q 64 1087 75 1068 q 39 1135 54 1107 q 33 1150 35 1143 q 32 1162 32 1157 q 35 1174 32 1169 q 45 1181 39 1178 q 98 1210 71 1196 q 153 1240 125 1225 q 209 1272 181 1255 q 261 1305 236 1288 q 271 1309 268 1309 q 276 1303 275 1309 l 352 907 q 355 892 353 898 q 356 881 356 886 q 354 869 356 875 q 345 861 352 864 q 319 849 331 854 q 295 838 307 844 q 270 825 283 832 q 240 808 256 818 q 233 806 237 806 q 219 815 227 806 q 200 843 212 824 q 173 893 189 863 q 132 968 156 924 z " - }, - "Ȓ": { - "ha": 999, - "x_min": 83, - "x_max": 1026, - "o": "m 446 54 q 444 42 446 48 q 435 33 442 37 q 408 23 432 32 q 352 4 384 15 q 290 -19 321 -7 q 243 -36 259 -30 q 223 -43 235 -39 q 199 -47 211 -47 q 183 -42 190 -47 q 176 -24 176 -37 q 177 30 176 5 q 182 82 179 55 q 188 142 184 109 q 193 220 191 175 q 201 335 197 280 q 209 450 205 391 l 218 566 q 222 624 220 595 q 227 685 224 654 l 234 768 q 230 769 234 769 q 212 767 224 769 q 181 761 199 764 q 142 754 163 758 q 98 747 121 750 q 88 749 93 747 q 83 755 83 751 q 84 759 83 758 l 194 951 q 274 967 231 959 q 367 983 317 976 q 472 994 416 989 q 590 998 528 998 q 727 984 661 997 q 846 942 794 972 q 929 862 898 913 q 961 734 961 812 q 946 656 961 692 q 909 591 932 620 q 859 540 886 562 q 807 503 832 518 q 764 478 783 487 q 738 466 745 469 q 739 463 738 465 q 743 455 740 460 q 753 438 747 449 q 770 410 760 428 q 795 366 781 393 q 831 302 810 339 q 879 220 852 265 q 941 122 906 174 q 968 110 953 112 q 996 107 983 107 q 1017 105 1008 106 q 1026 97 1026 104 q 1015 84 1026 92 q 989 70 1004 77 q 959 56 974 62 q 935 45 943 49 q 901 29 919 37 q 863 13 884 22 q 818 -9 843 3 q 762 -38 793 -21 q 747 -44 754 -43 q 734 -46 740 -46 q 713 -40 722 -46 q 698 -26 704 -35 q 688 -10 692 -18 q 682 4 684 -1 l 479 430 l 446 54 m 488 513 q 559 531 522 513 q 627 576 597 549 q 677 640 658 604 q 697 711 697 675 q 579 809 697 809 q 542 806 557 809 q 515 802 527 803 l 488 513 m 618 1046 q 620 1054 619 1049 q 621 1064 621 1059 q 604 1099 621 1082 q 551 1116 586 1116 q 514 1109 529 1116 q 491 1092 500 1102 q 479 1070 482 1082 q 475 1048 475 1059 q 476 1047 475 1048 q 476 1046 476 1047 q 474 1040 475 1043 q 467 1035 472 1037 q 452 1032 462 1033 q 426 1031 443 1031 q 390 1033 403 1031 q 371 1038 377 1034 q 363 1048 364 1042 q 361 1062 361 1054 q 377 1129 361 1100 q 421 1179 393 1159 q 487 1211 450 1200 q 568 1221 525 1221 q 647 1207 614 1221 q 701 1168 680 1192 q 731 1114 722 1144 q 741 1053 741 1084 q 740 1041 741 1046 q 731 1033 738 1036 q 711 1029 724 1030 q 675 1027 699 1027 q 646 1028 657 1027 q 628 1031 635 1029 q 620 1036 622 1033 q 618 1042 618 1038 q 618 1044 618 1043 q 618 1046 618 1044 z " - }, - "ȓ": { - "ha": 613, - "x_min": 73, - "x_max": 678, - "o": "m 636 552 q 604 555 622 553 q 567 557 587 557 q 506 552 537 557 q 449 532 475 547 q 404 491 422 517 q 379 423 385 465 q 371 341 374 373 q 367 288 368 309 q 365 255 366 267 q 363 231 363 242 q 362 216 363 229 q 359 188 361 204 q 355 153 357 172 q 351 117 353 134 q 348 89 349 101 q 347 74 347 77 q 348 65 347 68 q 348 58 348 61 q 343 48 348 52 q 320 40 338 45 l 140 -24 q 121 -31 133 -27 q 97 -35 109 -35 q 80 -31 87 -35 q 73 -14 73 -26 l 132 658 q 137 689 134 680 q 152 700 140 697 q 279 725 214 712 q 407 757 345 737 q 413 755 412 757 q 414 750 414 753 q 414 746 414 749 q 412 734 414 743 q 407 705 410 724 q 399 651 404 686 q 468 696 430 675 q 543 731 505 716 q 616 754 581 745 q 678 762 652 762 l 636 552 m 420 833 q 422 842 421 837 q 423 852 423 846 q 406 887 423 870 q 353 903 388 903 q 316 897 331 903 q 293 880 302 890 q 281 858 284 869 q 277 836 277 846 q 278 835 277 836 q 278 834 278 835 q 276 828 277 831 q 269 823 274 825 q 254 820 264 821 q 228 819 245 819 q 192 820 205 819 q 173 826 179 822 q 165 836 166 830 q 163 850 163 842 q 179 917 163 888 q 223 967 195 947 q 289 998 252 987 q 370 1009 327 1009 q 449 995 416 1009 q 503 956 481 980 q 533 902 524 932 q 543 840 543 871 q 542 829 543 833 q 533 821 540 824 q 513 817 526 818 q 477 815 500 815 q 448 816 459 815 q 430 819 437 817 q 422 823 424 821 q 420 829 420 826 q 420 831 420 831 q 420 833 420 832 z " - }, - "Ȕ": { - "ha": 935, - "x_min": 103, - "x_max": 937, - "o": "m 937 970 q 932 916 935 951 q 924 835 928 880 q 915 741 920 790 q 906 646 910 691 q 898 564 901 601 q 893 509 895 528 q 845 261 879 365 q 755 92 810 158 q 622 -4 699 26 q 442 -35 544 -35 q 311 -10 372 -35 q 203 62 249 16 q 130 173 157 108 q 103 317 103 237 q 105 354 103 327 q 110 419 106 380 q 116 507 113 458 q 124 612 120 556 l 132 724 q 138 827 136 786 q 143 893 140 868 q 150 930 145 918 q 165 945 155 941 l 396 996 q 414 999 405 999 q 429 993 425 999 q 433 970 433 987 l 381 435 q 376 384 380 412 q 373 327 373 356 q 377 288 373 309 q 393 249 382 267 q 425 217 405 230 q 477 205 445 205 q 539 221 515 205 q 577 266 563 238 q 598 328 591 293 q 608 399 604 363 q 616 500 612 442 q 626 623 621 557 l 646 894 q 647 914 647 906 q 649 928 648 922 q 655 936 650 933 q 669 940 659 939 l 900 996 q 918 999 909 999 q 932 993 928 999 q 937 970 937 987 m 629 1180 q 610 1227 618 1208 q 595 1264 602 1246 q 580 1300 588 1281 q 561 1348 572 1319 q 558 1359 559 1354 q 557 1369 557 1364 q 562 1384 557 1379 q 574 1394 566 1389 q 681 1452 625 1422 q 788 1518 737 1481 q 791 1519 788 1519 q 794 1520 794 1520 q 795 1521 795 1520 q 797 1521 796 1521 q 802 1516 802 1521 l 841 1119 q 841 1108 841 1113 q 842 1100 842 1103 q 839 1083 842 1088 q 827 1073 836 1078 q 799 1061 812 1067 q 773 1050 786 1056 q 747 1037 761 1044 q 714 1021 732 1030 q 706 1018 711 1018 q 694 1027 700 1018 q 679 1056 688 1036 q 659 1106 671 1075 q 629 1180 647 1137 m 290 1180 q 264 1227 275 1208 q 244 1263 254 1246 q 223 1300 234 1280 q 197 1348 212 1319 q 192 1362 193 1355 q 191 1374 191 1369 q 194 1386 191 1381 q 204 1394 197 1390 q 257 1422 229 1408 q 312 1452 284 1437 q 367 1484 340 1468 q 420 1518 395 1500 q 429 1521 427 1521 q 435 1516 433 1521 l 511 1119 q 513 1104 512 1110 q 515 1093 515 1099 q 513 1082 515 1087 q 504 1073 511 1076 q 478 1061 490 1067 q 454 1050 466 1056 q 428 1037 441 1044 q 399 1021 415 1030 q 391 1018 396 1018 q 378 1027 385 1018 q 359 1056 370 1036 q 331 1106 348 1075 q 290 1180 315 1137 z " - }, - "ȕ": { - "ha": 868, - "x_min": 79, - "x_max": 862, - "o": "m 798 84 q 793 53 796 62 q 778 42 789 45 q 657 9 720 26 q 536 -35 595 -7 q 530 -35 534 -35 q 523 -33 524 -35 q 522 -26 522 -30 q 523 -22 522 -25 q 524 -9 523 -18 q 528 16 526 0 q 534 60 530 33 q 400 -13 458 10 q 296 -35 341 -35 q 131 19 182 -35 q 79 182 79 74 q 79 223 79 202 q 83 265 80 243 q 96 402 91 345 q 105 500 102 460 q 111 565 109 540 q 115 608 113 591 q 118 636 117 625 q 120 658 119 647 q 125 688 123 680 q 140 700 127 697 q 201 711 172 706 q 258 722 230 716 q 315 734 286 728 q 377 751 345 741 q 380 751 378 751 q 382 751 381 751 q 391 746 391 751 l 391 745 q 386 701 388 722 q 382 660 384 681 q 377 614 380 638 q 372 557 375 589 q 363 483 368 525 q 352 385 359 441 q 344 304 348 345 q 340 229 340 264 q 342 194 340 210 q 352 167 345 178 q 371 150 359 156 q 401 144 382 144 q 439 150 415 144 q 488 173 464 157 q 531 215 513 189 q 553 281 550 241 q 561 393 557 348 q 568 469 565 438 q 572 521 570 500 q 576 561 574 542 q 579 603 578 581 q 582 658 581 625 q 587 689 584 680 q 602 700 590 697 q 728 725 664 712 q 854 757 793 737 q 861 755 860 757 q 862 750 862 753 l 798 84 m 582 968 q 563 1015 570 996 q 548 1052 555 1034 q 533 1088 541 1069 q 513 1135 525 1107 q 511 1147 512 1142 q 510 1156 510 1152 q 514 1172 510 1166 q 527 1181 518 1177 q 634 1239 578 1210 q 741 1305 690 1269 q 744 1307 741 1307 q 747 1308 747 1308 q 748 1309 747 1308 q 749 1309 749 1309 q 755 1303 755 1309 l 793 907 q 794 896 793 901 q 794 888 794 891 q 791 871 794 876 q 780 861 789 866 q 751 849 764 854 q 726 838 739 844 q 699 825 713 832 q 667 808 685 818 q 659 806 664 806 q 646 815 652 806 q 632 843 640 824 q 611 893 623 863 q 582 968 600 924 m 243 968 q 217 1015 227 996 q 196 1051 206 1034 q 176 1087 186 1068 q 150 1135 165 1107 q 144 1150 146 1143 q 143 1162 143 1157 q 146 1174 143 1169 q 157 1181 150 1178 q 209 1210 182 1196 q 264 1240 237 1225 q 320 1272 292 1255 q 372 1305 347 1288 q 382 1309 379 1309 q 387 1303 386 1309 l 463 907 q 466 892 465 898 q 467 881 467 886 q 465 869 467 875 q 456 861 463 864 q 430 849 442 854 q 406 838 418 844 q 381 825 394 832 q 351 808 368 818 q 344 806 349 806 q 330 815 338 806 q 312 843 323 824 q 284 893 300 863 q 243 968 267 924 z " - }, - "Ȗ": { - "ha": 935, - "x_min": 103, - "x_max": 937, - "o": "m 937 970 q 932 916 935 951 q 924 835 928 880 q 915 741 920 790 q 906 646 910 691 q 898 564 901 601 q 893 509 895 528 q 845 261 879 365 q 755 92 810 158 q 622 -4 699 26 q 442 -35 544 -35 q 311 -10 372 -35 q 203 62 249 16 q 130 173 157 108 q 103 317 103 237 q 105 354 103 327 q 110 419 106 380 q 116 507 113 458 q 124 612 120 556 l 132 724 q 138 827 136 786 q 143 893 140 868 q 150 930 145 918 q 165 945 155 941 l 396 996 q 414 999 405 999 q 429 993 425 999 q 433 970 433 987 l 381 435 q 376 384 380 412 q 373 327 373 356 q 377 288 373 309 q 393 249 382 267 q 425 217 405 230 q 477 205 445 205 q 539 221 515 205 q 577 266 563 238 q 598 328 591 293 q 608 399 604 363 q 616 500 612 442 q 626 623 621 557 l 646 894 q 647 914 647 906 q 649 928 648 922 q 655 936 650 933 q 669 940 659 939 l 900 996 q 918 999 909 999 q 932 993 928 999 q 937 970 937 987 m 579 1046 q 581 1054 580 1049 q 582 1064 582 1059 q 564 1099 582 1082 q 511 1116 547 1116 q 475 1109 490 1116 q 452 1092 460 1102 q 439 1070 443 1082 q 436 1048 436 1059 q 436 1047 436 1048 q 437 1046 437 1047 q 434 1040 436 1043 q 428 1035 433 1037 q 413 1032 422 1033 q 387 1031 404 1031 q 351 1033 363 1031 q 331 1038 338 1034 q 323 1048 325 1042 q 322 1062 322 1054 q 338 1129 322 1100 q 382 1179 354 1159 q 448 1211 410 1200 q 528 1221 486 1221 q 607 1207 574 1221 q 661 1168 640 1192 q 692 1114 682 1144 q 702 1053 702 1084 q 700 1041 702 1046 q 692 1033 699 1036 q 672 1029 685 1030 q 636 1027 659 1027 q 607 1028 618 1027 q 589 1031 595 1029 q 581 1036 583 1033 q 578 1042 578 1038 q 579 1044 578 1043 q 579 1046 579 1044 z " - }, - "ȗ": { - "ha": 868, - "x_min": 79, - "x_max": 862, - "o": "m 798 84 q 793 53 796 62 q 778 42 789 45 q 657 9 720 26 q 536 -35 595 -7 q 530 -35 534 -35 q 523 -33 524 -35 q 522 -26 522 -30 q 523 -22 522 -25 q 524 -9 523 -18 q 528 16 526 0 q 534 60 530 33 q 400 -13 458 10 q 296 -35 341 -35 q 131 19 182 -35 q 79 182 79 74 q 79 223 79 202 q 83 265 80 243 q 96 402 91 345 q 105 500 102 460 q 111 565 109 540 q 115 608 113 591 q 118 636 117 625 q 120 658 119 647 q 125 688 123 680 q 140 700 127 697 q 201 711 172 706 q 258 722 230 716 q 315 734 286 728 q 377 751 345 741 q 380 751 378 751 q 382 751 381 751 q 391 746 391 751 l 391 745 q 386 701 388 722 q 382 660 384 681 q 377 614 380 638 q 372 557 375 589 q 363 483 368 525 q 352 385 359 441 q 344 304 348 345 q 340 229 340 264 q 342 194 340 210 q 352 167 345 178 q 371 150 359 156 q 401 144 382 144 q 439 150 415 144 q 488 173 464 157 q 531 215 513 189 q 553 281 550 241 q 561 393 557 348 q 568 469 565 438 q 572 521 570 500 q 576 561 574 542 q 579 603 578 581 q 582 658 581 625 q 587 689 584 680 q 602 700 590 697 q 728 725 664 712 q 854 757 793 737 q 861 755 860 757 q 862 750 862 753 l 798 84 m 532 833 q 534 842 533 837 q 535 852 535 846 q 517 887 535 870 q 465 903 500 903 q 428 897 443 903 q 405 880 414 890 q 393 858 396 869 q 389 836 389 846 q 390 835 389 836 q 390 834 390 835 q 388 828 389 831 q 381 823 386 825 q 366 820 376 821 q 340 819 357 819 q 304 820 317 819 q 284 826 291 822 q 277 836 278 830 q 275 850 275 842 q 291 917 275 888 q 335 967 307 947 q 401 998 363 987 q 481 1009 439 1009 q 561 995 528 1009 q 614 956 593 980 q 645 902 635 932 q 655 840 655 871 q 653 829 655 833 q 645 821 652 824 q 625 817 638 818 q 589 815 612 815 q 560 816 571 815 q 542 819 549 817 q 534 823 536 821 q 532 829 532 826 q 532 831 532 831 q 532 833 532 832 z " - }, - "Ș": { - "ha": 745, - "x_min": 106, - "x_max": 732, - "o": "m 107 252 q 107 254 107 253 q 106 255 106 254 q 119 267 106 267 q 132 260 125 267 q 214 205 169 226 q 311 185 258 185 q 344 188 326 185 q 378 198 362 191 q 406 217 395 205 q 417 246 417 229 q 408 281 417 266 q 382 308 398 297 q 364 321 376 312 q 336 343 352 331 q 304 369 321 355 q 272 396 287 383 q 244 418 256 408 q 226 434 232 429 q 162 494 186 464 q 127 558 139 525 q 111 627 115 591 q 108 703 108 663 q 136 816 108 762 q 217 909 165 869 q 341 972 269 949 q 503 996 414 996 q 535 993 513 996 q 583 985 557 991 q 636 970 609 980 q 686 946 663 961 q 697 935 693 941 q 703 918 702 930 q 709 810 707 863 q 714 697 711 757 q 709 682 714 686 q 697 678 705 678 q 686 682 690 678 q 645 721 666 702 q 601 754 624 740 q 552 778 578 769 q 495 787 526 787 q 458 784 477 787 q 425 772 440 781 q 401 750 410 764 q 392 714 392 736 q 398 674 392 691 q 427 642 404 657 l 589 532 q 662 468 634 500 q 705 406 690 437 q 727 344 721 374 q 732 285 732 314 q 717 195 732 237 q 674 118 701 153 q 611 54 647 82 q 533 6 574 26 q 447 -25 492 -14 q 360 -35 403 -35 q 295 -34 327 -35 q 232 -29 262 -33 q 173 -15 201 -24 q 119 10 144 -6 l 107 252 m 342 -602 q 330 -596 334 -598 q 318 -591 326 -595 q 295 -579 310 -587 q 250 -555 279 -571 q 229 -536 229 -543 q 231 -530 229 -534 q 272 -466 250 -500 q 313 -398 293 -433 l 255 -397 l 243 -397 q 227 -396 233 -397 q 221 -391 221 -395 l 221 -389 q 225 -343 224 -360 q 228 -318 227 -327 q 229 -304 229 -309 q 230 -297 229 -300 q 230 -289 230 -294 q 231 -273 231 -284 q 234 -241 232 -261 q 238 -188 235 -221 q 242 -157 239 -165 q 258 -146 245 -148 q 321 -146 288 -146 q 388 -145 355 -146 q 453 -145 420 -145 q 515 -145 485 -145 q 526 -161 526 -145 l 514 -327 q 510 -353 512 -342 q 507 -371 509 -363 q 503 -388 505 -380 q 497 -407 500 -396 q 484 -432 493 -416 q 462 -465 474 -447 q 436 -500 450 -482 q 412 -534 423 -518 q 391 -562 400 -550 q 380 -577 382 -573 q 375 -584 378 -580 q 368 -593 372 -589 q 359 -601 363 -597 q 349 -604 354 -604 q 342 -602 346 -604 z " - }, - "ș": { - "ha": 584, - "x_min": 84, - "x_max": 568, - "o": "m 85 187 q 84 188 85 188 q 84 189 84 189 q 94 198 84 198 q 104 193 100 198 q 166 151 132 168 q 242 135 201 135 q 267 137 253 135 q 294 145 281 140 q 316 160 307 151 q 324 182 324 169 q 317 210 324 197 q 297 231 309 222 q 273 247 290 235 q 237 273 256 259 q 200 298 218 286 q 176 316 183 311 q 128 363 146 339 q 100 412 110 387 q 88 465 91 437 q 85 524 85 493 q 111 614 85 572 q 177 688 136 656 q 270 738 218 720 q 376 757 322 757 q 465 743 421 757 q 545 697 508 730 q 550 613 549 654 q 554 526 551 572 q 550 514 554 517 q 541 511 546 511 q 532 515 536 511 q 500 544 517 530 q 466 570 484 559 q 428 588 448 581 q 385 595 408 595 q 356 593 370 595 q 330 584 342 591 q 312 567 319 578 q 304 539 304 556 q 309 505 304 519 q 332 477 314 491 l 458 392 q 514 346 492 368 q 547 300 535 323 q 564 256 559 278 q 568 212 568 234 q 540 105 568 151 q 467 27 512 58 q 366 -19 422 -3 q 252 -35 309 -35 q 169 -26 209 -35 q 94 2 128 -17 l 85 187 m 260 -602 q 248 -596 252 -598 q 236 -591 243 -595 q 213 -579 228 -587 q 168 -555 197 -571 q 146 -536 146 -543 q 149 -530 146 -534 q 190 -466 168 -500 q 231 -398 211 -433 l 173 -397 l 161 -397 q 145 -396 151 -397 q 139 -391 139 -395 l 139 -389 q 143 -343 142 -360 q 146 -318 145 -327 q 147 -304 146 -309 q 148 -297 147 -300 q 148 -289 148 -294 q 149 -273 149 -284 q 152 -241 150 -261 q 156 -188 153 -221 q 160 -157 157 -165 q 176 -146 163 -148 q 239 -146 206 -146 q 306 -145 273 -146 q 371 -145 338 -145 q 433 -145 403 -145 q 444 -161 444 -145 l 432 -327 q 428 -353 430 -342 q 425 -371 427 -363 q 421 -388 423 -380 q 415 -407 418 -396 q 401 -432 411 -416 q 380 -465 392 -447 q 354 -500 368 -482 q 330 -534 341 -518 q 309 -562 318 -550 q 298 -577 300 -573 q 293 -584 296 -580 q 286 -593 290 -589 q 277 -601 281 -597 q 267 -604 272 -604 q 260 -602 264 -604 z " - }, - "Ț": { - "ha": 786, - "x_min": 58, - "x_max": 886, - "o": "m 243 -22 q 250 74 246 28 q 256 163 253 120 l 280 484 q 287 550 284 520 q 291 609 290 581 q 295 668 293 638 q 298 733 296 697 q 251 734 276 734 q 199 734 227 734 l 68 734 q 59 740 61 734 q 58 750 58 745 l 58 755 l 132 951 l 132 954 q 136 959 132 957 q 156 963 140 962 q 337 974 250 968 q 511 983 425 979 q 683 991 597 987 q 859 998 768 995 q 877 996 867 998 q 886 981 886 994 q 885 979 886 980 q 884 976 884 977 q 864 923 873 948 q 846 873 855 898 q 828 824 838 849 q 808 771 819 799 q 806 765 808 770 q 800 752 804 759 q 789 739 795 745 q 772 732 782 732 q 765 732 768 732 q 758 732 762 732 l 576 732 q 570 659 573 698 q 563 584 567 621 l 513 54 q 511 42 513 48 q 502 33 509 36 l 310 -36 q 290 -43 302 -39 q 267 -47 278 -47 q 250 -42 257 -47 q 243 -24 243 -37 l 243 -22 m 432 -602 q 420 -596 425 -598 q 408 -591 416 -595 q 385 -579 400 -587 q 340 -555 370 -571 q 319 -536 319 -543 q 321 -530 319 -534 q 362 -466 340 -500 q 403 -398 383 -433 l 345 -397 l 333 -397 q 317 -396 323 -397 q 311 -391 311 -395 l 311 -389 q 316 -343 314 -360 q 318 -318 317 -327 q 319 -304 319 -309 q 320 -297 319 -300 q 320 -289 320 -294 q 321 -273 321 -284 q 324 -241 322 -261 q 328 -188 326 -221 q 333 -157 330 -165 q 348 -146 336 -148 q 412 -146 378 -146 q 478 -145 445 -146 q 543 -145 511 -145 q 605 -145 575 -145 q 616 -161 616 -145 l 604 -327 q 601 -353 602 -342 q 597 -371 599 -363 q 593 -388 595 -380 q 587 -407 591 -396 q 574 -432 583 -416 q 552 -465 564 -447 q 527 -500 540 -482 q 502 -534 513 -518 q 481 -562 490 -550 q 470 -577 473 -573 q 465 -584 468 -580 q 458 -593 462 -589 q 449 -601 454 -597 q 439 -604 444 -604 q 432 -602 436 -604 z " - }, - "ț": { - "ha": 633, - "x_min": 51, - "x_max": 659, - "o": "m 447 523 q 429 381 437 452 q 418 248 420 310 q 422 204 418 222 q 434 176 427 186 q 453 162 442 166 q 477 157 464 157 q 525 164 499 157 q 576 180 551 170 q 590 185 585 184 q 600 187 596 187 q 609 181 607 187 q 614 160 612 175 q 621 119 616 144 q 637 54 626 93 q 638 48 637 50 q 638 43 638 45 q 631 30 638 34 q 608 20 624 26 q 549 1 580 11 q 488 -17 518 -9 q 430 -30 458 -25 q 381 -35 402 -35 q 216 21 268 -35 q 164 193 164 77 q 165 233 164 212 q 169 276 167 254 q 181 405 176 344 q 191 521 186 465 l 120 521 q 67 524 83 521 q 51 536 51 527 q 58 551 51 539 q 75 579 64 563 q 98 615 85 596 q 121 651 110 634 q 140 680 132 667 q 151 694 149 692 l 199 694 q 209 781 205 746 q 215 839 212 816 q 219 874 217 862 q 223 893 221 887 q 230 901 226 899 q 239 904 233 903 q 298 915 270 910 q 355 926 327 920 q 413 938 384 931 q 475 955 443 945 q 477 955 477 955 q 480 956 478 956 q 488 950 488 956 l 488 949 q 478 845 485 911 q 462 694 471 779 l 644 694 q 654 691 649 694 q 659 678 659 687 q 651 654 659 675 q 628 599 643 633 l 604 544 q 594 529 599 534 q 573 523 589 524 l 447 523 m 327 -602 q 315 -596 319 -598 q 303 -591 311 -595 q 280 -579 295 -587 q 235 -555 264 -571 q 214 -536 214 -543 q 216 -530 214 -534 q 257 -466 235 -500 q 298 -398 278 -433 l 240 -397 l 228 -397 q 212 -396 218 -397 q 206 -391 206 -395 l 206 -389 q 211 -343 209 -360 q 213 -318 212 -327 q 214 -304 214 -309 q 215 -297 214 -300 q 215 -289 215 -294 q 216 -273 216 -284 q 219 -241 217 -261 q 223 -188 220 -221 q 228 -157 224 -165 q 243 -146 231 -148 q 307 -146 273 -146 q 373 -145 340 -146 q 438 -145 406 -145 q 500 -145 470 -145 q 511 -161 511 -145 l 499 -327 q 495 -353 497 -342 q 492 -371 494 -363 q 488 -388 490 -380 q 482 -407 486 -396 q 469 -432 478 -416 q 447 -465 459 -447 q 421 -500 435 -482 q 397 -534 408 -518 q 376 -562 385 -550 q 365 -577 368 -573 q 360 -584 363 -580 q 353 -593 357 -589 q 344 -601 349 -597 q 334 -604 339 -604 q 327 -602 331 -604 z " - }, - "ˆ": { - "ha": 716, - "x_min": 27, - "x_max": 678, - "o": "m 549 1127 q 575 1095 564 1109 q 593 1069 585 1080 q 608 1047 602 1057 q 623 1024 615 1036 q 636 1006 627 1018 q 655 980 646 994 q 671 952 664 966 q 678 930 678 939 q 665 911 678 920 q 633 892 652 901 q 596 876 615 884 q 567 865 578 869 q 546 856 557 861 q 524 844 535 850 q 504 835 513 839 q 490 831 494 831 q 478 837 484 831 q 464 858 473 843 l 376 1044 q 294 941 335 991 q 212 838 253 890 q 203 833 209 833 q 187 839 199 833 q 157 852 174 844 q 123 869 140 860 q 92 884 105 878 q 73 892 84 887 q 52 903 62 897 q 34 913 41 908 q 27 924 27 919 q 33 939 27 930 q 53 961 39 948 l 155 1076 q 231 1160 194 1119 q 304 1243 267 1200 q 322 1254 313 1253 q 339 1255 332 1255 l 442 1255 q 458 1253 450 1255 q 472 1242 467 1252 q 481 1229 473 1241 q 500 1199 489 1217 q 525 1162 512 1182 q 549 1127 538 1143 z " - }, - "ˇ": { - "ha": 718, - "x_min": 38, - "x_max": 688, - "o": "m 168 968 q 132 1015 146 996 q 107 1050 119 1034 q 83 1086 96 1067 q 50 1135 71 1105 q 41 1152 43 1145 q 38 1165 38 1160 q 60 1187 38 1175 q 112 1213 82 1200 q 172 1238 142 1226 q 218 1258 202 1250 q 226 1260 222 1260 q 236 1255 231 1260 q 247 1239 240 1251 l 346 1063 l 509 1256 q 515 1259 511 1259 q 527 1256 519 1259 q 551 1245 535 1254 q 616 1213 585 1226 q 682 1181 648 1199 q 688 1171 688 1179 q 683 1156 688 1165 q 664 1135 677 1147 q 535 992 599 1063 q 410 851 472 921 q 396 842 404 844 q 382 840 389 840 l 373 840 l 268 840 q 256 842 262 840 q 246 851 250 844 q 237 865 245 852 q 217 895 229 878 q 192 932 205 913 q 168 968 178 952 z " - }, - "˘": { - "ha": 481, - "x_min": 51, - "x_max": 437, - "o": "m 315 991 q 317 998 315 995 q 326 1004 319 1002 q 344 1008 332 1006 q 376 1009 356 1009 q 408 1008 396 1009 q 427 1005 420 1007 q 435 1000 433 1003 q 437 992 437 997 q 421 928 437 960 q 378 871 406 896 q 312 831 350 846 q 230 815 274 815 q 161 823 194 815 q 104 847 129 831 q 65 886 80 863 q 51 939 51 909 q 52 952 51 945 q 54 968 53 959 q 58 985 56 978 q 66 997 60 992 q 87 1003 73 1001 q 126 1006 100 1006 q 151 1005 142 1006 q 165 1002 160 1004 q 172 998 170 1000 q 173 992 173 995 q 172 986 173 991 q 172 975 172 981 q 174 956 172 966 q 184 939 177 947 q 203 926 191 931 q 234 921 216 921 q 270 927 254 921 q 295 942 285 932 q 310 961 305 951 q 315 982 315 972 l 315 991 l 315 991 z " - }, - "˙": { - "ha": 393, - "x_min": 50, - "x_max": 341, - "o": "m 50 949 q 52 1000 51 981 q 53 1029 52 1019 q 53 1043 53 1039 q 53 1051 53 1047 q 53 1060 53 1055 q 54 1078 54 1065 q 56 1113 55 1090 q 60 1171 58 1135 q 64 1202 61 1194 q 79 1213 67 1211 q 204 1213 139 1213 q 327 1214 269 1213 q 337 1211 333 1214 q 341 1198 341 1207 l 322 985 q 317 954 319 962 q 302 944 315 945 q 183 943 244 943 q 57 942 123 942 q 51 943 53 942 q 50 947 50 943 l 50 949 z " - }, - "˚": { - "ha": 481, - "x_min": 50, - "x_max": 431, - "o": "m 239 808 q 164 821 199 808 q 104 856 130 833 q 64 912 79 879 q 50 988 50 945 q 65 1061 50 1027 q 108 1122 81 1096 q 172 1163 135 1147 q 252 1178 209 1178 q 322 1166 289 1178 q 379 1131 355 1154 q 417 1077 404 1109 q 431 1006 431 1045 q 418 934 431 970 q 379 870 404 899 q 319 825 355 842 q 239 808 283 808 m 309 989 q 310 996 310 992 q 310 1002 310 999 q 307 1028 310 1015 q 298 1054 304 1042 q 280 1074 291 1066 q 253 1081 269 1081 q 214 1073 231 1081 q 187 1051 197 1064 q 171 1021 176 1038 q 166 987 166 1004 q 169 961 166 975 q 178 935 172 947 q 197 916 185 924 q 227 907 208 908 q 261 915 247 907 q 286 933 276 922 q 301 960 296 945 q 309 989 307 975 z " - }, - "˛": { - "ha": 369, - "x_min": 34, - "x_max": 328, - "o": "m 34 -262 q 52 -185 37 -221 q 92 -117 68 -149 q 145 -60 115 -86 q 206 -12 175 -33 l 263 -12 q 304 -12 285 -12 q 328 -12 323 -12 q 279 -61 304 -36 q 230 -113 253 -85 q 187 -173 206 -141 q 159 -241 168 -204 q 157 -256 157 -249 q 169 -285 157 -273 q 205 -297 181 -297 q 236 -296 223 -297 q 261 -293 250 -295 q 284 -288 273 -291 q 309 -279 295 -284 q 307 -306 309 -289 q 304 -339 306 -322 q 299 -368 302 -355 q 295 -383 297 -381 l 296 -382 q 237 -400 270 -396 q 176 -404 204 -404 q 116 -394 142 -404 q 72 -365 90 -383 q 44 -320 54 -346 q 34 -262 34 -294 z " - }, - "˜": { - "ha": 760, - "x_min": 43, - "x_max": 719, - "o": "m 456 1071 q 480 1046 469 1053 q 506 1038 491 1038 q 536 1049 527 1038 q 549 1075 545 1061 q 555 1100 553 1088 q 563 1111 557 1111 q 574 1111 564 1111 q 598 1112 584 1112 q 629 1114 612 1113 q 661 1115 646 1114 q 687 1117 676 1116 q 701 1117 699 1117 q 713 1114 707 1117 q 719 1104 719 1112 q 702 1005 719 1055 q 653 915 684 956 q 577 849 621 874 q 479 823 533 823 q 436 827 458 823 q 394 843 415 831 q 351 874 372 854 q 307 926 329 894 q 282 947 295 943 q 252 951 270 951 q 226 945 236 951 q 210 927 216 938 q 201 903 203 916 q 199 877 199 890 q 193 866 199 871 q 179 861 188 861 q 144 861 157 861 q 120 860 131 861 q 96 860 109 860 q 63 859 83 859 q 49 862 56 859 q 43 871 43 865 q 61 987 43 935 q 111 1077 79 1040 q 184 1135 142 1114 q 275 1156 227 1156 q 325 1154 302 1156 q 371 1143 349 1152 q 413 1118 393 1135 q 456 1071 434 1101 z " - }, - "˝": { - "ha": 861, - "x_min": 32, - "x_max": 864, - "o": "m 255 944 q 205 876 225 903 q 172 833 185 849 q 152 812 159 818 q 140 806 144 806 q 133 808 136 806 q 107 825 119 818 q 85 838 96 832 q 65 849 75 844 q 41 861 54 854 q 32 875 32 866 q 34 888 33 880 q 40 907 36 895 l 165 1271 q 172 1284 169 1280 q 180 1287 176 1287 q 186 1285 183 1287 q 193 1282 190 1284 q 299 1221 246 1246 q 403 1168 351 1195 q 415 1149 415 1160 q 404 1122 415 1139 q 360 1071 377 1091 q 327 1033 342 1051 q 296 994 312 1015 q 255 944 279 974 m 667 944 q 605 876 630 903 q 564 833 580 849 q 540 812 549 818 q 527 806 532 806 q 521 808 523 806 q 494 827 506 819 q 472 842 482 836 q 450 854 461 848 q 425 867 439 861 q 418 879 418 873 q 421 892 418 884 q 432 913 425 900 l 608 1284 q 618 1297 613 1294 q 626 1301 623 1301 q 638 1295 631 1301 q 746 1227 690 1257 q 854 1168 802 1198 q 861 1161 859 1164 q 864 1153 864 1158 q 860 1139 864 1147 q 847 1122 857 1131 q 795 1070 816 1091 q 755 1032 774 1050 q 717 994 737 1014 q 667 944 696 974 z " - }, - "̏": { - "ha": 725, - "x_min": 30, - "x_max": 681, - "o": "m 469 968 q 449 1015 457 996 q 434 1052 441 1034 q 419 1088 427 1069 q 400 1135 412 1107 q 398 1147 399 1142 q 397 1156 397 1152 q 401 1172 397 1166 q 414 1181 405 1177 q 520 1239 465 1210 q 627 1305 576 1269 q 630 1307 627 1307 q 633 1308 633 1308 q 635 1309 634 1308 q 636 1309 635 1309 q 642 1303 642 1309 l 680 907 q 681 896 680 901 q 681 888 681 891 q 678 871 681 876 q 667 861 675 866 q 638 849 651 854 q 613 838 625 844 q 586 825 600 832 q 553 808 572 818 q 545 806 551 806 q 533 815 539 806 q 518 843 527 824 q 498 893 510 863 q 469 968 486 924 m 130 968 q 103 1015 114 996 q 83 1051 93 1034 q 62 1087 73 1068 q 37 1135 52 1107 q 31 1150 33 1143 q 30 1162 30 1157 q 33 1174 30 1169 q 43 1181 37 1178 q 96 1210 68 1196 q 151 1240 123 1225 q 207 1272 179 1255 q 259 1305 234 1288 q 269 1309 266 1309 q 274 1303 273 1309 l 350 907 q 353 892 351 898 q 354 881 354 886 q 352 869 354 875 q 343 861 350 864 q 317 849 329 854 q 293 838 305 844 q 268 825 281 832 q 238 808 254 818 q 231 806 235 806 q 217 815 224 806 q 198 843 210 824 q 171 893 187 863 q 130 968 154 924 z " - }, - "̑": { - "ha": 462, - "x_min": 39, - "x_max": 418, - "o": "m 296 833 q 297 842 296 837 q 298 852 298 846 q 281 887 298 870 q 228 903 263 903 q 192 897 206 903 q 168 880 177 890 q 156 858 159 869 q 153 836 153 846 q 153 835 153 836 q 153 834 153 835 q 151 828 153 831 q 144 823 149 825 q 130 820 139 821 q 103 819 120 819 q 67 820 80 819 q 48 826 54 822 q 40 836 41 830 q 39 850 39 842 q 55 917 39 888 q 99 967 71 947 q 164 998 127 987 q 245 1009 202 1009 q 324 995 291 1009 q 378 956 357 980 q 409 902 399 932 q 418 840 418 871 q 417 829 418 833 q 408 821 415 824 q 389 817 401 818 q 353 815 376 815 q 323 816 334 815 q 306 819 312 817 q 297 823 299 821 q 295 829 295 826 q 295 831 295 831 q 296 833 296 832 z " - }, - "̦": { - "ha": 379, - "x_min": 43, - "x_max": 349, - "o": "m 164 -602 q 152 -596 157 -598 q 140 -591 148 -595 q 117 -579 132 -587 q 73 -555 102 -571 q 51 -536 51 -543 q 53 -530 51 -534 q 94 -466 73 -500 q 135 -398 115 -433 l 77 -397 l 65 -397 q 50 -396 56 -397 q 43 -391 43 -395 l 43 -389 q 48 -343 46 -360 q 50 -318 50 -327 q 51 -304 51 -309 q 52 -297 52 -300 q 53 -289 52 -294 q 54 -273 53 -284 q 56 -241 54 -261 q 60 -188 58 -221 q 65 -157 62 -165 q 80 -146 68 -148 q 144 -146 111 -146 q 210 -145 177 -146 q 275 -145 243 -145 q 337 -145 307 -145 q 349 -161 349 -145 l 336 -327 q 333 -353 334 -342 q 329 -371 331 -363 q 325 -388 328 -380 q 319 -407 323 -396 q 306 -432 315 -416 q 284 -465 296 -447 q 259 -500 272 -482 q 234 -534 245 -518 q 214 -562 222 -550 q 202 -577 205 -573 q 197 -584 200 -580 q 190 -593 194 -589 q 181 -601 186 -597 q 172 -604 176 -604 q 164 -602 168 -604 z " - }, - "Δ": { - "ha": 868, - "x_min": 56, - "x_max": 838, - "o": "m 71 88 q 83 126 74 99 q 107 193 93 154 q 139 281 121 232 q 177 382 157 330 q 218 489 197 435 q 259 595 239 544 q 297 691 279 646 q 331 770 316 736 q 340 782 334 777 q 354 792 347 788 q 369 799 361 796 q 380 803 376 802 q 404 809 384 804 q 447 821 423 814 q 495 831 471 827 q 530 836 518 836 q 553 832 541 836 q 570 811 566 829 q 640 623 605 720 q 709 427 675 526 q 776 231 743 328 q 838 41 808 133 l 838 43 q 838 35 838 41 q 837 21 838 28 q 834 8 836 14 q 830 2 833 2 q 595 1 706 2 q 391 0 485 1 q 221 -2 297 -1 q 92 -4 146 -3 q 64 4 73 -2 q 56 25 56 10 q 71 88 56 46 m 435 532 l 389 384 q 371 327 380 355 q 355 275 362 299 q 343 235 348 252 q 337 212 338 218 q 337 206 337 208 q 336 200 337 203 l 499 200 q 483 276 492 235 q 466 360 475 317 q 450 447 458 404 q 435 532 441 491 z " - }, - "∆": { - "ha": 868, - "x_min": 56, - "x_max": 838, - "o": "m 71 88 q 83 126 74 99 q 107 193 93 154 q 139 281 121 232 q 177 382 157 330 q 218 489 197 435 q 259 595 239 544 q 297 691 279 646 q 331 770 316 736 q 340 782 334 777 q 354 792 347 788 q 369 799 361 796 q 380 803 376 802 q 404 809 384 804 q 447 821 423 814 q 495 831 471 827 q 530 836 518 836 q 553 832 541 836 q 570 811 566 829 q 640 623 605 720 q 709 427 675 526 q 776 231 743 328 q 838 41 808 133 l 838 43 q 838 35 838 41 q 837 21 838 28 q 834 8 836 14 q 830 2 833 2 q 595 1 706 2 q 391 0 485 1 q 221 -2 297 -1 q 92 -4 146 -3 q 64 4 73 -2 q 56 25 56 10 q 71 88 56 46 m 435 532 l 389 384 q 371 327 380 355 q 355 275 362 299 q 343 235 348 252 q 337 212 338 218 q 337 206 337 208 q 336 200 337 203 l 499 200 q 483 276 492 235 q 466 360 475 317 q 450 447 458 404 q 435 532 441 491 z " - }, - "–": { - "ha": 683, - "x_min": 76, - "x_max": 673, - "o": "m 176 351 q 99 354 123 351 q 76 367 76 357 q 80 384 76 372 q 92 408 85 395 q 109 436 100 421 q 130 462 119 450 q 152 482 140 474 q 173 490 163 490 l 412 497 q 439 497 420 497 q 483 498 458 498 q 534 499 507 498 q 584 500 561 500 q 622 501 606 500 q 641 501 638 501 q 657 498 650 500 q 668 491 663 495 q 673 477 673 486 q 671 451 673 469 q 667 416 669 433 l 661 370 q 659 363 660 366 q 654 359 658 361 q 645 356 651 357 q 627 355 638 355 l 545 355 q 509 355 528 355 q 473 354 491 355 q 439 354 456 354 q 410 354 422 354 l 176 351 z " - }, - "—": { - "ha": 926, - "x_min": 76, - "x_max": 917, - "o": "m 176 351 q 99 354 123 351 q 76 368 76 358 q 80 384 76 373 q 92 409 85 395 q 109 436 100 422 q 130 463 119 451 q 152 483 140 475 q 173 491 163 490 l 498 497 q 537 497 506 497 q 610 498 568 498 q 699 499 652 499 q 786 500 746 500 q 854 502 827 501 q 884 502 882 502 q 901 498 893 501 q 912 491 907 496 q 917 478 917 487 q 915 452 917 469 q 910 416 913 434 l 904 371 q 902 364 903 367 q 898 359 901 361 q 888 356 895 357 q 871 355 882 355 l 709 355 q 645 355 677 355 q 584 355 613 355 q 532 354 555 355 q 496 354 509 354 l 176 351 z " - }, - "‘": { - "ha": 389, - "x_min": 107, - "x_max": 412, - "o": "m 292 1056 q 303 1049 299 1051 q 315 1044 307 1047 q 338 1033 323 1040 q 383 1008 353 1025 q 405 989 405 997 q 403 984 405 987 q 362 920 383 954 q 321 852 340 886 l 378 851 q 401 851 391 851 q 412 844 412 850 l 412 843 q 407 787 409 804 q 405 762 406 769 q 404 751 404 754 q 403 739 404 748 q 400 707 402 729 q 395 642 399 686 q 390 610 393 619 q 376 600 387 602 q 312 600 345 600 q 246 599 279 600 q 180 599 213 599 q 119 599 148 599 q 107 615 107 599 l 119 781 q 123 806 121 796 q 126 825 125 817 q 131 842 128 833 q 136 861 133 850 q 150 885 140 870 q 171 918 159 901 q 196 954 183 936 q 221 988 209 972 q 241 1016 233 1004 q 254 1031 250 1027 q 259 1038 256 1033 q 266 1047 262 1042 q 274 1055 269 1051 q 284 1058 279 1058 q 292 1056 288 1058 z " - }, - "’": { - "ha": 370, - "x_min": 109, - "x_max": 414, - "o": "m 230 524 q 218 530 222 528 q 206 536 214 532 q 183 548 198 540 q 138 572 168 555 q 117 591 117 583 q 119 596 117 593 q 160 660 138 627 q 201 728 181 694 l 143 729 l 131 729 q 115 730 121 729 q 109 736 109 731 l 109 737 q 114 783 112 766 q 116 809 115 800 q 117 822 117 818 q 118 829 117 826 q 118 838 118 833 q 119 854 119 842 q 122 885 120 865 q 126 939 123 905 q 131 970 127 961 q 146 980 134 979 q 210 980 176 980 q 276 981 243 981 q 341 981 309 981 q 403 981 373 981 q 414 965 414 981 l 402 800 q 398 774 400 784 q 395 755 397 764 q 391 739 393 747 q 385 720 389 730 q 372 695 381 710 q 350 662 362 680 q 325 626 338 644 q 300 592 311 608 q 279 565 288 576 q 268 549 271 553 q 263 542 266 547 q 256 533 260 538 q 247 526 252 529 q 237 522 242 522 q 230 524 234 522 z " - }, - "‚": { - "ha": 398, - "x_min": 56, - "x_max": 361, - "o": "m 176 -225 q 164 -219 169 -221 q 152 -214 160 -218 q 129 -202 144 -210 q 85 -178 114 -194 q 63 -159 63 -166 q 65 -153 63 -157 q 106 -89 85 -123 q 147 -21 127 -56 l 90 -20 l 77 -20 q 62 -19 68 -20 q 56 -14 56 -18 l 56 -12 q 60 34 58 17 q 62 59 62 50 q 63 73 63 68 q 64 80 64 77 q 65 88 64 83 q 66 104 65 93 q 68 136 66 116 q 73 189 70 156 q 77 220 74 212 q 92 231 80 229 q 156 231 123 231 q 222 232 189 231 q 287 232 255 232 q 349 232 319 232 q 361 216 361 232 l 349 50 q 345 24 347 35 q 341 6 343 14 q 337 -11 340 -3 q 332 -30 335 -19 q 318 -55 328 -39 q 296 -87 309 -70 q 271 -123 284 -105 q 246 -157 258 -141 q 226 -184 235 -173 q 214 -200 217 -196 q 209 -207 212 -203 q 202 -216 206 -212 q 193 -224 198 -220 q 184 -227 189 -227 q 176 -225 180 -227 z " - }, - "“": { - "ha": 747, - "x_min": 107, - "x_max": 770, - "o": "m 649 1056 q 661 1049 656 1051 q 672 1044 665 1047 q 695 1033 680 1040 q 741 1008 711 1025 q 762 989 762 997 q 760 984 762 987 q 719 920 741 954 q 678 852 698 886 l 736 851 q 759 851 748 851 q 770 844 770 850 l 770 843 q 765 787 766 804 q 762 762 763 769 q 761 751 762 754 q 760 739 761 748 q 758 707 760 729 q 753 642 756 686 q 748 610 751 619 q 733 600 745 602 q 669 600 703 600 q 603 599 636 600 q 538 599 570 599 q 476 599 505 599 q 465 615 465 599 l 477 781 q 480 806 479 796 q 484 825 482 817 q 488 842 486 833 q 494 861 490 850 q 507 885 498 870 q 529 918 517 901 q 553 954 541 936 q 578 988 566 972 q 599 1016 590 1004 q 611 1031 608 1027 q 616 1038 613 1033 q 623 1047 619 1042 q 631 1055 627 1051 q 642 1058 636 1058 q 649 1056 645 1058 m 292 1056 q 303 1049 299 1051 q 315 1044 307 1047 q 338 1033 323 1040 q 383 1008 353 1025 q 405 989 405 997 q 403 984 405 987 q 362 920 383 954 q 321 852 340 886 l 378 851 q 401 851 391 851 q 412 844 412 850 l 412 843 q 407 787 409 804 q 405 762 406 769 q 404 751 404 754 q 403 739 404 748 q 400 707 402 729 q 395 642 399 686 q 390 610 393 619 q 376 600 387 602 q 312 600 345 600 q 246 599 279 600 q 180 599 213 599 q 119 599 148 599 q 107 615 107 599 l 119 781 q 123 806 121 796 q 126 825 125 817 q 131 842 128 833 q 136 861 133 850 q 150 885 140 870 q 171 918 159 901 q 196 954 183 936 q 221 988 209 972 q 241 1016 233 1004 q 254 1031 250 1027 q 259 1038 256 1033 q 266 1047 262 1042 q 274 1055 269 1051 q 284 1058 279 1058 q 292 1056 288 1058 z " - }, - "”": { - "ha": 727, - "x_min": 109, - "x_max": 771, - "o": "m 587 524 q 575 530 579 528 q 563 536 570 532 q 539 548 555 540 q 495 572 524 555 q 473 591 473 583 q 475 596 473 593 q 516 660 495 627 q 557 728 538 694 l 500 729 l 488 729 q 472 730 478 729 q 466 736 466 731 l 466 737 q 470 783 469 766 q 473 809 472 800 q 474 822 473 818 q 474 829 474 826 q 475 838 475 833 q 476 854 475 842 q 478 885 477 865 q 483 939 480 905 q 487 970 484 961 q 503 980 490 979 q 566 980 533 980 q 632 981 600 981 q 697 981 665 981 q 760 981 730 981 q 771 965 771 981 l 759 800 q 755 774 757 784 q 752 755 753 764 q 748 739 750 747 q 742 720 745 730 q 728 695 738 710 q 707 662 719 680 q 681 626 694 644 q 656 592 668 608 q 636 565 645 576 q 625 549 627 553 q 620 542 623 547 q 612 533 616 538 q 604 526 608 529 q 594 522 599 522 q 587 524 591 522 m 230 524 q 218 530 222 528 q 206 536 214 532 q 183 548 198 540 q 138 572 168 555 q 117 591 117 583 q 119 596 117 593 q 160 660 138 627 q 201 728 181 694 l 143 729 l 131 729 q 115 730 121 729 q 109 736 109 731 l 109 737 q 114 783 112 766 q 116 809 115 800 q 117 822 117 818 q 118 829 117 826 q 118 838 118 833 q 119 854 119 842 q 122 885 120 865 q 126 939 123 905 q 131 970 127 961 q 146 980 134 979 q 210 980 176 980 q 276 981 243 981 q 341 981 309 981 q 403 981 373 981 q 414 965 414 981 l 402 800 q 398 774 400 784 q 395 755 397 764 q 391 739 393 747 q 385 720 389 730 q 372 695 381 710 q 350 662 362 680 q 325 626 338 644 q 300 592 311 608 q 279 565 288 576 q 268 549 271 553 q 263 542 266 547 q 256 533 260 538 q 247 526 252 529 q 237 522 242 522 q 230 524 234 522 z " - }, - "„": { - "ha": 781, - "x_min": 56, - "x_max": 745, - "o": "m 560 -225 q 548 -219 553 -221 q 536 -214 544 -218 q 513 -202 528 -210 q 469 -178 498 -194 q 447 -159 447 -166 q 449 -153 447 -157 q 490 -89 469 -123 q 531 -21 511 -56 l 473 -20 l 461 -20 q 446 -19 452 -20 q 439 -14 439 -18 l 439 -12 q 444 34 442 17 q 446 59 446 50 q 447 73 447 68 q 448 80 448 77 q 449 88 448 83 q 450 104 449 93 q 452 136 450 116 q 456 189 454 156 q 461 220 458 212 q 476 231 464 229 q 540 231 507 231 q 606 232 573 231 q 671 232 639 232 q 733 232 703 232 q 745 216 745 232 l 732 50 q 729 24 730 35 q 725 6 727 14 q 721 -11 724 -3 q 715 -30 719 -19 q 702 -55 711 -39 q 680 -87 692 -70 q 655 -123 668 -105 q 630 -157 642 -141 q 610 -184 618 -173 q 598 -200 601 -196 q 593 -207 596 -203 q 586 -216 590 -212 q 577 -224 582 -220 q 568 -227 572 -227 q 560 -225 564 -227 m 176 -225 q 164 -219 169 -221 q 152 -214 160 -218 q 129 -202 144 -210 q 85 -178 114 -194 q 63 -159 63 -166 q 65 -153 63 -157 q 106 -89 85 -123 q 147 -21 127 -56 l 90 -20 l 77 -20 q 62 -19 68 -20 q 56 -14 56 -18 l 56 -12 q 60 34 58 17 q 62 59 62 50 q 63 73 63 68 q 64 80 64 77 q 65 88 64 83 q 66 104 65 93 q 68 136 66 116 q 73 189 70 156 q 77 220 74 212 q 92 231 80 229 q 156 231 123 231 q 222 232 189 231 q 287 232 255 232 q 349 232 319 232 q 361 216 361 232 l 349 50 q 345 24 347 35 q 341 6 343 14 q 337 -11 340 -3 q 332 -30 335 -19 q 318 -55 328 -39 q 296 -87 309 -70 q 271 -123 284 -105 q 246 -157 258 -141 q 226 -184 235 -173 q 214 -200 217 -196 q 209 -207 212 -203 q 202 -216 206 -212 q 193 -224 198 -220 q 184 -227 189 -227 q 176 -225 180 -227 z " - }, - "†": { - "ha": 612, - "x_min": 91, - "x_max": 640, - "o": "m 437 623 l 406 96 q 406 87 406 91 q 406 81 406 83 q 403 73 406 75 q 389 66 400 70 l 309 68 q 299 67 307 68 q 283 66 292 67 q 267 65 275 66 q 255 65 258 65 q 245 69 250 65 q 241 84 241 73 l 241 87 q 244 144 242 117 q 248 199 245 172 q 252 253 250 226 q 256 311 254 281 q 261 382 258 342 q 265 465 263 422 q 270 547 267 507 q 274 621 272 588 l 190 621 l 172 621 q 110 624 128 621 q 91 638 91 627 q 93 659 91 646 q 97 687 94 672 q 102 718 99 703 q 109 745 106 733 q 119 754 115 750 q 140 760 123 759 l 222 762 q 238 763 222 762 q 279 764 254 764 l 292 933 q 295 961 293 954 q 304 971 296 968 q 451 979 380 975 q 454 980 452 980 q 459 974 459 980 l 446 768 q 551 769 513 768 q 608 771 589 771 q 624 768 616 770 q 635 761 630 765 q 640 747 640 756 q 638 721 640 739 q 633 686 636 703 l 627 640 q 626 633 627 636 q 621 629 625 631 q 611 626 618 627 q 594 625 605 625 q 585 624 594 625 q 558 624 575 624 q 518 624 541 624 q 468 623 495 623 l 437 623 z " - }, - "‡": { - "ha": 684, - "x_min": 68, - "x_max": 692, - "o": "m 465 236 l 457 109 q 457 101 457 104 q 458 94 458 97 q 455 86 458 89 q 441 79 452 83 l 333 20 q 321 15 328 18 q 307 11 314 11 q 297 15 301 11 q 292 30 292 19 q 296 135 292 86 q 304 235 300 184 l 168 234 q 92 237 115 233 q 68 250 68 241 q 73 267 68 256 q 85 291 77 278 q 102 319 92 304 q 122 346 111 334 q 144 365 133 357 q 165 374 155 373 l 248 375 q 265 376 248 376 q 311 378 283 377 q 318 503 314 439 q 326 621 322 566 l 194 621 q 118 624 141 620 q 94 637 94 627 q 99 653 94 642 q 111 678 103 665 q 127 706 118 691 q 148 732 137 720 q 170 752 159 744 q 191 760 181 760 l 273 762 q 289 763 273 762 q 331 764 305 764 l 336 892 q 339 920 338 912 q 349 930 341 928 q 426 951 387 941 q 503 979 464 962 q 506 980 504 980 q 511 974 511 980 l 498 768 q 603 769 565 768 q 659 771 640 771 q 675 768 668 770 q 687 761 682 765 q 692 747 692 756 q 690 721 692 739 q 685 686 688 703 l 679 640 q 677 633 678 636 q 673 629 676 631 q 663 626 669 627 q 646 625 656 625 q 636 624 646 625 q 610 624 627 624 q 570 624 593 624 q 519 623 547 624 l 489 623 l 474 381 q 577 384 539 382 q 633 385 615 385 q 650 381 642 384 q 661 374 656 378 q 666 361 666 370 q 664 334 666 352 q 659 299 662 317 l 653 254 q 651 247 652 250 q 647 242 650 244 q 637 239 644 240 q 620 238 631 238 q 610 238 620 238 q 584 237 601 237 q 544 237 567 237 q 494 236 521 237 l 465 236 z " - }, - "•": { - "ha": 663, - "x_min": 90, - "x_max": 656, - "o": "m 349 203 q 236 225 285 203 q 155 283 188 247 q 106 367 123 319 q 90 465 90 414 q 115 581 90 528 q 184 671 140 634 q 284 729 227 709 q 406 750 342 750 q 507 731 460 750 q 586 678 553 711 q 638 599 619 644 q 656 502 656 553 q 632 376 656 431 q 566 282 608 321 q 468 223 524 243 q 349 203 412 203 z " - }, - "…": { - "ha": 1174, - "x_min": 61, - "x_max": 1138, - "o": "m 61 -26 q 63 25 62 6 q 64 54 64 43 q 64 68 64 64 q 64 76 64 72 q 65 85 64 79 q 66 103 65 90 q 68 137 66 115 q 71 196 69 159 q 76 227 73 218 q 91 237 79 235 q 216 238 151 237 q 338 239 281 238 q 349 235 345 239 q 353 222 353 232 l 334 9 q 329 -21 331 -13 q 313 -31 326 -30 q 195 -33 256 -32 q 68 -33 134 -33 q 63 -33 64 -33 q 61 -28 61 -32 l 61 -26 m 454 -26 q 456 25 455 6 q 457 54 456 43 q 457 68 457 64 q 457 76 457 72 q 457 85 457 79 q 458 103 458 90 q 460 137 459 115 q 464 196 462 159 q 468 227 465 218 q 484 237 471 235 q 608 238 543 237 q 731 239 673 238 q 741 235 737 239 q 745 222 745 232 l 726 9 q 721 -21 724 -13 q 706 -31 719 -30 q 588 -33 648 -32 q 461 -33 527 -33 q 455 -33 457 -33 q 454 -28 454 -32 l 454 -26 m 846 -26 q 848 25 848 6 q 849 54 849 43 q 850 68 850 64 q 850 76 850 72 q 850 85 850 79 q 851 103 850 90 q 853 137 852 115 q 857 196 854 159 q 861 227 858 218 q 876 237 864 235 q 1001 238 936 237 q 1124 239 1066 238 q 1134 235 1130 239 q 1138 222 1138 232 l 1119 9 q 1114 -21 1116 -13 q 1099 -31 1112 -30 q 980 -33 1041 -32 q 854 -33 920 -33 q 848 -33 850 -33 q 846 -28 846 -32 l 846 -26 z " - }, - "‰": { - "ha": 2116, - "x_min": 103, - "x_max": 2104, - "o": "m 717 586 q 827 720 770 652 q 938 857 883 789 q 950 871 946 867 q 961 876 954 876 q 967 876 966 876 q 1032 825 1000 849 q 1096 782 1063 802 q 1110 775 1101 780 q 1118 766 1118 771 q 1116 761 1118 763 l 582 113 q 575 103 576 106 q 568 100 574 100 q 561 101 565 100 q 549 104 556 102 q 487 153 510 136 q 450 180 463 171 q 431 193 437 190 q 422 200 426 197 q 416 209 417 203 q 416 222 416 214 q 493 312 456 268 q 566 400 530 356 q 639 491 602 445 q 717 586 676 536 m 103 764 q 121 889 103 831 q 175 989 139 947 q 265 1056 211 1031 q 391 1080 319 1080 q 508 1056 458 1080 q 591 991 558 1031 q 639 899 623 951 q 654 791 654 846 q 634 661 654 718 q 576 564 614 604 q 487 503 539 524 q 372 482 435 482 q 263 502 313 482 q 178 559 214 522 q 123 648 142 595 q 103 764 103 700 m 277 778 q 281 724 277 751 q 296 675 285 697 q 326 639 307 653 q 375 625 345 625 q 428 641 407 625 q 461 682 449 657 q 479 735 474 706 q 484 793 484 765 q 479 842 484 816 q 463 890 474 868 q 433 927 452 913 q 387 942 414 942 q 334 927 355 942 q 300 888 313 912 q 282 836 287 865 q 277 778 277 806 m 924 247 q 942 372 924 314 q 996 472 960 429 q 1086 538 1032 514 q 1212 563 1140 563 q 1330 538 1280 563 q 1412 474 1379 514 q 1460 381 1444 433 q 1476 273 1476 329 q 1455 143 1476 201 q 1398 46 1435 86 q 1308 -14 1360 7 q 1193 -35 1256 -35 q 1084 -15 1134 -35 q 999 41 1035 5 q 944 130 964 78 q 924 247 924 182 m 1098 260 q 1102 207 1098 234 q 1117 158 1106 180 q 1147 122 1128 136 q 1196 108 1166 108 q 1249 124 1228 108 q 1283 164 1270 140 q 1300 218 1295 189 q 1305 275 1305 248 q 1300 325 1305 298 q 1284 373 1295 351 q 1254 410 1273 395 q 1208 425 1236 425 q 1155 410 1176 425 q 1121 371 1134 395 q 1103 318 1108 347 q 1098 260 1098 289 m 1553 247 q 1571 372 1553 314 q 1625 472 1589 429 q 1715 538 1661 514 q 1841 563 1769 563 q 1958 538 1908 563 q 2041 474 2008 514 q 2089 381 2073 433 q 2104 273 2104 329 q 2084 143 2104 201 q 2026 46 2064 86 q 1937 -14 1989 7 q 1822 -35 1885 -35 q 1713 -15 1763 -35 q 1628 41 1664 5 q 1573 130 1592 78 q 1553 247 1553 182 m 1727 260 q 1731 207 1727 234 q 1746 158 1735 180 q 1776 122 1757 136 q 1825 108 1795 108 q 1878 124 1857 108 q 1911 164 1899 140 q 1929 218 1924 189 q 1934 275 1934 248 q 1929 325 1934 298 q 1913 373 1924 351 q 1883 410 1902 395 q 1837 425 1864 425 q 1784 410 1805 425 q 1750 371 1763 395 q 1732 318 1737 347 q 1727 260 1727 289 z " - }, - "‹": { - "ha": 712, - "x_min": 70, - "x_max": 694, - "o": "m 689 220 q 694 212 694 216 q 693 204 694 208 q 646 100 665 153 q 608 -7 627 46 q 591 -20 604 -20 q 581 -18 586 -20 q 566 -12 575 -16 l 121 248 q 92 265 99 258 q 84 286 84 272 q 79 390 82 337 q 71 500 77 443 q 70 502 71 501 q 70 503 70 503 l 71 508 q 74 514 71 511 q 79 516 77 516 q 137 542 101 527 q 216 573 172 556 q 311 609 260 591 q 414 648 361 628 q 519 687 467 667 q 618 724 571 706 q 649 730 640 730 q 660 720 658 730 q 669 610 664 667 q 686 502 674 553 q 678 486 686 487 l 380 376 q 410 361 387 372 q 463 334 433 349 q 528 301 494 319 q 595 268 563 283 q 652 239 627 252 q 689 220 677 226 z " - }, - "›": { - "ha": 692, - "x_min": 78, - "x_max": 703, - "o": "m 83 220 q 120 239 95 226 q 178 268 146 252 q 244 301 210 283 q 309 334 279 319 q 362 361 340 349 q 393 376 385 372 l 94 486 q 86 502 86 487 q 103 610 98 553 q 113 720 109 667 q 123 730 115 730 q 154 724 132 730 q 254 687 201 706 q 358 648 306 667 q 461 609 411 628 q 556 573 512 591 q 636 542 600 556 q 694 516 671 527 q 699 514 696 516 q 702 508 701 511 l 703 503 q 702 502 703 503 q 702 500 702 501 q 693 390 696 443 q 688 286 690 337 q 681 265 688 272 q 652 248 673 258 l 207 -12 q 192 -18 197 -16 q 181 -20 186 -20 q 170 -17 174 -20 q 164 -7 167 -14 q 125 100 144 46 q 79 204 106 153 q 78 212 78 208 q 79 217 78 215 q 83 220 80 218 z " - }, - "⁄": { - "ha": 503, - "x_min": -6, - "x_max": 601, - "o": "m 256 640 q 336 819 298 729 q 414 1001 374 908 q 428 1028 423 1021 q 442 1036 433 1036 l 447 1036 q 519 1004 484 1021 q 591 980 555 987 q 598 977 595 979 q 601 971 601 975 l 601 969 l 166 10 q 162 -1 163 4 q 159 -11 161 -7 q 155 -17 157 -15 q 146 -20 152 -20 q 129 -15 138 -20 l 60 14 q 44 19 55 16 q 22 28 33 23 q 2 40 11 33 q -6 56 -6 47 q -3 68 -6 62 q 57 198 28 134 q 116 329 86 261 q 180 473 146 397 q 256 640 214 549 z " - }, - "⁴": { - "ha": 599, - "x_min": 43, - "x_max": 615, - "o": "m 602 562 q 592 513 597 538 q 590 503 591 506 q 584 499 590 500 q 562 498 578 498 q 515 497 547 498 l 507 418 q 506 410 507 414 q 500 405 505 406 q 486 399 497 404 q 460 389 475 395 q 428 377 445 383 q 395 366 410 371 q 367 357 379 360 q 351 353 355 353 q 340 356 345 353 q 336 369 336 359 q 338 421 336 389 q 343 495 340 454 q 270 495 307 495 q 203 494 234 494 q 149 494 172 494 q 114 494 125 494 q 59 496 75 494 q 43 509 43 499 q 43 514 43 511 q 47 520 44 517 q 61 544 51 527 q 85 585 71 562 q 117 637 100 609 q 152 694 134 666 l 241 843 q 271 897 258 870 q 299 945 283 923 q 336 982 315 966 q 392 1005 358 998 l 528 1041 q 534 1042 532 1042 q 540 1042 537 1042 q 548 1040 545 1042 q 551 1029 551 1037 l 551 1024 q 545 920 548 964 q 540 834 543 876 q 534 748 537 793 q 529 644 532 703 q 577 645 558 644 q 600 645 596 645 q 610 641 605 645 q 615 629 615 637 q 614 625 615 626 l 602 562 m 355 637 q 363 701 359 667 q 370 768 367 734 q 375 836 373 802 q 378 901 377 869 l 221 637 l 355 637 z " - }, - "€": { - "ha": 985, - "x_min": 72, - "x_max": 991, - "o": "m 659 638 q 670 637 666 638 q 675 633 673 635 q 677 629 677 631 q 679 624 677 627 q 687 593 684 610 q 689 558 689 575 q 686 525 689 536 q 671 509 682 514 q 639 503 660 503 q 583 502 618 502 l 488 502 q 486 478 487 490 q 486 452 486 465 l 659 447 q 675 438 669 447 q 685 418 682 430 q 688 392 688 406 q 689 367 689 378 q 686 334 689 345 q 671 317 682 323 q 639 311 660 312 q 583 311 618 311 l 513 311 q 578 226 536 258 q 682 195 621 195 q 751 197 721 195 q 806 206 781 200 q 857 222 832 212 q 910 248 882 233 q 917 249 912 249 q 923 245 922 249 q 925 230 925 241 q 925 171 925 205 q 925 105 925 136 q 924 51 924 73 q 922 28 923 28 q 856 -4 891 9 q 782 -23 820 -16 q 707 -33 745 -31 q 633 -35 669 -35 q 480 -11 552 -35 q 350 60 408 14 q 251 170 292 106 q 191 314 210 235 q 133 314 156 314 q 96 315 110 313 q 77 321 83 317 q 72 336 72 326 q 73 366 72 338 q 79 437 74 393 q 91 449 84 445 q 105 455 98 453 q 116 457 112 457 q 121 458 121 458 q 143 458 128 458 q 178 457 158 458 q 179 481 178 469 q 181 505 180 494 q 134 505 153 505 q 105 507 115 505 q 90 514 94 509 q 85 530 85 519 q 88 555 85 542 l 90 587 q 91 612 91 600 q 93 628 92 624 q 105 640 98 636 q 119 646 112 644 q 130 649 125 648 q 134 649 134 649 q 165 649 144 649 q 216 648 186 649 q 293 784 245 722 q 403 889 340 845 q 542 958 466 934 q 703 983 618 983 q 807 975 762 983 q 886 955 852 967 q 942 929 920 943 q 980 902 965 915 q 979 897 979 902 q 981 860 979 887 q 985 800 983 833 q 989 732 987 766 q 991 673 991 698 q 988 664 991 669 q 975 659 985 659 q 960 661 968 659 q 924 679 945 665 q 873 710 902 694 q 809 738 844 726 q 731 751 773 751 q 617 722 666 751 q 535 642 568 692 l 659 638 z " - }, - "™": { - "ha": 1327, - "x_min": 149, - "x_max": 1298, - "o": "m 262 376 l 296 822 q 235 823 269 823 q 155 823 202 823 q 150 826 151 823 q 149 833 149 830 l 149 836 l 195 948 q 194 949 194 948 l 194 950 q 210 955 194 952 q 252 960 226 958 q 314 965 279 963 q 387 970 349 968 q 463 975 425 972 q 536 979 502 977 q 596 982 570 981 q 638 984 623 983 q 649 983 644 984 q 654 974 654 981 q 654 972 654 972 q 654 970 654 971 q 631 908 640 937 q 608 845 621 879 q 606 842 607 845 q 602 834 604 838 q 595 826 600 829 q 585 821 591 822 q 576 822 581 822 q 565 822 572 822 l 466 822 q 462 782 464 801 q 458 740 460 762 q 453 691 456 718 q 447 629 450 665 l 427 422 q 426 415 427 419 q 420 410 425 412 l 303 368 q 291 363 298 366 q 277 361 283 361 q 267 364 271 361 q 262 374 262 367 l 262 376 m 1196 985 q 1200 986 1198 985 q 1204 986 1202 986 q 1216 981 1211 986 q 1222 964 1221 975 q 1226 929 1223 953 q 1233 880 1230 905 q 1240 834 1237 854 q 1244 809 1243 813 l 1257 730 q 1261 699 1259 714 q 1265 671 1263 684 q 1268 648 1267 658 q 1270 634 1270 638 l 1298 422 l 1294 410 q 1284 402 1293 407 q 1260 392 1274 397 q 1230 381 1246 387 q 1200 371 1214 376 q 1176 364 1186 367 q 1164 361 1166 361 q 1154 365 1158 361 q 1147 376 1149 368 q 1138 422 1142 397 q 1130 475 1134 447 q 1124 532 1126 503 q 1118 590 1121 562 l 1102 711 l 949 430 q 921 411 936 411 q 908 416 913 411 q 900 430 903 422 q 887 474 892 456 q 876 507 881 492 q 867 536 871 522 q 858 568 863 550 q 846 612 852 587 q 831 673 840 637 q 823 635 826 652 q 818 614 819 619 l 760 368 q 750 363 760 363 q 725 367 741 363 q 694 377 710 372 q 663 390 678 383 q 638 400 648 396 q 632 404 635 401 q 629 414 629 407 q 632 431 629 419 q 640 458 635 443 q 648 489 644 473 q 656 520 652 505 q 663 552 659 536 q 671 587 667 569 l 722 816 q 733 863 728 840 q 742 905 738 886 q 749 937 747 924 q 752 954 752 950 l 856 985 q 866 984 861 985 q 871 977 870 983 l 974 719 l 1067 950 l 1196 985 z " - }, - "−": { - "ha": 739, - "x_min": 102, - "x_max": 700, - "o": "m 202 351 q 126 354 149 351 q 102 367 102 357 q 107 384 102 372 q 119 408 111 395 q 136 436 126 421 q 156 462 145 450 q 178 482 167 474 q 199 490 189 490 l 438 497 q 466 497 446 497 q 509 498 485 498 q 561 499 534 498 q 610 500 587 500 q 649 501 633 500 q 667 501 665 501 q 684 498 676 500 q 695 491 690 495 q 700 477 700 486 q 698 451 700 469 q 693 416 696 433 l 687 370 q 685 363 686 366 q 681 359 684 361 q 671 356 677 357 q 654 355 665 355 l 571 355 q 536 355 554 355 q 500 354 517 355 q 466 354 482 354 q 436 354 449 354 l 202 351 z " - }, - "fi": { - "ha": 1046, - "x_min": 47, - "x_max": 1078, - "o": "m 751 523 l 475 523 q 461 382 468 452 q 448 251 454 313 q 437 142 442 190 q 430 68 433 94 q 429 61 429 66 q 430 56 429 58 q 430 53 430 54 q 426 43 430 47 q 403 35 421 39 l 224 -28 q 205 -35 217 -31 q 181 -39 193 -39 q 164 -35 172 -39 q 157 -18 157 -30 l 157 -14 q 160 18 158 -7 q 166 82 163 43 q 174 170 170 120 q 184 277 178 220 q 195 396 189 334 q 207 521 201 458 l 117 521 q 64 524 80 521 q 47 536 47 527 q 54 551 47 539 q 72 579 61 563 q 94 615 82 596 q 118 651 106 634 q 137 680 129 667 q 147 694 145 692 l 230 694 l 243 802 q 333 1037 261 960 q 543 1114 405 1114 q 572 1109 553 1114 q 611 1098 590 1105 q 655 1083 633 1092 q 695 1066 677 1075 q 724 1051 713 1058 q 735 1039 735 1044 q 730 1025 735 1034 q 703 963 712 987 q 688 924 693 939 q 679 904 682 909 q 669 898 675 898 q 659 904 664 903 q 647 905 654 905 q 620 916 633 911 q 594 921 608 921 q 542 902 564 921 q 507 830 519 883 q 495 764 499 800 q 486 694 490 729 l 796 694 q 910 708 851 694 q 1024 736 969 721 q 1030 736 1026 736 q 1036 731 1032 732 l 1038 730 l 977 80 q 971 49 974 58 q 957 38 969 41 q 837 -3 897 20 q 709 -46 777 -25 q 703 -44 704 -46 q 702 -39 702 -43 q 703 -20 702 -39 q 707 26 705 -2 q 712 91 709 55 q 718 163 715 127 q 724 232 721 199 q 728 288 726 264 l 751 523 m 1078 1120 q 1075 1076 1076 1091 q 1074 1052 1074 1060 q 1073 1042 1073 1044 q 1073 1039 1073 1040 q 1072 1035 1072 1038 q 1071 1022 1072 1032 q 1069 994 1070 1013 q 1065 941 1067 975 q 1060 910 1063 919 q 1045 899 1057 902 q 921 873 985 887 q 796 842 856 860 l 789 849 l 804 1035 q 809 1066 806 1057 q 823 1077 811 1074 q 943 1104 882 1088 q 1071 1134 1003 1120 q 1077 1130 1076 1134 q 1078 1120 1078 1126 z " - }, - "fl": { - "ha": 1181, - "x_min": 47, - "x_max": 1198, - "o": "m 157 -10 q 160 22 158 -3 q 166 85 163 47 q 174 172 170 123 q 184 278 178 221 q 195 396 189 334 q 207 521 201 458 l 117 521 q 64 524 80 521 q 47 536 47 527 q 54 551 47 539 q 72 579 61 563 q 94 615 82 596 q 118 651 106 634 q 137 680 129 667 q 147 694 145 692 l 230 694 l 243 802 q 278 946 253 888 q 339 1040 302 1004 q 424 1092 376 1076 q 526 1107 471 1107 q 638 1094 580 1107 q 757 1058 697 1081 q 776 1049 770 1053 q 783 1039 783 1045 q 778 1025 783 1034 q 746 957 756 983 q 729 916 735 931 q 719 896 723 901 q 707 891 715 891 q 698 893 703 891 q 688 898 694 895 q 640 914 664 907 q 594 921 616 921 q 542 902 564 921 q 507 830 519 883 q 494 764 499 800 q 486 694 490 729 l 663 694 q 674 691 669 694 q 679 678 679 687 q 671 654 679 675 q 648 599 663 633 l 623 544 q 613 529 618 534 q 593 523 608 524 l 475 523 q 461 383 468 452 q 448 253 454 314 q 437 145 442 193 q 430 73 433 98 q 429 65 429 71 q 430 60 429 62 q 430 57 430 58 q 426 47 430 51 q 403 39 421 43 l 224 -24 q 205 -31 217 -27 q 181 -35 193 -35 q 163 -30 170 -35 q 157 -10 157 -24 m 887 574 q 900 758 895 667 q 911 944 905 848 q 916 975 913 966 q 931 986 919 983 q 1058 1009 994 998 q 1185 1041 1121 1021 q 1191 1042 1187 1042 q 1198 1035 1198 1042 l 1110 66 l 1110 55 q 1105 45 1110 49 q 1083 37 1101 41 l 905 -28 q 886 -36 898 -32 q 862 -39 873 -39 q 845 -35 852 -39 q 838 -18 838 -30 l 838 -14 q 849 120 844 54 q 860 255 854 185 q 872 403 865 325 q 887 574 879 481 z " - } - }, - "familyName": "Carter One", - "ascender": 1535, - "descender": -604, - "underlinePosition": -104, - "underlineThickness": 69, - "boundingBox": { - "yMin": -604, - "xMin": -193, - "yMax": 1535, - "xMax": 2104 - }, - "resolution": 1000, - "original_font_information": { - "format": 0, - "copyright": "Copyright (c) 2011 by vernon adams. All rights reserved.", - "fontFamily": "Carter One", - "fontSubfamily": "Regular", - "uniqueID": "vernonadams: Carter One: 2011", - "fullName": "Carter One", - "version": "Version 1.000", - "postScriptName": "CarterOne", - "trademark": "Carter One is a trademark of vernon adams.", - "manufacturer": "vernon adams", - "designer": "vernon adams", - "description": "Copyright (c) 2011 by vernon adams. All rights reserved.", - "licenceURL": "http://scripts.sil.org/OFL" - }, - "cssFontWeight": "normal", - "cssFontStyle": "normal" -} \ No newline at end of file diff --git a/frontend/apps/artcraft/app/public/resources/gifs/2D_CANVAS_DEMO.webp b/frontend/apps/artcraft/app/public/resources/gifs/2D_CANVAS_DEMO.webp deleted file mode 100644 index 975d642dcc..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/gifs/2D_CANVAS_DEMO.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/gifs/3D_CANVAS_DEMO.webp b/frontend/apps/artcraft/app/public/resources/gifs/3D_CANVAS_DEMO.webp deleted file mode 100644 index 0c2b11291c..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/gifs/3D_CANVAS_DEMO.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/gifs/artcraft-logo-load.gif b/frontend/apps/artcraft/app/public/resources/gifs/artcraft-logo-load.gif deleted file mode 100644 index 6d5e2bcac2..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/gifs/artcraft-logo-load.gif and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/gpu/edge1.png b/frontend/apps/artcraft/app/public/resources/gpu/edge1.png deleted file mode 100644 index 6c1a3aa5ee..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/gpu/edge1.png and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/gpu/edge2.png b/frontend/apps/artcraft/app/public/resources/gpu/edge2.png deleted file mode 100644 index af4cb7b0b4..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/gpu/edge2.png and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/gpu/edge3.png b/frontend/apps/artcraft/app/public/resources/gpu/edge3.png deleted file mode 100644 index 836f144ed7..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/gpu/edge3.png and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/gpu/edge4.png b/frontend/apps/artcraft/app/public/resources/gpu/edge4.png deleted file mode 100644 index 882482cf86..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/gpu/edge4.png and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/gpu/google1.png b/frontend/apps/artcraft/app/public/resources/gpu/google1.png deleted file mode 100644 index df1f20da2e..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/gpu/google1.png and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/gpu/google2.png b/frontend/apps/artcraft/app/public/resources/gpu/google2.png deleted file mode 100644 index 032d3cc72b..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/gpu/google2.png and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/icons/animations.png b/frontend/apps/artcraft/app/public/resources/icons/animations.png deleted file mode 100644 index 430647afa9..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/icons/animations.png and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/icons/audios.png b/frontend/apps/artcraft/app/public/resources/icons/audios.png deleted file mode 100644 index 96979fc9c3..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/icons/audios.png and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/icons/brush.png b/frontend/apps/artcraft/app/public/resources/icons/brush.png deleted file mode 100644 index 06436ab45a..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/icons/brush.png and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/icons/camera.png b/frontend/apps/artcraft/app/public/resources/icons/camera.png deleted file mode 100644 index 3e5ff43ffe..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/icons/camera.png and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/icons/characters.png b/frontend/apps/artcraft/app/public/resources/icons/characters.png deleted file mode 100644 index 4a5c484c47..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/icons/characters.png and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/icons/expressions.png b/frontend/apps/artcraft/app/public/resources/icons/expressions.png deleted file mode 100644 index 4697a4d2c5..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/icons/expressions.png and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/icons/mouse_lmb.png b/frontend/apps/artcraft/app/public/resources/icons/mouse_lmb.png deleted file mode 100644 index 7cd1073f08..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/icons/mouse_lmb.png and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/icons/mouse_mmb.png b/frontend/apps/artcraft/app/public/resources/icons/mouse_mmb.png deleted file mode 100644 index eea44942db..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/icons/mouse_mmb.png and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/icons/mouse_rmb.png b/frontend/apps/artcraft/app/public/resources/icons/mouse_rmb.png deleted file mode 100644 index 10ddd409dd..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/icons/mouse_rmb.png and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/icons/objects.png b/frontend/apps/artcraft/app/public/resources/icons/objects.png deleted file mode 100644 index 0f79e3d075..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/icons/objects.png and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/icons/shapes.png b/frontend/apps/artcraft/app/public/resources/icons/shapes.png deleted file mode 100644 index aca5d2aec9..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/icons/shapes.png and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/images/default-covers/0.webp b/frontend/apps/artcraft/app/public/resources/images/default-covers/0.webp deleted file mode 100644 index 22d64316ab..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/images/default-covers/0.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/images/default-covers/1.webp b/frontend/apps/artcraft/app/public/resources/images/default-covers/1.webp deleted file mode 100644 index 39e12d0bb4..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/images/default-covers/1.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/images/default-covers/10.webp b/frontend/apps/artcraft/app/public/resources/images/default-covers/10.webp deleted file mode 100644 index 1bdfaba961..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/images/default-covers/10.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/images/default-covers/11.webp b/frontend/apps/artcraft/app/public/resources/images/default-covers/11.webp deleted file mode 100644 index 925c954737..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/images/default-covers/11.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/images/default-covers/12.webp b/frontend/apps/artcraft/app/public/resources/images/default-covers/12.webp deleted file mode 100644 index 927cb714c4..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/images/default-covers/12.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/images/default-covers/13.webp b/frontend/apps/artcraft/app/public/resources/images/default-covers/13.webp deleted file mode 100644 index 68c2ab838f..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/images/default-covers/13.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/images/default-covers/14.webp b/frontend/apps/artcraft/app/public/resources/images/default-covers/14.webp deleted file mode 100644 index 84582b89c9..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/images/default-covers/14.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/images/default-covers/15.webp b/frontend/apps/artcraft/app/public/resources/images/default-covers/15.webp deleted file mode 100644 index d56fb04a7d..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/images/default-covers/15.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/images/default-covers/16.webp b/frontend/apps/artcraft/app/public/resources/images/default-covers/16.webp deleted file mode 100644 index 6b280616c2..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/images/default-covers/16.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/images/default-covers/17.webp b/frontend/apps/artcraft/app/public/resources/images/default-covers/17.webp deleted file mode 100644 index d13b86daa6..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/images/default-covers/17.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/images/default-covers/18.webp b/frontend/apps/artcraft/app/public/resources/images/default-covers/18.webp deleted file mode 100644 index 29f751a168..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/images/default-covers/18.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/images/default-covers/19.webp b/frontend/apps/artcraft/app/public/resources/images/default-covers/19.webp deleted file mode 100644 index 7bed881ef0..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/images/default-covers/19.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/images/default-covers/2.webp b/frontend/apps/artcraft/app/public/resources/images/default-covers/2.webp deleted file mode 100644 index 9715e6bcd6..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/images/default-covers/2.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/images/default-covers/20.webp b/frontend/apps/artcraft/app/public/resources/images/default-covers/20.webp deleted file mode 100644 index 1968e9f039..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/images/default-covers/20.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/images/default-covers/21.webp b/frontend/apps/artcraft/app/public/resources/images/default-covers/21.webp deleted file mode 100644 index ea1f1b77f4..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/images/default-covers/21.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/images/default-covers/22.webp b/frontend/apps/artcraft/app/public/resources/images/default-covers/22.webp deleted file mode 100644 index 97fd2b89ed..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/images/default-covers/22.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/images/default-covers/23.webp b/frontend/apps/artcraft/app/public/resources/images/default-covers/23.webp deleted file mode 100644 index 9e4a6bce1c..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/images/default-covers/23.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/images/default-covers/24.webp b/frontend/apps/artcraft/app/public/resources/images/default-covers/24.webp deleted file mode 100644 index 72bb9ff41f..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/images/default-covers/24.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/images/default-covers/3.webp b/frontend/apps/artcraft/app/public/resources/images/default-covers/3.webp deleted file mode 100644 index 089141a371..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/images/default-covers/3.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/images/default-covers/4.webp b/frontend/apps/artcraft/app/public/resources/images/default-covers/4.webp deleted file mode 100644 index 9f4c72b6fb..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/images/default-covers/4.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/images/default-covers/5.webp b/frontend/apps/artcraft/app/public/resources/images/default-covers/5.webp deleted file mode 100644 index 7c0501f52c..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/images/default-covers/5.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/images/default-covers/6.webp b/frontend/apps/artcraft/app/public/resources/images/default-covers/6.webp deleted file mode 100644 index d0a990bbaa..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/images/default-covers/6.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/images/default-covers/7.webp b/frontend/apps/artcraft/app/public/resources/images/default-covers/7.webp deleted file mode 100644 index c1a2b9f3f4..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/images/default-covers/7.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/images/default-covers/8.webp b/frontend/apps/artcraft/app/public/resources/images/default-covers/8.webp deleted file mode 100644 index b5ac96d226..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/images/default-covers/8.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/images/default-covers/9.webp b/frontend/apps/artcraft/app/public/resources/images/default-covers/9.webp deleted file mode 100644 index 68627ee8e2..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/images/default-covers/9.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/images/digital-mountains.webp b/frontend/apps/artcraft/app/public/resources/images/digital-mountains.webp deleted file mode 100644 index 5fc9663153..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/images/digital-mountains.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/images/floating-cubes.webp b/frontend/apps/artcraft/app/public/resources/images/floating-cubes.webp deleted file mode 100644 index 93249331a5..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/images/floating-cubes.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/images/forest-trees.webp b/frontend/apps/artcraft/app/public/resources/images/forest-trees.webp deleted file mode 100644 index 07935fa76e..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/images/forest-trees.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/images/room-of-items.webp b/frontend/apps/artcraft/app/public/resources/images/room-of-items.webp deleted file mode 100644 index 9e3c089235..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/images/room-of-items.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/images/services/alibaba.svg b/frontend/apps/artcraft/app/public/resources/images/services/alibaba.svg deleted file mode 100644 index a4bb382a63..0000000000 --- a/frontend/apps/artcraft/app/public/resources/images/services/alibaba.svg +++ /dev/null @@ -1 +0,0 @@ -Qwen \ No newline at end of file diff --git a/frontend/apps/artcraft/app/public/resources/images/services/artcraft.svg b/frontend/apps/artcraft/app/public/resources/images/services/artcraft.svg deleted file mode 100644 index 3fefcd113e..0000000000 --- a/frontend/apps/artcraft/app/public/resources/images/services/artcraft.svg +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/frontend/apps/artcraft/app/public/resources/images/services/blackforestlabs.svg b/frontend/apps/artcraft/app/public/resources/images/services/blackforestlabs.svg deleted file mode 100644 index 12a4ba1d76..0000000000 --- a/frontend/apps/artcraft/app/public/resources/images/services/blackforestlabs.svg +++ /dev/null @@ -1 +0,0 @@ -Flux \ No newline at end of file diff --git a/frontend/apps/artcraft/app/public/resources/images/services/bytedance.svg b/frontend/apps/artcraft/app/public/resources/images/services/bytedance.svg deleted file mode 100644 index dec27435c1..0000000000 --- a/frontend/apps/artcraft/app/public/resources/images/services/bytedance.svg +++ /dev/null @@ -1 +0,0 @@ -ByteDance \ No newline at end of file diff --git a/frontend/apps/artcraft/app/public/resources/images/services/color/alibaba.svg b/frontend/apps/artcraft/app/public/resources/images/services/color/alibaba.svg deleted file mode 100644 index bb458d7ed0..0000000000 --- a/frontend/apps/artcraft/app/public/resources/images/services/color/alibaba.svg +++ /dev/null @@ -1 +0,0 @@ -Alibaba \ No newline at end of file diff --git a/frontend/apps/artcraft/app/public/resources/images/services/color/bytedance.svg b/frontend/apps/artcraft/app/public/resources/images/services/color/bytedance.svg deleted file mode 100644 index 6921097dac..0000000000 --- a/frontend/apps/artcraft/app/public/resources/images/services/color/bytedance.svg +++ /dev/null @@ -1 +0,0 @@ -ByteDance \ No newline at end of file diff --git a/frontend/apps/artcraft/app/public/resources/images/services/color/fal.svg b/frontend/apps/artcraft/app/public/resources/images/services/color/fal.svg deleted file mode 100644 index d06b8054c0..0000000000 --- a/frontend/apps/artcraft/app/public/resources/images/services/color/fal.svg +++ /dev/null @@ -1 +0,0 @@ -Fal \ No newline at end of file diff --git a/frontend/apps/artcraft/app/public/resources/images/services/color/google.svg b/frontend/apps/artcraft/app/public/resources/images/services/color/google.svg deleted file mode 100644 index e8e0f867bd..0000000000 --- a/frontend/apps/artcraft/app/public/resources/images/services/color/google.svg +++ /dev/null @@ -1 +0,0 @@ -Google \ No newline at end of file diff --git a/frontend/apps/artcraft/app/public/resources/images/services/color/kling.svg b/frontend/apps/artcraft/app/public/resources/images/services/color/kling.svg deleted file mode 100644 index 199e2804d1..0000000000 --- a/frontend/apps/artcraft/app/public/resources/images/services/color/kling.svg +++ /dev/null @@ -1 +0,0 @@ -Kling \ No newline at end of file diff --git a/frontend/apps/artcraft/app/public/resources/images/services/color/meshy.svg b/frontend/apps/artcraft/app/public/resources/images/services/color/meshy.svg deleted file mode 100644 index dd6bdd557a..0000000000 --- a/frontend/apps/artcraft/app/public/resources/images/services/color/meshy.svg +++ /dev/null @@ -1 +0,0 @@ -Meshy \ No newline at end of file diff --git a/frontend/apps/artcraft/app/public/resources/images/services/color/minimax.svg b/frontend/apps/artcraft/app/public/resources/images/services/color/minimax.svg deleted file mode 100644 index beb7adb86e..0000000000 --- a/frontend/apps/artcraft/app/public/resources/images/services/color/minimax.svg +++ /dev/null @@ -1 +0,0 @@ -Minimax \ No newline at end of file diff --git a/frontend/apps/artcraft/app/public/resources/images/services/color/stability.svg b/frontend/apps/artcraft/app/public/resources/images/services/color/stability.svg deleted file mode 100644 index 4ad0535dff..0000000000 --- a/frontend/apps/artcraft/app/public/resources/images/services/color/stability.svg +++ /dev/null @@ -1 +0,0 @@ -Stability \ No newline at end of file diff --git a/frontend/apps/artcraft/app/public/resources/images/services/color/tencent.svg b/frontend/apps/artcraft/app/public/resources/images/services/color/tencent.svg deleted file mode 100644 index 42edd6cd94..0000000000 --- a/frontend/apps/artcraft/app/public/resources/images/services/color/tencent.svg +++ /dev/null @@ -1 +0,0 @@ -Hunyuan \ No newline at end of file diff --git a/frontend/apps/artcraft/app/public/resources/images/services/color/tripo.svg b/frontend/apps/artcraft/app/public/resources/images/services/color/tripo.svg deleted file mode 100644 index 748a22b0af..0000000000 --- a/frontend/apps/artcraft/app/public/resources/images/services/color/tripo.svg +++ /dev/null @@ -1 +0,0 @@ -Tripo \ No newline at end of file diff --git a/frontend/apps/artcraft/app/public/resources/images/services/color/vidu.svg b/frontend/apps/artcraft/app/public/resources/images/services/color/vidu.svg deleted file mode 100644 index f3d890240d..0000000000 --- a/frontend/apps/artcraft/app/public/resources/images/services/color/vidu.svg +++ /dev/null @@ -1 +0,0 @@ -Vidu \ No newline at end of file diff --git a/frontend/apps/artcraft/app/public/resources/images/services/fal.svg b/frontend/apps/artcraft/app/public/resources/images/services/fal.svg deleted file mode 100644 index c41076f911..0000000000 --- a/frontend/apps/artcraft/app/public/resources/images/services/fal.svg +++ /dev/null @@ -1 +0,0 @@ -Fal \ No newline at end of file diff --git a/frontend/apps/artcraft/app/public/resources/images/services/generic.svg b/frontend/apps/artcraft/app/public/resources/images/services/generic.svg deleted file mode 100644 index 1c8166697d..0000000000 --- a/frontend/apps/artcraft/app/public/resources/images/services/generic.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/frontend/apps/artcraft/app/public/resources/images/services/google.svg b/frontend/apps/artcraft/app/public/resources/images/services/google.svg deleted file mode 100644 index 87736bbe09..0000000000 --- a/frontend/apps/artcraft/app/public/resources/images/services/google.svg +++ /dev/null @@ -1 +0,0 @@ -Gemini \ No newline at end of file diff --git a/frontend/apps/artcraft/app/public/resources/images/services/grok.svg b/frontend/apps/artcraft/app/public/resources/images/services/grok.svg deleted file mode 100644 index efb1a6183c..0000000000 --- a/frontend/apps/artcraft/app/public/resources/images/services/grok.svg +++ /dev/null @@ -1 +0,0 @@ -Grok \ No newline at end of file diff --git a/frontend/apps/artcraft/app/public/resources/images/services/higgsfield.svg b/frontend/apps/artcraft/app/public/resources/images/services/higgsfield.svg deleted file mode 100644 index de89784862..0000000000 --- a/frontend/apps/artcraft/app/public/resources/images/services/higgsfield.svg +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/frontend/apps/artcraft/app/public/resources/images/services/hyper3d.svg b/frontend/apps/artcraft/app/public/resources/images/services/hyper3d.svg deleted file mode 100644 index aa99495e5f..0000000000 --- a/frontend/apps/artcraft/app/public/resources/images/services/hyper3d.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/frontend/apps/artcraft/app/public/resources/images/services/kling.svg b/frontend/apps/artcraft/app/public/resources/images/services/kling.svg deleted file mode 100644 index 32fb6bed29..0000000000 --- a/frontend/apps/artcraft/app/public/resources/images/services/kling.svg +++ /dev/null @@ -1 +0,0 @@ -Kling \ No newline at end of file diff --git a/frontend/apps/artcraft/app/public/resources/images/services/krea.svg b/frontend/apps/artcraft/app/public/resources/images/services/krea.svg deleted file mode 100644 index d112dc3eab..0000000000 --- a/frontend/apps/artcraft/app/public/resources/images/services/krea.svg +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/frontend/apps/artcraft/app/public/resources/images/services/meshy.svg b/frontend/apps/artcraft/app/public/resources/images/services/meshy.svg deleted file mode 100644 index da77f22eb2..0000000000 --- a/frontend/apps/artcraft/app/public/resources/images/services/meshy.svg +++ /dev/null @@ -1 +0,0 @@ -Meshy \ No newline at end of file diff --git a/frontend/apps/artcraft/app/public/resources/images/services/midjourney.svg b/frontend/apps/artcraft/app/public/resources/images/services/midjourney.svg deleted file mode 100644 index e59e3b0709..0000000000 --- a/frontend/apps/artcraft/app/public/resources/images/services/midjourney.svg +++ /dev/null @@ -1 +0,0 @@ -Midjourney \ No newline at end of file diff --git a/frontend/apps/artcraft/app/public/resources/images/services/minimax.svg b/frontend/apps/artcraft/app/public/resources/images/services/minimax.svg deleted file mode 100644 index 1d32449ab8..0000000000 --- a/frontend/apps/artcraft/app/public/resources/images/services/minimax.svg +++ /dev/null @@ -1 +0,0 @@ -Minimax \ No newline at end of file diff --git a/frontend/apps/artcraft/app/public/resources/images/services/openai.svg b/frontend/apps/artcraft/app/public/resources/images/services/openai.svg deleted file mode 100644 index 50d94d6c10..0000000000 --- a/frontend/apps/artcraft/app/public/resources/images/services/openai.svg +++ /dev/null @@ -1 +0,0 @@ -OpenAI \ No newline at end of file diff --git a/frontend/apps/artcraft/app/public/resources/images/services/openart.svg b/frontend/apps/artcraft/app/public/resources/images/services/openart.svg deleted file mode 100644 index f47a86e82d..0000000000 --- a/frontend/apps/artcraft/app/public/resources/images/services/openart.svg +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/frontend/apps/artcraft/app/public/resources/images/services/recraft.svg b/frontend/apps/artcraft/app/public/resources/images/services/recraft.svg deleted file mode 100644 index b4ea390a72..0000000000 --- a/frontend/apps/artcraft/app/public/resources/images/services/recraft.svg +++ /dev/null @@ -1 +0,0 @@ -Recraft \ No newline at end of file diff --git a/frontend/apps/artcraft/app/public/resources/images/services/replicate.svg b/frontend/apps/artcraft/app/public/resources/images/services/replicate.svg deleted file mode 100644 index 48f148af26..0000000000 --- a/frontend/apps/artcraft/app/public/resources/images/services/replicate.svg +++ /dev/null @@ -1 +0,0 @@ -Replicate \ No newline at end of file diff --git a/frontend/apps/artcraft/app/public/resources/images/services/suno.svg b/frontend/apps/artcraft/app/public/resources/images/services/suno.svg deleted file mode 100644 index 7aceb6d56b..0000000000 --- a/frontend/apps/artcraft/app/public/resources/images/services/suno.svg +++ /dev/null @@ -1 +0,0 @@ -Suno diff --git a/frontend/apps/artcraft/app/public/resources/images/services/tencent.svg b/frontend/apps/artcraft/app/public/resources/images/services/tencent.svg deleted file mode 100644 index 724a815028..0000000000 --- a/frontend/apps/artcraft/app/public/resources/images/services/tencent.svg +++ /dev/null @@ -1 +0,0 @@ -Hunyuan \ No newline at end of file diff --git a/frontend/apps/artcraft/app/public/resources/images/services/tensorart.svg b/frontend/apps/artcraft/app/public/resources/images/services/tensorart.svg deleted file mode 100644 index d7e32012d4..0000000000 --- a/frontend/apps/artcraft/app/public/resources/images/services/tensorart.svg +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/frontend/apps/artcraft/app/public/resources/images/services/tripo.svg b/frontend/apps/artcraft/app/public/resources/images/services/tripo.svg deleted file mode 100644 index 40f4c37190..0000000000 --- a/frontend/apps/artcraft/app/public/resources/images/services/tripo.svg +++ /dev/null @@ -1 +0,0 @@ -Tripo \ No newline at end of file diff --git a/frontend/apps/artcraft/app/public/resources/images/services/vidu.svg b/frontend/apps/artcraft/app/public/resources/images/services/vidu.svg deleted file mode 100644 index 0cb11823b4..0000000000 --- a/frontend/apps/artcraft/app/public/resources/images/services/vidu.svg +++ /dev/null @@ -1 +0,0 @@ -Vidu \ No newline at end of file diff --git a/frontend/apps/artcraft/app/public/resources/images/services/worldlabs.svg b/frontend/apps/artcraft/app/public/resources/images/services/worldlabs.svg deleted file mode 100644 index 795cf7d000..0000000000 --- a/frontend/apps/artcraft/app/public/resources/images/services/worldlabs.svg +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/frontend/apps/artcraft/app/public/resources/images/tutorial-thumbnails/2D_Editor_Basics.jpg b/frontend/apps/artcraft/app/public/resources/images/tutorial-thumbnails/2D_Editor_Basics.jpg deleted file mode 100644 index 7ad1b1bbf4..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/images/tutorial-thumbnails/2D_Editor_Basics.jpg and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/images/tutorial-thumbnails/3D_Editor_Basics.jpg b/frontend/apps/artcraft/app/public/resources/images/tutorial-thumbnails/3D_Editor_Basics.jpg deleted file mode 100644 index 304473c988..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/images/tutorial-thumbnails/3D_Editor_Basics.jpg and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/images/tutorial-thumbnails/Turn_Images_Into_Objects.jpg b/frontend/apps/artcraft/app/public/resources/images/tutorial-thumbnails/Turn_Images_Into_Objects.jpg deleted file mode 100644 index bc3932fca4..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/images/tutorial-thumbnails/Turn_Images_Into_Objects.jpg and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/logo/artcraft-icon.png b/frontend/apps/artcraft/app/public/resources/logo/artcraft-icon.png deleted file mode 100644 index ded60e7ef4..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/logo/artcraft-icon.png and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/logo/artcraft-logo-color-black.svg b/frontend/apps/artcraft/app/public/resources/logo/artcraft-logo-color-black.svg deleted file mode 100644 index e28a3ff4d8..0000000000 --- a/frontend/apps/artcraft/app/public/resources/logo/artcraft-logo-color-black.svg +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/frontend/apps/artcraft/app/public/resources/logo/artcraft-logo-color-white.svg b/frontend/apps/artcraft/app/public/resources/logo/artcraft-logo-color-white.svg deleted file mode 100644 index 7906a3eb06..0000000000 --- a/frontend/apps/artcraft/app/public/resources/logo/artcraft-logo-color-white.svg +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/frontend/apps/artcraft/app/public/resources/memes/doge.jpg b/frontend/apps/artcraft/app/public/resources/memes/doge.jpg deleted file mode 100644 index aadbba17df..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/memes/doge.jpg and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/memes/grimace.jpg b/frontend/apps/artcraft/app/public/resources/memes/grimace.jpg deleted file mode 100644 index 5dba23f510..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/memes/grimace.jpg and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/memes/jd_vance.jpg b/frontend/apps/artcraft/app/public/resources/memes/jd_vance.jpg deleted file mode 100644 index b32376fc27..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/memes/jd_vance.jpg and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/memes/lil_jd.jpg b/frontend/apps/artcraft/app/public/resources/memes/lil_jd.jpg deleted file mode 100644 index 01d26978da..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/memes/lil_jd.jpg and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/memes/roblox.jpg b/frontend/apps/artcraft/app/public/resources/memes/roblox.jpg deleted file mode 100644 index 595a0234be..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/memes/roblox.jpg and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/memes/toothless.jpg b/frontend/apps/artcraft/app/public/resources/memes/toothless.jpg deleted file mode 100644 index 1eb4fa52b9..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/memes/toothless.jpg and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/objects/crown.png b/frontend/apps/artcraft/app/public/resources/objects/crown.png deleted file mode 100644 index 1af3d75465..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/objects/crown.png and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/objects/moon.png b/frontend/apps/artcraft/app/public/resources/objects/moon.png deleted file mode 100644 index 2a6f3607f9..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/objects/moon.png and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/objects/sakura.png b/frontend/apps/artcraft/app/public/resources/objects/sakura.png deleted file mode 100644 index f7ac5fe8da..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/objects/sakura.png and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/placeholders/audio_placeholder.png b/frontend/apps/artcraft/app/public/resources/placeholders/audio_placeholder.png deleted file mode 100644 index a5715be612..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/placeholders/audio_placeholder.png and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/placeholders/placeholder.png b/frontend/apps/artcraft/app/public/resources/placeholders/placeholder.png deleted file mode 100644 index f02db529a9..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/placeholders/placeholder.png and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/placeholders/placeholder_play.png b/frontend/apps/artcraft/app/public/resources/placeholders/placeholder_play.png deleted file mode 100644 index c0d0d94aee..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/placeholders/placeholder_play.png and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/placeholders/scene_placeholder.png b/frontend/apps/artcraft/app/public/resources/placeholders/scene_placeholder.png deleted file mode 100644 index 1956ea76e9..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/placeholders/scene_placeholder.png and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/placeholders/style_placeholder.png b/frontend/apps/artcraft/app/public/resources/placeholders/style_placeholder.png deleted file mode 100644 index 26aa85367b..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/placeholders/style_placeholder.png and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/pose/7.vpd b/frontend/apps/artcraft/app/public/resources/pose/7.vpd deleted file mode 100644 index b55ef36d35..0000000000 --- a/frontend/apps/artcraft/app/public/resources/pose/7.vpd +++ /dev/null @@ -1,305 +0,0 @@ -Vocaloid Pose Data file - -–؂̐lŒ`.osm; // �eƒtƒ@ƒCƒ‹–¼ -60; // ‘�ƒ|�[ƒYƒ{�[ƒ“�” - -Bone0{‘S‚Ă̐e - 0.000000,0.000000,0.000000; // trans x,y,z - 0.000000,0.000000,0.000000,1.000000; // Quaternion x,y,z,w -} - -Bone1{ƒZƒ“ƒ^�[ - 0.000000,0.000000,0.000000; // trans x,y,z - 0.000000,0.000000,0.000000,1.000000; // Quaternion x,y,z,w -} - -Bone2{�㔼�g - 0.000000,0.000000,0.000000; // trans x,y,z - 0.000000,0.000000,0.000000,1.000000; // Quaternion x,y,z,w -} - -Bone3{Žñ - 0.000000,0.000000,0.000000; // trans x,y,z - -0.000286,0.002004,-0.028579,0.999590; // Quaternion x,y,z,w -} - -Bone4{“ª - 0.000000,0.000000,0.000000; // trans x,y,z - 0.003903,-0.047796,-0.030391,0.998387; // Quaternion x,y,z,w -} - -Bone5{‰º”¼�g - 0.000000,0.000000,0.000000; // trans x,y,z - -0.000950,0.006664,-0.095038,0.995451; // Quaternion x,y,z,w -} - -Bone6{�¶Œ¨P - -0.000000,0.000000,0.000000; // trans x,y,z - 0.000000,-0.000000,-0.000000,1.000000; // Quaternion x,y,z,w -} - -Bone7{�¶Œ¨ - -0.000000,0.000000,0.000000; // trans x,y,z - 0.003159,-0.000000,0.105260,0.994440; // Quaternion x,y,z,w -} - -Bone8{�¶˜r - -0.000000,0.000000,0.000000; // trans x,y,z - 0.034463,0.034156,-0.396750,0.916644; // Quaternion x,y,z,w -} - -Bone9{�¶˜r�€ - 0.000000,0.000000,0.000000; // trans x,y,z - 0.000000,0.000000,0.000000,1.000000; // Quaternion x,y,z,w -} - -Bone10{�¶‚Ђ¶ - -0.000000,0.000000,0.000000; // trans x,y,z - 0.014712,-0.013995,0.076793,0.996840; // Quaternion x,y,z,w -} - -Bone11{�¶Ž蝀 - 0.000000,0.000000,0.000000; // trans x,y,z - 0.000000,0.000000,0.000000,1.000000; // Quaternion x,y,z,w -} - -Bone12{�¶ŽèŽñ - -0.000000,0.000000,0.000000; // trans x,y,z - 0.028156,-0.026783,0.146962,0.988378; // Quaternion x,y,z,w -} - -Bone13{�¶�eŽw‚P - 0.000000,0.000000,0.000000; // trans x,y,z - 0.002261,-0.000573,-0.306446,0.951885; // Quaternion x,y,z,w -} - -Bone14{�¶�eŽw‚Q - 0.000000,0.000000,0.000000; // trans x,y,z - 0.047385,-0.118953,0.062146,0.989819; // Quaternion x,y,z,w -} - -Bone15{�¶�lŽw‚P - 0.000000,0.000000,0.000000; // trans x,y,z - 0.020755,0.017947,0.064537,0.997538; // Quaternion x,y,z,w -} - -Bone16{�¶�lŽw‚Q - 0.000000,0.000000,0.000000; // trans x,y,z - 0.000000,0.000000,0.024997,0.999687; // Quaternion x,y,z,w -} - -Bone17{�¶�lŽw‚R - 0.000000,0.000000,0.000000; // trans x,y,z - 0.000000,0.000000,0.029995,0.999550; // Quaternion x,y,z,w -} - -Bone18{�¶’†Žw‚P - 0.000000,0.000000,0.000000; // trans x,y,z - -0.000000,-0.000000,-0.064954,0.997888; // Quaternion x,y,z,w -} - -Bone19{�¶’†Žw‚Q - 0.000000,0.000000,0.000000; // trans x,y,z - -0.000000,-0.000000,-0.054972,0.998488; // Quaternion x,y,z,w -} - -Bone20{�¶’†Žw‚R - 0.000000,0.000000,0.000000; // trans x,y,z - -0.000000,0.000000,0.104807,0.994492; // Quaternion x,y,z,w -} - -Bone21{�¶–òŽw‚P - 0.000000,0.000000,0.000000; // trans x,y,z - 0.000000,-0.000000,-0.232843,0.972514; // Quaternion x,y,z,w -} - -Bone22{�¶–òŽw‚Q - 0.000000,0.000000,0.000000; // trans x,y,z - 0.000000,-0.000000,-0.188859,0.982004; // Quaternion x,y,z,w -} - -Bone23{�¶–òŽw‚R - 0.000000,0.000000,0.000000; // trans x,y,z - -0.000000,0.000000,0.124675,0.992197; // Quaternion x,y,z,w -} - -Bone24{�¶�¬Žw‚P - 0.000000,0.000000,0.000000; // trans x,y,z - -0.000000,-0.000000,-0.094857,0.995490; // Quaternion x,y,z,w -} - -Bone25{�¶�¬Žw‚Q - 0.000000,0.000000,0.000000; // trans x,y,z - 0.000000,-0.000000,-0.496880,0.867819; // Quaternion x,y,z,w -} - -Bone26{�¶�¬Žw‚R - 0.000000,0.000000,0.000000; // trans x,y,z - -0.000000,-0.000000,0.010000,0.999949; // Quaternion x,y,z,w -} - -Bone27{‰EŒ¨P - 0.000000,0.000000,0.000000; // trans x,y,z - 0.000000,0.000000,0.000000,1.000000; // Quaternion x,y,z,w -} - -Bone28{‰EŒ¨ - 0.000000,0.000000,0.000000; // trans x,y,z - 0.003159,0.000000,-0.105260,0.994440; // Quaternion x,y,z,w -} - -Bone29{‰E˜r - 0.000000,0.000000,0.000000; // trans x,y,z - 0.034463,-0.034156,0.396750,0.916644; // Quaternion x,y,z,w -} - -Bone30{‰E˜r�€ - 0.000000,0.000000,0.000000; // trans x,y,z - 0.000000,0.000000,0.000000,1.000000; // Quaternion x,y,z,w -} - -Bone31{‰E‚Ђ¶ - 0.000000,0.000000,0.000000; // trans x,y,z - 0.014712,0.013995,-0.076793,0.996840; // Quaternion x,y,z,w -} - -Bone32{‰EŽ蝀 - 0.000000,0.000000,0.000000; // trans x,y,z - 0.000000,0.000000,0.000000,1.000000; // Quaternion x,y,z,w -} - -Bone33{‰EŽèŽñ - 0.000000,0.000000,0.000000; // trans x,y,z - 0.028156,0.026783,-0.146962,0.988378; // Quaternion x,y,z,w -} - -Bone34{‰E�eŽw‚P - -0.000000,0.000000,0.000000; // trans x,y,z - 0.002261,0.000573,0.306446,0.951885; // Quaternion x,y,z,w -} - -Bone35{‰E�eŽw‚Q - -0.000000,0.000000,0.000000; // trans x,y,z - 0.047385,0.118953,-0.062146,0.989819; // Quaternion x,y,z,w -} - -Bone36{‰E�lŽw‚P - -0.000000,0.000000,0.000000; // trans x,y,z - 0.020755,-0.017947,-0.064537,0.997538; // Quaternion x,y,z,w -} - -Bone37{‰E�lŽw‚Q - -0.000000,0.000000,0.000000; // trans x,y,z - 0.000000,-0.000000,-0.024997,0.999687; // Quaternion x,y,z,w -} - -Bone38{‰E�lŽw‚R - -0.000000,0.000000,0.000000; // trans x,y,z - 0.000000,-0.000000,-0.029995,0.999550; // Quaternion x,y,z,w -} - -Bone39{‰E’†Žw‚P - -0.000000,0.000000,0.000000; // trans x,y,z - -0.000000,0.000000,0.064954,0.997888; // Quaternion x,y,z,w -} - -Bone40{‰E’†Žw‚Q - -0.000000,0.000000,0.000000; // trans x,y,z - -0.000000,0.000000,0.054972,0.998488; // Quaternion x,y,z,w -} - -Bone41{‰E’†Žw‚R - -0.000000,0.000000,0.000000; // trans x,y,z - -0.000000,-0.000000,-0.104807,0.994492; // Quaternion x,y,z,w -} - -Bone42{‰E–òŽw‚P - -0.000000,0.000000,0.000000; // trans x,y,z - 0.000000,0.000000,0.232843,0.972514; // Quaternion x,y,z,w -} - -Bone43{‰E–òŽw‚Q - -0.000000,0.000000,0.000000; // trans x,y,z - 0.000000,0.000000,0.188859,0.982004; // Quaternion x,y,z,w -} - -Bone44{‰E–òŽw‚R - -0.000000,0.000000,0.000000; // trans x,y,z - -0.000000,-0.000000,-0.124675,0.992197; // Quaternion x,y,z,w -} - -Bone45{‰E�¬Žw‚P - -0.000000,0.000000,0.000000; // trans x,y,z - -0.000000,0.000000,0.094857,0.995490; // Quaternion x,y,z,w -} - -Bone46{‰E�¬Žw‚Q - -0.000000,0.000000,0.000000; // trans x,y,z - 0.000000,0.000000,0.496880,0.867819; // Quaternion x,y,z,w -} - -Bone47{‰E�¬Žw‚R - -0.000000,0.000000,0.000000; // trans x,y,z - -0.000000,0.000000,-0.010000,0.999949; // Quaternion x,y,z,w -} - -Bone48{�¶‘« - 0.000000,0.000000,0.000000; // trans x,y,z - 0.000000,0.000000,0.000000,1.000000; // Quaternion x,y,z,w -} - -Bone49{�¶‚Ђ´ - 0.000000,0.000000,0.000000; // trans x,y,z - 0.000000,0.000000,0.000000,1.000000; // Quaternion x,y,z,w -} - -Bone50{�¶‘«Žñ - 0.000000,0.000000,0.000000; // trans x,y,z - 0.000000,0.000000,0.000000,1.000000; // Quaternion x,y,z,w -} - -Bone51{‰E‘« - 0.000000,0.000000,0.000000; // trans x,y,z - 0.000000,0.000000,0.000000,1.000000; // Quaternion x,y,z,w -} - -Bone52{‰E‚Ђ´ - 0.000000,0.000000,0.000000; // trans x,y,z - 0.000000,0.000000,0.000000,1.000000; // Quaternion x,y,z,w -} - -Bone53{‰E‘«Žñ - 0.000000,0.000000,0.000000; // trans x,y,z - 0.000000,0.000000,0.000000,1.000000; // Quaternion x,y,z,w -} - -Bone54{�¶‚‚ܐæ - 0.000000,0.000000,0.000000; // trans x,y,z - 0.000000,0.000000,0.000000,1.000000; // Quaternion x,y,z,w -} - -Bone55{‰E‚‚ܐæ - 0.000000,0.000000,0.000000; // trans x,y,z - 0.000000,0.000000,0.000000,1.000000; // Quaternion x,y,z,w -} - -Bone56{�¶‘«‚h‚j - -0.132786,0.336300,0.033801; // trans x,y,z - 0.000000,0.000000,0.000000,1.000000; // Quaternion x,y,z,w -} - -Bone57{‰E‘«‚h‚j - 0.148176,0.000000,0.001482; // trans x,y,z - 0.000000,0.000000,0.000000,1.000000; // Quaternion x,y,z,w -} - -Bone58{�¶‚‚ܐæ‚h‚j - -0.419457,-0.807707,-0.002797; // trans x,y,z - 0.000000,0.000000,0.000000,1.000000; // Quaternion x,y,z,w -} - -Bone59{‰E‚‚ܐæ‚h‚j - 0.069849,-0.366887,0.000000; // trans x,y,z - 0.000000,0.000000,0.000000,1.000000; // Quaternion x,y,z,w -} - diff --git a/frontend/apps/artcraft/app/public/resources/pose/Lumine Idle cycle.vmd b/frontend/apps/artcraft/app/public/resources/pose/Lumine Idle cycle.vmd deleted file mode 100644 index 31db30dce9..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/pose/Lumine Idle cycle.vmd and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/shapes/cube.png b/frontend/apps/artcraft/app/public/resources/shapes/cube.png deleted file mode 100644 index 51cb24114c..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/shapes/cube.png and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/shapes/cylinder.png b/frontend/apps/artcraft/app/public/resources/shapes/cylinder.png deleted file mode 100644 index 73cf7eaec4..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/shapes/cylinder.png and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/shapes/donut.png b/frontend/apps/artcraft/app/public/resources/shapes/donut.png deleted file mode 100644 index bb4e5a0fbb..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/shapes/donut.png and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/shapes/pointlight.png b/frontend/apps/artcraft/app/public/resources/shapes/pointlight.png deleted file mode 100644 index 2fd80d5677..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/shapes/pointlight.png and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/shapes/sphere.png b/frontend/apps/artcraft/app/public/resources/shapes/sphere.png deleted file mode 100644 index b482e9fa30..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/shapes/sphere.png and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/shapes/water.png b/frontend/apps/artcraft/app/public/resources/shapes/water.png deleted file mode 100644 index ad1251a700..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/shapes/water.png and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/skybox/black.jpg b/frontend/apps/artcraft/app/public/resources/skybox/black.jpg deleted file mode 100644 index 01e7d8a48d..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/skybox/black.jpg and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/skybox/day/nx.webp b/frontend/apps/artcraft/app/public/resources/skybox/day/nx.webp deleted file mode 100644 index 0339ce6915..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/skybox/day/nx.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/skybox/day/ny.webp b/frontend/apps/artcraft/app/public/resources/skybox/day/ny.webp deleted file mode 100644 index c7fd8e47da..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/skybox/day/ny.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/skybox/day/nz.webp b/frontend/apps/artcraft/app/public/resources/skybox/day/nz.webp deleted file mode 100644 index 2f4c856676..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/skybox/day/nz.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/skybox/day/px.webp b/frontend/apps/artcraft/app/public/resources/skybox/day/px.webp deleted file mode 100644 index ffb6f051cd..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/skybox/day/px.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/skybox/day/py.webp b/frontend/apps/artcraft/app/public/resources/skybox/day/py.webp deleted file mode 100644 index 46f7e73ed6..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/skybox/day/py.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/skybox/day/pz.webp b/frontend/apps/artcraft/app/public/resources/skybox/day/pz.webp deleted file mode 100644 index 78aa941511..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/skybox/day/pz.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/skybox/gray/Sky_AllSky_Overcast4_Low_Cam_0_FrontZ.webp b/frontend/apps/artcraft/app/public/resources/skybox/gray/Sky_AllSky_Overcast4_Low_Cam_0_FrontZ.webp deleted file mode 100644 index db9ed476ae..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/skybox/gray/Sky_AllSky_Overcast4_Low_Cam_0_FrontZ.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/skybox/gray/Sky_AllSky_Overcast4_Low_Cam_1_Back-Z.webp b/frontend/apps/artcraft/app/public/resources/skybox/gray/Sky_AllSky_Overcast4_Low_Cam_1_Back-Z.webp deleted file mode 100644 index 10a529c12a..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/skybox/gray/Sky_AllSky_Overcast4_Low_Cam_1_Back-Z.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/skybox/gray/Sky_AllSky_Overcast4_Low_Cam_2_LeftX.webp b/frontend/apps/artcraft/app/public/resources/skybox/gray/Sky_AllSky_Overcast4_Low_Cam_2_LeftX.webp deleted file mode 100644 index 0e2c486a68..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/skybox/gray/Sky_AllSky_Overcast4_Low_Cam_2_LeftX.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/skybox/gray/Sky_AllSky_Overcast4_Low_Cam_3_Right-X.webp b/frontend/apps/artcraft/app/public/resources/skybox/gray/Sky_AllSky_Overcast4_Low_Cam_3_Right-X.webp deleted file mode 100644 index 1631047a86..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/skybox/gray/Sky_AllSky_Overcast4_Low_Cam_3_Right-X.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/skybox/gray/Sky_AllSky_Overcast4_Low_Cam_4_UpY.webp b/frontend/apps/artcraft/app/public/resources/skybox/gray/Sky_AllSky_Overcast4_Low_Cam_4_UpY.webp deleted file mode 100644 index d2d3b7b28e..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/skybox/gray/Sky_AllSky_Overcast4_Low_Cam_4_UpY.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/skybox/gray/Sky_AllSky_Overcast4_Low_Cam_5_Down-Y.webp b/frontend/apps/artcraft/app/public/resources/skybox/gray/Sky_AllSky_Overcast4_Low_Cam_5_Down-Y.webp deleted file mode 100644 index 3cb86a0ac3..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/skybox/gray/Sky_AllSky_Overcast4_Low_Cam_5_Down-Y.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/skybox/night/Night_Moon_Burst_Cam_0_FrontZ.webp b/frontend/apps/artcraft/app/public/resources/skybox/night/Night_Moon_Burst_Cam_0_FrontZ.webp deleted file mode 100644 index df05a3496b..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/skybox/night/Night_Moon_Burst_Cam_0_FrontZ.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/skybox/night/Night_Moon_Burst_Cam_1_Back-Z.webp b/frontend/apps/artcraft/app/public/resources/skybox/night/Night_Moon_Burst_Cam_1_Back-Z.webp deleted file mode 100644 index 6ba76abdfd..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/skybox/night/Night_Moon_Burst_Cam_1_Back-Z.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/skybox/night/Night_Moon_Burst_Cam_2_LeftX.webp b/frontend/apps/artcraft/app/public/resources/skybox/night/Night_Moon_Burst_Cam_2_LeftX.webp deleted file mode 100644 index 8b07856a80..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/skybox/night/Night_Moon_Burst_Cam_2_LeftX.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/skybox/night/Night_Moon_Burst_Cam_3_Right-X.webp b/frontend/apps/artcraft/app/public/resources/skybox/night/Night_Moon_Burst_Cam_3_Right-X.webp deleted file mode 100644 index d6f3157017..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/skybox/night/Night_Moon_Burst_Cam_3_Right-X.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/skybox/night/Night_Moon_Burst_Cam_4_UpY.webp b/frontend/apps/artcraft/app/public/resources/skybox/night/Night_Moon_Burst_Cam_4_UpY.webp deleted file mode 100644 index 082800e9a9..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/skybox/night/Night_Moon_Burst_Cam_4_UpY.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/skybox/night/Night_Moon_Burst_Cam_5_Down-Y.webp b/frontend/apps/artcraft/app/public/resources/skybox/night/Night_Moon_Burst_Cam_5_Down-Y.webp deleted file mode 100644 index 72a4c18027..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/skybox/night/Night_Moon_Burst_Cam_5_Down-Y.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/skybox/single.webp b/frontend/apps/artcraft/app/public/resources/skybox/single.webp deleted file mode 100644 index e2a5f213c5..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/skybox/single.webp and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/sound/2pac.wav b/frontend/apps/artcraft/app/public/resources/sound/2pac.wav deleted file mode 100644 index d6a9f825e3..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/sound/2pac.wav and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/sound/goldensun_101.wav b/frontend/apps/artcraft/app/public/resources/sound/goldensun_101.wav deleted file mode 100644 index ecdaa953cb..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/sound/goldensun_101.wav and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/sound/goldensun_102.wav b/frontend/apps/artcraft/app/public/resources/sound/goldensun_102.wav deleted file mode 100644 index d508557bd7..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/sound/goldensun_102.wav and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/sound/goldensun_111.wav b/frontend/apps/artcraft/app/public/resources/sound/goldensun_111.wav deleted file mode 100644 index c477f5c4d0..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/sound/goldensun_111.wav and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/sound/goldensun_113.wav b/frontend/apps/artcraft/app/public/resources/sound/goldensun_113.wav deleted file mode 100644 index 5ae208c9d1..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/sound/goldensun_113.wav and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/sound/goldensun_135.wav b/frontend/apps/artcraft/app/public/resources/sound/goldensun_135.wav deleted file mode 100644 index 30b04b46fa..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/sound/goldensun_135.wav and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/sound/goldensun_173.wav b/frontend/apps/artcraft/app/public/resources/sound/goldensun_173.wav deleted file mode 100644 index 70eeab321a..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/sound/goldensun_173.wav and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/sound/goldensun_174.wav b/frontend/apps/artcraft/app/public/resources/sound/goldensun_174.wav deleted file mode 100644 index 2845ef0dee..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/sound/goldensun_174.wav and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/sound/goldensun_175.wav b/frontend/apps/artcraft/app/public/resources/sound/goldensun_175.wav deleted file mode 100644 index d0f5e053d7..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/sound/goldensun_175.wav and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/sound/goldensun_214.wav b/frontend/apps/artcraft/app/public/resources/sound/goldensun_214.wav deleted file mode 100644 index fd58d5521e..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/sound/goldensun_214.wav and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/sound/metroidprime_UI_12.wav b/frontend/apps/artcraft/app/public/resources/sound/metroidprime_UI_12.wav deleted file mode 100644 index 2323f269fa..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/sound/metroidprime_UI_12.wav and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/sound/metroidprime_UI_13.wav b/frontend/apps/artcraft/app/public/resources/sound/metroidprime_UI_13.wav deleted file mode 100644 index fdd1442c7e..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/sound/metroidprime_UI_13.wav and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/sound/metroidprime_UI_14.wav b/frontend/apps/artcraft/app/public/resources/sound/metroidprime_UI_14.wav deleted file mode 100644 index c43944278a..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/sound/metroidprime_UI_14.wav and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/sound/metroidprime_UI_15.wav b/frontend/apps/artcraft/app/public/resources/sound/metroidprime_UI_15.wav deleted file mode 100644 index a51077fe51..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/sound/metroidprime_UI_15.wav and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/sound/metroidprime_UI_18.wav b/frontend/apps/artcraft/app/public/resources/sound/metroidprime_UI_18.wav deleted file mode 100644 index f6eb93512c..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/sound/metroidprime_UI_18.wav and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/sound/metroidprime_UI_51.wav b/frontend/apps/artcraft/app/public/resources/sound/metroidprime_UI_51.wav deleted file mode 100644 index 649699fd36..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/sound/metroidprime_UI_51.wav and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/sound/metroidprime_UI_52.wav b/frontend/apps/artcraft/app/public/resources/sound/metroidprime_UI_52.wav deleted file mode 100644 index 467db39108..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/sound/metroidprime_UI_52.wav and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/sound/monologue.wav b/frontend/apps/artcraft/app/public/resources/sound/monologue.wav deleted file mode 100644 index c26cf84f04..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/sound/monologue.wav and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/sound/oot_dialogue_done.wav b/frontend/apps/artcraft/app/public/resources/sound/oot_dialogue_done.wav deleted file mode 100644 index 6a34234919..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/sound/oot_dialogue_done.wav and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/sound/oot_dialogue_next.wav b/frontend/apps/artcraft/app/public/resources/sound/oot_dialogue_next.wav deleted file mode 100644 index 33fdd81998..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/sound/oot_dialogue_next.wav and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/sound/oot_scrub_crumble.wav b/frontend/apps/artcraft/app/public/resources/sound/oot_scrub_crumble.wav deleted file mode 100644 index cacadcc22c..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/sound/oot_scrub_crumble.wav and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/sound/smrpg_click.wav b/frontend/apps/artcraft/app/public/resources/sound/smrpg_click.wav deleted file mode 100644 index f954d9c709..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/sound/smrpg_click.wav and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/sound/smrpg_enemy_staticE.wav b/frontend/apps/artcraft/app/public/resources/sound/smrpg_enemy_staticE.wav deleted file mode 100644 index f6507d6413..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/sound/smrpg_enemy_staticE.wav and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/sound/smrpg_mario_giantshellkick.wav b/frontend/apps/artcraft/app/public/resources/sound/smrpg_mario_giantshellkick.wav deleted file mode 100644 index 0a0a24ec0c..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/sound/smrpg_mario_giantshellkick.wav and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/uiAssets/video_player_placeholder.gif b/frontend/apps/artcraft/app/public/resources/uiAssets/video_player_placeholder.gif deleted file mode 100644 index b6a8dea036..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/uiAssets/video_player_placeholder.gif and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/videos/artcraft-3d-demo.mp4 b/frontend/apps/artcraft/app/public/resources/videos/artcraft-3d-demo.mp4 deleted file mode 100644 index f0b86eb82b..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/videos/artcraft-3d-demo.mp4 and /dev/null differ diff --git a/frontend/apps/artcraft/app/public/resources/videos/artcraft-canvas-demo.mp4 b/frontend/apps/artcraft/app/public/resources/videos/artcraft-canvas-demo.mp4 deleted file mode 100644 index 0e98e936a9..0000000000 Binary files a/frontend/apps/artcraft/app/public/resources/videos/artcraft-canvas-demo.mp4 and /dev/null differ diff --git a/frontend/apps/artcraft/app/src/BuildEnvironment.ts b/frontend/apps/artcraft/app/src/BuildEnvironment.ts deleted file mode 100644 index 21b0b25e36..0000000000 --- a/frontend/apps/artcraft/app/src/BuildEnvironment.ts +++ /dev/null @@ -1,61 +0,0 @@ - -/** - * This is cached whenever vite/remix/whatever launches. - * It's fed from an environment variable. - */ -export enum BuildEnvironmentType { - Dev, - DevProxy, - Staging, - Production, -} - -export class BuildEnvironment { - private static instance: BuildEnvironment; - private readonly environmentType: BuildEnvironmentType; - - public static getInstance(): BuildEnvironment { - if (BuildEnvironment.instance !== undefined) { - return BuildEnvironment.instance; - } - - // https://v2.vitejs.dev/guide/env-and-mode.html - console.log('Reading environment variable: `VITE_ENVIRONMENT_TYPE` to determine build environment.') - console.log(`Environment variable 'VITE_ENVIRONMENT_TYPE' = ${import.meta.env.VITE_ENVIRONMENT_TYPE}`) - - const environmentLabel : string | undefined = import.meta.env.VITE_ENVIRONMENT_TYPE; - - let environmentType = BuildEnvironmentType.Production; - - switch (environmentLabel?.toLocaleLowerCase()) { - case "dev": - case "development": - environmentType = BuildEnvironmentType.Dev; - break; - case "dev-proxy": - case "devproxy": - environmentType = BuildEnvironmentType.DevProxy; - break; - case "stage": - case "staging": - environmentType = BuildEnvironmentType.Staging; - break; - } - - const instance = new BuildEnvironment(environmentType); - BuildEnvironment.instance = instance; - return instance; - } - - public getBuildEnvironmentType(): BuildEnvironmentType { - return this.environmentType; - } - - private constructor(environmentType: BuildEnvironmentType) { - this.environmentType = environmentType; - } -} - -export function GetBuildEnvironment() : BuildEnvironment { - return BuildEnvironment.getInstance(); -} diff --git a/frontend/apps/artcraft/app/src/Classes/ApiHelpers.ts b/frontend/apps/artcraft/app/src/Classes/ApiHelpers.ts deleted file mode 100644 index 20ff1ba595..0000000000 --- a/frontend/apps/artcraft/app/src/Classes/ApiHelpers.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { GetCdnOrigin } from "~/api/GetCdnOrigin"; -import { StorytellerApiHostStore } from "@storyteller/api"; - -export async function get_media_url(mediaId: string) { - //This is for prod when we have the proper info on the url. - const apiSchemeAndHost = StorytellerApiHostStore.getInstance().getApiSchemeAndHost(); - const url = `${apiSchemeAndHost}/v1/media_files/file/${mediaId}`; - - const response = await fetch(url); - const json = await JSON.parse(await response.text()); - const bucketPath = json["media_file"]["public_bucket_path"]; - - const media_api_base_url = GetCdnOrigin(); - - const media_url = `${media_api_base_url}${bucketPath}`; - return media_url; -} diff --git a/frontend/apps/artcraft/app/src/Classes/ApiManager/ApiManager.ts b/frontend/apps/artcraft/app/src/Classes/ApiManager/ApiManager.ts deleted file mode 100644 index 480d2031c9..0000000000 --- a/frontend/apps/artcraft/app/src/Classes/ApiManager/ApiManager.ts +++ /dev/null @@ -1,217 +0,0 @@ -import { GetBuildEnvironment } from "~/BuildEnvironment"; -import environmentVariables from "../EnvironmentVariables"; -import { Configs } from "~/configs"; -import { FetchProxy as fetch } from "@storyteller/tauri-utils"; -import { StorytellerApiHostStore } from "@storyteller/api"; - -type NonNullableObject = NonNullable; - -export interface ApiResponse { - success: boolean; - errorMessage?: string; - data?: T; - pagination?: P; -} - -export class ApiManager { - ApiTargets: Record = {}; - - constructor() { - const environmentType = GetBuildEnvironment().getBuildEnvironmentType(); - const configs = new Configs(environmentType); - - // TODO(bt,2025-07-06): Not sure that any of this is used anymore. - // If so, try to use Configs, StorytellerApiHostStore, or another configuration source. - - // look at the .env file - this.ApiTargets = { - GoggleApi: environmentVariables.values.GOOGLE_API as string, - FunnelApi: environmentVariables.values.FUNNEL_API as string, - CdnApi: environmentVariables.values.CDN_API as string, - GravatarApi: environmentVariables.values.GRAVATAR_API as string, - uploadApi: environmentVariables.values.UPLOAD_API_VIDEO as string, - }; - } - - protected getApiSchemeAndHost(): string { - return StorytellerApiHostStore.getInstance().getApiSchemeAndHost(); - } - - public async fetch( - endpoint: string, - { - method, - query, - body, - }: { - method: string; - query?: Record; - body?: B; - }, - ): Promise { - const queryInString = - query && - Object.entries(query).reduce( - (allOptions, [key, value]) => { - if (!value) { - return allOptions; - } - allOptions[key] = value.toString(); - return allOptions; - }, - {} as Record, - ); - - const endpointWithQueries = queryInString - ? endpoint + "?" + new URLSearchParams(queryInString) - : endpoint; - - const bodyInString = JSON.stringify(body); - - const response = await fetch(endpointWithQueries, { - method, - headers: { - Accept: "application/json", - "Content-Type": "application/json", - }, - credentials: "include", - body: bodyInString, - }); - return response.json(); - } - - public async fetchMultipartFormData( - endpoint: string, - { - method, - body, - }: { - method: string; - body: FormData; - }, - ): Promise { - const response = await fetch(endpoint, { - method, - headers: { - Accept: "application/json", - }, - credentials: "include", - body: body, - }); - return response.json(); - } - - protected get({ - endpoint, - query, - }: { - endpoint: string; - query?: Record; - }): Promise { - return this.fetch(endpoint, { method: "GET", query }); - } - - protected post({ - endpoint, - query, - body, - }: { - endpoint: string; - query?: Record; - body?: B; - }): Promise { - return this.fetch(endpoint, { - method: "POST", - query, - body, - }); - } - - protected delete({ - endpoint, - query, - body, - }: { - endpoint: string; - query?: Record; - body?: B; - }): Promise { - return this.fetch(endpoint, { - method: "DELETE", - query, - body, - }); - } - - protected async postForm({ - endpoint, - formRecord, - uuid, - blob, - blobFileName, - }: { - endpoint: string; - formRecord: Record; - uuid: string; - blob?: Blob | File; - blobFileName?: string; - }): Promise { - const formData = new FormData(); - formData.append("uuid_idempotency_token", uuid); - Object.entries(formRecord).forEach(([key, value]) => { - formData.append(key, value); - }); - if (blob && blobFileName) { - formData.append("file", blob, blobFileName); - } else if (blob) { - formData.append("file", blob); - } - - console.log(`HELLO${formData}`); - return this.fetchMultipartFormData(endpoint, { - method: "POST", - headers: { - Accept: "application/json", - }, - credentials: "include", - body: formData, - }); - } - - protected camelToSnakeCase(str: string) { - return str.replace(/([a-z0])([A-Z])/g, "$1_$2").toLowerCase(); - } - - protected parseQueryValues( - params: Record, - ): Record { - return Object.entries(params).reduce( - (allParams, [key, value]) => { - if (!value) { - return allParams; - } - const snakeKey = this.camelToSnakeCase(key); - if (Array.isArray(value)) { - return { ...allParams, [snakeKey]: value.join(",") }; - } - return { ...allParams, [snakeKey]: value.toString() }; - }, - {} as Record, - ); - } - - protected parseBodyValues( - params: NonNullableObject, - ): B { - return Object.entries(params).reduce((allParams, [key, value]) => { - if (!value) { - return allParams; - } - const snakeKey = this.camelToSnakeCase(key); - if (Array.isArray(value)) { - return { ...allParams, [snakeKey]: value }; - } - return { ...allParams, [snakeKey]: value }; - }, {} as B); - } -} diff --git a/frontend/apps/artcraft/app/src/Classes/ApiManager/BetaKeysApi.ts b/frontend/apps/artcraft/app/src/Classes/ApiManager/BetaKeysApi.ts deleted file mode 100644 index a089e67b19..0000000000 --- a/frontend/apps/artcraft/app/src/Classes/ApiManager/BetaKeysApi.ts +++ /dev/null @@ -1,167 +0,0 @@ -import { ApiManager, ApiResponse } from "./ApiManager"; -import { BetaKey } from "~/models"; -import type { Pagination } from "@storyteller/ui-pagescene"; - -export class BetaKeysApi extends ApiManager { - public CreateBetaKey({ - maybeNote, - maybeReferrerUsername, - numberOfKeys, - uuidIdempotencyToken, - }: { - maybeNote?: string; - maybeReferrerUsername?: string; - numberOfKeys: number; - uuidIdempotencyToken: string; - }): Promise> { - const endpoint = `${this.getApiSchemeAndHost()}/v1/beta_keys/create`; - - const body = { - maybe_note: maybeNote, - maybe_referrer_username: maybeReferrerUsername, - number_of_keys: numberOfKeys, - uuid_idempotency_token: uuidIdempotencyToken, - }; - - return this.post< - { - maybe_note?: string; - maybe_referrer_username?: string; - number_of_keys: number; - uuid_idempotency_token: string; - }, - { - success?: boolean; - beta_keys?: string[]; - BadInput?: string; - } - >({ endpoint, body }) - .then((response) => ({ - success: response.success ?? false, - data: response.beta_keys, - errorMessage: response.BadInput, - })) - .catch((err) => { - return { success: false, errorMessage: err.message }; - }); - } - - public ListBetaKeys({ - sortAscending, - pageSize, - pageIndex, - maybeReferrerUsername, - onlyListRemaining, - }: { - sortAscending?: boolean; - pageSize?: number; - pageIndex?: number; - maybeReferrerUsername?: string; - onlyListRemaining?: boolean; - }): Promise> { - const endpoint = `${this.getApiSchemeAndHost()}/v1/beta_keys/list`; - - const query = { - sort_ascending: sortAscending, - page_size: pageSize, - page_index: pageIndex, - maybe_referrer_username: maybeReferrerUsername, - only_list_remaining: onlyListRemaining, - }; - - return this.get<{ - success?: boolean; - beta_keys?: BetaKey[]; - pagination?: Pagination; - BadInput?: string; - }>({ endpoint, query }) - .then((response) => ({ - success: response.success ?? false, - data: response.beta_keys, - pagination: response.pagination, - errorMessage: response.BadInput, - })) - .catch((err) => { - return { success: false, errorMessage: err.message }; - }); - } - - public RedeemBetaKey({ - betaKey, - }: { - betaKey: string; - }): Promise> { - const endpoint = `${this.getApiSchemeAndHost()}/v1/beta_keys/redeem`; - - return this.post< - { - beta_key: string; - }, - { - success?: boolean; - BadInput?: string; - } - >({ endpoint, body: { beta_key: betaKey } }) - .then((response) => ({ - success: response.success ?? false, - errorMessage: response.BadInput, - })) - .catch((err) => { - return { success: false, errorMessage: err.message }; - }); - } - - public UpdateBetaKeyIsDistributed({ - betaKey, - isDistributed, - }: { - betaKey: string; - isDistributed: boolean; - }): Promise> { - const endpoint = `${this.getApiSchemeAndHost()}/v1/beta_keys/${betaKey}/distributed`; - - return this.post< - { - is_distributed: boolean; - }, - { - success?: boolean; - BadInput?: string; - } - >({ endpoint, body: { is_distributed: isDistributed } }) - .then((response) => ({ - success: response.success ?? false, - errorMessage: response.BadInput, - })) - .catch((err) => { - return { success: false, errorMessage: err.message }; - }); - } - - public UpdateBetaKeyNote({ - token, - note, - }: { - token: string; - note?: string; - }): Promise> { - const endpoint = `${this.getApiSchemeAndHost()}/v1/beta_keys/${token}/note`; - - return this.post< - { - note?: string; - }, - { - success?: boolean; - BadInput?: string; - } - >({ endpoint, body: { note } }) - .then((response) => ({ - success: response.success ?? false, - errorMessage: response.BadInput, - })) - .catch((err) => { - return { success: false, errorMessage: err.message }; - }); - } -} diff --git a/frontend/apps/artcraft/app/src/Classes/ApiManager/BillingApi.ts b/frontend/apps/artcraft/app/src/Classes/ApiManager/BillingApi.ts deleted file mode 100644 index 51282a16d6..0000000000 --- a/frontend/apps/artcraft/app/src/Classes/ApiManager/BillingApi.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { ApiManager, ApiResponse } from "./ApiManager"; -import { Subscription } from "~/models/Billing"; -import { LoyaltyProgram } from "~/enums"; - -export class BillingApi extends ApiManager { - public async ListActiveSubscriptions(): Promise< - ApiResponse<{ - active_subscriptions: Subscription[]; - maybe_loyalty_program?: LoyaltyProgram; - }> - > { - const endpoint = `${this.getApiSchemeAndHost()}/v1/billing/active_subscriptions`; - return await this.get<{ - success: boolean; - active_subscriptions?: Subscription[]; - maybe_loyalty_program?: LoyaltyProgram; - error_message?: string; - }>({ endpoint: endpoint }) - .then((response) => ({ - success: response.success, - data: { - active_subscriptions: response.active_subscriptions || [], - maybe_loyalty_program: response.maybe_loyalty_program, - }, - })) - .catch((err) => { - return { - success: false, - errorMessage: err.message, - }; - }); - } -} diff --git a/frontend/apps/artcraft/app/src/Classes/ApiManager/CommentsApi.ts b/frontend/apps/artcraft/app/src/Classes/ApiManager/CommentsApi.ts deleted file mode 100644 index d32f8245fb..0000000000 --- a/frontend/apps/artcraft/app/src/Classes/ApiManager/CommentsApi.ts +++ /dev/null @@ -1,91 +0,0 @@ -import { ApiManager, ApiResponse } from "./ApiManager"; - -export class CommentsApi extends ApiManager { - public CreateComment({ - commentMarkdown, - entityToken, - entityType, - uuidIdempotencyToken, - }: { - commentMarkdown: string; - entityToken: string; - entityType: string; - uuidIdempotencyToken: string; - }): Promise> { - const endpoint = `${this.getApiSchemeAndHost()}/v1/comments/new`; - - const body = { - comment_markdown: commentMarkdown, - entity_token: entityToken, - entity_type: entityType, - uuid_idempotency_token: uuidIdempotencyToken, - }; - - return this.post< - { - comment_markdown: string; - entity_token: string; - entity_type: string; - uuid_idempotency_token: string; - }, - { - success?: boolean; - comment_token?: string; - BadInput?: string; - } - >({ endpoint, body }) - .then((response) => ({ - success: response.success ?? false, - data: response.comment_token, - errorMessage: response.BadInput, - })) - .catch((err) => { - return { success: false, errorMessage: err.message }; - }); - } - - public DeleteComment({ - commentToken, - }: { - commentToken: string; - }): Promise> { - const endpoint = `${this.getApiSchemeAndHost()}/v1/comments/delete/${commentToken}`; - - return this.post< - { as_mod: boolean }, - { - success?: boolean; - BadInput?: string; - } - >({ endpoint, body: { as_mod: true } }) - .then((response) => ({ - success: response.success ?? false, - errorMessage: response.BadInput, - })) - .catch((err) => { - return { success: false, errorMessage: err.message }; - }); - } - - public ListCommentsByEntity({ - entityType, - entityToken, - }: { - entityType: string; - entityToken: string; - }): Promise> { - const endpoint = `${this.getApiSchemeAndHost()}/v1/comments/list/${entityType}/${entityToken}`; - - return this.get<{ - success: boolean; - comments: string[]; - }>({ endpoint }) - .then((response) => ({ - success: true, - data: response.comments, - })) - .catch((err) => { - return { success: false, errorMessage: err.message }; - }); - } -} diff --git a/frontend/apps/artcraft/app/src/Classes/ApiManager/EngineApi.ts b/frontend/apps/artcraft/app/src/Classes/ApiManager/EngineApi.ts deleted file mode 100644 index 09723a3b13..0000000000 --- a/frontend/apps/artcraft/app/src/Classes/ApiManager/EngineApi.ts +++ /dev/null @@ -1,89 +0,0 @@ -import { ApiManager, ApiResponse } from "./ApiManager"; - -export class EngineApi extends ApiManager { - public async ConvertTbxToGltf({ - mediaFileToken, - uuidIdempotencyToken, - }: { - mediaFileToken: string; - uuidIdempotencyToken: string; - }): Promise> { - const endpoint = `${this.getApiSchemeAndHost()}/v1/conversion/enqueue_fbx_to_gltf`; - - const body = { - media_file_token: mediaFileToken, - uuid_idempotency_token: uuidIdempotencyToken, - }; - - return this.post< - { media_file_token: string; uuid_idempotency_token: string }, - { success?: boolean; inference_job_token?: string; BadInput?: string } - >({ - endpoint, - body: body, - }) - .then((response) => { - return { - success: response.success ?? false, - data: response.inference_job_token, - errorMessage: response.BadInput, - }; - }) - .catch((err) => { - return { - success: false, - errorMessage: err.message, - }; - }); - } - - public async uploadSceneSnapshot({ - screenshot, - sceneMediaToken, - }: { - screenshot: File; // base64 encoded PNG - sceneMediaToken?: string; - }): Promise> { - const endpoint = `${this.getApiSchemeAndHost()}/v1/image_studio/scene_snapshot`; - const formData = new FormData(); - formData.append("snapshot", screenshot); // Changed from "screenshot" to "snapshot" to match API spec - if (sceneMediaToken) { - formData.append("scene_media_token", sceneMediaToken); - } - - // for now ... - const uuidIdempotencyToken = crypto.randomUUID(); // Generate a new UUID - formData.append("uuid_idempotency_token", uuidIdempotencyToken); // Added uuid_idempotency_token - - const response = await fetch(endpoint, { - method: "POST", - headers: { - Accept: "application/json", - }, - credentials: "include", - body: formData, - }); - - const postResponse = await response.json(); - - console.log(postResponse); - - let result: { success: boolean; data?: string; errorMessage?: string }; - - if (postResponse.success) { - result = { - success: true, - data: postResponse.snapshot_media_token, - errorMessage: undefined, - }; - } else { - result = { - success: false, - errorMessage: postResponse.BadInput, - }; - } - - return result; - } - -} diff --git a/frontend/apps/artcraft/app/src/Classes/ApiManager/FeaturedItemsApi.ts b/frontend/apps/artcraft/app/src/Classes/ApiManager/FeaturedItemsApi.ts deleted file mode 100644 index 431ce3bc9d..0000000000 --- a/frontend/apps/artcraft/app/src/Classes/ApiManager/FeaturedItemsApi.ts +++ /dev/null @@ -1,96 +0,0 @@ -import { ApiManager, ApiResponse } from "./ApiManager"; - -export class FeaturedItemsApi extends ApiManager { - public CreateFeaturedItem({ - entityToken, - entityType, - }: { - entityToken: string; - entityType: string; - }): Promise> { - const endpoint = `${this.getApiSchemeAndHost()}/v1/featured_item/create`; - - const body = { - entity_token: entityToken, - entity_type: entityType, - }; - - return this.post< - { - entity_token: string; - entity_type: string; - }, - { - success?: boolean; - BadInput?: string; - } - >({ endpoint, body }) - .then((response) => ({ - success: response.success ?? false, - errorMessage: response.BadInput, - })) - .catch((err) => { - return { success: false, errorMessage: err.message }; - }); - } - - public DeleteFeaturedItem({ - entityToken, - entityType, - }: { - entityToken: string; - entityType: string; - }): Promise> { - const endpoint = `${this.getApiSchemeAndHost()}/v1/featured_item/delete`; - - const body = { - entity_token: entityToken, - entity_type: entityType, - }; - - return this.delete< - { - entity_token: string; - entity_type: string; - }, - { - success?: boolean; - BadInput?: string; - } - >({ endpoint, body }) - .then((response) => ({ - success: response.success ?? false, - errorMessage: response.BadInput, - })) - .catch((err) => { - return { success: false, errorMessage: err.message }; - }); - } - - public CheckFeaturedItem({ - entityType, - entityToken, - }: { - entityType: string; - entityToken: string; - }): Promise> { - const endpoint = `${this.getApiSchemeAndHost()}/v1/featured_item/is_featured/${entityType}/${entityToken}`; - - return this.post< - undefined, - { - success?: boolean; - is_featured?: boolean; - BadInput?: string; - } - >({ endpoint }) - .then((response) => ({ - success: response.success ?? false, - data: response.is_featured, - errorMessage: response.BadInput, - })) - .catch((err) => { - return { success: false, errorMessage: err.message }; - }); - } -} diff --git a/frontend/apps/artcraft/app/src/Classes/ApiManager/JobsApi.ts b/frontend/apps/artcraft/app/src/Classes/ApiManager/JobsApi.ts deleted file mode 100644 index a9b4b8da65..0000000000 --- a/frontend/apps/artcraft/app/src/Classes/ApiManager/JobsApi.ts +++ /dev/null @@ -1,74 +0,0 @@ -import { ApiManager, ApiResponse } from "./ApiManager"; -import { Job, JobState } from "~/models"; - -export class JobsApi extends ApiManager { - public GetJobByToken({ - token, - }: { - token: string; - }): Promise> { - const endpoint = `${this.getApiSchemeAndHost()}/v1/jobs/job/${token}`; - - return this.get<{ - success: boolean; - state: JobState; - }>({ endpoint }) - .then((response) => ({ - success: response.success, - data: response.state, - })) - .catch((err) => { - return { success: false, errorMessage: err.message }; - }); - } - - public ListJobs(): Promise> { - const endpoint = `${this.getApiSchemeAndHost()}/v1/jobs/batch`; - - return this.get<{ - success: boolean; - job_states: JobState[]; - }>({ endpoint }) - .then((response) => ({ - success: response.success, - data: response.job_states, - })) - .catch((err) => { - return { success: false, errorMessage: err.message }; - }); - } - - public ListRecentJobs(): Promise> { - const endpoint = `${this.getApiSchemeAndHost()}/v1/jobs/session`; - - return this.get<{ - success: boolean; - jobs: Job[]; - error_reason?: string; - }>({ endpoint }) - .then((response) => ({ - success: response.success, - data: response.jobs, - })) - .catch((err) => { - return { success: false, errorMessage: err.message }; - }); - } - - public DeleteJobByToken(jobToken: string): Promise> { - const endpoint = `${this.getApiSchemeAndHost()}/v1/jobs/job/${jobToken}`; - - return this.delete< - undefined, - { - success: boolean; - } - >({ endpoint }) - .then((response) => ({ - success: response.success, - })) - .catch((err) => { - return { success: false, errorMessage: err.message }; - }); - } -} diff --git a/frontend/apps/artcraft/app/src/Classes/ApiManager/MediaFilesApi.ts b/frontend/apps/artcraft/app/src/Classes/ApiManager/MediaFilesApi.ts deleted file mode 100644 index 9dde488f64..0000000000 --- a/frontend/apps/artcraft/app/src/Classes/ApiManager/MediaFilesApi.ts +++ /dev/null @@ -1,399 +0,0 @@ -import type { - MediaFile, - MediaInfo, - Pagination, - PaginationInfinite, -} from "@storyteller/ui-pagescene"; -import { ApiManager, ApiResponse } from "./ApiManager"; -import { authentication } from "~/signals"; -import type { Property } from "csstype"; -import { Visibility } from "~/enums"; - -import { - FilterEngineCategories, - FilterMediaClasses, - FilterMediaType, -} from "~/enums"; - -interface ListMediaQuery { - sort_ascending?: boolean; - page_size?: number; - cursor?: string; - cursor_is_reversed?: boolean; - filter_media_classes?: FilterMediaClasses[]; - filter_media_type?: FilterMediaType[]; - filter_engine_categories?: FilterEngineCategories[]; -} - -interface ListUserMediaQuery { - sort_ascending?: boolean; - page_size?: number; - page_index?: number; - filter_media_classes?: FilterMediaClasses[]; - filter_media_type?: FilterMediaType[]; - filter_engine_categories?: FilterEngineCategories[]; -} - -interface SearchFeaturedMediaQuery { - search_term: string; - filter_media_classes?: FilterMediaClasses[]; - filter_media_type?: FilterMediaType[]; - filter_engine_categories?: FilterEngineCategories[]; -} - -export class MediaFilesApi extends ApiManager { - - public async ListMediaFilesByTokens({ - mediaTokens, - }: { - mediaTokens: string[]; - }): Promise> { - const endpoint = `${this.getApiSchemeAndHost()}/v1/media_files/batch`; - - return await this.get<{ - success: boolean; - media_files: MediaFile[]; - error_reason?: string; - }>({ endpoint, query: { tokens: mediaTokens.join(",") } }) - .then((response) => ({ - success: response.success, - data: response.media_files, - })) - .catch((err) => { - return { success: false, errorMessage: err.message }; - }); - } - - public async GetMediaFileByToken({ - mediaFileToken, - }: { - mediaFileToken: string; - }): Promise> { - const endpoint = `${this.getApiSchemeAndHost()}/v1/media_files/file/${mediaFileToken}`; - return await this.get<{ - success: boolean; - media_file: MediaFile; - }>({ endpoint }) - .then((response) => ({ - success: response.success, - data: response.media_file, - })) - .catch((err) => { - return { - success: false, - errorMessage: err.message, - }; - }); - } - - public async ListMediaFiles( - query: ListMediaQuery, - ): Promise> { - const endpoint = `${this.getApiSchemeAndHost()}/v1/media_files/list`; - const queryWithStrings = { - ...query, - filter_media_classes: query.filter_media_classes - ? query.filter_media_classes.join(",") - : undefined, - filter_media_type: query.filter_media_type - ? query.filter_media_type.join(",") - : undefined, - filter_engine_categories: query.filter_engine_categories - ? query.filter_engine_categories.join(",") - : undefined, - }; - return await this.get<{ - success: boolean; - results: MediaInfo[]; - pagination?: PaginationInfinite; - }>({ endpoint, query: queryWithStrings }) - .then((response) => ({ - success: response.success, - data: response.results ?? [], - pagination: response.pagination, - })) - .catch((err) => { - return { - success: false, - errorMessage: err.message, - }; - }); - } - - public async ListFeaturedMediaFiles( - query: ListMediaQuery, - ): Promise> { - const endpoint = `${this.getApiSchemeAndHost()}/v1/media_files/list_featured`; - const queryWithStrings = { - ...query, - filter_media_classes: query.filter_media_classes - ? query.filter_media_classes.join(",") - : undefined, - filter_media_type: query.filter_media_type - ? query.filter_media_type.join(",") - : undefined, - filter_engine_categories: query.filter_engine_categories - ? query.filter_engine_categories.join(",") - : undefined, - }; - return await this.get<{ - success: boolean; - results: MediaInfo[]; - pagination: PaginationInfinite; - }>({ endpoint, query: queryWithStrings }) - .then((response) => ({ - success: true, - data: response.results, - pagination: response.pagination, - })) - .catch((err) => { - return { - success: false, - errorMessage: err.message, - }; - }); - } - - public async ListUserMediaFiles( - query: ListUserMediaQuery, - ): Promise> { - const userName = authentication.userInfo.value?.username; - const endpoint = `${this.getApiSchemeAndHost()}/v1/media_files/list/user/${userName}`; - const queryWithStrings = { - ...query, - include_user_uploads: true, - filter_media_classes: query.filter_media_classes - ? query.filter_media_classes.join(",") - : undefined, - filter_media_type: query.filter_media_type - ? query.filter_media_type.join(",") - : undefined, - filter_engine_categories: query.filter_engine_categories - ? query.filter_engine_categories.join(",") - : undefined, - }; - return await this.get<{ - success: boolean; - results: MediaInfo[]; - pagination?: Pagination; - }>({ endpoint, query: queryWithStrings }) - .then((response) => ({ - success: response.success, - data: response.results ?? [], - pagination: response.pagination, - })) - .catch((err) => { - return { - success: false, - errorMessage: err.message, - }; - }); - } - - public async SearchFeaturedMediaFiles( - query: SearchFeaturedMediaQuery, - ): Promise> { - const endpoint = `${this.getApiSchemeAndHost()}/v1/media_files/search_featured`; - const queryWithStrings = { - search_term: query.search_term, - filter_media_classes: query.filter_media_classes - ? query.filter_media_classes.join(",") - : undefined, - filter_media_type: query.filter_media_type - ? query.filter_media_type.join(",") - : undefined, - filter_engine_categories: query.filter_engine_categories - ? query.filter_engine_categories.join(",") - : undefined, - }; - return await this.get<{ - success: boolean; - results: MediaInfo[]; - pagination: Pagination; - }>({ endpoint, query: queryWithStrings }) - .then((response) => ({ - success: true, - data: response.results, - pagination: response.pagination, - })) - .catch((err) => ({ - success: false, - errorMessage: err.message, - })); - } - - public async SearchUserMediaFiles( - query: SearchFeaturedMediaQuery, - ): Promise> { - const endpoint = `${this.getApiSchemeAndHost()}/v1/media_files/search_session`; - const queryWithStrings = { - search_term: query.search_term, - filter_media_classes: query.filter_media_classes - ? query.filter_media_classes.join(",") - : undefined, - filter_media_type: query.filter_media_type - ? query.filter_media_type.join(",") - : undefined, - filter_engine_categories: query.filter_engine_categories - ? query.filter_engine_categories.join(",") - : undefined, - }; - return await this.get<{ - success: boolean; - results: MediaInfo[]; - pagination: Pagination; - }>({ endpoint, query: queryWithStrings }) - .then((response) => ({ - success: true, - data: response.results, - pagination: response.pagination, - })) - .catch((err) => ({ - success: false, - errorMessage: err.message, - })); - } - - public async RenameMediaFileByToken({ - mediaToken, - name, - }: { - mediaToken: string; - name: string; - }): Promise> { - const endpoint = `${this.getApiSchemeAndHost()}/v1/media_files/rename/${mediaToken}`; - const body = { name }; - - return await this.post< - { name: string }, - { - success?: boolean; - BadInput?: string; - } - >({ endpoint, body }) - .then((response) => ({ - success: response.success ?? false, - errorMessage: response.BadInput, - })) - .catch((err) => { - return { success: false, errorMessage: err.message }; - }); - } - - public async UpdateCoverImage({ - mediaFileToken, - imageToken, - }: { - mediaFileToken: string; - imageToken: string; - }): Promise> { - const endpoint = `${this.getApiSchemeAndHost()}/v1/media_files/cover_image/${mediaFileToken}`; - return await this.post< - { cover_image_media_file_token: string }, - { - success?: boolean; - BadInput?: string; - } - >({ endpoint, body: { cover_image_media_file_token: imageToken } }) - .then((response) => ({ - success: response.success ?? false, - errorMessage: response.BadInput, - })) - .catch((err) => { - return { - success: false, - errorMessage: err.message, - }; - }); - } - - public async UpdateVisibility({ - mediaFileToken, - visibility, - }: { - mediaFileToken: string; - visibility: Visibility; - }): Promise> { - const endpoint = `${this.getApiSchemeAndHost()}/v1/media_files/visibility/${mediaFileToken}`; - return await this.post< - { creator_set_visibility: string }, - { - success?: boolean; - BadInput?: string; - } - >({ endpoint, body: { creator_set_visibility: visibility } }) - .then((response) => ({ - success: response.success ?? false, - errorMessage: response.BadInput, - })) - .catch((err) => { - return { - success: false, - errorMessage: err.message, - }; - }); - } - - public async UploadSpzFile({ - file, - fileName, - uuid, - maybe_title, - maybe_visibility = Visibility.Public, - }: { - file: File; - fileName: string; - uuid: string; - maybe_title?: string; - maybe_visibility?: Visibility; - }): Promise> { - const endpoint = `${this.getApiSchemeAndHost()}/v1/media_files/upload/spz`; - const options: Record = { - maybe_title, - maybe_visibility: maybe_visibility?.toString(), - }; - return this.Upload({ endpoint, blob: file, fileName, uuid, options }); - } - - private async Upload({ - endpoint, - uuid, - blob, - fileName, - options, - }: { - endpoint: string; - blob: Blob | File; - fileName: string; - uuid: string; - options: Record; - }): Promise> { - const formRecord = Object.entries(options).reduce( - (allOptions, [key, value]) => { - if (value === undefined) { - return allOptions; - } - return { ...allOptions, [key]: value.toString() }; - }, - {} as Record, - ); - - return await this.postForm<{ - success: boolean; - media_file_token?: string; - BadInput?: string; - }>({ endpoint, formRecord, blob, blobFileName: fileName, uuid }) - .then((response) => ({ - success: Boolean(response.success ?? false), - data: response.media_file_token, - errorMessage: response.BadInput, - })) - .catch((err) => { - return { - success: false, - errorMessage: err.message, - }; - }); - } - -} diff --git a/frontend/apps/artcraft/app/src/Classes/ApiManager/MediaUploadApi.ts b/frontend/apps/artcraft/app/src/Classes/ApiManager/MediaUploadApi.ts deleted file mode 100644 index 623379ac7e..0000000000 --- a/frontend/apps/artcraft/app/src/Classes/ApiManager/MediaUploadApi.ts +++ /dev/null @@ -1,339 +0,0 @@ -import { EIntermediateFile } from "~/enums/EIntermediateFile"; -import { ApiManager, ApiResponse } from "./ApiManager"; -import { FilterEngineCategories, Visibility } from "~/enums"; - -export class MediaUploadApi extends ApiManager { - private sessionToken: string = undefined; - - private async getSessionTokenForUploadStudioShot() { - const endpoint = `${this.getApiSchemeAndHost()}/v1/session_token`; - return await this.get<{ - maybe_signed_session: string; - }>({ endpoint }) - .then((response) => { - return { - success: true, - data: response["maybe_signed_session"], - }; - }) - .catch((err) => { - return { - success: false, - errorMessage: err.message, - }; - }); - } - - public async UploadStudioShot({ - maybe_title, - uuid_idempotency_token, - blob, - fileName, - maybe_visibility, - }: { - maybe_title?: string; - uuid_idempotency_token: string; - blob: Blob | null; - fileName: string; - maybe_visibility?: Visibility; - }): Promise> { - // This function is a bit special it requires that - const endpoint = `${this.ApiTargets.uploadApi}/v1/media_files/upload/studio_shot`; - - if (!this.sessionToken) { - console.log("Session Token"); - const response = await this.getSessionTokenForUploadStudioShot(); - if (response.success && response.data) { - this.sessionToken = response.data; - console.log(`Token ${this.sessionToken}`); - } else { - return { - success: false, - errorMessage: "Could not obtain session tokens.", - }; - } - } else { - console.log(`Session Token: ${this.sessionToken}`); - } - - const options: Record = { - maybe_title, - maybe_frame_rate_fps: 60, - maybe_visibility: maybe_visibility?.toString(), - }; - - const formRecord = Object.entries(options).reduce( - (allOptions, [key, value]) => { - if (value === undefined) { - return allOptions; - } - return { ...allOptions, [key]: value.toString() }; - }, - {} as Record, - ); - - const formData = new FormData(); - formData.append("uuid_idempotency_token", uuid_idempotency_token); - Object.entries(formRecord).forEach(([key, value]) => { - formData.append(key, value); - }); - if (blob && fileName) { - formData.append("file", blob, fileName); - } else if (blob) { - formData.append("file", blob); - } - - const response = await fetch(endpoint, { - method: "POST", - headers: { - Accept: "application/json", - Session: this.sessionToken, - }, - credentials: "include", - body: formData, - }); - - const result = await response.json(); - - if (result.success && result.media_file_token) { - return { success: true, data: result.media_file_token }; - } else { - return { success: false, errorMessage: "Failed to Get Media Token" }; - } - } - - private async Upload({ - endpoint, - uuid, - blob, - fileName, - options, - }: { - endpoint: string; - blob: Blob | File; - fileName: string; - uuid: string; - options: Record; - }): Promise> { - const formRecord = Object.entries(options).reduce( - (allOptions, [key, value]) => { - if (value === undefined) { - return allOptions; - } - return { ...allOptions, [key]: value.toString() }; - }, - {} as Record, - ); - - return await this.postForm<{ - success: boolean; - media_file_token?: string; - BadInput?: string; - }>({ endpoint, formRecord, blob, blobFileName: fileName, uuid }) - .then((response) => ({ - success: Boolean(response.success ?? false), - data: response.media_file_token, - errorMessage: response.BadInput, - })) - .catch((err) => { - return { - success: false, - errorMessage: err.message, - }; - }); - } - - public async UploadAudio({ - blob, - fileName, - uuid, - maybe_title, - maybe_visibility = Visibility.Public, - }: { - blob: Blob; - fileName: string; - uuid: string; - maybe_title?: string | undefined; - maybe_visibility?: Visibility | undefined; - }): Promise> { - const endpoint = `${this.getApiSchemeAndHost()}/v1/media_files/upload/audio`; - const options: Record = { - maybe_title, - maybe_visibility: maybe_visibility?.toString(), - }; - return this.Upload({ endpoint, blob, fileName, uuid, options }); - } - - public async UploadImage({ - blob, - fileName, - uuid, - maybe_title, - maybe_visibility = Visibility.Public, - is_intermediate_system_file = EIntermediateFile.true - }: { - blob: Blob; - fileName: string; - uuid: string; - maybe_title?: string | undefined; - maybe_visibility?: Visibility | undefined; - is_intermediate_system_file?: EIntermediateFile; - }): Promise> { - const endpoint = `${this.getApiSchemeAndHost()}/v1/media_files/upload/image`; - const options: Record = { - is_intermediate_system_file: EIntermediateFile[is_intermediate_system_file], - maybe_title, - maybe_visibility: maybe_visibility?.toString(), - }; - return this.Upload({ endpoint, blob, fileName, uuid, options }); - } - - public async UploadNewEngineAsset({ - file, - fileName, - uuid, - engine_category, - maybe_animation_type, - maybe_duration_millis, - maybe_title, - maybe_visibility = Visibility.Public, - }: { - file: File; - fileName: string; - uuid: string; - engine_category: FilterEngineCategories; - maybe_animation_type?: string; - maybe_duration_millis?: number; - maybe_title?: string; - maybe_visibility?: Visibility; - }): Promise> { - const endpoint = `${this.getApiSchemeAndHost()}/v1/media_files/upload/new_engine_asset`; - const options: Record = { - engine_category, - maybe_title, - maybe_visibility: maybe_visibility?.toString(), - maybe_animation_type, - maybe_duration_millis, - }; - return this.Upload({ endpoint, blob: file, fileName, uuid, options }); - } - - public async UploadNewScene({ - blob, - fileName, - uuid, - maybe_title, - maybe_visibility = Visibility.Public, - }: { - blob: Blob; - fileName: string; - uuid: string; - maybe_title?: string; - maybe_visibility?: Visibility; - }): Promise> { - const endpoint = `${this.getApiSchemeAndHost()}/v1/media_files/upload/new_scene`; - const options: Record = { - maybe_title, - maybe_visibility: maybe_visibility?.toString(), - }; - return this.Upload({ endpoint, blob, fileName, uuid, options }); - } - - public async UploadNewVideo({ - blob, - fileName, - uuid, - maybe_title, - maybe_visibility = Visibility.Public, - maybe_style_name, - maybe_scene_source_media_file_token, - }: { - blob: Blob; - fileName: string; - uuid: string; - maybe_title?: string; - maybe_visibility?: Visibility; - maybe_style_name?: string; - maybe_scene_source_media_file_token?: string; - }): Promise> { - const endpoint = `${this.getApiSchemeAndHost()}/v1/media_files/upload/new_video`; - const options: Record = { - is_intermediate_system_file: "true", - maybe_title, - maybe_visibility: maybe_visibility?.toString(), - maybe_style_name, - maybe_scene_source_media_file_token, - }; - return this.Upload({ endpoint, blob, fileName, uuid, options }); - } - - public async UploadPmx({ - file, - fileName, - uuid, - engine_category, - maybe_animation_type, - maybe_duration_millis, - maybe_title, - maybe_visibility = Visibility.Public, - }: { - file: File; - fileName: string; - uuid: string; - engine_category?: string; - maybe_animation_type?: string; - maybe_duration_millis?: number; - maybe_title?: string; - maybe_visibility?: Visibility; - }): Promise> { - const endpoint = `${this.getApiSchemeAndHost()}/v1/media_files/upload/pmx`; - const options: Record = { - is_intermediate_system_file: "true", - engine_category, - maybe_animation_type, - maybe_duration_millis, - maybe_title, - maybe_visibility, - }; - return this.Upload({ endpoint, blob: file, fileName, uuid, options }); - } - - public async UploadSavedScene({ - blob, - fileName, - uuid, - mediaToken, - }: { - blob: Blob; - fileName: string; - uuid: string; - mediaToken: string; - }): Promise> { - const endpoint = `${this.getApiSchemeAndHost()}/v1/media_files/upload/saved_scene/${mediaToken}`; - const options: Record = {}; - return this.Upload({ endpoint, blob, fileName, uuid, options }); - } - - // this is used to send the scene snapshot to the vst upload endpoint this creates a snapshot of the scene where in we can remix from the og. - public async UploadSceneSnapshotMediaFileForm({ - blob, - uuid, - maybe_title, // title of the scene at the time - maybe_scene_source_media_file_token, // original token that started it all - }: { - blob: Blob; - uuid: string; - maybe_title: string; - maybe_scene_source_media_file_token: string | undefined; - }): Promise> { - const endpoint = `${this.getApiSchemeAndHost()}/v1/media_files/upload/scene_snapshot`; - - const options: Record = { - maybe_title: maybe_title, - maybe_scene_source_media_file_token: maybe_scene_source_media_file_token, - }; - - const fileName = `${maybe_title}-${uuid}`; - return this.Upload({ endpoint, blob, fileName, uuid, options }); // token comes back and send it VST - } -} diff --git a/frontend/apps/artcraft/app/src/Classes/ApiManager/MiscApi.ts b/frontend/apps/artcraft/app/src/Classes/ApiManager/MiscApi.ts deleted file mode 100644 index cfa347f7c1..0000000000 --- a/frontend/apps/artcraft/app/src/Classes/ApiManager/MiscApi.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { ApiManager, ApiResponse } from "./ApiManager"; -import { StatusAlert } from "~/models/StatusAlert"; - -export class MiscApi extends ApiManager { - public GetStatusAlertCheck(): Promise> { - const endpoint = `${this.getApiSchemeAndHost()}/v1/session`; - return this.get<{ - success: boolean; - maybe_alert?: Omit; - refresh_interval_millis: number; - }>({ endpoint: endpoint }) - .then((response) => ({ - success: response.success, - data: { - ...response.maybe_alert, - refresh_interval_millis: response.refresh_interval_millis, - }, - })) - .catch((err) => { - return { - success: false, - errorMessage: err.mesasge, - }; - }); - } -} diff --git a/frontend/apps/artcraft/app/src/Classes/ApiManager/ModerationApi.ts b/frontend/apps/artcraft/app/src/Classes/ApiManager/ModerationApi.ts deleted file mode 100644 index d476726b25..0000000000 --- a/frontend/apps/artcraft/app/src/Classes/ApiManager/ModerationApi.ts +++ /dev/null @@ -1,42 +0,0 @@ -import { ApiManager, ApiResponse } from "./ApiManager"; - -export class ModerationApi extends ApiManager { - public async UpdateFeatureFlagsByToken({ - usernameOrToken, - flags, - }: { - usernameOrToken: string; - flags: string[]; - }): Promise< - ApiResponse<{ - inference_job_token?: string; - inference_job_token_type?: string; - }> - > { - const endpoint = `${this.getApiSchemeAndHost()}/v1/moderation/user_feature_flags/${usernameOrToken}`; - - const body = { - action: { - AddFlags: { - flags, - }, - }, - }; - - return this.post< - { action: { AddFlags: { flags: string[] } } }, - { success?: boolean; BadInput?: string } - >({ - endpoint, - body: body, - }) - .then((response) => ({ - success: response.success ?? false, - errorMessage: response.BadInput, - })) - .catch((err) => ({ - success: false, - errorMessage: err.message, - })); - } -} diff --git a/frontend/apps/artcraft/app/src/Classes/ApiManager/PromptsApi.ts b/frontend/apps/artcraft/app/src/Classes/ApiManager/PromptsApi.ts deleted file mode 100644 index 7421c087e6..0000000000 --- a/frontend/apps/artcraft/app/src/Classes/ApiManager/PromptsApi.ts +++ /dev/null @@ -1,51 +0,0 @@ -import { ApiManager, ApiResponse } from "./ApiManager"; -import type { Prompts } from "@storyteller/ui-pagescene"; - -export class PromptsApi extends ApiManager { - public GetPromptsByToken({ - token, - }: { - token: string; - }): Promise> { - const endpoint = `${this.getApiSchemeAndHost()}/v1/prompts/${token}`; - - return this.get<{ - success: boolean; - prompt: Prompts; - error_reason?: string; - }>({ endpoint }) - .then((response) => ({ - success: response.success, - data: response.prompt, - })) - .catch((err) => { - return { success: false, errorMessage: err.message }; - }); - } - - public BatchGetPrompts({ - tokens, - }: { - tokens: string[]; - }): Promise> { - if (tokens.length === 0) { - return Promise.resolve({ success: true, data: [] }); - } - const query = tokens - .map((t) => `tokens=${encodeURIComponent(t)}`) - .join("&"); - const endpoint = `${this.getApiSchemeAndHost()}/v1/prompt/batch?${query}`; - - return this.get<{ - success: boolean; - prompts: Prompts[]; - }>({ endpoint }) - .then((response) => ({ - success: response.success, - data: response.prompts, - })) - .catch((err) => { - return { success: false, errorMessage: err.message }; - }); - } -} diff --git a/frontend/apps/artcraft/app/src/Classes/ApiManager/StudioGen2Api.ts b/frontend/apps/artcraft/app/src/Classes/ApiManager/StudioGen2Api.ts deleted file mode 100644 index 9b4eb0cd46..0000000000 --- a/frontend/apps/artcraft/app/src/Classes/ApiManager/StudioGen2Api.ts +++ /dev/null @@ -1,61 +0,0 @@ - -import { ApiManager, ApiResponse } from "./ApiManager"; -import { Visibility } from "~/enums"; - -interface EnqueueStudioGen2Request { - // Idempotency - uuid_idempotency_token: string; - - // Media token for starting frame - image_file: string; - - // Media token for driver video - video_file: string; - - // Optional visibility override - creator_set_visibility?: string; -} - -export class StudioGen2Api extends ApiManager { - public async EnqueueStudioGen2({ - enqueueVideo, - }: { - enqueueVideo: EnqueueStudioGen2Request; - }): Promise< - ApiResponse<{ - inference_job_token?: string; - inference_job_token_type?: string; - }> - > { - const endpoint = `${this.getApiSchemeAndHost()}/v1/studio_gen2/enqueue`; - - const body = { - ...enqueueVideo, - ...(enqueueVideo.creator_set_visibility - ? {} - : { creator_set_visibility: Visibility.Public }), - }; - - return await this.post< - EnqueueStudioGen2Request, - { - success?: boolean; - inference_job_token?: string; - //inference_job_token_type?: string; - //BadInput?: string; - } - >({ endpoint, body: body }) - .then((response) => ({ - success: Boolean(response.success ?? false), - data: { - inference_job_token: response.inference_job_token, - //inference_job_token_type: response.inference_job_token_type, - }, - //errorMessage: response.BadInput, - })) - .catch((err) => { - console.log(err.message); - return { success: false, error_reason: err.message }; - }); - } -} diff --git a/frontend/apps/artcraft/app/src/Classes/ApiManager/TtsApi.ts b/frontend/apps/artcraft/app/src/Classes/ApiManager/TtsApi.ts deleted file mode 100644 index 10a20b7dd6..0000000000 --- a/frontend/apps/artcraft/app/src/Classes/ApiManager/TtsApi.ts +++ /dev/null @@ -1,64 +0,0 @@ -import { ApiManager, ApiResponse } from "./ApiManager"; -import { GenerateTtsAudioErrorType } from "@storyteller/ui-pagescene"; -import { Visibility } from "~/enums"; - -export interface GenerateTtsAudioRequest { - creator_set_visibility?: Visibility; - uuid_idempotency_token: string; - tts_model_token: string; - inference_text: string; - is_storyteller_demo?: boolean; -} - -export interface GenerateTtsAudioResponse { - success?: boolean; - inference_job_token?: string; - inference_job_token_type?: string; - BadInput?: string; -} - -export class TtsApi extends ApiManager { - public async GenerateTtsAudio(request: GenerateTtsAudioRequest): Promise< - ApiResponse<{ - inference_job_token?: string; - inference_job_token_type?: string; - }> - > { - const endpoint = `${this.getApiSchemeAndHost()}/v1/tts/inference`; - - const body = { - ...request, - ...(request.creator_set_visibility - ? {} - : { creator_set_visibility: Visibility.Public }), - }; - - return this.post({ - endpoint, - body: body, - }) - .then((response) => { - if (!response.success) { - return { - success: false, - errorMessage: response.BadInput, - data: {}, - }; - } - return { - success: true, - data: { - inference_job_token: response.inference_job_token, - inference_job_token_type: response.inference_job_token_type, - }, - }; - }) - .catch(() => { - return { - success: false, - errorMessage: GenerateTtsAudioErrorType.UnknownError, - data: {}, - }; - }); - } -} diff --git a/frontend/apps/artcraft/app/src/Classes/ApiManager/UserBookmarksApi.ts b/frontend/apps/artcraft/app/src/Classes/ApiManager/UserBookmarksApi.ts deleted file mode 100644 index 369b2bd50b..0000000000 --- a/frontend/apps/artcraft/app/src/Classes/ApiManager/UserBookmarksApi.ts +++ /dev/null @@ -1,89 +0,0 @@ -import { ApiManager, ApiResponse } from "./ApiManager"; -import type { UserBookmarkBatch } from "@storyteller/ui-pagescene"; - -export class UserBookmarksApi extends ApiManager { - public CreateUserBookmark({ - entityToken, - entityType, - }: { - entityToken: string; - entityType: string; - }): Promise< - ApiResponse<{ - new_bookmark_count_for_entity?: number; - user_bookmark_token?: string; - }> - > { - const endpoint = `${this.getApiSchemeAndHost()}/v1/user_bookmarks/create`; - const body = { - entity_token: entityToken, - entity_type: entityType, - }; - - return this.post< - { - entity_token: string; - entity_type: string; - }, - { - success?: boolean; - new_bookmark_count_for_entity?: number; - user_bookmark_token: string; - BadInput?: string; - } - >({ endpoint, body }) - .then((response) => ({ - success: response.success ?? false, - data: { - new_bookmark_count_for_entity: response.new_bookmark_count_for_entity, - user_bookmark_token: response.user_bookmark_token, - }, - errorMessage: response.BadInput, - })) - .catch((err) => { - return { success: false, errorMessage: err.message }; - }); - } - - public DeleteUserBookmark({ - entityToken, - }: { - entityToken: string; - }): Promise> { - const endpoint = `${this.getApiSchemeAndHost()}/v1/user_bookmarks/delete/${entityToken}`; - - return this.delete< - { as_mod: boolean }, - { - success?: boolean; - BadInput?: string; - } - >({ endpoint, body: { as_mod: true } }) - .then((response) => ({ - success: response.success ?? false, - errorMessage: response.BadInput, - })) - .catch((err) => { - return { success: false, errorMessage: err.message }; - }); - } - - public ListUserBookmarks(): Promise> { - const endpoint = `${this.getApiSchemeAndHost()}/v1/user_bookmarks/batch`; - - return this.get<{ - success?: boolean; - bookmarks?: UserBookmarkBatch[]; - BadInput?: string; - }>({ endpoint }) - .then((response) => ({ - success: response.success ?? false, - data: response.bookmarks, - errorMessage: response.BadInput, - })) - .catch((err) => { - return { success: false, errorMessage: err.message }; - }); - } - -} diff --git a/frontend/apps/artcraft/app/src/Classes/ApiManager/UserRatingsApi.ts b/frontend/apps/artcraft/app/src/Classes/ApiManager/UserRatingsApi.ts deleted file mode 100644 index 52a6630794..0000000000 --- a/frontend/apps/artcraft/app/src/Classes/ApiManager/UserRatingsApi.ts +++ /dev/null @@ -1,92 +0,0 @@ -import { ApiManager, ApiResponse } from "./ApiManager"; - -export interface UserRating { - entity_token: string; - entity_type: string; - rating_value: string; -} - -export class UserRatingApi extends ApiManager { - public ListUserRatings(): Promise> { - const endpoint = `${this.getApiSchemeAndHost()}/v1/user_rating/batch`; - - return this.get<{ - success?: boolean; - ratings?: UserRating[]; - BadInput?: string; - }>({ endpoint }) - .then((response) => ({ - success: response.success ?? false, - data: response.ratings, - errorMessage: response.BadInput, - })) - .catch((err) => { - return { success: false, errorMessage: err.message }; - }); - } - - public PostUserRating({ - entityToken, - entityType, - ratingValue, - }: { - entityToken: string; - entityType: string; - ratingValue: string; - }): Promise> { - const endpoint = `${this.getApiSchemeAndHost()}/v1/user_rating/rate`; - - const body = { - entity_token: entityToken, - entity_type: entityType, - rating_value: ratingValue, - }; - - return this.post< - { - entity_token: string; - entity_type: string; - rating_value: string; - }, - { - success?: boolean; - new_positive_rating_count_for_entity?: number; - BadInput?: string; - } - >({ endpoint, body }) - .then((response) => ({ - success: response.success ?? false, - data: response.new_positive_rating_count_for_entity, - errorMessage: response.BadInput, - })) - .catch((err) => { - return { success: false, errorMessage: err.message }; - }); - } - - public ListUserRatingByEntity({ - entityType, - entityToken, - }: { - entityType: string; - entityToken: string; - }): Promise> { - const endpoint = `${this.getApiSchemeAndHost()}/v1/user_rating/view/${entityType}/${entityToken}`; - - return this.get<{ - success?: boolean; - maybe_rating_value?: string; - BadInput?: string; - }>({ endpoint }) - .then((response) => { - return { - success: response.success ?? false, - data: response.maybe_rating_value, - errorMessage: response.BadInput, - }; - }) - .catch((err) => { - return { success: false, errorMessage: err.message }; - }); - } -} diff --git a/frontend/apps/artcraft/app/src/Classes/ApiManager/UsersApi.ts b/frontend/apps/artcraft/app/src/Classes/ApiManager/UsersApi.ts deleted file mode 100644 index daa147493b..0000000000 --- a/frontend/apps/artcraft/app/src/Classes/ApiManager/UsersApi.ts +++ /dev/null @@ -1,169 +0,0 @@ -import { ApiManager, ApiResponse } from "./ApiManager"; -import { UserInfo } from "~/models"; - -interface SignupRequest { - username: string; - email_address: string; - password: string; - password_confirmation: string; - signup_source?: string; -}; - -export class UsersApi extends ApiManager { - public GetSession(): Promise< - ApiResponse<{ - loggedIn: boolean; - user?: UserInfo; - }> - > { - const endpoint = `${this.getApiSchemeAndHost()}/v1/session`; - return this.get<{ - success: boolean; - logged_in: boolean; - user?: UserInfo; - error_message?: string; - }>({ endpoint: endpoint }) - .then((response) => ({ - success: response.success, - data: { - loggedIn: response.logged_in, - user: response.user, - }, - })) - .catch((err) => { - return { - success: false, - errorMessage: err.mesasge, - }; - }); - } - - public GetUserProfile(username: string): Promise< - ApiResponse<{ - user?: UserInfo; - }> - > { - const endpoint = `${this.getApiSchemeAndHost()}/v1/user/${username}/profile`; - return this.get<{ - success: boolean; - user?: UserInfo; - error_message?: string; - }>({ endpoint: endpoint }) - .then((response) => ({ - success: response.success, - data: { - user: response.user, - }, - })) - .catch((err) => { - return { - success: false, - error_message: err.message, - }; - }); - } - - public async Login({ - usernameOrEmail, - password, - }: { - usernameOrEmail: string; - password: string; - }): Promise> { - const endpoint = `${this.getApiSchemeAndHost()}/v1/login`; - const body = { - username_or_email: usernameOrEmail, - password: password, - }; - return await this.post< - { username_or_email: string; password: string }, - { - success: boolean; - signed_session?: string; - error_message?: string; - error_type?: string; - } - >({ - endpoint: endpoint, - body: body, - }) - .then((response) => ({ - success: response.success, - data: { signedSession: response.signed_session }, - errorMessage: response.error_message, - })) - .catch((err) => { - return { - success: false, - error_message: err.message, - }; - }); - } - - public Logout(): Promise> { - const endpoint = `${this.getApiSchemeAndHost()}/v1/logout`; - return this.post({ - endpoint: endpoint, - }) - .then((response) => ({ - success: response.success, - })) - .catch((err) => { - return { - success: false, - errorMessage: err.message, - }; - }); - } - - public async Signup({ - username, - email, - password, - passwordConfirmation, - signupSource, - }: { - username: string; - email: string; - password: string; - passwordConfirmation: string; - signupSource?: string; - }): Promise> { - const endpoint = `${this.getApiSchemeAndHost()}/v1/create_account`; - let body: SignupRequest = { - email_address: email, - password, - password_confirmation: passwordConfirmation, - username, - }; - if (!!signupSource) { - body.signup_source = signupSource; - } - return await this.post< - SignupRequest, - { - success: boolean; - signed_session?: string; - error_fields?: Record; - error_message?: string; - error_type?: string; - } - >({ - endpoint: endpoint, - body: body, - }) - .then((response) => { - return { - success: response.success, - data: { signedSession: response.signed_session }, - errorMessage: Object.values(response.error_fields ?? {}).join(","), - }; - }) - .catch((err) => { - return { - success: false, - error_message: err.message, - }; - }); - } -} diff --git a/frontend/apps/artcraft/app/src/Classes/ApiManager/VideoApi.ts b/frontend/apps/artcraft/app/src/Classes/ApiManager/VideoApi.ts deleted file mode 100644 index 15a2bd0544..0000000000 --- a/frontend/apps/artcraft/app/src/Classes/ApiManager/VideoApi.ts +++ /dev/null @@ -1,70 +0,0 @@ -import { ApiManager, ApiResponse } from "./ApiManager"; -import { Visibility } from "~/enums"; - -interface GenerateVideoStyleTransferRequest { - creator_set_visibility: string; - disable_lcm: boolean; - enable_lipsync: boolean; - frame_skip: number; - global_ipa_media_token: string; - input_depth_file: string; - input_file: string; - input_normal_file: string; - input_outline_file: string; - negative_prompt: string; - prompt: string; - remove_watermark: boolean; - style: string; - travel_prompt: string; - trim_end_millis: number; - trim_start_millis: number; - use_cinematic: boolean; - use_face_detailer: boolean; - use_strength: number; - use_upscaler: boolean; - uuid_idempotency_token: string; -} - -export class VideoApi extends ApiManager { - public async EnqueueStudio({ - enqueueVideo, - }: { - enqueueVideo: GenerateVideoStyleTransferRequest; - }): Promise< - ApiResponse<{ - inference_job_token?: string; - inference_job_token_type?: string; - }> - > { - const endpoint = `${this.getApiSchemeAndHost()}/v1/workflows/enqueue_studio`; - - const body = { - ...enqueueVideo, - ...(enqueueVideo.creator_set_visibility - ? {} - : { creator_set_visibility: Visibility.Public }), - }; - - return await this.post< - GenerateVideoStyleTransferRequest, - { - success?: boolean; - inference_job_token?: string; - inference_job_token_type?: string; - BadInput?: string; - } - >({ endpoint, body: body }) - .then((response) => ({ - success: Boolean(response.success ?? false), - data: { - inference_job_token: response.inference_job_token, - inference_job_token_type: response.inference_job_token_type, - }, - errorMessage: response.BadInput, - })) - .catch((err) => { - console.log(err.message); - return { success: false, error_reason: err.message }; - }); - } -} diff --git a/frontend/apps/artcraft/app/src/Classes/ApiManager/WeightsApi.ts b/frontend/apps/artcraft/app/src/Classes/ApiManager/WeightsApi.ts deleted file mode 100644 index 9cc192a2b6..0000000000 --- a/frontend/apps/artcraft/app/src/Classes/ApiManager/WeightsApi.ts +++ /dev/null @@ -1,296 +0,0 @@ -import { ApiManager, ApiResponse } from "./ApiManager"; -import { authentication } from "~/signals"; -import { Weight } from "~/models"; -import type { Pagination, PaginationInfinite } from "@storyteller/ui-pagescene"; -import { - FilterEngineCategories, - FilterMediaClasses, - FilterMediaType, - Visibility, -} from "~/enums"; - -export enum ScopedWeightType { - HIFIGAN_TT2 = "hifigan_tt2", - RVC_V2 = "rvc_v2", - SD_1_5 = "sd_1.5", - SDXL = "sdxl", - SO_VITS_SVC = "so_vits_svc", - TT2 = "tt2", - LORA = "loRA", - VALL_E = "vall_e", - COMFY_UI = "comfy_ui", -} -export enum ScopedWeightCategory { - IMAGE_GENERATION = "image_generation", - TEXT_TO_SPEECH = "text_to_speech", - VOCODER = "vocoder", - VOICE_CONVERSION = "voice_conversion", - WORKFLOW_CONFIG = "workflow_config", -} - -interface WeightsRequest { - username?: string; - pageSize?: number; - weightType?: ScopedWeightType[]; - weightCategory?: ScopedWeightCategory[]; - //TODO: what is scoped?? - scopedWeightType?: ScopedWeightType[]; - scopedWeightCategory?: ScopedWeightCategory[]; -} - -export interface ListWeightsByUserRequest extends WeightsRequest { - pageIndex?: number; - sortAscending?: boolean; -} - -export interface ListWeightsRequest extends WeightsRequest { - cursor?: string; - cursorIsReversed?: boolean; -} - -export interface ListFeaturedWeightsRequest { - sortAscending?: boolean; - pageSize?: number; - cursor?: string; - cursorIsReversed?: boolean; - filterMediaClasses?: FilterMediaClasses[]; - filterMediaType?: FilterMediaType[]; - filterEngineCategories?: FilterEngineCategories[]; -} - -export interface SearchWeightParams { - ietfLanguageSubtag: string; - searchTerm: string; - weightCategory: ScopedWeightCategory; - weightType: ScopedWeightType; -} - -export interface SearchWeightRequest { - ietf_language_subtag: string; - search_term: string; - weight_category: string; - weight_type: string; -} - -interface GetWeightByTokenResponse extends Weight { - success: boolean; -} - -export interface UpdateWeightByTokenParams { - weightToken: string; - coverImageMediaFileToken: string; - descriptionMarkdown: string; - title: string; - visibility: Visibility; -} -export interface UpdateWeightByTokenRequest { - cover_image_media_file_token: string; - description_markdown: string; - title: string; - visibility: Visibility; -} - -export class WeightsApi extends ApiManager { - public ListWeightsByUser({ - username, - ...params - }: ListWeightsByUserRequest): Promise> { - const user = username ?? authentication.userInfo.value?.username; - const endpoint = `${this.getApiSchemeAndHost()}/v1/weights/by_user/${user}`; - - const query = this.parseQueryValues(params); - - return this.get<{ - success: boolean; - results: Weight[]; - pagination: Pagination; - }>({ endpoint, query }) - .then((response) => ({ - success: true, - data: response.results, - pagination: response.pagination, - })) - .catch((err) => { - return { success: false, errorMessage: err.message }; - }); - } - - public ListWeights({ - ...params - }: ListWeightsRequest): Promise> { - const endpoint = `${this.getApiSchemeAndHost()}/v1/weights/list`; - - const query = this.parseQueryValues(params); - - return this.get<{ - success: boolean; - results: Weight[]; - pagination: PaginationInfinite; - }>({ endpoint, query }) - .then((response) => ({ - success: true, - data: response.results, - pagination: response.pagination, - })) - .catch((err) => { - return { success: false, errorMessage: err.message }; - }); - } - - public ListWeightsFeatured({ - ...params - }: ListFeaturedWeightsRequest): Promise< - ApiResponse - > { - const endpoint = `${this.getApiSchemeAndHost()}/v1/weights/list_featured`; - - const query = this.parseQueryValues(params); - - return this.get<{ - success: boolean; - results: Weight[]; - pagination: PaginationInfinite; - }>({ endpoint, query }) - .then((response) => ({ - success: true, - data: response.results, - pagination: response.pagination, - })) - .catch((err) => { - return { success: false, errorMessage: err.message }; - }); - } - - public ListWeightsPinned(): Promise> { - const endpoint = `${this.getApiSchemeAndHost()}/v1/weights/list_pinned`; - - return this.get<{ - success: boolean; - results: Weight[]; - }>({ endpoint }) - .then((response) => ({ - success: true, - data: response.results, - })) - .catch((err) => { - return { success: false, errorMessage: err.message }; - }); - } - - public SearchWeights( - params: SearchWeightParams, - ): Promise> { - const endpoint = `${this.getApiSchemeAndHost()}/v1/weights/search`; - - const body = this.parseBodyValues( - params, - ); - - return this.post< - SearchWeightRequest, - { - success: boolean; - weights: Weight[]; - } - >({ endpoint, body }) - .then((response) => ({ - success: true, - data: response.weights, - })) - .catch((err) => { - return { success: false, errorMessage: err.message }; - }); - } - - public GetWeightByToken({ - weightToken, - }: { - weightToken: string; - }): Promise> { - const endpoint = `${this.getApiSchemeAndHost()}/v1/weights/weight/${weightToken}`; - - return this.get({ endpoint }) - .then(({ success, ...mediaFile }) => ({ - success: success, - data: mediaFile, - })) - .catch((err) => { - return { success: false, errorMessage: err.message }; - }); - } - - public UpdateWeightByToken({ - weightToken, - ...params - }: UpdateWeightByTokenParams): Promise> { - const endpoint = `${this.getApiSchemeAndHost()}/v1/weights/weight/${weightToken}`; - - const body = this.parseBodyValues< - Omit, - UpdateWeightByTokenRequest - >(params); - - return this.post< - UpdateWeightByTokenRequest, - { success?: boolean; BadInput?: string } - >({ endpoint, body }) - .then(({ success, BadInput }) => ({ - success: success ?? false, - errorMessage: BadInput, - })) - .catch((err) => { - return { success: false, errorMessage: err.message }; - }); - } - - public DeleteWeightByToken({ - weightToken, - }: { - weightToken: string; - }): Promise> { - const endpoint = `${this.getApiSchemeAndHost()}/v1/weights/weight/${weightToken}`; - - const body = { - as_mod: true, - set_delete: true, - }; - - return this.delete< - { as_mod: boolean; set_delete: boolean }, - { success?: boolean; BadInput?: string } - >({ endpoint, body }) - .then(({ success, BadInput }) => ({ - success: success ?? false, - errorMessage: BadInput, - })) - .catch((err) => { - return { success: false, errorMessage: err.message }; - }); - } - - public UpdateWeightCoverImageByToken({ - weightToken, - coverImageMediaFileToken, - }: { - weightToken: string; - coverImageMediaFileToken: string; - }): Promise> { - const endpoint = `${this.getApiSchemeAndHost()}/v1/weights/weight/${weightToken}/cover_image`; - - const body = { - cover_image_media_file_token: coverImageMediaFileToken, - }; - - return this.post< - { cover_image_media_file_token: string }, - { success?: boolean; BadInput?: string } - >({ endpoint, body }) - .then(({ success, BadInput }) => ({ - success: success ?? false, - errorMessage: BadInput, - })) - .catch((err) => { - return { success: false, errorMessage: err.message }; - }); - } -} diff --git a/frontend/apps/artcraft/app/src/Classes/ApiManager/index.ts b/frontend/apps/artcraft/app/src/Classes/ApiManager/index.ts deleted file mode 100644 index b48add4b72..0000000000 --- a/frontend/apps/artcraft/app/src/Classes/ApiManager/index.ts +++ /dev/null @@ -1,18 +0,0 @@ -// https://storyteller-docs.netlify.app/#/ -export * from "./BetaKeysApi"; -export * from "./BillingApi"; -export * from "./CommentsApi"; -export * from "./EngineApi"; -export * from "./FeaturedItemsApi"; -export * from "./JobsApi"; -export * from "./MediaFilesApi"; -export * from "./MediaUploadApi"; -export * from "./MiscApi"; -export * from "./ModerationApi"; -export * from "./PromptsApi"; -export * from "./StudioGen2Api"; -export * from "./TtsApi"; -export * from "./UserBookmarksApi"; -export * from "./UsersApi"; -export * from "./VideoApi"; -export * from "./WeightsApi"; diff --git a/frontend/apps/artcraft/app/src/Classes/EnvironmentVariables.ts b/frontend/apps/artcraft/app/src/Classes/EnvironmentVariables.ts deleted file mode 100644 index 90813c83fa..0000000000 --- a/frontend/apps/artcraft/app/src/Classes/EnvironmentVariables.ts +++ /dev/null @@ -1,10 +0,0 @@ -class EnvironmentVariables { - values: Record = {}; - - initialize(values: Record) { - this.values = values; - } -} - -const environmentVariables = new EnvironmentVariables(); -export default environmentVariables; diff --git a/frontend/apps/artcraft/app/src/Helpers/CanvasHelpers.ts b/frontend/apps/artcraft/app/src/Helpers/CanvasHelpers.ts deleted file mode 100644 index 929ab13416..0000000000 --- a/frontend/apps/artcraft/app/src/Helpers/CanvasHelpers.ts +++ /dev/null @@ -1,29 +0,0 @@ - -export const normalizeCanvas = (canvas: HTMLCanvasElement, width: number, height: number): OffscreenCanvas => { - const newCanvas = new OffscreenCanvas(width, height); - newCanvas.width = width; - newCanvas.height = height; - - const ctx = newCanvas.getContext("2d"); - if (!ctx) { - throw new Error("Failed to get offscreen canvas context"); - } - - ctx.imageSmoothingEnabled = true; - ctx.drawImage(canvas, 0, 0, width, height); - return newCanvas; -} - -export const drawAlphaMask = (canvas: OffscreenCanvas, width: number, height: number) => { - const ctx = canvas.getContext("2d"); - if (!ctx) { - throw new Error("Failed to get canvas context"); - } - - // Fill the entire screen with black and composite to keep non-transparent pixels - ctx.save(); - ctx.globalCompositeOperation = "source-in"; - ctx.fillStyle = "black"; - ctx.fillRect(0, 0, width, height); - ctx.restore(); -} diff --git a/frontend/apps/artcraft/app/src/Helpers/ImageHelpers.ts b/frontend/apps/artcraft/app/src/Helpers/ImageHelpers.ts deleted file mode 100644 index 585fc55f25..0000000000 --- a/frontend/apps/artcraft/app/src/Helpers/ImageHelpers.ts +++ /dev/null @@ -1,19 +0,0 @@ -export async function loadImage(img: HTMLImageElement) { - return new Promise((resolve, reject) => { - img.onload = () => resolve(img); - img.onerror = reject; - }); -} - -export async function loadImageFromUrl(url: string) { - const img = new Image(); - img.src = url; - return loadImage(img); -} - -export async function loadImageFromAnonymousOriginUrl(url: string) { - const img = new Image(); - img.crossOrigin = "anonymous"; - img.src = url; - return loadImage(img); -} diff --git a/frontend/apps/artcraft/app/src/Helpers/galleryModalTauriBindings.ts b/frontend/apps/artcraft/app/src/Helpers/galleryModalTauriBindings.ts deleted file mode 100644 index 5cc7a9a0f3..0000000000 --- a/frontend/apps/artcraft/app/src/Helpers/galleryModalTauriBindings.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { MediaFileDelete } from "@storyteller/tauri-api"; -import { listen } from "@tauri-apps/api/event"; - -export const galleryModalDeleteMedia = (id: string) => MediaFileDelete(id); - -export const galleryModalSubscribeToMediaEvents = (handlers: { - onGenerationComplete: () => void; - onMediaDeleted: (mediaId: string) => void; -}) => { - const unlistenGen = listen("generation-complete-event", () => { - handlers.onGenerationComplete(); - }); - const unlistenDel = listen("media_file_deleted_event", (event) => { - const token: string | undefined = - event?.payload?.data?.media_file_token ?? - event?.payload?.media_file_token; - if (token) handlers.onMediaDeleted(token); - }); - return () => { - unlistenGen.then((fn) => fn()); - unlistenDel.then((fn) => fn()); - }; -}; diff --git a/frontend/apps/artcraft/app/src/api/BucketConfig.ts b/frontend/apps/artcraft/app/src/api/BucketConfig.ts deleted file mode 100644 index 4887f88caf..0000000000 --- a/frontend/apps/artcraft/app/src/api/BucketConfig.ts +++ /dev/null @@ -1,53 +0,0 @@ -import environmentVariables from "~/Classes/EnvironmentVariables"; -import { GetCdnOrigin } from "./GetCdnOrigin"; - -class BucketConfig { - isLocalDev: boolean; - - constructor() { - this.isLocalDev = - document.location.host.includes("localhost") || - document.location.host.includes("jungle.horse") || - document.location.host.startsWith("dev."); - } - - // TODO: Prevent callers with undefined/null paths - // TODO pipeline works make more robust.... - getGcsUrl(bucketRelativePath: string | undefined | null): string { - let path = bucketRelativePath; - if (path !== undefined && path !== null && !path.startsWith("/")) { - path = "/" + path; - } - const media_api_base_url = GetCdnOrigin(); - return `${media_api_base_url}${path}`; - } - - getCdnUrl( - bucketRelativePath: string, - width?: number, - quality?: number, - ): string { - const cndBasePath = environmentVariables.values.CDN_API; - const path = bucketRelativePath?.startsWith("/") - ? bucketRelativePath - : "/" + bucketRelativePath; - let resizeParams = ""; - if (width || quality) { - resizeParams = "cdn-cgi/image/"; - if (width) { - resizeParams += `width=${width},`; - } - if (quality) { - resizeParams += `quality=${quality},`; - } - resizeParams = resizeParams.slice(0, -1); - } - if (resizeParams) { - return `${cndBasePath}/${resizeParams}${path}`; - } else { - return `${cndBasePath}${path}`; - } - } -} - -export { BucketConfig }; diff --git a/frontend/apps/artcraft/app/src/api/GetCdnOrigin.ts b/frontend/apps/artcraft/app/src/api/GetCdnOrigin.ts deleted file mode 100644 index 79e16f250c..0000000000 --- a/frontend/apps/artcraft/app/src/api/GetCdnOrigin.ts +++ /dev/null @@ -1,37 +0,0 @@ -// TODO(bt,2025-05-15): Remove this code - -/** - * Return the CDN origin (scheme + host + optional port, but no path) - * See: https://web.dev/articles/url-parts - * - * TODO(bt,2025-02-10): Make this easier to configure in development - */ -class CdnHostHelper { - private static instance: CdnHostHelper; - private readonly origin: string; - - public static getInstance(): CdnHostHelper { - if (CdnHostHelper.instance !== undefined) { - return CdnHostHelper.instance; - } - - const origin = 'https://cdn-2.fakeyou.com'; - const instance = new CdnHostHelper(origin); - - CdnHostHelper.instance = instance; - return instance; - } - - public getOrigin(): string { - return this.origin; - } - - private constructor(origin: string) { - this.origin = origin; - } -} - -// TODO(bt,2025-02-10): Consolidate all of this logic. -export function GetCdnOrigin() : string { - return CdnHostHelper.getInstance().getOrigin(); -} diff --git a/frontend/apps/artcraft/app/src/api/SyncStorytellerApiConfig.ts b/frontend/apps/artcraft/app/src/api/SyncStorytellerApiConfig.ts deleted file mode 100644 index 04c63ee99e..0000000000 --- a/frontend/apps/artcraft/app/src/api/SyncStorytellerApiConfig.ts +++ /dev/null @@ -1,70 +0,0 @@ -import { GetAppInfo } from "@storyteller/tauri-api"; -import { StorytellerApiHostStore } from "@storyteller/api"; -import { forceGetUserInfoAndSubcriptions } from "~/signals"; - -// Time before we should call Tauri again. -const SYNC_THRESHOLD = 10 * 1000; - -/** - * Keep track of if we can call Tauri again. - */ -class Cache { - private static instance: Cache; - private lastFetchSuccess?: number; - - public static getInstance(): Cache { - if (Cache.instance !== undefined) { - return Cache.instance; - } - const instance = new Cache(); - Cache.instance = instance; - return instance; - } - - public canCall() : boolean { - if (this.lastFetchSuccess === undefined) { - return true; - } - return Date.now() - this.lastFetchSuccess > SYNC_THRESHOLD; - } - - public setCallSuccess() { - this.lastFetchSuccess = Date.now(); - } -} - -/** - * Syncs our view of the Storyteller API configs with Tauri. - * Runs any necessary user session functions if things change. - */ -export const SyncStorytellerApiConfig = async () => { - console.log("SyncStorytellerApiConfig()") - - const cache = Cache.getInstance(); - const oldValue = StorytellerApiHostStore.getInstance().getApiSchemeAndHost(); - - if (!cache.canCall()) { - return; - } - - GetAppInfo().then(async (appInfo) => { - console.log("SyncStorytellerApiConfig() - appInfo", appInfo); - - const schemeAndHost = appInfo.payload.storyteller_host; - if (!schemeAndHost) { - return ; - } - - console.log(`Updating hostname to ${schemeAndHost}`); - StorytellerApiHostStore.getInstance().setApiSchemeAndHost(schemeAndHost); - - cache.setCallSuccess(); - - if (oldValue !== schemeAndHost) { - console.log("SyncStorytellerApiConfig() - force session refresh") - // NB: This is a hack that might prevent the login screen from being shown - // if the user is working in development. - await forceGetUserInfoAndSubcriptions(); - } - }); -} diff --git a/frontend/apps/artcraft/app/src/components/GlobalFileDropHandler/GlobalFileDropHandler.tsx b/frontend/apps/artcraft/app/src/components/GlobalFileDropHandler/GlobalFileDropHandler.tsx deleted file mode 100644 index 231bf158ba..0000000000 --- a/frontend/apps/artcraft/app/src/components/GlobalFileDropHandler/GlobalFileDropHandler.tsx +++ /dev/null @@ -1,228 +0,0 @@ -import { useEffect, useRef, useState } from "react"; -import { toast } from "react-hot-toast"; -import { BoxIcon, ImagesIcon, Maximize2Icon } from "lucide-react"; -import { - UploadModal3D, - UploadModalImage, - UploadModalSplat, -} from "@storyteller/ui-upload-modal"; -import { isPromptBoxDropZoneActive } from "@storyteller/ui-promptbox"; -import { FilterEngineCategories } from "../../enums"; - -type ModalType = "3d" | "image" | "splat" | null; - -function getModalTypeForFileName(name: string): ModalType { - const ext = name.split(".").pop()?.toLowerCase() ?? ""; - if (ext === "glb") return "3d"; - if (ext === "png" || ext === "jpg" || ext === "jpeg") return "image"; - if (ext === "spz") return "splat"; - return null; -} - -function isAnyModalOpen(): boolean { - return !!document.querySelector("[data-radix-dialog-content]"); -} - -/** - * Whole-app drops stand down while a prompt box owns them. On the create - * pages the prompt box is the only drop target (matching the webapp), so a - * drop anywhere else must do nothing rather than open the upload modal. - */ -function isGlobalDropSuppressed(): boolean { - return isAnyModalOpen() || isPromptBoxDropZoneActive(); -} - -const isTauri = typeof window !== "undefined" && "__TAURI__" in window; - -export function GlobalFileDropHandler() { - const dragCounter = useRef(0); - const [isDragging, setIsDragging] = useState(false); - const [modalType, setModalType] = useState(null); - const [pendingFiles, setPendingFiles] = useState([]); - - const closeModal = () => { - setModalType(null); - setPendingFiles([]); - }; - - useEffect(() => { - if (isTauri) { - const unlisteners: Array<() => void> = []; - - const setup = async () => { - try { - const { getCurrentWebviewWindow } = await import("@tauri-apps/api/webviewWindow"); - const { convertFileSrc } = await import("@tauri-apps/api/core"); - const appWindow = getCurrentWebviewWindow(); - - const unlisten = await appWindow.onDragDropEvent(async (event) => { - const payload = event.payload; - - if (payload.type === "enter") { - if (!isGlobalDropSuppressed()) setIsDragging(true); - } else if (payload.type === "over") { - // The prompt box can mount mid-drag (or the pointer can move - // onto it), so keep re-checking rather than trusting "enter". - if (isGlobalDropSuppressed()) setIsDragging(false); - } else if (payload.type === "drop") { - setIsDragging(false); - if (isGlobalDropSuppressed()) return; - - if (payload.paths.length === 0) return; - - // Find first path with a recognised extension - let modalKind: ModalType = null; - for (const p of payload.paths) { - modalKind = getModalTypeForFileName(p.split(/[/\\]/).pop() ?? ""); - if (modalKind) break; - } - if (!modalKind) return; - - // Keep only paths matching the detected modal type - const matchingPaths = payload.paths.filter((p) => { - const name = p.split(/[/\\]/).pop() ?? ""; - return getModalTypeForFileName(name) === modalKind; - }); - - const skippedCount = payload.paths.length - matchingPaths.length; - if (skippedCount > 0) { - toast( - `${skippedCount} file${skippedCount > 1 ? "s" : ""} skipped — unsupported or mixed types`, - { icon: "⚠️" } - ); - } - - try { - const files = await Promise.all( - matchingPaths.map(async (path) => { - const fileName = path.split(/[/\\]/).pop() ?? "file"; - const assetUrl = convertFileSrc(path); - const response = await fetch(assetUrl); - if (!response.ok) throw new Error(`HTTP ${response.status}`); - const blob = await response.blob(); - return new File([blob], fileName); - }) - ); - await appWindow.setFocus(); - setModalType(modalKind); - setPendingFiles(files); - } catch (err) { - console.error("[DragDrop] file read failed:", err); - } - } else { - setIsDragging(false); - } - }); - - unlisteners.push(unlisten); - } catch (err) { - console.error("[DragDrop] setup failed:", err); - } - }; - - setup(); - return () => { unlisteners.forEach((fn) => fn()); }; - - } else { - // HTML5 path (browser dev mode) - const handleDragEnter = (e: DragEvent) => { - e.preventDefault(); - if (!e.dataTransfer?.types.includes("Files")) return; - if (isGlobalDropSuppressed()) return; - dragCounter.current++; - setIsDragging(true); - }; - const handleDragLeave = (e: DragEvent) => { - if (!e.dataTransfer?.types.includes("Files")) return; - dragCounter.current--; - if (dragCounter.current <= 0) { dragCounter.current = 0; setIsDragging(false); } - }; - const handleDragOver = (e: DragEvent) => { - e.preventDefault(); - if (e.dataTransfer) e.dataTransfer.dropEffect = "copy"; - }; - const handleDrop = (e: DragEvent) => { - if (!e.dataTransfer?.types.includes("Files")) return; - e.preventDefault(); - setIsDragging(false); - dragCounter.current = 0; - if (isGlobalDropSuppressed()) return; - - const allFiles = Array.from(e.dataTransfer.files); - if (allFiles.length === 0) return; - - // Find first file with a recognised extension - let modalKind: ModalType = null; - for (const f of allFiles) { - modalKind = getModalTypeForFileName(f.name); - if (modalKind) break; - } - if (!modalKind) return; - - // Keep only files matching the detected modal type - const matchingFiles = allFiles.filter( - (f) => getModalTypeForFileName(f.name) === modalKind - ); - - const skippedCount = allFiles.length - matchingFiles.length; - if (skippedCount > 0) { - toast( - `${skippedCount} file${skippedCount > 1 ? "s" : ""} skipped — unsupported or mixed types`, - { icon: "⚠️" } - ); - } - - setModalType(modalKind); - setPendingFiles(matchingFiles); - }; - window.addEventListener("dragenter", handleDragEnter); - window.addEventListener("dragleave", handleDragLeave); - window.addEventListener("dragover", handleDragOver); - window.addEventListener("drop", handleDrop); - return () => { - window.removeEventListener("dragenter", handleDragEnter); - window.removeEventListener("dragleave", handleDragLeave); - window.removeEventListener("dragover", handleDragOver); - window.removeEventListener("drop", handleDrop); - }; - } - }, []); - - return ( - <> - {isDragging && modalType === null && ( -
-
- -
Drop to Upload
-
GLB, PNG, JPG, JPEG, SPZ
-
-
- )} - 0 ? pendingFiles : undefined} - onClose={closeModal} - onSuccess={(_category: FilterEngineCategories) => closeModal()} - title="Upload a 3D Model" - titleIcon={BoxIcon} - /> - 0 ? pendingFiles : undefined} - onClose={closeModal} - onSuccess={() => closeModal()} - title="Upload an Image" - titleIcon={ImagesIcon} - /> - 0 ? pendingFiles : undefined} - onClose={closeModal} - onSuccess={() => {}} - title="Upload a Splat" - titleIcon={BoxIcon} - /> - - ); -} diff --git a/frontend/apps/artcraft/app/src/components/experiences/ImageTo3DExperience.tsx b/frontend/apps/artcraft/app/src/components/experiences/ImageTo3DExperience.tsx deleted file mode 100644 index eb4f3d6420..0000000000 --- a/frontend/apps/artcraft/app/src/components/experiences/ImageTo3DExperience.tsx +++ /dev/null @@ -1,1220 +0,0 @@ -import { useEffect, useMemo, useRef, useState } from "react"; -import { animated, useSpring } from "@react-spring/web"; -import { Button, GenerateButton } from "@storyteller/ui-button"; -import { TabSelector } from "@storyteller/ui-tab-selector"; -import { Tooltip } from "@storyteller/ui-tooltip"; -import { Viewer3D } from "@storyteller/ui-viewer-3d"; -import { BoxIcon, ImagesIcon, PlusIcon, UploadIcon, XIcon } from "lucide-react"; -import { twMerge } from "tailwind-merge"; -import { useImageTo3DStore } from "../../pages/PageImageTo3DObject/ImageTo3DStore"; -import { useImageTo3DWorldStore } from "../../pages/PageImageTo3DWorld/ImageTo3DWorldStore"; -import { MediaUploadApi, downloadFileFromUrl } from "@storyteller/api"; -import { GalleryItem, GalleryModal } from "@storyteller/ui-gallery-modal"; -import { - GenerateMesh, - EnqueueImageTo3dObjectModel, - GenerateSplat, - commandErrorMessage, -} from "@storyteller/tauri-api"; -import { toast } from "react-hot-toast"; -import { v4 as uuidv4 } from "uuid"; -import { useTabStore } from "../../pages/Stores/TabState"; -import { addObject, getActiveEditor } from "@storyteller/ui-pagescene"; -import type { MediaItem } from "@storyteller/ui-pagescene"; -import { AssetType } from "~/enums"; -import { SPLAT_MODELS } from "@storyteller/model-list"; -import { - ClassyModelSelector, - IMAGE_TO_3D_OBJECT_PAGE_MODEL_LIST, - IMAGE_TO_3D_WORLD_PAGE_MODEL_LIST, - ModelPage, - useSelectedModel, - useSelectedProviderForModel, -} from "@storyteller/ui-model-selector"; -import { - CostCalculatorButton, - useCostBreakdownModalStore, -} from "@storyteller/ui-pricing-modal"; -import { HelpMenuButton } from "@storyteller/ui-help-menu"; - -type Mode = "image" | "text"; -type Variant = "object" | "world"; - -interface WorldImage { - id: string; - preview: string; - mediaToken: string | null; - name: string; - isUploading: boolean; -} - -const MAX_WORLD_IMAGES = 10; - -interface ImageTo3DExperienceProps { - title: string; - subtitle: string; - variant: Variant; - backgroundImage?: string; -} - -const MODE_TABS = [ - { id: "image", label: "Image to 3D" }, - // { id: "text", label: "Text to 3D" }, -] satisfies { id: Mode; label: string }[]; - -const formatTime = (timestamp: number) => { - const date = new Date(timestamp); - return date.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" }); -}; - -const generateId = () => - typeof crypto !== "undefined" && crypto.randomUUID - ? crypto.randomUUID() - : Math.random().toString(36).slice(2, 10); - -const WORLD_MODEL_PAGE = ModelPage.ImageTo3DWorld; -const OBJECT_MODEL_PAGE = ModelPage.ImageTo3DObject; -const DEFAULT_OBJECT_MODEL_ID = EnqueueImageTo3dObjectModel.Hunyuan3d3; - -export const ImageTo3DExperience = ({ - title, - subtitle, - variant, - backgroundImage, -}: ImageTo3DExperienceProps) => { - const [activeMode, setActiveMode] = useState("image"); - const selectedWorldModel = useSelectedModel(WORLD_MODEL_PAGE); - const selectedWorldProvider = useSelectedProviderForModel( - WORLD_MODEL_PAGE, - selectedWorldModel?.id, - ); - const selectedObjectModel = useSelectedModel(OBJECT_MODEL_PAGE); - const selectedObjectModelId = - (selectedObjectModel?.id as EnqueueImageTo3dObjectModel | undefined) ?? - DEFAULT_OBJECT_MODEL_ID; - const worldCredits = useCostBreakdownModalStore( - (s) => s.estimatedCreditsByPage[WORLD_MODEL_PAGE], - ); - const objectCredits = useCostBreakdownModalStore( - (s) => s.estimatedCreditsByPage[OBJECT_MODEL_PAGE], - ); - const [uploadedPreview, setUploadedPreview] = useState(null); - const [uploadedName, setUploadedName] = useState(null); - const [prompt, setPrompt] = useState(""); - const [isGenerating, setIsGenerating] = useState(false); - const [isUploading, setIsUploading] = useState(false); - const [dragActive, setDragActive] = useState(false); - const fileInputRef = useRef(null); - const textareaRef = useRef(null); - const worldFileInputRef = useRef(null); - const worldTextareaRef = useRef(null); - const [worldImages, setWorldImages] = useState([]); - const [worldPrompt, setWorldPrompt] = useState(""); - const [previewImage, setPreviewImage] = useState(null); - - const [selectedResultId, setSelectedResultId] = useState(null); - const promptContentRef = useRef(null); - const [promptHeight, setPromptHeight] = useState(400); - const [vh, setVh] = useState( - typeof window !== "undefined" ? window.innerHeight : 800, - ); - - const objectResults = useImageTo3DStore((s) => s.results); - const objectStartGeneration = useImageTo3DStore((s) => s.startGeneration); - const objectFailGeneration = useImageTo3DStore((s) => s.failGeneration); - const objectReset = useImageTo3DStore((s) => s.reset); - - const worldResults = useImageTo3DWorldStore((s) => s.results); - const worldStartGeneration = useImageTo3DWorldStore((s) => s.startGeneration); - const worldFailGeneration = useImageTo3DWorldStore((s) => s.failGeneration); - const worldReset = useImageTo3DWorldStore((s) => s.reset); - const pendingExternalImage = useImageTo3DWorldStore( - (s) => s.pendingExternalImage, - ); - const clearPendingExternalImage = useImageTo3DWorldStore( - (s) => s.clearPendingExternalImage, - ); - const pendingObjectImage = useImageTo3DStore((s) => s.pendingExternalImage); - const clearPendingObjectImage = useImageTo3DStore( - (s) => s.clearPendingExternalImage, - ); - - const results = variant === "object" ? objectResults : worldResults; - const resetResults = variant === "object" ? objectReset : worldReset; - const [uploadedMediaToken, setUploadedMediaToken] = useState( - null, - ); - const [isGalleryModalOpen, setIsGalleryModalOpen] = useState(false); - const [selectedGalleryImages, setSelectedGalleryImages] = useState( - [], - ); - - useEffect(() => { - // Read from store directly to avoid Strict Mode double-execution adding the image twice - if (variant === "world") { - const pending = useImageTo3DWorldStore.getState().pendingExternalImage; - if (pending) { - setWorldImages((prev) => { - if (prev.length >= MAX_WORLD_IMAGES) return prev; - return [ - ...prev, - { - id: generateId(), - preview: pending.url, - mediaToken: pending.mediaToken, - name: "Library Image", - isUploading: false, - }, - ]; - }); - clearPendingExternalImage(); - } - } else if (variant === "object") { - const pending = useImageTo3DStore.getState().pendingExternalImage; - if (pending) { - setUploadedPreview(pending.url); - setUploadedMediaToken(pending.mediaToken); - setUploadedName("Library Image"); - clearPendingObjectImage(); - } - } - }, [ - variant, - pendingExternalImage, - clearPendingExternalImage, - pendingObjectImage, - clearPendingObjectImage, - ]); - - useEffect(() => { - const onResize = () => setVh(window.innerHeight); - window.addEventListener("resize", onResize); - return () => window.removeEventListener("resize", onResize); - }, []); - - useEffect(() => { - const el = promptContentRef.current; - if (!el || typeof ResizeObserver === "undefined") return; - const update = () => setPromptHeight(el.offsetHeight); - update(); - const ro = new ResizeObserver(() => update()); - ro.observe(el); - return () => ro.disconnect(); - }, []); - - useEffect(() => { - if (textareaRef.current) { - textareaRef.current.style.height = "auto"; - textareaRef.current.style.height = `${textareaRef.current.scrollHeight}px`; - } - if (worldTextareaRef.current) { - worldTextareaRef.current.style.height = "auto"; - worldTextareaRef.current.style.height = `${worldTextareaRef.current.scrollHeight}px`; - } - }); - - const handleFiles = async (files?: FileList | null) => { - if (!files || files.length === 0) return; - const file = files[0]; - if (!file.type.startsWith("image/")) return; - - setUploadedName(file.name); - setUploadedMediaToken(null); - setIsUploading(true); - - const reader = new FileReader(); - reader.onload = (e) => { - const dataUrl = e.target?.result as string; - setUploadedPreview(dataUrl); - }; - reader.readAsDataURL(file); - - try { - const mediaUploadApi = new MediaUploadApi(); - const uuid = uuidv4(); - - const uploadResult = await mediaUploadApi.UploadImage({ - blob: file, - fileName: file.name, - uuid: uuid, - }); - - if (!uploadResult.success || !uploadResult.data) { - throw new Error("Failed to upload image"); - } - - setUploadedMediaToken(uploadResult.data); - } catch (error) { - toast.error("Failed to upload image"); - setUploadedPreview(null); - setUploadedName(null); - } finally { - setIsUploading(false); - } - }; - - const handleFileChange = (event: React.ChangeEvent) => { - handleFiles(event.target.files); - event.target.value = ""; - }; - - const handleDrop = (event: React.DragEvent) => { - event.preventDefault(); - event.stopPropagation(); - setDragActive(false); - handleFiles(event.dataTransfer?.files); - }; - - const handlePickFromLibrary = () => { - setIsGalleryModalOpen(true); - }; - - const handleWorldFiles = async (files: File[]) => { - const remaining = MAX_WORLD_IMAGES - worldImages.length; - const imageFiles = files - .filter((f) => f.type.startsWith("image/")) - .slice(0, remaining); - - await Promise.all( - imageFiles.map(async (file) => { - const imageId = generateId(); - - const preview = await new Promise((resolve) => { - const reader = new FileReader(); - reader.onload = (e) => resolve(e.target?.result as string); - reader.readAsDataURL(file); - }); - - setWorldImages((prev) => [ - ...prev, - { - id: imageId, - preview, - mediaToken: null, - name: file.name, - isUploading: true, - }, - ]); - - try { - const mediaUploadApi = new MediaUploadApi(); - const uploadResult = await mediaUploadApi.UploadImage({ - blob: file, - fileName: file.name, - uuid: uuidv4(), - }); - - if (!uploadResult.success || !uploadResult.data) { - throw new Error("Upload failed"); - } - - setWorldImages((prev) => - prev.map((img) => - img.id === imageId - ? { ...img, mediaToken: uploadResult.data!, isUploading: false } - : img, - ), - ); - } catch { - toast.error(`Failed to upload ${file.name}`); - setWorldImages((prev) => prev.filter((img) => img.id !== imageId)); - } - }), - ); - }; - - const removeWorldImage = (imageId: string) => { - setWorldImages((prev) => prev.filter((img) => img.id !== imageId)); - }; - - const handleImageSelect = (id: string) => { - setSelectedGalleryImages((prev) => { - if (prev.includes(id)) return prev.filter((x) => x !== id); - if (variant === "world") { - const max = MAX_WORLD_IMAGES - worldImages.length; - if (prev.length >= max) return prev; - return [...prev, id]; - } - return [id]; - }); - }; - - const handleGallerySelect = async (selectedItems: GalleryItem[]) => { - if (variant === "world") { - const remaining = MAX_WORLD_IMAGES - worldImages.length; - const newImages: WorldImage[] = selectedItems - .slice(0, remaining) - .filter((item) => item.fullImage) - .map((item) => ({ - id: generateId(), - preview: item.fullImage!, - mediaToken: item.id, - name: item.label || "Library Image", - isUploading: false, - })); - setWorldImages((prev) => [...prev, ...newImages]); - setIsGalleryModalOpen(false); - setSelectedGalleryImages([]); - return; - } - - const item = selectedItems[0]; - if (!item || !item.fullImage) { - toast.error("No image selected"); - return; - } - - if (isUploading) return; - - setIsGalleryModalOpen(false); - setSelectedGalleryImages([]); - - setUploadedName(item.label || "Library Image"); - setUploadedPreview(item.fullImage); - setUploadedMediaToken(item.id); - }; - - const handleGenerate = async () => { - if (isGenerating) return; - - if (variant === "world") { - const readyTokens = worldImages - .filter((img) => img.mediaToken && !img.isUploading) - .map((img) => img.mediaToken!); - if (readyTokens.length === 0) return; - } else { - if (isUploading) return; - if (activeMode === "image" && !uploadedMediaToken) return; - if (activeMode === "text" && prompt.trim().length <= 3) return; - } - - setIsGenerating(true); - const subscriberId = generateId(); - - try { - if (variant === "world") { - const readyTokens = worldImages - .filter((img) => img.mediaToken && !img.isUploading) - .map((img) => img.mediaToken!); - const note = - worldPrompt.trim() || - `${worldImages.length} image${worldImages.length !== 1 ? "s" : ""}`; - const firstPreview = worldImages[0]?.preview; - - worldStartGeneration("image", note, firstPreview, subscriberId); - setSelectedResultId(subscriberId); - - window.__storeTaskEnqueueMeta?.({ - prompt: worldPrompt.trim() || undefined, - refImageUrls: worldImages - .map((img) => img.preview) - .filter(Boolean) as string[], - modelType: - (selectedWorldModel as any)?.tauriId || - (SPLAT_MODELS[0] as any)?.tauriId || - String(selectedWorldModel ?? SPLAT_MODELS[0]), - timestamp: Date.now(), - }); - - await GenerateSplat({ - reference_image_media_tokens: readyTokens, - prompt: worldPrompt.trim() || undefined, - model: (selectedWorldModel ?? SPLAT_MODELS[0]).tauriId, - provider: selectedWorldProvider, - frontend_caller: "mini_app", - frontend_subscriber_id: subscriberId, - }); - - } else { - const snapshotPrompt = prompt.trim(); - const snapshotPreview = uploadedPreview || undefined; - const snapshotName = uploadedName; - const note = - activeMode === "text" - ? snapshotPrompt - : snapshotName || "Generated Model"; - - objectStartGeneration( - activeMode, - note, - snapshotPreview, - false, - subscriberId, - ); - setSelectedResultId(subscriberId); - - window.__storeTaskEnqueueMeta?.({ - prompt: snapshotPrompt || undefined, - refImageUrls: snapshotPreview ? [snapshotPreview] : undefined, - modelType: selectedObjectModel?.tauriId || selectedObjectModelId, - timestamp: Date.now(), - }); - - await GenerateMesh({ - prompt: snapshotPrompt || undefined, - reference_image_media_tokens: activeMode === "image" && uploadedMediaToken ? [uploadedMediaToken] : undefined, - model: selectedObjectModel?.tauriId ?? selectedObjectModelId, - frontend_caller: "mini_app", - frontend_subscriber_id: subscriberId, - }); - - - if (activeMode === "text") { - setPrompt(""); - } - } - } catch (error) { - const errorMessage = commandErrorMessage(error, "An unexpected error occurred"); - toast.error(`Failed to generate 3D model: ${errorMessage}`); - if (variant === "world") { - worldFailGeneration(subscriberId); - } else { - objectFailGeneration(subscriberId); - } - } finally { - setIsGenerating(false); - } - }; - - const canGenerate = useMemo(() => { - if (isGenerating) return false; - if (variant === "world") { - return worldImages.some((img) => img.mediaToken && !img.isUploading); - } - if (isUploading) return false; - if (activeMode === "image") { - return Boolean(uploadedMediaToken); - } - if (activeMode === "text") { - return prompt.trim().length > 3; - } - return true; - }, [ - variant, - activeMode, - uploadedMediaToken, - prompt, - isGenerating, - isUploading, - worldImages, - ]); - - const hasResults = results.length > 0; - const showPromptAtBottom = hasResults; - - // Animation logic - const bottomMarginPx = 24; - const bottomOffsetPx = promptHeight + bottomMarginPx; - - const centerTop = vh / 2 - promptHeight / 2 + 80; - const bottomTop = vh - bottomOffsetPx; - - const targetTop = showPromptAtBottom - ? Math.max(0, bottomTop) - : Math.max(0, centerTop); - - const promptAnim = useSpring({ - top: targetTop, - config: { tension: 200, friction: 28, mass: 1.1 }, - }); - - const renderAddImageTile = () => ( - - - - - } - > -
{ - event.preventDefault(); - event.stopPropagation(); - setDragActive(true); - }} - onDragOver={(event) => { - event.preventDefault(); - event.stopPropagation(); - }} - onDragLeave={(event) => { - event.preventDefault(); - event.stopPropagation(); - if (!event.currentTarget.contains(event.relatedTarget as Node)) { - setDragActive(false); - } - }} - onDrop={handleDrop} - onClick={() => fileInputRef.current?.click()} - onKeyDown={(event) => { - if (event.key === "Enter" || event.key === " ") { - event.preventDefault(); - fileInputRef.current?.click(); - } - }} - > - - {!hasResults && ( - - Add Image - - )} -
-
- ); - - const renderImageMode = () => ( -
- {uploadedPreview ? ( -
!isUploading && fileInputRef.current?.click()} - > - Reference - {isUploading && ( -
-
-
- )} - {!isUploading && ( - - )} -
- ) : ( - renderAddImageTile() - )} -
- ); - - const promptInputId = `image-to-3d-${variant}-prompt`; - - const renderTextMode = () => ( -
-