@import url(https://fonts.googleapis.com/css?family=Josefin+Sans:300,300i,400,400i,600,600i,700,700i);
@import url(https://fonts.googleapis.com/css?family=Cormorant+Upright:300,400,500,600,700);

body {
  font-family: Josefin Sans;
  font-style: normal;
  line-height: 1.5;
}
.mbr-section-title {
  font-style: normal;
  line-height: 1.2;
}
.mbr-section-subtitle {
  line-height: 1.3;
}
.mbr-text {
  font-style: normal;
  line-height: 1.6;
}
.display-1 {
  font-family: 'Josefin Sans', sans-serif;
  font-size: 3rem;
}
.display-1 > .mbr-iconfont {
  font-size: 4.8rem;
}
.display-2 {
  font-family: 'Josefin Sans', sans-serif;
  font-size: 2.25rem;
}
.display-2 > .mbr-iconfont {
  font-size: 3.6rem;
}
.display-4 {
  font-family: 'Cormorant Upright', serif;
  font-size: 1.2rem;
}
.display-4 > .mbr-iconfont {
  font-size: 1.92rem;
}
.display-5 {
  font-family: 'Josefin Sans', sans-serif;
  font-size: 1.8rem;
}
.display-5 > .mbr-iconfont {
  font-size: 2.88rem;
}
.display-7 {
  font-family: 'Cormorant Upright', serif;
  font-size: 1.3rem;
}
.display-7 > .mbr-iconfont {
  font-size: 2.08rem;
}
/* ---- Fluid typography for mobile devices ---- */
/* 1.4 - font scale ratio ( bootstrap == 1.42857 ) */
/* 100vw - current viewport width */
/* (48 - 20)  48 == 48rem == 768px, 20 == 20rem == 320px(minimal supported viewport) */
/* 0.65 - min scale variable, may vary */
@media (max-width: 768px) {
  .display-1 {
    font-size: 2.4rem;
    font-size: calc( 1.7rem + (3 - 1.7) * ((100vw - 20rem) / (48 - 20)));
    line-height: calc( 1.4 * (1.7rem + (3 - 1.7) * ((100vw - 20rem) / (48 - 20))));
  }
  .display-2 {
    font-size: 1.8rem;
    font-size: calc( 1.4375rem + (2.25 - 1.4375) * ((100vw - 20rem) / (48 - 20)));
    line-height: calc( 1.4 * (1.4375rem + (2.25 - 1.4375) * ((100vw - 20rem) / (48 - 20))));
  }
  .display-4 {
    font-size: 0.96rem;
    font-size: calc( 1.07rem + (1.2 - 1.07) * ((100vw - 20rem) / (48 - 20)));
    line-height: calc( 1.4 * (1.07rem + (1.2 - 1.07) * ((100vw - 20rem) / (48 - 20))));
  }
  .display-5 {
    font-size: 1.44rem;
    font-size: calc( 1.28rem + (1.8 - 1.28) * ((100vw - 20rem) / (48 - 20)));
    line-height: calc( 1.4 * (1.28rem + (1.8 - 1.28) * ((100vw - 20rem) / (48 - 20))));
  }
}
/* Buttons */
.btn {
  border-radius: 0;
  font-weight: 600;
  border-width: 2px;
  font-style: normal;
  letter-spacing: 2px;
  margin: .4rem .8rem;
  white-space: normal;
  -webkit-transition: all 0.3s ease-in-out;
  -moz-transition: all 0.3s ease-in-out;
  transition: all 0.3s ease-in-out;
  display: -webkit-inline-flex;
  display: inline-flex;
  -webkit-align-items: center;
  align-items: center;
  -webkit-justify-content: center;
  justify-content: center;
  word-break: break-word;
  padding: 0.8rem 2rem;
  border-radius: 0px;
}
.btn-sm {
  font-weight: 600;
  letter-spacing: 2px;
  -webkit-transition: all 0.3s ease-in-out;
  -moz-transition: all 0.3s ease-in-out;
  transition: all 0.3s ease-in-out;
  padding: 0.5rem 1.5rem;
  border-radius: 0px;
}
.btn-md {
  font-weight: 600;
  letter-spacing: 2px;
  margin: .4rem .8rem !important;
  -webkit-transition: all 0.3s ease-in-out;
  -moz-transition: all 0.3s ease-in-out;
  transition: all 0.3s ease-in-out;
  padding: 0.8rem 2rem;
  border-radius: 0px;
}
.btn-lg {
  font-weight: 600;
  letter-spacing: 2px;
  margin: .4rem .8rem !important;
  -webkit-transition: all 0.3s ease-in-out;
  -moz-transition: all 0.3s ease-in-out;
  transition: all 0.3s ease-in-out;
  padding: 0.8rem 2rem;
  border-radius: 0px;
}
.bg-primary {
  background-color: #f9e2af !important;
}
.bg-success {
  background-color: #98e38d !important;
}
.bg-info {
  background-color: #69b9d0 !important;
}
.bg-warning {
  background-color: #c1c1c1 !important;
}
.bg-danger {
  background-color: #444444 !important;
}
.btn-primary,
.btn-primary:active,
.btn-primary.active {
  background-color: #f9e2af !important;
  border-color: #f9e2af !important;
  color: #9d700c !important;
}
.btn-primary:hover,
.btn-primary:focus,
.btn-primary.focus {
  color: #9d700c !important;
  background-color: #f4c868 !important;
  border-color: #f4c868 !important;
}
.btn-primary.disabled,
.btn-primary:disabled {
  color: #9d700c !important;
  background-color: #f4c868 !important;
  border-color: #f4c868 !important;
}
.btn-secondary,
.btn-secondary:active,
.btn-secondary.active {
  background-color: #f5aeb5 !important;
  border-color: #f5aeb5 !important;
  color: #ffffff !important;
}
.btn-secondary:hover,
.btn-secondary:focus,
.btn-secondary.focus {
  color: #ffffff !important;
  background-color: #ed6a77 !important;
  border-color: #ed6a77 !important;
}
.btn-secondary.disabled,
.btn-secondary:disabled {
  color: #ffffff !important;
  background-color: #ed6a77 !important;
  border-color: #ed6a77 !important;
}
.btn-info,
.btn-info:active,
.btn-info.active {
  background-color: #69b9d0 !important;
  border-color: #69b9d0 !important;
  color: #ffffff !important;
}
.btn-info:hover,
.btn-info:focus,
.btn-info.focus {
  color: #ffffff !important;
  background-color: #3898b4 !important;
  border-color: #3898b4 !important;
}
.btn-info.disabled,
.btn-info:disabled {
  color: #ffffff !important;
  background-color: #3898b4 !important;
  border-color: #3898b4 !important;
}
.btn-success,
.btn-success:active,
.btn-success.active {
  background-color: #98e38d !important;
  border-color: #98e38d !important;
  color: #1f5b16 !important;
}
.btn-success:hover,
.btn-success:focus,
.btn-success.focus {
  color: #1f5b16 !important;
  background-color: #61d450 !important;
  border-color: #61d450 !important;
}
.btn-success.disabled,
.btn-success:disabled {
  color: #1f5b16 !important;
  background-color: #61d450 !important;
  border-color: #61d450 !important;
}
.btn-warning,
.btn-warning:active,
.btn-warning.active {
  background-color: #c1c1c1 !important;
  border-color: #c1c1c1 !important;
  color: #ffffff !important;
}
.btn-warning:hover,
.btn-warning:focus,
.btn-warning.focus {
  color: #ffffff !important;
  background-color: #9b9b9b !important;
  border-color: #9b9b9b !important;
}
.btn-warning.disabled,
.btn-warning:disabled {
  color: #ffffff !important;
  background-color: #9b9b9b !important;
  border-color: #9b9b9b !important;
}
.btn-danger,
.btn-danger:active,
.btn-danger.active {
  background-color: #444444 !important;
  border-color: #444444 !important;
  color: #ffffff !important;
}
.btn-danger:hover,
.btn-danger:focus,
.btn-danger.focus {
  color: #ffffff !important;
  background-color: #1e1e1e !important;
  border-color: #1e1e1e !important;
}
.btn-danger.disabled,
.btn-danger:disabled {
  color: #ffffff !important;
  background-color: #1e1e1e !important;
  border-color: #1e1e1e !important;
}
.btn-white {
  color: #333333 !important;
}
.btn-white,
.btn-white:active,
.btn-white.active {
  background-color: #ffffff !important;
  border-color: #ffffff !important;
  color: #808080 !important;
}
.btn-white:hover,
.btn-white:focus,
.btn-white.focus {
  color: #808080 !important;
  background-color: #d9d9d9 !important;
  border-color: #d9d9d9 !important;
}
.btn-white.disabled,
.btn-white:disabled {
  color: #808080 !important;
  background-color: #d9d9d9 !important;
  border-color: #d9d9d9 !important;
}
.btn-black,
.btn-black:active,
.btn-black.active {
  background-color: #333333 !important;
  border-color: #333333 !important;
  color: #ffffff !important;
}
.btn-black:hover,
.btn-black:focus,
.btn-black.focus {
  color: #ffffff !important;
  background-color: #0d0d0d !important;
  border-color: #0d0d0d !important;
}
.btn-black.disabled,
.btn-black:disabled {
  color: #ffffff !important;
  background-color: #0d0d0d !important;
  border-color: #0d0d0d !important;
}
.btn-primary-outline,
.btn-primary-outline:active,
.btn-primary-outline.active {
  background: none;
  border-color: #f2c050;
  color: #f2c050;
}
.btn-primary-outline:hover,
.btn-primary-outline:focus,
.btn-primary-outline.focus {
  color: #9d700c;
  background-color: #f9e2af;
  border-color: #f9e2af;
}
.btn-primary-outline.disabled,
.btn-primary-outline:disabled {
  color: #9d700c !important;
  background-color: #f9e2af !important;
  border-color: #f9e2af !important;
}
.btn-secondary-outline,
.btn-secondary-outline:active,
.btn-secondary-outline.active {
  background: none;
  border-color: #ea5362;
  color: #ea5362;
}
.btn-secondary-outline:hover,
.btn-secondary-outline:focus,
.btn-secondary-outline.focus {
  color: #ffffff;
  background-color: #f5aeb5;
  border-color: #f5aeb5;
}
.btn-secondary-outline.disabled,
.btn-secondary-outline:disabled {
  color: #ffffff !important;
  background-color: #f5aeb5 !important;
  border-color: #f5aeb5 !important;
}
.btn-info-outline,
.btn-info-outline:active,
.btn-info-outline.active {
  background: none;
  border-color: #3288a1;
  color: #3288a1;
}
.btn-info-outline:hover,
.btn-info-outline:focus,
.btn-info-outline.focus {
  color: #ffffff;
  background-color: #69b9d0;
  border-color: #69b9d0;
}
.btn-info-outline.disabled,
.btn-info-outline:disabled {
  color: #ffffff !important;
  background-color: #69b9d0 !important;
  border-color: #69b9d0 !important;
}
.btn-success-outline,
.btn-success-outline:active,
.btn-success-outline.active {
  background: none;
  border-color: #4ecf3b;
  color: #4ecf3b;
}
.btn-success-outline:hover,
.btn-success-outline:focus,
.btn-success-outline.focus {
  color: #1f5b16;
  background-color: #98e38d;
  border-color: #98e38d;
}
.btn-success-outline.disabled,
.btn-success-outline:disabled {
  color: #1f5b16 !important;
  background-color: #98e38d !important;
  border-color: #98e38d !important;
}
.btn-warning-outline,
.btn-warning-outline:active,
.btn-warning-outline.active {
  background: none;
  border-color: #8e8e8e;
  color: #8e8e8e;
}
.btn-warning-outline:hover,
.btn-warning-outline:focus,
.btn-warning-outline.focus {
  color: #ffffff;
  background-color: #c1c1c1;
  border-color: #c1c1c1;
}
.btn-warning-outline.disabled,
.btn-warning-outline:disabled {
  color: #ffffff !important;
  background-color: #c1c1c1 !important;
  border-color: #c1c1c1 !important;
}
.btn-danger-outline,
.btn-danger-outline:active,
.btn-danger-outline.active {
  background: none;
  border-color: #111111;
  color: #111111;
}
.btn-danger-outline:hover,
.btn-danger-outline:focus,
.btn-danger-outline.focus {
  color: #ffffff;
  background-color: #444444;
  border-color: #444444;
}
.btn-danger-outline.disabled,
.btn-danger-outline:disabled {
  color: #ffffff !important;
  background-color: #444444 !important;
  border-color: #444444 !important;
}
.btn-black-outline,
.btn-black-outline:active,
.btn-black-outline.active {
  background: none;
  border-color: #000000;
  color: #000000;
}
.btn-black-outline:hover,
.btn-black-outline:focus,
.btn-black-outline.focus {
  color: #ffffff;
  background-color: #333333;
  border-color: #333333;
}
.btn-black-outline.disabled,
.btn-black-outline:disabled {
  color: #ffffff !important;
  background-color: #333333 !important;
  border-color: #333333 !important;
}
.btn-white-outline,
.btn-white-outline:active,
.btn-white-outline.active {
  background: none;
  border-color: #ffffff;
  color: #ffffff;
}
.btn-white-outline:hover,
.btn-white-outline:focus,
.btn-white-outline.focus {
  color: #333333;
  background-color: #ffffff;
  border-color: #ffffff;
}
.text-primary {
  color: #f9e2af !important;
}
.text-secondary {
  color: #f5aeb5 !important;
}
.text-success {
  color: #98e38d !important;
}
.text-info {
  color: #69b9d0 !important;
}
.text-warning {
  color: #c1c1c1 !important;
}
.text-danger {
  color: #444444 !important;
}
.text-white {
  color: #ffffff !important;
}
.text-black {
  color: #000000 !important;
}
a.text-primary:hover,
a.text-primary:focus {
  color: #f2c050 !important;
}
a.text-secondary:hover,
a.text-secondary:focus {
  color: #ea5362 !important;
}
a.text-success:hover,
a.text-success:focus {
  color: #4ecf3b !important;
}
a.text-info:hover,
a.text-info:focus {
  color: #3288a1 !important;
}
a.text-warning:hover,
a.text-warning:focus {
  color: #8e8e8e !important;
}
a.text-danger:hover,
a.text-danger:focus {
  color: #111111 !important;
}
a.text-white:hover,
a.text-white:focus {
  color: #b3b3b3 !important;
}
a.text-black:hover,
a.text-black:focus {
  color: #4d4d4d !important;
}
.alert-success {
  background-color: #98e38d;
}
.alert-info {
  background-color: #69b9d0;
}
.alert-warning {
  background-color: #c1c1c1;
}
.alert-danger {
  background-color: #444444;
}
.mbr-section-btn a.btn:not(.btn-form):hover,
.mbr-section-btn a.btn:not(.btn-form):focus {
  box-shadow: none !important;
}
.mbr-gallery-filter li.active .btn {
  background-color: #f9e2af;
  border-color: #f9e2af;
  color: #b5810e;
}
.mbr-gallery-filter li.active .btn:focus {
  box-shadow: none;
}
.btn-form {
  border-radius: 0;
}
.btn-form:hover {
  cursor: pointer;
}
a,
a:hover {
  color: #f9e2af;
}
.mbr-plan-header.bg-primary .mbr-plan-subtitle,
.mbr-plan-header.bg-primary .mbr-plan-price-desc {
  color: #ffffff;
}
.mbr-plan-header.bg-success .mbr-plan-subtitle,
.mbr-plan-header.bg-success .mbr-plan-price-desc {
  color: #ffffff;
}
.mbr-plan-header.bg-info .mbr-plan-subtitle,
.mbr-plan-header.bg-info .mbr-plan-price-desc {
  color: #ffffff;
}
.mbr-plan-header.bg-warning .mbr-plan-subtitle,
.mbr-plan-header.bg-warning .mbr-plan-price-desc {
  color: #ffffff;
}
.mbr-plan-header.bg-danger .mbr-plan-subtitle,
.mbr-plan-header.bg-danger .mbr-plan-price-desc {
  color: #b7b7b7;
}
/* Scroll to top button*/
.scrollToTop_wraper {
  display: none;
}
#scrollToTop a {
  border: 2px solid #ffbc00;
  background: transparent;
}
#scrollToTop a i:before {
  content: '';
  position: absolute;
  height: 40%;
  top: 25%;
  background: #ffbc00;
  width: 2px;
  left: calc(50% - 1px);
}
#scrollToTop a i:after {
  content: '';
  position: absolute;
  display: block;
  border-top: 2px solid #ffbc00;
  border-right: 2px solid #ffbc00;
  width: 40%;
  height: 40%;
  left: 30%;
  bottom: 30%;
  -webkit-transform: rotate(135deg);
  transform: rotate(135deg);
}
/* Others*/
.note-check a[data-value=Rubik] {
  font-style: normal;
}
.mbr-arrow {
  background-color: transparent;
  opacity: .7;
  transition: .3s;
  text-align: center;
  width: auto;
}
.mbr-arrow:hover {
  opacity: 1;
}
.mbr-arrow a {
  display: block;
}
.mbr-arrow a i {
  color: #ffbc00;
  top: auto !important;
  left: auto !important;
}
@media (max-width: 767px) {
  .mbr-arrow {
    display: none;
  }
}
.form-control-label {
  position: relative;
  cursor: pointer;
  margin-bottom: .357em;
  padding: 0;
}
.alert {
  color: #ffffff;
  border-radius: 0;
  border: 0;
  font-size: .875rem;
  line-height: 1.5;
  margin-bottom: 1.875rem;
  padding: 1.25rem;
  position: relative;
}
.alert.alert-form::after {
  background-color: inherit;
  bottom: -7px;
  content: "";
  display: block;
  height: 14px;
  left: 50%;
  margin-left: -7px;
  position: absolute;
  -webkit-transform: rotate(45deg);
  transform: rotate(45deg);
  width: 14px;
}
.form-control {
  background-color: #f5f5f5;
  box-shadow: none;
  color: #565656;
  font-family: 'Cormorant Upright', serif;
  font-size: 1.3rem;
  line-height: 1.43;
  min-height: 3.5em;
  padding: 1.07em .5em;
}
.form-control > .mbr-iconfont {
  font-size: 2.08rem;
}
.form-control,
.form-control:focus {
  border: 1px solid #e8e8e8;
}
.form-active .form-control:invalid {
  border-color: red;
}
.mbr-overlay {
  background-color: #000;
  bottom: 0;
  left: 0;
  opacity: .5;
  position: absolute;
  right: 0;
  top: 0;
  z-index: 0;
}
blockquote {
  font-style: italic;
  padding: 10px 0 10px 20px;
  font-size: 1.09rem;
  position: relative;
  border-color: #f9e2af;
  border-width: 3px;
}
ul,
ol,
pre,
blockquote {
  margin-bottom: 2.3125rem;
}
pre {
  background: #f4f4f4;
  padding: 10px 24px;
  white-space: pre-wrap;
}
.inactive {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  pointer-events: none;
  -webkit-user-drag: none;
  user-drag: none;
}
.mbr-section__comments .row {
  -webkit-justify-content: center;
  justify-content: center;
}
/* Forms */
.mbr-form .btn {
  margin: .4rem 0;
}
@media (max-width: 767px) {
  .btn {
    font-size: .75rem !important;
  }
  .btn .mbr-iconfont {
    font-size: 1rem !important;
  }
}
/* Social block */
.btn-social {
  font-size: 20px;
  border-radius: 50%;
  padding: 0;
  width: 44px;
  height: 44px;
  line-height: 44px;
  text-align: center;
  position: relative;
  border: 2px solid #c0a375;
  border-color: #f9e2af;
  color: #232323;
  cursor: pointer;
}
.btn-social i {
  top: 0;
  line-height: 44px;
  width: 44px;
}
.btn-social:hover {
  color: #fff;
  background: #f9e2af;
}
.btn-social + .btn {
  margin-left: .1rem;
}
.carousel-item.active,
.carousel-item-next,
.carousel-item-prev {
  display: -webkit-box;
  display: -webkit-flex;
  display: -ms-flexbox;
  display: flex;
}
.note-air-layout .dropup .dropdown-menu,
.note-air-layout .navbar-fixed-bottom .dropdown .dropdown-menu {
  bottom: initial !important;
}
html,
body {
  height: auto;
  min-height: 100vh;
}
.dropup .dropdown-toggle::after {
  display: none;
}
.cid-rbgv0rt4j3 {
  padding-top: 135px;
  padding-bottom: 135px;
  background-image: url("../../../assets/images/anshu-a-1180959-unsplash-2000x1335.jpg");
}
.cid-rbgv0rt4j3 .mbr-overlay {
  background: #ffffff;
}
.cid-rbgv0rt4j3 .mbr-section-title {
  letter-spacing: .5rem;
  text-align: left;
}
.cid-rbgv0rt4j3 .mbr-section-subtitle {
  text-align: left;
}
.cid-rbgv0rt4j3 .mbr-text,
.cid-rbgv0rt4j3 .mbr-section-btn {
  text-align: left;
}
.cid-raMGzBDSdH {
  padding-top: 90px;
  padding-bottom: 90px;
  background-color: #ffffff;
}
.cid-raMGzBDSdH .text-box {
  position: absolute;
  top: 0px;
  min-height: 100%;
  -webkit-writing-mode: vertical-rl;
  writing-mode: vertical-rl;
}
.cid-raMGzBDSdH .text-block {
  position: relative;
  z-index: 0;
}
.cid-raMGzBDSdH .box {
  width: 25%;
  height: 40%;
  background: #e2f7df;
  position: absolute;
  top: 4%;
}
.cid-raMGzBDSdH .box {
  left: 20%;
}
.cid-raMGzBDSdH .text-box {
  left: 0;
  -webkit-transform: rotate(180deg);
  transform: rotate(180deg);
}
.cid-raMGzBDSdH .mbr-section-text,
.cid-raMGzBDSdH .mbr-section-title {
  margin-left: 31%;
}
@media (max-width: 991px) {
  .cid-raMGzBDSdH .text-box {
    display: none;
  }
  .cid-raMGzBDSdH .mbr-section-title,
  .cid-raMGzBDSdH .mbr-section-text {
    margin: auto;
  }
}
@media (max-width: 767px) {
  .cid-raMGzBDSdH .box {
    display: none;
  }
  .cid-raMGzBDSdH .row {
    -webkit-flex-direction: column-reverse;
    flex-direction: column-reverse;
  }
  .cid-raMGzBDSdH .img-block {
    margin-bottom: 1rem;
  }
}
@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
  .cid-raMGzBDSdH .text-box {
    writing-mode: bt-rl;
  }
}
.cid-raMGAt0bMx {
  padding-top: 90px;
  padding-bottom: 90px;
  background-color: #efefef;
}
.cid-raMGAt0bMx .text-box {
  position: absolute;
  top: 0px;
  min-height: 100%;
  -webkit-writing-mode: vertical-rl;
  writing-mode: vertical-rl;
}
.cid-raMGAt0bMx .text-block {
  position: relative;
  z-index: 0;
}
.cid-raMGAt0bMx .box {
  width: 25%;
  height: 40%;
  background: #e2f7df;
  position: absolute;
  top: 4%;
}
.cid-raMGAt0bMx .box {
  left: 20%;
}
.cid-raMGAt0bMx .text-box {
  left: 0;
  -webkit-transform: rotate(180deg);
  transform: rotate(180deg);
}
.cid-raMGAt0bMx .mbr-section-text,
.cid-raMGAt0bMx .mbr-section-title {
  margin-left: 31%;
}
@media (max-width: 991px) {
  .cid-raMGAt0bMx .text-box {
    display: none;
  }
  .cid-raMGAt0bMx .mbr-section-title,
  .cid-raMGAt0bMx .mbr-section-text {
    margin: auto;
  }
}
@media (max-width: 767px) {
  .cid-raMGAt0bMx .box {
    display: none;
  }
  .cid-raMGAt0bMx .row {
    -webkit-flex-direction: column-reverse;
    flex-direction: column-reverse;
  }
  .cid-raMGAt0bMx .img-block {
    margin-bottom: 1rem;
  }
}
@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
  .cid-raMGAt0bMx .text-box {
    writing-mode: bt-rl;
  }
}
.cid-raMHjovLlV {
  padding-top: 90px;
  padding-bottom: 90px;
  background-color: #ffffff;
}
.cid-raMHjovLlV .text-box {
  position: absolute;
  top: 0px;
  min-height: 100%;
  -webkit-writing-mode: vertical-rl;
  writing-mode: vertical-rl;
}
.cid-raMHjovLlV .text-block {
  position: relative;
  z-index: 0;
}
.cid-raMHjovLlV .box {
  width: 25%;
  height: 40%;
  background: #e2f7df;
  position: absolute;
  top: 4%;
}
.cid-raMHjovLlV .box {
  left: 20%;
}
.cid-raMHjovLlV .text-box {
  left: 0;
  -webkit-transform: rotate(180deg);
  transform: rotate(180deg);
}
.cid-raMHjovLlV .mbr-section-text,
.cid-raMHjovLlV .mbr-section-title {
  margin-left: 31%;
}
@media (max-width: 991px) {
  .cid-raMHjovLlV .text-box {
    display: none;
  }
  .cid-raMHjovLlV .mbr-section-title,
  .cid-raMHjovLlV .mbr-section-text {
    margin: auto;
  }
}
@media (max-width: 767px) {
  .cid-raMHjovLlV .box {
    display: none;
  }
  .cid-raMHjovLlV .row {
    -webkit-flex-direction: column-reverse;
    flex-direction: column-reverse;
  }
  .cid-raMHjovLlV .img-block {
    margin-bottom: 1rem;
  }
}
@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
  .cid-raMHjovLlV .text-box {
    writing-mode: bt-rl;
  }
}
.cid-raMISJsI0L {
  padding-top: 90px;
  padding-bottom: 90px;
  background-color: #f4f4f4;
}
.cid-raMISJsI0L .text-box {
  position: absolute;
  top: 0px;
  min-height: 100%;
  -webkit-writing-mode: vertical-rl;
  writing-mode: vertical-rl;
}
.cid-raMISJsI0L .text-block {
  position: relative;
  z-index: 0;
}
.cid-raMISJsI0L .box {
  width: 25%;
  height: 40%;
  background: #efefef;
  position: absolute;
  top: 4%;
}
.cid-raMISJsI0L .box {
  left: 20%;
}
.cid-raMISJsI0L .text-box {
  left: 0;
  -webkit-transform: rotate(180deg);
  transform: rotate(180deg);
}
.cid-raMISJsI0L .mbr-section-text,
.cid-raMISJsI0L .mbr-section-title {
  margin-left: 31%;
}
@media (max-width: 991px) {
  .cid-raMISJsI0L .text-box {
    display: none;
  }
  .cid-raMISJsI0L .mbr-section-title,
  .cid-raMISJsI0L .mbr-section-text {
    margin: auto;
  }
}
@media (max-width: 767px) {
  .cid-raMISJsI0L .box {
    display: none;
  }
  .cid-raMISJsI0L .row {
    -webkit-flex-direction: column-reverse;
    flex-direction: column-reverse;
  }
  .cid-raMISJsI0L .img-block {
    margin-bottom: 1rem;
  }
}
@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
  .cid-raMISJsI0L .text-box {
    writing-mode: bt-rl;
  }
}
.cid-raMRyizfov {
  padding-top: 90px;
  padding-bottom: 90px;
  background-color: #ffffff;
}
.cid-raMRyizfov .text-content .btn-bgr {
  z-index: 0;
}
.cid-raMRyizfov .mbr-overlay {
  background: #ffffff;
}
.cid-raMRyizfov .content-row {
  -webkit-flex-direction: row-reverse;
  flex-direction: row-reverse;
}
.cid-raMRyizfov .text-content {
  padding: 2rem 0rem;
  background-color: #ffffff;
}
.cid-raMRyizfov .mbr-section-btn {
  margin-left: -0.8rem;
}
.cid-raMRyizfov .media-container-row {
  padding-left: 1rem;
  padding-right: 1rem;
}
@media (max-width: 767px) {
  .cid-raMRyizfov .mbr-text {
    text-align: center;
  }
}
@media (max-width: 991px) {
  .cid-raMRyizfov .text-content {
    margin-bottom: 2rem;
  }
}
.cid-raSLS2Jnck {
  padding-top: 90px;
  padding-bottom: 90px;
  background-color: #f4f4f4;
}
.cid-raSLS2Jnck .text-box {
  position: absolute;
  top: 0px;
  min-height: 100%;
  writing-mode: vertical-rl;
}
.cid-raSLS2Jnck .text-block {
  position: relative;
  z-index: 0;
}
.cid-raSLS2Jnck .box {
  width: 25%;
  height: 40%;
  background: #e2f7df;
  position: absolute;
  top: 4%;
}
.cid-raSLS2Jnck .box {
  left: 20%;
}
.cid-raSLS2Jnck .text-box {
  left: 0;
  -webkit-transform: rotate(180deg);
  transform: rotate(180deg);
}
.cid-raSLS2Jnck .mbr-section-text,
.cid-raSLS2Jnck .mbr-section-title {
  margin-left: 31%;
  margin-left: 0;
}
@media (max-width: 991px) {
  .cid-raSLS2Jnck .text-box {
    display: none;
  }
  .cid-raSLS2Jnck .mbr-section-title,
  .cid-raSLS2Jnck .mbr-section-text {
    margin: auto;
  }
}
@media (max-width: 767px) {
  .cid-raSLS2Jnck .box {
    display: none;
  }
  .cid-raSLS2Jnck .row {
    -webkit-flex-direction: column-reverse;
    flex-direction: column-reverse;
  }
  .cid-raSLS2Jnck .img-block {
    margin-bottom: 1rem;
  }
}
@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
  .cid-raSLS2Jnck .text-box {
    writing-mode: bt-rl;
  }
}
.cid-raSLS2Jnck .mbr-section-title {
  color: #444444;
  text-align: left;
}
.cid-raSLS2Jnck .mbr-section-text {
  color: #000000;
  text-align: left;
}
.cid-raMRhrRKkc {
  padding-top: 60px;
  padding-bottom: 60px;
  background-color: #000000;
}
.cid-raMRhrRKkc *:focus {
  outline: none;
}
.cid-raMRhrRKkc .input-wrap {
  padding-bottom: 1rem;
}
.cid-raMRhrRKkc input,
.cid-raMRhrRKkc textarea {
  width: 100%;
  background: #ffffff;
  border-radius: 0;
  border: none;
}
.cid-raMRhrRKkc input {
  padding: .5rem;
}
.cid-raMRhrRKkc ::-webkit-input-placeholder {
  color: #000000;
}
.cid-raMRhrRKkc ::-moz-placeholder {
  color: #000000;
}
.cid-raMRhrRKkc :-ms-input-placeholder {
  color: #000000;
}
.cid-raMRhrRKkc :-moz-placeholder {
  color: #000000;
}
.cid-raMRhrRKkc .soc-item {
  display: inline-block;
  margin: 0 .1rem .2rem .1rem;
  padding: 10px 11px 0 11px;
  border: 2px solid #f9e2af;
  border-radius: 50%;
}
.cid-raMRhrRKkc .soc-item:hover {
  opacity: .5;
}
.cid-raMRhrRKkc .soc-item .socicon {
  font-size: 1.5rem;
  color: #f9e2af;
}
.cid-raMRhrRKkc .days-column,
.cid-raMRhrRKkc .hours-column {
  display: inline-block;
}
.cid-raMRhrRKkc .days-column span,
.cid-raMRhrRKkc .hours-column span {
  display: block;
}
.cid-raMRhrRKkc .input-group-btn {
  display: block;
}
@media (max-width: 767px) {
  .cid-raMRhrRKkc .days-column {
    padding-right: 0 !important;
  }
  .cid-raMRhrRKkc .hours-column {
    max-width: 50% !important;
  }
  .cid-raMRhrRKkc .opening-hours {
    padding-bottom: 48px !important;
  }
}
.cid-raMecSBRXp .nav-item:focus,
.cid-raMecSBRXp .nav-link:focus {
  outline: none;
}
.cid-raMecSBRXp .dropdown .dropdown-menu .dropdown-item {
  width: auto;
  -webkit-transition: all 0.25s ease-in-out;
  -moz-transition: all 0.25s ease-in-out;
  transition: all 0.25s ease-in-out;
}
.cid-raMecSBRXp .dropdown .dropdown-menu .dropdown-item::after {
  right: 0.5rem;
}
.cid-raMecSBRXp .dropdown .dropdown-menu .dropdown-item .mbr-iconfont {
  margin-left: -1.8rem;
  padding-right: 1rem;
  font-size: inherit;
}
.cid-raMecSBRXp .dropdown .dropdown-menu .dropdown-item .mbr-iconfont:before {
  display: inline-block;
  -webkit-transform: scale(1, 1);
  transform: scale(1, 1);
  -webkit-transition: all 0.25s ease-in-out;
  -moz-transition: all 0.25s ease-in-out;
  transition: all 0.25s ease-in-out;
}
.cid-raMecSBRXp .collapsed .dropdown .dropdown-menu .dropdown-item {
  padding: 0.235em 1.5em !important;
  transition: none;
  margin: 0 !important;
}
.cid-raMecSBRXp .navbar {
  min-height: 77px;
  transition: all .3s;
  background: #ffffff;
  background: none;
}
.cid-raMecSBRXp .navbar.opened {
  transition: all .3s;
  background: #ffffff !important;
}
.cid-raMecSBRXp .navbar .dropdown-item {
  padding: .235rem 1.5rem;
}
.cid-raMecSBRXp .navbar .navbar-collapse {
  -webkit-justify-content: flex-end;
  justify-content: flex-end;
  z-index: 1;
}
.cid-raMecSBRXp .navbar.collapsed.opened .dropdown-menu {
  top: 0;
}
.cid-raMecSBRXp .navbar.collapsed .dropdown-menu {
  background: transparent !important;
}
.cid-raMecSBRXp .navbar.collapsed .dropdown-menu .dropdown-submenu {
  left: 0 !important;
}
.cid-raMecSBRXp .navbar.collapsed .dropdown-menu .dropdown-item:after {
  right: auto;
}
.cid-raMecSBRXp .navbar.collapsed .dropdown-menu .dropdown-toggle[data-toggle="dropdown-submenu"]:after {
  margin-left: .25rem;
  border-top: 0.35em solid;
  border-right: 0.35em solid transparent;
  border-left: 0.35em solid transparent;
  border-bottom: 0;
  top: 55%;
}
.cid-raMecSBRXp .navbar.collapsed ul.navbar-nav li {
  margin: auto;
}
.cid-raMecSBRXp .navbar.collapsed .dropdown-menu .dropdown-item {
  padding: .25rem 1.5rem;
  text-align: center;
}
.cid-raMecSBRXp .navbar.collapsed .icons-menu {
  padding-left: 0;
  padding-top: .5rem;
  padding-bottom: .5rem;
}
@media (max-width: 991px) {
  .cid-raMecSBRXp .navbar.opened .dropdown-menu {
    top: 0;
  }
  .cid-raMecSBRXp .navbar .dropdown-menu {
    background: transparent !important;
  }
  .cid-raMecSBRXp .navbar .dropdown-menu .dropdown-submenu {
    left: 0 !important;
  }
  .cid-raMecSBRXp .navbar .dropdown-menu .dropdown-item:after {
    right: auto;
  }
  .cid-raMecSBRXp .navbar .dropdown-menu .dropdown-toggle[data-toggle="dropdown-submenu"]:after {
    margin-left: .25rem;
    border-top: 0.35em solid;
    border-right: 0.35em solid transparent;
    border-left: 0.35em solid transparent;
    border-bottom: 0;
    top: 55%;
  }
  .cid-raMecSBRXp .navbar .navbar-logo img {
    height: 3.8rem !important;
  }
  .cid-raMecSBRXp .navbar ul.navbar-nav li {
    margin: auto;
  }
  .cid-raMecSBRXp .navbar .dropdown-menu .dropdown-item {
    padding: .25rem 1.5rem !important;
    text-align: center;
  }
  .cid-raMecSBRXp .navbar .navbar-brand {
    -webkit-flex-shrink: initial;
    flex-shrink: initial;
    -webkit-flex-basis: auto;
    flex-basis: auto;
    word-break: break-word;
  }
  .cid-raMecSBRXp .navbar .navbar-toggler {
    -webkit-flex-basis: auto;
    flex-basis: auto;
  }
  .cid-raMecSBRXp .navbar .icons-menu {
    padding-left: 0;
    padding-top: .5rem;
    padding-bottom: .5rem;
  }
}
.cid-raMecSBRXp .navbar.navbar-short {
  background: #ffffff !important;
  min-height: 60px;
}
.cid-raMecSBRXp .navbar.navbar-short .navbar-logo img {
  height: 3rem !important;
}
.cid-raMecSBRXp .navbar.navbar-short .navbar-brand {
  padding: 0;
}
.cid-raMecSBRXp .navbar-brand {
  -webkit-flex-shrink: 0;
  flex-shrink: 0;
  -webkit-align-items: center;
  align-items: center;
  margin-right: 0;
  padding: 0;
  transition: all .3s;
  word-break: break-word;
  z-index: 1;
}
.cid-raMecSBRXp .navbar-brand .navbar-caption {
  line-height: inherit !important;
}
.cid-raMecSBRXp .navbar-brand .navbar-logo a {
  outline: none;
}
.cid-raMecSBRXp .dropdown-item.active,
.cid-raMecSBRXp .dropdown-item:active {
  background-color: transparent;
}
.cid-raMecSBRXp .navbar-expand-lg .navbar-nav .nav-link {
  padding: 0;
}
.cid-raMecSBRXp .nav-dropdown .link.dropdown-toggle {
  margin-right: 1.667em;
}
.cid-raMecSBRXp .nav-dropdown .link.dropdown-toggle[aria-expanded="true"] {
  margin-right: 0;
  padding: 0.667em 1.667em;
}
.cid-raMecSBRXp .navbar.navbar-expand-lg .dropdown .dropdown-menu {
  background: #ffffff;
}
.cid-raMecSBRXp .navbar.navbar-expand-lg .dropdown .dropdown-menu .dropdown-submenu {
  margin: 0;
  left: 100%;
}
.cid-raMecSBRXp .navbar .dropdown.open > .dropdown-menu {
  display: block;
}
.cid-raMecSBRXp ul.navbar-nav {
  -webkit-flex-wrap: wrap;
  flex-wrap: wrap;
}
.cid-raMecSBRXp .navbar-buttons {
  text-align: center;
}
.cid-raMecSBRXp button.navbar-toggler {
  outline: none;
  width: 31px;
  height: 20px;
  cursor: pointer;
  transition: all .2s;
  position: relative;
  -webkit-align-self: center;
  align-self: center;
}
.cid-raMecSBRXp button.navbar-toggler .hamburger span {
  position: absolute;
  right: 0;
  width: 30px;
  height: 2px;
  border-right: 5px;
  background-color: #232323;
}
.cid-raMecSBRXp button.navbar-toggler .hamburger span:nth-child(1) {
  top: 0;
  transition: all .2s;
}
.cid-raMecSBRXp button.navbar-toggler .hamburger span:nth-child(2) {
  top: 8px;
  transition: all .15s;
}
.cid-raMecSBRXp button.navbar-toggler .hamburger span:nth-child(3) {
  top: 8px;
  transition: all .15s;
}
.cid-raMecSBRXp button.navbar-toggler .hamburger span:nth-child(4) {
  top: 16px;
  transition: all .2s;
}
.cid-raMecSBRXp nav.opened .hamburger span:nth-child(1) {
  top: 8px;
  width: 0;
  opacity: 0;
  right: 50%;
  transition: all .2s;
}
.cid-raMecSBRXp nav.opened .hamburger span:nth-child(2) {
  -webkit-transform: rotate(45deg);
  transform: rotate(45deg);
  transition: all .25s;
}
.cid-raMecSBRXp nav.opened .hamburger span:nth-child(3) {
  -webkit-transform: rotate(-45deg);
  transform: rotate(-45deg);
  transition: all .25s;
}
.cid-raMecSBRXp nav.opened .hamburger span:nth-child(4) {
  top: 8px;
  width: 0;
  opacity: 0;
  right: 50%;
  transition: all .2s;
}
.cid-raMecSBRXp .navbar-dropdown {
  padding: .5rem 1rem;
  position: fixed;
}
.cid-raMecSBRXp a.nav-link {
  -webkit-justify-content: center;
  justify-content: center;
  display: flex;
  -webkit-align-items: center;
  align-items: center;
}
.cid-raMecSBRXp .mbr-iconfont {
  font-size: 1.5rem;
  padding-right: .5rem;
}
.cid-raMecSBRXp .icons-menu {
  -webkit-flex-wrap: wrap;
  flex-wrap: wrap;
  display: flex;
  -webkit-justify-content: center;
  justify-content: center;
  padding-left: 1rem;
  text-align: center;
}
.cid-raMecSBRXp .icons-menu span {
  font-size: 20px;
  color: #232323;
}
.cid-raMecSBRXp .nav-link:hover,
.cid-raMecSBRXp .dropdown-item:hover,
.cid-raMecSBRXp .icons-menu .mbr-iconfont:hover {
  color: #cccccc !important;
}
@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
  .cid-raMecSBRXp .navbar {
    height: 77px;
  }
  .cid-raMecSBRXp .navbar.opened {
    height: auto;
  }
}

{'repo_name': 'Mobirise/Mobirise', 'stars': '611', 'repo_language': 'HTML', 'file_name': 'jquery.viewportchecker.js', 'mime_type': 'text/plain', 'hash': -8612695358540048816, 'source_dataset': 'data'}


# coding=utf-8
# Copyright 2018 The Google AI Language Team Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Tokenization classes."""

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import collections
import re
import unicodedata
import six
import tensorflow as tf

def validate_case_matches_checkpoint(do_lower_case, init_checkpoint):
  """Checks whether the casing config is consistent with the checkpoint name."""

  # The casing has to be passed in by the user and there is no explicit check
  # as to whether it matches the checkpoint. The casing information probably
  # should have been stored in the bert_config.json file, but it's not, so
  # we have to heuristically detect it to validate.

  if not init_checkpoint:
    return

  m = re.match("^.*?([A-Za-z0-9_-]+)/bert_model.ckpt", init_checkpoint)
  if m is None:
    return

  model_name = m.group(1)

  lower_models = [
      "uncased_L-24_H-1024_A-16", "uncased_L-12_H-768_A-12",
      "multilingual_L-12_H-768_A-12", "chinese_L-12_H-768_A-12"
  ]

  cased_models = [
      "cased_L-12_H-768_A-12", "cased_L-24_H-1024_A-16",
      "multi_cased_L-12_H-768_A-12"
  ]

  is_bad_config = False
  if model_name in lower_models and not do_lower_case:
    is_bad_config = True
    actual_flag = "False"
    case_name = "lowercased"
    opposite_flag = "True"

  if model_name in cased_models and do_lower_case:
    is_bad_config = True
    actual_flag = "True"
    case_name = "cased"
    opposite_flag = "False"

  if is_bad_config:
    raise ValueError(
        "You passed in `--do_lower_case=%s` with `--init_checkpoint=%s`. "
        "However, `%s` seems to be a %s model, so you "
        "should pass in `--do_lower_case=%s` so that the fine-tuning matches "
        "how the model was pre-training. If this error is wrong, please "
        "just comment out this check." % (actual_flag, init_checkpoint,
                                          model_name, case_name, opposite_flag))

def convert_to_unicode(text):
  """Converts `text` to Unicode (if it's not already), assuming utf-8 input."""
  if six.PY3:
    if isinstance(text, str):
      return text
    elif isinstance(text, bytes):
      return text.decode("utf-8", "ignore")
    else:
      raise ValueError("Unsupported string type: %s" % (type(text)))
  elif six.PY2:
    if isinstance(text, str):
      return text.decode("utf-8", "ignore")
    elif isinstance(text, unicode):
      return text
    else:
      raise ValueError("Unsupported string type: %s" % (type(text)))
  else:
    raise ValueError("Not running on Python2 or Python 3?")

def printable_text(text):
  """Returns text encoded in a way suitable for print or `tf.logging`."""

  # These functions want `str` for both Python2 and Python3, but in one case
  # it's a Unicode string and in the other it's a byte string.
  if six.PY3:
    if isinstance(text, str):
      return text
    elif isinstance(text, bytes):
      return text.decode("utf-8", "ignore")
    else:
      raise ValueError("Unsupported string type: %s" % (type(text)))
  elif six.PY2:
    if isinstance(text, str):
      return text
    elif isinstance(text, unicode):
      return text.encode("utf-8")
    else:
      raise ValueError("Unsupported string type: %s" % (type(text)))
  else:
    raise ValueError("Not running on Python2 or Python 3?")

def load_vocab(vocab_file):
  """Loads a vocabulary file into a dictionary."""
  vocab = collections.OrderedDict()
  index = 0
  with tf.gfile.GFile(vocab_file, "r") as reader:
    while True:
      token = convert_to_unicode(reader.readline())
      if not token:
        break
      token = token.strip()
      vocab[token] = index
      index += 1
  return vocab

def convert_by_vocab(vocab, items):
  """Converts a sequence of [tokens|ids] using the vocab."""
  output = []
  #print("items:",items) #['[CLS]', '日', '##期', '，', '但', '被', '##告', '金', '##东', '##福', '载', '##明', '[MASK]', 'U', '##N', '##K', ']', '保', '##证', '本', '##月', '1', '##4', '[MASK]', '到', '##位', '，', '2', '##0', '##1', '##5', '年', '6', '[MASK]', '1', '##1', '日', '[', 'U', '##N', '##K', ']', '，', '原', '##告', '[MASK]', '认', '##可', '于', '2', '##0', '##1', '##5', '[MASK]', '6', '月', '[MASK]', '[MASK]', '日', '##向', '被', '##告', '主', '##张', '权', '##利', '。', '而', '[MASK]', '[MASK]', '自', '[MASK]', '[MASK]', '[MASK]', '[MASK]', '年', '6', '月', '1', '##1', '日', '[SEP]', '原', '##告', '于', '2', '##0', '##1', '##6', '[MASK]', '6', '[MASK]', '2', '##4', '日', '起', '##诉', '，', '主', '##张', '保', '##证', '责', '##任', '，', '已', '超', '##过', '保', '##证', '期', '##限', '[MASK]', '保', '##证', '人', '依', '##法', '不', '##再', '承', '##担', '保', '##证', '[MASK]', '[MASK]', '[MASK]', '[SEP]']
  for i,item in enumerate(items):
    #print(i,"item:",item) #  ##期
    output.append(vocab[item])
  return output

def convert_tokens_to_ids(vocab, tokens):
  return convert_by_vocab(vocab, tokens)

def convert_ids_to_tokens(inv_vocab, ids):
  return convert_by_vocab(inv_vocab, ids)

def whitespace_tokenize(text):
  """Runs basic whitespace cleaning and splitting on a piece of text."""
  text = text.strip()
  if not text:
    return []
  tokens = text.split()
  return tokens

class FullTokenizer(object):
  """Runs end-to-end tokenziation."""

  def __init__(self, vocab_file, do_lower_case=True):
    self.vocab = load_vocab(vocab_file)
    self.inv_vocab = {v: k for k, v in self.vocab.items()}
    self.basic_tokenizer = BasicTokenizer(do_lower_case=do_lower_case)
    self.wordpiece_tokenizer = WordpieceTokenizer(vocab=self.vocab)

  def tokenize(self, text):
    split_tokens = []
    for token in self.basic_tokenizer.tokenize(text):
      for sub_token in self.wordpiece_tokenizer.tokenize(token):
        split_tokens.append(sub_token)

    return split_tokens

  def convert_tokens_to_ids(self, tokens):
    return convert_by_vocab(self.vocab, tokens)

  def convert_ids_to_tokens(self, ids):
    return convert_by_vocab(self.inv_vocab, ids)

class BasicTokenizer(object):
  """Runs basic tokenization (punctuation splitting, lower casing, etc.)."""

  def __init__(self, do_lower_case=True):
    """Constructs a BasicTokenizer.

    Args:
      do_lower_case: Whether to lower case the input.
    """
    self.do_lower_case = do_lower_case

  def tokenize(self, text):
    """Tokenizes a piece of text."""
    text = convert_to_unicode(text)
    text = self._clean_text(text)

    # This was added on November 1st, 2018 for the multilingual and Chinese
    # models. This is also applied to the English models now, but it doesn't
    # matter since the English models were not trained on any Chinese data
    # and generally don't have any Chinese data in them (there are Chinese
    # characters in the vocabulary because Wikipedia does have some Chinese
    # words in the English Wikipedia.).
    text = self._tokenize_chinese_chars(text)

    orig_tokens = whitespace_tokenize(text)
    split_tokens = []
    for token in orig_tokens:
      if self.do_lower_case:
        token = token.lower()
        token = self._run_strip_accents(token)
      split_tokens.extend(self._run_split_on_punc(token))

    output_tokens = whitespace_tokenize(" ".join(split_tokens))
    return output_tokens

  def _run_strip_accents(self, text):
    """Strips accents from a piece of text."""
    text = unicodedata.normalize("NFD", text)
    output = []
    for char in text:
      cat = unicodedata.category(char)
      if cat == "Mn":
        continue
      output.append(char)
    return "".join(output)

  def _run_split_on_punc(self, text):
    """Splits punctuation on a piece of text."""
    chars = list(text)
    i = 0
    start_new_word = True
    output = []
    while i < len(chars):
      char = chars[i]
      if _is_punctuation(char):
        output.append([char])
        start_new_word = True
      else:
        if start_new_word:
          output.append([])
        start_new_word = False
        output[-1].append(char)
      i += 1

    return ["".join(x) for x in output]

  def _tokenize_chinese_chars(self, text):
    """Adds whitespace around any CJK character."""
    output = []
    for char in text:
      cp = ord(char)
      if self._is_chinese_char(cp):
        output.append(" ")
        output.append(char)
        output.append(" ")
      else:
        output.append(char)
    return "".join(output)

  def _is_chinese_char(self, cp):
    """Checks whether CP is the codepoint of a CJK character."""
    # This defines a "chinese character" as anything in the CJK Unicode block:
    #   https://en.wikipedia.org/wiki/CJK_Unified_Ideographs_(Unicode_block)
    #
    # Note that the CJK Unicode block is NOT all Japanese and Korean characters,
    # despite its name. The modern Korean Hangul alphabet is a different block,
    # as is Japanese Hiragana and Katakana. Those alphabets are used to write
    # space-separated words, so they are not treated specially and handled
    # like the all of the other languages.
    if ((cp >= 0x4E00 and cp <= 0x9FFF) or  #
        (cp >= 0x3400 and cp <= 0x4DBF) or  #
        (cp >= 0x20000 and cp <= 0x2A6DF) or  #
        (cp >= 0x2A700 and cp <= 0x2B73F) or  #
        (cp >= 0x2B740 and cp <= 0x2B81F) or  #
        (cp >= 0x2B820 and cp <= 0x2CEAF) or
        (cp >= 0xF900 and cp <= 0xFAFF) or  #
        (cp >= 0x2F800 and cp <= 0x2FA1F)):  #
      return True

    return False

  def _clean_text(self, text):
    """Performs invalid character removal and whitespace cleanup on text."""
    output = []
    for char in text:
      cp = ord(char)
      if cp == 0 or cp == 0xfffd or _is_control(char):
        continue
      if _is_whitespace(char):
        output.append(" ")
      else:
        output.append(char)
    return "".join(output)

class WordpieceTokenizer(object):
  """Runs WordPiece tokenziation."""

  def __init__(self, vocab, unk_token="[UNK]", max_input_chars_per_word=200):
    self.vocab = vocab
    self.unk_token = unk_token
    self.max_input_chars_per_word = max_input_chars_per_word

  def tokenize(self, text):
    """Tokenizes a piece of text into its word pieces.

    This uses a greedy longest-match-first algorithm to perform tokenization
    using the given vocabulary.

    For example:
      input = "unaffable"
      output = ["un", "##aff", "##able"]

    Args:
      text: A single token or whitespace separated tokens. This should have
        already been passed through `BasicTokenizer.

    Returns:
      A list of wordpiece tokens.
    """

    text = convert_to_unicode(text)

    output_tokens = []
    for token in whitespace_tokenize(text):
      chars = list(token)
      if len(chars) > self.max_input_chars_per_word:
        output_tokens.append(self.unk_token)
        continue

      is_bad = False
      start = 0
      sub_tokens = []
      while start < len(chars):
        end = len(chars)
        cur_substr = None
        while start < end:
          substr = "".join(chars[start:end])
          if start > 0:
            substr = "##" + substr
          if substr in self.vocab:
            cur_substr = substr
            break
          end -= 1
        if cur_substr is None:
          is_bad = True
          break
        sub_tokens.append(cur_substr)
        start = end

      if is_bad:
        output_tokens.append(self.unk_token)
      else:
        output_tokens.extend(sub_tokens)
    return output_tokens

def _is_whitespace(char):
  """Checks whether `chars` is a whitespace character."""
  # \t, \n, and \r are technically contorl characters but we treat them
  # as whitespace since they are generally considered as such.
  if char == " " or char == "\t" or char == "\n" or char == "\r":
    return True
  cat = unicodedata.category(char)
  if cat == "Zs":
    return True
  return False

def _is_control(char):
  """Checks whether `chars` is a control character."""
  # These are technically control characters but we count them as whitespace
  # characters.
  if char == "\t" or char == "\n" or char == "\r":
    return False
  cat = unicodedata.category(char)
  if cat in ("Cc", "Cf"):
    return True
  return False

def _is_punctuation(char):
  """Checks whether `chars` is a punctuation character."""
  cp = ord(char)
  # We treat all non-letter/number ASCII as punctuation.
  # Characters such as "^", "$", and "`" are not in the Unicode
  # Punctuation class but we treat them as punctuation anyways, for
  # consistency.
  if ((cp >= 33 and cp <= 47) or (cp >= 58 and cp <= 64) or
      (cp >= 91 and cp <= 96) or (cp >= 123 and cp <= 126)):
    return True
  cat = unicodedata.category(char)
  if cat.startswith("P"):
    return True
  return False

{'repo_name': 'ChineseGLUE/ChineseGLUE', 'stars': '1235', 'repo_language': 'Python', 'file_name': 'run_classifier_jdcomment.sh', 'mime_type': 'text/plain', 'hash': -1074748149130009368, 'source_dataset': 'data'}


/*
 * Copyright (c) 2017-2018 THL A29 Limited, a Tencent company. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.tencentcloudapi.cwp.v20180228.models;

import com.tencentcloudapi.common.AbstractModel;
import com.google.gson.annotations.SerializedName;
import com.google.gson.annotations.Expose;
import java.util.HashMap;

public class DescribeOpenPortsResponse extends AbstractModel{

    /**
    * 端口列表记录总数。
    */
    @SerializedName("TotalCount")
    @Expose
    private Long TotalCount;

    /**
    * 端口列表。
    */
    @SerializedName("OpenPorts")
    @Expose
    private OpenPort [] OpenPorts;

    /**
    * 唯一请求 ID，每次请求都会返回。定位问题时需要提供该次请求的 RequestId。
    */
    @SerializedName("RequestId")
    @Expose
    private String RequestId;

    /**
     * Get 端口列表记录总数。
     * @return TotalCount 端口列表记录总数。
     */
    public Long getTotalCount() {
        return this.TotalCount;
    }

    /**
     * Set 端口列表记录总数。
     * @param TotalCount 端口列表记录总数。
     */
    public void setTotalCount(Long TotalCount) {
        this.TotalCount = TotalCount;
    }

    /**
     * Get 端口列表。
     * @return OpenPorts 端口列表。
     */
    public OpenPort [] getOpenPorts() {
        return this.OpenPorts;
    }

    /**
     * Set 端口列表。
     * @param OpenPorts 端口列表。
     */
    public void setOpenPorts(OpenPort [] OpenPorts) {
        this.OpenPorts = OpenPorts;
    }

    /**
     * Get 唯一请求 ID，每次请求都会返回。定位问题时需要提供该次请求的 RequestId。
     * @return RequestId 唯一请求 ID，每次请求都会返回。定位问题时需要提供该次请求的 RequestId。
     */
    public String getRequestId() {
        return this.RequestId;
    }

    /**
     * Set 唯一请求 ID，每次请求都会返回。定位问题时需要提供该次请求的 RequestId。
     * @param RequestId 唯一请求 ID，每次请求都会返回。定位问题时需要提供该次请求的 RequestId。
     */
    public void setRequestId(String RequestId) {
        this.RequestId = RequestId;
    }

    /**
     * Internal implementation, normal users should not use it.
     */
    public void toMap(HashMap<String, String> map, String prefix) {
        this.setParamSimple(map, prefix + "TotalCount", this.TotalCount);
        this.setParamArrayObj(map, prefix + "OpenPorts.", this.OpenPorts);
        this.setParamSimple(map, prefix + "RequestId", this.RequestId);

    }
}

{'repo_name': 'TencentCloud/tencentcloud-sdk-java', 'stars': '220', 'repo_language': 'Java', 'file_name': 'EvaluationExamples.java', 'mime_type': 'text/x-java', 'hash': 378952660773270248, 'source_dataset': 'data'}


<phpunit colors="true"
         bootstrap="bootstrap.php">
    <testsuites>
        <testsuite name="Larry Four">
            <directory>tests</directory>
        </testsuite>
    </testsuites>
</phpunit>

{'repo_name': 'XCMer/larry-four-generator', 'stars': '131', 'repo_language': 'PHP', 'file_name': 'FieldParserTest.php', 'mime_type': 'text/x-php', 'hash': 554235760056603519, 'source_dataset': 'data'}


//
//  NSPropertyDescription+SSDataKitAdditions.m
//  SSDataKit
//
//  Created by Sam Soffes on 3/31/14.
//  Copyright (c) 2014 Sam Soffes. All rights reserved.
//

#import "NSPropertyDescription+SSDataKitAdditions.h"

@implementation NSPropertyDescription (SSDataKitAdditions)

- (id)ss_minimumValue {
	for (NSComparisonPredicate *predicate in [self validationPredicates]) {
		if (predicate.predicateOperatorType == NSGreaterThanOrEqualToPredicateOperatorType) {
			return [[predicate rightExpression] constantValue];
		}
	}
	return nil;
}

- (id)ss_maximumValue {
	for (NSComparisonPredicate *predicate in [self validationPredicates]) {
		if (predicate.predicateOperatorType == NSLessThanOrEqualToPredicateOperatorType) {
			return [[predicate rightExpression] constantValue];
		}
	}
	return nil;
}

@end

{'repo_name': 'soffes/ssdatakit', 'stars': '463', 'repo_language': 'Objective-C', 'file_name': 'SSRemoteManagedObject.m', 'mime_type': 'text/x-objective-c', 'hash': 8788324647069547442, 'source_dataset': 'data'}


<project name="prefuse" default="usage" basedir=".">

  <target name="init">
    <tstamp>
    	<format property="year" pattern="yyyy" locale="en"/>
    </tstamp>

  	<property file="build.properties"/>
    <property name="Name" value="prefuse"/>
    <property name="name" value="prefuse"/>
    <property name="version" value="beta"/>

    <property name="build.compiler" value="modern"/>
    <property name="debug" value="off"/>
    <property name="optimize" value="on"/>
    <property name="deprecation" value="on"/>
    <property name="packages" value="prefuse.*"/>

    <property name="root.dir" value="./"/>
  	<property name="data.dir" value="${root.dir}/data"/>
  	<property name="demos.dir" value="${root.dir}/demos"/>
    <property name="doc.dir" value="${root.dir}/doc"/>
    <property name="lib.dir" value="${root.dir}/lib"/>
    <property name="src.dir" value="${root.dir}/src"/>
    <property name="test.dir" value="${root.dir}/test"/>

  	<property name="lucene.lib" value="${root.dir}/lib/lucene-1.4.3.jar"/>

    <property name="doc.apidocs" value="${doc.dir}/api"/>
    <property name="build.dir" value="${root.dir}/build"/>
    <property name="build.lib" value="${root.dir}/build/lib"/>
    <property name="build.prefuse.src" value="${root.dir}/build/prefuse/src"/>
    <property name="build.prefuse.dest" value="${root.dir}/build/prefuse/classes"/>
    <property name="build.demos.src" value="${root.dir}/build/demos/src"/>
    <property name="build.demos.dest" value="${root.dir}/build/demos/classes"/>

    <property name="dist.root" value="${root.dir}/dist"/>
    <property name="sourcedist.dir" value="${dist.root}/${name}-${version}/"/>
    <property name="compiledist.dir" value="${dist.root}/${name}-${version}"/>
  </target>

  <target name="usage">
    <echo message=""/>
    <echo message=""/>
    <echo message="prefuse build control"/>
    <echo message="-------------------------------------------------------------"/>
    <echo message=""/>
    <echo message=" available targets are:"/>
    <echo message=""/>
    <echo message="   all        --> builds all the jars in ./build"/>
    <echo message="   prefuse    --> builds the prefuse.jar file in ./build"/>
    <echo message="   demos      --> builds the demos.jar file in ./build"/>
    <echo message="   compiledist--> creates the compiled distribution in ./dist"/>
    <echo message="   sourcedist --> creates the source distribution in ./dist"/>
    <echo message="   api        --> generates prefuse API docs in ./doc/api"/>
    <echo message="   clean      --> restores distribution to original state"/>
    <echo message="   usage      --> (default) displays build menu"/>
    <echo message=""/>
    <echo message=" See the comments inside the build.xml file for more details."/>
    <echo message="-------------------------------------------------------------"/>
    <echo message=""/>
    <echo message=""/>
  </target>

  <target name="prepare" depends="init">
    <mkdir dir="${build.dir}"/>
    <mkdir dir="${build.lib}"/>

    <copy todir="${build.lib}">
      <fileset dir="${lib.dir}"/>
    </copy>

  </target>

  <target name="prepare-prefuse" depends="prepare">
    <mkdir dir="${build.prefuse.src}"/>
    <mkdir dir="${build.prefuse.dest}"/>

    <copy todir="${build.prefuse.src}">
      <fileset dir="${src.dir}"/>
    </copy>

  </target>

  <target name="prepare-demos" depends="prepare">
    <mkdir dir="${build.demos.src}"/>
    <mkdir dir="${build.demos.dest}"/>

    <copy todir="${build.demos.src}">
      <fileset dir="${demos.dir}"/>
    </copy>

  </target>

  <target name="compile-prefuse" depends="prepare-prefuse">

    <copy todir="${build.prefuse.dest}">
      <fileset dir="${build.prefuse.src}" excludes="**/*.java"/>
    </copy>

    <javac srcdir="${build.prefuse.src}"
           destdir="${build.prefuse.dest}"
    	       classpath="${lucene.lib}"
           debug="${debug}"
           deprecation="${deprecation}"
           optimize="${optimize}"
           encoding="cp1252"/>
  </target>

  <target name="compile-demos" depends="prepare-demos, prefuse">

    <copy todir="${build.demos.dest}">
      <fileset dir="${build.demos.src}" excludes="**/*.java"/>
    </copy>
  	<copy todir="${build.demos.dest}">
  	  <fileset dir="${data.dir}"/>
  	</copy>

    <javac srcdir="${build.demos.src}"
           destdir="${build.demos.dest}"
		   classpath="${build.dir}/${name}.jar"
           debug="${debug}"
           deprecation="${deprecation}"
           optimize="${optimize}"/>
  </target>

  <target name="prefuse" depends="compile-prefuse">
    <jar jarfile="${build.dir}/${name}.jar"
         basedir="${build.prefuse.dest}"
         includes="**"/>
  	<jar jarfile="${build.dir}/${name}.src.jar"
  		 basedir="${build.prefuse.src}"
  		 includes="**"/>
  </target>

  <target name="demos" depends="compile-demos">
    <jar jarfile="${build.dir}/demos.jar"
         basedir="${build.demos.dest}"
         includes="**"/>

  </target>

  <target name="all" depends="prefuse, demos"/>

  <target name="api" depends="prepare-prefuse, prepare-demos">
    <mkdir dir="${doc.apidocs}"/>
    <javadoc packagenames="${packages}"
             sourcepath="${build.prefuse.src}"
    	     classpath="${lucene.lib}"
             destdir="${doc.apidocs}"
             author="true"
             version="true"
           	 use="true"
	         breakiterator="yes"
             splitindex="true"
             noindex="false"
             windowtitle="${Name} API Documentation"
             doctitle="the ${Name} visualization toolkit"
             overview="${build.prefuse.src}/prefuse/overview.html"
             bottom="Copyright © ${year} Regents of the University of California"
    />
  </target>

  <target name="addTabsWithLength4" depends="init">
    <fixcrlf
         srcdir="${root.dir}"
         tab="add"
         tablength="4"
         includes="**/*.java"/>
  </target>

  <target name="removeTabsWithLength4" depends="init">
    <fixcrlf
         srcdir="${root.dir}"
         tab="remove"
         tablength="4"
         includes="**/*.java"/>
  </target>

  <target name="sourcedist" depends="clean">
    <mkdir dir="${dist.root}"/>
    <mkdir dir="${sourcedist.dir}"/>

    <copy todir="${sourcedist.dir}">
      <fileset dir="${root.dir}" excludes="**/.*" />
    </copy>
  	<copy todir="${sourcedist.dir}">
  		<fileset dir="${root.dir}" casesensitive="yes">
  		  <include name=".project"/>
  		  <include name=".classpath"/>
  		</fileset>
  	</copy>

    <delete dir="${sourcedist.dir}/dist"/>
  	<delete dir="${sourcedist.dir}/classes"/>
  	<delete dir="${sourcedist.dir}/build"/>
  	<delete dir="${sourcedist.dir}/.settings"/>

    <fixcrlf srcdir="${sourcedist.dir}"
    	eol="lf" eof="remove"
    	tablength="4" tab="remove"
        includes="**/*.sh"
    />
    <zip zipfile="${dist.root}/${name}-${version}-${DSTAMP}.zip"
         basedir="${dist.root}"
         whenempty="create"
    />
  </target>

  <target name="compiledist" depends="clean, all, api">
    <mkdir dir="${dist.root}"/>
    <mkdir dir="${compiledist.dir}"/>

    <copy todir="${compiledist.dir}">
      <fileset dir="${root.dir}"/>
    </copy>

    <delete dir="${compiledist.dir}/dist"/>
  	<delete dir="${sourcedist.dir}/classes"/>
    <delete dir="${compiledist.dir}/build/demos"/>
    <delete dir="${compiledist.dir}/build/prefuse"/>
  	<delete dir="${compiledist.dir}/build/lib"/>

    <fixcrlf srcdir="${compiledist.dir}"
       eol="lf" eof="remove"
       includes="**/*.sh"
    />

    <zip zipfile="${dist.root}/${name}-${version}-${DSTAMP}-bin.zip"
         basedir="${dist.root}/${name}-${version}"
         whenempty="create"
    />

  </target>

  <target name="clean" depends="init">
    <delete dir="${build.dir}"/>
    <delete dir="${dist.root}"/>
    <delete dir="${doc.apidocs}"/>
  </target>

  <target name="fixtabs" depends="init">
  	<fixcrlf srcdir="${src.dir}" eol="lf" eof="remove"
  		tablength="4" tab="remove" includes="**/*.java"	/>
  	<fixcrlf srcdir="${demos.dir}" eol="lf" eof="remove"
  		tablength="4" tab="remove" includes="**/*.java"	/>
  	<fixcrlf srcdir="${test.dir}" eol="lf" eof="remove"
  		tablength="4" tab="remove" includes="**/*.java"	/>
  </target>

</project>

{'repo_name': 'prefuse/Prefuse', 'stars': '518', 'repo_language': 'Java', 'file_name': 'treeml-sample.xml', 'mime_type': 'text/xml', 'hash': -4608376619511183874, 'source_dataset': 'data'}


/*
 * Copyright 2016 Google LLC
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
 * met:
 *
 *     * Redistributions of source code must retain the above copyright
 * notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above
 * copyright notice, this list of conditions and the following disclaimer
 * in the documentation and/or other materials provided with the
 * distribution.
 *     * Neither the name of Google LLC nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
package com.google.api.gax.rpc;

import com.google.api.core.BetaApi;
import com.google.common.base.Preconditions;

/**
 * BatchedRequestIssuer receives a response or an exception and waits to set the given batchedFuture
 * until sendResult() is called.
 *
 * <p>This class is designed to be used by generated code.
 */
@BetaApi("The surface for batching is not stable yet and may change in the future.")
public final class BatchedRequestIssuer<ResponseT> {
  private final BatchedFuture<ResponseT> batchedFuture;
  private final long messageCount;
  private ResponseT responseToSend;
  private boolean hasResponse;
  private Throwable throwableToSend;

  public BatchedRequestIssuer(BatchedFuture<ResponseT> batchedFuture, long messageCount) {
    this.batchedFuture = batchedFuture;
    this.messageCount = messageCount;
    this.responseToSend = null;
    this.throwableToSend = null;
  }

  public long getMessageCount() {
    return messageCount;
  }

  /**
   * Set the response to set on the batched future. If this is called, setException cannot be
   * called.
   */
  public void setResponse(ResponseT response) {
    Preconditions.checkState(throwableToSend == null, "Cannot set both exception and response");
    hasResponse = true;
    responseToSend = response;
  }

  /**
   * Set the exception to set on the batched future. If this is called, setResponse cannot be
   * called.
   */
  public void setException(Throwable throwable) {
    Preconditions.checkState(!hasResponse, "Cannot set both exception and response");
    throwableToSend = throwable;
  }

  /** Sends back the result that was stored by either setResponse or setException */
  public void sendResult() {
    if (hasResponse) {
      batchedFuture.set(responseToSend);
    } else if (throwableToSend != null) {
      batchedFuture.setException(throwableToSend);
    } else {
      throw new IllegalStateException(
          "Neither response nor exception were set in BatchedRequestIssuer");
    }
  }
}

{'repo_name': 'googleapis/gax-java', 'stars': '122', 'repo_language': 'Java', 'file_name': 'FakeApiMessage.java', 'mime_type': 'text/x-java', 'hash': 8949890263263475562, 'source_dataset': 'data'}


# Gallery

![Karmilla, Latin and Cyrillic](Karmilla_01.jpg)

![Karmilla in FontForge](Karmilla-Regular-26-01-2018-01.jpg)

![Apostrophe height](apostrophe-height.png)

![](cedilla-copy-paste.png)

![](karla-with-cedilla.png)

![New quotation marks](quotation-marks-v011-sample.png)

![Icelandic glyphs. Image released to the public domain by David Mundstock](ice.jpg)

{'repo_name': 'ms-studio/karmilla', 'stars': '121', 'repo_language': 'HTML', 'file_name': 'grid_12-825-55-15.css', 'mime_type': 'text/plain', 'hash': -2269929069710383533, 'source_dataset': 'data'}


// Copyright 2006 The Closure Library Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS-IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/**
 * @fileoverview Definition of the Logger class. Please minimize dependencies
 * this file has on other closure classes as any dependency it takes won't be
 * able to use the logging infrastructure.
 *
 * @see ../demos/debug.html
 */

goog.provide('goog.debug.LogManager');
goog.provide('goog.debug.Loggable');
goog.provide('goog.debug.Logger');
goog.provide('goog.debug.Logger.Level');

goog.require('goog.array');
goog.require('goog.asserts');
goog.require('goog.debug');
goog.require('goog.debug.LogBuffer');
goog.require('goog.debug.LogRecord');

/**
 * A message value that can be handled by a Logger.
 *
 * Functions are treated like callbacks, but are only called when the event's
 * log level is enabled. This is useful for logging messages that are expensive
 * to construct.
 *
 * @typedef {string|function(): string}
 */
goog.debug.Loggable;

/**
 * The Logger is an object used for logging debug messages. Loggers are
 * normally named, using a hierarchical dot-separated namespace. Logger names
 * can be arbitrary strings, but they should normally be based on the package
 * name or class name of the logged component, such as goog.net.BrowserChannel.
 *
 * The Logger object is loosely based on the java class
 * java.util.logging.Logger. It supports different levels of filtering for
 * different loggers.
 *
 * The logger object should never be instantiated by application code. It
 * should always use the goog.debug.Logger.getLogger function.
 *
 * @constructor
 * @param {string} name The name of the Logger.
 * @final
 */
goog.debug.Logger = function(name) {
  /**
   * Name of the Logger. Generally a dot-separated namespace
   * @private {string}
   */
  this.name_ = name;

  /**
   * Parent Logger.
   * @private {goog.debug.Logger}
   */
  this.parent_ = null;

  /**
   * Level that this logger only filters above. Null indicates it should
   * inherit from the parent.
   * @private {goog.debug.Logger.Level}
   */
  this.level_ = null;

  /**
   * Map of children loggers. The keys are the leaf names of the children and
   * the values are the child loggers.
   * @private {Object}
   */
  this.children_ = null;

  /**
   * Handlers that are listening to this logger.
   * @private {Array<Function>}
   */
  this.handlers_ = null;
};

/** @const */
goog.debug.Logger.ROOT_LOGGER_NAME = '';

/**
 * @define {boolean} Toggles whether loggers other than the root logger can have
 *     log handlers attached to them and whether they can have their log level
 *     set. Logging is a bit faster when this is set to false.
 */
goog.define('goog.debug.Logger.ENABLE_HIERARCHY', true);

if (!goog.debug.Logger.ENABLE_HIERARCHY) {
  /**
   * @type {!Array<Function>}
   * @private
   */
  goog.debug.Logger.rootHandlers_ = [];

  /**
   * @type {goog.debug.Logger.Level}
   * @private
   */
  goog.debug.Logger.rootLevel_;
}

/**
 * The Level class defines a set of standard logging levels that
 * can be used to control logging output.  The logging Level objects
 * are ordered and are specified by ordered integers.  Enabling logging
 * at a given level also enables logging at all higher levels.
 *

 * Clients should normally use the predefined Level constants such
 * as Level.SEVERE.
 *

 * The levels in descending order are:
 *

 *
SEVERE (highest value)
 *
WARNING
 *
INFO
 *
CONFIG
 *
FINE
 *
FINER
 *
FINEST  (lowest value)
 *

 * In addition there is a level OFF that can be used to turn
 * off logging, and a level ALL that can be used to enable
 * logging of all messages.
 *
 * @param {string} name The name of the level.
 * @param {number} value The numeric value of the level.
 * @constructor
 * @final
 */
goog.debug.Logger.Level = function(name, value) {
  /**
   * The name of the level
   * @type {string}
   */
  this.name = name;

  /**
   * The numeric value of the level
   * @type {number}
   */
  this.value = value;
};

/**
 * @return {string} String representation of the logger level.
 * @override
 */
goog.debug.Logger.Level.prototype.toString = function() {
  return this.name;
};

/**
 * OFF is a special level that can be used to turn off logging.
 * This level is initialized to Infinity.
 * @type {!goog.debug.Logger.Level}
 */
goog.debug.Logger.Level.OFF =
    new goog.debug.Logger.Level('OFF', Infinity);

/**
 * SHOUT is a message level for extra debugging loudness.
 * This level is initialized to 1200.
 * @type {!goog.debug.Logger.Level}
 */
goog.debug.Logger.Level.SHOUT = new goog.debug.Logger.Level('SHOUT', 1200);

/**
 * SEVERE is a message level indicating a serious failure.
 * This level is initialized to 1000.
 * @type {!goog.debug.Logger.Level}
 */
goog.debug.Logger.Level.SEVERE = new goog.debug.Logger.Level('SEVERE', 1000);

/**
 * WARNING is a message level indicating a potential problem.
 * This level is initialized to 900.
 * @type {!goog.debug.Logger.Level}
 */
goog.debug.Logger.Level.WARNING = new goog.debug.Logger.Level('WARNING', 900);

/**
 * INFO is a message level for informational messages.
 * This level is initialized to 800.
 * @type {!goog.debug.Logger.Level}
 */
goog.debug.Logger.Level.INFO = new goog.debug.Logger.Level('INFO', 800);

/**
 * CONFIG is a message level for static configuration messages.
 * This level is initialized to 700.
 * @type {!goog.debug.Logger.Level}
 */
goog.debug.Logger.Level.CONFIG = new goog.debug.Logger.Level('CONFIG', 700);

/**
 * FINE is a message level providing tracing information.
 * This level is initialized to 500.
 * @type {!goog.debug.Logger.Level}
 */
goog.debug.Logger.Level.FINE = new goog.debug.Logger.Level('FINE', 500);

/**
 * FINER indicates a fairly detailed tracing message.
 * This level is initialized to 400.
 * @type {!goog.debug.Logger.Level}
 */
goog.debug.Logger.Level.FINER = new goog.debug.Logger.Level('FINER', 400);

/**
 * FINEST indicates a highly detailed tracing message.
 * This level is initialized to 300.
 * @type {!goog.debug.Logger.Level}
 */

goog.debug.Logger.Level.FINEST = new goog.debug.Logger.Level('FINEST', 300);

/**
 * ALL indicates that all messages should be logged.
 * This level is initialized to 0.
 * @type {!goog.debug.Logger.Level}
 */
goog.debug.Logger.Level.ALL = new goog.debug.Logger.Level('ALL', 0);

/**
 * The predefined levels.
 * @type {!Array<!goog.debug.Logger.Level>}
 * @final
 */
goog.debug.Logger.Level.PREDEFINED_LEVELS = [
  goog.debug.Logger.Level.OFF,
  goog.debug.Logger.Level.SHOUT,
  goog.debug.Logger.Level.SEVERE,
  goog.debug.Logger.Level.WARNING,
  goog.debug.Logger.Level.INFO,
  goog.debug.Logger.Level.CONFIG,
  goog.debug.Logger.Level.FINE,
  goog.debug.Logger.Level.FINER,
  goog.debug.Logger.Level.FINEST,
  goog.debug.Logger.Level.ALL];

/**
 * A lookup map used to find the level object based on the name or value of
 * the level object.
 * @type {Object}
 * @private
 */
goog.debug.Logger.Level.predefinedLevelsCache_ = null;

/**
 * Creates the predefined levels cache and populates it.
 * @private
 */
goog.debug.Logger.Level.createPredefinedLevelsCache_ = function() {
  goog.debug.Logger.Level.predefinedLevelsCache_ = {};
  for (var i = 0, level; level = goog.debug.Logger.Level.PREDEFINED_LEVELS[i];
       i++) {
    goog.debug.Logger.Level.predefinedLevelsCache_[level.value] = level;
    goog.debug.Logger.Level.predefinedLevelsCache_[level.name] = level;
  }
};

/**
 * Gets the predefined level with the given name.
 * @param {string} name The name of the level.
 * @return {goog.debug.Logger.Level} The level, or null if none found.
 */
goog.debug.Logger.Level.getPredefinedLevel = function(name) {
  if (!goog.debug.Logger.Level.predefinedLevelsCache_) {
    goog.debug.Logger.Level.createPredefinedLevelsCache_();
  }

  return goog.debug.Logger.Level.predefinedLevelsCache_[name] || null;
};

/**
 * Gets the highest predefined level <= #value.
 * @param {number} value Level value.
 * @return {goog.debug.Logger.Level} The level, or null if none found.
 */
goog.debug.Logger.Level.getPredefinedLevelByValue = function(value) {
  if (!goog.debug.Logger.Level.predefinedLevelsCache_) {
    goog.debug.Logger.Level.createPredefinedLevelsCache_();
  }

  if (value in goog.debug.Logger.Level.predefinedLevelsCache_) {
    return goog.debug.Logger.Level.predefinedLevelsCache_[value];
  }

  for (var i = 0; i < goog.debug.Logger.Level.PREDEFINED_LEVELS.length; ++i) {
    var level = goog.debug.Logger.Level.PREDEFINED_LEVELS[i];
    if (level.value <= value) {
      return level;
    }
  }
  return null;
};

/**
 * Finds or creates a logger for a named subsystem. If a logger has already been
 * created with the given name it is returned. Otherwise a new logger is
 * created. If a new logger is created its log level will be configured based
 * on the LogManager configuration and it will configured to also send logging
 * output to its parent's handlers. It will be registered in the LogManager
 * global namespace.
 *
 * @param {string} name A name for the logger. This should be a dot-separated
 * name and should normally be based on the package name or class name of the
 * subsystem, such as goog.net.BrowserChannel.
 * @return {!goog.debug.Logger} The named logger.
 * @deprecated use goog.log instead. http://go/goog-debug-logger-deprecated
 */
goog.debug.Logger.getLogger = function(name) {
  return goog.debug.LogManager.getLogger(name);
};

/**
 * Logs a message to profiling tools, if available.
 * {@see https://developers.google.com/web-toolkit/speedtracer/logging-api}
 * {@see http://msdn.microsoft.com/en-us/library/dd433074(VS.85).aspx}
 * @param {string} msg The message to log.
 */
goog.debug.Logger.logToProfilers = function(msg) {
  // Using goog.global, as loggers might be used in window-less contexts.
  if (goog.global['console']) {
    if (goog.global['console']['timeStamp']) {
      // Logs a message to Firebug, Web Inspector, SpeedTracer, etc.
      goog.global['console']['timeStamp'](msg);
    } else if (goog.global['console']['markTimeline']) {
      // TODO(user): markTimeline is deprecated. Drop this else clause entirely
      // after Chrome M14 hits stable.
      goog.global['console']['markTimeline'](msg);
    }
  }

  if (goog.global['msWriteProfilerMark']) {
    // Logs a message to the Microsoft profiler
    goog.global['msWriteProfilerMark'](msg);
  }
};

/**
 * Gets the name of this logger.
 * @return {string} The name of this logger.
 */
goog.debug.Logger.prototype.getName = function() {
  return this.name_;
};

/**
 * Adds a handler to the logger. This doesn't use the event system because
 * we want to be able to add logging to the event system.
 * @param {Function} handler Handler function to add.
 */
goog.debug.Logger.prototype.addHandler = function(handler) {
  if (goog.debug.LOGGING_ENABLED) {
    if (goog.debug.Logger.ENABLE_HIERARCHY) {
      if (!this.handlers_) {
        this.handlers_ = [];
      }
      this.handlers_.push(handler);
    } else {
      goog.asserts.assert(!this.name_,
          'Cannot call addHandler on a non-root logger when ' +
          'goog.debug.Logger.ENABLE_HIERARCHY is false.');
      goog.debug.Logger.rootHandlers_.push(handler);
    }
  }
};

/**
 * Removes a handler from the logger. This doesn't use the event system because
 * we want to be able to add logging to the event system.
 * @param {Function} handler Handler function to remove.
 * @return {boolean} Whether the handler was removed.
 */
goog.debug.Logger.prototype.removeHandler = function(handler) {
  if (goog.debug.LOGGING_ENABLED) {
    var handlers = goog.debug.Logger.ENABLE_HIERARCHY ? this.handlers_ :
        goog.debug.Logger.rootHandlers_;
    return !!handlers && goog.array.remove(handlers, handler);
  } else {
    return false;
  }
};

/**
 * Returns the parent of this logger.
 * @return {goog.debug.Logger} The parent logger or null if this is the root.
 */
goog.debug.Logger.prototype.getParent = function() {
  return this.parent_;
};

/**
 * Returns the children of this logger as a map of the child name to the logger.
 * @return {!Object} The map where the keys are the child leaf names and the
 *     values are the Logger objects.
 */
goog.debug.Logger.prototype.getChildren = function() {
  if (!this.children_) {
    this.children_ = {};
  }
  return this.children_;
};

/**
 * Set the log level specifying which message levels will be logged by this
 * logger. Message levels lower than this value will be discarded.
 * The level value Level.OFF can be used to turn off logging. If the new level
 * is null, it means that this node should inherit its level from its nearest
 * ancestor with a specific (non-null) level value.
 *
 * @param {goog.debug.Logger.Level} level The new level.
 */
goog.debug.Logger.prototype.setLevel = function(level) {
  if (goog.debug.LOGGING_ENABLED) {
    if (goog.debug.Logger.ENABLE_HIERARCHY) {
      this.level_ = level;
    } else {
      goog.asserts.assert(!this.name_,
          'Cannot call setLevel() on a non-root logger when ' +
          'goog.debug.Logger.ENABLE_HIERARCHY is false.');
      goog.debug.Logger.rootLevel_ = level;
    }
  }
};

/**
 * Gets the log level specifying which message levels will be logged by this
 * logger. Message levels lower than this value will be discarded.
 * The level value Level.OFF can be used to turn off logging. If the level
 * is null, it means that this node should inherit its level from its nearest
 * ancestor with a specific (non-null) level value.
 *
 * @return {goog.debug.Logger.Level} The level.
 */
goog.debug.Logger.prototype.getLevel = function() {
  return goog.debug.LOGGING_ENABLED ?
      this.level_ : goog.debug.Logger.Level.OFF;
};

/**
 * Returns the effective level of the logger based on its ancestors' levels.
 * @return {goog.debug.Logger.Level} The level.
 */
goog.debug.Logger.prototype.getEffectiveLevel = function() {
  if (!goog.debug.LOGGING_ENABLED) {
    return goog.debug.Logger.Level.OFF;
  }

  if (!goog.debug.Logger.ENABLE_HIERARCHY) {
    return goog.debug.Logger.rootLevel_;
  }
  if (this.level_) {
    return this.level_;
  }
  if (this.parent_) {
    return this.parent_.getEffectiveLevel();
  }
  goog.asserts.fail('Root logger has no level set.');
  return null;
};

/**
 * Checks if a message of the given level would actually be logged by this
 * logger. This check is based on the Loggers effective level, which may be
 * inherited from its parent.
 * @param {goog.debug.Logger.Level} level The level to check.
 * @return {boolean} Whether the message would be logged.
 */
goog.debug.Logger.prototype.isLoggable = function(level) {
  return goog.debug.LOGGING_ENABLED &&
      level.value >= this.getEffectiveLevel().value;
};

/**
 * Logs a message. If the logger is currently enabled for the
 * given message level then the given message is forwarded to all the
 * registered output Handler objects.
 * @param {goog.debug.Logger.Level} level One of the level identifiers.
 * @param {goog.debug.Loggable} msg The message to log.
 * @param {Error|Object=} opt_exception An exception associated with the
 *     message.
 */
goog.debug.Logger.prototype.log = function(level, msg, opt_exception) {
  // java caches the effective level, not sure it's necessary here
  if (goog.debug.LOGGING_ENABLED && this.isLoggable(level)) {
    // Message callbacks can be useful when a log message is expensive to build.
    if (goog.isFunction(msg)) {
      msg = msg();
    }

    this.doLogRecord_(this.getLogRecord(level, msg, opt_exception));
  }
};

/**
 * Creates a new log record and adds the exception (if present) to it.
 * @param {goog.debug.Logger.Level} level One of the level identifiers.
 * @param {string} msg The string message.
 * @param {Error|Object=} opt_exception An exception associated with the
 *     message.
 * @return {!goog.debug.LogRecord} A log record.
 * @suppress {es5Strict}
 */
goog.debug.Logger.prototype.getLogRecord = function(
    level, msg, opt_exception) {
  if (goog.debug.LogBuffer.isBufferingEnabled()) {
    var logRecord =
        goog.debug.LogBuffer.getInstance().addRecord(level, msg, this.name_);
  } else {
    logRecord = new goog.debug.LogRecord(level, String(msg), this.name_);
  }
  if (opt_exception) {
    logRecord.setException(opt_exception);
  }
  return logRecord;
};

/**
 * Logs a message at the Logger.Level.SHOUT level.
 * If the logger is currently enabled for the given message level then the
 * given message is forwarded to all the registered output Handler objects.
 * @param {goog.debug.Loggable} msg The message to log.
 * @param {Error=} opt_exception An exception associated with the message.
 */
goog.debug.Logger.prototype.shout = function(msg, opt_exception) {
  if (goog.debug.LOGGING_ENABLED) {
    this.log(goog.debug.Logger.Level.SHOUT, msg, opt_exception);
  }
};

/**
 * Logs a message at the Logger.Level.SEVERE level.
 * If the logger is currently enabled for the given message level then the
 * given message is forwarded to all the registered output Handler objects.
 * @param {goog.debug.Loggable} msg The message to log.
 * @param {Error=} opt_exception An exception associated with the message.
 */
goog.debug.Logger.prototype.severe = function(msg, opt_exception) {
  if (goog.debug.LOGGING_ENABLED) {
    this.log(goog.debug.Logger.Level.SEVERE, msg, opt_exception);
  }
};

/**
 * Logs a message at the Logger.Level.WARNING level.
 * If the logger is currently enabled for the given message level then the
 * given message is forwarded to all the registered output Handler objects.
 * @param {goog.debug.Loggable} msg The message to log.
 * @param {Error=} opt_exception An exception associated with the message.
 */
goog.debug.Logger.prototype.warning = function(msg, opt_exception) {
  if (goog.debug.LOGGING_ENABLED) {
    this.log(goog.debug.Logger.Level.WARNING, msg, opt_exception);
  }
};

/**
 * Logs a message at the Logger.Level.INFO level.
 * If the logger is currently enabled for the given message level then the
 * given message is forwarded to all the registered output Handler objects.
 * @param {goog.debug.Loggable} msg The message to log.
 * @param {Error=} opt_exception An exception associated with the message.
 */
goog.debug.Logger.prototype.info = function(msg, opt_exception) {
  if (goog.debug.LOGGING_ENABLED) {
    this.log(goog.debug.Logger.Level.INFO, msg, opt_exception);
  }
};

/**
 * Logs a message at the Logger.Level.CONFIG level.
 * If the logger is currently enabled for the given message level then the
 * given message is forwarded to all the registered output Handler objects.
 * @param {goog.debug.Loggable} msg The message to log.
 * @param {Error=} opt_exception An exception associated with the message.
 */
goog.debug.Logger.prototype.config = function(msg, opt_exception) {
  if (goog.debug.LOGGING_ENABLED) {
    this.log(goog.debug.Logger.Level.CONFIG, msg, opt_exception);
  }
};

/**
 * Logs a message at the Logger.Level.FINE level.
 * If the logger is currently enabled for the given message level then the
 * given message is forwarded to all the registered output Handler objects.
 * @param {goog.debug.Loggable} msg The message to log.
 * @param {Error=} opt_exception An exception associated with the message.
 */
goog.debug.Logger.prototype.fine = function(msg, opt_exception) {
  if (goog.debug.LOGGING_ENABLED) {
    this.log(goog.debug.Logger.Level.FINE, msg, opt_exception);
  }
};

/**
 * Logs a message at the Logger.Level.FINER level.
 * If the logger is currently enabled for the given message level then the
 * given message is forwarded to all the registered output Handler objects.
 * @param {goog.debug.Loggable} msg The message to log.
 * @param {Error=} opt_exception An exception associated with the message.
 */
goog.debug.Logger.prototype.finer = function(msg, opt_exception) {
  if (goog.debug.LOGGING_ENABLED) {
    this.log(goog.debug.Logger.Level.FINER, msg, opt_exception);
  }
};

/**
 * Logs a message at the Logger.Level.FINEST level.
 * If the logger is currently enabled for the given message level then the
 * given message is forwarded to all the registered output Handler objects.
 * @param {goog.debug.Loggable} msg The message to log.
 * @param {Error=} opt_exception An exception associated with the message.
 */
goog.debug.Logger.prototype.finest = function(msg, opt_exception) {
  if (goog.debug.LOGGING_ENABLED) {
    this.log(goog.debug.Logger.Level.FINEST, msg, opt_exception);
  }
};

/**
 * Logs a LogRecord. If the logger is currently enabled for the
 * given message level then the given message is forwarded to all the
 * registered output Handler objects.
 * @param {goog.debug.LogRecord} logRecord A log record to log.
 */
goog.debug.Logger.prototype.logRecord = function(logRecord) {
  if (goog.debug.LOGGING_ENABLED && this.isLoggable(logRecord.getLevel())) {
    this.doLogRecord_(logRecord);
  }
};

/**
 * Logs a LogRecord.
 * @param {goog.debug.LogRecord} logRecord A log record to log.
 * @private
 */
goog.debug.Logger.prototype.doLogRecord_ = function(logRecord) {
  goog.debug.Logger.logToProfilers('log:' + logRecord.getMessage());
  if (goog.debug.Logger.ENABLE_HIERARCHY) {
    var target = this;
    while (target) {
      target.callPublish_(logRecord);
      target = target.getParent();
    }
  } else {
    for (var i = 0, handler; handler = goog.debug.Logger.rootHandlers_[i++]; ) {
      handler(logRecord);
    }
  }
};

/**
 * Calls the handlers for publish.
 * @param {goog.debug.LogRecord} logRecord The log record to publish.
 * @private
 */
goog.debug.Logger.prototype.callPublish_ = function(logRecord) {
  if (this.handlers_) {
    for (var i = 0, handler; handler = this.handlers_[i]; i++) {
      handler(logRecord);
    }
  }
};

/**
 * Sets the parent of this logger. This is used for setting up the logger tree.
 * @param {goog.debug.Logger} parent The parent logger.
 * @private
 */
goog.debug.Logger.prototype.setParent_ = function(parent) {
  this.parent_ = parent;
};

/**
 * Adds a child to this logger. This is used for setting up the logger tree.
 * @param {string} name The leaf name of the child.
 * @param {goog.debug.Logger} logger The child logger.
 * @private
 */
goog.debug.Logger.prototype.addChild_ = function(name, logger) {
  this.getChildren()[name] = logger;
};

/**
 * There is a single global LogManager object that is used to maintain a set of
 * shared state about Loggers and log services. This is loosely based on the
 * java class java.util.logging.LogManager.
 * @const
 */
goog.debug.LogManager = {};

/**
 * Map of logger names to logger objects.
 *
 * @type {!Object<string, !goog.debug.Logger>}
 * @private
 */
goog.debug.LogManager.loggers_ = {};

/**
 * The root logger which is the root of the logger tree.
 * @type {goog.debug.Logger}
 * @private
 */
goog.debug.LogManager.rootLogger_ = null;

/**
 * Initializes the LogManager if not already initialized.
 */
goog.debug.LogManager.initialize = function() {
  if (!goog.debug.LogManager.rootLogger_) {
    goog.debug.LogManager.rootLogger_ = new goog.debug.Logger(
        goog.debug.Logger.ROOT_LOGGER_NAME);
    goog.debug.LogManager.loggers_[goog.debug.Logger.ROOT_LOGGER_NAME] =
        goog.debug.LogManager.rootLogger_;
    goog.debug.LogManager.rootLogger_.setLevel(goog.debug.Logger.Level.CONFIG);
  }
};

/**
 * Returns all the loggers.
 * @return {!Object<string, !goog.debug.Logger>} Map of logger names to logger
 *     objects.
 */
goog.debug.LogManager.getLoggers = function() {
  return goog.debug.LogManager.loggers_;
};

/**
 * Returns the root of the logger tree namespace, the logger with the empty
 * string as its name.
 *
 * @return {!goog.debug.Logger} The root logger.
 */
goog.debug.LogManager.getRoot = function() {
  goog.debug.LogManager.initialize();
  return /** @type {!goog.debug.Logger} */ (goog.debug.LogManager.rootLogger_);
};

/**
 * Finds a named logger.
 *
 * @param {string} name A name for the logger. This should be a dot-separated
 * name and should normally be based on the package name or class name of the
 * subsystem, such as goog.net.BrowserChannel.
 * @return {!goog.debug.Logger} The named logger.
 */
goog.debug.LogManager.getLogger = function(name) {
  goog.debug.LogManager.initialize();
  var ret = goog.debug.LogManager.loggers_[name];
  return ret || goog.debug.LogManager.createLogger_(name);
};

/**
 * Creates a function that can be passed to goog.debug.catchErrors. The function
 * will log all reported errors using the given logger.
 * @param {goog.debug.Logger=} opt_logger The logger to log the errors to.
 *     Defaults to the root logger.
 * @return {function(Object)} The created function.
 */
goog.debug.LogManager.createFunctionForCatchErrors = function(opt_logger) {
  return function(info) {
    var logger = opt_logger || goog.debug.LogManager.getRoot();
    logger.severe('Error: ' + info.message + ' (' + info.fileName +
                  ' @ Line: ' + info.line + ')');
  };
};

/**
 * Creates the named logger. Will also create the parents of the named logger
 * if they don't yet exist.
 * @param {string} name The name of the logger.
 * @return {!goog.debug.Logger} The named logger.
 * @private
 */
goog.debug.LogManager.createLogger_ = function(name) {
  // find parent logger
  var logger = new goog.debug.Logger(name);
  if (goog.debug.Logger.ENABLE_HIERARCHY) {
    var lastDotIndex = name.lastIndexOf('.');
    var parentName = name.substr(0, lastDotIndex);
    var leafName = name.substr(lastDotIndex + 1);
    var parentLogger = goog.debug.LogManager.getLogger(parentName);

    // tell the parent about the child and the child about the parent
    parentLogger.addChild_(leafName, logger);
    logger.setParent_(parentLogger);
  }

  goog.debug.LogManager.loggers_[name] = logger;
  return logger;
};

{'repo_name': 'carsenk/explorer', 'stars': '395', 'repo_language': 'JavaScript', 'file_name': 'scenarios.js', 'mime_type': 'text/plain', 'hash': -602779616093785484, 'source_dataset': 'data'}


<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<DICTIONARY type="singlelanguage" lang="en" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="dictionary.xsd">
  <STRING id="Control.Text.Languages#Back" value="[ButtonText_Back]"/>
  <STRING id="Control.Text.Languages#BannerBitmap" value="[BannerBitmap]"/>
  <STRING id="Control.Text.Languages#Cancel" value="[ButtonText_Cancel]"/>
  <STRING id="Control.Text.Languages#ComboBox_Language" value="{260}"/>
  <STRING id="Control.Text.Languages#Description" value="Please select the main language you'll be using in Optikey"/>
  <STRING id="Control.Text.Languages#Logo" value="Advanced Installer"/>
  <STRING id="Control.Text.Languages#Next" value="[ButtonText_Next]"/>
  <STRING id="Control.Text.Languages#Title" value="Language"/>
  <STRING id="Dialog.Languages" value="[ProductName] [Setup]"/>
</DICTIONARY>

{'repo_name': 'OptiKey/OptiKey', 'stars': '3747', 'repo_language': 'C#', 'file_name': 'OptikeyApp.aitemplate', 'mime_type': 'text/xml', 'hash': 2174214103856233404, 'source_dataset': 'data'}


/*******************************************************************************
 * Copyright (c) 2015 Tasktop Technologies and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Tasktop Technologies - initial API and implementation
 *******************************************************************************/

package org.jkiss.dbeaver.ui.notifications;

import org.eclipse.e4.ui.css.swt.theme.IThemeEngine;
import org.eclipse.e4.ui.css.swt.theme.IThemeManager;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.jkiss.dbeaver.Log;
import org.osgi.framework.BundleContext;
import org.osgi.framework.FrameworkUtil;
import org.osgi.framework.ServiceReference;
import org.w3c.dom.css.CSSStyleDeclaration;
import org.w3c.dom.css.CSSValue;

public class E4ThemeColor {

    private static final Log log = Log.getLog(E4ThemeColor.class);
    private static boolean loggedError = false;

    public static RGB getRGBFromCssString(String cssValue) {
        try {
            if (cssValue.startsWith("rgb(")) { //$NON-NLS-1$
                String rest = cssValue.substring(4, cssValue.length());
                int idx = rest.indexOf("rgb("); //$NON-NLS-1$
                if (idx != -1) {
                    rest = rest.substring(idx + 4, rest.length());
                }
                idx = rest.indexOf(")"); //$NON-NLS-1$
                if (idx != -1) {
                    rest = rest.substring(0, idx);
                }
                String[] rgbValues = rest.split(","); //$NON-NLS-1$
                if (rgbValues.length == 3) {
                    return new RGB(Integer.parseInt(rgbValues[0].trim()), Integer.parseInt(rgbValues[1].trim()),
                        Integer.parseInt(rgbValues[2].trim()));
                }
            } else if (cssValue.startsWith("#")) { //$NON-NLS-1$
                String rest = cssValue.substring(1, cssValue.length());
                int idx = rest.indexOf("#"); //$NON-NLS-1$
                if (idx != -1) {
                    rest = rest.substring(idx + 1, rest.length());
                }
                if (rest.length() > 5) {
                    return new RGB(Integer.parseInt(rest.substring(0, 2), 16),
                        Integer.parseInt(rest.substring(2, 4), 16), Integer.parseInt(rest.substring(4, 6), 16));
                }
            }
            throw new IllegalArgumentException("RGB: " + cssValue); //$NON-NLS-1$
        } catch (IllegalArgumentException e) {
            logOnce(e);
            return null;
        }
    }

    public static String getCssValueFromTheme(Display display, String value) {
        // use reflection so that this can build against Eclipse 3.x
        BundleContext context = FrameworkUtil.getBundle(E4ThemeColor.class).getBundleContext();
        ServiceReference<IThemeManager> reference = context.getServiceReference(IThemeManager.class);
        if (reference != null) {
            IThemeManager iThemeManager = context.getService(reference);
            if (iThemeManager != null) {
                IThemeEngine themeEngine = iThemeManager.getEngineForDisplay(display);
                if (themeEngine != null) {
                    CSSStyleDeclaration shellStyle = getStyleDeclaration(themeEngine, display);
                    if (shellStyle != null) {
                        CSSValue cssValue = shellStyle.getPropertyCSSValue(value);
                        if (cssValue != null) {
                            return cssValue.getCssText();
                        }
                    }
                }
            }
        }

        return null;
    }

    private static CSSStyleDeclaration getStyleDeclaration(IThemeEngine themeEngine, Display display) {
        Shell shell = display.getActiveShell();
        CSSStyleDeclaration shellStyle = null;
        if (shell != null) {
            shellStyle = themeEngine.getStyle(shell);
        } else {
            for (Shell input : display.getShells()) {
                shellStyle = themeEngine.getStyle(input);
                if (shellStyle != null) {
                    break;
                }
            }
        }
        return shellStyle;
    }

    private static void logOnce(Exception e) {
        if (!loggedError) {
            log.error(e);
            loggedError = true;
        }
    }
}

{'repo_name': 'dbeaver/dbeaver', 'stars': '14217', 'repo_language': 'Java', 'file_name': 'JDBCObjectLookupCache.java', 'mime_type': 'text/x-java', 'hash': 7461729480286685561, 'source_dataset': 'data'}