import { $APP, shadow$provide } from "./shared.js";
const shadow_esm_import = function(x) { return import(x) };
var $app$rasterizer$create_image$$=function($uri$jscomp$104$$){return $APP.$beicon$v2$core$create$$(function($subs$jscomp$18$$){var $image$jscomp$34$$=new Image;$APP.$app$util$object$set_BANG_$$($image$jscomp$34$$,"onload",function(){$subs$jscomp$18$$.next($image$jscomp$34$$);return $subs$jscomp$18$$.complete()});$APP.$app$util$object$set_BANG_$$($image$jscomp$34$$,"crossOrigin","anonymous");$APP.$app$util$object$set_BANG_$$($image$jscomp$34$$,"onerror",function($p1__73571_SHARP_$$){return $subs$jscomp$18$$.error($p1__73571_SHARP_$$)});
$APP.$app$util$object$set_BANG_$$($image$jscomp$34$$,"onabort",function(){return $subs$jscomp$18$$.error($APP.$cljs$core$ex_info$cljs$0core$0IFn$0_invoke$0arity$03$$("operation aborted",$APP.$cljs$core$merge$$.$cljs$core$IFn$_invoke$arity$variadic$($APP.$cljs$core$prim_seq$cljs$0core$0IFn$0_invoke$0arity$02$$([new $APP.$cljs$core$PersistentArrayMap$$(null,3,[$APP.$cljs$cst$139$type$$,$APP.$cljs$cst$1528$abort$$,$APP.$cljs$cst$271$code$$,$APP.$cljs$cst$1529$operation_aborted$$,$APP.$cljs$cst$273$hint$$,
"operation aborted"],null),null])),null))});$APP.$app$util$object$set_BANG_$$($image$jscomp$34$$,"src",$uri$jscomp$104$$);return function(){$APP.$app$util$object$set_BANG_$$($image$jscomp$34$$,"src","");$APP.$app$util$object$set_BANG_$$($image$jscomp$34$$,"onload",null);$APP.$app$util$object$set_BANG_$$($image$jscomp$34$$,"onerror",null);return $APP.$app$util$object$set_BANG_$$($image$jscomp$34$$,"onabort",null)}})},$app$rasterizer$svg_get_adjusted_size$$=function($width$jscomp$178$$,$height$jscomp$155$$,
$max$jscomp$78$$){var $ratio$jscomp$3$$=$width$jscomp$178$$/$height$jscomp$155$$;return $width$jscomp$178$$<$height$jscomp$155$$?new $APP.$cljs$core$PersistentVector$$(null,2,5,$APP.$cljs$core$PersistentVector$EMPTY_NODE$$,[$max$jscomp$78$$,1/$ratio$jscomp$3$$*$max$jscomp$78$$],null):new $APP.$cljs$core$PersistentVector$$(null,2,5,$APP.$cljs$core$PersistentVector$EMPTY_NODE$$,[$max$jscomp$78$$*$ratio$jscomp$3$$,$max$jscomp$78$$],null)},$app$rasterizer$fetch_as_data_uri$$=function($uri$jscomp$105$$){if($APP.$cljs$core$truth_$$($app$rasterizer$data_uri_cache$$.has($uri$jscomp$105$$))){var $blob$jscomp$28$$=
$app$rasterizer$data_uri_cache$$.get($uri$jscomp$105$$);return $APP.$beicon$v2$core$from$$($blob$jscomp$28$$.text())}return $APP.$beicon$v2$core$mapcat$$(function($response$jscomp$15$$){return $response$jscomp$15$$==null?(0,$APP.$beicon$v2$core$of$$)($uri$jscomp$105$$):$APP.$beicon$v2$core$tap$cljs$0core$0IFn$0_invoke$0arity$02$$(function($data_uri$jscomp$3$$){return $app$rasterizer$data_uri_cache$$.set($uri$jscomp$105$$,$APP.$app$util$webapi$create_blob$cljs$0core$0IFn$0_invoke$0arity$02$$($data_uri$jscomp$3$$,
"text/plain"))},$APP.$beicon$v2$core$mapcat$$($APP.$app$util$webapi$read_file_as_data_url$$,(0,$APP.$beicon$v2$core$of$$)($APP.$cljs$cst$1565$body$$.$cljs$core$IFn$_invoke$arity$1$($response$jscomp$15$$))))},$APP.$beicon$v2$core$catch$0$cljs$0core$0IFn$0_invoke$0arity$02$$(function($cause$jscomp$92$$){$APP.$app$common$logging$enabled_QMARK_$$("app.rasterizer",$APP.$cljs$cst$847$error$$)&&$APP.$app$common$logging$emit_log$$(new $APP.$cljs$core$Delay$$(function(){return new $APP.$cljs$core$PersistentVector$$(null,
1,5,$APP.$cljs$core$PersistentVector$EMPTY_NODE$$,[new $APP.$cljs$core$PersistentVector$$(null,2,5,$APP.$cljs$core$PersistentVector$EMPTY_NODE$$,[$APP.$cljs$cst$273$hint$$,"fetching data uri"],null)],null)}),$cause$jscomp$92$$,"app.rasterizer",$APP.$cljs$cst$847$error$$,!1);return(0,$APP.$beicon$v2$core$of$$)(null)},$APP.$app$util$http$send_BANG_$$(new $APP.$cljs$core$PersistentArrayMap$$(null,5,[$APP.$cljs$cst$1563$uri$$,$uri$jscomp$105$$,$APP.$cljs$cst$1571$response_type$$,$APP.$cljs$cst$1575$blob$$,
$APP.$cljs$cst$1562$method$$,$APP.$cljs$cst$1283$get$$,$APP.$cljs$cst$318$mode$$,$APP.$cljs$cst$1188$cors$$,$APP.$cljs$cst$1566$omit_default_headers$$,!0],null))))},$app$rasterizer$svg_update_image_BANG_$$=function($image$jscomp$35$$){var $temp__5823__auto__$jscomp$204$$=$APP.$app$util$dom$get_attribute$$($image$jscomp$35$$,"href");return $APP.$cljs$core$truth_$$($temp__5823__auto__$jscomp$204$$)?$APP.$cuerdas$core$starts_with_QMARK_$$($temp__5823__auto__$jscomp$204$$,"data:")?(0,$APP.$beicon$v2$core$of$$)($image$jscomp$35$$):
$APP.$beicon$v2$core$map$$(function($url$jscomp$94$$){$APP.$app$util$dom$set_attribute_BANG_$$($image$jscomp$35$$,"href",$url$jscomp$94$$);return $image$jscomp$35$$},$app$rasterizer$fetch_as_data_uri$$($temp__5823__auto__$jscomp$204$$)):$APP.$beicon$v2$core$empty$$()},$app$rasterizer$svg_add_style_BANG_$$=function($svg$jscomp$7$$,$styles$jscomp$19$$){var $doc$jscomp$41$$=$svg$jscomp$7$$.documentElement;var $style$jscomp$69$$=$svg$jscomp$7$$.createElementNS("http://www.w3.org/2000/svg","style");$APP.$app$util$dom$append_child_BANG_$$($style$jscomp$69$$,
$svg$jscomp$7$$.createTextNode($styles$jscomp$19$$));return $APP.$app$util$dom$append_child_BANG_$$($doc$jscomp$41$$,$style$jscomp$69$$)},$app$rasterizer$svg_resolve_external_resources$$=function($styles$jscomp$20$$){return $APP.$beicon$v2$core$reduce$cljs$0core$0IFn$0_invoke$0arity$03$$(function($styles__$1$jscomp$2$$,$p__73625_uri$jscomp$106$$){var $url$jscomp$95$$=$APP.$cljs$core$nth$cljs$0core$0IFn$0_invoke$0arity$03$$($p__73625_uri$jscomp$106$$,0,null);$p__73625_uri$jscomp$106$$=$APP.$cljs$core$nth$cljs$0core$0IFn$0_invoke$0arity$03$$($p__73625_uri$jscomp$106$$,
1,null);return $APP.$cuerdas$core$replace$$($styles__$1$jscomp$2$$,$url$jscomp$95$$,$p__73625_uri$jscomp$106$$)},$styles$jscomp$20$$,$APP.$beicon$v2$core$mapcat$$(function($url$jscomp$96$$){return $APP.$beicon$v2$core$map$$(function($uri$jscomp$107$$){return new $APP.$cljs$core$PersistentVector$$(null,2,5,$APP.$cljs$core$PersistentVector$EMPTY_NODE$$,[$url$jscomp$96$$,$uri$jscomp$107$$],null)},$app$rasterizer$fetch_as_data_uri$$($url$jscomp$96$$))},$APP.$beicon$v2$core$map$$($APP.$cljs$core$second$$,
$APP.$beicon$v2$core$from$$($APP.$cljs$core$re_seq$$(/url\((https?:\/\/[^)]+)\)/,$styles$jscomp$20$$)))))},$app$rasterizer$svg_resolve_inline_styles_BANG_$$=function($svg$jscomp$9$$){return $APP.$beicon$v2$core$ignore$$($APP.$beicon$v2$core$mapcat$$(function($node$jscomp$377$$){var $styles$jscomp$22$$=$APP.$app$util$dom$get_attribute$$($node$jscomp$377$$,"style");return $APP.$beicon$v2$core$tap$cljs$0core$0IFn$0_invoke$0arity$02$$(function($styles__$1$jscomp$3$$){return $APP.$app$util$dom$set_attribute_BANG_$$($node$jscomp$377$$,
"style",$styles__$1$jscomp$3$$)},$app$rasterizer$svg_resolve_external_resources$$($styles$jscomp$22$$))},$APP.$beicon$v2$core$from$$($APP.$app$util$dom$query_all$cljs$0core$0IFn$0_invoke$0arity$02$$($svg$jscomp$9$$,"[style]"))))},$app$rasterizer$svg_resolve_style_elements_BANG_$$=function($svg$jscomp$10$$){return $APP.$beicon$v2$core$ignore$$($APP.$beicon$v2$core$mapcat$$(function($node$jscomp$378$$){return $APP.$beicon$v2$core$tap$cljs$0core$0IFn$0_invoke$0arity$02$$(function($styles__$1$jscomp$4$$){return $APP.$app$util$dom$set_text_BANG_$$($node$jscomp$378$$,
$styles__$1$jscomp$4$$)},$app$rasterizer$svg_resolve_external_resources$$($APP.$app$util$dom$get_text$$($node$jscomp$378$$)))},$APP.$beicon$v2$core$from$$($APP.$app$util$dom$query_all$cljs$0core$0IFn$0_invoke$0arity$02$$($svg$jscomp$10$$,"style"))))},$app$rasterizer$svg_resolve_all_BANG_$$=function($svg$jscomp$11$$,$styles$jscomp$24$$){return $APP.$beicon$v2$core$concat$$($APP.$beicon$v2$core$ignore$$($APP.$beicon$v2$core$mapcat$$($app$rasterizer$svg_update_image_BANG_$$,$APP.$beicon$v2$core$from$$($APP.$app$util$dom$query_all$cljs$0core$0IFn$0_invoke$0arity$02$$($svg$jscomp$11$$,
"image")))),$APP.$beicon$v2$core$ignore$$($APP.$beicon$v2$core$tap$cljs$0core$0IFn$0_invoke$0arity$02$$($APP.$cljs$core$partial$cljs$0core$0IFn$0_invoke$0arity$02$$($app$rasterizer$svg_add_style_BANG_$$,$svg$jscomp$11$$),$app$rasterizer$svg_resolve_external_resources$$($styles$jscomp$24$$))),$app$rasterizer$svg_resolve_inline_styles_BANG_$$($svg$jscomp$11$$),$app$rasterizer$svg_resolve_style_elements_BANG_$$($svg$jscomp$11$$),(0,$APP.$beicon$v2$core$of$$)($svg$jscomp$11$$))},$app$rasterizer$svg_parse$$=
function($data$jscomp$452$$){return(new DOMParser).parseFromString($data$jscomp$452$$,"image/svg+xml")},$app$rasterizer$svg_stringify$$=function($doc$jscomp$42_svg$jscomp$12$$){$doc$jscomp$42_svg$jscomp$12$$=$doc$jscomp$42_svg$jscomp$12$$.documentElement;return(new XMLSerializer).serializeToString($doc$jscomp$42_svg$jscomp$12$$)},$app$rasterizer$svg_prepare$$=function($data$jscomp$453_svg$jscomp$13$$,$styles$jscomp$25$$,$width$jscomp$182$$){$data$jscomp$453_svg$jscomp$13$$=$app$rasterizer$svg_parse$$($data$jscomp$453_svg$jscomp$13$$);
return $APP.$beicon$v2$core$map$$($app$rasterizer$svg_stringify$$,$APP.$beicon$v2$core$map$$(function($p1__73632_SHARP_$$){var $doc_73646$jscomp$inline_7779$$=$p1__73632_SHARP_$$.documentElement;var $doc$jscomp$inline_13810_doc$jscomp$inline_13816_h_73649$jscomp$inline_7782_height$jscomp$inline_13812_height$jscomp$inline_13818_height$jscomp$inline_13825_vec__73612$jscomp$inline_13823_vec__73617_73647$jscomp$inline_7780$$=$p1__73632_SHARP_$$.documentElement;var $JSCompiler_temp$jscomp$13399_vbox$jscomp$inline_13822_w_73648$jscomp$inline_7781_width$jscomp$inline_13811_width$jscomp$inline_13817_width$jscomp$inline_13824$$=
$APP.$app$util$dom$get_attribute$$($doc$jscomp$inline_13810_doc$jscomp$inline_13816_h_73649$jscomp$inline_7782_height$jscomp$inline_13812_height$jscomp$inline_13818_height$jscomp$inline_13825_vec__73612$jscomp$inline_13823_vec__73617_73647$jscomp$inline_7780$$,"width");$doc$jscomp$inline_13810_doc$jscomp$inline_13816_h_73649$jscomp$inline_7782_height$jscomp$inline_13812_height$jscomp$inline_13818_height$jscomp$inline_13825_vec__73612$jscomp$inline_13823_vec__73617_73647$jscomp$inline_7780$$=$APP.$app$util$dom$get_attribute$$($doc$jscomp$inline_13810_doc$jscomp$inline_13816_h_73649$jscomp$inline_7782_height$jscomp$inline_13812_height$jscomp$inline_13818_height$jscomp$inline_13825_vec__73612$jscomp$inline_13823_vec__73617_73647$jscomp$inline_7780$$,
"height");$APP.$app$common$data$num_QMARK_$cljs$0core$0IFn$0_invoke$0arity$02$$($JSCompiler_temp$jscomp$13399_vbox$jscomp$inline_13822_w_73648$jscomp$inline_7781_width$jscomp$inline_13811_width$jscomp$inline_13817_width$jscomp$inline_13824$$,$doc$jscomp$inline_13810_doc$jscomp$inline_13816_h_73649$jscomp$inline_7782_height$jscomp$inline_13812_height$jscomp$inline_13818_height$jscomp$inline_13825_vec__73612$jscomp$inline_13823_vec__73617_73647$jscomp$inline_7780$$)?($doc$jscomp$inline_13810_doc$jscomp$inline_13816_h_73649$jscomp$inline_7782_height$jscomp$inline_13812_height$jscomp$inline_13818_height$jscomp$inline_13825_vec__73612$jscomp$inline_13823_vec__73617_73647$jscomp$inline_7780$$=
$p1__73632_SHARP_$$.documentElement,$JSCompiler_temp$jscomp$13399_vbox$jscomp$inline_13822_w_73648$jscomp$inline_7781_width$jscomp$inline_13811_width$jscomp$inline_13817_width$jscomp$inline_13824$$=$APP.$app$util$dom$get_attribute$$($doc$jscomp$inline_13810_doc$jscomp$inline_13816_h_73649$jscomp$inline_7782_height$jscomp$inline_13812_height$jscomp$inline_13818_height$jscomp$inline_13825_vec__73612$jscomp$inline_13823_vec__73617_73647$jscomp$inline_7780$$,"width"),$doc$jscomp$inline_13810_doc$jscomp$inline_13816_h_73649$jscomp$inline_7782_height$jscomp$inline_13812_height$jscomp$inline_13818_height$jscomp$inline_13825_vec__73612$jscomp$inline_13823_vec__73617_73647$jscomp$inline_7780$$=
$APP.$app$util$dom$get_attribute$$($doc$jscomp$inline_13810_doc$jscomp$inline_13816_h_73649$jscomp$inline_7782_height$jscomp$inline_13812_height$jscomp$inline_13818_height$jscomp$inline_13825_vec__73612$jscomp$inline_13823_vec__73617_73647$jscomp$inline_7780$$,"height"),$JSCompiler_temp$jscomp$13399_vbox$jscomp$inline_13822_w_73648$jscomp$inline_7781_width$jscomp$inline_13811_width$jscomp$inline_13817_width$jscomp$inline_13824$$=$app$rasterizer$svg_get_adjusted_size$$($APP.$app$common$data$parse_integer$cljs$0core$0IFn$0_invoke$0arity$02$$($JSCompiler_temp$jscomp$13399_vbox$jscomp$inline_13822_w_73648$jscomp$inline_7781_width$jscomp$inline_13811_width$jscomp$inline_13817_width$jscomp$inline_13824$$,
0),$APP.$app$common$data$parse_integer$cljs$0core$0IFn$0_invoke$0arity$02$$($doc$jscomp$inline_13810_doc$jscomp$inline_13816_h_73649$jscomp$inline_7782_height$jscomp$inline_13812_height$jscomp$inline_13818_height$jscomp$inline_13825_vec__73612$jscomp$inline_13823_vec__73617_73647$jscomp$inline_7780$$,0),$width$jscomp$182$$)):($JSCompiler_temp$jscomp$13399_vbox$jscomp$inline_13822_w_73648$jscomp$inline_7781_width$jscomp$inline_13811_width$jscomp$inline_13817_width$jscomp$inline_13824$$=$APP.$app$util$dom$get_attribute$$($p1__73632_SHARP_$$.documentElement,
"viewBox"),typeof $JSCompiler_temp$jscomp$13399_vbox$jscomp$inline_13822_w_73648$jscomp$inline_7781_width$jscomp$inline_13811_width$jscomp$inline_13817_width$jscomp$inline_13824$$==="string"?($doc$jscomp$inline_13810_doc$jscomp$inline_13816_h_73649$jscomp$inline_7782_height$jscomp$inline_13812_height$jscomp$inline_13818_height$jscomp$inline_13825_vec__73612$jscomp$inline_13823_vec__73617_73647$jscomp$inline_7780$$=$APP.$cuerdas$core$split$cljs$0core$0IFn$0_invoke$0arity$02$$($JSCompiler_temp$jscomp$13399_vbox$jscomp$inline_13822_w_73648$jscomp$inline_7781_width$jscomp$inline_13811_width$jscomp$inline_13817_width$jscomp$inline_13824$$,
/\s+/),$APP.$cljs$core$nth$cljs$0core$0IFn$0_invoke$0arity$03$$($doc$jscomp$inline_13810_doc$jscomp$inline_13816_h_73649$jscomp$inline_7782_height$jscomp$inline_13812_height$jscomp$inline_13818_height$jscomp$inline_13825_vec__73612$jscomp$inline_13823_vec__73617_73647$jscomp$inline_7780$$,0,null),$APP.$cljs$core$nth$cljs$0core$0IFn$0_invoke$0arity$03$$($doc$jscomp$inline_13810_doc$jscomp$inline_13816_h_73649$jscomp$inline_7782_height$jscomp$inline_13812_height$jscomp$inline_13818_height$jscomp$inline_13825_vec__73612$jscomp$inline_13823_vec__73617_73647$jscomp$inline_7780$$,
1,null),$JSCompiler_temp$jscomp$13399_vbox$jscomp$inline_13822_w_73648$jscomp$inline_7781_width$jscomp$inline_13811_width$jscomp$inline_13817_width$jscomp$inline_13824$$=$APP.$cljs$core$nth$cljs$0core$0IFn$0_invoke$0arity$03$$($doc$jscomp$inline_13810_doc$jscomp$inline_13816_h_73649$jscomp$inline_7782_height$jscomp$inline_13812_height$jscomp$inline_13818_height$jscomp$inline_13825_vec__73612$jscomp$inline_13823_vec__73617_73647$jscomp$inline_7780$$,2,null),$doc$jscomp$inline_13810_doc$jscomp$inline_13816_h_73649$jscomp$inline_7782_height$jscomp$inline_13812_height$jscomp$inline_13818_height$jscomp$inline_13825_vec__73612$jscomp$inline_13823_vec__73617_73647$jscomp$inline_7780$$=
$APP.$cljs$core$nth$cljs$0core$0IFn$0_invoke$0arity$03$$($doc$jscomp$inline_13810_doc$jscomp$inline_13816_h_73649$jscomp$inline_7782_height$jscomp$inline_13812_height$jscomp$inline_13818_height$jscomp$inline_13825_vec__73612$jscomp$inline_13823_vec__73617_73647$jscomp$inline_7780$$,3,null),$JSCompiler_temp$jscomp$13399_vbox$jscomp$inline_13822_w_73648$jscomp$inline_7781_width$jscomp$inline_13811_width$jscomp$inline_13817_width$jscomp$inline_13824$$=$app$rasterizer$svg_get_adjusted_size$$($APP.$app$common$data$parse_integer$cljs$0core$0IFn$0_invoke$0arity$02$$($JSCompiler_temp$jscomp$13399_vbox$jscomp$inline_13822_w_73648$jscomp$inline_7781_width$jscomp$inline_13811_width$jscomp$inline_13817_width$jscomp$inline_13824$$,
0),$APP.$app$common$data$parse_integer$cljs$0core$0IFn$0_invoke$0arity$02$$($doc$jscomp$inline_13810_doc$jscomp$inline_13816_h_73649$jscomp$inline_7782_height$jscomp$inline_13812_height$jscomp$inline_13818_height$jscomp$inline_13825_vec__73612$jscomp$inline_13823_vec__73617_73647$jscomp$inline_7780$$,0),$width$jscomp$182$$)):$JSCompiler_temp$jscomp$13399_vbox$jscomp$inline_13822_w_73648$jscomp$inline_7781_width$jscomp$inline_13811_width$jscomp$inline_13817_width$jscomp$inline_13824$$=null);$doc$jscomp$inline_13810_doc$jscomp$inline_13816_h_73649$jscomp$inline_7782_height$jscomp$inline_13812_height$jscomp$inline_13818_height$jscomp$inline_13825_vec__73612$jscomp$inline_13823_vec__73617_73647$jscomp$inline_7780$$=
$JSCompiler_temp$jscomp$13399_vbox$jscomp$inline_13822_w_73648$jscomp$inline_7781_width$jscomp$inline_13811_width$jscomp$inline_13817_width$jscomp$inline_13824$$;$JSCompiler_temp$jscomp$13399_vbox$jscomp$inline_13822_w_73648$jscomp$inline_7781_width$jscomp$inline_13811_width$jscomp$inline_13817_width$jscomp$inline_13824$$=$APP.$cljs$core$nth$cljs$0core$0IFn$0_invoke$0arity$03$$($doc$jscomp$inline_13810_doc$jscomp$inline_13816_h_73649$jscomp$inline_7782_height$jscomp$inline_13812_height$jscomp$inline_13818_height$jscomp$inline_13825_vec__73612$jscomp$inline_13823_vec__73617_73647$jscomp$inline_7780$$,
0,null);$doc$jscomp$inline_13810_doc$jscomp$inline_13816_h_73649$jscomp$inline_7782_height$jscomp$inline_13812_height$jscomp$inline_13818_height$jscomp$inline_13825_vec__73612$jscomp$inline_13823_vec__73617_73647$jscomp$inline_7780$$=$APP.$cljs$core$nth$cljs$0core$0IFn$0_invoke$0arity$03$$($doc$jscomp$inline_13810_doc$jscomp$inline_13816_h_73649$jscomp$inline_7782_height$jscomp$inline_13812_height$jscomp$inline_13818_height$jscomp$inline_13825_vec__73612$jscomp$inline_13823_vec__73617_73647$jscomp$inline_7780$$,
1,null);$APP.$app$util$dom$set_attribute_BANG_$$($doc_73646$jscomp$inline_7779$$,"width",""+($JSCompiler_temp$jscomp$13399_vbox$jscomp$inline_13822_w_73648$jscomp$inline_7781_width$jscomp$inline_13811_width$jscomp$inline_13817_width$jscomp$inline_13824$$??""));$APP.$app$util$dom$set_attribute_BANG_$$($doc_73646$jscomp$inline_7779$$,"height",""+($doc$jscomp$inline_13810_doc$jscomp$inline_13816_h_73649$jscomp$inline_7782_height$jscomp$inline_13812_height$jscomp$inline_13818_height$jscomp$inline_13825_vec__73612$jscomp$inline_13823_vec__73617_73647$jscomp$inline_7780$$??
""));return $p1__73632_SHARP_$$},$app$rasterizer$svg_resolve_all_BANG_$$($data$jscomp$453_svg$jscomp$13$$,$styles$jscomp$25$$)))},$app$rasterizer$bitmap__GT_blob$$=function($bitmap$jscomp$5$$){return $APP.$beicon$v2$core$create$$(function($subs$jscomp$19$$){var $canvas$jscomp$8$$=$APP.$app$util$dom$create_element$cljs$0core$0IFn$0_invoke$0arity$01$$("canvas");$canvas$jscomp$8$$.width=$bitmap$jscomp$5$$.width;$canvas$jscomp$8$$.height=$bitmap$jscomp$5$$.height;$canvas$jscomp$8$$.getContext("bitmaprenderer").transferFromImageBitmap($bitmap$jscomp$5$$);
$canvas$jscomp$8$$.toBlob(function($p1__73633_SHARP_$$){$subs$jscomp$19$$.next($p1__73633_SHARP_$$);return $subs$jscomp$19$$.complete()});return $APP.$cljs$core$constantly$$(null)})},$app$rasterizer$render_image_bitmap$$=function($payload$jscomp$9$$){var $data$jscomp$454$$=$payload$jscomp$9$$.data,$styles$jscomp$26$$=$payload$jscomp$9$$.styles,$width$jscomp$183$$=$APP.$app$common$data$nilv$$.$cljs$core$IFn$_invoke$arity$2$($payload$jscomp$9$$.width,300),$quality$$=$APP.$app$common$data$nilv$$.$cljs$core$IFn$_invoke$arity$2$($payload$jscomp$9$$.quality,
"medium");return $APP.$beicon$v2$core$mapcat$$(function($uri$jscomp$108$$){return $APP.$beicon$v2$core$tap$cljs$0core$0IFn$0_invoke$0arity$02$$(function(){return $APP.$app$util$webapi$revoke_uri$$($uri$jscomp$108$$)},$APP.$beicon$v2$core$mapcat$$(function($p1__73635_SHARP_$$){var $options$jscomp$inline_7785$$={resizeWidth:$width$jscomp$183$$,resizeQuality:$quality$$};var $JSCompiler_temp$jscomp$13398_offscreen_canvas$jscomp$inline_7786_width$jscomp$inline_12533$$=$p1__73635_SHARP_$$.width;var $height$jscomp$inline_12534$$=
$p1__73635_SHARP_$$.height;if("OffscreenCanvas"in window)$JSCompiler_temp$jscomp$13398_offscreen_canvas$jscomp$inline_7786_width$jscomp$inline_12533$$=new OffscreenCanvas($JSCompiler_temp$jscomp$13398_offscreen_canvas$jscomp$inline_7786_width$jscomp$inline_12533$$,$height$jscomp$inline_12534$$);else{var $canvas$jscomp$inline_13829$$=document.createElement("canvas");$APP.$app$util$object$set_BANG_$$($canvas$jscomp$inline_13829$$,"width",$JSCompiler_temp$jscomp$13398_offscreen_canvas$jscomp$inline_7786_width$jscomp$inline_12533$$);
$APP.$app$util$object$set_BANG_$$($canvas$jscomp$inline_13829$$,"height",$height$jscomp$inline_12534$$);$JSCompiler_temp$jscomp$13398_offscreen_canvas$jscomp$inline_7786_width$jscomp$inline_12533$$=$canvas$jscomp$inline_13829$$}$JSCompiler_temp$jscomp$13398_offscreen_canvas$jscomp$inline_7786_width$jscomp$inline_12533$$.getContext("2d").drawImage($p1__73635_SHARP_$$,0,0);return createImageBitmap($JSCompiler_temp$jscomp$13398_offscreen_canvas$jscomp$inline_7786_width$jscomp$inline_12533$$,$options$jscomp$inline_7785$$)},
$app$rasterizer$create_image$$($uri$jscomp$108$$)))},$APP.$beicon$v2$core$map$$($APP.$app$util$webapi$create_uri$$,$APP.$beicon$v2$core$map$$(function($p1__73634_SHARP_$$){return $APP.$app$util$webapi$create_blob$cljs$0core$0IFn$0_invoke$0arity$02$$($p1__73634_SHARP_$$,"image/svg+xml")},$app$rasterizer$svg_prepare$$($data$jscomp$454$$,$styles$jscomp$26$$,$width$jscomp$183$$))))},$app$rasterizer$on_message$$=function($JSCompiler_inline_result$jscomp$1444_JSCompiler_temp$jscomp$1441_event$jscomp$262_payload$jscomp$12$$){var $JSCompiler_temp_const$jscomp$1443_evdata$jscomp$1_scope$jscomp$8$$=
$JSCompiler_inline_result$jscomp$1444_JSCompiler_temp$jscomp$1441_event$jscomp$262_payload$jscomp$12$$.data;if($APP.$cuerdas$core$starts_with_QMARK_$$($app$rasterizer$parent_origin$$,$JSCompiler_inline_result$jscomp$1444_JSCompiler_temp$jscomp$1441_event$jscomp$262_payload$jscomp$12$$.origin)){var $JSCompiler_temp_const$jscomp$1442_id$jscomp$872$$=$JSCompiler_temp_const$jscomp$1443_evdata$jscomp$1_scope$jscomp$8$$.id;$JSCompiler_inline_result$jscomp$1444_JSCompiler_temp$jscomp$1441_event$jscomp$262_payload$jscomp$12$$=
$JSCompiler_temp_const$jscomp$1443_evdata$jscomp$1_scope$jscomp$8$$.payload;$JSCompiler_temp_const$jscomp$1443_evdata$jscomp$1_scope$jscomp$8$$=$JSCompiler_temp_const$jscomp$1443_evdata$jscomp$1_scope$jscomp$8$$.scope;if($JSCompiler_inline_result$jscomp$1444_JSCompiler_temp$jscomp$1441_event$jscomp$262_payload$jscomp$12$$!=null&&$APP.$cljs$core$_EQ_$$.$cljs$core$IFn$_invoke$arity$2$($JSCompiler_temp_const$jscomp$1443_evdata$jscomp$1_scope$jscomp$8$$,"penpot/rasterizer")){$JSCompiler_temp_const$jscomp$1443_evdata$jscomp$1_scope$jscomp$8$$=
$APP.$cljs$core$partial$cljs$0core$0IFn$0_invoke$0arity$02$$($app$rasterizer$send_success_BANG_$$,$JSCompiler_temp_const$jscomp$1442_id$jscomp$872$$);$JSCompiler_temp_const$jscomp$1442_id$jscomp$872$$=$APP.$cljs$core$partial$cljs$0core$0IFn$0_invoke$0arity$02$$($app$rasterizer$send_failure_BANG_$$,$JSCompiler_temp_const$jscomp$1442_id$jscomp$872$$);a:switch($APP.$app$common$data$nilv$$.$cljs$core$IFn$_invoke$arity$2$($JSCompiler_inline_result$jscomp$1444_JSCompiler_temp$jscomp$1441_event$jscomp$262_payload$jscomp$12$$.result,
"blob")){case "image-bitmap":$JSCompiler_inline_result$jscomp$1444_JSCompiler_temp$jscomp$1441_event$jscomp$262_payload$jscomp$12$$=$app$rasterizer$render_image_bitmap$$($JSCompiler_inline_result$jscomp$1444_JSCompiler_temp$jscomp$1441_event$jscomp$262_payload$jscomp$12$$);break a;default:$JSCompiler_inline_result$jscomp$1444_JSCompiler_temp$jscomp$1441_event$jscomp$262_payload$jscomp$12$$=$APP.$beicon$v2$core$mapcat$$($app$rasterizer$bitmap__GT_blob$$,$app$rasterizer$render_image_bitmap$$($JSCompiler_inline_result$jscomp$1444_JSCompiler_temp$jscomp$1441_event$jscomp$262_payload$jscomp$12$$))}$JSCompiler_inline_result$jscomp$1444_JSCompiler_temp$jscomp$1441_event$jscomp$262_payload$jscomp$12$$=
$APP.$beicon$v2$core$subscribe$cljs$0core$0IFn$0_invoke$0arity$03$$($JSCompiler_inline_result$jscomp$1444_JSCompiler_temp$jscomp$1441_event$jscomp$262_payload$jscomp$12$$,$JSCompiler_temp_const$jscomp$1443_evdata$jscomp$1_scope$jscomp$8$$,$JSCompiler_temp_const$jscomp$1442_id$jscomp$872$$)}else $JSCompiler_inline_result$jscomp$1444_JSCompiler_temp$jscomp$1441_event$jscomp$262_payload$jscomp$12$$=null;return $JSCompiler_inline_result$jscomp$1444_JSCompiler_temp$jscomp$1441_event$jscomp$262_payload$jscomp$12$$}return null},
$app$rasterizer$send_answer_BANG_$$=function($id$jscomp$873_message$jscomp$110$$,$type$jscomp$578$$,$payload$jscomp$13$$){$id$jscomp$873_message$jscomp$110$$={id:$id$jscomp$873_message$jscomp$110$$,type:$type$jscomp$578$$,scope:"penpot/rasterizer",payload:$payload$jscomp$13$$};return window===parent?null:$payload$jscomp$13$$ instanceof ImageBitmap?parent.postMessage($id$jscomp$873_message$jscomp$110$$,$app$rasterizer$parent_origin$$,[$payload$jscomp$13$$]):parent.postMessage($id$jscomp$873_message$jscomp$110$$,
$app$rasterizer$parent_origin$$)},$app$rasterizer$send_success_BANG_$$=function($id$jscomp$874$$,$payload$jscomp$14$$){return $app$rasterizer$send_answer_BANG_$$($id$jscomp$874$$,"success",$payload$jscomp$14$$)},$app$rasterizer$send_failure_BANG_$$=function($id$jscomp$875$$,$cause$jscomp$93$$){return $app$rasterizer$send_answer_BANG_$$($id$jscomp$875$$,"failure",$APP.$cljs$core$ex_message$$($cause$jscomp$93$$))},$app$rasterizer$init$$=function(){window.addEventListener("message",$app$rasterizer$on_message$$);
$app$rasterizer$send_answer_BANG_$$(null,"ready",null);$APP.$app$common$logging$enabled_QMARK_$$("app.rasterizer",$APP.$cljs$cst$1159$info$$)&&$APP.$app$common$logging$emit_log$$(new $APP.$cljs$core$Delay$$(function(){return new $APP.$cljs$core$PersistentVector$$(null,3,5,$APP.$cljs$core$PersistentVector$EMPTY_NODE$$,[new $APP.$cljs$core$PersistentVector$$(null,2,5,$APP.$cljs$core$PersistentVector$EMPTY_NODE$$,[$APP.$cljs$cst$273$hint$$,"initialized"],null),new $APP.$cljs$core$PersistentVector$$(null,
2,5,$APP.$cljs$core$PersistentVector$EMPTY_NODE$$,[$APP.$cljs$cst$2985$public_uri$$,""+($APP.$app$config$public_uri$$??"")],null),new $APP.$cljs$core$PersistentVector$$(null,2,5,$APP.$cljs$core$PersistentVector$EMPTY_NODE$$,[$cljs$cst$5164$parent_uri$$,""+($app$rasterizer$parent_origin$$??"")],null)],null)}),null,"app.rasterizer",$APP.$cljs$cst$1159$info$$,!1);return null},$cljs$cst$5164$parent_uri$$=new $APP.$cljs$core$Keyword$$(null,"parent-uri","parent-uri",-371819908);$APP.$app$common$logging$loggers$$.set("app.rasterizer",$APP.$app$common$logging$level__GT_int$$($APP.$cljs$cst$1159$info$$));var $app$rasterizer$data_uri_cache$$=new Map,$app$rasterizer$parent_origin$$=""+($APP.$app$config$public_uri$$??"");$APP.$goog$exportSymbol$$("app.rasterizer.init",$app$rasterizer$init$$);export const init=$app$rasterizer$init$$;
//# sourceMappingURL=rasterizer.js.map
