//
// NanoRT, single header only modern ray tracing kernel.
//

/*
The MIT License (MIT)

Copyright (c) 2015 Light Transport Entertainment, Inc.

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.
*/

#ifndef __NANORT_H__
#define __NANORT_H__

#include <vector>
#include <queue>
#include <cmath>
#include <limits>
#include <cstdlib>
#include <cstring>
#include <string>

namespace nanort {

// Parallelized BVH build is not yet fully tested,
// thus turn off if you face a problem when building BVH.
#define NANORT_ENABLE_PARALLEL_BUILD (0)

// Small vector class useful for multi-threaded environment.
//
// stack_container.h
//
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

//#include "base/basictypes.h"

// This allocator can be used with STL containers to provide a stack buffer
// from which to allocate memory and overflows onto the heap. This stack buffer
// would be allocated on the stack and allows us to avoid heap operations in
// some situations.
//
// STL likes to make copies of allocators, so the allocator itself can't hold
// the data. Instead, we make the creator responsible for creating a
// StackAllocator::Source which contains the data. Copying the allocator
// merely copies the pointer to this shared source, so all allocators created
// based on our allocator will share the same stack buffer.
//
// This stack buffer implementation is very simple. The first allocation that
// fits in the stack buffer will use the stack buffer. Any subsequent
// allocations will not use the stack buffer, even if there is unused room.
// This makes it appropriate for array-like containers, but the caller should
// be sure to reserve() in the container up to the stack buffer size. Otherwise
// the container will allocate a small array which will "use up" the stack
// buffer.
template <typename T, size_t stack_capacity>
class StackAllocator : public std::allocator<T> {
public:
  typedef typename std::allocator<T>::pointer pointer;
  typedef typename std::allocator<T>::size_type size_type;

  // Backing store for the allocator. The container owner is responsible for
  // maintaining this for as long as any containers using this allocator are
  // live.
  struct Source {
    Source() : used_stack_buffer_(false) {}

    // Casts the buffer in its right type.
    T *stack_buffer() { return reinterpret_cast<T *>(stack_buffer_); }
    const T *stack_buffer() const {
      return reinterpret_cast<const T *>(stack_buffer_);
    }

    //
    // IMPORTANT: Take care to ensure that stack_buffer_ is aligned
    // since it is used to mimic an array of T.
    // Be careful while declaring any unaligned types (like bool)
    // before stack_buffer_.
    //

    // The buffer itself. It is not of type T because we don't want the
    // constructors and destructors to be automatically called. Define a POD
    // buffer of the right size instead.
    char stack_buffer_[sizeof(T[stack_capacity])];

    // Set when the stack buffer is used for an allocation. We do not track
    // how much of the buffer is used, only that somebody is using it.
    bool used_stack_buffer_;
  };

  // Used by containers when they want to refer to an allocator of type U.
  template <typename U> struct rebind {
    typedef StackAllocator<U, stack_capacity> other;
  };

  // For the straight up copy c-tor, we can share storage.
  StackAllocator(const StackAllocator<T, stack_capacity> &rhs)
      : source_(rhs.source_) {}

  // ISO C++ requires the following constructor to be defined,
  // and std::vector in VC++2008SP1 Release fails with an error
  // in the class _Container_base_aux_alloc_real (from <xutility>)
  // if the constructor does not exist.
  // For this constructor, we cannot share storage; there's
  // no guarantee that the Source buffer of Ts is large enough
  // for Us.
  // TODO: If we were fancy pants, perhaps we could share storage
  // iff sizeof(T) == sizeof(U).
  template <typename U, size_t other_capacity>
  StackAllocator(const StackAllocator<U, other_capacity> &other)
      : source_(NULL) {}

  explicit StackAllocator(Source *source) : source_(source) {}

  // Actually do the allocation. Use the stack buffer if nobody has used it yet
  // and the size requested fits. Otherwise, fall through to the standard
  // allocator.
  pointer allocate(size_type n, void *hint = 0) {
    if (source_ != NULL && !source_->used_stack_buffer_ &&
        n <= stack_capacity) {
      source_->used_stack_buffer_ = true;
      return source_->stack_buffer();
    } else {
      return std::allocator<T>::allocate(n, hint);
    }
  }

  // Free: when trying to free the stack buffer, just mark it as free. For
  // non-stack-buffer pointers, just fall though to the standard allocator.
  void deallocate(pointer p, size_type n) {
    if (source_ != NULL && p == source_->stack_buffer())
      source_->used_stack_buffer_ = false;
    else
      std::allocator<T>::deallocate(p, n);
  }

private:
  Source *source_;
};

// A wrapper around STL containers that maintains a stack-sized buffer that the
// initial capacity of the vector is based on. Growing the container beyond the
// stack capacity will transparently overflow onto the heap. The container must
// support reserve().
//
// WATCH OUT: the ContainerType MUST use the proper StackAllocator for this
// type. This object is really intended to be used only internally. You'll want
// to use the wrappers below for different types.
template <typename TContainerType, int stack_capacity> class StackContainer {
public:
  typedef TContainerType ContainerType;
  typedef typename ContainerType::value_type ContainedType;
  typedef StackAllocator<ContainedType, stack_capacity> Allocator;

  // Allocator must be constructed before the container!
  StackContainer() : allocator_(&stack_data_), container_(allocator_) {
    // Make the container use the stack allocation by reserving our buffer size
    // before doing anything else.
    container_.reserve(stack_capacity);
  }

  // Getters for the actual container.
  //
  // Danger: any copies of this made using the copy constructor must have
  // shorter lifetimes than the source. The copy will share the same allocator
  // and therefore the same stack buffer as the original. Use std::copy to
  // copy into a "real" container for longer-lived objects.
  ContainerType &container() { return container_; }
  const ContainerType &container() const { return container_; }

  // Support operator-> to get to the container. This allows nicer syntax like:
  //   StackContainer<...> foo;
  //   std::sort(foo->begin(), foo->end());
  ContainerType *operator->() { return &container_; }
  const ContainerType *operator->() const { return &container_; }

#ifdef UNIT_TEST
  // Retrieves the stack source so that that unit tests can verify that the
  // buffer is being used properly.
  const typename Allocator::Source &stack_data() const { return stack_data_; }
#endif

protected:
  typename Allocator::Source stack_data_;
  Allocator allocator_;
  ContainerType container_;

  // DISALLOW_EVIL_CONSTRUCTORS(StackContainer);
  StackContainer(const StackContainer &);
  void operator=(const StackContainer &);
};

// StackString
template <size_t stack_capacity>
class StackString
    : public StackContainer<
          std::basic_string<char, std::char_traits<char>,
                            StackAllocator<char, stack_capacity> >,
          stack_capacity> {
public:
  StackString()
      : StackContainer<std::basic_string<char, std::char_traits<char>,
                                         StackAllocator<char, stack_capacity> >,
                       stack_capacity>() {}

private:
  // DISALLOW_EVIL_CONSTRUCTORS(StackString);
  StackString(const StackString &);
  void operator=(const StackString &);
};

// StackWString
template <size_t stack_capacity>
class StackWString
    : public StackContainer<
          std::basic_string<wchar_t, std::char_traits<wchar_t>,
                            StackAllocator<wchar_t, stack_capacity> >,
          stack_capacity> {
public:
  StackWString()
      : StackContainer<
            std::basic_string<wchar_t, std::char_traits<wchar_t>,
                              StackAllocator<wchar_t, stack_capacity> >,
            stack_capacity>() {}

private:
  // DISALLOW_EVIL_CONSTRUCTORS(StackWString);
  StackWString(const StackWString &);
  void operator=(const StackWString &);
};

// StackVector
//
// Example:
//   StackVector<int, 16> foo;
//   foo->push_back(22);  // we have overloaded operator->
//   foo[0] = 10;         // as well as operator[]
template <typename T, size_t stack_capacity>
class StackVector
    : public StackContainer<std::vector<T, StackAllocator<T, stack_capacity> >,
                            stack_capacity> {
public:
  StackVector()
      : StackContainer<std::vector<T, StackAllocator<T, stack_capacity> >,
                       stack_capacity>() {}

  // We need to put this in STL containers sometimes, which requires a copy
  // constructor. We can't call the regular copy constructor because that will
  // take the stack buffer from the original. Here, we create an empty object
  // and make a stack buffer of its own.
  StackVector(const StackVector<T, stack_capacity> &other)
      : StackContainer<std::vector<T, StackAllocator<T, stack_capacity> >,
                       stack_capacity>() {
    this->container().assign(other->begin(), other->end());
  }

  StackVector<T, stack_capacity> &
  operator=(const StackVector<T, stack_capacity> &other) {
    this->container().assign(other->begin(), other->end());
    return *this;
  }

  // Vectors are commonly indexed, which isn't very convenient even with
  // operator-> (using "->at()" does exception stuff we don't want).
  T &operator[](size_t i) { return this->container().operator[](i); }
  const T &operator[](size_t i) const {
    return this->container().operator[](i);
  }
};

namespace {

struct float3 {
  float3() {}
  float3(float xx, float yy, float zz) {
    x = xx;
    y = yy;
    z = zz;
  }
  float3(const float *p) {
    x = p[0];
    y = p[1];
    z = p[2];
  }

  float3 operator*(float f) const { return float3(x * f, y * f, z * f); }
  float3 operator-(const float3 &f2) const {
    return float3(x - f2.x, y - f2.y, z - f2.z);
  }
  float3 operator*(const float3 &f2) const {
    return float3(x * f2.x, y * f2.y, z * f2.z);
  }
  float3 operator+(const float3 &f2) const {
    return float3(x + f2.x, y + f2.y, z + f2.z);
  }
  float3 &operator+=(const float3 &f2) {
    x += f2.x;
    y += f2.y;
    z += f2.z;
    return (*this);
  }
  float3 operator/(const float3 &f2) const {
    return float3(x / f2.x, y / f2.y, z / f2.z);
  }
  float operator[](int i) const { return (&x)[i]; }
  float &operator[](int i) { return (&x)[i]; }

  float3 neg() { return float3(-x, -y, -z); }

  float length() { return sqrtf(x * x + y * y + z * z); }

  void normalize() {
    float len = length();
    if (fabs(len) > 1.0e-6f) {
      float inv_len = 1.0 / len;
      x *= inv_len;
      y *= inv_len;
      z *= inv_len;
    }
  }

  float x, y, z;
  // float pad;  // for alignment
};

inline float3 operator*(float f, const float3 &v) {
  return float3(v.x * f, v.y * f, v.z * f);
}

inline float3 vcross(float3 a, float3 b) {
  float3 c;
  c[0] = a[1] * b[2] - a[2] * b[1];
  c[1] = a[2] * b[0] - a[0] * b[2];
  c[2] = a[0] * b[1] - a[1] * b[0];
  return c;
}

inline float vdot(float3 a, float3 b) {
  return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
}

} // namespace

typedef struct {
  float t;
  float u;
  float v;
  unsigned int faceID;
} Intersection;

typedef struct {
  float org[3];    // must set
  float dir[3];    // must set
  float invDir[3]; // filled internally
  int dirSign[3];  // filled internally
} Ray;

class BVHNode {
public:
  BVHNode(){};
  ~BVHNode(){};

  float bmin[3];
  float bmax[3];

  int flag; // 1 = leaf node, 0 = branch node
  int axis;

  // leaf
  //   data[0] = npoints
  //   data[1] = index
  //
  // branch
  //   data[0] = child[0]
  //   data[1] = child[1]
  unsigned int data[2];
};

namespace {

class IsectComparator {
public:
  bool operator()(const Intersection &a, const Intersection &b) const {
    return a.t < b.t;
  }
};

// Stores furthest intersection at top
typedef std::priority_queue<Intersection, std::vector<Intersection>,
                            IsectComparator> IsectVector;

template <typename T> class Matrix {
public:
  void Print(T m[4][4]) {
    for (int i = 0; i < 4; i++) {
      printf("m[%d] = %f, %f, %f, %f\n", i, m[i][0], m[i][1], m[i][2], m[i][3]);
    }
  }

  void Identity(T m[4][4]) {
    m[0][0] = 1.0;
    m[0][1] = 0.0;
    m[0][2] = 0.0;
    m[0][3] = 0.0;
    m[1][0] = 0.0;
    m[1][1] = 1.0;
    m[1][2] = 0.0;
    m[1][3] = 0.0;
    m[2][0] = 0.0;
    m[2][1] = 0.0;
    m[2][2] = 1.0;
    m[2][3] = 0.0;
    m[3][0] = 0.0;
    m[3][1] = 0.0;
    m[3][2] = 0.0;
    m[3][3] = 1.0;
  }

  void Inverse(T m[4][4]) {
    /*
     * codes from intel web
     * cramer's rule version
     */
    int i, j;
    T tmp[12];  /* tmp array for pairs */
    T tsrc[16]; /* array of transpose source matrix */
    T det;      /* determinant */

    /* transpose matrix */
    for (i = 0; i < 4; i++) {
      tsrc[i] = m[i][0];
      tsrc[i + 4] = m[i][1];
      tsrc[i + 8] = m[i][2];
      tsrc[i + 12] = m[i][3];
    }

    /* calculate pair for first 8 elements(cofactors) */
    tmp[0] = tsrc[10] * tsrc[15];
    tmp[1] = tsrc[11] * tsrc[14];
    tmp[2] = tsrc[9] * tsrc[15];
    tmp[3] = tsrc[11] * tsrc[13];
    tmp[4] = tsrc[9] * tsrc[14];
    tmp[5] = tsrc[10] * tsrc[13];
    tmp[6] = tsrc[8] * tsrc[15];
    tmp[7] = tsrc[11] * tsrc[12];
    tmp[8] = tsrc[8] * tsrc[14];
    tmp[9] = tsrc[10] * tsrc[12];
    tmp[10] = tsrc[8] * tsrc[13];
    tmp[11] = tsrc[9] * tsrc[12];

    /* calculate first 8 elements(cofactors) */
    m[0][0] = tmp[0] * tsrc[5] + tmp[3] * tsrc[6] + tmp[4] * tsrc[7];
    m[0][0] -= tmp[1] * tsrc[5] + tmp[2] * tsrc[6] + tmp[5] * tsrc[7];
    m[0][1] = tmp[1] * tsrc[4] + tmp[6] * tsrc[6] + tmp[9] * tsrc[7];
    m[0][1] -= tmp[0] * tsrc[4] + tmp[7] * tsrc[6] + tmp[8] * tsrc[7];
    m[0][2] = tmp[2] * tsrc[4] + tmp[7] * tsrc[5] + tmp[10] * tsrc[7];
    m[0][2] -= tmp[3] * tsrc[4] + tmp[6] * tsrc[5] + tmp[11] * tsrc[7];
    m[0][3] = tmp[5] * tsrc[4] + tmp[8] * tsrc[5] + tmp[11] * tsrc[6];
    m[0][3] -= tmp[4] * tsrc[4] + tmp[9] * tsrc[5] + tmp[10] * tsrc[6];
    m[1][0] = tmp[1] * tsrc[1] + tmp[2] * tsrc[2] + tmp[5] * tsrc[3];
    m[1][0] -= tmp[0] * tsrc[1] + tmp[3] * tsrc[2] + tmp[4] * tsrc[3];
    m[1][1] = tmp[0] * tsrc[0] + tmp[7] * tsrc[2] + tmp[8] * tsrc[3];
    m[1][1] -= tmp[1] * tsrc[0] + tmp[6] * tsrc[2] + tmp[9] * tsrc[3];
    m[1][2] = tmp[3] * tsrc[0] + tmp[6] * tsrc[1] + tmp[11] * tsrc[3];
    m[1][2] -= tmp[2] * tsrc[0] + tmp[7] * tsrc[1] + tmp[10] * tsrc[3];
    m[1][3] = tmp[4] * tsrc[0] + tmp[9] * tsrc[1] + tmp[10] * tsrc[2];
    m[1][3] -= tmp[5] * tsrc[0] + tmp[8] * tsrc[1] + tmp[11] * tsrc[2];

    /* calculate pairs for second 8 elements(cofactors) */
    tmp[0] = tsrc[2] * tsrc[7];
    tmp[1] = tsrc[3] * tsrc[6];
    tmp[2] = tsrc[1] * tsrc[7];
    tmp[3] = tsrc[3] * tsrc[5];
    tmp[4] = tsrc[1] * tsrc[6];
    tmp[5] = tsrc[2] * tsrc[5];
    tmp[6] = tsrc[0] * tsrc[7];
    tmp[7] = tsrc[3] * tsrc[4];
    tmp[8] = tsrc[0] * tsrc[6];
    tmp[9] = tsrc[2] * tsrc[4];
    tmp[10] = tsrc[0] * tsrc[5];
    tmp[11] = tsrc[1] * tsrc[4];

    /* calculate second 8 elements(cofactors) */
    m[2][0] = tmp[0] * tsrc[13] + tmp[3] * tsrc[14] + tmp[4] * tsrc[15];
    m[2][0] -= tmp[1] * tsrc[13] + tmp[2] * tsrc[14] + tmp[5] * tsrc[15];
    m[2][1] = tmp[1] * tsrc[12] + tmp[6] * tsrc[14] + tmp[9] * tsrc[15];
    m[2][1] -= tmp[0] * tsrc[12] + tmp[7] * tsrc[14] + tmp[8] * tsrc[15];
    m[2][2] = tmp[2] * tsrc[12] + tmp[7] * tsrc[13] + tmp[10] * tsrc[15];
    m[2][2] -= tmp[3] * tsrc[12] + tmp[6] * tsrc[13] + tmp[11] * tsrc[15];
    m[2][3] = tmp[5] * tsrc[12] + tmp[8] * tsrc[13] + tmp[11] * tsrc[14];
    m[2][3] -= tmp[4] * tsrc[12] + tmp[9] * tsrc[13] + tmp[10] * tsrc[14];
    m[3][0] = tmp[2] * tsrc[10] + tmp[5] * tsrc[11] + tmp[1] * tsrc[9];
    m[3][0] -= tmp[4] * tsrc[11] + tmp[0] * tsrc[9] + tmp[3] * tsrc[10];
    m[3][1] = tmp[8] * tsrc[11] + tmp[0] * tsrc[8] + tmp[7] * tsrc[10];
    m[3][1] -= tmp[6] * tsrc[10] + tmp[9] * tsrc[11] + tmp[1] * tsrc[8];
    m[3][2] = tmp[6] * tsrc[9] + tmp[11] * tsrc[11] + tmp[3] * tsrc[8];
    m[3][2] -= tmp[10] * tsrc[11] + tmp[2] * tsrc[8] + tmp[7] * tsrc[9];
    m[3][3] = tmp[10] * tsrc[10] + tmp[4] * tsrc[8] + tmp[9] * tsrc[9];
    m[3][3] -= tmp[8] * tsrc[9] + tmp[11] * tsrc[0] + tmp[5] * tsrc[8];

    /* calculate determinant */
    det = tsrc[0] * m[0][0] + tsrc[1] * m[0][1] + tsrc[2] * m[0][2] +
          tsrc[3] * m[0][3];

    /* calculate matrix inverse */
    det = 1.0 / det;

    for (j = 0; j < 4; j++) {
      for (i = 0; i < 4; i++) {
        m[j][i] *= det;
      }
    }
  }

  void Transpose(T m[4][4]) {
    T t[4][4];

    // Transpose
    for (int j = 0; j < 4; j++) {
      for (int i = 0; i < 4; i++) {
        t[j][i] = m[i][j];
      }
    }

    // Copy
    for (int j = 0; j < 4; j++) {
      for (int i = 0; i < 4; i++) {
        m[j][i] = t[j][i];
      }
    }
  }

  void Mult(T dst[4][4], const T m0[4][4], const T m1[4][4]) {
    for (int i = 0; i < 4; ++i) {
      for (int j = 0; j < 4; ++j) {
        dst[i][j] = 0;
        for (int k = 0; k < 4; ++k) {
          dst[i][j] += m0[k][j] * m1[i][k];
        }
      }
    }
  }

  void MultV(T dst[3], const T m[4][4], const T v[3]) {
    T tmp[3];
    tmp[0] = m[0][0] * v[0] + m[1][0] * v[1] + m[2][0] * v[2] + m[3][0];
    tmp[1] = m[0][1] * v[0] + m[1][1] * v[1] + m[2][1] * v[2] + m[3][1];
    tmp[2] = m[0][2] * v[0] + m[1][2] * v[1] + m[2][2] * v[2] + m[3][2];
    dst[0] = tmp[0];
    dst[1] = tmp[1];
    dst[2] = tmp[2];
  }

  void MultV(float3 &dst, const T m[4][4], const float3 &v) {
    T tmp[3];
    tmp[0] = m[0][0] * v[0] + m[1][0] * v[1] + m[2][0] * v[2] + m[3][0];
    tmp[1] = m[0][1] * v[0] + m[1][1] * v[1] + m[2][1] * v[2] + m[3][1];
    tmp[2] = m[0][2] * v[0] + m[1][2] * v[1] + m[2][2] * v[2] + m[3][2];
    dst[0] = tmp[0];
    dst[1] = tmp[1];
    dst[2] = tmp[2];
  }
};
}

///< BVH build option.
struct BVHBuildOptions {
  float costTaabb;
  int minLeafPrimitives;
  int maxTreeDepth;
  int binSize;
  int shallowDepth;
  size_t minPrimitivesForParallelBuild;

  // Cache bounding box computation.
  // Requires more memory, but BVHbuild can be faster.
  bool cacheBBox;

  // Set default value: Taabb = 0.2
  BVHBuildOptions()
      : costTaabb(0.2), minLeafPrimitives(4), maxTreeDepth(256), binSize(64),
        shallowDepth(3), minPrimitivesForParallelBuild(1024 * 128),
        cacheBBox(false) {}
};

///< BVH build statistics.
class BVHBuildStatistics {
public:
  int maxTreeDepth;
  int numLeafNodes;
  int numBranchNodes;
  float epsScale;
  double buildSecs;

  // Set default value: Taabb = 0.2
  BVHBuildStatistics()
      : maxTreeDepth(0), numLeafNodes(0), numBranchNodes(0), epsScale(1.0f),
        buildSecs(0.0) {}
};

///< BVH trace option.
class BVHTraceOptions {
public:
  // Hit only for face IDs in indexRange.
  // This feature is good to mimic something like glDrawArrays()
  unsigned int faceIdsRange[2];

  BVHTraceOptions() {
    faceIdsRange[0] = 0;
    faceIdsRange[1] = 0x7FFFFFFF; // Up to 2G face IDs.
  }
};

class BBox {
public:
  float bmin[3];
  float bmax[3];

  BBox() {
    bmin[0] = bmin[1] = bmin[2] = std::numeric_limits<float>::max();
    bmax[0] = bmax[1] = bmax[2] = -std::numeric_limits<float>::max();
  }
};

class BVHAccel {
public:
  BVHAccel() : epsScale_(1.0f){};
  ~BVHAccel(){};

  ///< Build BVH for input mesh.
  bool Build(const float *vertices, const unsigned int *faces,
             const unsigned int numFaces, const BVHBuildOptions &options);

  ///< Get statistics of built BVH tree. Valid after Build()
  BVHBuildStatistics GetStatistics() const { return stats_; }

  ///< Dump built BVH to the file.
  bool Dump(const char *filename);

  /// Load BVH binary
  bool Load(const char *filename);

  ///< Traverse into BVH along ray and find closest hit point if found
  bool Traverse(Intersection &isect, const float *vertices,
                const unsigned int *faces, const Ray &ray, const BVHTraceOptions& options);

  ///< Multi-hit ray tracversal
  ///< Returns `maxIntersections` frontmost intersections
  bool MultiHitTraverse(StackVector<Intersection, 128> &isects,
                        int maxIntersections, const float *vertices,
                        const unsigned int *faces, Ray &ray);

  const std::vector<BVHNode> &GetNodes() const { return nodes_; }
  const std::vector<unsigned int> &GetIndices() const { return indices_; }

  void BoundingBox(float bmin[3], float bmax[3]) const {
    if (nodes_.empty()) {
      bmin[0] = bmin[1] = bmin[2] = std::numeric_limits<float>::max();
      bmax[0] = bmax[1] = bmax[2] = -std::numeric_limits<float>::max();
    } else {
      bmin[0] = nodes_[0].bmin[0];
      bmin[1] = nodes_[0].bmin[1];
      bmin[2] = nodes_[0].bmin[2];
      bmax[0] = nodes_[0].bmax[0];
      bmax[1] = nodes_[0].bmax[1];
      bmax[2] = nodes_[0].bmax[2];
    }
  }

private:
#if NANORT_ENABLE_PARALLEL_BUILD
  typedef struct {
    unsigned int leftIdx;
    unsigned int rightIdx;
    unsigned int offset;
  } ShallowNodeInfo;

  // Used only during BVH construction
  std::vector<ShallowNodeInfo> shallowNodeInfos_;

  ///< Builds shallow BVH tree recursively.
  unsigned int BuildShallowTree(std::vector<BVHNode> &outNodes,
                                const float *vertices,
                                const unsigned int *faces, unsigned int leftIdx,
                                unsigned int rightIdx, int depth,
                                int maxShallowDepth, float epsScale);
#endif

  ///< Builds BVH tree recursively.
  size_t BuildTree(BVHBuildStatistics &outStat, std::vector<BVHNode> &outNodes,
                   const float *vertices, const unsigned int *faces,
                   unsigned int leftIdx, unsigned int rightIdx, int depth,
                   float epsScale);

  BVHBuildOptions options_;
  std::vector<BVHNode> nodes_;
  std::vector<unsigned int> indices_; // max 4G triangles.
  BVHBuildStatistics stats_;
  float epsScale_;
  std::vector<BBox> bboxes_;
};

#if 0
class BVHBox
{

}

class Scene
{
  std::vector<BVHBox> nodes_;
};
#endif

} // namespace nanort

#ifdef NANORT_IMPLEMENTATION

#include <limits>
#include <cassert>
#include <algorithm>
#include <functional>

//
// SAH functions
//
namespace nanort {

struct BinBuffer {

  BinBuffer(int size) {
    binSize = size;
    bin.resize(2 * 3 * size);
    clear();
  }

  void clear() { memset(&bin[0], 0, sizeof(size_t) * 2 * 3 * binSize); }

  std::vector<size_t> bin; // (min, max) * xyz * binsize
  int binSize;
};

inline float CalculateSurfaceArea(const float3 &min, const float3 &max) {
  float3 box = max - min;
  return 2.0 * (box[0] * box[1] + box[1] * box[2] + box[2] * box[0]);
}

inline void GetBoundingBoxOfTriangle(float3 &bmin, float3 &bmax,
                                     const float *vertices,
                                     const unsigned int *faces,
                                     unsigned int index) {
  unsigned int f0 = faces[3 * index + 0];
  unsigned int f1 = faces[3 * index + 1];
  unsigned int f2 = faces[3 * index + 2];

  float3 p[3];

  p[0] = float3(&vertices[3 * f0]);
  p[1] = float3(&vertices[3 * f1]);
  p[2] = float3(&vertices[3 * f2]);

  bmin = p[0];
  bmax = p[0];

  for (int i = 1; i < 3; i++) {
    bmin[0] = std::min(bmin[0], p[i][0]);
    bmin[1] = std::min(bmin[1], p[i][1]);
    bmin[2] = std::min(bmin[2], p[i][2]);

    bmax[0] = std::max(bmax[0], p[i][0]);
    bmax[1] = std::max(bmax[1], p[i][1]);
    bmax[2] = std::max(bmax[2], p[i][2]);
  }
}

void ContributeBinBuffer(BinBuffer *bins, // [out]
                         const float3 &sceneMin, const float3 &sceneMax,
                         const float *vertices, const unsigned int *faces,
                         unsigned int *indices, unsigned int leftIdx,
                         unsigned int rightIdx, float epsScale) {
  const float kEPS = std::numeric_limits<float>::epsilon() * epsScale;

  float binSize = (float)bins->binSize;

  // Calculate extent
  float3 sceneSize, sceneInvSize;
  sceneSize = sceneMax - sceneMin;
  for (int i = 0; i < 3; ++i) {
    assert(sceneSize[i] >= 0.0);

    if (sceneSize[i] > kEPS) {
      sceneInvSize[i] = binSize / sceneSize[i];
    } else {
      sceneInvSize[i] = 0.0;
    }
  }

  // Clear bin data
  std::fill(bins->bin.begin(), bins->bin.end(), 0);
  // memset(&bins->bin[0], 0, sizeof(2 * 3 * bins->binSize));

  size_t idxBMin[3];
  size_t idxBMax[3];

  for (size_t i = leftIdx; i < rightIdx; i++) {

    //
    // Quantize the position into [0, BIN_SIZE)
    //
    // q[i] = (int)(p[i] - scene_bmin) / scene_size
    //
    float3 bmin;
    float3 bmax;

    GetBoundingBoxOfTriangle(bmin, bmax, vertices, faces, indices[i]);

    float3 quantizedBMin = (bmin - sceneMin) * sceneInvSize;
    float3 quantizedBMax = (bmax - sceneMin) * sceneInvSize;

    // idx is now in [0, BIN_SIZE)
    for (size_t j = 0; j < 3; ++j) {
      int q0 = (int)quantizedBMin[j];
      if (q0 < 0)
        q0 = 0;
      int q1 = (int)quantizedBMax[j];
      if (q1 < 0)
        q1 = 0;

      idxBMin[j] = (unsigned int)q0;
      idxBMax[j] = (unsigned int)q1;

      if (idxBMin[j] >= binSize)
        idxBMin[j] = binSize - 1;
      if (idxBMax[j] >= binSize)
        idxBMax[j] = binSize - 1;

      assert(idxBMin[j] < binSize);
      assert(idxBMax[j] < binSize);

      // Increment bin counter
      bins->bin[0 * (bins->binSize * 3) + j * bins->binSize + idxBMin[j]] += 1;
      bins->bin[1 * (bins->binSize * 3) + j * bins->binSize + idxBMax[j]] += 1;
    }
  }
}

inline float SAH(size_t ns1, float leftArea, size_t ns2, float rightArea,
                 float invS, float Taabb, float Ttri) {
  // const float Taabb = 0.2f;
  // const float Ttri = 0.8f;
  float T;

  T = 2.0f * Taabb + (leftArea * invS) * (float)(ns1)*Ttri +
      (rightArea * invS) * (float)(ns2)*Ttri;

  return T;
}

bool FindCutFromBinBuffer(float *cutPos,    // [out] xyz
                          int &minCostAxis, // [out]
                          const BinBuffer *bins, const float3 &bmin,
                          const float3 &bmax, size_t numTriangles,
                          float costTaabb, // should be in [0.0, 1.0]
                          float epsScale) {
  const float eps = std::numeric_limits<float>::epsilon() * epsScale;

  size_t left, right;
  float3 bsize, bstep;
  float3 bminLeft, bmaxLeft;
  float3 bminRight, bmaxRight;
  float saLeft, saRight, saTotal;
  float pos;
  float minCost[3];

  float costTtri = 1.0 - costTaabb;

  minCostAxis = 0;

  bsize = bmax - bmin;
  bstep = bsize * (1.0 / bins->binSize);
  saTotal = CalculateSurfaceArea(bmin, bmax);

  float invSaTotal = 0.0;
  if (saTotal > eps) {
    invSaTotal = 1.0 / saTotal;
  }

  for (int j = 0; j < 3; ++j) {

    //
    // Compute SAH cost for right side of each cell of the bbox.
    // Exclude both extreme side of the bbox.
    //
    //  i:      0    1    2    3
    //     +----+----+----+----+----+
    //     |    |    |    |    |    |
    //     +----+----+----+----+----+
    //

    float minCostPos = bmin[j] + 0.5 * bstep[j];
    minCost[j] = std::numeric_limits<float>::max();

    left = 0;
    right = numTriangles;
    bminLeft = bminRight = bmin;
    bmaxLeft = bmaxRight = bmax;

    for (int i = 0; i < bins->binSize - 1; ++i) {
      left += bins->bin[0 * (3 * bins->binSize) + j * bins->binSize + i];
      right -= bins->bin[1 * (3 * bins->binSize) + j * bins->binSize + i];

      assert(left <= numTriangles);
      assert(right <= numTriangles);

      //
      // Split pos bmin + (i + 1) * (bsize / BIN_SIZE)
      // +1 for i since we want a position on right side of the cell.
      //

      pos = bmin[j] + (i + 0.5) * bstep[j];
      bmaxLeft[j] = pos;
      bminRight[j] = pos;

      saLeft = CalculateSurfaceArea(bminLeft, bmaxLeft);
      saRight = CalculateSurfaceArea(bminRight, bmaxRight);

      float cost =
          SAH(left, saLeft, right, saRight, invSaTotal, costTaabb, costTtri);
      if (cost < minCost[j]) {
        //
        // Update the min cost
        //
        minCost[j] = cost;
        minCostPos = pos;
        // minCostAxis = j;
      }
    }

    cutPos[j] = minCostPos;
  }

  // cutAxis = minCostAxis;
  // cutPos = minCostPos;

  // Find min cost axis
  float cost = minCost[0];
  minCostAxis = 0;
  if (cost > minCost[1]) {
    minCostAxis = 1;
    cost = minCost[1];
  }
  if (cost > minCost[2]) {
    minCostAxis = 2;
    cost = minCost[2];
  }

  return true;
}

class SAHPred : public std::unary_function<unsigned int, bool> {
public:
  SAHPred(int axis, float pos, const float *vertices, const unsigned int *faces)
      : axis_(axis), pos_(pos), vertices_(vertices), faces_(faces) {}

  bool operator()(unsigned int i) const {
    int axis = axis_;
    float pos = pos_;

    unsigned int i0 = faces_[3 * i + 0];
    unsigned int i1 = faces_[3 * i + 1];
    unsigned int i2 = faces_[3 * i + 2];

    float3 p0(&vertices_[3 * i0]);
    float3 p1(&vertices_[3 * i1]);
    float3 p2(&vertices_[3 * i2]);

    float center = p0[axis] + p1[axis] + p2[axis];

    return (center < pos * 3.0f);
  }

private:
  int axis_;
  float pos_;
  const float *vertices_;
  const unsigned int *faces_;
};

#ifdef _OPENMP
void ComputeBoundingBoxOMP(float3 &bmin, float3 &bmax, const float *vertices,
                           const unsigned int *faces, unsigned int *indices,
                           unsigned int leftIndex, unsigned int rightIndex,
                           float epsScale) {
  const float kEPS = std::numeric_limits<float>::epsilon() * epsScale;

  long long i = leftIndex;
  long long idx = indices[i];
  long long n = rightIndex - leftIndex;
  bmin[0] = vertices[3 * faces[3 * idx + 0] + 0] - kEPS;
  bmin[1] = vertices[3 * faces[3 * idx + 0] + 1] - kEPS;
  bmin[2] = vertices[3 * faces[3 * idx + 0] + 2] - kEPS;
  bmax[0] = vertices[3 * faces[3 * idx + 0] + 0] + kEPS;
  bmax[1] = vertices[3 * faces[3 * idx + 0] + 1] + kEPS;
  bmax[2] = vertices[3 * faces[3 * idx + 0] + 2] + kEPS;

  float local_bmin[3] = {bmin[0], bmin[1], bmin[2]};
  float local_bmax[3] = {bmax[0], bmax[1], bmax[2]};

#pragma omp parallel firstprivate(local_bmin, local_bmax) if (n > (1024 * 128))
  {

#pragma omp for
    for (i = leftIndex; i < rightIndex; i++) { // for each faces
      size_t idx = indices[i];
      for (int j = 0; j < 3; j++) { // for each face vertex
        size_t fid = faces[3 * idx + j];
        for (int k = 0; k < 3; k++) { // xyz
          float minval = vertices[3 * fid + k] - kEPS;
          float maxval = vertices[3 * fid + k] + kEPS;
          if (local_bmin[k] > minval)
            local_bmin[k] = minval;
          if (local_bmax[k] < maxval)
            local_bmax[k] = maxval;
        }
      }
    }

#pragma omp critical
    {
      for (int k = 0; k < 3; k++) {

        if (local_bmin[k] < bmin[k]) {
          {
            if (local_bmin[k] < bmin[k])
              bmin[k] = local_bmin[k];
          }
        }

        if (local_bmax[k] > bmax[k]) {
          {
            if (local_bmax[k] > bmax[k])
              bmax[k] = local_bmax[k];
          }
        }
      }
    }
  }
}
#endif

void ComputeBoundingBox(float3 &bmin, float3 &bmax, const float *vertices,
                        const unsigned int *faces, unsigned int *indices,
                        unsigned int leftIndex, unsigned int rightIndex,
                        float epsScale) {
  const float kEPS = std::numeric_limits<float>::epsilon() * epsScale;

  long long i = leftIndex;
  long long idx = indices[i];
  bmin[0] = vertices[3 * faces[3 * idx + 0] + 0] - kEPS;
  bmin[1] = vertices[3 * faces[3 * idx + 0] + 1] - kEPS;
  bmin[2] = vertices[3 * faces[3 * idx + 0] + 2] - kEPS;
  bmax[0] = vertices[3 * faces[3 * idx + 0] + 0] + kEPS;
  bmax[1] = vertices[3 * faces[3 * idx + 0] + 1] + kEPS;
  bmax[2] = vertices[3 * faces[3 * idx + 0] + 2] + kEPS;

  float local_bmin[3] = {bmin[0], bmin[1], bmin[2]};
  float local_bmax[3] = {bmax[0], bmax[1], bmax[2]};

  {

    for (i = leftIndex; i < rightIndex; i++) { // for each faces
      size_t idx = indices[i];
      for (int j = 0; j < 3; j++) { // for each face vertex
        size_t fid = faces[3 * idx + j];
        for (int k = 0; k < 3; k++) { // xyz
          float minval = vertices[3 * fid + k] - kEPS;
          float maxval = vertices[3 * fid + k] + kEPS;
          if (local_bmin[k] > minval)
            local_bmin[k] = minval;
          if (local_bmax[k] < maxval)
            local_bmax[k] = maxval;
        }
      }
    }

    for (int k = 0; k < 3; k++) {
      bmin[k] = local_bmin[k];
      bmax[k] = local_bmax[k];
    }
  }
}

void GetBoundingBox(float3 &bmin, float3 &bmax, std::vector<BBox> &bboxes,
                    unsigned int *indices, unsigned int leftIndex,
                    unsigned int rightIndex, float epsScale) {
  const float kEPS = std::numeric_limits<float>::epsilon() * epsScale;

  long long i = leftIndex;
  long long idx = indices[i];
  bmin[0] = bboxes[idx].bmin[0] - kEPS;
  bmin[1] = bboxes[idx].bmin[1] - kEPS;
  bmin[2] = bboxes[idx].bmin[2] - kEPS;
  bmax[0] = bboxes[idx].bmax[0] + kEPS;
  bmax[1] = bboxes[idx].bmax[1] + kEPS;
  bmax[2] = bboxes[idx].bmax[2] + kEPS;

  float local_bmin[3] = {bmin[0], bmin[1], bmin[2]};
  float local_bmax[3] = {bmax[0], bmax[1], bmax[2]};

  {

    for (i = leftIndex; i < rightIndex; i++) { // for each faces
      size_t idx = indices[i];

      for (int k = 0; k < 3; k++) { // xyz
        float minval = bboxes[idx].bmin[k] - kEPS;
        float maxval = bboxes[idx].bmax[k] + kEPS;
        if (local_bmin[k] > minval)
          local_bmin[k] = minval;
        if (local_bmax[k] < maxval)
          local_bmax[k] = maxval;
      }
    }

    for (int k = 0; k < 3; k++) {
      bmin[k] = local_bmin[k];
      bmax[k] = local_bmax[k];
    }
  }
}

//
// --
//

#if NANORT_ENABLE_PARALLEL_BUILD
unsigned int BVHAccel::BuildShallowTree(std::vector<BVHNode> &outNodes,
                                        const float *vertices,
                                        const unsigned int *faces,
                                        unsigned int leftIdx,
                                        unsigned int rightIdx, int depth,
                                        int maxShallowDepth, float epsScale) {
  assert(leftIdx <= rightIdx);

  unsigned int offset = outNodes.size();

  if (stats_.maxTreeDepth < depth) {
    stats_.maxTreeDepth = depth;
  }

  float3 bmin, bmax;
  ComputeBoundingBox(bmin, bmax, vertices, faces, &indices_.at(0), leftIdx,
                     rightIdx, epsScale);

  long long n = rightIdx - leftIdx;
  if ((n < options_.minLeafPrimitives) || (depth >= options_.maxTreeDepth)) {
    // Create leaf node.
    BVHNode leaf;

    leaf.bmin[0] = bmin[0];
    leaf.bmin[1] = bmin[1];
    leaf.bmin[2] = bmin[2];

    leaf.bmax[0] = bmax[0];
    leaf.bmax[1] = bmax[1];
    leaf.bmax[2] = bmax[2];

    assert(leftIdx < std::numeric_limits<unsigned int>::max());

    leaf.flag = 1; // leaf
    leaf.data[0] = n;
    leaf.data[1] = (unsigned int)leftIdx;

    outNodes.push_back(leaf); // atomic update

    stats_.numLeafNodes++;

    return offset;
  }

  //
  // Create branch node.
  //
  if (depth >= maxShallowDepth) {

    // Delay to build tree
    ShallowNodeInfo info;
    info.leftIdx = leftIdx;
    info.rightIdx = rightIdx;
    info.offset = offset;
    shallowNodeInfos_.push_back(info);

    // Add dummy node.
    BVHNode node;
    node.axis = -1;
    node.flag = -1;
    outNodes.push_back(node);

    return offset;

  } else {

    //
    // Compute SAH and find best split axis and position
    //
    int minCutAxis = 0;
    float cutPos[3] = {0.0, 0.0, 0.0};

    BinBuffer bins(options_.binSize);
    ContributeBinBuffer(&bins, bmin, bmax, vertices, faces, &indices_.at(0),
                        leftIdx, rightIdx, epsScale);
    FindCutFromBinBuffer(cutPos, minCutAxis, &bins, bmin, bmax, n,
                         options_.costTaabb, epsScale);

    // Try all 3 axis until good cut position avaiable.
    unsigned int midIdx;
    int cutAxis = minCutAxis;
    for (int axisTry = 0; axisTry < 1; axisTry++) {

      unsigned int *begin = &indices_[leftIdx];
      unsigned int *end = &indices_[rightIdx - 1] + 1; // mimics end() iterator.
      unsigned int *mid = 0;

      // try minCutAxis first.
      cutAxis = (minCutAxis + axisTry) % 3;

      //
      // Split at (cutAxis, cutPos)
      // indices_ will be modified.
      //
      mid = std::partition(begin, end,
                           SAHPred(cutAxis, cutPos[cutAxis], vertices, faces));

      midIdx = leftIdx + (mid - begin);
      if ((midIdx == leftIdx) || (midIdx == rightIdx)) {

        // Can't split well.
        // Switch to object median(which may create unoptimized tree, but
        // stable)
        midIdx = leftIdx + (n >> 1);

        // Try another axis if there's axis to try.

      } else {

        // Found good cut. exit loop.
        break;
      }
    }

    BVHNode node;
    node.axis = cutAxis;
    node.flag = 0; // 0 = branch

    outNodes.push_back(node);

    unsigned int leftChildIndex = 0;
    unsigned int rightChildIndex = 0;

    leftChildIndex =
        BuildShallowTree(outNodes, vertices, faces, leftIdx, midIdx, depth + 1,
                         maxShallowDepth, epsScale);

    rightChildIndex =
        BuildShallowTree(outNodes, vertices, faces, midIdx, rightIdx, depth + 1,
                         maxShallowDepth, epsScale);

    if ((leftChildIndex != (unsigned int)(-1)) &&
        (rightChildIndex != (unsigned int)(-1))) {
      outNodes[offset].data[0] = leftChildIndex;
      outNodes[offset].data[1] = rightChildIndex;

      outNodes[offset].bmin[0] = bmin[0];
      outNodes[offset].bmin[1] = bmin[1];
      outNodes[offset].bmin[2] = bmin[2];

      outNodes[offset].bmax[0] = bmax[0];
      outNodes[offset].bmax[1] = bmax[1];
      outNodes[offset].bmax[2] = bmax[2];
    } else {
      if ((leftChildIndex == (unsigned int)(-1)) &&
          (rightChildIndex != (unsigned int)(-1))) {
        fprintf(stderr, "??? : %u, %u\n", leftChildIndex, rightChildIndex);
        exit(-1);
      } else if ((leftChildIndex != (unsigned int)(-1)) &&
                 (rightChildIndex == (unsigned int)(-1))) {
        fprintf(stderr, "??? : %u, %u\n", leftChildIndex, rightChildIndex);
        exit(-1);
      }
    }
  }

  stats_.numBranchNodes++;

  return offset;
}
#endif

size_t BVHAccel::BuildTree(BVHBuildStatistics &outStat,
                           std::vector<BVHNode> &outNodes,
                           const float *vertices, const unsigned int *faces,
                           unsigned int leftIdx, unsigned int rightIdx,
                           int depth, float epsScale) {
  assert(leftIdx <= rightIdx);

  size_t offset = outNodes.size();

  if (outStat.maxTreeDepth < depth) {
    outStat.maxTreeDepth = depth;
  }

  float3 bmin, bmax;
  if (!bboxes_.empty()) {
    GetBoundingBox(bmin, bmax, bboxes_, &indices_.at(0), leftIdx, rightIdx,
                   epsScale);
  } else {
    ComputeBoundingBox(bmin, bmax, vertices, faces, &indices_.at(0), leftIdx,
                       rightIdx, epsScale);
  }

  long long n = rightIdx - leftIdx;
  if ((n < options_.minLeafPrimitives) || (depth >= options_.maxTreeDepth)) {
    // Create leaf node.
    BVHNode leaf;

    leaf.bmin[0] = bmin[0];
    leaf.bmin[1] = bmin[1];
    leaf.bmin[2] = bmin[2];

    leaf.bmax[0] = bmax[0];
    leaf.bmax[1] = bmax[1];
    leaf.bmax[2] = bmax[2];

    assert(leftIdx < std::numeric_limits<unsigned int>::max());

    leaf.flag = 1; // leaf
    leaf.data[0] = n;
    leaf.data[1] = (unsigned int)leftIdx;

    outNodes.push_back(leaf); // atomic update

    outStat.numLeafNodes++;

    return offset;
  }

  //
  // Create branch node.
  //

  //
  // Compute SAH and find best split axis and position
  //
  int minCutAxis = 0;
  float cutPos[3] = {0.0, 0.0, 0.0};

  BinBuffer bins(options_.binSize);
  ContributeBinBuffer(&bins, bmin, bmax, vertices, faces, &indices_.at(0),
                      leftIdx, rightIdx, epsScale);
  FindCutFromBinBuffer(cutPos, minCutAxis, &bins, bmin, bmax, n,
                       options_.costTaabb, epsScale);

  // Try all 3 axis until good cut position avaiable.
  unsigned int midIdx;
  int cutAxis = minCutAxis;
  for (int axisTry = 0; axisTry < 1; axisTry++) {

    unsigned int *begin = &indices_[leftIdx];
    unsigned int *end = &indices_[rightIdx - 1] + 1; // mimics end() iterator.
    unsigned int *mid = 0;

    // try minCutAxis first.
    cutAxis = (minCutAxis + axisTry) % 3;

    //
    // Split at (cutAxis, cutPos)
    // indices_ will be modified.
    //
    mid = std::partition(begin, end,
                         SAHPred(cutAxis, cutPos[cutAxis], vertices, faces));

    midIdx = leftIdx + (mid - begin);
    if ((midIdx == leftIdx) || (midIdx == rightIdx)) {

      // Can't split well.
      // Switch to object median(which may create unoptimized tree, but
      // stable)
      midIdx = leftIdx + (n >> 1);

      // Try another axis if there's axis to try.

    } else {

      // Found good cut. exit loop.
      break;
    }
  }

  BVHNode node;
  node.axis = cutAxis;
  node.flag = 0; // 0 = branch

  outNodes.push_back(node); // atomic update

  unsigned int leftChildIndex = 0;
  unsigned int rightChildIndex = 0;

  leftChildIndex = BuildTree(outStat, outNodes, vertices, faces, leftIdx,
                             midIdx, depth + 1, epsScale);

  rightChildIndex = BuildTree(outStat, outNodes, vertices, faces, midIdx,
                              rightIdx, depth + 1, epsScale);

  {
    outNodes[offset].data[0] = leftChildIndex;
    outNodes[offset].data[1] = rightChildIndex;

    outNodes[offset].bmin[0] = bmin[0];
    outNodes[offset].bmin[1] = bmin[1];
    outNodes[offset].bmin[2] = bmin[2];

    outNodes[offset].bmax[0] = bmax[0];
    outNodes[offset].bmax[1] = bmax[1];
    outNodes[offset].bmax[2] = bmax[2];
  }

  outStat.numBranchNodes++;

  return offset;
}

bool BVHAccel::Build(const float *vertices, const unsigned int *faces,
                     unsigned int numFaces, const BVHBuildOptions &options) {
  options_ = options;
  stats_ = BVHBuildStatistics();

  assert(options_.binSize > 1);

  size_t n = numFaces;

  //
  // 1. Create triangle indices(this will be permutated in BuildTree)
  //
  indices_.resize(n);

#ifdef _OPENMP
#pragma omp parallel for
#endif
  for (long long i = 0; i < (long long)n; i++) {
    indices_[i] = i;
  }

  //
  // 2. Compute bounding box to find scene scale.
  //
  float epsScale = 1.0f;
  float3 bmin, bmax;
  if (options.cacheBBox) {

    bmin[0] = bmin[1] = bmin[2] = std::numeric_limits<float>::max();
    bmax[0] = bmax[1] = bmax[2] = -std::numeric_limits<float>::max();

    bboxes_.resize(n);
    for (size_t i = 0; i < n; i++) { // for each faces
      size_t idx = indices_[i];

      BBox bbox;
      for (int j = 0; j < 3; j++) { // for each face vertex
        size_t fid = faces[3 * idx + j];
        for (int k = 0; k < 3; k++) { // xyz
          float minval = vertices[3 * fid + k];
          float maxval = vertices[3 * fid + k];
          if (bbox.bmin[k] > minval) {
            bbox.bmin[k] = minval;
          }
          if (bbox.bmax[k] < maxval) {
            bbox.bmax[k] = maxval;
          }
        }
      }

      bboxes_[idx] = bbox;

      for (int k = 0; k < 3; k++) { // xyz
        if (bmin[k] > bbox.bmin[k]) {
          bmin[k] = bbox.bmin[k];
        }
        if (bmax[k] < bbox.bmax[k]) {
          bmax[k] = bbox.bmax[k];
        }
      }
    }

  } else {

#ifdef _OPENMP
    ComputeBoundingBoxOMP(bmin, bmax, vertices, faces, &indices_.at(0), 0, n,
                          epsScale);
#else
    ComputeBoundingBox(bmin, bmax, vertices, faces, &indices_.at(0), 0, n,
                       epsScale);
#endif
  }

  // Find max
  float3 bsize = bmax - bmin;
  epsScale = std::abs(bsize[0]);
  if (epsScale < std::abs(bsize[1])) {
    epsScale = std::abs(bsize[1]);
  }
  if (epsScale < std::abs(bsize[2])) {
    epsScale = std::abs(bsize[2]);
  }

//
// 3. Build tree
//
#ifdef _OPENMP
#if NANORT_ENABLE_PARALLEL_BUILD

  // Do parallel build for enoughly large dataset.
  if (n > options.minPrimitivesForParallelBuild) {

    BuildShallowTree(nodes_, vertices, faces, 0, n, /* root depth */ 0,
                     options.shallowDepth, epsScale); // [0, n)

    assert(shallowNodeInfos_.size() > 0);

    // Build deeper tree in parallel
    std::vector<std::vector<BVHNode> > local_nodes(shallowNodeInfos_.size());
    std::vector<BVHBuildStatistics> local_stats(shallowNodeInfos_.size());

#pragma omp parallel for
    for (int i = 0; i < (int)shallowNodeInfos_.size(); i++) {
      unsigned int leftIdx = shallowNodeInfos_[i].leftIdx;
      unsigned int rightIdx = shallowNodeInfos_[i].rightIdx;
      BuildTree(local_stats[i], local_nodes[i], vertices, faces, leftIdx,
                rightIdx, options.shallowDepth, epsScale);
    }

    // Join local nodes
    for (int i = 0; i < (int)local_nodes.size(); i++) {

      assert(!local_nodes[i].empty());
      size_t offset = nodes_.size();

      // Add offset to child index(for branch node).
      for (size_t j = 0; j < local_nodes[i].size(); j++) {
        if (local_nodes[i][j].flag == 0) { // branch
          local_nodes[i][j].data[0] += offset - 1;
          local_nodes[i][j].data[1] += offset - 1;
        }
      }

      // replace
      nodes_[shallowNodeInfos_[i].offset] = local_nodes[i][0];

      // Skip root element of the local node.
      nodes_.insert(nodes_.end(), local_nodes[i].begin() + 1,
                    local_nodes[i].end());
    }

    // Join statistics
    for (int i = 0; i < (int)local_nodes.size(); i++) {
      stats_.maxTreeDepth =
          std::max(stats_.maxTreeDepth, local_stats[i].maxTreeDepth);
      stats_.numLeafNodes += local_stats[i].numLeafNodes;
      stats_.numBranchNodes += local_stats[i].numBranchNodes;
    }

  } else {
    BuildTree(stats_, nodes_, vertices, faces, 0, n, /* root depth */ 0,
              epsScale); // [0, n)
  }

#else // !NANORT_ENABLE_PARALLEL_BUILD
  {
    BuildTree(stats_, nodes_, vertices, faces, 0, n, /* root depth */ 0,
              epsScale); // [0, n)
  }
#endif
#else // !_OPENMP
  {
    BuildTree(stats_, nodes_, vertices, faces, 0, n, /* root depth */ 0,
              epsScale); // [0, n)
  }
#endif

  stats_.epsScale = epsScale;
  epsScale_ = epsScale;

  return true;
}

bool BVHAccel::Dump(const char *filename) {
  FILE *fp = fopen(filename, "wb");
  if (!fp) {
    fprintf(stderr, "[BVHAccel] Cannot write a file: %s\n", filename);
    return false;
  }

  unsigned long long numNodes = nodes_.size();
  assert(nodes_.size() > 0);

  unsigned long long numIndices = indices_.size();

  size_t r = 0;
  r = fwrite(&numNodes, sizeof(unsigned long long), 1, fp);
  assert(r == 1);

  r = fwrite(&nodes_.at(0), sizeof(BVHNode), numNodes, fp);
  assert(r == numNodes);

  r = fwrite(&numIndices, sizeof(unsigned long long), 1, fp);
  assert(r == 1);

  r = fwrite(&indices_.at(0), sizeof(unsigned int), numIndices, fp);
  assert(r == numIndices);

  fclose(fp);

  return true;
}

bool BVHAccel::Load(const char *filename) {
  FILE *fp = fopen(filename, "rb");
  if (!fp) {
    fprintf(stderr, "Cannot open file: %s\n", filename);
    return false;
  }

  unsigned long long numNodes;
  unsigned long long numIndices;

  size_t r = 0;
  r = fread(&numNodes, sizeof(unsigned long long), 1, fp);
  assert(r == 1);
  assert(numNodes > 0);

  nodes_.resize(numNodes);
  r = fread(&nodes_.at(0), sizeof(BVHNode), numNodes, fp);
  assert(r == numNodes);

  r = fread(&numIndices, sizeof(unsigned long long), 1, fp);
  assert(r == 1);

  indices_.resize(numIndices);

  r = fread(&indices_.at(0), sizeof(unsigned int), numIndices, fp);
  assert(r == numIndices);

  fclose(fp);

  return true;
}

namespace {

const int kMaxStackDepth = 512;

inline bool IntersectRayAABB(float &tminOut, // [out]
                             float &tmaxOut, // [out]
                             float maxT, float bmin[3], float bmax[3],
                             float3 rayOrg, float3 rayInvDir,
                             int rayDirSign[3]) {
  float tmin, tmax;

  const float min_x = rayDirSign[0] ? bmax[0] : bmin[0];
  const float min_y = rayDirSign[1] ? bmax[1] : bmin[1];
  const float min_z = rayDirSign[2] ? bmax[2] : bmin[2];
  const float max_x = rayDirSign[0] ? bmin[0] : bmax[0];
  const float max_y = rayDirSign[1] ? bmin[1] : bmax[1];
  const float max_z = rayDirSign[2] ? bmin[2] : bmax[2];

  // X
  const float tmin_x = (min_x - rayOrg[0]) * rayInvDir[0];
  const float tmax_x = (max_x - rayOrg[0]) * rayInvDir[0];

  // Y
  const float tmin_y = (min_y - rayOrg[1]) * rayInvDir[1];
  const float tmax_y = (max_y - rayOrg[1]) * rayInvDir[1];

  tmin = (tmin_x > tmin_y) ? tmin_x : tmin_y;
  tmax = (tmax_x < tmax_y) ? tmax_x : tmax_y;

  // Z
  const float tmin_z = (min_z - rayOrg[2]) * rayInvDir[2];
  const float tmax_z = (max_z - rayOrg[2]) * rayInvDir[2];

  tmin = (tmin > tmin_z) ? tmin : tmin_z;
  tmax = (tmax < tmax_z) ? tmax : tmax_z;

  //
  // Hit include (tmin == tmax) edge case(hit 2D plane).
  //
  if ((tmax > 0.0) && (tmin <= tmax) && (tmin <= maxT)) {

    tminOut = tmin;
    tmaxOut = tmax;

    return true;
  }

  return false; // no hit
}

inline bool TriangleIsect(float &tInOut, float &uOut, float &vOut,
                          const float3 &v0, const float3 &v1, const float3 &v2,
                          const float3 &rayOrg, const float3 &rayDir,
                          float epsScale) {
  const float kEPS = std::numeric_limits<float>::epsilon() * epsScale;

  float3 p0(v0[0], v0[1], v0[2]);
  float3 p1(v1[0], v1[1], v1[2]);
  float3 p2(v2[0], v2[1], v2[2]);
  float3 e1, e2;
  float3 p, s, q;

  e1 = p1 - p0;
  e2 = p2 - p0;

  p = vcross(rayDir, e2);

  float invDet;
  float det = vdot(e1, p);
  if (std::abs(det) < kEPS) { // no-cull
    return false;
  }

  invDet = 1.0 / det;

  s = rayOrg - p0;
  q = vcross(s, e1);

  float u = vdot(s, p) * invDet;
  float v = vdot(q, rayDir) * invDet;
  float t = vdot(e2, q) * invDet;

  if (u < 0.0 || u > 1.0)
    return false;
  if (v < 0.0 || u + v > 1.0)
    return false;
  if (t < 0.0 || t > tInOut)
    return false;

  tInOut = t;
  uOut = u;
  vOut = v;

  return true;
}

inline bool TestLeafNode(Intersection &isect, // [inout]
                         const BVHNode &node,
                         const std::vector<unsigned int> &indices,
                         const float *vertices, const unsigned int *faces,
                         const Ray &ray, float epsScale, const BVHTraceOptions& traceOptions) {
  bool hit = false;

  unsigned int numTriangles = node.data[0];
  unsigned int offset = node.data[1];

  float t = isect.t; // current hit distance

  float3 rayOrg;
  rayOrg[0] = ray.org[0];
  rayOrg[1] = ray.org[1];
  rayOrg[2] = ray.org[2];

  float3 rayDir;
  rayDir[0] = ray.dir[0];
  rayDir[1] = ray.dir[1];
  rayDir[2] = ray.dir[2];

  for (unsigned int i = 0; i < numTriangles; i++) {
    int faceIdx = indices[i + offset];

    if ((faceIdx < traceOptions.faceIdsRange[0]) || (faceIdx >= traceOptions.faceIdsRange[1])) {
      continue;
    }

    int f0 = faces[3 * faceIdx + 0];
    int f1 = faces[3 * faceIdx + 1];
    int f2 = faces[3 * faceIdx + 2];

    float3 v0, v1, v2;
    v0[0] = vertices[3 * f0 + 0];
    v0[1] = vertices[3 * f0 + 1];
    v0[2] = vertices[3 * f0 + 2];

    v1[0] = vertices[3 * f1 + 0];
    v1[1] = vertices[3 * f1 + 1];
    v1[2] = vertices[3 * f1 + 2];

    v2[0] = vertices[3 * f2 + 0];
    v2[1] = vertices[3 * f2 + 1];
    v2[2] = vertices[3 * f2 + 2];

    float u, v;
    if (TriangleIsect(t, u, v, v0, v1, v2, rayOrg, rayDir, epsScale)) {
      // Update isect state
      isect.t = t;
      isect.u = u;
      isect.v = v;
      isect.faceID = faceIdx;
      hit = true;
    }
  }

  return hit;
}

inline bool MultiHitTestLeafNode(IsectVector &isects, // [inout]
                                 int maxIntersections, const BVHNode &node,
                                 const std::vector<unsigned int> &indices,
                                 const float *vertices,
                                 const unsigned int *faces, const Ray &ray,
                                 float epsScale) {
  bool hit = false;

  unsigned int numTriangles = node.data[0];
  unsigned int offset = node.data[1];

  float t = std::numeric_limits<float>::max();
  if (isects.size() >= (size_t)maxIntersections) {
    t = isects.top().t; // current furthest hit distance
  }

  float3 rayOrg;
  rayOrg[0] = ray.org[0];
  rayOrg[1] = ray.org[1];
  rayOrg[2] = ray.org[2];

  float3 rayDir;
  rayDir[0] = ray.dir[0];
  rayDir[1] = ray.dir[1];
  rayDir[2] = ray.dir[2];

  for (unsigned int i = 0; i < numTriangles; i++) {
    int faceIdx = indices[i + offset];

    int f0 = faces[3 * faceIdx + 0];
    int f1 = faces[3 * faceIdx + 1];
    int f2 = faces[3 * faceIdx + 2];

    float3 v0, v1, v2;
    v0[0] = vertices[3 * f0 + 0];
    v0[1] = vertices[3 * f0 + 1];
    v0[2] = vertices[3 * f0 + 2];

    v1[0] = vertices[3 * f1 + 0];
    v1[1] = vertices[3 * f1 + 1];
    v1[2] = vertices[3 * f1 + 2];

    v2[0] = vertices[3 * f2 + 0];
    v2[1] = vertices[3 * f2 + 1];
    v2[2] = vertices[3 * f2 + 2];

    float u, v;
    if (TriangleIsect(t, u, v, v0, v1, v2, rayOrg, rayDir, epsScale)) {
      // Update isect state
      if (isects.size() < (size_t)maxIntersections) {
        Intersection isect;
        isect.t = t;
        isect.u = u;
        isect.v = v;
        isect.faceID = faceIdx;
        isects.push(isect);

        // Update furthest distance to far.
        t = std::numeric_limits<float>::max();

        hit = true;
      } else {
        if (t < isects.top().t) {
          // delete furthest intersection and add new intersection.
          isects.pop();

          Intersection isect;
          isect.t = t;
          isect.u = u;
          isect.v = v;
          isect.faceID = faceIdx;
          isects.push(isect);

          // Update furthest hit distance
          t = isects.top().t;

          hit = true;
        }
      }
    }
  }

  return hit;
}

} // namespace

bool BVHAccel::Traverse(Intersection &isect, const float *vertices,
                        const unsigned int *faces, const Ray &ray, const BVHTraceOptions& options) {
  float hitT = std::numeric_limits<float>::max(); // far = no hit.

  int nodeStackIndex = 0;
  int nodeStack[512];
  nodeStack[0] = 0;

  // Init isect info as no hit
  isect.t = hitT;
  isect.u = 0.0;
  isect.v = 0.0;
  isect.faceID = -1;

  int dirSign[3];
  dirSign[0] = ray.dir[0] < 0.0 ? 1 : 0;
  dirSign[1] = ray.dir[1] < 0.0 ? 1 : 0;
  dirSign[2] = ray.dir[2] < 0.0 ? 1 : 0;

  // @fixme { Check edge case; i.e., 1/0 }
  float3 rayInvDir;
  rayInvDir[0] = 1.0 / ray.dir[0];
  rayInvDir[1] = 1.0 / ray.dir[1];
  rayInvDir[2] = 1.0 / ray.dir[2];

  float3 rayOrg;
  rayOrg[0] = ray.org[0];
  rayOrg[1] = ray.org[1];
  rayOrg[2] = ray.org[2];

  float minT, maxT;
  while (nodeStackIndex >= 0) {
    int index = nodeStack[nodeStackIndex];
    BVHNode &node = nodes_[index];

    nodeStackIndex--;

    bool hit = IntersectRayAABB(minT, maxT, hitT, node.bmin, node.bmax, rayOrg,
                                rayInvDir, dirSign);

    if (node.flag == 0) { // branch node

      if (hit) {

        int orderNear = dirSign[node.axis];
        int orderFar = 1 - orderNear;

        // Traverse near first.
        nodeStack[++nodeStackIndex] = node.data[orderFar];
        nodeStack[++nodeStackIndex] = node.data[orderNear];
      }

    } else { // leaf node
      if (hit) {
        if (TestLeafNode(isect, node, indices_, vertices, faces, ray,
                         epsScale_, options)) {
          hitT = isect.t;
        }
      }
    }
  }

  assert(nodeStackIndex < kMaxStackDepth);

  if (isect.t < std::numeric_limits<float>::max()) {
    return true;
  }

  return false;
}

bool BVHAccel::MultiHitTraverse(StackVector<Intersection, 128> &isects,
                                int maxIntersections, const float *vertices,
                                const unsigned int *faces, Ray &ray) {
  float hitT = std::numeric_limits<float>::max(); // far = no hit.

  int nodeStackIndex = 0;
  int nodeStack[512];
  nodeStack[0] = 0;

  IsectVector isectPQ;

  isects->clear();

  int dirSign[3];
  dirSign[0] = ray.dir[0] < 0.0 ? 1 : 0;
  dirSign[1] = ray.dir[1] < 0.0 ? 1 : 0;
  dirSign[2] = ray.dir[2] < 0.0 ? 1 : 0;

  // @fixme { Check edge case; i.e., 1/0 }
  float3 rayInvDir;
  rayInvDir[0] = 1.0 / ray.dir[0];
  rayInvDir[1] = 1.0 / ray.dir[1];
  rayInvDir[2] = 1.0 / ray.dir[2];

  float3 rayOrg;
  rayOrg[0] = ray.org[0];
  rayOrg[1] = ray.org[1];
  rayOrg[2] = ray.org[2];

  float minT, maxT;
  while (nodeStackIndex >= 0) {
    int index = nodeStack[nodeStackIndex];
    BVHNode &node = nodes_[index];

    nodeStackIndex--;

    bool hit = IntersectRayAABB(minT, maxT, hitT, node.bmin, node.bmax, rayOrg,
                                rayInvDir, dirSign);

    if (node.flag == 0) { // branch node

      if (hit) {

        int orderNear = dirSign[node.axis];
        int orderFar = 1 - orderNear;

        // Traverse near first.
        nodeStack[++nodeStackIndex] = node.data[orderFar];
        nodeStack[++nodeStackIndex] = node.data[orderNear];
      }

    } else { // leaf node
      if (hit) {
        if (MultiHitTestLeafNode(isectPQ, maxIntersections, node, indices_,
                                 vertices, faces, ray, epsScale_)) {
          // Only update `hitT` when queue is full.
          if (isectPQ.size() >= (size_t)maxIntersections) {
            hitT = isectPQ.top().t;
          }
        }
      }
    }
  }

  assert(nodeStackIndex < kMaxStackDepth);

  if (!isectPQ.empty()) {

    // Store intesection in reverse order(make it frontmost order)
    size_t n = isectPQ.size();
    isects->resize(n);
    for (size_t i = 0; i < n; i++) {
      const Intersection &isect = isectPQ.top();
      isects[n - i - 1] = isect;
      isectPQ.pop();
    }

    return true;
  }

  return false;
}

} // namespace

#endif

#endif // __NANORT_H__


<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="http://www.test.eraclito.net/crm_dtd/operation.xsl"?>
<!DOCTYPE operation SYSTEM "http://www.test.eraclito.net/crm_dtd/user-folder.dtd">

<operation>
<description>Domanda di immatricolazione</description>
<uid>v.golino</uid>
<id>domanda_di_immatricolazione</id>
<date>25/10/2006 14:52:14</date>
<holder>Sandra Ceccarelli</holder>
<author>workflow</author>
<course-id>01</course-id>
</operation>


<?xml version="1.0" encoding="utf-8"?>
<browserconfig>
  <msapplication>
    <tile>
      <square70x70logo src="http://js.org/icon/ms70.png"/>
      <square150x150logo src="http://js.org/icon/ms150.png"/>
      <square310x310logo src="http://js.org/icon/ms310.png"/>
      <wide310x150logo src="http://js.org/icon/ms310w.png"/>
      <TileColor>#FDB400</TileColor>
    </tile>
  </msapplication>
</browserconfig>


<!DOCTYPE html>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="ECharts">
    <meta name="author" content="kener.linfeng@gmail.com">
    <title>ECharts · Example</title>

    <link rel="shortcut icon" href="../asset/ico/favicon.png">

    <link href="../asset/css/font-awesome.min.css" rel="stylesheet">
    <link href="../asset/css/bootstrap.css" rel="stylesheet">
    <link href="../asset/css/carousel.css" rel="stylesheet">
    <link href="../asset/css/echartsHome.css" rel="stylesheet">

    <link href="../asset/css/codemirror.css" rel="stylesheet">
    <link href="../asset/css/monokai.css" rel="stylesheet">

option

                    <textarea id="code" name="code">
option = {
    tooltip : {
        trigger: 'axis',
        axisPointer : {            // 坐标轴指示器，坐标轴触发有效
            type : 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
        }
    },
    legend: {
        data:['直接访问', '邮件营销','联盟广告','视频广告','搜索引擎']
    },
    toolbox: {
        show : true,
        feature : {
            mark : {show: true},
            dataView : {show: true, readOnly: false},
            magicType : {show: true, type: ['line', 'bar', 'stack', 'tiled']},
            restore : {show: true},
            saveAsImage : {show: true}
        }
    },
    calculable : true,
    xAxis : [
        {
            type : 'value'
        }
    ],
    yAxis : [
        {
            type : 'category',
            data : ['周一','周二','周三','周四','周五','周六','周日']
        }
    ],
    series : [
        {
            name:'直接访问',
            type:'bar',
            stack: '总量',
            itemStyle : { normal: {label : {show: true, position: 'insideRight'}}},
            data:[320, 302, 301, 334, 390, 330, 320]
        },
        {
            name:'邮件营销',
            type:'bar',
            stack: '总量',
            itemStyle : { normal: {label : {show: true, position: 'insideRight'}}},
            data:[120, 132, 101, 134, 90, 230, 210]
        },
        {
            name:'联盟广告',
            type:'bar',
            stack: '总量',
            itemStyle : { normal: {label : {show: true, position: 'insideRight'}}},
            data:[220, 182, 191, 234, 290, 330, 310]
        },
        {
            name:'视频广告',
            type:'bar',
            stack: '总量',
            itemStyle : { normal: {label : {show: true, position: 'insideRight'}}},
            data:[150, 212, 201, 154, 190, 330, 410]
        },
        {
            name:'搜索引擎',
            type:'bar',
            stack: '总量',
            itemStyle : { normal: {label : {show: true, position: 'insideRight'}}},
            data:[820, 832, 901, 934, 1290, 1330, 1320]
        }
    ]
};
                    </textarea>

                    <button type="button" class="btn btn-sm btn-success" onclick="refresh(true)">刷 新</button>
                    切换主题
                    <select id="theme-select"></select>


/**
 * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package com.liferay.ide.project.ui;

import com.liferay.ide.sdk.core.SDK;
import com.liferay.ide.sdk.core.SDKUtil;

import org.eclipse.core.expressions.PropertyTester;

/**
 * @author Simon Jiang
 */
public class HasOneWorkspaceSDKTester extends PropertyTester {

	@Override
	public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
		boolean retVal = false;

		try {
			SDK workspaceSDK = SDKUtil.getWorkspaceSDK();

			if (workspaceSDK != null) {
				retVal = true;
			}
		}
		catch (Exception e) {
			ProjectUI.logError(e);
		}

		return retVal;
	}

}


[gd_resource type="AtlasTexture" load_steps=2 format=2]

[ext_resource path="res://addons/Rakugo/emojis/atlas/16x16.png" type="Texture" id=1]

[resource]
flags = 7
atlas = ExtResource( 1 )
region = Rect2( 342, 397, 16, 15 )
margin = Rect2( 0, 1, 0, 1 )


<Project>
  <ItemDefinitionGroup Condition="$(VCToolsVersion) < 14.26">
    <ClCompile>
      <AdditionalOptions>-experimental:preprocessor %(AdditionalOptions)</AdditionalOptions>
    </ClCompile>
  </ItemDefinitionGroup>
</Project>


// (c) ammap.com | SVG (in JSON format) map of USA
// areas: {id:"US-AK"},{id:"US-AL"},{id:"US-AR"},{id:"US-AZ"},{id:"US-CA"},{id:"US-CO"},{id:"US-CT"},{id:"US-DC"},{id:"US-DE"},{id:"US-FL"},{id:"US-GA"},{id:"US-HI"},{id:"US-IA"},{id:"US-ID"},{id:"US-IL"},{id:"US-IN"},{id:"US-KS"},{id:"US-KY"},{id:"US-LA"},{id:"US-MA"},{id:"US-MD"},{id:"US-ME"},{id:"US-MI"},{id:"US-MN"},{id:"US-MO"},{id:"US-MS"},{id:"US-MT"},{id:"US-NC"},{id:"US-ND"},{id:"US-NE"},{id:"US-NH"},{id:"US-NJ"},{id:"US-NM"},{id:"US-NV"},{id:"US-NY"},{id:"US-OH"},{id:"US-OK"},{id:"US-OR"},{id:"US-PA"},{id:"US-RI"},{id:"US-SC"},{id:"US-SD"},{id:"US-TN"},{id:"US-TX"},{id:"US-UT"},{id:"US-VA"},{id:"US-VT"},{id:"US-WA"},{id:"US-WI"},{id:"US-WV"},{id:"US-WY"}
AmCharts.maps.usaLow={
	"svg": {
		"g":{
			"path":[
				{
					"id":"US-AK",
					"title":"Alaska",
					"d":"M191.8,495.91l2.87,8.43l3.02,-2.96l9.45,2.36l-0.85,3.93l8.45,3.99l6.07,-1.1l11.73,6.53l11.14,2.37l4.41,2.47l7.93,-2.48l8.81,5.39l6.42,2.46l0,0l-0.29,61.92l-0.41,89.84l7.5,0.44l7.5,4.15l5.52,6.58l7.22,9.78l7.24,-8.8l7.5,-5.33l4.57,7.63l5.67,5.86l7.72,6.27l5.88,10.36l9.87,16.24l15.03,7.91l1.32,9.26l-3.88,7.62l-5.24,-5.02l-7.87,-3.96l-3.56,-12.68l-11.56,-11.14l-5.39,-13.83l-7.71,-0.46l-12.67,0.3l-9.46,-4l-16.5,-15.44l-7.41,-2.87l-13.37,-5.62l-10.64,1l-14.65,-7.75l-8.54,-7.13l-8.59,2.6l0.69,10.76l-4.31,0.62l-9.17,2.34l-7.32,4.4l-8.95,2.21v-9.05l5.22,-14.52l8.47,-3.82l-1.62,-4.08l-10.5,7.43l-6.45,9.48L169.57,686l4.61,8.12l-8.97,9.68l-9.49,4.89l-8.73,3.17l-3.13,6.19l-14.01,5.24l-3.92,6.35l-10.87,4.25l-5.39,-2.33l-8.57,2.31l-9.52,2.92l-8.06,3.09l-15.29,0.34l-0.64,-2.74l10.79,-4.25l9.15,-2.37l10.61,-5.76l10.46,0.68l5.31,-5.08l12.97,-6.42l2.37,-2.58l6.88,-4.06l3.48,-10.97l5.58,-8.06l-9.78,2.83l-1.99,-3.05l-5.29,4.55l-3.47,-8.58l-3.22,4.87l-1.26,-8.01l-9,4.19l-4.71,-1.12l1.45,-8.95l2.67,-5.11l-3.54,-6.46l-10.41,0.39l-4.4,-8.61l-4.04,-4.93l2.31,-8.42l-3.72,-7.91l5.2,-7.81l8.05,-6.82l4.58,-7.12l5.87,0.36l4.11,3.66l7.39,-6.02l4.68,2.52l6.33,-3.59l0.34,-7.37l-3.13,-3.67l6.35,-4.88l-4.14,-0.76l-7.89,1.7l-2.89,2.92l-4.41,-4.75l-9.88,-0.77l-8.65,-6.44l-0.92,-7.01l-5.42,-11.46l10.92,-3.79l16.26,-3.71l5.19,1.37l-2.92,7.67l13.69,2.75l-2.8,-11.1l-6.17,-8.03l-2.27,-9.16l-3.95,-8.45l-6.76,-7.45l5.78,-7.51l10.57,2.37l9.34,-5.56l3.41,-7.73l7.78,-6.53l5.97,-0.64l12.31,-5.24l4.93,2.18l10.31,-7.58L191.8,495.91zM59.27,587.82l3.09,4.29l4.68,-0.11l4.08,5.78l6.04,4.18l-1.08,1.46l-6.17,1.5l-4.07,-4.97l-1.64,-3.58l-6.21,-1.19l-1.13,-1.88L59.27,587.82zM84.05,658.96l-5.19,0.99l-4.04,-4.16l-3.25,-5.32l7.96,-0.37l5.42,3L84.05,658.96zM172.79,720.54l-8.89,4.49l-3.56,-4.44l-0.17,-7.13l8.04,-4.19l4.56,-1.67l5.13,1.72l2.78,5.07L172.79,720.54z"
				},
				{
					"id":"US-AL",
					"title":"Alabama",
					"d":"M823.25,403.55L831.37,431.02L838.53,452.95L842.13,459.7L844.3,463.54L841.61,467.9L841.4,475.24L842.96,479.38L842.96,483.45L842.88,487.23L844.46,489.98L845.75,492.54L805.82,497.08L794.73,499.45L794.58,501.21L799.58,506.33L798.97,510.92L797.83,514.18L780.04,513.21L776.52,478.48L776.84,441.91L777.66,412.26L775.95,407.99L799.35,405.82z"
				},
				{
					"id":"US-AR",
					"title":"Arkansas",
					"d":"M746.45,386.99L746.39,388.88L744.74,392.2L741.65,394.62L741.19,398.42L738.45,401.59L739.1,408.17L737.11,410.42L736.87,412.24L733.64,414.14L733.77,417.43L731.63,423.65L729.53,425.07L726.38,428.35L724.64,433.14L720.94,441.29L720.79,446.7L723.3,452.55L722.62,457.07L706.39,457.09L685.47,458.65L666.94,459.1L667.77,446.16L663.36,446.16L659.67,446.53L658.64,445.06L658.85,425.16L658.87,403.06L654.82,379.13L677.08,378.97L697.32,378.33L716.63,377.44L737.54,377.61L739.25,380.31L737.34,382.88L735.44,385.46L734.45,387.78z"
				},
				{
					"id":"US-AZ",
					"title":"Arizona",
					"d":"M393.21,351.89L374.82,479.32L336.43,473.46L295.45,449.76L268.97,433.11L271.6,429.19L274.1,429.74L277.1,425.71L274.42,421.95L274.45,418.47L274.3,414.34L279,409.98L282.58,400.09L289.13,396.66L286.51,391.67L284.99,386.99L284.28,382.78L283.9,379.56L283.94,377.49L285.97,373.36L285.98,368.82L286.5,364.43L287.5,359.65L286.52,356.27L288.33,353.79L292.12,354.57L295.26,356.86L297.54,358.24L299.42,355.09L300.35,354.51L303.82,336.59L332.7,341.78L367.14,347.74z"
				},
				{
					"id":"US-CA",
					"title":"California",
					"d":"M227.74,202.25L209.97,267.9L234.88,306L259.69,342.73L283.94,377.49L283.9,379.56L284.28,382.78L284.99,386.99L286.51,391.67L289.13,396.66L282.58,400.09L279,409.98L274.3,414.34L274.45,418.47L274.42,421.95L277.1,425.71L274.1,429.74L271.6,429.19L247.2,426.36L225.43,423.15L225.09,414.45L219.96,401.1L203.57,383L196.4,380.28L190.28,371.27L176.35,365.7L172.7,360.88L173.84,348.28L162.81,321.41L157.2,286.87L159.32,282.02L153.91,272.55L146.38,250.33L149.63,231.97L144.55,217.34L153.92,200.58L159.29,181.87z"
				},
				{
					"id":"US-CO",
					"title":"Colorado",
					"d":"M524.26,297.34L522.11,332.21L519.88,365.43L502.43,364.1L480.73,362.25L449.96,359.16L421.42,355.72L393.21,351.89L406.05,262.04L423.12,264.4L440.2,266.58L474.43,270.36L491.58,271.97L525.81,274.63L524.3,296.61z"
				},
				{
					"id":"US-CT",
					"title":"Connecticut",
					"d":"M1034.84,200.91L1038.24,212.85L1038.11,216.33L1031.11,219.4L1021.77,223.02L1010.11,231.52L1008.84,228.98L1011.92,225.92L1010.14,224.38L1006.81,207.31L1019.47,204.48z"
				},
				{
					"id":"US-DC",
					"title":"Washington, DC",
					"d":"M963.72,293.35L963.53,292.03L961.68,290.43L962.86,289.07L965.55,290.9z"
				},
				{
					"id":"US-DE",
					"title":"Delaware",
					"d":"M986.93,264.85L984.93,267.74L986.35,271.89L992.67,282.97L1000,293.17L988.42,295.83L980.78,267.93L981.69,265.89L983,264.55z"
				},
				{
					"id":"US-FL",
					"title":"Florida",
					"d":"M915.25,488.75L920.47,504.83L931.05,522.16L942.9,537.63L944.43,546.48L957.31,568.23L961.78,588.44L960.97,609.01L952.91,614.56L942.16,613.5L937.22,603.98L928.48,599.97L914.49,581.98L901.97,566.79L898.51,556.09L899.92,541.71L893.44,529.65L878.58,517.85L866.13,510.74L845.03,523.09L839.71,517.25L819.88,509.08L797.83,514.18L798.97,510.92L799.58,506.33L794.58,501.21L794.73,499.45L805.82,497.08L845.75,492.54L849.47,498.29L869.32,496.79L901.59,495.62L903.65,499.35L905.87,496.93L904.7,489.07L906.93,487.93L911.06,488.99z"
				},
				{
					"id":"US-GA",
					"title":"Georgia",
					"d":"M870.54,397.61L868.77,399.77L866.4,404.45L871.95,407.48L875.38,408.38L879.89,414.99L882.71,418.65L890.05,423L891.77,425.6L896.8,428.57L899.84,433.58L906.61,437.16L908.79,442.08L910.32,444.39L909.93,446.15L913.88,448.03L916.46,451.94L917.13,456.23L919.03,456.77L922.51,457.38L916.86,475.27L915.25,488.75L911.06,488.99L906.93,487.93L904.7,489.07L905.87,496.93L903.65,499.35L901.59,495.62L869.32,496.79L849.47,498.29L845.75,492.54L844.46,489.98L842.88,487.23L842.96,483.45L842.96,479.38L841.4,475.24L841.61,467.9L844.3,463.54L842.13,459.7L838.53,452.95L831.37,431.02L823.25,403.55L837.59,402.05L847.46,400.57z"
				},
				{
					"id":"US-HI",
					"title":"Hawaii",
					"d":"M443.39,612.09l-3.04,0.1l-1.75,-2.38l-0.9,-4.35l2.24,-0.78l3.28,0.52l3.31,2.87l-0.17,1.63L443.39,612.09zM460.92,640.38l-0.66,3.48l-2.99,-1.37l-0.62,-2.43l-1.04,-0.48l-0.48,-0.1l-1.92,-1.63l1.05,-6.3l2.46,1.6l3.75,0.34l-1,5.34L460.92,640.38zM472.36,657.57l-3.54,-0.18l-5.86,-6.16l2.14,-1.41L472.36,657.57zM472.75,661.08l0.38,3.47l3.3,1.61l1.96,5.74l-0.91,1.33l-2.35,0.03l-5.18,-3l1.42,-4.08l-1.82,-1.98l0.38,-3.08l1.6,-0.74L472.75,661.08zM464.41,705.67l-3.3,1.32l-2.68,-4.91l3.87,-5.3l2.25,-8.02l6.97,-1.6l0.83,-3.42l1.47,-1.3l0.87,0.25l6.34,12.29l0.27,3.33l-1.3,2.37l1.01,1.2l-0.53,1.9l0.83,3.79l-6.57,0.44l-4.82,-2.11L464.41,705.67z"
				},
				{
					"id":"US-IA",
					"title":"Iowa",
					"d":"M708.74,219.26L709.04,220.49L711.39,223.98L710,225.78L710.31,230.55L711.1,232.54L712.37,236.09L717.96,237.96L719.79,241.33L720.87,243L722.93,244.04L723.88,246.44L726.64,248.09L728.51,249.94L727.99,256.09L725.17,261.42L724.13,263.12L720.32,264.66L714.53,266.11L713.21,270.09L715.43,271.74L716.35,275.21L714.32,279.26L713.36,282.76L709.11,286.36L708.97,290.51L706.51,288.74L703.03,285.22L684.16,286.48L664.27,287.22L648.77,287.52L633.24,287.62L632.09,283.51L632.57,279.45L632.19,275.54L630.42,268.99L629.29,266.28L628.06,265.54L627.94,260.29L626.88,256.53L623.81,252.24L623.86,250.36L622.8,246.61L622.06,244.34L622.09,242.26L619.39,239.72L620.76,236L621.65,232.36L622.06,229.89L619.95,226.86L620.01,221.31L622.21,221.31L640.32,221.33L662.83,220.7L687.01,219.83z"
				},
				{
					"id":"US-ID",
					"title":"Idaho",
					"d":"M384.7,178.06L385.21,178.56L375.87,234.37L326.11,225.41L276.58,214.43L286.18,174.71L289.06,168.74L288.45,165.54L285.82,163.34L286.7,159.8L290.12,155.29L294.56,151.7L298.48,145.04L301.92,139.8L304.17,137.26L304.11,133.69L301.91,131.28L299.24,126.14L300.3,122.21L299.68,118.48L306.56,87.28L313.23,58.66L327.79,61.98L323.71,85.85L326.37,92.69L325.47,96.73L327.51,100.93L330.57,103.82L332.38,107.84L335.18,115.68L338.48,119.77L343.09,120.94L340.37,125.56L337.65,131.15L337.77,137.18L335.65,138.25L334.63,144.02L336.98,146.81L340.63,144.78L342.87,141.95L344.65,142.95L345.92,146.4L346.33,153.84L348.59,157.19L348.46,163.24L349.11,165.06L352.25,166.24L353.6,169.87L355.34,176.23L358.88,173.67L363.99,175.46L364.82,173.33L373.63,176.35L377.44,176.27L380.5,172.2L382.13,173.11L383.16,176.53z"
				},
				{
					"id":"US-IL",
					"title":"Illinois",
					"d":"M767.4,237.97L767.4,238.03L768.06,243.91L773.71,255.38L773.71,255.38L773.71,255.38L776.14,281.56L778.56,307.71L777.15,314.18L778.75,315.7L780.04,319.47L780.19,322.52L778.83,324.03L777.89,327.89L774.65,333.15L772.69,339.44L772.52,344.06L772.79,345.73L771.03,349.05L772.75,351.05L769.73,352.97L765.81,355.21L766.92,360.09L764.7,362.15L760.16,360.41L755.25,359.56L754.19,361.85L755.15,365.22L751.67,361.95L749.76,362.68L747.04,357.29L747.46,353.85L745.73,348.47L743.87,347.93L738.83,343.28L736.79,343.33L733.04,340.37L730.3,337.13L731.2,333.08L732.64,329.68L733.38,325.44L729.78,322.01L726.52,323.68L724.45,322.85L723.94,319.08L722.22,314.86L720.54,313.92L716.32,311.1L712.77,307.43L709.63,302.92L707.74,296.22L708.97,290.51L709.11,286.36L713.36,282.76L714.32,279.26L716.35,275.21L715.43,271.74L713.21,270.09L714.53,266.11L720.32,264.66L724.13,263.12L725.17,261.42L727.99,256.09L728.51,249.94L726.64,248.09L723.88,246.44L722.93,244.04L720.87,243L719.79,241.33L736.92,240.23L754.43,238.94L767.35,238.03L767.34,237.97z"
				},
				{
					"id":"US-IN",
					"title":"Indiana",
					"d":"M819.8,251.07L822.26,271.46L824.84,293.39L826.66,309L825.79,310.19L827.78,314.61L827.23,316.37L824.27,316.77L821.75,319.09L817.48,318.77L817.61,323.14L815.31,325.08L813.42,329.22L810.98,330.21L807.81,337.35L803.98,335.81L802.57,333.17L799.94,337.99L798.22,340.71L794.11,338.45L790.21,341.01L789.07,343.34L783.23,340.43L779.62,343.26L774.85,341.93L774.89,344.44L772.52,344.06L772.69,339.44L774.65,333.15L777.89,327.89L778.83,324.03L780.19,322.52L780.04,319.47L778.75,315.7L777.15,314.18L778.56,307.71L776.14,281.56L773.71,255.38L773.71,255.38L775.41,256.76L781.16,256.08L785.48,253.14L785.48,253.14L803.69,251.3L819.57,249.31z"
				},
				{
					"id":"US-KS",
					"title":"Kansas",
					"d":"M654.77,368.71L638.81,368.9L606.07,368.79L573.32,368.04L555.14,367.35L536.98,366.45L519.88,365.43L522.11,332.21L524.26,297.34L524.29,297.34L554.73,299.07L577.39,299.98L617.51,300.79L641.53,300.79L645.7,303.78L647.97,303.71L648.51,306.99L646.09,311.22L647.45,313.36L649.68,318.1L654.35,320.18L654.53,344.47z"
				},
				{
					"id":"US-KY",
					"title":"Kentucky",
					"d":"M868.09,319.18L868.74,321.26L869.24,325.93L871.88,329.12L873.25,332.39L876.29,334.91L878.49,337.35L882.03,337.23L875.89,345L870.68,348.46L870.51,350.34L868.95,352.99L864.4,356.38L863.09,358.79L859.56,360.71L854.51,362.7L842.33,365.07L826.21,366.09L821.02,366.98L810.52,367.52L799.86,368.47L790.05,369.33L778.72,371.03L778.04,370.05L774.43,370.42L774.8,373.97L748.7,375.84L752.62,373.16L755.37,371.06L754.75,367.53L755.15,365.22L754.19,361.85L755.25,359.56L760.16,360.41L764.7,362.15L766.92,360.09L765.81,355.21L769.73,352.97L772.75,351.05L771.03,349.05L772.79,345.73L772.52,344.06L774.89,344.44L774.85,341.93L779.62,343.26L783.23,340.43L789.07,343.34L790.21,341.01L794.11,338.45L798.22,340.71L799.94,337.99L802.57,333.17L803.98,335.81L807.81,337.35L810.98,330.21L813.42,329.22L815.31,325.08L817.61,323.14L817.48,318.77L821.75,319.09L824.27,316.77L827.23,316.37L827.78,314.61L825.79,310.19L826.66,309L832.73,308.77L836.11,310.54L841.45,315.01L845.39,316.1L848.35,317.55L852.46,316.35L855.74,317.21L859.34,315.44L862.62,314.57L864.48,317.51z"
				},
				{
					"id":"US-LA",
					"title":"Louisiana",
					"d":"M722.62,457.07L724.06,458.3L722.49,461.68L725.53,466.21L724.89,469.07L727.6,472.85L725.04,475.33L724.38,479.68L720.81,483.43L719.3,488.3L717.8,493.89L715.53,496.56L716.6,502.22L733.98,502.02L752.51,500.89L752.21,504.72L751.16,508.55L752.61,511.35L755.39,513.82L756.36,517.55L756.89,519.79L755.26,529.47L762.48,542.76L734.86,545.47L717.53,541.69L705.74,537.49L690.4,535.09L673.04,534.9L671.32,531.91L673.27,528.5L676.18,525.4L676.12,520.83L674.63,519.34L676.22,513.83L677.42,511.32L679.1,502.91L677.27,499.84L674.87,494.7L673.07,489.45L671.9,485.95L668.65,483.45L666.94,459.1L685.47,458.65L706.39,457.09z"
				},
				{
					"id":"US-MA",
					"title":"Massachusetts",
					"d":"M1045.63,177.8L1048.77,189.44L1057.46,199.48L1064.38,198.06L1060.35,190.6L1066.65,194.01L1067.17,200.62L1057.15,207.36L1049.14,209.17L1047.75,205.96L1044.47,204.17L1041.66,198.77L1034.84,200.91L1019.47,204.48L1006.81,207.31L1006.47,191.24L1019.95,188.12L1039.54,183L1040.61,180.37L1043.61,177.93z"
				},
				{
					"id":"US-MD",
					"title":"Maryland",
					"d":"M980.78,267.93L988.42,295.83L1000,293.17L1001.44,294.94L996.49,304.07L992.51,305.34L991.48,307.17L980.22,298.59L975.8,282.14L974.67,290.56L979.11,309.68L967.2,305.35L965.52,302.45L962.88,304.01L960.31,303.28L961.26,297.92L963.79,295.21L963.72,293.35L965.55,290.9L962.86,289.07L961.68,290.43L957.94,288.63L954.01,288.05L954.78,285.4L952.15,284.2L949.46,283.97L947.53,281.41L944.79,278.66L939.12,277.96L936.14,280.29L934.58,282.31L929.32,282.4L927.46,285.17L924.2,286.7L921.71,289.82L919.42,292.31L917.49,280.96L933.46,277.97L938.9,276.86L951.06,274.31L965.73,271.32z"
				},
				{
					"id":"US-ME",
					"title":"Maine",
					"d":"M1046.95,172.11L1045.32,172.81L1043.71,169.97L1039.84,167.56L1039.83,165.23L1026.54,125.88L1031.85,120.24L1034.43,108.68L1034.08,90.22L1040.58,70.21L1047.3,74.47L1056.14,67.64L1064.77,71.84L1074.29,101.57L1088.28,110.6L1091.52,119.75L1078.66,131.52L1065.07,141.37L1051.08,159.84z"
				},
				{
					"id":"US-MI",
					"title":"Michigan",
					"d":"M810.31,140.6L810.31,140.6l5.32,0.03l0,0l-1.7,2.51l9.03,8.01L809.3,155l-0.54,-0.04l-12.74,-0.9l-11.87,5.92l-10.61,3.16l-8.01,15.38l-0.43,-0.12l-0.01,0.04l-2.39,-2.49l0.85,-3.77l-3.55,0.12l0.4,-3.76l0.81,-1.92l-1.7,-3.07l-3.89,-1.11l-1.2,-3.67l-3.12,-0.03l-4.49,0.34l-9.47,-3.39l-14.14,-3.12l-1.54,-4.03l-2.52,-0.59l-0.02,-0.07l-0.95,0.53l-0.15,-0.11l0.14,0.1l11.76,-6.62l12,-8.35l13.09,-8.73l-3.95,12.49l9.13,2.13l11.89,7.63l13.42,-6.53l15.16,-3.76l4.06,5.97l4.91,0.32L810.31,140.6zM855.86,215.95L855.86,215.95l-0.37,0.36l-5.98,13.52l-2.54,8.4h0l-4.54,9.49l0,0l-6.33,1.07l-7.68,1.01l-8.62,1.26l-0.23,-1.76l-15.88,1.99l-18.21,1.84v0l0,0l3.1,-3.48l5.66,-11.73l-1.15,-14.96l-6.97,-13.41l-0.19,-9.69l3.06,-11.57l3.2,-8.06l5.82,-6.16l2.38,7.43l1.52,-11.52l3.25,-2.73l1.18,-8.89l14.08,2.82l13,7.22l2.75,10.08l-0.03,10.5l-7.71,10.26l1.6,5.57l3.28,-0.25l8.73,-11.34l6.35,1.38l4.89,12.62l2.21,9.1L855.86,215.95z"
				},
				{
					"id":"US-MN",
					"title":"Minnesota",
					"d":"M728.42,114.75L728.41,114.76L713.15,123.35L702.62,133.13L692.46,143.3L692.56,146.66L688.46,148.11L689.15,160.93L688.65,160.93L684.81,163.61L681.49,165.93L679.36,170.21L682.88,174.37L681.86,180.15L682.07,186.34L681.75,191.37L686.66,195.58L688.61,195.71L694.02,198.73L695.92,200.19L697.18,202.59L701.49,206.31L707.21,209.4L707.84,211.25L708.17,216.72L708.74,219.26L687.01,219.83L662.83,220.7L640.32,221.33L622.21,221.31L622.54,200.03L620.69,178.18L617.89,176.38L616.33,172.84L617.22,169.75L620.82,167.22L621.12,163.9L621.15,159.74L620.18,156.26L618.88,152.54L618.15,147.88L618,142.66L617.48,141.4L616.9,134.67L616.87,131.58L616.59,128.83L615.86,124.17L614.03,119.43L612.29,115.2L612.08,111.02L611.94,106.51L612.5,103.57L612.63,100.89L611.25,97.55L611.06,95.28L642.49,95.37L642.44,86.5L647.55,86.32L650.41,98.96L655.22,102.79L665.92,103.97L681.65,107.14L696.84,113.64L709.12,109.99L728.41,114.75z"
				},
				{
					"id":"US-MO",
					"title":"Missouri",
					"d":"M708.97,290.51L707.74,296.22L709.63,302.92L712.77,307.43L716.32,311.1L720.54,313.92L722.22,314.86L723.94,319.08L724.45,322.85L726.52,323.68L729.78,322.01L733.38,325.44L732.64,329.68L731.2,333.08L730.3,337.13L733.04,340.37L736.79,343.33L738.83,343.28L743.87,347.93L745.73,348.47L747.46,353.85L747.04,357.29L749.76,362.68L751.67,361.95L755.15,365.22L754.75,367.53L755.37,371.06L752.62,373.16L748.7,375.84L748.38,378.06L747.49,381.37L746.45,386.99L734.45,387.78L735.44,385.46L737.34,382.88L739.25,380.31L737.54,377.61L716.63,377.44L697.32,378.33L677.08,378.97L654.82,379.13L654.86,368.71L654.77,368.71L654.53,344.47L654.35,320.18L649.68,318.1L647.45,313.36L646.09,311.22L648.51,306.99L647.97,303.71L645.7,303.78L641.53,300.79L639.23,295.96L636.52,293.07L633.59,289.49L633.24,287.62L648.77,287.52L664.27,287.22L684.16,286.48L703.03,285.22L706.51,288.74z"
				},
				{
					"id":"US-MS",
					"title":"Mississippi",
					"d":"M775.95,407.99L777.66,412.26L776.84,441.91L776.52,478.48L780.04,513.21L768.32,519.32L756.89,519.79L756.36,517.55L755.39,513.82L752.61,511.35L751.16,508.55L752.21,504.72L752.51,500.89L733.98,502.02L716.6,502.22L715.53,496.56L717.8,493.89L719.3,488.3L720.81,483.43L724.38,479.68L725.04,475.33L727.6,472.85L724.89,469.07L725.53,466.21L722.49,461.68L724.06,458.3L722.62,457.07L723.3,452.55L720.79,446.7L720.94,441.29L724.64,433.14L726.38,428.35L729.53,425.07L731.63,423.65L733.77,417.43L733.64,414.14L736.87,412.24L737.11,410.42L755.47,409.14z"
				},
				{
					"id":"US-MT",
					"title":"Montana",
					"d":"M501.84,159.67L499.16,180.45L472.33,177.57L443.38,174.28L418.47,170.63L386.97,165.87L385.13,177.31L384.7,178.06L383.16,176.53L382.13,173.11L380.5,172.2L377.44,176.27L373.63,176.35L364.82,173.33L363.99,175.46L358.88,173.67L355.34,176.23L353.6,169.87L352.25,166.24L349.11,165.06L348.46,163.24L348.59,157.19L346.33,153.84L345.92,146.4L344.65,142.95L342.87,141.95L340.63,144.78L336.98,146.81L334.63,144.02L335.65,138.25L337.77,137.18L337.65,131.15L340.37,125.56L343.09,120.94L338.48,119.77L335.18,115.68L332.38,107.84L330.57,103.82L327.51,100.93L325.47,96.73L326.37,92.69L323.71,85.85L327.79,61.98L372.22,71.15L416.94,78.85L461.89,85.08L507.02,89.83L503.5,131.88z"
				},
				{
					"id":"US-NC",
					"title":"North Carolina",
					"d":"M995.21,338.43L1002.75,360L994.84,379.03L978.65,391.44L965.08,405.88L958.75,408.49L934.04,391.25L913.5,394.62L913.11,392L909.59,388.69L907.98,390.48L907.51,388.53L898.72,388.9L881.69,391.36L872.29,396.68L870.54,397.61L847.46,400.57L847.25,395.75L850.98,393.82L851.93,391.24L854.18,388.16L857.83,387.06L862.01,385.43L865.93,382.9L867.46,380.66L870.69,378.36L870.36,376.75L874.51,373.03L876.28,374.79L882.37,369.54L885.58,369.5L887.79,365.3L891.33,363.75L890.63,360.58L890.64,357.69L921.25,353.54L957.11,346.86L976.05,342.75z"
				},
				{
					"id":"US-ND",
					"title":"North Dakota",
					"d":"M611.06,95.28L611.25,97.55L612.63,100.89L612.5,103.57L611.94,106.51L612.08,111.02L612.29,115.2L614.03,119.43L615.86,124.17L616.59,128.83L616.87,131.58L616.9,134.67L617.48,141.4L618,142.66L618.15,147.88L618.88,152.54L620.18,156.26L621.15,159.74L621.12,163.9L590.77,164.65L564.87,163.67L532.22,161.94L501.84,159.67L503.5,131.88L507.02,89.83L559.45,93.57z"
				},
				{
					"id":"US-NE",
					"title":"Nebraska",
					"d":"M622.06,244.34L622.8,246.61L623.86,250.36L623.81,252.24L626.88,256.53L627.94,260.29L628.06,265.54L629.29,266.28L630.42,268.99L632.19,275.54L632.57,279.45L632.09,283.51L633.24,287.62L633.59,289.49L636.52,293.07L639.23,295.96L641.53,300.79L617.51,300.79L577.39,299.98L554.73,299.07L524.29,297.34L524.26,297.34L524.3,296.61L525.81,274.63L491.58,271.97L495.46,226.79L527.96,229.32L552.96,230.8L586.41,232.12L590.65,235.11L596.76,237.07L598.22,236.06L602.2,236.22L608.18,236.09L612.47,239.07L617.05,241.01L617.8,242.91L619.24,244.01z"
				},
				{
					"id":"US-NH",
					"title":"New Hampshire",
					"d":"M1046.95,172.11L1045.63,177.8L1043.61,177.93L1040.61,180.37L1039.54,183L1019.95,188.12L1018.05,186.18L1018.57,182.99L1017.43,177.12L1017.56,175.61L1016.72,170.27L1017.3,165.41L1018.09,163.14L1018.58,157.42L1017.99,153.78L1017.94,151.5L1020.7,149.61L1023.53,146.09L1023.4,143.19L1021.37,140.36L1021.55,133.87L1021.52,133.86L1021.57,128.01L1026.54,125.88L1039.83,165.23L1039.84,167.56L1043.71,169.97L1045.32,172.81z"
				},
				{
					"id":"US-NJ",
					"title":"New Jersey",
					"d":"M1005.97,233.13L1002.85,245.27L1007.3,245.2L1008.29,261.79L999.91,281.76L997.29,276.39L993.25,276.13L987.8,271.3L986.35,271.89L984.93,267.74L986.93,264.85L989.95,262.02L990.85,260.36L994.19,256.49L995.8,253.57L989.13,249.11L988.29,246.84L986.3,246.58L985.55,243.01L986.88,239.85L985.31,237.18L987.53,234.61L989.28,228.98L991.08,227.52z"
				},
				{
					"id":"US-NM",
					"title":"New Mexico",
					"d":"M502.43,364.1L501.59,375.32L497.01,434.63L493.71,477.35L475.73,475.87L440.89,472.47L423.5,470.51L423.48,472.47L425.23,476.34L391.9,472.15L390.39,481.45L374.82,479.32L393.21,351.89L421.42,355.72L449.96,359.16L480.73,362.25z"
				},
				{
					"id":"US-NV",
					"title":"Nevada",
					"d":"M326.11,225.41L303.82,336.59L300.35,354.51L299.42,355.09L297.54,358.24L295.26,356.86L292.12,354.57L288.33,353.79L286.52,356.27L287.5,359.65L286.5,364.43L285.98,368.82L285.97,373.36L283.94,377.49L259.69,342.73L234.88,306L209.97,267.9L227.74,202.25L276.56,214.49L276.58,214.43z"
				},
				{
					"id":"US-NY",
					"title":"New York",
					"d":"M1006.47,191.24L1006.81,207.31L1010.14,224.38L1011.92,225.92L1008.84,228.98L1010.11,231.52L1032.89,222.46L1038.92,225.29L1017.3,238.01L1006.63,240.74L1005.97,233.13L991.08,227.52L988.02,226.6L984.83,225.73L983,222.77L982.87,220.23L980.43,218.69L976.03,216.05L953.56,221.02L929.39,226.03L903.43,230.95L902.33,224.89L914.06,208.94L913.34,206.86L913.33,206.8L909.87,200.77L917.84,196.33L930.8,194.61L944.51,193.68L955.07,183.7L952.2,175.26L949.61,172.2L949.54,172.18L949.55,172.17L949.62,172.2L962.67,153.32L968.84,147.56L992.69,141.54L993.51,146.1L993.6,149.11L995.65,155.57L997.38,158.72L996.94,163.69L999.87,169.09L999.66,172.55L1000.17,173.31L1002.51,172.89z"
				},
				{
					"id":"US-OH",
					"title":"Ohio",
					"d":"M895.99,263.59L893.82,265.11L895.03,267.83L895.11,273.12L894.33,279.24L893.47,284.35L893.57,286.7L889.71,292.59L887.88,294.01L885.64,295.02L883.46,294.86L880.19,299.33L880.12,303.48L879.92,305.75L878.5,306.88L877.89,304.42L875.44,304.24L873.72,309.48L874.2,314.49L872.38,317.95L868.09,319.18L864.48,317.51L862.62,314.57L859.34,315.44L855.74,317.21L852.46,316.35L848.35,317.55L845.39,316.1L841.45,315.01L836.11,310.54L832.73,308.77L826.66,309L824.84,293.39L822.26,271.46L819.8,251.07L828.42,249.81L836.1,248.8L842.43,247.72L842.43,247.72L842.43,247.73L853.5,250.9L862.09,250.8L873.84,245.91L882.78,238.09L890.88,233.62z"
				},
				{
					"id":"US-OK",
					"title":"Oklahoma",
					"d":"M654.82,379.13L658.87,403.06L658.85,425.16L658.64,445.06L650.4,440.72L645.06,438.36L640.76,439.93L634.09,439.72L630.14,439.76L626.89,441.61L623.71,442.55L620.93,441.42L614.58,442.61L611.74,438.79L608.74,442.04L603.58,440.5L598.33,436.88L592.59,439.04L590.23,433.51L581.41,433.82L575.82,432.43L569.54,430.6L566.91,425.79L561.9,427.12L558.91,425.14L554.53,422.51L555.49,400.85L556.46,378.64L538.16,377.73L519.86,376.63L501.59,375.32L502.43,364.1L519.88,365.43L536.98,366.45L555.14,367.35L573.32,368.04L606.07,368.79L638.81,368.9L654.77,368.71L654.86,368.71z"
				},
				{
					"id":"US-OR",
					"title":"Oregon",
					"d":"M299.24,126.14L301.91,131.28L304.11,133.69L304.17,137.26L301.92,139.8L298.48,145.04L294.56,151.7L290.12,155.29L286.7,159.8L285.82,163.34L288.45,165.54L289.06,168.74L286.18,174.71L276.58,214.43L276.56,214.49L227.74,202.25L159.29,181.87L158.03,168.07L170.35,146.42L179.28,122.31L192.49,90.34L195.72,91.03L200.31,92.59L203.38,95.72L207.41,98.33L208.97,103.37L208.26,107.16L208.47,110.57L211.77,112.47L215.57,113.53L222.2,112.96L225.89,113.27L231.12,115.79L233.22,117.63L236.67,117.76L240.68,116.96L247.56,119.17L253.95,118.28L257.44,117.29L261.12,119.3L267.26,118.43z"
				},
				{
					"id":"US-PA",
					"title":"Pennsylvania",
					"d":"M991.08,227.52L989.28,228.98L987.53,234.61L985.31,237.18L986.88,239.85L985.55,243.01L986.3,246.58L988.29,246.84L989.13,249.11L995.8,253.57L994.19,256.49L990.85,260.36L989.95,262.02L986.93,264.85L983,264.55L981.69,265.89L980.78,267.93L965.73,271.32L951.06,274.31L938.9,276.86L933.46,277.97L917.49,280.96L899.53,284.16L895.99,263.59L890.88,233.62L890.88,233.62L902.3,224.93L902.33,224.89L903.43,230.95L929.39,226.03L953.56,221.02L976.03,216.05L980.43,218.69L982.87,220.23L983,222.77L984.83,225.73L988.02,226.6z"
				},
				{
					"id":"US-RI",
					"title":"Rhode Island",
					"d":"M1049.14,209.17L1038.11,216.33L1038.24,212.85L1034.84,200.91L1041.66,198.77L1044.47,204.17L1047.75,205.96z"
				},
				{
					"id":"US-SC",
					"title":"South Carolina",
					"d":"M958.75,408.49L954.4,425.6L940.47,442.52L922.51,457.38L919.03,456.77L917.13,456.23L916.46,451.94L913.88,448.03L909.93,446.15L910.32,444.39L908.79,442.08L906.61,437.16L899.84,433.58L896.8,428.57L891.77,425.6L890.05,423L882.71,418.65L879.89,414.99L875.38,408.38L871.95,407.48L866.4,404.45L868.77,399.77L870.54,397.61L872.29,396.68L881.69,391.36L898.72,388.9L907.51,388.53L907.98,390.48L909.59,388.69L913.11,392L913.5,394.62L934.04,391.25z"
				},
				{
					"id":"US-SD",
					"title":"South Dakota",
					"d":"M622.21,221.31L620.01,221.31L619.95,226.86L622.06,229.89L621.65,232.36L620.76,236L619.39,239.72L622.09,242.26L622.06,244.34L619.24,244.01L617.8,242.91L617.05,241.01L612.47,239.07L608.18,236.09L602.2,236.22L598.22,236.06L596.76,237.07L590.65,235.11L586.41,232.12L552.96,230.8L527.96,229.32L495.46,226.79L499.16,180.45L501.84,159.67L532.22,161.94L564.87,163.67L590.77,164.65L621.12,163.9L620.82,167.22L617.22,169.75L616.33,172.84L617.89,176.38L620.69,178.18L622.54,200.03z"
				},
				{
					"id":"US-TN",
					"title":"Tennessee",
					"d":"M854.51,362.7L881.54,359.56L890.64,357.69L890.63,360.58L891.33,363.75L887.79,365.3L885.58,369.5L882.37,369.54L876.28,374.79L874.51,373.03L870.36,376.75L870.69,378.36L867.46,380.66L865.93,382.9L862.01,385.43L857.83,387.06L854.18,388.16L851.93,391.24L850.98,393.82L847.25,395.75L847.46,400.57L837.59,402.05L823.25,403.55L799.35,405.82L775.95,407.99L755.47,409.14L737.11,410.42L739.1,408.17L738.45,401.59L741.19,398.42L741.65,394.62L744.74,392.2L746.39,388.88L746.45,386.99L747.49,381.37L748.38,378.06L748.7,375.84L774.8,373.97L774.43,370.42L778.04,370.05L778.72,371.03L790.05,369.33L799.86,368.47L810.52,367.52L821.02,366.98L826.21,366.09L842.33,365.07z"
				},
				{
					"id":"US-TX",
					"title":"Texas",
					"d":"M658.64,445.06L659.67,446.53L663.36,446.16L667.77,446.16L666.94,459.1L668.65,483.45L671.9,485.95L673.07,489.45L674.87,494.7L677.27,499.84L679.1,502.91L677.42,511.32L676.22,513.83L674.63,519.34L676.12,520.83L676.18,525.4L673.27,528.5L671.32,531.91L673.04,534.9L656.02,540.04L637.82,557.24L617.61,567.14L606.35,578.03L601.48,588.34L601.04,604.28L601.91,615.41L605.78,623.36L597.58,623.93L582.8,618.52L566.71,610.86L561.26,599.79L557.33,583.46L545.79,569.82L539.4,556.02L530.11,539.78L516.53,529.83L500.18,529.18L486.19,546.32L470.08,538.07L460.36,530.23L456.6,517.21L451.21,504.67L440.58,493.46L431.39,485.2L425.23,476.34L423.48,472.47L423.5,470.51L440.89,472.47L475.73,475.87L493.71,477.35L497.01,434.63L501.59,375.32L519.86,376.63L538.16,377.73L556.46,378.64L555.49,400.85L554.53,422.51L558.91,425.14L561.9,427.12L566.91,425.79L569.54,430.6L575.82,432.43L581.41,433.82L590.23,433.51L592.59,439.04L598.33,436.88L603.58,440.5L608.74,442.04L611.74,438.79L614.58,442.61L620.93,441.42L623.71,442.55L626.89,441.61L630.14,439.76L634.09,439.72L640.76,439.93L645.06,438.36L650.4,440.72z"
				},
				{
					"id":"US-UT",
					"title":"Utah",
					"d":"M406.05,262.04L393.21,351.89L367.14,347.74L332.7,341.78L303.82,336.59L326.11,225.41L375.87,234.37L372.15,256.16z"
				},
				{
					"id":"US-VA",
					"title":"Virginia",
					"d":"M949.46,283.97l2.68,0.24l2.64,1.19l-0.78,2.65l3.93,0.58l3.75,1.8l1.84,1.6l0.19,1.32l0.07,1.86l-2.52,2.71l-0.95,5.36l2.57,0.72l2.64,-1.56l1.68,2.91l13.73,10.02l5.74,9.84l0.35,0.6l8.2,12.61l-19.16,4.32l-18.93,4.11l-35.87,6.68l-30.61,4.16l-9.1,1.87l-27.04,3.14l5.06,-2l3.53,-1.92l1.3,-2.42l4.55,-3.38l1.57,-2.65l0.17,-1.88l5.21,-3.46l6.13,-7.78l1.39,3.68l2.33,1.71l3.01,1.37l5.21,-3.61l2.41,1.22l6.36,-2.98l0.05,-2.07l2.15,0.45l1.93,-2.01l2.54,-0.11l2.53,-2.22l0.03,-2.11L911.2,328l1.72,-4.29l2.9,-3.52l0.28,-3.45l2.3,-4.51l0.8,-5.16l2.64,1.3l2.9,1.11l2.36,-1.33l0.46,-2.19l1.2,-3.09l1.34,-3.53l1.44,0.69l2.03,-3.37l2.84,-3.57l1.72,-2.63l0.2,-6.19l10.03,4.26L949.46,283.97zM988.81,323.46l1.81,0.52l5.88,-19.91l-3.99,1.27l-1.03,1.82L988.81,323.46z"
				},
				{
					"id":"US-VT",
					"title":"Vermont",
					"d":"M1019.95,188.12L1006.47,191.24L1002.51,172.89L1000.17,173.31L999.66,172.55L999.87,169.09L996.94,163.69L997.38,158.72L995.65,155.57L993.6,149.11L993.51,146.1L992.69,141.54L1021.52,133.86L1021.55,133.87L1021.37,140.36L1023.4,143.19L1023.53,146.09L1020.7,149.61L1017.94,151.5L1017.99,153.78L1018.58,157.42L1018.09,163.14L1017.3,165.41L1016.72,170.27L1017.56,175.61L1017.43,177.12L1018.57,182.99L1018.05,186.18z"
				},
				{
					"id":"US-WA",
					"title":"Washington",
					"d":"M313.23,58.66L306.56,87.28L299.68,118.48L300.3,122.21L299.24,126.14L267.26,118.43L261.12,119.3L257.44,117.29L253.95,118.28L247.56,119.17L240.68,116.96L236.67,117.76L233.22,117.63L231.12,115.79L225.89,113.27L222.2,112.96L215.57,113.53L211.77,112.47L208.47,110.57L208.26,107.16L208.97,103.37L207.41,98.33L203.38,95.72L200.31,92.59L195.72,91.03L192.49,90.34L194.19,70.89L198.52,49.07L217.79,59.52L219.14,78.74L224.58,74.04L227.61,55.27L226.19,34.98L269.51,47.56z"
				},
				{
					"id":"US-WI",
					"title":"Wisconsin",
					"d":"M718.02,148.31L718.17,148.42L719.11,147.88L719.13,147.95L721.66,148.55L723.2,152.58L737.33,155.69L746.81,159.08L751.29,158.75L754.41,158.78L755.61,162.45L759.51,163.56L761.21,166.63L760.4,168.55L760,172.31L763.55,172.19L762.7,175.96L765.09,178.45L765.1,178.41L765.53,178.53L765.4,178.76L759.81,187.53L762.25,190.02L772.73,174.27L775.14,173.95L768.45,192.24L766.23,208.39L764.26,221.5L767.34,232.41L767.4,237.97L767.34,237.97L767.35,238.03L754.43,238.94L736.92,240.23L719.79,241.33L717.96,237.96L712.37,236.09L711.1,232.54L710.31,230.55L710,225.78L711.39,223.98L709.04,220.49L708.74,219.26L708.17,216.72L707.84,211.25L707.21,209.4L701.49,206.31L697.18,202.59L695.92,200.19L694.02,198.73L688.61,195.71L686.66,195.58L681.75,191.37L682.07,186.34L681.86,180.15L682.88,174.37L679.36,170.21L681.49,165.93L684.81,163.61L688.65,160.93L689.15,160.93L688.46,148.11L692.56,146.66L692.56,146.66L708.07,141.11z"
				},
				{
					"id":"US-WV",
					"title":"West Virginia",
					"d":"M917.49,280.96L919.42,292.31L921.71,289.82L924.2,286.7L927.46,285.17L929.32,282.4L934.58,282.31L936.14,280.29L939.12,277.96L944.79,278.66L947.53,281.41L949.46,283.97L948.37,288.54L938.34,284.28L938.14,290.47L936.42,293.1L933.58,296.67L931.55,300.04L930.11,299.35L928.76,302.87L927.56,305.97L927.1,308.15L924.75,309.48L921.84,308.37L919.2,307.07L918.4,312.23L916.1,316.74L915.82,320.19L912.93,323.71L911.2,328L911.95,330.57L911.92,332.68L909.4,334.9L906.86,335.01L904.93,337.02L902.78,336.56L902.73,338.63L896.37,341.61L893.96,340.38L888.75,343.99L885.75,342.62L883.41,340.91L882.03,337.23L878.49,337.35L876.29,334.91L873.25,332.39L871.88,329.12L869.24,325.93L868.74,321.26L868.09,319.18L872.38,317.95L874.2,314.49L873.72,309.48L875.44,304.24L877.89,304.42L878.5,306.88L879.92,305.75L880.12,303.48L880.19,299.33L883.46,294.86L885.64,295.02L887.88,294.01L889.71,292.59L893.57,286.7L893.47,284.35L894.33,279.24L895.11,273.12L895.03,267.83L893.82,265.11L895.99,263.59L899.53,284.16z"
				},
				{
					"id":"US-WY",
					"title":"Wyoming",
					"d":"M499.16,180.45L495.46,226.79L491.58,271.97L474.43,270.36L440.2,266.58L423.12,264.4L406.05,262.04L372.15,256.16L375.87,234.37L385.21,178.56L384.7,178.06L385.13,177.31L386.97,165.87L418.47,170.63L443.38,174.28L472.33,177.57z"
				}
			]
		}
	}
};


<?xml version="1.0" encoding="UTF-8"?>
<!--
 /**
  * Copyright © Magento, Inc. All rights reserved.
  * See COPYING.txt for license details.
  */
-->

<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
    <actionGroup name="StorefrontCheckQuickSearchStringActionGroup">
        <annotations>
            <description>Fill the Storefront Search field. Submits the Form. Validates that the provided Search Phrase is present and correct.</description>
        </annotations>
        <arguments>
            <argument name="phrase" type="string"/>
        </arguments>

        <fillField stepKey="fillInput" selector="{{StorefrontQuickSearchResultsSection.searchTextBox}}" userInput="{{phrase}}"/>
        <submitForm selector="{{StorefrontQuickSearchResultsSection.searchTextBox}}" parameterArray="[]" stepKey="submitQuickSearch"/>
        <seeInCurrentUrl url="{{StorefrontCatalogSearchPage.url}}" stepKey="checkUrl"/>
        <dontSeeInCurrentUrl url="form_key=" stepKey="checkUrlFormKey"/>
        <seeInTitle userInput="Search results for: '{{phrase}}'" stepKey="assertQuickSearchTitle"/>
        <see userInput="Search results for: '{{phrase}}'" selector="{{StorefrontCatalogSearchMainSection.SearchTitle}}" stepKey="assertQuickSearchName"/>
    </actionGroup>
</actionGroups>


---
layout: project
title: Conduit
categories:
  - server
description: Conduit is a server written in Rust.
author: Timo Koesters
maturity: Alpha
language: Rust
license: AGPL-3.0
repo: https://git.koesters.xyz/timo/conduit
home: https://conduit.rs
room: "#conduit:koesters.xyz"
---

Conduit is a server written in Rust ([git](https://git.koesters.xyz/timo/conduit))