 
 : run-spider ( spider -- spider )
     "spider" [
-        dup queue-initial-links [ run-spider-loop ] keep
+        queue-initial-links
+        [ run-spider-loop ] keep
     ] with-logging ;


: spider-sleep ( spider -- ) sleep>> [ sleep ] when* ;

: queue-initial-links ( spider -- )
    [
        [ currently-spidering>> ] [ initial-links>> ] bi normalize-hrefs 0
    ] keep add-todo ;

: spider-page? ( spider -- ? )
    {

: <spider-result> ( url depth -- spider-result )
    spider-result new
        swap >>depth
        swap >>url ; inline

<PRIVATE

: apply-filters ( links spider -- links' )
    filters>> [
        '[ [ _ 1&& ] filter ] call( seq -- seq' )
    ] when* ;

: push-links ( links level unique-deque -- )
    '[ _ _ push-url ] each ;
