cartodb.core.js 238 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272
  1. var LZMA = (function () {
  2. var action_compress = 1,
  3. action_decompress = 2,
  4. action_update = 3;
  5. function update_progress(percent, callback_num) {
  6. ///TODO: Calculate ETA.
  7. postMessage({
  8. action: 3,
  9. callback_num: callback_num,
  10. result: percent
  11. });
  12. }
  13. var $moduleName, $moduleBase;
  14. var _,
  15. N8000000000000000_longLit = [0, -9223372036854775808],
  16. N1_longLit = [4294967295, -4294967296],
  17. P0_longLit = [0, 0],
  18. P1_longLit = [1, 0],
  19. P4_longLit = [4, 0],
  20. P1000_longLit = [4096, 0],
  21. Pffffff_longLit = [16777215, 0],
  22. P1000000_longLit = [16777216, 0],
  23. Pff000000_longLit = [4278190080, 0],
  24. Pffffffff_longLit = [4294967295, 0],
  25. P7fffffffffffffff_longLit = [4294967295, 9223372032559808512];
  26. function getClass_18() {
  27. return Ljava_lang_Object_2_classLit;
  28. }
  29. function Object_0() {
  30. }
  31. _ = Object_0.prototype = {};
  32. _.getClass$ = getClass_18;
  33. _.typeMarker$ = nullMethod;
  34. _.typeId$ = 1;
  35. function getClass_22() {
  36. return Ljava_lang_Throwable_2_classLit;
  37. }
  38. function Throwable() {
  39. }
  40. _ = Throwable.prototype = new Object_0();
  41. _.getClass$ = getClass_22;
  42. _.typeId$ = 3;
  43. _.detailMessage = null;
  44. function getClass_13() {
  45. return Ljava_lang_Exception_2_classLit;
  46. }
  47. function Exception() {
  48. }
  49. _ = Exception.prototype = new Throwable();
  50. _.getClass$ = getClass_13;
  51. _.typeId$ = 4;
  52. function $RuntimeException(this$static, message) {
  53. this$static.detailMessage = message;
  54. return this$static;
  55. }
  56. function getClass_19() {
  57. return Ljava_lang_RuntimeException_2_classLit;
  58. }
  59. function RuntimeException() {
  60. }
  61. _ = RuntimeException.prototype = new Exception();
  62. _.getClass$ = getClass_19;
  63. _.typeId$ = 5;
  64. function $JavaScriptException(this$static, e) {
  65. return this$static;
  66. }
  67. function getClass_0() {
  68. return Lcom_google_gwt_core_client_JavaScriptException_2_classLit;
  69. }
  70. function JavaScriptException() {
  71. }
  72. _ = JavaScriptException.prototype = new RuntimeException();
  73. _.getClass$ = getClass_0;
  74. _.typeId$ = 6;
  75. function $append(a, x) {
  76. a[a.explicitLength++] = x;
  77. }
  78. function $appendNonNull(a, x) {
  79. a[a.explicitLength++] = x;
  80. }
  81. function $toString(a) {
  82. var s_0, s;
  83. s_0 = (s = a.join('') , a.length = a.explicitLength = 0 , s);
  84. a[a.explicitLength++] = s_0;
  85. return s_0;
  86. }
  87. function createFromSeed(seedType, length_0) {
  88. var array = new Array(length_0);
  89. if (seedType > 0) {
  90. var value = [null, 0, false, [0, 0]][seedType];
  91. for (var i = 0; i < length_0; ++i) {
  92. array[i] = value;
  93. }
  94. }
  95. return array;
  96. }
  97. function getClass_2() {
  98. return this.arrayClass$;
  99. }
  100. function initDim(arrayClass, typeId, queryId, length_0, seedType) {
  101. var result;
  102. result = createFromSeed(seedType, length_0);
  103. $clinit_4();
  104. wrapArray(result, expandoNames_0, expandoValues_0);
  105. result.arrayClass$ = arrayClass;
  106. result.typeId$ = typeId;
  107. result.queryId$ = queryId;
  108. return result;
  109. }
  110. function initValues(arrayClass, typeId, queryId, array) {
  111. $clinit_4();
  112. wrapArray(array, expandoNames_0, expandoValues_0);
  113. array.arrayClass$ = arrayClass;
  114. array.typeId$ = typeId;
  115. array.queryId$ = queryId;
  116. return array;
  117. }
  118. function setCheck(array, index, value) {
  119. if (value != null) {
  120. if (array.queryId$ > 0 && !canCastUnsafe(value.typeId$, array.queryId$)) {
  121. throw new ArrayStoreException();
  122. }
  123. if (array.queryId$ < 0 && (value.typeMarker$ == nullMethod || value.typeId$ == 2)) {
  124. throw new ArrayStoreException();
  125. }
  126. }
  127. return array[index] = value;
  128. }
  129. function Array_0() {
  130. }
  131. _ = Array_0.prototype = new Object_0();
  132. _.getClass$ = getClass_2;
  133. _.typeId$ = 0;
  134. _.arrayClass$ = null;
  135. _.length = 0;
  136. _.queryId$ = 0;
  137. function $clinit_4() {
  138. $clinit_4 = nullMethod;
  139. expandoNames_0 = [];
  140. expandoValues_0 = [];
  141. initExpandos(new Array_0(), expandoNames_0, expandoValues_0);
  142. }
  143. function initExpandos(protoType, expandoNames, expandoValues) {
  144. var i = 0, value;
  145. for (var name_0 in protoType) {
  146. if (value = protoType[name_0]) {
  147. expandoNames[i] = name_0;
  148. expandoValues[i] = value;
  149. ++i;
  150. }
  151. }
  152. }
  153. function wrapArray(array, expandoNames, expandoValues) {
  154. $clinit_4();
  155. for (var i = 0, c = expandoNames.length; i < c; ++i) {
  156. array[expandoNames[i]] = expandoValues[i];
  157. }
  158. }
  159. var expandoNames_0, expandoValues_0;
  160. function canCast(srcId, dstId) {
  161. return srcId && !!typeIdArray[srcId][dstId];
  162. }
  163. function canCastUnsafe(srcId, dstId) {
  164. return srcId && typeIdArray[srcId][dstId];
  165. }
  166. function dynamicCast(src, dstId) {
  167. if (src != null && !canCastUnsafe(src.typeId$, dstId)) {
  168. throw new ClassCastException();
  169. }
  170. return src;
  171. }
  172. function instanceOf(src, dstId) {
  173. return src != null && canCast(src.typeId$, dstId);
  174. }
  175. function round_int(x) {
  176. return ~~Math.max(Math.min(x, 2147483647), -2147483648);
  177. }
  178. var typeIdArray = [
  179. {},
  180. {},
  181. {1:1},
  182. {2:1},
  183. {2:1},
  184. {2:1},
  185. {2:1},
  186. {2:1, 10:1},
  187. {2:1},
  188. {2:1},
  189. {2:1},
  190. {2:1},
  191. {2:1},
  192. {2:1, 11:1},
  193. {2:1},
  194. {2:1},
  195. {2:1},
  196. {4:1},
  197. {5:1},
  198. {6:1},
  199. {7:1},
  200. {8:1},
  201. {9:1}
  202. ];
  203. function caught(e) {
  204. if (e != null && canCast(e.typeId$, 2)) {
  205. return e;
  206. }
  207. return $JavaScriptException(new JavaScriptException(), e);
  208. }
  209. function add(a, b) {
  210. var newHigh, newLow;
  211. newHigh = a[1] + b[1];
  212. newLow = a[0] + b[0];
  213. return create(newLow, newHigh);
  214. }
  215. function addTimes(accum, a, b) {
  216. if (a == 0) {
  217. return accum;
  218. }
  219. if (b == 0) {
  220. return accum;
  221. }
  222. return add(accum, create(a * b, 0));
  223. }
  224. function and(a, b) {
  225. return makeFromBits(~~Math.max(Math.min(a[1] / 4294967296, 2147483647), -2147483648) & ~~Math.max(Math.min(b[1] / 4294967296, 2147483647), -2147483648), lowBits_0(a) & lowBits_0(b));
  226. }
  227. function compare(a, b) {
  228. var nega, negb;
  229. if (a[0] == b[0] && a[1] == b[1]) {
  230. return 0;
  231. }
  232. nega = a[1] < 0;
  233. negb = b[1] < 0;
  234. if (nega && !negb) {
  235. return -1;
  236. }
  237. if (!nega && negb) {
  238. return 1;
  239. }
  240. if (sub(a, b)[1] < 0) {
  241. return -1;
  242. }
  243. else {
  244. return 1;
  245. }
  246. }
  247. function create(valueLow, valueHigh) {
  248. var diffHigh, diffLow;
  249. valueHigh %= 1.8446744073709552E19;
  250. valueLow %= 1.8446744073709552E19;
  251. diffHigh = valueHigh % 4294967296;
  252. diffLow = Math.floor(valueLow / 4294967296) * 4294967296;
  253. valueHigh = valueHigh - diffHigh + diffLow;
  254. valueLow = valueLow - diffLow + diffHigh;
  255. while (valueLow < 0) {
  256. valueLow += 4294967296;
  257. valueHigh -= 4294967296;
  258. }
  259. while (valueLow > 4294967295) {
  260. valueLow -= 4294967296;
  261. valueHigh += 4294967296;
  262. }
  263. valueHigh = valueHigh % 1.8446744073709552E19;
  264. while (valueHigh > 9223372032559808512) {
  265. valueHigh -= 1.8446744073709552E19;
  266. }
  267. while (valueHigh < -9223372036854775808) {
  268. valueHigh += 1.8446744073709552E19;
  269. }
  270. return [valueLow, valueHigh];
  271. }
  272. function div(a, b) {
  273. var approx, deltaRem, deltaResult, halfa, rem, result;
  274. if (b[0] == 0 && b[1] == 0) {
  275. throw $ArithmeticException(new ArithmeticException(), '/ by zero');
  276. }
  277. if (a[0] == 0 && a[1] == 0) {
  278. return $clinit_10() , ZERO;
  279. }
  280. if (eq(a, ($clinit_10() , MIN_VALUE))) {
  281. if (eq(b, ONE) || eq(b, NEG_ONE)) {
  282. return MIN_VALUE;
  283. }
  284. halfa = shr(a, 1);
  285. approx = shl(div(halfa, b), 1);
  286. rem = sub(a, mul(b, approx));
  287. return add(approx, div(rem, b));
  288. }
  289. if (eq(b, MIN_VALUE)) {
  290. return ZERO;
  291. }
  292. if (a[1] < 0) {
  293. if (b[1] < 0) {
  294. return div(neg(a), neg(b));
  295. } else {
  296. return neg(div(neg(a), b));
  297. }
  298. }
  299. if (b[1] < 0) {
  300. return neg(div(a, neg(b)));
  301. }
  302. result = ZERO;
  303. rem = a;
  304. while (compare(rem, b) >= 0) {
  305. deltaResult = fromDouble(Math.floor(toDoubleRoundDown(rem) / toDoubleRoundUp(b)));
  306. if (deltaResult[0] == 0 && deltaResult[1] == 0) {
  307. deltaResult = ONE;
  308. }
  309. deltaRem = mul(deltaResult, b);
  310. result = add(result, deltaResult);
  311. rem = sub(rem, deltaRem);
  312. }
  313. return result;
  314. }
  315. function eq(a, b) {
  316. return a[0] == b[0] && a[1] == b[1];
  317. }
  318. function fromDouble(value) {
  319. if (isNaN(value)) {
  320. return $clinit_10() , ZERO;
  321. }
  322. if (value < -9223372036854775808) {
  323. return $clinit_10() , MIN_VALUE;
  324. }
  325. if (value >= 9223372036854775807) {
  326. return $clinit_10() , MAX_VALUE;
  327. }
  328. if (value > 0) {
  329. return create(Math.floor(value), 0);
  330. } else {
  331. return create(Math.ceil(value), 0);
  332. }
  333. }
  334. function fromInt(value) {
  335. var rebase, result;
  336. if (value > -129 && value < 128) {
  337. rebase = value + 128;
  338. result = ($clinit_9() , boxedValues)[rebase];
  339. if (result == null) {
  340. result = boxedValues[rebase] = internalFromInt(value);
  341. }
  342. return result;
  343. }
  344. return internalFromInt(value);
  345. }
  346. function internalFromInt(value) {
  347. if (value >= 0) {
  348. return [value, 0];
  349. } else {
  350. return [value + 4294967296, -4294967296];
  351. }
  352. }
  353. function lowBits_0(a) {
  354. if (a[0] >= 2147483648) {
  355. return ~~Math.max(Math.min(a[0] - 4294967296, 2147483647), -2147483648);
  356. } else {
  357. return ~~Math.max(Math.min(a[0], 2147483647), -2147483648);
  358. }
  359. }
  360. function makeFromBits(highBits, lowBits) {
  361. var high, low;
  362. high = highBits * 4294967296;
  363. low = lowBits;
  364. if (lowBits < 0) {
  365. low += 4294967296;
  366. }
  367. return [low, high];
  368. }
  369. function mul(a, b) {
  370. var a1, a2, a3, a4, b1, b2, b3, b4, res;
  371. if (a[0] == 0 && a[1] == 0) {
  372. return $clinit_10() , ZERO;
  373. }
  374. if (b[0] == 0 && b[1] == 0) {
  375. return $clinit_10() , ZERO;
  376. }
  377. if (eq(a, ($clinit_10() , MIN_VALUE))) {
  378. return multByMinValue(b);
  379. }
  380. if (eq(b, MIN_VALUE)) {
  381. return multByMinValue(a);
  382. }
  383. if (a[1] < 0) {
  384. if (b[1] < 0) {
  385. return mul(neg(a), neg(b));
  386. } else {
  387. return neg(mul(neg(a), b));
  388. }
  389. }
  390. if (b[1] < 0) {
  391. return neg(mul(a, neg(b)));
  392. }
  393. if (compare(a, TWO_PWR_24) < 0 && compare(b, TWO_PWR_24) < 0) {
  394. return create((a[1] + a[0]) * (b[1] + b[0]), 0);
  395. }
  396. a3 = a[1] % 281474976710656;
  397. a4 = a[1] - a3;
  398. a1 = a[0] % 65536;
  399. a2 = a[0] - a1;
  400. b3 = b[1] % 281474976710656;
  401. b4 = b[1] - b3;
  402. b1 = b[0] % 65536;
  403. b2 = b[0] - b1;
  404. res = ZERO;
  405. res = addTimes(res, a4, b1);
  406. res = addTimes(res, a3, b2);
  407. res = addTimes(res, a3, b1);
  408. res = addTimes(res, a2, b3);
  409. res = addTimes(res, a2, b2);
  410. res = addTimes(res, a2, b1);
  411. res = addTimes(res, a1, b4);
  412. res = addTimes(res, a1, b3);
  413. res = addTimes(res, a1, b2);
  414. res = addTimes(res, a1, b1);
  415. return res;
  416. }
  417. function multByMinValue(a) {
  418. if ((lowBits_0(a) & 1) == 1) {
  419. return $clinit_10() , MIN_VALUE;
  420. } else {
  421. return $clinit_10() , ZERO;
  422. }
  423. }
  424. function neg(a) {
  425. var newHigh, newLow;
  426. if (eq(a, ($clinit_10() , MIN_VALUE))) {
  427. return MIN_VALUE;
  428. }
  429. newHigh = -a[1];
  430. newLow = -a[0];
  431. if (newLow > 4294967295) {
  432. newLow -= 4294967296;
  433. newHigh += 4294967296;
  434. }
  435. if (newLow < 0) {
  436. newLow += 4294967296;
  437. newHigh -= 4294967296;
  438. }
  439. return [newLow, newHigh];
  440. }
  441. function pwrAsDouble(n) {
  442. if (n <= 30) {
  443. return 1 << n;
  444. } else {
  445. return pwrAsDouble(30) * pwrAsDouble(n - 30);
  446. }
  447. }
  448. function shl(a, n) {
  449. var diff, newHigh, newLow, twoToN;
  450. n &= 63;
  451. if (eq(a, ($clinit_10() , MIN_VALUE))) {
  452. if (n == 0) {
  453. return a;
  454. } else {
  455. return ZERO;
  456. }
  457. }
  458. if (a[1] < 0) {
  459. return neg(shl(neg(a), n));
  460. }
  461. twoToN = pwrAsDouble(n);
  462. newHigh = a[1] * twoToN % 1.8446744073709552E19;
  463. newLow = a[0] * twoToN;
  464. diff = newLow - newLow % 4294967296;
  465. newHigh += diff;
  466. newLow -= diff;
  467. if (newHigh >= 9223372036854775807) {
  468. newHigh -= 1.8446744073709552E19;
  469. }
  470. return [newLow, newHigh];
  471. }
  472. function shr(a, n) {
  473. var newHigh, newLow, shiftFact;
  474. n &= 63;
  475. shiftFact = pwrAsDouble(n);
  476. newHigh = a[1] / shiftFact;
  477. newLow = Math.floor(a[0] / shiftFact);
  478. return create(newLow, newHigh);
  479. }
  480. function shru(a, n) {
  481. var sr;
  482. n &= 63;
  483. sr = shr(a, n);
  484. if (a[1] < 0) {
  485. sr = add(sr, shl(($clinit_10() , TWO), 63 - n));
  486. }
  487. return sr;
  488. }
  489. function sub(a, b) {
  490. var newHigh, newLow;
  491. newHigh = a[1] - b[1];
  492. newLow = a[0] - b[0];
  493. return create(newLow, newHigh);
  494. }
  495. function toDoubleRoundDown(a) {
  496. var diff, magnitute, toSubtract;
  497. magnitute = round_int(Math.log(a[1]) / ($clinit_10() , LN_2));
  498. if (magnitute <= 48) {
  499. return a[1] + a[0];
  500. } else {
  501. diff = magnitute - 48;
  502. toSubtract = (1 << diff) - 1;
  503. return a[1] + (a[0] - toSubtract);
  504. }
  505. }
  506. function toDoubleRoundUp(a) {
  507. var diff, magnitute, toAdd;
  508. magnitute = round_int(Math.log(a[1]) / ($clinit_10() , LN_2));
  509. if (magnitute <= 48) {
  510. return a[1] + a[0];
  511. } else {
  512. diff = magnitute - 48;
  513. toAdd = (1 << diff) - 1;
  514. return a[1] + (a[0] + toAdd);
  515. }
  516. }
  517. function toString_0(a) {
  518. var digits, rem, remDivTenPower, res, tenPowerLong, zeroesNeeded;
  519. if (a[0] == 0 && a[1] == 0) {
  520. return '0';
  521. }
  522. if (eq(a, ($clinit_10() , MIN_VALUE))) {
  523. return '-9223372036854775808';
  524. }
  525. if (a[1] < 0) {
  526. return '-' + toString_0(neg(a));
  527. }
  528. rem = a;
  529. res = '';
  530. while (!(rem[0] == 0 && rem[1] == 0)) {
  531. tenPowerLong = fromInt(1000000000);
  532. remDivTenPower = div(rem, tenPowerLong);
  533. digits = '' + lowBits_0(sub(rem, mul(remDivTenPower, tenPowerLong)));
  534. rem = remDivTenPower;
  535. if (!(rem[0] == 0 && rem[1] == 0)) {
  536. zeroesNeeded = 9 - digits.length;
  537. for (; zeroesNeeded > 0; --zeroesNeeded) {
  538. digits = '0' + digits;
  539. }
  540. }
  541. res = digits + res;
  542. }
  543. return res;
  544. }
  545. function $clinit_9() {
  546. $clinit_9 = nullMethod;
  547. boxedValues = initDim(_3_3D_classLit, 0, 9, 256, 0);
  548. }
  549. var boxedValues;
  550. function $clinit_10() {
  551. $clinit_10 = nullMethod;
  552. LN_2 = Math.log(2);
  553. MAX_VALUE = P7fffffffffffffff_longLit;
  554. MIN_VALUE = N8000000000000000_longLit;
  555. NEG_ONE = fromInt(-1);
  556. ONE = fromInt(1);
  557. TWO = fromInt(2);
  558. TWO_PWR_24 = P1000000_longLit;
  559. ZERO = fromInt(0);
  560. }
  561. var LN_2, MAX_VALUE, MIN_VALUE, NEG_ONE, ONE, TWO, TWO_PWR_24, ZERO;
  562. function getClass_6() {
  563. return Ljava_io_InputStream_2_classLit;
  564. }
  565. function InputStream() {
  566. }
  567. _ = InputStream.prototype = new Object_0();
  568. _.getClass$ = getClass_6;
  569. _.typeId$ = 0;
  570. function $ByteArrayInputStream(this$static, buf) {
  571. $ByteArrayInputStream_0(this$static, buf, 0, buf.length);
  572. return this$static;
  573. }
  574. function $ByteArrayInputStream_0(this$static, buf, off, len) {
  575. this$static.buf = buf;
  576. this$static.pos = off;
  577. this$static.count = off + len;
  578. if (this$static.count > buf.length)
  579. this$static.count = buf.length;
  580. return this$static;
  581. }
  582. function $read(this$static) {
  583. if (this$static.pos >= this$static.count)
  584. return -1;
  585. return this$static.buf[this$static.pos++] & 255;
  586. }
  587. function $read_0(this$static, buf, off, len) {
  588. if (this$static.pos >= this$static.count)
  589. return -1;
  590. len = min(len, this$static.count - this$static.pos);
  591. arraycopy(this$static.buf, this$static.pos, buf, off, len);
  592. this$static.pos += len;
  593. return len;
  594. }
  595. function getClass_3() {
  596. return Ljava_io_ByteArrayInputStream_2_classLit;
  597. }
  598. function ByteArrayInputStream() {
  599. }
  600. _ = ByteArrayInputStream.prototype = new InputStream();
  601. _.getClass$ = getClass_3;
  602. _.typeId$ = 0;
  603. _.buf = null;
  604. _.count = 0;
  605. _.pos = 0;
  606. function getClass_7() {
  607. return Ljava_io_OutputStream_2_classLit;
  608. }
  609. function OutputStream() {
  610. }
  611. _ = OutputStream.prototype = new Object_0();
  612. _.getClass$ = getClass_7;
  613. _.typeId$ = 0;
  614. function $ByteArrayOutputStream(this$static) {
  615. this$static.buf = initDim(_3B_classLit, 0, -1, 32, 1);
  616. return this$static;
  617. }
  618. function $ensureCapacity(this$static, len) {
  619. var newbuf;
  620. if (len <= this$static.buf.length)
  621. return;
  622. len = max(len, this$static.buf.length * 2);
  623. newbuf = initDim(_3B_classLit, 0, -1, len, 1);
  624. arraycopy(this$static.buf, 0, newbuf, 0, this$static.buf.length);
  625. this$static.buf = newbuf;
  626. }
  627. function $toByteArray(this$static) {
  628. var data;
  629. data = initDim(_3B_classLit, 0, -1, this$static.count, 1);
  630. arraycopy(this$static.buf, 0, data, 0, this$static.count);
  631. return data;
  632. }
  633. function $write(this$static, b) {
  634. $ensureCapacity(this$static, this$static.count + 1);
  635. this$static.buf[this$static.count++] = b << 24 >> 24;
  636. }
  637. function $write_0(this$static, buf, off, len) {
  638. $ensureCapacity(this$static, this$static.count + len);
  639. arraycopy(buf, off, this$static.buf, this$static.count, len);
  640. this$static.count += len;
  641. }
  642. function getClass_4() {
  643. return Ljava_io_ByteArrayOutputStream_2_classLit;
  644. }
  645. function ByteArrayOutputStream() {
  646. }
  647. _ = ByteArrayOutputStream.prototype = new OutputStream();
  648. _.getClass$ = getClass_4;
  649. _.typeId$ = 0;
  650. _.buf = null;
  651. _.count = 0;
  652. function $IOException(this$static, message) {
  653. this$static.detailMessage = message;
  654. return this$static;
  655. }
  656. function getClass_5() {
  657. return Ljava_io_IOException_2_classLit;
  658. }
  659. function IOException() {
  660. }
  661. _ = IOException.prototype = new Exception();
  662. _.getClass$ = getClass_5;
  663. _.typeId$ = 7;
  664. function $ArithmeticException(this$static, explanation) {
  665. this$static.detailMessage = explanation;
  666. return this$static;
  667. }
  668. function getClass_8() {
  669. return Ljava_lang_ArithmeticException_2_classLit;
  670. }
  671. function ArithmeticException() {
  672. }
  673. _ = ArithmeticException.prototype = new RuntimeException();
  674. _.getClass$ = getClass_8;
  675. _.typeId$ = 8;
  676. function $ArrayStoreException(this$static, message) {
  677. this$static.detailMessage = message;
  678. return this$static;
  679. }
  680. function getClass_9() {
  681. return Ljava_lang_ArrayStoreException_2_classLit;
  682. }
  683. function ArrayStoreException() {
  684. }
  685. _ = ArrayStoreException.prototype = new RuntimeException();
  686. _.getClass$ = getClass_9;
  687. _.typeId$ = 9;
  688. function createForArray(packageName, className) {
  689. var clazz;
  690. clazz = new Class();
  691. clazz.typeName = packageName + className;
  692. return clazz;
  693. }
  694. function createForClass(packageName, className) {
  695. var clazz;
  696. clazz = new Class();
  697. clazz.typeName = packageName + className;
  698. return clazz;
  699. }
  700. function createForEnum(packageName, className) {
  701. var clazz;
  702. clazz = new Class();
  703. clazz.typeName = packageName + className;
  704. return clazz;
  705. }
  706. function getClass_11() {
  707. return Ljava_lang_Class_2_classLit;
  708. }
  709. function Class() {
  710. }
  711. _ = Class.prototype = new Object_0();
  712. _.getClass$ = getClass_11;
  713. _.typeId$ = 0;
  714. _.typeName = null;
  715. function getClass_10() {
  716. return Ljava_lang_ClassCastException_2_classLit;
  717. }
  718. function ClassCastException() {
  719. }
  720. _ = ClassCastException.prototype = new RuntimeException();
  721. _.getClass$ = getClass_10;
  722. _.typeId$ = 12;
  723. function getClass_12() {
  724. return Ljava_lang_Enum_2_classLit;
  725. }
  726. function Enum() {
  727. }
  728. _ = Enum.prototype = new Object_0();
  729. _.getClass$ = getClass_12;
  730. _.typeId$ = 0;
  731. function $IllegalArgumentException(this$static, message) {
  732. this$static.detailMessage = message;
  733. return this$static;
  734. }
  735. function getClass_14() {
  736. return Ljava_lang_IllegalArgumentException_2_classLit;
  737. }
  738. function IllegalArgumentException() {
  739. }
  740. _ = IllegalArgumentException.prototype = new RuntimeException();
  741. _.getClass$ = getClass_14;
  742. _.typeId$ = 13;
  743. function getClass_15() {
  744. return Ljava_lang_IllegalStateException_2_classLit;
  745. }
  746. function IllegalStateException() {
  747. }
  748. _ = IllegalStateException.prototype = new RuntimeException();
  749. _.getClass$ = getClass_15;
  750. _.typeId$ = 14;
  751. function getClass_16() {
  752. return Ljava_lang_IndexOutOfBoundsException_2_classLit;
  753. }
  754. function IndexOutOfBoundsException() {
  755. }
  756. _ = IndexOutOfBoundsException.prototype = new RuntimeException();
  757. _.getClass$ = getClass_16;
  758. _.typeId$ = 15;
  759. function max(x, y) {
  760. return x > y?x:y;
  761. }
  762. function min(x, y) {
  763. return x < y?x:y;
  764. }
  765. function getClass_17() {
  766. return Ljava_lang_NullPointerException_2_classLit;
  767. }
  768. function NullPointerException() {
  769. }
  770. _ = NullPointerException.prototype = new RuntimeException();
  771. _.getClass$ = getClass_17;
  772. _.typeId$ = 16;
  773. function $equals(this$static, other) {
  774. if (other == null) {
  775. return false;
  776. }
  777. return String(this$static) == other;
  778. }
  779. function $getChars(this$static, srcBegin, srcEnd, dst, dstBegin) {
  780. var srcIdx;
  781. for (srcIdx = srcBegin; srcIdx < srcEnd; ++srcIdx) {
  782. dst[dstBegin++] = this$static.charCodeAt(srcIdx);
  783. }
  784. }
  785. function getClass_21() {
  786. return Ljava_lang_String_2_classLit;
  787. }
  788. _ = String.prototype;
  789. _.getClass$ = getClass_21;
  790. _.typeId$ = 2;
  791. function $StringBuilder(this$static) {
  792. var array;
  793. this$static.data = (array = [] , array.explicitLength = 0 , array);
  794. return this$static;
  795. }
  796. function getClass_20() {
  797. return Ljava_lang_StringBuilder_2_classLit;
  798. }
  799. function StringBuilder() {
  800. }
  801. _ = StringBuilder.prototype = new Object_0();
  802. _.getClass$ = getClass_20;
  803. _.typeId$ = 0;
  804. function arraycopy(src, srcOfs, dest, destOfs, len) {
  805. var destArray, destEnd, destTypeName, destlen, i, srcArray, srcTypeName, srclen;
  806. if (src == null || dest == null) {
  807. throw new NullPointerException();
  808. }
  809. srcTypeName = (src.typeMarker$ == nullMethod || src.typeId$ == 2 ? src.getClass$() : Lcom_google_gwt_core_client_JavaScriptObject_2_classLit).typeName;
  810. destTypeName = (dest.typeMarker$ == nullMethod || dest.typeId$ == 2 ? dest.getClass$() : Lcom_google_gwt_core_client_JavaScriptObject_2_classLit).typeName;
  811. if (srcTypeName.charCodeAt(0) != 91 || destTypeName.charCodeAt(0) != 91) {
  812. throw $ArrayStoreException(new ArrayStoreException(), 'Must be array types');
  813. }
  814. if (srcTypeName.charCodeAt(1) != destTypeName.charCodeAt(1)) {
  815. throw $ArrayStoreException(new ArrayStoreException(), 'Array types must match');
  816. }
  817. srclen = src.length;
  818. destlen = dest.length;
  819. if (srcOfs < 0 || destOfs < 0 || len < 0 || srcOfs + len > srclen || destOfs + len > destlen) {
  820. throw new IndexOutOfBoundsException();
  821. }
  822. if ((srcTypeName.charCodeAt(1) == 76 || srcTypeName.charCodeAt(1) == 91) && !$equals(srcTypeName, destTypeName)) {
  823. srcArray = dynamicCast(src, 3);
  824. destArray = dynamicCast(dest, 3);
  825. if ((src == null ? null : src) === (dest == null ? null : dest) && srcOfs < destOfs) {
  826. srcOfs += len;
  827. for (destEnd = destOfs + len; destEnd-- > destOfs;) {
  828. setCheck(destArray, destEnd, srcArray[--srcOfs]);
  829. }
  830. } else {
  831. for (destEnd = destOfs + len; destOfs < destEnd;) {
  832. setCheck(destArray, destOfs++, srcArray[srcOfs++]);
  833. }
  834. }
  835. } else {
  836. for (i = 0; i < len; ++i) {
  837. dest[destOfs + i] = src[srcOfs + i]
  838. }
  839. }
  840. }
  841. function $configure(this$static, encoder) {
  842. if (!$SetDictionarySize_0(encoder, 1 << this$static.dictionarySize))
  843. throw $RuntimeException(new RuntimeException(), 'unexpected failure');
  844. if (!$SetNumFastBytes(encoder, this$static.fb))
  845. throw $RuntimeException(new RuntimeException(), 'unexpected failure');
  846. if (!$SetMatchFinder(encoder, this$static.matchFinder))
  847. throw $RuntimeException(new RuntimeException(), 'unexpected failure');
  848. if (!$SetLcLpPb_0(encoder, this$static.lc, this$static.lp, this$static.pb))
  849. throw $RuntimeException(new RuntimeException(), 'unexpected failure');
  850. }
  851. function getClass_23() {
  852. return Lorg_dellroad_lzma_client_CompressionMode_2_classLit;
  853. }
  854. function CompressionMode() {
  855. }
  856. _ = CompressionMode.prototype = new Enum();
  857. _.getClass$ = getClass_23;
  858. _.typeId$ = 0;
  859. _.dictionarySize = 0;
  860. _.fb = 0;
  861. _.lc = 0;
  862. _.lp = 0;
  863. _.matchFinder = 0;
  864. _.pb = 0;
  865. function $execute(this$static) {
  866. var $e0;
  867. try {
  868. return $processChunk(this$static.chunker);
  869. }
  870. catch ($e0) {
  871. $e0 = caught($e0);
  872. if (instanceOf($e0, 10)) {
  873. return false;
  874. } else {
  875. throw $e0;
  876. }
  877. }
  878. }
  879. function $init(this$static, input, output, length_0, mode) {
  880. var encoder, i;
  881. if (!mode)
  882. throw $IllegalArgumentException(new IllegalArgumentException(), 'null mode');
  883. if (compare(length_0, N1_longLit) < 0)
  884. throw $IllegalArgumentException(new IllegalArgumentException(), 'invalid length ' + toString_0(length_0));
  885. this$static.length_0 = length_0;
  886. encoder = $Encoder(new Encoder());
  887. $configure(mode, encoder);
  888. encoder._writeEndMark = true;
  889. $WriteCoderProperties(encoder, output);
  890. for (i = 0; i < 64; i += 8)
  891. $write(output, lowBits_0(shr(length_0, i)) & 255);
  892. this$static.chunker = (encoder._needReleaseMFStream = false , (encoder._inStream = input , encoder._finished = false , $Create_2(encoder) , encoder._rangeEncoder.Stream = output , $Init_4(encoder) , $FillDistancesPrices(encoder) , $FillAlignPrices(encoder) , encoder._lenEncoder._tableSize = encoder._numFastBytes + 1 - 2 , $UpdateTables(encoder._lenEncoder, 1 << encoder._posStateBits) , encoder._repMatchLenEncoder._tableSize = encoder._numFastBytes + 1 - 2 , $UpdateTables(encoder._repMatchLenEncoder, 1 << encoder._posStateBits) , encoder.nowPos64 = P0_longLit , undefined) , $Chunker_0(new Chunker(), encoder));
  893. }
  894. function getClass_26() {
  895. return Lorg_dellroad_lzma_client_LZMACompressor_2_classLit;
  896. }
  897. function LZMACompressor() {
  898. }
  899. _ = LZMACompressor.prototype = new Object_0();
  900. _.getClass$ = getClass_26;
  901. _.typeId$ = 0;
  902. _.chunker = null;
  903. function $LZMAByteArrayCompressor(this$static, data, mode) {
  904. var $e0;
  905. this$static.output = $ByteArrayOutputStream(new ByteArrayOutputStream());
  906. try {
  907. $init(this$static, $ByteArrayInputStream(new ByteArrayInputStream(), data), this$static.output, fromInt(data.length), mode);
  908. } catch ($e0) {
  909. $e0 = caught($e0);
  910. if (instanceOf($e0, 10)) {
  911. throw $RuntimeException(new RuntimeException(), 'impossible exception');
  912. } else {
  913. throw $e0;
  914. }
  915. }
  916. return this$static;
  917. }
  918. function getClass_24() {
  919. return Lorg_dellroad_lzma_client_LZMAByteArrayCompressor_2_classLit;
  920. }
  921. function LZMAByteArrayCompressor() {
  922. }
  923. _ = LZMAByteArrayCompressor.prototype = new LZMACompressor();
  924. _.getClass$ = getClass_24;
  925. _.typeId$ = 0;
  926. _.output = null;
  927. function $execute_0(this$static) {
  928. var $e0, e;
  929. try {
  930. return $processChunk(this$static.chunker);
  931. }
  932. catch ($e0) {
  933. $e0 = caught($e0);
  934. if (instanceOf($e0, 10)) {
  935. e = $e0;
  936. this$static.exception = e;
  937. return false;
  938. } else {
  939. throw $e0;
  940. }
  941. }
  942. }
  943. function $init_0(this$static, input, output) {
  944. var decoder,
  945. hex_length = "",
  946. i,
  947. properties,
  948. r,
  949. tmp_length;
  950. properties = initDim(_3B_classLit, 0, -1, 5, 1);
  951. for (i = 0; i < properties.length; ++i) {
  952. r = $read(input);
  953. if (r == -1)
  954. throw $IOException(new IOException(), 'truncated input');
  955. properties[i] = r << 24 >> 24;
  956. }
  957. decoder = $Decoder(new Decoder());
  958. if (!$SetDecoderProperties(decoder, properties))
  959. throw $IOException(new IOException(), 'corrupted input');
  960. for (i = 0; i < 64; i += 8) {
  961. r = $read(input);
  962. if (r == -1)
  963. throw $IOException(new IOException(), 'truncated input');
  964. r = r.toString(16);
  965. if (r.length == 1) r = "0" + r;
  966. hex_length = r + "" + hex_length;
  967. }
  968. /// Was the length set in the header (if it was compressed from a stream, the length is all f's).
  969. if (hex_length.toLowerCase() == "ffffffffffffffffff" || hex_length == 0) {
  970. /// The length is unknown, so set to -1.
  971. this$static.length_0 = N1_longLit;
  972. } else {
  973. ///NOTE: If there is a problem with the decoder because of the length, you can always set the length to -1 (N1_longLit) which means unknown.
  974. tmp_length = parseInt(hex_length, 16);
  975. /// If the length is too long to handle, just set it to unknown.
  976. if (tmp_length > 4294967295) {
  977. this$static.length_0 = N1_longLit;
  978. } else {
  979. this$static.length_0 = fromDouble(tmp_length);
  980. }
  981. }
  982. this$static.chunker = $CodeInChunks(decoder, input, output, this$static.length_0);
  983. }
  984. function getClass_27() {
  985. return Lorg_dellroad_lzma_client_LZMADecompressor_2_classLit;
  986. }
  987. function LZMADecompressor() {
  988. }
  989. _ = LZMADecompressor.prototype = new Object_0();
  990. _.getClass$ = getClass_27;
  991. _.typeId$ = 0;
  992. _.chunker = null;
  993. _.exception = null;
  994. _.length_0 = P0_longLit;
  995. function $LZMAByteArrayDecompressor(this$static, data) {
  996. this$static.output = $ByteArrayOutputStream(new ByteArrayOutputStream());
  997. $init_0(this$static, $ByteArrayInputStream(new ByteArrayInputStream(), data), this$static.output);
  998. return this$static;
  999. }
  1000. function getClass_25() {
  1001. return Lorg_dellroad_lzma_client_LZMAByteArrayDecompressor_2_classLit;
  1002. }
  1003. function LZMAByteArrayDecompressor() {
  1004. }
  1005. _ = LZMAByteArrayDecompressor.prototype = new LZMADecompressor();
  1006. _.getClass$ = getClass_25;
  1007. _.typeId$ = 0;
  1008. _.output = null;
  1009. function $Create_4(this$static, keepSizeBefore, keepSizeAfter, keepSizeReserv) {
  1010. var blockSize;
  1011. this$static._keepSizeBefore = keepSizeBefore;
  1012. this$static._keepSizeAfter = keepSizeAfter;
  1013. blockSize = keepSizeBefore + keepSizeAfter + keepSizeReserv;
  1014. if (this$static._bufferBase == null || this$static._blockSize != blockSize) {
  1015. this$static._bufferBase = null;
  1016. this$static._blockSize = blockSize;
  1017. this$static._bufferBase = initDim(_3B_classLit, 0, -1, this$static._blockSize, 1);
  1018. }
  1019. this$static._pointerToLastSafePosition = this$static._blockSize - keepSizeAfter;
  1020. }
  1021. function $GetIndexByte(this$static, index) {
  1022. return this$static._bufferBase[this$static._bufferOffset + this$static._pos + index];
  1023. }
  1024. function $GetMatchLen(this$static, index, distance, limit) {
  1025. var i, pby;
  1026. if (this$static._streamEndWasReached) {
  1027. if (this$static._pos + index + limit > this$static._streamPos) {
  1028. limit = this$static._streamPos - (this$static._pos + index);
  1029. }
  1030. }
  1031. ++distance;
  1032. pby = this$static._bufferOffset + this$static._pos + index;
  1033. for (i = 0; i < limit && this$static._bufferBase[pby + i] == this$static._bufferBase[pby + i - distance]; ++i) {
  1034. }
  1035. return i;
  1036. }
  1037. function $GetNumAvailableBytes(this$static) {
  1038. return this$static._streamPos - this$static._pos;
  1039. }
  1040. function $MoveBlock(this$static) {
  1041. var i, numBytes, offset;
  1042. offset = this$static._bufferOffset + this$static._pos - this$static._keepSizeBefore;
  1043. if (offset > 0) {
  1044. --offset;
  1045. }
  1046. numBytes = this$static._bufferOffset + this$static._streamPos - offset;
  1047. for (i = 0; i < numBytes; ++i) {
  1048. this$static._bufferBase[i] = this$static._bufferBase[offset + i];
  1049. }
  1050. this$static._bufferOffset -= offset;
  1051. }
  1052. function $MovePos_1(this$static) {
  1053. var pointerToPostion;
  1054. ++this$static._pos;
  1055. if (this$static._pos > this$static._posLimit) {
  1056. pointerToPostion = this$static._bufferOffset + this$static._pos;
  1057. if (pointerToPostion > this$static._pointerToLastSafePosition) {
  1058. $MoveBlock(this$static);
  1059. }
  1060. $ReadBlock(this$static);
  1061. }
  1062. }
  1063. function $ReadBlock(this$static) {
  1064. var numReadBytes, pointerToPostion, size;
  1065. if (this$static._streamEndWasReached)
  1066. return;
  1067. while (true) {
  1068. size = -this$static._bufferOffset + this$static._blockSize - this$static._streamPos;
  1069. if (size == 0)
  1070. return;
  1071. numReadBytes = $read_0(this$static._stream, this$static._bufferBase, this$static._bufferOffset + this$static._streamPos, size);
  1072. if (numReadBytes == -1) {
  1073. this$static._posLimit = this$static._streamPos;
  1074. pointerToPostion = this$static._bufferOffset + this$static._posLimit;
  1075. if (pointerToPostion > this$static._pointerToLastSafePosition) {
  1076. this$static._posLimit = this$static._pointerToLastSafePosition - this$static._bufferOffset;
  1077. }
  1078. this$static._streamEndWasReached = true;
  1079. return;
  1080. }
  1081. this$static._streamPos += numReadBytes;
  1082. if (this$static._streamPos >= this$static._pos + this$static._keepSizeAfter) {
  1083. this$static._posLimit = this$static._streamPos - this$static._keepSizeAfter;
  1084. }
  1085. }
  1086. }
  1087. function $ReduceOffsets(this$static, subValue) {
  1088. this$static._bufferOffset += subValue;
  1089. this$static._posLimit -= subValue;
  1090. this$static._pos -= subValue;
  1091. this$static._streamPos -= subValue;
  1092. }
  1093. function getClass_40() {
  1094. return Lorg_dellroad_lzma_client_SevenZip_Compression_LZ_InWindow_2_classLit;
  1095. }
  1096. function InWindow() {
  1097. }
  1098. _ = InWindow.prototype = new Object_0();
  1099. _.getClass$ = getClass_40;
  1100. _.typeId$ = 0;
  1101. _._blockSize = 0;
  1102. _._bufferBase = null;
  1103. _._bufferOffset = 0;
  1104. _._keepSizeAfter = 0;
  1105. _._keepSizeBefore = 0;
  1106. _._pointerToLastSafePosition = 0;
  1107. _._pos = 0;
  1108. _._posLimit = 0;
  1109. _._stream = null;
  1110. _._streamEndWasReached = false;
  1111. _._streamPos = 0;
  1112. function $clinit_60() {
  1113. $clinit_60 = nullMethod;
  1114. var i, j, r;
  1115. CrcTable = initDim(_3I_classLit, 0, -1, 256, 1);
  1116. for (i = 0; i < 256; ++i) {
  1117. r = i;
  1118. for (j = 0; j < 8; ++j)
  1119. if ((r & 1) != 0) {
  1120. r = r >>> 1 ^ -306674912;
  1121. } else {
  1122. r >>>= 1;
  1123. }
  1124. CrcTable[i] = r;
  1125. }
  1126. }
  1127. function $Create_3(this$static, historySize, keepAddBufferBefore, matchMaxLen, keepAddBufferAfter) {
  1128. var cyclicBufferSize, hs, windowReservSize;
  1129. if (historySize > 1073741567) {
  1130. return false;
  1131. }
  1132. this$static._cutValue = 16 + (matchMaxLen >> 1);
  1133. windowReservSize = ~~((historySize + keepAddBufferBefore + matchMaxLen + keepAddBufferAfter) / 2) + 256;
  1134. $Create_4(this$static, historySize + keepAddBufferBefore, matchMaxLen + keepAddBufferAfter, windowReservSize);
  1135. this$static._matchMaxLen = matchMaxLen;
  1136. cyclicBufferSize = historySize + 1;
  1137. if (this$static._cyclicBufferSize != cyclicBufferSize) {
  1138. this$static._son = initDim(_3I_classLit, 0, -1, (this$static._cyclicBufferSize = cyclicBufferSize) * 2, 1);
  1139. }
  1140. hs = 65536;
  1141. if (this$static.HASH_ARRAY) {
  1142. hs = historySize - 1;
  1143. hs |= hs >> 1;
  1144. hs |= hs >> 2;
  1145. hs |= hs >> 4;
  1146. hs |= hs >> 8;
  1147. hs >>= 1;
  1148. hs |= 65535;
  1149. if (hs > 16777216)
  1150. hs >>= 1;
  1151. this$static._hashMask = hs;
  1152. ++hs;
  1153. hs += this$static.kFixHashSize;
  1154. }
  1155. if (hs != this$static._hashSizeSum) {
  1156. this$static._hash = initDim(_3I_classLit, 0, -1, this$static._hashSizeSum = hs, 1);
  1157. }
  1158. return true;
  1159. }
  1160. function $GetMatches(this$static, distances) {
  1161. var count, cur, curMatch, curMatch2, curMatch3, cyclicPos, delta, hash2Value, hash3Value, hashValue, len, len0, len1, lenLimit, matchMinPos, maxLen, offset, pby1, ptr0, ptr1, temp;
  1162. if (this$static._pos + this$static._matchMaxLen <= this$static._streamPos) {
  1163. lenLimit = this$static._matchMaxLen;
  1164. } else {
  1165. lenLimit = this$static._streamPos - this$static._pos;
  1166. if (lenLimit < this$static.kMinMatchCheck) {
  1167. $MovePos_0(this$static);
  1168. return 0;
  1169. }
  1170. }
  1171. offset = 0;
  1172. matchMinPos = this$static._pos > this$static._cyclicBufferSize?this$static._pos - this$static._cyclicBufferSize:0;
  1173. cur = this$static._bufferOffset + this$static._pos;
  1174. maxLen = 1;
  1175. hash2Value = 0;
  1176. hash3Value = 0;
  1177. if (this$static.HASH_ARRAY) {
  1178. temp = CrcTable[this$static._bufferBase[cur] & 255] ^ this$static._bufferBase[cur + 1] & 255;
  1179. hash2Value = temp & 1023;
  1180. temp ^= (this$static._bufferBase[cur + 2] & 255) << 8;
  1181. hash3Value = temp & 65535;
  1182. hashValue = (temp ^ CrcTable[this$static._bufferBase[cur + 3] & 255] << 5) & this$static._hashMask;
  1183. } else {
  1184. hashValue = this$static._bufferBase[cur] & 255 ^ (this$static._bufferBase[cur + 1] & 255) << 8;
  1185. }
  1186. curMatch = this$static._hash[this$static.kFixHashSize + hashValue];
  1187. if (this$static.HASH_ARRAY) {
  1188. curMatch2 = this$static._hash[hash2Value];
  1189. curMatch3 = this$static._hash[1024 + hash3Value];
  1190. this$static._hash[hash2Value] = this$static._pos;
  1191. this$static._hash[1024 + hash3Value] = this$static._pos;
  1192. if (curMatch2 > matchMinPos) {
  1193. if (this$static._bufferBase[this$static._bufferOffset + curMatch2] == this$static._bufferBase[cur]) {
  1194. distances[offset++] = maxLen = 2;
  1195. distances[offset++] = this$static._pos - curMatch2 - 1;
  1196. }
  1197. }
  1198. if (curMatch3 > matchMinPos) {
  1199. if (this$static._bufferBase[this$static._bufferOffset + curMatch3] == this$static._bufferBase[cur]) {
  1200. if (curMatch3 == curMatch2) {
  1201. offset -= 2;
  1202. }
  1203. distances[offset++] = maxLen = 3;
  1204. distances[offset++] = this$static._pos - curMatch3 - 1;
  1205. curMatch2 = curMatch3;
  1206. }
  1207. }
  1208. if (offset != 0 && curMatch2 == curMatch) {
  1209. offset -= 2;
  1210. maxLen = 1;
  1211. }
  1212. }
  1213. this$static._hash[this$static.kFixHashSize + hashValue] = this$static._pos;
  1214. ptr0 = (this$static._cyclicBufferPos << 1) + 1;
  1215. ptr1 = this$static._cyclicBufferPos << 1;
  1216. len0 = len1 = this$static.kNumHashDirectBytes;
  1217. if (this$static.kNumHashDirectBytes != 0) {
  1218. if (curMatch > matchMinPos) {
  1219. if (this$static._bufferBase[this$static._bufferOffset + curMatch + this$static.kNumHashDirectBytes] != this$static._bufferBase[cur + this$static.kNumHashDirectBytes]) {
  1220. distances[offset++] = maxLen = this$static.kNumHashDirectBytes;
  1221. distances[offset++] = this$static._pos - curMatch - 1;
  1222. }
  1223. }
  1224. }
  1225. count = this$static._cutValue;
  1226. while (true) {
  1227. if (curMatch <= matchMinPos || count-- == 0) {
  1228. this$static._son[ptr0] = this$static._son[ptr1] = 0;
  1229. break;
  1230. }
  1231. delta = this$static._pos - curMatch;
  1232. cyclicPos = (delta <= this$static._cyclicBufferPos?this$static._cyclicBufferPos - delta:this$static._cyclicBufferPos - delta + this$static._cyclicBufferSize) << 1;
  1233. pby1 = this$static._bufferOffset + curMatch;
  1234. len = len0 < len1?len0:len1;
  1235. if (this$static._bufferBase[pby1 + len] == this$static._bufferBase[cur + len]) {
  1236. while (++len != lenLimit) {
  1237. if (this$static._bufferBase[pby1 + len] != this$static._bufferBase[cur + len]) {
  1238. break;
  1239. }
  1240. }
  1241. if (maxLen < len) {
  1242. distances[offset++] = maxLen = len;
  1243. distances[offset++] = delta - 1;
  1244. if (len == lenLimit) {
  1245. this$static._son[ptr1] = this$static._son[cyclicPos];
  1246. this$static._son[ptr0] = this$static._son[cyclicPos + 1];
  1247. break;
  1248. }
  1249. }
  1250. }
  1251. if ((this$static._bufferBase[pby1 + len] & 255) < (this$static._bufferBase[cur + len] & 255)) {
  1252. this$static._son[ptr1] = curMatch;
  1253. ptr1 = cyclicPos + 1;
  1254. curMatch = this$static._son[ptr1];
  1255. len1 = len;
  1256. } else {
  1257. this$static._son[ptr0] = curMatch;
  1258. ptr0 = cyclicPos;
  1259. curMatch = this$static._son[ptr0];
  1260. len0 = len;
  1261. }
  1262. }
  1263. $MovePos_0(this$static);
  1264. return offset;
  1265. }
  1266. function $Init_5(this$static) {
  1267. var i;
  1268. this$static._bufferOffset = 0;
  1269. this$static._pos = 0;
  1270. this$static._streamPos = 0;
  1271. this$static._streamEndWasReached = false;
  1272. $ReadBlock(this$static);
  1273. for (i = 0; i < this$static._hashSizeSum; ++i) {
  1274. this$static._hash[i] = 0;
  1275. }
  1276. this$static._cyclicBufferPos = 0;
  1277. $ReduceOffsets(this$static, -1);
  1278. }
  1279. function $MovePos_0(this$static) {
  1280. var subValue;
  1281. if (++this$static._cyclicBufferPos >= this$static._cyclicBufferSize) {
  1282. this$static._cyclicBufferPos = 0;
  1283. }
  1284. $MovePos_1(this$static);
  1285. if (this$static._pos == 1073741823) {
  1286. subValue = this$static._pos - this$static._cyclicBufferSize;
  1287. $NormalizeLinks(this$static._son, this$static._cyclicBufferSize * 2, subValue);
  1288. $NormalizeLinks(this$static._hash, this$static._hashSizeSum, subValue);
  1289. $ReduceOffsets(this$static, subValue);
  1290. }
  1291. }
  1292. function $NormalizeLinks(items, numItems, subValue) {
  1293. var i, value;
  1294. for (i = 0; i < numItems; ++i) {
  1295. value = items[i];
  1296. if (value <= subValue) {
  1297. value = 0;
  1298. } else {
  1299. value -= subValue;
  1300. }
  1301. items[i] = value;
  1302. }
  1303. }
  1304. function $SetType(this$static, numHashBytes) {
  1305. this$static.HASH_ARRAY = numHashBytes > 2;
  1306. if (this$static.HASH_ARRAY) {
  1307. this$static.kNumHashDirectBytes = 0;
  1308. this$static.kMinMatchCheck = 4;
  1309. this$static.kFixHashSize = 66560;
  1310. } else {
  1311. this$static.kNumHashDirectBytes = 2;
  1312. this$static.kMinMatchCheck = 3;
  1313. this$static.kFixHashSize = 0;
  1314. }
  1315. }
  1316. function $Skip(this$static, num) {
  1317. var count, cur, curMatch, cyclicPos, delta, hash2Value, hash3Value, hashValue, len, len0, len1, lenLimit, matchMinPos, pby1, ptr0, ptr1, temp;
  1318. do {
  1319. if (this$static._pos + this$static._matchMaxLen <= this$static._streamPos) {
  1320. lenLimit = this$static._matchMaxLen;
  1321. } else {
  1322. lenLimit = this$static._streamPos - this$static._pos;
  1323. if (lenLimit < this$static.kMinMatchCheck) {
  1324. $MovePos_0(this$static);
  1325. continue;
  1326. }
  1327. }
  1328. matchMinPos = this$static._pos > this$static._cyclicBufferSize?this$static._pos - this$static._cyclicBufferSize:0;
  1329. cur = this$static._bufferOffset + this$static._pos;
  1330. if (this$static.HASH_ARRAY) {
  1331. temp = CrcTable[this$static._bufferBase[cur] & 255] ^ this$static._bufferBase[cur + 1] & 255;
  1332. hash2Value = temp & 1023;
  1333. this$static._hash[hash2Value] = this$static._pos;
  1334. temp ^= (this$static._bufferBase[cur + 2] & 255) << 8;
  1335. hash3Value = temp & 65535;
  1336. this$static._hash[1024 + hash3Value] = this$static._pos;
  1337. hashValue = (temp ^ CrcTable[this$static._bufferBase[cur + 3] & 255] << 5) & this$static._hashMask;
  1338. } else {
  1339. hashValue = this$static._bufferBase[cur] & 255 ^ (this$static._bufferBase[cur + 1] & 255) << 8;
  1340. }
  1341. curMatch = this$static._hash[this$static.kFixHashSize + hashValue];
  1342. this$static._hash[this$static.kFixHashSize + hashValue] = this$static._pos;
  1343. ptr0 = (this$static._cyclicBufferPos << 1) + 1;
  1344. ptr1 = this$static._cyclicBufferPos << 1;
  1345. len0 = len1 = this$static.kNumHashDirectBytes;
  1346. count = this$static._cutValue;
  1347. while (true) {
  1348. if (curMatch <= matchMinPos || count-- == 0) {
  1349. this$static._son[ptr0] = this$static._son[ptr1] = 0;
  1350. break;
  1351. }
  1352. delta = this$static._pos - curMatch;
  1353. cyclicPos = (delta <= this$static._cyclicBufferPos?this$static._cyclicBufferPos - delta:this$static._cyclicBufferPos - delta + this$static._cyclicBufferSize) << 1;
  1354. pby1 = this$static._bufferOffset + curMatch;
  1355. len = len0 < len1?len0:len1;
  1356. if (this$static._bufferBase[pby1 + len] == this$static._bufferBase[cur + len]) {
  1357. while (++len != lenLimit) {
  1358. if (this$static._bufferBase[pby1 + len] != this$static._bufferBase[cur + len]) {
  1359. break;
  1360. }
  1361. }
  1362. if (len == lenLimit) {
  1363. this$static._son[ptr1] = this$static._son[cyclicPos];
  1364. this$static._son[ptr0] = this$static._son[cyclicPos + 1];
  1365. break;
  1366. }
  1367. }
  1368. if ((this$static._bufferBase[pby1 + len] & 255) < (this$static._bufferBase[cur + len] & 255)) {
  1369. this$static._son[ptr1] = curMatch;
  1370. ptr1 = cyclicPos + 1;
  1371. curMatch = this$static._son[ptr1];
  1372. len1 = len;
  1373. } else {
  1374. this$static._son[ptr0] = curMatch;
  1375. ptr0 = cyclicPos;
  1376. curMatch = this$static._son[ptr0];
  1377. len0 = len;
  1378. }
  1379. }
  1380. $MovePos_0(this$static);
  1381. }
  1382. while (--num != 0);
  1383. }
  1384. function getClass_39() {
  1385. return Lorg_dellroad_lzma_client_SevenZip_Compression_LZ_BinTree_2_classLit;
  1386. }
  1387. function BinTree() {
  1388. }
  1389. _ = BinTree.prototype = new InWindow();
  1390. _.getClass$ = getClass_39;
  1391. _.typeId$ = 0;
  1392. _.HASH_ARRAY = true;
  1393. _._cutValue = 255;
  1394. _._cyclicBufferPos = 0;
  1395. _._cyclicBufferSize = 0;
  1396. _._hash = null;
  1397. _._hashMask = 0;
  1398. _._hashSizeSum = 0;
  1399. _._matchMaxLen = 0;
  1400. _._son = null;
  1401. _.kFixHashSize = 66560;
  1402. _.kMinMatchCheck = 4;
  1403. _.kNumHashDirectBytes = 0;
  1404. var CrcTable;
  1405. function $CopyBlock(this$static, distance, len) {
  1406. var pos;
  1407. pos = this$static._pos - distance - 1;
  1408. if (pos < 0) {
  1409. pos += this$static._windowSize;
  1410. }
  1411. for (; len != 0; --len) {
  1412. if (pos >= this$static._windowSize) {
  1413. pos = 0;
  1414. }
  1415. this$static._buffer[this$static._pos++] = this$static._buffer[pos++];
  1416. if (this$static._pos >= this$static._windowSize) {
  1417. $Flush_0(this$static);
  1418. }
  1419. }
  1420. }
  1421. function $Create_5(this$static, windowSize) {
  1422. if (this$static._buffer == null || this$static._windowSize != windowSize) {
  1423. this$static._buffer = initDim(_3B_classLit, 0, -1, windowSize, 1);
  1424. }
  1425. this$static._windowSize = windowSize;
  1426. this$static._pos = 0;
  1427. this$static._streamPos = 0;
  1428. }
  1429. function $Flush_0(this$static) {
  1430. var size;
  1431. size = this$static._pos - this$static._streamPos;
  1432. if (size == 0) {
  1433. return;
  1434. }
  1435. $write_0(this$static._stream, this$static._buffer, this$static._streamPos, size);
  1436. if (this$static._pos >= this$static._windowSize) {
  1437. this$static._pos = 0;
  1438. }
  1439. this$static._streamPos = this$static._pos;
  1440. }
  1441. function $GetByte(this$static, distance) {
  1442. var pos;
  1443. pos = this$static._pos - distance - 1;
  1444. if (pos < 0) {
  1445. pos += this$static._windowSize;
  1446. }
  1447. return this$static._buffer[pos];
  1448. }
  1449. function $Init_7(this$static, solid) {
  1450. if (!solid) {
  1451. this$static._streamPos = 0;
  1452. this$static._pos = 0;
  1453. }
  1454. }
  1455. function $PutByte(this$static, b) {
  1456. this$static._buffer[this$static._pos++] = b;
  1457. if (this$static._pos >= this$static._windowSize) {
  1458. $Flush_0(this$static);
  1459. }
  1460. }
  1461. function $ReleaseStream(this$static) {
  1462. $Flush_0(this$static);
  1463. this$static._stream = null;
  1464. }
  1465. function $SetStream_0(this$static, stream) {
  1466. $Flush_0(this$static);
  1467. this$static._stream = null;
  1468. this$static._stream = stream;
  1469. }
  1470. function getClass_41() {
  1471. return Lorg_dellroad_lzma_client_SevenZip_Compression_LZ_OutWindow_2_classLit;
  1472. }
  1473. function OutWindow() {
  1474. }
  1475. _ = OutWindow.prototype = new Object_0();
  1476. _.getClass$ = getClass_41;
  1477. _.typeId$ = 0;
  1478. _._buffer = null;
  1479. _._pos = 0;
  1480. _._stream = null;
  1481. _._streamPos = 0;
  1482. _._windowSize = 0;
  1483. function GetLenToPosState(len) {
  1484. len -= 2;
  1485. if (len < 4) {
  1486. return len;
  1487. }
  1488. return 3;
  1489. }
  1490. function StateUpdateChar(index) {
  1491. if (index < 4) {
  1492. return 0;
  1493. }
  1494. if (index < 10) {
  1495. return index - 3;
  1496. }
  1497. return index - 6;
  1498. }
  1499. function $Chunker_0(this$static, encoder) {
  1500. this$static.encoder = encoder;
  1501. this$static.decoder = null;
  1502. this$static.alive = true;
  1503. return this$static;
  1504. }
  1505. function $Chunker(this$static, decoder) {
  1506. this$static.decoder = decoder;
  1507. this$static.encoder = null;
  1508. this$static.alive = true;
  1509. return this$static;
  1510. }
  1511. function $processChunk(this$static) {
  1512. var exception;
  1513. if (!this$static.alive) {
  1514. throw new IllegalStateException();
  1515. }
  1516. exception = true;
  1517. try {
  1518. if (this$static.encoder) {
  1519. $processEncoderChunk(this$static);
  1520. } else {
  1521. $processDecoderChunk(this$static);
  1522. }
  1523. exception = false;
  1524. return this$static.alive;
  1525. } finally {
  1526. if (exception) {
  1527. this$static.alive = false;
  1528. }
  1529. }
  1530. }
  1531. function $processDecoderChunk(this$static) {
  1532. var result;
  1533. result = $CodeOneChunk(this$static.decoder);
  1534. if (result == -1) {
  1535. throw $IOException(new IOException(), 'corrupted input');
  1536. }
  1537. this$static.inBytesProcessed = N1_longLit;
  1538. this$static.outBytesProcessed = this$static.decoder.nowPos64;
  1539. if (result == 1 || compare(this$static.decoder.outSize, P0_longLit) >= 0 && compare(this$static.decoder.nowPos64, this$static.decoder.outSize) >= 0) {
  1540. $CodeFinish(this$static.decoder);
  1541. this$static.alive = false;
  1542. }
  1543. }
  1544. function $processEncoderChunk(this$static) {
  1545. $CodeOneBlock(this$static.encoder, this$static.encoder.processedInSize, this$static.encoder.processedOutSize, this$static.encoder.finished);
  1546. this$static.inBytesProcessed = this$static.encoder.processedInSize[0];
  1547. if (this$static.encoder.finished[0]) {
  1548. $ReleaseStreams(this$static.encoder);
  1549. this$static.alive = false;
  1550. }
  1551. }
  1552. function getClass_28() {
  1553. return Lorg_dellroad_lzma_client_SevenZip_Compression_LZMA_Chunker_2_classLit;
  1554. }
  1555. function Chunker() {
  1556. }
  1557. _ = Chunker.prototype = new Object_0();
  1558. _.getClass$ = getClass_28;
  1559. _.typeId$ = 0;
  1560. _.alive = false;
  1561. _.decoder = null;
  1562. _.encoder = null;
  1563. function $CodeFinish(this$static) {
  1564. $Flush_0(this$static.m_OutWindow);
  1565. $ReleaseStream(this$static.m_OutWindow);
  1566. this$static.m_RangeDecoder.Stream = null;
  1567. }
  1568. function $CodeInChunks(this$static, inStream, outStream, outSize) {
  1569. this$static.m_RangeDecoder.Stream = inStream;
  1570. $SetStream_0(this$static.m_OutWindow, outStream);
  1571. $Init_1(this$static);
  1572. this$static.state = 0;
  1573. this$static.rep0 = 0;
  1574. this$static.rep1 = 0;
  1575. this$static.rep2 = 0;
  1576. this$static.rep3 = 0;
  1577. this$static.outSize = outSize;
  1578. this$static.nowPos64 = P0_longLit;
  1579. this$static.prevByte = 0;
  1580. return $Chunker(new Chunker(), this$static);
  1581. }
  1582. function $CodeOneChunk(this$static) {
  1583. var decoder2, distance, len, numDirectBits, posSlot, posState;
  1584. posState = lowBits_0(this$static.nowPos64) & this$static.m_PosStateMask;
  1585. if ($DecodeBit(this$static.m_RangeDecoder, this$static.m_IsMatchDecoders, (this$static.state << 4) + posState) == 0) {
  1586. decoder2 = $GetDecoder(this$static.m_LiteralDecoder, lowBits_0(this$static.nowPos64), this$static.prevByte);
  1587. if (this$static.state < 7) {
  1588. this$static.prevByte = $DecodeNormal(decoder2, this$static.m_RangeDecoder);
  1589. }
  1590. else {
  1591. this$static.prevByte = $DecodeWithMatchByte(decoder2, this$static.m_RangeDecoder, $GetByte(this$static.m_OutWindow, this$static.rep0));
  1592. }
  1593. $PutByte(this$static.m_OutWindow, this$static.prevByte);
  1594. this$static.state = StateUpdateChar(this$static.state);
  1595. this$static.nowPos64 = add(this$static.nowPos64, P1_longLit);
  1596. } else {
  1597. if ($DecodeBit(this$static.m_RangeDecoder, this$static.m_IsRepDecoders, this$static.state) == 1) {
  1598. len = 0;
  1599. if ($DecodeBit(this$static.m_RangeDecoder, this$static.m_IsRepG0Decoders, this$static.state) == 0) {
  1600. if ($DecodeBit(this$static.m_RangeDecoder, this$static.m_IsRep0LongDecoders, (this$static.state << 4) + posState) == 0) {
  1601. this$static.state = this$static.state < 7?9:11;
  1602. len = 1;
  1603. }
  1604. } else {
  1605. if ($DecodeBit(this$static.m_RangeDecoder, this$static.m_IsRepG1Decoders, this$static.state) == 0) {
  1606. distance = this$static.rep1;
  1607. } else {
  1608. if ($DecodeBit(this$static.m_RangeDecoder, this$static.m_IsRepG2Decoders, this$static.state) == 0) {
  1609. distance = this$static.rep2;
  1610. } else {
  1611. distance = this$static.rep3;
  1612. this$static.rep3 = this$static.rep2;
  1613. }
  1614. this$static.rep2 = this$static.rep1;
  1615. }
  1616. this$static.rep1 = this$static.rep0;
  1617. this$static.rep0 = distance;
  1618. }
  1619. if (len == 0) {
  1620. len = $Decode(this$static.m_RepLenDecoder, this$static.m_RangeDecoder, posState) + 2;
  1621. this$static.state = this$static.state < 7?8:11;
  1622. }
  1623. } else {
  1624. this$static.rep3 = this$static.rep2;
  1625. this$static.rep2 = this$static.rep1;
  1626. this$static.rep1 = this$static.rep0;
  1627. len = 2 + $Decode(this$static.m_LenDecoder, this$static.m_RangeDecoder, posState);
  1628. this$static.state = this$static.state < 7?7:10;
  1629. posSlot = $Decode_0(this$static.m_PosSlotDecoder[GetLenToPosState(len)], this$static.m_RangeDecoder);
  1630. if (posSlot >= 4) {
  1631. numDirectBits = (posSlot >> 1) - 1;
  1632. this$static.rep0 = (2 | posSlot & 1) << numDirectBits;
  1633. if (posSlot < 14) {
  1634. this$static.rep0 += ReverseDecode(this$static.m_PosDecoders, this$static.rep0 - posSlot - 1, this$static.m_RangeDecoder, numDirectBits);
  1635. } else {
  1636. this$static.rep0 += $DecodeDirectBits(this$static.m_RangeDecoder, numDirectBits - 4) << 4;
  1637. this$static.rep0 += $ReverseDecode(this$static.m_PosAlignDecoder, this$static.m_RangeDecoder);
  1638. if (this$static.rep0 < 0) {
  1639. if (this$static.rep0 == -1) {
  1640. return 1;
  1641. }
  1642. return -1;
  1643. }
  1644. }
  1645. } else
  1646. this$static.rep0 = posSlot;
  1647. }
  1648. if (compare(fromInt(this$static.rep0), this$static.nowPos64) >= 0 || this$static.rep0 >= this$static.m_DictionarySizeCheck) {
  1649. return -1;
  1650. }
  1651. $CopyBlock(this$static.m_OutWindow, this$static.rep0, len);
  1652. this$static.nowPos64 = add(this$static.nowPos64, fromInt(len));
  1653. this$static.prevByte = $GetByte(this$static.m_OutWindow, 0);
  1654. }
  1655. return 0;
  1656. }
  1657. function $Decoder(this$static) {
  1658. var i;
  1659. this$static.m_OutWindow = new OutWindow();
  1660. this$static.m_RangeDecoder = new Decoder_0();
  1661. this$static.m_IsMatchDecoders = initDim(_3S_classLit, 0, -1, 192, 1);
  1662. this$static.m_IsRepDecoders = initDim(_3S_classLit, 0, -1, 12, 1);
  1663. this$static.m_IsRepG0Decoders = initDim(_3S_classLit, 0, -1, 12, 1);
  1664. this$static.m_IsRepG1Decoders = initDim(_3S_classLit, 0, -1, 12, 1);
  1665. this$static.m_IsRepG2Decoders = initDim(_3S_classLit, 0, -1, 12, 1);
  1666. this$static.m_IsRep0LongDecoders = initDim(_3S_classLit, 0, -1, 192, 1);
  1667. this$static.m_PosSlotDecoder = initDim(_3Lorg_dellroad_lzma_client_SevenZip_Compression_RangeCoder_BitTreeDecoder_2_classLit, 0, 7, 4, 0);
  1668. this$static.m_PosDecoders = initDim(_3S_classLit, 0, -1, 114, 1);
  1669. this$static.m_PosAlignDecoder = $BitTreeDecoder(new BitTreeDecoder(), 4);
  1670. this$static.m_LenDecoder = $Decoder$LenDecoder(new Decoder$LenDecoder());
  1671. this$static.m_RepLenDecoder = $Decoder$LenDecoder(new Decoder$LenDecoder());
  1672. this$static.m_LiteralDecoder = new Decoder$LiteralDecoder();
  1673. for (i = 0; i < 4; ++i) {
  1674. this$static.m_PosSlotDecoder[i] = $BitTreeDecoder(new BitTreeDecoder(), 6);
  1675. }
  1676. return this$static;
  1677. }
  1678. function $Init_1(this$static) {
  1679. var i;
  1680. $Init_7(this$static.m_OutWindow, false);
  1681. InitBitModels(this$static.m_IsMatchDecoders);
  1682. InitBitModels(this$static.m_IsRep0LongDecoders);
  1683. InitBitModels(this$static.m_IsRepDecoders);
  1684. InitBitModels(this$static.m_IsRepG0Decoders);
  1685. InitBitModels(this$static.m_IsRepG1Decoders);
  1686. InitBitModels(this$static.m_IsRepG2Decoders);
  1687. InitBitModels(this$static.m_PosDecoders);
  1688. $Init_0(this$static.m_LiteralDecoder);
  1689. for (i = 0; i < 4; ++i) {
  1690. InitBitModels(this$static.m_PosSlotDecoder[i].Models);
  1691. }
  1692. $Init(this$static.m_LenDecoder);
  1693. $Init(this$static.m_RepLenDecoder);
  1694. InitBitModels(this$static.m_PosAlignDecoder.Models);
  1695. $Init_8(this$static.m_RangeDecoder);
  1696. }
  1697. function $SetDecoderProperties(this$static, properties) {
  1698. var dictionarySize, i, lc, lp, pb, remainder, val;
  1699. if (properties.length < 5)
  1700. return false;
  1701. val = properties[0] & 255;
  1702. lc = val % 9;
  1703. remainder = ~~(val / 9);
  1704. lp = remainder % 5;
  1705. pb = ~~(remainder / 5);
  1706. dictionarySize = 0;
  1707. for (i = 0; i < 4; ++i) {
  1708. dictionarySize += (properties[1 + i] & 255) << i * 8;
  1709. }
  1710. if (!$SetLcLpPb(this$static, lc, lp, pb)) {
  1711. return false;
  1712. }
  1713. return $SetDictionarySize(this$static, dictionarySize);
  1714. }
  1715. function $SetDictionarySize(this$static, dictionarySize) {
  1716. if (dictionarySize < 0) {
  1717. return false;
  1718. }
  1719. if (this$static.m_DictionarySize != dictionarySize) {
  1720. this$static.m_DictionarySize = dictionarySize;
  1721. this$static.m_DictionarySizeCheck = max(this$static.m_DictionarySize, 1);
  1722. $Create_5(this$static.m_OutWindow, max(this$static.m_DictionarySizeCheck, 4096));
  1723. }
  1724. return true;
  1725. }
  1726. function $SetLcLpPb(this$static, lc, lp, pb) {
  1727. var numPosStates;
  1728. if (lc > 8 || lp > 4 || pb > 4) {
  1729. return false;
  1730. }
  1731. $Create_0(this$static.m_LiteralDecoder, lp, lc);
  1732. numPosStates = 1 << pb;
  1733. $Create(this$static.m_LenDecoder, numPosStates);
  1734. $Create(this$static.m_RepLenDecoder, numPosStates);
  1735. this$static.m_PosStateMask = numPosStates - 1;
  1736. return true;
  1737. }
  1738. function getClass_32() {
  1739. return Lorg_dellroad_lzma_client_SevenZip_Compression_LZMA_Decoder_2_classLit;
  1740. }
  1741. function Decoder() {
  1742. }
  1743. _ = Decoder.prototype = new Object_0();
  1744. _.getClass$ = getClass_32;
  1745. _.typeId$ = 0;
  1746. _.m_DictionarySize = -1;
  1747. _.m_DictionarySizeCheck = -1;
  1748. _.m_PosStateMask = 0;
  1749. _.nowPos64 = P0_longLit;
  1750. _.outSize = P0_longLit;
  1751. _.prevByte = 0;
  1752. _.rep0 = 0;
  1753. _.rep1 = 0;
  1754. _.rep2 = 0;
  1755. _.rep3 = 0;
  1756. _.state = 0;
  1757. function $Create(this$static, numPosStates) {
  1758. for (; this$static.m_NumPosStates < numPosStates; ++this$static.m_NumPosStates) {
  1759. this$static.m_LowCoder[this$static.m_NumPosStates] = $BitTreeDecoder(new BitTreeDecoder(), 3);
  1760. this$static.m_MidCoder[this$static.m_NumPosStates] = $BitTreeDecoder(new BitTreeDecoder(), 3);
  1761. }
  1762. }
  1763. function $Decode(this$static, rangeDecoder, posState) {
  1764. var symbol;
  1765. if ($DecodeBit(rangeDecoder, this$static.m_Choice, 0) == 0) {
  1766. return $Decode_0(this$static.m_LowCoder[posState], rangeDecoder);
  1767. }
  1768. symbol = 8;
  1769. if ($DecodeBit(rangeDecoder, this$static.m_Choice, 1) == 0) {
  1770. symbol += $Decode_0(this$static.m_MidCoder[posState], rangeDecoder);
  1771. } else {
  1772. symbol += 8 + $Decode_0(this$static.m_HighCoder, rangeDecoder);
  1773. }
  1774. return symbol;
  1775. }
  1776. function $Decoder$LenDecoder(this$static) {
  1777. this$static.m_Choice = initDim(_3S_classLit, 0, -1, 2, 1);
  1778. this$static.m_LowCoder = initDim(_3Lorg_dellroad_lzma_client_SevenZip_Compression_RangeCoder_BitTreeDecoder_2_classLit, 0, 7, 16, 0);
  1779. this$static.m_MidCoder = initDim(_3Lorg_dellroad_lzma_client_SevenZip_Compression_RangeCoder_BitTreeDecoder_2_classLit, 0, 7, 16, 0);
  1780. this$static.m_HighCoder = $BitTreeDecoder(new BitTreeDecoder(), 8);
  1781. return this$static;
  1782. }
  1783. function $Init(this$static) {
  1784. var posState;
  1785. InitBitModels(this$static.m_Choice);
  1786. for (posState = 0; posState < this$static.m_NumPosStates; ++posState) {
  1787. InitBitModels(this$static.m_LowCoder[posState].Models);
  1788. InitBitModels(this$static.m_MidCoder[posState].Models);
  1789. }
  1790. InitBitModels(this$static.m_HighCoder.Models);
  1791. }
  1792. function getClass_29() {
  1793. return Lorg_dellroad_lzma_client_SevenZip_Compression_LZMA_Decoder$LenDecoder_2_classLit;
  1794. }
  1795. function Decoder$LenDecoder() {
  1796. }
  1797. _ = Decoder$LenDecoder.prototype = new Object_0();
  1798. _.getClass$ = getClass_29;
  1799. _.typeId$ = 0;
  1800. _.m_NumPosStates = 0;
  1801. function $Create_0(this$static, numPosBits, numPrevBits) {
  1802. var i, numStates;
  1803. if (this$static.m_Coders != null && this$static.m_NumPrevBits == numPrevBits && this$static.m_NumPosBits == numPosBits)
  1804. return;
  1805. this$static.m_NumPosBits = numPosBits;
  1806. this$static.m_PosMask = (1 << numPosBits) - 1;
  1807. this$static.m_NumPrevBits = numPrevBits;
  1808. numStates = 1 << this$static.m_NumPrevBits + this$static.m_NumPosBits;
  1809. this$static.m_Coders = initDim(_3Lorg_dellroad_lzma_client_SevenZip_Compression_LZMA_Decoder$LiteralDecoder$Decoder2_2_classLit, 0, 4, numStates, 0);
  1810. for (i = 0; i < numStates; ++i)
  1811. this$static.m_Coders[i] = $Decoder$LiteralDecoder$Decoder2(new Decoder$LiteralDecoder$Decoder2());
  1812. }
  1813. function $GetDecoder(this$static, pos, prevByte) {
  1814. return this$static.m_Coders[((pos & this$static.m_PosMask) << this$static.m_NumPrevBits) + ((prevByte & 255) >>> 8 - this$static.m_NumPrevBits)];
  1815. }
  1816. function $Init_0(this$static) {
  1817. var i, numStates;
  1818. numStates = 1 << this$static.m_NumPrevBits + this$static.m_NumPosBits;
  1819. for (i = 0; i < numStates; ++i) {
  1820. InitBitModels(this$static.m_Coders[i].m_Decoders);
  1821. }
  1822. }
  1823. function getClass_31() {
  1824. return Lorg_dellroad_lzma_client_SevenZip_Compression_LZMA_Decoder$LiteralDecoder_2_classLit;
  1825. }
  1826. function Decoder$LiteralDecoder() {
  1827. }
  1828. _ = Decoder$LiteralDecoder.prototype = new Object_0();
  1829. _.getClass$ = getClass_31;
  1830. _.typeId$ = 0;
  1831. _.m_Coders = null;
  1832. _.m_NumPosBits = 0;
  1833. _.m_NumPrevBits = 0;
  1834. _.m_PosMask = 0;
  1835. function $DecodeNormal(this$static, rangeDecoder) {
  1836. var symbol;
  1837. symbol = 1;
  1838. do {
  1839. symbol = symbol << 1 | $DecodeBit(rangeDecoder, this$static.m_Decoders, symbol);
  1840. } while (symbol < 256);
  1841. return symbol << 24 >> 24;
  1842. }
  1843. function $DecodeWithMatchByte(this$static, rangeDecoder, matchByte) {
  1844. var bit, matchBit, symbol;
  1845. symbol = 1;
  1846. do {
  1847. matchBit = matchByte >> 7 & 1;
  1848. matchByte <<= 1;
  1849. bit = $DecodeBit(rangeDecoder, this$static.m_Decoders, (1 + matchBit << 8) + symbol);
  1850. symbol = symbol << 1 | bit;
  1851. if (matchBit != bit) {
  1852. while (symbol < 256) {
  1853. symbol = symbol << 1 | $DecodeBit(rangeDecoder, this$static.m_Decoders, symbol);
  1854. }
  1855. break;
  1856. }
  1857. } while (symbol < 256);
  1858. return symbol << 24 >> 24;
  1859. }
  1860. function $Decoder$LiteralDecoder$Decoder2(this$static) {
  1861. this$static.m_Decoders = initDim(_3S_classLit, 0, -1, 768, 1);
  1862. return this$static;
  1863. }
  1864. function getClass_30() {
  1865. return Lorg_dellroad_lzma_client_SevenZip_Compression_LZMA_Decoder$LiteralDecoder$Decoder2_2_classLit;
  1866. }
  1867. function Decoder$LiteralDecoder$Decoder2() {
  1868. }
  1869. _ = Decoder$LiteralDecoder$Decoder2.prototype = new Object_0();
  1870. _.getClass$ = getClass_30;
  1871. _.typeId$ = 17;
  1872. function $clinit_59() {
  1873. $clinit_59 = nullMethod;
  1874. var c, j, k, slotFast;
  1875. g_FastPos = initDim(_3B_classLit, 0, -1, 2048, 1);
  1876. c = 2;
  1877. g_FastPos[0] = 0;
  1878. g_FastPos[1] = 1;
  1879. for (slotFast = 2; slotFast < 22; ++slotFast) {
  1880. k = 1 << (slotFast >> 1) - 1;
  1881. for (j = 0; j < k; ++j , ++c)
  1882. g_FastPos[c] = slotFast << 24 >> 24;
  1883. }
  1884. }
  1885. function $Backward(this$static, cur) {
  1886. var backCur, backMem, posMem, posPrev;
  1887. this$static._optimumEndIndex = cur;
  1888. posMem = this$static._optimum[cur].PosPrev;
  1889. backMem = this$static._optimum[cur].BackPrev;
  1890. do {
  1891. if (this$static._optimum[cur].Prev1IsChar) {
  1892. $MakeAsChar(this$static._optimum[posMem]);
  1893. this$static._optimum[posMem].PosPrev = posMem - 1;
  1894. if (this$static._optimum[cur].Prev2) {
  1895. this$static._optimum[posMem - 1].Prev1IsChar = false;
  1896. this$static._optimum[posMem - 1].PosPrev = this$static._optimum[cur].PosPrev2;
  1897. this$static._optimum[posMem - 1].BackPrev = this$static._optimum[cur].BackPrev2;
  1898. }
  1899. }
  1900. posPrev = posMem;
  1901. backCur = backMem;
  1902. backMem = this$static._optimum[posPrev].BackPrev;
  1903. posMem = this$static._optimum[posPrev].PosPrev;
  1904. this$static._optimum[posPrev].BackPrev = backCur;
  1905. this$static._optimum[posPrev].PosPrev = cur;
  1906. cur = posPrev;
  1907. } while (cur > 0);
  1908. this$static.backRes = this$static._optimum[0].BackPrev;
  1909. this$static._optimumCurrentIndex = this$static._optimum[0].PosPrev;
  1910. return this$static._optimumCurrentIndex;
  1911. }
  1912. function $BaseInit(this$static) {
  1913. var i;
  1914. this$static._state = 0;
  1915. this$static._previousByte = 0;
  1916. for (i = 0; i < 4; ++i) {
  1917. this$static._repDistances[i] = 0;
  1918. }
  1919. }
  1920. function $CodeOneBlock(this$static, inSize, outSize, finished) {
  1921. var baseVal, complexState, curByte, distance, footerBits, i, len, lenToPosState, matchByte, pos, posReduced, posSlot, posState, progressPosValuePrev, subCoder;
  1922. inSize[0] = P0_longLit;
  1923. outSize[0] = P0_longLit;
  1924. finished[0] = true;
  1925. if (this$static._inStream) {
  1926. this$static._matchFinder._stream = this$static._inStream;
  1927. $Init_5(this$static._matchFinder);
  1928. this$static._needReleaseMFStream = true;
  1929. this$static._inStream = null;
  1930. }
  1931. if (this$static._finished) {
  1932. return;
  1933. }
  1934. this$static._finished = true;
  1935. progressPosValuePrev = this$static.nowPos64;
  1936. if (eq(this$static.nowPos64, P0_longLit)) {
  1937. if ($GetNumAvailableBytes(this$static._matchFinder) == 0) {
  1938. $Flush(this$static, lowBits_0(this$static.nowPos64));
  1939. return;
  1940. }
  1941. $ReadMatchDistances(this$static);
  1942. posState = lowBits_0(this$static.nowPos64) & this$static._posStateMask;
  1943. $Encode_3(this$static._rangeEncoder, this$static._isMatch, (this$static._state << 4) + posState, 0);
  1944. this$static._state = StateUpdateChar(this$static._state);
  1945. curByte = $GetIndexByte(this$static._matchFinder, -this$static._additionalOffset);
  1946. $Encode_1($GetSubCoder(this$static._literalEncoder, lowBits_0(this$static.nowPos64), this$static._previousByte), this$static._rangeEncoder, curByte);
  1947. this$static._previousByte = curByte;
  1948. --this$static._additionalOffset;
  1949. this$static.nowPos64 = add(this$static.nowPos64, P1_longLit);
  1950. }
  1951. if ($GetNumAvailableBytes(this$static._matchFinder) == 0) {
  1952. $Flush(this$static, lowBits_0(this$static.nowPos64));
  1953. return;
  1954. }
  1955. while (true) {
  1956. len = $GetOptimum(this$static, lowBits_0(this$static.nowPos64));
  1957. pos = this$static.backRes;
  1958. posState = lowBits_0(this$static.nowPos64) & this$static._posStateMask;
  1959. complexState = (this$static._state << 4) + posState;
  1960. if (len == 1 && pos == -1) {
  1961. $Encode_3(this$static._rangeEncoder, this$static._isMatch, complexState, 0);
  1962. curByte = $GetIndexByte(this$static._matchFinder, -this$static._additionalOffset);
  1963. subCoder = $GetSubCoder(this$static._literalEncoder, lowBits_0(this$static.nowPos64), this$static._previousByte);
  1964. if (this$static._state < 7) {
  1965. $Encode_1(subCoder, this$static._rangeEncoder, curByte);
  1966. } else {
  1967. matchByte = $GetIndexByte(this$static._matchFinder, -this$static._repDistances[0] - 1 - this$static._additionalOffset);
  1968. $EncodeMatched(subCoder, this$static._rangeEncoder, matchByte, curByte);
  1969. }
  1970. this$static._previousByte = curByte;
  1971. this$static._state = StateUpdateChar(this$static._state);
  1972. } else {
  1973. $Encode_3(this$static._rangeEncoder, this$static._isMatch, complexState, 1);
  1974. if (pos < 4) {
  1975. $Encode_3(this$static._rangeEncoder, this$static._isRep, this$static._state, 1);
  1976. if (pos == 0) {
  1977. $Encode_3(this$static._rangeEncoder, this$static._isRepG0, this$static._state, 0);
  1978. if (len == 1) {
  1979. $Encode_3(this$static._rangeEncoder, this$static._isRep0Long, complexState, 0);
  1980. } else {
  1981. $Encode_3(this$static._rangeEncoder, this$static._isRep0Long, complexState, 1);
  1982. }
  1983. } else {
  1984. $Encode_3(this$static._rangeEncoder, this$static._isRepG0, this$static._state, 1);
  1985. if (pos == 1) {
  1986. $Encode_3(this$static._rangeEncoder, this$static._isRepG1, this$static._state, 0);
  1987. } else {
  1988. $Encode_3(this$static._rangeEncoder, this$static._isRepG1, this$static._state, 1);
  1989. $Encode_3(this$static._rangeEncoder, this$static._isRepG2, this$static._state, pos - 2);
  1990. }
  1991. }
  1992. if (len == 1) {
  1993. this$static._state = this$static._state < 7?9:11;
  1994. } else {
  1995. $Encode_0(this$static._repMatchLenEncoder, this$static._rangeEncoder, len - 2, posState);
  1996. this$static._state = this$static._state < 7?8:11;
  1997. }
  1998. distance = this$static._repDistances[pos];
  1999. if (pos != 0) {
  2000. for (i = pos; i >= 1; --i) {
  2001. this$static._repDistances[i] = this$static._repDistances[i - 1];
  2002. }
  2003. this$static._repDistances[0] = distance;
  2004. }
  2005. } else {
  2006. $Encode_3(this$static._rangeEncoder, this$static._isRep, this$static._state, 0);
  2007. this$static._state = this$static._state < 7?7:10;
  2008. $Encode_0(this$static._lenEncoder, this$static._rangeEncoder, len - 2, posState);
  2009. pos -= 4;
  2010. posSlot = GetPosSlot(pos);
  2011. lenToPosState = GetLenToPosState(len);
  2012. $Encode_2(this$static._posSlotEncoder[lenToPosState], this$static._rangeEncoder, posSlot);
  2013. if (posSlot >= 4) {
  2014. footerBits = (posSlot >> 1) - 1;
  2015. baseVal = (2 | posSlot & 1) << footerBits;
  2016. posReduced = pos - baseVal;
  2017. if (posSlot < 14) {
  2018. ReverseEncode(this$static._posEncoders, baseVal - posSlot - 1, this$static._rangeEncoder, footerBits, posReduced);
  2019. } else {
  2020. $EncodeDirectBits(this$static._rangeEncoder, posReduced >> 4, footerBits - 4);
  2021. $ReverseEncode(this$static._posAlignEncoder, this$static._rangeEncoder, posReduced & 15);
  2022. ++this$static._alignPriceCount;
  2023. }
  2024. }
  2025. distance = pos;
  2026. for (i = 3; i >= 1; --i) {
  2027. this$static._repDistances[i] = this$static._repDistances[i - 1];
  2028. }
  2029. this$static._repDistances[0] = distance;
  2030. ++this$static._matchPriceCount;
  2031. }
  2032. this$static._previousByte = $GetIndexByte(this$static._matchFinder, len - 1 - this$static._additionalOffset);
  2033. }
  2034. this$static._additionalOffset -= len;
  2035. this$static.nowPos64 = add(this$static.nowPos64, fromInt(len));
  2036. if (this$static._additionalOffset == 0) {
  2037. if (this$static._matchPriceCount >= 128) {
  2038. $FillDistancesPrices(this$static);
  2039. }
  2040. if (this$static._alignPriceCount >= 16) {
  2041. $FillAlignPrices(this$static);
  2042. }
  2043. inSize[0] = this$static.nowPos64;
  2044. outSize[0] = $GetProcessedSizeAdd(this$static._rangeEncoder);
  2045. if ($GetNumAvailableBytes(this$static._matchFinder) == 0) {
  2046. $Flush(this$static, lowBits_0(this$static.nowPos64));
  2047. return;
  2048. }
  2049. if (compare(sub(this$static.nowPos64, progressPosValuePrev), P1000_longLit) >= 0) {
  2050. this$static._finished = false;
  2051. finished[0] = false;
  2052. return;
  2053. }
  2054. }
  2055. }
  2056. }
  2057. function $Create_2(this$static) {
  2058. var bt, numHashBytes;
  2059. if (!this$static._matchFinder) {
  2060. bt = ($clinit_60() , new BinTree());
  2061. numHashBytes = 4;
  2062. if (this$static._matchFinderType == 0) {
  2063. numHashBytes = 2;
  2064. }
  2065. $SetType(bt, numHashBytes);
  2066. this$static._matchFinder = bt;
  2067. }
  2068. $Create_1(this$static._literalEncoder, this$static._numLiteralPosStateBits, this$static._numLiteralContextBits);
  2069. if (this$static._dictionarySize == this$static._dictionarySizePrev && this$static._numFastBytesPrev == this$static._numFastBytes) {
  2070. return;
  2071. }
  2072. $Create_3(this$static._matchFinder, this$static._dictionarySize, 4096, this$static._numFastBytes, 274);
  2073. this$static._dictionarySizePrev = this$static._dictionarySize;
  2074. this$static._numFastBytesPrev = this$static._numFastBytes;
  2075. }
  2076. function $Encoder(this$static) {
  2077. var i;
  2078. $clinit_59();
  2079. this$static._repDistances = initDim(_3I_classLit, 0, -1, 4, 1);
  2080. this$static._optimum = initDim(_3Lorg_dellroad_lzma_client_SevenZip_Compression_LZMA_Encoder$Optimal_2_classLit, 0, 6, 4096, 0);
  2081. this$static._rangeEncoder = ($clinit_66() , new Encoder_0());
  2082. this$static._isMatch = initDim(_3S_classLit, 0, -1, 192, 1);
  2083. this$static._isRep = initDim(_3S_classLit, 0, -1, 12, 1);
  2084. this$static._isRepG0 = initDim(_3S_classLit, 0, -1, 12, 1);
  2085. this$static._isRepG1 = initDim(_3S_classLit, 0, -1, 12, 1);
  2086. this$static._isRepG2 = initDim(_3S_classLit, 0, -1, 12, 1);
  2087. this$static._isRep0Long = initDim(_3S_classLit, 0, -1, 192, 1);
  2088. this$static._posSlotEncoder = initDim(_3Lorg_dellroad_lzma_client_SevenZip_Compression_RangeCoder_BitTreeEncoder_2_classLit, 0, 8, 4, 0);
  2089. this$static._posEncoders = initDim(_3S_classLit, 0, -1, 114, 1);
  2090. this$static._posAlignEncoder = $BitTreeEncoder(new BitTreeEncoder(), 4);
  2091. this$static._lenEncoder = $Encoder$LenPriceTableEncoder(new Encoder$LenPriceTableEncoder());
  2092. this$static._repMatchLenEncoder = $Encoder$LenPriceTableEncoder(new Encoder$LenPriceTableEncoder());
  2093. this$static._literalEncoder = new Encoder$LiteralEncoder();
  2094. this$static._matchDistances = initDim(_3I_classLit, 0, -1, 548, 1);
  2095. this$static._posSlotPrices = initDim(_3I_classLit, 0, -1, 256, 1);
  2096. this$static._distancesPrices = initDim(_3I_classLit, 0, -1, 512, 1);
  2097. this$static._alignPrices = initDim(_3I_classLit, 0, -1, 16, 1);
  2098. this$static.reps = initDim(_3I_classLit, 0, -1, 4, 1);
  2099. this$static.repLens = initDim(_3I_classLit, 0, -1, 4, 1);
  2100. this$static.processedInSize = initDim(_3J_classLit, 0, -1, 1, 3);
  2101. this$static.processedOutSize = initDim(_3J_classLit, 0, -1, 1, 3);
  2102. this$static.finished = initDim(_3Z_classLit, 0, -1, 1, 2);
  2103. this$static.properties = initDim(_3B_classLit, 0, -1, 5, 1);
  2104. this$static.tempPrices = initDim(_3I_classLit, 0, -1, 128, 1);
  2105. for (i = 0; i < 4096; ++i) {
  2106. this$static._optimum[i] = new Encoder$Optimal();
  2107. }
  2108. for (i = 0; i < 4; ++i) {
  2109. this$static._posSlotEncoder[i] = $BitTreeEncoder(new BitTreeEncoder(), 6);
  2110. }
  2111. return this$static;
  2112. }
  2113. function $FillAlignPrices(this$static) {
  2114. var i;
  2115. for (i = 0; i < 16; ++i) {
  2116. this$static._alignPrices[i] = $ReverseGetPrice(this$static._posAlignEncoder, i);
  2117. }
  2118. this$static._alignPriceCount = 0;
  2119. }
  2120. function $FillDistancesPrices(this$static) {
  2121. var baseVal, encoder, footerBits, i, lenToPosState, posSlot, st, st2;
  2122. for (i = 4; i < 128; ++i) {
  2123. posSlot = GetPosSlot(i);
  2124. footerBits = (posSlot >> 1) - 1;
  2125. baseVal = (2 | posSlot & 1) << footerBits;
  2126. this$static.tempPrices[i] = ReverseGetPrice(this$static._posEncoders, baseVal - posSlot - 1, footerBits, i - baseVal);
  2127. }
  2128. for (lenToPosState = 0; lenToPosState < 4; ++lenToPosState) {
  2129. encoder = this$static._posSlotEncoder[lenToPosState];
  2130. st = lenToPosState << 6;
  2131. for (posSlot = 0; posSlot < this$static._distTableSize; ++posSlot) {
  2132. this$static._posSlotPrices[st + posSlot] = $GetPrice_1(encoder, posSlot);
  2133. }
  2134. for (posSlot = 14; posSlot < this$static._distTableSize; ++posSlot) {
  2135. this$static._posSlotPrices[st + posSlot] += (posSlot >> 1) - 1 - 4 << 6;
  2136. }
  2137. st2 = lenToPosState * 128;
  2138. for (i = 0; i < 4; ++i) {
  2139. this$static._distancesPrices[st2 + i] = this$static._posSlotPrices[st + i];
  2140. }
  2141. for (; i < 128; ++i) {
  2142. this$static._distancesPrices[st2 + i] = this$static._posSlotPrices[st + GetPosSlot(i)] + this$static.tempPrices[i];
  2143. }
  2144. }
  2145. this$static._matchPriceCount = 0;
  2146. }
  2147. function $Flush(this$static, nowPos) {
  2148. $ReleaseMFStream(this$static);
  2149. $WriteEndMarker(this$static, nowPos & this$static._posStateMask);
  2150. $FlushData(this$static._rangeEncoder);
  2151. }
  2152. function $GetOptimum(this$static, position) {
  2153. var cur, curAnd1Price, curAndLenCharPrice, curAndLenPrice, curBack, curPrice, currentByte, distance, i, len, lenEnd, lenMain, lenRes, lenTest, lenTest2, lenTestTemp, matchByte, matchPrice, newLen, nextIsChar, nextMatchPrice, nextOptimum, nextRepMatchPrice, normalMatchPrice, numAvailableBytes, numAvailableBytesFull, numDistancePairs, offs, offset, opt, optimum, pos, posPrev, posState, posStateNext, price_4, repIndex, repLen, repMatchPrice, repMaxIndex, shortRepPrice, startLen, state, state2, t, price, price_0, price_1, price_2, price_3;
  2154. if (this$static._optimumEndIndex != this$static._optimumCurrentIndex) {
  2155. lenRes = this$static._optimum[this$static._optimumCurrentIndex].PosPrev - this$static._optimumCurrentIndex;
  2156. this$static.backRes = this$static._optimum[this$static._optimumCurrentIndex].BackPrev;
  2157. this$static._optimumCurrentIndex = this$static._optimum[this$static._optimumCurrentIndex].PosPrev;
  2158. return lenRes;
  2159. }
  2160. this$static._optimumCurrentIndex = this$static._optimumEndIndex = 0;
  2161. if (this$static._longestMatchWasFound) {
  2162. lenMain = this$static._longestMatchLength;
  2163. this$static._longestMatchWasFound = false;
  2164. } else {
  2165. lenMain = $ReadMatchDistances(this$static);
  2166. }
  2167. numDistancePairs = this$static._numDistancePairs;
  2168. numAvailableBytes = $GetNumAvailableBytes(this$static._matchFinder) + 1;
  2169. if (numAvailableBytes < 2) {
  2170. this$static.backRes = -1;
  2171. return 1;
  2172. }
  2173. if (numAvailableBytes > 273) {
  2174. numAvailableBytes = 273;
  2175. }
  2176. repMaxIndex = 0;
  2177. for (i = 0; i < 4; ++i) {
  2178. this$static.reps[i] = this$static._repDistances[i];
  2179. this$static.repLens[i] = $GetMatchLen(this$static._matchFinder, -1, this$static.reps[i], 273);
  2180. if (this$static.repLens[i] > this$static.repLens[repMaxIndex]) {
  2181. repMaxIndex = i;
  2182. }
  2183. }
  2184. if (this$static.repLens[repMaxIndex] >= this$static._numFastBytes) {
  2185. this$static.backRes = repMaxIndex;
  2186. lenRes = this$static.repLens[repMaxIndex];
  2187. $MovePos(this$static, lenRes - 1);
  2188. return lenRes;
  2189. }
  2190. if (lenMain >= this$static._numFastBytes) {
  2191. this$static.backRes = this$static._matchDistances[numDistancePairs - 1] + 4;
  2192. $MovePos(this$static, lenMain - 1);
  2193. return lenMain;
  2194. }
  2195. currentByte = $GetIndexByte(this$static._matchFinder, -1);
  2196. matchByte = $GetIndexByte(this$static._matchFinder, -this$static._repDistances[0] - 1 - 1);
  2197. if (lenMain < 2 && currentByte != matchByte && this$static.repLens[repMaxIndex] < 2) {
  2198. this$static.backRes = -1;
  2199. return 1;
  2200. }
  2201. this$static._optimum[0].State = this$static._state;
  2202. posState = position & this$static._posStateMask;
  2203. this$static._optimum[1].Price = ($clinit_66() , ProbPrices[this$static._isMatch[(this$static._state << 4) + posState] >>> 2]) + $GetPrice_0($GetSubCoder(this$static._literalEncoder, position, this$static._previousByte), this$static._state >= 7, matchByte, currentByte);
  2204. $MakeAsChar(this$static._optimum[1]);
  2205. matchPrice = ProbPrices[2048 - this$static._isMatch[(this$static._state << 4) + posState] >>> 2];
  2206. repMatchPrice = matchPrice + ProbPrices[2048 - this$static._isRep[this$static._state] >>> 2];
  2207. if (matchByte == currentByte) {
  2208. shortRepPrice = repMatchPrice + $GetRepLen1Price(this$static, this$static._state, posState);
  2209. if (shortRepPrice < this$static._optimum[1].Price) {
  2210. this$static._optimum[1].Price = shortRepPrice;
  2211. $MakeAsShortRep(this$static._optimum[1]);
  2212. }
  2213. }
  2214. lenEnd = lenMain >= this$static.repLens[repMaxIndex]?lenMain:this$static.repLens[repMaxIndex];
  2215. if (lenEnd < 2) {
  2216. this$static.backRes = this$static._optimum[1].BackPrev;
  2217. return 1;
  2218. }
  2219. this$static._optimum[1].PosPrev = 0;
  2220. this$static._optimum[0].Backs0 = this$static.reps[0];
  2221. this$static._optimum[0].Backs1 = this$static.reps[1];
  2222. this$static._optimum[0].Backs2 = this$static.reps[2];
  2223. this$static._optimum[0].Backs3 = this$static.reps[3];
  2224. len = lenEnd;
  2225. do {
  2226. this$static._optimum[len--].Price = 268435455;
  2227. } while (len >= 2);
  2228. for (i = 0; i < 4; ++i) {
  2229. repLen = this$static.repLens[i];
  2230. if (repLen < 2) {
  2231. continue;
  2232. }
  2233. price_4 = repMatchPrice + $GetPureRepPrice(this$static, i, this$static._state, posState);
  2234. do {
  2235. curAndLenPrice = price_4 + $GetPrice(this$static._repMatchLenEncoder, repLen - 2, posState);
  2236. optimum = this$static._optimum[repLen];
  2237. if (curAndLenPrice < optimum.Price) {
  2238. optimum.Price = curAndLenPrice;
  2239. optimum.PosPrev = 0;
  2240. optimum.BackPrev = i;
  2241. optimum.Prev1IsChar = false;
  2242. }
  2243. } while (--repLen >= 2);
  2244. }
  2245. normalMatchPrice = matchPrice + ProbPrices[this$static._isRep[this$static._state] >>> 2];
  2246. len = this$static.repLens[0] >= 2?this$static.repLens[0] + 1:2;
  2247. if (len <= lenMain) {
  2248. offs = 0;
  2249. while (len > this$static._matchDistances[offs]) {
  2250. offs += 2;
  2251. }
  2252. for (;; ++len) {
  2253. distance = this$static._matchDistances[offs + 1];
  2254. curAndLenPrice = normalMatchPrice + $GetPosLenPrice(this$static, distance, len, posState);
  2255. optimum = this$static._optimum[len];
  2256. if (curAndLenPrice < optimum.Price) {
  2257. optimum.Price = curAndLenPrice;
  2258. optimum.PosPrev = 0;
  2259. optimum.BackPrev = distance + 4;
  2260. optimum.Prev1IsChar = false;
  2261. }
  2262. if (len == this$static._matchDistances[offs]) {
  2263. offs += 2;
  2264. if (offs == numDistancePairs) {
  2265. break;
  2266. }
  2267. }
  2268. }
  2269. }
  2270. cur = 0;
  2271. while (true) {
  2272. ++cur;
  2273. if (cur == lenEnd) {
  2274. return $Backward(this$static, cur);
  2275. }
  2276. newLen = $ReadMatchDistances(this$static);
  2277. numDistancePairs = this$static._numDistancePairs;
  2278. if (newLen >= this$static._numFastBytes) {
  2279. this$static._longestMatchLength = newLen;
  2280. this$static._longestMatchWasFound = true;
  2281. return $Backward(this$static, cur);
  2282. }
  2283. ++position;
  2284. posPrev = this$static._optimum[cur].PosPrev;
  2285. if (this$static._optimum[cur].Prev1IsChar) {
  2286. --posPrev;
  2287. if (this$static._optimum[cur].Prev2) {
  2288. state = this$static._optimum[this$static._optimum[cur].PosPrev2].State;
  2289. if (this$static._optimum[cur].BackPrev2 < 4) {
  2290. state = (state < 7) ? 8 : 11;
  2291. } else {
  2292. state = (state < 7) ? 7 : 10;
  2293. }
  2294. } else {
  2295. state = this$static._optimum[posPrev].State;
  2296. }
  2297. state = StateUpdateChar(state);
  2298. } else {
  2299. state = this$static._optimum[posPrev].State;
  2300. }
  2301. if (posPrev == cur - 1) {
  2302. if (this$static._optimum[cur].BackPrev == 0) {
  2303. state = state < 7?9:11;
  2304. } else {
  2305. state = StateUpdateChar(state);
  2306. }
  2307. } else {
  2308. if (this$static._optimum[cur].Prev1IsChar && this$static._optimum[cur].Prev2) {
  2309. posPrev = this$static._optimum[cur].PosPrev2;
  2310. pos = this$static._optimum[cur].BackPrev2;
  2311. state = state < 7?8:11;
  2312. } else {
  2313. pos = this$static._optimum[cur].BackPrev;
  2314. if (pos < 4) {
  2315. state = state < 7?8:11;
  2316. } else {
  2317. state = state < 7?7:10;
  2318. }
  2319. }
  2320. opt = this$static._optimum[posPrev];
  2321. if (pos < 4) {
  2322. if (pos == 0) {
  2323. this$static.reps[0] = opt.Backs0;
  2324. this$static.reps[1] = opt.Backs1;
  2325. this$static.reps[2] = opt.Backs2;
  2326. this$static.reps[3] = opt.Backs3;
  2327. } else if (pos == 1) {
  2328. this$static.reps[0] = opt.Backs1;
  2329. this$static.reps[1] = opt.Backs0;
  2330. this$static.reps[2] = opt.Backs2;
  2331. this$static.reps[3] = opt.Backs3;
  2332. } else if (pos == 2) {
  2333. this$static.reps[0] = opt.Backs2;
  2334. this$static.reps[1] = opt.Backs0;
  2335. this$static.reps[2] = opt.Backs1;
  2336. this$static.reps[3] = opt.Backs3;
  2337. } else {
  2338. this$static.reps[0] = opt.Backs3;
  2339. this$static.reps[1] = opt.Backs0;
  2340. this$static.reps[2] = opt.Backs1;
  2341. this$static.reps[3] = opt.Backs2;
  2342. }
  2343. } else {
  2344. this$static.reps[0] = pos - 4;
  2345. this$static.reps[1] = opt.Backs0;
  2346. this$static.reps[2] = opt.Backs1;
  2347. this$static.reps[3] = opt.Backs2;
  2348. }
  2349. }
  2350. this$static._optimum[cur].State = state;
  2351. this$static._optimum[cur].Backs0 = this$static.reps[0];
  2352. this$static._optimum[cur].Backs1 = this$static.reps[1];
  2353. this$static._optimum[cur].Backs2 = this$static.reps[2];
  2354. this$static._optimum[cur].Backs3 = this$static.reps[3];
  2355. curPrice = this$static._optimum[cur].Price;
  2356. currentByte = $GetIndexByte(this$static._matchFinder, -1);
  2357. matchByte = $GetIndexByte(this$static._matchFinder, -this$static.reps[0] - 1 - 1);
  2358. posState = position & this$static._posStateMask;
  2359. curAnd1Price = curPrice + ProbPrices[this$static._isMatch[(state << 4) + posState] >>> 2] + $GetPrice_0($GetSubCoder(this$static._literalEncoder, position, $GetIndexByte(this$static._matchFinder, -2)), state >= 7, matchByte, currentByte);
  2360. nextOptimum = this$static._optimum[cur + 1];
  2361. nextIsChar = false;
  2362. if (curAnd1Price < nextOptimum.Price) {
  2363. nextOptimum.Price = curAnd1Price;
  2364. nextOptimum.PosPrev = cur;
  2365. nextOptimum.BackPrev = -1;
  2366. nextOptimum.Prev1IsChar = false;
  2367. nextIsChar = true;
  2368. }
  2369. matchPrice = curPrice + ProbPrices[2048 - this$static._isMatch[(state << 4) + posState] >>> 2];
  2370. repMatchPrice = matchPrice + ProbPrices[2048 - this$static._isRep[state] >>> 2];
  2371. if (matchByte == currentByte && !(nextOptimum.PosPrev < cur && nextOptimum.BackPrev == 0)) {
  2372. shortRepPrice = repMatchPrice + (ProbPrices[this$static._isRepG0[state] >>> 2] + ProbPrices[this$static._isRep0Long[(state << 4) + posState] >>> 2]);
  2373. if (shortRepPrice <= nextOptimum.Price) {
  2374. nextOptimum.Price = shortRepPrice;
  2375. nextOptimum.PosPrev = cur;
  2376. nextOptimum.BackPrev = 0;
  2377. nextOptimum.Prev1IsChar = false;
  2378. nextIsChar = true;
  2379. }
  2380. }
  2381. numAvailableBytesFull = $GetNumAvailableBytes(this$static._matchFinder) + 1;
  2382. numAvailableBytesFull = 4095 - cur < numAvailableBytesFull?4095 - cur:numAvailableBytesFull;
  2383. numAvailableBytes = numAvailableBytesFull;
  2384. if (numAvailableBytes < 2) {
  2385. continue;
  2386. }
  2387. if (numAvailableBytes > this$static._numFastBytes) {
  2388. numAvailableBytes = this$static._numFastBytes;
  2389. }
  2390. if (!nextIsChar && matchByte != currentByte) {
  2391. t = min(numAvailableBytesFull - 1, this$static._numFastBytes);
  2392. lenTest2 = $GetMatchLen(this$static._matchFinder, 0, this$static.reps[0], t);
  2393. if (lenTest2 >= 2) {
  2394. state2 = StateUpdateChar(state);
  2395. posStateNext = position + 1 & this$static._posStateMask;
  2396. nextRepMatchPrice = curAnd1Price + ProbPrices[2048 - this$static._isMatch[(state2 << 4) + posStateNext] >>> 2] + ProbPrices[2048 - this$static._isRep[state2] >>> 2];
  2397. offset = cur + 1 + lenTest2;
  2398. while (lenEnd < offset) {
  2399. this$static._optimum[++lenEnd].Price = 268435455;
  2400. }
  2401. curAndLenPrice = nextRepMatchPrice + (price = $GetPrice(this$static._repMatchLenEncoder, lenTest2 - 2, posStateNext) , price + $GetPureRepPrice(this$static, 0, state2, posStateNext));
  2402. optimum = this$static._optimum[offset];
  2403. if (curAndLenPrice < optimum.Price) {
  2404. optimum.Price = curAndLenPrice;
  2405. optimum.PosPrev = cur + 1;
  2406. optimum.BackPrev = 0;
  2407. optimum.Prev1IsChar = true;
  2408. optimum.Prev2 = false;
  2409. }
  2410. }
  2411. }
  2412. startLen = 2;
  2413. for (repIndex = 0; repIndex < 4; ++repIndex) {
  2414. lenTest = $GetMatchLen(this$static._matchFinder, -1, this$static.reps[repIndex], numAvailableBytes);
  2415. if (lenTest < 2) {
  2416. continue;
  2417. }
  2418. lenTestTemp = lenTest;
  2419. do {
  2420. while (lenEnd < cur + lenTest) {
  2421. this$static._optimum[++lenEnd].Price = 268435455;
  2422. }
  2423. curAndLenPrice = repMatchPrice + (price_0 = $GetPrice(this$static._repMatchLenEncoder, lenTest - 2, posState) , price_0 + $GetPureRepPrice(this$static, repIndex, state, posState));
  2424. optimum = this$static._optimum[cur + lenTest];
  2425. if (curAndLenPrice < optimum.Price) {
  2426. optimum.Price = curAndLenPrice;
  2427. optimum.PosPrev = cur;
  2428. optimum.BackPrev = repIndex;
  2429. optimum.Prev1IsChar = false;
  2430. }
  2431. } while (--lenTest >= 2);
  2432. lenTest = lenTestTemp;
  2433. if (repIndex == 0) {
  2434. startLen = lenTest + 1;
  2435. }
  2436. if (lenTest < numAvailableBytesFull) {
  2437. t = min(numAvailableBytesFull - 1 - lenTest, this$static._numFastBytes);
  2438. lenTest2 = $GetMatchLen(this$static._matchFinder, lenTest, this$static.reps[repIndex], t);
  2439. if (lenTest2 >= 2) {
  2440. state2 = state < 7?8:11;
  2441. posStateNext = position + lenTest & this$static._posStateMask;
  2442. curAndLenCharPrice = repMatchPrice + (price_1 = $GetPrice(this$static._repMatchLenEncoder, lenTest - 2, posState) , price_1 + $GetPureRepPrice(this$static, repIndex, state, posState)) + ProbPrices[this$static._isMatch[(state2 << 4) + posStateNext] >>> 2] + $GetPrice_0($GetSubCoder(this$static._literalEncoder, position + lenTest, $GetIndexByte(this$static._matchFinder, lenTest - 1 - 1)), true, $GetIndexByte(this$static._matchFinder, lenTest - 1 - (this$static.reps[repIndex] + 1)), $GetIndexByte(this$static._matchFinder, lenTest - 1));
  2443. state2 = StateUpdateChar(state2);
  2444. posStateNext = position + lenTest + 1 & this$static._posStateMask;
  2445. nextMatchPrice = curAndLenCharPrice + ProbPrices[2048 - this$static._isMatch[(state2 << 4) + posStateNext] >>> 2];
  2446. nextRepMatchPrice = nextMatchPrice + ProbPrices[2048 - this$static._isRep[state2] >>> 2];
  2447. offset = lenTest + 1 + lenTest2;
  2448. while (lenEnd < cur + offset) {
  2449. this$static._optimum[++lenEnd].Price = 268435455;
  2450. }
  2451. curAndLenPrice = nextRepMatchPrice + (price_2 = $GetPrice(this$static._repMatchLenEncoder, lenTest2 - 2, posStateNext) , price_2 + $GetPureRepPrice(this$static, 0, state2, posStateNext));
  2452. optimum = this$static._optimum[cur + offset];
  2453. if (curAndLenPrice < optimum.Price) {
  2454. optimum.Price = curAndLenPrice;
  2455. optimum.PosPrev = cur + lenTest + 1;
  2456. optimum.BackPrev = 0;
  2457. optimum.Prev1IsChar = true;
  2458. optimum.Prev2 = true;
  2459. optimum.PosPrev2 = cur;
  2460. optimum.BackPrev2 = repIndex;
  2461. }
  2462. }
  2463. }
  2464. }
  2465. if (newLen > numAvailableBytes) {
  2466. newLen = numAvailableBytes;
  2467. for (numDistancePairs = 0; newLen > this$static._matchDistances[numDistancePairs]; numDistancePairs += 2) {
  2468. }
  2469. this$static._matchDistances[numDistancePairs] = newLen;
  2470. numDistancePairs += 2;
  2471. }
  2472. if (newLen >= startLen) {
  2473. normalMatchPrice = matchPrice + ProbPrices[this$static._isRep[state] >>> 2];
  2474. while (lenEnd < cur + newLen) {
  2475. this$static._optimum[++lenEnd].Price = 268435455;
  2476. }
  2477. offs = 0;
  2478. while (startLen > this$static._matchDistances[offs]) {
  2479. offs += 2;
  2480. }
  2481. for (lenTest = startLen;; ++lenTest) {
  2482. curBack = this$static._matchDistances[offs + 1];
  2483. curAndLenPrice = normalMatchPrice + $GetPosLenPrice(this$static, curBack, lenTest, posState);
  2484. optimum = this$static._optimum[cur + lenTest];
  2485. if (curAndLenPrice < optimum.Price) {
  2486. optimum.Price = curAndLenPrice;
  2487. optimum.PosPrev = cur;
  2488. optimum.BackPrev = curBack + 4;
  2489. optimum.Prev1IsChar = false;
  2490. }
  2491. if (lenTest == this$static._matchDistances[offs]) {
  2492. if (lenTest < numAvailableBytesFull) {
  2493. t = min(numAvailableBytesFull - 1 - lenTest, this$static._numFastBytes);
  2494. lenTest2 = $GetMatchLen(this$static._matchFinder, lenTest, curBack, t);
  2495. if (lenTest2 >= 2) {
  2496. state2 = state < 7?7:10;
  2497. posStateNext = position + lenTest & this$static._posStateMask;
  2498. curAndLenCharPrice = curAndLenPrice + ProbPrices[this$static._isMatch[(state2 << 4) + posStateNext] >>> 2] + $GetPrice_0($GetSubCoder(this$static._literalEncoder, position + lenTest, $GetIndexByte(this$static._matchFinder, lenTest - 1 - 1)), true, $GetIndexByte(this$static._matchFinder, lenTest - (curBack + 1) - 1), $GetIndexByte(this$static._matchFinder, lenTest - 1));
  2499. state2 = StateUpdateChar(state2);
  2500. posStateNext = position + lenTest + 1 & this$static._posStateMask;
  2501. nextMatchPrice = curAndLenCharPrice + ProbPrices[2048 - this$static._isMatch[(state2 << 4) + posStateNext] >>> 2];
  2502. nextRepMatchPrice = nextMatchPrice + ProbPrices[2048 - this$static._isRep[state2] >>> 2];
  2503. offset = lenTest + 1 + lenTest2;
  2504. while (lenEnd < cur + offset) {
  2505. this$static._optimum[++lenEnd].Price = 268435455;
  2506. }
  2507. curAndLenPrice = nextRepMatchPrice + (price_3 = $GetPrice(this$static._repMatchLenEncoder, lenTest2 - 2, posStateNext) , price_3 + $GetPureRepPrice(this$static, 0, state2, posStateNext));
  2508. optimum = this$static._optimum[cur + offset];
  2509. if (curAndLenPrice < optimum.Price) {
  2510. optimum.Price = curAndLenPrice;
  2511. optimum.PosPrev = cur + lenTest + 1;
  2512. optimum.BackPrev = 0;
  2513. optimum.Prev1IsChar = true;
  2514. optimum.Prev2 = true;
  2515. optimum.PosPrev2 = cur;
  2516. optimum.BackPrev2 = curBack + 4;
  2517. }
  2518. }
  2519. }
  2520. offs += 2;
  2521. if (offs == numDistancePairs)
  2522. break;
  2523. }
  2524. }
  2525. }
  2526. }
  2527. }
  2528. function $GetPosLenPrice(this$static, pos, len, posState) {
  2529. var lenToPosState, price;
  2530. lenToPosState = GetLenToPosState(len);
  2531. if (pos < 128) {
  2532. price = this$static._distancesPrices[lenToPosState * 128 + pos];
  2533. } else {
  2534. price = this$static._posSlotPrices[(lenToPosState << 6) + GetPosSlot2(pos)] + this$static._alignPrices[pos & 15];
  2535. }
  2536. return price + $GetPrice(this$static._lenEncoder, len - 2, posState);
  2537. }
  2538. function $GetPureRepPrice(this$static, repIndex, state, posState) {
  2539. var price;
  2540. if (repIndex == 0) {
  2541. price = ($clinit_66() , ProbPrices[this$static._isRepG0[state] >>> 2]);
  2542. price += ProbPrices[2048 - this$static._isRep0Long[(state << 4) + posState] >>> 2];
  2543. } else {
  2544. price = ($clinit_66() , ProbPrices[2048 - this$static._isRepG0[state] >>> 2]);
  2545. if (repIndex == 1) {
  2546. price += ProbPrices[this$static._isRepG1[state] >>> 2];
  2547. } else {
  2548. price += ProbPrices[2048 - this$static._isRepG1[state] >>> 2];
  2549. price += GetPrice(this$static._isRepG2[state], repIndex - 2);
  2550. }
  2551. }
  2552. return price;
  2553. }
  2554. function $GetRepLen1Price(this$static, state, posState) {
  2555. return ($clinit_66() , ProbPrices[this$static._isRepG0[state] >>> 2]) + ProbPrices[this$static._isRep0Long[(state << 4) + posState] >>> 2];
  2556. }
  2557. function $Init_4(this$static) {
  2558. var i;
  2559. $BaseInit(this$static);
  2560. $Init_9(this$static._rangeEncoder);
  2561. InitBitModels_0(this$static._isMatch);
  2562. InitBitModels_0(this$static._isRep0Long);
  2563. InitBitModels_0(this$static._isRep);
  2564. InitBitModels_0(this$static._isRepG0);
  2565. InitBitModels_0(this$static._isRepG1);
  2566. InitBitModels_0(this$static._isRepG2);
  2567. InitBitModels_0(this$static._posEncoders);
  2568. $Init_3(this$static._literalEncoder);
  2569. for (i = 0; i < 4; ++i) {
  2570. InitBitModels(this$static._posSlotEncoder[i].Models);
  2571. }
  2572. $Init_2(this$static._lenEncoder, 1 << this$static._posStateBits);
  2573. $Init_2(this$static._repMatchLenEncoder, 1 << this$static._posStateBits);
  2574. InitBitModels(this$static._posAlignEncoder.Models);
  2575. this$static._longestMatchWasFound = false;
  2576. this$static._optimumEndIndex = 0;
  2577. this$static._optimumCurrentIndex = 0;
  2578. this$static._additionalOffset = 0;
  2579. }
  2580. function $MovePos(this$static, num) {
  2581. if (num > 0) {
  2582. $Skip(this$static._matchFinder, num);
  2583. this$static._additionalOffset += num;
  2584. }
  2585. }
  2586. function $ReadMatchDistances(this$static) {
  2587. var lenRes;
  2588. lenRes = 0;
  2589. this$static._numDistancePairs = $GetMatches(this$static._matchFinder, this$static._matchDistances);
  2590. if (this$static._numDistancePairs > 0) {
  2591. lenRes = this$static._matchDistances[this$static._numDistancePairs - 2];
  2592. if (lenRes == this$static._numFastBytes)
  2593. lenRes += $GetMatchLen(this$static._matchFinder, lenRes - 1, this$static._matchDistances[this$static._numDistancePairs - 1], 273 - lenRes);
  2594. }
  2595. ++this$static._additionalOffset;
  2596. return lenRes;
  2597. }
  2598. function $ReleaseMFStream(this$static) {
  2599. if (!!this$static._matchFinder && this$static._needReleaseMFStream) {
  2600. this$static._matchFinder._stream = null;
  2601. this$static._needReleaseMFStream = false;
  2602. }
  2603. }
  2604. function $ReleaseStreams(this$static) {
  2605. $ReleaseMFStream(this$static);
  2606. this$static._rangeEncoder.Stream = null;
  2607. }
  2608. function $SetDictionarySize_0(this$static, dictionarySize) {
  2609. var dicLogSize;
  2610. if (dictionarySize < 1 || dictionarySize > 536870912) {
  2611. return false;
  2612. }
  2613. this$static._dictionarySize = dictionarySize;
  2614. for (dicLogSize = 0; dictionarySize > 1 << dicLogSize; ++dicLogSize) {
  2615. }
  2616. this$static._distTableSize = dicLogSize * 2;
  2617. return true;
  2618. }
  2619. function $SetLcLpPb_0(this$static, lc, lp, pb) {
  2620. if (lp < 0 || lp > 4 || lc < 0 || lc > 8 || pb < 0 || pb > 4) {
  2621. return false;
  2622. }
  2623. this$static._numLiteralPosStateBits = lp;
  2624. this$static._numLiteralContextBits = lc;
  2625. this$static._posStateBits = pb;
  2626. this$static._posStateMask = (1 << this$static._posStateBits) - 1;
  2627. return true;
  2628. }
  2629. function $SetMatchFinder(this$static, matchFinderIndex) {
  2630. var matchFinderIndexPrev;
  2631. if (matchFinderIndex < 0 || matchFinderIndex > 2) {
  2632. return false;
  2633. }
  2634. matchFinderIndexPrev = this$static._matchFinderType;
  2635. this$static._matchFinderType = matchFinderIndex;
  2636. if (!!this$static._matchFinder && matchFinderIndexPrev != this$static._matchFinderType) {
  2637. this$static._dictionarySizePrev = -1;
  2638. this$static._matchFinder = null;
  2639. }
  2640. return true;
  2641. }
  2642. function $SetNumFastBytes(this$static, numFastBytes) {
  2643. if (numFastBytes < 5 || numFastBytes > 273) {
  2644. return false;
  2645. }
  2646. this$static._numFastBytes = numFastBytes;
  2647. return true;
  2648. }
  2649. function $WriteCoderProperties(this$static, outStream) {
  2650. var i;
  2651. this$static.properties[0] = (this$static._posStateBits * 5 + this$static._numLiteralPosStateBits) * 9 + this$static._numLiteralContextBits << 24 >> 24;
  2652. for (i = 0; i < 4; ++i) {
  2653. this$static.properties[1 + i] = this$static._dictionarySize >> 8 * i << 24 >> 24;
  2654. }
  2655. $write_0(outStream, this$static.properties, 0, 5);
  2656. }
  2657. function $WriteEndMarker(this$static, posState) {
  2658. var lenToPosState;
  2659. if (!this$static._writeEndMark) {
  2660. return;
  2661. }
  2662. $Encode_3(this$static._rangeEncoder, this$static._isMatch, (this$static._state << 4) + posState, 1);
  2663. $Encode_3(this$static._rangeEncoder, this$static._isRep, this$static._state, 0);
  2664. this$static._state = this$static._state < 7?7:10;
  2665. $Encode_0(this$static._lenEncoder, this$static._rangeEncoder, 0, posState);
  2666. lenToPosState = GetLenToPosState(2);
  2667. $Encode_2(this$static._posSlotEncoder[lenToPosState], this$static._rangeEncoder, 63);
  2668. $EncodeDirectBits(this$static._rangeEncoder, 67108863, 26);
  2669. $ReverseEncode(this$static._posAlignEncoder, this$static._rangeEncoder, 15);
  2670. }
  2671. function GetPosSlot(pos) {
  2672. if (pos < 2048) {
  2673. return g_FastPos[pos];
  2674. }
  2675. if (pos < 2097152) {
  2676. return g_FastPos[pos >> 10] + 20;
  2677. }
  2678. return g_FastPos[pos >> 20] + 40;
  2679. }
  2680. function GetPosSlot2(pos) {
  2681. if (pos < 131072) {
  2682. return g_FastPos[pos >> 6] + 12;
  2683. }
  2684. if (pos < 134217728) {
  2685. return g_FastPos[pos >> 16] + 32;
  2686. }
  2687. return g_FastPos[pos >> 26] + 52;
  2688. }
  2689. function getClass_38() {
  2690. return Lorg_dellroad_lzma_client_SevenZip_Compression_LZMA_Encoder_2_classLit;
  2691. }
  2692. function Encoder() {
  2693. }
  2694. _ = Encoder.prototype = new Object_0();
  2695. _.getClass$ = getClass_38;
  2696. _.typeId$ = 0;
  2697. _._additionalOffset = 0;
  2698. _._alignPriceCount = 0;
  2699. _._dictionarySize = 4194304;
  2700. _._dictionarySizePrev = -1;
  2701. _._distTableSize = 44;
  2702. _._finished = false;
  2703. _._inStream = null;
  2704. _._longestMatchLength = 0;
  2705. _._longestMatchWasFound = false;
  2706. _._matchFinder = null;
  2707. _._matchFinderType = 1;
  2708. _._matchPriceCount = 0;
  2709. _._needReleaseMFStream = false;
  2710. _._numDistancePairs = 0;
  2711. _._numFastBytes = 32;
  2712. _._numFastBytesPrev = -1;
  2713. _._numLiteralContextBits = 3;
  2714. _._numLiteralPosStateBits = 0;
  2715. _._optimumCurrentIndex = 0;
  2716. _._optimumEndIndex = 0;
  2717. _._posStateBits = 2;
  2718. _._posStateMask = 3;
  2719. _._previousByte = 0;
  2720. _._state = 0;
  2721. _._writeEndMark = false;
  2722. _.backRes = 0;
  2723. _.nowPos64 = P0_longLit;
  2724. var g_FastPos;
  2725. function $Encode(this$static, rangeEncoder, symbol, posState) {
  2726. if (symbol < 8) {
  2727. $Encode_3(rangeEncoder, this$static._choice, 0, 0);
  2728. $Encode_2(this$static._lowCoder[posState], rangeEncoder, symbol);
  2729. } else {
  2730. symbol -= 8;
  2731. $Encode_3(rangeEncoder, this$static._choice, 0, 1);
  2732. if (symbol < 8) {
  2733. $Encode_3(rangeEncoder, this$static._choice, 1, 0);
  2734. $Encode_2(this$static._midCoder[posState], rangeEncoder, symbol);
  2735. } else {
  2736. $Encode_3(rangeEncoder, this$static._choice, 1, 1);
  2737. $Encode_2(this$static._highCoder, rangeEncoder, symbol - 8);
  2738. }
  2739. }
  2740. }
  2741. function $Encoder$LenEncoder(this$static) {
  2742. var posState;
  2743. this$static._choice = initDim(_3S_classLit, 0, -1, 2, 1);
  2744. this$static._lowCoder = initDim(_3Lorg_dellroad_lzma_client_SevenZip_Compression_RangeCoder_BitTreeEncoder_2_classLit, 0, 8, 16, 0);
  2745. this$static._midCoder = initDim(_3Lorg_dellroad_lzma_client_SevenZip_Compression_RangeCoder_BitTreeEncoder_2_classLit, 0, 8, 16, 0);
  2746. this$static._highCoder = $BitTreeEncoder(new BitTreeEncoder(), 8);
  2747. for (posState = 0; posState < 16; ++posState) {
  2748. this$static._lowCoder[posState] = $BitTreeEncoder(new BitTreeEncoder(), 3);
  2749. this$static._midCoder[posState] = $BitTreeEncoder(new BitTreeEncoder(), 3);
  2750. }
  2751. return this$static;
  2752. }
  2753. function $Init_2(this$static, numPosStates) {
  2754. var posState;
  2755. InitBitModels_0(this$static._choice);
  2756. for (posState = 0; posState < numPosStates; ++posState) {
  2757. InitBitModels(this$static._lowCoder[posState].Models);
  2758. InitBitModels(this$static._midCoder[posState].Models);
  2759. }
  2760. InitBitModels(this$static._highCoder.Models);
  2761. }
  2762. function $SetPrices(this$static, posState, numSymbols, prices, st) {
  2763. var a0, a1, b0, b1, i;
  2764. a0 = ($clinit_66() , ProbPrices[this$static._choice[0] >>> 2]);
  2765. a1 = ProbPrices[2048 - this$static._choice[0] >>> 2];
  2766. b0 = a1 + ProbPrices[this$static._choice[1] >>> 2];
  2767. b1 = a1 + ProbPrices[2048 - this$static._choice[1] >>> 2];
  2768. i = 0;
  2769. for (i = 0; i < 8; ++i) {
  2770. if (i >= numSymbols)
  2771. return;
  2772. prices[st + i] = a0 + $GetPrice_1(this$static._lowCoder[posState], i);
  2773. }
  2774. for (; i < 16; ++i) {
  2775. if (i >= numSymbols)
  2776. return;
  2777. prices[st + i] = b0 + $GetPrice_1(this$static._midCoder[posState], i - 8);
  2778. }
  2779. for (; i < numSymbols; ++i) {
  2780. prices[st + i] = b1 + $GetPrice_1(this$static._highCoder, i - 8 - 8);
  2781. }
  2782. }
  2783. function getClass_33() {
  2784. return Lorg_dellroad_lzma_client_SevenZip_Compression_LZMA_Encoder$LenEncoder_2_classLit;
  2785. }
  2786. function Encoder$LenEncoder() {
  2787. }
  2788. _ = Encoder$LenEncoder.prototype = new Object_0();
  2789. _.getClass$ = getClass_33;
  2790. _.typeId$ = 0;
  2791. function $Encode_0(this$static, rangeEncoder, symbol, posState) {
  2792. $Encode(this$static, rangeEncoder, symbol, posState);
  2793. if (--this$static._counters[posState] == 0) {
  2794. $SetPrices(this$static, posState, this$static._tableSize, this$static._prices, posState * 272);
  2795. this$static._counters[posState] = this$static._tableSize;
  2796. }
  2797. }
  2798. function $Encoder$LenPriceTableEncoder(this$static) {
  2799. $Encoder$LenEncoder(this$static);
  2800. this$static._prices = initDim(_3I_classLit, 0, -1, 4352, 1);
  2801. this$static._counters = initDim(_3I_classLit, 0, -1, 16, 1);
  2802. return this$static;
  2803. }
  2804. function $GetPrice(this$static, symbol, posState) {
  2805. return this$static._prices[posState * 272 + symbol];
  2806. }
  2807. function $UpdateTables(this$static, numPosStates) {
  2808. var posState;
  2809. for (posState = 0; posState < numPosStates; ++posState) {
  2810. $SetPrices(this$static, posState, this$static._tableSize, this$static._prices, posState * 272);
  2811. this$static._counters[posState] = this$static._tableSize;
  2812. }
  2813. }
  2814. function getClass_34() {
  2815. return Lorg_dellroad_lzma_client_SevenZip_Compression_LZMA_Encoder$LenPriceTableEncoder_2_classLit;
  2816. }
  2817. function Encoder$LenPriceTableEncoder() {
  2818. }
  2819. _ = Encoder$LenPriceTableEncoder.prototype = new Encoder$LenEncoder();
  2820. _.getClass$ = getClass_34;
  2821. _.typeId$ = 0;
  2822. _._tableSize = 0;
  2823. function $Create_1(this$static, numPosBits, numPrevBits) {
  2824. var i, numStates;
  2825. if (this$static.m_Coders != null && this$static.m_NumPrevBits == numPrevBits && this$static.m_NumPosBits == numPosBits) {
  2826. return;
  2827. }
  2828. this$static.m_NumPosBits = numPosBits;
  2829. this$static.m_PosMask = (1 << numPosBits) - 1;
  2830. this$static.m_NumPrevBits = numPrevBits;
  2831. numStates = 1 << this$static.m_NumPrevBits + this$static.m_NumPosBits;
  2832. this$static.m_Coders = initDim(_3Lorg_dellroad_lzma_client_SevenZip_Compression_LZMA_Encoder$LiteralEncoder$Encoder2_2_classLit, 0, 5, numStates, 0);
  2833. for (i = 0; i < numStates; ++i) {
  2834. this$static.m_Coders[i] = $Encoder$LiteralEncoder$Encoder2(new Encoder$LiteralEncoder$Encoder2());
  2835. }
  2836. }
  2837. function $GetSubCoder(this$static, pos, prevByte) {
  2838. return this$static.m_Coders[((pos & this$static.m_PosMask) << this$static.m_NumPrevBits) + ((prevByte & 255) >>> 8 - this$static.m_NumPrevBits)];
  2839. }
  2840. function $Init_3(this$static) {
  2841. var i, numStates;
  2842. numStates = 1 << this$static.m_NumPrevBits + this$static.m_NumPosBits;
  2843. for (i = 0; i < numStates; ++i) {
  2844. InitBitModels_0(this$static.m_Coders[i].m_Encoders);
  2845. }
  2846. }
  2847. function getClass_36() {
  2848. return Lorg_dellroad_lzma_client_SevenZip_Compression_LZMA_Encoder$LiteralEncoder_2_classLit;
  2849. }
  2850. function Encoder$LiteralEncoder() {
  2851. }
  2852. _ = Encoder$LiteralEncoder.prototype = new Object_0();
  2853. _.getClass$ = getClass_36;
  2854. _.typeId$ = 0;
  2855. _.m_Coders = null;
  2856. _.m_NumPosBits = 0;
  2857. _.m_NumPrevBits = 0;
  2858. _.m_PosMask = 0;
  2859. function $Encode_1(this$static, rangeEncoder, symbol) {
  2860. var bit, context, i;
  2861. context = 1;
  2862. for (i = 7; i >= 0; --i) {
  2863. bit = symbol >> i & 1;
  2864. $Encode_3(rangeEncoder, this$static.m_Encoders, context, bit);
  2865. context = context << 1 | bit;
  2866. }
  2867. }
  2868. function $EncodeMatched(this$static, rangeEncoder, matchByte, symbol) {
  2869. var bit, context, i, matchBit, same, state;
  2870. context = 1;
  2871. same = true;
  2872. for (i = 7; i >= 0; --i) {
  2873. bit = symbol >> i & 1;
  2874. state = context;
  2875. if (same) {
  2876. matchBit = matchByte >> i & 1;
  2877. state += 1 + matchBit << 8;
  2878. same = matchBit == bit;
  2879. }
  2880. $Encode_3(rangeEncoder, this$static.m_Encoders, state, bit);
  2881. context = context << 1 | bit;
  2882. }
  2883. }
  2884. function $Encoder$LiteralEncoder$Encoder2(this$static) {
  2885. this$static.m_Encoders = initDim(_3S_classLit, 0, -1, 768, 1);
  2886. return this$static;
  2887. }
  2888. function $GetPrice_0(this$static, matchMode, matchByte, symbol) {
  2889. var bit, context, i, matchBit, price;
  2890. price = 0;
  2891. context = 1;
  2892. i = 7;
  2893. if (matchMode) {
  2894. for (; i >= 0; --i) {
  2895. matchBit = matchByte >> i & 1;
  2896. bit = symbol >> i & 1;
  2897. price += GetPrice(this$static.m_Encoders[(1 + matchBit << 8) + context], bit);
  2898. context = context << 1 | bit;
  2899. if (matchBit != bit) {
  2900. --i;
  2901. break;
  2902. }
  2903. }
  2904. }
  2905. for (; i >= 0; --i) {
  2906. bit = symbol >> i & 1;
  2907. price += GetPrice(this$static.m_Encoders[context], bit);
  2908. context = context << 1 | bit;
  2909. }
  2910. return price;
  2911. }
  2912. function getClass_35() {
  2913. return Lorg_dellroad_lzma_client_SevenZip_Compression_LZMA_Encoder$LiteralEncoder$Encoder2_2_classLit;
  2914. }
  2915. function Encoder$LiteralEncoder$Encoder2() {
  2916. }
  2917. _ = Encoder$LiteralEncoder$Encoder2.prototype = new Object_0();
  2918. _.getClass$ = getClass_35;
  2919. _.typeId$ = 18;
  2920. function $MakeAsChar(this$static) {
  2921. this$static.BackPrev = -1;
  2922. this$static.Prev1IsChar = false;
  2923. }
  2924. function $MakeAsShortRep(this$static) {
  2925. this$static.BackPrev = 0;
  2926. this$static.Prev1IsChar = false;
  2927. }
  2928. function getClass_37() {
  2929. return Lorg_dellroad_lzma_client_SevenZip_Compression_LZMA_Encoder$Optimal_2_classLit;
  2930. }
  2931. function Encoder$Optimal() {
  2932. }
  2933. _ = Encoder$Optimal.prototype = new Object_0();
  2934. _.getClass$ = getClass_37;
  2935. _.typeId$ = 19;
  2936. _.BackPrev = 0;
  2937. _.BackPrev2 = 0;
  2938. _.Backs0 = 0;
  2939. _.Backs1 = 0;
  2940. _.Backs2 = 0;
  2941. _.Backs3 = 0;
  2942. _.PosPrev = 0;
  2943. _.PosPrev2 = 0;
  2944. _.Prev1IsChar = false;
  2945. _.Prev2 = false;
  2946. _.Price = 0;
  2947. _.State = 0;
  2948. function $BitTreeDecoder(this$static, numBitLevels) {
  2949. this$static.NumBitLevels = numBitLevels;
  2950. this$static.Models = initDim(_3S_classLit, 0, -1, 1 << numBitLevels, 1);
  2951. return this$static;
  2952. }
  2953. function $Decode_0(this$static, rangeDecoder) {
  2954. var bitIndex, m;
  2955. m = 1;
  2956. for (bitIndex = this$static.NumBitLevels; bitIndex != 0; --bitIndex) {
  2957. m = (m << 1) + $DecodeBit(rangeDecoder, this$static.Models, m);
  2958. }
  2959. return m - (1 << this$static.NumBitLevels);
  2960. }
  2961. function $ReverseDecode(this$static, rangeDecoder) {
  2962. var bit, bitIndex, m, symbol;
  2963. m = 1;
  2964. symbol = 0;
  2965. for (bitIndex = 0; bitIndex < this$static.NumBitLevels; ++bitIndex) {
  2966. bit = $DecodeBit(rangeDecoder, this$static.Models, m);
  2967. m <<= 1;
  2968. m += bit;
  2969. symbol |= bit << bitIndex;
  2970. }
  2971. return symbol;
  2972. }
  2973. function ReverseDecode(Models, startIndex, rangeDecoder, NumBitLevels) {
  2974. var bit, bitIndex, m, symbol;
  2975. m = 1;
  2976. symbol = 0;
  2977. for (bitIndex = 0; bitIndex < NumBitLevels; ++bitIndex) {
  2978. bit = $DecodeBit(rangeDecoder, Models, startIndex + m);
  2979. m <<= 1;
  2980. m += bit;
  2981. symbol |= bit << bitIndex;
  2982. }
  2983. return symbol;
  2984. }
  2985. function getClass_42() {
  2986. return Lorg_dellroad_lzma_client_SevenZip_Compression_RangeCoder_BitTreeDecoder_2_classLit;
  2987. }
  2988. function BitTreeDecoder() {
  2989. }
  2990. _ = BitTreeDecoder.prototype = new Object_0();
  2991. _.getClass$ = getClass_42;
  2992. _.typeId$ = 20;
  2993. _.Models = null;
  2994. _.NumBitLevels = 0;
  2995. function $BitTreeEncoder(this$static, numBitLevels) {
  2996. this$static.NumBitLevels = numBitLevels;
  2997. this$static.Models = initDim(_3S_classLit, 0, -1, 1 << numBitLevels, 1);
  2998. return this$static;
  2999. }
  3000. function $Encode_2(this$static, rangeEncoder, symbol) {
  3001. var bit, bitIndex, m;
  3002. m = 1;
  3003. for (bitIndex = this$static.NumBitLevels; bitIndex != 0;) {
  3004. --bitIndex;
  3005. bit = symbol >>> bitIndex & 1;
  3006. $Encode_3(rangeEncoder, this$static.Models, m, bit);
  3007. m = m << 1 | bit;
  3008. }
  3009. }
  3010. function $GetPrice_1(this$static, symbol) {
  3011. var bit, bitIndex, m, price;
  3012. price = 0;
  3013. m = 1;
  3014. for (bitIndex = this$static.NumBitLevels; bitIndex != 0;) {
  3015. --bitIndex;
  3016. bit = symbol >>> bitIndex & 1;
  3017. price += GetPrice(this$static.Models[m], bit);
  3018. m = (m << 1) + bit;
  3019. }
  3020. return price;
  3021. }
  3022. function $ReverseEncode(this$static, rangeEncoder, symbol) {
  3023. var bit, i, m;
  3024. m = 1;
  3025. for (i = 0; i < this$static.NumBitLevels; ++i) {
  3026. bit = symbol & 1;
  3027. $Encode_3(rangeEncoder, this$static.Models, m, bit);
  3028. m = m << 1 | bit;
  3029. symbol >>= 1;
  3030. }
  3031. }
  3032. function $ReverseGetPrice(this$static, symbol) {
  3033. var bit, i, m, price;
  3034. price = 0;
  3035. m = 1;
  3036. for (i = this$static.NumBitLevels; i != 0; --i) {
  3037. bit = symbol & 1;
  3038. symbol >>>= 1;
  3039. price += GetPrice(this$static.Models[m], bit);
  3040. m = m << 1 | bit;
  3041. }
  3042. return price;
  3043. }
  3044. function ReverseEncode(Models, startIndex, rangeEncoder, NumBitLevels, symbol) {
  3045. var bit, i, m;
  3046. m = 1;
  3047. for (i = 0; i < NumBitLevels; ++i) {
  3048. bit = symbol & 1;
  3049. $Encode_3(rangeEncoder, Models, startIndex + m, bit);
  3050. m = m << 1 | bit;
  3051. symbol >>= 1;
  3052. }
  3053. }
  3054. function ReverseGetPrice(Models, startIndex, NumBitLevels, symbol) {
  3055. var bit, i, m, price;
  3056. price = 0;
  3057. m = 1;
  3058. for (i = NumBitLevels; i != 0; --i) {
  3059. bit = symbol & 1;
  3060. symbol >>>= 1;
  3061. price += ($clinit_66() , ProbPrices[((Models[startIndex + m] - bit ^ -bit) & 2047) >>> 2]);
  3062. m = m << 1 | bit;
  3063. }
  3064. return price;
  3065. }
  3066. function getClass_43() {
  3067. return Lorg_dellroad_lzma_client_SevenZip_Compression_RangeCoder_BitTreeEncoder_2_classLit;
  3068. }
  3069. function BitTreeEncoder() {
  3070. }
  3071. _ = BitTreeEncoder.prototype = new Object_0();
  3072. _.getClass$ = getClass_43;
  3073. _.typeId$ = 21;
  3074. _.Models = null;
  3075. _.NumBitLevels = 0;
  3076. function $DecodeBit(this$static, probs, index) {
  3077. var newBound, prob;
  3078. prob = probs[index];
  3079. newBound = (this$static.Range >>> 11) * prob;
  3080. if ((this$static.Code ^ -2147483648) < (newBound ^ -2147483648)) {
  3081. this$static.Range = newBound;
  3082. probs[index] = prob + (2048 - prob >>> 5) << 16 >> 16;
  3083. if ((this$static.Range & -16777216) == 0) {
  3084. this$static.Code = this$static.Code << 8 | $read(this$static.Stream);
  3085. this$static.Range <<= 8;
  3086. }
  3087. return 0;
  3088. } else {
  3089. this$static.Range -= newBound;
  3090. this$static.Code -= newBound;
  3091. probs[index] = prob - (prob >>> 5) << 16 >> 16;
  3092. if ((this$static.Range & -16777216) == 0) {
  3093. this$static.Code = this$static.Code << 8 | $read(this$static.Stream);
  3094. this$static.Range <<= 8;
  3095. }
  3096. return 1;
  3097. }
  3098. }
  3099. function $DecodeDirectBits(this$static, numTotalBits) {
  3100. var i, result, t;
  3101. result = 0;
  3102. for (i = numTotalBits; i != 0; --i) {
  3103. this$static.Range >>>= 1;
  3104. t = this$static.Code - this$static.Range >>> 31;
  3105. this$static.Code -= this$static.Range & t - 1;
  3106. result = result << 1 | 1 - t;
  3107. if ((this$static.Range & -16777216) == 0) {
  3108. this$static.Code = this$static.Code << 8 | $read(this$static.Stream);
  3109. this$static.Range <<= 8;
  3110. }
  3111. }
  3112. return result;
  3113. }
  3114. function $Init_8(this$static) {
  3115. var i;
  3116. this$static.Code = 0;
  3117. this$static.Range = -1;
  3118. for (i = 0; i < 5; ++i) {
  3119. this$static.Code = this$static.Code << 8 | $read(this$static.Stream);
  3120. }
  3121. }
  3122. function InitBitModels(probs) {
  3123. var i;
  3124. for (i = 0; i < probs.length; ++i) {
  3125. probs[i] = 1024;
  3126. }
  3127. }
  3128. function getClass_44() {
  3129. return Lorg_dellroad_lzma_client_SevenZip_Compression_RangeCoder_Decoder_2_classLit;
  3130. }
  3131. function Decoder_0() {
  3132. }
  3133. _ = Decoder_0.prototype = new Object_0();
  3134. _.getClass$ = getClass_44;
  3135. _.typeId$ = 0;
  3136. _.Code = 0;
  3137. _.Range = 0;
  3138. _.Stream = null;
  3139. function $clinit_66() {
  3140. $clinit_66 = nullMethod;
  3141. var end, i, j, start;
  3142. ProbPrices = initDim(_3I_classLit, 0, -1, 512, 1);
  3143. for (i = 8; i >= 0; --i) {
  3144. start = 1 << 9 - i - 1;
  3145. end = 1 << 9 - i;
  3146. for (j = start; j < end; ++j) {
  3147. ProbPrices[j] = (i << 6) + (end - j << 6 >>> 9 - i - 1);
  3148. }
  3149. }
  3150. }
  3151. function $Encode_3(this$static, probs, index, symbol) {
  3152. var newBound, prob;
  3153. prob = probs[index];
  3154. newBound = (this$static.Range >>> 11) * prob;
  3155. if (symbol == 0) {
  3156. this$static.Range = newBound;
  3157. probs[index] = prob + (2048 - prob >>> 5) << 16 >> 16;
  3158. } else {
  3159. this$static.Low = add(this$static.Low, and(fromInt(newBound), Pffffffff_longLit));
  3160. this$static.Range -= newBound;
  3161. probs[index] = prob - (prob >>> 5) << 16 >> 16;
  3162. }
  3163. if ((this$static.Range & -16777216) == 0) {
  3164. this$static.Range <<= 8;
  3165. $ShiftLow(this$static);
  3166. }
  3167. }
  3168. function $EncodeDirectBits(this$static, v, numTotalBits) {
  3169. var i;
  3170. for (i = numTotalBits - 1; i >= 0; --i) {
  3171. this$static.Range >>>= 1;
  3172. if ((v >>> i & 1) == 1) {
  3173. this$static.Low = add(this$static.Low, fromInt(this$static.Range));
  3174. }
  3175. if ((this$static.Range & -16777216) == 0) {
  3176. this$static.Range <<= 8;
  3177. $ShiftLow(this$static);
  3178. }
  3179. }
  3180. }
  3181. function $FlushData(this$static) {
  3182. var i;
  3183. for (i = 0; i < 5; ++i) {
  3184. $ShiftLow(this$static);
  3185. }
  3186. }
  3187. function $GetProcessedSizeAdd(this$static) {
  3188. return add(add(fromInt(this$static._cacheSize), this$static._position), P4_longLit);
  3189. }
  3190. function $Init_9(this$static) {
  3191. this$static._position = P0_longLit;
  3192. this$static.Low = P0_longLit;
  3193. this$static.Range = -1;
  3194. this$static._cacheSize = 1;
  3195. this$static._cache = 0;
  3196. }
  3197. function $ShiftLow(this$static) {
  3198. var LowHi, temp;
  3199. LowHi = lowBits_0(shru(this$static.Low, 32));
  3200. if (LowHi != 0 || compare(this$static.Low, Pff000000_longLit) < 0) {
  3201. this$static._position = add(this$static._position, fromInt(this$static._cacheSize));
  3202. temp = this$static._cache;
  3203. do {
  3204. $write(this$static.Stream, temp + LowHi);
  3205. temp = 255;
  3206. } while (--this$static._cacheSize != 0);
  3207. this$static._cache = lowBits_0(this$static.Low) >>> 24;
  3208. }
  3209. ++this$static._cacheSize;
  3210. this$static.Low = shl(and(this$static.Low, Pffffff_longLit), 8);
  3211. }
  3212. function GetPrice(Prob, symbol) {
  3213. $clinit_66();
  3214. return ProbPrices[((Prob - symbol ^ -symbol) & 2047) >>> 2];
  3215. }
  3216. function InitBitModels_0(probs) {
  3217. $clinit_66();
  3218. var i;
  3219. for (i = 0; i < probs.length; ++i) {
  3220. probs[i] = 1024;
  3221. }
  3222. }
  3223. function getClass_45() {
  3224. return Lorg_dellroad_lzma_client_SevenZip_Compression_RangeCoder_Encoder_2_classLit;
  3225. }
  3226. function Encoder_0() {
  3227. }
  3228. _ = Encoder_0.prototype = new Object_0();
  3229. _.getClass$ = getClass_45;
  3230. _.typeId$ = 0;
  3231. _.Low = P0_longLit;
  3232. _.Range = 0;
  3233. _.Stream = null;
  3234. _._cache = 0;
  3235. _._cacheSize = 0;
  3236. _._position = P0_longLit;
  3237. var ProbPrices;
  3238. function decode(utf) {
  3239. var buf, i, x, y, z;
  3240. buf = $StringBuilder(new StringBuilder());
  3241. for (i = 0; i < utf.length; ++i) {
  3242. x = utf[i] & 255;
  3243. if ((x & 128) == 0) {
  3244. if (x == 0) {
  3245. throw $IllegalArgumentException(new IllegalArgumentException(), 'invalid UTF-8');
  3246. }
  3247. $appendNonNull(buf.data, String.fromCharCode(x & 65535));
  3248. } else if ((x & 224) == 192) {
  3249. if (i + 1 >= utf.length) {
  3250. throw $IllegalArgumentException(new IllegalArgumentException(), 'invalid UTF-8');
  3251. }
  3252. y = utf[++i] & 255;
  3253. if ((y & 192) != 128) {
  3254. throw $IllegalArgumentException(new IllegalArgumentException(), 'invalid UTF-8');
  3255. }
  3256. $append(buf.data, String.fromCharCode((x & 31) << 6 & 65535 | y & 63));
  3257. } else if ((x & 240) == 224) {
  3258. if (i + 2 >= utf.length) {
  3259. throw $IllegalArgumentException(new IllegalArgumentException(), 'invalid UTF-8');
  3260. }
  3261. y = utf[++i] & 255;
  3262. if ((y & 192) != 128) {
  3263. throw $IllegalArgumentException(new IllegalArgumentException(), 'invalid UTF-8');
  3264. }
  3265. z = utf[++i] & 255;
  3266. if ((z & 192) != 128) {
  3267. throw $IllegalArgumentException(new IllegalArgumentException(), 'invalid UTF-8');
  3268. }
  3269. $appendNonNull(buf.data, String.fromCharCode(((x & 15) << 12 | (y & 63) << 6 | z & 63) & 65535));
  3270. } else {
  3271. throw $IllegalArgumentException(new IllegalArgumentException(), 'invalid UTF-8');
  3272. }
  3273. }
  3274. return $toString(buf.data);
  3275. }
  3276. function encode(s) {
  3277. var ch, chars, data, elen, i, charArr, n;
  3278. chars = (n = s.length , charArr = initDim(_3C_classLit, 0, -1, n, 1) , $getChars(s, 0, n, charArr, 0) , charArr);
  3279. elen = 0;
  3280. for (i = 0; i < s.length; ++i) {
  3281. ch = chars[i];
  3282. if (ch >= 1 && ch <= 127) {
  3283. ++elen;
  3284. } else if (ch == 0 || ch >= 128 && ch <= 2047) {
  3285. elen += 2;
  3286. } else {
  3287. elen += 3;
  3288. }
  3289. }
  3290. data = initDim(_3B_classLit, 0, -1, elen, 1);
  3291. elen = 0;
  3292. for (i = 0; i < s.length; ++i) {
  3293. ch = chars[i];
  3294. if (ch >= 1 && ch <= 127) {
  3295. data[elen++] = ch << 24 >> 24;
  3296. } else if (ch == 0 || ch >= 128 && ch <= 2047) {
  3297. data[elen++] = (192 | ch >> 6 & 31) << 24 >> 24;
  3298. data[elen++] = (128 | ch & 63) << 24 >> 24;
  3299. } else {
  3300. data[elen++] = (224 | ch >> 12 & 15) << 24 >> 24;
  3301. data[elen++] = (128 | ch >> 6 & 63) << 24 >> 24;
  3302. data[elen++] = (128 | ch & 63) << 24 >> 24;
  3303. }
  3304. }
  3305. return data;
  3306. }
  3307. function $LZMADemo(this$static) {
  3308. return this$static;
  3309. }
  3310. function toDouble(a) {
  3311. return a[1] + a[0];
  3312. }
  3313. function compress() {
  3314. var this$static = $LZMADemo(new LZMADemo()),
  3315. percent,
  3316. start,
  3317. /// Arguments
  3318. str = arguments[0],
  3319. mode = arguments[1],
  3320. callback_num,
  3321. on_finish,
  3322. on_progress;
  3323. if (typeof arguments[2] === "function") {
  3324. on_finish = arguments[2];
  3325. if (typeof arguments[3] === "function") {
  3326. on_progress = arguments[3];
  3327. }
  3328. } else {
  3329. callback_num = arguments[2];
  3330. }
  3331. this$static.mode = get_mode_obj(mode);
  3332. this$static.c = $LZMAByteArrayCompressor(new LZMAByteArrayCompressor(), encode(str), this$static.mode);
  3333. if (on_progress) {
  3334. on_progress(0);
  3335. } else if (typeof callback_num !== "undefined") {
  3336. update_progress(0, callback_num);
  3337. }
  3338. function do_action() {
  3339. var res;
  3340. start = (new Date).getTime();
  3341. while ($execute(this$static.c)) {
  3342. percent = toDouble(this$static.c.chunker.inBytesProcessed) / toDouble(this$static.c.length_0);
  3343. /// If about 200 miliseconds have passed, update the progress.
  3344. if ((new Date).getTime() - start > 200) {
  3345. if (on_progress) {
  3346. on_progress(percent);
  3347. } else if (typeof callback_num !== "undefined") {
  3348. update_progress(percent, callback_num);
  3349. }
  3350. setTimeout(do_action, 0);
  3351. return false;
  3352. }
  3353. }
  3354. if (on_progress) {
  3355. on_progress(1);
  3356. } else if (typeof callback_num !== "undefined") {
  3357. update_progress(1, callback_num);
  3358. }
  3359. /// .slice(0) is required for Firefox 4.0 (because I think arrays are now passed by reference, which is not allowed when sending messages to or from web workers).
  3360. /// .slice(0) simply returns the entire array by value.
  3361. res = $toByteArray(this$static.c.output).slice(0);
  3362. if (on_finish) {
  3363. on_finish(res);
  3364. } else if (typeof callback_num !== "undefined") {
  3365. postMessage({
  3366. action: action_compress,
  3367. callback_num: callback_num,
  3368. result: res
  3369. });
  3370. }
  3371. }
  3372. setTimeout(do_action, 1);
  3373. }
  3374. function decompress() {
  3375. var this$static = $LZMADemo(new LZMADemo()),
  3376. percent,
  3377. data,
  3378. start,
  3379. text,
  3380. /// Arguments
  3381. byte_arr = arguments[0],
  3382. callback_num,
  3383. on_finish,
  3384. on_progress;
  3385. if (typeof arguments[1] === "function") {
  3386. on_finish = arguments[1];
  3387. if (typeof arguments[2] === "function") {
  3388. on_progress = arguments[2];
  3389. }
  3390. } else {
  3391. callback_num = arguments[1];
  3392. }
  3393. data = initValues(_3B_classLit, 0, -1, byte_arr);
  3394. this$static.d = $LZMAByteArrayDecompressor(new LZMAByteArrayDecompressor(), data);
  3395. if (on_progress) {
  3396. on_progress(0);
  3397. } else if (typeof callback_num !== "undefined") {
  3398. update_progress(0, callback_num);
  3399. }
  3400. function do_action() {
  3401. var res;
  3402. start = (new Date).getTime();
  3403. while ($execute_0(this$static.d)) {
  3404. percent = toDouble(this$static.d.chunker.decoder.nowPos64) / toDouble(this$static.d.length_0);
  3405. /// If about 200 miliseconds have passed, update the progress.
  3406. if ((new Date).getTime() - start > 200) {
  3407. if (on_progress) {
  3408. on_progress(percent);
  3409. } else if (typeof callback_num !== "undefined") {
  3410. update_progress(percent, callback_num);
  3411. }
  3412. setTimeout(do_action, 0);
  3413. return false;
  3414. }
  3415. }
  3416. if (on_progress) {
  3417. on_progress(1);
  3418. } else if (typeof callback_num !== "undefined") {
  3419. update_progress(1, callback_num);
  3420. }
  3421. res = decode($toByteArray(this$static.d.output));
  3422. if (on_finish) {
  3423. on_finish(res);
  3424. } else if (typeof callback_num !== "undefined") {
  3425. postMessage({
  3426. action: action_decompress,
  3427. callback_num: callback_num,
  3428. result: res
  3429. });
  3430. }
  3431. }
  3432. setTimeout(do_action, 0);
  3433. }
  3434. function $onModuleLoad(this$static) {
  3435. compress(this$static);
  3436. decompress(this$static);
  3437. }
  3438. function getClass_46() {
  3439. return Lorg_dellroad_lzma_demo_client_LZMADemo_2_classLit;
  3440. }
  3441. function LZMADemo () {}
  3442. _ = LZMADemo.prototype = new Object_0();
  3443. _.getClass$ = getClass_46;
  3444. _.typeId$ = 0;
  3445. _.c = null;
  3446. _.d = null;
  3447. var DEFAULT_COMPRESSION_MODE;
  3448. function init() {
  3449. !!$stats && $stats({moduleName:$moduleName, subSystem:'startup', evtGroup:'moduleStartup', millis:(new Date()).getTime(), type:'onModuleLoadStart', className:'org.dellroad.lzma.demo.client.LZMADemo'});
  3450. }
  3451. function gwtOnLoad(errFn, modName, modBase) {
  3452. $moduleName = modName;
  3453. $moduleBase = modBase;
  3454. if (errFn) {
  3455. try {
  3456. init();
  3457. }
  3458. catch (e) {
  3459. errFn(modName);
  3460. }
  3461. } else {
  3462. init();
  3463. }
  3464. }
  3465. function nullMethod() {
  3466. }
  3467. var Ljava_lang_Object_2_classLit = createForClass('java.lang.', 'Object'),
  3468. Ljava_lang_Throwable_2_classLit = createForClass('java.lang.', 'Throwable'),
  3469. Ljava_lang_Exception_2_classLit = createForClass('java.lang.', 'Exception'),
  3470. Ljava_lang_RuntimeException_2_classLit = createForClass('java.lang.', 'RuntimeException'),
  3471. Lcom_google_gwt_core_client_JavaScriptException_2_classLit = createForClass('com.google.gwt.core.client.', 'JavaScriptException'),
  3472. Lcom_google_gwt_core_client_JavaScriptObject_2_classLit = createForClass('com.google.gwt.core.client.', 'JavaScriptObject$'), _3_3D_classLit = createForArray('', '[[D'),
  3473. Ljava_io_InputStream_2_classLit = createForClass('java.io.', 'InputStream'),
  3474. Ljava_io_ByteArrayInputStream_2_classLit = createForClass('java.io.', 'ByteArrayInputStream'), _3B_classLit = createForArray('', '[B'),
  3475. Ljava_io_OutputStream_2_classLit = createForClass('java.io.', 'OutputStream'),
  3476. Ljava_io_ByteArrayOutputStream_2_classLit = createForClass('java.io.', 'ByteArrayOutputStream'),
  3477. Ljava_io_IOException_2_classLit = createForClass('java.io.', 'IOException'),
  3478. Ljava_lang_Enum_2_classLit = createForClass('java.lang.', 'Enum'),
  3479. Ljava_lang_ArithmeticException_2_classLit = createForClass('java.lang.', 'ArithmeticException'),
  3480. Ljava_lang_ArrayStoreException_2_classLit = createForClass('java.lang.', 'ArrayStoreException'), _3C_classLit = createForArray('', '[C'),
  3481. Ljava_lang_Class_2_classLit = createForClass('java.lang.', 'Class'),
  3482. Ljava_lang_ClassCastException_2_classLit = createForClass('java.lang.', 'ClassCastException'),
  3483. Ljava_lang_IllegalArgumentException_2_classLit = createForClass('java.lang.', 'IllegalArgumentException'),
  3484. Ljava_lang_IllegalStateException_2_classLit = createForClass('java.lang.', 'IllegalStateException'),
  3485. Ljava_lang_IndexOutOfBoundsException_2_classLit = createForClass('java.lang.', 'IndexOutOfBoundsException'), _3I_classLit = createForArray('', '[I'),
  3486. Ljava_lang_NullPointerException_2_classLit = createForClass('java.lang.', 'NullPointerException'),
  3487. Ljava_lang_String_2_classLit = createForClass('java.lang.', 'String'),
  3488. Ljava_lang_StringBuilder_2_classLit = createForClass('java.lang.', 'StringBuilder'),
  3489. Lorg_dellroad_lzma_client_SevenZip_Compression_LZ_InWindow_2_classLit = createForClass('org.dellroad.lzma.client.SevenZip.Compression.LZ.', 'InWindow'),
  3490. Lorg_dellroad_lzma_client_SevenZip_Compression_LZ_BinTree_2_classLit = createForClass('org.dellroad.lzma.client.SevenZip.Compression.LZ.', 'BinTree'),
  3491. Lorg_dellroad_lzma_client_SevenZip_Compression_LZ_OutWindow_2_classLit = createForClass('org.dellroad.lzma.client.SevenZip.Compression.LZ.', 'OutWindow'),
  3492. Lorg_dellroad_lzma_client_SevenZip_Compression_LZMA_Chunker_2_classLit = createForClass('org.dellroad.lzma.client.SevenZip.Compression.LZMA.', 'Chunker'), _3S_classLit = createForArray('', '[S'), _3Lorg_dellroad_lzma_client_SevenZip_Compression_RangeCoder_BitTreeDecoder_2_classLit = createForArray('[Lorg.dellroad.lzma.client.SevenZip.Compression.RangeCoder.', 'BitTreeDecoder;'),
  3493. Lorg_dellroad_lzma_client_SevenZip_Compression_LZMA_Decoder_2_classLit = createForClass('org.dellroad.lzma.client.SevenZip.Compression.LZMA.', 'Decoder'),
  3494. Lorg_dellroad_lzma_client_SevenZip_Compression_LZMA_Decoder$LenDecoder_2_classLit = createForClass('org.dellroad.lzma.client.SevenZip.Compression.LZMA.', 'Decoder$LenDecoder'), _3Lorg_dellroad_lzma_client_SevenZip_Compression_LZMA_Decoder$LiteralDecoder$Decoder2_2_classLit = createForArray('[Lorg.dellroad.lzma.client.SevenZip.Compression.LZMA.', 'Decoder$LiteralDecoder$Decoder2;'),
  3495. Lorg_dellroad_lzma_client_SevenZip_Compression_LZMA_Decoder$LiteralDecoder_2_classLit = createForClass('org.dellroad.lzma.client.SevenZip.Compression.LZMA.', 'Decoder$LiteralDecoder'),
  3496. Lorg_dellroad_lzma_client_SevenZip_Compression_LZMA_Decoder$LiteralDecoder$Decoder2_2_classLit = createForClass('org.dellroad.lzma.client.SevenZip.Compression.LZMA.', 'Decoder$LiteralDecoder$Decoder2'), _3Lorg_dellroad_lzma_client_SevenZip_Compression_LZMA_Encoder$Optimal_2_classLit = createForArray('[Lorg.dellroad.lzma.client.SevenZip.Compression.LZMA.', 'Encoder$Optimal;'), _3Lorg_dellroad_lzma_client_SevenZip_Compression_RangeCoder_BitTreeEncoder_2_classLit = createForArray('[Lorg.dellroad.lzma.client.SevenZip.Compression.RangeCoder.', 'BitTreeEncoder;'), _3J_classLit = createForArray('', '[J'), _3Z_classLit = createForArray('', '[Z'),
  3497. Lorg_dellroad_lzma_client_SevenZip_Compression_LZMA_Encoder_2_classLit = createForClass('org.dellroad.lzma.client.SevenZip.Compression.LZMA.', 'Encoder'), _3Lorg_dellroad_lzma_client_SevenZip_Compression_LZMA_Encoder$LiteralEncoder$Encoder2_2_classLit = createForArray('[Lorg.dellroad.lzma.client.SevenZip.Compression.LZMA.', 'Encoder$LiteralEncoder$Encoder2;'),
  3498. Lorg_dellroad_lzma_client_SevenZip_Compression_LZMA_Encoder$LiteralEncoder_2_classLit = createForClass('org.dellroad.lzma.client.SevenZip.Compression.LZMA.', 'Encoder$LiteralEncoder'),
  3499. Lorg_dellroad_lzma_client_SevenZip_Compression_LZMA_Encoder$LiteralEncoder$Encoder2_2_classLit = createForClass('org.dellroad.lzma.client.SevenZip.Compression.LZMA.', 'Encoder$LiteralEncoder$Encoder2'),
  3500. Lorg_dellroad_lzma_client_SevenZip_Compression_LZMA_Encoder$LenEncoder_2_classLit = createForClass('org.dellroad.lzma.client.SevenZip.Compression.LZMA.', 'Encoder$LenEncoder'),
  3501. Lorg_dellroad_lzma_client_SevenZip_Compression_LZMA_Encoder$LenPriceTableEncoder_2_classLit = createForClass('org.dellroad.lzma.client.SevenZip.Compression.LZMA.', 'Encoder$LenPriceTableEncoder'),
  3502. Lorg_dellroad_lzma_client_SevenZip_Compression_LZMA_Encoder$Optimal_2_classLit = createForClass('org.dellroad.lzma.client.SevenZip.Compression.LZMA.', 'Encoder$Optimal'),
  3503. Lorg_dellroad_lzma_client_SevenZip_Compression_RangeCoder_BitTreeDecoder_2_classLit = createForClass('org.dellroad.lzma.client.SevenZip.Compression.RangeCoder.', 'BitTreeDecoder'),
  3504. Lorg_dellroad_lzma_client_SevenZip_Compression_RangeCoder_BitTreeEncoder_2_classLit = createForClass('org.dellroad.lzma.client.SevenZip.Compression.RangeCoder.', 'BitTreeEncoder'),
  3505. Lorg_dellroad_lzma_client_SevenZip_Compression_RangeCoder_Decoder_2_classLit = createForClass('org.dellroad.lzma.client.SevenZip.Compression.RangeCoder.', 'Decoder'),
  3506. Lorg_dellroad_lzma_client_SevenZip_Compression_RangeCoder_Encoder_2_classLit = createForClass('org.dellroad.lzma.client.SevenZip.Compression.RangeCoder.', 'Encoder'),
  3507. Lorg_dellroad_lzma_client_CompressionMode_2_classLit = createForEnum('org.dellroad.lzma.client.', 'CompressionMode'),
  3508. Lorg_dellroad_lzma_client_LZMACompressor_2_classLit = createForClass('org.dellroad.lzma.client.', 'LZMACompressor'),
  3509. Lorg_dellroad_lzma_client_LZMAByteArrayCompressor_2_classLit = createForClass('org.dellroad.lzma.client.', 'LZMAByteArrayCompressor'),
  3510. Lorg_dellroad_lzma_client_LZMADecompressor_2_classLit = createForClass('org.dellroad.lzma.client.', 'LZMADecompressor'),
  3511. Lorg_dellroad_lzma_client_LZMAByteArrayDecompressor_2_classLit = createForClass('org.dellroad.lzma.client.', 'LZMAByteArrayDecompressor'),
  3512. Lorg_dellroad_lzma_demo_client_LZMADemo_2_classLit = createForClass('org.dellroad.lzma.demo.client.', 'LZMADemo');
  3513. gwtOnLoad(function() {},'lzma_demo','');
  3514. var get_mode_obj = (function () {
  3515. var modes = [
  3516. {dictionarySize: 16, fb: 64, matchFinder: 0, lc: 3, lp: 0, pb: 2},
  3517. {dictionarySize: 20, fb: 64, matchFinder: 0, lc: 3, lp: 0, pb: 2},
  3518. {dictionarySize: 19, fb: 64, matchFinder: 1, lc: 3, lp: 0, pb: 2},
  3519. {dictionarySize: 20, fb: 64, matchFinder: 1, lc: 3, lp: 0, pb: 2},
  3520. {dictionarySize: 21, fb: 128, matchFinder: 1, lc: 3, lp: 0, pb: 2},
  3521. {dictionarySize: 22, fb: 128, matchFinder: 1, lc: 3, lp: 0, pb: 2},
  3522. {dictionarySize: 23, fb: 128, matchFinder: 1, lc: 3, lp: 0, pb: 2},
  3523. {dictionarySize: 24, fb: 255, matchFinder: 1, lc: 3, lp: 0, pb: 2},
  3524. {dictionarySize: 25, fb: 255, matchFinder: 1, lc: 3, lp: 0, pb: 2}
  3525. ];
  3526. function isNumber(n) {
  3527. return !isNaN(parseFloat(n)) && isFinite(n);
  3528. }
  3529. return function (mode) {
  3530. if (!isNumber(mode)) {
  3531. mode = 1;
  3532. } else {
  3533. if (mode < 1) {
  3534. mode = 1;
  3535. } else if (mode > 9) {
  3536. mode = 9;
  3537. }
  3538. }
  3539. return modes[mode - 1];
  3540. }
  3541. }());
  3542. return {
  3543. compress: compress,
  3544. decompress: decompress
  3545. };
  3546. }());
  3547. /// Allow node.js to be able to access this directly if it is included directly.
  3548. this.LZMA = LZMA;
  3549. // CartoDB.js version: 3.15.10
  3550. // sha: b0f743801efcdf67255637c955b8fcfc9e811f64
  3551. ! function() {
  3552. function MapProperties(a) { this.mapProperties = a }
  3553. function MapBase(a) {
  3554. var b = this;
  3555. this.options = _.defaults(a, { ajax: window.$ ? window.$.ajax : reqwest.compat, pngParams: ["map_key", "api_key", "cache_policy", "updated_at"], gridParams: ["map_key", "api_key", "cache_policy", "updated_at"], cors: cdb.core.util.isCORSSupported(), MAX_GET_SIZE: 2033, force_cors: !1, instanciateCallback: function() {
  3556. return "_cdbc_" + b._callbackName() } }), this.mapProperties = null, this.urls = null, this.silent = !1, this.interactionEnabled = [], this._timeout = -1, this._createMapCallsStack = [], this._createMapCallbacks = [], this._waiting = !1, this.lastTimeUpdated = null, this._refreshTimer = -1, this.options.maps_api_template || this._buildMapsApiTemplate(this.options) }
  3557. function LayerDefinition(a, b) { MapBase.call(this, b), this.endPoint = MapBase.BASE_URL, this.setLayerDefinition(a, { silent: !0 }) }
  3558. function NamedMap(a, b) { MapBase.call(this, b), this.options.pngParams.push("auth_token"), this.options.gridParams.push("auth_token"), this.setLayerDefinition(a, b), this.stat_tag = a.stat_tag }
  3559. function SubLayerFactory() {}
  3560. function SubLayerBase(a, b) { this._parent = a, this._position = b, this._added = !0 }
  3561. function CartoDBSubLayer(a, b) { SubLayerBase.call(this, a, b), this._bindInteraction();
  3562. var a = this._parent.getLayer(this._position);
  3563. Backbone.Model && a && (this.infowindow = new Backbone.Model(a.infowindow), this.infowindow.bind("change", function() { a.infowindow = this.infowindow.toJSON(), this._parent.setLayer(this._position, a) }, this)) }
  3564. function HttpSubLayer(a, b) { SubLayerBase.call(this, a, b) }
  3565. this.cartodb = {};
  3566. var Backbone = {};
  3567. (function() {
  3568. var a = this,
  3569. b = a._,
  3570. c = {},
  3571. d = Array.prototype,
  3572. e = Object.prototype,
  3573. f = Function.prototype,
  3574. g = d.push,
  3575. h = d.slice,
  3576. i = d.concat,
  3577. j = e.toString,
  3578. k = e.hasOwnProperty,
  3579. l = d.forEach,
  3580. m = d.map,
  3581. n = d.reduce,
  3582. o = d.reduceRight,
  3583. p = d.filter,
  3584. q = d.every,
  3585. r = d.some,
  3586. s = d.indexOf,
  3587. t = d.lastIndexOf,
  3588. u = Array.isArray,
  3589. v = Object.keys,
  3590. w = f.bind,
  3591. x = function(a) {
  3592. return a instanceof x ? a : this instanceof x ? void(this._wrapped = a) : new x(a) }; "undefined" != typeof exports ? ("undefined" != typeof module && module.exports && (exports = module.exports = x), exports._ = x) : a._ = x, x.VERSION = "1.4.4";
  3593. var y = x.each = x.forEach = function(a, b, d) {
  3594. if (null != a)
  3595. if (l && a.forEach === l) a.forEach(b, d);
  3596. else if (a.length === +a.length) {
  3597. for (var e = 0, f = a.length; f > e; e++)
  3598. if (b.call(d, a[e], e, a) === c) return } else
  3599. for (var g in a)
  3600. if (x.has(a, g) && b.call(d, a[g], g, a) === c) return };
  3601. x.map = x.collect = function(a, b, c) {
  3602. var d = [];
  3603. return null == a ? d : m && a.map === m ? a.map(b, c) : (y(a, function(a, e, f) { d[d.length] = b.call(c, a, e, f) }), d) };
  3604. var z = "Reduce of empty array with no initial value";
  3605. x.reduce = x.foldl = x.inject = function(a, b, c, d) {
  3606. var e = arguments.length > 2;
  3607. if (null == a && (a = []), n && a.reduce === n) return d && (b = x.bind(b, d)), e ? a.reduce(b, c) : a.reduce(b);
  3608. if (y(a, function(a, f, g) { e ? c = b.call(d, c, a, f, g) : (c = a, e = !0) }), !e) throw new TypeError(z);
  3609. return c }, x.reduceRight = x.foldr = function(a, b, c, d) {
  3610. var e = arguments.length > 2;
  3611. if (null == a && (a = []), o && a.reduceRight === o) return d && (b = x.bind(b, d)), e ? a.reduceRight(b, c) : a.reduceRight(b);
  3612. var f = a.length;
  3613. if (f !== +f) {
  3614. var g = x.keys(a);
  3615. f = g.length }
  3616. if (y(a, function(h, i, j) { i = g ? g[--f] : --f, e ? c = b.call(d, c, a[i], i, j) : (c = a[i], e = !0) }), !e) throw new TypeError(z);
  3617. return c }, x.find = x.detect = function(a, b, c) {
  3618. var d;
  3619. return A(a, function(a, e, f) {
  3620. return b.call(c, a, e, f) ? (d = a, !0) : void 0 }), d }, x.filter = x.select = function(a, b, c) {
  3621. var d = [];
  3622. return null == a ? d : p && a.filter === p ? a.filter(b, c) : (y(a, function(a, e, f) { b.call(c, a, e, f) && (d[d.length] = a) }), d) }, x.reject = function(a, b, c) {
  3623. return x.filter(a, function(a, d, e) {
  3624. return !b.call(c, a, d, e) }, c) }, x.every = x.all = function(a, b, d) { b || (b = x.identity);
  3625. var e = !0;
  3626. return null == a ? e : q && a.every === q ? a.every(b, d) : (y(a, function(a, f, g) {
  3627. return (e = e && b.call(d, a, f, g)) ? void 0 : c }), !!e) };
  3628. var A = x.some = x.any = function(a, b, d) { b || (b = x.identity);
  3629. var e = !1;
  3630. return null == a ? e : r && a.some === r ? a.some(b, d) : (y(a, function(a, f, g) {
  3631. return e || (e = b.call(d, a, f, g)) ? c : void 0 }), !!e) };
  3632. x.contains = x.include = function(a, b) {
  3633. return null == a ? !1 : s && a.indexOf === s ? -1 != a.indexOf(b) : A(a, function(a) {
  3634. return a === b }) }, x.invoke = function(a, b) {
  3635. var c = h.call(arguments, 2),
  3636. d = x.isFunction(b);
  3637. return x.map(a, function(a) {
  3638. return (d ? b : a[b]).apply(a, c) }) }, x.pluck = function(a, b) {
  3639. return x.map(a, function(a) {
  3640. return a[b] }) }, x.where = function(a, b, c) {
  3641. return x.isEmpty(b) ? c ? null : [] : x[c ? "find" : "filter"](a, function(a) {
  3642. for (var c in b)
  3643. if (b[c] !== a[c]) return !1;
  3644. return !0 }) }, x.findWhere = function(a, b) {
  3645. return x.where(a, b, !0) }, x.max = function(a, b, c) {
  3646. if (!b && x.isArray(a) && a[0] === +a[0] && 65535 > a.length) return Math.max.apply(Math, a);
  3647. if (!b && x.isEmpty(a)) return -1 / 0;
  3648. var d = { computed: -1 / 0, value: -1 / 0 };
  3649. return y(a, function(a, e, f) {
  3650. var g = b ? b.call(c, a, e, f) : a;
  3651. g >= d.computed && (d = { value: a, computed: g }) }), d.value }, x.min = function(a, b, c) {
  3652. if (!b && x.isArray(a) && a[0] === +a[0] && 65535 > a.length) return Math.min.apply(Math, a);
  3653. if (!b && x.isEmpty(a)) return 1 / 0;
  3654. var d = { computed: 1 / 0, value: 1 / 0 };
  3655. return y(a, function(a, e, f) {
  3656. var g = b ? b.call(c, a, e, f) : a;
  3657. d.computed > g && (d = { value: a, computed: g }) }), d.value }, x.shuffle = function(a) {
  3658. var b, c = 0,
  3659. d = [];
  3660. return y(a, function(a) { b = x.random(c++), d[c - 1] = d[b], d[b] = a }), d };
  3661. var B = function(a) {
  3662. return x.isFunction(a) ? a : function(b) {
  3663. return b[a] } };
  3664. x.sortBy = function(a, b, c) {
  3665. var d = B(b);
  3666. return x.pluck(x.map(a, function(a, b, e) {
  3667. return { value: a, index: b, criteria: d.call(c, a, b, e) } }).sort(function(a, b) {
  3668. var c = a.criteria,
  3669. d = b.criteria;
  3670. if (c !== d) {
  3671. if (c > d || void 0 === c) return 1;
  3672. if (d > c || void 0 === d) return -1 }
  3673. return a.index < b.index ? -1 : 1 }), "value") };
  3674. var C = function(a, b, c, d) {
  3675. var e = {},
  3676. f = B(b || x.identity);
  3677. return y(a, function(b, g) {
  3678. var h = f.call(c, b, g, a);
  3679. d(e, h, b) }), e };
  3680. x.groupBy = function(a, b, c) {
  3681. return C(a, b, c, function(a, b, c) {
  3682. (x.has(a, b) ? a[b] : a[b] = []).push(c) }) }, x.countBy = function(a, b, c) {
  3683. return C(a, b, c, function(a, b) { x.has(a, b) || (a[b] = 0), a[b]++ }) }, x.sortedIndex = function(a, b, c, d) { c = null == c ? x.identity : B(c);
  3684. for (var e = c.call(d, b), f = 0, g = a.length; g > f;) {
  3685. var h = f + g >>> 1;
  3686. e > c.call(d, a[h]) ? f = h + 1 : g = h }
  3687. return f }, x.toArray = function(a) {
  3688. return a ? x.isArray(a) ? h.call(a) : a.length === +a.length ? x.map(a, x.identity) : x.values(a) : [] }, x.size = function(a) {
  3689. return null == a ? 0 : a.length === +a.length ? a.length : x.keys(a).length }, x.first = x.head = x.take = function(a, b, c) {
  3690. return null == a ? void 0 : null == b || c ? a[0] : h.call(a, 0, b) }, x.initial = function(a, b, c) {
  3691. return h.call(a, 0, a.length - (null == b || c ? 1 : b)) }, x.last = function(a, b, c) {
  3692. return null == a ? void 0 : null == b || c ? a[a.length - 1] : h.call(a, Math.max(a.length - b, 0)) }, x.rest = x.tail = x.drop = function(a, b, c) {
  3693. return h.call(a, null == b || c ? 1 : b) }, x.compact = function(a) {
  3694. return x.filter(a, x.identity) };
  3695. var D = function(a, b, c) {
  3696. return y(a, function(a) { x.isArray(a) ? b ? g.apply(c, a) : D(a, b, c) : c.push(a) }), c };
  3697. x.flatten = function(a, b) {
  3698. return D(a, b, []) }, x.without = function(a) {
  3699. return x.difference(a, h.call(arguments, 1)) }, x.uniq = x.unique = function(a, b, c, d) { x.isFunction(b) && (d = c, c = b, b = !1);
  3700. var e = c ? x.map(a, c, d) : a,
  3701. f = [],
  3702. g = [];
  3703. return y(e, function(c, d) {
  3704. (b ? d && g[g.length - 1] === c : x.contains(g, c)) || (g.push(c), f.push(a[d])) }), f }, x.union = function() {
  3705. return x.uniq(i.apply(d, arguments)) }, x.intersection = function(a) {
  3706. var b = h.call(arguments, 1);
  3707. return x.filter(x.uniq(a), function(a) {
  3708. return x.every(b, function(b) {
  3709. return x.indexOf(b, a) >= 0 }) }) }, x.difference = function(a) {
  3710. var b = i.apply(d, h.call(arguments, 1));
  3711. return x.filter(a, function(a) {
  3712. return !x.contains(b, a) }) }, x.zip = function() {
  3713. for (var a = h.call(arguments), b = x.max(x.pluck(a, "length")), c = Array(b), d = 0; b > d; d++) c[d] = x.pluck(a, "" + d);
  3714. return c }, x.object = function(a, b) {
  3715. if (null == a) return {};
  3716. for (var c = {}, d = 0, e = a.length; e > d; d++) b ? c[a[d]] = b[d] : c[a[d][0]] = a[d][1];
  3717. return c }, x.indexOf = function(a, b, c) {
  3718. if (null == a) return -1;
  3719. var d = 0,
  3720. e = a.length;
  3721. if (c) {
  3722. if ("number" != typeof c) return d = x.sortedIndex(a, b), a[d] === b ? d : -1;
  3723. d = 0 > c ? Math.max(0, e + c) : c }
  3724. if (s && a.indexOf === s) return a.indexOf(b, c);
  3725. for (; e > d; d++)
  3726. if (a[d] === b) return d;
  3727. return -1 }, x.lastIndexOf = function(a, b, c) {
  3728. if (null == a) return -1;
  3729. var d = null != c;
  3730. if (t && a.lastIndexOf === t) return d ? a.lastIndexOf(b, c) : a.lastIndexOf(b);
  3731. for (var e = d ? c : a.length; e--;)
  3732. if (a[e] === b) return e;
  3733. return -1 }, x.range = function(a, b, c) { 1 >= arguments.length && (b = a || 0, a = 0), c = arguments[2] || 1;
  3734. for (var d = Math.max(Math.ceil((b - a) / c), 0), e = 0, f = Array(d); d > e;) f[e++] = a, a += c;
  3735. return f }, x.bind = function(a, b) {
  3736. if (a.bind === w && w) return w.apply(a, h.call(arguments, 1));
  3737. var c = h.call(arguments, 2);
  3738. return function() {
  3739. return a.apply(b, c.concat(h.call(arguments))) } }, x.partial = function(a) {
  3740. var b = h.call(arguments, 1);
  3741. return function() {
  3742. return a.apply(this, b.concat(h.call(arguments))) } }, x.bindAll = function(a) {
  3743. var b = h.call(arguments, 1);
  3744. return 0 === b.length && (b = x.functions(a)), y(b, function(b) { a[b] = x.bind(a[b], a) }), a }, x.memoize = function(a, b) {
  3745. var c = {};
  3746. return b || (b = x.identity),
  3747. function() {
  3748. var d = b.apply(this, arguments);
  3749. return x.has(c, d) ? c[d] : c[d] = a.apply(this, arguments) } }, x.delay = function(a, b) {
  3750. var c = h.call(arguments, 2);
  3751. return setTimeout(function() {
  3752. return a.apply(null, c) }, b) }, x.defer = function(a) {
  3753. return x.delay.apply(x, [a, 1].concat(h.call(arguments, 1))) }, x.throttle = function(a, b) {
  3754. var c, d, e, f, g = 0,
  3755. h = function() { g = new Date, e = null, f = a.apply(c, d) };
  3756. return function() {
  3757. var i = new Date,
  3758. j = b - (i - g);
  3759. return c = this, d = arguments, 0 >= j ? (clearTimeout(e), e = null, g = i, f = a.apply(c, d)) : e || (e = setTimeout(h, j)), f } }, x.debounce = function(a, b, c) {
  3760. var d, e;
  3761. return function() {
  3762. var f = this,
  3763. g = arguments,
  3764. h = function() { d = null, c || (e = a.apply(f, g)) },
  3765. i = c && !d;
  3766. return clearTimeout(d), d = setTimeout(h, b), i && (e = a.apply(f, g)), e } }, x.once = function(a) {
  3767. var b, c = !1;
  3768. return function() {
  3769. return c ? b : (c = !0, b = a.apply(this, arguments), a = null, b) } }, x.wrap = function(a, b) {
  3770. return function() {
  3771. var c = [a];
  3772. return g.apply(c, arguments), b.apply(this, c) } }, x.compose = function() {
  3773. var a = arguments;
  3774. return function() {
  3775. for (var b = arguments, c = a.length - 1; c >= 0; c--) b = [a[c].apply(this, b)];
  3776. return b[0] } }, x.after = function(a, b) {
  3777. return 0 >= a ? b() : function() {
  3778. return 1 > --a ? b.apply(this, arguments) : void 0 } }, x.keys = v || function(a) {
  3779. if (a !== Object(a)) throw new TypeError("Invalid object");
  3780. var b = [];
  3781. for (var c in a) x.has(a, c) && (b[b.length] = c);
  3782. return b }, x.values = function(a) {
  3783. var b = [];
  3784. for (var c in a) x.has(a, c) && b.push(a[c]);
  3785. return b }, x.pairs = function(a) {
  3786. var b = [];
  3787. for (var c in a) x.has(a, c) && b.push([c, a[c]]);
  3788. return b }, x.invert = function(a) {
  3789. var b = {};
  3790. for (var c in a) x.has(a, c) && (b[a[c]] = c);
  3791. return b }, x.functions = x.methods = function(a) {
  3792. var b = [];
  3793. for (var c in a) x.isFunction(a[c]) && b.push(c);
  3794. return b.sort() }, x.extend = function(a) {
  3795. return y(h.call(arguments, 1), function(b) {
  3796. if (b)
  3797. for (var c in b) a[c] = b[c] }), a }, x.pick = function(a) {
  3798. var b = {},
  3799. c = i.apply(d, h.call(arguments, 1));
  3800. return y(c, function(c) { c in a && (b[c] = a[c]) }), b }, x.omit = function(a) {
  3801. var b = {},
  3802. c = i.apply(d, h.call(arguments, 1));
  3803. for (var e in a) x.contains(c, e) || (b[e] = a[e]);
  3804. return b }, x.defaults = function(a) {
  3805. return y(h.call(arguments, 1), function(b) {
  3806. if (b)
  3807. for (var c in b) null == a[c] && (a[c] = b[c]) }), a }, x.clone = function(a) {
  3808. return x.isObject(a) ? x.isArray(a) ? a.slice() : x.extend({}, a) : a }, x.tap = function(a, b) {
  3809. return b(a), a };
  3810. var E = function(a, b, c, d) {
  3811. if (a === b) return 0 !== a || 1 / a == 1 / b;
  3812. if (null == a || null == b) return a === b;
  3813. a instanceof x && (a = a._wrapped), b instanceof x && (b = b._wrapped);
  3814. var e = j.call(a);
  3815. if (e != j.call(b)) return !1;
  3816. switch (e) {
  3817. case "[object String]":
  3818. return a == b + "";
  3819. case "[object Number]":
  3820. return a != +a ? b != +b : 0 == a ? 1 / a == 1 / b : a == +b;
  3821. case "[object Date]":
  3822. case "[object Boolean]":
  3823. return +a == +b;
  3824. case "[object RegExp]":
  3825. return a.source == b.source && a.global == b.global && a.multiline == b.multiline && a.ignoreCase == b.ignoreCase }
  3826. if ("object" != typeof a || "object" != typeof b) return !1;
  3827. for (var f = c.length; f--;)
  3828. if (c[f] == a) return d[f] == b;
  3829. c.push(a), d.push(b);
  3830. var g = 0,
  3831. h = !0;
  3832. if ("[object Array]" == e) {
  3833. if (g = a.length, h = g == b.length)
  3834. for (; g-- && (h = E(a[g], b[g], c, d));); } else {
  3835. var i = a.constructor,
  3836. k = b.constructor;
  3837. if (i !== k && !(x.isFunction(i) && i instanceof i && x.isFunction(k) && k instanceof k)) return !1;
  3838. for (var l in a)
  3839. if (x.has(a, l) && (g++, !(h = x.has(b, l) && E(a[l], b[l], c, d)))) break;
  3840. if (h) {
  3841. for (l in b)
  3842. if (x.has(b, l) && !g--) break;
  3843. h = !g } }
  3844. return c.pop(), d.pop(), h };
  3845. x.isEqual = function(a, b) {
  3846. return E(a, b, [], []) }, x.isEmpty = function(a) {
  3847. if (null == a) return !0;
  3848. if (x.isArray(a) || x.isString(a)) return 0 === a.length;
  3849. for (var b in a)
  3850. if (x.has(a, b)) return !1;
  3851. return !0 }, x.isElement = function(a) {
  3852. return !(!a || 1 !== a.nodeType) }, x.isArray = u || function(a) {
  3853. return "[object Array]" == j.call(a) }, x.isObject = function(a) {
  3854. return a === Object(a) }, y(["Arguments", "Function", "String", "Number", "Date", "RegExp"], function(a) { x["is" + a] = function(b) {
  3855. return j.call(b) == "[object " + a + "]" } }), x.isArguments(arguments) || (x.isArguments = function(a) {
  3856. return !(!a || !x.has(a, "callee")) }), "function" != typeof /./ && (x.isFunction = function(a) {
  3857. return "function" == typeof a }), x.isFinite = function(a) {
  3858. return isFinite(a) && !isNaN(parseFloat(a)) }, x.isNaN = function(a) {
  3859. return x.isNumber(a) && a != +a }, x.isBoolean = function(a) {
  3860. return a === !0 || a === !1 || "[object Boolean]" == j.call(a) }, x.isNull = function(a) {
  3861. return null === a }, x.isUndefined = function(a) {
  3862. return void 0 === a }, x.has = function(a, b) {
  3863. return k.call(a, b) }, x.noConflict = function() {
  3864. return a._ = b, this }, x.identity = function(a) {
  3865. return a }, x.times = function(a, b, c) {
  3866. for (var d = Array(a), e = 0; a > e; e++) d[e] = b.call(c, e);
  3867. return d }, x.random = function(a, b) {
  3868. return null == b && (b = a, a = 0), a + Math.floor(Math.random() * (b - a + 1)) };
  3869. var F = { escape: { "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#x27;", "/": "&#x2F;" } };
  3870. F.unescape = x.invert(F.escape);
  3871. var G = { escape: RegExp("[" + x.keys(F.escape).join("") + "]", "g"), unescape: RegExp("(" + x.keys(F.unescape).join("|") + ")", "g") };
  3872. x.each(["escape", "unescape"], function(a) { x[a] = function(b) {
  3873. return null == b ? "" : ("" + b).replace(G[a], function(b) {
  3874. return F[a][b] }) } }), x.result = function(a, b) {
  3875. if (null == a) return null;
  3876. var c = a[b];
  3877. return x.isFunction(c) ? c.call(a) : c }, x.mixin = function(a) { y(x.functions(a), function(b) {
  3878. var c = x[b] = a[b];
  3879. x.prototype[b] = function() {
  3880. var a = [this._wrapped];
  3881. return g.apply(a, arguments), L.call(this, c.apply(x, a)) } }) };
  3882. var H = 0;
  3883. x.uniqueId = function(a) {
  3884. var b = ++H + "";
  3885. return a ? a + b : b }, x.templateSettings = { evaluate: /<%([\s\S]+?)%>/g, interpolate: /<%=([\s\S]+?)%>/g, escape: /<%-([\s\S]+?)%>/g };
  3886. var I = /(.)^/,
  3887. J = { "'": "'", "\\": "\\", "\r": "r", "\n": "n", " ": "t", "\u2028": "u2028", "\u2029": "u2029" },
  3888. K = /\\|'|\r|\n|\t|\u2028|\u2029/g;
  3889. x.template = function(a, b, c) {
  3890. var d;
  3891. c = x.defaults({}, c, x.templateSettings);
  3892. var e = RegExp([(c.escape || I).source, (c.interpolate || I).source, (c.evaluate || I).source].join("|") + "|$", "g"),
  3893. f = 0,
  3894. g = "__p+='";
  3895. a.replace(e, function(b, c, d, e, h) {
  3896. return g += a.slice(f, h).replace(K, function(a) {
  3897. return "\\" + J[a] }), c && (g += "'+\n((__t=(" + c + "))==null?'':_.escape(__t))+\n'"), d && (g += "'+\n((__t=(" + d + "))==null?'':__t)+\n'"), e && (g += "';\n" + e + "\n__p+='"), f = h + b.length, b }), g += "';\n", c.variable || (g = "with(obj||{}){\n" + g + "}\n"), g = "var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n" + g + "return __p;\n";
  3898. try { d = Function(c.variable || "obj", "_", g) } catch (h) {
  3899. throw h.source = g, h }
  3900. if (b) return d(b, x);
  3901. var i = function(a) {
  3902. return d.call(this, a, x) };
  3903. return i.source = "function(" + (c.variable || "obj") + "){\n" + g + "}", i }, x.chain = function(a) {
  3904. return x(a).chain() };
  3905. var L = function(a) {
  3906. return this._chain ? x(a).chain() : a };
  3907. x.mixin(x), y(["pop", "push", "reverse", "shift", "sort", "splice", "unshift"], function(a) {
  3908. var b = d[a];
  3909. x.prototype[a] = function() {
  3910. var c = this._wrapped;
  3911. return b.apply(c, arguments), "shift" != a && "splice" != a || 0 !== c.length || delete c[0], L.call(this, c) } }), y(["concat", "join", "slice"], function(a) {
  3912. var b = d[a];
  3913. x.prototype[a] = function() {
  3914. return L.call(this, b.apply(this._wrapped, arguments)) } }), x.extend(x.prototype, { chain: function() {
  3915. return this._chain = !0, this }, value: function() {
  3916. return this._wrapped } }) }).call(this);
  3917. var _ = this._;
  3918. _.noConflict(),
  3919. function(a, b) { "object" == typeof exports && exports ? b(exports) : "function" == typeof define && define.amd ? define(["exports"], b) : b(a.Mustache = {}) }(this, function(a) {
  3920. function b(a) {
  3921. return "function" == typeof a }
  3922. function c(a) {
  3923. return a.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&") }
  3924. function d(a, b) {
  3925. return o.call(a, b) }
  3926. function e(a) {
  3927. return !d(p, a) }
  3928. function f(a) {
  3929. return String(a).replace(/[&<>"'\/]/g, function(a) {
  3930. return q[a] }) }
  3931. function g(b, d) {
  3932. function f() {
  3933. if (w && !x)
  3934. for (; q.length;) delete p[q.pop()];
  3935. else q = [];
  3936. w = !1, x = !1 }
  3937. function g(a) {
  3938. if ("string" == typeof a && (a = a.split(s, 2)), !n(a) || 2 !== a.length) throw new Error("Invalid tags: " + a);
  3939. k = new RegExp(c(a[0]) + "\\s*"), l = new RegExp("\\s*" + c(a[1])), m = new RegExp("\\s*" + c("}" + a[1])) }
  3940. if (!b) return [];
  3941. var k, l, m, o = [],
  3942. p = [],
  3943. q = [],
  3944. w = !1,
  3945. x = !1;
  3946. g(d || a.tags);
  3947. for (var y, z, A, B, C, D, E = new j(b); !E.eos();) {
  3948. if (y = E.pos, A = E.scanUntil(k))
  3949. for (var F = 0, G = A.length; G > F; ++F) B = A.charAt(F), e(B) ? q.push(p.length) : x = !0, p.push(["text", B, y, y + 1]), y += 1, "\n" === B && f();
  3950. if (!E.scan(k)) break;
  3951. if (w = !0, z = E.scan(v) || "name", E.scan(r), "=" === z ? (A = E.scanUntil(t), E.scan(t), E.scanUntil(l)) : "{" === z ? (A = E.scanUntil(m), E.scan(u), E.scanUntil(l), z = "&") : A = E.scanUntil(l), !E.scan(l)) throw new Error("Unclosed tag at " + E.pos);
  3952. if (C = [z, A, y, E.pos], p.push(C), "#" === z || "^" === z) o.push(C);
  3953. else if ("/" === z) {
  3954. if (D = o.pop(), !D) throw new Error('Unopened section "' + A + '" at ' + y);
  3955. if (D[1] !== A) throw new Error('Unclosed section "' + D[1] + '" at ' + y) } else "name" === z || "{" === z || "&" === z ? x = !0 : "=" === z && g(A) }
  3956. if (D = o.pop()) throw new Error('Unclosed section "' + D[1] + '" at ' + E.pos);
  3957. return i(h(p)) }
  3958. function h(a) {
  3959. for (var b, c, d = [], e = 0, f = a.length; f > e; ++e) b = a[e], b && ("text" === b[0] && c && "text" === c[0] ? (c[1] += b[1], c[3] = b[3]) : (d.push(b), c = b));
  3960. return d }
  3961. function i(a) {
  3962. for (var b, c, d = [], e = d, f = [], g = 0, h = a.length; h > g; ++g) switch (b = a[g], b[0]) {
  3963. case "#":
  3964. case "^":
  3965. e.push(b), f.push(b), e = b[4] = [];
  3966. break;
  3967. case "/":
  3968. c = f.pop(), c[5] = b[2], e = f.length > 0 ? f[f.length - 1][4] : d;
  3969. break;
  3970. default:
  3971. e.push(b) }
  3972. return d }
  3973. function j(a) { this.string = a, this.tail = a, this.pos = 0 }
  3974. function k(a, b) { this.view = null == a ? {} : a, this.cache = { ".": this.view }, this.parent = b }
  3975. function l() { this.cache = {} }
  3976. var m = Object.prototype.toString,
  3977. n = Array.isArray || function(a) {
  3978. return "[object Array]" === m.call(a) },
  3979. o = RegExp.prototype.test,
  3980. p = /\S/,
  3981. q = { "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;", "/": "&#x2F;" },
  3982. r = /\s*/,
  3983. s = /\s+/,
  3984. t = /\s*=/,
  3985. u = /\s*\}/,
  3986. v = /#|\^|\/|>|\{|&|=|!/;
  3987. j.prototype.eos = function() {
  3988. return "" === this.tail }, j.prototype.scan = function(a) {
  3989. var b = this.tail.match(a);
  3990. if (!b || 0 !== b.index) return "";
  3991. var c = b[0];
  3992. return this.tail = this.tail.substring(c.length), this.pos += c.length, c }, j.prototype.scanUntil = function(a) {
  3993. var b, c = this.tail.search(a);
  3994. switch (c) {
  3995. case -1:
  3996. b = this.tail, this.tail = "";
  3997. break;
  3998. case 0:
  3999. b = "";
  4000. break;
  4001. default:
  4002. b = this.tail.substring(0, c), this.tail = this.tail.substring(c) }
  4003. return this.pos += b.length, b }, k.prototype.push = function(a) {
  4004. return new k(a, this) }, k.prototype.lookup = function(a) {
  4005. var c, d = this.cache;
  4006. if (a in d) c = d[a];
  4007. else {
  4008. for (var e, f, g = this; g;) {
  4009. if (a.indexOf(".") > 0)
  4010. for (c = g.view, e = a.split("."), f = 0; null != c && f < e.length;) c = c[e[f++]];
  4011. else "object" == typeof g.view && (c = g.view[a]);
  4012. if (null != c) break;
  4013. g = g.parent }
  4014. d[a] = c }
  4015. return b(c) && (c = c.call(this.view)), c }, l.prototype.clearCache = function() { this.cache = {} }, l.prototype.parse = function(a, b) {
  4016. var c = this.cache,
  4017. d = c[a];
  4018. return null == d && (d = c[a] = g(a, b)), d }, l.prototype.render = function(a, b, c) {
  4019. var d = this.parse(a),
  4020. e = b instanceof k ? b : new k(b);
  4021. return this.renderTokens(d, e, c, a) }, l.prototype.renderTokens = function(a, b, c, d) {
  4022. for (var e, f, g, h = "", i = 0, j = a.length; j > i; ++i) g = void 0, e = a[i], f = e[0], "#" === f ? g = this._renderSection(e, b, c, d) : "^" === f ? g = this._renderInverted(e, b, c, d) : ">" === f ? g = this._renderPartial(e, b, c, d) : "&" === f ? g = this._unescapedValue(e, b) : "name" === f ? g = this._escapedValue(e, b) : "text" === f && (g = this._rawValue(e)), void 0 !== g && (h += g);
  4023. return h }, l.prototype._renderSection = function(a, c, d, e) {
  4024. function f(a) {
  4025. return g.render(a, c, d) }
  4026. var g = this,
  4027. h = "",
  4028. i = c.lookup(a[1]);
  4029. if (i) {
  4030. if (n(i))
  4031. for (var j = 0, k = i.length; k > j; ++j) h += this.renderTokens(a[4], c.push(i[j]), d, e);
  4032. else if ("object" == typeof i || "string" == typeof i) h += this.renderTokens(a[4], c.push(i), d, e);
  4033. else if (b(i)) {
  4034. if ("string" != typeof e) throw new Error("Cannot use higher-order sections without the original template");
  4035. i = i.call(c.view, e.slice(a[3], a[5]), f), null != i && (h += i) } else h += this.renderTokens(a[4], c, d, e);
  4036. return h } }, l.prototype._renderInverted = function(a, b, c, d) {
  4037. var e = b.lookup(a[1]);
  4038. return !e || n(e) && 0 === e.length ? this.renderTokens(a[4], b, c, d) : void 0 }, l.prototype._renderPartial = function(a, c, d) {
  4039. if (d) {
  4040. var e = b(d) ? d(a[1]) : d[a[1]];
  4041. return null != e ? this.renderTokens(this.parse(e), c, d, e) : void 0 } }, l.prototype._unescapedValue = function(a, b) {
  4042. var c = b.lookup(a[1]);
  4043. return null != c ? c : void 0 }, l.prototype._escapedValue = function(b, c) {
  4044. var d = c.lookup(b[1]);
  4045. return null != d ? a.escape(d) : void 0 }, l.prototype._rawValue = function(a) {
  4046. return a[1] }, a.name = "mustache.js", a.version = "1.1.0", a.tags = ["{{", "}}"];
  4047. var w = new l;
  4048. a.clearCache = function() {
  4049. return w.clearCache() }, a.parse = function(a, b) {
  4050. return w.parse(a, b) }, a.render = function(a, b, c) {
  4051. return w.render(a, b, c) }, a.to_html = function(c, d, e, f) {
  4052. var g = a.render(c, d, e);
  4053. return b(f) ? void f(g) : g }, a.escape = f, a.Scanner = j, a.Context = k, a.Writer = l }),
  4054. function(a, b, c) { "undefined" != typeof module && module.exports ? module.exports = c() : "function" == typeof define && define.amd ? define(c) : b[a] = c() }("reqwest", this, function() {
  4055. function handleReadyState(a, b, c) {
  4056. return function() {
  4057. return a._aborted ? c(a.request) : void(a.request && 4 == a.request[readyState] && (a.request.onreadystatechange = noop, twoHundo.test(a.request.status) ? b(a.request) : c(a.request))) } }
  4058. function setHeaders(a, b) {
  4059. var c, d = b.headers || {};
  4060. d.Accept = d.Accept || defaultHeaders.accept[b.type] || defaultHeaders.accept["*"], b.crossOrigin || d[requestedWith] || (d[requestedWith] = defaultHeaders.requestedWith), d[contentType] || (d[contentType] = b.contentType || defaultHeaders.contentType);
  4061. for (c in d) d.hasOwnProperty(c) && a.setRequestHeader(c, d[c]) }
  4062. function setCredentials(a, b) { "undefined" != typeof b.withCredentials && "undefined" != typeof a.withCredentials && (a.withCredentials = !!b.withCredentials) }
  4063. function generalCallback(a) { lastValue = a }
  4064. function urlappend(a, b) {
  4065. return a + (/\?/.test(a) ? "&" : "?") + b }
  4066. function handleJsonp(a, b, c, d) {
  4067. var e = uniqid++,
  4068. f = a.jsonpCallback || "callback",
  4069. g = a.jsonpCallbackName || reqwest.getcallbackPrefix(e),
  4070. h = new RegExp("((^|\\?|&)" + f + ")=([^&]+)"),
  4071. i = d.match(h),
  4072. j = doc.createElement("script"),
  4073. k = 0,
  4074. l = -1 !== navigator.userAgent.indexOf("MSIE 10.0"),
  4075. m = -1 !== navigator.userAgent.indexOf("MSIE 9.0");
  4076. return i ? "?" === i[3] ? d = d.replace(h, "$1=" + g) : g = i[3] : d = urlappend(d, f + "=" + g), win[g] = generalCallback, j.type = "text/javascript", j.src = d, j.async = !0, "undefined" == typeof j.onreadystatechange || l || m || (j.event = "onclick", j.htmlFor = j.id = "_reqwest_" + e), j.onload = j.onreadystatechange = function() {
  4077. return j[readyState] && "complete" !== j[readyState] && "loaded" !== j[readyState] || k ? !1 : (j.onload = j.onreadystatechange = null, j.onclick && j.onclick(), a.success && a.success(lastValue), lastValue = void 0, head.removeChild(j), void(k = 1)) }, head.appendChild(j), { abort: function() { j.onload = j.onreadystatechange = null, a.error && a.error({}, "Request is aborted: timeout", {}), lastValue = void 0, head.removeChild(j), k = 1 } } }
  4078. function getRequest(a, b) {
  4079. var c, d = this.o,
  4080. e = (d.method || "GET").toUpperCase(),
  4081. f = "string" == typeof d ? d : d.url,
  4082. g = d.processData !== !1 && d.data && "string" != typeof d.data ? reqwest.toQueryString(d.data) : d.data || null;
  4083. return "jsonp" != d.type && "GET" != e || !g || (f = urlappend(f, g), g = null), "jsonp" == d.type ? handleJsonp(d, a, b, f) : (c = xhr(), c.open(e, f, !0), setHeaders(c, d), setCredentials(c, d), c.onreadystatechange = handleReadyState(this, a, b), d.before && d.before(c), c.send(g), c) }
  4084. function Reqwest(a, b) { this.o = a, this.fn = b, init.apply(this, arguments) }
  4085. function setType(a) {
  4086. var b = a.match(/\.(json|jsonp|html|xml)(\?|$)/);
  4087. return b ? b[1] : "js" }
  4088. function init(o, fn) {
  4089. function complete(a) {
  4090. for (o.timeout && clearTimeout(self.timeout), self.timeout = null; self._completeHandlers.length > 0;) self._completeHandlers.shift()(a) }
  4091. function success(resp) {
  4092. var r = resp.responseText;
  4093. if (r) switch (type) {
  4094. case "json":
  4095. try { resp = win.JSON ? win.JSON.parse(r) : eval("(" + r + ")") } catch (err) {
  4096. return error(resp, "Could not parse JSON in response", err) }
  4097. break;
  4098. case "js":
  4099. resp = eval(r);
  4100. break;
  4101. case "html":
  4102. resp = r;
  4103. break;
  4104. case "xml":
  4105. resp = resp.responseXML && resp.responseXML.parseError && resp.responseXML.parseError.errorCode && resp.responseXML.parseError.reason ? null : resp.responseXML }
  4106. for (self._responseArgs.resp = resp, self._fulfilled = !0, fn(resp); self._fulfillmentHandlers.length > 0;) self._fulfillmentHandlers.shift()(resp);
  4107. complete(resp) }
  4108. function error(a, b, c) {
  4109. for (self._responseArgs.resp = a, self._responseArgs.msg = b, self._responseArgs.t = c, self._erred = !0; self._errorHandlers.length > 0;) self._errorHandlers.shift()(a, b, c);
  4110. complete(a) }
  4111. this.url = "string" == typeof o ? o : o.url, this.timeout = null, this._fulfilled = !1, this._fulfillmentHandlers = [], this._errorHandlers = [], this._completeHandlers = [], this._erred = !1, this._responseArgs = {};
  4112. var self = this,
  4113. type = o.type || setType(this.url);
  4114. fn = fn || function() {}, o.timeout && (this.timeout = setTimeout(function() { self.abort() }, o.timeout)), o.success && this._fulfillmentHandlers.push(function() { o.success.apply(o, arguments) }), o.error && this._errorHandlers.push(function() { o.error.apply(o, arguments) }), o.complete && this._completeHandlers.push(function() { o.complete.apply(o, arguments) }), this.request = getRequest.call(this, success, error) }
  4115. function reqwest(a, b) {
  4116. return new Reqwest(a, b) }
  4117. function normalize(a) {
  4118. return a ? a.replace(/\r?\n/g, "\r\n") : "" }
  4119. function serial(a, b) {
  4120. var c, d, e, f, g = a.name,
  4121. h = a.tagName.toLowerCase(),
  4122. i = function(a) { a && !a.disabled && b(g, normalize(a.attributes.value && a.attributes.value.specified ? a.value : a.text)) };
  4123. if (!a.disabled && g) switch (h) {
  4124. case "input":
  4125. /reset|button|image|file/i.test(a.type) || (c = /checkbox/i.test(a.type), d = /radio/i.test(a.type), e = a.value, (!(c || d) || a.checked) && b(g, normalize(c && "" === e ? "on" : e)));
  4126. break;
  4127. case "textarea":
  4128. b(g, normalize(a.value));
  4129. break;
  4130. case "select":
  4131. if ("select-one" === a.type.toLowerCase()) i(a.selectedIndex >= 0 ? a.options[a.selectedIndex] : null);
  4132. else
  4133. for (f = 0; a.length && f < a.length; f++) a.options[f].selected && i(a.options[f]) } }
  4134. function eachFormElement() {
  4135. var a, b, c = this,
  4136. d = function(a, b) {
  4137. var d, e, f;
  4138. for (d = 0; d < b.length; d++)
  4139. for (f = a[byTag](b[d]), e = 0; e < f.length; e++) serial(f[e], c) };
  4140. for (b = 0; b < arguments.length; b++) a = arguments[b], /input|select|textarea/i.test(a.tagName) && serial(a, c), d(a, ["input", "select", "textarea"]) }
  4141. function serializeQueryString() {
  4142. return reqwest.toQueryString(reqwest.serializeArray.apply(null, arguments)) }
  4143. function serializeHash() {
  4144. var a = {};
  4145. return eachFormElement.apply(function(b, c) { b in a ? (a[b] && !isArray(a[b]) && (a[b] = [a[b]]), a[b].push(c)) : a[b] = c }, arguments), a }
  4146. function getValue(a) {
  4147. return "function" == typeof a ? a() : a }
  4148. var win = window,
  4149. doc = document,
  4150. twoHundo = /^20\d$/,
  4151. byTag = "getElementsByTagName",
  4152. readyState = "readyState",
  4153. contentType = "Content-Type",
  4154. requestedWith = "X-Requested-With",
  4155. head = doc[byTag]("head")[0],
  4156. uniqid = 0,
  4157. callbackPrefix = "reqwest_" + +new Date,
  4158. lastValue, xmlHttpRequest = "XMLHttpRequest",
  4159. noop = function() {},
  4160. isArray = "function" == typeof Array.isArray ? Array.isArray : function(a) {
  4161. return a instanceof Array },
  4162. defaultHeaders = { contentType: "application/x-www-form-urlencoded", requestedWith: xmlHttpRequest, accept: { "*": "text/javascript, text/html, application/xml, text/xml, */*", xml: "application/xml, text/xml", html: "text/html", text: "text/plain", json: "application/json, text/javascript", js: "application/javascript, text/javascript" } },
  4163. xhr = win[xmlHttpRequest] ? function() {
  4164. return new XMLHttpRequest } : function() {
  4165. return new ActiveXObject("Microsoft.XMLHTTP") };
  4166. return Reqwest.prototype = { abort: function() { this._aborted = !0, this.request.abort() }, retry: function() { init.call(this, this.o, this.fn) }, then: function(a, b) {
  4167. return this._fulfilled ? a(this._responseArgs.resp) : this._erred ? b(this._responseArgs.resp, this._responseArgs.msg, this._responseArgs.t) : (this._fulfillmentHandlers.push(a), this._errorHandlers.push(b)), this }, always: function(a) {
  4168. return this._fulfilled || this._erred ? a(this._responseArgs.resp) : this._completeHandlers.push(a), this }, fail: function(a) {
  4169. return this._erred ? a(this._responseArgs.resp, this._responseArgs.msg, this._responseArgs.t) : this._errorHandlers.push(a), this } }, reqwest.serializeArray = function() {
  4170. var a = [];
  4171. return eachFormElement.apply(function(b, c) { a.push({ name: b, value: c }) }, arguments), a }, reqwest.serialize = function() {
  4172. if (0 === arguments.length) return "";
  4173. var a, b, c = Array.prototype.slice.call(arguments, 0);
  4174. return a = c.pop(), a && a.nodeType && c.push(a) && (a = null), a && (a = a.type), b = "map" == a ? serializeHash : "array" == a ? reqwest.serializeArray : serializeQueryString, b.apply(null, c) }, reqwest.toQueryString = function(a) {
  4175. var b, c, d, e = "",
  4176. f = encodeURIComponent,
  4177. g = function(a, b) { e += f(a) + "=" + f(b) + "&" };
  4178. if (isArray(a))
  4179. for (b = 0; a && b < a.length; b++) g(a[b].name, a[b].value);
  4180. else
  4181. for (c in a)
  4182. if (Object.hasOwnProperty.call(a, c))
  4183. if (d = a[c], isArray(d))
  4184. for (b = 0; b < d.length; b++) g(c, d[b]);
  4185. else g(c, a[c]); return e.replace(/&$/, "").replace(/%20/g, "+") }, reqwest.getcallbackPrefix = function() {
  4186. return callbackPrefix }, reqwest.compat = function(a, b) {
  4187. return a && (a.type && (a.method = a.type) && delete a.type, a.dataType && (a.type = a.dataType), a.jsonpCallback && (a.jsonpCallbackName = getValue(a.jsonpCallback)) && delete a.jsonpCallback, a.jsonp && (a.jsonpCallback = a.jsonp)), new Reqwest(a, b) }, reqwest }),
  4188. function() {
  4189. var a = this,
  4190. b = a.cdb = {};
  4191. b.VERSION = "3.15.10", b.DEBUG = !1, b.CARTOCSS_VERSIONS = { "2.0.0": "", "2.1.0": "" }, b.CARTOCSS_DEFAULT_VERSION = "2.1.1", a.cdb.config = {}, a.cdb.core = {}, a.cdb.image = {}, a.cdb.geo = {}, a.cdb.geo.ui = {}, a.cdb.geo.geocoder = {}, a.cdb.ui = {}, a.cdb.ui.common = {}, a.cdb.vis = {}, a.cdb.decorators = {}, a.JST = a.JST || {}, a.cartodb = b, b.files = ["../vendor/jquery.min.js", "../vendor/underscore-min.js", "../vendor/json2.js", "../vendor/backbone.js", "../vendor/mustache.js", "../vendor/leaflet.js", "../vendor/wax.cartodb.js", "../vendor/GeoJSON.js", "../vendor/jscrollpane.js", "../vendor/mousewheel.js", "../vendor/mwheelIntent.js", "../vendor/spin.js", "../vendor/lzma.js", "../vendor/html-css-sanitizer-bundle.js", "core/sanitize.js", "core/decorator.js", "core/config.js", "core/log.js", "core/profiler.js", "core/template.js", "core/model.js", "core/view.js", "core/loader.js", "core/util.js", "geo/geocoder.js", "geo/geometry.js", "geo/map.js", "geo/ui/text.js", "geo/ui/annotation.js", "geo/ui/image.js", "geo/ui/share.js", "geo/ui/zoom.js", "geo/ui/zoom_info.js", "geo/ui/legend.js", "geo/ui/switcher.js", "geo/ui/infowindow.js", "geo/ui/header.js", "geo/ui/search.js", "geo/ui/layer_selector.js", "geo/ui/slides_controller.js", "geo/ui/mobile.js", "geo/ui/tiles_loader.js", "geo/ui/infobox.js", "geo/ui/tooltip.js", "geo/ui/fullscreen.js", "geo/sublayer.js", "geo/layer_definition.js", "geo/common.js", "geo/leaflet/leaflet_base.js", "geo/leaflet/leaflet_plainlayer.js", "geo/leaflet/leaflet_tiledlayer.js", "geo/leaflet/leaflet_gmaps_tiledlayer.js", "geo/leaflet/leaflet_wmslayer.js", "geo/leaflet/leaflet_cartodb_layergroup.js", "geo/leaflet/leaflet_cartodb_layer.js", "geo/leaflet/leaflet.geometry.js", "geo/leaflet/leaflet.js", "geo/gmaps/gmaps_base.js", "geo/gmaps/gmaps_baselayer.js", "geo/gmaps/gmaps_plainlayer.js", "geo/gmaps/gmaps_tiledlayer.js", "geo/gmaps/gmaps_cartodb_layergroup.js", "geo/gmaps/gmaps_cartodb_layer.js", "geo/gmaps/gmaps.geometry.js", "geo/gmaps/gmaps.js", "ui/common/dialog.js", "ui/common/share.js", "ui/common/notification.js", "ui/common/table.js", "ui/common/dropdown.js", "vis/vis.js", "vis/image.js", "vis/overlays.js", "vis/layers.js", "api/layers.js", "api/sql.js", "api/vis.js"], b.init = function(c) {
  4192. var d = b.Class = function() {};
  4193. _.extend(d.prototype, Backbone.Events), b._loadJST(), a.cdb.god = new Backbone.Model, c && c() }, b.load = function(a, c) {
  4194. var d = 0,
  4195. e = function() {
  4196. var f = document.createElement("script");
  4197. f.src = a + b.files[d], document.body.appendChild(f), ++d, d == b.files.length ? c && (f.onload = c) : f.onload = e };
  4198. e() } }(),
  4199. function() {
  4200. function a() {}
  4201. var b = Array.prototype.slice,
  4202. c = (Array.prototype.splice, /\s+/),
  4203. d = Backbone.Events = { on: function(a, b, d) {
  4204. var e, f, g, h, i;
  4205. if (!b) return this;
  4206. for (a = a.split(c), e = this._callbacks || (this._callbacks = {}); f = a.shift();) i = e[f], g = i ? i.tail : {}, g.next = h = {}, g.context = d, g.callback = b, e[f] = { tail: h, next: i ? i.next : g };
  4207. return this }, off: function(a, b, d) {
  4208. var f, g, h, i, j, k;
  4209. if (g = this._callbacks) {
  4210. if (!(a || b || d)) return delete this._callbacks, this;
  4211. for (a = a ? a.split(c) : e.keys(g); f = a.shift();)
  4212. if (h = g[f], delete g[f], h && (b || d))
  4213. for (i = h.tail;
  4214. (h = h.next) !== i;) j = h.callback, k = h.context, (b && j !== b || d && k !== d) && this.on(f, j, k);
  4215. return this } }, trigger: function(a) {
  4216. var d, e, f, g, h, i, j;
  4217. if (!(f = this._callbacks)) return this;
  4218. for (i = f.all, a = a.split(c), j = b.call(arguments, 1); d = a.shift();) {
  4219. if (e = f[d])
  4220. for (g = e.tail;
  4221. (e = e.next) !== g;) e.callback.apply(e.context || this, j);
  4222. if (e = i)
  4223. for (g = e.tail, h = [d].concat(j);
  4224. (e = e.next) !== g;) e.callback.apply(e.context || this, h) }
  4225. return this } };
  4226. if (d.bind = d.on, d.unbind = d.off, void 0 === cartodb._Promise && (a.prototype = d, a.prototype.done = function(a) {
  4227. return this.on("done", a) }, a.prototype.error = function(a) {
  4228. return this.on("error", a) }, cartodb._Promise = a), "undefined" == typeof e) var e = { extend: function(a, b) {
  4229. for (var c in b) a[c] = b[c];
  4230. return a }, defaults: function(a, b) {
  4231. for (var c in b) void 0 == a[c] && (a[c] = b[c]);
  4232. return a }, isFunction: function(a) {
  4233. return "function" == typeof a } } }(),
  4234. function(a) {
  4235. function b() {}
  4236. function c(a) { this.t0 = null, this.name = a, this.count = 0 }
  4237. var d = 1024;
  4238. b.metrics = {}, b._backend = null, b.get = function(a) {
  4239. return b.metrics[a] || {
  4240. max: 0,
  4241. min: Number.MAX_VALUE,
  4242. avg: 0,
  4243. total: 0,
  4244. count: 0,
  4245. last: 0,
  4246. history: "undefined" != typeof Float32Array ? new Float32Array(d) : []
  4247. }
  4248. }, b.backend = function(a) { b._backend = a }, b.new_value = function(a, c, e, f) { e = e || "i";
  4249. var g = b.metrics[a] = b.get(a);
  4250. if (g.max = Math.max(g.max, c), g.min = Math.min(g.min, c), g.total += c, ++g.count, g.avg = g.total / g.count, g.history[g.count % d] = c, f) {
  4251. var h = (new Date).getTime();
  4252. h - g.last > 1e3 && (b._backend && b._backend([e, a, g.avg]), g.last = h) } else b._backend && b._backend([e, a, c]) }, b.print_stats = function() {
  4253. for (k in b.metrics) {
  4254. var a = b.metrics[k];
  4255. console.log(" === " + k + " === "), console.log(" max: " + a.max), console.log(" min: " + a.min), console.log(" avg: " + a.avg), console.log(" count: " + a.count), console.log(" total: " + a.total) } }, c.prototype = { start: function() {
  4256. return this.t0 = +new Date, this }, _elapsed: function() {
  4257. return +new Date - this.t0 }, end: function(a) { null !== this.t0 && (b.new_value(this.name, this._elapsed(), "t", a), this.t0 = null) }, inc: function(a) { a = void 0 === a ? 1 : a, b.new_value(this.name, a, "i") }, dec: function(a) { a = void 0 === a ? 1 : a, b.new_value(this.name, a, "d") }, mark: function() {
  4258. if (++this.count, null === this.t0) return void this.start();
  4259. var a = this._elapsed();
  4260. a > 1 && (b.new_value(this.name, this.count), this.count = 0, this.start()) } }, b.metric = function(a) {
  4261. return new c(a) }, a.Profiler = b
  4262. }(cdb.core), cdb.core.util = {}, cdb.core.util.isCORSSupported = function() {
  4263. return "withCredentials" in new XMLHttpRequest }, cdb.core.util.array2hex = function(a) {
  4264. for (var b = [], c = 0; c < a.length; ++c) b.push(String.fromCharCode(a[c] + 128));
  4265. return cdb.core.util.btoa(b.join("")) }, cdb.core.util.btoa = function(a) {
  4266. return "function" == typeof window.btoa ? cdb.core.util.encodeBase64Native(a) : cdb.core.util.encodeBase64(a) }, cdb.core.util.encodeBase64Native = function(a) {
  4267. return btoa(a) }, cdb.core.util.encodeBase64 = function(a) {
  4268. var b, c, d, e, f, g, h, i, j = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
  4269. k = 0,
  4270. l = 0,
  4271. m = "",
  4272. n = [];
  4273. if (!a) return a;
  4274. do b = a.charCodeAt(k++), c = a.charCodeAt(k++), d = a.charCodeAt(k++), i = b << 16 | c << 8 | d, e = i >> 18 & 63, f = i >> 12 & 63, g = i >> 6 & 63, h = 63 & i, n[l++] = j.charAt(e) + j.charAt(f) + j.charAt(g) + j.charAt(h); while (k < a.length);
  4275. m = n.join("");
  4276. var o = a.length % 3;
  4277. return (o ? m.slice(0, o - 3) : m) + "===".slice(o || 3) }, cdb.core.util.uniqueCallbackName = function(a) {
  4278. return cdb.core.util._callback_c = cdb.core.util._callback_c || 0, ++cdb.core.util._callback_c, cdb.core.util.crc32(a) + "_" + cdb.core.util._callback_c }, cdb.core.util.crc32 = function(a) {
  4279. for (var b = cdb.core.util._crcTable || (cdb.core.util._crcTable = cdb.core.util._makeCRCTable()), c = -1, d = 0, e = a.length; e > d; ++d) c = c >>> 8 ^ b[255 & (c ^ a.charCodeAt(d))];
  4280. return (-1 ^ c) >>> 0 }, cdb.core.util._makeCRCTable = function() {
  4281. for (var a, b = [], c = 0; 256 > c; ++c) { a = c;
  4282. for (var d = 0; 8 > d; ++d) a = 1 & a ? 3988292384 ^ a >>> 1 : a >>> 1;
  4283. b[c] = a }
  4284. return b }, cdb.core.util._inferBrowser = function(a) {
  4285. function b() {
  4286. var b = a.indexOf("MSIE "),
  4287. c = a.indexOf("Trident/");
  4288. return b > -1 || c > -1 ? !0 : !1 }
  4289. function c() {
  4290. return document.compatMode ? window.XMLHttpRequest ? document.querySelector ? document.addEventListener ? window.atob ? document.all ? 10 : 11 : 9 : 8 : 7 : 6 : 5 }
  4291. var d = {};
  4292. return a = a || window.navigator.userAgent, b() ? d.ie = { version: c() } : a.indexOf("Edge/") > -1 ? d.edge = a : a.indexOf("Chrome") > -1 ? d.chrome = a : a.indexOf("Firefox") > -1 ? d.firefox = a : a.indexOf("Opera") > -1 ? d.opera = a : a.indexOf("Safari") > -1 && (d.safari = a), d }, cdb.core.util.browser = cdb.core.util._inferBrowser(),
  4293. function() {
  4294. function a(b) {
  4295. if (cartodb === this || window === this) return new a(b);
  4296. if (!b.user) throw new Error("user should be provided");
  4297. var c = new String(window.location.protocol);
  4298. if (c = c.slice(0, c.length - 1), "file" == c && (c = "https"), this.ajax = b.ajax || ("undefined" != typeof jQuery ? jQuery.ajax : reqwest), !this.ajax) throw new Error("jQuery or reqwest should be loaded");
  4299. if (this.options = _.defaults(b, { version: "v2", protocol: c, jsonp: "undefined" != typeof jQuery ? !jQuery.support.cors : !1 }), !this.options.sql_api_template) {
  4300. var d = this.options,
  4301. e = null;
  4302. if (d && d.completeDomain) e = d.completeDomain;
  4303. else {
  4304. var f = d.host || "carto.com",
  4305. g = d.protocol || "https";
  4306. e = g + "://{user}." + f }
  4307. this.options.sql_api_template = e } }
  4308. function b(a) {
  4309. return JSON.parse(a.replace(/^{/, "[").replace(/}$/, "]")) }
  4310. var c = this;
  4311. c.cartodb = c.cartodb || {}, a.prototype._host = function() {
  4312. var a = this.options;
  4313. return a.sql_api_template.replace("{user}", a.user) + "/api/" + a.version + "/sql" }, a.prototype.execute = function(a, b, c, d) {
  4314. var e = 1024,
  4315. f = new cartodb._Promise;
  4316. if (!a) throw new TypeError("sql should not be null");
  4317. var g = arguments,
  4318. h = g[g.length - 1];
  4319. _.isFunction(h) && (d = h), c = _.defaults(c || {}, this.options);
  4320. var i = { type: "get", dataType: "json", crossDomain: !0 };
  4321. void 0 !== c.cache && (i.cache = c.cache), c.jsonp && (delete i.crossDomain, c.jsonpCallback && (i.jsonpCallback = c.jsonpCallback), i.dataType = "jsonp");
  4322. var j = "156543.03515625",
  4323. k = "ST_MakeEnvelope(-20037508.5,-20037508.5,20037508.5,20037508.5,3857)";
  4324. a = a.replace("!bbox!", k).replace("!pixel_width!", j).replace("!pixel_height!", j);
  4325. var l = Mustache.render(a, b),
  4326. m = l.length < e,
  4327. n = ["format", "dp", "api_key"];
  4328. if (c.extra_params && (n = n.concat(c.extra_params)), i.url = this._host(), m) {
  4329. var o = "q=" + encodeURIComponent(l);
  4330. for (var p in n) {
  4331. var q = n[p],
  4332. r = c[q];
  4333. r && (o += "&" + q + "=" + r) }
  4334. i.url += "?" + o } else {
  4335. var s = { q: l };
  4336. for (var p in n) {
  4337. var q = n[p],
  4338. r = c[q];
  4339. r && (s[q] = r) }
  4340. i.data = s, "undefined" != typeof jQuery ? i.type = "post" : i.method = "post" }
  4341. var t = c.success,
  4342. u = c.error;
  4343. return t && delete c.success, u && delete u.success, i.error = function(a) {
  4344. var b = a.responseText || a.response,
  4345. c = b && JSON.parse(b);
  4346. f.trigger("error", c && c.error, a), u && u(a) }, i.success = function(a, b, c) { void 0 == b && (b = a.status, c = a, a = JSON.parse(a.response)), setTimeout(function() { f.trigger("done", a, b, c), t && t(a, b, c), d && d(a) }, 0) }, delete c.jsonp, this.ajax(_.extend(i, c)), f }, a.prototype.getBounds = function(a, b, c, d) {
  4347. var e = new cartodb._Promise,
  4348. f = arguments,
  4349. g = f[f.length - 1];
  4350. _.isFunction(g) && (d = g);
  4351. var h = "SELECT ST_XMin(ST_Extent(the_geom)) as minx, ST_YMin(ST_Extent(the_geom)) as miny, ST_XMax(ST_Extent(the_geom)) as maxx, ST_YMax(ST_Extent(the_geom)) as maxy from ({{{ sql }}}) as subq";
  4352. return a = Mustache.render(a, b), this.execute(h, { sql: a }, c).done(function(a) {
  4353. if (a.rows && a.rows.length > 0 && null != a.rows[0].maxx) {
  4354. var b = a.rows[0],
  4355. c = -85.0511,
  4356. f = 85.0511,
  4357. g = -179,
  4358. h = 179,
  4359. i = function(a, b, c) {
  4360. return b > a ? b : a > c ? c : a },
  4361. j = i(b.maxx, g, h),
  4362. k = i(b.minx, g, h),
  4363. l = i(b.maxy, c, f),
  4364. m = i(b.miny, c, f),
  4365. n = [
  4366. [l, j],
  4367. [m, k]
  4368. ];
  4369. e.trigger("done", n), d && d(n) } }).error(function(a) { e.trigger("error", a) }), e }, a.prototype.table = function(a) {
  4370. function b() { b.fetch.apply(b, arguments) }
  4371. var c, d, e, f, g = a,
  4372. h = [],
  4373. i = this;
  4374. return b.fetch = function(a) { a = a || {};
  4375. var c = arguments,
  4376. d = c[c.length - 1];
  4377. _.isFunction(d) && (callback = d, 1 === c.length && (a = {})), i.execute(b.sql(), a, callback) }, b.sql = function() {
  4378. var a = "select";
  4379. return a += h.length ? " " + h.join(",") + " " : " * ", a += "from " + g, c && (a += " where " + c), d && (a += " limit " + d), e && (a += " order by " + e), f && (a += " " + f), a }, b.filter = function(a) {
  4380. return c = a, b }, b.order_by = function(a) {
  4381. return e = a, b }, b.asc = function() {
  4382. return f = "asc", b }, b.desc = function() {
  4383. return f = "desc", b }, b.columns = function(a) {
  4384. return h = a, b }, b.limit = function(a) {
  4385. return d = a, b }, b }, a.prototype.describeString = function(a, c, d) {
  4386. var e = ["WITH t as (", " SELECT count(*) as total,", " count(DISTINCT {{column}}) as ndist", " FROM ({{sql}}) _wrap", " ), a as (", " SELECT ", " count(*) cnt, ", " {{column}}", " FROM ", " ({{sql}}) _wrap ", " GROUP BY ", " {{column}} ", " ORDER BY ", " cnt DESC", " ), b As (", " SELECT", " row_number() OVER (ORDER BY cnt DESC) rn,", " cnt", " FROM a", " ), c As (", " SELECT ", " sum(cnt) OVER (ORDER BY rn ASC) / t.total cumperc,", " rn,", " cnt ", " FROM b, t", " LIMIT 10", " ),", "stats as (", "select count(distinct({{column}})) as uniq, ", " count(*) as cnt, ", " sum(case when COALESCE(NULLIF({{column}},'')) is null then 1 else 0 end)::numeric as null_count, ", " sum(case when COALESCE(NULLIF({{column}},'')) is null then 1 else 0 end)::numeric / count(*)::numeric as null_ratio, ", " (SELECT max(cumperc) weight FROM c) As skew ", "from ({{sql}}) __wrap", "),", "hist as (", "select array_agg(row(d, c)) array_agg from (select distinct({{column}}) d, count(*) as c from ({{sql}}) __wrap, stats group by 1 limit 100) _a", ")", "select * from stats, hist"],
  4387. f = Mustache.render(e.join("\n"), { column: c, sql: a }),
  4388. g = function(a) {
  4389. var b = a.replace(/^"(.+(?="$))?"$/, "$1");
  4390. return b.replace(/""/g, '"') };
  4391. this.execute(f, function(a) {
  4392. var c = a.rows[0],
  4393. e = 0,
  4394. f = [];
  4395. try {
  4396. var h = b(c.array_agg),
  4397. f = _(h).map(function(a) {
  4398. var b = a.match(/\((.*),(\d+)/),
  4399. c = g(b[1]);
  4400. return [c, +b[2]] });
  4401. e = c.skew * (1 - c.null_ratio) * (1 - c.uniq / c.cnt) * (c.uniq > 1 ? 1 : 0) } catch (i) {}
  4402. d({ type: "string", hist: f, distinct: c.uniq, count: c.cnt, null_count: c.null_count, null_ratio: c.null_ratio, skew: c.skew, weight: e }) }) }, a.prototype.describeDate = function(a, b, c) {
  4403. var d = ["with minimum as (", "SELECT min({{column}}) as start_time FROM ({{sql}}) _wrap), ", "maximum as (SELECT max({{column}}) as end_time FROM ({{sql}}) _wrap), ", "null_ratio as (SELECT sum(case when {{column}} is null then 1 else 0 end)::numeric / count(*)::numeric as null_ratio FROM ({{sql}}) _wrap), ", "moments as (SELECT count(DISTINCT {{column}}) as moments FROM ({{sql}}) _wrap)", "SELECT * FROM minimum, maximum, moments, null_ratio"],
  4404. e = Mustache.render(d.join("\n"), { column: b, sql: a });
  4405. this.execute(e, function(a) {
  4406. var b = a.rows[0],
  4407. d = new Date(b.end_time),
  4408. e = new Date(b.start_time),
  4409. f = (b.moments, Math.min(b.moments, 1024));
  4410. c({ type: "date", start_time: e, end_time: d, range: d - e, steps: f, null_ratio: b.null_ratio }) }) }, a.prototype.describeBoolean = function(a, b, c) {
  4411. var d = ["with stats as (", "select count(distinct({{column}})) as uniq,", "count(*) as cnt", "from ({{sql}}) _wrap ", "),", "null_ratio as (", "SELECT sum(case when {{column}} is null then 1 else 0 end)::numeric / count(*)::numeric as null_ratio FROM ({{sql}}) _wrap), ", "true_ratio as (", "SELECT sum(case when {{column}} is true then 1 else 0 end)::numeric / count(*)::numeric as true_ratio FROM ({{sql}}) _wrap) ", "SELECT * FROM true_ratio, null_ratio, stats"],
  4412. e = Mustache.render(d.join("\n"), { column: b, sql: a });
  4413. this.execute(e, function(a) {
  4414. var b = a.rows[0];
  4415. c({ type: "boolean", null_ratio: b.null_ratio, true_ratio: b.true_ratio, distinct: b.uniq, count: b.cnt }) }) }, a.prototype.describeGeom = function(a, b, c) {
  4416. function d(a) {
  4417. return { st_multipolygon: "polygon", st_polygon: "polygon", st_multilinestring: "line", st_linestring: "line", st_multipoint: "point", st_point: "point" }[a.toLowerCase()] }
  4418. var e = ["with stats as (", "select st_asgeojson(st_extent({{column}})) as bbox", "from ({{sql}}) _wrap", "),", "geotype as (", "select st_geometrytype({{column}}) as geometry_type from ({{sql}}) _w where {{column}} is not null limit 1", "),", "clusters as (", "with clus as (", "SELECT distinct(ST_snaptogrid(the_geom, 10)) as cluster, count(*) as clustercount FROM ({{sql}}) _wrap group by 1 order by 2 desc limit 3),", "total as (", "SELECT count(*) FROM ({{sql}}) _wrap)", "SELECT sum(clus.clustercount)/sum(total.count) AS clusterrate FROM clus, total", "),", "density as (", "SELECT count(*) / st_area(st_extent(the_geom)) as density FROM ({{sql}}) _wrap", ")", "select * from stats, geotype, clusters, density"],
  4419. f = Mustache.render(e.join("\n"), { column: b, sql: a });
  4420. this.execute(f, function(a) {
  4421. var b = a.rows[0],
  4422. e = JSON.parse(b.bbox).coordinates[0];
  4423. c({ type: "geom", bbox: [
  4424. [e[0][0], e[0][1]],
  4425. [e[2][0], e[2][1]]
  4426. ], geometry_type: b.geometry_type, simplified_geometry_type: d(b.geometry_type), cluster_rate: b.clusterrate, density: b.density }) }) }, a.prototype.columns = function(a, b, c) {
  4427. var d = arguments,
  4428. e = d[d.length - 1];
  4429. _.isFunction(e) && (c = e);
  4430. var f = "select * from (" + a + ") __wrap limit 0",
  4431. g = ["cartodb_id", "latitude", "longitude", "created_at", "updated_at", "lat", "lon", "the_geom_webmercator"];
  4432. this.execute(f, function(a) {
  4433. var b = {};
  4434. for (var d in a.fields) - 1 === g.indexOf(d) && (b[d] = a.fields[d].type);
  4435. c(b) }) }, a.prototype.describeFloat = function(a, c, d) {
  4436. var e = ["with stats as (", "select min({{column}}) as min,", "max({{column}}) as max,", "avg({{column}}) as avg,", "count(DISTINCT {{column}}) as cnt,", "count(distinct({{column}})) as uniq,", "count(*) as cnt,", "sum(case when {{column}} is null then 1 else 0 end)::numeric / count(*)::numeric as null_ratio,", "stddev_pop({{column}}) / count({{column}}) as stddev,", "CASE WHEN abs(avg({{column}})) > 1e-7 THEN stddev({{column}}) / abs(avg({{column}})) ELSE 1e12 END as stddevmean,", 'CDB_DistType(array_agg("{{column}}"::numeric)) as dist_type ', "from ({{sql}}) _wrap ", "),", "params as (select min(a) as min, (max(a) - min(a)) / 7 as diff from ( select {{column}} as a from ({{sql}}) _table_sql where {{column}} is not null ) as foo ),", "histogram as (", "select array_agg(row(bucket, range, freq)) as hist from (", "select CASE WHEN uniq > 1 then width_bucket({{column}}, min-0.01*abs(min), max+0.01*abs(max), 100) ELSE 1 END as bucket,", "numrange(min({{column}})::numeric, max({{column}})::numeric) as range,", "count(*) as freq", "from ({{sql}}) _w, stats", "group by 1", "order by 1", ") __wrap", "),", "hist as (", "select array_agg(row(d, c)) cat_hist from (select distinct({{column}}) d, count(*) as c from ({{sql}}) __wrap, stats group by 1 limit 100) _a", "),", "buckets as (", "select CDB_QuantileBins(array_agg(distinct({{column}}::numeric)), 7) as quantiles, ", " (select array_agg(x::numeric) FROM (SELECT (min + n * diff)::numeric as x FROM generate_series(1,7) n, params) p) as equalint,", " CDB_JenksBins(array_agg(distinct({{column}}::numeric)), 7) as jenks, ", " CDB_HeadsTailsBins(array_agg(distinct({{column}}::numeric)), 7) as headtails ", "from ({{sql}}) _table_sql where {{column}} is not null", ")", "select * from histogram, stats, buckets, hist"],
  4437. f = Mustache.render(e.join("\n"), { column: c, sql: a });
  4438. this.execute(f, function(a) {
  4439. var c = a.rows[0],
  4440. e = b(c.hist),
  4441. f = b(c.cat_hist);
  4442. d({ type: "number", cat_hist: _(f).map(function(a) {
  4443. var b = a.match(/\((.*),(\d+)/);
  4444. return [+b[1], +b[2]] }), hist: _(e).map(function(a) {
  4445. if (!(a.indexOf("empty") > -1)) {
  4446. var b = a.split('"');
  4447. return { index: b[0].replace(/\D/g, ""), range: b[1].split(",").map(function(a) {
  4448. return a.replace(/\D/g, "") }), freq: b[2].replace(/\D/g, "") } } }), stddev: c.stddev, null_ratio: c.null_ratio, count: c.cnt, distinct: c.uniq, avg: c.avg, max: c.max, min: c.min, stddevmean: c.stddevmean, weight: (c.uniq > 1 ? 1 : 0) * (1 - c.null_ratio) * (c.stddev < -1 ? 1 : c.stddev < 1 ? .5 : c.stddev < 3 ? .25 : .1), quantiles: c.quantiles, equalint: c.equalint, jenks: c.jenks, headtails: c.headtails, dist_type: c.dist_type }) }) }, a.prototype.describe = function(a, b, c) {
  4449. var d = this,
  4450. e = arguments,
  4451. f = e[e.length - 1];
  4452. if (_.isFunction(f)) var g = f;
  4453. var h = function(a) { a.column = b, g(a) },
  4454. i = "select * from (" + a + ") __wrap limit 0";
  4455. this.execute(i, function(e) {
  4456. var f = c && c.type ? c.type : e.fields[b].type;
  4457. return f ? void("string" === f ? d.describeString(a, b, h) : "number" === f ? d.describeFloat(a, b, h) : "geometry" === f ? d.describeGeom(a, b, h) : "date" === f ? d.describeDate(a, b, h) : "boolean" === f ? d.describeBoolean(a, b, h) : h(new Error("column type is not supported"))) : void h(new Error("column does not exist")) }) }, c.cartodb.SQL = a }(), MapProperties.prototype.getMapId = function() {
  4458. return this.mapProperties.layergroupid }, MapProperties.prototype.getLayerIndexByType = function(a, b) {
  4459. var c = this.mapProperties.metadata && this.mapProperties.metadata.layers;
  4460. if (!c) return a;
  4461. for (var d = {}, e = 0, f = 0; f < c.length; f++) c[f].type == b && (d[e] = f, e++);
  4462. return void 0 == d[a] ? -1 : d[a] }, MapProperties.prototype.getLayerIndexesByType = function(a) {
  4463. var b = this.mapProperties.metadata && this.mapProperties.metadata.layers;
  4464. if (b) {
  4465. for (var c = [], d = 0; d < b.length; d++) {
  4466. var e = b[d],
  4467. f = "torque" !== e.type;
  4468. a && a.length > 0 && (f = f && -1 != a.indexOf(e.type)), f && c.push(d) }
  4469. return c } }, MapBase.BASE_URL = "/api/v1/map", MapBase.EMPTY_GIF = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7", MapBase.prototype = { _buildMapsApiTemplate: function(a) {
  4470. var b = a.tiler_protocol,
  4471. c = a.tiler_domain,
  4472. d = "" != a.tiler_port ? ":" + a.tiler_port : "",
  4473. e = a.user_name ? "{user}." : "";
  4474. a.maps_api_template = [b, "://", e, c, d].join("") }, createMap: function(a) {
  4475. function b(a, b) {
  4476. for (var d; d = c._createMapCallbacks.pop();) d(a, b) }
  4477. var c = this;
  4478. clearTimeout(this._timeout), this._createMapCallsStack.push(b), this._createMapCallbacks.push(a), this._timeout = setTimeout(function() { c._createMap(b) }, 4) }, _createMap: function(a) {
  4479. if (a = a || function() {}, this._waiting) return this;
  4480. if (this._createMapCallsStack = [], !this.named_map && 0 === this.visibleLayers().length) return void a(null);
  4481. this._waiting = !0;
  4482. var b = null;
  4483. b = this._usePOST() ? this._requestPOST : this._requestGET;
  4484. var c = this._getParamsFromOptions(this.options);
  4485. return b.call(this, c, a), this }, _getParamsFromOptions: function(a) {
  4486. var b = [],
  4487. c = a.extra_params || {},
  4488. d = a.map_key || a.api_key || c.map_key || c.api_key;
  4489. if (d && b.push("map_key=" + d), c.auth_token)
  4490. if (_.isArray(c.auth_token))
  4491. for (var e = 0, f = c.auth_token.length; f > e; e++) b.push("auth_token[]=" + c.auth_token[e]);
  4492. else b.push("auth_token=" + c.auth_token);
  4493. return this.stat_tag && b.push("stat_tag=" + this.stat_tag), b }, _usePOST: function() {
  4494. if (this.options.cors) {
  4495. if (this.options.force_cors) return !0;
  4496. var a = JSON.stringify(this.toJSON());
  4497. if (a.length > this.options.MAX_GET_SIZE) return !0 }
  4498. return !1 }, _requestPOST: function(a, b) {
  4499. var c = this,
  4500. d = this.options.ajax,
  4501. e = cartodb.core.Profiler.metric("cartodb-js.layergroup.post.time").start();
  4502. d({ crossOrigin: !0, type: "POST", method: "POST", dataType: "json", contentType: "application/json", url: this._tilerHost() + this.endPoint + (a.length ? "?" + a.join("&") : ""), data: JSON.stringify(this.toJSON()), success: function(a) { e.end(), 0 === c._createMapCallsStack.length && (a.errors ? (cartodb.core.Profiler.metric("cartodb-js.layergroup.post.error").inc(), b(null, a)) : b(a)), c._requestFinished() }, error: function(a) { e.end(), cartodb.core.Profiler.metric("cartodb-js.layergroup.post.error").inc();
  4503. var d = { errors: ["unknow error"] };
  4504. 0 === a.status && (d = { errors: ["connection error"] });
  4505. try { d = JSON.parse(a.responseText) } catch (f) {}
  4506. 0 === c._createMapCallsStack.length && b(null, d), c._requestFinished() } }) }, _requestGET: function(a, b) {
  4507. var c = this,
  4508. d = this.options.ajax,
  4509. e = JSON.stringify(this.toJSON()),
  4510. f = this._getCompressor(e),
  4511. g = c.JSONPendPoint || c.endPoint;
  4512. f(e, 3, function(e) { a.push(e);
  4513. var f = cartodb.core.Profiler.metric("cartodb-js.layergroup.get.time").start(),
  4514. h = c.options.dynamic_cdn ? c._host() : c._tilerHost();
  4515. d({ dataType: "jsonp", url: h + g + "?" + a.join("&"), jsonpCallback: c.options.instanciateCallback, cache: !!c.options.instanciateCallback, success: function(a) { f.end(), 0 === c._createMapCallsStack.length && (a.errors ? (cartodb.core.Profiler.metric("cartodb-js.layergroup.get.error").inc(), b(null, a)) : b(a)), c._requestFinished() }, error: function(a) { f.end(), cartodb.core.Profiler.metric("cartodb-js.layergroup.get.error").inc();
  4516. var d = { errors: ["unknow error"] };
  4517. try { d = JSON.parse(xhr.responseText) } catch (e) {}
  4518. 0 === c._createMapCallsStack.length && b(null, d), c._requestFinished() } }) }) }, _getCompressor: function(a) {
  4519. return this.options.compressor ? this.options.compressor : (a = a || JSON.stringify(this.toJSON()), !this.options.force_compress && a.length < this.options.MAX_GET_SIZE ? function(a, b, c) { c("config=" + encodeURIComponent(a)) } : function(a, b, c) { a = JSON.stringify({ config: a }), LZMA.compress(a, b, function(a) { c("lzma=" + encodeURIComponent(cdb.core.util.array2hex(a))) }) }) }, _requestFinished: function() {
  4520. var a = this;
  4521. if (this._waiting = !1, this.lastTimeUpdated = (new Date).getTime(), clearTimeout(this._refreshTimer), this._refreshTimer = setTimeout(function() { a.invalidate() }, this.options.refreshTime || 72e5), this._createMapCallsStack.length) {
  4522. var b = this._createMapCallsStack.pop();
  4523. this._createMap(b) } }, fetchAttributes: function(a, b, c, d) { this._attrCallbackName = this._attrCallbackName || this._callbackName();
  4524. var e = this.options.ajax,
  4525. f = cartodb.core.Profiler.metric("cartodb-js.named_map.attributes.time").start();
  4526. e({ dataType: "jsonp", url: this._attributesUrl(a, b), jsonpCallback: "_cdbi_layer_attributes_" + this._attrCallbackName, cache: !0, success: function(a) { f.end(), d(a) }, error: function(a) { f.end(), cartodb.core.Profiler.metric("cartodb-js.named_map.attributes.error").inc(), d(null) } }) }, _callbackName: function() {
  4527. return cdb.core.util.uniqueCallbackName(JSON.stringify(this.toJSON())) }, _attributesUrl: function(a, b) {
  4528. var c = this._host(),
  4529. d = [c, MapBase.BASE_URL.slice(1), this.mapProperties.getMapId(), this.mapProperties.getLayerIndexByType(this.getLayerIndexByNumber(a), "mapnik"), "attributes", b].join("/"),
  4530. e = this.options.extra_params || {},
  4531. f = e.auth_token;
  4532. if (f)
  4533. if (_.isArray(f)) {
  4534. for (var g = [], h = 0, i = f.length; i > h; h++) g.push("auth_token[]=" + f[h]);
  4535. d += "?" + g.join("&") } else d += "?auth_token=" + f;
  4536. return d }, invalidate: function() { this.mapProperties = null, this.urls = null, this.onLayerDefinitionUpdated() }, getTiles: function(a) {
  4537. var b = this;
  4538. return b.mapProperties ? (a && a(b._layerGroupTiles(b.mapProperties, b.options.extra_params)), this) : (this.createMap(function(c, d) {
  4539. if (c) b.mapProperties = new MapProperties(c), c.cdn_url && (b.options.cdn_url = b.options.cdn_url || {}, b.options.cdn_url = { http: c.cdn_url.http || b.options.cdn_url.http, https: c.cdn_url.https || b.options.cdn_url.https }), b.urls = b._layerGroupTiles(b.mapProperties, b.options.extra_params), a && a(b.urls);
  4540. else if (null !== b.named_map && d) a && a(null, d);
  4541. else if (0 === b.visibleLayers().length) return void(a && a({ tiles: [MapBase.EMPTY_GIF], grids: [] })) }), this) }, isHttps: function() {
  4542. return 0 === this.options.maps_api_template.indexOf("https") }, _layerGroupTiles: function(a, b) {
  4543. var c = [],
  4544. d = [],
  4545. e = this._encodeParams(b, this.options.pngParams),
  4546. f = this._encodeParams(b, this.options.gridParams),
  4547. g = this.options.subdomains || ["0", "1", "2", "3"];
  4548. this.isHttps() && (g = [null]);
  4549. var h = a.getLayerIndexesByType(this.options.filter);
  4550. if (h.length)
  4551. for (var i = "/" + h.join(",") + "/{z}/{x}/{y}", j = "/{z}/{x}/{y}", k = 0; k < g.length; ++k) {
  4552. var l = g[k],
  4553. m = this._host(l) + MapBase.BASE_URL + "/" + a.getMapId();
  4554. d.push(m + i + ".png" + (e ? "?" + e : ""));
  4555. for (var n = 0; n < this.layers.length; ++n) {
  4556. var o = a.getLayerIndexByType(n, "mapnik");
  4557. c[n] = c[n] || [], c[n].push(m + "/" + o + j + ".grid.json" + (f ? "?" + f : "")) } } else d = [MapBase.EMPTY_GIF];
  4558. return { tiles: d, grids: c } }, _encodeParams: function(a, b) {
  4559. if (!a) return "";
  4560. var c = [];
  4561. b = b || _.keys(a);
  4562. for (var d in b) {
  4563. var e = b[d],
  4564. f = a[e];
  4565. if (f)
  4566. if (_.isArray(f))
  4567. for (var g = 0, h = f.length; h > g; g++) c.push(e + "[]=" + encodeURIComponent(f[g]));
  4568. else {
  4569. var i = encodeURIComponent(f);
  4570. i = i.replace(/%7Bx%7D/g, "{x}").replace(/%7By%7D/g, "{y}").replace(/%7Bz%7D/g, "{z}"), c.push(e + "=" + i) } }
  4571. return c.join("&") }, onLayerDefinitionUpdated: function() {}, setSilent: function(a) { this.silent = a }, _definitionUpdated: function() { this.silent || this.invalidate() }, getTileJSON: function(a, b) { a = void 0 == a ? 0 : a;
  4572. var c = this;
  4573. this.getTiles(function(d) {
  4574. return d ? void(b && b(c._tileJSONfromTiles(a, d))) : void b(null) }) }, _tileJSONfromTiles: function(a, b, c) {
  4575. function d(a) {
  4576. for (var b = [], c = 0; c < a.length; ++c) b.push(a[c].replace("{s}", e[c % e.length]));
  4577. return b }
  4578. c = c || {};
  4579. var e = c.subdomains || ["0", "1", "2", "3"];
  4580. return { tilejson: "2.0.0", scheme: "xyz", grids: d(b.grids[a]), tiles: d(b.tiles), formatter: function(a, b) {
  4581. return b } } }, _tilerHost: function() {
  4582. var a = this.options;
  4583. return a.maps_api_template.replace("{user}", a.user_name) }, _host: function(a) {
  4584. var b = this.options,
  4585. c = b.cdn_url,
  4586. d = !c || c && !c.http && !c.https;
  4587. if (b.no_cdn || d) return this._tilerHost();
  4588. var e = this.isHttps() ? "https" : "http",
  4589. f = e + "://";
  4590. a && (f += a + ".");
  4591. var g = c[e];
  4592. return this._isUserTemplateUrl(g) || (g += "/{user}"), f += g.replace("{user}", b.user_name) }, _isUserTemplateUrl: function(a) {
  4593. return a && -1 !== a.indexOf("{user}") }, getLayer: function(a) {
  4594. return _.clone(this.layers[a]) }, getLayerCount: function() {
  4595. return this.layers ? this.layers.length : 0 }, getLayerIndexByNumber: function(a) {
  4596. for (var b = {}, c = 0, d = 0; d < this.layers.length; ++d) {
  4597. var e = this.layers[d];
  4598. b[d] = c, e.options && !e.options.hidden && ++c }
  4599. return b[a] }, getLayerNumberByIndex: function(a) {
  4600. for (var b = [], c = 0; c < this.layers.length; ++c) {
  4601. var d = this.layers[c];
  4602. this._isLayerVisible(d) && b.push(c) }
  4603. return a >= b.length ? -1 : +b[a] }, visibleLayers: function() {
  4604. for (var a = [], b = 0; b < this.layers.length; ++b) {
  4605. var c = this.layers[b];
  4606. this._isLayerVisible(c) && a.push(c) }
  4607. return a }, _isLayerVisible: function(a) {
  4608. return a.options && "hidden" in a.options ? !a.options.hidden : a.visible !== !1 }, setLayer: function(a, b) {
  4609. if (a < this.getLayerCount() && a >= 0) {
  4610. if (b.options.hidden) {
  4611. var c = this.interactionEnabled[a];
  4612. c && (b.interaction = !0, this.setInteraction(a, !1)) } else this.layers[a].interaction && (this.setInteraction(a, !0), delete this.layers[a].interaction);
  4613. this.layers[a] = _.clone(b) }
  4614. return this.invalidate(), this }, getTooltipData: function(a) {
  4615. var b = this.layers[a].tooltip;
  4616. return b && b.fields && b.fields.length ? b : null }, getInfowindowData: function(a) {
  4617. var b, c = this.layers[a].infowindow;
  4618. return !c && this.options.layer_definition && (b = this.options.layer_definition.layers[a]) && (c = b.infowindow), c && c.fields && c.fields.length > 0 ? c : null }, containInfowindow: function() {
  4619. for (var a = this.options.layer_definition.layers, b = 0; b < a.length; ++b) {
  4620. var c = a[b].infowindow;
  4621. if (c && c.fields && c.fields.length > 0) return !0 }
  4622. return !1 }, containTooltip: function() {
  4623. for (var a = this.options.layer_definition.layers, b = 0; b < a.length; ++b) {
  4624. var c = a[b].tooltip;
  4625. if (c && c.fields && c.fields.length) return !0 }
  4626. return !1 }, getSubLayer: function(a) {
  4627. var b = this.layers[a];
  4628. return b.sub = b.sub || SubLayerFactory.createSublayer(b.type, this, a), b.sub }, getSubLayerCount: function() {
  4629. return this.getLayerCount() }, getSubLayers: function() {
  4630. for (var a = [], b = 0; b < this.getSubLayerCount(); ++b) a.push(this.getSubLayer(b));
  4631. return a } }, LayerDefinition.layerDefFromSubLayers = function(a) {
  4632. if (!a || void 0 === a.length) throw new Error("sublayers should be an array");
  4633. a = _.map(a, function(a) {
  4634. var b = a.type;
  4635. return delete a.type, { type: b, options: a } });
  4636. var b = { version: "1.3.0", stat_tag: "API", layers: a };
  4637. return new LayerDefinition(b, {}).toJSON() }, LayerDefinition.prototype = _.extend({}, MapBase.prototype, { setLayerDefinition: function(a, b) { b = b || {}, this.version = a.version || "1.0.0", this.stat_tag = a.stat_tag, this.layers = _.clone(a.layers), b.silent || this._definitionUpdated() }, toJSON: function() {
  4638. var a = {};
  4639. a.version = this.version, this.stat_tag && (a.stat_tag = this.stat_tag), a.layers = [];
  4640. for (var b = this.visibleLayers(), c = 0; c < b.length; ++c) {
  4641. var d = this.getSubLayer(this.getLayerNumberByIndex(c));
  4642. a.layers.push(d.toJSON()) }
  4643. return a }, removeLayer: function(a) {
  4644. return a < this.getLayerCount() && a >= 0 && (this.layers.splice(a, 1), this.interactionEnabled.splice(a, 1), this._reorderSubLayers(), this.invalidate()), this }, _reorderSubLayers: function() {
  4645. for (var a = 0; a < this.layers.length; ++a) {
  4646. var b = this.layers[a];
  4647. b.sub && b.sub._setPosition(a) } }, addLayer: function(a, b) {
  4648. if (b = void 0 === b ? this.getLayerCount() : b, b <= this.getLayerCount() && b >= 0) {
  4649. var c = a.type || "cartodb";
  4650. delete a.type, this.layers.splice(b, 0, { type: c, options: a });
  4651. var d = this.getSubLayer(b);
  4652. if (!d.isValid()) throw d.remove(), "Layer definition should contain all the required attributes";
  4653. this._definitionUpdated() }
  4654. return this }, setInteractivity: function(a, b) {
  4655. if (void 0 === b && (b = a, a = 0), a >= this.getLayerCount() && 0 > a) throw new Error("layer does not exist"); "string" == typeof b && (b = b.split(","));
  4656. for (var c = 0; c < b.length; ++c) b[c] = b[c].replace(/ /g, "");
  4657. return this.layers[a].options.interactivity = b, this._definitionUpdated(), this }, setQuery: function(a, b) { void 0 === b && (b = a, a = 0), this.layers[a].options.sql = b, this._definitionUpdated() }, getQuery: function(a) {
  4658. return a = a || 0, this.layers[a].options.sql }, setCartoCSS: function(a, b, c) { void 0 === c && (c = b, b = a, a = 0), c = c || cartodb.CARTOCSS_DEFAULT_VERSION, this.layers[a].options.cartocss = b, this.layers[a].options.cartocss_version = c, this._definitionUpdated() }, createSubLayer: function(a, b) {
  4659. return this.addLayer(a), this.getSubLayer(this.getLayerCount() - 1) } }), NamedMap.prototype = _.extend({}, MapBase.prototype, { getSubLayer: function(a) {
  4660. var b = this.layers[a];
  4661. return b || (b = this.layers[a] = { options: {} }), b.sub = b.sub || SubLayerFactory.createSublayer(b.type, this, a), b.sub }, setLayerDefinition: function(a, b) { b = b || {}, this.endPoint = MapBase.BASE_URL + "/named/" + a.name, this.JSONPendPoint = MapBase.BASE_URL + "/named/" + a.name + "/jsonp", this.layers = _.clone(a.layers) || [];
  4662. for (var c = 0; c < this.layers.length; ++c) {
  4663. var d = this.layers[c];
  4664. d.options = d.options || { hidden: d.visible === !1 }, d.options.layer_name = d.layer_name }
  4665. this.named_map = a;
  4666. var e = a.auth_token || b.auth_token;
  4667. e && this.setAuthToken(e), b.silent || this.invalidate() }, setAuthToken: function(a) {
  4668. if (!this.isHttps()) throw new Error("https must be used when map has token authentication");
  4669. return this.options.extra_params = this.options.extra_params || {}, this.options.extra_params.auth_token = a, this.invalidate(), this }, setParams: function(a, b) {
  4670. var c;
  4671. 2 === arguments.length ? (c = {}, c[a] = b) : c = a, this.named_map.params || (this.named_map.params = {});
  4672. for (var d in c) void 0 === c[d] || null === c[d] ? delete this.named_map.params[d] : this.named_map.params[d] = c[d];
  4673. return this.invalidate(), this }, toJSON: function() {
  4674. for (var a = this.named_map.params || {}, b = 0; b < this.layers.length; ++b) {
  4675. var c = this.layers[b];
  4676. a["layer" + b] = this._isLayerVisible(c) ? 1 : 0 }
  4677. return a }, containInfowindow: function() {
  4678. for (var a = this.layers || [], b = 0; b < a.length; ++b) {
  4679. var c = a[b].infowindow;
  4680. if (c && c.fields && c.fields.length > 0) return !0 }
  4681. return !1 }, containTooltip: function() {
  4682. for (var a = this.layers || [], b = 0; b < a.length; ++b) {
  4683. var c = a[b].tooltip;
  4684. if (c) return !0 }
  4685. return !1 }, setSQL: function(a) {
  4686. throw new Error("SQL is read-only in NamedMaps") }, setCartoCSS: function(a) {
  4687. throw new Error("cartocss is read-only in NamedMaps") }, getCartoCSS: function() {
  4688. throw new Error("cartocss can't be accessed in NamedMaps") }, getSQL: function() {
  4689. throw new Error("SQL can't be accessed in NamedMaps") }, setLayer: function(a, b) {
  4690. var c = { sql: 1, cartocss: 1, interactivity: 1 };
  4691. for (var d in b.options)
  4692. if (d in c) throw delete b.options[d], new Error(d + " is read-only in NamedMaps");
  4693. return MapBase.prototype.setLayer.call(this, a, b) }, removeLayer: function(a) {
  4694. throw new Error("sublayers are read-only in Named Maps") }, createSubLayer: function(a, b) {
  4695. throw new Error("sublayers are read-only in Named Maps") }, addLayer: function(a, b) {
  4696. throw new Error("sublayers are read-only in Named Maps") }, getLayerIndexByNumber: function(a) {
  4697. return +a } }), SubLayerFactory.createSublayer = function(a, b, c) {
  4698. if (a = a && a.toLowerCase(), a && "mapnik" !== a && "cartodb" !== a) {
  4699. if ("http" === a) return new HttpSubLayer(b, c);
  4700. throw "Sublayer type not supported" }
  4701. return new CartoDBSubLayer(b, c) }, SubLayerBase.prototype = { toJSON: function() {
  4702. throw "toJSON must be implemented" }, isValid: function() {
  4703. throw "isValid must be implemented" }, remove: function() { this._check(), this._parent.removeLayer(this._position), this._added = !1, this.trigger("remove", this), this._onRemove() }, _onRemove: function() {}, toggle: function() {
  4704. return this.get("hidden") ? this.show() : this.hide(), !this.get("hidden") }, show: function() { this.get("hidden") && this.set({ hidden: !1 }) }, hide: function() { this.get("hidden") || this.set({ hidden: !0 }) }, set: function(a) { this._check();
  4705. var b = this._parent.getLayer(this._position),
  4706. c = b.options;
  4707. for (var d in a) c[d] = a[d];
  4708. return this._parent.setLayer(this._position, b), void 0 !== a.hidden && this.trigger("change:visibility", this, a.hidden), this }, unset: function(a) {
  4709. var b = this._parent.getLayer(this._position);
  4710. delete b.options[a], this._parent.setLayer(this._position, b) }, get: function(a) { this._check();
  4711. var b = this._parent.getLayer(this._position);
  4712. return b.options[a] }, isVisible: function() {
  4713. return !this.get("hidden") }, _check: function() {
  4714. if (!this._added) throw "sublayer was removed" }, _unbindInteraction: function() { this._parent.off && this._parent.off(null, null, this) }, _bindInteraction: function() {
  4715. if (this._parent.on) {
  4716. var a = this,
  4717. b = function(b, c) { c = c || b, a._parent.on(b, function() {
  4718. var b = Array.prototype.slice.call(arguments);
  4719. parseInt(b[b.length - 1], 10) == a._position && a.trigger.apply(a, [c].concat(b)) }, a) };
  4720. b("featureOver"), b("featureOut"), b("featureClick"), b("layermouseover", "mouseover"), b("layermouseout", "mouseout") } }, _setPosition: function(a) { this._position = a } }, _.extend(SubLayerBase.prototype, Backbone.Events), CartoDBSubLayer.prototype = _.extend({}, SubLayerBase.prototype, {
  4721. toJSON: function() {
  4722. var a = { type: "cartodb", options: { sql: this.getSQL(), cartocss: this.getCartoCSS(), cartocss_version: this.get("cartocss_version") || "2.1.0" } },
  4723. b = this.getInteractivity();
  4724. if (b && b.length > 0) { a.options.interactivity = b;
  4725. var c = this.getAttributes();
  4726. c.length > 0 && (a.options.attributes = { id: "cartodb_id", columns: c }) }
  4727. return this.get("raster") && (a.options.raster = !0, a.options.geom_column = "the_raster_webmercator", a.options.geom_type = "raster", a.options.raster_band = this.get("raster_band") || 0, a.options.cartocss_version = this.get("cartocss_version") || "2.3.0"), a },
  4728. isValid: function() {
  4729. return this.get("sql") && this.get("cartocss") },
  4730. _onRemove: function() { this._unbindInteraction() },
  4731. setSQL: function(a) {
  4732. return this.set({ sql: a }) },
  4733. setCartoCSS: function(a) {
  4734. return this.set({ cartocss: a }) },
  4735. setInteractivity: function(a) {
  4736. return this.set({ interactivity: a }) },
  4737. setInteraction: function(a) { this._parent.setInteraction(this._position, a) },
  4738. getSQL: function() {
  4739. return this.get("sql") },
  4740. getCartoCSS: function() {
  4741. return this.get("cartocss") },
  4742. getInteractivity: function() {
  4743. var a = this.get("interactivity");
  4744. return a ? ("string" == typeof a && (a = a.split(",")), this._trimArrayItems(a)) : void 0
  4745. },
  4746. getAttributes: function() {
  4747. var columns = [];
  4748. if (this.get('attributes')) {
  4749. columns = this.get('attributes');
  4750. } else if(this.infowindow) {
  4751. columns = _.map(this.infowindow.get('fields'), function(field){
  4752. return field.name;
  4753. });
  4754. }
  4755. return this._trimArrayItems(columns);
  4756. // var a = [];
  4757. // return a = this.get("attributes") ? this.get("attributes") : _.map(this.infowindow.get("fields"), function(a) {
  4758. // return a.name }), this._trimArrayItems(a)
  4759. },
  4760. _trimArrayItems: function(a) {
  4761. return _.map(a, function(a) {
  4762. return a.trim() }) }
  4763. }), HttpSubLayer.prototype = _.extend({}, SubLayerBase.prototype, { toJSON: function() {
  4764. var a = { type: "http", options: { urlTemplate: this.getURLTemplate() } },
  4765. b = this.get("subdomains");
  4766. b && (a.options.subdomains = b);
  4767. var c = this.get("tms");
  4768. return void 0 !== c && (a.options.tms = c), a }, isValid: function() {
  4769. return this.get("urlTemplate") }, setURLTemplate: function(a) {
  4770. return this.set({ urlTemplate: a }) }, setSubdomains: function(a) {
  4771. return this.set({ subdomains: a }) }, setTms: function(a) {
  4772. return this.set({ tms: a }) }, getURLTemplate: function(a) {
  4773. return this.get("urlTemplate") }, getSubdomains: function(a) {
  4774. return this.get("subdomains") }, getTms: function(a) {
  4775. return this.get("tms") } });
  4776. var Loader = cdb.vis.Loader = cdb.core.Loader = { queue: [], current: void 0, _script: null, head: null, loadScript: function(a) {
  4777. var b = document.createElement("script");
  4778. return b.type = "text/javascript", b.src = a, b.async = !0, Loader.head || (Loader.head = document.getElementsByTagName("head")[0]), setTimeout(function() { Loader.head.appendChild(b) }, 0), b }, get: function(a, b) { Loader._script ? Loader.queue.push([a, b]) : (Loader.current = b, Loader._script = Loader.loadScript(a + (~a.indexOf("?") ? "&" : "?") + "callback=vizjson")) }, getPath: function(a) {
  4779. var b = document.getElementsByTagName("script"),
  4780. c = /\/?cartodb[\-\._]?([\w\-\._]*)\.js\??/;
  4781. for (i = 0, len = b.length; i < len; i++)
  4782. if (src = b[i].src, matches = src.match(c), matches) {
  4783. var d = src.split("/");
  4784. return delete d[d.length - 1], d.join("/") + a }
  4785. return null }, loadModule: function(a) {
  4786. var b = "cartodb.mod." + a + (cartodb.DEBUG ? ".uncompressed.js" : ".js"),
  4787. c = this.getPath(b);
  4788. c || cartodb.log.error("can't find cartodb.js file"), Loader.loadScript(c) } };
  4789. window.vizjson = function(a) { Loader.current && Loader.current(a), Loader.head.removeChild(Loader._script), Loader._script = null;
  4790. var b = Loader.queue.shift();
  4791. b && Loader.get(b[0], b[1]) },
  4792. function() { Queue = function() { this._methods = [], this._response = null, this._flushed = !1 }, Queue.prototype = { add: function(a) { this._flushed ? a(this._response) : this._methods.push(a) }, flush: function(a) {
  4793. if (!this._flushed)
  4794. for (this._response = a, this._flushed = !0; this._methods[0];) this._methods.shift()(a) } }, StaticImage = function() { MapBase.call(this, this), this.imageOptions = {}, this.error = null, this.supported_formats = ["png", "jpg"], this.defaults = { basemap_url_template: "http://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png", basemap_subdomains: ["a", "b", "c"], format: "png", zoom: 10, center: [0, 0], size: [320, 240], tiler_port: 80, tiler_domain: "carto.com" } }, StaticImage.prototype = _.extend({}, MapBase.prototype, { load: function(a, b) {
  4795. return _.bindAll(this, "_onVisLoaded"), this.queue = new Queue, this.no_cdn = b.no_cdn, this.userOptions = b, b = _.defaults({ vizjson: a, temp_id: "s" + this._getUUID() }, this.defaults), this.imageOptions = b, cdb.core.Loader.get(a, this._onVisLoaded), this }, loadLayerDefinition: function(a, b) {
  4796. return this.queue = new Queue, a.user_name ? (this.userOptions = b, this.options.api_key = a.api_key, this.options.user_name = a.user_name, this.options.tiler_protocol = a.tiler_protocol, this.options.tiler_domain = a.tiler_domain, this.options.tiler_port = a.tiler_port, this.options.maps_api_template = a.maps_api_template, this.endPoint = "/api/v1/map", this.options.maps_api_template || this._buildMapsApiTemplate(this.options), this.options.layers = a, void this._requestLayerGroupID()) : void cartodb.log.error("Please, specify the username") }, _onVisLoaded: function(a) {
  4797. if (a) {
  4798. var b = a.layers[0],
  4799. c = this._getDataLayer(a.layers);
  4800. c.options && (this.options.user_name = c.options.user_name), c.options.maps_api_template ? this.options.maps_api_template = c.options.maps_api_template : this._setupTilerConfiguration(c.options.tiler_protocol, c.options.tiler_domain, c.options.tiler_port), this.auth_tokens = a.auth_tokens, this.endPoint = "/api/v1/map";
  4801. var d = [],
  4802. e = a.bounds;
  4803. e && (d.push([e[0][1], e[0][0]]), d.push([e[1][1], e[1][0]])), this.imageOptions.zoom = a.zoom, this.imageOptions.center = JSON.parse(a.center), this.imageOptions.bbox = d, this.imageOptions.bounds = a.bounds, b && b.options && (this.imageOptions.basemap = b);
  4804. var f = !1,
  4805. g = this._getLayerByType(a.layers, "namedmap");
  4806. if (g) {
  4807. var h = this._getLayerByType(a.layers, "torque");
  4808. h && h.options && h.options.named_map && h.options.named_map.name === g.options.named_map.name && (f = !0) }
  4809. var i = [],
  4810. j = this._getBasemapLayer();
  4811. j && i.push(j);
  4812. for (var k, l = 1; l < a.layers.length; l++) {
  4813. var m = a.layers[l];
  4814. if ("torque" !== m.type || f) {
  4815. if ("namedmap" === m.type) i.push(this._getNamedmapLayerDefinition(m));
  4816. else if ("tiled" === m.type) k = this._getHTTPLayer(m);
  4817. else if ("torque" !== m.type && "namedmap" !== m.type)
  4818. for (var n = this._getLayergroupLayerDefinition(m), o = 0; o < n.length; o++) i.push(n[o]) } else i.push(this._getTorqueLayerDefinition(m)) }
  4819. k && i.push(k), this.options.layers = { layers: i }, this._requestLayerGroupID() } }, _getDataLayer: function(a) {
  4820. return this._getLayerByType(a, "namedmap") || this._getLayerByType(a, "layergroup") || this._getLayerByType(a, "torque") }, visibleLayers: function() {
  4821. return this.options.layers.layers }, _getLayerByType: function(a, b) {
  4822. return _.find(a, function(a) {
  4823. return a.type === b }) }, _setupTilerConfiguration: function(a, b, c) { this.options.tiler_domain = b, this.options.tiler_protocol = a, this.options.tiler_port = c, this._buildMapsApiTemplate(this.options) }, toJSON: function() {
  4824. return this.options.layers }, _requestLayerGroupID: function() {
  4825. var a = this;
  4826. this.createMap(function(b, c) { c && (a.error = c), b && (a.imageOptions.layergroupid = b.layergroupid, a.cdn_url = b.cdn_url), a.queue.flush(this) }) }, _getDefaultBasemapLayer: function() {
  4827. return { type: "http", options: { urlTemplate: this.defaults.basemap_url_template, subdomains: this.defaults.basemap_subdomains } } }, _getHTTPLayer: function(a) {
  4828. var b = a.options.urlTemplate;
  4829. return b ? { type: "http", options: { urlTemplate: b, subdomains: a.options.subdomains || this.defaults.basemap_subdomains } } : null }, _getPlainBasemapLayer: function(a) {
  4830. return { type: "plain", options: { color: a } } }, _getBasemapLayer: function() {
  4831. var a = this.userOptions.basemap || this.imageOptions.basemap;
  4832. if (a) {
  4833. var b = a.type.toLowerCase();
  4834. return a.options && a.options.type && (b = a.options.type.toLowerCase()), "plain" === b ? this._getPlainBasemapLayer(a.options.color) : this._getHTTPLayer(a) }
  4835. return this._getDefaultBasemapLayer() }, _getTorqueLayerDefinition: function(a) {
  4836. if (a.options.named_map) return this._getNamedmapLayerDefinition(a);
  4837. var b = new LayerDefinition(a, a.options),
  4838. c = b.options.query || "SELECT * FROM " + b.options.table_name,
  4839. d = a.options.tile_style;
  4840. return { type: "torque", options: { step: this.userOptions.step || 0, sql: c, cartocss: d } } }, _getLayergroupLayerDefinition: function(a) {
  4841. var b = a.options;
  4842. b.layer_definition.layers = this._getVisibleLayers(b.layer_definition.layers);
  4843. var c = new LayerDefinition(b.layer_definition, b);
  4844. return c.toJSON().layers }, _getNamedmapLayerDefinition: function(a) {
  4845. var b = a.options,
  4846. c = new NamedMap(b.named_map, b),
  4847. b = { name: c.named_map.name };
  4848. return this.auth_tokens && this.auth_tokens.length > 0 && (b.auth_tokens = this.auth_tokens), { type: "named", options: b } }, _getVisibleLayers: function(a) {
  4849. return _.filter(a, function(a) {
  4850. return a.visible }) }, _getUrl: function() {
  4851. var a = (this.options.user_name, this.imageOptions.bbox),
  4852. b = this.imageOptions.layergroupid,
  4853. c = this.imageOptions.zoom || this.defaults.zoom,
  4854. d = this.imageOptions.center || this.defaults.center,
  4855. e = this.imageOptions.size || this.defaults.size,
  4856. f = this.imageOptions.format || this.defaults.format,
  4857. g = d[0],
  4858. h = d[1],
  4859. i = e[0],
  4860. j = e[1],
  4861. k = this.isHttps() ? null : "a",
  4862. l = this._host(k) + this.endPoint;
  4863. return a && a.length && !this.userOptions.override_bbox ? [l, "static/bbox", b, a.join(","), i, j + "." + f].join("/") : [l, "static/center", b, c, g, h, i, j + "." + f].join("/") }, _getUUID: function() {
  4864. var a = function() {
  4865. return (65536 * (1 + Math.random()) | 0).toString(16).substring(1) };
  4866. return a() + a() + "-" + a() + "-" + a() + "-" + a() + "-" + a() + a() + a() }, _set: function(a, b) {
  4867. var c = this;
  4868. return this.queue.add(function() { c.imageOptions[a] = b }), this }, zoom: function(a) {
  4869. return this._set("zoom", a) }, bbox: function(a) {
  4870. return this._set("bbox", a) }, center: function(a) {
  4871. return this._set("bbox", null), this._set("center", a) }, format: function(a) {
  4872. return this._set("format", _.include(this.supported_formats, a) ? a : this.defaults.format) }, size: function(a, b) {
  4873. return this._set("size", [a, void 0 === b ? a : b]) }, into: function(a) {
  4874. var b = this;
  4875. return a instanceof HTMLImageElement ? (this.imageOptions.size = [a.width, a.height], void this.queue.add(function(c) { a.src = b._getUrl() })) : void cartodb.log.error("img should be an image") }, getUrl: function(a) {
  4876. var b = this;
  4877. this.queue.add(function() { a && a(b.error, b._getUrl()) }) }, write: function(a) {
  4878. var b = this;
  4879. return this.imageOptions.attributes = a, a && a.src ? document.write('<img id="' + this.imageOptions.temp_id + '" src="' + a.src + '" />') : document.write('<img id="' + this.imageOptions.temp_id + '" />'), this.queue.add(function() {
  4880. var a = document.getElementById(b.imageOptions.temp_id);
  4881. a.src = b._getUrl(), a.removeAttribute("temp_id");
  4882. var c = b.imageOptions.attributes;
  4883. c && c["class"] && a.setAttribute("class", c["class"]), c && c.id && a.setAttribute("id", c.id) }), this } }), cdb.Image = function(a, b) { b || (b = {});
  4884. var c = new StaticImage;
  4885. return "string" == typeof a ? c.load(a, b) : c.loadLayerDefinition(a, b), c } }(),
  4886. function() {
  4887. var a = this;
  4888. a.cartodb = a.cartodb || {};
  4889. var b = { tiler_domain: "carto.com", tiler_port: "80", tiler_protocol: "http", subdomains: ["{s}"], extra_params: { cache_policy: "persist" } },
  4890. c = function(a) {
  4891. if (_.defaults(a, b), !a.sublayers) throw new Error("sublayers should be passed");
  4892. if (!a.user_name) throw new Error("username should be passed");
  4893. a.layer_definition = LayerDefinition.layerDefFromSubLayers(a.sublayers), a.ajax = reqwest.compat, LayerDefinition.call(this, a.layer_definition, a) };
  4894. _.extend(c.prototype, LayerDefinition.prototype), a.cartodb.Tiles = c, c.getTiles = function(a, b) {
  4895. var d = new c(a);
  4896. return d.getTiles(b), d } }()
  4897. }();